Merge remote-tracking branch 'refs/remotes/origin/master' into culling
This commit is contained in:
@@ -374,8 +374,8 @@ namespace Ndk
|
||||
}
|
||||
|
||||
inline Application::WindowInfo::WindowInfo(std::unique_ptr<Nz::Window>&& window) :
|
||||
window(std::move(window)),
|
||||
renderTarget(nullptr)
|
||||
renderTarget(nullptr),
|
||||
window(std::move(window))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace Ndk
|
||||
*/
|
||||
|
||||
inline BaseSystem::BaseSystem(SystemIndex systemId) :
|
||||
m_updateEnabled(true),
|
||||
m_systemIndex(systemId)
|
||||
m_systemIndex(systemId),
|
||||
m_updateEnabled(true)
|
||||
{
|
||||
SetUpdateRate(30);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
#define NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/LightComponent.hpp>
|
||||
#include <NDK/Components/ListenerComponent.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
|
||||
#endif // NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
||||
@@ -7,53 +7,53 @@
|
||||
#ifndef NDK_COMPONENTS_COLLISIONCOMPONENT_HPP
|
||||
#define NDK_COMPONENTS_COLLISIONCOMPONENT_HPP
|
||||
|
||||
#include <Nazara/Physics/Geom.hpp>
|
||||
#include <Nazara/Physics3D/Collider3D.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class PhysObject;
|
||||
class RigidBody3D;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API CollisionComponent : public Component<CollisionComponent>
|
||||
class NDK_API CollisionComponent3D : public Component<CollisionComponent3D>
|
||||
{
|
||||
friend class PhysicsSystem;
|
||||
friend class PhysicsSystem3D;
|
||||
friend class StaticCollisionSystem;
|
||||
|
||||
public:
|
||||
CollisionComponent(Nz::PhysGeomRef geom = Nz::PhysGeomRef());
|
||||
CollisionComponent(const CollisionComponent& collision);
|
||||
~CollisionComponent() = default;
|
||||
CollisionComponent3D(Nz::Collider3DRef geom = Nz::Collider3DRef());
|
||||
CollisionComponent3D(const CollisionComponent3D& collision);
|
||||
~CollisionComponent3D() = default;
|
||||
|
||||
const Nz::PhysGeomRef& GetGeom() const;
|
||||
const Nz::Collider3DRef& GetGeom() const;
|
||||
|
||||
void SetGeom(Nz::PhysGeomRef geom);
|
||||
void SetGeom(Nz::Collider3DRef geom);
|
||||
|
||||
CollisionComponent& operator=(Nz::PhysGeomRef geom);
|
||||
CollisionComponent& operator=(CollisionComponent&& collision) = default;
|
||||
CollisionComponent3D& operator=(Nz::Collider3DRef geom);
|
||||
CollisionComponent3D& operator=(CollisionComponent3D&& collision) = default;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
void InitializeStaticBody();
|
||||
Nz::PhysObject* GetStaticBody();
|
||||
Nz::RigidBody3D* GetStaticBody();
|
||||
|
||||
void OnAttached() override;
|
||||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
|
||||
std::unique_ptr<Nz::PhysObject> m_staticBody;
|
||||
Nz::PhysGeomRef m_geom;
|
||||
std::unique_ptr<Nz::RigidBody3D> m_staticBody;
|
||||
Nz::Collider3DRef m_geom;
|
||||
bool m_bodyUpdated;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Components/CollisionComponent.inl>
|
||||
#include <NDK/Components/CollisionComponent3D.inl>
|
||||
|
||||
#endif // NDK_COMPONENTS_COLLISIONCOMPONENT_HPP
|
||||
@@ -4,30 +4,30 @@
|
||||
|
||||
#include <NDK/Entity.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
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a CollisionComponent object with a geometry
|
||||
* \brief Constructs a CollisionComponent3D object with a geometry
|
||||
*
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent::CollisionComponent(Nz::PhysGeomRef geom) :
|
||||
inline CollisionComponent3D::CollisionComponent3D(Nz::Collider3DRef geom) :
|
||||
m_geom(std::move(geom)),
|
||||
m_bodyUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a CollisionComponent object by copy semantic
|
||||
* \brief Constructs a CollisionComponent3D object by copy semantic
|
||||
*
|
||||
* \param collision CollisionComponent to copy
|
||||
* \param collision CollisionComponent3D to copy
|
||||
*/
|
||||
|
||||
inline CollisionComponent::CollisionComponent(const CollisionComponent& collision) :
|
||||
inline CollisionComponent3D::CollisionComponent3D(const CollisionComponent3D& collision) :
|
||||
m_geom(collision.m_geom),
|
||||
m_bodyUpdated(false)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace Ndk
|
||||
* \return A constant reference to the physics geometry
|
||||
*/
|
||||
|
||||
inline const Nz::PhysGeomRef& CollisionComponent::GetGeom() const
|
||||
inline const Nz::Collider3DRef& CollisionComponent3D::GetGeom() const
|
||||
{
|
||||
return m_geom;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace Ndk
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent& CollisionComponent::operator=(Nz::PhysGeomRef geom)
|
||||
inline CollisionComponent3D& CollisionComponent3D::operator=(Nz::Collider3DRef geom)
|
||||
{
|
||||
SetGeom(geom);
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Ndk
|
||||
* \return A pointer to the entity
|
||||
*/
|
||||
|
||||
inline Nz::PhysObject* CollisionComponent::GetStaticBody()
|
||||
inline Nz::RigidBody3D* CollisionComponent3D::GetStaticBody()
|
||||
{
|
||||
return m_staticBody.get();
|
||||
}
|
||||
@@ -79,12 +79,12 @@ namespace Ndk
|
||||
}
|
||||
|
||||
Renderable(Renderable&& renderable) noexcept :
|
||||
data(std::move(renderable.data)),
|
||||
renderable(std::move(renderable.renderable)),
|
||||
dataUpdated(renderable.dataUpdated),
|
||||
renderableBoundingVolumeInvalidationSlot(std::move(renderable.renderableBoundingVolumeInvalidationSlot)),
|
||||
renderableDataInvalidationSlot(std::move(renderable.renderableDataInvalidationSlot)),
|
||||
renderableReleaseSlot(std::move(renderable.renderableReleaseSlot))
|
||||
renderableReleaseSlot(std::move(renderable.renderableReleaseSlot)),
|
||||
data(std::move(renderable.data)),
|
||||
renderable(std::move(renderable.renderable)),
|
||||
dataUpdated(renderable.dataUpdated)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_COMPONENTS_PHYSICSCOMPONENT_HPP
|
||||
#define NDK_COMPONENTS_PHYSICSCOMPONENT_HPP
|
||||
#ifndef NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP
|
||||
#define NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP
|
||||
|
||||
#include <Nazara/Physics/PhysObject.hpp>
|
||||
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -15,15 +15,15 @@ namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API PhysicsComponent : public Component<PhysicsComponent>
|
||||
class NDK_API PhysicsComponent3D : public Component<PhysicsComponent3D>
|
||||
{
|
||||
friend class CollisionComponent;
|
||||
friend class PhysicsSystem;
|
||||
friend class CollisionComponent3D;
|
||||
friend class PhysicsSystem3D;
|
||||
|
||||
public:
|
||||
PhysicsComponent() = default;
|
||||
PhysicsComponent(const PhysicsComponent& physics);
|
||||
~PhysicsComponent() = default;
|
||||
PhysicsComponent3D() = default;
|
||||
PhysicsComponent3D(const PhysicsComponent3D& physics);
|
||||
~PhysicsComponent3D() = default;
|
||||
|
||||
void AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||
void AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||
@@ -56,17 +56,17 @@ namespace Ndk
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
Nz::PhysObject& GetPhysObject();
|
||||
Nz::RigidBody3D& GetPhysObject();
|
||||
|
||||
void OnAttached() override;
|
||||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
|
||||
std::unique_ptr<Nz::PhysObject> m_object;
|
||||
std::unique_ptr<Nz::RigidBody3D> m_object;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Components/PhysicsComponent.inl>
|
||||
#include <NDK/Components/PhysicsComponent3D.inl>
|
||||
|
||||
#endif // NDK_COMPONENTS_PHYSICSCOMPONENT_HPP
|
||||
#endif // NDK_COMPONENTS_PHYSICSCOMPONENT3D_HPP
|
||||
@@ -7,12 +7,12 @@
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a PhysicsComponent object by copy semantic
|
||||
* \brief Constructs a PhysicsComponent3D object by copy semantic
|
||||
*
|
||||
* \param physics PhysicsComponent to copy
|
||||
* \param physics PhysicsComponent3D to copy
|
||||
*/
|
||||
|
||||
inline PhysicsComponent::PhysicsComponent(const PhysicsComponent& physics)
|
||||
inline PhysicsComponent3D::PhysicsComponent3D(const PhysicsComponent3D& physics)
|
||||
{
|
||||
// No copy of physical object (because we only create it when attached to an entity)
|
||||
NazaraUnused(physics);
|
||||
@@ -27,7 +27,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys)
|
||||
inline void PhysicsComponent3D::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys)
|
||||
inline void PhysicsComponent3D::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys)
|
||||
inline void PhysicsComponent3D::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::EnableAutoSleep(bool autoSleep)
|
||||
inline void PhysicsComponent3D::EnableAutoSleep(bool autoSleep)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Boxf PhysicsComponent::GetAABB() const
|
||||
inline Nz::Boxf PhysicsComponent3D::GetAABB() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Vector3f PhysicsComponent::GetAngularVelocity() const
|
||||
inline Nz::Vector3f PhysicsComponent3D::GetAngularVelocity() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline float PhysicsComponent::GetGravityFactor() const
|
||||
inline float PhysicsComponent3D::GetGravityFactor() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline float PhysicsComponent::GetMass() const
|
||||
inline float PhysicsComponent3D::GetMass() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Vector3f PhysicsComponent::GetMassCenter(Nz::CoordSys coordSys) const
|
||||
inline Nz::Vector3f PhysicsComponent3D::GetMassCenter(Nz::CoordSys coordSys) const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline const Nz::Matrix4f& PhysicsComponent::GetMatrix() const
|
||||
inline const Nz::Matrix4f& PhysicsComponent3D::GetMatrix() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Vector3f PhysicsComponent::GetPosition() const
|
||||
inline Nz::Vector3f PhysicsComponent3D::GetPosition() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Quaternionf PhysicsComponent::GetRotation() const
|
||||
inline Nz::Quaternionf PhysicsComponent3D::GetRotation() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Vector3f PhysicsComponent::GetVelocity() const
|
||||
inline Nz::Vector3f PhysicsComponent3D::GetVelocity() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline bool PhysicsComponent::IsAutoSleepEnabled() const
|
||||
inline bool PhysicsComponent3D::IsAutoSleepEnabled() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline bool PhysicsComponent::IsSleeping() const
|
||||
inline bool PhysicsComponent3D::IsSleeping() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::SetAngularVelocity(const Nz::Vector3f& angularVelocity)
|
||||
inline void PhysicsComponent3D::SetAngularVelocity(const Nz::Vector3f& angularVelocity)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::SetGravityFactor(float gravityFactor)
|
||||
inline void PhysicsComponent3D::SetGravityFactor(float gravityFactor)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the mass is negative
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::SetMass(float mass)
|
||||
inline void PhysicsComponent3D::SetMass(float mass)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
NazaraAssert(mass > 0.f, "Mass should be positive");
|
||||
@@ -293,7 +293,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::SetMassCenter(const Nz::Vector3f& center)
|
||||
inline void PhysicsComponent3D::SetMassCenter(const Nz::Vector3f& center)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::SetPosition(const Nz::Vector3f& position)
|
||||
inline void PhysicsComponent3D::SetPosition(const Nz::Vector3f& position)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::SetRotation(const Nz::Quaternionf& rotation)
|
||||
inline void PhysicsComponent3D::SetRotation(const Nz::Quaternionf& rotation)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace Ndk
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent::SetVelocity(const Nz::Vector3f& velocity)
|
||||
inline void PhysicsComponent3D::SetVelocity(const Nz::Vector3f& velocity)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace Ndk
|
||||
* \return A reference to the physics object
|
||||
*/
|
||||
|
||||
inline Nz::PhysObject& PhysicsComponent::GetPhysObject()
|
||||
inline Nz::RigidBody3D& PhysicsComponent3D::GetPhysObject()
|
||||
{
|
||||
return *m_object.get();
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/ParticleSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_PHYSICSSYSTEM_HPP
|
||||
#define NDK_SYSTEMS_PHYSICSSYSTEM_HPP
|
||||
|
||||
#include <Nazara/Physics/PhysWorld.hpp>
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API PhysicsSystem : public System<PhysicsSystem>
|
||||
{
|
||||
public:
|
||||
PhysicsSystem();
|
||||
PhysicsSystem(const PhysicsSystem& system);
|
||||
~PhysicsSystem() = default;
|
||||
|
||||
Nz::PhysWorld& GetWorld();
|
||||
const Nz::PhysWorld& GetWorld() const;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
EntityList m_dynamicObjects;
|
||||
EntityList m_staticObjects;
|
||||
Nz::PhysWorld m_world;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Systems/PhysicsSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_PHYSICSSYSTEM_HPP
|
||||
42
SDK/include/NDK/Systems/PhysicsSystem3D.hpp
Normal file
42
SDK/include/NDK/Systems/PhysicsSystem3D.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP
|
||||
#define NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP
|
||||
|
||||
#include <Nazara/Physics3D/PhysWorld3D.hpp>
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API PhysicsSystem3D : public System<PhysicsSystem3D>
|
||||
{
|
||||
public:
|
||||
PhysicsSystem3D();
|
||||
PhysicsSystem3D(const PhysicsSystem3D& system);
|
||||
~PhysicsSystem3D() = default;
|
||||
|
||||
Nz::PhysWorld3D& GetWorld();
|
||||
const Nz::PhysWorld3D& GetWorld() const;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void CreatePhysWorld() const;
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
EntityList m_dynamicObjects;
|
||||
EntityList m_staticObjects;
|
||||
mutable std::unique_ptr<Nz::PhysWorld3D> m_world; ///TODO: std::optional (Should I make a Nz::Optional class?)
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Systems/PhysicsSystem3D.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP
|
||||
@@ -9,9 +9,12 @@ namespace Ndk
|
||||
* \return A reference to the physical world
|
||||
*/
|
||||
|
||||
inline Nz::PhysWorld& PhysicsSystem::GetWorld()
|
||||
inline Nz::PhysWorld3D& PhysicsSystem3D::GetWorld()
|
||||
{
|
||||
return m_world;
|
||||
if (!m_world)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_world;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -19,8 +22,11 @@ namespace Ndk
|
||||
* \return A constant reference to the physical world
|
||||
*/
|
||||
|
||||
inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const
|
||||
inline const Nz::PhysWorld3D& PhysicsSystem3D::GetWorld() const
|
||||
{
|
||||
return m_world;
|
||||
if (!m_world)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_world;
|
||||
}
|
||||
}
|
||||
@@ -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 <Nazara/Physics/PhysObject.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::PhysGeomRef 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,16 +49,16 @@ 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::PhysWorld& 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::PhysObject(&physWorld, m_geom));
|
||||
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 <Nazara/Physics/PhysObject.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::PhysWorld& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
|
||||
Nz::PhysWorld3D& world = entityWorld->GetSystem<PhysicsSystem3D>().GetWorld();
|
||||
|
||||
Nz::PhysGeomRef geom;
|
||||
if (m_entity->HasComponent<CollisionComponent>())
|
||||
geom = m_entity->GetComponent<CollisionComponent>().GetGeom();
|
||||
Nz::Collider3DRef geom;
|
||||
if (m_entity->HasComponent<CollisionComponent3D>())
|
||||
geom = m_entity->GetComponent<CollisionComponent3D>().GetGeom();
|
||||
|
||||
Nz::Matrix4f matrix;
|
||||
if (m_entity->HasComponent<NodeComponent>())
|
||||
@@ -41,7 +41,7 @@ namespace Ndk
|
||||
else
|
||||
matrix.MakeIdentity();
|
||||
|
||||
m_object.reset(new Nz::PhysObject(&world, geom, matrix));
|
||||
m_object.reset(new Nz::RigidBody3D(&world, geom, matrix));
|
||||
m_object->SetMass(1.f);
|
||||
}
|
||||
|
||||
@@ -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,12 +70,12 @@ 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::NullGeom::New());
|
||||
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;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace Ndk
|
||||
void LuaBinding::BindCore()
|
||||
{
|
||||
/*********************************** Nz::Clock **********************************/
|
||||
clockClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock, std::size_t argumentCount)
|
||||
clockClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock, std::size_t /*argumentCount*/)
|
||||
{
|
||||
int argIndex = 1;
|
||||
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
|
||||
|
||||
@@ -20,10 +20,8 @@ namespace Ndk
|
||||
return reinterpret_cast<Nz::InstancedRenderableRef*>(model); //TODO: Make a ObjectRefCast
|
||||
});
|
||||
|
||||
modelClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::ModelRef* model, std::size_t argumentCount)
|
||||
modelClass.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::ModelRef* model, std::size_t /*argumentCount*/)
|
||||
{
|
||||
NazaraUnused(argumentCount);
|
||||
|
||||
Nz::PlacementNew(model, Nz::Model::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -93,10 +93,8 @@ namespace Ndk
|
||||
});
|
||||
|
||||
/*********************************** Nz::Font **********************************/
|
||||
fontClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::FontRef* font, std::size_t argumentCount)
|
||||
fontClass.SetConstructor([] (Nz::LuaInstance& /*lua*/, Nz::FontRef* font, std::size_t /*argumentCount*/)
|
||||
{
|
||||
NazaraUnused(argumentCount);
|
||||
|
||||
Nz::PlacementNew(font, Nz::Font::New());
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
#include <Nazara/Graphics/Graphics.hpp>
|
||||
#include <Nazara/Lua/Lua.hpp>
|
||||
#include <Nazara/Noise/Noise.hpp>
|
||||
#include <Nazara/Physics/Physics.hpp>
|
||||
#include <Nazara/Physics3D/Physics3D.hpp>
|
||||
#include <Nazara/Utility/Utility.hpp>
|
||||
#include <NDK/Algorithm.hpp>
|
||||
#include <NDK/BaseSystem.hpp>
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
@@ -68,7 +68,7 @@ namespace Ndk
|
||||
|
||||
Nz::Lua::Initialize();
|
||||
Nz::Noise::Initialize();
|
||||
Nz::Physics::Initialize();
|
||||
Nz::Physics3D::Initialize();
|
||||
Nz::Utility::Initialize();
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
@@ -83,9 +83,9 @@ namespace Ndk
|
||||
BaseComponent::Initialize();
|
||||
|
||||
// Shared components
|
||||
InitializeComponent<CollisionComponent>("NdkColli");
|
||||
InitializeComponent<CollisionComponent3D>("NdkColli");
|
||||
InitializeComponent<NodeComponent>("NdkNode");
|
||||
InitializeComponent<PhysicsComponent>("NdkPhys");
|
||||
InitializeComponent<PhysicsComponent3D>("NdkPhys");
|
||||
InitializeComponent<VelocityComponent>("NdkVeloc");
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
@@ -103,7 +103,7 @@ namespace Ndk
|
||||
BaseSystem::Initialize();
|
||||
|
||||
// Shared systems
|
||||
InitializeSystem<PhysicsSystem>();
|
||||
InitializeSystem<PhysicsSystem3D>();
|
||||
InitializeSystem<VelocitySystem>();
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
@@ -161,7 +161,7 @@ namespace Ndk
|
||||
// Shared modules
|
||||
Nz::Lua::Uninitialize();
|
||||
Nz::Noise::Uninitialize();
|
||||
Nz::Physics::Uninitialize();
|
||||
Nz::Physics3D::Uninitialize();
|
||||
Nz::Utility::Uninitialize();
|
||||
|
||||
NazaraNotice("Uninitialized: SDK");
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <Nazara/Physics/PhysObject.hpp>
|
||||
#include <NDK/Components/CollisionComponent.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
@@ -15,7 +15,7 @@ namespace Ndk
|
||||
* \class Ndk::PhysicsSystem
|
||||
* \brief NDK class that represents the physics system
|
||||
*
|
||||
* \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: CollisionComponent or PhysicsComponent
|
||||
* \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: CollisionComponent3D or PhysicsComponent3D
|
||||
* \remark Static objects do not have a velocity specified by the physical engine
|
||||
*/
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace Ndk
|
||||
* \brief Constructs an PhysicsSystem object by default
|
||||
*/
|
||||
|
||||
PhysicsSystem::PhysicsSystem()
|
||||
PhysicsSystem3D::PhysicsSystem3D()
|
||||
{
|
||||
Requires<NodeComponent>();
|
||||
RequiresAny<CollisionComponent, PhysicsComponent>();
|
||||
RequiresAny<CollisionComponent3D, PhysicsComponent3D>();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -35,12 +35,19 @@ namespace Ndk
|
||||
* \param system PhysicsSystem to copy
|
||||
*/
|
||||
|
||||
PhysicsSystem::PhysicsSystem(const PhysicsSystem& system) :
|
||||
PhysicsSystem3D::PhysicsSystem3D(const PhysicsSystem3D& system) :
|
||||
System(system),
|
||||
m_world()
|
||||
{
|
||||
}
|
||||
|
||||
void PhysicsSystem3D::CreatePhysWorld() const
|
||||
{
|
||||
NazaraAssert(!m_world, "Physics world should not be created twice");
|
||||
|
||||
m_world = std::make_unique<Nz::PhysWorld3D>();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Operation to perform when entity is validated for the system
|
||||
*
|
||||
@@ -48,18 +55,21 @@ namespace Ndk
|
||||
* \param justAdded Is the entity newly added
|
||||
*/
|
||||
|
||||
void PhysicsSystem::OnEntityValidation(Entity* entity, bool justAdded)
|
||||
void PhysicsSystem3D::OnEntityValidation(Entity* entity, bool justAdded)
|
||||
{
|
||||
// If entity has not been just added to the system, it is possible that it does not own to the right array
|
||||
// It's possible our entity got revalidated because of the addition/removal of a PhysicsComponent3D
|
||||
if (!justAdded)
|
||||
{
|
||||
// We take the inverted array from which the entity should belong to
|
||||
auto& entities = (entity->HasComponent<PhysicsComponent>()) ? m_staticObjects : m_dynamicObjects;
|
||||
// We take the opposite array from which the entity should belong to
|
||||
auto& entities = (entity->HasComponent<PhysicsComponent3D>()) ? m_staticObjects : m_dynamicObjects;
|
||||
entities.Remove(entity);
|
||||
}
|
||||
|
||||
auto& entities = (entity->HasComponent<PhysicsComponent>()) ? m_dynamicObjects : m_staticObjects;
|
||||
auto& entities = (entity->HasComponent<PhysicsComponent3D>()) ? m_dynamicObjects : m_staticObjects;
|
||||
entities.Insert(entity);
|
||||
|
||||
if (!m_world)
|
||||
CreatePhysWorld();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -68,16 +78,19 @@ namespace Ndk
|
||||
* \param elapsedTime Delta time used for the update
|
||||
*/
|
||||
|
||||
void PhysicsSystem::OnUpdate(float elapsedTime)
|
||||
void PhysicsSystem3D::OnUpdate(float elapsedTime)
|
||||
{
|
||||
m_world.Step(elapsedTime);
|
||||
if (!m_world)
|
||||
return;
|
||||
|
||||
m_world->Step(elapsedTime);
|
||||
|
||||
for (const Ndk::EntityHandle& entity : m_dynamicObjects)
|
||||
{
|
||||
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||
PhysicsComponent& phys = entity->GetComponent<PhysicsComponent>();
|
||||
PhysicsComponent3D& phys = entity->GetComponent<PhysicsComponent3D>();
|
||||
|
||||
Nz::PhysObject& physObj = phys.GetPhysObject();
|
||||
Nz::RigidBody3D& physObj = phys.GetPhysObject();
|
||||
node.SetRotation(physObj.GetRotation(), Nz::CoordSys_Global);
|
||||
node.SetPosition(physObj.GetPosition(), Nz::CoordSys_Global);
|
||||
}
|
||||
@@ -85,10 +98,10 @@ namespace Ndk
|
||||
float invElapsedTime = 1.f / elapsedTime;
|
||||
for (const Ndk::EntityHandle& entity : m_staticObjects)
|
||||
{
|
||||
CollisionComponent& collision = entity->GetComponent<CollisionComponent>();
|
||||
CollisionComponent3D& collision = entity->GetComponent<CollisionComponent3D>();
|
||||
NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||
|
||||
Nz::PhysObject* physObj = collision.GetStaticBody();
|
||||
Nz::RigidBody3D* physObj = collision.GetStaticBody();
|
||||
|
||||
Nz::Quaternionf oldRotation = physObj->GetRotation();
|
||||
Nz::Vector3f oldPosition = physObj->GetPosition();
|
||||
@@ -121,5 +134,5 @@ namespace Ndk
|
||||
}
|
||||
}
|
||||
|
||||
SystemIndex PhysicsSystem::systemIndex;
|
||||
SystemIndex PhysicsSystem3D::systemIndex;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ namespace Ndk
|
||||
* \param viewer Viewer of the scene
|
||||
*/
|
||||
|
||||
void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer)
|
||||
void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& /*viewer*/)
|
||||
{
|
||||
if (!m_shadowRT.IsValid())
|
||||
m_shadowRT.Create();
|
||||
@@ -265,7 +265,6 @@ namespace Ndk
|
||||
for (const Ndk::EntityHandle& drawable : m_drawables)
|
||||
{
|
||||
GraphicsComponent& graphicsComponent = drawable->GetComponent<GraphicsComponent>();
|
||||
NodeComponent& drawableNode = drawable->GetComponent<NodeComponent>();
|
||||
|
||||
graphicsComponent.AddToRenderQueue(renderQueue);
|
||||
}
|
||||
@@ -338,7 +337,6 @@ namespace Ndk
|
||||
for (const Ndk::EntityHandle& drawable : m_drawables)
|
||||
{
|
||||
GraphicsComponent& graphicsComponent = drawable->GetComponent<GraphicsComponent>();
|
||||
NodeComponent& drawableNode = drawable->GetComponent<NodeComponent>();
|
||||
|
||||
graphicsComponent.AddToRenderQueue(renderQueue);
|
||||
}
|
||||
@@ -366,7 +364,6 @@ namespace Ndk
|
||||
for (const Ndk::EntityHandle& drawable : m_drawables)
|
||||
{
|
||||
GraphicsComponent& graphicsComponent = drawable->GetComponent<GraphicsComponent>();
|
||||
NodeComponent& drawableNode = drawable->GetComponent<NodeComponent>();
|
||||
|
||||
graphicsComponent.AddToRenderQueue(renderQueue);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
|
||||
namespace Ndk
|
||||
@@ -15,7 +15,7 @@ namespace Ndk
|
||||
* \brief NDK class that represents the velocity system
|
||||
*
|
||||
* \remark This system is enabled if the entity owns the trait: NodeComponent and VelocityComponent
|
||||
* but it's disabled with the trait: PhysicsComponent
|
||||
* but it's disabled with the trait: PhysicsComponent3D
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -25,7 +25,7 @@ namespace Ndk
|
||||
VelocitySystem::VelocitySystem()
|
||||
{
|
||||
Requires<NodeComponent, VelocityComponent>();
|
||||
Excludes<PhysicsComponent>();
|
||||
Excludes<PhysicsComponent3D>();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <NDK/World.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <NDK/BaseComponent.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
@@ -40,7 +40,7 @@ namespace Ndk
|
||||
|
||||
void World::AddDefaultSystems()
|
||||
{
|
||||
AddSystem<PhysicsSystem>();
|
||||
AddSystem<PhysicsSystem3D>();
|
||||
AddSystem<VelocitySystem>();
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
|
||||
Reference in New Issue
Block a user