private static unsafe extern bool SVONFindPath(IntPtr volume, FloatVector startPos, FloatVector targetPos, float agentSize, out PathSafeHandle pathHandle, out SVONPathPoint *pathPoints, out int count);
private unsafe void DoFindPath(Vector3 start, Vector3 end, float agentSize, ref List <PathPoint> oPath) { SVONPathPoint *pathPoints = null; int pointsCount = 0; FloatVector startPos = new FloatVector(start); FloatVector targetPos = new FloatVector(end); using (GenerateFindPathWrapper(volumeHandle, startPos, targetPos, agentSize, out pathPoints, out pointsCount)) { SVONPathPoint *pPoint = pathPoints; for (int i = 0; i < pointsCount; ++i) { PathPoint ppt = new PathPoint { layer = pPoint->layer, mortonCode = pPoint->mortonCode, position = pPoint->position.ToVector3() }; oPath.Add(ppt); ++pPoint; } } }
private static unsafe PathSafeHandle GenerateFindPathWrapper(IntPtr volume, FloatVector startPos, FloatVector targetPos, float agentSize, out SVONPathPoint *pathPoints, out int count) { PathSafeHandle itemsHandle; if (!SVONFindPath(volume, startPos, targetPos, agentSize, out itemsHandle, out pathPoints, out count)) { Debug.Log($"Path was not found!"); } return(itemsHandle); }