mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: add option to adjust navmesh bounding area
User can now define where the navmesh will be build and what would be excluded in the map. Also adjusted some colors of existing bounding boxes to make them more visible. They weren't as visible as they used to be after the UX and rendering improvements.
This commit is contained in:
parent
dbe35ce53f
commit
a99f3f3eb3
@ -251,6 +251,25 @@ void Editor::handleCommonSettings()
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Bounding");
|
||||
|
||||
float* navMeshBMin = m_geom->getNavMeshBoundsMin();
|
||||
float* navMeshBMax = m_geom->getNavMeshBoundsMax();
|
||||
|
||||
ImGui::PushItemWidth(230);
|
||||
|
||||
ImGui::SliderFloat3("Mins##BuildSettings", navMeshBMin, -MAX_COORD_FLOAT, MAX_COORD_FLOAT);
|
||||
ImGui::SliderFloat3("Maxs##BuildSettings", navMeshBMax, -MAX_COORD_FLOAT, MAX_COORD_FLOAT);
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (ImGui::Button("Reset##BuildSettings", ImVec2(120, 0)))
|
||||
{
|
||||
dtVcopy(navMeshBMin, m_geom->getOriginalNavMeshBoundsMin());
|
||||
dtVcopy(navMeshBMax, m_geom->getOriginalNavMeshBoundsMax());
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Partitioning");
|
||||
|
||||
|
@ -61,9 +61,15 @@ static void EditorCommon_DrawInputGeometry(duDebugDraw* const dd, const InputGeo
|
||||
static void EditorCommon_DrawBoundingBox(duDebugDraw* const dd, const InputGeom* const geom)
|
||||
{
|
||||
// Draw bounds
|
||||
const float* const bmin = geom->getNavMeshBoundsMin();
|
||||
const float* const bmax = geom->getNavMeshBoundsMax();
|
||||
duDebugDrawBoxWire(dd, bmin[0], bmin[1], bmin[2], bmax[0], bmax[1], bmax[2], duRGBA(255, 255, 255, 128), 1.0f, nullptr);
|
||||
const float* const origBmin = geom->getOriginalNavMeshBoundsMin();
|
||||
const float* const origBmax = geom->getOriginalNavMeshBoundsMax();
|
||||
duDebugDrawBoxWire(dd, origBmin[0], origBmin[1], origBmin[2], origBmax[0], origBmax[1], origBmax[2], duRGBA(255, 255, 255, 170), 1.0f, nullptr);
|
||||
|
||||
const float* const navBmin = geom->getNavMeshBoundsMin();
|
||||
const float* const navBmax = geom->getNavMeshBoundsMax();
|
||||
|
||||
if (!rcVequal(origBmin, navBmin) || !rcVequal(origBmax, navBmax))
|
||||
duDebugDrawBoxWire(dd, navBmin[0], navBmin[1], navBmin[2], navBmax[0], navBmax[1], navBmax[2], duRGBA(0, 255, 0, 215), 1.0f, nullptr);
|
||||
}
|
||||
|
||||
static void EditorCommon_DrawTilingGrid(duDebugDraw* const dd, const InputGeom* const geom, const int tileSize, const float cellSize)
|
||||
@ -130,7 +136,7 @@ Editor_StaticTileMeshCommon::Editor_StaticTileMeshCommon()
|
||||
, m_pmesh(nullptr)
|
||||
, m_dmesh(nullptr)
|
||||
, m_tileMeshDrawFlags(TM_DRAWFLAGS_INPUT_MESH|TM_DRAWFLAGS_NAVMESH)
|
||||
, m_tileCol(duRGBA(0, 0, 0, 32))
|
||||
, m_tileCol(duRGBA(0, 0, 0, 64))
|
||||
, m_totalBuildTimeMs(0.0f)
|
||||
, m_drawActiveTile(false)
|
||||
, m_keepInterResults(false)
|
||||
|
@ -498,7 +498,7 @@ void Editor_TileMesh::removeTile(const float* pos)
|
||||
getTilePos(pos, tx, ty);
|
||||
getTileExtents(tx, ty, m_lastBuiltTileBmin, m_lastBuiltTileBmax);
|
||||
|
||||
m_tileCol = duRGBA(128,32,16,64);
|
||||
m_tileCol = duRGBA(255,0,0,180);
|
||||
|
||||
m_navMesh->removeTile(m_navMesh->getTileRefAt(tx,ty,0),0,0);
|
||||
}
|
||||
@ -545,7 +545,7 @@ void Editor_TileMesh::buildAllTiles()
|
||||
m_ctx->stopTimer(RC_TIMER_TEMP);
|
||||
|
||||
m_totalBuildTimeMs = m_ctx->getAccumulatedTime(RC_TIMER_TEMP)/1000.0f;
|
||||
|
||||
m_tileCol = duRGBA(0,0,0,64);
|
||||
}
|
||||
|
||||
void Editor_TileMesh::removeAllTiles()
|
||||
|
@ -111,6 +111,10 @@ InputGeom::InputGeom() :
|
||||
m_offMeshConCount(0),
|
||||
m_volumeCount(0)
|
||||
{
|
||||
rcVset(m_meshBMin, 0.0f, 0.0f, 0.0f);
|
||||
rcVset(m_meshBMax, 0.0f, 0.0f, 0.0f);
|
||||
rcVset(m_navMeshBMin, 0.0f, 0.0f, 0.0f);
|
||||
rcVset(m_navMeshBMax, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
InputGeom::~InputGeom()
|
||||
@ -144,6 +148,8 @@ bool InputGeom::loadMesh(rcContext* ctx, const std::string& filepath)
|
||||
}
|
||||
|
||||
rcCalcBounds(m_mesh->getVerts(), m_mesh->getVertCount(), m_meshBMin, m_meshBMax);
|
||||
rcVcopy(m_navMeshBMin, m_meshBMin);
|
||||
rcVcopy(m_navMeshBMax, m_meshBMax);
|
||||
|
||||
m_chunkyMesh = new rcChunkyTriMesh;
|
||||
if (!m_chunkyMesh)
|
||||
@ -184,6 +190,8 @@ bool InputGeom::loadPlyMesh(rcContext* ctx, const std::string& filepath)
|
||||
}
|
||||
|
||||
rcCalcBounds(m_mesh->getVerts(), m_mesh->getVertCount(), m_meshBMin, m_meshBMax);
|
||||
rcVcopy(m_navMeshBMin, m_meshBMin);
|
||||
rcVcopy(m_navMeshBMax, m_meshBMax);
|
||||
|
||||
m_chunkyMesh = new rcChunkyTriMesh;
|
||||
if (!m_chunkyMesh)
|
||||
@ -334,6 +342,11 @@ bool InputGeom::loadGeomSet(rcContext* ctx, const std::string& filepath)
|
||||
&m_buildSettings.navMeshBMax[1],
|
||||
&m_buildSettings.navMeshBMax[2],
|
||||
&m_buildSettings.tileSize);
|
||||
|
||||
// Copy the original values over so we can reset to them in the
|
||||
// editor after changes have been made.
|
||||
rcVcopy(m_buildSettings.origNavMeshBMin, m_buildSettings.navMeshBMin);
|
||||
rcVcopy(m_buildSettings.origNavMeshBMax, m_buildSettings.navMeshBMax);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,9 @@ protected:
|
||||
float m_detailSampleMaxError;
|
||||
int m_partitionType;
|
||||
|
||||
float m_navMeshBMin[3];
|
||||
float m_navMeshBMax[3];
|
||||
|
||||
NavMeshType_e m_selectedNavMeshType;
|
||||
NavMeshType_e m_loadedNavMeshType;
|
||||
const char* m_navmeshName;
|
||||
|
@ -65,6 +65,9 @@ struct BuildSettings
|
||||
// Bounds of the area to mesh
|
||||
float navMeshBMin[3];
|
||||
float navMeshBMax[3];
|
||||
// Original bounds of the area to mesh.
|
||||
float origNavMeshBMin[3];
|
||||
float origNavMeshBMax[3];
|
||||
// Size of the tiles in voxels
|
||||
int tileSize;
|
||||
};
|
||||
@ -74,6 +77,7 @@ class InputGeom
|
||||
rcChunkyTriMesh* m_chunkyMesh;
|
||||
IMeshLoader* m_mesh;
|
||||
float m_meshBMin[3], m_meshBMax[3];
|
||||
float m_navMeshBMin[3], m_navMeshBMax[3];
|
||||
BuildSettings m_buildSettings;
|
||||
bool m_hasBuildSettings;
|
||||
|
||||
@ -113,8 +117,16 @@ public:
|
||||
const IMeshLoader* getMesh() const { return m_mesh; }
|
||||
const float* getMeshBoundsMin() const { return m_meshBMin; }
|
||||
const float* getMeshBoundsMax() const { return m_meshBMax; }
|
||||
const float* getNavMeshBoundsMin() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMin : m_meshBMin; }
|
||||
const float* getNavMeshBoundsMax() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMax : m_meshBMax; }
|
||||
|
||||
float* getNavMeshBoundsMin() { return m_hasBuildSettings ? m_buildSettings.navMeshBMin : m_navMeshBMin; }
|
||||
float* getNavMeshBoundsMax() { return m_hasBuildSettings ? m_buildSettings.navMeshBMax : m_navMeshBMax; }
|
||||
|
||||
const float* getNavMeshBoundsMin() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMin : m_navMeshBMin; }
|
||||
const float* getNavMeshBoundsMax() const { return m_hasBuildSettings ? m_buildSettings.navMeshBMax : m_navMeshBMax; }
|
||||
|
||||
const float* getOriginalNavMeshBoundsMin() const { return m_hasBuildSettings ? m_buildSettings.origNavMeshBMin : m_meshBMin; }
|
||||
const float* getOriginalNavMeshBoundsMax() const { return m_hasBuildSettings ? m_buildSettings.origNavMeshBMax : m_meshBMax; }
|
||||
|
||||
const rcChunkyTriMesh* getChunkyMesh() const { return m_chunkyMesh; }
|
||||
const BuildSettings* getBuildSettings() const { return m_hasBuildSettings ? &m_buildSettings : 0; }
|
||||
bool raycastMesh(float* src, float* dst, float& tmin);
|
||||
|
Loading…
x
Reference in New Issue
Block a user