mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
NavMesh rename from "Sample" to "Editor"
This commit only contains a rename, the logic has not been modified. Renamed everything named "Sample" to "Editor" as its no longer a sample.
This commit is contained in:
parent
edd1c62352
commit
28299b4c59
@ -89,8 +89,8 @@ static int pointInPoly(int nvert, const float* verts, const float* p)
|
||||
|
||||
|
||||
ConvexVolumeTool::ConvexVolumeTool() :
|
||||
m_sample(0),
|
||||
m_areaType(SAMPLE_POLYAREA_GROUND),
|
||||
m_editor(0),
|
||||
m_areaType(EDITOR_POLYAREA_GROUND),
|
||||
m_polyOffset(0.0f),
|
||||
m_boxHeight(650.0f),
|
||||
m_boxDescent(150.0f),
|
||||
@ -99,9 +99,9 @@ ConvexVolumeTool::ConvexVolumeTool() :
|
||||
{
|
||||
}
|
||||
|
||||
void ConvexVolumeTool::init(Sample* sample)
|
||||
void ConvexVolumeTool::init(Editor* editor)
|
||||
{
|
||||
m_sample = sample;
|
||||
m_editor = editor;
|
||||
}
|
||||
|
||||
void ConvexVolumeTool::reset()
|
||||
@ -120,18 +120,18 @@ void ConvexVolumeTool::handleMenu()
|
||||
|
||||
imguiLabel("Area Type");
|
||||
imguiIndent();
|
||||
if (imguiCheck("Ground", m_areaType == SAMPLE_POLYAREA_GROUND))
|
||||
m_areaType = SAMPLE_POLYAREA_GROUND;
|
||||
if (imguiCheck("Water", m_areaType == SAMPLE_POLYAREA_WATER))
|
||||
m_areaType = SAMPLE_POLYAREA_WATER;
|
||||
if (imguiCheck("Road", m_areaType == SAMPLE_POLYAREA_ROAD))
|
||||
m_areaType = SAMPLE_POLYAREA_ROAD;
|
||||
if (imguiCheck("Door", m_areaType == SAMPLE_POLYAREA_DOOR))
|
||||
m_areaType = SAMPLE_POLYAREA_DOOR;
|
||||
if (imguiCheck("Grass", m_areaType == SAMPLE_POLYAREA_GRASS))
|
||||
m_areaType = SAMPLE_POLYAREA_GRASS;
|
||||
if (imguiCheck("Jump", m_areaType == SAMPLE_POLYAREA_JUMP))
|
||||
m_areaType = SAMPLE_POLYAREA_JUMP;
|
||||
if (imguiCheck("Ground", m_areaType == EDITOR_POLYAREA_GROUND))
|
||||
m_areaType = EDITOR_POLYAREA_GROUND;
|
||||
if (imguiCheck("Water", m_areaType == EDITOR_POLYAREA_WATER))
|
||||
m_areaType = EDITOR_POLYAREA_WATER;
|
||||
if (imguiCheck("Road", m_areaType == EDITOR_POLYAREA_ROAD))
|
||||
m_areaType = EDITOR_POLYAREA_ROAD;
|
||||
if (imguiCheck("Door", m_areaType == EDITOR_POLYAREA_DOOR))
|
||||
m_areaType = EDITOR_POLYAREA_DOOR;
|
||||
if (imguiCheck("Grass", m_areaType == EDITOR_POLYAREA_GRASS))
|
||||
m_areaType = EDITOR_POLYAREA_GRASS;
|
||||
if (imguiCheck("Jump", m_areaType == EDITOR_POLYAREA_JUMP))
|
||||
m_areaType = EDITOR_POLYAREA_JUMP;
|
||||
imguiUnindent();
|
||||
|
||||
imguiSeparator();
|
||||
@ -145,8 +145,8 @@ void ConvexVolumeTool::handleMenu()
|
||||
|
||||
void ConvexVolumeTool::handleClick(const float* /*s*/, const float* p, bool shift)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
InputGeom* geom = m_sample->getInputGeom();
|
||||
if (!m_editor) return;
|
||||
InputGeom* geom = m_editor->getInputGeom();
|
||||
if (!geom) return;
|
||||
|
||||
if (shift)
|
||||
@ -240,7 +240,7 @@ void ConvexVolumeTool::handleUpdate(const float /*dt*/)
|
||||
|
||||
void ConvexVolumeTool::handleRender()
|
||||
{
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
duDebugDraw& dd = m_editor->getDebugDraw();
|
||||
|
||||
// Find height extent of the shape.
|
||||
float minh = FLT_MAX, maxh = 0;
|
||||
|
@ -81,7 +81,7 @@ static void getAgentBounds(const dtCrowdAgent* ag, float* bmin, float* bmax)
|
||||
}
|
||||
|
||||
CrowdToolState::CrowdToolState() :
|
||||
m_sample(0),
|
||||
m_editor(0),
|
||||
m_nav(0),
|
||||
m_crowd(0),
|
||||
m_targetRef(0),
|
||||
@ -126,25 +126,25 @@ CrowdToolState::~CrowdToolState()
|
||||
dtFreeObstacleAvoidanceDebugData(m_vod);
|
||||
}
|
||||
|
||||
void CrowdToolState::init(class Sample* sample)
|
||||
void CrowdToolState::init(class Editor* editor)
|
||||
{
|
||||
if (m_sample != sample)
|
||||
if (m_editor != editor)
|
||||
{
|
||||
m_sample = sample;
|
||||
m_editor = editor;
|
||||
}
|
||||
|
||||
dtNavMesh* nav = m_sample->getNavMesh();
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
dtNavMesh* nav = m_editor->getNavMesh();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
|
||||
if (nav && crowd && (m_nav != nav || m_crowd != crowd))
|
||||
{
|
||||
m_nav = nav;
|
||||
m_crowd = crowd;
|
||||
|
||||
crowd->init(MAX_AGENTS, m_sample->getAgentRadius(), nav);
|
||||
crowd->init(MAX_AGENTS, m_editor->getAgentRadius(), nav);
|
||||
|
||||
// Make polygons with 'disabled' flag invalid.
|
||||
crowd->getEditableFilter(0)->setExcludeFlags(SAMPLE_POLYFLAGS_DISABLED);
|
||||
crowd->getEditableFilter(0)->setExcludeFlags(EDITOR_POLYFLAGS_DISABLED);
|
||||
|
||||
// Setup local avoidance params to different qualities.
|
||||
dtObstacleAvoidanceParams params;
|
||||
@ -188,11 +188,11 @@ void CrowdToolState::reset()
|
||||
|
||||
void CrowdToolState::handleRender()
|
||||
{
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
const float rad = m_sample->getAgentRadius();
|
||||
duDebugDraw& dd = m_editor->getDebugDraw();
|
||||
const float rad = m_editor->getAgentRadius();
|
||||
|
||||
dtNavMesh* nav = m_sample->getNavMesh();
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
dtNavMesh* nav = m_editor->getNavMesh();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
if (!nav || !crowd)
|
||||
return;
|
||||
|
||||
@ -520,7 +520,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
|
||||
if (m_toolParams.m_showNodes)
|
||||
{
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
if (crowd && crowd->getPathQueue())
|
||||
{
|
||||
const dtNavMeshQuery* navquery = crowd->getPathQueue()->getNavQuery();
|
||||
@ -550,7 +550,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
|
||||
if (m_toolParams.m_showLabels)
|
||||
{
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
if (crowd)
|
||||
{
|
||||
for (int i = 0; i < crowd->getAgentCount(); ++i)
|
||||
@ -570,7 +570,7 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
}
|
||||
if (m_agentDebug.idx != -1)
|
||||
{
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
if (crowd)
|
||||
{
|
||||
for (int i = 0; i < crowd->getAgentCount(); i++)
|
||||
@ -625,13 +625,13 @@ void CrowdToolState::handleUpdate(const float dt)
|
||||
|
||||
void CrowdToolState::addAgent(const float* p)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
if (!m_editor) return;
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
|
||||
dtCrowdAgentParams ap;
|
||||
memset(&ap, 0, sizeof(ap));
|
||||
ap.radius = m_sample->getAgentRadius();
|
||||
ap.height = m_sample->getAgentHeight();
|
||||
ap.radius = m_editor->getAgentRadius();
|
||||
ap.height = m_editor->getAgentHeight();
|
||||
ap.maxAcceleration = m_toolParams.m_maxAcceleration;
|
||||
ap.maxSpeed = m_toolParams.m_maxSpeed;
|
||||
ap.collisionQueryRange = ap.radius * 50.0f;
|
||||
@ -666,8 +666,8 @@ void CrowdToolState::addAgent(const float* p)
|
||||
|
||||
void CrowdToolState::removeAgent(const int idx)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
if (!m_editor) return;
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
|
||||
crowd->removeAgent(idx);
|
||||
|
||||
@ -690,11 +690,11 @@ static void calcVel(float* vel, const float* pos, const float* tgt, const float
|
||||
|
||||
void CrowdToolState::setMoveTarget(const float* p, bool adjust)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
if (!m_editor) return;
|
||||
|
||||
// Find nearest point on navmesh and set move request to that location.
|
||||
dtNavMeshQuery* navquery = m_sample->getNavMeshQuery();
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
dtNavMeshQuery* navquery = m_editor->getNavMeshQuery();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
const dtQueryFilter* filter = crowd->getFilter(0);
|
||||
const float* halfExtents = crowd->getQueryExtents();
|
||||
|
||||
@ -746,8 +746,8 @@ void CrowdToolState::setMoveTarget(const float* p, bool adjust)
|
||||
|
||||
int CrowdToolState::hitTestAgents(const float* s, const float* p)
|
||||
{
|
||||
if (!m_sample) return -1;
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
if (!m_editor) return -1;
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
|
||||
int isel = -1;
|
||||
float tsel = FLT_MAX;
|
||||
@ -774,8 +774,8 @@ int CrowdToolState::hitTestAgents(const float* s, const float* p)
|
||||
|
||||
void CrowdToolState::updateAgentParams()
|
||||
{
|
||||
if (!m_sample) return;
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
if (!m_editor) return;
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
if (!crowd) return;
|
||||
|
||||
unsigned char updateFlags = 0;
|
||||
@ -814,9 +814,9 @@ void CrowdToolState::updateAgentParams()
|
||||
|
||||
void CrowdToolState::updateTick(const float dt)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
dtNavMesh* nav = m_sample->getNavMesh();
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
if (!m_editor) return;
|
||||
dtNavMesh* nav = m_editor->getNavMesh();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
if (!nav || !crowd) return;
|
||||
|
||||
TimeVal startTime = getPerfTime();
|
||||
@ -847,29 +847,29 @@ void CrowdToolState::updateTick(const float dt)
|
||||
|
||||
|
||||
CrowdTool::CrowdTool() :
|
||||
m_sample(0),
|
||||
m_editor(0),
|
||||
m_state(0),
|
||||
m_mode(TOOLMODE_CREATE)
|
||||
{
|
||||
}
|
||||
|
||||
void CrowdTool::init(Sample* sample)
|
||||
void CrowdTool::init(Editor* editor)
|
||||
{
|
||||
if (m_sample != sample)
|
||||
if (m_editor != editor)
|
||||
{
|
||||
m_sample = sample;
|
||||
m_editor = editor;
|
||||
}
|
||||
|
||||
if (!sample)
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
m_state = (CrowdToolState*)sample->getToolState(type());
|
||||
m_state = (CrowdToolState*)editor->getToolState(type());
|
||||
if (!m_state)
|
||||
{
|
||||
m_state = new CrowdToolState();
|
||||
sample->setToolState(type(), m_state);
|
||||
editor->setToolState(type(), m_state);
|
||||
}
|
||||
m_state->init(sample);
|
||||
m_state->init(editor);
|
||||
}
|
||||
|
||||
void CrowdTool::reset()
|
||||
@ -987,11 +987,11 @@ void CrowdTool::handleMenu()
|
||||
|
||||
void CrowdTool::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
if (!m_editor) return;
|
||||
if (!m_state) return;
|
||||
InputGeom* geom = m_sample->getInputGeom();
|
||||
InputGeom* geom = m_editor->getInputGeom();
|
||||
if (!geom) return;
|
||||
dtCrowd* crowd = m_sample->getCrowd();
|
||||
dtCrowd* crowd = m_editor->getCrowd();
|
||||
if (!crowd) return;
|
||||
|
||||
if (m_mode == TOOLMODE_CREATE)
|
||||
@ -1021,8 +1021,8 @@ void CrowdTool::handleClick(const float* s, const float* p, bool shift)
|
||||
}
|
||||
else if (m_mode == TOOLMODE_TOGGLE_POLYS)
|
||||
{
|
||||
dtNavMesh* nav = m_sample->getNavMesh();
|
||||
dtNavMeshQuery* navquery = m_sample->getNavMeshQuery();
|
||||
dtNavMesh* nav = m_editor->getNavMesh();
|
||||
dtNavMeshQuery* navquery = m_editor->getNavMeshQuery();
|
||||
if (nav && navquery)
|
||||
{
|
||||
dtQueryFilter filter;
|
||||
@ -1035,7 +1035,7 @@ void CrowdTool::handleClick(const float* s, const float* p, bool shift)
|
||||
unsigned short flags = 0;
|
||||
if (dtStatusSucceed(nav->getPolyFlags(ref, &flags)))
|
||||
{
|
||||
flags ^= SAMPLE_POLYFLAGS_DISABLED;
|
||||
flags ^= EDITOR_POLYFLAGS_DISABLED;
|
||||
nav->setPolyFlags(ref, flags);
|
||||
}
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
const ConvexVolume* vol = &m_volumes[i];
|
||||
unsigned int col;
|
||||
|
||||
if (vol->area == SAMPLE_POLYAREA_GROUND)
|
||||
if (vol->area == EDITOR_POLYAREA_GROUND)
|
||||
col = duRGBA(255, 0, 0, 128); // Use red for visibility (ground acts as deletion).
|
||||
else
|
||||
col = duTransCol(dd->areaToCol(vol->area), 64);
|
||||
@ -627,7 +627,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
const ConvexVolume* vol = &m_volumes[i];
|
||||
unsigned int col;
|
||||
|
||||
if (vol->area == SAMPLE_POLYAREA_GROUND)
|
||||
if (vol->area == EDITOR_POLYAREA_GROUND)
|
||||
col = duRGBA(255, 0, 0, 220);
|
||||
else
|
||||
col = duTransCol(dd->areaToCol(vol->area), 220);
|
||||
@ -652,7 +652,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
const ConvexVolume* vol = &m_volumes[i];
|
||||
unsigned int col;
|
||||
|
||||
if (vol->area == SAMPLE_POLYAREA_GROUND)
|
||||
if (vol->area == EDITOR_POLYAREA_GROUND)
|
||||
col = duRGBA(255, 0, 0, 220);
|
||||
else
|
||||
col = duDarkenCol(duTransCol(dd->areaToCol(vol->area), 220));
|
||||
|
@ -173,14 +173,14 @@ static void disableUnvisitedPolys(dtNavMesh* nav, NavmeshFlags* flags)
|
||||
{
|
||||
unsigned short f = 0;
|
||||
nav->getPolyFlags(ref, &f);
|
||||
nav->setPolyFlags(ref, f | SAMPLE_POLYFLAGS_DISABLED);
|
||||
nav->setPolyFlags(ref, f | EDITOR_POLYFLAGS_DISABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NavMeshPruneTool::NavMeshPruneTool() :
|
||||
m_sample(0),
|
||||
m_editor(0),
|
||||
m_flags(0),
|
||||
m_hitPosSet(false)
|
||||
{
|
||||
@ -191,9 +191,9 @@ NavMeshPruneTool::~NavMeshPruneTool()
|
||||
delete m_flags;
|
||||
}
|
||||
|
||||
void NavMeshPruneTool::init(Sample* sample)
|
||||
void NavMeshPruneTool::init(Editor* editor)
|
||||
{
|
||||
m_sample = sample;
|
||||
m_editor = editor;
|
||||
}
|
||||
|
||||
void NavMeshPruneTool::reset()
|
||||
@ -205,7 +205,7 @@ void NavMeshPruneTool::reset()
|
||||
|
||||
void NavMeshPruneTool::handleMenu()
|
||||
{
|
||||
dtNavMesh* nav = m_sample->getNavMesh();
|
||||
dtNavMesh* nav = m_editor->getNavMesh();
|
||||
if (!nav) return;
|
||||
if (!m_flags) return;
|
||||
|
||||
@ -227,12 +227,12 @@ void NavMeshPruneTool::handleClick(const float* s, const float* p, bool shift)
|
||||
rcIgnoreUnused(s);
|
||||
rcIgnoreUnused(shift);
|
||||
|
||||
if (!m_sample) return;
|
||||
InputGeom* geom = m_sample->getInputGeom();
|
||||
if (!m_editor) return;
|
||||
InputGeom* geom = m_editor->getInputGeom();
|
||||
if (!geom) return;
|
||||
dtNavMesh* nav = m_sample->getNavMesh();
|
||||
dtNavMesh* nav = m_editor->getNavMesh();
|
||||
if (!nav) return;
|
||||
dtNavMeshQuery* query = m_sample->getNavMeshQuery();
|
||||
dtNavMeshQuery* query = m_editor->getNavMeshQuery();
|
||||
if (!query) return;
|
||||
|
||||
dtVcopy(m_hitPos, p);
|
||||
@ -266,11 +266,11 @@ void NavMeshPruneTool::handleUpdate(const float /*dt*/)
|
||||
|
||||
void NavMeshPruneTool::handleRender()
|
||||
{
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
duDebugDraw& dd = m_editor->getDebugDraw();
|
||||
|
||||
if (m_hitPosSet)
|
||||
{
|
||||
const float s = m_sample->getAgentRadius();
|
||||
const float s = m_editor->getAgentRadius();
|
||||
const unsigned int col = duRGBA(255,255,255,255);
|
||||
dd.begin(DU_DRAW_LINES);
|
||||
dd.vertex(m_hitPos[0]-s,m_hitPos[1],m_hitPos[2], col);
|
||||
@ -282,7 +282,7 @@ void NavMeshPruneTool::handleRender()
|
||||
dd.end();
|
||||
}
|
||||
|
||||
const dtNavMesh* nav = m_sample->getNavMesh();
|
||||
const dtNavMesh* nav = m_editor->getNavMesh();
|
||||
if (m_flags && nav)
|
||||
{
|
||||
for (int i = 0; i < nav->getMaxTiles(); ++i)
|
||||
|
@ -199,7 +199,7 @@ static bool getSteerTarget(dtNavMeshQuery* navQuery, const float* startPos, cons
|
||||
|
||||
|
||||
NavMeshTesterTool::NavMeshTesterTool() :
|
||||
m_sample(0),
|
||||
m_editor(0),
|
||||
m_navMesh(0),
|
||||
m_navQuery(0),
|
||||
m_pathFindStatus(DT_FAILURE),
|
||||
@ -220,7 +220,7 @@ NavMeshTesterTool::NavMeshTesterTool() :
|
||||
m_pathIterPolyCount(0),
|
||||
m_steerPointCount(0)
|
||||
{
|
||||
m_filter.setIncludeFlags(SAMPLE_POLYFLAGS_ALL ^ SAMPLE_POLYFLAGS_DISABLED);
|
||||
m_filter.setIncludeFlags(EDITOR_POLYFLAGS_ALL ^ EDITOR_POLYFLAGS_DISABLED);
|
||||
m_filter.setExcludeFlags(0);
|
||||
|
||||
m_polyPickExt[0] = 2;
|
||||
@ -231,26 +231,26 @@ NavMeshTesterTool::NavMeshTesterTool() :
|
||||
m_randomRadius = 5.0f;
|
||||
}
|
||||
|
||||
void NavMeshTesterTool::init(Sample* sample)
|
||||
void NavMeshTesterTool::init(Editor* editor)
|
||||
{
|
||||
m_sample = sample;
|
||||
m_navMesh = sample->getNavMesh();
|
||||
m_navQuery = sample->getNavMeshQuery();
|
||||
m_editor = editor;
|
||||
m_navMesh = editor->getNavMesh();
|
||||
m_navQuery = editor->getNavMeshQuery();
|
||||
recalc();
|
||||
|
||||
if (m_navQuery)
|
||||
{
|
||||
// Change costs.
|
||||
m_filter.setAreaCost(SAMPLE_POLYAREA_GROUND, 1.0f);
|
||||
m_filter.setAreaCost(SAMPLE_POLYAREA_WATER, 10.0f);
|
||||
m_filter.setAreaCost(SAMPLE_POLYAREA_ROAD, 1.0f);
|
||||
m_filter.setAreaCost(SAMPLE_POLYAREA_DOOR, 1.0f);
|
||||
m_filter.setAreaCost(SAMPLE_POLYAREA_GRASS, 2.0f);
|
||||
m_filter.setAreaCost(SAMPLE_POLYAREA_JUMP, 1.5f);
|
||||
m_filter.setAreaCost(EDITOR_POLYAREA_GROUND, 1.0f);
|
||||
m_filter.setAreaCost(EDITOR_POLYAREA_WATER, 10.0f);
|
||||
m_filter.setAreaCost(EDITOR_POLYAREA_ROAD, 1.0f);
|
||||
m_filter.setAreaCost(EDITOR_POLYAREA_DOOR, 1.0f);
|
||||
m_filter.setAreaCost(EDITOR_POLYAREA_GRASS, 2.0f);
|
||||
m_filter.setAreaCost(EDITOR_POLYAREA_JUMP, 1.5f);
|
||||
}
|
||||
|
||||
m_neighbourhoodRadius = sample->getAgentRadius() * 20.0f;
|
||||
m_randomRadius = sample->getAgentRadius() * 30.0f;
|
||||
m_neighbourhoodRadius = editor->getAgentRadius() * 20.0f;
|
||||
m_randomRadius = editor->getAgentRadius() * 30.0f;
|
||||
}
|
||||
|
||||
void NavMeshTesterTool::handleMenu()
|
||||
@ -398,24 +398,24 @@ void NavMeshTesterTool::handleMenu()
|
||||
imguiLabel("Include Flags");
|
||||
|
||||
imguiIndent();
|
||||
if (imguiCheck("Walk", (m_filter.getIncludeFlags() & SAMPLE_POLYFLAGS_WALK) != 0))
|
||||
if (imguiCheck("Walk", (m_filter.getIncludeFlags() & EDITOR_POLYFLAGS_WALK) != 0))
|
||||
{
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ SAMPLE_POLYFLAGS_WALK);
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ EDITOR_POLYFLAGS_WALK);
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Swim", (m_filter.getIncludeFlags() & SAMPLE_POLYFLAGS_SWIM) != 0))
|
||||
if (imguiCheck("Swim", (m_filter.getIncludeFlags() & EDITOR_POLYFLAGS_SWIM) != 0))
|
||||
{
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ SAMPLE_POLYFLAGS_SWIM);
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ EDITOR_POLYFLAGS_SWIM);
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Door", (m_filter.getIncludeFlags() & SAMPLE_POLYFLAGS_DOOR) != 0))
|
||||
if (imguiCheck("Door", (m_filter.getIncludeFlags() & EDITOR_POLYFLAGS_DOOR) != 0))
|
||||
{
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ SAMPLE_POLYFLAGS_DOOR);
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ EDITOR_POLYFLAGS_DOOR);
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Jump", (m_filter.getIncludeFlags() & SAMPLE_POLYFLAGS_JUMP) != 0))
|
||||
if (imguiCheck("Jump", (m_filter.getIncludeFlags() & EDITOR_POLYFLAGS_JUMP) != 0))
|
||||
{
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ SAMPLE_POLYFLAGS_JUMP);
|
||||
m_filter.setIncludeFlags(m_filter.getIncludeFlags() ^ EDITOR_POLYFLAGS_JUMP);
|
||||
recalc();
|
||||
}
|
||||
imguiUnindent();
|
||||
@ -424,24 +424,24 @@ void NavMeshTesterTool::handleMenu()
|
||||
imguiLabel("Exclude Flags");
|
||||
|
||||
imguiIndent();
|
||||
if (imguiCheck("Walk", (m_filter.getExcludeFlags() & SAMPLE_POLYFLAGS_WALK) != 0))
|
||||
if (imguiCheck("Walk", (m_filter.getExcludeFlags() & EDITOR_POLYFLAGS_WALK) != 0))
|
||||
{
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ SAMPLE_POLYFLAGS_WALK);
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ EDITOR_POLYFLAGS_WALK);
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Swim", (m_filter.getExcludeFlags() & SAMPLE_POLYFLAGS_SWIM) != 0))
|
||||
if (imguiCheck("Swim", (m_filter.getExcludeFlags() & EDITOR_POLYFLAGS_SWIM) != 0))
|
||||
{
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ SAMPLE_POLYFLAGS_SWIM);
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ EDITOR_POLYFLAGS_SWIM);
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Door", (m_filter.getExcludeFlags() & SAMPLE_POLYFLAGS_DOOR) != 0))
|
||||
if (imguiCheck("Door", (m_filter.getExcludeFlags() & EDITOR_POLYFLAGS_DOOR) != 0))
|
||||
{
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ SAMPLE_POLYFLAGS_DOOR);
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ EDITOR_POLYFLAGS_DOOR);
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Jump", (m_filter.getExcludeFlags() & SAMPLE_POLYFLAGS_JUMP) != 0))
|
||||
if (imguiCheck("Jump", (m_filter.getExcludeFlags() & EDITOR_POLYFLAGS_JUMP) != 0))
|
||||
{
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ SAMPLE_POLYFLAGS_JUMP);
|
||||
m_filter.setExcludeFlags(m_filter.getExcludeFlags() ^ EDITOR_POLYFLAGS_JUMP);
|
||||
recalc();
|
||||
}
|
||||
imguiUnindent();
|
||||
@ -949,7 +949,7 @@ void NavMeshTesterTool::recalc()
|
||||
{
|
||||
const float nx = -(m_epos[1] - m_spos[1])*0.25f;
|
||||
const float ny = (m_epos[0] - m_spos[0])*0.25f;
|
||||
const float agentHeight = m_sample ? m_sample->getAgentHeight() : 0;
|
||||
const float agentHeight = m_editor ? m_editor->getAgentHeight() : 0;
|
||||
|
||||
m_queryPoly[0] = m_spos[0] + nx*1.2f;
|
||||
m_queryPoly[1] = m_spos[1] + ny*1.2f;
|
||||
@ -1023,15 +1023,15 @@ static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center)
|
||||
|
||||
void NavMeshTesterTool::handleRender()
|
||||
{
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
duDebugDraw& dd = m_editor->getDebugDraw();
|
||||
|
||||
static const unsigned int startCol = duRGBA(128,25,0,192);
|
||||
static const unsigned int endCol = duRGBA(51,102,0,129);
|
||||
static const unsigned int pathCol = duRGBA(0,0,0,64);
|
||||
|
||||
const float agentRadius = m_sample->getAgentRadius();
|
||||
const float agentHeight = m_sample->getAgentHeight();
|
||||
const float agentClimb = m_sample->getAgentClimb();
|
||||
const float agentRadius = m_editor->getAgentRadius();
|
||||
const float agentHeight = m_editor->getAgentHeight();
|
||||
const float agentClimb = m_editor->getAgentClimb();
|
||||
|
||||
dd.depthMask(false);
|
||||
if (m_sposSet)
|
||||
@ -1380,7 +1380,7 @@ void NavMeshTesterTool::handleRenderOverlay(double* proj, double* model, int* vi
|
||||
|
||||
void NavMeshTesterTool::drawAgent(const float* pos, float r, float h, float c, const unsigned int col)
|
||||
{
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
duDebugDraw& dd = m_editor->getDebugDraw();
|
||||
|
||||
dd.depthMask(false);
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#endif
|
||||
|
||||
OffMeshConnectionTool::OffMeshConnectionTool() :
|
||||
m_sample(0),
|
||||
m_editor(0),
|
||||
m_hitPosSet(0),
|
||||
m_bidir(true),
|
||||
m_oldFlags(0)
|
||||
@ -38,19 +38,19 @@ OffMeshConnectionTool::OffMeshConnectionTool() :
|
||||
|
||||
OffMeshConnectionTool::~OffMeshConnectionTool()
|
||||
{
|
||||
if (m_sample)
|
||||
if (m_editor)
|
||||
{
|
||||
m_sample->setNavMeshDrawFlags(m_oldFlags);
|
||||
m_editor->setNavMeshDrawFlags(m_oldFlags);
|
||||
}
|
||||
}
|
||||
|
||||
void OffMeshConnectionTool::init(Sample* sample)
|
||||
void OffMeshConnectionTool::init(Editor* editor)
|
||||
{
|
||||
if (m_sample != sample)
|
||||
if (m_editor != editor)
|
||||
{
|
||||
m_sample = sample;
|
||||
m_oldFlags = m_sample->getNavMeshDrawFlags();
|
||||
m_sample->setNavMeshDrawFlags(m_oldFlags & ~DU_DRAWNAVMESH_OFFMESHCONS);
|
||||
m_editor = editor;
|
||||
m_oldFlags = m_editor->getNavMeshDrawFlags();
|
||||
m_editor->setNavMeshDrawFlags(m_oldFlags & ~DU_DRAWNAVMESH_OFFMESHCONS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +69,8 @@ void OffMeshConnectionTool::handleMenu()
|
||||
|
||||
void OffMeshConnectionTool::handleClick(const float* /*s*/, const float* p, bool shift)
|
||||
{
|
||||
if (!m_sample) return;
|
||||
InputGeom* geom = m_sample->getInputGeom();
|
||||
if (!m_editor) return;
|
||||
InputGeom* geom = m_editor->getInputGeom();
|
||||
if (!geom) return;
|
||||
|
||||
if (shift)
|
||||
@ -92,7 +92,7 @@ void OffMeshConnectionTool::handleClick(const float* /*s*/, const float* p, bool
|
||||
}
|
||||
// If end point close enough, delete it.
|
||||
if (nearestIndex != -1 &&
|
||||
sqrtf(nearestDist) < m_sample->getAgentRadius())
|
||||
sqrtf(nearestDist) < m_editor->getAgentRadius())
|
||||
{
|
||||
geom->deleteOffMeshConnection(nearestIndex);
|
||||
}
|
||||
@ -107,9 +107,9 @@ void OffMeshConnectionTool::handleClick(const float* /*s*/, const float* p, bool
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned char area = SAMPLE_POLYAREA_JUMP;
|
||||
const unsigned short flags = SAMPLE_POLYFLAGS_JUMP;
|
||||
geom->addOffMeshConnection(m_hitPos, p, m_sample->getAgentRadius(), m_bidir ? 1 : 0, area, flags);
|
||||
const unsigned char area = EDITOR_POLYAREA_JUMP;
|
||||
const unsigned short flags = EDITOR_POLYFLAGS_JUMP;
|
||||
geom->addOffMeshConnection(m_hitPos, p, m_editor->getAgentRadius(), m_bidir ? 1 : 0, area, flags);
|
||||
m_hitPosSet = false;
|
||||
}
|
||||
}
|
||||
@ -129,13 +129,13 @@ void OffMeshConnectionTool::handleUpdate(const float /*dt*/)
|
||||
|
||||
void OffMeshConnectionTool::handleRender()
|
||||
{
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
const float s = m_sample->getAgentRadius();
|
||||
duDebugDraw& dd = m_editor->getDebugDraw();
|
||||
const float s = m_editor->getAgentRadius();
|
||||
|
||||
if (m_hitPosSet)
|
||||
duDebugDrawCross(&dd, m_hitPos[0],m_hitPos[1],m_hitPos[2]+0.1f, s, duRGBA(0,0,0,128), 2.0f);
|
||||
|
||||
InputGeom* geom = m_sample->getInputGeom();
|
||||
InputGeom* geom = m_editor->getInputGeom();
|
||||
if (geom)
|
||||
geom->drawOffMeshConnections(&dd, true);
|
||||
}
|
||||
|
@ -28,28 +28,28 @@
|
||||
#include "NavEditor/Include/InputGeom.h"
|
||||
#include "NavEditor/Include/Sample.h"
|
||||
|
||||
unsigned int SampleDebugDraw::areaToCol(unsigned int area)
|
||||
unsigned int EditorDebugDraw::areaToCol(unsigned int area)
|
||||
{
|
||||
switch(area)
|
||||
{
|
||||
// Ground (0) : light blue
|
||||
case SAMPLE_POLYAREA_GROUND: return duRGBA(0, 135, 255, 255);
|
||||
case EDITOR_POLYAREA_GROUND: return duRGBA(0, 135, 255, 255);
|
||||
// Water : blue
|
||||
case SAMPLE_POLYAREA_WATER: return duRGBA(0, 0, 255, 255);
|
||||
case EDITOR_POLYAREA_WATER: return duRGBA(0, 0, 255, 255);
|
||||
// Road : brown
|
||||
case SAMPLE_POLYAREA_ROAD: return duRGBA(50, 20, 12, 255);
|
||||
case EDITOR_POLYAREA_ROAD: return duRGBA(50, 20, 12, 255);
|
||||
// Door : cyan
|
||||
case SAMPLE_POLYAREA_DOOR: return duRGBA(0, 255, 255, 255);
|
||||
case EDITOR_POLYAREA_DOOR: return duRGBA(0, 255, 255, 255);
|
||||
// Grass : green
|
||||
case SAMPLE_POLYAREA_GRASS: return duRGBA(0, 255, 0, 255);
|
||||
case EDITOR_POLYAREA_GRASS: return duRGBA(0, 255, 0, 255);
|
||||
// Jump : yellow
|
||||
case SAMPLE_POLYAREA_JUMP: return duRGBA(255, 255, 0, 255);
|
||||
case EDITOR_POLYAREA_JUMP: return duRGBA(255, 255, 0, 255);
|
||||
// Unexpected : red
|
||||
default: return duRGBA(255, 0, 0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
Sample::Sample() :
|
||||
Editor::Editor() :
|
||||
m_geom(0),
|
||||
m_navMesh(0),
|
||||
m_navQuery(0),
|
||||
@ -69,7 +69,7 @@ Sample::Sample() :
|
||||
m_toolStates[i] = 0;
|
||||
}
|
||||
|
||||
Sample::~Sample()
|
||||
Editor::~Editor()
|
||||
{
|
||||
dtFreeNavMeshQuery(m_navQuery);
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
@ -79,7 +79,7 @@ Sample::~Sample()
|
||||
delete m_toolStates[i];
|
||||
}
|
||||
|
||||
void Sample::setTool(SampleTool* tool)
|
||||
void Editor::setTool(EditorTool* tool)
|
||||
{
|
||||
delete m_tool;
|
||||
m_tool = tool;
|
||||
@ -87,19 +87,19 @@ void Sample::setTool(SampleTool* tool)
|
||||
m_tool->init(this);
|
||||
}
|
||||
|
||||
void Sample::handleSettings()
|
||||
void Editor::handleSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample::handleTools()
|
||||
void Editor::handleTools()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample::handleDebugMode()
|
||||
void Editor::handleDebugMode()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample::handleRender()
|
||||
void Editor::handleRender()
|
||||
{
|
||||
if (!m_geom)
|
||||
return;
|
||||
@ -113,11 +113,11 @@ void Sample::handleRender()
|
||||
duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
}
|
||||
|
||||
void Sample::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/)
|
||||
void Editor::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/)
|
||||
{
|
||||
}
|
||||
|
||||
void Sample::handleMeshChanged(InputGeom* geom)
|
||||
void Editor::handleMeshChanged(InputGeom* geom)
|
||||
{
|
||||
m_geom = geom;
|
||||
|
||||
@ -141,7 +141,7 @@ void Sample::handleMeshChanged(InputGeom* geom)
|
||||
}
|
||||
}
|
||||
|
||||
void Sample::collectSettings(BuildSettings& settings)
|
||||
void Editor::collectSettings(BuildSettings& settings)
|
||||
{
|
||||
settings.cellSize = m_cellSize;
|
||||
settings.cellHeight = m_cellHeight;
|
||||
@ -160,7 +160,7 @@ void Sample::collectSettings(BuildSettings& settings)
|
||||
}
|
||||
|
||||
|
||||
void Sample::resetCommonSettings()
|
||||
void Editor::resetCommonSettings()
|
||||
{
|
||||
m_cellSize = 15.0f;
|
||||
m_cellHeight = 5.85f;
|
||||
@ -175,10 +175,10 @@ void Sample::resetCommonSettings()
|
||||
m_vertsPerPoly = 6.0f;
|
||||
m_detailSampleDist = 6.0f;
|
||||
m_detailSampleMaxError = 1.0f;
|
||||
m_partitionType = SAMPLE_PARTITION_WATERSHED;
|
||||
m_partitionType = EDITOR_PARTITION_WATERSHED;
|
||||
m_reachabilityTableCount = 4;
|
||||
}
|
||||
void Sample::handleCommonSettings()
|
||||
void Editor::handleCommonSettings()
|
||||
{
|
||||
imguiLabel("Rasterization");
|
||||
imguiSlider("Cell Size", &m_cellSize, 0.1f, 100.0f, 0.01f);
|
||||
@ -209,12 +209,12 @@ void Sample::handleCommonSettings()
|
||||
|
||||
imguiSeparator();
|
||||
imguiLabel("Partitioning");
|
||||
if (imguiCheck("Watershed", m_partitionType == SAMPLE_PARTITION_WATERSHED))
|
||||
m_partitionType = SAMPLE_PARTITION_WATERSHED;
|
||||
if (imguiCheck("Monotone", m_partitionType == SAMPLE_PARTITION_MONOTONE))
|
||||
m_partitionType = SAMPLE_PARTITION_MONOTONE;
|
||||
if (imguiCheck("Layers", m_partitionType == SAMPLE_PARTITION_LAYERS))
|
||||
m_partitionType = SAMPLE_PARTITION_LAYERS;
|
||||
if (imguiCheck("Watershed", m_partitionType == EDITOR_PARTITION_WATERSHED))
|
||||
m_partitionType = EDITOR_PARTITION_WATERSHED;
|
||||
if (imguiCheck("Monotone", m_partitionType == EDITOR_PARTITION_MONOTONE))
|
||||
m_partitionType = EDITOR_PARTITION_MONOTONE;
|
||||
if (imguiCheck("Layers", m_partitionType == EDITOR_PARTITION_LAYERS))
|
||||
m_partitionType = EDITOR_PARTITION_LAYERS;
|
||||
|
||||
imguiSeparator();
|
||||
imguiLabel("Filtering");
|
||||
@ -239,30 +239,30 @@ void Sample::handleCommonSettings()
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
void Sample::handleClick(const float* s, const float* p, bool shift)
|
||||
void Editor::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleClick(s, p, shift);
|
||||
}
|
||||
|
||||
void Sample::handleToggle()
|
||||
void Editor::handleToggle()
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleToggle();
|
||||
}
|
||||
|
||||
void Sample::handleStep()
|
||||
void Editor::handleStep()
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleStep();
|
||||
}
|
||||
|
||||
bool Sample::handleBuild()
|
||||
bool Editor::handleBuild()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Sample::handleUpdate(const float dt)
|
||||
void Editor::handleUpdate(const float dt)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleUpdate(dt);
|
||||
@ -270,7 +270,7 @@ void Sample::handleUpdate(const float dt)
|
||||
}
|
||||
|
||||
|
||||
void Sample::updateToolStates(const float dt)
|
||||
void Editor::updateToolStates(const float dt)
|
||||
{
|
||||
for (int i = 0; i < MAX_TOOLS; i++)
|
||||
{
|
||||
@ -279,16 +279,16 @@ void Sample::updateToolStates(const float dt)
|
||||
}
|
||||
}
|
||||
|
||||
void Sample::initToolStates(Sample* sample)
|
||||
void Editor::initToolStates(Editor* editor)
|
||||
{
|
||||
for (int i = 0; i < MAX_TOOLS; i++)
|
||||
{
|
||||
if (m_toolStates[i])
|
||||
m_toolStates[i]->init(sample);
|
||||
m_toolStates[i]->init(editor);
|
||||
}
|
||||
}
|
||||
|
||||
void Sample::resetToolStates()
|
||||
void Editor::resetToolStates()
|
||||
{
|
||||
for (int i = 0; i < MAX_TOOLS; i++)
|
||||
{
|
||||
@ -297,7 +297,7 @@ void Sample::resetToolStates()
|
||||
}
|
||||
}
|
||||
|
||||
void Sample::renderToolStates()
|
||||
void Editor::renderToolStates()
|
||||
{
|
||||
for (int i = 0; i < MAX_TOOLS; i++)
|
||||
{
|
||||
@ -306,7 +306,7 @@ void Sample::renderToolStates()
|
||||
}
|
||||
}
|
||||
|
||||
void Sample::renderOverlayToolStates(double* proj, double* model, int* view)
|
||||
void Editor::renderOverlayToolStates(double* proj, double* model, int* view)
|
||||
{
|
||||
for (int i = 0; i < MAX_TOOLS; i++)
|
||||
{
|
||||
@ -315,7 +315,7 @@ void Sample::renderOverlayToolStates(double* proj, double* model, int* view)
|
||||
}
|
||||
}
|
||||
|
||||
dtNavMesh* Sample::loadAll(std::string path)
|
||||
dtNavMesh* Editor::loadAll(std::string path)
|
||||
{
|
||||
std::filesystem::path p = "..\\maps\\navmesh\\";
|
||||
if (std::filesystem::is_directory(p))
|
||||
@ -401,7 +401,7 @@ dtNavMesh* Sample::loadAll(std::string path)
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void Sample::saveAll(std::string path, dtNavMesh* mesh)
|
||||
void Editor::saveAll(std::string path, dtNavMesh* mesh)
|
||||
{
|
||||
if (!mesh)
|
||||
return;
|
||||
|
@ -40,7 +40,7 @@ static int loadBin(const char* path, unsigned char** data)
|
||||
}
|
||||
*/
|
||||
|
||||
Sample_Debug::Sample_Debug() :
|
||||
Editor_Debug::Editor_Debug() :
|
||||
m_chf(0),
|
||||
m_cset(0),
|
||||
m_pmesh(0)
|
||||
@ -161,26 +161,26 @@ Sample_Debug::Sample_Debug() :
|
||||
|
||||
}
|
||||
|
||||
Sample_Debug::~Sample_Debug()
|
||||
Editor_Debug::~Editor_Debug()
|
||||
{
|
||||
rcFreeCompactHeightfield(m_chf);
|
||||
rcFreeContourSet(m_cset);
|
||||
rcFreePolyMesh(m_pmesh);
|
||||
}
|
||||
|
||||
void Sample_Debug::handleSettings()
|
||||
void Editor_Debug::handleSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleTools()
|
||||
void Editor_Debug::handleTools()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleDebugMode()
|
||||
void Editor_Debug::handleDebugMode()
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleRender()
|
||||
void Editor_Debug::handleRender()
|
||||
{
|
||||
if (m_chf)
|
||||
{
|
||||
@ -309,16 +309,16 @@ void Sample_Debug::handleRender()
|
||||
dd.depthMask(true);*/
|
||||
}
|
||||
|
||||
void Sample_Debug::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/)
|
||||
void Editor_Debug::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/)
|
||||
{
|
||||
}
|
||||
|
||||
void Sample_Debug::handleMeshChanged(InputGeom* geom)
|
||||
void Editor_Debug::handleMeshChanged(InputGeom* geom)
|
||||
{
|
||||
m_geom = geom;
|
||||
}
|
||||
|
||||
const float* Sample_Debug::getBoundsMin()
|
||||
const float* Editor_Debug::getBoundsMin()
|
||||
{
|
||||
if (m_cset)
|
||||
return m_cset->bmin;
|
||||
@ -329,7 +329,7 @@ const float* Sample_Debug::getBoundsMin()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const float* Sample_Debug::getBoundsMax()
|
||||
const float* Editor_Debug::getBoundsMax()
|
||||
{
|
||||
if (m_cset)
|
||||
return m_cset->bmax;
|
||||
@ -340,19 +340,19 @@ const float* Sample_Debug::getBoundsMax()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sample_Debug::handleClick(const float* s, const float* p, bool shift)
|
||||
void Editor_Debug::handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleClick(s, p, shift);
|
||||
}
|
||||
|
||||
void Sample_Debug::handleToggle()
|
||||
void Editor_Debug::handleToggle()
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleToggle();
|
||||
}
|
||||
|
||||
bool Sample_Debug::handleBuild()
|
||||
bool Editor_Debug::handleBuild()
|
||||
{
|
||||
|
||||
if (m_chf)
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "NavEditor/Include/CrowdTool.h"
|
||||
#include "NavEditor/Include/InputGeom.h"
|
||||
#include "NavEditor/Include/Sample.h"
|
||||
#include "NavEditor/Include/Sample_TempObstacles.h"
|
||||
#include "NavEditor/Include/Editor_TempObstacles.h"
|
||||
|
||||
|
||||
// This value specifies how many layers (or "floors") each navmesh tile is expected to have.
|
||||
@ -254,7 +254,7 @@ struct RasterizationContext
|
||||
int ntiles;
|
||||
};
|
||||
|
||||
int Sample_TempObstacles::rasterizeTileLayers(
|
||||
int Editor_TempObstacles::rasterizeTileLayers(
|
||||
const int tx, const int ty,
|
||||
const rcConfig& cfg,
|
||||
TileCacheData* tiles,
|
||||
@ -652,9 +652,9 @@ void drawObstacles(duDebugDraw* dd, const dtTileCache* tc)
|
||||
|
||||
|
||||
|
||||
class TempObstacleHilightTool : public SampleTool
|
||||
class TempObstacleHilightTool : public EditorTool
|
||||
{
|
||||
Sample_TempObstacles* m_sample;
|
||||
Editor_TempObstacles* ;
|
||||
float m_hitPos[3];
|
||||
bool m_hitPosSet;
|
||||
int m_drawType;
|
||||
@ -662,7 +662,7 @@ class TempObstacleHilightTool : public SampleTool
|
||||
public:
|
||||
|
||||
TempObstacleHilightTool() :
|
||||
m_sample(0),
|
||||
(0),
|
||||
m_hitPosSet(false),
|
||||
m_drawType(DRAWDETAIL_AREAS)
|
||||
{
|
||||
@ -677,7 +677,7 @@ public:
|
||||
|
||||
virtual void init(Sample* sample)
|
||||
{
|
||||
m_sample = (Sample_TempObstacles*)sample;
|
||||
= (Editor_TempObstacles*)sample;
|
||||
}
|
||||
|
||||
virtual void reset() {}
|
||||
@ -711,9 +711,9 @@ public:
|
||||
|
||||
virtual void handleRender()
|
||||
{
|
||||
if (m_hitPosSet && m_sample)
|
||||
if (m_hitPosSet && )
|
||||
{
|
||||
const float s = m_sample->getAgentRadius();
|
||||
const float s = ->getAgentRadius();
|
||||
glColor4ub(0,0,0,128);
|
||||
glLineWidth(2.0f);
|
||||
glBegin(GL_LINES);
|
||||
@ -727,8 +727,8 @@ public:
|
||||
glLineWidth(1.0f);
|
||||
|
||||
int tx=0, ty=0;
|
||||
m_sample->getTilePos(m_hitPos, tx, ty);
|
||||
m_sample->renderCachedTile(tx,ty,m_drawType);
|
||||
->getTilePos(m_hitPos, tx, ty);
|
||||
->renderCachedTile(tx,ty,m_drawType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -736,24 +736,24 @@ public:
|
||||
{
|
||||
if (m_hitPosSet)
|
||||
{
|
||||
if (m_sample)
|
||||
if ()
|
||||
{
|
||||
int tx=0, ty=0;
|
||||
m_sample->getTilePos(m_hitPos, tx, ty);
|
||||
m_sample->renderCachedTileOverlay(tx,ty,proj,model,view);
|
||||
->getTilePos(m_hitPos, tx, ty);
|
||||
->renderCachedTileOverlay(tx,ty,proj,model,view);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TempObstacleCreateTool : public SampleTool
|
||||
class TempObstacleCreateTool : public EditorTool
|
||||
{
|
||||
Sample_TempObstacles* m_sample;
|
||||
Editor_TempObstacles* ;
|
||||
|
||||
public:
|
||||
|
||||
TempObstacleCreateTool() : m_sample(0)
|
||||
TempObstacleCreateTool() : (0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -765,7 +765,7 @@ public:
|
||||
|
||||
virtual void init(Sample* sample)
|
||||
{
|
||||
m_sample = (Sample_TempObstacles*)sample;
|
||||
= (Editor_TempObstacles*)sample;
|
||||
}
|
||||
|
||||
virtual void reset() {}
|
||||
@ -775,7 +775,7 @@ public:
|
||||
imguiLabel("Create Temp Obstacles");
|
||||
|
||||
if (imguiButton("Remove All"))
|
||||
m_sample->clearAllTempObstacles();
|
||||
->clearAllTempObstacles();
|
||||
|
||||
imguiSeparator();
|
||||
|
||||
@ -785,12 +785,12 @@ public:
|
||||
|
||||
virtual void handleClick(const float* s, const float* p, bool shift)
|
||||
{
|
||||
if (m_sample)
|
||||
if ()
|
||||
{
|
||||
if (shift)
|
||||
m_sample->removeTempObstacle(s,p);
|
||||
->removeTempObstacle(s,p);
|
||||
else
|
||||
m_sample->addTempObstacle(p);
|
||||
->addTempObstacle(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -805,7 +805,7 @@ public:
|
||||
|
||||
|
||||
|
||||
Sample_TempObstacles::Sample_TempObstacles() :
|
||||
Editor_TempObstacles::Editor_TempObstacles() :
|
||||
m_keepInterResults(false),
|
||||
m_tileCache(0),
|
||||
m_cacheBuildTimeMs(0),
|
||||
@ -827,14 +827,14 @@ Sample_TempObstacles::Sample_TempObstacles() :
|
||||
setTool(new TempObstacleCreateTool);
|
||||
}
|
||||
|
||||
Sample_TempObstacles::~Sample_TempObstacles()
|
||||
Editor_TempObstacles::~Editor_TempObstacles()
|
||||
{
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
m_navMesh = 0;
|
||||
dtFreeTileCache(m_tileCache);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::handleSettings()
|
||||
void Editor_TempObstacles::handleSettings()
|
||||
{
|
||||
Sample::handleCommonSettings();
|
||||
|
||||
@ -919,7 +919,7 @@ void Sample_TempObstacles::handleSettings()
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::handleTools()
|
||||
void Editor_TempObstacles::handleTools()
|
||||
{
|
||||
int type = !m_tool ? TOOL_NONE : m_tool->type();
|
||||
|
||||
@ -958,7 +958,7 @@ void Sample_TempObstacles::handleTools()
|
||||
imguiUnindent();
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::handleDebugMode()
|
||||
void Editor_TempObstacles::handleDebugMode()
|
||||
{
|
||||
// Check which modes are valid.
|
||||
bool valid[MAX_DRAWMODE];
|
||||
@ -1010,7 +1010,7 @@ void Sample_TempObstacles::handleDebugMode()
|
||||
}
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::handleRender()
|
||||
void Editor_TempObstacles::handleRender()
|
||||
{
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
return;
|
||||
@ -1080,19 +1080,19 @@ void Sample_TempObstacles::handleRender()
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::renderCachedTile(const int tx, const int ty, const int type)
|
||||
void Editor_TempObstacles::renderCachedTile(const int tx, const int ty, const int type)
|
||||
{
|
||||
if (m_tileCache)
|
||||
drawDetail(&m_dd,m_tileCache,tx,ty,type);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::renderCachedTileOverlay(const int tx, const int ty, double* proj, double* model, int* view)
|
||||
void Editor_TempObstacles::renderCachedTileOverlay(const int tx, const int ty, double* proj, double* model, int* view)
|
||||
{
|
||||
if (m_tileCache)
|
||||
drawDetailOverlay(m_tileCache, tx, ty, proj, model, view);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
void Editor_TempObstacles::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleRenderOverlay(proj, model, view);
|
||||
@ -1122,7 +1122,7 @@ void Sample_TempObstacles::handleRenderOverlay(double* proj, double* model, int*
|
||||
*/
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::handleMeshChanged(class InputGeom* geom)
|
||||
void Editor_TempObstacles::handleMeshChanged(class InputGeom* geom)
|
||||
{
|
||||
Sample::handleMeshChanged(geom);
|
||||
|
||||
@ -1142,7 +1142,7 @@ void Sample_TempObstacles::handleMeshChanged(class InputGeom* geom)
|
||||
initToolStates(this);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::addTempObstacle(const float* pos)
|
||||
void Editor_TempObstacles::addTempObstacle(const float* pos)
|
||||
{
|
||||
if (!m_tileCache)
|
||||
return;
|
||||
@ -1152,7 +1152,7 @@ void Sample_TempObstacles::addTempObstacle(const float* pos)
|
||||
m_tileCache->addObstacle(p, 1.0f, 2.0f, 0);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::removeTempObstacle(const float* sp, const float* sq)
|
||||
void Editor_TempObstacles::removeTempObstacle(const float* sp, const float* sq)
|
||||
{
|
||||
if (!m_tileCache)
|
||||
return;
|
||||
@ -1160,7 +1160,7 @@ void Sample_TempObstacles::removeTempObstacle(const float* sp, const float* sq)
|
||||
m_tileCache->removeObstacle(ref);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::clearAllTempObstacles()
|
||||
void Editor_TempObstacles::clearAllTempObstacles()
|
||||
{
|
||||
if (!m_tileCache)
|
||||
return;
|
||||
@ -1172,7 +1172,7 @@ void Sample_TempObstacles::clearAllTempObstacles()
|
||||
}
|
||||
}
|
||||
|
||||
bool Sample_TempObstacles::handleBuild()
|
||||
bool Editor_TempObstacles::handleBuild()
|
||||
{
|
||||
dtStatus status;
|
||||
|
||||
@ -1341,7 +1341,7 @@ bool Sample_TempObstacles::handleBuild()
|
||||
return true;
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::handleUpdate(const float dt)
|
||||
void Editor_TempObstacles::handleUpdate(const float dt)
|
||||
{
|
||||
Sample::handleUpdate(dt);
|
||||
|
||||
@ -1353,7 +1353,7 @@ void Sample_TempObstacles::handleUpdate(const float dt)
|
||||
m_tileCache->update(dt, m_navMesh);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::getTilePos(const float* pos, int& tx, int& ty)
|
||||
void Editor_TempObstacles::getTilePos(const float* pos, int& tx, int& ty)
|
||||
{
|
||||
if (!m_geom) return;
|
||||
|
||||
@ -1382,7 +1382,7 @@ struct TileCacheTileHeader
|
||||
int dataSize;
|
||||
};
|
||||
|
||||
void Sample_TempObstacles::saveAll(const char* path)
|
||||
void Editor_TempObstacles::saveAll(const char* path)
|
||||
{
|
||||
if (!m_tileCache) return;
|
||||
|
||||
@ -1422,7 +1422,7 @@ void Sample_TempObstacles::saveAll(const char* path)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::loadAll(const char* path)
|
||||
void Editor_TempObstacles::loadAll(const char* path)
|
||||
{
|
||||
FILE* fp = fopen(path, "rb");
|
||||
if (!fp) return;
|
||||
|
@ -56,16 +56,16 @@ inline unsigned int ilog2(unsigned int v)
|
||||
return r;
|
||||
}
|
||||
|
||||
class NavMeshTileTool : public SampleTool
|
||||
class NavMeshTileTool : public EditorTool
|
||||
{
|
||||
Sample_TileMesh* m_sample;
|
||||
Editor_TileMesh* m_editor;
|
||||
float m_hitPos[3];
|
||||
bool m_hitPosSet;
|
||||
|
||||
public:
|
||||
|
||||
NavMeshTileTool() :
|
||||
m_sample(0),
|
||||
m_editor(0),
|
||||
m_hitPosSet(false)
|
||||
{
|
||||
m_hitPos[0] = m_hitPos[1] = m_hitPos[2] = 0;
|
||||
@ -77,9 +77,9 @@ public:
|
||||
|
||||
virtual int type() { return TOOL_TILE_EDIT; }
|
||||
|
||||
virtual void init(Sample* sample)
|
||||
virtual void init(Editor* editor)
|
||||
{
|
||||
m_sample = (Sample_TileMesh*)sample;
|
||||
m_editor = (Editor_TileMesh*)editor;
|
||||
}
|
||||
|
||||
virtual void reset() {}
|
||||
@ -89,13 +89,13 @@ public:
|
||||
imguiLabel("Create Tiles");
|
||||
if (imguiButton("Create All"))
|
||||
{
|
||||
if (m_sample)
|
||||
m_sample->buildAllTiles();
|
||||
if (m_editor)
|
||||
m_editor->buildAllTiles();
|
||||
}
|
||||
if (imguiButton("Remove All"))
|
||||
{
|
||||
if (m_sample)
|
||||
m_sample->removeAllTiles();
|
||||
if (m_editor)
|
||||
m_editor->removeAllTiles();
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,12 +103,12 @@ public:
|
||||
{
|
||||
m_hitPosSet = true;
|
||||
rcVcopy(m_hitPos,p);
|
||||
if (m_sample)
|
||||
if (m_editor)
|
||||
{
|
||||
if (shift)
|
||||
m_sample->removeTile(m_hitPos);
|
||||
m_editor->removeTile(m_hitPos);
|
||||
else
|
||||
m_sample->buildTile(m_hitPos);
|
||||
m_editor->buildTile(m_hitPos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ public:
|
||||
{
|
||||
if (m_hitPosSet)
|
||||
{
|
||||
const float s = m_sample->getAgentRadius();
|
||||
const float s = m_editor->getAgentRadius();
|
||||
glColor4ub(0,0,0,128);
|
||||
glLineWidth(2.0f);
|
||||
glBegin(GL_LINES);
|
||||
@ -144,7 +144,7 @@ public:
|
||||
model, proj, view, &x, &y, &z))
|
||||
{
|
||||
int tx=0, ty=0;
|
||||
m_sample->getTilePos(m_hitPos, tx, ty);
|
||||
m_editor->getTilePos(m_hitPos, tx, ty);
|
||||
char text[32];
|
||||
snprintf(text,32,"(%d,%d)", tx,ty);
|
||||
imguiDrawText((int)x, (int)y-25, IMGUI_ALIGN_CENTER, text, imguiRGBA(0,0,0,220));
|
||||
@ -159,7 +159,7 @@ public:
|
||||
|
||||
|
||||
|
||||
Sample_TileMesh::Sample_TileMesh() :
|
||||
Editor_TileMesh::Editor_TileMesh() :
|
||||
m_keepInterResults(false),
|
||||
m_buildAll(true),
|
||||
m_totalBuildTimeMs(0),
|
||||
@ -185,14 +185,14 @@ Sample_TileMesh::Sample_TileMesh() :
|
||||
setTool(new NavMeshTileTool);
|
||||
}
|
||||
|
||||
Sample_TileMesh::~Sample_TileMesh()
|
||||
Editor_TileMesh::~Editor_TileMesh()
|
||||
{
|
||||
cleanup();
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
m_navMesh = 0;
|
||||
}
|
||||
|
||||
void Sample_TileMesh::cleanup()
|
||||
void Editor_TileMesh::cleanup()
|
||||
{
|
||||
delete [] m_triareas;
|
||||
m_triareas = 0;
|
||||
@ -214,7 +214,7 @@ const hulldef hulls[5] = {
|
||||
{ "large", 60, 235 * 0.5, 60, 64.0f },
|
||||
{ "extra_large", 88, 235 * 0.5, 65, 64.0f },
|
||||
};
|
||||
void Sample_TileMesh::handleSettings()
|
||||
void Editor_TileMesh::handleSettings()
|
||||
{
|
||||
for (const hulldef& h : hulls)
|
||||
{
|
||||
@ -227,7 +227,7 @@ void Sample_TileMesh::handleSettings()
|
||||
m_tileSize = h.tile_size;
|
||||
}
|
||||
}
|
||||
Sample::handleCommonSettings();
|
||||
Editor::handleCommonSettings();
|
||||
|
||||
if (imguiCheck("Keep Itermediate Results", m_keepInterResults))
|
||||
m_keepInterResults = !m_keepInterResults;
|
||||
@ -277,13 +277,13 @@ void Sample_TileMesh::handleSettings()
|
||||
|
||||
if (imguiButton("Save"))
|
||||
{
|
||||
Sample::saveAll(m_modelName.c_str(), m_navMesh);
|
||||
Editor::saveAll(m_modelName.c_str(), m_navMesh);
|
||||
}
|
||||
|
||||
if (imguiButton("Load"))
|
||||
{
|
||||
dtFreeNavMesh(m_navMesh);
|
||||
m_navMesh = Sample::loadAll(m_modelName.c_str());
|
||||
m_navMesh = Editor::loadAll(m_modelName.c_str());
|
||||
m_navQuery->init(m_navMesh, 2048);
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ void Sample_TileMesh::handleSettings()
|
||||
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleTools()
|
||||
void Editor_TileMesh::handleTools()
|
||||
{
|
||||
int type = !m_tool ? TOOL_NONE : m_tool->type();
|
||||
|
||||
@ -339,7 +339,7 @@ void Sample_TileMesh::handleTools()
|
||||
imguiUnindent();
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleDebugMode()
|
||||
void Editor_TileMesh::handleDebugMode()
|
||||
{
|
||||
// Check which modes are valid.
|
||||
bool valid[MAX_DRAWMODE];
|
||||
@ -421,7 +421,7 @@ void Sample_TileMesh::handleDebugMode()
|
||||
}
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleRender()
|
||||
void Editor_TileMesh::handleRender()
|
||||
{
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
return;
|
||||
@ -473,7 +473,7 @@ void Sample_TileMesh::handleRender()
|
||||
duDebugDrawNavMeshPortals(&m_dd, *m_navMesh);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_NODES)
|
||||
duDebugDrawNavMeshNodes(&m_dd, *m_navQuery);
|
||||
duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, EDITOR_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
}
|
||||
|
||||
|
||||
@ -549,7 +549,7 @@ void Sample_TileMesh::handleRender()
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
void Editor_TileMesh::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
{
|
||||
GLdouble x, y, z;
|
||||
|
||||
@ -567,9 +567,9 @@ void Sample_TileMesh::handleRenderOverlay(double* proj, double* model, int* view
|
||||
renderOverlayToolStates(proj, model, view);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleMeshChanged(InputGeom* geom)
|
||||
void Editor_TileMesh::handleMeshChanged(InputGeom* geom)
|
||||
{
|
||||
Sample::handleMeshChanged(geom);
|
||||
Editor::handleMeshChanged(geom);
|
||||
|
||||
const BuildSettings* buildSettings = geom->getBuildSettings();
|
||||
if (buildSettings && buildSettings->tileSize > 0)
|
||||
@ -589,7 +589,7 @@ void Sample_TileMesh::handleMeshChanged(InputGeom* geom)
|
||||
initToolStates(this);
|
||||
}
|
||||
|
||||
bool Sample_TileMesh::handleBuild()
|
||||
bool Editor_TileMesh::handleBuild()
|
||||
{
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
{
|
||||
@ -642,14 +642,14 @@ bool Sample_TileMesh::handleBuild()
|
||||
return true;
|
||||
}
|
||||
|
||||
void Sample_TileMesh::collectSettings(BuildSettings& settings)
|
||||
void Editor_TileMesh::collectSettings(BuildSettings& settings)
|
||||
{
|
||||
Sample::collectSettings(settings);
|
||||
Editor::collectSettings(settings);
|
||||
|
||||
settings.tileSize = m_tileSize;
|
||||
}
|
||||
|
||||
void Sample_TileMesh::buildTile(const float* pos)
|
||||
void Editor_TileMesh::buildTile(const float* pos)
|
||||
{
|
||||
if (!m_geom) return;
|
||||
if (!m_navMesh) return;
|
||||
@ -680,7 +680,7 @@ void Sample_TileMesh::buildTile(const float* pos)
|
||||
m_ctx->dumpLog("Build Tile (%d,%d):", tx,ty);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::getTileExtents(int tx, int ty, float* tmin, float* tmax)
|
||||
void Editor_TileMesh::getTileExtents(int tx, int ty, float* tmin, float* tmax)
|
||||
{
|
||||
const float ts = m_tileSize * m_cellSize;
|
||||
const float* bmin = m_geom->getNavMeshBoundsMin();
|
||||
@ -693,7 +693,7 @@ void Sample_TileMesh::getTileExtents(int tx, int ty, float* tmin, float* tmax)
|
||||
tmax[1] = bmin[1] + (ty+1)*ts;
|
||||
tmax[2] = bmax[2];
|
||||
}
|
||||
void Sample_TileMesh::getTilePos(const float* pos, int& tx, int& ty)
|
||||
void Editor_TileMesh::getTilePos(const float* pos, int& tx, int& ty)
|
||||
{
|
||||
if (!m_geom) return;
|
||||
|
||||
@ -705,7 +705,7 @@ void Sample_TileMesh::getTilePos(const float* pos, int& tx, int& ty)
|
||||
ty = (int)((pos[1] - bmin[1]) / ts);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::removeTile(const float* pos)
|
||||
void Editor_TileMesh::removeTile(const float* pos)
|
||||
{
|
||||
if (!m_geom) return;
|
||||
if (!m_navMesh) return;
|
||||
@ -719,7 +719,7 @@ void Sample_TileMesh::removeTile(const float* pos)
|
||||
m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),0,0);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::buildAllTiles()
|
||||
void Editor_TileMesh::buildAllTiles()
|
||||
{
|
||||
if (!m_geom) return;
|
||||
if (!m_navMesh) return;
|
||||
@ -764,7 +764,7 @@ void Sample_TileMesh::buildAllTiles()
|
||||
|
||||
}
|
||||
|
||||
void Sample_TileMesh::removeAllTiles()
|
||||
void Editor_TileMesh::removeAllTiles()
|
||||
{
|
||||
if (!m_geom || !m_navMesh)
|
||||
return;
|
||||
@ -782,7 +782,7 @@ void Sample_TileMesh::removeAllTiles()
|
||||
m_navMesh->removeTile(m_navMesh->getTileRefAt(x,y,0),0,0);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::buildAllHulls()
|
||||
void Editor_TileMesh::buildAllHulls()
|
||||
{
|
||||
for (const hulldef& h : hulls)
|
||||
{
|
||||
@ -794,11 +794,11 @@ void Sample_TileMesh::buildAllHulls()
|
||||
|
||||
handleSettings();
|
||||
handleBuild();
|
||||
Sample::saveAll(m_modelName.c_str(), m_navMesh);
|
||||
Editor::saveAll(m_modelName.c_str(), m_navMesh);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const float* bmin, const float* bmax, int& dataSize)
|
||||
unsigned char* Editor_TileMesh::buildTileMesh(const int tx, const int ty, const float* bmin, const float* bmax, int& dataSize)
|
||||
{
|
||||
if (!m_geom || !m_geom->getMesh() || !m_geom->getChunkyMesh())
|
||||
{
|
||||
@ -1030,7 +1030,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
// if you have large open areas with small obstacles (not a problem if you use tiles)
|
||||
// * good choice to use for tiled navmesh with medium and small sized tiles
|
||||
|
||||
if (m_partitionType == SAMPLE_PARTITION_WATERSHED)
|
||||
if (m_partitionType == EDITOR_PARTITION_WATERSHED)
|
||||
{
|
||||
// Prepare for region partitioning, by calculating distance field along the walkable surface.
|
||||
if (!rcBuildDistanceField(m_ctx, *m_chf))
|
||||
@ -1046,7 +1046,7 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (m_partitionType == SAMPLE_PARTITION_MONOTONE)
|
||||
else if (m_partitionType == EDITOR_PARTITION_MONOTONE)
|
||||
{
|
||||
// Partition the walkable surface into simple regions without holes.
|
||||
// Monotone partitioning does not need distancefield.
|
||||
@ -1137,21 +1137,21 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
for (int i = 0; i < m_pmesh->npolys; ++i)
|
||||
{
|
||||
if (m_pmesh->areas[i] == RC_WALKABLE_AREA)
|
||||
m_pmesh->areas[i] = SAMPLE_POLYAREA_GROUND;
|
||||
m_pmesh->areas[i] = EDITOR_POLYAREA_GROUND;
|
||||
|
||||
if (m_pmesh->areas[i] == SAMPLE_POLYAREA_GROUND ||
|
||||
m_pmesh->areas[i] == SAMPLE_POLYAREA_GRASS ||
|
||||
m_pmesh->areas[i] == SAMPLE_POLYAREA_ROAD)
|
||||
if (m_pmesh->areas[i] == EDITOR_POLYAREA_GROUND ||
|
||||
m_pmesh->areas[i] == EDITOR_POLYAREA_GRASS ||
|
||||
m_pmesh->areas[i] == EDITOR_POLYAREA_ROAD)
|
||||
{
|
||||
m_pmesh->flags[i] = SAMPLE_POLYFLAGS_WALK;
|
||||
m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK;
|
||||
}
|
||||
else if (m_pmesh->areas[i] == SAMPLE_POLYAREA_WATER)
|
||||
else if (m_pmesh->areas[i] == EDITOR_POLYAREA_WATER)
|
||||
{
|
||||
m_pmesh->flags[i] = SAMPLE_POLYFLAGS_SWIM;
|
||||
m_pmesh->flags[i] = EDITOR_POLYFLAGS_SWIM;
|
||||
}
|
||||
else if (m_pmesh->areas[i] == SAMPLE_POLYAREA_DOOR)
|
||||
else if (m_pmesh->areas[i] == EDITOR_POLYAREA_DOOR)
|
||||
{
|
||||
m_pmesh->flags[i] = SAMPLE_POLYFLAGS_WALK | SAMPLE_POLYFLAGS_DOOR;
|
||||
m_pmesh->flags[i] = EDITOR_POLYFLAGS_WALK | EDITOR_POLYFLAGS_DOOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
// Tool to create convex volumess for InputGeom
|
||||
|
||||
class ConvexVolumeTool : public SampleTool
|
||||
class ConvexVolumeTool : public EditorTool
|
||||
{
|
||||
Sample* m_sample;
|
||||
Editor* m_editor;
|
||||
int m_areaType;
|
||||
float m_polyOffset;
|
||||
float m_boxHeight;
|
||||
@ -41,7 +41,7 @@ public:
|
||||
ConvexVolumeTool();
|
||||
|
||||
virtual int type() { return TOOL_CONVEX_VOLUME; }
|
||||
virtual void init(Sample* sample);
|
||||
virtual void init(Editor* editor);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
|
@ -57,9 +57,9 @@ struct CrowdToolParams
|
||||
float m_maxSpeed;
|
||||
};
|
||||
|
||||
class CrowdToolState : public SampleToolState
|
||||
class CrowdToolState : public EditorToolState
|
||||
{
|
||||
Sample* m_sample;
|
||||
Editor* m_editor;
|
||||
dtNavMesh* m_nav;
|
||||
dtCrowd* m_crowd;
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
CrowdToolState();
|
||||
virtual ~CrowdToolState();
|
||||
|
||||
virtual void init(class Sample* sample);
|
||||
virtual void init(class Editor* editor);
|
||||
virtual void reset();
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
@ -115,9 +115,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class CrowdTool : public SampleTool
|
||||
class CrowdTool : public EditorTool
|
||||
{
|
||||
Sample* m_sample;
|
||||
Editor* m_editor;
|
||||
CrowdToolState* m_state;
|
||||
|
||||
enum ToolMode
|
||||
@ -133,7 +133,7 @@ public:
|
||||
CrowdTool();
|
||||
|
||||
virtual int type() { return TOOL_CROWD; }
|
||||
virtual void init(Sample* sample);
|
||||
virtual void init(Editor* editor);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
// Prune navmesh to accessible locations from a point.
|
||||
|
||||
class NavMeshPruneTool : public SampleTool
|
||||
class NavMeshPruneTool : public EditorTool
|
||||
{
|
||||
Sample* m_sample;
|
||||
Editor* m_editor;
|
||||
|
||||
class NavmeshFlags* m_flags;
|
||||
|
||||
@ -37,7 +37,7 @@ public:
|
||||
virtual ~NavMeshPruneTool();
|
||||
|
||||
virtual int type() { return TOOL_NAVMESH_PRUNE; }
|
||||
virtual void init(Sample* sample);
|
||||
virtual void init(Editor* editor);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include "Detour/Include/DetourNavMeshQuery.h"
|
||||
#include "NavEditor/Include/Sample.h"
|
||||
|
||||
class NavMeshTesterTool : public SampleTool
|
||||
class NavMeshTesterTool : public EditorTool
|
||||
{
|
||||
Sample* m_sample;
|
||||
Editor* m_editor;
|
||||
|
||||
dtNavMesh* m_navMesh;
|
||||
dtNavMeshQuery* m_navQuery;
|
||||
@ -96,7 +96,7 @@ public:
|
||||
NavMeshTesterTool();
|
||||
|
||||
virtual int type() { return TOOL_NAVMESH_TESTER; }
|
||||
virtual void init(Sample* sample);
|
||||
virtual void init(Editor* editor);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
// Tool to create off-mesh connection for InputGeom
|
||||
|
||||
class OffMeshConnectionTool : public SampleTool
|
||||
class OffMeshConnectionTool : public EditorTool
|
||||
{
|
||||
Sample* m_sample;
|
||||
Editor* m_editor;
|
||||
float m_hitPos[3];
|
||||
bool m_hitPosSet;
|
||||
bool m_bidir;
|
||||
@ -36,7 +36,7 @@ public:
|
||||
~OffMeshConnectionTool();
|
||||
|
||||
virtual int type() { return TOOL_OFFMESH_CONNECTION; }
|
||||
virtual void init(Sample* sample);
|
||||
virtual void init(Editor* editor);
|
||||
virtual void reset();
|
||||
virtual void handleMenu();
|
||||
virtual void handleClick(const float* s, const float* p, bool shift);
|
||||
|
@ -35,7 +35,7 @@ struct hulldef
|
||||
extern const hulldef hulls[5];
|
||||
|
||||
/// Tool types.
|
||||
enum SampleToolType
|
||||
enum EditorToolType
|
||||
{
|
||||
TOOL_NONE = 0,
|
||||
TOOL_TILE_EDIT,
|
||||
@ -51,43 +51,43 @@ enum SampleToolType
|
||||
|
||||
/// These are just sample areas to use consistent values across the samples.
|
||||
/// The use should specify these base on his needs.
|
||||
enum SamplePolyAreas
|
||||
enum EditorPolyAreas
|
||||
{
|
||||
SAMPLE_POLYAREA_GROUND,
|
||||
SAMPLE_POLYAREA_WATER,
|
||||
SAMPLE_POLYAREA_ROAD,
|
||||
SAMPLE_POLYAREA_DOOR,
|
||||
SAMPLE_POLYAREA_GRASS,
|
||||
SAMPLE_POLYAREA_JUMP,
|
||||
EDITOR_POLYAREA_GROUND,
|
||||
EDITOR_POLYAREA_WATER,
|
||||
EDITOR_POLYAREA_ROAD,
|
||||
EDITOR_POLYAREA_DOOR,
|
||||
EDITOR_POLYAREA_GRASS,
|
||||
EDITOR_POLYAREA_JUMP,
|
||||
};
|
||||
enum SamplePolyFlags
|
||||
enum EditorPolyFlags
|
||||
{
|
||||
SAMPLE_POLYFLAGS_WALK = 0x01, // Ability to walk (ground, grass, road)
|
||||
SAMPLE_POLYFLAGS_SWIM = 0x02, // Ability to swim (water).
|
||||
SAMPLE_POLYFLAGS_DOOR = 0x04, // Ability to move through doors.
|
||||
SAMPLE_POLYFLAGS_JUMP = 0x08, // Ability to jump.
|
||||
SAMPLE_POLYFLAGS_DISABLED = 0x10, // Disabled polygon
|
||||
SAMPLE_POLYFLAGS_ALL = 0xffff // All abilities.
|
||||
EDITOR_POLYFLAGS_WALK = 0x01, // Ability to walk (ground, grass, road)
|
||||
EDITOR_POLYFLAGS_SWIM = 0x02, // Ability to swim (water).
|
||||
EDITOR_POLYFLAGS_DOOR = 0x04, // Ability to move through doors.
|
||||
EDITOR_POLYFLAGS_JUMP = 0x08, // Ability to jump.
|
||||
EDITOR_POLYFLAGS_DISABLED = 0x10, // Disabled polygon
|
||||
EDITOR_POLYFLAGS_ALL = 0xffff // All abilities.
|
||||
};
|
||||
|
||||
class SampleDebugDraw : public DebugDrawGL
|
||||
class EditorDebugDraw : public DebugDrawGL
|
||||
{
|
||||
public:
|
||||
virtual unsigned int areaToCol(unsigned int area);
|
||||
};
|
||||
|
||||
enum SamplePartitionType
|
||||
enum EditorPartitionType
|
||||
{
|
||||
SAMPLE_PARTITION_WATERSHED,
|
||||
SAMPLE_PARTITION_MONOTONE,
|
||||
SAMPLE_PARTITION_LAYERS,
|
||||
EDITOR_PARTITION_WATERSHED,
|
||||
EDITOR_PARTITION_MONOTONE,
|
||||
EDITOR_PARTITION_LAYERS,
|
||||
};
|
||||
|
||||
struct SampleTool
|
||||
struct EditorTool
|
||||
{
|
||||
virtual ~SampleTool() {}
|
||||
virtual ~EditorTool() {}
|
||||
virtual int type() = 0;
|
||||
virtual void init(class Sample* sample) = 0;
|
||||
virtual void init(class Editor* editor) = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void handleMenu() = 0;
|
||||
virtual void handleClick(const float* s, const float* p, bool shift) = 0;
|
||||
@ -98,16 +98,16 @@ struct SampleTool
|
||||
virtual void handleUpdate(const float dt) = 0;
|
||||
};
|
||||
|
||||
struct SampleToolState {
|
||||
virtual ~SampleToolState() {}
|
||||
virtual void init(class Sample* sample) = 0;
|
||||
struct EditorToolState {
|
||||
virtual ~EditorToolState() {}
|
||||
virtual void init(class Editor* editor) = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void handleRender() = 0;
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view) = 0;
|
||||
virtual void handleUpdate(const float dt) = 0;
|
||||
};
|
||||
|
||||
class Sample
|
||||
class Editor
|
||||
{
|
||||
protected:
|
||||
class InputGeom* m_geom;
|
||||
@ -137,12 +137,12 @@ protected:
|
||||
int m_reachabilityTableCount;
|
||||
const char* m_navmeshName = "unnamed";
|
||||
|
||||
SampleTool* m_tool;
|
||||
SampleToolState* m_toolStates[MAX_TOOLS];
|
||||
EditorTool* m_tool;
|
||||
EditorToolState* m_toolStates[MAX_TOOLS];
|
||||
|
||||
BuildContext* m_ctx;
|
||||
|
||||
SampleDebugDraw m_dd;
|
||||
EditorDebugDraw m_dd;
|
||||
|
||||
dtNavMesh* loadAll(std::string path);
|
||||
void saveAll(std::string path, dtNavMesh* mesh);
|
||||
@ -150,16 +150,16 @@ protected:
|
||||
public:
|
||||
std::string m_modelName;
|
||||
|
||||
Sample();
|
||||
virtual ~Sample();
|
||||
Editor();
|
||||
virtual ~Editor();
|
||||
|
||||
void setContext(BuildContext* ctx) { m_ctx = ctx; }
|
||||
|
||||
void setTool(SampleTool* tool);
|
||||
SampleToolState* getToolState(int type) { return m_toolStates[type]; }
|
||||
void setToolState(int type, SampleToolState* s) { m_toolStates[type] = s; }
|
||||
void setTool(EditorTool* tool);
|
||||
EditorToolState* getToolState(int type) { return m_toolStates[type]; }
|
||||
void setToolState(int type, EditorToolState* s) { m_toolStates[type] = s; }
|
||||
|
||||
SampleDebugDraw& getDebugDraw() { return m_dd; }
|
||||
EditorDebugDraw& getDebugDraw() { return m_dd; }
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
@ -186,7 +186,7 @@ public:
|
||||
void setNavMeshDrawFlags(unsigned char flags) { m_navMeshDrawFlags = flags; }
|
||||
|
||||
void updateToolStates(const float dt);
|
||||
void initToolStates(Sample* sample);
|
||||
void initToolStates(Editor* editor);
|
||||
void resetToolStates();
|
||||
void renderToolStates();
|
||||
void renderOverlayToolStates(double* proj, double* model, int* view);
|
||||
@ -196,8 +196,8 @@ public:
|
||||
|
||||
private:
|
||||
// Explicitly disabled copy constructor and copy assignment operator.
|
||||
Sample(const Sample&);
|
||||
Sample& operator=(const Sample&);
|
||||
Editor(const Editor&);
|
||||
Editor& operator=(const Editor&);
|
||||
};
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "Recast/Include/Recast.h"
|
||||
|
||||
/// Sample used for random debugging.
|
||||
class Sample_Debug : public Sample
|
||||
class Editor_Debug : public Editor
|
||||
{
|
||||
protected:
|
||||
rcCompactHeightfield* m_chf;
|
||||
@ -37,8 +37,8 @@ protected:
|
||||
dtPolyRef m_ref;
|
||||
|
||||
public:
|
||||
Sample_Debug();
|
||||
virtual ~Sample_Debug();
|
||||
Editor_Debug();
|
||||
virtual ~Editor_Debug();
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
@ -55,8 +55,8 @@ public:
|
||||
|
||||
private:
|
||||
// Explicitly disabled copy constructor and copy assignment operator.
|
||||
Sample_Debug(const Sample_Debug&);
|
||||
Sample_Debug& operator=(const Sample_Debug&);
|
||||
Editor_Debug(const Editor_Debug&);
|
||||
Editor_Debug& operator=(const Editor_Debug&);
|
||||
};
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "NavEditor/Include/Sample.h"
|
||||
|
||||
|
||||
class Sample_TempObstacles : public Sample
|
||||
class Editor_TempObstacles : public Sample
|
||||
{
|
||||
protected:
|
||||
bool m_keepInterResults;
|
||||
@ -62,8 +62,8 @@ protected:
|
||||
float m_tileSize;
|
||||
|
||||
public:
|
||||
Sample_TempObstacles();
|
||||
virtual ~Sample_TempObstacles();
|
||||
Editor_TempObstacles();
|
||||
virtual ~Editor_TempObstacles();
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
@ -88,8 +88,8 @@ public:
|
||||
|
||||
private:
|
||||
// Explicitly disabled copy constructor and copy assignment operator.
|
||||
Sample_TempObstacles(const Sample_TempObstacles&);
|
||||
Sample_TempObstacles& operator=(const Sample_TempObstacles&);
|
||||
Editor_TempObstacles(const Editor_TempObstacles&);
|
||||
Editor_TempObstacles& operator=(const Editor_TempObstacles&);
|
||||
|
||||
int rasterizeTileLayers(const int tx, const int ty, const rcConfig& cfg, struct TileCacheData* tiles, const int maxTiles);
|
||||
};
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "NavEditor/Include/ChunkyTriMesh.h"
|
||||
#include "NavEditor/Include/Sample.h"
|
||||
|
||||
class Sample_TileMesh : public Sample
|
||||
class Editor_TileMesh : public Editor
|
||||
{
|
||||
protected:
|
||||
bool m_keepInterResults;
|
||||
@ -83,8 +83,8 @@ protected:
|
||||
dtNavMesh* loadAll(const char* path);
|
||||
|
||||
public:
|
||||
Sample_TileMesh();
|
||||
virtual ~Sample_TileMesh();
|
||||
Editor_TileMesh();
|
||||
virtual ~Editor_TileMesh();
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
@ -106,8 +106,8 @@ public:
|
||||
void buildAllHulls();
|
||||
private:
|
||||
// Explicitly disabled copy constructor and copy assignment operator.
|
||||
Sample_TileMesh(const Sample_TileMesh&);
|
||||
Sample_TileMesh& operator=(const Sample_TileMesh&);
|
||||
Editor_TileMesh(const Editor_TileMesh&);
|
||||
Editor_TileMesh& operator=(const Editor_TileMesh&);
|
||||
};
|
||||
|
||||
|
||||
|
@ -32,11 +32,11 @@ using std::vector;
|
||||
|
||||
struct SampleItem
|
||||
{
|
||||
Sample* (*create)();
|
||||
Editor* (*create)();
|
||||
const string name;
|
||||
};
|
||||
Sample* createTile() { return new Sample_TileMesh(); }
|
||||
Sample* createDebug() { return new Sample_Debug(); }
|
||||
Editor* createTile() { return new Editor_TileMesh(); }
|
||||
Editor* createDebug() { return new Editor_Debug(); }
|
||||
|
||||
void save_ply(std::vector<float>& pts,std::vector<int>& colors,rcIntArray& tris)
|
||||
{
|
||||
@ -117,7 +117,7 @@ void generate_points(float* pts, int count, float dx, float dy, float dz)
|
||||
}
|
||||
}
|
||||
|
||||
void auto_load(const char* path, BuildContext& ctx, Sample*& sample,InputGeom*& geom, string& meshName)
|
||||
void auto_load(const char* path, BuildContext& ctx, Editor*& sample,InputGeom*& geom, string& meshName)
|
||||
{
|
||||
string geom_path = std::string(path);
|
||||
meshName = geom_path.substr(geom_path.rfind("\\") + 1);
|
||||
@ -393,22 +393,22 @@ int not_main(int argc, char** argv)
|
||||
bool markerPositionSet = false;
|
||||
|
||||
InputGeom* geom = nullptr;
|
||||
Sample* sample = nullptr;
|
||||
Editor* editor = nullptr;
|
||||
TestCase* test = nullptr;
|
||||
BuildContext ctx;
|
||||
|
||||
//Load tiled sample
|
||||
|
||||
sample = createTile();
|
||||
sample->setContext(&ctx);
|
||||
editor = createTile();
|
||||
editor->setContext(&ctx);
|
||||
if (geom)
|
||||
{
|
||||
sample->handleMeshChanged(geom);
|
||||
editor->handleMeshChanged(geom);
|
||||
}
|
||||
if (autoLoad)
|
||||
{
|
||||
auto_load(autoLoad, ctx, sample, geom, meshName);
|
||||
if (geom || sample)
|
||||
auto_load(autoLoad, ctx, editor, geom, meshName);
|
||||
if (geom || editor)
|
||||
{
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
@ -424,7 +424,7 @@ int not_main(int argc, char** argv)
|
||||
}
|
||||
if (argc > 2)
|
||||
{
|
||||
auto ts = dynamic_cast<Sample_TileMesh*>(sample);
|
||||
auto ts = dynamic_cast<Editor_TileMesh*>(editor);
|
||||
ts->buildAllHulls();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -500,17 +500,17 @@ int not_main(int argc, char** argv)
|
||||
}
|
||||
else if (event.key.keysym.sym == SDLK_SPACE)
|
||||
{
|
||||
if (sample)
|
||||
sample->handleToggle();
|
||||
if (editor)
|
||||
editor->handleToggle();
|
||||
}
|
||||
else if (event.key.keysym.sym == SDLK_1)
|
||||
{
|
||||
if (sample)
|
||||
sample->handleStep();
|
||||
if (editor)
|
||||
editor->handleStep();
|
||||
}
|
||||
else if (event.key.keysym.sym == SDLK_9)
|
||||
{
|
||||
if (sample && geom)
|
||||
if (editor && geom)
|
||||
{
|
||||
string savePath = meshesFolder + "/";
|
||||
BuildSettings settings;
|
||||
@ -519,7 +519,7 @@ int not_main(int argc, char** argv)
|
||||
rcVcopy(settings.navMeshBMin, geom->getNavMeshBoundsMin());
|
||||
rcVcopy(settings.navMeshBMax, geom->getNavMeshBoundsMax());
|
||||
|
||||
sample->collectSettings(settings);
|
||||
editor->collectSettings(settings);
|
||||
|
||||
geom->saveGeomSet(&settings);
|
||||
}
|
||||
@ -631,7 +631,7 @@ int not_main(int argc, char** argv)
|
||||
t += dt;
|
||||
|
||||
// Hit test mesh.
|
||||
if (processHitTest && geom && sample)
|
||||
if (processHitTest && geom && editor)
|
||||
{
|
||||
float hitTime;
|
||||
bool hit = geom->raycastMesh(rayStart, rayEnd, hitTime);
|
||||
@ -652,7 +652,7 @@ int not_main(int argc, char** argv)
|
||||
pos[0] = rayStart[0] + (rayEnd[0] - rayStart[0]) * hitTime;
|
||||
pos[1] = rayStart[1] + (rayEnd[1] - rayStart[1]) * hitTime;
|
||||
pos[2] = rayStart[2] + (rayEnd[2] - rayStart[2]) * hitTime;
|
||||
sample->handleClick(rayStart, pos, processHitTestShift);
|
||||
editor->handleClick(rayStart, pos, processHitTestShift);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -673,9 +673,9 @@ int not_main(int argc, char** argv)
|
||||
while (timeAcc > DELTA_TIME)
|
||||
{
|
||||
timeAcc -= DELTA_TIME;
|
||||
if (simIter < 5 && sample)
|
||||
if (simIter < 5 && editor)
|
||||
{
|
||||
sample->handleUpdate(DELTA_TIME);
|
||||
editor->handleUpdate(DELTA_TIME);
|
||||
}
|
||||
simIter++;
|
||||
}
|
||||
@ -768,8 +768,8 @@ int not_main(int argc, char** argv)
|
||||
|
||||
glEnable(GL_FOG);
|
||||
|
||||
if (sample)
|
||||
sample->handleRender();
|
||||
if (editor)
|
||||
editor->handleRender();
|
||||
if (test)
|
||||
test->handleRender();
|
||||
|
||||
@ -787,9 +787,9 @@ int not_main(int argc, char** argv)
|
||||
|
||||
imguiBeginFrame(mousePos[0], mousePos[1], mouseButtonMask, mouseScroll);
|
||||
|
||||
if (sample)
|
||||
if (editor)
|
||||
{
|
||||
sample->handleRenderOverlay(reinterpret_cast<double*>(projectionMatrix),
|
||||
editor->handleRenderOverlay(reinterpret_cast<double*>(projectionMatrix),
|
||||
reinterpret_cast<double*>(modelviewMatrix), reinterpret_cast<int*>(viewport));
|
||||
}
|
||||
if (test)
|
||||
@ -874,16 +874,16 @@ int not_main(int argc, char** argv)
|
||||
}
|
||||
imguiSeparator();
|
||||
|
||||
if (geom && sample)
|
||||
if (geom && editor)
|
||||
{
|
||||
imguiSeparatorLine();
|
||||
|
||||
sample->handleSettings();
|
||||
editor->handleSettings();
|
||||
|
||||
if (imguiButton("Build"))
|
||||
{
|
||||
ctx.resetLog();
|
||||
if (!sample->handleBuild())
|
||||
if (!editor->handleBuild())
|
||||
{
|
||||
showLog = true;
|
||||
logScroll = 0;
|
||||
@ -898,10 +898,10 @@ int not_main(int argc, char** argv)
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
if (sample)
|
||||
if (editor)
|
||||
{
|
||||
imguiSeparatorLine();
|
||||
sample->handleDebugMode();
|
||||
editor->handleDebugMode();
|
||||
}
|
||||
|
||||
imguiEndScrollArea();
|
||||
@ -911,7 +911,7 @@ int not_main(int argc, char** argv)
|
||||
if (showSample)
|
||||
{
|
||||
static int levelScroll = 0;
|
||||
if (geom || sample)
|
||||
if (geom || editor)
|
||||
{
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
@ -968,23 +968,23 @@ int not_main(int argc, char** argv)
|
||||
geom = 0;
|
||||
|
||||
// Destroy the sample if it already had geometry loaded, as we've just deleted it!
|
||||
if (sample && sample->getInputGeom())
|
||||
if (editor && editor->getInputGeom())
|
||||
{
|
||||
delete sample;
|
||||
sample = 0;
|
||||
delete editor;
|
||||
editor = 0;
|
||||
}
|
||||
|
||||
showLog = true;
|
||||
logScroll = 0;
|
||||
ctx.dumpLog("Geom load log %s:", meshName.c_str());
|
||||
}
|
||||
if (sample && geom)
|
||||
if (editor && geom)
|
||||
{
|
||||
sample->handleMeshChanged(geom);
|
||||
sample->m_modelName = meshName.substr(0, meshName.size() - 4);
|
||||
editor->handleMeshChanged(geom);
|
||||
editor->m_modelName = meshName.substr(0, meshName.size() - 4);
|
||||
}
|
||||
|
||||
if (geom || sample)
|
||||
if (geom || editor)
|
||||
{
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
@ -1028,9 +1028,9 @@ int not_main(int argc, char** argv)
|
||||
test = 0;
|
||||
}
|
||||
|
||||
if (sample)
|
||||
if (editor)
|
||||
{
|
||||
sample->setContext(&ctx);
|
||||
editor->setContext(&ctx);
|
||||
showSample = false;
|
||||
}
|
||||
|
||||
@ -1046,29 +1046,29 @@ int not_main(int argc, char** argv)
|
||||
{
|
||||
delete geom;
|
||||
geom = 0;
|
||||
delete sample;
|
||||
sample = 0;
|
||||
delete editor;
|
||||
editor = 0;
|
||||
showLog = true;
|
||||
logScroll = 0;
|
||||
ctx.dumpLog("Geom load log %s:", meshName.c_str());
|
||||
}
|
||||
if (sample && geom)
|
||||
if (editor && geom)
|
||||
{
|
||||
sample->handleMeshChanged(geom);
|
||||
sample->m_modelName = meshName.substr(0, meshName.size() - 4);
|
||||
editor->handleMeshChanged(geom);
|
||||
editor->m_modelName = meshName.substr(0, meshName.size() - 4);
|
||||
}
|
||||
|
||||
// This will ensure that tile & poly bits are updated in tiled sample.
|
||||
if (sample)
|
||||
sample->handleSettings();
|
||||
if (editor)
|
||||
editor->handleSettings();
|
||||
|
||||
ctx.resetLog();
|
||||
if (sample && !sample->handleBuild())
|
||||
if (editor && !editor->handleBuild())
|
||||
{
|
||||
ctx.dumpLog("Build log %s:", meshName.c_str());
|
||||
}
|
||||
|
||||
if (geom || sample)
|
||||
if (geom || editor)
|
||||
{
|
||||
const float* bmin = 0;
|
||||
const float* bmax = 0;
|
||||
@ -1082,8 +1082,8 @@ int not_main(int argc, char** argv)
|
||||
}
|
||||
|
||||
// Do the tests.
|
||||
if (sample)
|
||||
test->doTests(sample->getNavMesh(), sample->getNavMeshQuery());
|
||||
if (editor)
|
||||
test->doTests(editor->getNavMesh(), editor->getNavMeshQuery());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1107,8 +1107,8 @@ int not_main(int argc, char** argv)
|
||||
if (imguiBeginScrollArea("Tools", 10, 10, 250, height - 20, &toolsScroll))
|
||||
mouseOverMenu = true;
|
||||
|
||||
if (sample)
|
||||
sample->handleTools();
|
||||
if (editor)
|
||||
editor->handleTools();
|
||||
|
||||
imguiEndScrollArea();
|
||||
}
|
||||
@ -1146,7 +1146,7 @@ int not_main(int argc, char** argv)
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
delete sample;
|
||||
delete editor;
|
||||
delete geom;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user