@@ -4014,7 +4014,7 @@ void GameObject::UpdateModel()
40144014 modelCollisionEnabled = GetGoType () == GAMEOBJECT_TYPE_CHEST ? getLootState () == GO_READY : (GetGoState () == GO_STATE_READY || IsTransport ());
40154015
40164016 RemoveFlag (GO_FLAG_MAP_OBJECT);
4017- m_model = nullptr ;
4017+ std::unique_ptr<GameObjectModel> oldModel = std::exchange (m_model, nullptr ) ;
40184018
40194019 CreateModel ();
40204020 if (m_model)
@@ -4023,6 +4023,23 @@ void GameObject::UpdateModel()
40234023 if (modelCollisionEnabled)
40244024 m_model->EnableCollision (modelCollisionEnabled);
40254025 }
4026+
4027+ switch (GetGoType ())
4028+ {
4029+ // Only update navmesh when display id changes and not on spawn
4030+ // default state of destructible buildings is intended to be baked in the mesh produced by mmaps_generator
4031+ case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
4032+ case GAMEOBJECT_TYPE_TRAPDOOR:
4033+ case GAMEOBJECT_TYPE_PHASEABLE_MO:
4034+ case GAMEOBJECT_TYPE_SIEGEABLE_MO:
4035+ if (m_model)
4036+ GetMap ()->RequestRebuildNavMeshOnGameObjectModelChange (*m_model, GetPhaseShift ());
4037+ else if (oldModel)
4038+ GetMap ()->RequestRebuildNavMeshOnGameObjectModelChange (*oldModel, GetPhaseShift ());
4039+ break ;
4040+ default :
4041+ break ;
4042+ }
40264043}
40274044
40284045bool GameObject::IsLootAllowedFor (Player const * player) const
@@ -4499,6 +4516,7 @@ class GameObjectModelOwnerImpl : public GameObjectModelOwnerBase
44994516 bool IsInPhase (PhaseShift const & phaseShift) const override { return _owner->GetPhaseShift ().CanSee (phaseShift); }
45004517 G3D::Vector3 GetPosition () const override { return G3D::Vector3 (_owner->GetPositionX (), _owner->GetPositionY (), _owner->GetPositionZ ()); }
45014518 G3D::Quat GetRotation () const override { return G3D::Quat (_owner->GetLocalRotation ().x , _owner->GetLocalRotation ().y , _owner->GetLocalRotation ().z , _owner->GetLocalRotation ().w ); }
4519+ int64 GetPackedRotation () const override { return _owner->GetPackedLocalRotation (); }
45024520 float GetScale () const override { return _owner->GetObjectScale (); }
45034521 void DebugVisualizeCorner (G3D::Vector3 const & corner) const override { _owner->SummonCreature (1 , corner.x , corner.y , corner.z , 0 , TEMPSUMMON_MANUAL_DESPAWN); }
45044522
@@ -4538,8 +4556,20 @@ void GameObject::CreateModel()
45384556 if (m_model->IsMapObject ())
45394557 SetFlag (GO_FLAG_MAP_OBJECT);
45404558
4541- if (GetGoType () == GAMEOBJECT_TYPE_DOOR)
4542- m_model->DisableLosBlocking (GetGOInfo ()->door .NotLOSBlocking );
4559+ switch (GetGoType ())
4560+ {
4561+ case GAMEOBJECT_TYPE_DOOR:
4562+ m_model->DisableLosBlocking (GetGOInfo ()->door .NotLOSBlocking );
4563+ break ;
4564+ case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
4565+ case GAMEOBJECT_TYPE_TRAPDOOR:
4566+ case GAMEOBJECT_TYPE_PHASEABLE_MO:
4567+ case GAMEOBJECT_TYPE_SIEGEABLE_MO:
4568+ m_model->IncludeInNavMesh (true );
4569+ break ;
4570+ default :
4571+ break ;
4572+ }
45434573 }
45444574}
45454575
0 commit comments