forked from mirror/DotRecast
for unity3d
This commit is contained in:
parent
17891c2d43
commit
ed55d6a7f2
|
@ -40,6 +40,7 @@ using DotRecast.Recast.Demo.Draw;
|
|||
using DotRecast.Recast.DemoTool.Geom;
|
||||
using DotRecast.Recast.Demo.Tools;
|
||||
using DotRecast.Recast.Demo.UI;
|
||||
using DotRecast.Recast.DemoTool;
|
||||
using static DotRecast.Core.RcMath;
|
||||
using Window = Silk.NET.Windowing.Window;
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
using DotRecast.Core;
|
||||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class AgentData
|
||||
{
|
||||
public readonly AgentType type;
|
||||
public readonly RcVec3f home = new RcVec3f();
|
||||
|
||||
public AgentData(AgentType type, RcVec3f home)
|
||||
{
|
||||
this.type = type;
|
||||
this.home = home;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class AgentTrail
|
||||
{
|
||||
public float[] trail = new float[CrowdTool.AGENT_MAX_TRAIL * 3];
|
||||
public int htrail;
|
||||
};
|
|
@ -1,8 +0,0 @@
|
|||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public enum AgentType
|
||||
{
|
||||
VILLAGER,
|
||||
TRAVELLER,
|
||||
MOB,
|
||||
}
|
|
@ -26,6 +26,7 @@ using DotRecast.Detour.Crowd;
|
|||
using DotRecast.Detour.QueryResults;
|
||||
using DotRecast.Recast.DemoTool.Builder;
|
||||
using DotRecast.Recast.Demo.Draw;
|
||||
using DotRecast.Recast.DemoTool;
|
||||
using ImGuiNET;
|
||||
using Silk.NET.Windowing;
|
||||
using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
||||
|
@ -87,7 +88,7 @@ public class CrowdProfilingTool
|
|||
for (int i = 0; i < agents; i++)
|
||||
{
|
||||
float tr = rnd.Next();
|
||||
AgentType type = AgentType.MOB;
|
||||
CrowdAgentType type = CrowdAgentType.MOB;
|
||||
float mobsPcnt = percentMobs / 100f;
|
||||
if (tr > mobsPcnt)
|
||||
{
|
||||
|
@ -95,24 +96,24 @@ public class CrowdProfilingTool
|
|||
float travellerPcnt = percentTravellers / 100f;
|
||||
if (tr > travellerPcnt)
|
||||
{
|
||||
type = AgentType.VILLAGER;
|
||||
type = CrowdAgentType.VILLAGER;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = AgentType.TRAVELLER;
|
||||
type = CrowdAgentType.TRAVELLER;
|
||||
}
|
||||
}
|
||||
|
||||
RcVec3f? pos = null;
|
||||
switch (type)
|
||||
{
|
||||
case AgentType.MOB:
|
||||
case CrowdAgentType.MOB:
|
||||
pos = GetMobPosition(navquery, filter);
|
||||
break;
|
||||
case AgentType.VILLAGER:
|
||||
case CrowdAgentType.VILLAGER:
|
||||
pos = GetVillagerPosition(navquery, filter);
|
||||
break;
|
||||
case AgentType.TRAVELLER:
|
||||
case CrowdAgentType.TRAVELLER:
|
||||
pos = GetVillagerPosition(navquery, filter);
|
||||
break;
|
||||
}
|
||||
|
@ -257,17 +258,17 @@ public class CrowdProfilingTool
|
|||
{
|
||||
if (NeedsNewTarget(ag))
|
||||
{
|
||||
AgentData agentData = (AgentData)ag.option.userData;
|
||||
switch (agentData.type)
|
||||
CrowdAgentData crowAgentData = (CrowdAgentData)ag.option.userData;
|
||||
switch (crowAgentData.type)
|
||||
{
|
||||
case AgentType.MOB:
|
||||
MoveMob(navquery, filter, ag, agentData);
|
||||
case CrowdAgentType.MOB:
|
||||
MoveMob(navquery, filter, ag, crowAgentData);
|
||||
break;
|
||||
case AgentType.VILLAGER:
|
||||
MoveVillager(navquery, filter, ag, agentData);
|
||||
case CrowdAgentType.VILLAGER:
|
||||
MoveVillager(navquery, filter, ag, crowAgentData);
|
||||
break;
|
||||
case AgentType.TRAVELLER:
|
||||
MoveTraveller(navquery, filter, ag, agentData);
|
||||
case CrowdAgentType.TRAVELLER:
|
||||
MoveTraveller(navquery, filter, ag, crowAgentData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -277,14 +278,14 @@ public class CrowdProfilingTool
|
|||
crowdUpdateTime = (endTime - startTime) / TimeSpan.TicksPerMillisecond;
|
||||
}
|
||||
|
||||
private void MoveMob(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, AgentData agentData)
|
||||
private void MoveMob(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, CrowdAgentData crowAgentData)
|
||||
{
|
||||
// Move somewhere
|
||||
Result<FindNearestPolyResult> nearestPoly = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter);
|
||||
if (nearestPoly.Succeeded())
|
||||
{
|
||||
Result<FindRandomPointResult> result = navquery.FindRandomPointAroundCircle(nearestPoly.result.GetNearestRef(),
|
||||
agentData.home, zoneRadius * 2f, filter, rnd);
|
||||
crowAgentData.home, zoneRadius * 2f, filter, rnd);
|
||||
if (result.Succeeded())
|
||||
{
|
||||
crowd.RequestMoveTarget(ag, result.result.GetRandomRef(), result.result.GetRandomPt());
|
||||
|
@ -292,14 +293,14 @@ public class CrowdProfilingTool
|
|||
}
|
||||
}
|
||||
|
||||
private void MoveVillager(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, AgentData agentData)
|
||||
private void MoveVillager(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, CrowdAgentData crowAgentData)
|
||||
{
|
||||
// Move somewhere close
|
||||
Result<FindNearestPolyResult> nearestPoly = navquery.FindNearestPoly(ag.npos, crowd.GetQueryExtents(), filter);
|
||||
if (nearestPoly.Succeeded())
|
||||
{
|
||||
Result<FindRandomPointResult> result = navquery.FindRandomPointAroundCircle(nearestPoly.result.GetNearestRef(),
|
||||
agentData.home, zoneRadius * 0.2f, filter, rnd);
|
||||
crowAgentData.home, zoneRadius * 0.2f, filter, rnd);
|
||||
if (result.Succeeded())
|
||||
{
|
||||
crowd.RequestMoveTarget(ag, result.result.GetRandomRef(), result.result.GetRandomPt());
|
||||
|
@ -307,7 +308,7 @@ public class CrowdProfilingTool
|
|||
}
|
||||
}
|
||||
|
||||
private void MoveTraveller(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, AgentData agentData)
|
||||
private void MoveTraveller(NavMeshQuery navquery, IQueryFilter filter, CrowdAgent ag, CrowdAgentData crowAgentData)
|
||||
{
|
||||
// Move to another zone
|
||||
List<FindRandomPointResult> potentialTargets = new();
|
||||
|
@ -369,19 +370,19 @@ public class CrowdProfilingTool
|
|||
|
||||
foreach (CrowdAgent ag in crowd.GetActiveAgents())
|
||||
{
|
||||
AgentData agentData = (AgentData)ag.option.userData;
|
||||
CrowdAgentData crowAgentData = (CrowdAgentData)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 (agentData.type == AgentType.TRAVELLER)
|
||||
if (crowAgentData.type == CrowdAgentType.TRAVELLER)
|
||||
{
|
||||
col = DuRGBA(100, 160, 100, 128);
|
||||
}
|
||||
|
||||
if (agentData.type == AgentType.VILLAGER)
|
||||
if (crowAgentData.type == CrowdAgentType.VILLAGER)
|
||||
{
|
||||
col = DuRGBA(120, 80, 160, 128);
|
||||
}
|
||||
|
@ -404,10 +405,10 @@ public class CrowdProfilingTool
|
|||
dd.DepthMask(true);
|
||||
}
|
||||
|
||||
private CrowdAgent AddAgent(RcVec3f p, AgentType type)
|
||||
private CrowdAgent AddAgent(RcVec3f p, CrowdAgentType type)
|
||||
{
|
||||
CrowdAgentParams ap = agentParamsSupplier.Invoke();
|
||||
ap.userData = new AgentData(type, p);
|
||||
ap.userData = new CrowdAgentData(type, p);
|
||||
return crowd.AddAgent(p, ap);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ using DotRecast.Detour.Crowd.Tracking;
|
|||
using DotRecast.Detour.QueryResults;
|
||||
using DotRecast.Recast.DemoTool.Builder;
|
||||
using DotRecast.Recast.Demo.Draw;
|
||||
using DotRecast.Recast.DemoTool;
|
||||
using DotRecast.Recast.DemoTool.Geom;
|
||||
using ImGuiNET;
|
||||
using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
||||
|
@ -46,8 +47,7 @@ public class CrowdTool : Tool
|
|||
private readonly CrowdProfilingTool profilingTool;
|
||||
private readonly CrowdAgentDebugInfo m_agentDebug = new CrowdAgentDebugInfo();
|
||||
|
||||
public static readonly int AGENT_MAX_TRAIL = 64;
|
||||
private readonly Dictionary<long, AgentTrail> m_trails = new();
|
||||
private readonly Dictionary<long, CrowdAgentTrail> m_trails = new();
|
||||
private RcVec3f m_targetPos;
|
||||
private long m_targetRef;
|
||||
private CrowdToolMode m_mode = CrowdToolMode.CREATE;
|
||||
|
@ -197,11 +197,11 @@ public class CrowdTool : Tool
|
|||
// Init trail
|
||||
if (!m_trails.TryGetValue(ag.idx, out var trail))
|
||||
{
|
||||
trail = new AgentTrail();
|
||||
trail = new CrowdAgentTrail();
|
||||
m_trails.Add(ag.idx, trail);
|
||||
}
|
||||
|
||||
for (int i = 0; i < AGENT_MAX_TRAIL; ++i)
|
||||
for (int i = 0; i < CrowdAgentTrail.AGENT_MAX_TRAIL; ++i)
|
||||
{
|
||||
trail.trail[i * 3] = p.x;
|
||||
trail.trail[i * 3 + 1] = p.y;
|
||||
|
@ -394,18 +394,18 @@ public class CrowdTool : Tool
|
|||
// Trail
|
||||
foreach (CrowdAgent ag in crowd.GetActiveAgents())
|
||||
{
|
||||
AgentTrail trail = m_trails[ag.idx];
|
||||
CrowdAgentTrail trail = m_trails[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 < AGENT_MAX_TRAIL - 1; ++j)
|
||||
for (int j = 0; j < CrowdAgentTrail.AGENT_MAX_TRAIL - 1; ++j)
|
||||
{
|
||||
int idx = (trail.htrail + AGENT_MAX_TRAIL - j) % AGENT_MAX_TRAIL;
|
||||
int idx = (trail.htrail + CrowdAgentTrail.AGENT_MAX_TRAIL - j) % CrowdAgentTrail.AGENT_MAX_TRAIL;
|
||||
int v = idx * 3;
|
||||
float a = 1 - j / (float)AGENT_MAX_TRAIL;
|
||||
float a = 1 - j / (float)CrowdAgentTrail.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;
|
||||
|
@ -650,9 +650,9 @@ public class CrowdTool : Tool
|
|||
// Update agent trails
|
||||
foreach (CrowdAgent ag in crowd.GetActiveAgents())
|
||||
{
|
||||
AgentTrail trail = m_trails[ag.idx];
|
||||
CrowdAgentTrail trail = m_trails[ag.idx];
|
||||
// Update agent movement trail.
|
||||
trail.htrail = (trail.htrail + 1) % AGENT_MAX_TRAIL;
|
||||
trail.htrail = (trail.htrail + 1) % CrowdAgentTrail.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;
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
using System.Collections.Immutable;
|
||||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class CrowdToolMode
|
||||
{
|
||||
public static readonly CrowdToolMode CREATE = new(0, "Create Agents");
|
||||
public static readonly CrowdToolMode MOVE_TARGET = new(1, "Move Target");
|
||||
public static readonly CrowdToolMode SELECT = new(2, "Select Agent");
|
||||
public static readonly CrowdToolMode TOGGLE_POLYS = new(3, "Toggle Polys");
|
||||
public static readonly CrowdToolMode PROFILING = new(4, "Profiling");
|
||||
|
||||
public static readonly ImmutableArray<CrowdToolMode> Values = ImmutableArray.Create(
|
||||
CREATE,
|
||||
MOVE_TARGET,
|
||||
SELECT,
|
||||
TOGGLE_POLYS,
|
||||
PROFILING
|
||||
);
|
||||
|
||||
public int Idx { get; }
|
||||
public string Label { get; }
|
||||
|
||||
private CrowdToolMode(int idx, string label)
|
||||
{
|
||||
Idx = idx;
|
||||
Label = label;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
recast4j copyright (c) 2020-2021 Piotr Piastucki piotr@jtilia.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class CrowdToolParams
|
||||
{
|
||||
public int m_expandSelectedDebugDraw = 1;
|
||||
public bool m_showCorners;
|
||||
public bool m_showCollisionSegments;
|
||||
public bool m_showPath;
|
||||
public bool m_showVO;
|
||||
public bool m_showOpt;
|
||||
public bool m_showNeis;
|
||||
|
||||
public int m_expandDebugDraw = 0;
|
||||
public bool m_showLabels;
|
||||
public bool m_showGrid;
|
||||
public bool m_showNodes;
|
||||
public bool m_showPerfGraph;
|
||||
public bool m_showDetailAll;
|
||||
|
||||
public int m_expandOptions = 1;
|
||||
public bool m_anticipateTurns = true;
|
||||
public bool m_optimizeVis = true;
|
||||
public bool m_optimizeTopo = true;
|
||||
public bool m_obstacleAvoidance = true;
|
||||
public int m_obstacleAvoidanceType = 3;
|
||||
public bool m_separation;
|
||||
public float m_separationWeight = 2f;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using DotRecast.Recast.DemoTool.Geom;
|
||||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public static class DemoObjImporter
|
||||
{
|
||||
public static DemoInputGeomProvider Load(byte[] chunk)
|
||||
{
|
||||
var context = ObjImporter.LoadContext(chunk);
|
||||
return new DemoInputGeomProvider(context.vertexPositions, context.meshFaces);
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ using DotRecast.Recast.Demo.Draw;
|
|||
using DotRecast.Recast.DemoTool.Geom;
|
||||
using DotRecast.Recast.Demo.Tools.Gizmos;
|
||||
using DotRecast.Recast.Demo.UI;
|
||||
using DotRecast.Recast.DemoTool;
|
||||
using ImGuiNET;
|
||||
using Silk.NET.OpenAL;
|
||||
using Silk.NET.Windowing;
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
using System.Collections.Immutable;
|
||||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class DynamicUpdateToolMode
|
||||
{
|
||||
public static readonly DynamicUpdateToolMode BUILD = new(0, "Build");
|
||||
public static readonly DynamicUpdateToolMode COLLIDERS = new(1, "Colliders");
|
||||
public static readonly DynamicUpdateToolMode RAYCAST = new(2, "Raycast");
|
||||
|
||||
public static readonly ImmutableArray<DynamicUpdateToolMode> Values = ImmutableArray.Create(
|
||||
BUILD, COLLIDERS, RAYCAST
|
||||
);
|
||||
|
||||
public int Idx { get; }
|
||||
public string Label { get; }
|
||||
|
||||
private DynamicUpdateToolMode(int idx, string label)
|
||||
{
|
||||
Idx = idx;
|
||||
Label = label;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ using Silk.NET.Windowing;
|
|||
using DotRecast.Detour.Extras.Jumplink;
|
||||
using DotRecast.Recast.DemoTool.Builder;
|
||||
using DotRecast.Recast.Demo.Draw;
|
||||
using DotRecast.Recast.DemoTool;
|
||||
using DotRecast.Recast.DemoTool.Geom;
|
||||
using ImGuiNET;
|
||||
using static DotRecast.Core.RcMath;
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
recast4j copyright (c) 2020-2021 Piotr Piastucki piotr@jtilia.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using DotRecast.Detour.Extras.Jumplink;
|
||||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class JumpLinkBuilderToolParams
|
||||
{
|
||||
public const int DRAW_WALKABLE_SURFACE = 1 << 0;
|
||||
public const int DRAW_WALKABLE_BORDER = 1 << 1;
|
||||
public const int DRAW_SELECTED_EDGE = 1 << 2;
|
||||
public const int DRAW_ANIM_TRAJECTORY = 1 << 3;
|
||||
public const int DRAW_LAND_SAMPLES = 1 << 4;
|
||||
public const int DRAW_COLLISION_SLICES = 1 << 5;
|
||||
public const int DRAW_ANNOTATIONS = 1 << 6;
|
||||
|
||||
public int flags = DRAW_WALKABLE_SURFACE | DRAW_WALKABLE_BORDER | DRAW_SELECTED_EDGE | DRAW_ANIM_TRAJECTORY | DRAW_LAND_SAMPLES | DRAW_ANNOTATIONS;
|
||||
public float groundTolerance = 0.3f;
|
||||
public float climbDownDistance = 0.4f;
|
||||
public float climbDownMaxHeight = 3.2f;
|
||||
public float climbDownMinHeight = 1.5f;
|
||||
public float edgeJumpEndDistance = 2f;
|
||||
public float edgeJumpHeight = 0.4f;
|
||||
public float edgeJumpDownMaxHeight = 2.5f;
|
||||
public float edgeJumpUpMaxHeight = 0.3f;
|
||||
public int buildTypes = JumpLinkType.EDGE_CLIMB_DOWN.Bit | JumpLinkType.EDGE_JUMP.Bit;
|
||||
}
|
|
@ -5,6 +5,7 @@ using DotRecast.Detour;
|
|||
using DotRecast.Detour.QueryResults;
|
||||
using DotRecast.Recast.DemoTool.Builder;
|
||||
using DotRecast.Recast.Demo.Draw;
|
||||
using DotRecast.Recast.DemoTool;
|
||||
using ImGuiNET;
|
||||
using static DotRecast.Core.RcMath;
|
||||
using static DotRecast.Recast.Demo.Draw.DebugDraw;
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
using System.Collections.Immutable;
|
||||
|
||||
namespace DotRecast.Recast.Demo.Tools;
|
||||
|
||||
public class TestNavmeshToolMode
|
||||
{
|
||||
public static readonly TestNavmeshToolMode PATHFIND_FOLLOW = new(0, "Pathfind Follow");
|
||||
public static readonly TestNavmeshToolMode PATHFIND_STRAIGHT = new(1, "Pathfind Straight");
|
||||
public static readonly TestNavmeshToolMode PATHFIND_SLICED = new(2, "Pathfind Sliced");
|
||||
public static readonly TestNavmeshToolMode DISTANCE_TO_WALL = new(3, "Distance to Wall");
|
||||
public static readonly TestNavmeshToolMode RAYCAST = new(4, "Raycast");
|
||||
public static readonly TestNavmeshToolMode FIND_POLYS_IN_CIRCLE = new(5, "Find Polys in Circle");
|
||||
public static readonly TestNavmeshToolMode FIND_POLYS_IN_SHAPE = new(6, "Find Polys in Shape");
|
||||
public static readonly TestNavmeshToolMode FIND_LOCAL_NEIGHBOURHOOD = new(7, "Find Local Neighbourhood");
|
||||
public static readonly TestNavmeshToolMode RANDOM_POINTS_IN_CIRCLE = new(8, "Random Points in Circle");
|
||||
|
||||
public static readonly ImmutableArray<TestNavmeshToolMode> Values = ImmutableArray.Create(
|
||||
PATHFIND_FOLLOW,
|
||||
PATHFIND_STRAIGHT,
|
||||
PATHFIND_SLICED,
|
||||
DISTANCE_TO_WALL,
|
||||
RAYCAST,
|
||||
FIND_POLYS_IN_CIRCLE,
|
||||
FIND_POLYS_IN_SHAPE,
|
||||
FIND_LOCAL_NEIGHBOURHOOD,
|
||||
RANDOM_POINTS_IN_CIRCLE
|
||||
);
|
||||
|
||||
|
||||
public int Idx { get; }
|
||||
public string Label { get; }
|
||||
|
||||
private TestNavmeshToolMode(int idx, string label)
|
||||
{
|
||||
Idx = idx;
|
||||
Label = label;
|
||||
}
|
||||
}
|
|
@ -26,6 +26,9 @@ namespace DotRecast.Recast.Demo.Tools;
|
|||
|
||||
public abstract class Tool
|
||||
{
|
||||
public abstract string GetName();
|
||||
public abstract void Layout();
|
||||
|
||||
public abstract void SetSample(Sample m_sample);
|
||||
|
||||
public abstract void HandleClick(RcVec3f s, RcVec3f p, bool shift);
|
||||
|
@ -34,10 +37,6 @@ public abstract class Tool
|
|||
|
||||
public abstract void HandleUpdate(float dt);
|
||||
|
||||
public abstract void Layout();
|
||||
|
||||
public abstract string GetName();
|
||||
|
||||
public virtual void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
|
||||
{
|
||||
// ...
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using DotRecast.Core;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
public class CrowdAgentData
|
||||
{
|
||||
public readonly CrowdAgentType type;
|
||||
public readonly RcVec3f home = new RcVec3f();
|
||||
|
||||
public CrowdAgentData(CrowdAgentType type, RcVec3f home)
|
||||
{
|
||||
this.type = type;
|
||||
this.home = home;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
public class CrowdAgentTrail
|
||||
{
|
||||
public const int AGENT_MAX_TRAIL = 64;
|
||||
public float[] trail = new float[AGENT_MAX_TRAIL * 3];
|
||||
public int htrail;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
public enum CrowdAgentType
|
||||
{
|
||||
VILLAGER,
|
||||
TRAVELLER,
|
||||
MOB,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using System.Collections.Immutable;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
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 CrowdToolMode PROFILING = new CrowdToolMode(4, "Profiling");
|
||||
|
||||
public static readonly ImmutableArray<CrowdToolMode> Values = ImmutableArray.Create(
|
||||
CREATE,
|
||||
MOVE_TARGET,
|
||||
SELECT,
|
||||
TOGGLE_POLYS,
|
||||
PROFILING
|
||||
);
|
||||
|
||||
public int Idx { get; }
|
||||
public string Label { get; }
|
||||
|
||||
private CrowdToolMode(int idx, string label)
|
||||
{
|
||||
Idx = idx;
|
||||
Label = label;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
recast4j copyright (c) 2020-2021 Piotr Piastucki piotr@jtilia.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
public class CrowdToolParams
|
||||
{
|
||||
public int m_expandSelectedDebugDraw = 1;
|
||||
public bool m_showCorners;
|
||||
public bool m_showCollisionSegments;
|
||||
public bool m_showPath;
|
||||
public bool m_showVO;
|
||||
public bool m_showOpt;
|
||||
public bool m_showNeis;
|
||||
|
||||
public int m_expandDebugDraw = 0;
|
||||
public bool m_showLabels;
|
||||
public bool m_showGrid;
|
||||
public bool m_showNodes;
|
||||
public bool m_showPerfGraph;
|
||||
public bool m_showDetailAll;
|
||||
|
||||
public int m_expandOptions = 1;
|
||||
public bool m_anticipateTurns = true;
|
||||
public bool m_optimizeVis = true;
|
||||
public bool m_optimizeTopo = true;
|
||||
public bool m_obstacleAvoidance = true;
|
||||
public int m_obstacleAvoidanceType = 3;
|
||||
public bool m_separation;
|
||||
public float m_separationWeight = 2f;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using DotRecast.Recast.DemoTool.Geom;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
public static class DemoObjImporter
|
||||
{
|
||||
public static DemoInputGeomProvider Load(byte[] chunk)
|
||||
{
|
||||
var context = ObjImporter.LoadContext(chunk);
|
||||
return new DemoInputGeomProvider(context.vertexPositions, context.meshFaces);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System.Collections.Immutable;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
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 ImmutableArray<DynamicUpdateToolMode> Values = ImmutableArray.Create(
|
||||
BUILD, COLLIDERS, RAYCAST
|
||||
);
|
||||
|
||||
public int Idx { get; }
|
||||
public string Label { get; }
|
||||
|
||||
private DynamicUpdateToolMode(int idx, string label)
|
||||
{
|
||||
Idx = idx;
|
||||
Label = label;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
recast4j copyright (c) 2020-2021 Piotr Piastucki piotr@jtilia.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using DotRecast.Detour.Extras.Jumplink;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
public class JumpLinkBuilderToolParams
|
||||
{
|
||||
public const int DRAW_WALKABLE_SURFACE = 1 << 0;
|
||||
public const int DRAW_WALKABLE_BORDER = 1 << 1;
|
||||
public const int DRAW_SELECTED_EDGE = 1 << 2;
|
||||
public const int DRAW_ANIM_TRAJECTORY = 1 << 3;
|
||||
public const int DRAW_LAND_SAMPLES = 1 << 4;
|
||||
public const int DRAW_COLLISION_SLICES = 1 << 5;
|
||||
public const int DRAW_ANNOTATIONS = 1 << 6;
|
||||
|
||||
public int flags = DRAW_WALKABLE_SURFACE | DRAW_WALKABLE_BORDER | DRAW_SELECTED_EDGE | DRAW_ANIM_TRAJECTORY | DRAW_LAND_SAMPLES | DRAW_ANNOTATIONS;
|
||||
public float groundTolerance = 0.3f;
|
||||
public float climbDownDistance = 0.4f;
|
||||
public float climbDownMaxHeight = 3.2f;
|
||||
public float climbDownMinHeight = 1.5f;
|
||||
public float edgeJumpEndDistance = 2f;
|
||||
public float edgeJumpHeight = 0.4f;
|
||||
public float edgeJumpDownMaxHeight = 2.5f;
|
||||
public float edgeJumpUpMaxHeight = 0.3f;
|
||||
public int buildTypes = JumpLinkType.EDGE_CLIMB_DOWN.Bit | JumpLinkType.EDGE_JUMP.Bit;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
using System.Collections.Immutable;
|
||||
|
||||
namespace DotRecast.Recast.DemoTool
|
||||
{
|
||||
public class TestNavmeshToolMode
|
||||
{
|
||||
public static readonly TestNavmeshToolMode PATHFIND_FOLLOW = new TestNavmeshToolMode(0, "Pathfind Follow");
|
||||
public static readonly TestNavmeshToolMode PATHFIND_STRAIGHT = new TestNavmeshToolMode(1, "Pathfind Straight");
|
||||
public static readonly TestNavmeshToolMode PATHFIND_SLICED = new TestNavmeshToolMode(2, "Pathfind Sliced");
|
||||
public static readonly TestNavmeshToolMode DISTANCE_TO_WALL = new TestNavmeshToolMode(3, "Distance to Wall");
|
||||
public static readonly TestNavmeshToolMode RAYCAST = new TestNavmeshToolMode(4, "Raycast");
|
||||
public static readonly TestNavmeshToolMode FIND_POLYS_IN_CIRCLE = new TestNavmeshToolMode(5, "Find Polys in Circle");
|
||||
public static readonly TestNavmeshToolMode FIND_POLYS_IN_SHAPE = new TestNavmeshToolMode(6, "Find Polys in Shape");
|
||||
public static readonly TestNavmeshToolMode FIND_LOCAL_NEIGHBOURHOOD = new TestNavmeshToolMode(7, "Find Local Neighbourhood");
|
||||
public static readonly TestNavmeshToolMode RANDOM_POINTS_IN_CIRCLE = new TestNavmeshToolMode(8, "Random Points in Circle");
|
||||
|
||||
public static readonly ImmutableArray<TestNavmeshToolMode> Values = ImmutableArray.Create(
|
||||
PATHFIND_FOLLOW,
|
||||
PATHFIND_STRAIGHT,
|
||||
PATHFIND_SLICED,
|
||||
DISTANCE_TO_WALL,
|
||||
RAYCAST,
|
||||
FIND_POLYS_IN_CIRCLE,
|
||||
FIND_POLYS_IN_SHAPE,
|
||||
FIND_LOCAL_NEIGHBOURHOOD,
|
||||
RANDOM_POINTS_IN_CIRCLE
|
||||
);
|
||||
|
||||
|
||||
public int Idx { get; }
|
||||
public string Label { get; }
|
||||
|
||||
private TestNavmeshToolMode(int idx, string label)
|
||||
{
|
||||
Idx = idx;
|
||||
Label = label;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue