refactor: DynamicupdateSampleTool

This commit is contained in:
ikpil 2023-09-10 16:12:43 +09:00
parent ab50f0fd53
commit f7ca2efc3f
14 changed files with 125 additions and 123 deletions

View File

@ -29,7 +29,7 @@ using DotRecast.Detour.Dynamic.Io;
using DotRecast.Recast.Toolset.Builder; using DotRecast.Recast.Toolset.Builder;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Toolset.Geom; using DotRecast.Recast.Toolset.Geom;
using DotRecast.Recast.Toolset.Tools.Gizmos; using DotRecast.Recast.Toolset.Gizmos;
using DotRecast.Recast.Demo.UI; using DotRecast.Recast.Demo.UI;
using DotRecast.Recast.Toolset; using DotRecast.Recast.Toolset;
using DotRecast.Recast.Toolset.Tools; using DotRecast.Recast.Toolset.Tools;
@ -75,7 +75,7 @@ public class DynamicUpdateSampleTool : ISampleTool
private DynamicNavMesh dynaMesh; private DynamicNavMesh dynaMesh;
private readonly TaskFactory executor; private readonly TaskFactory executor;
private readonly Dictionary<long, ColliderWithGizmo> colliderGizmos = new(); private readonly Dictionary<long, RcGizmo> colliderGizmos = new();
private readonly Random random = Random.Shared; private readonly Random random = Random.Shared;
private readonly DemoInputGeomProvider bridgeGeom; private readonly DemoInputGeomProvider bridgeGeom;
private readonly DemoInputGeomProvider houseGeom; private readonly DemoInputGeomProvider houseGeom;
@ -281,7 +281,7 @@ public class DynamicUpdateSampleTool : ISampleTool
{ {
colliderGizmos.Values.ForEach(g => colliderGizmos.Values.ForEach(g =>
{ {
g.Render(renderer.GetDebugDraw()); GizmoRenderer.Render(renderer.GetDebugDraw(), g.Gizmo);
}); });
} }
} }
@ -359,7 +359,7 @@ public class DynamicUpdateSampleTool : ISampleTool
{ {
if (!shift) if (!shift)
{ {
ColliderWithGizmo colliderWithGizmo = null; RcGizmo colliderWithGizmo = null;
if (dynaMesh != null) if (dynaMesh != null)
{ {
if (colliderShape == DynamicColliderShape.SPHERE) if (colliderShape == DynamicColliderShape.SPHERE)
@ -433,16 +433,16 @@ public class DynamicUpdateSampleTool : ISampleTool
} }
} }
private ColliderWithGizmo SphereCollider(RcVec3f p) private RcGizmo SphereCollider(RcVec3f p)
{ {
float radius = 1 + (float)random.NextDouble() * 10; float radius = 1 + (float)random.NextDouble() * 10;
var collider = new SphereCollider(p, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb); var collider = new SphereCollider(p, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb);
var gizmo = GizmoFactory.Sphere(p, radius); var gizmo = GizmoFactory.Sphere(p, radius);
return new ColliderWithGizmo(collider, gizmo); return new RcGizmo(collider, gizmo);
} }
private ColliderWithGizmo CapsuleCollider(RcVec3f p) private RcGizmo CapsuleCollider(RcVec3f p)
{ {
float radius = 0.4f + (float)random.NextDouble() * 4f; float radius = 0.4f + (float)random.NextDouble() * 4f;
RcVec3f a = RcVec3f.Of( RcVec3f a = RcVec3f.Of(
@ -459,10 +459,10 @@ public class DynamicUpdateSampleTool : ISampleTool
RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z);
var collider = new CapsuleCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb); var collider = new CapsuleCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb);
var gizmo = GizmoFactory.Capsule(start, end, radius); var gizmo = GizmoFactory.Capsule(start, end, radius);
return new ColliderWithGizmo(collider, gizmo); return new RcGizmo(collider, gizmo);
} }
private ColliderWithGizmo BoxCollider(RcVec3f p) private RcGizmo BoxCollider(RcVec3f p)
{ {
RcVec3f extent = RcVec3f.Of( RcVec3f extent = RcVec3f.Of(
0.5f + (float)random.NextDouble() * 6f, 0.5f + (float)random.NextDouble() * 6f,
@ -474,10 +474,10 @@ public class DynamicUpdateSampleTool : ISampleTool
RcVec3f[] halfEdges = Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(up, forward, extent); RcVec3f[] halfEdges = Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(up, forward, extent);
var collider = new BoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb); var collider = new BoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb);
var gizmo = GizmoFactory.Box(p, halfEdges); var gizmo = GizmoFactory.Box(p, halfEdges);
return new ColliderWithGizmo(collider, gizmo); return new RcGizmo(collider, gizmo);
} }
private ColliderWithGizmo CylinderCollider(RcVec3f p) private RcGizmo CylinderCollider(RcVec3f p)
{ {
float radius = 0.7f + (float)random.NextDouble() * 4f; float radius = 0.7f + (float)random.NextDouble() * 4f;
RcVec3f a = RcVec3f.Of(1f - 2 * (float)random.NextDouble(), 0.01f + (float)random.NextDouble(), 1f - 2 * (float)random.NextDouble()); RcVec3f a = RcVec3f.Of(1f - 2 * (float)random.NextDouble(), 0.01f + (float)random.NextDouble(), 1f - 2 * (float)random.NextDouble());
@ -491,10 +491,10 @@ public class DynamicUpdateSampleTool : ISampleTool
var collider = new CylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb); var collider = new CylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb);
var gizmo = GizmoFactory.Cylinder(start, end, radius); var gizmo = GizmoFactory.Cylinder(start, end, radius);
return new ColliderWithGizmo(collider, gizmo); return new RcGizmo(collider, gizmo);
} }
private ColliderWithGizmo CompositeCollider(RcVec3f p) private RcGizmo CompositeCollider(RcVec3f p)
{ {
RcVec3f baseExtent = RcVec3f.Of(5, 3, 8); RcVec3f baseExtent = RcVec3f.Of(5, 3, 8);
RcVec3f baseCenter = RcVec3f.Of(p.x, p.y + 3, p.z); RcVec3f baseCenter = RcVec3f.Of(p.x, p.y + 3, p.z);
@ -531,36 +531,36 @@ public class DynamicUpdateSampleTool : ISampleTool
IRcGizmoMeshFilter trunkGizmo = GizmoFactory.Capsule(trunkStart, trunkEnd, 0.5f); IRcGizmoMeshFilter trunkGizmo = GizmoFactory.Capsule(trunkStart, trunkEnd, 0.5f);
IRcGizmoMeshFilter crownGizmo = GizmoFactory.Sphere(crownCenter, 4f); IRcGizmoMeshFilter crownGizmo = GizmoFactory.Sphere(crownCenter, 4f);
IRcGizmoMeshFilter gizmo = GizmoFactory.Composite(baseGizmo, roofGizmo, trunkGizmo, crownGizmo); IRcGizmoMeshFilter gizmo = GizmoFactory.Composite(baseGizmo, roofGizmo, trunkGizmo, crownGizmo);
return new ColliderWithGizmo(collider, gizmo); return new RcGizmo(collider, gizmo);
} }
private ColliderWithGizmo TrimeshBridge(RcVec3f p) private RcGizmo TrimeshBridge(RcVec3f p)
{ {
return TrimeshCollider(p, bridgeGeom); return TrimeshCollider(p, bridgeGeom);
} }
private ColliderWithGizmo TrimeshHouse(RcVec3f p) private RcGizmo TrimeshHouse(RcVec3f p)
{ {
return TrimeshCollider(p, houseGeom); return TrimeshCollider(p, houseGeom);
} }
private ColliderWithGizmo ConvexTrimesh(RcVec3f p) private RcGizmo ConvexTrimesh(RcVec3f p)
{ {
float[] verts = TransformVertices(p, convexGeom, 360); float[] verts = TransformVertices(p, convexGeom, 360);
var collider = new ConvexTrimeshCollider(verts, convexGeom.faces, var collider = new ConvexTrimeshCollider(verts, convexGeom.faces,
SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb * 10); SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb * 10);
var gizmo = GizmoFactory.Trimesh(verts, convexGeom.faces); var gizmo = GizmoFactory.Trimesh(verts, convexGeom.faces);
return new ColliderWithGizmo(collider, gizmo); return new RcGizmo(collider, gizmo);
} }
private ColliderWithGizmo TrimeshCollider(RcVec3f p, DemoInputGeomProvider geom) private RcGizmo TrimeshCollider(RcVec3f p, DemoInputGeomProvider geom)
{ {
float[] verts = TransformVertices(p, geom, 0); float[] verts = TransformVertices(p, geom, 0);
var collider = new TrimeshCollider(verts, geom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, var collider = new TrimeshCollider(verts, geom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD,
dynaMesh.config.walkableClimb * 10); dynaMesh.config.walkableClimb * 10);
var gizmo = GizmoFactory.Trimesh(verts, geom.faces); var gizmo = GizmoFactory.Trimesh(verts, geom.faces);
return new ColliderWithGizmo(collider, gizmo); return new RcGizmo(collider, gizmo);
} }
private float[] TransformVertices(RcVec3f p, DemoInputGeomProvider geom, float ax) private float[] TransformVertices(RcVec3f p, DemoInputGeomProvider geom, float ax)

View File

@ -1,50 +1,35 @@
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Dynamic.Colliders;
using DotRecast.Recast.Toolset.Tools.Gizmos;
using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.Demo.Draw;
using DotRecast.Recast.Toolset.Gizmos;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
namespace DotRecast.Recast.Demo.Tools; namespace DotRecast.Recast.Demo.Tools;
public class ColliderWithGizmo public static class GizmoRenderer
{ {
public readonly IRcGizmoMeshFilter Gizmo;
public readonly ICollider Collider;
public ColliderWithGizmo(ICollider collider, IRcGizmoMeshFilter gizmo)
{
Collider = collider;
Gizmo = gizmo;
}
public void Render(RecastDebugDraw dd)
{
Render(dd, Gizmo);
}
public static void Render(RecastDebugDraw dd, IRcGizmoMeshFilter gizmo) public static void Render(RecastDebugDraw dd, IRcGizmoMeshFilter gizmo)
{ {
if (gizmo is BoxGizmo box) if (gizmo is RcBoxGizmo box)
{ {
RenderBox(dd, box); RenderBox(dd, box);
} }
else if (gizmo is CapsuleGizmo capsule) else if (gizmo is RcCapsuleGizmo capsule)
{ {
RenderCapsule(dd, capsule); RenderCapsule(dd, capsule);
} }
else if (gizmo is TrimeshGizmo trimesh) else if (gizmo is RcTrimeshGizmo trimesh)
{ {
RenderTrimesh(dd, trimesh); RenderTrimesh(dd, trimesh);
} }
else if (gizmo is CylinderGizmo cylinder) else if (gizmo is RcCylinderGizmo cylinder)
{ {
RenderCylinder(dd, cylinder); RenderCylinder(dd, cylinder);
} }
else if (gizmo is SphereGizmo sphere) else if (gizmo is RcSphereGizmo sphere)
{ {
RenderSphere(dd, sphere); RenderSphere(dd, sphere);
} }
else if (gizmo is CompositeGizmo composite) else if (gizmo is RcCompositeGizmo composite)
{ {
RenderComposite(dd, composite); RenderComposite(dd, composite);
} }
@ -74,7 +59,7 @@ public class ColliderWithGizmo
return col; return col;
} }
public static void RenderBox(RecastDebugDraw debugDraw, BoxGizmo box) public static void RenderBox(RecastDebugDraw debugDraw, RcBoxGizmo box)
{ {
var trX = RcVec3f.Of(box.halfEdges[0].x, box.halfEdges[1].x, box.halfEdges[2].x); var trX = RcVec3f.Of(box.halfEdges[0].x, box.halfEdges[1].x, box.halfEdges[2].x);
var trY = RcVec3f.Of(box.halfEdges[0].y, box.halfEdges[1].y, box.halfEdges[2].y); var trY = RcVec3f.Of(box.halfEdges[0].y, box.halfEdges[1].y, box.halfEdges[2].y);
@ -82,9 +67,9 @@ public class ColliderWithGizmo
float[] vertices = new float[8 * 3]; float[] vertices = new float[8 * 3];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
vertices[i * 3 + 0] = RcVec3f.Dot(BoxGizmo.VERTS[i], trX) + box.center.x; vertices[i * 3 + 0] = RcVec3f.Dot(RcBoxGizmo.VERTS[i], trX) + box.center.x;
vertices[i * 3 + 1] = RcVec3f.Dot(BoxGizmo.VERTS[i], trY) + box.center.y; vertices[i * 3 + 1] = RcVec3f.Dot(RcBoxGizmo.VERTS[i], trY) + box.center.y;
vertices[i * 3 + 2] = RcVec3f.Dot(BoxGizmo.VERTS[i], trZ) + box.center.z; vertices[i * 3 + 2] = RcVec3f.Dot(RcBoxGizmo.VERTS[i], trZ) + box.center.z;
} }
debugDraw.Begin(DebugDrawPrimitives.TRIS); debugDraw.Begin(DebugDrawPrimitives.TRIS);
@ -102,7 +87,7 @@ public class ColliderWithGizmo
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
int v = BoxGizmo.TRIANLGES[i * 3 + j] * 3; int v = RcBoxGizmo.TRIANLGES[i * 3 + j] * 3;
debugDraw.Vertex(vertices[v], vertices[v + 1], vertices[v + 2], col); debugDraw.Vertex(vertices[v], vertices[v + 1], vertices[v + 2], col);
} }
} }
@ -110,7 +95,7 @@ public class ColliderWithGizmo
debugDraw.End(); debugDraw.End();
} }
public static void RenderCapsule(RecastDebugDraw debugDraw, CapsuleGizmo capsule) public static void RenderCapsule(RecastDebugDraw debugDraw, RcCapsuleGizmo capsule)
{ {
debugDraw.Begin(DebugDrawPrimitives.TRIS); debugDraw.Begin(DebugDrawPrimitives.TRIS);
for (int i = 0; i < capsule.triangles.Length; i += 3) for (int i = 0; i < capsule.triangles.Length; i += 3)
@ -128,7 +113,7 @@ public class ColliderWithGizmo
debugDraw.End(); debugDraw.End();
} }
public static void RenderCylinder(RecastDebugDraw debugDraw, CylinderGizmo cylinder) public static void RenderCylinder(RecastDebugDraw debugDraw, RcCylinderGizmo cylinder)
{ {
debugDraw.Begin(DebugDrawPrimitives.TRIS); debugDraw.Begin(DebugDrawPrimitives.TRIS);
for (int i = 0; i < cylinder.triangles.Length; i += 3) for (int i = 0; i < cylinder.triangles.Length; i += 3)
@ -146,7 +131,7 @@ public class ColliderWithGizmo
debugDraw.End(); debugDraw.End();
} }
public static void RenderSphere(RecastDebugDraw debugDraw, SphereGizmo sphere) public static void RenderSphere(RecastDebugDraw debugDraw, RcSphereGizmo sphere)
{ {
debugDraw.Begin(DebugDrawPrimitives.TRIS); debugDraw.Begin(DebugDrawPrimitives.TRIS);
for (int i = 0; i < sphere.triangles.Length; i += 3) for (int i = 0; i < sphere.triangles.Length; i += 3)
@ -169,7 +154,7 @@ public class ColliderWithGizmo
debugDraw.End(); debugDraw.End();
} }
public static void RenderTrimesh(RecastDebugDraw debugDraw, TrimeshGizmo trimesh) public static void RenderTrimesh(RecastDebugDraw debugDraw, RcTrimeshGizmo trimesh)
{ {
debugDraw.Begin(DebugDrawPrimitives.TRIS); debugDraw.Begin(DebugDrawPrimitives.TRIS);
for (int i = 0; i < trimesh.triangles.Length; i += 3) for (int i = 0; i < trimesh.triangles.Length; i += 3)
@ -186,7 +171,7 @@ public class ColliderWithGizmo
debugDraw.End(); debugDraw.End();
} }
public static void RenderComposite(RecastDebugDraw debugDraw, CompositeGizmo composite) public static void RenderComposite(RecastDebugDraw debugDraw, RcCompositeGizmo composite)
{ {
composite.gizmoMeshes.ForEach(g => Render(debugDraw, g)); composite.gizmoMeshes.ForEach(g => Render(debugDraw, g));
} }

View File

@ -0,0 +1,37 @@
using DotRecast.Core;
namespace DotRecast.Recast.Toolset.Gizmos
{
public static class GizmoFactory
{
public static RcBoxGizmo Box(RcVec3f center, RcVec3f[] halfEdges)
{
return new RcBoxGizmo(center, halfEdges);
}
public static RcSphereGizmo Sphere(RcVec3f center, float radius)
{
return new RcSphereGizmo(center, radius);
}
public static RcCapsuleGizmo Capsule(RcVec3f start, RcVec3f end, float radius)
{
return new RcCapsuleGizmo(start, end, radius);
}
public static RcCylinderGizmo Cylinder(RcVec3f start, RcVec3f end, float radius)
{
return new RcCylinderGizmo(start, end, radius);
}
public static RcTrimeshGizmo Trimesh(float[] verts, int[] faces)
{
return new RcTrimeshGizmo(verts, faces);
}
public static RcCompositeGizmo Composite(params IRcGizmoMeshFilter[] gizmos)
{
return new RcCompositeGizmo(gizmos);
}
}
}

View File

@ -1,6 +1,6 @@
using System; using System;
namespace DotRecast.Recast.Toolset.Tools.Gizmos namespace DotRecast.Recast.Toolset.Gizmos
{ {
public static class GizmoHelper public static class GizmoHelper
{ {

View File

@ -1,6 +1,6 @@
//using DotRecast.Recast.Demo.Draw; //using DotRecast.Recast.Demo.Draw;
namespace DotRecast.Recast.Toolset.Tools.Gizmos namespace DotRecast.Recast.Toolset.Gizmos
{ {
public interface IRcGizmoMeshFilter public interface IRcGizmoMeshFilter
{ {

View File

@ -1,9 +1,9 @@
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Detour.Dynamic.Colliders; using DotRecast.Detour.Dynamic.Colliders;
namespace DotRecast.Recast.Toolset.Tools.Gizmos namespace DotRecast.Recast.Toolset.Gizmos
{ {
public class BoxGizmo : IRcGizmoMeshFilter public class RcBoxGizmo : IRcGizmoMeshFilter
{ {
public static readonly int[] TRIANLGES = public static readonly int[] TRIANLGES =
{ {
@ -27,12 +27,12 @@ namespace DotRecast.Recast.Toolset.Tools.Gizmos
public readonly RcVec3f center; public readonly RcVec3f center;
public readonly RcVec3f[] halfEdges; public readonly RcVec3f[] halfEdges;
public BoxGizmo(RcVec3f center, RcVec3f extent, RcVec3f forward, RcVec3f up) : public RcBoxGizmo(RcVec3f center, RcVec3f extent, RcVec3f forward, RcVec3f up) :
this(center, BoxCollider.GetHalfEdges(up, forward, extent)) this(center, BoxCollider.GetHalfEdges(up, forward, extent))
{ {
} }
public BoxGizmo(RcVec3f center, RcVec3f[] halfEdges) public RcBoxGizmo(RcVec3f center, RcVec3f[] halfEdges)
{ {
this.center = center; this.center = center;
this.halfEdges = halfEdges; this.halfEdges = halfEdges;

View File

@ -1,17 +1,17 @@
using DotRecast.Core; using DotRecast.Core;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
using static DotRecast.Recast.Toolset.Tools.Gizmos.GizmoHelper; using static DotRecast.Recast.Toolset.Gizmos.GizmoHelper;
namespace DotRecast.Recast.Toolset.Tools.Gizmos namespace DotRecast.Recast.Toolset.Gizmos
{ {
public class CapsuleGizmo : IRcGizmoMeshFilter public class RcCapsuleGizmo : IRcGizmoMeshFilter
{ {
public readonly float[] vertices; public readonly float[] vertices;
public readonly int[] triangles; public readonly int[] triangles;
public readonly float[] center; public readonly float[] center;
public readonly float[] gradient; public readonly float[] gradient;
public CapsuleGizmo(RcVec3f start, RcVec3f end, float radius) public RcCapsuleGizmo(RcVec3f start, RcVec3f end, float radius)
{ {
center = new float[] center = new float[]
{ {

View File

@ -0,0 +1,12 @@
namespace DotRecast.Recast.Toolset.Gizmos
{
public class RcCompositeGizmo : IRcGizmoMeshFilter
{
public readonly IRcGizmoMeshFilter[] gizmoMeshes;
public RcCompositeGizmo(params IRcGizmoMeshFilter[] gizmoMeshes)
{
this.gizmoMeshes = gizmoMeshes;
}
}
}

View File

@ -1,18 +1,18 @@
using DotRecast.Core; using DotRecast.Core;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
using static DotRecast.Recast.Toolset.Tools.Gizmos.GizmoHelper; using static DotRecast.Recast.Toolset.Gizmos.GizmoHelper;
namespace DotRecast.Recast.Toolset.Tools.Gizmos namespace DotRecast.Recast.Toolset.Gizmos
{ {
public class CylinderGizmo : IRcGizmoMeshFilter public class RcCylinderGizmo : IRcGizmoMeshFilter
{ {
public readonly float[] vertices; public readonly float[] vertices;
public readonly int[] triangles; public readonly int[] triangles;
public readonly RcVec3f center; public readonly RcVec3f center;
public readonly float[] gradient; public readonly float[] gradient;
public CylinderGizmo(RcVec3f start, RcVec3f end, float radius) public RcCylinderGizmo(RcVec3f start, RcVec3f end, float radius)
{ {
center = RcVec3f.Of( center = RcVec3f.Of(
0.5f * (start.x + end.x), 0.5f * (start.y + end.y), 0.5f * (start.x + end.x), 0.5f * (start.y + end.y),

View File

@ -0,0 +1,17 @@
using DotRecast.Detour.Dynamic.Colliders;
using DotRecast.Recast.Toolset.Gizmos;
namespace DotRecast.Recast.Toolset.Gizmos
{
public class RcGizmo
{
public readonly IRcGizmoMeshFilter Gizmo;
public readonly ICollider Collider;
public RcGizmo(ICollider collider, IRcGizmoMeshFilter gizmo)
{
Collider = collider;
Gizmo = gizmo;
}
}
}

View File

@ -1,17 +1,17 @@
using DotRecast.Core; using DotRecast.Core;
using static DotRecast.Recast.Toolset.Tools.Gizmos.GizmoHelper; using static DotRecast.Recast.Toolset.Gizmos.GizmoHelper;
namespace DotRecast.Recast.Toolset.Tools.Gizmos namespace DotRecast.Recast.Toolset.Gizmos
{ {
public class SphereGizmo : IRcGizmoMeshFilter public class RcSphereGizmo : IRcGizmoMeshFilter
{ {
public readonly float[] vertices; public readonly float[] vertices;
public readonly int[] triangles; public readonly int[] triangles;
public readonly float radius; public readonly float radius;
public readonly RcVec3f center; public readonly RcVec3f center;
public SphereGizmo(RcVec3f center, float radius) public RcSphereGizmo(RcVec3f center, float radius)
{ {
this.center = center; this.center = center;
this.radius = radius; this.radius = radius;

View File

@ -1,11 +1,11 @@
namespace DotRecast.Recast.Toolset.Tools.Gizmos namespace DotRecast.Recast.Toolset.Gizmos
{ {
public class TrimeshGizmo : IRcGizmoMeshFilter public class RcTrimeshGizmo : IRcGizmoMeshFilter
{ {
public readonly float[] vertices; public readonly float[] vertices;
public readonly int[] triangles; public readonly int[] triangles;
public TrimeshGizmo(float[] vertices, int[] triangles) public RcTrimeshGizmo(float[] vertices, int[] triangles)
{ {
this.vertices = vertices; this.vertices = vertices;
this.triangles = triangles; this.triangles = triangles;

View File

@ -1,12 +0,0 @@
namespace DotRecast.Recast.Toolset.Tools.Gizmos
{
public class CompositeGizmo : IRcGizmoMeshFilter
{
public readonly IRcGizmoMeshFilter[] gizmoMeshes;
public CompositeGizmo(params IRcGizmoMeshFilter[] gizmoMeshes)
{
this.gizmoMeshes = gizmoMeshes;
}
}
}

View File

@ -1,37 +0,0 @@
using DotRecast.Core;
namespace DotRecast.Recast.Toolset.Tools.Gizmos
{
public static class GizmoFactory
{
public static BoxGizmo Box(RcVec3f center, RcVec3f[] halfEdges)
{
return new BoxGizmo(center, halfEdges);
}
public static SphereGizmo Sphere(RcVec3f center, float radius)
{
return new SphereGizmo(center, radius);
}
public static CapsuleGizmo Capsule(RcVec3f start, RcVec3f end, float radius)
{
return new CapsuleGizmo(start, end, radius);
}
public static CylinderGizmo Cylinder(RcVec3f start, RcVec3f end, float radius)
{
return new CylinderGizmo(start, end, radius);
}
public static TrimeshGizmo Trimesh(float[] verts, int[] faces)
{
return new TrimeshGizmo(verts, faces);
}
public static CompositeGizmo Composite(params IRcGizmoMeshFilter[] gizmos)
{
return new CompositeGizmo(gizmos);
}
}
}