Sdk: Rename [Collision|Physics]Component to [Collision|Physics]Component3D
This commit is contained in:
@@ -2,18 +2,18 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||
#include <NDK/Algorithm.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \ingroup NDK
|
||||
* \class Ndk::CollisionComponent
|
||||
* \class Ndk::CollisionComponent3D
|
||||
* \brief NDK class that represents the component for collision (meant for static objects)
|
||||
*/
|
||||
|
||||
@@ -25,14 +25,14 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the entity has no physics component and has no static body
|
||||
*/
|
||||
|
||||
void CollisionComponent::SetGeom(Nz::Collider3DRef geom)
|
||||
void CollisionComponent3D::SetGeom(Nz::Collider3DRef geom)
|
||||
{
|
||||
m_geom = std::move(geom);
|
||||
|
||||
if (m_entity->HasComponent<PhysicsComponent>())
|
||||
if (m_entity->HasComponent<PhysicsComponent3D>())
|
||||
{
|
||||
// We update the geometry of the PhysiscsObject linked to the PhysicsComponent
|
||||
PhysicsComponent& physComponent = m_entity->GetComponent<PhysicsComponent>();
|
||||
// We update the geometry of the PhysiscsObject linked to the PhysicsComponent3D
|
||||
PhysicsComponent3D& physComponent = m_entity->GetComponent<PhysicsComponent3D>();
|
||||
physComponent.GetPhysObject().SetGeom(m_geom);
|
||||
}
|
||||
else
|
||||
@@ -49,14 +49,14 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if entity is not linked to a world, or the world has no physics system
|
||||
*/
|
||||
|
||||
void CollisionComponent::InitializeStaticBody()
|
||||
void CollisionComponent3D::InitializeStaticBody()
|
||||
{
|
||||
NazaraAssert(m_entity, "Invalid entity");
|
||||
World* entityWorld = m_entity->GetWorld();
|
||||
|
||||
NazaraAssert(entityWorld, "Entity must have world");
|
||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
||||
Nz::PhysWorld3D& physWorld = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem3D>(), "World must have a physics system");
|
||||
Nz::PhysWorld3D& physWorld = entityWorld->GetSystem<PhysicsSystem3D>().GetWorld();
|
||||
|
||||
m_staticBody.reset(new Nz::RigidBody3D(&physWorld, m_geom));
|
||||
m_staticBody->EnableAutoSleep(false);
|
||||
@@ -66,9 +66,9 @@ namespace Ndk
|
||||
* \brief Operation to perform when component is attached to an entity
|
||||
*/
|
||||
|
||||
void CollisionComponent::OnAttached()
|
||||
void CollisionComponent3D::OnAttached()
|
||||
{
|
||||
if (!m_entity->HasComponent<PhysicsComponent>())
|
||||
if (!m_entity->HasComponent<PhysicsComponent3D>())
|
||||
InitializeStaticBody();
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace Ndk
|
||||
* \param component Component being attached
|
||||
*/
|
||||
|
||||
void CollisionComponent::OnComponentAttached(BaseComponent& component)
|
||||
void CollisionComponent3D::OnComponentAttached(BaseComponent& component)
|
||||
{
|
||||
if (IsComponent<PhysicsComponent>(component))
|
||||
if (IsComponent<PhysicsComponent3D>(component))
|
||||
m_staticBody.reset();
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ namespace Ndk
|
||||
* \param component Component being detached
|
||||
*/
|
||||
|
||||
void CollisionComponent::OnComponentDetached(BaseComponent& component)
|
||||
void CollisionComponent3D::OnComponentDetached(BaseComponent& component)
|
||||
{
|
||||
if (IsComponent<PhysicsComponent>(component))
|
||||
if (IsComponent<PhysicsComponent3D>(component))
|
||||
InitializeStaticBody();
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ namespace Ndk
|
||||
* \brief Operation to perform when component is detached from an entity
|
||||
*/
|
||||
|
||||
void CollisionComponent::OnDetached()
|
||||
void CollisionComponent3D::OnDetached()
|
||||
{
|
||||
m_staticBody.reset();
|
||||
}
|
||||
|
||||
ComponentIndex CollisionComponent::componentIndex;
|
||||
ComponentIndex CollisionComponent3D::componentIndex;
|
||||
}
|
||||
@@ -2,19 +2,19 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||
#include <NDK/Algorithm.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \ingroup NDK
|
||||
* \class Ndk::PhysicsComponent
|
||||
* \class Ndk::PhysicsComponent3D
|
||||
* \brief NDK class that represents the component for physics (meant for dynamic objects)
|
||||
*/
|
||||
|
||||
@@ -24,16 +24,16 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the world does not have a physics system
|
||||
*/
|
||||
|
||||
void PhysicsComponent::OnAttached()
|
||||
void PhysicsComponent3D::OnAttached()
|
||||
{
|
||||
World* entityWorld = m_entity->GetWorld();
|
||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
|
||||
NazaraAssert(entityWorld->HasSystem<PhysicsSystem3D>(), "World must have a physics system");
|
||||
|
||||
Nz::PhysWorld3D& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||
Nz::PhysWorld3D& world = entityWorld->GetSystem<PhysicsSystem3D>().GetWorld();
|
||||
|
||||
Nz::Collider3DRef geom;
|
||||
if (m_entity->HasComponent<CollisionComponent>())
|
||||
geom = m_entity->GetComponent<CollisionComponent>().GetGeom();
|
||||
if (m_entity->HasComponent<CollisionComponent3D>())
|
||||
geom = m_entity->GetComponent<CollisionComponent3D>().GetGeom();
|
||||
|
||||
Nz::Matrix4f matrix;
|
||||
if (m_entity->HasComponent<NodeComponent>())
|
||||
@@ -53,12 +53,12 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if physical object is invalid
|
||||
*/
|
||||
|
||||
void PhysicsComponent::OnComponentAttached(BaseComponent& component)
|
||||
void PhysicsComponent3D::OnComponentAttached(BaseComponent& component)
|
||||
{
|
||||
if (IsComponent<CollisionComponent>(component))
|
||||
if (IsComponent<CollisionComponent3D>(component))
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid object");
|
||||
m_object->SetGeom(static_cast<CollisionComponent&>(component).GetGeom());
|
||||
m_object->SetGeom(static_cast<CollisionComponent3D&>(component).GetGeom());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if physical object is invalid
|
||||
*/
|
||||
|
||||
void PhysicsComponent::OnComponentDetached(BaseComponent& component)
|
||||
void PhysicsComponent3D::OnComponentDetached(BaseComponent& component)
|
||||
{
|
||||
if (IsComponent<CollisionComponent>(component))
|
||||
if (IsComponent<CollisionComponent3D>(component))
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid object");
|
||||
m_object->SetGeom(Nz::NullCollider3D::New());
|
||||
@@ -83,10 +83,10 @@ namespace Ndk
|
||||
* \brief Operation to perform when component is detached from an entity
|
||||
*/
|
||||
|
||||
void PhysicsComponent::OnDetached()
|
||||
void PhysicsComponent3D::OnDetached()
|
||||
{
|
||||
m_object.reset();
|
||||
}
|
||||
|
||||
ComponentIndex PhysicsComponent::componentIndex;
|
||||
ComponentIndex PhysicsComponent3D::componentIndex;
|
||||
}
|
||||
Reference in New Issue
Block a user