diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index 5b2d780..6de4e2d 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -387,7 +387,7 @@ public class RecastDemo : IRecastDemoChannel new OffMeshConnectionSampleTool(), new ConvexVolumeSampleTool(), new CrowdSampleTool(), - new CrowdProfilingSampleTool(), + new CrowdAgentProfilingSampleTool(), new JumpLinkBuilderSampleTool(), new DynamicUpdateSampleTool() ); diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdAgentProfilingSampleTool.cs similarity index 94% rename from src/DotRecast.Recast.Demo/Tools/CrowdProfilingSampleTool.cs rename to src/DotRecast.Recast.Demo/Tools/CrowdAgentProfilingSampleTool.cs index 17aac84..23312d0 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdAgentProfilingSampleTool.cs @@ -33,17 +33,17 @@ using static DotRecast.Recast.Demo.Draw.DebugDraw; namespace DotRecast.Recast.Demo.Tools; -public class CrowdProfilingSampleTool : ISampleTool +public class CrowdAgentProfilingSampleTool : ISampleTool { - private static readonly ILogger Logger = Log.ForContext(); + private static readonly ILogger Logger = Log.ForContext(); private DemoSample _sample; private DtNavMesh m_nav; - private readonly RcCrowdProfilingTool _tool; + private readonly RcCrowdAgentProfilingTool _tool; - public CrowdProfilingSampleTool() + public CrowdAgentProfilingSampleTool() { _tool = new(); } @@ -139,19 +139,19 @@ public class CrowdProfilingSampleTool : ISampleTool foreach (DtCrowdAgent ag in crowd.GetActiveAgents()) { - CrowdAgentData crowAgentData = (CrowdAgentData)ag.option.userData; + RcCrowdAgentData crowAgentData = (RcCrowdAgentData)ag.option.userData; float height = ag.option.height; float radius = ag.option.radius; RcVec3f pos = ag.npos; int col = DuRGBA(220, 220, 220, 128); - if (crowAgentData.type == CrowdAgentType.TRAVELLER) + if (crowAgentData.type == RcCrowdAgentType.TRAVELLER) { col = DuRGBA(100, 160, 100, 128); } - if (crowAgentData.type == CrowdAgentType.VILLAGER) + if (crowAgentData.type == RcCrowdAgentType.VILLAGER) { col = DuRGBA(120, 80, 160, 128); } diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs index 951bc86..08bbf4c 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs @@ -44,8 +44,8 @@ public class CrowdSampleTool : ISampleTool private DtNavMesh m_nav; - private CrowdToolMode m_mode = CrowdToolMode.CREATE; - private int m_modeIdx = CrowdToolMode.CREATE.Idx; + private RcCrowdToolMode m_mode = RcCrowdToolMode.CREATE; + private int m_modeIdx = RcCrowdToolMode.CREATE.Idx; private int _expandSelectedDebugDraw = 1; private bool _showCorners = true; @@ -71,16 +71,16 @@ public class CrowdSampleTool : ISampleTool { ImGui.Text($"Crowd Tool Mode"); ImGui.Separator(); - CrowdToolMode previousToolMode = m_mode; - ImGui.RadioButton(CrowdToolMode.CREATE.Label, ref m_modeIdx, CrowdToolMode.CREATE.Idx); - ImGui.RadioButton(CrowdToolMode.MOVE_TARGET.Label, ref m_modeIdx, CrowdToolMode.MOVE_TARGET.Idx); - ImGui.RadioButton(CrowdToolMode.SELECT.Label, ref m_modeIdx, CrowdToolMode.SELECT.Idx); - ImGui.RadioButton(CrowdToolMode.TOGGLE_POLYS.Label, ref m_modeIdx, CrowdToolMode.TOGGLE_POLYS.Idx); + RcCrowdToolMode previousToolMode = m_mode; + ImGui.RadioButton(RcCrowdToolMode.CREATE.Label, ref m_modeIdx, RcCrowdToolMode.CREATE.Idx); + ImGui.RadioButton(RcCrowdToolMode.MOVE_TARGET.Label, ref m_modeIdx, RcCrowdToolMode.MOVE_TARGET.Idx); + ImGui.RadioButton(RcCrowdToolMode.SELECT.Label, ref m_modeIdx, RcCrowdToolMode.SELECT.Idx); + ImGui.RadioButton(RcCrowdToolMode.TOGGLE_POLYS.Label, ref m_modeIdx, RcCrowdToolMode.TOGGLE_POLYS.Idx); ImGui.NewLine(); if (previousToolMode.Idx != m_modeIdx) { - m_mode = CrowdToolMode.Values[m_modeIdx]; + m_mode = RcCrowdToolMode.Values[m_modeIdx]; } var crowdCfg = _tool.GetCrowdConfig(); @@ -219,18 +219,18 @@ public class CrowdSampleTool : ISampleTool // Trail foreach (DtCrowdAgent ag in crowd.GetActiveAgents()) { - CrowdAgentTrail trail = agentTrails[ag.idx]; + RcCrowdAgentTrail trail = agentTrails[ag.idx]; RcVec3f pos = ag.npos; dd.Begin(LINES, 3.0f); RcVec3f prev = new RcVec3f(); float preva = 1; prev = pos; - for (int j = 0; j < CrowdAgentTrail.AGENT_MAX_TRAIL - 1; ++j) + for (int j = 0; j < RcCrowdAgentTrail.AGENT_MAX_TRAIL - 1; ++j) { - int idx = (trail.htrail + CrowdAgentTrail.AGENT_MAX_TRAIL - j) % CrowdAgentTrail.AGENT_MAX_TRAIL; + int idx = (trail.htrail + RcCrowdAgentTrail.AGENT_MAX_TRAIL - j) % RcCrowdAgentTrail.AGENT_MAX_TRAIL; int v = idx * 3; - float a = 1 - j / (float)CrowdAgentTrail.AGENT_MAX_TRAIL; + float a = 1 - j / (float)RcCrowdAgentTrail.AGENT_MAX_TRAIL; dd.Vertex(prev.x, prev.y + 0.1f, prev.z, DuRGBA(0, 0, 0, (int)(128 * preva))); dd.Vertex(trail.trail[v], trail.trail[v + 1] + 0.1f, trail.trail[v + 2], DuRGBA(0, 0, 0, (int)(128 * a))); preva = a; @@ -480,7 +480,7 @@ public class CrowdSampleTool : ISampleTool return; } - if (m_mode == CrowdToolMode.CREATE) + if (m_mode == RcCrowdToolMode.CREATE) { if (shift) { @@ -498,17 +498,17 @@ public class CrowdSampleTool : ISampleTool _tool.AddAgent(p, settings.agentRadius, settings.agentHeight, settings.agentMaxAcceleration, settings.agentMaxSpeed); } } - else if (m_mode == CrowdToolMode.MOVE_TARGET) + else if (m_mode == RcCrowdToolMode.MOVE_TARGET) { _tool.SetMoveTarget(p, shift); } - else if (m_mode == CrowdToolMode.SELECT) + else if (m_mode == RcCrowdToolMode.SELECT) { // Highlight DtCrowdAgent ahit = _tool.HitTestAgents(s, p); _tool.HighlightAgent(ahit); } - else if (m_mode == CrowdToolMode.TOGGLE_POLYS) + else if (m_mode == RcCrowdToolMode.TOGGLE_POLYS) { DtNavMesh nav = _sample.GetNavMesh(); DtNavMeshQuery navquery = _sample.GetNavMeshQuery(); diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs index 664288d..f6079a9 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs @@ -44,7 +44,7 @@ public class DynamicUpdateSampleTool : ISampleTool private DemoSample _sample; private readonly RcDynamicUpdateTool _tool; - private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD; + private RcDynamicUpdateToolMode mode = RcDynamicUpdateToolMode.BUILD; private float cellSize = 0.3f; // build config @@ -75,7 +75,7 @@ public class DynamicUpdateSampleTool : ISampleTool private long buildTime; private long raycastTime; - private DynamicColliderShape colliderShape = DynamicColliderShape.SPHERE; + private RcDynamicColliderShape colliderShape = RcDynamicColliderShape.SPHERE; private readonly TaskFactory executor; @@ -101,20 +101,20 @@ public class DynamicUpdateSampleTool : ISampleTool ImGui.Text($"Dynamic Update Tool Modes"); ImGui.Separator(); - ImGui.RadioButton(DynamicUpdateToolMode.BUILD.Label, ref prevModeIdx, DynamicUpdateToolMode.BUILD.Idx); - ImGui.RadioButton(DynamicUpdateToolMode.COLLIDERS.Label, ref prevModeIdx, DynamicUpdateToolMode.COLLIDERS.Idx); - ImGui.RadioButton(DynamicUpdateToolMode.RAYCAST.Label, ref prevModeIdx, DynamicUpdateToolMode.RAYCAST.Idx); + ImGui.RadioButton(RcDynamicUpdateToolMode.BUILD.Label, ref prevModeIdx, RcDynamicUpdateToolMode.BUILD.Idx); + ImGui.RadioButton(RcDynamicUpdateToolMode.COLLIDERS.Label, ref prevModeIdx, RcDynamicUpdateToolMode.COLLIDERS.Idx); + ImGui.RadioButton(RcDynamicUpdateToolMode.RAYCAST.Label, ref prevModeIdx, RcDynamicUpdateToolMode.RAYCAST.Idx); ImGui.NewLine(); if (prevModeIdx != mode.Idx) { - mode = DynamicUpdateToolMode.Values[prevModeIdx]; + mode = RcDynamicUpdateToolMode.Values[prevModeIdx]; } ImGui.Text($"Selected mode - {mode.Label}"); ImGui.Separator(); - if (mode == DynamicUpdateToolMode.BUILD) + if (mode == RcDynamicUpdateToolMode.BUILD) { var loadVoxelPopupStrId = "Load Voxels Popup"; bool isLoadVoxelPopup = true; @@ -224,30 +224,30 @@ public class DynamicUpdateSampleTool : ISampleTool } } - if (mode == DynamicUpdateToolMode.COLLIDERS) + if (mode == RcDynamicUpdateToolMode.COLLIDERS) { var prevColliderShape = (int)colliderShape; ImGui.Text("Colliders"); ImGui.Separator(); ImGui.Checkbox("Show", ref showColliders); - ImGui.RadioButton("Sphere", ref prevColliderShape, (int)DynamicColliderShape.SPHERE); - ImGui.RadioButton("Capsule", ref prevColliderShape, (int)DynamicColliderShape.CAPSULE); - ImGui.RadioButton("Box", ref prevColliderShape, (int)DynamicColliderShape.BOX); - ImGui.RadioButton("Cylinder", ref prevColliderShape, (int)DynamicColliderShape.CYLINDER); - ImGui.RadioButton("Composite", ref prevColliderShape, (int)DynamicColliderShape.COMPOSITE); - ImGui.RadioButton("Convex Trimesh", ref prevColliderShape, (int)DynamicColliderShape.CONVEX); - ImGui.RadioButton("Trimesh Bridge", ref prevColliderShape, (int)DynamicColliderShape.TRIMESH_BRIDGE); - ImGui.RadioButton("Trimesh House", ref prevColliderShape, (int)DynamicColliderShape.TRIMESH_HOUSE); + ImGui.RadioButton("Sphere", ref prevColliderShape, (int)RcDynamicColliderShape.SPHERE); + ImGui.RadioButton("Capsule", ref prevColliderShape, (int)RcDynamicColliderShape.CAPSULE); + ImGui.RadioButton("Box", ref prevColliderShape, (int)RcDynamicColliderShape.BOX); + ImGui.RadioButton("Cylinder", ref prevColliderShape, (int)RcDynamicColliderShape.CYLINDER); + ImGui.RadioButton("Composite", ref prevColliderShape, (int)RcDynamicColliderShape.COMPOSITE); + ImGui.RadioButton("Convex Trimesh", ref prevColliderShape, (int)RcDynamicColliderShape.CONVEX); + ImGui.RadioButton("Trimesh Bridge", ref prevColliderShape, (int)RcDynamicColliderShape.TRIMESH_BRIDGE); + ImGui.RadioButton("Trimesh House", ref prevColliderShape, (int)RcDynamicColliderShape.TRIMESH_HOUSE); ImGui.NewLine(); if (prevColliderShape != (int)colliderShape) { - colliderShape = (DynamicColliderShape)prevColliderShape; + colliderShape = (RcDynamicColliderShape)prevColliderShape; } } - if (mode == DynamicUpdateToolMode.RAYCAST) + if (mode == RcDynamicUpdateToolMode.RAYCAST) { ImGui.Text($"Raycast Time: {raycastTime} ms"); ImGui.Separator(); @@ -276,7 +276,7 @@ public class DynamicUpdateSampleTool : ISampleTool public void HandleRender(NavMeshRenderer renderer) { - if (mode == DynamicUpdateToolMode.COLLIDERS) + if (mode == RcDynamicUpdateToolMode.COLLIDERS) { if (showColliders) { @@ -287,7 +287,7 @@ public class DynamicUpdateSampleTool : ISampleTool } } - if (mode == DynamicUpdateToolMode.RAYCAST) + if (mode == RcDynamicUpdateToolMode.RAYCAST) { RecastDebugDraw dd = renderer.GetDebugDraw(); int startCol = DuRGBA(128, 25, 0, 192); @@ -356,7 +356,7 @@ public class DynamicUpdateSampleTool : ISampleTool public void HandleClick(RcVec3f s, RcVec3f p, bool shift) { - if (mode == DynamicUpdateToolMode.COLLIDERS) + if (mode == RcDynamicUpdateToolMode.COLLIDERS) { if (!shift) { @@ -364,7 +364,7 @@ public class DynamicUpdateSampleTool : ISampleTool } } - if (mode == DynamicUpdateToolMode.RAYCAST) + if (mode == RcDynamicUpdateToolMode.RAYCAST) { if (shift) { @@ -392,7 +392,7 @@ public class DynamicUpdateSampleTool : ISampleTool public void HandleClickRay(RcVec3f start, RcVec3f dir, bool shift) { - if (mode == DynamicUpdateToolMode.COLLIDERS) + if (mode == RcDynamicUpdateToolMode.COLLIDERS) { if (shift) { diff --git a/src/DotRecast.Recast.Toolset/Gizmos/RcCapsuleGizmo.cs b/src/DotRecast.Recast.Toolset/Gizmos/RcCapsuleGizmo.cs index 41a2ce6..54cd270 100644 --- a/src/DotRecast.Recast.Toolset/Gizmos/RcCapsuleGizmo.cs +++ b/src/DotRecast.Recast.Toolset/Gizmos/RcCapsuleGizmo.cs @@ -1,6 +1,6 @@ using DotRecast.Core; using static DotRecast.Core.RcMath; -using static DotRecast.Recast.Toolset.Gizmos.GizmoHelper; +using static DotRecast.Recast.Toolset.Gizmos.RcGizmoHelper; namespace DotRecast.Recast.Toolset.Gizmos { diff --git a/src/DotRecast.Recast.Toolset/Gizmos/RcCylinderGizmo.cs b/src/DotRecast.Recast.Toolset/Gizmos/RcCylinderGizmo.cs index bbafda0..8e9b9b3 100644 --- a/src/DotRecast.Recast.Toolset/Gizmos/RcCylinderGizmo.cs +++ b/src/DotRecast.Recast.Toolset/Gizmos/RcCylinderGizmo.cs @@ -1,6 +1,6 @@ using DotRecast.Core; using static DotRecast.Core.RcMath; -using static DotRecast.Recast.Toolset.Gizmos.GizmoHelper; +using static DotRecast.Recast.Toolset.Gizmos.RcGizmoHelper; namespace DotRecast.Recast.Toolset.Gizmos diff --git a/src/DotRecast.Recast.Toolset/Gizmos/GizmoFactory.cs b/src/DotRecast.Recast.Toolset/Gizmos/RcGizmoFactory.cs similarity index 96% rename from src/DotRecast.Recast.Toolset/Gizmos/GizmoFactory.cs rename to src/DotRecast.Recast.Toolset/Gizmos/RcGizmoFactory.cs index f58a06c..62aece4 100644 --- a/src/DotRecast.Recast.Toolset/Gizmos/GizmoFactory.cs +++ b/src/DotRecast.Recast.Toolset/Gizmos/RcGizmoFactory.cs @@ -2,7 +2,7 @@ namespace DotRecast.Recast.Toolset.Gizmos { - public static class GizmoFactory + public static class RcGizmoFactory { public static RcBoxGizmo Box(RcVec3f center, RcVec3f[] halfEdges) { diff --git a/src/DotRecast.Recast.Toolset/Gizmos/GizmoHelper.cs b/src/DotRecast.Recast.Toolset/Gizmos/RcGizmoHelper.cs similarity index 99% rename from src/DotRecast.Recast.Toolset/Gizmos/GizmoHelper.cs rename to src/DotRecast.Recast.Toolset/Gizmos/RcGizmoHelper.cs index 2cfcb0e..1737839 100644 --- a/src/DotRecast.Recast.Toolset/Gizmos/GizmoHelper.cs +++ b/src/DotRecast.Recast.Toolset/Gizmos/RcGizmoHelper.cs @@ -2,7 +2,7 @@ using System; namespace DotRecast.Recast.Toolset.Gizmos { - public static class GizmoHelper + public static class RcGizmoHelper { private static readonly int SEGMENTS = 16; private static readonly int RINGS = 8; diff --git a/src/DotRecast.Recast.Toolset/Gizmos/RcSphereGizmo.cs b/src/DotRecast.Recast.Toolset/Gizmos/RcSphereGizmo.cs index 1ee8608..f3ab52f 100644 --- a/src/DotRecast.Recast.Toolset/Gizmos/RcSphereGizmo.cs +++ b/src/DotRecast.Recast.Toolset/Gizmos/RcSphereGizmo.cs @@ -1,5 +1,5 @@ using DotRecast.Core; -using static DotRecast.Recast.Toolset.Gizmos.GizmoHelper; +using static DotRecast.Recast.Toolset.Gizmos.RcGizmoHelper; namespace DotRecast.Recast.Toolset.Gizmos diff --git a/src/DotRecast.Recast.Toolset/Tools/CrowdToolMode.cs b/src/DotRecast.Recast.Toolset/Tools/CrowdToolMode.cs deleted file mode 100644 index 1ebced8..0000000 --- a/src/DotRecast.Recast.Toolset/Tools/CrowdToolMode.cs +++ /dev/null @@ -1,28 +0,0 @@ -using DotRecast.Core; - -namespace DotRecast.Recast.Toolset.Tools -{ - public class CrowdToolMode - { - public static readonly CrowdToolMode CREATE = new CrowdToolMode(0, "Create Agents"); - public static readonly CrowdToolMode MOVE_TARGET = new CrowdToolMode(1, "Move Target"); - public static readonly CrowdToolMode SELECT = new CrowdToolMode(2, "Select Agent"); - public static readonly CrowdToolMode TOGGLE_POLYS = new CrowdToolMode(3, "Toggle Polys"); - - public static readonly RcImmutableArray Values = RcImmutableArray.Create( - CREATE, - MOVE_TARGET, - SELECT, - TOGGLE_POLYS - ); - - public int Idx { get; } - public string Label { get; } - - private CrowdToolMode(int idx, string label) - { - Idx = idx; - Label = label; - } - } -} \ No newline at end of file diff --git a/src/DotRecast.Recast.Toolset/Tools/DynamicUpdateToolMode.cs b/src/DotRecast.Recast.Toolset/Tools/DynamicUpdateToolMode.cs deleted file mode 100644 index 95b0a92..0000000 --- a/src/DotRecast.Recast.Toolset/Tools/DynamicUpdateToolMode.cs +++ /dev/null @@ -1,24 +0,0 @@ -using DotRecast.Core; - -namespace DotRecast.Recast.Toolset.Tools -{ - public class DynamicUpdateToolMode - { - public static readonly DynamicUpdateToolMode BUILD = new DynamicUpdateToolMode(0, "Build"); - public static readonly DynamicUpdateToolMode COLLIDERS = new DynamicUpdateToolMode(1, "Colliders"); - public static readonly DynamicUpdateToolMode RAYCAST = new DynamicUpdateToolMode(2, "Raycast"); - - public static readonly RcImmutableArray Values = RcImmutableArray.Create( - BUILD, COLLIDERS, RAYCAST - ); - - public int Idx { get; } - public string Label { get; } - - private DynamicUpdateToolMode(int idx, string label) - { - Idx = idx; - Label = label; - } - } -} \ No newline at end of file diff --git a/src/DotRecast.Recast.Toolset/Tools/CrowdAgentData.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentData.cs similarity index 58% rename from src/DotRecast.Recast.Toolset/Tools/CrowdAgentData.cs rename to src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentData.cs index 4da3bcf..a2f6560 100644 --- a/src/DotRecast.Recast.Toolset/Tools/CrowdAgentData.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentData.cs @@ -2,12 +2,12 @@ namespace DotRecast.Recast.Toolset.Tools { - public class CrowdAgentData + public class RcCrowdAgentData { - public readonly CrowdAgentType type; + public readonly RcCrowdAgentType type; public readonly RcVec3f home = new RcVec3f(); - public CrowdAgentData(CrowdAgentType type, RcVec3f home) + public RcCrowdAgentData(RcCrowdAgentType type, RcVec3f home) { this.type = type; this.home = home; diff --git a/src/DotRecast.Recast.Toolset/Tools/RcCrowdProfilingTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingTool.cs similarity index 90% rename from src/DotRecast.Recast.Toolset/Tools/RcCrowdProfilingTool.cs rename to src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingTool.cs index 98c7d66..556e3b5 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcCrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingTool.cs @@ -7,9 +7,9 @@ using DotRecast.Recast.Toolset.Builder; namespace DotRecast.Recast.Toolset.Tools { - public class RcCrowdProfilingTool : IRcToolable + public class RcCrowdAgentProfilingTool : IRcToolable { - private CrowdProfilingToolConfig _cfg; + private RcCrowdAgentProfilingToolConfig _cfg; private DtCrowdConfig _crowdCfg; private DtCrowd crowd; @@ -21,19 +21,19 @@ namespace DotRecast.Recast.Toolset.Tools private readonly List _polyPoints; private long crowdUpdateTime; - public RcCrowdProfilingTool() + public RcCrowdAgentProfilingTool() { - _cfg = new CrowdProfilingToolConfig(); + _cfg = new RcCrowdAgentProfilingToolConfig(); _agCfg = new DtCrowdAgentConfig(); _polyPoints = new List(); } public string GetName() { - return "Crowd Profiling"; + return "Crowd Agent Profiling"; } - public CrowdProfilingToolConfig GetToolConfig() + public RcCrowdAgentProfilingToolConfig GetToolConfig() { return _cfg; } @@ -170,7 +170,7 @@ namespace DotRecast.Recast.Toolset.Tools for (int i = 0; i < _cfg.agents; i++) { float tr = rnd.Next(); - CrowdAgentType type = CrowdAgentType.MOB; + RcCrowdAgentType type = RcCrowdAgentType.MOB; float mobsPcnt = _cfg.percentMobs / 100f; if (tr > mobsPcnt) { @@ -178,11 +178,11 @@ namespace DotRecast.Recast.Toolset.Tools float travellerPcnt = _cfg.percentTravellers / 100f; if (tr > travellerPcnt) { - type = CrowdAgentType.VILLAGER; + type = RcCrowdAgentType.VILLAGER; } else { - type = CrowdAgentType.TRAVELLER; + type = RcCrowdAgentType.TRAVELLER; } } @@ -190,13 +190,13 @@ namespace DotRecast.Recast.Toolset.Tools var randomPt = RcVec3f.Zero; switch (type) { - case CrowdAgentType.MOB: + case RcCrowdAgentType.MOB: status = GetMobPosition(navquery, filter, out randomPt); break; - case CrowdAgentType.VILLAGER: + case RcCrowdAgentType.VILLAGER: status = GetVillagerPosition(navquery, filter, out randomPt); break; - case CrowdAgentType.TRAVELLER: + case RcCrowdAgentType.TRAVELLER: status = GetVillagerPosition(navquery, filter, out randomPt); break; } @@ -227,16 +227,16 @@ namespace DotRecast.Recast.Toolset.Tools { if (NeedsNewTarget(ag)) { - CrowdAgentData crowAgentData = (CrowdAgentData)ag.option.userData; + RcCrowdAgentData crowAgentData = (RcCrowdAgentData)ag.option.userData; switch (crowAgentData.type) { - case CrowdAgentType.MOB: + case RcCrowdAgentType.MOB: MoveMob(navquery, filter, ag, crowAgentData); break; - case CrowdAgentType.VILLAGER: + case RcCrowdAgentType.VILLAGER: MoveVillager(navquery, filter, ag, crowAgentData); break; - case CrowdAgentType.TRAVELLER: + case RcCrowdAgentType.TRAVELLER: MoveTraveller(navquery, filter, ag, crowAgentData); break; } @@ -247,7 +247,7 @@ namespace DotRecast.Recast.Toolset.Tools crowdUpdateTime = (endTime - startTime) / TimeSpan.TicksPerMillisecond; } - private void MoveMob(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, CrowdAgentData crowAgentData) + private void MoveMob(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, RcCrowdAgentData crowAgentData) { // Move somewhere var status = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter, out var nearestRef, out var nearestPt, out var _); @@ -262,7 +262,7 @@ namespace DotRecast.Recast.Toolset.Tools } } - private void MoveVillager(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, CrowdAgentData crowAgentData) + private void MoveVillager(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, RcCrowdAgentData crowAgentData) { // Move somewhere close var status = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter, out var nearestRef, out var nearestPt, out var _); @@ -277,7 +277,7 @@ namespace DotRecast.Recast.Toolset.Tools } } - private void MoveTraveller(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, CrowdAgentData crowAgentData) + private void MoveTraveller(DtNavMeshQuery navquery, IDtQueryFilter filter, DtCrowdAgent ag, RcCrowdAgentData crowAgentData) { // Move to another zone List potentialTargets = new List(); @@ -315,10 +315,10 @@ namespace DotRecast.Recast.Toolset.Tools return false; } - private DtCrowdAgent AddAgent(RcVec3f p, CrowdAgentType type, float agentRadius, float agentHeight, float agentMaxAcceleration, float agentMaxSpeed) + private DtCrowdAgent AddAgent(RcVec3f p, RcCrowdAgentType type, float agentRadius, float agentHeight, float agentMaxAcceleration, float agentMaxSpeed) { DtCrowdAgentParams ap = GetAgentParams(agentRadius, agentHeight, agentMaxAcceleration, agentMaxSpeed); - ap.userData = new CrowdAgentData(type, p); + ap.userData = new RcCrowdAgentData(type, p); return crowd.AddAgent(p, ap); } diff --git a/src/DotRecast.Recast.Toolset/Tools/CrowdProfilingToolConfig.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs similarity index 90% rename from src/DotRecast.Recast.Toolset/Tools/CrowdProfilingToolConfig.cs rename to src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs index ac9e6fb..65794d1 100644 --- a/src/DotRecast.Recast.Toolset/Tools/CrowdProfilingToolConfig.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentProfilingToolConfig.cs @@ -1,6 +1,6 @@ namespace DotRecast.Recast.Toolset.Tools { - public class CrowdProfilingToolConfig + public class RcCrowdAgentProfilingToolConfig { public int expandSimOptions = 1; public int expandCrowdOptions = 1; diff --git a/src/DotRecast.Recast.Toolset/Tools/CrowdAgentTrail.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentTrail.cs similarity index 84% rename from src/DotRecast.Recast.Toolset/Tools/CrowdAgentTrail.cs rename to src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentTrail.cs index e4950ba..1717620 100644 --- a/src/DotRecast.Recast.Toolset/Tools/CrowdAgentTrail.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentTrail.cs @@ -1,6 +1,6 @@ namespace DotRecast.Recast.Toolset.Tools { - public class CrowdAgentTrail + public class RcCrowdAgentTrail { public const int AGENT_MAX_TRAIL = 64; public float[] trail = new float[AGENT_MAX_TRAIL * 3]; diff --git a/src/DotRecast.Recast.Toolset/Tools/CrowdAgentType.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentType.cs similarity index 76% rename from src/DotRecast.Recast.Toolset/Tools/CrowdAgentType.cs rename to src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentType.cs index 124e628..1fce64c 100644 --- a/src/DotRecast.Recast.Toolset/Tools/CrowdAgentType.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdAgentType.cs @@ -1,6 +1,6 @@ namespace DotRecast.Recast.Toolset.Tools { - public enum CrowdAgentType + public enum RcCrowdAgentType { VILLAGER, TRAVELLER, diff --git a/src/DotRecast.Recast.Toolset/Tools/RcCrowdTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdTool.cs index f0af2a0..ee48eff 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcCrowdTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdTool.cs @@ -14,7 +14,7 @@ namespace DotRecast.Recast.Toolset.Tools private DtCrowd crowd; private readonly DtCrowdAgentDebugInfo _agentDebug; private long crowdUpdateTime; - private readonly Dictionary _trails; + private readonly Dictionary _trails; private long _moveTargetRef; private RcVec3f _moveTargetPos; @@ -23,7 +23,7 @@ namespace DotRecast.Recast.Toolset.Tools _agCfg = new DtCrowdAgentConfig(); _agentDebug = new DtCrowdAgentDebugInfo(); _agentDebug.vod = new DtObstacleAvoidanceDebugData(2048); - _trails = new Dictionary(); + _trails = new Dictionary(); } @@ -42,7 +42,7 @@ namespace DotRecast.Recast.Toolset.Tools return _agentDebug; } - public Dictionary GetCrowdAgentTrails() + public Dictionary GetCrowdAgentTrails() { return _trails; } @@ -147,9 +147,9 @@ namespace DotRecast.Recast.Toolset.Tools // Update agent trails foreach (DtCrowdAgent ag in crowd.GetActiveAgents()) { - CrowdAgentTrail trail = _trails[ag.idx]; + RcCrowdAgentTrail trail = _trails[ag.idx]; // Update agent movement trail. - trail.htrail = (trail.htrail + 1) % CrowdAgentTrail.AGENT_MAX_TRAIL; + trail.htrail = (trail.htrail + 1) % RcCrowdAgentTrail.AGENT_MAX_TRAIL; trail.trail[trail.htrail * 3] = ag.npos.x; trail.trail[trail.htrail * 3 + 1] = ag.npos.y; trail.trail[trail.htrail * 3 + 2] = ag.npos.z; @@ -182,11 +182,11 @@ namespace DotRecast.Recast.Toolset.Tools // Init trail if (!_trails.TryGetValue(ag.idx, out var trail)) { - trail = new CrowdAgentTrail(); + trail = new RcCrowdAgentTrail(); _trails.Add(ag.idx, trail); } - for (int i = 0; i < CrowdAgentTrail.AGENT_MAX_TRAIL; ++i) + for (int i = 0; i < RcCrowdAgentTrail.AGENT_MAX_TRAIL; ++i) { trail.trail[i * 3] = p.x; trail.trail[i * 3 + 1] = p.y; diff --git a/src/DotRecast.Recast.Toolset/Tools/RcCrowdToolMode.cs b/src/DotRecast.Recast.Toolset/Tools/RcCrowdToolMode.cs new file mode 100644 index 0000000..25d4164 --- /dev/null +++ b/src/DotRecast.Recast.Toolset/Tools/RcCrowdToolMode.cs @@ -0,0 +1,28 @@ +using DotRecast.Core; + +namespace DotRecast.Recast.Toolset.Tools +{ + public class RcCrowdToolMode + { + public static readonly RcCrowdToolMode CREATE = new RcCrowdToolMode(0, "Create Agents"); + public static readonly RcCrowdToolMode MOVE_TARGET = new RcCrowdToolMode(1, "Move Target"); + public static readonly RcCrowdToolMode SELECT = new RcCrowdToolMode(2, "Select Agent"); + public static readonly RcCrowdToolMode TOGGLE_POLYS = new RcCrowdToolMode(3, "Toggle Polys"); + + public static readonly RcImmutableArray Values = RcImmutableArray.Create( + CREATE, + MOVE_TARGET, + SELECT, + TOGGLE_POLYS + ); + + public int Idx { get; } + public string Label { get; } + + private RcCrowdToolMode(int idx, string label) + { + Idx = idx; + Label = label; + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast.Toolset/Tools/DynamicColliderShape.cs b/src/DotRecast.Recast.Toolset/Tools/RcDynamicColliderShape.cs similarity index 83% rename from src/DotRecast.Recast.Toolset/Tools/DynamicColliderShape.cs rename to src/DotRecast.Recast.Toolset/Tools/RcDynamicColliderShape.cs index 70c964e..9ea240a 100644 --- a/src/DotRecast.Recast.Toolset/Tools/DynamicColliderShape.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcDynamicColliderShape.cs @@ -1,6 +1,6 @@ namespace DotRecast.Recast.Toolset.Tools { - public enum DynamicColliderShape + public enum RcDynamicColliderShape { SPHERE, CAPSULE, diff --git a/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs index 9c01be1..76ed491 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs @@ -88,7 +88,7 @@ namespace DotRecast.Recast.Toolset.Tools } - public RcGizmo AddShape(DynamicColliderShape colliderShape, RcVec3f p) + public RcGizmo AddShape(RcDynamicColliderShape colliderShape, RcVec3f p) { if (dynaMesh == null) { @@ -97,35 +97,35 @@ namespace DotRecast.Recast.Toolset.Tools RcGizmo colliderWithGizmo = null; { - if (colliderShape == DynamicColliderShape.SPHERE) + if (colliderShape == RcDynamicColliderShape.SPHERE) { colliderWithGizmo = SphereCollider(p, dynaMesh.config.walkableClimb); } - else if (colliderShape == DynamicColliderShape.CAPSULE) + else if (colliderShape == RcDynamicColliderShape.CAPSULE) { colliderWithGizmo = CapsuleCollider(p, dynaMesh.config.walkableClimb); } - else if (colliderShape == DynamicColliderShape.BOX) + else if (colliderShape == RcDynamicColliderShape.BOX) { colliderWithGizmo = BoxCollider(p, dynaMesh.config.walkableClimb); } - else if (colliderShape == DynamicColliderShape.CYLINDER) + else if (colliderShape == RcDynamicColliderShape.CYLINDER) { colliderWithGizmo = CylinderCollider(p, dynaMesh.config.walkableClimb); } - else if (colliderShape == DynamicColliderShape.COMPOSITE) + else if (colliderShape == RcDynamicColliderShape.COMPOSITE) { colliderWithGizmo = CompositeCollider(p, dynaMesh.config.walkableClimb); } - else if (colliderShape == DynamicColliderShape.TRIMESH_BRIDGE) + else if (colliderShape == RcDynamicColliderShape.TRIMESH_BRIDGE) { colliderWithGizmo = TrimeshBridge(p, dynaMesh.config.walkableClimb); } - else if (colliderShape == DynamicColliderShape.TRIMESH_HOUSE) + else if (colliderShape == RcDynamicColliderShape.TRIMESH_HOUSE) { colliderWithGizmo = TrimeshHouse(p, dynaMesh.config.walkableClimb); } - else if (colliderShape == DynamicColliderShape.CONVEX) + else if (colliderShape == RcDynamicColliderShape.CONVEX) { colliderWithGizmo = ConvexTrimesh(p, dynaMesh.config.walkableClimb); } @@ -169,7 +169,7 @@ namespace DotRecast.Recast.Toolset.Tools { float radius = 1 + (float)random.NextDouble() * 10; var collider = new DtSphereCollider(p, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, walkableClimb); - var gizmo = GizmoFactory.Sphere(p, radius); + var gizmo = RcGizmoFactory.Sphere(p, radius); return new RcGizmo(collider, gizmo); } @@ -190,7 +190,7 @@ namespace DotRecast.Recast.Toolset.Tools RcVec3f start = RcVec3f.Of(p.x, p.y, p.z); RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); var collider = new DtCapsuleCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, walkableClimb); - var gizmo = GizmoFactory.Capsule(start, end, radius); + var gizmo = RcGizmoFactory.Capsule(start, end, radius); return new RcGizmo(collider, gizmo); } @@ -205,7 +205,7 @@ namespace DotRecast.Recast.Toolset.Tools RcVec3f up = RcVec3f.Of((1f - 2 * (float)random.NextDouble()), 0.01f + (float)random.NextDouble(), (1f - 2 * (float)random.NextDouble())); RcVec3f[] halfEdges = Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(up, forward, extent); var collider = new DtBoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, walkableClimb); - var gizmo = GizmoFactory.Box(p, halfEdges); + var gizmo = RcGizmoFactory.Box(p, halfEdges); return new RcGizmo(collider, gizmo); } @@ -221,7 +221,7 @@ namespace DotRecast.Recast.Toolset.Tools RcVec3f start = RcVec3f.Of(p.x, p.y, p.z); RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); var collider = new DtCylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, walkableClimb); - var gizmo = GizmoFactory.Cylinder(start, end, radius); + var gizmo = RcGizmoFactory.Cylinder(start, end, radius); return new RcGizmo(collider, gizmo); } @@ -258,11 +258,11 @@ namespace DotRecast.Recast.Toolset.Tools DtSphereCollider crown = new DtSphereCollider(crownCenter, 4f, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_GRASS, walkableClimb); DtCompositeCollider collider = new DtCompositeCollider(@base, roof, trunk, crown); - IRcGizmoMeshFilter baseGizmo = GizmoFactory.Box(baseCenter, Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(baseUp, forward, baseExtent)); - IRcGizmoMeshFilter roofGizmo = GizmoFactory.Box(roofCenter, Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(roofUp, forward, roofExtent)); - IRcGizmoMeshFilter trunkGizmo = GizmoFactory.Capsule(trunkStart, trunkEnd, 0.5f); - IRcGizmoMeshFilter crownGizmo = GizmoFactory.Sphere(crownCenter, 4f); - IRcGizmoMeshFilter gizmo = GizmoFactory.Composite(baseGizmo, roofGizmo, trunkGizmo, crownGizmo); + IRcGizmoMeshFilter baseGizmo = RcGizmoFactory.Box(baseCenter, Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(baseUp, forward, baseExtent)); + IRcGizmoMeshFilter roofGizmo = RcGizmoFactory.Box(roofCenter, Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(roofUp, forward, roofExtent)); + IRcGizmoMeshFilter trunkGizmo = RcGizmoFactory.Capsule(trunkStart, trunkEnd, 0.5f); + IRcGizmoMeshFilter crownGizmo = RcGizmoFactory.Sphere(crownCenter, 4f); + IRcGizmoMeshFilter gizmo = RcGizmoFactory.Composite(baseGizmo, roofGizmo, trunkGizmo, crownGizmo); return new RcGizmo(collider, gizmo); } @@ -281,7 +281,7 @@ namespace DotRecast.Recast.Toolset.Tools float[] verts = TransformVertices(p, convexGeom, 360); var collider = new DtConvexTrimeshCollider(verts, convexGeom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, walkableClimb * 10); - var gizmo = GizmoFactory.Trimesh(verts, convexGeom.faces); + var gizmo = RcGizmoFactory.Trimesh(verts, convexGeom.faces); return new RcGizmo(collider, gizmo); } @@ -290,7 +290,7 @@ namespace DotRecast.Recast.Toolset.Tools float[] verts = TransformVertices(p, geom, 0); var collider = new DtTrimeshCollider(verts, geom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, walkableClimb * 10); - var gizmo = GizmoFactory.Trimesh(verts, geom.faces); + var gizmo = RcGizmoFactory.Trimesh(verts, geom.faces); return new RcGizmo(collider, gizmo); } diff --git a/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateToolMode.cs b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateToolMode.cs new file mode 100644 index 0000000..3e2ee02 --- /dev/null +++ b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateToolMode.cs @@ -0,0 +1,24 @@ +using DotRecast.Core; + +namespace DotRecast.Recast.Toolset.Tools +{ + public class RcDynamicUpdateToolMode + { + public static readonly RcDynamicUpdateToolMode BUILD = new RcDynamicUpdateToolMode(0, "Build"); + public static readonly RcDynamicUpdateToolMode COLLIDERS = new RcDynamicUpdateToolMode(1, "Colliders"); + public static readonly RcDynamicUpdateToolMode RAYCAST = new RcDynamicUpdateToolMode(2, "Raycast"); + + public static readonly RcImmutableArray Values = RcImmutableArray.Create( + BUILD, COLLIDERS, RAYCAST + ); + + public int Idx { get; } + public string Label { get; } + + private RcDynamicUpdateToolMode(int idx, string label) + { + Idx = idx; + Label = label; + } + } +} \ No newline at end of file