Merge remote-tracking branch 'refs/remotes/origin/master' into culling

This commit is contained in:
Lynix
2016-10-12 16:51:18 +02:00
95 changed files with 2139 additions and 348 deletions

View File

@@ -34,21 +34,21 @@ namespace Ndk
inline void EnsureViewMatrixUpdate() const;
inline void EnsureViewportUpdate() const;
inline float GetAspectRatio() const override;
inline Nz::Vector3f GetEyePosition() const override;
inline Nz::Vector3f GetForward() const override;
float GetAspectRatio() const override;
Nz::Vector3f GetEyePosition() const override;
Nz::Vector3f GetForward() const override;
inline float GetFOV() const;
inline const Nz::Frustumf& GetFrustum() const override;
const Nz::Frustumf& GetFrustum() const override;
inline unsigned int GetLayer() const;
inline const Nz::Matrix4f& GetProjectionMatrix() const override;
const Nz::Matrix4f& GetProjectionMatrix() const override;
inline Nz::ProjectionType GetProjectionType() const;
inline const Nz::Vector2f& GetSize() const;
inline const Nz::RenderTarget* GetTarget() const override;
const Nz::RenderTarget* GetTarget() const override;
inline const Nz::Rectf& GetTargetRegion() const;
inline const Nz::Matrix4f& GetViewMatrix() const override;
inline const Nz::Recti& GetViewport() const override;
inline float GetZFar() const override;
inline float GetZNear() const override;
const Nz::Matrix4f& GetViewMatrix() const override;
const Nz::Recti& GetViewport() const override;
float GetZFar() const override;
float GetZNear() const override;
inline void SetFOV(float fov);
inline void SetLayer(unsigned int layer);

View File

@@ -97,40 +97,15 @@ namespace Ndk
UpdateViewport();
}
/*!
* \brief Gets the aspect ratio of the camera
* \return Aspect ratio of the camera
*/
inline float CameraComponent::GetAspectRatio() const
{
EnsureViewportUpdate();
return m_aspectRatio;
}
/*!
* \brief Gets the field of view of the camera
* \return Field of view of the camera
*/
inline float CameraComponent::GetFOV() const
float CameraComponent::GetFOV() const
{
return m_fov;
}
/*!
* \brief Gets the frutum of the camera
* \return A constant reference to the frustum of the camera
*/
inline const Nz::Frustumf& CameraComponent::GetFrustum() const
{
EnsureFrustumUpdate();
return m_frustum;
}
/*!
* \brief Gets the layer of the camera
* \return Layer of the camera
@@ -141,18 +116,6 @@ namespace Ndk
return m_layer;
}
/*!
* \brief Gets the projection matrix of the camera
* \return A constant reference to the projection matrix of the camera
*/
inline const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const
{
EnsureProjectionMatrixUpdate();
return m_projectionMatrix;
}
/*!
* \brief Gets the projection type of the camera
* \return Projection type of the camera
@@ -173,16 +136,6 @@ namespace Ndk
return m_size;
}
/*!
* \brief Gets the target of the camera
* \return A constant reference to the render target of the camera
*/
inline const Nz::RenderTarget* CameraComponent::GetTarget() const
{
return m_target;
}
/*!
* \brief Gets the target region of the camera
* \return A constant reference to the target region of the camera
@@ -193,50 +146,6 @@ namespace Ndk
return m_targetRegion;
}
/*!
* \brief Gets the view matrix of the camera
* \return A constant reference to the view matrix of the camera
*/
inline const Nz::Matrix4f& CameraComponent::GetViewMatrix() const
{
EnsureViewMatrixUpdate();
return m_viewMatrix;
}
/*!
* \brief Gets the view port of the camera
* \return A constant reference to the view port of the camera
*/
inline const Nz::Recti& CameraComponent::GetViewport() const
{
EnsureViewportUpdate();
return m_viewport;
}
/*!
* \brief Gets the Z far distance of the camera
* \return Z far distance of the camera
*/
inline float CameraComponent::GetZFar() const
{
return m_zFar;
}
/*!
* \brief Gets the Z near distance of the camera
* \return Z near distance of the camera
*/
inline float CameraComponent::GetZNear() const
{
return m_zNear;
}
/*!
* \brief Sets the field of view of the camera
*

View File

@@ -172,4 +172,4 @@ namespace Ndk
InvalidateBoundingVolume();
InvalidateRenderables();
}
}
}

View File

@@ -51,7 +51,7 @@ namespace Ndk
inline bool IsVisible() const;
void SendCharacter(char32_t character);
void SendEvent(Nz::WindowEvent event);
void SendEvent(const Nz::WindowEvent& event);
void SetCharacterSize(unsigned int size);
void SetSize(const Nz::Vector2f& size);

View File

@@ -27,32 +27,15 @@
#include <Nazara/Prerequesites.hpp>
// Version of SDK
#define NDK_VERSION_MAJOR 0
#define NDK_VERSION_MINOR 1
// Importation/Exportation of the API
#if defined(NAZARA_PLATFORM_WINDOWS)
#if !defined(NDK_STATIC)
#ifdef NDK_BUILD
#define NDK_API NAZARA_EXPORT
#else
#define NDK_API NAZARA_IMPORT
#endif
#else
#define NDK_API
#endif
#elif defined(NAZARA_PLATFORM_LINUX)
#if !defined(NDK_STATIC) && defined(NAZARA_COMPILER_GCC)
#define NDK_API NAZARA_EXPORT
#else
#define NDK_API
#endif
#if defined(NAZARA_STATIC)
#define #define NDK_API
#else
// To comment to force a compilation
#error This operating system is not fully supported by the Nazara Development Kit
#define NDK_API
#ifdef NDK_BUILD
#define NDK_API NAZARA_EXPORT
#else
#define NDK_API NAZARA_IMPORT
#endif
#endif
namespace Ndk

View File

@@ -34,7 +34,7 @@ namespace Ndk
*
* \remark Only one Application instance can exist at a time
*/
inline Application::Application(int argc, char* argv[]) :
Application::Application(int argc, char* argv[]) :
Application()
{
std::regex optionRegex(R"(-(\w+))");

View File

@@ -35,6 +35,17 @@ namespace Ndk
Nz::Renderer::SetViewport(m_viewport);
}
/*!
* \brief Gets the aspect ratio of the camera
* \return Aspect ratio of the camera
*/
float CameraComponent::GetAspectRatio() const
{
EnsureViewportUpdate();
return m_aspectRatio;
}
/*!
* \brief Gets the eye position of the camera
*
@@ -53,7 +64,6 @@ namespace Ndk
*
* \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent
*/
Nz::Vector3f CameraComponent::GetForward() const
{
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
@@ -61,6 +71,77 @@ namespace Ndk
return m_entity->GetComponent<NodeComponent>().GetForward();
}
/*!
* \brief Gets the frutum of the camera
* \return A constant reference to the frustum of the camera
*/
const Nz::Frustumf& CameraComponent::GetFrustum() const
{
EnsureFrustumUpdate();
return m_frustum;
}
/*!
* \brief Gets the projection matrix of the camera
* \return A constant reference to the projection matrix of the camera
*/
const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const
{
EnsureProjectionMatrixUpdate();
return m_projectionMatrix;
}
/*!
* \brief Gets the target of the camera
* \return A constant reference to the render target of the camera
*/
const Nz::RenderTarget* CameraComponent::GetTarget() const
{
return m_target;
}
/*!
* \brief Gets the view matrix of the camera
* \return A constant reference to the view matrix of the camera
*/
const Nz::Matrix4f& CameraComponent::GetViewMatrix() const
{
EnsureViewMatrixUpdate();
return m_viewMatrix;
}
/*!
* \brief Gets the view port of the camera
* \return A constant reference to the view port of the camera
*/
const Nz::Recti& CameraComponent::GetViewport() const
{
EnsureViewportUpdate();
return m_viewport;
}
/*!
* \brief Gets the Z far distance of the camera
* \return Z far distance of the camera
*/
float CameraComponent::GetZFar() const
{
return m_zFar;
}
/*!
* \brief Gets the Z near distance of the camera
* \return Z near distance of the camera
*/
float CameraComponent::GetZNear() const
{
return m_zNear;
}
/*!
* \brief Sets the layer of the camera in case of multiples fields
*

View File

@@ -167,8 +167,7 @@ namespace Ndk
*
* \param event Event to be takin into consideration by the console
*/
void Console::SendEvent(Nz::WindowEvent event)
void Console::SendEvent(const Nz::WindowEvent& event)
{
switch (event.type)
{
@@ -204,6 +203,9 @@ namespace Ndk
}
break;
}
default:
break;
}
}

View File

@@ -78,9 +78,10 @@ namespace Ndk
});
/*********************************** Nz::SoundBuffer **********************************/
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance)
soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount)
{
NazaraUnused(lua);
NazaraUnused(argumentCount);
Nz::PlacementNew(instance, Nz::SoundBuffer::New());
return true;

View File

@@ -13,7 +13,7 @@ namespace Ndk
void LuaBinding::BindCore()
{
/*********************************** Nz::Clock **********************************/
clockClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock)
clockClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock, std::size_t argumentCount)
{
int argIndex = 1;
Nz::Int64 startingValue = lua.Check<Nz::Int64>(&argIndex, 0);
@@ -44,9 +44,9 @@ namespace Ndk
});
/********************************* Nz::Directory ********************************/
directoryClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* directory)
directoryClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* directory, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 1U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
int argIndex = 1;
switch (argCount)
@@ -138,9 +138,9 @@ namespace Ndk
/*********************************** Nz::File ***********************************/
fileClass.Inherit(streamClass);
fileClass.SetConstructor([](Nz::LuaInstance& lua, Nz::File* file)
fileClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* file, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
int argIndex = 1;
switch (argCount)

View File

@@ -20,8 +20,10 @@ namespace Ndk
return reinterpret_cast<Nz::InstancedRenderableRef*>(model); //TODO: Make a ObjectRefCast
});
modelClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::ModelRef* model)
modelClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::ModelRef* model, std::size_t argumentCount)
{
NazaraUnused(argumentCount);
Nz::PlacementNew(model, Nz::Model::New());
return true;
});

View File

@@ -14,9 +14,10 @@ namespace Ndk
void LuaBinding::BindMath()
{
/*********************************** Nz::EulerAngles **********************************/
eulerAnglesClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* angles)
eulerAnglesClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* angles, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 3U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 1U);
switch (argCount)
{
case 0:
@@ -154,9 +155,10 @@ namespace Ndk
});
/*********************************** Nz::Rect **********************************/
rectClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect)
rectClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 4U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
switch (argCount)
{
case 0:
@@ -309,9 +311,10 @@ namespace Ndk
});
/*********************************** Nz::Quaternion **********************************/
quaternionClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion)
quaternionClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 4U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 4U);
switch (argCount)
{
case 0:
@@ -337,6 +340,9 @@ namespace Ndk
case 4:
Nz::PlacementNew(quaternion, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4));
return true;
default:
break;
}
lua.Error("No matching overload for Quaternion constructor");
@@ -411,9 +417,10 @@ namespace Ndk
});
/*********************************** Nz::Vector2 **********************************/
vector2dClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Vector2d* vector)
vector2dClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector2d* vector, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 2U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 2U);
switch (argCount)
{
case 0:
@@ -533,9 +540,10 @@ namespace Ndk
});
/*********************************** Nz::Vector3 **********************************/
vector3dClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector)
vector3dClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 3U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 3U);
switch (argCount)
{
case 0:
@@ -546,7 +554,7 @@ namespace Ndk
case 1:
{
if (lua.IsOfType(1, Nz::LuaType_Number))
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(1, "Vector2")));
Nz::PlacementNew(vector, lua.CheckNumber(1));
else if (lua.IsOfType(1, "Vector2"))
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)));
else if (lua.IsOfType(1, "Vector3"))
@@ -560,7 +568,7 @@ namespace Ndk
case 2:
{
if (lua.IsOfType(1, Nz::LuaType_Number))
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(1, "Vector2")));
Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast<Nz::Vector2d*>(lua.CheckUserdata(2, "Vector2")));
else if (lua.IsOfType(1, "Vector2"))
Nz::PlacementNew(vector, *static_cast<Nz::Vector2d*>(lua.ToUserdata(1)), lua.CheckNumber(2));
else

View File

@@ -21,9 +21,9 @@ namespace Ndk
abstractSocketClass.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes);
/*********************************** Nz::IpAddress **********************************/
ipAddressClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* address)
ipAddressClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* address, std::size_t argumentCount)
{
unsigned int argCount = std::min(lua.GetStackTop(), 9U);
std::size_t argCount = std::min<std::size_t>(argumentCount, 9U);
int argIndex = 1;
switch (argCount)

View File

@@ -233,6 +233,9 @@ namespace Ndk
return &m_componentBinding[it->second];
}
default:
break;
}
instance.Error("Invalid component index at #" + Nz::String::Number(argIndex));

View File

@@ -93,8 +93,10 @@ namespace Ndk
});
/*********************************** Nz::Font **********************************/
fontClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::FontRef* font)
fontClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::FontRef* font, std::size_t argumentCount)
{
NazaraUnused(argumentCount);
Nz::PlacementNew(font, Nz::Font::New());
return true;
});

View File

@@ -59,6 +59,13 @@ namespace Ndk
// Initialize the engine first
// Shared modules
#ifdef NDK_SERVER
Nz::ParameterList parameters;
parameters.SetParameter("NoWindowSystem", true);
Nz::Utility::SetParameters(parameters);
#endif
Nz::Lua::Initialize();
Nz::Noise::Initialize();
Nz::Physics::Initialize();

View File

@@ -216,6 +216,13 @@ namespace Ndk
m_forceRenderQueueInvalidation = false;
}
for (const Ndk::EntityHandle& particleGroup : m_particleGroups)
{
ParticleGroupComponent& groupComponent = particleGroup->GetComponent<ParticleGroupComponent>();
groupComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::Identity()); //< ParticleGroup doesn't use Matrix4f
}
camComponent.ApplyView();
Nz::SceneData sceneData;