5 protected bool m_bIsSpline;
6 protected bool m_bIsClosed;
8 protected ref array<ref SCR_Ray> m_aAnchorRays;
9 protected ref array<ref SCR_Ray> m_aMidPointRays;
10 protected ref array<ref SCR_Ray> m_aTesselatedPointRays;
13 protected float m_fLength2D;
14 protected float m_fLength3D;
15 protected float m_fSurface;
16 protected float m_fMinAltitude, m_fMaxAltitude;
17 protected float m_fMinSlope, m_fMaxSlope;
32 array<ref SCR_Ray> GetPoints()
34 array<ref SCR_Ray> result = {};
35 foreach (
SCR_Ray point : m_aAnchorRays)
43 array<ref SCR_Ray> GetMiddlePoints()
45 array<ref SCR_Ray> result = {};
46 foreach (
SCR_Ray point : m_aMidPointRays)
54 array<ref SCR_Ray> GetTesselatedPoints()
56 array<ref SCR_Ray> result = {};
57 foreach (
SCR_Ray point : m_aTesselatedPointRays)
67 array<float> GetStats()
69 return { m_fLength2D, m_fLength3D, m_fSurface, m_fMinAltitude, m_fMaxAltitude, m_fMinSlope, m_fMaxSlope };
77 m_bIsSpline = SplineShapeEntity.Cast(shapeEntity) !=
null;
79 vector origin = shapeEntity.GetOrigin();
81 array<vector> points = {};
82 shapeEntity.GetPointsPositions(points);
84 int pointsCount = points.Count();
88 array<vector> tesselatedPoints = {};
89 shapeEntity.GenerateTesselatedShape(tesselatedPoints);
92 m_aTesselatedPointRays = {};
94 vector prevPoint, diff;
95 vector prevTessPoint, currTessPoint;
96 vector currPoint = points[0];
99 array<int> pointTesselatedIndices = {};
102 array<float> polygon2D = {};
103 m_fMinAltitude = currPoint[1];
104 m_fMaxAltitude = currPoint[1];
105 m_fMinSlope =
float.INFINITY;
106 m_fMaxSlope = -
float.INFINITY;
108 for (
int i, count = tesselatedPoints.Count(); i < count; i++)
110 currTessPoint = tesselatedPoints[i];
113 diff = tesselatedPoints[1] - currTessPoint;
115 diff = currTessPoint - prevTessPoint;
118 point.m_vPosition = origin + currTessPoint;
120 float slopeRad = Math.Atan2(diff[1], vector.DistanceXZ(diff, vector.Zero));
123 point.m_vDirection = (tesselatedPoints[i + 1] - currTessPoint).Normalized();
124 else if (i < count - 1)
125 point.m_vDirection = (0.5 * ((currTessPoint - prevTessPoint) + (tesselatedPoints[i + 1] - currTessPoint))).Normalized();
129 point.m_vDirection = (currTessPoint - prevTessPoint).Normalized();
131 m_aTesselatedPointRays.Insert(point);
133 if (currTessPoint == currPoint)
135 pointTesselatedIndices.Insert(i);
136 m_aAnchorRays.Insert(point);
139 if (pointIndex >= pointsCount)
142 prevPoint = currPoint;
143 currPoint = points[pointIndex];
149 m_fLength2D += vector.DistanceXZ(prevTessPoint, currTessPoint);
150 m_fLength3D += vector.Distance(prevTessPoint, currTessPoint);
153 if (point.m_vPosition[1] < m_fMinAltitude)
154 m_fMinAltitude = point.m_vPosition[1];
156 if (point.m_vPosition[1] > m_fMaxAltitude)
157 m_fMaxAltitude = point.m_vPosition[1];
159 if (slopeRad < m_fMinSlope)
160 m_fMinSlope = slopeRad;
162 if (slopeRad > m_fMaxSlope)
163 m_fMaxSlope = slopeRad;
165 polygon2D.Insert(point.m_vPosition[0]);
166 polygon2D.Insert(point.m_vPosition[2]);
169 prevTessPoint = currTessPoint;
172 m_aMidPointRays = {};
175 int prevIndex = pointTesselatedIndices[0];
177 for (
int i = 1, count = pointTesselatedIndices.Count(); i < count; i++)
179 nextIndex = pointTesselatedIndices[i];
180 m_aMidPointRays.Insert(m_aTesselatedPointRays[prevIndex + 0.5 * (nextIndex - prevIndex)]);
181 prevIndex = nextIndex;
186 SCR_Ray currRay = m_aAnchorRays[0];
188 for (
int i = 1, count = m_aAnchorRays.Count(); i < count; i++)
190 nextRay = m_aAnchorRays[i];
191 m_aMidPointRays.Insert(
SCR_Ray.Lerp(currRay, nextRay, 0.5));
196 m_aMidPointRays.Insert(
SCR_Ray.Lerp(currRay, m_aAnchorRays[0], 0.5));
199 m_fSurface = SCR_Math2D.GetPolygonArea(polygon2D);