/// <summary>Gets a skeleton version of this geo.</summary> /// <returns>A skeleton version of this geo.</returns> public GeoSkel getSkeleton() { GeoSkel skel = new GeoSkel(); skel.ID = this.ID; skel.Vertices = (VectorF[])this.Vertices.Clone(); skel.UpperLeft = this.UpperLeft; skel.LowerRight = this.LowerRight; skel.LineTopLeft = (VectorF[])this.LineTopLeft.Clone(); skel.LineLowerRight = (VectorF[])this.LineLowerRight.Clone(); skel.CloseLoop = this.CloseLoop; skel.LineVisible = (skel.LineVisible == null) ? null : (bool[])this.LineVisible.Clone(); return skel; }
/// <summary>Searches for a collision between the provided line and any node or segment. Also finds the exact intersection point if segment collision.</summary> /// <param name="point1">The first point in the line.</param> /// <param name="point2">The second point in the line.</param> /// <param name="ignoreSeg">The segments to ignore.</param> /// <param name="ignoreNode">The nodes to ignore.</param> /// <param name="nodeColl">The node that collided with the provided line.</param> /// <param name="segColl">The segment that collided with the provided line.</param> /// <param name="geoColl">The geometric object that collided with the provided line.</param> /// <param name="intersection">The intersection point if intersecting a segment.</param> /// <returns>Whether or not there was a collision between the line and any node or segment.</returns> public bool segCollisionIntPoint(VectorF point1, VectorF point2, List<SegmentSkel> ignoreSeg, List<NodeSkel> ignoreNode, out SegmentSkel segColl, out NodeSkel nodeColl, out GeoSkel geoColl, out VectorF? intersection) { intersection = null; segColl = null; nodeColl = null; geoColl = null; object[] array = new object[8]; array[0] = point1; array[1] = point2; array[5] = false; array[6] = null; // look for collisions with segments List<SegmentSkel> segColls = new List<SegmentSkel>(1); array[2] = ignoreSeg; array[3] = segColls; array[4] = CollSrchType.GetIntersection; Grid.Line(point1, point2, array, gridSegCollSeg); if (segColls.Count > 0) { segColl = segColls[0]; intersection = (VectorF)array[7]; #if DEBUG if (array[7] == null) throw new Exception(segColls.Count.ToString() + " segment(s) was returned, but no intersections."); #endif } else // look for collisions with nodes and geos { // look for nodes List<NodeSkel> nodeColls = new List<NodeSkel>(1); array[2] = ignoreNode; array[3] = nodeColls; array[4] = CollSrchType.DoesItCollide; Grid.LineExpand(point1, point2, array, gridSegCollNode); if (nodeColls.Count > 0) { nodeColl = nodeColls[0]; } else // look for geos { List<GeoSkel> geoColls = new List<GeoSkel>(1); array[2] = null; array[3] = geoColls; array[4] = CollSrchType.DoesItCollide; Grid.LineExpand(point1, point2, array, gridSegCollGeo); if (geoColls.Count > 0) geoColl = geoColls[0]; } } return nodeColl != null || segColl != null || geoColl != null; }