Ndk/Physics: Improved code
Former-commit-id: 8774d0ce7cf55a0a1793e69eda6c97ececc1b44a
This commit is contained in:
parent
3f423239f5
commit
31227ca567
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <Nazara/Physics/PhysObject.hpp>
|
||||
#include <NDK/Algorithm.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
|
|
@ -48,13 +49,13 @@ namespace Ndk
|
|||
|
||||
void CollisionComponent::OnComponentAttached(BaseComponent& component)
|
||||
{
|
||||
if (component.GetIndex() == GetComponentIndex<PhysicsComponent>())
|
||||
if (IsComponent<PhysicsComponent>(component))
|
||||
m_staticBody.reset();
|
||||
}
|
||||
|
||||
void CollisionComponent::OnComponentDetached(BaseComponent& component)
|
||||
{
|
||||
if (component.GetIndex() == GetComponentIndex<PhysicsComponent>())
|
||||
if (IsComponent<PhysicsComponent>(component))
|
||||
InitializeStaticBody();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <Nazara/Physics/PhysObject.hpp>
|
||||
#include <NDK/Algorithm.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
|
|
@ -34,7 +35,7 @@ namespace Ndk
|
|||
|
||||
void PhysicsComponent::OnComponentAttached(BaseComponent& component)
|
||||
{
|
||||
if (component.GetIndex() == GetComponentIndex<CollisionComponent>())
|
||||
if (IsComponent<CollisionComponent>(component))
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid object");
|
||||
m_object->SetGeom(static_cast<CollisionComponent&>(component).GetGeom());
|
||||
|
|
@ -43,7 +44,7 @@ namespace Ndk
|
|||
|
||||
void PhysicsComponent::OnComponentDetached(BaseComponent& component)
|
||||
{
|
||||
if (component.GetIndex() == GetComponentIndex<CollisionComponent>())
|
||||
if (IsComponent<CollisionComponent>(component))
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid object");
|
||||
m_object->SetGeom(NzNullGeom::New());
|
||||
|
|
|
|||
Loading…
Reference in New Issue