Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use moved RcRecast helpers
  • Loading branch information
Doprez committed Dec 30, 2025
commit 37e084ee0e2c87e56f6451ef596ff5c7fb346c7d
36 changes: 1 addition & 35 deletions sources/engine/Stride.Navigation/NavigationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public GeneratedData BuildNavmesh(ref Vector3[] vertices, ref int[] indices)
}

// Find walkable triangles and rasterize into heightfield
triAreas = MarkWalkableTriangles(context, buildSettings.AgentMaxSlope, verts, indices, numTriangles, new RcAreaModification(RcAreaModification.RC_AREA_FLAGS_MASK));
triAreas = RcRecast.MarkWalkableTriangles(context, buildSettings.AgentMaxSlope, verts, indices, numTriangles, new RcAreaModification(RcAreaModification.RC_AREA_FLAGS_MASK));
RcRasterizations.RasterizeTriangles(context, verts, indices, triAreas, numTriangles, solid, walkableClimb);

// Filter walkable surfaces.
Expand Down Expand Up @@ -189,38 +189,4 @@ private bool CreateDetourMesh()

return navmeshData != null;
}

private static int[] MarkWalkableTriangles(RcContext ctx, float walkableSlopeAngle, float[] verts, int[] tris, int nt, RcAreaModification areaMod)
{
int[] array = new int[nt];
float num = MathF.Cos(walkableSlopeAngle / 180f * (float)Math.PI);
Vector3 norm = default(Vector3);
for (int i = 0; i < nt; i++)
{
int num2 = i * 3;
Vector3 v = ToVec3(verts, tris[num2] * 3);
Vector3 v2 = ToVec3(verts, tris[num2 + 1] * 3);
Vector3 v3 = ToVec3(verts, tris[num2 + 2] * 3);
CalcTriNormal(v, v2, v3, ref norm);
if (norm.Y > num)
{
array[i] = areaMod.Apply(array[i]);
}
}

return array;
}

private static void CalcTriNormal(Vector3 v0, Vector3 v1, Vector3 v2, ref Vector3 norm)
{
Vector3 v3 = v1 - v0;
Vector3 v4 = v2 - v0;
norm = Vector3.Cross(v3, v4);
norm = Vector3.Normalize(norm);
}

private static Vector3 ToVec3(float[] values, int n)
{
return new Vector3(values[n], values[n + 1], values[n + 2]);
}
}