Merge remote-tracking branch 'refs/remotes/origin/master' into gui
This commit is contained in:
@@ -59,7 +59,7 @@ namespace Ndk
|
||||
* \param args Arguments used to create the window
|
||||
*/
|
||||
#ifndef NDK_SERVER
|
||||
template<typename T, typename... Args>
|
||||
template<typename T, typename... Args>
|
||||
T& Application::AddWindow(Args&&... args)
|
||||
{
|
||||
static_assert(std::is_base_of<Nz::Window, T>::value, "Type must inherit Window");
|
||||
@@ -82,7 +82,7 @@ namespace Ndk
|
||||
* \param args Arguments used to create the world
|
||||
*/
|
||||
|
||||
template<typename... Args>
|
||||
template<typename... Args>
|
||||
World& Application::AddWorld(Args&&... args)
|
||||
{
|
||||
m_worlds.emplace_back(std::forward<Args>(args)...);
|
||||
@@ -373,9 +373,9 @@ namespace Ndk
|
||||
{
|
||||
}
|
||||
|
||||
inline Application::WindowInfo::WindowInfo(std::unique_ptr<Nz::Window>&& window) :
|
||||
inline Application::WindowInfo::WindowInfo(std::unique_ptr<Nz::Window>&& windowPtr) :
|
||||
renderTarget(nullptr),
|
||||
window(std::move(window))
|
||||
window(std::move(windowPtr))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Ndk
|
||||
|
||||
inline const std::vector<EntityHandle>& GetEntities() const;
|
||||
inline SystemIndex GetIndex() const;
|
||||
inline int GetUpdateOrder() const;
|
||||
inline float GetUpdateRate() const;
|
||||
inline World& GetWorld() const;
|
||||
|
||||
@@ -42,6 +43,7 @@ namespace Ndk
|
||||
|
||||
inline bool HasEntity(const Entity* entity) const;
|
||||
|
||||
void SetUpdateOrder(int updateOrder);
|
||||
inline void SetUpdateRate(float updatePerSecond);
|
||||
|
||||
inline void Update(float elapsedTime);
|
||||
@@ -93,6 +95,7 @@ namespace Ndk
|
||||
bool m_updateEnabled;
|
||||
float m_updateCounter;
|
||||
float m_updateRate;
|
||||
int m_updateOrder;
|
||||
|
||||
static SystemIndex s_nextIndex;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace Ndk
|
||||
|
||||
inline BaseSystem::BaseSystem(SystemIndex systemId) :
|
||||
m_systemIndex(systemId),
|
||||
m_updateEnabled(true)
|
||||
m_world(nullptr),
|
||||
m_updateEnabled(true),
|
||||
m_updateOrder(0)
|
||||
{
|
||||
SetUpdateRate(30);
|
||||
}
|
||||
@@ -33,7 +35,8 @@ namespace Ndk
|
||||
m_systemIndex(system.m_systemIndex),
|
||||
m_updateEnabled(system.m_updateEnabled),
|
||||
m_updateCounter(0.f),
|
||||
m_updateRate(system.m_updateRate)
|
||||
m_updateRate(system.m_updateRate),
|
||||
m_updateOrder(system.m_updateOrder)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -69,7 +72,18 @@ namespace Ndk
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the rate of update for the system
|
||||
* \brief Gets the update order of the system
|
||||
* \return Update order
|
||||
*
|
||||
* \see SetUpdateOrder
|
||||
*/
|
||||
inline int BaseSystem::GetUpdateOrder() const
|
||||
{
|
||||
return m_updateOrder;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the rate of update of the system
|
||||
* \return Update rate
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 30 Jul 2016 at 15:29:16
|
||||
// This file was automatically generated
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define NDK_COMPONENTS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <NDK/Components/CollisionComponent2D.hpp>
|
||||
#include <NDK/Components/CollisionComponent3D.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/LightComponent.hpp>
|
||||
@@ -13,6 +14,7 @@
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NDK/Components/PhysicsComponent2D.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Components/VelocityComponent.hpp>
|
||||
|
||||
|
||||
@@ -18,9 +18,12 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class CameraComponent;
|
||||
class Entity;
|
||||
|
||||
class NDK_API CameraComponent : public Component<CameraComponent>, public Nz::AbstractViewer
|
||||
using CameraComponentHandle = Nz::ObjectHandle<CameraComponent>;
|
||||
|
||||
class NDK_API CameraComponent : public Component<CameraComponent>, public Nz::AbstractViewer, public Nz::HandledObject<CameraComponent>
|
||||
{
|
||||
public:
|
||||
inline CameraComponent();
|
||||
@@ -51,7 +54,7 @@ namespace Ndk
|
||||
float GetZNear() const override;
|
||||
|
||||
inline void SetFOV(float fov);
|
||||
inline void SetLayer(unsigned int layer);
|
||||
void SetLayer(unsigned int layer);
|
||||
inline void SetProjectionType(Nz::ProjectionType projection);
|
||||
inline void SetSize(const Nz::Vector2f& size);
|
||||
inline void SetSize(float width, float height);
|
||||
@@ -61,6 +64,8 @@ namespace Ndk
|
||||
inline void SetZFar(float zFar);
|
||||
inline void SetZNear(float zNear);
|
||||
|
||||
inline bool UpdateVisibility(std::size_t visibilityHash);
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
@@ -86,6 +91,7 @@ namespace Ndk
|
||||
NazaraSlot(Nz::RenderTarget, OnRenderTargetRelease, m_targetReleaseSlot);
|
||||
NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, m_targetResizeSlot);
|
||||
|
||||
std::size_t m_visibilityHash;
|
||||
Nz::ProjectionType m_projectionType;
|
||||
mutable Nz::Frustumf m_frustum;
|
||||
mutable Nz::Matrix4f m_projectionMatrix;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Ndk
|
||||
*/
|
||||
|
||||
inline CameraComponent::CameraComponent() :
|
||||
m_visibilityHash(0U),
|
||||
m_projectionType(Nz::ProjectionType_Perspective),
|
||||
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
||||
m_target(nullptr),
|
||||
@@ -38,6 +39,7 @@ namespace Ndk
|
||||
inline CameraComponent::CameraComponent(const CameraComponent& camera) :
|
||||
Component(camera),
|
||||
AbstractViewer(camera),
|
||||
m_visibilityHash(camera.m_visibilityHash),
|
||||
m_projectionType(camera.m_projectionType),
|
||||
m_targetRegion(camera.m_targetRegion),
|
||||
m_target(nullptr),
|
||||
@@ -99,7 +101,7 @@ namespace Ndk
|
||||
* \brief Gets the field of view of the camera
|
||||
* \return Field of view of the camera
|
||||
*/
|
||||
float CameraComponent::GetFOV() const
|
||||
inline float CameraComponent::GetFOV() const
|
||||
{
|
||||
return m_fov;
|
||||
}
|
||||
@@ -280,6 +282,26 @@ namespace Ndk
|
||||
InvalidateProjectionMatrix();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Update the camera component visibility hash
|
||||
*
|
||||
* This is used with CullingList (which produce a visibility hash)
|
||||
*
|
||||
* \param visibilityHash New visibility hash
|
||||
*
|
||||
* \return True if the visibility hash is not the same as before
|
||||
*/
|
||||
inline bool CameraComponent::UpdateVisibility(std::size_t visibilityHash)
|
||||
{
|
||||
if (m_visibilityHash != visibilityHash)
|
||||
{
|
||||
m_visibilityHash = visibilityHash;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the frustum
|
||||
*/
|
||||
|
||||
58
SDK/include/NDK/Components/CollisionComponent2D.hpp
Normal file
58
SDK/include/NDK/Components/CollisionComponent2D.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// 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_COMPONENTS_COLLISIONCOMPONENT2D_HPP
|
||||
#define NDK_COMPONENTS_COLLISIONCOMPONENT2D_HPP
|
||||
|
||||
#include <Nazara/Physics2D/Collider2D.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RigidBody2D;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API CollisionComponent2D : public Component<CollisionComponent2D>
|
||||
{
|
||||
friend class PhysicsSystem2D;
|
||||
|
||||
public:
|
||||
CollisionComponent2D(Nz::Collider2DRef geom = Nz::Collider2DRef());
|
||||
CollisionComponent2D(const CollisionComponent2D& collision);
|
||||
~CollisionComponent2D() = default;
|
||||
|
||||
const Nz::Collider2DRef& GetGeom() const;
|
||||
|
||||
void SetGeom(Nz::Collider2DRef geom);
|
||||
|
||||
CollisionComponent2D& operator=(Nz::Collider2DRef geom);
|
||||
CollisionComponent2D& operator=(CollisionComponent2D&& collision) = default;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
void InitializeStaticBody();
|
||||
Nz::RigidBody2D* GetStaticBody();
|
||||
|
||||
void OnAttached() override;
|
||||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
|
||||
std::unique_ptr<Nz::RigidBody2D> m_staticBody;
|
||||
Nz::Collider2DRef m_geom;
|
||||
bool m_bodyUpdated;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Components/CollisionComponent2D.inl>
|
||||
|
||||
#endif // NDK_COMPONENTS_COLLISIONCOMPONENT2D_HPP
|
||||
70
SDK/include/NDK/Components/CollisionComponent2D.inl
Normal file
70
SDK/include/NDK/Components/CollisionComponent2D.inl
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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
|
||||
|
||||
#include <NDK/Components/CollisionComponent2D.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/PhysicsComponent2D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem2D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a CollisionComponent2D object with a geometry
|
||||
*
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent2D::CollisionComponent2D(Nz::Collider2DRef geom) :
|
||||
m_geom(std::move(geom)),
|
||||
m_bodyUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a CollisionComponent2D object by copy semantic
|
||||
*
|
||||
* \param collision CollisionComponent2D to copy
|
||||
*/
|
||||
|
||||
inline CollisionComponent2D::CollisionComponent2D(const CollisionComponent2D& collision) :
|
||||
m_geom(collision.m_geom),
|
||||
m_bodyUpdated(false)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the geometry representing the entity
|
||||
* \return A constant reference to the physics geometry
|
||||
*/
|
||||
|
||||
inline const Nz::Collider2DRef& CollisionComponent2D::GetGeom() const
|
||||
{
|
||||
return m_geom;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Assigns the geometry to this component
|
||||
* \return A reference to this
|
||||
*
|
||||
* \param geom Reference to a geometry symbolizing the entity
|
||||
*/
|
||||
|
||||
inline CollisionComponent2D& CollisionComponent2D::operator=(Nz::Collider2DRef geom)
|
||||
{
|
||||
SetGeom(geom);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the static body used by the entity
|
||||
* \return A pointer to the entity
|
||||
*/
|
||||
|
||||
inline Nz::RigidBody2D* CollisionComponent2D::GetStaticBody()
|
||||
{
|
||||
return m_staticBody.get();
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_COMPONENTS_COLLISIONCOMPONENT_HPP
|
||||
#define NDK_COMPONENTS_COLLISIONCOMPONENT_HPP
|
||||
#ifndef NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
|
||||
#define NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
|
||||
|
||||
#include <Nazara/Physics3D/Collider3D.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
@@ -23,7 +23,6 @@ namespace Ndk
|
||||
class NDK_API CollisionComponent3D : public Component<CollisionComponent3D>
|
||||
{
|
||||
friend class PhysicsSystem3D;
|
||||
friend class StaticCollisionSystem;
|
||||
|
||||
public:
|
||||
CollisionComponent3D(Nz::Collider3DRef geom = Nz::Collider3DRef());
|
||||
@@ -56,4 +55,4 @@ namespace Ndk
|
||||
|
||||
#include <NDK/Components/CollisionComponent3D.inl>
|
||||
|
||||
#endif // NDK_COMPONENTS_COLLISIONCOMPONENT_HPP
|
||||
#endif // NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP
|
||||
#define NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP
|
||||
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
@@ -16,6 +17,7 @@ namespace Ndk
|
||||
{
|
||||
class GraphicsComponent;
|
||||
|
||||
using GraphicsComponentCullingList = Nz::CullingList<GraphicsComponent>;
|
||||
using GraphicsComponentHandle = Nz::ObjectHandle<GraphicsComponent>;
|
||||
|
||||
class NDK_API GraphicsComponent : public Component<GraphicsComponent>, public Nz::HandledObject<GraphicsComponent>
|
||||
@@ -29,10 +31,11 @@ namespace Ndk
|
||||
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
|
||||
~GraphicsComponent() = default;
|
||||
|
||||
inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
|
||||
inline void AddToCullingList(GraphicsComponentCullingList* cullingList) const;
|
||||
void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
|
||||
|
||||
inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
||||
inline void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0);
|
||||
void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
||||
void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0);
|
||||
|
||||
inline void Clear();
|
||||
|
||||
@@ -46,10 +49,12 @@ namespace Ndk
|
||||
|
||||
inline const Nz::BoundingVolumef& GetBoundingVolume() const;
|
||||
|
||||
inline void RemoveFromCullingList(GraphicsComponentCullingList* cullingList) const;
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
inline void InvalidateBoundingVolume();
|
||||
inline void InvalidateBoundingVolume() const;
|
||||
void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index);
|
||||
inline void InvalidateRenderables();
|
||||
inline void InvalidateTransformMatrix();
|
||||
@@ -73,19 +78,20 @@ namespace Ndk
|
||||
{
|
||||
}
|
||||
|
||||
Renderable(Renderable&& renderable) noexcept :
|
||||
renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)),
|
||||
renderableReleaseSlot(std::move(renderable.renderableReleaseSlot)),
|
||||
data(std::move(renderable.data)),
|
||||
renderable(std::move(renderable.renderable)),
|
||||
dataUpdated(renderable.dataUpdated)
|
||||
Renderable(Renderable&& rhs) noexcept :
|
||||
renderableBoundingVolumeInvalidationSlot(std::move(rhs.renderableBoundingVolumeInvalidationSlot)),
|
||||
renderableDataInvalidationSlot(std::move(rhs.renderableDataInvalidationSlot)),
|
||||
renderableReleaseSlot(std::move(rhs.renderableReleaseSlot)),
|
||||
data(std::move(rhs.data)),
|
||||
renderable(std::move(rhs.renderable)),
|
||||
dataUpdated(rhs.dataUpdated)
|
||||
{
|
||||
}
|
||||
|
||||
~Renderable()
|
||||
{
|
||||
// Disconnect release slot before releasing instanced renderable reference
|
||||
renderableReleaseSlot.Disconnect();
|
||||
renderableReleaseSlot.Disconnect();
|
||||
}
|
||||
|
||||
Renderable& operator=(Renderable&& r) noexcept
|
||||
@@ -93,13 +99,15 @@ namespace Ndk
|
||||
data = std::move(r.data);
|
||||
dataUpdated = r.dataUpdated;
|
||||
renderable = std::move(r.renderable);
|
||||
renderableInvalidationSlot = std::move(r.renderableInvalidationSlot);
|
||||
renderableBoundingVolumeInvalidationSlot = std::move(r.renderableBoundingVolumeInvalidationSlot);
|
||||
renderableDataInvalidationSlot = std::move(r.renderableDataInvalidationSlot);
|
||||
renderableReleaseSlot = std::move(r.renderableReleaseSlot);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot);
|
||||
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateBoundingVolume, renderableBoundingVolumeInvalidationSlot);
|
||||
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableDataInvalidationSlot);
|
||||
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableRelease, renderableReleaseSlot);
|
||||
|
||||
mutable Nz::InstancedRenderable::InstanceData data;
|
||||
@@ -107,6 +115,16 @@ namespace Ndk
|
||||
mutable bool dataUpdated;
|
||||
};
|
||||
|
||||
using VolumeCullingListEntry = GraphicsComponentCullingList::VolumeEntry;
|
||||
|
||||
struct VolumeCullingEntry
|
||||
{
|
||||
VolumeCullingListEntry listEntry;
|
||||
|
||||
NazaraSlot(GraphicsComponentCullingList, OnCullingListRelease, cullingListReleaseSlot);
|
||||
};
|
||||
|
||||
mutable std::vector<VolumeCullingEntry> m_volumeCullingEntries;
|
||||
std::vector<Renderable> m_renderables;
|
||||
mutable Nz::BoundingVolumef m_boundingVolume;
|
||||
mutable Nz::Matrix4f m_transformMatrix;
|
||||
@@ -118,4 +136,4 @@ namespace Ndk
|
||||
#include <NDK/Components/GraphicsComponent.inl>
|
||||
|
||||
#endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP
|
||||
#endif // NDK_SERVER
|
||||
#endif // NDK_SERVER
|
||||
|
||||
@@ -28,52 +28,12 @@ namespace Ndk
|
||||
Attach(r.renderable, r.data.renderOrder);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Adds the renderable elements to the render queue
|
||||
*
|
||||
* \param renderQueue Queue to be added
|
||||
*/
|
||||
|
||||
inline void GraphicsComponent::AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const
|
||||
inline void GraphicsComponent::AddToCullingList(GraphicsComponentCullingList* cullingList) const
|
||||
{
|
||||
EnsureTransformMatrixUpdate();
|
||||
|
||||
Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem<Ndk::RenderSystem>();
|
||||
|
||||
for (const Renderable& object : m_renderables)
|
||||
{
|
||||
if (!object.dataUpdated)
|
||||
{
|
||||
object.data.transformMatrix = Nz::Matrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), Nz::Matrix4f::ConcatenateAffine(object.data.localMatrix, m_transformMatrix));
|
||||
object.renderable->UpdateData(&object.data);
|
||||
object.dataUpdated = true;
|
||||
}
|
||||
|
||||
object.renderable->AddToRenderQueue(renderQueue, object.data);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Attaches a renderable to the entity
|
||||
*
|
||||
* \param renderable Reference to a renderable element
|
||||
* \param renderOrder Render order of the element
|
||||
*/
|
||||
|
||||
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, int renderOrder)
|
||||
{
|
||||
return Attach(renderable, Nz::Matrix4f::Identity(), renderOrder);
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder)
|
||||
{
|
||||
m_renderables.emplace_back(m_transformMatrix);
|
||||
Renderable& r = m_renderables.back();
|
||||
r.data.localMatrix = localMatrix;
|
||||
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));
|
||||
r.renderableReleaseSlot.Connect(r.renderable->OnInstancedRenderableRelease, this, &GraphicsComponent::Detach);
|
||||
m_volumeCullingEntries.emplace_back(VolumeCullingEntry{});
|
||||
VolumeCullingEntry& entry = m_volumeCullingEntries.back();
|
||||
entry.cullingListReleaseSlot.Connect(cullingList->OnCullingListRelease, this, &GraphicsComponent::RemoveFromCullingList);
|
||||
entry.listEntry = cullingList->RegisterVolumeTest(this);
|
||||
|
||||
InvalidateBoundingVolume();
|
||||
}
|
||||
@@ -167,11 +127,26 @@ namespace Ndk
|
||||
return m_boundingVolume;
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::RemoveFromCullingList(GraphicsComponentCullingList* cullingList) const
|
||||
{
|
||||
for (auto it = m_volumeCullingEntries.begin(); it != m_volumeCullingEntries.end(); ++it)
|
||||
{
|
||||
if (it->listEntry.GetParent() == cullingList)
|
||||
{
|
||||
if (m_volumeCullingEntries.size() > 1)
|
||||
*it = std::move(m_volumeCullingEntries.back());
|
||||
|
||||
m_volumeCullingEntries.pop_back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the bounding volume
|
||||
*/
|
||||
|
||||
inline void GraphicsComponent::InvalidateBoundingVolume()
|
||||
inline void GraphicsComponent::InvalidateBoundingVolume() const
|
||||
{
|
||||
m_boundingVolumeUpdated = false;
|
||||
}
|
||||
@@ -192,9 +167,9 @@ namespace Ndk
|
||||
|
||||
inline void GraphicsComponent::InvalidateTransformMatrix()
|
||||
{
|
||||
m_boundingVolumeUpdated = false;
|
||||
m_transformMatrixUpdated = false;
|
||||
|
||||
InvalidateBoundingVolume();
|
||||
InvalidateRenderables();
|
||||
}
|
||||
}
|
||||
}
|
||||
65
SDK/include/NDK/Components/PhysicsComponent2D.hpp
Normal file
65
SDK/include/NDK/Components/PhysicsComponent2D.hpp
Normal file
@@ -0,0 +1,65 @@
|
||||
// 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_COMPONENTS_PHYSICSCOMPONENT2D_HPP
|
||||
#define NDK_COMPONENTS_PHYSICSCOMPONENT2D_HPP
|
||||
|
||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API PhysicsComponent2D : public Component<PhysicsComponent2D>
|
||||
{
|
||||
friend class CollisionComponent2D;
|
||||
friend class PhysicsSystem2D;
|
||||
|
||||
public:
|
||||
PhysicsComponent2D() = default;
|
||||
PhysicsComponent2D(const PhysicsComponent2D& physics);
|
||||
~PhysicsComponent2D() = default;
|
||||
|
||||
void AddForce(const Nz::Vector2f& force, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||
void AddForce(const Nz::Vector2f& force, const Nz::Vector2f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global);
|
||||
void AddTorque(float torque);
|
||||
|
||||
Nz::Rectf GetAABB() const;
|
||||
float GetAngularVelocity() const;
|
||||
Nz::Vector2f GetCenterOfGravity(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
|
||||
float GetMass() const;
|
||||
Nz::Vector2f GetPosition() const;
|
||||
float GetRotation() const;
|
||||
Nz::Vector2f GetVelocity() const;
|
||||
|
||||
bool IsSleeping() const;
|
||||
|
||||
void SetAngularVelocity(float angularVelocity);
|
||||
void SetMass(float mass);
|
||||
void SetMassCenter(const Nz::Vector2f& center);
|
||||
void SetPosition(const Nz::Vector2f& position);
|
||||
void SetRotation(float rotation);
|
||||
void SetVelocity(const Nz::Vector2f& velocity);
|
||||
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
Nz::RigidBody2D& GetRigidBody();
|
||||
|
||||
void OnAttached() override;
|
||||
void OnComponentAttached(BaseComponent& component) override;
|
||||
void OnComponentDetached(BaseComponent& component) override;
|
||||
void OnDetached() override;
|
||||
|
||||
std::unique_ptr<Nz::RigidBody2D> m_object;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Components/PhysicsComponent2D.inl>
|
||||
|
||||
#endif // NDK_COMPONENTS_PHYSICSCOMPONENT2D_HPP
|
||||
284
SDK/include/NDK/Components/PhysicsComponent2D.inl
Normal file
284
SDK/include/NDK/Components/PhysicsComponent2D.inl
Normal file
@@ -0,0 +1,284 @@
|
||||
// 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
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include "PhysicsComponent2D.hpp"
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a PhysicsComponent2D object by copy semantic
|
||||
*
|
||||
* \param physics PhysicsComponent2D to copy
|
||||
*/
|
||||
|
||||
inline PhysicsComponent2D::PhysicsComponent2D(const PhysicsComponent2D& physics)
|
||||
{
|
||||
// No copy of physical object (because we only create it when attached to an entity)
|
||||
NazaraUnused(physics);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Applies a physics force to the entity
|
||||
*
|
||||
* \param force Force to apply on the entity
|
||||
* \param coordSys System coordinates to consider
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::AddForce(const Nz::Vector2f& force, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->AddForce(force, coordSys);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Applies a physics force to the entity
|
||||
*
|
||||
* \param force Force to apply on the entity
|
||||
* \param point Point where to apply the force
|
||||
* \param coordSys System coordinates to consider
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::AddForce(const Nz::Vector2f& force, const Nz::Vector2f& point, Nz::CoordSys coordSys)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->AddForce(force, point, coordSys);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Applies a torque to the entity
|
||||
*
|
||||
* \param torque Torque to apply on the entity
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::AddTorque(float torque)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->AddTorque(torque);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the AABB of the physics object
|
||||
* \return AABB of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
inline Nz::Rectf PhysicsComponent2D::GetAABB() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetAABB();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the angular velocity of the physics object
|
||||
* \return Angular velocity of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline float PhysicsComponent2D::GetAngularVelocity() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetAngularVelocity();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the gravity center of the physics object
|
||||
* \return Gravity center of the object
|
||||
*
|
||||
* \param coordSys System coordinates to consider
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Vector2f PhysicsComponent2D::GetCenterOfGravity(Nz::CoordSys coordSys) const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetCenterOfGravity(coordSys);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the mass of the physics object
|
||||
* \return Mass of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline float PhysicsComponent2D::GetMass() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetMass();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the position of the physics object
|
||||
* \return Position of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Vector2f PhysicsComponent2D::GetPosition() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetPosition();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the rotation of the physics object
|
||||
* \return Rotation of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline float PhysicsComponent2D::GetRotation() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetRotation();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the velocity of the physics object
|
||||
* \return Velocity of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline Nz::Vector2f PhysicsComponent2D::GetVelocity() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->GetVelocity();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether the entity is currently sleeping
|
||||
* \return true If it is the case
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline bool PhysicsComponent2D::IsSleeping() const
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
return m_object->IsSleeping();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the angular velocity of the physics object
|
||||
*
|
||||
* \param angularVelocity Angular velocity of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::SetAngularVelocity(float angularVelocity)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetAngularVelocity(angularVelocity);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the mass of the physics object
|
||||
*
|
||||
* \param mass Mass of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
* \remark Produces a NazaraAssert if the mass is negative
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::SetMass(float mass)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
NazaraAssert(mass > 0.f, "Mass should be positive");
|
||||
|
||||
m_object->SetMass(mass);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the gravity center of the physics object
|
||||
*
|
||||
* \param center Gravity center of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::SetMassCenter(const Nz::Vector2f& center)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetMassCenter(center);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the position of the physics object
|
||||
*
|
||||
* \param position Position of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::SetPosition(const Nz::Vector2f& position)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetPosition(position);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the rotation of the physics object
|
||||
*
|
||||
* \param rotation Rotation of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::SetRotation(float rotation)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetRotation(rotation);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the velocity of the physics object
|
||||
*
|
||||
* \param velocity Velocity of the object
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the physics object is invalid
|
||||
*/
|
||||
|
||||
inline void PhysicsComponent2D::SetVelocity(const Nz::Vector2f& velocity)
|
||||
{
|
||||
NazaraAssert(m_object, "Invalid physics object");
|
||||
|
||||
m_object->SetVelocity(velocity);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the underlying physics object
|
||||
* \return A reference to the physics object
|
||||
*/
|
||||
|
||||
inline Nz::RigidBody2D& PhysicsComponent2D::GetRigidBody()
|
||||
{
|
||||
return *m_object.get();
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace Ndk
|
||||
static ComponentIndex componentIndex;
|
||||
|
||||
private:
|
||||
Nz::RigidBody3D& GetPhysObject();
|
||||
Nz::RigidBody3D& GetRigidBody();
|
||||
|
||||
void OnAttached() override;
|
||||
void OnComponentAttached(BaseComponent& component) override;
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace Ndk
|
||||
* \return A reference to the physics object
|
||||
*/
|
||||
|
||||
inline Nz::RigidBody3D& PhysicsComponent3D::GetPhysObject()
|
||||
inline Nz::RigidBody3D& PhysicsComponent3D::GetRigidBody()
|
||||
{
|
||||
return *m_object.get();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_CONSOLE_HPP
|
||||
#define NDK_CONSOLE_HPP
|
||||
|
||||
@@ -99,3 +100,4 @@ namespace Ndk
|
||||
#include <NDK/Console.inl>
|
||||
|
||||
#endif // NDK_CONSOLE_HPP
|
||||
#endif // NDK_SERVER
|
||||
|
||||
68
SDK/include/NDK/Lua/LuaBinding.hpp
Normal file
68
SDK/include/NDK/Lua/LuaBinding.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// 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_LUABINDING_HPP
|
||||
#define NDK_LUABINDING_HPP
|
||||
|
||||
#include <NDK/BaseComponent.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding
|
||||
{
|
||||
friend class LuaBinding_SDK;
|
||||
|
||||
public:
|
||||
LuaBinding();
|
||||
~LuaBinding() = default;
|
||||
|
||||
template<typename T> void BindComponent(const Nz::String& name);
|
||||
|
||||
void RegisterClasses(Nz::LuaInstance& instance);
|
||||
|
||||
std::unique_ptr<LuaBinding_Base> core;
|
||||
std::unique_ptr<LuaBinding_Base> math;
|
||||
std::unique_ptr<LuaBinding_Base> network;
|
||||
std::unique_ptr<LuaBinding_Base> sdk;
|
||||
std::unique_ptr<LuaBinding_Base> utility;
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
std::unique_ptr<LuaBinding_Base> audio;
|
||||
std::unique_ptr<LuaBinding_Base> graphics;
|
||||
std::unique_ptr<LuaBinding_Base> renderer;
|
||||
#endif
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
static int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle);
|
||||
|
||||
template<typename T>
|
||||
static int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component);
|
||||
|
||||
using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&);
|
||||
using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&);
|
||||
|
||||
struct ComponentBinding
|
||||
{
|
||||
AddComponentFunc adder;
|
||||
ComponentIndex index;
|
||||
GetComponentFunc getter;
|
||||
Nz::String name;
|
||||
};
|
||||
|
||||
ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 2);
|
||||
|
||||
std::vector<ComponentBinding> m_componentBinding;
|
||||
std::unordered_map<Nz::String, ComponentIndex> m_componentBindingByName;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Lua/LuaBinding.inl>
|
||||
|
||||
#endif // NDK_LUABINDING_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/LuaBinding.hpp>
|
||||
#include <NDK/Lua/LuaBinding.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
@@ -32,18 +32,8 @@ namespace Ndk
|
||||
m_componentBindingByName[name] = T::componentIndex;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Adds a component to an entity
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance that will interact with the component
|
||||
* \param handle Entity which component will be added to
|
||||
*
|
||||
* \remark T must be a subtype of BaseComponent
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
||||
int LuaBinding::AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
||||
{
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
@@ -52,18 +42,8 @@ namespace Ndk
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Pushes a component
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance that will interact with the component
|
||||
* \param component Component that will be pushed
|
||||
*
|
||||
* \remark T must be a subtype of BaseComponent
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
||||
int LuaBinding::PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
||||
{
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
33
SDK/include/NDK/Lua/LuaBinding_Audio.hpp
Normal file
33
SDK/include/NDK/Lua/LuaBinding_Audio.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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_LUABINDING_AUDIO_HPP
|
||||
#define NDK_LUABINDING_AUDIO_HPP
|
||||
|
||||
#include <Nazara/Audio/Music.hpp>
|
||||
#include <Nazara/Audio/Sound.hpp>
|
||||
#include <Nazara/Audio/SoundBuffer.hpp>
|
||||
#include <Nazara/Audio/SoundEmitter.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Audio : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Audio(LuaBinding& binding);
|
||||
~LuaBinding_Audio() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::Music> music;
|
||||
Nz::LuaClass<Nz::Sound> sound;
|
||||
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
||||
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_CORE_HPP
|
||||
53
SDK/include/NDK/Lua/LuaBinding_Base.hpp
Normal file
53
SDK/include/NDK/Lua/LuaBinding_Base.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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_LUABINDING_BASE_HPP
|
||||
#define NDK_LUABINDING_BASE_HPP
|
||||
|
||||
#include <Nazara/Lua/LuaClass.hpp>
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class LuaBinding;
|
||||
|
||||
class LuaBinding_Audio;
|
||||
class LuaBinding_Core;
|
||||
class LuaBinding_Graphics;
|
||||
class LuaBinding_Math;
|
||||
class LuaBinding_Network;
|
||||
class LuaBinding_Renderer;
|
||||
class LuaBinding_SDK;
|
||||
class LuaBinding_Utility;
|
||||
|
||||
class NDK_API LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Base(LuaBinding& binding);
|
||||
virtual ~LuaBinding_Base();
|
||||
|
||||
virtual void Register(Nz::LuaInstance& instance) = 0;
|
||||
|
||||
// Implementation lies in the respective .cpp files (still searching for a cleaner way..)
|
||||
static std::unique_ptr<LuaBinding_Base> BindCore(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindMath(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindNetwork(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindSDK(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindUtility(LuaBinding& binding);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
static std::unique_ptr<LuaBinding_Base> BindAudio(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindGraphics(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindRenderer(LuaBinding& binding);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
LuaBinding& m_binding;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_BASE_HPP
|
||||
33
SDK/include/NDK/Lua/LuaBinding_Core.hpp
Normal file
33
SDK/include/NDK/Lua/LuaBinding_Core.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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_LUABINDING_CORE_HPP
|
||||
#define NDK_LUABINDING_CORE_HPP
|
||||
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Directory.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <Nazara/Core/Stream.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Core : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Core(LuaBinding& binding);
|
||||
~LuaBinding_Core() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::Clock> clock;
|
||||
Nz::LuaClass<Nz::Directory> directory;
|
||||
Nz::LuaClass<Nz::File> file;
|
||||
Nz::LuaClass<Nz::Stream> stream;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_CORE_HPP
|
||||
36
SDK/include/NDK/Lua/LuaBinding_Graphics.hpp
Normal file
36
SDK/include/NDK/Lua/LuaBinding_Graphics.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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_LUABINDING_GRAPHICS_HPP
|
||||
#define NDK_LUABINDING_GRAPHICS_HPP
|
||||
|
||||
#include <Nazara/Graphics/AbstractViewer.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Graphics : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Graphics(LuaBinding& binding);
|
||||
~LuaBinding_Graphics() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::AbstractViewer> abstractViewer;
|
||||
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
||||
Nz::LuaClass<Nz::MaterialRef> material;
|
||||
Nz::LuaClass<Nz::ModelRef> model;
|
||||
Nz::LuaClass<Nz::SpriteRef> sprite;
|
||||
Nz::LuaClass<Nz::SpriteLibrary> spriteLibrary;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_GRAPHICS_HPP
|
||||
37
SDK/include/NDK/Lua/LuaBinding_Math.hpp
Normal file
37
SDK/include/NDK/Lua/LuaBinding_Math.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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_LUABINDING_MATH_HPP
|
||||
#define NDK_LUABINDING_MATH_HPP
|
||||
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Quaternion.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Math : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Math(LuaBinding& binding);
|
||||
~LuaBinding_Math() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::EulerAnglesd> eulerAngles;
|
||||
Nz::LuaClass<Nz::Matrix4d> matrix4d;
|
||||
Nz::LuaClass<Nz::Quaterniond> quaternion;
|
||||
Nz::LuaClass<Nz::Rectd> rect;
|
||||
Nz::LuaClass<Nz::Vector2d> vector2d;
|
||||
Nz::LuaClass<Nz::Vector3d> vector3d;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_MATH_HPP
|
||||
29
SDK/include/NDK/Lua/LuaBinding_Network.hpp
Normal file
29
SDK/include/NDK/Lua/LuaBinding_Network.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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_LUABINDING_NETWORK_HPP
|
||||
#define NDK_LUABINDING_NETWORK_HPP
|
||||
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Network : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Network(LuaBinding& binding);
|
||||
~LuaBinding_Network() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::AbstractSocket> abstractSocket;
|
||||
Nz::LuaClass<Nz::IpAddress> ipAddress;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_NETWORK_HPP
|
||||
29
SDK/include/NDK/Lua/LuaBinding_Renderer.hpp
Normal file
29
SDK/include/NDK/Lua/LuaBinding_Renderer.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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_LUABINDING_RENDERER_HPP
|
||||
#define NDK_LUABINDING_RENDERER_HPP
|
||||
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Renderer : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Renderer(LuaBinding& binding);
|
||||
~LuaBinding_Renderer() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Nz::TextureRef> texture;
|
||||
Nz::LuaClass<Nz::TextureLibrary> textureLibrary;
|
||||
Nz::LuaClass<Nz::TextureManager> textureManager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_RENDERER_HPP
|
||||
42
SDK/include/NDK/Lua/LuaBinding_SDK.hpp
Normal file
42
SDK/include/NDK/Lua/LuaBinding_SDK.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_LUABINDING_SDK_HPP
|
||||
#define NDK_LUABINDING_SDK_HPP
|
||||
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Application;
|
||||
|
||||
class NDK_API LuaBinding_SDK : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_SDK(LuaBinding& binding);
|
||||
~LuaBinding_SDK() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
Nz::LuaClass<Application*> application;
|
||||
Nz::LuaClass<EntityHandle> entity;
|
||||
Nz::LuaClass<NodeComponentHandle> nodeComponent;
|
||||
Nz::LuaClass<VelocityComponentHandle> velocityComponent;
|
||||
Nz::LuaClass<WorldHandle> world;
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
Nz::LuaClass<CameraComponentHandle> cameraComponent;
|
||||
Nz::LuaClass<ConsoleHandle> console;
|
||||
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
||||
#endif
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_SDK_HPP
|
||||
34
SDK/include/NDK/Lua/LuaBinding_Utility.hpp
Normal file
34
SDK/include/NDK/Lua/LuaBinding_Utility.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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_LUABINDING_UTILITY_HPP
|
||||
#define NDK_LUABINDING_UTILITY_HPP
|
||||
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/Keyboard.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Utility : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Utility(LuaBinding& binding);
|
||||
~LuaBinding_Utility() = default;
|
||||
|
||||
void Register(Nz::LuaInstance& instance) override;
|
||||
|
||||
// Utility
|
||||
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||
Nz::LuaClass<Nz::FontRef> font;
|
||||
Nz::LuaClass<Nz::Keyboard> keyboard;
|
||||
Nz::LuaClass<Nz::Node> node;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_UTILITY_HPP
|
||||
@@ -28,15 +28,6 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param color Resulting color
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Color* color, TypeTag<Color>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
@@ -49,15 +40,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param angles Resulting euler angles
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesd* angles, TypeTag<EulerAnglesd>)
|
||||
{
|
||||
switch (instance.GetType(index))
|
||||
@@ -78,15 +60,6 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param angles Resulting euler angles
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesf* angles, TypeTag<EulerAnglesf>)
|
||||
{
|
||||
EulerAnglesd anglesDouble;
|
||||
@@ -96,15 +69,6 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param fontRef Resulting reference to a font
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontRef* fontRef, TypeTag<FontRef>)
|
||||
{
|
||||
*fontRef = *static_cast<FontRef*>(instance.CheckUserdata(index, "Font"));
|
||||
@@ -112,15 +76,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param params Resulting parameters for a font
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag<FontParams>)
|
||||
{
|
||||
NazaraUnused(params);
|
||||
@@ -132,14 +87,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param params Resulting parameters for an image
|
||||
*/
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ImageParams* params, TypeTag<ImageParams>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
@@ -150,15 +97,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param address Resulting IP address
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, IpAddress* address, TypeTag<IpAddress>)
|
||||
{
|
||||
switch (instance.GetType(index))
|
||||
@@ -173,15 +111,6 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param quat Resulting quaternion
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4d* mat, TypeTag<Matrix4d>)
|
||||
{
|
||||
switch (instance.GetType(index))
|
||||
@@ -212,55 +141,29 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param quat Resulting quaternion
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Matrix4f* mat, TypeTag<Matrix4f>)
|
||||
{
|
||||
Matrix4d matDouble;
|
||||
Matrix4d matDouble = Matrix4d::Identity();
|
||||
unsigned int ret = LuaImplQueryArg(instance, index, &matDouble, TypeTag<Matrix4d>());
|
||||
|
||||
mat->Set(matDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param params Resulting parameters for a mesh
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MeshParams* params, TypeTag<MeshParams>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
|
||||
params->animated = instance.CheckField<bool>("Animated", params->animated);
|
||||
params->center = instance.CheckField<bool>("Center", params->center);
|
||||
params->flipUVs = instance.CheckField<bool>("FlipUVs", params->flipUVs);
|
||||
params->matrix = instance.CheckField<Matrix4f>("Matrix", params->matrix);
|
||||
params->optimizeIndexBuffers = instance.CheckField<bool>("OptimizeIndexBuffers", params->optimizeIndexBuffers);
|
||||
params->texCoordOffset = instance.CheckField<Vector2f>("TexCoordOffset", params->texCoordOffset);
|
||||
params->texCoordScale = instance.CheckField<Vector2f>("TexCoordScale", params->texCoordScale);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param quat Resulting quaternion
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag<Quaterniond>)
|
||||
{
|
||||
switch (instance.GetType(index))
|
||||
@@ -281,15 +184,6 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param quat Resulting quaternion
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaternionf* quat, TypeTag<Quaternionf>)
|
||||
{
|
||||
Quaterniond quatDouble;
|
||||
@@ -299,15 +193,6 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param rect Resulting rectangle
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectd* rect, TypeTag<Rectd>)
|
||||
{
|
||||
instance.CheckType(index, LuaType_Table);
|
||||
@@ -320,15 +205,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param rect Resulting rectangle
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectf* rect, TypeTag<Rectf>)
|
||||
{
|
||||
Rectd rectDouble;
|
||||
@@ -338,14 +214,14 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param rect Resulting rectangle
|
||||
*/
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Recti* rect, TypeTag<Recti>)
|
||||
{
|
||||
Rectd rectDouble;
|
||||
unsigned int ret = LuaImplQueryArg(instance, index, &rectDouble, TypeTag<Rectd>());
|
||||
|
||||
rect->Set(rectDouble);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectui* rect, TypeTag<Rectui>)
|
||||
{
|
||||
@@ -356,15 +232,6 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param vec Resulting vector2D
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2d* vec, TypeTag<Vector2d>)
|
||||
{
|
||||
switch (instance.GetType(index))
|
||||
@@ -386,15 +253,6 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param vec Resulting vector2D
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2f* vec, TypeTag<Vector2f>)
|
||||
{
|
||||
Vector2d vecDouble;
|
||||
@@ -404,15 +262,6 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param vec Resulting vector2D
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2ui* vec, TypeTag<Vector2ui>)
|
||||
{
|
||||
Vector2d vecDouble;
|
||||
@@ -422,15 +271,6 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param vec Resulting vector3D
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3d* vec, TypeTag<Vector3d>)
|
||||
{
|
||||
switch (instance.GetType(index))
|
||||
@@ -452,15 +292,6 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param vec Resulting vector3D
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3f* vec, TypeTag<Vector3f>)
|
||||
{
|
||||
Vector3d vecDouble;
|
||||
@@ -470,15 +301,6 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param vec Resulting vector3D
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3ui* vec, TypeTag<Vector3ui>)
|
||||
{
|
||||
Vector3d vecDouble;
|
||||
@@ -488,15 +310,6 @@ namespace Nz
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param handle Resulting entity
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::EntityHandle* handle, TypeTag<Ndk::EntityHandle>)
|
||||
{
|
||||
*handle = *static_cast<Ndk::EntityHandle*>(instance.CheckUserdata(index, "Entity"));
|
||||
@@ -504,15 +317,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param handle Resulting world
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::WorldHandle* handle, TypeTag<Ndk::WorldHandle>)
|
||||
{
|
||||
*handle = *static_cast<Ndk::WorldHandle*>(instance.CheckUserdata(index, "World"));
|
||||
@@ -521,16 +325,6 @@ namespace Nz
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param renderable Resulting reference to a instanced renderable
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, InstancedRenderableRef* renderable, TypeTag<InstancedRenderableRef>)
|
||||
{
|
||||
if (instance.IsOfType(index, "InstancedRenderable") ||
|
||||
@@ -545,15 +339,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param renderable Resulting reference to a material
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MaterialRef* materialRef, TypeTag<MaterialRef>)
|
||||
{
|
||||
*materialRef = *static_cast<MaterialRef*>(instance.CheckUserdata(index, "Material"));
|
||||
@@ -561,15 +346,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param params Resulting parameters for a material
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MaterialParams* params, TypeTag<MaterialParams>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
@@ -585,15 +361,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param params Resulting parameters for a model
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ModelParameters* params, TypeTag<ModelParameters>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
@@ -606,15 +373,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param params Resulting parameters for a music
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MusicParams* params, TypeTag<MusicParams>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
@@ -624,15 +382,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param params Resulting parameters for a sound buffer
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SoundBufferParams* params, TypeTag<SoundBufferParams>)
|
||||
{
|
||||
instance.CheckType(index, Nz::LuaType_Table);
|
||||
@@ -642,15 +391,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param renderable Resulting reference to a sprite
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SpriteRef* spriteRef, TypeTag<SpriteRef>)
|
||||
{
|
||||
*spriteRef = *static_cast<SpriteRef*>(instance.CheckUserdata(index, "Sprite"));
|
||||
@@ -658,32 +398,14 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Queries arguments for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param index Index type
|
||||
* \param fontRef Resulting reference to a font
|
||||
*/
|
||||
|
||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, TextureRef* textureRef, TypeTag<TextureRef>)
|
||||
{
|
||||
*textureRef = *static_cast<TextureRef*>(instance.CheckUserdata(index, "Texture"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting color
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Color&& val, TypeTag<Color>)
|
||||
{
|
||||
instance.PushTable();
|
||||
@@ -695,56 +417,24 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting euler angles
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesd&& val, TypeTag<EulerAnglesd>)
|
||||
{
|
||||
instance.PushInstance<EulerAnglesd>("EulerAngles", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting euler angles
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesf&& val, TypeTag<EulerAnglesf>)
|
||||
{
|
||||
instance.PushInstance<EulerAnglesd>("EulerAngles", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting reference to a font
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, FontRef&& val, TypeTag<FontRef>)
|
||||
{
|
||||
instance.PushInstance<FontRef>("Font", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting size information for a font
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo&& val, TypeTag<Font::SizeInfo>)
|
||||
{
|
||||
instance.PushTable();
|
||||
@@ -756,14 +446,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting ImageParams
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, ImageParams&& val, TypeTag<ImageParams>)
|
||||
{
|
||||
instance.PushTable(0, 2);
|
||||
@@ -773,111 +455,53 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting IP address
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress&& val, TypeTag<IpAddress>)
|
||||
{
|
||||
instance.PushInstance<IpAddress>("IpAddress", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting rectangle
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Matrix4d&& val, TypeTag<Matrix4d>)
|
||||
{
|
||||
instance.PushInstance<Matrix4d>("Matrix4", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting rectangle
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Matrix4f&& val, TypeTag<Matrix4f>)
|
||||
{
|
||||
instance.PushInstance<Matrix4d>("Matrix4", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting quaternion
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond&& val, TypeTag<Quaterniond>)
|
||||
{
|
||||
instance.PushInstance<Quaterniond>("Quaternion", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting quaternion
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaternionf&& val, TypeTag<Quaternionf>)
|
||||
{
|
||||
instance.PushInstance<Quaterniond>("Quaternion", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting rectangle
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Rectd&& val, TypeTag<Rectd>)
|
||||
{
|
||||
instance.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting rectangle
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Rectf&& val, TypeTag<Rectf>)
|
||||
{
|
||||
instance.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting rectangle
|
||||
*/
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Recti&& val, TypeTag<Recti>)
|
||||
{
|
||||
instance.PushInstance<Rectd>("Rect", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Rectui&& val, TypeTag<Rectui>)
|
||||
{
|
||||
@@ -885,182 +509,78 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting vector2D
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d&& val, TypeTag<Vector2d>)
|
||||
{
|
||||
instance.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting vector2D
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2f&& val, TypeTag<Vector2f>)
|
||||
{
|
||||
instance.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting vector2D
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2ui&& val, TypeTag<Vector2ui>)
|
||||
{
|
||||
instance.PushInstance<Vector2d>("Vector2", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting vector3D
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d&& val, TypeTag<Vector3d>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting vector3D
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f&& val, TypeTag<Vector3f>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting vector3D
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui&& val, TypeTag<Vector3ui>)
|
||||
{
|
||||
instance.PushInstance<Vector3d>("Vector3", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param ptr Resulting entity
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Entity* ptr, TypeTag<Ndk::Entity*>)
|
||||
{
|
||||
instance.PushInstance<Ndk::EntityHandle>("Entity", ptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param ptr Resulting application
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Application* ptr, TypeTag<Ndk::Application*>)
|
||||
{
|
||||
instance.PushInstance<Ndk::Application*>("Application", ptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting entity
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::EntityHandle&& handle, TypeTag<Ndk::EntityHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::EntityHandle>("Entity", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting node component
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::NodeComponentHandle&& handle, TypeTag<Ndk::NodeComponentHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::NodeComponentHandle>("NodeComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting velocity component
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::VelocityComponentHandle&& handle, TypeTag<Ndk::VelocityComponentHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::VelocityComponentHandle>("VelocityComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param ptr Resulting world
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::World* ptr, TypeTag<Ndk::World*>)
|
||||
{
|
||||
instance.PushInstance<Ndk::WorldHandle>("World", ptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param ptr Resulting world
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::WorldHandle&& handle, TypeTag<Ndk::WorldHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::WorldHandle>("World", handle);
|
||||
@@ -1068,70 +588,35 @@ namespace Nz
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting material
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, MaterialRef&& handle, TypeTag<MaterialRef>)
|
||||
{
|
||||
instance.PushInstance<MaterialRef>("Material", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param val Resulting sound buffer
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, const SoundBuffer* val, TypeTag<const SoundBuffer*>)
|
||||
{
|
||||
instance.PushInstance<SoundBufferConstRef>("SoundBuffer", val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting sprite
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, SpriteRef&& handle, TypeTag<SpriteRef>)
|
||||
{
|
||||
instance.PushInstance<SpriteRef>("Sprite", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting texture
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, TextureRef&& handle, TypeTag<TextureRef>)
|
||||
{
|
||||
instance.PushInstance<TextureRef>("Texture", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting console
|
||||
*/
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::CameraComponentHandle&& handle, TypeTag<Ndk::CameraComponentHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::CameraComponentHandle>("CameraComponent", handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::ConsoleHandle&& handle, TypeTag<Ndk::ConsoleHandle>)
|
||||
{
|
||||
@@ -1139,14 +624,6 @@ namespace Nz
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Replies by value for Lua
|
||||
* \return 1 in case of success
|
||||
*
|
||||
* \param instance Lua instance to interact with
|
||||
* \param handle Resulting graphics component
|
||||
*/
|
||||
|
||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle&& handle, TypeTag<Ndk::GraphicsComponentHandle>)
|
||||
{
|
||||
instance.PushInstance<Ndk::GraphicsComponentHandle>("GraphicsComponent", handle);
|
||||
|
||||
@@ -1,144 +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_LUABINDING_HPP
|
||||
#define NDK_LUABINDING_HPP
|
||||
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Lua.hpp>
|
||||
#include <Nazara/Math.hpp>
|
||||
#include <Nazara/Network.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <NDK/Application.hpp>
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/Systems.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <Nazara/Audio.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#endif
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding
|
||||
{
|
||||
public:
|
||||
LuaBinding();
|
||||
~LuaBinding() = default;
|
||||
|
||||
template<typename T> void BindComponent(const Nz::String& name);
|
||||
|
||||
void RegisterClasses(Nz::LuaInstance& instance);
|
||||
|
||||
// Core
|
||||
Nz::LuaClass<Nz::Clock> clock;
|
||||
Nz::LuaClass<Nz::Directory> directory;
|
||||
Nz::LuaClass<Nz::File> file;
|
||||
Nz::LuaClass<Nz::Stream> stream;
|
||||
|
||||
// Math
|
||||
Nz::LuaClass<Nz::EulerAnglesd> eulerAngles;
|
||||
Nz::LuaClass<Nz::Matrix4d> matrix4d;
|
||||
Nz::LuaClass<Nz::Quaterniond> quaternion;
|
||||
Nz::LuaClass<Nz::Rectd> rect;
|
||||
Nz::LuaClass<Nz::Vector2d> vector2d;
|
||||
Nz::LuaClass<Nz::Vector3d> vector3d;
|
||||
|
||||
// Network
|
||||
Nz::LuaClass<Nz::AbstractSocket> abstractSocket;
|
||||
Nz::LuaClass<Nz::IpAddress> ipAddress;
|
||||
|
||||
// Utility
|
||||
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||
Nz::LuaClass<Nz::FontRef> font;
|
||||
Nz::LuaClass<Nz::Node> node;
|
||||
|
||||
// SDK
|
||||
Nz::LuaClass<Application*> application;
|
||||
Nz::LuaClass<EntityHandle> entity;
|
||||
Nz::LuaClass<NodeComponentHandle> nodeComponent;
|
||||
Nz::LuaClass<VelocityComponentHandle> velocityComponent;
|
||||
Nz::LuaClass<WorldHandle> world;
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
// Audio
|
||||
Nz::LuaClass<Nz::Music> music;
|
||||
Nz::LuaClass<Nz::Sound> sound;
|
||||
Nz::LuaClass<Nz::SoundBufferRef> soundBuffer;
|
||||
Nz::LuaClass<Nz::SoundEmitter> soundEmitter;
|
||||
|
||||
// Graphics
|
||||
Nz::LuaClass<Nz::InstancedRenderableRef> instancedRenderable;
|
||||
Nz::LuaClass<Nz::MaterialRef> material;
|
||||
Nz::LuaClass<Nz::ModelRef> model;
|
||||
Nz::LuaClass<Nz::SpriteRef> sprite;
|
||||
Nz::LuaClass<Nz::SpriteLibrary> spriteLibrary;
|
||||
Nz::LuaClass<Nz::TextureLibrary> textureLibrary;
|
||||
Nz::LuaClass<Nz::TextureManager> textureManager;
|
||||
|
||||
// Renderer
|
||||
Nz::LuaClass<Nz::TextureRef> texture;
|
||||
|
||||
// SDK
|
||||
Nz::LuaClass<ConsoleHandle> console;
|
||||
Nz::LuaClass<GraphicsComponentHandle> graphicsComponent;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void BindCore();
|
||||
void BindMath();
|
||||
void BindNetwork();
|
||||
void BindSDK();
|
||||
void BindUtility();
|
||||
|
||||
void RegisterCore(Nz::LuaInstance& instance);
|
||||
void RegisterMath(Nz::LuaInstance& instance);
|
||||
void RegisterNetwork(Nz::LuaInstance& instance);
|
||||
void RegisterSDK(Nz::LuaInstance& instance);
|
||||
void RegisterUtility(Nz::LuaInstance& instance);
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
void BindAudio();
|
||||
void BindGraphics();
|
||||
void BindRenderer();
|
||||
|
||||
void RegisterAudio(Nz::LuaInstance& instance);
|
||||
void RegisterGraphics(Nz::LuaInstance& instance);
|
||||
void RegisterRenderer(Nz::LuaInstance& instance);
|
||||
#endif
|
||||
|
||||
|
||||
using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&);
|
||||
using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&);
|
||||
|
||||
struct ComponentBinding
|
||||
{
|
||||
AddComponentFunc adder;
|
||||
ComponentIndex index;
|
||||
GetComponentFunc getter;
|
||||
Nz::String name;
|
||||
};
|
||||
|
||||
ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 2);
|
||||
|
||||
std::vector<ComponentBinding> m_componentBinding;
|
||||
std::unordered_map<Nz::String, ComponentIndex> m_componentBindingByName;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle);
|
||||
|
||||
template<typename T>
|
||||
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component);
|
||||
}
|
||||
|
||||
#include <NDK/LuaBinding.inl>
|
||||
|
||||
#endif // NDK_LUABINDING_HPP
|
||||
@@ -25,11 +25,16 @@
|
||||
#ifndef NDK_PREREQUESITES_HPP
|
||||
#define NDK_PREREQUESITES_HPP
|
||||
|
||||
/*!
|
||||
* \defgroup NDK (NazaraSDK) Nazara Development Kit
|
||||
* A library grouping every modules of Nazara into multiple higher-level features suchs as scene management (handled by an ECS), application, lua binding, etc.
|
||||
*/
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
// Importation/Exportation of the API
|
||||
#if defined(NAZARA_STATIC)
|
||||
#define #define NDK_API
|
||||
#define NDK_API
|
||||
#else
|
||||
#ifdef NDK_BUILD
|
||||
#define NDK_API NAZARA_EXPORT
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 30 Jul 2016 at 15:29:16
|
||||
// This file was automatically generated
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <NDK/Systems/ListenerSystem.hpp>
|
||||
#include <NDK/Systems/ParticleSystem.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem2D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
#include <NDK/Systems/RenderSystem.hpp>
|
||||
#include <NDK/Systems/VelocitySystem.hpp>
|
||||
|
||||
42
SDK/include/NDK/Systems/PhysicsSystem2D.hpp
Normal file
42
SDK/include/NDK/Systems/PhysicsSystem2D.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_PHYSICSSYSTEM2D_HPP
|
||||
#define NDK_SYSTEMS_PHYSICSSYSTEM2D_HPP
|
||||
|
||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API PhysicsSystem2D : public System<PhysicsSystem2D>
|
||||
{
|
||||
public:
|
||||
PhysicsSystem2D();
|
||||
PhysicsSystem2D(const PhysicsSystem2D& system);
|
||||
~PhysicsSystem2D() = default;
|
||||
|
||||
Nz::PhysWorld2D& GetWorld();
|
||||
const Nz::PhysWorld2D& 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::PhysWorld2D> m_world; ///TODO: std::optional (Should I make a Nz::Optional class?)
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Systems/PhysicsSystem2D.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_PHYSICSSYSTEM2D_HPP
|
||||
32
SDK/include/NDK/Systems/PhysicsSystem2D.inl
Normal file
32
SDK/include/NDK/Systems/PhysicsSystem2D.inl
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Gets the physical world
|
||||
* \return A reference to the physical world
|
||||
*/
|
||||
|
||||
inline Nz::PhysWorld2D& PhysicsSystem2D::GetWorld()
|
||||
{
|
||||
if (!m_world)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_world;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the physical world
|
||||
* \return A constant reference to the physical world
|
||||
*/
|
||||
|
||||
inline const Nz::PhysWorld2D& PhysicsSystem2D::GetWorld() const
|
||||
{
|
||||
if (!m_world)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_world;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,11 @@
|
||||
#define NDK_SYSTEMS_RENDERSYSTEM_HPP
|
||||
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Graphics/DepthRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
#include <unordered_map>
|
||||
@@ -19,8 +21,6 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class GraphicsComponent;
|
||||
|
||||
class NDK_API RenderSystem : public System<RenderSystem>
|
||||
{
|
||||
public:
|
||||
@@ -51,21 +51,25 @@ namespace Ndk
|
||||
void OnEntityRemoved(Entity* entity) override;
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
void UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer);
|
||||
void UpdatePointSpotShadowMaps();
|
||||
|
||||
std::unique_ptr<Nz::AbstractRenderTechnique> m_renderTechnique;
|
||||
std::vector<GraphicsComponentCullingList::VolumeEntry> m_volumeEntries;
|
||||
EntityList m_cameras;
|
||||
EntityList m_drawables;
|
||||
EntityList m_directionalLights;
|
||||
EntityList m_lights;
|
||||
EntityList m_pointSpotLights;
|
||||
EntityList m_particleGroups;
|
||||
GraphicsComponentCullingList m_drawableCulling;
|
||||
Nz::BackgroundRef m_background;
|
||||
Nz::DepthRenderTechnique m_shadowTechnique;
|
||||
Nz::Matrix4f m_coordinateSystemMatrix;
|
||||
Nz::RenderTexture m_shadowRT;
|
||||
bool m_coordinateSystemInvalidated;
|
||||
bool m_forceRenderQueueInvalidation;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 27 Oct 2016 at 21:39:00
|
||||
// This file was automatically generated
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Ndk
|
||||
|
||||
class NDK_API World : public Nz::HandledObject<World>
|
||||
{
|
||||
friend BaseSystem;
|
||||
friend Entity;
|
||||
|
||||
public:
|
||||
@@ -72,6 +73,8 @@ namespace Ndk
|
||||
private:
|
||||
inline void Invalidate();
|
||||
inline void Invalidate(EntityId id);
|
||||
inline void InvalidateSystemOrder();
|
||||
void ReorderSystems();
|
||||
|
||||
struct EntityBlock
|
||||
{
|
||||
@@ -83,15 +86,17 @@ namespace Ndk
|
||||
EntityBlock(EntityBlock&& block) = default;
|
||||
|
||||
Entity entity;
|
||||
unsigned int aliveIndex;
|
||||
std::size_t aliveIndex;
|
||||
};
|
||||
|
||||
std::vector<std::unique_ptr<BaseSystem>> m_systems;
|
||||
std::vector<BaseSystem*> m_orderedSystems;
|
||||
std::vector<EntityBlock> m_entities;
|
||||
std::vector<EntityId> m_freeIdList;
|
||||
EntityList m_aliveEntities;
|
||||
Nz::Bitset<Nz::UInt64> m_dirtyEntities;
|
||||
Nz::Bitset<Nz::UInt64> m_killedEntities;
|
||||
bool m_orderedSystemsUpdated;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Ndk
|
||||
m_systems[index]->SetWorld(this);
|
||||
|
||||
Invalidate(); // We force an update for every entities
|
||||
InvalidateSystemOrder(); // And regenerate the system update list
|
||||
|
||||
return *m_systems[index].get();
|
||||
}
|
||||
@@ -206,6 +207,8 @@ namespace Ndk
|
||||
inline void World::RemoveAllSystems()
|
||||
{
|
||||
m_systems.clear();
|
||||
|
||||
InvalidateSystemOrder();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -219,7 +222,11 @@ namespace Ndk
|
||||
inline void World::RemoveSystem(SystemIndex index)
|
||||
{
|
||||
if (HasSystem(index))
|
||||
{
|
||||
m_systems[index].reset();
|
||||
|
||||
InvalidateSystemOrder();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -246,32 +253,8 @@ namespace Ndk
|
||||
Update(); //< Update entities
|
||||
|
||||
// And then update systems
|
||||
for (auto& systemPtr : m_systems)
|
||||
{
|
||||
if (systemPtr)
|
||||
systemPtr->Update(elapsedTime);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates each entity in the world
|
||||
*/
|
||||
|
||||
inline void World::Invalidate()
|
||||
{
|
||||
m_dirtyEntities.Resize(m_entities.size(), false);
|
||||
m_dirtyEntities.Set(true); // Activation of all bits
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates an entity in the world
|
||||
*
|
||||
* \param id Identifier of the entity
|
||||
*/
|
||||
|
||||
inline void World::Invalidate(EntityId id)
|
||||
{
|
||||
m_dirtyEntities.UnboundedSet(id, true);
|
||||
for (auto& systemPtr : m_orderedSystems)
|
||||
systemPtr->Update(elapsedTime);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -281,10 +264,12 @@ namespace Ndk
|
||||
|
||||
inline World& World::operator=(World&& world) noexcept
|
||||
{
|
||||
m_aliveEntities = std::move(world.m_aliveEntities);
|
||||
m_dirtyEntities = std::move(world.m_dirtyEntities);
|
||||
m_freeIdList = std::move(world.m_freeIdList);
|
||||
m_killedEntities = std::move(world.m_killedEntities);
|
||||
m_aliveEntities = std::move(world.m_aliveEntities);
|
||||
m_dirtyEntities = std::move(world.m_dirtyEntities);
|
||||
m_freeIdList = std::move(world.m_freeIdList);
|
||||
m_killedEntities = std::move(world.m_killedEntities);
|
||||
m_orderedSystems = std::move(world.m_orderedSystems);
|
||||
m_orderedSystemsUpdated = world.m_orderedSystemsUpdated;
|
||||
|
||||
m_entities = std::move(world.m_entities);
|
||||
for (EntityBlock& block : m_entities)
|
||||
@@ -296,4 +281,20 @@ namespace Ndk
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void World::Invalidate()
|
||||
{
|
||||
m_dirtyEntities.Resize(m_entities.size(), false);
|
||||
m_dirtyEntities.Set(true); // Activation of all bits
|
||||
}
|
||||
|
||||
inline void World::Invalidate(EntityId id)
|
||||
{
|
||||
m_dirtyEntities.UnboundedSet(id, true);
|
||||
}
|
||||
|
||||
inline void World::InvalidateSystemOrder()
|
||||
{
|
||||
m_orderedSystemsUpdated = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user