mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: add option for changing off-mesh connection radius
New slider that is also synced on change with the selected NavMesh type.
This commit is contained in:
parent
1378a6db9c
commit
9f0312cbf1
@ -29,6 +29,7 @@
|
||||
|
||||
OffMeshConnectionTool::OffMeshConnectionTool() :
|
||||
m_editor(0),
|
||||
m_radius(0),
|
||||
m_hitPosSet(0),
|
||||
m_bidir(true),
|
||||
m_invertVertexLookupOrder(false),
|
||||
@ -57,11 +58,18 @@ void OffMeshConnectionTool::init(Editor* editor)
|
||||
m_editor = editor;
|
||||
m_oldFlags = m_editor->getNavMeshDrawFlags();
|
||||
m_editor->setNavMeshDrawFlags(m_oldFlags & ~DU_DRAWNAVMESH_OFFMESHCONS);
|
||||
|
||||
const float agentRadius = m_editor->getAgentRadius();
|
||||
m_radius = agentRadius;
|
||||
m_lastSelectedAgentRadius = agentRadius;
|
||||
}
|
||||
}
|
||||
|
||||
void OffMeshConnectionTool::reset()
|
||||
{
|
||||
const float agentRadius = m_editor->getAgentRadius();
|
||||
m_radius = agentRadius;
|
||||
m_lastSelectedAgentRadius = agentRadius;
|
||||
m_hitPosSet = false;
|
||||
}
|
||||
|
||||
@ -72,6 +80,7 @@ void OffMeshConnectionTool::handleMenu()
|
||||
|
||||
ImGui::PushItemWidth(140);
|
||||
ImGui::SliderInt("Traverse Type##OffMeshConnectionTool", &m_traverseType, 0, DT_MAX_TRAVERSE_TYPES-1, "%d", ImGuiSliderFlags_NoInput);
|
||||
ImGui::SliderFloat("Radius##OffMeshConnectionTool", &m_radius, 0, 512);
|
||||
ImGui::PopItemWidth();
|
||||
}
|
||||
|
||||
@ -100,7 +109,7 @@ void OffMeshConnectionTool::handleClick(const float* /*s*/, const float* p, bool
|
||||
}
|
||||
// If end point close enough, delete it.
|
||||
if (nearestIndex != -1 &&
|
||||
sqrtf(nearestDist) < m_editor->getAgentRadius())
|
||||
sqrtf(nearestDist) < m_radius)
|
||||
{
|
||||
geom->deleteOffMeshConnection(nearestIndex);
|
||||
}
|
||||
@ -117,7 +126,7 @@ void OffMeshConnectionTool::handleClick(const float* /*s*/, const float* p, bool
|
||||
{
|
||||
const unsigned char area = EDITOR_POLYAREA_JUMP;
|
||||
const unsigned short flags = EDITOR_POLYFLAGS_WALK;
|
||||
geom->addOffMeshConnection(m_hitPos, p, m_editor->getAgentRadius(), m_bidir ? 1 : 0,
|
||||
geom->addOffMeshConnection(m_hitPos, p, m_radius, m_bidir ? 1 : 0,
|
||||
(unsigned char)m_traverseType, m_invertVertexLookupOrder ? 1 : 0, area, flags);
|
||||
m_hitPosSet = false;
|
||||
}
|
||||
@ -134,6 +143,13 @@ void OffMeshConnectionTool::handleStep()
|
||||
|
||||
void OffMeshConnectionTool::handleUpdate(const float /*dt*/)
|
||||
{
|
||||
const float agentRadius = m_editor->getAgentRadius();
|
||||
|
||||
if (m_lastSelectedAgentRadius < agentRadius || m_lastSelectedAgentRadius > agentRadius)
|
||||
{
|
||||
m_lastSelectedAgentRadius = agentRadius;
|
||||
m_radius = agentRadius;
|
||||
}
|
||||
}
|
||||
|
||||
void OffMeshConnectionTool::handleRender()
|
||||
|
@ -27,6 +27,8 @@ class OffMeshConnectionTool : public EditorTool
|
||||
{
|
||||
Editor* m_editor;
|
||||
float m_hitPos[3];
|
||||
float m_lastSelectedAgentRadius;
|
||||
float m_radius;
|
||||
bool m_hitPosSet;
|
||||
bool m_bidir;
|
||||
bool m_invertVertexLookupOrder;
|
||||
|
Loading…
x
Reference in New Issue
Block a user