Merge remote-tracking branch 'refs/remotes/origin/master' into culling
This commit is contained in:
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user