Skip to content

Commit

Permalink
fixed crash when deleting navigation agents not in a zone; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Nov 8, 2024
1 parent a0ce055 commit 71c7d10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 128 deletions.
4 changes: 2 additions & 2 deletions src/animation/animation_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ struct AnimationModuleImpl final : AnimationModule {
m_render_module->unlockPose(entity, true);
}

void updateAnimator(Animator& animator, float time_delta)
{
void updateAnimator(Animator& animator, float time_delta) {
PROFILE_FUNCTION();
if (!animator.resource || !animator.resource->isReady()) return;
if (!animator.ctx) {
animator.ctx = animator.resource->createRuntime(animator.default_set);
Expand Down
123 changes: 0 additions & 123 deletions src/engine/engine.def

This file was deleted.

9 changes: 6 additions & 3 deletions src/navigation/navigation_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ struct NavigationModuleImpl final : NavigationModule

void update(RecastZone& zone, float time_delta) {
if (!zone.crowd) return;
zone.crowd->update(time_delta, nullptr);
{
PROFILE_BLOCK("dtCrowd::update");
zone.crowd->update(time_delta, nullptr);
}

for (auto& agent : m_agents) {
if (agent.agent < 0) continue;
Expand Down Expand Up @@ -982,7 +985,7 @@ struct NavigationModuleImpl final : NavigationModule
ASSERT(!zone.crowd);

zone.crowd = dtAllocCrowd();
if (!zone.crowd->init(1000, 4.0f, zone.navmesh)) {
if (!zone.crowd->init(2000, 4.0f, zone.navmesh)) {
dtFreeCrowd(zone.crowd);
zone.crowd = nullptr;
return false;
Expand Down Expand Up @@ -1484,8 +1487,8 @@ struct NavigationModuleImpl final : NavigationModule
if (agent.zone.isValid()) {
RecastZone& zone = m_zones[(EntityRef)agent.zone];
if (zone.crowd && agent.agent >= 0) zone.crowd->removeAgent(agent.agent);
m_agents.erase(iter);
}
m_agents.erase(iter);
m_world.onComponentDestroyed(entity, NAVMESH_AGENT_TYPE, this);
}

Expand Down

0 comments on commit 71c7d10

Please sign in to comment.