Adjusted for new component removal method
This commit is contained in:
parent
8139cc78b2
commit
35771a619a
|
@ -630,19 +630,17 @@ namespace SHADE
|
||||||
auto* rigidBodyComponent = SHComponentManager::GetComponent_s<SHRigidBodyComponent>(ENTITY_ID);
|
auto* rigidBodyComponent = SHComponentManager::GetComponent_s<SHRigidBodyComponent>(ENTITY_ID);
|
||||||
auto* colliderComponent = SHComponentManager::GetComponent_s<SHColliderComponent>(ENTITY_ID);
|
auto* colliderComponent = SHComponentManager::GetComponent_s<SHColliderComponent>(ENTITY_ID);
|
||||||
|
|
||||||
SHASSERT(physicsObject != nullptr, "Physics object " + std::to_string(ENTITY_ID) + " has been lost from the world!")
|
// Wake up all physics objects
|
||||||
|
for (auto& [entityID, object] : map)
|
||||||
if (REMOVED_ID == RIGID_BODY_ID)
|
|
||||||
{
|
{
|
||||||
// Wake up all physics objects
|
if (SHComponentManager::HasComponent<SHRigidBodyComponent>(entityID))
|
||||||
for (auto& [entityID, object] : map)
|
reinterpret_cast<rp3d::RigidBody*>(object.rp3dBody)->setIsSleeping(false);
|
||||||
{
|
}
|
||||||
if (SHComponentManager::HasComponent<SHRigidBodyComponent>(entityID))
|
|
||||||
reinterpret_cast<rp3d::RigidBody*>(object.rp3dBody)->setIsSleeping(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (REMOVED_ID == RIGID_BODY_ID && physicsObject != nullptr)
|
||||||
|
{
|
||||||
world->destroyRigidBody(reinterpret_cast<rp3d::RigidBody*>(physicsObject->rp3dBody));
|
world->destroyRigidBody(reinterpret_cast<rp3d::RigidBody*>(physicsObject->rp3dBody));
|
||||||
physicsObject->rp3dBody = nullptr;
|
physicsObject->rp3dBody = nullptr;
|
||||||
|
|
||||||
if (colliderComponent != nullptr)
|
if (colliderComponent != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -657,7 +655,7 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (REMOVED_ID == COLLIDER_ID)
|
if (REMOVED_ID == COLLIDER_ID && physicsObject != nullptr)
|
||||||
{
|
{
|
||||||
// Remove all colliders
|
// Remove all colliders
|
||||||
const int NUM_COLLIDERS = static_cast<int>(physicsObject->rp3dBody->getNbColliders());
|
const int NUM_COLLIDERS = static_cast<int>(physicsObject->rp3dBody->getNbColliders());
|
||||||
|
@ -673,8 +671,8 @@ namespace SHADE
|
||||||
physicsObject->rp3dBody = nullptr;
|
physicsObject->rp3dBody = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (physicsObject->rp3dBody == nullptr)
|
if (physicsObject != nullptr && physicsObject->rp3dBody == nullptr)
|
||||||
DestroyPhysicsObject(ENTITY_ID);
|
DestroyPhysicsObject(ENTITY_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EVENT_DATA->handle;
|
return EVENT_DATA->handle;
|
||||||
|
|
Loading…
Reference in New Issue