Merge branch 'master' into NDK-ShadowMapping

Former-commit-id: 83435ab51753299b30a102871fbcd5558d2ac4f1
This commit is contained in:
Lynix
2015-12-09 00:59:07 +01:00
751 changed files with 79400 additions and 71735 deletions

View File

@@ -9,7 +9,7 @@ namespace Ndk
{
inline Application::Application()
{
NzErrorFlags errFlags(nzErrorFlag_ThrowException, true);
Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true);
// Initialisation du SDK
Sdk::Initialize();

View File

@@ -24,7 +24,7 @@ namespace Ndk
BaseComponent(ComponentIndex componentIndex);
BaseComponent(const BaseComponent&) = default;
BaseComponent(BaseComponent&&) noexcept = default;
BaseComponent(BaseComponent&&) = default;
virtual ~BaseComponent();
virtual BaseComponent* Clone() const = 0;
@@ -32,7 +32,7 @@ namespace Ndk
ComponentIndex GetIndex() const;
BaseComponent& operator=(const BaseComponent&) = default;
BaseComponent& operator=(BaseComponent&&) noexcept = default;
BaseComponent& operator=(BaseComponent&&) = default;
protected:
ComponentIndex m_componentIndex;

View File

@@ -79,11 +79,11 @@ namespace Ndk
static inline void Uninitialize();
std::vector<EntityHandle> m_entities;
NzBitset<nzUInt64> m_entityBits;
NzBitset<> m_excludedComponents;
mutable NzBitset<> m_filterResult;
NzBitset<> m_requiredAnyComponents;
NzBitset<> m_requiredComponents;
Nz::Bitset<Nz::UInt64> m_entityBits;
Nz::Bitset<> m_excludedComponents;
mutable Nz::Bitset<> m_filterResult;
Nz::Bitset<> m_requiredAnyComponents;
Nz::Bitset<> m_requiredComponents;
SystemIndex m_systemIndex;
World* m_world;
float m_updateCounter;

View File

@@ -19,7 +19,7 @@ namespace Ndk
{
class Entity;
class NDK_API CameraComponent : public Component<CameraComponent>, public NzAbstractViewer
class NDK_API CameraComponent : public Component<CameraComponent>, public Nz::AbstractViewer
{
public:
inline CameraComponent();
@@ -34,26 +34,26 @@ namespace Ndk
inline void EnsureViewportUpdate() const;
inline float GetAspectRatio() const;
inline NzVector3f GetEyePosition() const;
inline NzVector3f GetForward() const;
inline Nz::Vector3f GetEyePosition() const;
inline Nz::Vector3f GetForward() const;
inline float GetFOV() const;
inline const NzFrustumf& GetFrustum() const;
inline const Nz::Frustumf& GetFrustum() const;
inline unsigned int GetLayer() const;
inline const NzMatrix4f& GetProjectionMatrix() const;
inline nzProjectionType GetProjectionType() const;
inline const NzRenderTarget* GetTarget() const;
inline const NzRectf& GetTargetRegion() const;
inline const NzMatrix4f& GetViewMatrix() const;
inline const NzRecti& GetViewport() const;
inline const Nz::Matrix4f& GetProjectionMatrix() const;
inline Nz::ProjectionType GetProjectionType() const;
inline const Nz::RenderTarget* GetTarget() const;
inline const Nz::Rectf& GetTargetRegion() const;
inline const Nz::Matrix4f& GetViewMatrix() const;
inline const Nz::Recti& GetViewport() const;
inline float GetZFar() const;
inline float GetZNear() const;
inline void SetFOV(float fov);
inline void SetLayer(unsigned int layer);
inline void SetProjectionType(nzProjectionType projection);
inline void SetTarget(const NzRenderTarget* renderTarget);
inline void SetTargetRegion(const NzRectf& region);
inline void SetViewport(const NzRecti& viewport);
inline void SetProjectionType(Nz::ProjectionType projection);
inline void SetTarget(const Nz::RenderTarget* renderTarget);
inline void SetTargetRegion(const Nz::Rectf& region);
inline void SetViewport(const Nz::Recti& viewport);
inline void SetZFar(float zFar);
inline void SetZNear(float zNear);
@@ -69,26 +69,26 @@ namespace Ndk
void OnComponentAttached(BaseComponent& component) override;
void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override;
void OnNodeInvalidated(const NzNode* node);
void OnRenderTargetRelease(const NzRenderTarget* renderTarget);
void OnRenderTargetSizeChange(const NzRenderTarget* renderTarget);
void OnNodeInvalidated(const Nz::Node* node);
void OnRenderTargetRelease(const Nz::RenderTarget* renderTarget);
void OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget);
void UpdateFrustum() const;
void UpdateProjectionMatrix() const;
void UpdateViewMatrix() const;
void UpdateViewport() const;
NazaraSlot(NzNode, OnNodeInvalidation, m_nodeInvalidationSlot);
NazaraSlot(NzRenderTarget, OnRenderTargetRelease, m_targetReleaseSlot);
NazaraSlot(NzRenderTarget, OnRenderTargetSizeChange, m_targetResizeSlot);
NazaraSlot(Nz::Node, OnNodeInvalidation, m_nodeInvalidationSlot);
NazaraSlot(Nz::RenderTarget, OnRenderTargetRelease, m_targetReleaseSlot);
NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, m_targetResizeSlot);
nzProjectionType m_projectionType;
mutable NzFrustumf m_frustum;
mutable NzMatrix4f m_projectionMatrix;
mutable NzMatrix4f m_viewMatrix;
NzRectf m_targetRegion;
mutable NzRecti m_viewport;
const NzRenderTarget* m_target;
Nz::ProjectionType m_projectionType;
mutable Nz::Frustumf m_frustum;
mutable Nz::Matrix4f m_projectionMatrix;
mutable Nz::Matrix4f m_viewMatrix;
Nz::Rectf m_targetRegion;
mutable Nz::Recti m_viewport;
const Nz::RenderTarget* m_target;
mutable bool m_frustumUpdated;
mutable bool m_projectionMatrixUpdated;
mutable bool m_viewMatrixUpdated;

View File

@@ -8,7 +8,7 @@
namespace Ndk
{
inline CameraComponent::CameraComponent() :
m_projectionType(nzProjectionType_Perspective),
m_projectionType(Nz::ProjectionType_Perspective),
m_targetRegion(0.f, 0.f, 1.f, 1.f),
m_target(nullptr),
m_frustumUpdated(false),
@@ -25,7 +25,7 @@ namespace Ndk
inline CameraComponent::CameraComponent(const CameraComponent& camera) :
Component(camera),
NzAbstractViewer(camera),
AbstractViewer(camera),
m_projectionType(camera.m_projectionType),
m_targetRegion(camera.m_targetRegion),
m_target(nullptr),
@@ -78,7 +78,7 @@ namespace Ndk
return m_fov;
}
inline const NzFrustumf& CameraComponent::GetFrustum() const
inline const Nz::Frustumf& CameraComponent::GetFrustum() const
{
EnsureFrustumUpdate();
@@ -90,36 +90,36 @@ namespace Ndk
return m_layer;
}
inline const NzMatrix4f& CameraComponent::GetProjectionMatrix() const
inline const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const
{
EnsureProjectionMatrixUpdate();
return m_projectionMatrix;
}
inline nzProjectionType CameraComponent::GetProjectionType() const
inline Nz::ProjectionType CameraComponent::GetProjectionType() const
{
return m_projectionType;
}
inline const NzRenderTarget* CameraComponent::GetTarget() const
inline const Nz::RenderTarget* CameraComponent::GetTarget() const
{
return m_target;
}
inline const NzRectf& CameraComponent::GetTargetRegion() const
inline const Nz::Rectf& CameraComponent::GetTargetRegion() const
{
return m_targetRegion;
}
inline const NzMatrix4f& CameraComponent::GetViewMatrix() const
inline const Nz::Matrix4f& CameraComponent::GetViewMatrix() const
{
EnsureViewMatrixUpdate();
return m_viewMatrix;
}
inline const NzRecti& CameraComponent::GetViewport() const
inline const Nz::Recti& CameraComponent::GetViewport() const
{
EnsureViewportUpdate();
@@ -138,36 +138,42 @@ namespace Ndk
inline void CameraComponent::SetFOV(float fov)
{
NazaraAssert(!NzNumberEquals(fov, 0.f), "FOV must be different from zero");
NazaraAssert(!Nz::NumberEquals(fov, 0.f), "FOV must be different from zero");
m_fov = fov;
InvalidateProjectionMatrix();
}
inline void CameraComponent::SetProjectionType(nzProjectionType projectionType)
inline void CameraComponent::SetProjectionType(Nz::ProjectionType projectionType)
{
m_projectionType = projectionType;
InvalidateProjectionMatrix();
}
inline void CameraComponent::SetTarget(const NzRenderTarget* renderTarget)
inline void CameraComponent::SetTarget(const Nz::RenderTarget* renderTarget)
{
m_target = renderTarget;
if (m_target)
{
m_targetResizeSlot.Connect(m_target->OnRenderTargetSizeChange, this, &CameraComponent::OnRenderTargetSizeChange);
m_targetReleaseSlot.Connect(m_target->OnRenderTargetRelease, this, &CameraComponent::OnRenderTargetRelease);
}
else
{
m_targetResizeSlot.Disconnect();
m_targetReleaseSlot.Disconnect();
}
}
inline void CameraComponent::SetTargetRegion(const NzRectf& region)
inline void CameraComponent::SetTargetRegion(const Nz::Rectf& region)
{
m_targetRegion = region;
InvalidateViewport();
}
inline void CameraComponent::SetViewport(const NzRecti& viewport)
inline void CameraComponent::SetViewport(const Nz::Recti& viewport)
{
NazaraAssert(m_target, "Component has no render target");
@@ -175,7 +181,7 @@ namespace Ndk
float invWidth = 1.f/m_target->GetWidth();
float invHeight = 1.f/m_target->GetHeight();
SetTargetRegion(NzRectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
}
inline void CameraComponent::SetZFar(float zFar)
@@ -187,7 +193,7 @@ namespace Ndk
inline void CameraComponent::SetZNear(float zNear)
{
NazaraAssert(!NzNumberEquals(zNear, 0.f), "zNear cannot be zero");
NazaraAssert(!Nz::NumberEquals(zNear, 0.f), "zNear cannot be zero");
m_zNear = zNear;
InvalidateProjectionMatrix();

View File

@@ -11,7 +11,10 @@
#include <NDK/Component.hpp>
#include <memory>
class NzPhysObject;
namespace Nz
{
class PhysObject;
}
namespace Ndk
{
@@ -23,30 +26,30 @@ namespace Ndk
friend class StaticCollisionSystem;
public:
CollisionComponent(NzPhysGeomRef geom = NzPhysGeomRef());
CollisionComponent(Nz::PhysGeomRef geom = Nz::PhysGeomRef());
CollisionComponent(const CollisionComponent& collision);
~CollisionComponent() = default;
const NzPhysGeomRef& GetGeom() const;
const Nz::PhysGeomRef& GetGeom() const;
void SetGeom(NzPhysGeomRef geom);
void SetGeom(Nz::PhysGeomRef geom);
CollisionComponent& operator=(NzPhysGeomRef geom);
CollisionComponent& operator=(Nz::PhysGeomRef geom);
CollisionComponent& operator=(CollisionComponent&& collision) = default;
static ComponentIndex componentIndex;
private:
void InitializeStaticBody();
NzPhysObject* GetStaticBody();
Nz::PhysObject* GetStaticBody();
void OnAttached() override;
void OnComponentAttached(BaseComponent& component) override;
void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override;
std::unique_ptr<NzPhysObject> m_staticBody;
NzPhysGeomRef m_geom;
std::unique_ptr<Nz::PhysObject> m_staticBody;
Nz::PhysGeomRef m_geom;
bool m_bodyUpdated;
};
}

View File

@@ -9,7 +9,7 @@
namespace Ndk
{
inline CollisionComponent::CollisionComponent(NzPhysGeomRef geom) :
inline CollisionComponent::CollisionComponent(Nz::PhysGeomRef geom) :
m_geom(std::move(geom)),
m_bodyUpdated(false)
{
@@ -21,19 +21,19 @@ namespace Ndk
{
}
inline const NzPhysGeomRef& CollisionComponent::GetGeom() const
inline const Nz::PhysGeomRef& CollisionComponent::GetGeom() const
{
return m_geom;
}
inline CollisionComponent& CollisionComponent::operator=(NzPhysGeomRef geom)
inline CollisionComponent& CollisionComponent::operator=(Nz::PhysGeomRef geom)
{
SetGeom(geom);
return *this;
}
inline NzPhysObject* CollisionComponent::GetStaticBody()
inline Nz::PhysObject* CollisionComponent::GetStaticBody()
{
return m_staticBody.get();
}

View File

@@ -22,16 +22,16 @@ namespace Ndk
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
~GraphicsComponent() = default;
inline void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const;
inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
inline void Attach(NzInstancedRenderableRef renderable);
inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
inline void EnsureTransformMatrixUpdate() const;
static ComponentIndex componentIndex;
private:
void InvalidateRenderableData(const NzInstancedRenderable* renderable, nzUInt32 flags, unsigned int index);
void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index);
inline void InvalidateRenderables();
inline void InvalidateTransformMatrix();
@@ -39,29 +39,29 @@ namespace Ndk
void OnComponentAttached(BaseComponent& component) override;
void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override;
void OnNodeInvalidated(const NzNode* node);
void OnNodeInvalidated(const Nz::Node* node);
void UpdateTransformMatrix() const;
NazaraSlot(NzNode, OnNodeInvalidation, m_nodeInvalidationSlot);
NazaraSlot(Nz::Node, OnNodeInvalidation, m_nodeInvalidationSlot);
struct Renderable
{
Renderable(NzMatrix4f& transformMatrix) :
Renderable(Nz::Matrix4f& transformMatrix) :
data(transformMatrix),
dataUpdated(false)
{
}
NazaraSlot(NzInstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot);
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot);
mutable NzInstancedRenderable::InstanceData data;
NzInstancedRenderableRef renderable;
mutable Nz::InstancedRenderable::InstanceData data;
Nz::InstancedRenderableRef renderable;
mutable bool dataUpdated;
};
std::vector<Renderable> m_renderables;
mutable NzMatrix4f m_transformMatrix;
mutable Nz::Matrix4f m_transformMatrix;
mutable bool m_transformMatrixUpdated;
};
}

View File

@@ -13,10 +13,10 @@ namespace Ndk
{
m_renderables.reserve(graphicsComponent.m_renderables.size());
for (const Renderable& r : graphicsComponent.m_renderables)
Attach(r.renderable);
Attach(r.renderable, r.data.renderOrder);
}
inline void GraphicsComponent::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
inline void GraphicsComponent::AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const
{
EnsureTransformMatrixUpdate();
@@ -32,10 +32,11 @@ namespace Ndk
}
}
inline void GraphicsComponent::Attach(NzInstancedRenderableRef renderable)
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, int renderOrder)
{
m_renderables.emplace_back(m_transformMatrix);
Renderable& r = m_renderables.back();
r.data.renderOrder = renderOrder;
r.renderable = std::move(renderable);
r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1));
}

View File

@@ -12,10 +12,10 @@
namespace Ndk
{
class NDK_API LightComponent : public Component<LightComponent>, public NzLight
class NDK_API LightComponent : public Component<LightComponent>, public Nz::Light
{
public:
inline LightComponent(nzLightType lightType = nzLightType_Point);
inline LightComponent(Nz::LightType lightType = Nz::LightType_Point);
LightComponent(const LightComponent& light) = default;
~LightComponent() = default;

View File

@@ -4,8 +4,8 @@
namespace Ndk
{
inline LightComponent::LightComponent(nzLightType lightType) :
NzLight(lightType)
inline LightComponent::LightComponent(Nz::LightType lightType) :
Nz::Light(lightType)
{
}
}
}

View File

@@ -14,14 +14,14 @@ namespace Ndk
{
class Entity;
class NDK_API NodeComponent : public Component<NodeComponent>, public NzNode
class NDK_API NodeComponent : public Component<NodeComponent>, public Nz::Node
{
public:
NodeComponent() = default;
~NodeComponent() = default;
void SetParent(Entity* entity, bool keepDerived = false);
using NzNode::SetParent;
using Nz::Node::SetParent;
static ComponentIndex componentIndex;
};

View File

@@ -13,9 +13,9 @@ namespace Ndk
{
NazaraAssert(entity->HasComponent<NodeComponent>(), "Entity must have a NodeComponent");
NzNode::SetParent(entity->GetComponent<NodeComponent>(), keepDerived);
Nz::Node::SetParent(entity->GetComponent<NodeComponent>(), keepDerived);
}
else
NzNode::SetParent(nullptr, keepDerived);
Nz::Node::SetParent(nullptr, keepDerived);
}
}

View File

@@ -25,45 +25,45 @@ namespace Ndk
PhysicsComponent(const PhysicsComponent& physics);
~PhysicsComponent() = default;
void AddForce(const NzVector3f& force, nzCoordSys coordSys = nzCoordSys_Global);
void AddForce(const NzVector3f& force, const NzVector3f& point, nzCoordSys coordSys = nzCoordSys_Global);
void AddTorque(const NzVector3f& torque, nzCoordSys coordSys = nzCoordSys_Global);
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);
void AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys = Nz::CoordSys_Global);
void EnableAutoSleep(bool autoSleep);
NzBoxf GetAABB() const;
NzVector3f GetAngularVelocity() const;
Nz::Boxf GetAABB() const;
Nz::Vector3f GetAngularVelocity() const;
float GetGravityFactor() const;
float GetMass() const;
NzVector3f GetMassCenter(nzCoordSys coordSys = nzCoordSys_Local) const;
const NzMatrix4f& GetMatrix() const;
NzVector3f GetPosition() const;
NzQuaternionf GetRotation() const;
NzVector3f GetVelocity() const;
Nz::Vector3f GetMassCenter(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
const Nz::Matrix4f& GetMatrix() const;
Nz::Vector3f GetPosition() const;
Nz::Quaternionf GetRotation() const;
Nz::Vector3f GetVelocity() const;
bool IsAutoSleepEnabled() const;
bool IsMoveable() const;
bool IsSleeping() const;
void SetAngularVelocity(const NzVector3f& angularVelocity);
void SetAngularVelocity(const Nz::Vector3f& angularVelocity);
void SetGravityFactor(float gravityFactor);
void SetMass(float mass);
void SetMassCenter(const NzVector3f& center);
void SetPosition(const NzVector3f& position);
void SetRotation(const NzQuaternionf& rotation);
void SetVelocity(const NzVector3f& velocity);
void SetMassCenter(const Nz::Vector3f& center);
void SetPosition(const Nz::Vector3f& position);
void SetRotation(const Nz::Quaternionf& rotation);
void SetVelocity(const Nz::Vector3f& velocity);
static ComponentIndex componentIndex;
private:
NzPhysObject& GetPhysObject();
Nz::PhysObject& GetPhysObject();
void OnAttached() override;
void OnComponentAttached(BaseComponent& component) override;
void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override;
std::unique_ptr<NzPhysObject> m_object;
std::unique_ptr<Nz::PhysObject> m_object;
};
}

View File

@@ -12,21 +12,21 @@ namespace Ndk
NazaraUnused(physics);
}
inline void PhysicsComponent::AddForce(const NzVector3f& force, nzCoordSys coordSys)
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->AddForce(force, coordSys);
}
inline void PhysicsComponent::AddForce(const NzVector3f& force, const NzVector3f& point, nzCoordSys coordSys)
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->AddForce(force, point, coordSys);
}
inline void PhysicsComponent::AddTorque(const NzVector3f& torque, nzCoordSys coordSys)
inline void PhysicsComponent::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys)
{
NazaraAssert(m_object, "Invalid physics object");
@@ -40,14 +40,14 @@ namespace Ndk
m_object->EnableAutoSleep(autoSleep);
}
inline NzBoxf PhysicsComponent::GetAABB() const
inline Nz::Boxf PhysicsComponent::GetAABB() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetAABB();
}
inline NzVector3f PhysicsComponent::GetAngularVelocity() const
inline Nz::Vector3f PhysicsComponent::GetAngularVelocity() const
{
NazaraAssert(m_object, "Invalid physics object");
@@ -68,35 +68,35 @@ namespace Ndk
return m_object->GetMass();
}
inline NzVector3f PhysicsComponent::GetMassCenter(nzCoordSys coordSys) const
inline Nz::Vector3f PhysicsComponent::GetMassCenter(Nz::CoordSys coordSys) const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetMassCenter(coordSys);
}
inline const NzMatrix4f& PhysicsComponent::GetMatrix() const
inline const Nz::Matrix4f& PhysicsComponent::GetMatrix() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetMatrix();
}
inline NzVector3f PhysicsComponent::GetPosition() const
inline Nz::Vector3f PhysicsComponent::GetPosition() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetPosition();
}
inline NzQuaternionf PhysicsComponent::GetRotation() const
inline Nz::Quaternionf PhysicsComponent::GetRotation() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetRotation();
}
inline NzVector3f PhysicsComponent::GetVelocity() const
inline Nz::Vector3f PhysicsComponent::GetVelocity() const
{
NazaraAssert(m_object, "Invalid physics object");
@@ -117,7 +117,7 @@ namespace Ndk
return m_object->IsSleeping();
}
inline void PhysicsComponent::SetAngularVelocity(const NzVector3f& angularVelocity)
inline void PhysicsComponent::SetAngularVelocity(const Nz::Vector3f& angularVelocity)
{
NazaraAssert(m_object, "Invalid physics object");
@@ -139,35 +139,35 @@ namespace Ndk
m_object->SetMass(mass);
}
inline void PhysicsComponent::SetMassCenter(const NzVector3f& center)
inline void PhysicsComponent::SetMassCenter(const Nz::Vector3f& center)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetMassCenter(center);
}
inline void PhysicsComponent::SetPosition(const NzVector3f& position)
inline void PhysicsComponent::SetPosition(const Nz::Vector3f& position)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetPosition(position);
}
inline void PhysicsComponent::SetRotation(const NzQuaternionf& rotation)
inline void PhysicsComponent::SetRotation(const Nz::Quaternionf& rotation)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetRotation(rotation);
}
inline void PhysicsComponent::SetVelocity(const NzVector3f& velocity)
inline void PhysicsComponent::SetVelocity(const Nz::Vector3f& velocity)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetVelocity(velocity);
}
inline NzPhysObject& PhysicsComponent::GetPhysObject()
inline Nz::PhysObject& PhysicsComponent::GetPhysObject()
{
return *m_object.get();
}

View File

@@ -17,12 +17,12 @@ namespace Ndk
class NDK_API VelocityComponent : public Component<VelocityComponent>
{
public:
VelocityComponent(const NzVector3f& velocity = NzVector3f::Zero());
VelocityComponent(const Nz::Vector3f& velocity = Nz::Vector3f::Zero());
~VelocityComponent() = default;
NzVector3f linearVelocity;
Nz::Vector3f linearVelocity;
VelocityComponent& operator=(const NzVector3f& vel);
VelocityComponent& operator=(const Nz::Vector3f& vel);
static ComponentIndex componentIndex;
};

View File

@@ -7,12 +7,12 @@
namespace Ndk
{
inline VelocityComponent::VelocityComponent(const NzVector3f& velocity) :
inline VelocityComponent::VelocityComponent(const Nz::Vector3f& velocity) :
linearVelocity(velocity)
{
}
inline VelocityComponent& VelocityComponent::operator=(const NzVector3f& vel)
inline VelocityComponent& VelocityComponent::operator=(const Nz::Vector3f& vel)
{
linearVelocity = vel;
return *this;

View File

@@ -36,9 +36,9 @@ namespace Ndk
inline BaseComponent& GetComponent(ComponentIndex index);
template<typename ComponentType> ComponentType& GetComponent();
inline const NzBitset<>& GetComponentBits() const;
inline const Nz::Bitset<>& GetComponentBits() const;
inline EntityId GetId() const;
inline const NzBitset<>& GetSystemBits() const;
inline const Nz::Bitset<>& GetSystemBits() const;
inline World* GetWorld() const;
inline bool HasComponent(ComponentIndex index) const;
@@ -69,9 +69,9 @@ namespace Ndk
std::vector<std::unique_ptr<BaseComponent>> m_components;
std::vector<EntityHandle*> m_handles;
Nz::Bitset<> m_componentBits;
Nz::Bitset<> m_systemBits;
EntityId m_id;
NzBitset<> m_componentBits;
NzBitset<> m_systemBits;
World* m_world;
bool m_valid;
};

View File

@@ -40,7 +40,7 @@ namespace Ndk
return static_cast<ComponentType&>(GetComponent(index));
}
inline const NzBitset<>& Entity::GetComponentBits() const
inline const Nz::Bitset<>& Entity::GetComponentBits() const
{
return m_componentBits;
}
@@ -50,7 +50,7 @@ namespace Ndk
return m_id;
}
inline const NzBitset<>& Entity::GetSystemBits() const
inline const Nz::Bitset<>& Entity::GetSystemBits() const
{
return m_systemBits;
}

View File

@@ -33,7 +33,7 @@ namespace Ndk
EntityHandle& Swap(EntityHandle& handle);
NzString ToString() const;
Nz::String ToString() const;
operator bool() const;
operator Entity*() const;

View File

@@ -90,9 +90,9 @@ namespace Ndk
return *this;
}
inline NzString EntityHandle::ToString() const
inline Nz::String EntityHandle::ToString() const
{
NzStringStream ss;
Nz::StringStream ss;
ss << "EntityHandle(";
if (IsValid())
ss << "Entity(" << m_entity->GetId() << ')';
@@ -260,9 +260,9 @@ namespace Ndk
namespace std
{
template<>
struct hash<Ndk::EntityHandle>
{
template<>
struct hash<Ndk::EntityHandle>
{
size_t operator()(const Ndk::EntityHandle& handle) const
{
// Hasher le pointeur fonctionnerait jusqu'à ce que l'entité soit mise à jour et déplacée
@@ -271,9 +271,9 @@ namespace std
return hash<Ndk::EntityId>()(id);
}
};
};
inline void swap(Ndk::EntityHandle& lhs, Ndk::EntityHandle& rhs)
inline void swap(Ndk::EntityHandle& lhs, Ndk::EntityHandle& rhs)
{
lhs.Swap(rhs);
}

View File

@@ -54,7 +54,7 @@ namespace Ndk
private:
std::vector<EntityHandle> m_entities;
NzBitset<nzUInt64> m_entityBits;
Nz::Bitset<Nz::UInt64> m_entityBits;
};
}

View File

@@ -44,7 +44,7 @@ namespace Ndk
}
}
// Interface STD
// Nz::Interface STD
inline EntityList::Container::iterator EntityList::begin()
{
return m_entities.begin();

View File

@@ -57,10 +57,10 @@
namespace Ndk
{
using ComponentId = nzUInt64;
using ComponentIndex = nzUInt32;
using EntityId = nzUInt32;
using SystemIndex = nzUInt32;
using ComponentId = Nz::UInt64;
using ComponentIndex = Nz::UInt32;
using EntityId = Nz::UInt32;
using SystemIndex = Nz::UInt32;
}
#endif // NDK_PREREQUESITES_HPP

View File

@@ -20,8 +20,8 @@ namespace Ndk
PhysicsSystem(const PhysicsSystem& system);
~PhysicsSystem() = default;
NzPhysWorld& GetWorld();
const NzPhysWorld& GetWorld() const;
Nz::PhysWorld& GetWorld();
const Nz::PhysWorld& GetWorld() const;
static SystemIndex systemIndex;
@@ -31,7 +31,7 @@ namespace Ndk
EntityList m_dynamicObjects;
EntityList m_staticObjects;
NzPhysWorld m_world;
Nz::PhysWorld m_world;
};
}

View File

@@ -4,12 +4,12 @@
namespace Ndk
{
inline NzPhysWorld& PhysicsSystem::GetWorld()
inline Nz::PhysWorld& PhysicsSystem::GetWorld()
{
return m_world;
}
inline const NzPhysWorld& PhysicsSystem::GetWorld() const
inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const
{
return m_world;
}

View File

@@ -27,16 +27,16 @@ namespace Ndk
inline RenderSystem(const RenderSystem& renderSystem);
~RenderSystem() = default;
inline const NzBackgroundRef& GetDefaultBackground() const;
inline const NzMatrix4f& GetCoordinateSystemMatrix() const;
inline NzVector3f GetGlobalForward() const;
inline NzVector3f GetGlobalRight() const;
inline NzVector3f GetGlobalUp() const;
inline const Nz::BackgroundRef& GetDefaultBackground() const;
inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const;
inline Nz::Vector3f GetGlobalForward() const;
inline Nz::Vector3f GetGlobalRight() const;
inline Nz::Vector3f GetGlobalUp() const;
inline void SetDefaultBackground(NzBackgroundRef background);
inline void SetGlobalForward(const NzVector3f& direction);
inline void SetGlobalRight(const NzVector3f& direction);
inline void SetGlobalUp(const NzVector3f& direction);
inline void SetDefaultBackground(Nz::BackgroundRef background);
inline void SetGlobalForward(const Nz::Vector3f& direction);
inline void SetGlobalRight(const Nz::Vector3f& direction);
inline void SetGlobalUp(const Nz::Vector3f& direction);
static SystemIndex systemIndex;
@@ -46,7 +46,7 @@ namespace Ndk
void OnEntityRemoved(Entity* entity) override;
void OnEntityValidation(Entity* entity, bool justAdded) override;
void OnUpdate(float elapsedTime) override;
void UpdateDirectionalShadowMaps(const NzAbstractViewer& viewer);
void UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer);
void UpdatePointSpotShadowMaps();
EntityList m_cameras;
@@ -54,11 +54,11 @@ namespace Ndk
EntityList m_directionalLights;
EntityList m_lights;
EntityList m_pointSpotLights;
NzBackgroundRef m_background;
NzDepthRenderTechnique m_shadowTechnique;
NzForwardRenderTechnique m_renderTechnique;
NzMatrix4f m_coordinateSystemMatrix;
NzRenderTexture m_shadowRT;
Nz::BackgroundRef m_background;
Nz::DepthRenderTechnique m_shadowTechnique;
Nz::ForwardRenderTechnique m_renderTechnique;
Nz::Matrix4f m_coordinateSystemMatrix;
Nz::RenderTexture m_shadowRT;
bool m_coordinateSystemInvalidated;
};
}

View File

@@ -9,37 +9,37 @@ namespace Ndk
{
}
inline const NzBackgroundRef& RenderSystem::GetDefaultBackground() const
inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const
{
return m_background;
}
inline const NzMatrix4f& RenderSystem::GetCoordinateSystemMatrix() const
inline const Nz::Matrix4f& RenderSystem::GetCoordinateSystemMatrix() const
{
return m_coordinateSystemMatrix;
}
inline NzVector3f RenderSystem::GetGlobalForward() const
inline Nz::Vector3f RenderSystem::GetGlobalForward() const
{
return NzVector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33);
return Nz::Vector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33);
}
inline NzVector3f RenderSystem::GetGlobalRight() const
inline Nz::Vector3f RenderSystem::GetGlobalRight() const
{
return NzVector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31);
return Nz::Vector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31);
}
inline NzVector3f RenderSystem::GetGlobalUp() const
inline Nz::Vector3f RenderSystem::GetGlobalUp() const
{
return NzVector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32);
return Nz::Vector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32);
}
inline void RenderSystem::SetDefaultBackground(NzBackgroundRef background)
inline void RenderSystem::SetDefaultBackground(Nz::BackgroundRef background)
{
m_background = std::move(background);
}
inline void RenderSystem::SetGlobalForward(const NzVector3f& direction)
inline void RenderSystem::SetGlobalForward(const Nz::Vector3f& direction)
{
m_coordinateSystemMatrix.m13 = -direction.x;
m_coordinateSystemMatrix.m23 = -direction.y;
@@ -48,7 +48,7 @@ namespace Ndk
InvalidateCoordinateSystem();
}
inline void RenderSystem::SetGlobalRight(const NzVector3f& direction)
inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction)
{
m_coordinateSystemMatrix.m11 = direction.x;
m_coordinateSystemMatrix.m21 = direction.y;
@@ -57,7 +57,7 @@ namespace Ndk
InvalidateCoordinateSystem();
}
inline void RenderSystem::SetGlobalUp(const NzVector3f& direction)
inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction)
{
m_coordinateSystemMatrix.m12 = direction.x;
m_coordinateSystemMatrix.m22 = direction.y;

View File

@@ -8,7 +8,6 @@
#define NDK_WORLD_HPP
#include <Nazara/Core/Bitset.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <NDK/Entity.hpp>
#include <NDK/EntityHandle.hpp>
#include <NDK/System.hpp>
@@ -19,7 +18,7 @@
namespace Ndk
{
class NDK_API World : NzNonCopyable
class NDK_API World
{
friend Entity;
@@ -27,6 +26,8 @@ namespace Ndk
using EntityList = std::vector<EntityHandle>;
inline World(bool addDefaultSystems = true);
World(const World&) = delete;
World(World&&) = delete; ///TODO
~World();
void AddDefaultSystems();
@@ -60,6 +61,9 @@ namespace Ndk
void Update();
inline void Update(float elapsedTime);
World& operator=(const World&) = delete;
World& operator=(World&&) = delete; ///TODO
private:
inline void Invalidate();
inline void Invalidate(EntityId id);
@@ -81,8 +85,8 @@ namespace Ndk
std::vector<EntityBlock> m_entities;
std::vector<EntityId> m_freeIdList;
EntityList m_aliveEntities;
NzBitset<nzUInt64> m_dirtyEntities;
NzBitset<nzUInt64> m_killedEntities;
Nz::Bitset<Nz::UInt64> m_dirtyEntities;
Nz::Bitset<Nz::UInt64> m_killedEntities;
};
}

View File

@@ -136,7 +136,10 @@ namespace Ndk
// And then update systems
for (auto& systemPtr : m_systems)
systemPtr->Update(elapsedTime);
{
if (systemPtr)
systemPtr->Update(elapsedTime);
}
}
inline void World::Invalidate()

View File

@@ -17,15 +17,15 @@ namespace Ndk
if (!entity)
return false;
const NzBitset<>& components = entity->GetComponentBits();
const Nz::Bitset<>& components = entity->GetComponentBits();
m_filterResult.PerformsAND(m_requiredComponents, components);
if (m_filterResult != m_requiredComponents)
return false; // Au moins un component requis n'est pas présent
m_filterResult.PerformsAND(m_requiredComponents, components);
if (m_filterResult != m_requiredComponents)
return false; // Au moins un component requis n'est pas présent
m_filterResult.PerformsAND(m_excludedComponents, components);
if (m_filterResult.TestAny())
return false; // Au moins un component exclu est présent
m_filterResult.PerformsAND(m_excludedComponents, components);
if (m_filterResult.TestAny())
return false; // Au moins un component exclu est présent
// Si nous avons une liste de composants nécessaires
if (m_requiredAnyComponents.TestAny())
@@ -34,7 +34,7 @@ namespace Ndk
return false;
}
return true;
return true;
}
void BaseSystem::OnEntityAdded(Entity* entity)

View File

@@ -17,20 +17,20 @@ namespace Ndk
EnsureViewMatrixUpdate();
EnsureViewportUpdate();
NzRenderer::SetMatrix(nzMatrixType_Projection, m_projectionMatrix);
NzRenderer::SetMatrix(nzMatrixType_View, m_viewMatrix);
NzRenderer::SetTarget(m_target);
NzRenderer::SetViewport(m_viewport);
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, m_projectionMatrix);
Nz::Renderer::SetMatrix(Nz::MatrixType_View, m_viewMatrix);
Nz::Renderer::SetTarget(m_target);
Nz::Renderer::SetViewport(m_viewport);
}
NzVector3f CameraComponent::GetEyePosition() const
Nz::Vector3f CameraComponent::GetEyePosition() const
{
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
return m_entity->GetComponent<NodeComponent>().GetPosition();
}
NzVector3f CameraComponent::GetForward() const
Nz::Vector3f CameraComponent::GetForward() const
{
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
@@ -80,7 +80,7 @@ namespace Ndk
InvalidateViewMatrix();
}
void CameraComponent::OnNodeInvalidated(const NzNode* node)
void CameraComponent::OnNodeInvalidated(const Nz::Node* node)
{
NazaraUnused(node);
@@ -88,20 +88,20 @@ namespace Ndk
InvalidateViewMatrix();
}
void CameraComponent::OnRenderTargetRelease(const NzRenderTarget* renderTarget)
void CameraComponent::OnRenderTargetRelease(const Nz::RenderTarget* renderTarget)
{
if (renderTarget == m_target)
m_target = nullptr;
else
NazaraInternalError("Not listening to " + NzString::Pointer(renderTarget));
NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget));
}
void CameraComponent::OnRenderTargetSizeChange(const NzRenderTarget* renderTarget)
void CameraComponent::OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget)
{
if (renderTarget == m_target)
InvalidateViewport();
else
NazaraInternalError("Not listening to " + NzString::Pointer(renderTarget));
NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget));
}
void CameraComponent::UpdateFrustum() const
@@ -118,13 +118,13 @@ namespace Ndk
{
switch (m_projectionType)
{
case nzProjectionType_Orthogonal:
case Nz::ProjectionType_Orthogonal:
EnsureViewportUpdate();
m_projectionMatrix.MakeOrtho(0.f, static_cast<float>(m_viewport.width), 0.f, static_cast<float>(m_viewport.height), m_zNear, m_zFar);
break;
case nzProjectionType_Perspective:
case Nz::ProjectionType_Perspective:
EnsureViewportUpdate(); // Can affect aspect ratio
m_projectionMatrix.MakePerspective(m_fov, m_aspectRatio, m_zNear, m_zFar);
@@ -141,7 +141,7 @@ namespace Ndk
NodeComponent& nodeComponent = m_entity->GetComponent<NodeComponent>();
// Build the view matrix using the NodeComponent position/rotation
m_viewMatrix.MakeViewMatrix(nodeComponent.GetPosition(nzCoordSys_Global), nodeComponent.GetRotation(nzCoordSys_Global));
m_viewMatrix.MakeViewMatrix(nodeComponent.GetPosition(Nz::CoordSys_Global), nodeComponent.GetRotation(Nz::CoordSys_Global));
m_viewMatrixUpdated = true;
}
@@ -153,7 +153,7 @@ namespace Ndk
unsigned int targetHeight = std::max(m_target->GetHeight(), 1U); // Let's make sure we won't divide by zero
// Our target region is expressed as % of the viewport dimensions, let's compute it in pixels
NzRectf fViewport(m_targetRegion);
Nz::Rectf fViewport(m_targetRegion);
fViewport.x *= targetWidth;
fViewport.y *= targetHeight;
fViewport.width *= targetWidth;
@@ -161,11 +161,11 @@ namespace Ndk
// Compute the new aspect ratio, if it's different we need to invalidate the projection matrix
float aspectRatio = fViewport.width/fViewport.height;
if (!NzNumberEquals(m_aspectRatio, aspectRatio, 0.001f))
if (!Nz::NumberEquals(m_aspectRatio, aspectRatio, 0.001f))
{
m_aspectRatio = aspectRatio;
if (m_projectionType == nzProjectionType_Perspective)
if (m_projectionType == Nz::ProjectionType_Perspective)
InvalidateProjectionMatrix();
}

View File

@@ -11,7 +11,7 @@
namespace Ndk
{
void CollisionComponent::SetGeom(NzPhysGeomRef geom)
void CollisionComponent::SetGeom(Nz::PhysGeomRef geom)
{
m_geom = std::move(geom);
@@ -35,9 +35,9 @@ namespace Ndk
NazaraAssert(entityWorld, "Entity must have world");
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
NzPhysWorld& physWorld = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
Nz::PhysWorld& physWorld = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
m_staticBody.reset(new NzPhysObject(&physWorld, m_geom));
m_staticBody.reset(new Nz::PhysObject(&physWorld, m_geom));
m_staticBody->EnableAutoSleep(false);
}

View File

@@ -9,7 +9,7 @@
namespace Ndk
{
void GraphicsComponent::InvalidateRenderableData(const NzInstancedRenderable* renderable, nzUInt32 flags, unsigned int index)
void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index)
{
NazaraAssert(index < m_renderables.size(), "Invalid renderable index");
NazaraUnused(renderable);
@@ -55,7 +55,7 @@ namespace Ndk
InvalidateTransformMatrix();
}
void GraphicsComponent::OnNodeInvalidated(const NzNode* node)
void GraphicsComponent::OnNodeInvalidated(const Nz::Node* node)
{
NazaraUnused(node);
@@ -69,7 +69,7 @@ namespace Ndk
Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem<Ndk::RenderSystem>();
m_transformMatrix = NzMatrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), m_entity->GetComponent<NodeComponent>().GetTransformMatrix());
m_transformMatrix = Nz::Matrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), m_entity->GetComponent<NodeComponent>().GetTransformMatrix());
m_transformMatrixUpdated = true;
}

View File

@@ -17,19 +17,19 @@ namespace Ndk
World* entityWorld = m_entity->GetWorld();
NazaraAssert(entityWorld->HasSystem<PhysicsSystem>(), "World must have a physics system");
NzPhysWorld& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
Nz::PhysWorld& world = entityWorld->GetSystem<PhysicsSystem>().GetWorld();
NzPhysGeomRef geom;
Nz::PhysGeomRef geom;
if (m_entity->HasComponent<CollisionComponent>())
geom = m_entity->GetComponent<CollisionComponent>().GetGeom();
NzMatrix4f matrix;
Nz::Matrix4f matrix;
if (m_entity->HasComponent<NodeComponent>())
matrix = m_entity->GetComponent<NodeComponent>().GetTransformMatrix();
else
matrix.MakeIdentity();
m_object.reset(new NzPhysObject(&world, geom, matrix));
m_object.reset(new Nz::PhysObject(&world, geom, matrix));
m_object->SetMass(1.f);
}
@@ -47,7 +47,7 @@ namespace Ndk
if (IsComponent<CollisionComponent>(component))
{
NazaraAssert(m_object, "Invalid object");
m_object->SetGeom(NzNullGeom::New());
m_object->SetGeom(Nz::NullGeom::New());
}
}

View File

@@ -12,9 +12,9 @@ namespace Ndk
Entity::Entity(Entity&& entity) :
m_components(std::move(entity.m_components)),
m_handles(std::move(entity.m_handles)),
m_id(entity.m_id),
m_componentBits(std::move(entity.m_componentBits)),
m_systemBits(std::move(entity.m_systemBits)),
m_id(entity.m_id),
m_world(entity.m_world),
m_valid(entity.m_valid)
{

View File

@@ -35,19 +35,19 @@ namespace Ndk
try
{
NzErrorFlags errFlags(nzErrorFlag_ThrowException, true);
Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true);
// Initialisation du moteur
// Modules clients
NzAudio::Initialize();
NzGraphics::Initialize();
Nz::Audio::Initialize();
Nz::Graphics::Initialize();
// Modules serveurs
NzLua::Initialize();
NzNoise::Initialize();
NzPhysics::Initialize();
NzUtility::Initialize();
Nz::Lua::Initialize();
Nz::Noise::Initialize();
Nz::Physics::Initialize();
Nz::Utility::Initialize();
// Initialisation du SDK
@@ -76,7 +76,7 @@ namespace Ndk
}
catch (const std::exception& e)
{
NazaraError("Failed to initialize NDK: " + NzString(e.what()));
NazaraError("Failed to initialize NDK: " + Nz::String(e.what()));
return false;
}
@@ -99,14 +99,14 @@ namespace Ndk
// Libération du moteur
// Modules clients
NzAudio::Uninitialize();
NzGraphics::Uninitialize();
Nz::Audio::Uninitialize();
Nz::Graphics::Uninitialize();
// Modules serveurs
NzLua::Uninitialize();
NzNoise::Uninitialize();
NzPhysics::Uninitialize();
NzUtility::Uninitialize();
Nz::Lua::Uninitialize();
Nz::Noise::Uninitialize();
Nz::Physics::Uninitialize();
Nz::Utility::Uninitialize();
NazaraNotice("Uninitialized: SDK");
}

View File

@@ -30,22 +30,22 @@ namespace Ndk
// On récupère la position et la rotation pour les affecter au listener
const NodeComponent& node = entity->GetComponent<NodeComponent>();
NzAudio::SetListenerPosition(node.GetPosition(nzCoordSys_Global));
NzAudio::SetListenerRotation(node.GetRotation(nzCoordSys_Global));
Nz::Audio::SetListenerPosition(node.GetPosition(Nz::CoordSys_Global));
Nz::Audio::SetListenerRotation(node.GetRotation(Nz::CoordSys_Global));
// On vérifie la présence d'une donnée de vitesse, et on l'affecte
// (La vitesse du listener Audio ne le fait pas se déplacer, mais affecte par exemple l'effet Doppler)
if (entity->HasComponent<VelocityComponent>())
{
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
NzAudio::SetListenerVelocity(velocity.linearVelocity);
Nz::Audio::SetListenerVelocity(velocity.linearVelocity);
}
activeListenerCount++;
}
if (activeListenerCount > 1)
NazaraWarning(NzString::Number(activeListenerCount) + " listeners were active in the same update loop");
NazaraWarning(Nz::String::Number(activeListenerCount) + " listeners were active in the same update loop");
}
SystemIndex ListenerSystem::systemIndex;

View File

@@ -45,9 +45,9 @@ namespace Ndk
NodeComponent& node = entity->GetComponent<NodeComponent>();
PhysicsComponent& phys = entity->GetComponent<PhysicsComponent>();
NzPhysObject& physObj = phys.GetPhysObject();
node.SetRotation(physObj.GetRotation(), nzCoordSys_Global);
node.SetPosition(physObj.GetPosition(), nzCoordSys_Global);
Nz::PhysObject& physObj = phys.GetPhysObject();
node.SetRotation(physObj.GetRotation(), Nz::CoordSys_Global);
node.SetPosition(physObj.GetPosition(), Nz::CoordSys_Global);
}
float invElapsedTime = 1.f / elapsedTime;
@@ -56,12 +56,12 @@ namespace Ndk
CollisionComponent& collision = entity->GetComponent<CollisionComponent>();
NodeComponent& node = entity->GetComponent<NodeComponent>();
NzPhysObject* physObj = collision.GetStaticBody();
Nz::PhysObject* physObj = collision.GetStaticBody();
NzQuaternionf oldRotation = physObj->GetRotation();
NzVector3f oldPosition = physObj->GetPosition();
NzQuaternionf newRotation = node.GetRotation(nzCoordSys_Global);
NzVector3f newPosition = node.GetPosition(nzCoordSys_Global);
Nz::Quaternionf oldRotation = physObj->GetRotation();
Nz::Vector3f oldPosition = physObj->GetPosition();
Nz::Quaternionf newRotation = node.GetRotation(Nz::CoordSys_Global);
Nz::Vector3f newPosition = node.GetPosition(Nz::CoordSys_Global);
// Pour déplacer des objets statiques et assurer les collisions, il faut leur définir une vitesse
// (note importante: le moteur physique n'applique pas la vitesse sur les objets statiques)
@@ -71,21 +71,21 @@ namespace Ndk
physObj->SetVelocity((newPosition - oldPosition) * invElapsedTime);
}
else
physObj->SetVelocity(NzVector3f::Zero());
physObj->SetVelocity(Nz::Vector3f::Zero());
if (newRotation != oldRotation)
{
NzQuaternionf transition = newRotation * oldRotation.GetConjugate();
NzEulerAnglesf angles = transition.ToEulerAngles();
NzVector3f angularVelocity(NzToRadians(angles.pitch * invElapsedTime),
NzToRadians(angles.yaw * invElapsedTime),
NzToRadians(angles.roll * invElapsedTime));
Nz::Quaternionf transition = newRotation * oldRotation.GetConjugate();
Nz::EulerAnglesf angles = transition.ToEulerAngles();
Nz::Vector3f angularVelocity(Nz::ToRadians(angles.pitch * invElapsedTime),
Nz::ToRadians(angles.yaw * invElapsedTime),
Nz::ToRadians(angles.roll * invElapsedTime));
physObj->SetRotation(oldRotation);
physObj->SetAngularVelocity(angularVelocity);
}
else
physObj->SetAngularVelocity(NzVector3f::Zero());
physObj->SetAngularVelocity(Nz::Vector3f::Zero());
}
}

View File

@@ -13,10 +13,10 @@
namespace Ndk
{
RenderSystem::RenderSystem() :
m_coordinateSystemMatrix(NzMatrix4f::Identity()),
m_coordinateSystemMatrix(Nz::Matrix4f::Identity()),
m_coordinateSystemInvalidated(true)
{
SetDefaultBackground(NzColorBackground::New());
SetDefaultBackground(Nz::ColorBackground::New());
SetUpdateRate(0.f);
}
@@ -50,7 +50,7 @@ namespace Ndk
if (entity->HasComponent<LightComponent>() && entity->HasComponent<NodeComponent>())
{
LightComponent& lightComponent = entity->GetComponent<LightComponent>();
if (lightComponent.GetLightType() == nzLightType_Directional)
if (lightComponent.GetLightType() == Nz::LightType_Directional)
{
m_directionalLights.Insert(entity);
m_pointSpotLights.Remove(entity);
@@ -95,7 +95,7 @@ namespace Ndk
//UpdateDirectionalShadowMaps(camComponent);
NzAbstractRenderQueue* renderQueue = m_renderTechnique.GetRenderQueue();
Nz::AbstractRenderQueue* renderQueue = m_renderTechnique.GetRenderQueue();
renderQueue->Clear();
//TODO: Culling
@@ -113,13 +113,13 @@ namespace Ndk
NodeComponent& lightNode = light->GetComponent<NodeComponent>();
///TODO: Cache somehow?
lightComponent.AddToRenderQueue(renderQueue, NzMatrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix()));
lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix()));
}
camComponent.ApplyView();
NzSceneData sceneData;
sceneData.ambientColor = NzColor(25, 25, 25);
Nz::SceneData sceneData;
sceneData.ambientColor = Nz::Color(25, 25, 25);
sceneData.background = m_background;
sceneData.viewer = &camComponent;
@@ -127,13 +127,13 @@ namespace Ndk
}
}
void RenderSystem::UpdateDirectionalShadowMaps(const NzAbstractViewer& viewer)
void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer)
{
if (!m_shadowRT.IsValid())
m_shadowRT.Create();
NzSceneData dummySceneData;
dummySceneData.ambientColor = NzColor(0, 0, 0);
Nz::SceneData dummySceneData;
dummySceneData.ambientColor = Nz::Color(0, 0, 0);
dummySceneData.background = nullptr;
dummySceneData.viewer = nullptr; //< Depth technique doesn't require any viewer
@@ -145,13 +145,13 @@ namespace Ndk
if (!lightComponent.IsShadowCastingEnabled())
continue;
NzVector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
Nz::Vector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
m_shadowRT.AttachTexture(nzAttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
NzRenderer::SetTarget(&m_shadowRT);
NzRenderer::SetViewport(NzRecti(0, 0, shadowMapSize.x, shadowMapSize.y));
m_shadowRT.AttachTexture(Nz::AttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
Nz::Renderer::SetTarget(&m_shadowRT);
Nz::Renderer::SetViewport(Nz::Recti(0, 0, shadowMapSize.x, shadowMapSize.y));
NzAbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
Nz::AbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
renderQueue->Clear();
///TODO: Culling
@@ -164,8 +164,8 @@ namespace Ndk
}
///TODO: Cache the matrices in the light?
NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Ortho(0.f, 100.f, 100.f, 0.f, 1.f, 100.f));
NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::ViewMatrix(lightNode.GetRotation() * NzVector3f::Forward() * 100.f, lightNode.GetRotation()));
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, Nz::Matrix4f::Ortho(0.f, 100.f, 100.f, 0.f, 1.f, 100.f));
Nz::Renderer::SetMatrix(Nz::MatrixType_View, Nz::Matrix4f::ViewMatrix(lightNode.GetRotation() * Nz::Vector3f::Forward() * 100.f, lightNode.GetRotation()));
m_shadowTechnique.Draw(dummySceneData);
}
@@ -176,8 +176,8 @@ namespace Ndk
if (!m_shadowRT.IsValid())
m_shadowRT.Create();
NzSceneData dummySceneData;
dummySceneData.ambientColor = NzColor(0, 0, 0);
Nz::SceneData dummySceneData;
dummySceneData.ambientColor = Nz::Color(0, 0, 0);
dummySceneData.background = nullptr;
dummySceneData.viewer = nullptr; //< Depth technique doesn't require any viewer
@@ -189,37 +189,37 @@ namespace Ndk
if (!lightComponent.IsShadowCastingEnabled())
continue;
NzVector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
Nz::Vector2ui shadowMapSize(lightComponent.GetShadowMap()->GetSize());
switch (lightComponent.GetLightType())
{
case nzLightType_Directional:
case Nz::LightType_Directional:
NazaraInternalError("Directional lights included in point/spot light list");
break;
case nzLightType_Point:
case Nz::LightType_Point:
{
static NzQuaternionf rotations[6] =
static Nz::Quaternionf rotations[6] =
{
NzQuaternionf::RotationBetween(NzVector3f::Forward(), NzVector3f::UnitX()), // nzCubemapFace_PositiveX
NzQuaternionf::RotationBetween(NzVector3f::Forward(), -NzVector3f::UnitX()), // nzCubemapFace_NegativeX
NzQuaternionf::RotationBetween(NzVector3f::Forward(), -NzVector3f::UnitY()), // nzCubemapFace_PositiveY
NzQuaternionf::RotationBetween(NzVector3f::Forward(), NzVector3f::UnitY()), // nzCubemapFace_NegativeY
NzQuaternionf::RotationBetween(NzVector3f::Forward(), -NzVector3f::UnitZ()), // nzCubemapFace_PositiveZ
NzQuaternionf::RotationBetween(NzVector3f::Forward(), NzVector3f::UnitZ()) // nzCubemapFace_NegativeZ
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitX()), // nzCubemapFace_PositiveX
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitX()), // nzCubemapFace_NegativeX
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitY()), // nzCubemapFace_PositiveY
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitY()), // nzCubemapFace_NegativeY
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), -Nz::Vector3f::UnitZ()), // nzCubemapFace_PositiveZ
Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::UnitZ()) // nzCubemapFace_NegativeZ
};
for (unsigned int face = 0; face < 6; ++face)
{
m_shadowRT.AttachTexture(nzAttachmentPoint_Depth, 0, lightComponent.GetShadowMap(), face);
NzRenderer::SetTarget(&m_shadowRT);
NzRenderer::SetViewport(NzRecti(0, 0, shadowMapSize.x, shadowMapSize.y));
m_shadowRT.AttachTexture(Nz::AttachmentPoint_Depth, 0, lightComponent.GetShadowMap(), face);
Nz::Renderer::SetTarget(&m_shadowRT);
Nz::Renderer::SetViewport(Nz::Recti(0, 0, shadowMapSize.x, shadowMapSize.y));
///TODO: Cache the matrices in the light?
NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Perspective(NzFromDegrees(90.f), 1.f, 0.1f, lightComponent.GetRadius()));
NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::ViewMatrix(lightNode.GetPosition(), rotations[face]));
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, Nz::Matrix4f::Perspective(Nz::FromDegrees(90.f), 1.f, 0.1f, lightComponent.GetRadius()));
Nz::Renderer::SetMatrix(Nz::MatrixType_View, Nz::Matrix4f::ViewMatrix(lightNode.GetPosition(), rotations[face]));
NzAbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
Nz::AbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
renderQueue->Clear();
///TODO: Culling
@@ -236,16 +236,17 @@ namespace Ndk
break;
}
case nzLightType_Spot:
m_shadowRT.AttachTexture(nzAttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
NzRenderer::SetTarget(&m_shadowRT);
NzRenderer::SetViewport(NzRecti(0, 0, shadowMapSize.x, shadowMapSize.y));
case Nz::LightType_Spot:
{
m_shadowRT.AttachTexture(Nz::AttachmentPoint_Depth, 0, lightComponent.GetShadowMap());
Nz::Renderer::SetTarget(&m_shadowRT);
Nz::Renderer::SetViewport(Nz::Recti(0, 0, shadowMapSize.x, shadowMapSize.y));
///TODO: Cache the matrices in the light?
NzRenderer::SetMatrix(nzMatrixType_Projection, NzMatrix4f::Perspective(lightComponent.GetOuterAngle()*2.f, 1.f, 0.1f, lightComponent.GetRadius()));
NzRenderer::SetMatrix(nzMatrixType_View, NzMatrix4f::ViewMatrix(lightNode.GetPosition(), lightNode.GetRotation()));
Nz::Renderer::SetMatrix(Nz::MatrixType_Projection, Nz::Matrix4f::Perspective(lightComponent.GetOuterAngle()*2.f, 1.f, 0.1f, lightComponent.GetRadius()));
Nz::Renderer::SetMatrix(Nz::MatrixType_View, Nz::Matrix4f::ViewMatrix(lightNode.GetPosition(), lightNode.GetRotation()));
NzAbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
Nz::AbstractRenderQueue* renderQueue = m_shadowTechnique.GetRenderQueue();
renderQueue->Clear();
///TODO: Culling
@@ -259,6 +260,7 @@ namespace Ndk
m_shadowTechnique.Draw(dummySceneData);
break;
}
}
}
}

View File

@@ -132,6 +132,10 @@ namespace Ndk
{
for (auto& system : m_systems)
{
// Ignore non-existent systems
if (!system)
continue;
// L'entité est-elle enregistrée comme faisant partie du système ?
bool partOfSystem = system->HasEntity(entity);