From 3fef3d4779db2e873a2178ea774f0efdf557365d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 May 2016 00:44:58 +0200 Subject: [PATCH 001/235] Plugins/Assimp: Fix stack corruption Former-commit-id: a53fd468a11945738fb6308720bb2cb9f8825ee6 --- plugins/Assimp/Plugin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 1c998e91c..68c443b29 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -206,8 +206,8 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) { aiVector3D position = iMesh->mVertices[j]; aiVector3D normal = iMesh->mNormals[j]; - aiVector3D tangent = iMesh->mTangents[j]; - aiVector3D uv = iMesh->mTextureCoords[0][j]; + aiVector3D tangent = (iMesh->HasTangentsAndBitangents()) ? iMesh->mTangents[j] : aiVector3D(0.f, 1.f, 0.f); + aiVector3D uv = (iMesh->HasTextureCoords(0)) ? iMesh->mTextureCoords[0][j] : aiVector3D(0.f); vertex->position = parameters.scale * Vector3f(position.x, position.y, position.z); vertex->normal.Set(normal.x, normal.y, normal.z); @@ -246,8 +246,8 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) auto ConvertTexture = [&] (aiTextureType aiType, const char* textureKey, const char* wrapKey = nullptr) { aiString path; - aiTextureMapMode mapMode; - if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode, nullptr) == aiReturn_SUCCESS) + aiTextureMapMode mapMode[3]; + if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS) { matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length)); @@ -255,7 +255,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) if (wrapKey) { SamplerWrap wrap = SamplerWrap_Default; - switch (mapMode) + switch (mapMode[0]) { case aiTextureMapMode_Clamp: case aiTextureMapMode_Decal: @@ -271,7 +271,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) break; default: - NazaraWarning("Assimp texture map mode 0x" + String::Number(mapMode, 16) + " not handled"); + NazaraWarning("Assimp texture map mode 0x" + String::Number(mapMode[0], 16) + " not handled"); break; } From c3742299311434be49ae828c9c3614b5b3f983a8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 18:33:47 +0200 Subject: [PATCH 002/235] Vulkan: Wrap vulkan queues Former-commit-id: a52ec6d36cf91473c1b8b2be12c71f3f98043feb --- include/Nazara/Vulkan/VkDevice.hpp | 3 +- include/Nazara/Vulkan/VkDevice.inl | 5 +- include/Nazara/Vulkan/VkQueue.hpp | 52 +++++++++++++++ include/Nazara/Vulkan/VkQueue.inl | 102 +++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 include/Nazara/Vulkan/VkQueue.hpp create mode 100644 include/Nazara/Vulkan/VkQueue.inl diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 8f915e965..1b9d3a470 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -19,6 +19,7 @@ namespace Nz namespace Vk { class Device; + class Queue; class Instance; using DeviceHandle = ObjectHandle; @@ -34,7 +35,7 @@ namespace Nz bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); - inline VkQueue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); + inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index 471107c84..77dc1e254 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -31,12 +32,12 @@ namespace Nz } } - inline VkQueue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) + inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { VkQueue queue; vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - return queue; + return Queue(*this, queue); } inline Instance& Device::GetInstance() diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp new file mode 100644 index 000000000..35c8d16e0 --- /dev/null +++ b/include/Nazara/Vulkan/VkQueue.hpp @@ -0,0 +1,52 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKAN_VKQUEUE_HPP +#define NAZARA_VULKAN_VKQUEUE_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class Queue + { + public: + inline Queue(Device& device, VkQueue queue); + inline Queue(const Queue& queue); + inline Queue(Queue&& queue); + inline ~Queue() = default; + + inline Device& GetDevice(); + inline VkResult GetLastErrorCode() const; + + inline bool Present(const VkPresentInfoKHR& presentInfo); + inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); + + inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE); + inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE); + + inline bool WaitIdle(); + + Queue& operator=(const Queue& queue) = delete; + Queue& operator=(Queue&&) = delete; + + inline operator VkQueue(); + + protected: + Device& m_device; + VkQueue m_handle; + VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKQUEUE_HPP diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl new file mode 100644 index 000000000..a47918da3 --- /dev/null +++ b/include/Nazara/Vulkan/VkQueue.inl @@ -0,0 +1,102 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline Queue::Queue(Device& device, VkQueue queue) : + m_device(device), + m_handle(queue), + m_lastErrorCode(VkResult::VK_SUCCESS) + { + } + + inline Queue::Queue(const Queue& queue) : + m_device(queue.m_device), + m_handle(queue.m_handle), + m_lastErrorCode(queue.m_lastErrorCode) + { + } + + inline Queue::Queue(Queue&& queue) : + m_device(queue.m_device), + m_handle(queue.m_handle), + m_lastErrorCode(queue.m_lastErrorCode) + { + } + + inline Device& Queue::GetDevice() + { + return m_device; + } + + inline VkResult Queue::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) + { + m_lastErrorCode = m_device.vkQueuePresentKHR(m_handle, &presentInfo); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) + { + VkPresentInfoKHR presentInfo = + { + VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, + nullptr, + (waitSemaphore) ? 1U : 0U, + &waitSemaphore, + 1U, + &swapchain, + &imageIndex, + nullptr + }; + + return Present(presentInfo); + } + + inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) + { + return Submit(1, &submit, fence); + } + + inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) + { + m_lastErrorCode = m_device.vkQueueSubmit(m_handle, submitCount, submits, fence); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline bool Queue::WaitIdle() + { + m_lastErrorCode = m_device.vkQueueWaitIdle(m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline Queue::operator VkQueue() + { + return m_handle; + } + + } +} + +#include From 57a065217f9c938b1b36a2708714919b4a92fdde Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 18:34:03 +0200 Subject: [PATCH 003/235] Vulkan/CommandBuffer: Add Begin/End overloads Former-commit-id: 9168327ce644631cfd8ad4ec43dbcd6b1675931c --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 10 ++- include/Nazara/Vulkan/VkCommandBuffer.inl | 98 +++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 0399d4cf7..2dea341dd 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -23,7 +23,15 @@ namespace Nz CommandBuffer(const CommandBuffer&) = delete; CommandBuffer(CommandBuffer&& commandBuffer); inline ~CommandBuffer(); - + + inline bool Begin(const VkCommandBufferBeginInfo& info); + inline bool Begin(VkCommandBufferUsageFlags flags); + inline bool Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo); + inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); + inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); + + inline bool End(); + inline void Free(); inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index 7e48901c2..d9944e33b 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -31,6 +31,104 @@ namespace Nz Free(); } + inline bool CommandBuffer::Begin(const VkCommandBufferBeginInfo& info) + { + m_lastErrorCode = m_pool->GetDevice().vkBeginCommandBuffer(m_handle, &info); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to begin command buffer"); + return false; + } + + return true; + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags) + { + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + nullptr + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo) + { + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + &inheritanceInfo + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) + { + NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); + + VkCommandBufferInheritanceInfo inheritanceInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, + nullptr, + renderPass, + subpass, + framebuffer, + (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + queryFlags, + pipelineStatistics + }; + + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + &inheritanceInfo + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) + { + NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); + + VkCommandBufferInheritanceInfo inheritanceInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, + nullptr, + VK_NULL_HANDLE, + 0, + VK_NULL_HANDLE, + (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + queryFlags, + pipelineStatistics + }; + + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + &inheritanceInfo + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::End() + { + m_lastErrorCode = m_pool->GetDevice().vkEndCommandBuffer(m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to end command buffer"); + return false; + } + + return true; + } + inline void CommandBuffer::Free() { if (m_handle) From b2f176214815ab58a5228be61974de88a3d04524 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 25 May 2016 13:52:10 +0200 Subject: [PATCH 004/235] Fix some GCC warnings Former-commit-id: fc3fa0fba08f558fc78eae72efdd150da9110a31 --- .../NDK/Components/CameraComponent.inl | 4 +- .../NDK/Components/GraphicsComponent.inl | 3 +- SDK/include/NDK/LuaAPI.inl | 4 ++ SDK/src/NDK/Console.cpp | 5 +++ SDK/src/NDK/LuaBinding.cpp | 4 +- SDK/src/NDK/LuaBinding_Audio.cpp | 18 +++++---- SDK/src/NDK/LuaBinding_Math.cpp | 38 ++++++++++++++++++- include/Nazara/Core/Algorithm.inl | 4 +- include/Nazara/Core/HandledObject.inl | 3 +- include/Nazara/Graphics/Light.inl | 2 +- include/Nazara/Lua/LuaClass.inl | 10 +++-- include/Nazara/Network/IpAddress.inl | 8 ++-- include/Nazara/Network/TcpClient.hpp | 2 +- include/Nazara/Utility/PixelFormat.inl | 28 +++++++------- src/Nazara/Core/File.cpp | 6 +-- src/Nazara/Core/ParameterList.cpp | 13 +++++-- src/Nazara/Graphics/ForwardRenderQueue.cpp | 6 +-- src/Nazara/Renderer/RenderTexture.cpp | 5 ++- src/Nazara/Utility/AlgorithmUtility.cpp | 4 +- 19 files changed, 113 insertions(+), 54 deletions(-) diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index d3bb9177e..d91c357eb 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -11,8 +11,8 @@ namespace Ndk inline CameraComponent::CameraComponent() : m_projectionType(Nz::ProjectionType_Perspective), m_targetRegion(0.f, 0.f, 1.f, 1.f), - m_size(0.f), m_target(nullptr), + m_size(0.f), m_frustumUpdated(false), m_projectionMatrixUpdated(false), m_viewMatrixUpdated(false), @@ -30,8 +30,8 @@ namespace Ndk AbstractViewer(camera), m_projectionType(camera.m_projectionType), m_targetRegion(camera.m_targetRegion), - m_size(camera.m_size), m_target(nullptr), + m_size(camera.m_size), m_frustumUpdated(false), m_projectionMatrixUpdated(false), m_viewMatrixUpdated(false), diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 205eb9462..c330da5eb 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -8,6 +8,7 @@ namespace Ndk { inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) : Component(graphicsComponent), + HandledObject(graphicsComponent), m_boundingVolume(graphicsComponent.m_boundingVolume), m_transformMatrix(graphicsComponent.m_transformMatrix), m_boundingVolumeUpdated(graphicsComponent.m_boundingVolumeUpdated), @@ -41,7 +42,7 @@ namespace Ndk 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)); - + InvalidateBoundingVolume(); } diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index ae2da917c..a42479cae 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -84,8 +84,12 @@ namespace Nz inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag) { + NazaraUnused(params); + instance.CheckType(index, Nz::LuaType_Table); + // Structure is empty for now + return 1; } diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 24a5d8df2..48ad10196 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -145,6 +145,7 @@ namespace Ndk { case Nz::Keyboard::Down: case Nz::Keyboard::Up: + { if (event.key.code == Nz::Keyboard::Up) m_historyPosition = std::min(m_commandHistory.size(), m_historyPosition + 1); else @@ -159,6 +160,10 @@ namespace Ndk m_inputDrawer.SetText(s_inputPrefix + text); m_inputTextSprite->Update(m_inputDrawer); break; + } + + default: + break; } break; } diff --git a/SDK/src/NDK/LuaBinding.cpp b/SDK/src/NDK/LuaBinding.cpp index 33c70dbe1..6acc05a46 100644 --- a/SDK/src/NDK/LuaBinding.cpp +++ b/SDK/src/NDK/LuaBinding.cpp @@ -29,8 +29,8 @@ namespace Ndk // SDK application("Application"), - nodeComponent("NodeComponent"), entityClass("Entity"), + nodeComponent("NodeComponent"), velocityComponent("VelocityComponent"), worldClass("World") @@ -39,9 +39,9 @@ namespace Ndk // Audio musicClass("Music"), + soundClass("Sound"), soundBuffer("SoundBuffer"), soundEmitter("SoundEmitter"), - soundClass("Sound"), // Graphics instancedRenderable("InstancedRenderable"), diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index d75c8215e..89452d720 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -76,6 +76,8 @@ namespace Ndk /*********************************** Nz::SoundBuffer **********************************/ soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance) { + NazaraUnused(lua); + Nz::PlacementNew(instance, Nz::SoundBuffer::New()); return true; }); @@ -115,16 +117,16 @@ namespace Ndk return 1; }); - soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& soundBuffer) -> int + soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int { Nz::StringStream stream("SoundBuffer("); - if (soundBuffer->IsValid()) + if (instance->IsValid()) { - Nz::String filePath = soundBuffer->GetFilePath(); + Nz::String filePath = instance->GetFilePath(); if (!filePath.IsEmpty()) stream << "File: " << filePath << ", "; - - stream << "Duration: " << soundBuffer->GetDuration() / 1000.f << "s"; + + stream << "Duration: " << instance->GetDuration() / 1000.f << "s"; } stream << ')'; @@ -148,17 +150,17 @@ namespace Ndk soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping); soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized); - + soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause); soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play); - + soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation); soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance); soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch); soundEmitter.BindMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition); soundEmitter.BindMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity); soundEmitter.BindMethod("SetVolume", &Nz::SoundEmitter::SetVolume); - + soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop); } diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index cf5454450..7db9ae9e2 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -238,9 +238,15 @@ namespace Ndk case 'h': lua.Push(instance.height); return true; + + default: + break; } break; } + + default: + break; } return false; @@ -290,6 +296,9 @@ namespace Ndk } break; } + + default: + break; } return false; @@ -313,7 +322,7 @@ namespace Ndk Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); else break; - + return true; } @@ -389,6 +398,9 @@ namespace Ndk case 'z': instance.z = value; return true; + + default: + break; } return false; @@ -455,9 +467,15 @@ namespace Ndk case 'y': lua.Push(instance.y); return true; + + default: + break; } break; } + + default: + break; } return false; @@ -496,9 +514,15 @@ namespace Ndk case 'y': instance.y = value; return true; + + default: + break; } break; } + + default: + break; } return false; @@ -582,9 +606,15 @@ namespace Ndk case 'z': lua.Push(instance.z); return true; + + default: + break; } break; } + + default: + break; } return false; @@ -627,9 +657,15 @@ namespace Ndk case 'z': instance.z = value; return true; + + default: + break; } break; } + + default: + break; } return false; diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 72b5ee27a..048fae8e9 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -78,7 +78,7 @@ namespace Nz * \param v Object to hash * * \remark a HashAppend specialization for type T is required - * + * * \see ComputeHash */ template @@ -178,7 +178,7 @@ namespace Nz { T reversed = 0; for (std::size_t i = 0; i < sizeof(T); ++i) - reversed |= T(Detail::BitReverseTable256[(integer >> i * 8) & 0xFF]) << sizeof(T) * 8 - (i + 1) * 8; + reversed |= T(Detail::BitReverseTable256[(integer >> i * 8) & 0xFF]) << (sizeof(T) * 8 - (i + 1) * 8); return reversed; } diff --git a/include/Nazara/Core/HandledObject.inl b/include/Nazara/Core/HandledObject.inl index 738a5f7a5..da435302e 100644 --- a/include/Nazara/Core/HandledObject.inl +++ b/include/Nazara/Core/HandledObject.inl @@ -13,6 +13,7 @@ namespace Nz template HandledObject::HandledObject(const HandledObject& object) { + NazaraUnused(object); // Don't copy anything, we're a copy of the object, we have no handle right now } @@ -40,7 +41,7 @@ namespace Nz HandledObject& HandledObject::operator=(const HandledObject& object) { // Nothing to do - return *this; + return *this; } template diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index e877852cb..edff48a66 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -9,9 +9,9 @@ namespace Nz { inline Light::Light(const Light& light) : Renderable(light), + m_color(light.m_color), m_type(light.m_type), m_shadowMapFormat(light.m_shadowMapFormat), - m_color(light.m_color), m_shadowMapSize(light.m_shadowMapSize), m_shadowCastingEnabled(light.m_shadowCastingEnabled), m_shadowMapUpdated(false), diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index 710b50416..89487b653 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -21,6 +21,8 @@ namespace Nz { SetConstructor([] (Nz::LuaInstance& lua, T* instance) { + NazaraUnused(lua); + PlacementNew(instance); return true; }); @@ -132,9 +134,9 @@ namespace Nz lua.SetField(pair.first); // Method name } - m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& lua) + m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& instance) { - return static_cast(lua.CheckUserdata(1, info->name)); + return static_cast(instance.CheckUserdata(1, info->name)); }; } lua.Pop(); // On pop la metatable @@ -391,11 +393,11 @@ namespace Nz if (!lua.IsValid(-1)) { - for (const ParentFunc& getter : info->parentGetters) + for (const ParentFunc& parentGetter : info->parentGetters) { lua.Pop(); //< Pop the last nil value - getter(lua, instance); + parentGetter(lua, instance); if (lua.IsValid(-1)) return; } diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index c11c1879a..3184bd34d 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -224,7 +224,7 @@ namespace std // This is SDBM adapted for IP addresses, tested to generate the least collisions possible // (It doesn't mean it cannot be improved though) - std::size_t hash = 0; + std::size_t h = 0; switch (ip.GetProtocol()) { case Nz::NetProtocol_Any: @@ -233,20 +233,20 @@ namespace std case Nz::NetProtocol_IPv4: { - hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash; + h = ip.ToUInt32() + (h << 6) + (h << 16) - h; break; } case Nz::NetProtocol_IPv6: { Nz::IpAddress::IPv6 v6 = ip.ToIPv6(); for (std::size_t i = 0; i < v6.size(); i++) - hash = v6[i] + (hash << 6) + (hash << 16) - hash; + h = v6[i] + (h << 6) + (h << 16) - h; break; } } - return ip.GetPort() + (hash << 6) + (hash << 16) - hash; + return ip.GetPort() + (h << 6) + (h << 16) - h; } }; } diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index fda4671f9..0fcedcf39 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -79,8 +79,8 @@ namespace Nz PendingPacket m_pendingPacket; UInt64 m_keepAliveInterval; UInt64 m_keepAliveTime; - bool m_isLowDelayEnabled; bool m_isKeepAliveEnabled; + bool m_isLowDelayEnabled; }; } diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index 7b05ec8fb..e30701d3d 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -12,29 +12,29 @@ namespace Nz { inline PixelFormatInfo::PixelFormatInfo() : - bitsPerPixel(0), - content(PixelFormatContent_Undefined) + content(PixelFormatContent_Undefined), + bitsPerPixel(0) { } inline PixelFormatInfo::PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : - bitsPerPixel(bpp), - content(formatContent), - redType(subType), - greenType(subType), - blueType(subType), - alphaType(subType) - { - } - - inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : - bitsPerPixel(bpp), content(formatContent), redType(subType), greenType(subType), blueType(subType), alphaType(subType), - name(formatName) + bitsPerPixel(bpp) + { + } + + inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : + content(formatContent), + redType(subType), + greenType(subType), + blueType(subType), + alphaType(subType), + name(formatName), + bitsPerPixel(bpp) { } diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 97504b0ee..39e873373 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -385,7 +385,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param pos Position of the cursor @@ -404,7 +404,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param offset Offset according to the cursor begin position @@ -906,5 +906,5 @@ namespace Nz } return true; - }; + } } diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 91426a0b7..371e91b77 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -94,6 +94,7 @@ namespace Nz break; } + case ParameterType_Color: case ParameterType_Float: case ParameterType_None: case ParameterType_Pointer: @@ -198,6 +199,7 @@ namespace Nz } case ParameterType_Boolean: + case ParameterType_Color: case ParameterType_None: case ParameterType_Pointer: case ParameterType_Userdata: @@ -207,7 +209,7 @@ namespace Nz NazaraError("Parameter value is not representable as a float"); return false; } - + /*! * \brief Gets a parameter as an integer * \return true if the parameter could be represented as an integer @@ -263,6 +265,7 @@ namespace Nz break; } + case ParameterType_Color: case ParameterType_None: case ParameterType_Pointer: case ParameterType_Userdata: @@ -331,6 +334,7 @@ namespace Nz return true; case ParameterType_Boolean: + case ParameterType_Color: case ParameterType_Float: case ParameterType_Integer: case ParameterType_None: @@ -411,7 +415,7 @@ namespace Nz NazaraInternalError("Parameter value is not valid"); return false; } - + /*! * \brief Gets a parameter as an userdata * \return true if the parameter could be represented as a userdata @@ -584,7 +588,7 @@ namespace Nz parameter.type = ParameterType_Integer; parameter.value.intVal = value; } - + /*! * \brief Sets a pointer parameter named `name` * @@ -593,7 +597,7 @@ namespace Nz * \param name Name of the parameter * \param value The pointer value * - * \remark This sets a raw pointer, this class takes no responsibility toward it, + * \remark This sets a raw pointer, this class takes no responsibility toward it, if you wish to destroy the pointed variable along with the parameter list, you should set a userdata */ void ParameterList::SetParameter(const String& name, void* value) @@ -639,6 +643,7 @@ namespace Nz switch (it->second.type) { case ParameterType_Boolean: + case ParameterType_Color: case ParameterType_Float: case ParameterType_Integer: case ParameterType_Pointer: diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 683230706..9f0f5d04d 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -524,9 +524,9 @@ namespace Nz Vector3f viewerPos = viewer->GetEyePosition(); Vector3f viewerNormal = viewer->GetForward(); - for (auto& pair : layers) + for (auto& layerPair : layers) { - Layer& layer = pair.second; + Layer& layer = layerPair.second; std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2) { @@ -562,7 +562,7 @@ namespace Nz auto it = layers.find(i); if (it == layers.end()) it = layers.insert(std::make_pair(i, Layer())).first; - + Layer& layer = it->second; layer.clearCount = 0; diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 0ae0d97bf..c6e78df86 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -57,11 +57,14 @@ namespace Nz case PixelFormatContent_Stencil: return AttachmentPoint_Stencil; + + case PixelFormatContent_Undefined: + break; } NazaraInternalError("Unexpected pixel format content: 0x" + String::Number(info.content, 16)); return AttachmentPoint_Max; - }; + } GLuint lockedPrevious = 0; UInt8 lockedLevel = 0; diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index b23542993..7f4dbaf44 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -105,9 +105,9 @@ namespace Nz for (unsigned int i = 0; i < recursionLevel; ++i) { std::size_t triangleCount = triangles.size(); - for (std::size_t i = 0; i < triangleCount; ++i) + for (std::size_t j = 0; j < triangleCount; ++j) { - Vector3ui& triangle = triangles[i]; + Vector3ui& triangle = triangles[j]; unsigned int a = GetMiddleVertex(triangle.x, triangle.y); unsigned int b = GetMiddleVertex(triangle.y, triangle.z); From 3eb8642d0189bd7b281824cfb2c4955338392cc7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 07:41:32 +0200 Subject: [PATCH 005/235] Graphics/DepthRenderTechnique: Fix typo in include name Former-commit-id: cddcab2bc77cbed7b98ebb0085e3f32f82eb4d7e --- include/Nazara/Graphics/DepthRenderTechnique.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Graphics/DepthRenderTechnique.hpp b/include/Nazara/Graphics/DepthRenderTechnique.hpp index ac75f7e52..42b7f6e0a 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.hpp +++ b/include/Nazara/Graphics/DepthRenderTechnique.hpp @@ -74,6 +74,6 @@ namespace Nz } -#include +#include #endif // NAZARA_DEPTHRENDERTECHNIQUE_HPP From bffa500d88e22a4da5a40f8a32d7c2fed44117dd Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 08:48:22 +0200 Subject: [PATCH 006/235] Build: Improve build - Help linux default to 64bits build in case of 64bits OS - Fix linux linking with tools Former-commit-id: cacdaacf29cf2a14a46926c69e996b7d171b0d6a --- build/scripts/common.lua | 60 +++++++++++++++++++++++------------ examples/FirstScene/build.lua | 4 --- examples/Tut01/build.lua | 4 --- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index ec95c2641..15bf69849 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -5,12 +5,19 @@ function NazaraBuild:Execute() return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien end + local platformData + if (os.is64bit()) then + platformData = {"x64", "x86"} + else + platformData = {"x64", "x86"} + end + if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" if (#self.OrderedExtLibs > 0) then workspace("NazaraExtlibs") - platforms({"x32", "x64"}) + platforms(platformData) -- Configuration générale configurations({ @@ -23,13 +30,13 @@ function NazaraBuild:Execute() location(_ACTION) kind("StaticLib") - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") targetdir("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -40,7 +47,7 @@ function NazaraBuild:Execute() configuration("vs*") buildoptions("/MP") - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") targetdir("../extlibs/lib/msvc/x86") @@ -48,7 +55,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x64") targetdir("../extlibs/lib/msvc/x64") - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../extlibs/lib/xcode/x86") targetdir("../extlibs/lib/xcode/x86") @@ -102,7 +109,7 @@ function NazaraBuild:Execute() end workspace("NazaraEngine") - platforms({"x32", "x64"}) + platforms(platformData) -- Configuration générale configurations({ @@ -171,14 +178,14 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") targetdir("../lib/" .. makeLibDir .. "/x86") @@ -193,7 +200,7 @@ function NazaraBuild:Execute() self:MakeCopyAfterBuild(moduleTable) end - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") targetdir("../lib/msvc/x86") @@ -203,7 +210,7 @@ function NazaraBuild:Execute() libdirs("../lib/msvc/x64") targetdir("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") targetdir("../lib/xcode/x86") @@ -278,20 +285,20 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then targetdir("../lib/" .. makeLibDir .. "/x86") elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x32") + targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x86") end configuration({"codeblocks or codelite or gmake", "x64"}) @@ -308,7 +315,7 @@ function NazaraBuild:Execute() self:MakeCopyAfterBuild(toolTable) end - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") if (toolTable.Kind == "library") then @@ -326,7 +333,7 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x64") end - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") if (toolTable.Kind == "library") then @@ -406,26 +413,26 @@ function NazaraBuild:Execute() includedirs(exampleTable.Includes) links(exampleTable.Libraries) - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../lib/" .. makeLibDir .. "/x86") configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../lib/" .. makeLibDir .. "/x64") - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../lib/msvc/x86") configuration({"vs*", "x64"}) libdirs("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../lib/xcode/x86") configuration({"xcode3 or xcode4", "x64"}) @@ -801,6 +808,17 @@ function NazaraBuild:Process(infoTable) for k,v in ipairs(toolTable.Includes) do table.insert(infoTable.Includes, v) end + + -- And libraries + for k, v in pairs(toolTable.Libraries) do + table.insert(infoTable.Libraries, v) + end + + for config, libs in pairs(toolTable.ConfigurationLibraries) do + for k,v in pairs(libs) do + table.insert(infoTable.ConfigurationLibraries[config], v) + end + end table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") @@ -853,8 +871,8 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do local paths = {} - table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) - table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) + table.insert(paths, {"x86", "../extlibs/lib/common/x86/" .. v .. ".dll"}) + table.insert(paths, {"x86", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) diff --git a/examples/FirstScene/build.lua b/examples/FirstScene/build.lua index bdcdf8bca..14bf8a42f 100644 --- a/examples/FirstScene/build.lua +++ b/examples/FirstScene/build.lua @@ -7,9 +7,5 @@ EXAMPLE.Files = { } EXAMPLE.Libraries = { - "NazaraCore", - "NazaraGraphics", - "NazaraRenderer", - "NazaraUtility", "NazaraSDK" } diff --git a/examples/Tut01/build.lua b/examples/Tut01/build.lua index 03b4457ab..c12dc35b5 100644 --- a/examples/Tut01/build.lua +++ b/examples/Tut01/build.lua @@ -7,9 +7,5 @@ EXAMPLE.Files = { } EXAMPLE.Libraries = { - "NazaraCore", - "NazaraGraphics", - "NazaraRenderer", - "NazaraUtility", "NazaraSDK" } From d4bc32717f6cc3e76c17aa76c5662bbc73635ac1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 08:50:49 +0200 Subject: [PATCH 007/235] Build: Fix linking for audio and utility system for POSIX Former-commit-id: 4be274b9e7b9be6a62bde87ae2629cc87da3f1de --- build/scripts/modules/audio.lua | 17 ++++++++++++----- build/scripts/modules/utility.lua | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build/scripts/modules/audio.lua b/build/scripts/modules/audio.lua index 4fcb1bf5a..27e49a08c 100644 --- a/build/scripts/modules/audio.lua +++ b/build/scripts/modules/audio.lua @@ -5,19 +5,26 @@ MODULE.Defines = { } MODULE.Libraries = { - "NazaraCore", + "NazaraCore" +} + +MODULE.OsLibraries.Windows = { "sndfile-1" } +MODULE.OsLibraries.Posix = { + "sndfile" +} + +MODULE.OsDynLib.Windows = { + "soft_oal" +} + MODULE.OsFiles.Windows = { "../src/Nazara/Audio/Win32/**.hpp", "../src/Nazara/Audio/Win32/**.cpp" } -MODULE.OsDynLib.Windows = { - "soft_oal" -} - MODULE.OsFiles.Posix = { "../src/Nazara/Audio/Posix/**.hpp", "../src/Nazara/Audio/Posix/**.cpp" diff --git a/build/scripts/modules/utility.lua b/build/scripts/modules/utility.lua index 1fafbd1a4..c1bc186c0 100644 --- a/build/scripts/modules/utility.lua +++ b/build/scripts/modules/utility.lua @@ -1,7 +1,6 @@ MODULE.Name = "Utility" MODULE.Libraries = { - "freetype-s", "NazaraCore", "stb_image" } @@ -17,10 +16,12 @@ MODULE.OsFiles.Posix = { } MODULE.OsLibraries.Windows = { + "freetype-s", "gdi32" } MODULE.OsLibraries.Posix = { + "freetype", "X11", "xcb", "xcb-cursor", From 9eae42f72beb81ead63a3ef661b9bf27145a9c41 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 13:36:52 +0200 Subject: [PATCH 008/235] Documentation for module: Audio Former-commit-id: 0b55ca6dd75769c29d8882a709395a8b90203759 --- include/Nazara/Audio/Algorithm.inl | 16 +- include/Nazara/Audio/Config.hpp | 15 +- include/Nazara/Audio/ConfigCheck.hpp | 4 +- include/Nazara/Audio/DebugOff.hpp | 2 +- include/Nazara/Audio/Enums.hpp | 2 +- include/Nazara/Audio/OpenAL.hpp | 10 +- include/Nazara/Audio/SoundBuffer.inl | 7 + include/Nazara/Audio/SoundEmitter.hpp | 2 +- src/Nazara/Audio/Audio.cpp | 176 ++++++++++++++++-- src/Nazara/Audio/Music.cpp | 172 +++++++++++++++-- src/Nazara/Audio/OpenAL.cpp | 125 +++++++++++-- src/Nazara/Audio/Sound.cpp | 130 ++++++++++++- src/Nazara/Audio/SoundBuffer.cpp | 144 +++++++++++++- src/Nazara/Audio/SoundEmitter.cpp | 123 +++++++++++- src/Nazara/Audio/SoundStream.cpp | 8 + tests/Engine/Audio/AlgorithmAudio.cpp | 19 ++ tests/Engine/Audio/Music.cpp | 49 +++++ tests/Engine/Audio/Sound.cpp | 44 +++++ tests/Engine/Audio/SoundBuffer.cpp | 21 +++ tests/Engine/Audio/SoundEmitter.cpp | 41 ++++ .../Engine/Audio/Cat.flac.REMOVED.git-id | 1 + .../Audio/The_Brabanconne.ogg.REMOVED.git-id | 1 + tests/resources/Engine/Audio/copyrights.txt | 54 ++++++ 23 files changed, 1110 insertions(+), 56 deletions(-) create mode 100644 tests/Engine/Audio/AlgorithmAudio.cpp create mode 100644 tests/Engine/Audio/Music.cpp create mode 100644 tests/Engine/Audio/Sound.cpp create mode 100644 tests/Engine/Audio/SoundBuffer.cpp create mode 100644 tests/Engine/Audio/SoundEmitter.cpp create mode 100644 tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id create mode 100644 tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id create mode 100644 tests/resources/Engine/Audio/copyrights.txt diff --git a/include/Nazara/Audio/Algorithm.inl b/include/Nazara/Audio/Algorithm.inl index ec89cdca9..1075a8b57 100644 --- a/include/Nazara/Audio/Algorithm.inl +++ b/include/Nazara/Audio/Algorithm.inl @@ -7,11 +7,21 @@ namespace Nz { + /*! + * \ingroup audio + * \brief Mixes channels in mono + * + * \param input Input buffer with multiples channels + * \param output Output butter for mono + * \param channelCount Number of channels + * \param frameCount Number of frames + * + * \remark The input buffer may be the same as the output one + */ template void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount) { - ///DOC: Le buffer d'entrée peut être le même que le buffer de sortie - // Pour éviter l'overflow, on utilise comme accumulateur un type assez grand, (u)int 64 bits pour les entiers, double pour les flottants + // To avoid overflow, we use, as an accumulator, a type which is large enough: (u)int 64 bits for integers, double for floatings typedef typename std::conditional::value, UInt64, Int64>::type BiggestInt; typedef typename std::conditional::value, BiggestInt, double>::type Biggest; @@ -19,7 +29,7 @@ namespace Nz { Biggest acc = Biggest(0); for (unsigned int j = 0; j < channelCount; ++j) - acc += input[i*channelCount + j]; + acc += input[i * channelCount + j]; output[i] = static_cast(acc / channelCount); } diff --git a/include/Nazara/Audio/Config.hpp b/include/Nazara/Audio/Config.hpp index e11bda468..8e2068069 100644 --- a/include/Nazara/Audio/Config.hpp +++ b/include/Nazara/Audio/Config.hpp @@ -27,18 +27,23 @@ #ifndef NAZARA_CONFIG_AUDIO_HPP #define NAZARA_CONFIG_AUDIO_HPP -/// Modifier la configuration d'un module nécessite une recompilation quasi-intégrale de celui-ci et de ceux en héritant +/*! +* \defgroup audio (NazaraAudio) Audio module +* Audio/System module including classes to handle music, sound, etc... +*/ -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +/// Each modification of a parameter needs a recompilation of the module + +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) #define NAZARA_AUDIO_MANAGE_MEMORY 0 -// Active les tests de sécurité supplémentaires (Teste notamment les arguments des fonctions, conseillé pour le développement) +// Activate the security tests based on the code (Advised for development) #define NAZARA_AUDIO_SAFE 1 -// Le nombre de buffers utilisés lors du streaming d'objets audio (Au moins deux) +// The number of buffers used for audio streaming (At least two) #define NAZARA_AUDIO_STREAMED_BUFFER_COUNT 2 -/// Vérification des valeurs et types de certaines constantes +/// Checking the values and types of certain constants #include #if !defined(NAZARA_STATIC) diff --git a/include/Nazara/Audio/ConfigCheck.hpp b/include/Nazara/Audio/ConfigCheck.hpp index 9ed35c1a4..70d0c6fe5 100644 --- a/include/Nazara/Audio/ConfigCheck.hpp +++ b/include/Nazara/Audio/ConfigCheck.hpp @@ -7,12 +7,12 @@ #ifndef NAZARA_CONFIG_CHECK_AUDIO_HPP #define NAZARA_CONFIG_CHECK_AUDIO_HPP -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp +/// This file is used to check the constant values defined in Config.hpp #include #define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) -// On force la valeur de MANAGE_MEMORY en mode debug +// We force the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_AUDIO_MANAGE_MEMORY #undef NAZARA_AUDIO_MANAGE_MEMORY #define NAZARA_AUDIO_MANAGE_MEMORY 0 diff --git a/include/Nazara/Audio/DebugOff.hpp b/include/Nazara/Audio/DebugOff.hpp index 254d7701d..e5149d5b5 100644 --- a/include/Nazara/Audio/DebugOff.hpp +++ b/include/Nazara/Audio/DebugOff.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +// We assume that Debug.hpp has already been included, same thing for Config.hpp #if NAZARA_AUDIO_MANAGE_MEMORY #undef delete #undef new diff --git a/include/Nazara/Audio/Enums.hpp b/include/Nazara/Audio/Enums.hpp index b8d3e3ec6..20866e5e9 100644 --- a/include/Nazara/Audio/Enums.hpp +++ b/include/Nazara/Audio/Enums.hpp @@ -13,7 +13,7 @@ namespace Nz { AudioFormat_Unknown = -1, - // La valeur entière est le nombre de canaux possédés par ce format + // The integer value is the number of channels used by the format AudioFormat_Mono = 1, AudioFormat_Stereo = 2, AudioFormat_Quad = 4, diff --git a/include/Nazara/Audio/OpenAL.hpp b/include/Nazara/Audio/OpenAL.hpp index eab95e6d0..aa80f406e 100644 --- a/include/Nazara/Audio/OpenAL.hpp +++ b/include/Nazara/Audio/OpenAL.hpp @@ -15,18 +15,18 @@ #include #include -// Inclusion des headers OpenAL +// Inclusion of OpenAL headers -// Étant donné que les headers OpenAL ne nous permettent pas de n'avoir que les signatures sans les pointeurs de fonctions -// Et que je ne souhaite pas les modifier, je suis contraint de les placer dans un espace de nom différent pour ensuite -// remettre dans l'espace global les choses intéressantes (les typedef notamment) +// OpenAL headers does not allow us to only get the signatures without the pointers to the functions +// And I do no want to modify them, I'm obliged to put them in a different namespace +// to put only interesting things back in the global namespace (specially typedef) namespace OpenALDetail { #include #include } -// Si quelqu'un a une meilleure idée ... +// If someone has a better idea ... using OpenALDetail::ALboolean; using OpenALDetail::ALbyte; using OpenALDetail::ALchar; diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index 9c5d1198b..a4c42be69 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -7,6 +7,13 @@ namespace Nz { + /*! + * \brief Creates a new sound buffer from the arguments + * \return A reference to the newly created sound buffer + * + * \param args Arguments for the sound buffer + */ + template SoundBufferRef SoundBuffer::New(Args&&... args) { diff --git a/include/Nazara/Audio/SoundEmitter.hpp b/include/Nazara/Audio/SoundEmitter.hpp index d56cd1bca..9a68d88cc 100644 --- a/include/Nazara/Audio/SoundEmitter.hpp +++ b/include/Nazara/Audio/SoundEmitter.hpp @@ -12,7 +12,7 @@ #include #include -///TODO: Faire hériter SoundEmitter de Node +///TODO: Inherit SoundEmitter from Node namespace Nz { diff --git a/src/Nazara/Audio/Audio.cpp b/src/Nazara/Audio/Audio.cpp index c0e785865..6eaa86c39 100644 --- a/src/Nazara/Audio/Audio.cpp +++ b/src/Nazara/Audio/Audio.cpp @@ -16,6 +16,21 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::Audio + * \brief Audio class that represents the module initializer of Audio + */ + + /*! + * \brief Gets the format of the audio + * \return AudioFormat Enumeration type for the format + * + * \param channelCount Number of channels + * + * \remark Produces a NazaraError if the number of channels is erroneous (3 or 5) and AudioFormat_Unknown is returned + */ + AudioFormat Audio::GetAudioFormat(unsigned int channelCount) { switch (channelCount) @@ -34,19 +49,36 @@ namespace Nz } } + /*! + * \brief Gets the factor of the doppler effect + * \return Global factor of the doppler effect + */ + float Audio::GetDopplerFactor() { return alGetFloat(AL_DOPPLER_FACTOR); } + /*! + * \brief Gets the global volume + * \return Float between [0, inf) with 100.f being the default + */ + float Audio::GetGlobalVolume() { ALfloat gain = 0.f; alGetListenerf(AL_GAIN, &gain); - return gain*100.f; + return gain * 100.f; } + /*! + * \brief Gets the direction of the listener + * \return Direction of the listener, in front of the listener + * + * \see GetListenerRotation + */ + Vector3f Audio::GetListenerDirection() { ALfloat orientation[6]; @@ -55,6 +87,13 @@ namespace Nz return Vector3f(orientation[0], orientation[1], orientation[2]); } + /*! + * \brief Gets the position of the listener + * \return Position of the listener + * + * \see GetListenerVelocity + */ + Vector3f Audio::GetListenerPosition() { Vector3f position; @@ -63,6 +102,11 @@ namespace Nz return position; } + /*! + * \brief Gets the rotation of the listener + * \return Rotation of the listener + */ + Quaternionf Audio::GetListenerRotation() { ALfloat orientation[6]; @@ -73,6 +117,13 @@ namespace Nz return Quaternionf::RotationBetween(Vector3f::Forward(), forward); } + /*! + * \brief Gets the velocity of the listener + * \return Velocity of the listener + * + * \see GetListenerPosition + */ + Vector3f Audio::GetListenerVelocity() { Vector3f velocity; @@ -81,20 +132,33 @@ namespace Nz return velocity; } + /*! + * \brief Gets the speed of sound + * \return Speed of sound + */ + float Audio::GetSpeedOfSound() { return alGetFloat(AL_SPEED_OF_SOUND); } + /*! + * \brief Initializes the Audio module + * \return true if initialization is successful + * + * \remark Produces a NazaraError if initialization of modules Core, OpenAL or SoundBuffer failed + * \remark Produces a NazaraNotice + */ + bool Audio::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; - return true; // Déjà initialisé + return true; // Already initialized } - // Initialisation des dépendances + // Initialisation of dependencies if (!Core::Initialize()) { NazaraError("Failed to initialize core module"); @@ -103,10 +167,10 @@ namespace Nz s_moduleReferenceCounter++; - // Initialisation du module + // Initialisation of the module CallOnExit onExit(Audio::Uninitialize); - // Initialisation d'OpenAL + // Initialisation of OpenAL if (!OpenAL::Initialize()) { NazaraError("Failed to initialize OpenAL"); @@ -119,7 +183,7 @@ namespace Nz return false; } - // Définition de l'orientation par défaut + // Definition of the orientation by default SetListenerDirection(Vector3f::Forward()); // Loaders @@ -131,6 +195,13 @@ namespace Nz return true; } + /*! + * \brief Checks whether the format is supported by the engine + * \return true if it is the case + * + * \param format Format to check + */ + bool Audio::IsFormatSupported(AudioFormat format) { if (format == AudioFormat_Unknown) @@ -139,21 +210,46 @@ namespace Nz return OpenAL::AudioFormat[format] != 0; } + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + bool Audio::IsInitialized() { return s_moduleReferenceCounter != 0; } + /*! + * \brief Sets the factor of the doppler effect + * + * \param dopplerFactor Global factor of the doppler effect + */ + void Audio::SetDopplerFactor(float dopplerFactor) { alDopplerFactor(dopplerFactor); } + /*! + * \brief Sets the global volume + * + * \param volume Float between [0, inf) with 100.f being the default + */ + void Audio::SetGlobalVolume(float volume) { - alListenerf(AL_GAIN, volume*0.01f); + alListenerf(AL_GAIN, volume * 0.01f); } + /*! + * \brief Sets the direction of the listener + * + * \param direction Direction of the listener, in front of the listener + * + * \see SetListenerDirection, SetListenerRotation + */ + void Audio::SetListenerDirection(const Vector3f& direction) { Vector3f up = Vector3f::Up(); @@ -167,6 +263,14 @@ namespace Nz alListenerfv(AL_ORIENTATION, orientation); } + /*! + * \brief Sets the direction of the listener + * + * \param (dirX, dirY, dirZ) Direction of the listener, in front of the listener + * + * \see SetListenerDirection, SetListenerRotation + */ + void Audio::SetListenerDirection(float dirX, float dirY, float dirZ) { Vector3f up = Vector3f::Up(); @@ -180,16 +284,38 @@ namespace Nz alListenerfv(AL_ORIENTATION, orientation); } + /*! + * \brief Sets the position of the listener + * + * \param position Position of the listener + * + * \see SetListenerVelocity + */ + void Audio::SetListenerPosition(const Vector3f& position) { alListenerfv(AL_POSITION, position); } + /*! + * \brief Sets the position of the listener + * + * \param (x, y, z) Position of the listener + * + * \see SetListenerVelocity + */ + void Audio::SetListenerPosition(float x, float y, float z) { alListener3f(AL_POSITION, x, y, z); } + /*! + * \brief Sets the rotation of the listener + * + * \param rotation Rotation of the listener + */ + void Audio::SetListenerRotation(const Quaternionf& rotation) { Vector3f forward = rotation * Vector3f::Forward(); @@ -204,33 +330,61 @@ namespace Nz alListenerfv(AL_ORIENTATION, orientation); } + /*! + * \brief Sets the velocity of the listener + * + * \param velocity Velocity of the listener + * + * \see SetListenerPosition + */ + void Audio::SetListenerVelocity(const Vector3f& velocity) { alListenerfv(AL_VELOCITY, velocity); } + /*! + * \brief Sets the velocity of the listener + * + * \param (velX, velY, velZ) Velocity of the listener + * + * \see SetListenerPosition + */ + void Audio::SetListenerVelocity(float velX, float velY, float velZ) { alListener3f(AL_VELOCITY, velX, velY, velZ); } + /*! + * \brief Sets the speed of sound + * + * \param speed Speed of sound + */ + void Audio::SetSpeedOfSound(float speed) { alSpeedOfSound(speed); } + /*! + * \brief Uninitializes the Audio module + * + * \remark Produces a NazaraNotice + */ + void Audio::Uninitialize() { if (s_moduleReferenceCounter != 1) { - // Le module est soit encore utilisé, soit pas initialisé + // The module is still in use, or can not be uninitialized if (s_moduleReferenceCounter > 1) s_moduleReferenceCounter--; return; } - // Libération du module + // Free of module s_moduleReferenceCounter = 0; // Loaders @@ -241,7 +395,7 @@ namespace Nz NazaraNotice("Uninitialized: Audio module"); - // Libération des dépendances + // Free of dependencies Core::Uninitialize(); } diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index bbcb7d813..9e38c7114 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -14,6 +14,19 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::Music + * \brief Audio class that represents a music + * + * \remark Module Audio needs to be initialized to use this class + */ + + /*! + * \brief Checks whether the parameters for the loading of the music are correct + * \return true If parameters are valid + */ + bool MusicParams::IsValid() const { return true; @@ -32,11 +45,26 @@ namespace Nz unsigned int sampleRate; }; + /*! + * \brief Destructs the object and calls Destroy + * + * \see Destroy + */ + Music::~Music() { Destroy(); } + /*! + * \brief Creates a music with a sound stream + * \return true if creation was succesful + * + * \param soundStream Sound stream which is the source for the music + * + * \remark Produces a NazaraError if soundStream is invalid with NAZARA_AUDIO_SAFE defined + */ + bool Music::Create(SoundStream* soundStream) { NazaraAssert(soundStream, "Invalid stream"); @@ -48,7 +76,7 @@ namespace Nz m_impl = new MusicImpl; m_impl->sampleRate = soundStream->GetSampleRate(); m_impl->audioFormat = OpenAL::AudioFormat[format]; - m_impl->chunkSamples.resize(format * m_impl->sampleRate); // Une seconde de samples + m_impl->chunkSamples.resize(format * m_impl->sampleRate); // One second of samples m_impl->stream.reset(soundStream); SetPlayingOffset(0); @@ -56,6 +84,10 @@ namespace Nz return true; } + /*! + * \brief Destroys the current music and frees resources + */ + void Music::Destroy() { if (m_impl) @@ -67,6 +99,14 @@ namespace Nz } } + /*! + * \brief Enables the looping of the music + * + * \param loop Should music loop + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::EnableLooping(bool loop) { #if NAZARA_AUDIO_SAFE @@ -80,6 +120,13 @@ namespace Nz m_impl->loop = loop; } + /*! + * \brief Gets the duration of the music + * \return Duration of the music in milliseconds + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetDuration() const { #if NAZARA_AUDIO_SAFE @@ -93,6 +140,13 @@ namespace Nz return m_impl->stream->GetDuration(); } + /*! + * \brief Gets the format of the music + * \return Enumeration of type AudioFormat (mono, stereo, ...) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + AudioFormat Music::GetFormat() const { #if NAZARA_AUDIO_SAFE @@ -106,6 +160,13 @@ namespace Nz return m_impl->stream->GetFormat(); } + /*! + * \brief Gets the current offset in the music + * \return Offset in milliseconds (works with entire seconds) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetPlayingOffset() const { #if NAZARA_AUDIO_SAFE @@ -125,6 +186,13 @@ namespace Nz return static_cast((1000ULL * (samples + (m_impl->processedSamples / m_impl->stream->GetFormat()))) / m_impl->sampleRate); } + /*! + * \brief Gets the number of samples in the music + * \return Count of samples (number of seconds * sample rate * channel count) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetSampleCount() const { #if NAZARA_AUDIO_SAFE @@ -138,6 +206,13 @@ namespace Nz return m_impl->stream->GetSampleCount(); } + /*! + * \brief Gets the rates of sample in the music + * \return Rate of sample in Hertz (Hz) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetSampleRate() const { #if NAZARA_AUDIO_SAFE @@ -151,6 +226,14 @@ namespace Nz return m_impl->sampleRate; } + /*! + * \brief Gets the status of the music + * \return Enumeration of type SoundStatus (Playing, Stopped, ...) + * + * \remark If the music is not playing, Stopped is returned + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + SoundStatus Music::GetStatus() const { #if NAZARA_AUDIO_SAFE @@ -163,13 +246,20 @@ namespace Nz SoundStatus status = GetInternalStatus(); - // Pour compenser les éventuels retards (ou le laps de temps entre Play() et la mise en route du thread) + // To compensate any delays (or the timelaps between Play() and the thread startup) if (m_impl->streaming && status == SoundStatus_Stopped) status = SoundStatus_Playing; return status; } + /*! + * \brief Checks whether the music is looping + * \return true if it is the case + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + bool Music::IsLooping() const { #if NAZARA_AUDIO_SAFE @@ -183,26 +273,61 @@ namespace Nz return m_impl->loop; } + /*! + * \brief Loads the music from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the music + */ + bool Music::OpenFromFile(const String& filePath, const MusicParams& params) { return MusicLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the music from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the music + */ + bool Music::OpenFromMemory(const void* data, std::size_t size, const MusicParams& params) { return MusicLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the music from stream + * \return true if loading is successful + * + * \param stream Stream to the music + * \param params Parameters for the music + */ + bool Music::OpenFromStream(Stream& stream, const MusicParams& params) { return MusicLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Pauses the music + */ + void Music::Pause() { alSourcePause(m_source); } + /*! + * \brief Plays the music + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::Play() { #if NAZARA_AUDIO_SAFE @@ -238,6 +363,14 @@ namespace Nz } } + /*! + * \brief Sets the playing offset for the music + * + * \param offset Offset in the music in milliseconds + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::SetPlayingOffset(UInt32 offset) { #if NAZARA_AUDIO_SAFE @@ -260,6 +393,12 @@ namespace Nz Play(); } + /*! + * \brief Stops the music + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::Stop() { #if NAZARA_AUDIO_SAFE @@ -277,6 +416,13 @@ namespace Nz } } + /*! + * \brief Fills the buffer and queues it up + * \return true if operation was successful + * + * \param buffer Index of the buffer + */ + bool Music::FillAndQueueBuffer(unsigned int buffer) { unsigned int sampleCount = m_impl->chunkSamples.size(); @@ -304,27 +450,31 @@ namespace Nz alSourceQueueBuffers(m_source, 1, &buffer); } - return sampleRead != sampleCount; // Fin du stream (N'arrive pas en cas de loop) + return sampleRead != sampleCount; // End of stream (Does not happen when looping) } + /*! + * \brief Thread function for the music + */ + void Music::MusicThread() { - // Allocation des buffers de streaming + // Allocation of streaming buffers ALuint buffers[NAZARA_AUDIO_STREAMED_BUFFER_COUNT]; alGenBuffers(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, buffers); for (unsigned int i = 0; i < NAZARA_AUDIO_STREAMED_BUFFER_COUNT; ++i) { if (FillAndQueueBuffer(buffers[i])) - break; // Nous avons atteint la fin du stream, inutile de rajouter des buffers + break; // We have reached the end of the stream, there is no use to add new buffers } alSourcePlay(m_source); - // Boucle de lecture (remplissage de nouveaux buffers au fur et à mesure) + // Reading loop (Filling new buffers as playing) while (m_impl->streaming) { - // La lecture s'est arrêtée, nous avons atteint la fin du stream + // The reading has stopped, we have reached the end of the stream SoundStatus status = GetInternalStatus(); if (status == SoundStatus_Stopped) { @@ -334,7 +484,7 @@ namespace Nz Nz::LockGuard lock(m_impl->bufferLock); - // On traite les buffers lus + // We treat read buffers ALint processedCount = 0; alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &processedCount); while (processedCount--) @@ -355,14 +505,14 @@ namespace Nz lock.Unlock(); - // On retourne dormir un peu + // We go back to sleep Thread::Sleep(50); } - // Arrêt de la lecture du son (dans le cas où ça ne serait pas déjà fait) + // Stop playing of the sound (in the case where it has not been already done) alSourceStop(m_source); - // On supprime les buffers du stream + // We delete buffers from the stream ALint queuedBufferCount; alGetSourcei(m_source, AL_BUFFERS_QUEUED, &queuedBufferCount); diff --git a/src/Nazara/Audio/OpenAL.cpp b/src/Nazara/Audio/OpenAL.cpp index f527b682d..489855022 100644 --- a/src/Nazara/Audio/OpenAL.cpp +++ b/src/Nazara/Audio/OpenAL.cpp @@ -23,6 +23,14 @@ namespace Nz ALCcontext* s_context = nullptr; unsigned int s_version; + /*! + * \brief Parses the devices + * \return Number of devices + * + * \param deviceString String for the device (input / output) + * \param devices List of names of the devices + */ + std::size_t ParseDevices(const char* deviceString, std::vector& devices) { if (!deviceString) @@ -41,35 +49,77 @@ namespace Nz } } + /*! + * \ingroup audio + * \class Nz::OpenAL + * \brief Audio class that represents the link with OpenAL + * + * \remark This class is meant to be used by Module Audio + */ + + /*! + * \brief Gets the entry for the function name + * \return Pointer to the function + * + * \param entryPoint Name of the entry + * + * \remark This does not produces a NazaraError if entry does not exist + */ + OpenALFunc OpenAL::GetEntry(const String& entryPoint) { return LoadEntry(entryPoint.GetConstBuffer(), false); } + /*! + * \brief Gets the name of the renderer + * \return Name of the renderer + */ + String OpenAL::GetRendererName() { return s_rendererName; } + /*! + * \brief Gets the name of the vendor + * \return Name of the vendor + */ + String OpenAL::GetVendorName() { return s_vendorName; } + /*! + * \brief Gets the version of OpenAL + * \return Version of OpenAL + */ + unsigned int OpenAL::GetVersion() { return s_version; } + /*! + * \brief Initializes the module OpenAL + * \return true if initialization is successful + * + * \param openDevice True to get information from the device + * + * \remark Produces a NazaraError if one of the entry failed + * \remark Produces a NazaraError if opening device failed with openDevice parameter set to true + */ + bool OpenAL::Initialize(bool openDevice) { - if (s_library.IsLoaded()) + if (IsInitialized()) return true; #if defined(NAZARA_PLATFORM_WINDOWS) - ///FIXME: Est-ce qu'OpenAL Soft est une meilleure implémentation que Creative ? - /// Si on pouvait se résigner à utiliser OpenAL Soft tout le temps, cela nous permettrait d'utiliser les extensions sonores - /// et de donner plus de possibilités techniques au niveau de l'audio. + ///FIXME: Is OpenAL Soft a better implementation than Creative ? + /// If we could use OpenAL Soft everytime, this would allow us to use sonorous extensions + /// and give us more technical possibilities with audio const char* libs[] = { "soft_oal.dll", "wrap_oal.dll", @@ -217,11 +267,23 @@ namespace Nz return true; } + /*! + * \brief Checks whether the module is initialized + * \return true if it is the case + */ + bool OpenAL::IsInitialized() { return s_library.IsLoaded(); } + /*! + * \brief Queries the input devices + * \return Number of devices + * + * \param devices List of names of the input devices + */ + std::size_t OpenAL::QueryInputDevices(std::vector& devices) { const char* deviceString = reinterpret_cast(alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER)); @@ -231,6 +293,13 @@ namespace Nz return ParseDevices(deviceString, devices); } + /*! + * \brief Queries the output devices + * \return Number of devices + * + * \param devices List of names of the output devices + */ + std::size_t OpenAL::QueryOutputDevices(std::vector& devices) { const char* deviceString = reinterpret_cast(alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER)); @@ -240,6 +309,13 @@ namespace Nz return ParseDevices(deviceString, devices); } + /*! + * \brief Sets the active device + * \return true if device is successfully opened + * + * \param deviceName Name of the device + */ + bool OpenAL::SetDevice(const String& deviceName) { s_deviceName = deviceName; @@ -253,6 +329,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the module + */ + void OpenAL::Uninitialize() { CloseDevice(); @@ -262,8 +342,14 @@ namespace Nz s_library.Unload(); } - ///ATTENTION: La valeur entière est le nombre de canaux possédés par ce format - ALenum OpenAL::AudioFormat[AudioFormat_Max+1] = {0}; // Valeur ajoutées au chargement d'OpenAL + ///WARNING: The integer value is the number of canals owned by the format + ALenum OpenAL::AudioFormat[AudioFormat_Max+1] = {0}; // Added values with loading of OpenAL + + /*! + * \brief Closes the device + * + * \remark Produces a NazaraWarning if you try to close an active device + */ void OpenAL::CloseDevice() { @@ -277,24 +363,31 @@ namespace Nz } if (!alcCloseDevice(s_device)) - // Nous n'avons pas pu fermer le device, ce qui signifie qu'il est en cours d'utilisation + // We could not close the close, this means that it's still in use NazaraWarning("Failed to close device"); s_device = nullptr; } } + /*! + * \brief Opens the device + * \return true if open is successful + * + * \remark Produces a NazaraError if it could not create the context + */ + bool OpenAL::OpenDevice() { - // Initialisation du module - s_device = alcOpenDevice(s_deviceName.IsEmpty() ? nullptr : s_deviceName.GetConstBuffer()); // On choisit le device par défaut + // Initialisation of the module + s_device = alcOpenDevice(s_deviceName.IsEmpty() ? nullptr : s_deviceName.GetConstBuffer()); // We choose the default device if (!s_device) { NazaraError("Failed to open default device"); return false; } - // Un seul contexte nous suffira + // One context is enough s_context = alcCreateContext(s_device, nullptr); if (!s_context) { @@ -341,7 +434,7 @@ namespace Nz s_version = 0; } - // On complète le tableau de formats + // We complete the formats table AudioFormat[AudioFormat_Mono] = AL_FORMAT_MONO16; AudioFormat[AudioFormat_Stereo] = AL_FORMAT_STEREO16; @@ -359,6 +452,16 @@ namespace Nz return true; } + /*! + * \brief Loads the entry for the function name + * \return Pointer to the function + * + * \param name Name of the entry + * \param throwException Should throw exception if failed ? + * + * \remark Produces a std::runtime_error if entry does not exist and throwException is set to true + */ + OpenALFunc OpenAL::LoadEntry(const char* name, bool throwException) { OpenALFunc entry = reinterpret_cast(s_library.GetSymbol(name)); diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index 7198a01d6..d2b71318b 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -14,32 +14,76 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::Sound + * \brief Audio class that represents a sound + * + * \remark Module Audio needs to be initialized to use this class + */ + + /*! + * \brief Constructs a Sound object + * + * \param soundBuffer Buffer to read sound from + */ + Sound::Sound(const SoundBuffer* soundBuffer) { SetBuffer(soundBuffer); } + /*! + * \brief Constructs a Sound object which is a copy of another + * + * \param sound Sound to copy + */ + Sound::Sound(const Sound& sound) : SoundEmitter(sound) { SetBuffer(sound.m_buffer); } + /*! + * \brief Destructs the object and calls Stop + * + * \see Stop + */ + Sound::~Sound() { Stop(); } + /*! + * \brief Enables the looping of the music + * + * \param loop Should sound loop + */ + void Sound::EnableLooping(bool loop) { alSourcei(m_source, AL_LOOPING, loop); } + /*! + * \brief Gets the internal buffer + * \return Internal buffer + */ + const SoundBuffer* Sound::GetBuffer() const { return m_buffer; } + /*! + * \brief Gets the duration of the sound + * \return Duration of the music in milliseconds + * + * \remark Produces a NazaraError if there is no buffer + */ + UInt32 Sound::GetDuration() const { NazaraAssert(m_buffer, "Invalid sound buffer"); @@ -47,6 +91,11 @@ namespace Nz return m_buffer->GetDuration(); } + /*! + * \brief Gets the current offset in the sound + * \return Offset in milliseconds (works with entire seconds) + */ + UInt32 Sound::GetPlayingOffset() const { ALint samples = 0; @@ -55,11 +104,21 @@ namespace Nz return static_cast(1000ULL * samples / m_buffer->GetSampleRate()); } + /*! + * \brief Gets the status of the music + * \return Enumeration of type SoundStatus (Playing, Stopped, ...) + */ + SoundStatus Sound::GetStatus() const { return GetInternalStatus(); } + /*! + * \brief Checks whether the sound is looping + * \return true if it is the case + */ + bool Sound::IsLooping() const { ALint loop; @@ -68,16 +127,36 @@ namespace Nz return loop != AL_FALSE; } + /*! + * \brief Checks whether the sound is playable + * \return true if it is the case + */ + bool Sound::IsPlayable() const { return m_buffer != nullptr; } + /*! + * \brief Checks whether the sound is playing + * \return true if it is the case + */ + bool Sound::IsPlaying() const { return GetStatus() == SoundStatus_Playing; } + /*! + * \brief Loads the sound from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the sound + * + * \remark Produces a NazaraError if loading failed + */ + bool Sound::LoadFromFile(const String& filePath, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -91,6 +170,17 @@ namespace Nz return true; } + /*! + * \brief Loads the sound from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the sound + * + * \remark Produces a NazaraError if loading failed + */ + bool Sound::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -104,6 +194,16 @@ namespace Nz return true; } + /*! + * \brief Loads the sound from stream + * \return true if loading is successful + * + * \param stream Stream to the sound + * \param params Parameters for the sound + * + * \remark Produces a NazaraError if loading failed + */ + bool Sound::LoadFromStream(Stream& stream, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -117,15 +217,25 @@ namespace Nz return true; } + /*! + * \brief Pauses the sound + */ + void Sound::Pause() { alSourcePause(m_source); } + /*! + * \brief Plays the music + * + * \remark Produces a NazaraError if the sound is not playable with NAZARA_AUDIO_SAFE defined + */ + void Sound::Play() { #if NAZARA_AUDIO_SAFE - if (!m_buffer) + if (!IsPlayable()) { NazaraError("Invalid sound buffer"); return; @@ -135,6 +245,14 @@ namespace Nz alSourcePlay(m_source); } + /*! + * \brief Sets the internal buffer + * + * \param buffer Internal buffer + * + * \remark Produces a NazaraError if buffer is invalid with NAZARA_AUDIO_SAFE defined + */ + void Sound::SetBuffer(const SoundBuffer* buffer) { #if NAZARA_AUDIO_SAFE @@ -158,11 +276,21 @@ namespace Nz alSourcei(m_source, AL_BUFFER, AL_NONE); } + /*! + * \brief Sets the playing offset for the sound + * + * \param offset Offset in the sound in milliseconds + */ + void Sound::SetPlayingOffset(UInt32 offset) { alSourcei(m_source, AL_SAMPLE_OFFSET, static_cast(offset/1000.f * m_buffer->GetSampleRate())); } + /*! + * \brief Stops the sound + */ + void Sound::Stop() { alSourceStop(m_source); diff --git a/src/Nazara/Audio/SoundBuffer.cpp b/src/Nazara/Audio/SoundBuffer.cpp index c01878383..b59e74e23 100644 --- a/src/Nazara/Audio/SoundBuffer.cpp +++ b/src/Nazara/Audio/SoundBuffer.cpp @@ -12,10 +12,23 @@ #include #include -///FIXME: Adapter la création +///FIXME: Adapt the creation namespace Nz { + /*! + * \ingroup audio + * \class Nz::SoundBuffer + * \brief Audio class that represents a buffer for sound + * + * \remark Module Audio needs to be initialized to use this class + */ + + /*! + * \brief Checks whether the parameters for the buffer' sound are correct + * \return true If parameters are valid + */ + bool SoundBufferParams::IsValid() const { return true; @@ -31,6 +44,20 @@ namespace Nz UInt32 sampleRate; }; + /*! + * \brief Constructs a SoundBuffer object + * + * \param format Format for the audio + * \param sampleCount Number of samples + * \param sampleRate Rate of samples + * \param samples Samples raw data + * + * \remark Produces a NazaraError if creation went wrong with NAZARA_AUDIO_SAFE defined + * \remark Produces a std::runtime_error if creation went wrong with NAZARA_AUDIO_SAFE defined + * + * \see Create + */ + SoundBuffer::SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) { Create(format, sampleCount, sampleRate, samples); @@ -44,6 +71,12 @@ namespace Nz #endif } + /*! + * \brief Destructs the object and calls Destroy + * + * \see Destroy + */ + SoundBuffer::~SoundBuffer() { OnSoundBufferRelease(this); @@ -51,6 +84,19 @@ namespace Nz Destroy(); } + /*! + * \brief Creates the SoundBuffer object + * \return true if creation is successful + * + * \param format Format for the audio + * \param sampleCount Number of samples + * \param sampleRate Rate of samples + * \param samples Samples raw data + * + * \remark Produces a NazaraError if creation went wrong with NAZARA_AUDIO_SAFE defined, + * this could happen if parameters are invalid or creation of OpenAL buffers failed + */ + bool SoundBuffer::Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) { Destroy(); @@ -81,7 +127,7 @@ namespace Nz } #endif - // On vide le stack d'erreurs + // We empty the error stack while (alGetError() != AL_NO_ERROR); ALuint buffer; @@ -115,6 +161,10 @@ namespace Nz return true; } + /*! + * \brief Destroys the current sound buffer and frees resources + */ + void SoundBuffer::Destroy() { if (m_impl) @@ -126,6 +176,13 @@ namespace Nz } } + /*! + * \brief Gets the duration of the sound buffer + * \return Duration of the sound buffer in milliseconds + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + UInt32 SoundBuffer::GetDuration() const { #if NAZARA_AUDIO_SAFE @@ -139,6 +196,13 @@ namespace Nz return m_impl->duration; } + /*! + * \brief Gets the format of the sound buffer + * \return Enumeration of type AudioFormat (mono, stereo, ...) + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + AudioFormat SoundBuffer::GetFormat() const { #if NAZARA_AUDIO_SAFE @@ -152,6 +216,13 @@ namespace Nz return m_impl->format; } + /*! + * \brief Gets the internal raw samples + * \return Pointer to raw data + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + const Int16* SoundBuffer::GetSamples() const { #if NAZARA_AUDIO_SAFE @@ -165,6 +236,13 @@ namespace Nz return m_impl->samples.get(); } + /*! + * \brief Gets the number of samples in the sound buffer + * \return Count of samples (number of seconds * sample rate * channel count) + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + unsigned int SoundBuffer::GetSampleCount() const { #if NAZARA_AUDIO_SAFE @@ -178,6 +256,13 @@ namespace Nz return m_impl->sampleCount; } + /*! + * \brief Gets the rates of sample in the sound buffer + * \return Rate of sample in Hertz (Hz) + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + unsigned int SoundBuffer::GetSampleRate() const { #if NAZARA_AUDIO_SAFE @@ -191,31 +276,75 @@ namespace Nz return m_impl->sampleRate; } + /*! + * \brief Checks whether the sound buffer is valid + * \return true if it is the case + */ + bool SoundBuffer::IsValid() const { return m_impl != nullptr; } + /*! + * \brief Loads the sound buffer from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the sound buffer + */ + bool SoundBuffer::LoadFromFile(const String& filePath, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the sound buffer from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the sound buffer + */ + bool SoundBuffer::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the sound buffer from stream + * \return true if loading is successful + * + * \param stream Stream to the sound buffer + * \param params Parameters for the sound buffer + */ + bool SoundBuffer::LoadFromStream(Stream& stream, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Checks whether the format is supported by the engine + * \return true if it is the case + * + * \param format Format to check + */ + bool SoundBuffer::IsFormatSupported(AudioFormat format) { return Audio::IsFormatSupported(format); } + /*! + * \brief Gets the internal OpenAL buffer + * \return The index of the OpenAL buffer + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + unsigned int SoundBuffer::GetOpenALBuffer() const { #ifdef NAZARA_DEBUG @@ -229,6 +358,13 @@ namespace Nz return m_impl->buffer; } + /*! + * \brief Initializes the libraries and managers + * \return true if initialization is successful + * + * \remark Produces a NazaraError if sub-initialization failed + */ + bool SoundBuffer::Initialize() { if (!SoundBufferLibrary::Initialize()) @@ -246,6 +382,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the libraries and managers + */ + void SoundBuffer::Uninitialize() { SoundBufferManager::Uninitialize(); diff --git a/src/Nazara/Audio/SoundEmitter.cpp b/src/Nazara/Audio/SoundEmitter.cpp index cbee8a8f9..840c4f47d 100644 --- a/src/Nazara/Audio/SoundEmitter.cpp +++ b/src/Nazara/Audio/SoundEmitter.cpp @@ -11,11 +11,32 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::SoundEmitter + * \brief Audio class that represents a sound source, that emits sound + * + * \remark Module Audio needs to be initialized to use this class + * \remark This class is abstract + */ + + /*! + * \brief Constructs a SoundEmitter object + */ + SoundEmitter::SoundEmitter() { alGenSources(1, &m_source); } + /*! + * \brief Constructs a SoundEmitter object which is a copy of another + * + * \param emitter SoundEmitter to copy + * + * \remark Position and velocity are not copied + */ + SoundEmitter::SoundEmitter(const SoundEmitter& emitter) { alGenSources(1, &m_source); @@ -23,20 +44,35 @@ namespace Nz SetAttenuation(emitter.GetAttenuation()); SetMinDistance(emitter.GetMinDistance()); SetPitch(emitter.GetPitch()); - // Pas de copie de position ou de vitesse + // No copy for position or velocity SetVolume(emitter.GetVolume()); } + /*! + * \brief Destructs the object + */ + SoundEmitter::~SoundEmitter() { alDeleteSources(1, &m_source); } + /*! + * \brief Enables spatialization + * + * \param spatialization True if spatialization is enabled + */ + void SoundEmitter::EnableSpatialization(bool spatialization) { alSourcei(m_source, AL_SOURCE_RELATIVE, !spatialization); } + /*! + * \brief Gets the attenuation + * \return Amount that your sound will drop off as by the inverse square law + */ + float SoundEmitter::GetAttenuation() const { ALfloat attenuation; @@ -45,6 +81,11 @@ namespace Nz return attenuation; } + /*! + * \brief Gets the minimum distance to hear + * \return Distance to begin to hear + */ + float SoundEmitter::GetMinDistance() const { ALfloat distance; @@ -53,6 +94,11 @@ namespace Nz return distance; } + /*! + * \brief Gets the pitch + * \return Pitch of the sound + */ + float SoundEmitter::GetPitch() const { ALfloat pitch; @@ -61,6 +107,11 @@ namespace Nz return pitch; } + /*! + * \brief Gets the position of the emitter + * \return Position of the sound + */ + Vector3f SoundEmitter::GetPosition() const { Vector3f position; @@ -69,6 +120,11 @@ namespace Nz return position; } + /*! + * \brief Gets the velocity of the emitter + * \return Velocity of the sound + */ + Vector3f SoundEmitter::GetVelocity() const { Vector3f velocity; @@ -77,6 +133,11 @@ namespace Nz return velocity; } + /*! + * \brief Gets the volume of the emitter + * \param volume Float between [0, inf) with 100.f being the default + */ + float SoundEmitter::GetVolume() const { ALfloat gain; @@ -85,6 +146,11 @@ namespace Nz return gain * 100.f; } + /*! + * \brief Checks whether the sound emitter has spatialization enabled + * \return true if it the case + */ + bool SoundEmitter::IsSpatialized() const { ALint relative; @@ -93,46 +159,99 @@ namespace Nz return relative == AL_FALSE; } + /*! + * \brief Sets the attenuation + * + * \param attenuation Amount that your sound will drop off as by the inverse square law + */ + void SoundEmitter::SetAttenuation(float attenuation) { alSourcef(m_source, AL_ROLLOFF_FACTOR, attenuation); } + /*! + * \brief Sets the minimum distance to hear + * + * \param minDistance to begin to hear + */ + void SoundEmitter::SetMinDistance(float minDistance) { alSourcef(m_source, AL_REFERENCE_DISTANCE, minDistance); } + /*! + * \brief Sets the pitch + * + * \param pitch of the sound + */ + void SoundEmitter::SetPitch(float pitch) { alSourcef(m_source, AL_PITCH, pitch); } + /*! + * \brief Sets the position of the emitter + * + * \param position Position of the sound + */ + void SoundEmitter::SetPosition(const Vector3f& position) { alSourcefv(m_source, AL_POSITION, position); } + /*! + * \brief Sets the position of the emitter + * + * \param position Position of the sound with (x, y, z) + */ + void SoundEmitter::SetPosition(float x, float y, float z) { alSource3f(m_source, AL_POSITION, x, y, z); } + /*! + * \brief Sets the velocity of the emitter + * + * \param velocity Velocity of the sound + */ + void SoundEmitter::SetVelocity(const Vector3f& velocity) { alSourcefv(m_source, AL_VELOCITY, velocity); } + /*! + * \brief Sets the velocity of the emitter + * + * \param velocity Velocity with (velX, velY, velZ) + */ + void SoundEmitter::SetVelocity(float velX, float velY, float velZ) { alSource3f(m_source, AL_VELOCITY, velX, velY, velZ); } + /*! + * \brief Sets the volume of the emitter + * + * \param volume Float between [0, inf) with 100.f being the default + */ + void SoundEmitter::SetVolume(float volume) { - alSourcef(m_source, AL_GAIN, volume*0.01f); + alSourcef(m_source, AL_GAIN, volume * 0.01f); } + /*! + * \brief Gets the status of the sound emitter + * \return Enumeration of type SoundStatus (Playing, Stopped, ...) + */ + SoundStatus SoundEmitter::GetInternalStatus() const { ALint state; diff --git a/src/Nazara/Audio/SoundStream.cpp b/src/Nazara/Audio/SoundStream.cpp index c243e875f..88bc0069b 100644 --- a/src/Nazara/Audio/SoundStream.cpp +++ b/src/Nazara/Audio/SoundStream.cpp @@ -6,5 +6,13 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::SoundStream + * \brief Audio class that represents a sound stream + * + * \remark This class is abstract + */ + SoundStream::~SoundStream() = default; } diff --git a/tests/Engine/Audio/AlgorithmAudio.cpp b/tests/Engine/Audio/AlgorithmAudio.cpp new file mode 100644 index 000000000..dfcfeee56 --- /dev/null +++ b/tests/Engine/Audio/AlgorithmAudio.cpp @@ -0,0 +1,19 @@ +#include +#include + +#include + +TEST_CASE("MixToMono", "[AUDIO][ALGORITHM]") +{ + SECTION("Mix two channels together") + { + std::array input{ 1, 3, 5, 3 }; + std::array output{ 0, 0 }; + + // Two channels and two frames ! + Nz::MixToMono(input.data(), output.data(), 2, 2); + + std::array theoric{ 2, 4 }; // It's the mean of the two channels + REQUIRE(output == theoric); + } +} diff --git a/tests/Engine/Audio/Music.cpp b/tests/Engine/Audio/Music.cpp new file mode 100644 index 000000000..404c57c5f --- /dev/null +++ b/tests/Engine/Audio/Music.cpp @@ -0,0 +1,49 @@ +#include +#include + +#include +#include + +SCENARIO("Music", "[AUDIO][MUSIC]") +{ + GIVEN("A music") + { + Nz::Music music; + + WHEN("We load our music") + { + REQUIRE(music.OpenFromFile("resources/Engine/Audio/The_Brabanconne.ogg")); + + THEN("We can ask the informations of the file") + { + REQUIRE(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms + REQUIRE(music.GetDuration() >= 63000); + REQUIRE(music.GetFormat() == Nz::AudioFormat_Stereo); + REQUIRE(music.GetPlayingOffset() == 0); + REQUIRE(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo) + REQUIRE(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo) + REQUIRE(music.GetSampleRate() == 44100 /* Hz */); + REQUIRE(music.GetStatus() == Nz::SoundStatus_Stopped); + REQUIRE(music.IsLooping() == false); + } + + THEN("We can play it and get the time offset") + { + Nz::Audio::SetGlobalVolume(0.f); + + music.Play(); + Nz::Thread::Sleep(1000); + REQUIRE(music.GetPlayingOffset() >= 950); + Nz::Thread::Sleep(200); + REQUIRE(music.GetPlayingOffset() <= 1300); + music.Pause(); + REQUIRE(music.GetStatus() == Nz::SoundStatus_Paused); + + music.SetPlayingOffset(3500); + REQUIRE(music.GetPlayingOffset() >= 3500); + + Nz::Audio::SetGlobalVolume(100.f); + } + } + } +} diff --git a/tests/Engine/Audio/Sound.cpp b/tests/Engine/Audio/Sound.cpp new file mode 100644 index 000000000..684138ccd --- /dev/null +++ b/tests/Engine/Audio/Sound.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include +#include + +SCENARIO("Sound", "[AUDIO][SOUND]") +{ + GIVEN("A sound") + { + Nz::Sound sound; + + WHEN("We load our sound") + { + REQUIRE(sound.LoadFromFile("resources/Engine/Audio/Cat.flac")); + + THEN("We can ask the informations of the file") + { + REQUIRE(sound.GetDuration() <= 8500); // 8s = 8000ms + REQUIRE(sound.GetDuration() >= 8000); + REQUIRE(sound.GetStatus() == Nz::SoundStatus_Stopped); + REQUIRE(sound.IsLooping() == false); + } + + THEN("We can play it and get the time offset") + { + Nz::Audio::SetGlobalVolume(0.f); + + sound.Play(); + Nz::Thread::Sleep(1000); + REQUIRE(sound.GetPlayingOffset() >= 950); + Nz::Thread::Sleep(200); + REQUIRE(sound.GetPlayingOffset() <= 1300); + sound.Pause(); + REQUIRE(sound.GetStatus() == Nz::SoundStatus_Paused); + + sound.SetPlayingOffset(3500); + REQUIRE(sound.GetPlayingOffset() >= 3500); + + Nz::Audio::SetGlobalVolume(100.f); + } + } + } +} diff --git a/tests/Engine/Audio/SoundBuffer.cpp b/tests/Engine/Audio/SoundBuffer.cpp new file mode 100644 index 000000000..ed5f2f6c6 --- /dev/null +++ b/tests/Engine/Audio/SoundBuffer.cpp @@ -0,0 +1,21 @@ +#include +#include + +SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]") +{ + GIVEN("A sound buffer") + { + Nz::SoundBuffer soundBuffer; + + WHEN("We load our sound") + { + REQUIRE(soundBuffer.LoadFromFile("resources/Engine/Audio/Cat.flac")); + + THEN("We can ask the informations of the file") + { + REQUIRE(soundBuffer.GetDuration() <= 8500); // 8s = 8000ms + REQUIRE(soundBuffer.GetDuration() >= 8000); + } + } + } +} diff --git a/tests/Engine/Audio/SoundEmitter.cpp b/tests/Engine/Audio/SoundEmitter.cpp new file mode 100644 index 000000000..baac41eb3 --- /dev/null +++ b/tests/Engine/Audio/SoundEmitter.cpp @@ -0,0 +1,41 @@ +#include +#include + +#include + +SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]") +{ + GIVEN("A sound emitter") + { + Nz::Sound sound; + + WHEN("We load our sound") + { + REQUIRE(sound.LoadFromFile("resources/Engine/Audio/Cat.flac")); + + THEN("We can ask information about position and velocity") + { + sound.EnableSpatialization(true); + sound.SetPosition(Nz::Vector3f::Zero()); + sound.SetVelocity(Nz::Vector3f::UnitX()); + + REQUIRE(sound.IsSpatialized()); + REQUIRE(sound.GetPosition() == Nz::Vector3f::Zero()); + REQUIRE(sound.GetVelocity() == Nz::Vector3f::UnitX()); + } + + THEN("We can ask information about attenuation, pitch, ...") + { + sound.SetAttenuation(0.4f); + sound.SetMinDistance(40.f); + sound.SetPitch(0.8f); + sound.SetVolume(50.f); + + REQUIRE(Approx(sound.GetAttenuation()) == 0.4f); + REQUIRE(Approx(sound.GetMinDistance()) == 40.f); + REQUIRE(Approx(sound.GetPitch()) == 0.8f); + REQUIRE(Approx(sound.GetVolume()) == 50.f); + } + } + } +} diff --git a/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id b/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id new file mode 100644 index 000000000..a686bc57d --- /dev/null +++ b/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id @@ -0,0 +1 @@ +6993cbcca9ac596667135cb0f30bea4841178d3b \ No newline at end of file diff --git a/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id b/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id new file mode 100644 index 000000000..bfd8dbd70 --- /dev/null +++ b/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id @@ -0,0 +1 @@ +94b2c47c9143adbac0fb7e81df5cc87f969f7150 \ No newline at end of file diff --git a/tests/resources/Engine/Audio/copyrights.txt b/tests/resources/Engine/Audio/copyrights.txt new file mode 100644 index 000000000..7b01b7090 --- /dev/null +++ b/tests/resources/Engine/Audio/copyrights.txt @@ -0,0 +1,54 @@ +The_Brabanconne.ogg + +https://en.wikipedia.org/wiki/File:The_Brabanconne.ogg + +Original file: +The_Brabanconne.ogg ‎(Ogg Vorbis sound file, length 1 min 3 s, 378 kbps) + +Summary: + +Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3. +Date: 19 October 2004 +Source: http://www.navyband.navy.mil/anthems/national_anthems.htm +Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald + +Licencing: + +This file is a work of a sailor or employee of the U.S. Navy, taken or made as part of that person's official duties. As a work of the U.S. federal government, the image is in the public domain. +This file has been identified as being free of known restrictions under copyright law, including all related and neighboring rights. + +------------------------------------------------------------------------------------------------- + +Cat.flac: + +http://www.freesound.org/people/EARR/sounds/148013/ + +Original file: +148013__earr__angry-cat.flac (Flac sound file, length 8 s, 96000 Hz, 24 bit depth) + +Author: + +EARR + +Description: + +Slightly angry cat. She is a beautiful Siamese cat called Agostina. She is angry for the recording because i pressed his tail. + +Information about the recording and equipment: + +-Location: Living room. +-Type of acoustic environment: Small, diffuse, moderately reflective. +-Distance from sound source to microphones: Approx a few centimeters. +-Miking technique: Jecklin disk. + +-Microphones: 2 Brüel & Kjaer type 4190 capsules with type 2669L head amplifier. +-Microphone preamps: Modified Brüel & Kjaer type 5935L. +-ADC: Echo Audiofire 4. (line inputs 3 & 4). +-Recorder: Echo Audiofire 4 and Dell D630C running Samplitude 10. + +Eq: Compensation only for the response of the microphones (In this case for flat response at 60º. See Brüel & Kjaer type 4190 datasheet). +No reverb, no compression, no fx. + +Licencing: + +Creative commons From b2b2fe2bfe36f4c2aabfe42e32b251365f034d4f Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 13:50:52 +0200 Subject: [PATCH 009/235] Examples: Add empty project for testing purposes Former-commit-id: ae4bae0da88273f1fc6be0c2156a21025b1e1c8d --- examples/Tut00/build.lua | 20 ++++++++++++++++++++ examples/Tut00/main.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 examples/Tut00/build.lua create mode 100644 examples/Tut00/main.cpp diff --git a/examples/Tut00/build.lua b/examples/Tut00/build.lua new file mode 100644 index 000000000..d0c499df6 --- /dev/null +++ b/examples/Tut00/build.lua @@ -0,0 +1,20 @@ +EXAMPLE.Name = "Tut00_EmptyProject" + +EXAMPLE.Console = true + +EXAMPLE.Files = { + "main.cpp" +} + +EXAMPLE.Libraries = { + "NazaraAudio", + "NazaraCore", + "NazaraGraphics", + "NazaraLua", + "NazaraNetwork", + "NazaraNoise", + "NazaraPhysics", + "NazaraRenderer", + "NazaraUtility", + "NazaraSDK" +} diff --git a/examples/Tut00/main.cpp b/examples/Tut00/main.cpp new file mode 100644 index 000000000..472db3148 --- /dev/null +++ b/examples/Tut00/main.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + // This "example" has only one purpose: Giving an empty project for you to test whatever you want + // If you wish to have multiple test projects, you only have to copy/paste this directory and change the name in the build.lua + Ndk::Application app; + + // Do what you want here + + return EXIT_SUCCESS; +} \ No newline at end of file From d03b0d759d10bae18c8893638ff5a5e3db3d5c61 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 13:52:08 +0200 Subject: [PATCH 010/235] Build: Fix default platform on 32bits os Former-commit-id: 4d6c477bfb8516ec6665c92adf1cba6be1d5eed2 --- build/scripts/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 15bf69849..822067ea2 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -9,7 +9,7 @@ function NazaraBuild:Execute() if (os.is64bit()) then platformData = {"x64", "x86"} else - platformData = {"x64", "x86"} + platformData = {"x86", "x64"} end if (self.Actions[_ACTION] == nil) then From 6b1cfca761855cef59f4cdfba0fc185d20c4d406 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:09:51 +0200 Subject: [PATCH 012/235] Fix documentation for module: Core Former-commit-id: da32124ed87931c0b574bcad2b1ab44825e756bc --- include/Nazara/Core/Algorithm.inl | 2 +- include/Nazara/Core/ConfigCheck.hpp | 2 +- include/Nazara/Core/HandledObject.inl | 67 ++++++- include/Nazara/Core/ObjectHandle.inl | 265 +++++++++++++++++++++++-- include/Nazara/Core/ParameterList.hpp | 6 +- include/Nazara/Core/ResourceLoader.inl | 2 +- src/Nazara/Core/Core.cpp | 2 +- src/Nazara/Core/File.cpp | 6 +- src/Nazara/Core/ParameterList.cpp | 62 ++++++ tests/Engine/Core/ByteArray.cpp | 20 ++ tests/Engine/Core/File.cpp | 12 +- 11 files changed, 421 insertions(+), 25 deletions(-) diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 048fae8e9..6997f8d1e 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -78,7 +78,7 @@ namespace Nz * \param v Object to hash * * \remark a HashAppend specialization for type T is required - * + * * \see ComputeHash */ template diff --git a/include/Nazara/Core/ConfigCheck.hpp b/include/Nazara/Core/ConfigCheck.hpp index 8329f4ff0..aa1ac5cfa 100644 --- a/include/Nazara/Core/ConfigCheck.hpp +++ b/include/Nazara/Core/ConfigCheck.hpp @@ -12,7 +12,7 @@ #include #define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) -// We fore the value of MANAGE_MEMORY in debug +// We force the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_CORE_MANAGE_MEMORY #undef NAZARA_CORE_MANAGE_MEMORY #define NAZARA_CORE_MANAGE_MEMORY 0 diff --git a/include/Nazara/Core/HandledObject.inl b/include/Nazara/Core/HandledObject.inl index da435302e..6b4d64c45 100644 --- a/include/Nazara/Core/HandledObject.inl +++ b/include/Nazara/Core/HandledObject.inl @@ -10,6 +10,17 @@ namespace Nz { + /*! + * \ingroup core + * \class Nz::HandledObject + * \brief Core class that represents a handled object + */ + + /*! + * \brief Constructs a HandledObject object by assignation + * + * \param object HandledObject to assign into this + */ template HandledObject::HandledObject(const HandledObject& object) { @@ -17,6 +28,11 @@ namespace Nz // Don't copy anything, we're a copy of the object, we have no handle right now } + /*! + * \brief Constructs a HandledObject object by move semantic + * + * \param object HandledObject to move into this + */ template HandledObject::HandledObject(HandledObject&& object) : m_handles(std::move(object.m_handles)) @@ -25,25 +41,46 @@ namespace Nz handle->OnObjectMoved(static_cast(this)); } + /*! + * \brief Destructs the object and calls UnregisterAllHandles + * + * \see UnregisterAllHandles + */ template HandledObject::~HandledObject() { UnregisterAllHandles(); } + /*! + * \brief Creates a ObjectHandle for this + * \return ObjectHandle to this + */ template ObjectHandle HandledObject::CreateHandle() { return ObjectHandle(static_cast(this)); } + /*! + * \brief Sets the reference of the HandledObject with the handle from another + * \return A reference to this + * + * \param object The other HandledObject + */ template HandledObject& HandledObject::operator=(const HandledObject& object) { // Nothing to do - return *this; + return *this; } + /*! + * \brief Moves the HandledObject into this + * \return A reference to this + * + * \param object HandledObject to move in this + */ template HandledObject& HandledObject::operator=(HandledObject&& object) { @@ -54,13 +91,22 @@ namespace Nz return *this; } + /*! + * \brief Registers a handle + * + * \param handle Handle to register + * + * \remark One handle can only be registered once, errors can occur if it's more than once + */ template void HandledObject::RegisterHandle(ObjectHandle* handle) { - ///DOC: Un handle ne doit être enregistré qu'une fois, des erreurs se produisent s'il l'est plus d'une fois m_handles.push_back(handle); } + /*! + * \brief Unregisters all handles + */ template void HandledObject::UnregisterAllHandles() { @@ -71,10 +117,17 @@ namespace Nz m_handles.clear(); } + /*! + * \brief Unregisters a handle + * + * \param handle Handle to unregister + * + * \remark One handle can only be unregistered once, crash can occur if it's more than once + * \remark Produces a NazaraAssert if handle not registered + */ template void HandledObject::UnregisterHandle(ObjectHandle* handle) noexcept { - ///DOC: Un handle ne doit être libéré qu'une fois, et doit faire partie de la liste, sous peine de crash auto it = std::find(m_handles.begin(), m_handles.end(), handle); NazaraAssert(it != m_handles.end(), "Handle not registered"); @@ -83,6 +136,14 @@ namespace Nz m_handles.pop_back(); } + /*! + * \brief Updates one handle with another + * + * \param oldHandle Old handle to replace + * \param newHandle New handle to take place + * + * \remark Produces a NazaraAssert if handle not registered + */ template void HandledObject::UpdateHandle(ObjectHandle* oldHandle, ObjectHandle* newHandle) noexcept { diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index cfcd6bc0d..ee6e26268 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -9,12 +9,26 @@ namespace Nz { + /*! + * \ingroup core + * \class Nz::ObjectHandle + * \brief Core class that represents a object handle + */ + + /*! + * \brief Constructs a ObjectHandle object by default + */ template ObjectHandle::ObjectHandle() : m_object(nullptr) { } + /*! + * \brief Constructs a ObjectHandle object with a pointer to an object + * + * \param object Pointer to handle like an object (can be nullptr) + */ template ObjectHandle::ObjectHandle(T* object) : ObjectHandle() @@ -22,59 +36,97 @@ namespace Nz Reset(object); } + /*! + * \brief Constructs a ObjectHandle object by assignation + * + * \param handle ObjectHandle to assign into this + */ template - ObjectHandle::ObjectHandle(const ObjectHandle& handle) : + ObjectHandle::ObjectHandle(const ObjectHandle& handle) : ObjectHandle() { Reset(handle); } + /*! + * \brief Constructs a ObjectHandle object by move semantic + * + * \param handle ObjectHandle to move into this + */ template - ObjectHandle::ObjectHandle(ObjectHandle&& handle) noexcept : + ObjectHandle::ObjectHandle(ObjectHandle&& handle) noexcept : ObjectHandle() { Reset(std::move(handle)); } + /*! + * \brief Destructs the object and calls reset with nullptr + * + * \see Reset + */ template ObjectHandle::~ObjectHandle() { Reset(nullptr); } + /*! + * \brief Gets the underlying object + * \return Underlying object + */ template T* ObjectHandle::GetObject() const { return m_object; } + /*! + * \brief Checks whether the object is valid + * \return true if object is not nullptr + */ template bool ObjectHandle::IsValid() const { return m_object != nullptr; } + /*! + * \brief Resets the content of the ObjectHandle with another object + * + * \param object Object to handle + */ template void ObjectHandle::Reset(T* object) { - // Si nous avions déjà une entité, nous devons l'informer que nous ne pointons plus sur elle + // If we already have an entity, we must alert it that we are not pointing to it anymore if (m_object) m_object->UnregisterHandle(this); m_object = object; if (m_object) - // On informe la nouvelle entité que nous pointons sur elle + // We alert the new entity that we are pointing to it m_object->RegisterHandle(this); } + /*! + * \brief Resets the content of this with another object + * + * \param handle New object to handle + */ template - void ObjectHandle::Reset(const ObjectHandle& handle) + void ObjectHandle::Reset(const ObjectHandle& handle) { Reset(handle.GetObject()); } + /*! + * \brief Resets the content of this with another object by move semantic + * + * \param handle New object to handle to move into this + */ template - void ObjectHandle::Reset(ObjectHandle&& handle) noexcept + void ObjectHandle::Reset(ObjectHandle&& handle) noexcept { if (m_object) m_object->UnregisterHandle(this); @@ -87,12 +139,18 @@ namespace Nz } } + /*! + * \brief Swaps the content of the two ObjectHandle + * \return A reference to this + * + * \param handle ObjectHandle to swap + */ template - ObjectHandle& ObjectHandle::Swap(ObjectHandle& handle) + ObjectHandle& ObjectHandle::Swap(ObjectHandle& handle) { - // Comme nous inversons les handles, nous devons prévenir les entités - // La version par défaut de swap (à base de move) aurait fonctionné, - // mais en enregistrant les handles une fois de plus que nécessaire (à cause de la copie temporaire). + // As we swap the two handles, we must alert the entities + // The default version with swap (move) would be working, + // but will register handles one more time (due to temporary copy). if (m_object) { m_object->UnregisterHandle(this); @@ -105,11 +163,15 @@ namespace Nz handle.m_object->RegisterHandle(this); } - // On effectue l'échange + // We do the swap std::swap(m_object, handle.m_object); return *this; } + /*! + * \brief Gives a string representation + * \return A string representation of the object "ObjectHandle(object representation) or Null" + */ template Nz::String ObjectHandle::ToString() const { @@ -125,24 +187,44 @@ namespace Nz return ss; } + /*! + * \brief Converts the ObjectHandle to bool + * \return true if reference is not nullptr + * + * \see IsValid + */ template ObjectHandle::operator bool() const { return IsValid(); } + /*! + * \brief Dereferences the ObjectHandle + * \return Underlying pointer + */ template ObjectHandle::operator T*() const { return m_object; } + /*! + * \brief Dereferences the ObjectHandle + * \return Underlying pointer + */ template T* ObjectHandle::operator->() const { return m_object; } + /*! + * \brief Assigns the entity into this + * \return A reference to this + * + * \param entity Pointer to handle like an object (can be nullptr) + */ template ObjectHandle& ObjectHandle::operator=(T* entity) { @@ -151,22 +233,37 @@ namespace Nz return *this; } + /*! + * \brief Sets the handle of the ObjectHandle with the handle from another + * \return A reference to this + * + * \param handle The other ObjectHandle + */ template - ObjectHandle& ObjectHandle::operator=(const ObjectHandle& handle) + ObjectHandle& ObjectHandle::operator=(const ObjectHandle& handle) { Reset(handle); return *this; } + /*! + * \brief Moves the ObjectHandle into this + * \return A reference to this + * + * \param handle ObjectHandle to move in this + */ template - ObjectHandle& ObjectHandle::operator=(ObjectHandle&& handle) noexcept + ObjectHandle& ObjectHandle::operator=(ObjectHandle&& handle) noexcept { Reset(std::move(handle)); return *this; } + /*! + * \brief Action to do on object destruction + */ template void ObjectHandle::OnObjectDestroyed() { @@ -174,6 +271,9 @@ namespace Nz m_object = nullptr; } + /*! + * \brief Action to do on object move + */ template void ObjectHandle::OnObjectMoved(T* newObject) { @@ -181,114 +281,247 @@ namespace Nz m_object = newObject; } + /*! + * \brief Output operator + * \return The stream + * + * \param out The stream + * \param handle The ObjectHandle to output + */ template std::ostream& operator<<(std::ostream& out, const ObjectHandle& handle) { return handle.ToString(); } + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator==(const ObjectHandle& lhs, const ObjectHandle& rhs) { return lhs.GetObject() == rhs.GetObject(); } + /*! + * \brief Checks whether the object is equal to the second object handle + * \return true if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator==(const T& lhs, const ObjectHandle& rhs) { return &lhs == rhs.GetObject(); } + /*! + * \brief Checks whether the object handle is equal to the second object + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second Object to compare in right hand side + */ template bool operator==(const ObjectHandle& lhs, const T& rhs) { return lhs.GetObject() == &rhs; } + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return false if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator!=(const ObjectHandle& lhs, const ObjectHandle& rhs) { return !(lhs == rhs); } + /*! + * \brief Checks whether the object is equal to the second object handle + * \return false if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator!=(const T& lhs, const ObjectHandle& rhs) { return !(lhs == rhs); } + /*! + * \brief Checks whether the object handle is equal to the second object + * \return false if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second Object to compare in right hand side + */ template bool operator!=(const ObjectHandle& lhs, const T& rhs) { return !(lhs == rhs); } + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<(const ObjectHandle& lhs, const ObjectHandle& rhs) { return lhs.m_object < rhs.m_object; } + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<(const T& lhs, const ObjectHandle& rhs) { return &lhs < rhs.m_object; } + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<(const ObjectHandle& lhs, const T& rhs) { return lhs.m_object < &rhs; } + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<=(const ObjectHandle& lhs, const ObjectHandle& rhs) { return !(lhs > rhs); } + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<=(const T& lhs, const ObjectHandle& rhs) { return !(lhs > rhs); } + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<=(const ObjectHandle& lhs, const T& rhs) { return !(lhs > rhs); } + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>(const ObjectHandle& lhs, const ObjectHandle& rhs) { return rhs < lhs; } + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>(const T& lhs, const ObjectHandle& rhs) { return rhs < lhs; } + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>(const ObjectHandle& lhs, const T& rhs) { return rhs < lhs; } + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>=(const ObjectHandle& lhs, const ObjectHandle& rhs) { return !(lhs < rhs); } + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>=(const T& lhs, const ObjectHandle& rhs) { return !(lhs < rhs); } + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>=(const ObjectHandle& lhs, const T& rhs) { @@ -301,6 +534,12 @@ namespace Nz namespace std { + /*! + * \brief Swaps two ObjectHandle, specialisation of std + * + * \param lhs First object handle + * \param rhs Second object handle + */ template void swap(Nz::ObjectHandle& lhs, Nz::ObjectHandle& rhs) { diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index 119d05cca..751746aea 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -50,6 +50,8 @@ namespace Nz void SetParameter(const String& name, void* value); void SetParameter(const String& name, void* value, Destructor destructor); + String ToString() const; + ParameterList& operator=(const ParameterList& list); ParameterList& operator=(ParameterList&&) = default; @@ -73,7 +75,7 @@ namespace Nz ParameterType type; union Value { - // On définit un constructeur/destructeur vide, permettant de mettre des classes dans l'union + // We define an empty constructor/destructor, to be able to put classes in the union Value() {} Value(const Value&) {} // Placeholder ~Value() {} @@ -98,4 +100,6 @@ namespace Nz }; } +std::ostream& operator<<(std::ostream& out, const Nz::ParameterList& parameterList); + #endif // NAZARA_PARAMETERLIST_HPP diff --git a/include/Nazara/Core/ResourceLoader.inl b/include/Nazara/Core/ResourceLoader.inl index af0a8a7f0..74e59067d 100644 --- a/include/Nazara/Core/ResourceLoader.inl +++ b/include/Nazara/Core/ResourceLoader.inl @@ -66,7 +66,7 @@ namespace Nz return false; } - File file(path); // Ouvert seulement en cas de besoin + File file(path); // Open only if needed bool found = false; for (Loader& loader : Type::s_loaders) diff --git a/src/Nazara/Core/Core.cpp b/src/Nazara/Core/Core.cpp index 1ccb35212..026e4a247 100644 --- a/src/Nazara/Core/Core.cpp +++ b/src/Nazara/Core/Core.cpp @@ -28,7 +28,7 @@ namespace Nz bool Core::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; return true; // Already initialized diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 39e873373..97504b0ee 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -385,7 +385,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param pos Position of the cursor @@ -404,7 +404,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param offset Offset according to the cursor begin position @@ -906,5 +906,5 @@ namespace Nz } return true; - } + }; } diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 371e91b77..abe93c640 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -607,6 +607,54 @@ namespace Nz parameter.value.ptrVal = value; } + /*! + * \brief Gives a string representation + * \return A string representation of the object: "ParameterList(Name: Type(value), ...)" + */ + String ParameterList::ToString() const + { + StringStream ss; + + ss << "ParameterList("; + for (auto it = m_parameters.cbegin(); it != m_parameters.cend();) + { + ss << it->first << ": "; + switch (it->second.type) + { + case ParameterType_Boolean: + ss << "Boolean(" << String::Boolean(it->second.value.boolVal) << ")"; + break; + case ParameterType_Color: + ss << "Color(" << it->second.value.colorVal.ToString() << ")"; + break; + case ParameterType_Float: + ss << "Float(" << it->second.value.floatVal << ")"; + break; + case ParameterType_Integer: + ss << "Integer(" << it->second.value.intVal << ")"; + break; + case ParameterType_String: + ss << "String(" << it->second.value.stringVal << ")"; + break; + case ParameterType_Pointer: + ss << "Pointer(" << String::Pointer(it->second.value.ptrVal) << ")"; + break; + case ParameterType_Userdata: + ss << "Userdata(" << String::Pointer(it->second.value.userdataVal->ptr) << ")"; + break; + case ParameterType_None: + ss << "None"; + break; + } + + if (++it != m_parameters.cend()) + ss << ", "; + } + ss << ")"; + + return ss; + } + /*! * \brief Sets a userdata parameter named `name` * @@ -724,3 +772,17 @@ namespace Nz } } } + +/*! +* \brief Output operator +* \return The stream +* +* \param out The stream +* \param parameterList The ParameterList to output +*/ + +std::ostream& operator<<(std::ostream& out, const Nz::ParameterList& parameterList) +{ + out << parameterList.ToString(); + return out; +} diff --git a/tests/Engine/Core/ByteArray.cpp b/tests/Engine/Core/ByteArray.cpp index 476643d5e..d085585a5 100644 --- a/tests/Engine/Core/ByteArray.cpp +++ b/tests/Engine/Core/ByteArray.cpp @@ -213,4 +213,24 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]") } } } + + GIVEN("A default byte array") + { + Nz::ByteArray defaultByteArray; + + WHEN("We resize") + { + Nz::UInt64 oldSize = defaultByteArray.GetSize(); + REQUIRE(oldSize == 0); + defaultByteArray.Resize(10); + + THEN("Capacity has increased") + { + REQUIRE(defaultByteArray[oldSize] == 0); + + REQUIRE(defaultByteArray.GetCapacity() >= 10); + REQUIRE(defaultByteArray.GetSize() == 10); + } + } + } } diff --git a/tests/Engine/Core/File.cpp b/tests/Engine/Core/File.cpp index 2ddbfebbf..1163a8aad 100644 --- a/tests/Engine/Core/File.cpp +++ b/tests/Engine/Core/File.cpp @@ -32,12 +32,22 @@ SCENARIO("File", "[CORE][FILE]") REQUIRE(Nz::String(message) == "Test String"); } + AND_THEN("We can get its size") + { + REQUIRE(file.GetSize() == 33U); + } + AND_THEN("We close it") { file.Close(); - REQUIRE(file.GetSize() == 33U); CHECK(!file.IsOpen()); } + + AND_THEN("Change its size") + { + file.SetSize(50U); + REQUIRE(file.GetSize() == 50U); + } } WHEN("We delete this file") From 74081c2b9f31ee861217ff9c1de5a5fa6b3787f5 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:21:36 +0200 Subject: [PATCH 013/235] Documentation for module: Graphics Former-commit-id: 5fba876346aec7b35bc618002b669ff194e58544 --- include/Nazara/Graphics/Billboard.inl | 101 +++- include/Nazara/Graphics/ColorBackground.inl | 7 + include/Nazara/Graphics/Config.hpp | 19 +- include/Nazara/Graphics/ConfigCheck.hpp | 4 +- include/Nazara/Graphics/DebugOff.hpp | 2 +- include/Nazara/Graphics/DeferredBloomPass.hpp | 2 +- include/Nazara/Graphics/DeferredDOFPass.hpp | 2 +- include/Nazara/Graphics/DeferredFXAAPass.hpp | 2 +- include/Nazara/Graphics/DeferredFinalPass.hpp | 2 +- include/Nazara/Graphics/DeferredFogPass.hpp | 2 +- .../Nazara/Graphics/DeferredForwardPass.hpp | 2 +- .../Nazara/Graphics/DeferredGeometryPass.hpp | 2 +- .../Graphics/DeferredPhongLightingPass.hpp | 2 +- .../Nazara/Graphics/DeferredRenderPass.hpp | 2 +- .../Graphics/DeferredRenderTechnique.hpp | 2 +- include/Nazara/Graphics/DepthRenderQueue.inl | 8 + include/Nazara/Graphics/Enums.hpp | 4 +- .../Nazara/Graphics/ForwardRenderQueue.hpp | 1 + .../Graphics/ForwardRenderTechnique.hpp | 10 +- .../Graphics/ForwardRenderTechnique.inl | 58 ++ .../Nazara/Graphics/InstancedRenderable.inl | 31 ++ include/Nazara/Graphics/Light.inl | 174 ++++++ include/Nazara/Graphics/Material.hpp | 6 +- include/Nazara/Graphics/Material.inl | 509 ++++++++++++++++++ include/Nazara/Graphics/Model.hpp | 2 - include/Nazara/Graphics/Model.inl | 7 + .../Nazara/Graphics/ParticleDeclaration.hpp | 10 +- include/Nazara/Graphics/ParticleMapper.inl | 28 +- include/Nazara/Graphics/Renderable.inl | 14 + include/Nazara/Graphics/SkyboxBackground.inl | 56 ++ include/Nazara/Graphics/Sprite.inl | 120 ++++- include/Nazara/Graphics/TextSprite.inl | 84 ++- include/Nazara/Graphics/TextureBackground.inl | 18 + include/Nazara/Math/Frustum.inl | 4 +- include/Nazara/Math/Sphere.inl | 2 +- src/Nazara/Graphics/AbstractBackground.cpp | 8 + src/Nazara/Graphics/AbstractRenderQueue.cpp | 32 ++ .../Graphics/AbstractRenderTechnique.cpp | 30 ++ src/Nazara/Graphics/AbstractViewer.cpp | 8 + src/Nazara/Graphics/Billboard.cpp | 19 +- src/Nazara/Graphics/ColorBackground.cpp | 39 ++ src/Nazara/Graphics/DeferredBloomPass.cpp | 85 ++- src/Nazara/Graphics/DeferredDOFPass.cpp | 34 +- src/Nazara/Graphics/DeferredFXAAPass.cpp | 21 +- src/Nazara/Graphics/DeferredFinalPass.cpp | 21 +- src/Nazara/Graphics/DeferredFogPass.cpp | 26 +- src/Nazara/Graphics/DeferredForwardPass.cpp | 23 +- src/Nazara/Graphics/DeferredGeometryPass.cpp | 73 ++- .../Graphics/DeferredPhongLightingPass.cpp | 44 +- src/Nazara/Graphics/DeferredRenderPass.cpp | 34 ++ src/Nazara/Graphics/DeferredRenderQueue.cpp | 205 ++++++- .../Graphics/DeferredRenderTechnique.cpp | 166 +++++- src/Nazara/Graphics/DepthRenderQueue.cpp | 183 +++++++ src/Nazara/Graphics/DepthRenderTechnique.cpp | 136 ++++- src/Nazara/Graphics/Drawable.cpp | 8 + src/Nazara/Graphics/ForwardRenderQueue.cpp | 479 ++++++++++------ .../Graphics/ForwardRenderTechnique.cpp | 291 +++++++--- src/Nazara/Graphics/Graphics.cpp | 53 +- .../Graphics/GuillotineTextureAtlas.cpp | 28 +- src/Nazara/Graphics/InstancedRenderable.cpp | 54 ++ src/Nazara/Graphics/Light.cpp | 77 ++- src/Nazara/Graphics/Material.cpp | 64 ++- src/Nazara/Graphics/Model.cpp | 219 +++++++- src/Nazara/Graphics/ParticleController.cpp | 31 ++ src/Nazara/Graphics/ParticleDeclaration.cpp | 108 +++- src/Nazara/Graphics/ParticleEmitter.cpp | 72 ++- src/Nazara/Graphics/ParticleGenerator.cpp | 31 ++ src/Nazara/Graphics/ParticleMapper.cpp | 13 + src/Nazara/Graphics/ParticleRenderer.cpp | 29 + src/Nazara/Graphics/ParticleSystem.cpp | 244 ++++++++- src/Nazara/Graphics/RenderTechniques.cpp | 80 ++- src/Nazara/Graphics/Renderable.cpp | 27 + src/Nazara/Graphics/SkeletalModel.cpp | 167 +++++- src/Nazara/Graphics/SkinningManager.cpp | 69 ++- src/Nazara/Graphics/SkyboxBackground.cpp | 36 +- src/Nazara/Graphics/Sprite.cpp | 34 ++ src/Nazara/Graphics/TextSprite.cpp | 85 ++- src/Nazara/Graphics/TextureBackground.cpp | 28 + tests/Engine/Graphics/Billboard.cpp | 34 ++ tests/Engine/Graphics/ColorBackground.cpp | 20 + .../Graphics/DeferredRenderTechnique.cpp | 29 + tests/Engine/Graphics/Light.cpp | 31 ++ tests/Engine/Graphics/Model.cpp | 24 + tests/Engine/Graphics/ParticleDeclaration.cpp | 29 + tests/Engine/Graphics/ParticleSystem.cpp | 103 ++++ tests/Engine/Graphics/RenderTechniques.cpp | 47 ++ tests/Engine/Graphics/SkeletalModel.cpp | 26 + tests/Engine/Graphics/SkyboxBackground.cpp | 25 + tests/Engine/Graphics/TextureBackground.cpp | 20 + tests/Engine/Math/Sphere.cpp | 12 +- tests/main.cpp | 16 +- .../Engine/Graphics/Bob lamp/Readme.txt | 24 + .../resources/Engine/Graphics/copyrights.txt | 82 +++ .../Engine/Graphics/dragon_recon/README | 27 + 94 files changed, 4858 insertions(+), 504 deletions(-) create mode 100644 tests/Engine/Graphics/Billboard.cpp create mode 100644 tests/Engine/Graphics/ColorBackground.cpp create mode 100644 tests/Engine/Graphics/DeferredRenderTechnique.cpp create mode 100644 tests/Engine/Graphics/Light.cpp create mode 100644 tests/Engine/Graphics/Model.cpp create mode 100644 tests/Engine/Graphics/ParticleDeclaration.cpp create mode 100644 tests/Engine/Graphics/ParticleSystem.cpp create mode 100644 tests/Engine/Graphics/RenderTechniques.cpp create mode 100644 tests/Engine/Graphics/SkeletalModel.cpp create mode 100644 tests/Engine/Graphics/SkyboxBackground.cpp create mode 100644 tests/Engine/Graphics/TextureBackground.cpp create mode 100644 tests/resources/Engine/Graphics/Bob lamp/Readme.txt create mode 100644 tests/resources/Engine/Graphics/copyrights.txt create mode 100644 tests/resources/Engine/Graphics/dragon_recon/README diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index c9760d0d1..6c4a1e0a9 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a Billboard object by default + */ + inline Billboard::Billboard() { SetColor(Color::White); @@ -15,6 +19,12 @@ namespace Nz SetSize(64.f, 64.f); } + /*! + * \brief Constructs a Billboard object with a reference to a material + * + * \param material Reference to a material + */ + inline Billboard::Billboard(MaterialRef material) { SetColor(Color::White); @@ -23,6 +33,12 @@ namespace Nz SetSize(64.f, 64.f); } + /*! + * \brief Constructs a Billboard object with a pointer to a texture + * + * \param texture Pointer to a texture + */ + inline Billboard::Billboard(Texture* texture) { SetColor(Color::White); @@ -31,6 +47,12 @@ namespace Nz SetTexture(texture, true); } + /*! + * \brief Constructs a Billboard object by assignation + * + * \param billboard Billboard to copy into this + */ + inline Billboard::Billboard(const Billboard& billboard) : InstancedRenderable(billboard), m_color(billboard.m_color), @@ -41,31 +63,61 @@ namespace Nz { } + /*! + * \brief Gets the color of the billboard + * \return Current color + */ + inline const Color& Billboard::GetColor() const { return m_color; } + /*! + * \brief Gets the material of the billboard + * \return Current material + */ + inline const MaterialRef& Billboard::GetMaterial() const { return m_material; } + /*! + * \brief Gets the rotation of the billboard + * \return Current rotation + */ + inline float Billboard::GetRotation() const { return m_rotation; } + /*! + * \brief Gets the size of the billboard + * \return Current size + */ + inline const Vector2f& Billboard::GetSize() const { return m_size; } + /*! + * \brief Sets the color of the billboard + * + * \param color Color for the billboard + */ + inline void Billboard::SetColor(const Color& color) { m_color = color; } + /*! + * \brief Sets the default material of the billboard (just default material) + */ + inline void Billboard::SetDefaultMaterial() { MaterialRef material = Material::New(); @@ -75,6 +127,13 @@ namespace Nz SetMaterial(std::move(material)); } + /*! + * \brief Sets the material of the billboard + * + * \param material Material for the billboard + * \param resizeBillboard Should billboard be resized to the material size (diffuse map) + */ + inline void Billboard::SetMaterial(MaterialRef material, bool resizeBillboard) { m_material = std::move(material); @@ -86,25 +145,51 @@ namespace Nz } } + /*! + * \brief Sets the rotation of the billboard + * + * \param rotation Rotation for the billboard + */ + inline void Billboard::SetRotation(float rotation) { m_rotation = rotation; m_sinCos.Set(std::sin(m_rotation), std::cos(m_rotation)); } + /*! + * \brief Sets the size of the billboard + * + * \param size Size for the billboard + */ + inline void Billboard::SetSize(const Vector2f& size) { m_size = size; - // On invalide la bounding box + // We invalidate the bounding volume InvalidateBoundingVolume(); } + /*! + * \brief Sets the size of the billboard + * + * \param sizeX Size in X for the billboard + * \param sizeY Size in Y for the billboard + */ + inline void Billboard::SetSize(float sizeX, float sizeY) { SetSize(Vector2f(sizeX, sizeY)); } + /*! + * \brief Sets the texture of the billboard + * + * \param texture Texture for the billboard + * \param resizeBillboard Should billboard be resized to the texture size + */ + inline void Billboard::SetTexture(TextureRef texture, bool resizeBillboard) { if (!m_material) @@ -118,6 +203,13 @@ namespace Nz m_material->SetDiffuseMap(std::move(texture)); } + /*! + * \brief Sets the current billboard with the content of the other one + * \return A reference to this + * + * \param billboard The other Billboard + */ + inline Billboard& Billboard::operator=(const Billboard& billboard) { InstancedRenderable::operator=(billboard); @@ -131,6 +223,13 @@ namespace Nz return *this; } + /*! + * \brief Creates a new billboard from the arguments + * \return A reference to the newly created billboard + * + * \param args Arguments for the billboard + */ + template BillboardRef Billboard::New(Args&&... args) { diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 21b67d92c..67b1f2558 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -7,6 +7,13 @@ namespace Nz { + /*! + * \brief Creates a new color background from the arguments + * \return A reference to the newly created color background + * + * \param args Arguments for the color background + */ + template ColorBackgroundRef ColorBackground::New(Args&&... args) { diff --git a/include/Nazara/Graphics/Config.hpp b/include/Nazara/Graphics/Config.hpp index 77f1669c4..e47c8d3a5 100644 --- a/include/Nazara/Graphics/Config.hpp +++ b/include/Nazara/Graphics/Config.hpp @@ -27,23 +27,28 @@ #ifndef NAZARA_CONFIG_GRAPHICS_HPP #define NAZARA_CONFIG_GRAPHICS_HPP -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci +/*! +* \defgroup graphics (NazaraGraphics) Graphics module +* Graphics/System module including classes to handle graphical elements... +*/ -// À partir de combien d'instances d'un même mesh/matériau l'instancing doit-il être utilisé ? +/// Each modification of a paramater of the module needs a recompilation of the unit + +// How much instances are need of a same mesh/material to enable instancing ? #define NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT 10 -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) #define NAZARA_GRAPHICS_MANAGE_MEMORY 0 -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) +// Activate the security tests based on the code (Advised for development) #define NAZARA_GRAPHICS_SAFE 1 -/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code +/// Each modification of a parameter following implies a modification (often minor) of the code -// Le nombre maximum de lumières qu'un shader standard supportera +// The maximum number of lights in a standard shader #define NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS 3 -/// Vérification des valeurs et types de certaines constantes +/// Checking the values and types of certain constants #include #if defined(NAZARA_STATIC) diff --git a/include/Nazara/Graphics/ConfigCheck.hpp b/include/Nazara/Graphics/ConfigCheck.hpp index e93c8e0ec..c2bbda886 100644 --- a/include/Nazara/Graphics/ConfigCheck.hpp +++ b/include/Nazara/Graphics/ConfigCheck.hpp @@ -7,12 +7,12 @@ #ifndef NAZARA_CONFIG_CHECK_GRAPHICS_HPP #define NAZARA_CONFIG_CHECK_GRAPHICS_HPP -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp +/// This file is used to check the constant values defined in Config.hpp #include #define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) -// On force la valeur de MANAGE_MEMORY en mode debug +// We fore the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_GRAPHICS_MANAGE_MEMORY #undef NAZARA_GRAPHICS_MANAGE_MEMORY #define NAZARA_GRAPHICS_MANAGE_MEMORY 0 diff --git a/include/Nazara/Graphics/DebugOff.hpp b/include/Nazara/Graphics/DebugOff.hpp index 38a452aab..c90640fc0 100644 --- a/include/Nazara/Graphics/DebugOff.hpp +++ b/include/Nazara/Graphics/DebugOff.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +// We suppose that Debug.hpp is already included, same goes for Config.hpp #if NAZARA_GRAPHICS_MANAGE_MEMORY #undef delete #undef new diff --git a/include/Nazara/Graphics/DeferredBloomPass.hpp b/include/Nazara/Graphics/DeferredBloomPass.hpp index 603998d84..5c45a2277 100644 --- a/include/Nazara/Graphics/DeferredBloomPass.hpp +++ b/include/Nazara/Graphics/DeferredBloomPass.hpp @@ -29,7 +29,7 @@ namespace Nz float GetBrightThreshold() const; Texture* GetTexture(unsigned int i) const; - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; bool Resize(const Vector2ui& dimensions); void SetBlurPassCount(unsigned int passCount); diff --git a/include/Nazara/Graphics/DeferredDOFPass.hpp b/include/Nazara/Graphics/DeferredDOFPass.hpp index 4da8824c7..c3d6e4c0f 100644 --- a/include/Nazara/Graphics/DeferredDOFPass.hpp +++ b/include/Nazara/Graphics/DeferredDOFPass.hpp @@ -23,7 +23,7 @@ namespace Nz DeferredDOFPass(); virtual ~DeferredDOFPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; bool Resize(const Vector2ui& dimensions); protected: diff --git a/include/Nazara/Graphics/DeferredFXAAPass.hpp b/include/Nazara/Graphics/DeferredFXAAPass.hpp index 34fc46867..1c74ffb1c 100644 --- a/include/Nazara/Graphics/DeferredFXAAPass.hpp +++ b/include/Nazara/Graphics/DeferredFXAAPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFXAAPass(); virtual ~DeferredFXAAPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredFinalPass.hpp b/include/Nazara/Graphics/DeferredFinalPass.hpp index c800d44d1..f6b633925 100644 --- a/include/Nazara/Graphics/DeferredFinalPass.hpp +++ b/include/Nazara/Graphics/DeferredFinalPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFinalPass(); virtual ~DeferredFinalPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredFogPass.hpp b/include/Nazara/Graphics/DeferredFogPass.hpp index 37466305b..babccb0bf 100644 --- a/include/Nazara/Graphics/DeferredFogPass.hpp +++ b/include/Nazara/Graphics/DeferredFogPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFogPass(); virtual ~DeferredFogPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredForwardPass.hpp b/include/Nazara/Graphics/DeferredForwardPass.hpp index 0b1d8aa0a..cd5341d85 100644 --- a/include/Nazara/Graphics/DeferredForwardPass.hpp +++ b/include/Nazara/Graphics/DeferredForwardPass.hpp @@ -21,7 +21,7 @@ namespace Nz virtual ~DeferredForwardPass(); void Initialize(DeferredRenderTechnique* technique); - bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const; + bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const; protected: const ForwardRenderTechnique* m_forwardTechnique; diff --git a/include/Nazara/Graphics/DeferredGeometryPass.hpp b/include/Nazara/Graphics/DeferredGeometryPass.hpp index 652060b3d..15437f0d8 100644 --- a/include/Nazara/Graphics/DeferredGeometryPass.hpp +++ b/include/Nazara/Graphics/DeferredGeometryPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredGeometryPass(); virtual ~DeferredGeometryPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; bool Resize(const Vector2ui& dimensions); protected: diff --git a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp index 40b480217..68eb96264 100644 --- a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp +++ b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp @@ -28,7 +28,7 @@ namespace Nz bool IsLightMeshesDrawingEnabled() const; - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: LightUniforms m_directionalLightUniforms; diff --git a/include/Nazara/Graphics/DeferredRenderPass.hpp b/include/Nazara/Graphics/DeferredRenderPass.hpp index d9ad69919..34a4020a6 100644 --- a/include/Nazara/Graphics/DeferredRenderPass.hpp +++ b/include/Nazara/Graphics/DeferredRenderPass.hpp @@ -38,7 +38,7 @@ namespace Nz bool IsEnabled() const; - virtual bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const = 0; + virtual bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const = 0; virtual bool Resize(const Vector2ui& GBufferSize); DeferredRenderPass& operator=(const DeferredRenderPass&) = delete; diff --git a/include/Nazara/Graphics/DeferredRenderTechnique.hpp b/include/Nazara/Graphics/DeferredRenderTechnique.hpp index 99d1fc813..e9e357184 100644 --- a/include/Nazara/Graphics/DeferredRenderTechnique.hpp +++ b/include/Nazara/Graphics/DeferredRenderTechnique.hpp @@ -67,7 +67,7 @@ namespace Nz }; std::map>, RenderPassComparator> m_passes; - ForwardRenderTechnique m_forwardTechnique; // Doit être initialisé avant la RenderQueue + ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue DeferredRenderQueue m_renderQueue; mutable RenderBufferRef m_depthStencilBuffer; mutable RenderTexture m_GBufferRTT; diff --git a/include/Nazara/Graphics/DepthRenderQueue.inl b/include/Nazara/Graphics/DepthRenderQueue.inl index 7d6c9221f..a8a8da45e 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.inl +++ b/include/Nazara/Graphics/DepthRenderQueue.inl @@ -6,6 +6,14 @@ namespace Nz { + + /*! + * \brief Checks whether the material is suitable to fit in the render queue + * \return true If it is the case + * + * \param material Material to verify + */ + bool DepthRenderQueue::IsMaterialSuitable(const Material* material) const { NazaraAssert(material, "Invalid material"); diff --git a/include/Nazara/Graphics/Enums.hpp b/include/Nazara/Graphics/Enums.hpp index 6703f88a0..d378058f7 100644 --- a/include/Nazara/Graphics/Enums.hpp +++ b/include/Nazara/Graphics/Enums.hpp @@ -128,7 +128,7 @@ namespace Nz SceneNodeType_Max = SceneNodeType_User }; - // Ces paramètres sont indépendants du matériau: ils peuvent être demandés à tout moment + // These parameters are independant of the material: they can not be asked for the moment enum ShaderFlags { ShaderFlags_None = 0, @@ -139,7 +139,7 @@ namespace Nz ShaderFlags_TextureOverlay = 0x08, ShaderFlags_VertexColor = 0x10, - ShaderFlags_Max = ShaderFlags_VertexColor*2-1 + ShaderFlags_Max = ShaderFlags_VertexColor * 2 - 1 }; } diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index 9a17f5d2f..c358e331c 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -159,6 +159,7 @@ namespace Nz std::map layers; private: + BillboardData* GetBillboardData(int renderOrder, const Material* material, unsigned int count); Layer& GetLayer(int i); ///TODO: Inline void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer); diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index 447818958..21b3a0899 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -31,7 +31,7 @@ namespace Nz AbstractRenderQueue* GetRenderQueue() override; RenderTechniqueType GetType() const override; - void SetMaxLightPassPerObject(unsigned int passCount); + void SetMaxLightPassPerObject(unsigned int maxLightPassPerObject); static bool Initialize(); static void Uninitialize(); @@ -70,11 +70,11 @@ namespace Nz LightUniforms lightUniforms; bool hasLightUniforms; - /// Moins coûteux en mémoire que de stocker un LightUniforms par index de lumière, - /// à voir si ça fonctionne chez tout le monde - int lightOffset; // "Distance" entre Lights[0].type et Lights[1].type + /// Less costly in memory than storing a LightUniforms by index of light, + /// this may not work everywhere + int lightOffset; // "Distance" between Lights[0].type and Lights[1].type - // Autre uniformes + // Other uniforms int eyePosition; int sceneAmbient; int textureOverlay; diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index bf9e5674c..6490513f8 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -6,6 +6,16 @@ namespace Nz { + /*! + * \brief Sens the uniforms for light + * + * \param shader Shader to send uniforms to + * \param uniforms Uniforms to send + * \param index Index of the light + * \param uniformOffset Offset for the uniform + * \param availableTextureUnit Unit texture available + */ + inline void ForwardRenderTechnique::SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int uniformOffset, UInt8 availableTextureUnit) const { // If anyone got a better idea.. @@ -104,6 +114,14 @@ namespace Nz } } + /*! + * \brief Computes the score for directional light + * \return 0.f + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline float ForwardRenderTechnique::ComputeDirectionalLightScore(const Spheref& object, const AbstractRenderQueue::DirectionalLight& light) { NazaraUnused(object); @@ -113,18 +131,42 @@ namespace Nz return 0.f; } + /*! + * \brief Computes the score for point light + * \return Distance to the light + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline float ForwardRenderTechnique::ComputePointLightScore(const Spheref& object, const AbstractRenderQueue::PointLight& light) { ///TODO: Compute a score depending on the light luminosity return object.SquaredDistance(light.position); } + /*! + * \brief Computes the score for spot light + * \return Distance to the light + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline float ForwardRenderTechnique::ComputeSpotLightScore(const Spheref& object, const AbstractRenderQueue::SpotLight& light) { ///TODO: Compute a score depending on the light luminosity and spot direction return object.SquaredDistance(light.position); } + /*! + * \brief Checks whether the directional light is suitable for the computations + * \return true if light is enoughly close + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline bool ForwardRenderTechnique::IsDirectionalLightSuitable(const Spheref& object, const AbstractRenderQueue::DirectionalLight& light) { NazaraUnused(object); @@ -134,12 +176,28 @@ namespace Nz return true; } + /*! + * \brief Checks whether the point light is suitable for the computations + * \return true if light is enoughly close + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline bool ForwardRenderTechnique::IsPointLightSuitable(const Spheref& object, const AbstractRenderQueue::PointLight& light) { // If the object is too far away from this point light, there is not way it could light it return object.SquaredDistance(light.position) <= light.radius * light.radius; } + /*! + * \brief Checks whether the spot light is suitable for the computations + * \return true if light is enoughly close + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline bool ForwardRenderTechnique::IsSpotLightSuitable(const Spheref& object, const AbstractRenderQueue::SpotLight& light) { ///TODO: Exclude spot lights based on their direction and outer angle? diff --git a/include/Nazara/Graphics/InstancedRenderable.inl b/include/Nazara/Graphics/InstancedRenderable.inl index 0cc97f101..7f2537fbf 100644 --- a/include/Nazara/Graphics/InstancedRenderable.inl +++ b/include/Nazara/Graphics/InstancedRenderable.inl @@ -4,6 +4,12 @@ namespace Nz { + /*! + * \brief Constructs a InstancedRenderable object by assignation + * + * \param renderable InstancedRenderable to copy into this + */ + inline InstancedRenderable::InstancedRenderable(const InstancedRenderable& renderable) : RefCounted(), m_boundingVolume(renderable.m_boundingVolume), @@ -11,22 +17,43 @@ namespace Nz { } + /*! + * \brief Ensures that the bounding volume is up to date + */ + inline void InstancedRenderable::EnsureBoundingVolumeUpdated() const { if (!m_boundingVolumeUpdated) UpdateBoundingVolume(); } + /*! + * \brief Invalidates the bounding volume + */ + inline void InstancedRenderable::InvalidateBoundingVolume() { m_boundingVolumeUpdated = false; } + /*! + * \brief Invalidates the instance data based on flags + * + * \param flags Flags to invalidate + */ + inline void InstancedRenderable::InvalidateInstanceData(UInt32 flags) { OnInstancedRenderableInvalidateData(this, flags); } + /*! + * \brief Sets the current instanced renderable with the content of the other one + * \return A reference to this + * + * \param renderable The other InstancedRenderable + */ + inline InstancedRenderable& InstancedRenderable::operator=(const InstancedRenderable& renderable) { m_boundingVolume = renderable.m_boundingVolume; @@ -35,6 +62,10 @@ namespace Nz return *this; } + /*! + * \brief Updates the bounding volume + */ + inline void InstancedRenderable::UpdateBoundingVolume() const { MakeBoundingVolume(); diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index edff48a66..2852834b7 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a Light object by default + */ + inline Light::Light(const Light& light) : Renderable(light), m_color(light.m_color), @@ -28,6 +32,12 @@ namespace Nz { } + /*! + * \brief Enables shadow casting + * + * \param castShadows Should shadows be cast + */ + inline void Light::EnableShadowCasting(bool castShadows) { if (m_shadowCastingEnabled != castShadows) @@ -37,72 +47,141 @@ namespace Nz } } + /*! + * \brief Ensures that the shadow map is up to date + */ + inline void Light::EnsureShadowMapUpdate() const { if (!m_shadowMapUpdated) UpdateShadowMap(); } + /*! + * \brief Gets the ambient factor + * \return Current ambient factor + */ + inline float Light::GetAmbientFactor() const { return m_ambientFactor; } + /*! + * \brief Gets the light attenuation (in 1 / R^2) + * \return Attenuation + */ + inline float Light::GetAttenuation() const { return m_attenuation; } + /*! + * \brief Gets the color of the light + * \return Light color + */ + inline Color Light::GetColor() const { return m_color; } + /*! + * \brief Gets the diffuse factor + * \return Current diffuse factor + */ + inline float Light::GetDiffuseFactor() const { return m_diffuseFactor; } + /*! + * \brief Gets the inner angle in spot light + * \return Inner angle + */ + inline float Light::GetInnerAngle() const { return m_innerAngle; } + /*! + * \brief Gets the cosine inner angle in spot light + * \return Cosine inner angle + */ + inline float Light::GetInnerAngleCosine() const { return m_innerAngleCosine; } + /*! + * \brief Gets the inverse of the radius + * \return Inverse of the radius + */ + inline float Light::GetInvRadius() const { return m_invRadius; } + /*! + * \brief Gets the type of the light + * \return Light type + */ + inline LightType Light::GetLightType() const { return m_type; } + /*! + * \brief Gets the outer angle in spot light + * \return Outer angle + */ + inline float Light::GetOuterAngle() const { return m_outerAngle; } + /*! + * \brief Gets the cosine outer angle in spot light + * \return Cosine outer angle + */ + inline float Light::GetOuterAngleCosine() const { return m_outerAngleCosine; } + /*! + * \brief Gets the tangent outer angle in spot light + * \return Tangent outer angle + */ + inline float Light::GetOuterAngleTangent() const { return m_outerAngleTangent; } + /*! + * \brief Gets the radius of the light + * \return Light radius + */ + inline float Light::GetRadius() const { return m_radius; } + /*! + * \brief Gets the shadow map + * \return Reference to the shadow map texture + */ + inline TextureRef Light::GetShadowMap() const { EnsureShadowMapUpdate(); @@ -110,47 +189,97 @@ namespace Nz return m_shadowMap; } + /*! + * \brief Gets the format of the shadow map + * \return Shadow map format + */ + inline PixelFormatType Light::GetShadowMapFormat() const { return m_shadowMapFormat; } + /*! + * \brief Gets the size of the shadow map + * \return Shadow map size + */ + inline const Vector2ui& Light::GetShadowMapSize() const { return m_shadowMapSize; } + /*! + * \brief Checks whether the shadow casting is enabled + * \return true If it is the case + */ + inline bool Light::IsShadowCastingEnabled() const { return m_shadowCastingEnabled; } + /*! + * \brief Sets the ambient factor + * + * \param factor Ambient factor + */ + inline void Light::SetAmbientFactor(float factor) { m_ambientFactor = factor; } + /*! + * \brief Sets the light attenuation (in 1 / R^2) + * + * \param attenuation Light attenuation + */ + inline void Light::SetAttenuation(float attenuation) { m_attenuation = attenuation; } + /*! + * \brief Sets the color of the light + * + * \param color Light color + */ + inline void Light::SetColor(const Color& color) { m_color = color; } + /*! + * \brief Sets the diffuse factor + * + * \param factor Diffuse factor + */ + inline void Light::SetDiffuseFactor(float factor) { m_diffuseFactor = factor; } + /*! + * \brief Sets the inner angle in spot light + * \return innerAngle Inner angle + */ + inline void Light::SetInnerAngle(float innerAngle) { m_innerAngle = innerAngle; m_innerAngleCosine = std::cos(DegreeToRadian(m_innerAngle)); } + /*! + * \brief Sets the type of light + * + * \param type Light type + */ + inline void Light::SetLightType(LightType type) { m_type = type; @@ -158,6 +287,13 @@ namespace Nz InvalidateShadowMap(); } + /*! + * \brief Sets the outer angle in spot light + * \return outerAngle Outer angle + * + * \remark Invalidates the bounding volume + */ + inline void Light::SetOuterAngle(float outerAngle) { m_outerAngle = outerAngle; @@ -167,6 +303,13 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Sets the radius of the light + * \return radius Light radius + * + * \remark Invalidates the bounding volume + */ + inline void Light::SetRadius(float radius) { m_radius = radius; @@ -176,6 +319,15 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Sets the shadow map format + * + * \param shadowFormat Shadow map format + * + * \remark Invalidates the shadow map + * \remark Produces a NazaraAssert if format is not a depth type + */ + inline void Light::SetShadowMapFormat(PixelFormatType shadowFormat) { NazaraAssert(PixelFormat::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format"); @@ -185,6 +337,15 @@ namespace Nz InvalidateShadowMap(); } + /*! + * \brief Sets the size of the shadow map + * + * \param size Shadow map size + * + * \remark Invalidates the shadow map + * \remark Produces a NazaraAssert if size is zero + */ + inline void Light::SetShadowMapSize(const Vector2ui& size) { NazaraAssert(size.x > 0 && size.y > 0, "Shadow map size must have a positive size"); @@ -194,6 +355,15 @@ namespace Nz InvalidateShadowMap(); } + /*! + * \brief Sets the current light with the content of the other one + * \return A reference to this + * + * \param light The other Light + * + * \remark Invalidates the shadow map + */ + inline Light& Light::operator=(const Light& light) { Renderable::operator=(light); @@ -218,6 +388,10 @@ namespace Nz return *this; } + /*! + * \brief Invalidates the shadow map + */ + inline void Light::InvalidateShadowMap() { m_shadowMapUpdated = false; diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 4a110c64f..85c4d315c 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -151,7 +151,7 @@ namespace Nz inline Material& operator=(const Material& material); - static MaterialRef GetDefault(); + inline static MaterialRef GetDefault(); template static MaterialRef New(Args&&... args); // Signals: @@ -163,7 +163,7 @@ namespace Nz { const Shader* shader; UberShaderInstance* uberInstance = nullptr; - int uniforms[MaterialUniform_Max+1]; + int uniforms[MaterialUniform_Max + 1]; }; void Copy(const Material& material); @@ -187,7 +187,7 @@ namespace Nz TextureRef m_normalMap; TextureRef m_specularMap; UberShaderConstRef m_uberShader; - mutable ShaderInstance m_shaders[ShaderFlags_Max+1]; + mutable ShaderInstance m_shaders[ShaderFlags_Max + 1]; bool m_alphaTestEnabled; bool m_depthSortingEnabled; bool m_lightingEnabled; diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index c8559e11f..cdb9e0d5f 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -7,11 +7,21 @@ namespace Nz { + /*! + * \brief Constructs a Material object by default + */ + inline Material::Material() { Reset(); } + /*! + * \brief Constructs a Material object by assignation + * + * \param material Material to copy into this + */ + inline Material::Material(const Material& material) : RefCounted(), Resource(material) @@ -19,11 +29,26 @@ namespace Nz Copy(material); } + /*! + * \brief Destructs the object and calls OnMaterialRelease + * + * \see OnMaterialRelease + */ + inline Material::~Material() { OnMaterialRelease(this); } + /*! + * \brief Enables a renderer parameter + * + * \param renderParameter Parameter for the rendering + * \param enable Should the parameter be enabled + * + * \remark Produces a NazaraAssert if enumeration is invalid + */ + inline void Material::Enable(RendererParameter renderParameter, bool enable) { NazaraAssert(renderParameter <= RendererParameter_Max, "Renderer parameter out of enum"); @@ -31,6 +56,14 @@ namespace Nz m_states.parameters[renderParameter] = enable; } + /*! + * \brief Enables the alpha test + * + * \param alphaTest Should the parameter be enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableAlphaTest(bool alphaTest) { m_alphaTestEnabled = alphaTest; @@ -38,12 +71,26 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Enables the depth sorting + * + * \param depthSorting Should the parameter be enabled + */ + inline void Material::EnableDepthSorting(bool depthSorting) { // Has no influence on shaders m_depthSortingEnabled = depthSorting; } + /*! + * \brief Enables the lighting + * + * \param lighting Should the parameter be enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableLighting(bool lighting) { m_lightingEnabled = lighting; @@ -51,12 +98,26 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Enables the shadow casting + * + * \param castShadows Should shadow casting be enabled + */ + inline void Material::EnableShadowCasting(bool castShadows) { // Has no influence on shaders m_shadowCastingEnabled = castShadows; } + /*! + * \brief Enables the shadow on receiving object + * + * \param receiveShadow Should receiving object have shadows enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableShadowReceive(bool receiveShadows) { m_shadowReceiveEnabled = receiveShadows; @@ -64,6 +125,14 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Enables the transformation + * + * \param transform Should the parameter be enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableTransform(bool transform) { m_transformEnabled = transform; @@ -71,91 +140,183 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Gets the alpha map + * \return Constant reference to the current texture + */ + inline const TextureRef& Material::GetAlphaMap() const { return m_alphaMap; } + /*! + * \brief Gets the alpha threshold + * \return The threshold value for the alpha + */ + inline float Material::GetAlphaThreshold() const { return m_alphaThreshold; } + /*! + * \brief Gets the ambient color + * \return Ambient color + */ + inline Color Material::GetAmbientColor() const { return m_ambientColor; } + /*! + * \brief Gets the function to compare depth + * \return Function comparing the depth of two materials + */ + inline RendererComparison Material::GetDepthFunc() const { return m_states.depthFunc; } + /*! + * \brief Gets the depth material + * \return Constant reference to the depth material + */ + inline const MaterialRef& Material::GetDepthMaterial() const { return m_depthMaterial; } + /*! + * \brief Gets the diffuse color + * \return Diffuse color + */ + inline Color Material::GetDiffuseColor() const { return m_diffuseColor; } + /*! + * \brief Gets the diffuse sampler + * \return Reference to the current texture sampler for the diffuse + */ + inline TextureSampler& Material::GetDiffuseSampler() { return m_diffuseSampler; } + /*! + * \brief Gets the diffuse sampler + * \return Constant reference to the current texture sampler for the diffuse + */ + inline const TextureSampler& Material::GetDiffuseSampler() const { return m_diffuseSampler; } + /*! + * \brief Gets the diffuse map + * \return Constant reference to the texture + */ + const TextureRef& Material::GetDiffuseMap() const { return m_diffuseMap; } + /*! + * \brief Gets the dst in blend + * \return Function for dst blending + */ + inline BlendFunc Material::GetDstBlend() const { return m_states.dstBlend; } + /*! + * \brief Gets the emissive map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetEmissiveMap() const { return m_emissiveMap; } + /*! + * \brief Gets the face culling + * \return Current face culling side + */ + inline FaceSide Material::GetFaceCulling() const { return m_states.faceCulling; } + /*! + * \brief Gets the face filling + * \return Current face filling + */ + inline FaceFilling Material::GetFaceFilling() const { return m_states.faceFilling; } + /*! + * \brief Gets the height map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetHeightMap() const { return m_heightMap; } + /*! + * \brief Gets the normal map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetNormalMap() const { return m_normalMap; } + /*! + * \brief Gets the render states + * \return Constant reference to the render states + */ + inline const RenderStates& Material::GetRenderStates() const { return m_states; } + /*! + * \brief Gets the shader of this material + * \return Constant pointer to the ubershader used + */ + inline const UberShader* Material::GetShader() const { return m_uberShader; } + /*! + * \brief Gets the shader instance based on the flag + * \return Constant pointer to the ubershader instance + * + * \param flags Flag of the shader + */ + inline const UberShaderInstance* Material::GetShaderInstance(UInt32 flags) const { const ShaderInstance& instance = m_shaders[flags]; @@ -165,81 +326,165 @@ namespace Nz return instance.uberInstance; } + /*! + * \brief Gets the shininess + * \return Current shininess + */ + inline float Material::GetShininess() const { return m_shininess; } + /*! + * \brief Gets the specular color + * \return Specular color + */ + inline Color Material::GetSpecularColor() const { return m_specularColor; } + /*! + * \brief Gets the specular map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetSpecularMap() const { return m_specularMap; } + /*! + * \brief Gets the specular sampler + * \return Reference to the current texture sampler for the specular + */ + inline TextureSampler& Material::GetSpecularSampler() { return m_specularSampler; } + /*! + * \brief Gets the specular sampler + * \return Constant reference to the current texture sampler for the specular + */ + inline const TextureSampler& Material::GetSpecularSampler() const { return m_specularSampler; } + /*! + * \brief Gets the src in blend + * \return Function for src blending + */ + inline BlendFunc Material::GetSrcBlend() const { return m_states.srcBlend; } + /*! + * \brief Checks whether this material has an alpha map + * \return true If it is the case + */ + inline bool Material::HasAlphaMap() const { return m_alphaMap.IsValid(); } + /*! + * \brief Checks whether this material has a depth material + * \return true If it is the case + */ + inline bool Material::HasDepthMaterial() const { return m_depthMaterial.IsValid(); } + /*! + * \brief Checks whether this material has a diffuse map + * \return true If it is the case + */ + inline bool Material::HasDiffuseMap() const { return m_diffuseMap.IsValid(); } + /*! + * \brief Checks whether this material has a emissive map + * \return true If it is the case + */ + inline bool Material::HasEmissiveMap() const { return m_emissiveMap.IsValid(); } + /*! + * \brief Checks whether this material has a height map + * \return true If it is the case + */ + inline bool Material::HasHeightMap() const { return m_heightMap.IsValid(); } + /*! + * \brief Checks whether this material has a normal map + * \return true If it is the case + */ + inline bool Material::HasNormalMap() const { return m_normalMap.IsValid(); } + /*! + * \brief Checks whether this material has a specular map + * \return true If it is the case + */ + inline bool Material::HasSpecularMap() const { return m_specularMap.IsValid(); } + /*! + * \brief Checks whether this material has alpha test enabled + * \return true If it is the case + */ + inline bool Material::IsAlphaTestEnabled() const { return m_alphaTestEnabled; } + /*! + * \brief Checks whether this material has depth sorting enabled + * \return true If it is the case + */ + inline bool Material::IsDepthSortingEnabled() const { return m_depthSortingEnabled; } + /*! + * \brief Checks whether this material has the render parameter enabled + * \return true If it is the case + * + * \param parameter Parameter for the rendering + * + * \remark Produces a NazaraAssert if enumeration is invalid + */ + inline bool Material::IsEnabled(RendererParameter parameter) const { NazaraAssert(parameter <= RendererParameter_Max, "Renderer parameter out of enum"); @@ -247,41 +492,93 @@ namespace Nz return m_states.parameters[parameter]; } + /*! + * \brief Checks whether this material has lightning enabled + * \return true If it is the case + */ + inline bool Material::IsLightingEnabled() const { return m_lightingEnabled; } + /*! + * \brief Checks whether this material cast shadow + * \return true If it is the case + */ + inline bool Material::IsShadowCastingEnabled() const { return m_shadowCastingEnabled; } + /*! + * \brief Checks whether this material receive shadow + * \return true If it is the case + */ + inline bool Material::IsShadowReceiveEnabled() const { return m_shadowReceiveEnabled; } + /*! + * \brief Checks whether this material has transformation enabled + * \return true If it is the case + */ + inline bool Material::IsTransformEnabled() const { return m_transformEnabled; } + /*! + * \brief Loads the material from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the material + */ + inline bool Material::LoadFromFile(const String& filePath, const MaterialParams& params) { return MaterialLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the material from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the material + */ + inline bool Material::LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params) { return MaterialLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the material from stream + * \return true if loading is successful + * + * \param stream Stream to the material + * \param params Parameters for the material + */ + inline bool Material::LoadFromStream(Stream& stream, const MaterialParams& params) { return MaterialLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Sets the alpha map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetAlphaMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -296,6 +593,15 @@ namespace Nz return true; } + /*! + * \brief Sets the alpha map with a reference to a texture + * \return true If successful + * + * \param alphaMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetAlphaMap(TextureRef alphaMap) { m_alphaMap = std::move(alphaMap); @@ -303,31 +609,69 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the alpha threshold + * + * \param alphaThreshold Threshold for the alpha + */ + inline void Material::SetAlphaThreshold(float alphaThreshold) { m_alphaThreshold = alphaThreshold; } + /*! + * \brief Sets the color for ambient + * + * \param ambient Color for ambient + */ + inline void Material::SetAmbientColor(const Color& ambient) { m_ambientColor = ambient; } + /*! + * \brief Sets the depth functor + * + * \param depthFunc + */ + inline void Material::SetDepthFunc(RendererComparison depthFunc) { m_states.depthFunc = depthFunc; } + /*! + * \brief Sets the depth material + * \return true If successful + * + * \param depthMaterial Material for depth + */ + inline void Material::SetDepthMaterial(MaterialRef depthMaterial) { m_depthMaterial = std::move(depthMaterial); } + /*! + * \brief Sets the color for diffuse + * + * \param diffuse Color for diffuse + */ + inline void Material::SetDiffuseColor(const Color& diffuse) { m_diffuseColor = diffuse; } + /*! + * \brief Sets the diffuse map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetDiffuseMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -342,6 +686,15 @@ namespace Nz return true; } + /*! + * \brief Sets the diffuse map with a reference to a texture + * \return true If successful + * + * \param diffuseMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetDiffuseMap(TextureRef diffuseMap) { m_diffuseMap = std::move(diffuseMap); @@ -349,16 +702,35 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the diffuse sampler + * + * \param sampler Diffuse sample + */ + inline void Material::SetDiffuseSampler(const TextureSampler& sampler) { m_diffuseSampler = sampler; } + /*! + * \brief Sets the dst in blend + * + * \param func Function for dst blending + */ + inline void Material::SetDstBlend(BlendFunc func) { m_states.dstBlend = func; } + /*! + * \brief Sets the emissive map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetEmissiveMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -373,6 +745,15 @@ namespace Nz return true; } + /*! + * \brief Sets the emissive map with a reference to a texture + * \return true If successful + * + * \param emissiveMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetEmissiveMap(TextureRef emissiveMap) { m_emissiveMap = std::move(emissiveMap); @@ -380,16 +761,35 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the face culling + * + * \param faceSide Face to cull + */ + inline void Material::SetFaceCulling(FaceSide faceSide) { m_states.faceCulling = faceSide; } + /*! + * \brief Sets the face filling + * + * \param filling Face to fill + */ + inline void Material::SetFaceFilling(FaceFilling filling) { m_states.faceFilling = filling; } + /*! + * \brief Sets the height map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetHeightMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -404,6 +804,15 @@ namespace Nz return true; } + /*! + * \brief Sets the height map with a reference to a texture + * \return true If successful + * + * \param heightMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetHeightMap(TextureRef heightMap) { m_heightMap = std::move(heightMap); @@ -411,6 +820,13 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the normal map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetNormalMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -425,6 +841,15 @@ namespace Nz return true; } + /*! + * \brief Sets the normal map with a reference to a texture + * \return true If successful + * + * \param normalMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetNormalMap(TextureRef normalMap) { m_normalMap = std::move(normalMap); @@ -432,11 +857,25 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the render states + * + * \param states States for the rendering + */ + inline void Material::SetRenderStates(const RenderStates& states) { m_states = states; } + /*! + * \brief Sets the shader with a constant reference to a ubershader + * + * \param uberShader Uber shader to apply + * + * \remark Invalidates the shaders + */ + inline void Material::SetShader(UberShaderConstRef uberShader) { m_uberShader = std::move(uberShader); @@ -444,6 +883,13 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the shader by name + * \return true If successful + * + * \param uberShaderName Named shader + */ + inline bool Material::SetShader(const String& uberShaderName) { UberShaderConstRef uberShader = UberShaderLibrary::Get(uberShaderName); @@ -454,16 +900,35 @@ namespace Nz return true; } + /*! + * \brief Sets the shininess of the material + * + * \param shininess Value of the shininess + */ + inline void Material::SetShininess(float shininess) { m_shininess = shininess; } + /*! + * \brief Sets the color for specular + * + * \param specular Color + */ + inline void Material::SetSpecularColor(const Color& specular) { m_specularColor = specular; } + /*! + * \brief Sets the specular map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetSpecularMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -478,6 +943,15 @@ namespace Nz return true; } + /*! + * \brief Sets the specular map with a reference to a texture + * \return true If successful + * + * \param specularMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetSpecularMap(TextureRef specularMap) { m_specularMap = std::move(specularMap); @@ -485,16 +959,35 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the specular sampler + * + * \param sampler Specular sample + */ + inline void Material::SetSpecularSampler(const TextureSampler& sampler) { m_specularSampler = sampler; } + /*! + * \brief Sets the src in blend + * + * \param func Function for src blending + */ + inline void Material::SetSrcBlend(BlendFunc func) { m_states.srcBlend = func; } + /*! + * \brief Sets the current material with the content of the other one + * \return A reference to this + * + * \param material The other Material + */ + inline Material& Material::operator=(const Material& material) { Resource::operator=(material); @@ -503,17 +996,33 @@ namespace Nz return *this; } + /*! + * \brief Gets the default material + * \return Reference to the default material + */ + inline MaterialRef Material::GetDefault() { return s_defaultMaterial; } + /*! + * \brief Invalidates the shaders + */ + inline void Material::InvalidateShaders() { for (ShaderInstance& instance : m_shaders) instance.uberInstance = nullptr; } + /*! + * \brief Creates a new material from the arguments + * \return A reference to the newly created material + * + * \param args Arguments for the material + */ + template MaterialRef Material::New(Args&&... args) { diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index b4564d1b8..f119072c8 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -68,8 +68,6 @@ namespace Nz bool SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material); void SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material); virtual void SetMesh(Mesh* mesh); - bool SetSequence(const String& sequenceName); - void SetSequence(unsigned int sequenceIndex); void SetSkin(unsigned int skin); void SetSkinCount(unsigned int skinCount); diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index ea30ebd72..a2b4c3967 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -7,6 +7,13 @@ namespace Nz { + /*! + * \brief Creates a new Model from the arguments + * \return A reference to the newly created model + * + * \param args Arguments for the model + */ + template ModelRef Model::New(Args&&... args) { diff --git a/include/Nazara/Graphics/ParticleDeclaration.hpp b/include/Nazara/Graphics/ParticleDeclaration.hpp index 4fd8b6c33..0edfba85f 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.hpp +++ b/include/Nazara/Graphics/ParticleDeclaration.hpp @@ -62,16 +62,16 @@ namespace Nz /* ** -Lynix: - ** Il serait aussi possible de préciser le stride de façon indépendante, ce que je ne permets pas - ** pour décomplexifier l'interface en enlevant quelque chose que je juge inutile. - ** Si vous pensez que ça peut être utile, n'hésitez pas à me le faire savoir ! + ** It would be also possible to precise the stride by an independant way, what I don't allow + ** to decomplexify the interface of something I consider useless. + ** If you think that could be useful, don't hesitate to make me aware ! */ }; - Component m_components[ParticleComponent_Max+1]; + Component m_components[ParticleComponent_Max + 1]; unsigned int m_stride; - static ParticleDeclaration s_declarations[ParticleLayout_Max+1]; + static ParticleDeclaration s_declarations[ParticleLayout_Max + 1]; static ParticleDeclarationLibrary::LibraryMap s_library; }; } diff --git a/include/Nazara/Graphics/ParticleMapper.inl b/include/Nazara/Graphics/ParticleMapper.inl index a28315312..63c9c49ba 100644 --- a/include/Nazara/Graphics/ParticleMapper.inl +++ b/include/Nazara/Graphics/ParticleMapper.inl @@ -7,10 +7,20 @@ namespace Nz { + /*! + * \brief Gets a pointer to iterate through same components + * \return SparsePtr pointing to same components + * + * \param component Component to get in the declaration + * + * \remark The same components are not continguous but separated by sizeof(ParticleSize) + * \remark Produces a NazaraError if component is disabled + */ + template SparsePtr ParticleMapper::GetComponentPtr(ParticleComponent component) { - // Ensuite le composant qui nous intéresse + // Then the component that are interesting bool enabled; ComponentType type; unsigned int offset; @@ -18,7 +28,7 @@ namespace Nz if (enabled) { - ///TODO: Vérifier le rapport entre le type de l'attribut et le type template ? + ///TODO: Check the ratio between the type of the attribute and the template type ? return SparsePtr(m_ptr + offset, m_declaration->GetStride()); } else @@ -28,10 +38,20 @@ namespace Nz } } + /*! + * \brief Gets a pointer to iterate through same components + * \return SparsePtr pointing to same components + * + * \param component Component to get in the declaration + * + * \remark The same components are not continguous but separated by sizeof(ParticleSize) + * \remark Produces a NazaraError if component is disabled + */ + template SparsePtr ParticleMapper::GetComponentPtr(ParticleComponent component) const { - // Ensuite le composant qui nous intéresse + // Then the component that are interesting bool enabled; ComponentType type; unsigned int offset; @@ -39,7 +59,7 @@ namespace Nz if (enabled) { - ///TODO: Vérifier le rapport entre le type de l'attribut et le type template ? + ///TODO: Check the ratio between the type of the attribute and the template type ? return SparsePtr(m_ptr + offset, m_declaration->GetStride()); } else diff --git a/include/Nazara/Graphics/Renderable.inl b/include/Nazara/Graphics/Renderable.inl index ed445ec96..9a69329a5 100644 --- a/include/Nazara/Graphics/Renderable.inl +++ b/include/Nazara/Graphics/Renderable.inl @@ -4,17 +4,31 @@ namespace Nz { + /*! + * \brief Ensures that the bounding volume is up to date + */ + inline void Renderable::EnsureBoundingVolumeUpdated() const { if (!m_boundingVolumeUpdated) UpdateBoundingVolume(); } + /*! + * \brief Invalidates the bounding volume + */ + inline void Renderable::InvalidateBoundingVolume() { m_boundingVolumeUpdated = false; } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + */ + inline void Renderable::UpdateBoundingVolume() const { MakeBoundingVolume(); diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 8edb694c9..6171f1e28 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -7,31 +7,62 @@ namespace Nz { + /*! + * \brief Gets the movement offset + * \return Offset of the movement + */ + inline const Vector3f& Nz::SkyboxBackground::GetMovementOffset() const { return m_movementOffset; } + /*! + * \brief Gets the movement scale + * \return Scale of the movement + */ + inline float SkyboxBackground::GetMovementScale() const { return m_movementScale; } + /*! + * \brief Gets the texture of the background + * \return Texture of the background + */ + inline const TextureRef& SkyboxBackground::GetTexture() const { return m_texture; } + /*! + * \brief Gets the texture sampler of the background + * \return A reference to the texture sampler of the background + */ + inline TextureSampler& SkyboxBackground::GetTextureSampler() { return m_sampler; } + /*! + * \brief Gets the texture sampler of the background + * \return A constant reference to the texture sampler of the background + */ + inline const TextureSampler& SkyboxBackground::GetTextureSampler() const { return m_sampler; } + /*! + * \brief Sets the movement offset + * + * \param offset Offset of the movement + */ + inline void SkyboxBackground::SetMovementOffset(const Vector3f& offset) { NazaraAssert(std::isfinite(offset.x) && std::isfinite(offset.y) && std::isfinite(offset.z), "Offset must be a finite vector"); @@ -39,6 +70,12 @@ namespace Nz m_movementOffset = offset; } + /*! + * \brief Sets the movement scale + * + * \param scale Scale of the movement + */ + inline void SkyboxBackground::SetMovementScale(float scale) { NazaraAssert(std::isfinite(scale), "Scale must be a finite value"); @@ -46,6 +83,12 @@ namespace Nz m_movementScale = scale; } + /*! + * \brief Sets the texture of the background + * + * \param cubemapTexture Texture of the background + */ + inline void SkyboxBackground::SetTexture(TextureRef cubemapTexture) { NazaraAssert(!cubemapTexture || cubemapTexture->IsValid(), "Invalid texture"); @@ -54,11 +97,24 @@ namespace Nz m_texture = std::move(cubemapTexture); } + /*! + * \brief Sets the texture sampler of the background + * + * \param sampler Texture sampler of the background + */ + void SkyboxBackground::SetTextureSampler(const TextureSampler& sampler) { m_sampler = sampler; } + /*! + * \brief Creates a new skybox background from the arguments + * \return A reference to the newly created skybox background + * + * \param args Arguments for the skybox background + */ + template SkyboxBackgroundRef SkyboxBackground::New(Args&&... args) { diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 8969cddf0..840a930e6 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -8,6 +8,10 @@ namespace Nz { + /*! + * \brief Constructs a Sprite object by default + */ + inline Sprite::Sprite() : m_color(Color::White), m_textureCoords(0.f, 0.f, 1.f, 1.f), @@ -16,6 +20,12 @@ namespace Nz SetDefaultMaterial(); } + /*! + * \brief Constructs a Sprite object with a reference to a material + * + * \param material Reference to a material + */ + inline Sprite::Sprite(MaterialRef material) : m_color(Color::White), m_textureCoords(0.f, 0.f, 1.f, 1.f), @@ -24,6 +34,12 @@ namespace Nz SetMaterial(std::move(material), true); } + /*! + * \brief Constructs a Sprite object with a pointer to a texture + * + * \param texture Pointer to a texture + */ + inline Sprite::Sprite(Texture* texture) : m_color(Color::White), m_textureCoords(0.f, 0.f, 1.f, 1.f), @@ -32,6 +48,12 @@ namespace Nz SetTexture(texture, true); } + /*! + * \brief Constructs a Sprite object by assignation + * + * \param sprite Sprite to copy into this + */ + inline Sprite::Sprite(const Sprite& sprite) : InstancedRenderable(sprite), m_color(sprite.m_color), @@ -41,26 +63,52 @@ namespace Nz { } + /*! + * \brief Gets the color of the sprite + * \return Current color + */ + inline const Color& Sprite::GetColor() const { return m_color; } + /*! + * \brief Gets the material of the sprite + * \return Current material + */ + inline const MaterialRef& Sprite::GetMaterial() const { return m_material; } + /*! + * \brief Gets the size of the sprite + * \return Current size + */ + inline const Vector2f& Sprite::GetSize() const { return m_size; } + /*! + * \brief Gets the texture coordinates of the sprite + * \return Current texture coordinates + */ + inline const Rectf& Sprite::GetTextureCoords() const { return m_textureCoords; } + /*! + * \brief Sets the color of the billboard + * + * \param color Color for the billboard + */ + inline void Sprite::SetColor(const Color& color) { m_color = color; @@ -68,6 +116,10 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets the default material of the sprite (just default material) + */ + inline void Sprite::SetDefaultMaterial() { MaterialRef material = Material::New(); @@ -77,6 +129,13 @@ namespace Nz SetMaterial(std::move(material)); } + /*! + * \brief Sets the material of the sprite + * + * \param material Material for the sprite + * \param resizeSprite Should sprite be resized to the material size (diffuse map) + */ + inline void Sprite::SetMaterial(MaterialRef material, bool resizeSprite) { m_material = std::move(material); @@ -88,6 +147,12 @@ namespace Nz } } + /*! + * \brief Sets the size of the sprite + * + * \param size Size for the sprite + */ + inline void Sprite::SetSize(const Vector2f& size) { m_size = size; @@ -97,11 +162,25 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets the size of the sprite + * + * \param sizeX Size in X for the sprite + * \param sizeY Size in Y for the sprite + */ + inline void Sprite::SetSize(float sizeX, float sizeY) { SetSize(Vector2f(sizeX, sizeY)); } + /*! + * \brief Sets the texture of the sprite + * + * \param texture Texture for the sprite + * \param resizeSprite Should sprite be resized to the texture size + */ + inline void Sprite::SetTexture(TextureRef texture, bool resizeSprite) { if (!m_material) @@ -115,12 +194,27 @@ namespace Nz m_material->SetDiffuseMap(std::move(texture)); } + /*! + * \brief Sets the texture coordinates of the sprite + * + * \param coords Texture coordinates + */ + inline void Sprite::SetTextureCoords(const Rectf& coords) { m_textureCoords = coords; InvalidateVertices(); } + /*! + * \brief Sets the texture rectangle of the sprite + * + * \param rect Rectangles symbolizing the size of the texture + * + * \remark Produces a NazaraAssert if material is invalid + * \remark Produces a NazaraAssert if material has no diffuse map + */ + inline void Sprite::SetTextureRect(const Rectui& rect) { NazaraAssert(m_material, "Sprite has no material"); @@ -128,12 +222,19 @@ namespace Nz Texture* diffuseMap = m_material->GetDiffuseMap(); - float invWidth = 1.f/diffuseMap->GetWidth(); - float invHeight = 1.f/diffuseMap->GetHeight(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); - SetTextureCoords(Rectf(invWidth*rect.x, invHeight*rect.y, invWidth*rect.width, invHeight*rect.height)); + SetTextureCoords(Rectf(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height)); } + /*! + * \brief Sets the current sprite with the content of the other one + * \return A reference to this + * + * \param sprite The other Sprite + */ + inline Sprite& Sprite::operator=(const Sprite& sprite) { InstancedRenderable::operator=(sprite); @@ -143,18 +244,29 @@ namespace Nz m_textureCoords = sprite.m_textureCoords; m_size = sprite.m_size; - // On ne copie pas les sommets finaux car il est très probable que nos paramètres soient modifiés et qu'ils doivent être régénérés de toute façon + // We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated InvalidateBoundingVolume(); InvalidateVertices(); return *this; } + /*! + * \brief Invalidates the vertices + */ + inline void Sprite::InvalidateVertices() { InvalidateInstanceData(0); } + /*! + * \brief Creates a new sprite from the arguments + * \return A reference to the newly created sprite + * + * \param args Arguments for the sprite + */ + template SpriteRef Sprite::New(Args&&... args) { diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index 312658557..baeeb50db 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a TextSprite object by default + */ + inline TextSprite::TextSprite() : m_color(Color::White), m_scale(1.f) @@ -14,12 +18,24 @@ namespace Nz SetDefaultMaterial(); } + /*! + * \brief Constructs a TextSprite object with a drawer + * + * \param drawer Drawer used to compose text on the sprite + */ + inline TextSprite::TextSprite(const AbstractTextDrawer& drawer) : TextSprite() { Update(drawer); } + /*! + * \brief Constructs a TextSprite object by assignation + * + * \param sprite TextSprite to copy into this + */ + inline TextSprite::TextSprite(const TextSprite& sprite) : InstancedRenderable(sprite), m_renderInfos(sprite.m_renderInfos), @@ -40,6 +56,10 @@ namespace Nz } } + /*! + * \brief Clears the data + */ + inline void TextSprite::Clear() { m_atlases.clear(); @@ -48,21 +68,42 @@ namespace Nz m_renderInfos.clear(); } + /*! + * \brief Gets the color of the text sprite + * \return Current color + */ + inline const Color& TextSprite::GetColor() const { return m_color; } + /*! + * \brief Gets the material of the text sprite + * \return Current material + */ + inline const MaterialRef& TextSprite::GetMaterial() const { return m_material; } + /*! + * \brief Gets the current scale of the text sprite + * \return Current scale + */ + inline float TextSprite::GetScale() const { return m_scale; } + /*! + * \brief Sets the color of the text sprite + * + * \param color Color for the text sprite + */ + inline void TextSprite::SetColor(const Color& color) { m_color = color; @@ -70,6 +111,11 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets the default material of the text sprite (just default material) + */ + + inline void TextSprite::SetDefaultMaterial() { MaterialRef material = Material::New(); @@ -83,11 +129,23 @@ namespace Nz SetMaterial(material); } + /*! + * \brief Sets the material of the text sprite + * + * \param material Material for the text sprite + */ + inline void TextSprite::SetMaterial(MaterialRef material) { m_material = std::move(material); } + /*! + * \brief Sets the current scale of the text sprite + * + * \param scale Scale of the text sprite + */ + inline void TextSprite::SetScale(float scale) { m_scale = scale; @@ -95,10 +153,12 @@ namespace Nz InvalidateVertices(); } - inline void TextSprite::InvalidateVertices() - { - InvalidateInstanceData(0); - } + /*! + * \brief Sets the current text sprite with the content of the other one + * \return A reference to this + * + * \param text sprite The other TextSprite + */ inline TextSprite& TextSprite::operator=(const TextSprite& text) { @@ -130,6 +190,22 @@ namespace Nz return *this; } + /*! + * \brief Invalidates the vertices + */ + + inline void TextSprite::InvalidateVertices() + { + InvalidateInstanceData(0); + } + + /*! + * \brief Creates a new text sprite from the arguments + * \return A reference to the newly created text sprite + * + * \param args Arguments for the text sprite + */ + template TextSpriteRef TextSprite::New(Args&&... args) { diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index c40ad3d2d..31067f36c 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -7,11 +7,22 @@ namespace Nz { + /*! + * \brief Gets the texture of the background + * \return Texture of the background + */ + inline const TextureRef& TextureBackground::GetTexture() const { return m_texture; } + /*! + * \brief Sets the texture of the background + * + * \param texture Texture of the background + */ + inline void TextureBackground::SetTexture(TextureRef texture) { NazaraAssert(!texture || texture->IsValid(), "Invalid texture"); @@ -19,6 +30,13 @@ namespace Nz m_texture = std::move(texture); } + /*! + * \brief Creates a new texture background from the arguments + * \return A reference to the newly created texture background + * + * \param args Arguments for the texture background + */ + template TextureBackgroundRef TextureBackground::New(Args&&... args) { diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index b9f56c1e1..71f385cac 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -491,8 +491,8 @@ namespace Nz * * \remark If volume is infinite, IntersectionSide_Intersecting is returned * \remark If volume is null, IntersectionSide_Outside is returned - * \remark If enumeration of the volume is not defined in Extend, a NazaraError is thrown and false is returned - * \remark If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and false is returned. This should not never happen for a user of the library + * \remark If enumeration of the volume is not defined in Extend, a NazaraError is thrown and IntersectionSide_Outside is returned + * \remark If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and IntersectionSide_Outside is returned. This should not never happen for a user of the library */ template diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index b87bd51a7..0a8d1adae 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -485,7 +485,7 @@ namespace Nz template T Sphere::SquaredDistance(const Vector3& point) const { - return Vector3f::Distance(point, GetPosition()) - radius * radius; + return Vector3f::SquaredDistance(point, GetPosition() + (point - GetPosition()).Normalize() * radius); } /*! diff --git a/src/Nazara/Graphics/AbstractBackground.cpp b/src/Nazara/Graphics/AbstractBackground.cpp index 628819edd..28d0f0d4f 100644 --- a/src/Nazara/Graphics/AbstractBackground.cpp +++ b/src/Nazara/Graphics/AbstractBackground.cpp @@ -7,6 +7,14 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractBackground + * \brief Graphics class that represents the background for our scene + * + * \remark This class is abstract + */ + AbstractBackground::~AbstractBackground() = default; BackgroundLibrary::LibraryMap AbstractBackground::s_library; diff --git a/src/Nazara/Graphics/AbstractRenderQueue.cpp b/src/Nazara/Graphics/AbstractRenderQueue.cpp index d00816f85..1346e37ff 100644 --- a/src/Nazara/Graphics/AbstractRenderQueue.cpp +++ b/src/Nazara/Graphics/AbstractRenderQueue.cpp @@ -7,23 +7,55 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractRenderQueue + * \brief Graphics class that represents the rendering queue for our scene + * + * \remark This class is abstract + */ + AbstractRenderQueue::~AbstractRenderQueue() = default; + /*! + * \brief Adds a directional light to the rendering queue + * + * \param light Directional light + */ + void AbstractRenderQueue::AddDirectionalLight(const DirectionalLight& light) { directionalLights.push_back(light); } + /*! + * \brief Adds a point light to the rendering queue + * + * \param light Point light + */ + void AbstractRenderQueue::AddPointLight(const PointLight& light) { pointLights.push_back(light); } + /*! + * \brief Adds a spot light to the rendering queue + * + * \param light Spot light + */ + void AbstractRenderQueue::AddSpotLight(const SpotLight& light) { spotLights.push_back(light); } + /*! + * \brief Clears the rendering queue + * + * \param fully Should everything be cleared ? + */ + void AbstractRenderQueue::Clear(bool fully) { NazaraUnused(fully); diff --git a/src/Nazara/Graphics/AbstractRenderTechnique.cpp b/src/Nazara/Graphics/AbstractRenderTechnique.cpp index 11d894a00..9872178cf 100644 --- a/src/Nazara/Graphics/AbstractRenderTechnique.cpp +++ b/src/Nazara/Graphics/AbstractRenderTechnique.cpp @@ -10,6 +10,18 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractRenderTechnique + * \brief Graphics class that represents the rendering technique for our scene + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a AbstractRenderTechnique object + */ + AbstractRenderTechnique::AbstractRenderTechnique() : m_instancingEnabled(true) { @@ -17,16 +29,34 @@ namespace Nz AbstractRenderTechnique::~AbstractRenderTechnique() = default; + /*! + * \brief Enables the instancing + * + * \param instancing Should instancing be enabled + * + * \remark This may improve performances + */ + void AbstractRenderTechnique::EnableInstancing(bool instancing) { m_instancingEnabled = instancing; } + /*! + * \brief Gets the name of the actual technique + * \return Name of the technique being used + */ + String AbstractRenderTechnique::GetName() const { return RenderTechniques::ToString(GetType()); } + /*! + * \brief Checks whether the instancing is enabled + * \return true If it is the case + */ + bool AbstractRenderTechnique::IsInstancingEnabled() const { return m_instancingEnabled; diff --git a/src/Nazara/Graphics/AbstractViewer.cpp b/src/Nazara/Graphics/AbstractViewer.cpp index cc9a4b96a..bd8752bc7 100644 --- a/src/Nazara/Graphics/AbstractViewer.cpp +++ b/src/Nazara/Graphics/AbstractViewer.cpp @@ -7,5 +7,13 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractViewer + * \brief Graphics class that represents the viewer for our scene + * + * \remark This class is abstract + */ + AbstractViewer::~AbstractViewer() = default; } diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 3e5173c89..6f47e9847 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -12,6 +12,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Billboard + * \brief Graphics class that represents a billboard, a 2D surface which simulates a 3D object + */ + + /*! + * \brief Adds this billboard to the render queue + * + * \param renderQueue Queue to be added + * \param instanceData Data used for instance + */ + void Billboard::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_material) @@ -20,11 +33,15 @@ namespace Nz renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix.GetTranslation(), m_size, m_sinCos, m_color); } + /* + * \brief Makes the bounding volume of this billboard + */ + void Billboard::MakeBoundingVolume() const { constexpr float sqrt2 = float(M_SQRT2); - m_boundingVolume.Set(Vector3f(0.f), sqrt2*m_size.x*Vector3f::Right() + sqrt2*m_size.y*Vector3f::Down()); + m_boundingVolume.Set(Vector3f(0.f), sqrt2 * m_size.x * Vector3f::Right() + sqrt2 * m_size.y * Vector3f::Down()); } BillboardLibrary::LibraryMap Billboard::s_library; diff --git a/src/Nazara/Graphics/ColorBackground.cpp b/src/Nazara/Graphics/ColorBackground.cpp index 76f717858..33c282390 100644 --- a/src/Nazara/Graphics/ColorBackground.cpp +++ b/src/Nazara/Graphics/ColorBackground.cpp @@ -11,6 +11,11 @@ namespace Nz { namespace { + /*! + * \brief Defines render states + * \return RenderStates for the color background + */ + RenderStates BuildRenderStates() { RenderStates states; @@ -24,6 +29,18 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::ColorBackground + * \brief Graphics class that represents a background with uniform color + */ + + /*! + * \brief Constructs a ColorBackground object with a color + * + * \param color Uniform color (by default Black) + */ + ColorBackground::ColorBackground(const Color& color) : m_color(color) { @@ -38,6 +55,12 @@ namespace Nz m_vertexDepthUniform = shader->GetUniformLocation("VertexDepth"); } + /*! + * \brief Draws this relatively to the viewer + * + * \param viewer Viewer for the background + */ + void ColorBackground::Draw(const AbstractViewer* viewer) const { NazaraUnused(viewer); @@ -55,16 +78,32 @@ namespace Nz Renderer::DrawFullscreenQuad(); } + /*! + * \brief Gets the background type + * \return Type of background + */ + BackgroundType ColorBackground::GetBackgroundType() const { return BackgroundType_Color; } + /*! + * \brief Gets the color of the background + * \return Background color + */ + Color ColorBackground::GetColor() const { return m_color; } + /*! + * \brief Sets the color of the background + * + * \param color Background color + */ + void ColorBackground::SetColor(const Color& color) { m_color = color; diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index 0fc80e750..c902c7615 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -9,6 +9,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredBloomPass + * \brief Graphics class that represents the pass for bloom in deferred rendering + */ + + /*! + * \brief Constructs a DeferredBloomPass object by default + */ + DeferredBloomPass::DeferredBloomPass() : m_uniformUpdated(false), m_brightLuminance(0.8f), @@ -32,26 +42,55 @@ namespace Nz DeferredBloomPass::~DeferredBloomPass() = default; + /*! + * \brief Gets the number of pass for blur + * \return Number of pass for blur + */ + unsigned int DeferredBloomPass::GetBlurPassCount() const { return m_blurPassCount; } + /*! + * \brief Gets the coefficiant for luminosity + * \return Luminosity of bright elements + */ + float DeferredBloomPass::GetBrightLuminance() const { return m_brightLuminance; } + /*! + * \brief Gets the coefficiant for the middle grey + * \return Luminosity of grey elements + */ + float DeferredBloomPass::GetBrightMiddleGrey() const { return m_brightMiddleGrey; } + /*! + * \brief Gets the coefficiant for things to be bright + * \return Threshold for bright elements + */ + float DeferredBloomPass::GetBrightThreshold() const { return m_brightThreshold; } + /*! + * \brief Gets the ith texture + * \return Texture computed + * + * \param i Index of the texture + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if index is invalid + */ + Texture* DeferredBloomPass::GetTexture(unsigned int i) const { #if NAZARA_GRAPHICS_SAFE @@ -65,7 +104,16 @@ namespace Nz return m_bloomTextures[i]; } - bool DeferredBloomPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredBloomPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraUnused(sceneData); @@ -91,7 +139,7 @@ namespace Nz Renderer::DrawFullscreenQuad(); Renderer::SetTarget(&m_bloomRTT); - Renderer::SetViewport(Recti(0, 0, m_dimensions.x/8, m_dimensions.y/8)); + Renderer::SetViewport(Recti(0, 0, m_dimensions.x / 8, m_dimensions.y / 8)); Renderer::SetShader(m_gaussianBlurShader); @@ -124,6 +172,13 @@ namespace Nz return true; } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredBloomPass::Resize(const Vector2ui& dimensions) { DeferredRenderPass::Resize(dimensions); @@ -131,7 +186,7 @@ namespace Nz m_bloomRTT.Create(true); for (unsigned int i = 0; i < 2; ++i) { - m_bloomTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x/8, dimensions.y/8); + m_bloomTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x / 8, dimensions.y / 8); m_bloomRTT.AttachTexture(AttachmentPoint_Color, i, m_bloomTextures[i]); } m_bloomRTT.Unlock(); @@ -145,23 +200,47 @@ namespace Nz return true; } + /*! + * \brief Sets the number of pass for blur + * + * \param passCount Number of pass for blur + */ + void DeferredBloomPass::SetBlurPassCount(unsigned int passCount) { m_blurPassCount = passCount; // N'est pas une uniforme } + /*! + * \brief Sets the coefficiant for luminosity + * + * \param luminance Luminosity of bright elements + */ + void DeferredBloomPass::SetBrightLuminance(float luminance) { m_brightLuminance = luminance; m_uniformUpdated = false; } + /*! + * \brief Sets the coefficiant for the middle grey + * + * \param middleGrey Luminosity of grey elements + */ + void DeferredBloomPass::SetBrightMiddleGrey(float middleGrey) { m_brightMiddleGrey = middleGrey; m_uniformUpdated = false; } + /*! + * \brief Sets the coefficiant for things to be bright + * + * \param threshold Threshold for bright elements + */ + void DeferredBloomPass::SetBrightThreshold(float threshold) { m_brightThreshold = threshold; diff --git a/src/Nazara/Graphics/DeferredDOFPass.cpp b/src/Nazara/Graphics/DeferredDOFPass.cpp index f29529749..63df2c400 100644 --- a/src/Nazara/Graphics/DeferredDOFPass.cpp +++ b/src/Nazara/Graphics/DeferredDOFPass.cpp @@ -13,6 +13,10 @@ namespace Nz { namespace { + /*! + * \brief Builds the shader for the depth of field + * \return Reference to the shader newly created + */ // http://digitalerr0r.wordpress.com/2009/05/16/xna-shader-programming-tutorial-20-depth-of-field/ ShaderRef BuildDepthOfFieldShader() { @@ -92,6 +96,16 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::DeferredDOFPass + * \brief Graphics class that represents the pass for depth of field in deferred rendering + */ + + /*! + * \brief Constructs a DeferredDOFPass object by default + */ + DeferredDOFPass::DeferredDOFPass() { m_dofShader = BuildDepthOfFieldShader(); @@ -118,7 +132,16 @@ namespace Nz DeferredDOFPass::~DeferredDOFPass() = default; - bool DeferredDOFPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredDOFPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraUnused(sceneData); @@ -162,6 +185,13 @@ namespace Nz return true; } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredDOFPass::Resize(const Vector2ui& dimensions) { DeferredRenderPass::Resize(dimensions); @@ -181,5 +211,5 @@ namespace Nz } return true; -} + } } diff --git a/src/Nazara/Graphics/DeferredFXAAPass.cpp b/src/Nazara/Graphics/DeferredFXAAPass.cpp index 3a300392a..3f1e9395a 100644 --- a/src/Nazara/Graphics/DeferredFXAAPass.cpp +++ b/src/Nazara/Graphics/DeferredFXAAPass.cpp @@ -10,6 +10,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredFXAAPass + * \brief Graphics class that represents the pass for FXAA in deferred rendering + */ + + /*! + * \brief Constructs a DeferredFXAAPass object by default + */ + DeferredFXAAPass::DeferredFXAAPass() { m_fxaaShader = ShaderLibrary::Get("DeferredFXAA"); @@ -23,7 +33,16 @@ namespace Nz DeferredFXAAPass::~DeferredFXAAPass() = default; - bool DeferredFXAAPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredFXAAPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraUnused(sceneData); diff --git a/src/Nazara/Graphics/DeferredFinalPass.cpp b/src/Nazara/Graphics/DeferredFinalPass.cpp index 6ca1e72c4..091c95af6 100644 --- a/src/Nazara/Graphics/DeferredFinalPass.cpp +++ b/src/Nazara/Graphics/DeferredFinalPass.cpp @@ -10,6 +10,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredFinalPass + * \brief Graphics class that represents the final pass in deferred rendering + */ + + /*! + * \brief Constructs a DeferredFinalPass object by default + */ + DeferredFinalPass::DeferredFinalPass() { m_pointSampler.SetAnisotropyLevel(1); @@ -34,7 +44,16 @@ namespace Nz DeferredFinalPass::~DeferredFinalPass() = default; - bool DeferredFinalPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredFinalPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); diff --git a/src/Nazara/Graphics/DeferredFogPass.cpp b/src/Nazara/Graphics/DeferredFogPass.cpp index af00a7c1d..f64521daf 100644 --- a/src/Nazara/Graphics/DeferredFogPass.cpp +++ b/src/Nazara/Graphics/DeferredFogPass.cpp @@ -13,6 +13,11 @@ namespace Nz { namespace { + /*! + * \brief Builds the shader for the fog + * \return Reference to the shader newly created + */ + ShaderRef BuildFogShader() { /*const UInt8 fragmentSource[] = { @@ -117,6 +122,16 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::DeferredFogPass + * \brief Graphics class that represents the pass for fog in deferred rendering + */ + + /*! + * \brief Constructs a DeferredFogPass object by default + */ + DeferredFogPass::DeferredFogPass() { m_pointSampler.SetAnisotropyLevel(1); @@ -131,7 +146,16 @@ namespace Nz DeferredFogPass::~DeferredFogPass() = default; - bool DeferredFogPass::Process( const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredFogPass::Process( const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); diff --git a/src/Nazara/Graphics/DeferredForwardPass.cpp b/src/Nazara/Graphics/DeferredForwardPass.cpp index 35daabae8..ed7ad45d1 100644 --- a/src/Nazara/Graphics/DeferredForwardPass.cpp +++ b/src/Nazara/Graphics/DeferredForwardPass.cpp @@ -13,9 +13,21 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredForwardPass + * \brief Graphics class that represents the forward pass in deferred rendering + */ + DeferredForwardPass::DeferredForwardPass() = default; DeferredForwardPass::~DeferredForwardPass() = default; + /*! + * \brief Initializes the deferred forward pass which needs the forward technique + * + * \param technique Rendering technique + */ + void DeferredForwardPass::Initialize(DeferredRenderTechnique* technique) { DeferredRenderPass::Initialize(technique); @@ -23,7 +35,16 @@ namespace Nz m_forwardTechnique = technique->GetForwardTechnique(); } - bool DeferredForwardPass::Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredForwardPass::Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); NazaraUnused(workTexture); diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 2ae39ed9b..08b111a70 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -18,6 +18,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredGeometryPass + * \brief Graphics class that represents the pass for geometries in deferred rendering + */ + + /*! + * \brief Constructs a DeferredGeometryPass object by default + */ + DeferredGeometryPass::DeferredGeometryPass() { m_clearShader = ShaderLibrary::Get("DeferredGBufferClear"); @@ -31,7 +41,16 @@ namespace Nz DeferredGeometryPass::~DeferredGeometryPass() = default; - bool DeferredGeometryPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return false + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredGeometryPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); NazaraUnused(firstWorkTexture); @@ -72,22 +91,22 @@ namespace Nz bool useInstancing = instancingEnabled && matEntry.instancingEnabled; - // On commence par récupérer le programme du matériau + // We begin by getting the program for materials UInt32 flags = ShaderFlags_Deferred; if (useInstancing) flags |= ShaderFlags_Instancing; const Shader* shader = material->Apply(flags); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // The uniforms are conserved in our program, there's no point to send them back if they don't change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambient color for the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; @@ -105,7 +124,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before rendering loop Renderer::DrawCall drawFunc; Renderer::DrawCallInstanced instancedDrawFunc; unsigned int indexCount; @@ -128,33 +147,33 @@ namespace Nz if (useInstancing) { - // On récupère le buffer d'instancing du Renderer et on le configure pour fonctionner avec des matrices + // We get the buffer for instance of Renderer and we configure it to work with matrices VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); const Matrix4f* instanceMatrices = &instances[0]; unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Le nombre de matrices que peut contenir le buffer + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer while (instanceCount > 0) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to show this time (Depending on the instance buffer size) unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); instanceCount -= renderedInstanceCount; - // On remplit l'instancing buffer avec nos matrices world + // We fill the instancing buffer with our world matrices instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); instanceMatrices += renderedInstanceCount; - // Et on affiche + // And we show instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); } } else { - // Sans instancing, on doit effectuer un draw call pour chaque instance - // Cela reste néanmoins plus rapide que l'instancing en dessous d'un certain nombre d'instances - // À cause du temps de modification du buffer d'instancing + // Without instancing, we must do one draw call for each instance + // This may be faster than instancing under a threshold + // Due to the time to modify the instancing buffer for (const Matrix4f& matrix : instances) { Renderer::SetMatrix(MatrixType_World, matrix); @@ -167,16 +186,23 @@ namespace Nz } } - // Et on remet à zéro les données + // Abd we set it back data to zero matEntry.enabled = false; matEntry.instancingEnabled = false; } } } - return false; // On ne fait que remplir le G-Buffer, les work texture ne sont pas affectées + return false; // We only fill the G-Buffer, the work texture are unchanged } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredGeometryPass::Resize(const Vector2ui& dimensions) { DeferredRenderPass::Resize(dimensions); @@ -241,6 +267,13 @@ namespace Nz } } + /*! + * \brief Gets the uniforms of a shader + * \return Uniforms of the shader + * + * \param shader Shader to get uniforms from + */ + const DeferredGeometryPass::ShaderUniforms* DeferredGeometryPass::GetShaderUniforms(const Shader* shader) const { auto it = m_shaderUniforms.find(shader); @@ -260,6 +293,12 @@ namespace Nz return &it->second; } + /*! + * \brief Handle the invalidation of a shader + * + * \param shader Shader being invalidated + */ + void DeferredGeometryPass::OnShaderInvalidated(const Shader* shader) const { m_shaderUniforms.erase(shader); diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index c340d89a2..efcc88e75 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -13,6 +13,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredPhongLightingPass + * \brief Graphics class that represents the pass for phong lighting in deferred rendering + */ + + /*! + * \brief Constructs a DeferredPhongLightingPass object by default + */ + DeferredPhongLightingPass::DeferredPhongLightingPass() : m_lightMeshesDrawing(false) { @@ -21,7 +31,7 @@ namespace Nz m_directionalLightShaderSceneAmbientLocation = m_directionalLightShader->GetUniformLocation("SceneAmbient"); m_directionalLightUniforms.ubo = false; - m_directionalLightUniforms.locations.type = -1; // Type déjà connu + m_directionalLightUniforms.locations.type = -1; // Type already known m_directionalLightUniforms.locations.color = m_directionalLightShader->GetUniformLocation("LightColor"); m_directionalLightUniforms.locations.factors = m_directionalLightShader->GetUniformLocation("LightFactors"); m_directionalLightUniforms.locations.parameters1 = m_directionalLightShader->GetUniformLocation("LightDirection"); @@ -56,16 +66,36 @@ namespace Nz DeferredPhongLightingPass::~DeferredPhongLightingPass() = default; + /*! + * \brief Enables the drawing of meshes with light + * + * \param enable Should meshes with light parameter be drawed + */ + void DeferredPhongLightingPass::EnableLightMeshesDrawing(bool enable) { m_lightMeshesDrawing = enable; } + /*! + * \brief Checks whether the drawing of meshes with light is enabled + * \return true If it is the case + */ + bool DeferredPhongLightingPass::IsLightMeshesDrawingEnabled() const { return m_lightMeshesDrawing; } + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + bool DeferredPhongLightingPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -151,12 +181,12 @@ namespace Nz m_pointSpotLightShader->SendVector(m_pointSpotLightUniforms.locations.parameters1, Vector4f(light.position, light.attenuation)); m_pointSpotLightShader->SendVector(m_pointSpotLightUniforms.locations.parameters2, Vector4f(0.f, 0.f, 0.f, light.invRadius)); - lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // Pour corriger les imperfections liées à la sphère + lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // To correct imperfections due to the sphere lightMatrix.SetTranslation(light.position); Renderer::SetMatrix(MatrixType_World, lightMatrix); - // Rendu de la sphère dans le stencil buffer + // Sphere rendering in the stencil buffer Renderer::Enable(RendererParameter_ColorWrite, false); Renderer::Enable(RendererParameter_DepthBuffer, true); Renderer::Enable(RendererParameter_FaceCulling, false); @@ -166,7 +196,7 @@ namespace Nz Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, indexBuffer->GetIndexCount()); - // Rendu de la sphère comme zone d'effet + // Sphere rendering as effect zone Renderer::Enable(RendererParameter_ColorWrite, true); Renderer::Enable(RendererParameter_DepthBuffer, false); Renderer::Enable(RendererParameter_FaceCulling, true); @@ -192,7 +222,7 @@ namespace Nz Renderer::SetShader(shader); for (const auto& light : m_renderQueue->pointLights) { - lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // Pour corriger les imperfections liées à la sphère + lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // To correct imperfections due to the sphere lightMatrix.SetTranslation(light.position); Renderer::SetMatrix(MatrixType_World, lightMatrix); @@ -230,7 +260,7 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, lightMatrix); - // Rendu de la sphère dans le stencil buffer + // Sphere rendering in the stencil buffer Renderer::Enable(RendererParameter_ColorWrite, false); Renderer::Enable(RendererParameter_DepthBuffer, true); Renderer::Enable(RendererParameter_FaceCulling, false); @@ -240,7 +270,7 @@ namespace Nz Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, indexBuffer->GetIndexCount()); - // Rendu de la sphère comme zone d'effet + // Sphere rendering as effect zone Renderer::Enable(RendererParameter_ColorWrite, true); Renderer::Enable(RendererParameter_DepthBuffer, false); Renderer::Enable(RendererParameter_FaceCulling, true); diff --git a/src/Nazara/Graphics/DeferredRenderPass.cpp b/src/Nazara/Graphics/DeferredRenderPass.cpp index 8d688c871..da40c01da 100644 --- a/src/Nazara/Graphics/DeferredRenderPass.cpp +++ b/src/Nazara/Graphics/DeferredRenderPass.cpp @@ -9,6 +9,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredRenderPass + * \brief Graphics class that represents the pass for rendering in deferred rendering + */ + + /*! + * \brief Constructs a DeferredRenderPass object by default + */ + DeferredRenderPass::DeferredRenderPass() : m_enabled(true) { @@ -16,11 +26,23 @@ namespace Nz DeferredRenderPass::~DeferredRenderPass() = default; + /*! + * \brief Enables the deferred rendering + * + * \param enable Should deferred rendering be activated + */ + void DeferredRenderPass::Enable(bool enable) { m_enabled = enable; } + /*! + * \brief Initializes the deferred forward pass which needs the deferred technique + * + * \param technique Rendering technique + */ + void DeferredRenderPass::Initialize(DeferredRenderTechnique* technique) { m_deferredTechnique = technique; @@ -37,11 +59,23 @@ namespace Nz m_workTextures[i] = technique->GetWorkTexture(i); } + /*! + * \brief Checks whether the deferred rendering is enabled + * \return true If it the case + */ + bool DeferredRenderPass::IsEnabled() const { return m_enabled; } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredRenderPass::Resize(const Vector2ui& dimensions) { m_dimensions = dimensions; diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 5bd0931e3..738e7b799 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -8,69 +8,207 @@ #include #include -///TODO: Rendre les billboards via Deferred Shading si possible +///TODO: Render billboards using Deferred Shading if possible namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredRenderQueue + * \brief Graphics class that represents the rendering queue for deferred rendering + */ + + /*! + * \brief Constructs a DeferredRenderQueue object with the rendering queue of forward rendering + * + * \param forwardQueue Queue of data to render + */ + DeferredRenderQueue::DeferredRenderQueue(ForwardRenderQueue* forwardQueue) : m_forwardQueue(forwardQueue) { } + /*! + * \brief Adds billboard to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + * \param position Position of the billboard + * \param size Sizes of the billboard + * \param sinCos Rotation of the billboard + * \param color Color of the billboard + */ + void DeferredRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) { m_forwardQueue->AddBillboard(renderOrder, material, position, size, sinCos, color); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds drawable to the queue + * + * \param renderOrder Order of rendering + * \param drawable Drawable user defined + * + * \remark Produces a NazaraError if drawable is invalid + */ + void DeferredRenderQueue::AddDrawable(int renderOrder, const Drawable* drawable) { m_forwardQueue->AddDrawable(renderOrder, drawable); } + /*! + * \brief Adds mesh to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the mesh + * \param meshData Data of the mesh + * \param meshAABB Box of the mesh + * \param transformMatrix Matrix of the mesh + */ + void DeferredRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { if (material->IsEnabled(RendererParameter_Blend)) - // Un matériau transparent ? J'aime pas, va voir dans la forward queue si j'y suis + // One transparent material ? I don't like it, go see if I'm in the forward queue m_forwardQueue->AddMesh(renderOrder, material, meshData, meshAABB, transformMatrix); else { @@ -103,21 +241,37 @@ namespace Nz it2 = meshMap.insert(std::make_pair(meshData, std::move(instanceEntry))).first; } - // On ajoute la matrice à la liste des instances de cet objet + // We add matrices to the list of instances of this object std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - // Avons-nous suffisamment d'instances pour que le coût d'utilisation de l'instancing soit payé ? + // Do we have enough instances to perform instancing ? if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Apparemment oui, activons l'instancing avec ce matériau + entry.instancingEnabled = true; // Thus we can activate it } } + /*! + * \brief Adds sprites to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the sprites + * \param vertices Buffer of data for the sprites + * \param spriteCount Number of sprites + * \param overlay Texture of the sprites + */ + void DeferredRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { m_forwardQueue->AddSprites(renderOrder, material, vertices, spriteCount, overlay); } + /*! + * \brief Clears the queue + * + * \param fully Should everything be cleared or we can keep layers + */ + void DeferredRenderQueue::Clear(bool fully) { AbstractRenderQueue::Clear(fully); @@ -137,6 +291,13 @@ namespace Nz m_forwardQueue->Clear(fully); } + /*! + * \brief Gets the ith layer + * \return Reference to the ith layer for the queue + * + * \param i Index of the layer + */ + DeferredRenderQueue::Layer& DeferredRenderQueue::GetLayer(unsigned int i) { auto it = layers.find(i); @@ -149,6 +310,12 @@ namespace Nz return layer; } + /*! + * \brief Handle the invalidation of an index buffer + * + * \param indexBuffer Index buffer being invalidated + */ + void DeferredRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer) { for (auto& pair : layers) @@ -170,6 +337,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a material + * + * \param material Material being invalidated + */ + void DeferredRenderQueue::OnMaterialInvalidation(const Material* material) { for (auto& pair : layers) @@ -180,6 +353,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a vertex buffer + * + * \param vertexBuffer Vertex buffer being invalidated + */ + void DeferredRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer) { for (auto& pair : layers) @@ -201,6 +380,14 @@ namespace Nz } } + /*! + * \brief Functor to compare two batched model with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool DeferredRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const { const UberShader* uberShader1 = mat1->GetShader(); @@ -221,6 +408,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two mesh data + * \return true If first mesh is "smaller" than the second one + * + * \param data1 First mesh to compare + * \param data2 Second mesh to compare + */ + bool DeferredRenderQueue::MeshDataComparator::operator()(const MeshData& data1, const MeshData& data2) const { const Buffer* buffer1; diff --git a/src/Nazara/Graphics/DeferredRenderTechnique.cpp b/src/Nazara/Graphics/DeferredRenderTechnique.cpp index 88335d92b..585091406 100644 --- a/src/Nazara/Graphics/DeferredRenderTechnique.cpp +++ b/src/Nazara/Graphics/DeferredRenderTechnique.cpp @@ -77,7 +77,18 @@ namespace Nz 3, // RenderPassType_SSAO }; - static_assert(sizeof(RenderPassPriority)/sizeof(unsigned int) == RenderPassType_Max+1, "Render pass priority array is incomplete"); + static_assert(sizeof(RenderPassPriority) / sizeof(unsigned int) == RenderPassType_Max + 1, "Render pass priority array is incomplete"); + + /*! + * \brief Registers the deferred shader + * \return Reference to the newly created shader + * + * \param name Name of the shader + * \param fragmentSource Raw data to fragment shader + * \param fragmentSourceLength Size of the fragment source + * \param vertexStage Stage of the shader + * \param err Pointer to string to contain error message + */ inline ShaderRef RegisterDeferredShader(const String& name, const UInt8* fragmentSource, unsigned int fragmentSourceLength, const ShaderStage& vertexStage, String* err) { @@ -109,6 +120,18 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::DeferredRenderTechnique + * \brief Graphics class that represents the technique used in deferred rendering + */ + + /*! + * \brief Constructs a DeferredRenderTechnique object by default + * + * \remark Produces a NazaraError if one pass could not be created + */ + DeferredRenderTechnique::DeferredRenderTechnique() : m_renderQueue(static_cast(m_forwardTechnique.GetRenderQueue())), m_GBufferSize(0U) @@ -204,11 +227,27 @@ namespace Nz DeferredRenderTechnique::~DeferredRenderTechnique() = default; + /*! + * \brief Clears the data + * + * \param sceneData Data of the scene + */ + void DeferredRenderTechnique::Clear(const SceneData& sceneData) const { NazaraUnused(sceneData); } + /*! + * \brief Draws the data of the scene + * \return true If successful + * + * \param sceneData Data of the scene + * + * \remark Produces a NazaraAssert if viewer of the scene is invalid + * \remark Produces a NazaraError if updating viewport dimensions failed + */ + bool DeferredRenderTechnique::Draw(const SceneData& sceneData) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -242,6 +281,14 @@ namespace Nz return true; } + /*! + * \brief Enables a pass + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + * \param enable Should the pass be enabled + */ + void DeferredRenderTechnique::EnablePass(RenderPassType renderPass, int position, bool enable) { auto it = m_passes.find(renderPass); @@ -253,11 +300,25 @@ namespace Nz } } + /*! + * \brief Gets the stencil buffer + * \return Pointer to the rendering buffer + */ + RenderBuffer* DeferredRenderTechnique::GetDepthStencilBuffer() const { return m_depthStencilBuffer; } + /*! + * \brief Gets the G-buffer + * \return Pointer to the ith texture + * + * \param i Index of the G-buffer + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if index is invalid + */ + Texture* DeferredRenderTechnique::GetGBuffer(unsigned int i) const { #if NAZARA_GRAPHICS_SAFE @@ -271,16 +332,34 @@ namespace Nz return m_GBuffer[i]; } + /*! + * \brief Gets the rendering texture of the G-buffer + * \return Pointer to the rendering buffer + */ + RenderTexture* DeferredRenderTechnique::GetGBufferRTT() const { return &m_GBufferRTT; } + /*! + * \brief Gets the forward technique + * \return Constant pointer to the forward technique + */ + const ForwardRenderTechnique* DeferredRenderTechnique::GetForwardTechnique() const { return &m_forwardTechnique; } + /*! + * \brief Gets the pass + * \return Pointer to the deferred render pass + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + */ + DeferredRenderPass* DeferredRenderTechnique::GetPass(RenderPassType renderPass, int position) { auto it = m_passes.find(renderPass); @@ -294,21 +373,45 @@ namespace Nz return nullptr; } + /*! + * \brief Gets the render queue + * \return Pointer to the render queue + */ + AbstractRenderQueue* DeferredRenderTechnique::GetRenderQueue() { return &m_renderQueue; } + /*! + * \brief Gets the type of the current technique + * \return Type of the render technique + */ + RenderTechniqueType DeferredRenderTechnique::GetType() const { return RenderTechniqueType_DeferredShading; } + /*! + * \brief Gets the render texture used to work + * \return Pointer to the rendering texture + */ + RenderTexture* DeferredRenderTechnique::GetWorkRTT() const { return &m_workRTT; } + /*! + * \brief Gets the ith texture to work + * \return Pointer to the texture + * + * \param i Index of the texture used to work + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if index is invalid + */ + Texture* DeferredRenderTechnique::GetWorkTexture(unsigned int i) const { #if NAZARA_GRAPHICS_SAFE @@ -322,6 +425,14 @@ namespace Nz return m_workTextures[i]; } + /*! + * \brief Checks whether the pass is enable + * \return true If it is the case + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + */ + bool DeferredRenderTechnique::IsPassEnabled(RenderPassType renderPass, int position) { auto it = m_passes.find(renderPass); @@ -335,9 +446,17 @@ namespace Nz return false; } + /*! + * \brief Resets the pass + * \return Pointer to the new deferred render pass + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + */ + DeferredRenderPass* DeferredRenderTechnique::ResetPass(RenderPassType renderPass, int position) { - std::unique_ptr smartPtr; // Nous évite un leak en cas d'exception + std::unique_ptr smartPtr; // We avoid to leak in case of exception switch (renderPass) { @@ -386,6 +505,14 @@ namespace Nz return smartPtr.release(); } + /*! + * \brief Sets the pass + * + * \param relativeTo Enumeration for the pass + * \param position Position of the pass + * \param pass Render pass to set + */ + void DeferredRenderTechnique::SetPass(RenderPassType relativeTo, int position, DeferredRenderPass* pass) { if (pass) @@ -400,12 +527,26 @@ namespace Nz m_passes[relativeTo].erase(position); } + /*! + * \brief Checks whether the technique is supported + * \return true if it is the case + */ + bool DeferredRenderTechnique::IsSupported() { - // Depuis qu'OpenGL 3.3 est la version minimale, le Renderer supporte ce qu'il faut, mais par acquis de conscience... + // Since OpenGL 3.3 is the minimal version, the Renderer supports what it needs, but we are never sure... return Renderer::GetMaxColorAttachments() >= 4 && Renderer::GetMaxRenderTargets() >= 4; } + /*! + * \brief Resizes the texture sizes used for the render technique + * \return true If successful + * + * \param dimensions Dimensions for the render technique + * + * \param Produces a NazaraError if one pass could not be resized + */ + bool DeferredRenderTechnique::Resize(const Vector2ui& dimensions) const { try @@ -427,6 +568,13 @@ namespace Nz } } + /*! + * \brief Initializes the deferred render technique + * \return true If successful + * + * \remark Produces a NazaraError if one shader creation failed + */ + bool DeferredRenderTechnique::Initialize() { const char vertexSource_Basic[] = @@ -560,6 +708,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the deferred render technique + */ + void DeferredRenderTechnique::Uninitialize() { ShaderLibrary::Unregister("DeferredGBufferClear"); @@ -571,6 +723,14 @@ namespace Nz ShaderLibrary::Unregister("DeferredGaussianBlur"); } + /*! + * \brief Functor to compare two render pass + * \return true If first render pass is "smaller" than the second one + * + * \param pass1 First render pass to compare + * \param pass2 Second render pass to compare + */ + bool DeferredRenderTechnique::RenderPassComparator::operator()(RenderPassType pass1, RenderPassType pass2) const { return RenderPassPriority[pass1] < RenderPassPriority[pass2]; diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index e6fc71ae0..dc31d2a45 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -9,6 +9,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DepthRenderQueue + * \brief Graphics class that represents the rendering queue for depth rendering + */ + + /*! + * \brief Constructs a DepthRenderTechnique object by default + */ + DepthRenderQueue::DepthRenderQueue() { // Material @@ -18,6 +28,19 @@ namespace Nz //m_baseMaterial->SetFaceCulling(FaceSide_Front); } + /*! + * \brief Adds billboard to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + * \param position Position of the billboard + * \param size Sizes of the billboard + * \param sinCos Rotation of the billboard + * \param color Color of the billboard + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) { NazaraAssert(material, "Invalid material"); @@ -34,6 +57,20 @@ namespace Nz ForwardRenderQueue::AddBillboard(0, material, position, size, sinCos, color); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -50,6 +87,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -66,6 +117,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -82,6 +147,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -98,6 +177,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -114,6 +207,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -130,6 +237,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -146,6 +267,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -162,12 +297,32 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds a direcitonal light to the queue + * + * \param light Light to add + * + * \remark Produces a NazaraAssert + */ + void DepthRenderQueue::AddDirectionalLight(const DirectionalLight& light) { NazaraAssert(false, "Depth render queue doesn't handle lights"); NazaraUnused(light); } + /*! + * \brief Adds mesh to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the mesh + * \param meshData Data of the mesh + * \param meshAABB Box of the mesh + * \param transformMatrix Matrix of the mesh + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { NazaraAssert(material, "Invalid material"); @@ -185,18 +340,46 @@ namespace Nz ForwardRenderQueue::AddMesh(0, material, meshData, meshAABB, transformMatrix); } + /*! + * \brief Adds a point light to the queue + * + * \param light Light to add + * + * \remark Produces a NazaraAssert + */ + void DepthRenderQueue::AddPointLight(const PointLight& light) { NazaraAssert(false, "Depth render queue doesn't handle lights"); NazaraUnused(light); } + /*! + * \brief Adds a spot light to the queue + * + * \param light Light to add + * + * \remark Produces a NazaraAssert + */ + void DepthRenderQueue::AddSpotLight(const SpotLight& light) { NazaraAssert(false, "Depth render queue doesn't handle lights"); NazaraUnused(light); } + /*! + * \brief Adds sprites to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the sprites + * \param vertices Buffer of data for the sprites + * \param spriteCount Number of sprites + * \param overlay Texture of the sprites + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { NazaraAssert(material, "Invalid material"); diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 46e7fb043..233eb9c72 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -37,6 +37,16 @@ namespace Nz unsigned int s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB } + /*! + * \ingroup graphics + * \class Nz::DepthRenderTechnique + * \brief Graphics class that represents the technique used in depth rendering + */ + + /*! + * \brief Constructs a DepthRenderTechnique object by default + */ + DepthRenderTechnique::DepthRenderTechnique() : m_vertexBuffer(BufferType_Vertex) { @@ -48,6 +58,12 @@ namespace Nz m_spriteBuffer.Reset(VertexDeclaration::Get(VertexLayout_XYZ_Color_UV), &m_vertexBuffer); } + /*! + * \brief Clears the data + * + * \param sceneData Data of the scene + */ + void DepthRenderTechnique::Clear(const SceneData& sceneData) const { Renderer::Enable(RendererParameter_DepthBuffer, true); @@ -59,6 +75,13 @@ namespace Nz // sceneData.background->Draw(sceneData.viewer); } + /*! + * \brief Draws the data of the scene + * \return true If successful + * + * \param sceneData Data of the scene + */ + bool DepthRenderTechnique::Draw(const SceneData& sceneData) const { for (auto& pair : m_renderQueue.layers) @@ -81,16 +104,33 @@ namespace Nz return true; } + /*! + * \brief Gets the render queue + * \return Pointer to the render queue + */ + AbstractRenderQueue* DepthRenderTechnique::GetRenderQueue() { return &m_renderQueue; } + /*! + * \brief Gets the type of the current technique + * \return Type of the render technique + */ + RenderTechniqueType DepthRenderTechnique::GetType() const { return RenderTechniqueType_Depth; } + /*! + * \brief Initializes the depth render technique + * \return true If successful + * + * \remark Produces a NazaraError if one shader creation failed + */ + bool DepthRenderTechnique::Initialize() { try @@ -149,12 +189,23 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the depth render technique + */ + void DepthRenderTechnique::Uninitialize() { s_quadIndexBuffer.Reset(); s_quadVertexBuffer.Reset(); } + /*! + * \brief Draws basic sprites + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + */ + void DepthRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; @@ -180,7 +231,7 @@ namespace Nz unsigned int spriteChainCount = spriteChainVector.size(); if (spriteChainCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt32 flags = 0; if (overlay) flags |= ShaderFlags_TextureOverlay; @@ -195,26 +246,26 @@ namespace Nz Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); } - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); // Overlay shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); lastShader = shader; } - unsigned int spriteChain = 0; // Quelle chaîne de sprite traitons-nous - unsigned int spriteChainOffset = 0; // À quel offset dans la dernière chaîne nous sommes-nous arrêtés + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain do { - // On ouvre le buffer en écriture + // We open the buffer in writing mode BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(vertexMapper.GetPointer()); @@ -232,7 +283,7 @@ namespace Nz spriteCount += count; spriteChainOffset += count; - // Avons-nous traité la chaîne entière ? + // Have we treated the entire chain ? if (spriteChainOffset == currentChain.spriteCount) { spriteChain++; @@ -257,6 +308,13 @@ namespace Nz } } + /*! + * \brief Draws billboards + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + */ + void DepthRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; @@ -278,16 +336,16 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); lastShader = shader; @@ -325,16 +383,16 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); lastShader = shader; @@ -396,6 +454,13 @@ namespace Nz } } + /*! + * \brief Draws opaques models + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + */ + void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; @@ -415,14 +480,14 @@ namespace Nz bool instancing = m_instancingEnabled && matEntry.instancingEnabled; - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); lastShader = shader; } @@ -441,7 +506,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before rendering loop Renderer::DrawCall drawFunc; Renderer::DrawCallInstanced instancedDrawFunc; unsigned int indexCount; @@ -464,33 +529,33 @@ namespace Nz if (instancing) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); const Matrix4f* instanceMatrices = &instances[0]; unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Le nombre maximum d'instances en une fois + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The maximum number of instances in one batch while (instanceCount > 0) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); instanceCount -= renderedInstanceCount; - // On remplit l'instancing buffer avec nos matrices world + // We fill the instancing buffer with our world matrices instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); instanceMatrices += renderedInstanceCount; - // Et on affiche + // And we draw instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); } } else { - // Sans instancing, on doit effectuer un draw call pour chaque instance - // Cela reste néanmoins plus rapide que l'instancing en dessous d'un certain nombre d'instances - // À cause du temps de modification du buffer d'instancing + // Without instancing, we must do a draw call for each instance + // This may be faster than instancing under a certain number + // Due to the time to modify the instancing buffer for (const Matrix4f& matrix : instances) { Renderer::SetMatrix(MatrixType_World, matrix); @@ -502,13 +567,20 @@ namespace Nz } } - // Et on remet à zéro les données + // And we set the data back to zero matEntry.enabled = false; matEntry.instancingEnabled = false; } } } + /*! + * \brief Gets the shader uniforms + * \return Uniforms of the shader + * + * \param shader Shader to get uniforms from + */ + const DepthRenderTechnique::ShaderUniforms* DepthRenderTechnique::GetShaderUniforms(const Shader* shader) const { auto it = m_shaderUniforms.find(shader); @@ -527,6 +599,12 @@ namespace Nz return &it->second; } + /*! + * \brief Handle the invalidation of a shader + * + * \param shader Shader being invalidated + */ + void DepthRenderTechnique::OnShaderInvalidated(const Shader* shader) const { m_shaderUniforms.erase(shader); diff --git a/src/Nazara/Graphics/Drawable.cpp b/src/Nazara/Graphics/Drawable.cpp index baac1defb..7db121225 100644 --- a/src/Nazara/Graphics/Drawable.cpp +++ b/src/Nazara/Graphics/Drawable.cpp @@ -7,5 +7,13 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Drawable + * \brief Graphics class that represents something drawable for our scene + * + * \remark This class is abstract + */ + Drawable::~Drawable() = default; } diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 9f0f5d04d..0f182a185 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -7,10 +7,29 @@ #include #include -///TODO: Remplacer les sinus/cosinus par une lookup table (va booster les perfs d'un bon x10) +///TODO: Replace sinus/cosinus by a lookup table (which will lead to a speed up about 10x) namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ForwardRenderQueue + * \brief Graphics class that represents the rendering queue for forward rendering + */ + + /*! + * \brief Adds billboard to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + * \param position Position of the billboard + * \param size Sizes of the billboard + * \param sinCos Rotation of the billboard + * \param color Color of the billboard + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) { NazaraAssert(material, "Invalid material"); @@ -32,37 +51,33 @@ namespace Nz billboardVector.push_back(BillboardData{color, position, size, sinCos}); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -73,39 +88,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -116,37 +127,33 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -161,39 +168,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -208,37 +211,33 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -249,39 +248,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -292,37 +287,33 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -337,39 +328,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -384,6 +371,15 @@ namespace Nz } } + /*! + * \brief Adds drawable to the queue + * + * \param renderOrder Order of rendering + * \param drawable Drawable user defined + * + * \remark Produces a NazaraError if drawable is invalid + */ + void ForwardRenderQueue::AddDrawable(int renderOrder, const Drawable* drawable) { #if NAZARA_GRAPHICS_SAFE @@ -399,15 +395,29 @@ namespace Nz otherDrawables.push_back(drawable); } + /*! + * \brief Adds mesh to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the mesh + * \param meshData Data of the mesh + * \param meshAABB Box of the mesh + * \param transformMatrix Matrix of the mesh + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { + NazaraAssert(material, "Invalid material"); + if (material->IsEnabled(RendererParameter_Blend)) { Layer& currentLayer = GetLayer(renderOrder); auto& transparentModels = currentLayer.transparentModels; auto& transparentModelData = currentLayer.transparentModelData; - // Le matériau est transparent, nous devons rendre ce mesh d'une autre façon (après le rendu des objets opaques et en les triant) + // The material is transparent, we must draw this mesh using another way (after the rendering of opages objects while sorting them) unsigned int index = transparentModelData.size(); transparentModelData.resize(index+1); @@ -455,14 +465,28 @@ namespace Nz std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - // Avons-nous suffisamment d'instances pour que le coût d'utilisation de l'instancing soit payé ? + // Do we have enough instances to perform instancing ? if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Apparemment oui, activons l'instancing avec ce matériau + entry.instancingEnabled = true; // Thus we can activate it } } + /*! + * \brief Adds sprites to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the sprites + * \param vertices Buffer of data for the sprites + * \param spriteCount Number of sprites + * \param overlay Texture of the sprites + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { + NazaraAssert(material, "Invalid material"); + Layer& currentLayer = GetLayer(renderOrder); auto& basicSprites = currentLayer.basicSprites; @@ -494,6 +518,12 @@ namespace Nz spriteVector.push_back(SpriteChain_XYZ_Color_UV({vertices, spriteCount})); } + /*! + * \brief Clears the queue + * + * \param fully Should everything be cleared or we can keep layers + */ + void ForwardRenderQueue::Clear(bool fully) { AbstractRenderQueue::Clear(fully); @@ -518,15 +548,21 @@ namespace Nz } } + /*! + * \brief Sorts the object according to the viewer position, furthest to nearest + * + * \param viewer Viewer of the scene + */ + void ForwardRenderQueue::Sort(const AbstractViewer* viewer) { Planef nearPlane = viewer->GetFrustum().GetPlane(FrustumPlane_Near); Vector3f viewerPos = viewer->GetEyePosition(); Vector3f viewerNormal = viewer->GetForward(); - for (auto& layerPair : layers) + for (auto& pair : layers) { - Layer& layer = layerPair.second; + Layer& layer = pair.second; std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2) { @@ -557,18 +593,61 @@ namespace Nz } } + /*! + * \brief Gets the billboard data + * \return Pointer to the data of the billboards + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + */ + + ForwardRenderQueue::BillboardData* ForwardRenderQueue::GetBillboardData(int renderOrder, const Material* material, unsigned int count) + { + auto& billboards = GetLayer(renderOrder).billboards; + + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry; + entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); + + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + return &billboardVector[prevSize]; + } + + /*! + * \brief Gets the ith layer + * \return Reference to the ith layer for the queue + * + * \param i Index of the layer + */ + ForwardRenderQueue::Layer& ForwardRenderQueue::GetLayer(int i) { auto it = layers.find(i); if (it == layers.end()) it = layers.insert(std::make_pair(i, Layer())).first; - + Layer& layer = it->second; layer.clearCount = 0; return layer; } + /*! + * \brief Handle the invalidation of an index buffer + * + * \param indexBuffer Index buffer being invalidated + */ + void ForwardRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer) { for (auto& pair : layers) @@ -590,6 +669,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a material + * + * \param material Material being invalidated + */ + void ForwardRenderQueue::OnMaterialInvalidation(const Material* material) { for (auto& pair : layers) @@ -602,6 +687,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a texture + * + * \param texture Texture being invalidated + */ + void ForwardRenderQueue::OnTextureInvalidation(const Texture* texture) { for (auto& pair : layers) @@ -615,6 +706,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a vertex buffer + * + * \param vertexBuffer Vertex buffer being invalidated + */ + void ForwardRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer) { for (auto& pair : layers) @@ -635,6 +732,14 @@ namespace Nz } } + /*! + * \brief Functor to compare two batched billboard with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool ForwardRenderQueue::BatchedBillboardComparator::operator()(const Material* mat1, const Material* mat2) const { const UberShader* uberShader1 = mat1->GetShader(); @@ -655,6 +760,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two batched model with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool ForwardRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const { const UberShader* uberShader1 = mat1->GetShader(); @@ -675,6 +788,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two batched sprites with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool ForwardRenderQueue::BatchedSpriteMaterialComparator::operator()(const Material* mat1, const Material* mat2) { const UberShader* uberShader1 = mat1->GetShader(); @@ -695,6 +816,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two mesh data + * \return true If first mesh is "smaller" than the second one + * + * \param data1 First mesh to compare + * \param data2 Second mesh to compare + */ + bool ForwardRenderQueue::MeshDataComparator::operator()(const MeshData& data1, const MeshData& data2) const { const Buffer* buffer1; diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 2ec95aee7..482852347 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -33,10 +33,20 @@ namespace Nz Vector2f uv; }; - unsigned int s_maxQuads = std::numeric_limits::max()/6; - unsigned int s_vertexBufferSize = 4*1024*1024; // 4 MiB + unsigned int s_maxQuads = std::numeric_limits::max() / 6; + unsigned int s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB } + /*! + * \ingroup graphics + * \class Nz::ForwardRenderTechnique + * \brief Graphics class that represents the technique used in forward rendering + */ + + /*! + * \brief Constructs a ForwardRenderTechnique object by default + */ + ForwardRenderTechnique::ForwardRenderTechnique() : m_vertexBuffer(BufferType_Vertex), m_maxLightPassPerObject(3) @@ -49,6 +59,12 @@ namespace Nz m_spriteBuffer.Reset(VertexDeclaration::Get(VertexLayout_XYZ_Color_UV), &m_vertexBuffer); } + /*! + * \brief Clears the data + * + * \param sceneData Data of the scene + */ + void ForwardRenderTechnique::Clear(const SceneData& sceneData) const { Renderer::Enable(RendererParameter_DepthBuffer, true); @@ -59,6 +75,15 @@ namespace Nz sceneData.background->Draw(sceneData.viewer); } + /*! + * \brief Draws the data of the scene + * \return true If successful + * + * \param sceneData Data of the scene + * + * \remark Produces a NazaraAssert if viewer of the scene is invalid + */ + bool ForwardRenderTechnique::Draw(const SceneData& sceneData) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -88,55 +113,83 @@ namespace Nz return true; } + /*! + * \brief Gets the maximum number of lights available per pass per object + * \return Maximum number of light simulatenously per object + */ + unsigned int ForwardRenderTechnique::GetMaxLightPassPerObject() const { return m_maxLightPassPerObject; } + /*! + * \brief Gets the render queue + * \return Pointer to the render queue + */ + AbstractRenderQueue* ForwardRenderTechnique::GetRenderQueue() { return &m_renderQueue; } + /*! + * \brief Gets the type of the current technique + * \return Type of the render technique + */ + RenderTechniqueType ForwardRenderTechnique::GetType() const { return RenderTechniqueType_BasicForward; } - void ForwardRenderTechnique::SetMaxLightPassPerObject(unsigned int passCount) + /*! + * \brief Sets the maximum number of lights available per pass per object + * + * \param passCount Maximum number of light simulatenously per object + */ + + void ForwardRenderTechnique::SetMaxLightPassPerObject(unsigned int maxLightPassPerObject) { - m_maxLightPassPerObject = passCount; + m_maxLightPassPerObject = maxLightPassPerObject; } + /*! + * \brief Initializes the forward render technique + * \return true If successful + * + * \remark Produces a NazaraError if one shader creation failed + */ + bool ForwardRenderTechnique::Initialize() { try { ErrorFlags flags(ErrorFlag_ThrowException, true); - s_quadIndexBuffer.Reset(false, s_maxQuads*6, DataStorage_Hardware, BufferUsage_Static); + s_quadIndexBuffer.Reset(false, s_maxQuads * 6, DataStorage_Hardware, BufferUsage_Static); BufferMapper mapper(s_quadIndexBuffer, BufferAccess_WriteOnly); UInt16* indices = static_cast(mapper.GetPointer()); for (unsigned int i = 0; i < s_maxQuads; ++i) { - *indices++ = i*4 + 0; - *indices++ = i*4 + 2; - *indices++ = i*4 + 1; + *indices++ = i * 4 + 0; + *indices++ = i * 4 + 2; + *indices++ = i * 4 + 1; - *indices++ = i*4 + 2; - *indices++ = i*4 + 3; - *indices++ = i*4 + 1; + *indices++ = i * 4 + 2; + *indices++ = i * 4 + 3; + *indices++ = i * 4 + 1; } - mapper.Unmap(); // Inutile de garder le buffer ouvert plus longtemps + mapper.Unmap(); // No point to keep the buffer open any longer - // Quad buffer (utilisé pour l'instancing de billboard et de sprites) - //Note: Les UV sont calculés dans le shader + // Quad buffer (used for instancing of billboards and sprites) + //Note: UV are computed in the shader s_quadVertexBuffer.Reset(VertexDeclaration::Get(VertexLayout_XY), 4, DataStorage_Hardware, BufferUsage_Static); - float vertices[2*4] = { + float vertices[2 * 4] = { -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, @@ -145,14 +198,14 @@ namespace Nz s_quadVertexBuffer.FillRaw(vertices, 0, sizeof(vertices)); - // Déclaration lors du rendu des billboards par sommet + // Declaration used when rendering the vertex billboards s_billboardVertexDeclaration.EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(BillboardPoint, color)); s_billboardVertexDeclaration.EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(BillboardPoint, position)); s_billboardVertexDeclaration.EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(BillboardPoint, uv)); - s_billboardVertexDeclaration.EnableComponent(VertexComponent_Userdata0, ComponentType_Float4, NazaraOffsetOf(BillboardPoint, size)); // Englobe sincos + s_billboardVertexDeclaration.EnableComponent(VertexComponent_Userdata0, ComponentType_Float4, NazaraOffsetOf(BillboardPoint, size)); // Includes sincos - // Declaration utilisée lors du rendu des billboards par instancing - // L'avantage ici est la copie directe (std::memcpy) des données de la RenderQueue vers le buffer GPU + // Declaration used when rendering the billboards with intancing + // The main advantage is the direct copy (std::memcpy) of data in the RenderQueue to the GPU buffer s_billboardInstanceDeclaration.EnableComponent(VertexComponent_InstanceData0, ComponentType_Float3, NazaraOffsetOf(ForwardRenderQueue::BillboardData, center)); s_billboardInstanceDeclaration.EnableComponent(VertexComponent_InstanceData1, ComponentType_Float4, NazaraOffsetOf(ForwardRenderQueue::BillboardData, size)); // Englobe sincos s_billboardInstanceDeclaration.EnableComponent(VertexComponent_InstanceData2, ComponentType_Color, NazaraOffsetOf(ForwardRenderQueue::BillboardData, color)); @@ -169,12 +222,23 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the forward render technique + */ + void ForwardRenderTechnique::Uninitialize() { s_quadIndexBuffer.Reset(); s_quadVertexBuffer.Reset(); } + /*! + * \brief Chooses the nearest lights for one object + * + * \param object Sphere symbolising the object + * \param includeDirectionalLights Should directional lights be included in the computation + */ + void ForwardRenderTechnique::ChooseLights(const Spheref& object, bool includeDirectionalLights) const { m_lights.clear(); @@ -213,6 +277,15 @@ namespace Nz }); } + /*! + * \brief Draws basic sprites + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -240,7 +313,7 @@ namespace Nz unsigned int spriteChainCount = spriteChainVector.size(); if (spriteChainCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt32 flags = ShaderFlags_VertexColor; if (overlay) flags |= ShaderFlags_TextureOverlay; @@ -255,46 +328,46 @@ namespace Nz Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); } - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); // Overlay shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } - unsigned int spriteChain = 0; // Quelle chaîne de sprite traitons-nous - unsigned int spriteChainOffset = 0; // À quel offset dans la dernière chaîne nous sommes-nous arrêtés + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain do { - // On ouvre le buffer en écriture + // We open the buffer in writing mode BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); unsigned int spriteCount = 0; - unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount()/4); + unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); do { ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); - std::memcpy(vertices, currentChain.vertices + spriteChainOffset*4, 4*count*sizeof(VertexStruct_XYZ_Color_UV)); - vertices += count*4; + std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); + vertices += count * 4; spriteCount += count; spriteChainOffset += count; - // Avons-nous traité la chaîne entière ? + // Have we treated the entire chain ? if (spriteChainOffset == currentChain.spriteCount) { spriteChain++; @@ -305,7 +378,7 @@ namespace Nz vertexMapper.Unmap(); - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount*6); + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); } while (spriteChain < spriteChainCount); @@ -313,12 +386,21 @@ namespace Nz } } - // On remet à zéro + // We set it back to zero matEntry.enabled = false; } } } + /*! + * \brief Draws billboards + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -342,18 +424,18 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; @@ -391,32 +473,32 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount()/4); + unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); do { unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); billboardCount -= renderedBillboardCount; - BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount*4); + BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); for (unsigned int i = 0; i < renderedBillboardCount; ++i) @@ -454,7 +536,7 @@ namespace Nz vertexMapper.Unmap(); - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount*6); + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); } while (billboardCount > 0); @@ -464,6 +546,15 @@ namespace Nz } } + /*! + * \brief Draws opaques models + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -483,25 +574,25 @@ namespace Nz { const Material* material = matIt.first; - // Nous utilisons de l'instancing que lorsqu'aucune lumière (autre que directionnelle) n'est active - // Ceci car l'instancing n'est pas compatible avec la recherche des lumières les plus proches - // (Le deferred shading n'a pas ce problème) + // We only use instancing when no light (other than directional) is active + // This is because instancing is not compatible with the search of nearest lights + // Deferred shading does not have this problem bool noPointSpotLight = m_renderQueue.pointLights.empty() && m_renderQueue.spotLights.empty(); bool instancing = m_instancingEnabled && (!material->IsLightingEnabled() || noPointSpotLight) && matEntry.instancingEnabled; - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; @@ -521,7 +612,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before rendering loop Renderer::DrawCall drawFunc; Renderer::DrawCallInstanced instancedDrawFunc; unsigned int indexCount; @@ -544,17 +635,17 @@ namespace Nz if (instancing) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - // Avec l'instancing, impossible de sélectionner les lumières pour chaque objet - // Du coup, il n'est activé que pour les lumières directionnelles + // With instancing, impossible to select the lights for each object + // So, it's only activated for directional lights unsigned int lightCount = m_renderQueue.directionalLights.size(); unsigned int lightIndex = 0; RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; for (unsigned int pass = 0; pass < passCount; ++pass) { if (shaderUniforms->hasLightUniforms) @@ -564,10 +655,10 @@ namespace Nz if (pass == 1) { - // Pour additionner le résultat des calculs de lumière - // Aucune chance d'interférer avec les paramètres du matériau car nous ne rendons que les objets opaques - // (Autrement dit, sans blending) - // Quant à la fonction de profondeur, elle ne doit être appliquée que la première fois + // To add the result of light computations + // We won't interfeer with materials parameters because we only render opaques objects + // (A.K.A., without blending) + // About the depth function, it must be applied only the first time Renderer::Enable(RendererParameter_Blend, true); Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); Renderer::SetDepthFunc(RendererComparison_Equal); @@ -575,32 +666,32 @@ namespace Nz // Sends the uniforms for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); + SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); - // Et on passe à l'affichage + // And we give them to draw drawFunc(meshData.primitiveMode, 0, indexCount); } const Matrix4f* instanceMatrices = &instances[0]; unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Le nombre maximum d'instances en une fois + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch while (instanceCount > 0) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); instanceCount -= renderedInstanceCount; - // On remplit l'instancing buffer avec nos matrices world + // We fill the instancing buffer with our world matrices instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); instanceMatrices += renderedInstanceCount; - // Et on affiche + // And we draw instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); } } - // On n'oublie pas de désactiver le blending pour ne pas interférer sur le reste du rendu + // We don't forget to disable the blending to avoid to interfeer with the rest of the rendering Renderer::Enable(RendererParameter_Blend, false); Renderer::SetDepthFunc(oldDepthFunc); } @@ -617,19 +708,19 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, matrix); unsigned int lightIndex = 0; - RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // Dans le cas où nous aurions à le changer + RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; for (unsigned int pass = 0; pass < passCount; ++pass) { lightCount -= std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); if (pass == 1) { - // Pour additionner le résultat des calculs de lumière - // Aucune chance d'interférer avec les paramètres du matériau car nous ne rendons que les objets opaques - // (Autrement dit, sans blending) - // Quant à la fonction de profondeur, elle ne doit être appliquée que la première fois + // To add the result of light computations + // We won't interfeer with materials parameters because we only render opaques objects + // (A.K.A., without blending) + // About the depth function, it must be applied only the first time Renderer::Enable(RendererParameter_Blend, true); Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); Renderer::SetDepthFunc(RendererComparison_Equal); @@ -639,7 +730,7 @@ namespace Nz for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); - // Et on passe à l'affichage + // And we draw drawFunc(meshData.primitiveMode, 0, indexCount); } @@ -649,9 +740,9 @@ namespace Nz } else { - // Sans instancing, on doit effectuer un draw call pour chaque instance - // Cela reste néanmoins plus rapide que l'instancing en dessous d'un certain nombre d'instances - // À cause du temps de modification du buffer d'instancing + // Without instancing, we must do a draw call for each instance + // This may be faster than instancing under a certain number + // Due to the time to modify the instancing buffer for (const Matrix4f& matrix : instances) { Renderer::SetMatrix(MatrixType_World, matrix); @@ -664,13 +755,22 @@ namespace Nz } } - // Et on remet à zéro les données + // And we set the data back to zero matEntry.enabled = false; matEntry.instancingEnabled = false; } } } + /*! + * \brief Draws transparent models + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawTransparentModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -683,25 +783,25 @@ namespace Nz { const ForwardRenderQueue::TransparentModelData& modelData = layer.transparentModelData[index]; - // Matériau + // Material const Material* material = modelData.material; - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; const Shader* shader = material->Apply(0, 0, &freeTextureUnit); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // On envoie les lumières directionnelles s'il y a (Les mêmes pour tous) + // We send the directional lights if there is one (same for all) if (shaderUniforms->hasLightUniforms) { lightCount = std::min(m_renderQueue.directionalLights.size(), static_cast(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS)); @@ -720,7 +820,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before the rendering loop Renderer::DrawCall drawFunc; unsigned int indexCount; @@ -754,6 +854,13 @@ namespace Nz } } + /*! + * \brief Gets the shader uniforms + * \return Uniforms of the shader + * + * \param shader Shader to get uniforms from + */ + const ForwardRenderTechnique::ShaderUniforms* ForwardRenderTechnique::GetShaderUniforms(const Shader* shader) const { auto it = m_shaderUniforms.find(shader); @@ -795,6 +902,12 @@ namespace Nz return &it->second; } + /*! + * \brief Handle the invalidation of a shader + * + * \param shader Shader being invalidated + */ + void ForwardRenderTechnique::OnShaderInvalidated(const Shader* shader) const { m_shaderUniforms.erase(shader); diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index b501682bc..c9cc652a8 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -28,15 +28,29 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Graphics + * \brief Graphics class that represents the module initializer of Graphics + */ + + /*! + * \brief Initializes the Graphics module + * \return true if initialization is successful + * + * \remark Produces a NazaraNotice + * \remark Produces a NazaraError if one submodule failed + */ + bool Graphics::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; - return true; // Déjà initialisé + return true; // Already initialized } - // Initialisation des dépendances + // Initialisation of dependances if (!Renderer::Initialize()) { NazaraError("Failed to initialize Renderer module"); @@ -45,7 +59,7 @@ namespace Nz s_moduleReferenceCounter++; - // Initialisation du module + // Initialisation of the module CallOnExit onExit(Graphics::Uninitialize); if (!Material::Initialize()) @@ -96,7 +110,7 @@ namespace Nz return false; } - // Loaders génériques + // Generic loaders Loaders::RegisterMesh(); Loaders::RegisterTexture(); @@ -133,43 +147,54 @@ namespace Nz return true; } + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + bool Graphics::IsInitialized() { return s_moduleReferenceCounter != 0; } + /*! + * \brief Uninitializes the Core module + * + * \remark Produces a NazaraNotice + */ + void Graphics::Uninitialize() { if (s_moduleReferenceCounter != 1) { - // Le module est soit encore utilisé, soit pas initialisé + // The module is still in use, or can not be uninitialized if (s_moduleReferenceCounter > 1) s_moduleReferenceCounter--; return; } - // Libération du module + // Free of module s_moduleReferenceCounter = 0; - // Libération de l'atlas s'il vient de nous + // Free of atlas if it is ours std::shared_ptr defaultAtlas = Font::GetDefaultAtlas(); if (defaultAtlas && defaultAtlas->GetStorage() & DataStorage_Hardware) { Font::SetDefaultAtlas(nullptr); - // La police par défaut peut faire vivre un atlas hardware après la libération du module (ce qui va être problématique) - // du coup, si la police par défaut utilise un atlas hardware, on lui enlève. - // Je n'aime pas cette solution mais je n'en ai pas de meilleure sous la main pour l'instant + // The default police can make live one hardware atlas after the free of a module (which could be problematic) + // So, if the default police use a hardware atlas, we stole it. + // I don't like this solution, but I don't have any better if (!defaultAtlas.unique()) { - // Encore au moins une police utilise l'atlas + // Still at least one police use the atlas Font* defaultFont = Font::GetDefault(); defaultFont->SetAtlas(nullptr); if (!defaultAtlas.unique()) { - // Toujours pas seuls propriétaires ? Ah ben zut. + // Still not the only one to own it ? Then crap. NazaraWarning("Default font atlas uses hardware storage and is still used"); } } @@ -195,7 +220,7 @@ namespace Nz NazaraNotice("Uninitialized: Graphics module"); - // Libération des dépendances + // Free of dependances Renderer::Uninitialize(); } diff --git a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp index c8034d7b9..7c2122281 100644 --- a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp +++ b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp @@ -9,11 +9,32 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::GuillotineTextureAtlas + * \brief Graphics class that represents an atlas texture for guillotine + */ + + /*! + * \brief Gets the underlying data storage + * \return Value of the enumeration of the underlying data storage + */ + UInt32 GuillotineTextureAtlas::GetStorage() const { return DataStorage_Hardware; } + /*! + * \brief Resizes the image + * \return Updated texture + * + * \param oldImage Old image to resize + * \param size New image size + * + * \remark Produces a NazaraError if resize failed + */ + AbstractImage* GuillotineTextureAtlas::ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const { std::unique_ptr newTexture(new Texture); @@ -23,8 +44,8 @@ namespace Nz { Texture* oldTexture = static_cast(oldImage); - // Copie des anciennes données - ///TODO: Copie de texture à texture + // Copy of old data + ///TODO: Copy from texture to texture Image image; if (!oldTexture->Download(&image)) { @@ -43,8 +64,7 @@ namespace Nz } else { - // Si on arrive ici c'est que la taille demandée est trop grande pour la carte graphique - // ou que nous manquons de mémoire + // If we are here, it is that the size is too big for the graphic card or we don't have enough return nullptr; } } diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index 780f11a67..ef5f62b96 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -7,16 +7,43 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::InstancedRenderable + * \brief Graphics class that represents an instancer renderable + * + * \remark This class is abstract + */ + + /*! + * \brief Destructs the object and calls OnInstancedRenderableRelease + * + * \see OnInstancedRenderableRelease + */ + InstancedRenderable::~InstancedRenderable() { OnInstancedRenderableRelease(this); } + /*! + * \brief Culls the instanced if not in the frustum + * \return true If instanced is in the frustum + * + * \param frustum Symbolizing the field of view + * \param transformMatrix Matrix transformation for our object + */ + bool InstancedRenderable::Cull(const Frustumf& frustum, const InstanceData& instanceData) const { return frustum.Contains(instanceData.volume); } + /*! + * \brief Gets the bounding volume + * \return Bounding volume of the instanced + */ + const BoundingVolumef& InstancedRenderable::GetBoundingVolume() const { EnsureBoundingVolumeUpdated(); @@ -24,11 +51,30 @@ namespace Nz return m_boundingVolume; } + /*! + * \brief Invalidates data for instanced + * + * \param instanceData Pointer to data of instances + * \param flags Flags for the instances + * + * \remark Produces a NazaraAssert if instanceData is invalid + */ + void InstancedRenderable::InvalidateData(InstanceData* instanceData, UInt32 flags) const { + NazaraAssert(instanceData, "Invalid instance data"); + instanceData->flags |= flags; } + /*! + * \brief Updates the bounding volume + * + * \param instanceData Pointer to data of instances + * + * \remark Produces a NazaraAssert if instanceData is invalid + */ + void InstancedRenderable::UpdateBoundingVolume(InstanceData* instanceData) const { NazaraAssert(instanceData, "Invalid instance data"); @@ -37,6 +83,14 @@ namespace Nz instanceData->volume.Update(instanceData->transformMatrix); } + /*! + * \brief Updates the instance data + * + * \param instanceData Pointer to data of instances + * + * \remark Produces a NazaraAssert if instanceData is invalid + */ + void InstancedRenderable::UpdateData(InstanceData* instanceData) const { NazaraAssert(instanceData, "Invalid instance data"); diff --git a/src/Nazara/Graphics/Light.cpp b/src/Nazara/Graphics/Light.cpp index 14e33100b..275d78a79 100644 --- a/src/Nazara/Graphics/Light.cpp +++ b/src/Nazara/Graphics/Light.cpp @@ -13,11 +13,23 @@ #include #include -///TODO: Utilisation des UBOs +///TODO: Use of UBOs ///TODO: Scale ? namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Light + * \brief Graphics class that represents a light + */ + + /*! + * \brief Constructs a Light object with a type + * + * \param type Type of the light + */ + Light::Light(LightType type) : m_type(type), m_shadowMapFormat(PixelFormatType_Depth16), @@ -34,6 +46,15 @@ namespace Nz SetRadius(5.f); } + /*! + * \brief Adds this light to the render queue + * + * \param renderQueue Queue to be added + * \param transformMatrix Matrix transformation for this light + * + * \remark Produces a NazaraError if type is invalid + */ + void Light::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const { static Matrix4f biasMatrix(0.5f, 0.f, 0.f, 0.f, @@ -100,16 +121,36 @@ namespace Nz } } + /*! + * \brief Clones this light + * \return Pointer to newly allocated Light + */ + Light* Light::Clone() const { return new Light(*this); } + /*! + * \brief Creates a default light + * \return Pointer to newly allocated light + */ + Light* Light::Create() const { return new Light; } + /*! + * \brief Culls the light if not in the frustum + * \return true If light is in the frustum + * + * \param frustum Symbolizing the field of view + * \param transformMatrix Matrix transformation for our object + * + * \remark Produces a NazaraError if type is invalid + */ + bool Light::Cull(const Frustumf& frustum, const Matrix4f& transformMatrix) const { switch (m_type) @@ -128,6 +169,14 @@ namespace Nz return false; } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + * + * \remark Produces a NazaraError if type is invalid + */ + void Light::UpdateBoundingVolume(const Matrix4f& transformMatrix) { switch (m_type) @@ -149,6 +198,12 @@ namespace Nz } } + /* + * \brief Makes the bounding volume of this light + * + * \remark Produces a NazaraError if type is invalid + */ + void Light::MakeBoundingVolume() const { switch (m_type) @@ -166,19 +221,19 @@ namespace Nz case LightType_Spot: { - // On forme une boite sur l'origine + // We make a box center in the origin Boxf box(Vector3f::Zero()); - // On calcule le reste des points - Vector3f base(Vector3f::Forward()*m_radius); + // We compute the other points + Vector3f base(Vector3f::Forward() * m_radius); - // Il nous faut maintenant le rayon du cercle projeté à cette distance - // Tangente = Opposé/Adjaçent <=> Opposé = Adjaçent*Tangente + // Now we need the radius of the projected circle depending on the distance + // Tangent = Opposite/Adjacent <=> Opposite = Adjacent * Tangent float radius = m_radius * m_outerAngleTangent; - Vector3f lExtend = Vector3f::Left()*radius; - Vector3f uExtend = Vector3f::Up()*radius; + Vector3f lExtend = Vector3f::Left() * radius; + Vector3f uExtend = Vector3f::Up() * radius; - // Et on ajoute ensuite les quatres extrémités de la pyramide + // And we add the four extremities of our pyramid box.ExtendTo(base + lExtend + uExtend); box.ExtendTo(base + lExtend - uExtend); box.ExtendTo(base - lExtend + uExtend); @@ -194,6 +249,10 @@ namespace Nz } } + /*! + * \brief Updates the shadow map + */ + void Light::UpdateShadowMap() const { if (m_shadowCastingEnabled) diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 44ec0310d..24323960d 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #ifndef NAZARA_RENDERER_OPENGL -#define NAZARA_RENDERER_OPENGL // Nécessaire pour inclure les headers OpenGL +#define NAZARA_RENDERER_OPENGL // Mandatory to include the OpenGL headers #endif #include @@ -36,6 +36,17 @@ namespace Nz }; } + /*! + * \ingroup graphics + * \class Nz::Material + * \brief Graphics class that represents a material + */ + + /*! + * \brief Checks whether the parameters for the material are correct + * \return true If parameters are valid + */ + bool MaterialParams::IsValid() const { if (!UberShaderLibrary::Has(shaderName)) @@ -44,6 +55,15 @@ namespace Nz return true; } + /*! + * \brief Applies shader to the material + * \return Constant pointer to the shader + * + * \param shaderFlags Flags for the shader + * \param textureUnit Unit for the texture GL_TEXTURE"i" + * \param lastUsedUnit Optional argument to get the last texture unit + */ + const Shader* Material::Apply(UInt32 shaderFlags, UInt8 textureUnit, UInt8* lastUsedUnit) const { const ShaderInstance& instance = m_shaders[shaderFlags]; @@ -123,6 +143,13 @@ namespace Nz return instance.shader; } + /*! + * \brief Builds the material from parameters + * + * \param matData Data information for the material + * \param matParams Parameters for the material + */ + void Material::BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams) { Color color; @@ -283,6 +310,10 @@ namespace Nz SetShader(matParams.shaderName); } + /*! + * \brief Resets the material, cleans everything + */ + void Material::Reset() { OnMaterialReset(this); @@ -319,9 +350,15 @@ namespace Nz SetShader("Basic"); } + /*! + * \brief Copies the other material + * + * \param material Material to copy into this + */ + void Material::Copy(const Material& material) { - // Copie des états de base + // Copy of base states m_alphaTestEnabled = material.m_alphaTestEnabled; m_alphaThreshold = material.m_alphaThreshold; m_ambientColor = material.m_ambientColor; @@ -337,7 +374,7 @@ namespace Nz m_states = material.m_states; m_transformEnabled = material.m_transformEnabled; - // Copie des références de texture + // Copy of reference to the textures m_alphaMap = material.m_alphaMap; m_depthMaterial = material.m_depthMaterial; m_diffuseMap = material.m_diffuseMap; @@ -347,10 +384,16 @@ namespace Nz m_specularMap = material.m_specularMap; m_uberShader = material.m_uberShader; - // On copie les instances de shader par la même occasion - std::memcpy(&m_shaders[0], &material.m_shaders[0], (ShaderFlags_Max+1)*sizeof(ShaderInstance)); + // We copy the instances of the shader too + std::memcpy(&m_shaders[0], &material.m_shaders[0], (ShaderFlags_Max + 1) * sizeof(ShaderInstance)); } + /*! + * \brief Generates the shader based on flag + * + * \param flags Flag for the shaer + */ + void Material::GenerateShader(UInt32 flags) const { ParameterList list; @@ -396,6 +439,13 @@ namespace Nz #undef CacheUniform } + /*! + * \brief Initializes the material librairies + * \return true If successful + * + * \remark Produces a NazaraError if the material library failed to be initialized + */ + bool Material::Initialize() { if (!MaterialLibrary::Initialize()) @@ -462,6 +512,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the material librairies + */ + void Material::Uninitialize() { s_defaultMaterial.Reset(); diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index e8954a886..d382c77d9 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -12,11 +12,26 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Model + * \brief Graphics class that represents a model + */ + + /*! + * \brief Constructs a ModelParameters object by default + */ + ModelParameters::ModelParameters() { material.shaderName = "PhongLighting"; } + /*! + * \brief Checks whether the parameters for the model are correct + * \return true If parameters are valid + */ + bool ModelParameters::IsValid() const { if (loadMaterials && !material.IsValid()) @@ -25,6 +40,10 @@ namespace Nz return mesh.IsValid(); } + /*! + * \brief Constructs a Model object by default + */ + Model::Model() : m_matCount(0), m_skin(0), @@ -32,11 +51,24 @@ namespace Nz { } + /*! + * \brief Destructs the object and calls Reset + * + * \see Reset + */ + Model::~Model() { Reset(); } + /*! + * \brief Adds this model to the render queue + * + * \param renderQueue Queue to be added + * \param instanceData Data used for this instance + */ + void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { unsigned int submeshCount = m_mesh->GetSubMeshCount(); @@ -54,6 +86,17 @@ namespace Nz } } + /*! + * \brief Gets the material of the named submesh + * \return Pointer to the current material + * + * \param subMeshName Name of the subMesh + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material is invalid + */ + Material* Model::GetMaterial(const String& subMeshName) const { #if NAZARA_GRAPHICS_SAFE @@ -78,9 +121,18 @@ namespace Nz return nullptr; } - return m_materials[m_skin*m_matCount + matIndex]; + return m_materials[m_skin * m_matCount + matIndex]; } + /*! + * \brief Gets the material by index + * \return Pointer to the current material + * + * \param matIndex Index of the material + * + * \remark Produces a NazaraError if index is invalid + */ + Material* Model::GetMaterial(unsigned int matIndex) const { #if NAZARA_GRAPHICS_SAFE @@ -91,9 +143,21 @@ namespace Nz } #endif - return m_materials[m_skin*m_matCount + matIndex]; + return m_materials[m_skin * m_matCount + matIndex]; } + /*! + * \brief Gets the material by index of the named submesh + * \return Pointer to the current material + * + * \param skinIndex Index of the skin + * \param subMeshName Name of the subMesh + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material index is invalid + */ + Material* Model::GetMaterial(unsigned int skinIndex, const String& subMeshName) const { #if NAZARA_GRAPHICS_SAFE @@ -118,9 +182,20 @@ namespace Nz return nullptr; } - return m_materials[skinIndex*m_matCount + matIndex]; + return m_materials[skinIndex * m_matCount + matIndex]; } + /*! + * \brief Gets the material by index with skin + * \return Pointer to the current material + * + * \param skinIndex Index of the skin + * \param matIndex Index of the material + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if matIndex is invalid + */ + Material* Model::GetMaterial(unsigned int skinIndex, unsigned int matIndex) const { #if NAZARA_GRAPHICS_SAFE @@ -137,49 +212,103 @@ namespace Nz } #endif - return m_materials[skinIndex*m_matCount + matIndex]; + return m_materials[skinIndex * m_matCount + matIndex]; } + /*! + * \brief Gets the number of materials + * \return Current number of materials + */ + unsigned int Model::GetMaterialCount() const { return m_matCount; } + /*! + * \brief Gets the mesh + * \return Current mesh + */ + Mesh* Model::GetMesh() const { return m_mesh; } + /*! + * \brief Gets the skin + * \return Current skin + */ + unsigned int Model::GetSkin() const { return m_skin; } + /*! + * \brief Gets the number of skins + * \return Current number of skins + */ + unsigned int Model::GetSkinCount() const { return m_skinCount; } + /*! + * \brief Checks whether the model is animated + * \return false + */ + bool Model::IsAnimated() const { return false; } + /*! + * \brief Loads the model from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the model + */ + bool Model::LoadFromFile(const String& filePath, const ModelParameters& params) { return ModelLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the model from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the model + */ + bool Model::LoadFromMemory(const void* data, std::size_t size, const ModelParameters& params) { return ModelLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the model from stream + * \return true if loading is successful + * + * \param stream Stream to the model + * \param params Parameters for the model + */ + bool Model::LoadFromStream(Stream& stream, const ModelParameters& params) { return ModelLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Resets the model, cleans everything + */ + void Model::Reset() { m_matCount = 0; @@ -192,6 +321,17 @@ namespace Nz } } + /*! + * \brief Sets the material of the named submesh + * \return true If successful + * + * \param subMeshName Name of the subMesh + * \param material Pointer to the material + * + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material index is invalid + */ + bool Model::SetMaterial(const String& subMeshName, Material* material) { SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName); @@ -208,7 +348,7 @@ namespace Nz return false; } - unsigned int index = m_skin*m_matCount + matIndex; + unsigned int index = m_skin * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -218,6 +358,16 @@ namespace Nz return true; } + /*! + * \brief Sets the material by index + * \return true If successful + * + * \param matIndex Index of the material + * \param material Pointer to the material + * + * \remark Produces a NazaraError with if NAZARA_GRAPHICS_SAFE defined index is invalid + */ + void Model::SetMaterial(unsigned int matIndex, Material* material) { #if NAZARA_GRAPHICS_SAFE @@ -228,7 +378,7 @@ namespace Nz } #endif - unsigned int index = m_skin*m_matCount + matIndex; + unsigned int index = m_skin * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -236,6 +386,19 @@ namespace Nz m_materials[index] = Material::GetDefault(); } + /*! + * \brief Sets the material by index of the named submesh + * \return true If successful + * + * \param skinIndex Index of the skin + * \param subMeshName Name of the subMesh + * \param material Pointer to the material + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material index is invalid + */ + bool Model::SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material) { #if NAZARA_GRAPHICS_SAFE @@ -260,7 +423,7 @@ namespace Nz return false; } - unsigned int index = skinIndex*m_matCount + matIndex; + unsigned int index = skinIndex * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -270,6 +433,18 @@ namespace Nz return true; } + /*! + * \brief Sets the material by index with skin + * \return true If successful + * + * \param skinIndex Index of the skin + * \param matIndex Index of the material + * \param material Pointer to the material + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if matIndex is invalid + */ + void Model::SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material) { #if NAZARA_GRAPHICS_SAFE @@ -286,7 +461,7 @@ namespace Nz } #endif - unsigned int index = skinIndex*m_matCount + matIndex; + unsigned int index = skinIndex * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -294,6 +469,14 @@ namespace Nz m_materials[index] = Material::GetDefault(); } + /*! + * \brief Sets the mesh + * + * \param pointer to the mesh + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if mesh is invalid + */ + void Model::SetMesh(Mesh* mesh) { #if NAZARA_GRAPHICS_SAFE @@ -323,6 +506,14 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Sets the skin + * + * \param skin Skin to use + * + * \remark Produces a NazaraError if skin is invalid + */ + void Model::SetSkin(unsigned int skin) { #if NAZARA_GRAPHICS_SAFE @@ -336,6 +527,14 @@ namespace Nz m_skin = skin; } + /*! + * \brief Sets the number of skins + * + * \param skinCount Number of skins + * + * \remark Produces a NazaraError if skinCount equals zero + */ + void Model::SetSkinCount(unsigned int skinCount) { #if NAZARA_GRAPHICS_SAFE @@ -350,6 +549,10 @@ namespace Nz m_skinCount = skinCount; } + /* + * \brief Makes the bounding volume of this billboard + */ + void Model::MakeBoundingVolume() const { if (m_mesh) diff --git a/src/Nazara/Graphics/ParticleController.cpp b/src/Nazara/Graphics/ParticleController.cpp index 252887246..d46bb1621 100644 --- a/src/Nazara/Graphics/ParticleController.cpp +++ b/src/Nazara/Graphics/ParticleController.cpp @@ -7,17 +7,44 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleController + * \brief Graphics class which controls a flow of particles + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a ParticleController object by assignation + * + * \param controller ParticleController to copy into this + */ + ParticleController::ParticleController(const ParticleController& controller) : RefCounted() { NazaraUnused(controller); } + /*! + * \brief Destructs the object and calls OnParticleControllerRelease + * + * \see OnParticleControllerRelease + */ + ParticleController::~ParticleController() { OnParticleControllerRelease(this); } + /*! + * \brief Initializes the particle controller librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle controller library failed to be initialized + */ + bool ParticleController::Initialize() { if (!ParticleControllerLibrary::Initialize()) @@ -29,6 +56,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle controller librairies + */ + void ParticleController::Uninitialize() { ParticleControllerLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index 8d68b88ce..ecd09c752 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -15,23 +15,54 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleDeclaration + * \brief Graphics class that represents the declaration of the particle, works like an ECS + */ + + /*! + * \brief Constructs a ParticleDeclaration object by default + */ + ParticleDeclaration::ParticleDeclaration() : m_stride(0) { } + /*! + * \brief Constructs a ParticleDeclaration object by assignation + * + * \param declaration ParticleDeclaration to copy into this + */ + ParticleDeclaration::ParticleDeclaration(const ParticleDeclaration& declaration) : RefCounted(), m_stride(declaration.m_stride) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(ParticleComponent_Max+1)); + std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); } + /*! + * \brief Destructs the object and calls OnParticleDeclarationRelease + * + * \see OnParticleDeclarationRelease + */ + ParticleDeclaration::~ParticleDeclaration() { OnParticleDeclarationRelease(this); } + /*! + * \brief Disables a component + * + * \param component Component to disable in the declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG defined if enumeration is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if enumeration is equal to ParticleComponent_Unused + */ + void ParticleDeclaration::DisableComponent(ParticleComponent component) { #ifdef NAZARA_DEBUG @@ -58,6 +89,17 @@ namespace Nz } } + /*! + * \brief Enables a component + * + * \param component Component to enable in the declaration + * \param type Type of this component + * \param offset Offset in the declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG defined if enumeration is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if type is not supported + */ + void ParticleDeclaration::EnableComponent(ParticleComponent component, ComponentType type, unsigned int offset) { #ifdef NAZARA_DEBUG @@ -91,6 +133,18 @@ namespace Nz m_stride += Utility::ComponentStride[type]; } + /*! + * \brief Gets a component + * + * \param component Component in the declaration + * \param enabled Optional argument to get if this component is enabled + * \param type Optional argument to get if the type of the component + * \param offset Optional argument to get if the offset in the declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG defined if enumeration is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if enumeration is equal to ParticleComponent_Unused + */ + void ParticleDeclaration::GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, unsigned int* offset) const { #ifdef NAZARA_DEBUG @@ -121,24 +175,51 @@ namespace Nz *offset = particleComponent.offset; } + /*! + * \brief Gets the stride of the declaration + * \return Stride of the declaration + */ + unsigned int ParticleDeclaration::GetStride() const { return m_stride; } + /*! + * \brief Sets the stride of the declaration + * + * \param stride Stride of the declaration + */ + void ParticleDeclaration::SetStride(unsigned int stride) { m_stride = stride; } + /*! + * \brief Sets the current particle declaration with the content of the other one + * \return A reference to this + * + * \param declaration The other ParticleDeclaration + */ + ParticleDeclaration& ParticleDeclaration::operator=(const ParticleDeclaration& declaration) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(ParticleComponent_Max+1)); + std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); m_stride = declaration.m_stride; return *this; } + /*! + * \brief Gets the particle declaration based on the layout + * \return Pointer to the declaration + * + * \param layout Layout of the particle declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG if enumeration is invalid + */ + ParticleDeclaration* ParticleDeclaration::Get(ParticleLayout layout) { #ifdef NAZARA_DEBUG @@ -152,6 +233,15 @@ namespace Nz return &s_declarations[layout]; } + /*! + * \brief Checks whether the type is supported + * \return true If it is the case + * + * \param type Type of the component + * + * \remark Produces a NazaraError if enumeration is invalid + */ + bool ParticleDeclaration::IsTypeSupported(ComponentType type) { switch (type) @@ -177,6 +267,14 @@ namespace Nz return false; } + /*! + * \brief Initializes the particle declaration librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle declaration library failed to be initialized + * \remark Produces a NazaraAssert if memory layout of declaration does not match the corresponding structure + */ + bool ParticleDeclaration::Initialize() { if (!ParticleDeclarationLibrary::Initialize()) @@ -231,11 +329,15 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle declaration librairies + */ + void ParticleDeclaration::Uninitialize() { ParticleDeclarationLibrary::Uninitialize(); } - ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max+1]; + ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max + 1]; ParticleDeclarationLibrary::LibraryMap ParticleDeclaration::s_library; } diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index 9e87eb7c0..ded77d80e 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -14,6 +14,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleEmitter + * \brief Graphics class that represents an emitter of particles + */ + + /*! + * \brief Constructs a ParticleEmitter object by default + */ + ParticleEmitter::ParticleEmitter() : m_lagCompensationEnabled(false), m_emissionAccumulator(0.f), @@ -24,28 +34,35 @@ namespace Nz ParticleEmitter::~ParticleEmitter() = default; + /*! + * \brief Emits particles according to the delta time between the previous frame + * + * \param system Particle system to work on + * \param elapsedTime Delta time between the previous frame + */ + void ParticleEmitter::Emit(ParticleSystem& system, float elapsedTime) const { if (m_emissionRate > 0.f) { - // On accumule la partie réelle (pour éviter qu'un taux d'update élevé empêche des particules de se former) - m_emissionAccumulator += elapsedTime*m_emissionRate; + // We accumulate the real part (to avoid that a high emission rate prevents particles to form) + m_emissionAccumulator += elapsedTime * m_emissionRate; - float emissionCount = std::floor(m_emissionAccumulator); // Le nombre d'émissions de cette mise à jour - m_emissionAccumulator -= emissionCount; // On enlève la partie entière + float emissionCount = std::floor(m_emissionAccumulator); // The number of emissions in this update + m_emissionAccumulator -= emissionCount; // We get rid off the integer part if (emissionCount >= 1.f) { - // On calcule le nombre maximum de particules pouvant être émises cette fois-ci + // We compute the maximum number of particles which can be emitted unsigned int emissionCountInt = static_cast(emissionCount); - unsigned int maxParticleCount = emissionCountInt*m_emissionCount; + unsigned int maxParticleCount = emissionCountInt * m_emissionCount; - // On récupère le nombre de particules qu'il est possible de créer selon l'espace libre + // We get the number of particles that we are able to create (depending on the free space) unsigned int particleCount = std::min(maxParticleCount, system.GetMaxParticleCount() - system.GetParticleCount()); if (particleCount == 0) return; - // Et on émet nos particules + // And we emit our particles void* particles = system.GenerateParticles(particleCount); ParticleMapper mapper(particles, system.GetDeclaration()); @@ -53,40 +70,73 @@ namespace Nz if (m_lagCompensationEnabled) { - // On va maintenant appliquer les contrôleurs - float invEmissionRate = 1.f/m_emissionRate; + // We will now apply our controllers + float invEmissionRate = 1.f / m_emissionRate; for (unsigned int i = 1; i <= emissionCountInt; ++i) - system.ApplyControllers(mapper, std::min(m_emissionCount*i, particleCount), invEmissionRate); + system.ApplyControllers(mapper, std::min(m_emissionCount * i, particleCount), invEmissionRate); } } } } + /*! + * \brief Enables the lag compensation + * + * \param enable Should lag compensation be enabled + */ + void ParticleEmitter::EnableLagCompensation(bool enable) { m_lagCompensationEnabled = enable; } + /*! + * \brief Gets the emission count + * \return Current emission count + */ + unsigned int ParticleEmitter::GetEmissionCount() const { return m_emissionCount; } + /*! + * \brief Gets the emission rate + * \return Current emission rate + */ + float ParticleEmitter::GetEmissionRate() const { return m_emissionRate; } + /*! + * \brief Checks whether the lag compensation is enabled + * \return true If it is the case + */ + bool ParticleEmitter::IsLagCompensationEnabled() const { return m_lagCompensationEnabled; } + /*! + * \brief Sets the emission count + * + * \param count Emission count + */ + void ParticleEmitter::SetEmissionCount(unsigned int count) { m_emissionCount = count; } + /*! + * \brief Sets the emission rate + * + * \param rate Emission rate + */ + void ParticleEmitter::SetEmissionRate(float rate) { m_emissionRate = rate; diff --git a/src/Nazara/Graphics/ParticleGenerator.cpp b/src/Nazara/Graphics/ParticleGenerator.cpp index d5e3b80ff..304a99e8c 100644 --- a/src/Nazara/Graphics/ParticleGenerator.cpp +++ b/src/Nazara/Graphics/ParticleGenerator.cpp @@ -7,17 +7,44 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleGenerator + * \brief Graphics class which generates particles + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a ParticleGenerator object by assignation + * + * \param generator ParticleGenerator to copy into this + */ + ParticleGenerator::ParticleGenerator(const ParticleGenerator& generator) : RefCounted() { NazaraUnused(generator); } + /*! + * \brief Destructs the object and calls OnParticleGeneratorRelease + * + * \see OnParticleGeneratorRelease + */ + ParticleGenerator::~ParticleGenerator() { OnParticleGeneratorRelease(this); } + /*! + * \brief Initializes the particle generator librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle generator library failed to be initialized + */ + bool ParticleGenerator::Initialize() { if (!ParticleGeneratorLibrary::Initialize()) @@ -29,6 +56,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle generator librairies + */ + void ParticleGenerator::Uninitialize() { ParticleGeneratorLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/ParticleMapper.cpp b/src/Nazara/Graphics/ParticleMapper.cpp index ce883e6e0..27a4b4075 100644 --- a/src/Nazara/Graphics/ParticleMapper.cpp +++ b/src/Nazara/Graphics/ParticleMapper.cpp @@ -8,6 +8,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleMapper + * \brief Graphics class that represents the mapping between the internal buffer and the particle declaration + */ + + /*! + * \brief Constructs a ParticleMapper object with a raw buffer and a particle declaration + * + * \param buffer Raw buffer to store particles data + * \param declaration Declaration of the particle + */ + ParticleMapper::ParticleMapper(void* buffer, const ParticleDeclaration* declaration) : m_declaration(declaration), m_ptr(static_cast(buffer)) diff --git a/src/Nazara/Graphics/ParticleRenderer.cpp b/src/Nazara/Graphics/ParticleRenderer.cpp index 96ff3dd8a..e5fa56c74 100644 --- a/src/Nazara/Graphics/ParticleRenderer.cpp +++ b/src/Nazara/Graphics/ParticleRenderer.cpp @@ -7,17 +7,42 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleRenderer + * \brief Graphics class that represents the rendering of the particle + */ + + /*! + * \brief Constructs a ParticleRenderer object by assignation + * + * \param renderer ParticleRenderer to copy into this + */ + ParticleRenderer::ParticleRenderer(const ParticleRenderer& renderer) : RefCounted() { NazaraUnused(renderer); } + /*! + * \brief Destructs the object and calls OnParticleRendererRelease + * + * \see OnParticleRendererRelease + */ + ParticleRenderer::~ParticleRenderer() { OnParticleRendererRelease(this); } + /*! + * \brief Initializes the particle renderer librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle renderer library failed to be initialized + */ + bool ParticleRenderer::Initialize() { if (!ParticleRendererLibrary::Initialize()) @@ -29,6 +54,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle renderer librairies + */ + void ParticleRenderer::Uninitialize() { ParticleRendererLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/ParticleSystem.cpp b/src/Nazara/Graphics/ParticleSystem.cpp index 2ac54e4af..0783dd7fd 100644 --- a/src/Nazara/Graphics/ParticleSystem.cpp +++ b/src/Nazara/Graphics/ParticleSystem.cpp @@ -13,25 +13,51 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleSystem + * \brief Graphics class that represents the system to handle particles + */ + + /*! + * \brief Constructs a ParticleSystem object with a maximal number of particles and a layout + * + * \param maxParticleCount Maximum number of particles to generate + * \param layout Enumeration for the layout of data information for the particles + */ + ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout) : ParticleSystem(maxParticleCount, ParticleDeclaration::Get(layout)) { } + /*! + * \brief Constructs a ParticleSystem object with a maximal number of particles and a particle declaration + * + * \param maxParticleCount Maximum number of particles to generate + * \param declaration Data information for the particles + */ + ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : m_declaration(std::move(declaration)), m_processing(false), m_maxParticleCount(maxParticleCount), m_particleCount(0) { - // En cas d'erreur, un constructeur ne peut que lancer une exception + // In case of error, the constructor can only throw an exception ErrorFlags flags(ErrorFlag_ThrowException, true); - m_particleSize = m_declaration->GetStride(); // La taille de chaque particule + m_particleSize = m_declaration->GetStride(); // The size of each particle ResizeBuffer(); } + /*! + * \brief Constructs a ParticleSystem object by assignation + * + * \param system ParticleSystem to copy into this + */ + ParticleSystem::ParticleSystem(const ParticleSystem& system) : Renderable(system), m_controllers(system.m_controllers), @@ -47,12 +73,20 @@ namespace Nz ResizeBuffer(); - // On ne copie que les particules vivantes + // We only copy alive particles std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); } ParticleSystem::~ParticleSystem() = default; + /*! + * \brief Adds a controller to the particles + * + * \param controller Controller for the particles + * + * \remark Produces a NazaraAssert if controller is invalid + */ + void ParticleSystem::AddController(ParticleControllerRef controller) { NazaraAssert(controller, "Invalid particle controller"); @@ -60,6 +94,14 @@ namespace Nz m_controllers.emplace_back(std::move(controller)); } + /*! + * \brief Adds an emitter to the particles + * + * \param emitter Emitter for the particles + * + * \remark Produces a NazaraAssert if emitter is invalid + */ + void ParticleSystem::AddEmitter(ParticleEmitter* emitter) { NazaraAssert(emitter, "Invalid particle emitter"); @@ -67,6 +109,14 @@ namespace Nz m_emitters.emplace_back(emitter); } + /*! + * \brief Adds a generator to the particles + * + * \param generator Generator for the particles + * + * \remark Produces a NazaraAssert if generator is invalid + */ + void ParticleSystem::AddGenerator(ParticleGeneratorRef generator) { NazaraAssert(generator, "Invalid particle generator"); @@ -74,6 +124,16 @@ namespace Nz m_generators.emplace_back(std::move(generator)); } + /*! + * \brief Adds the particle system to the rendering queue + * + * \param renderQueue Queue to be added + * \param transformMatrix Transformation matrix for the system + * + * \remark Produces a NazaraAssert if inner renderer is invalid + * \remark Produces a NazaraAssert if renderQueue is invalid + */ + void ParticleSystem::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const { NazaraAssert(m_renderer, "Invalid particle renderer"); @@ -83,45 +143,63 @@ namespace Nz if (m_particleCount > 0) { ParticleMapper mapper(m_buffer.data(), m_declaration); - m_renderer->Render(*this, mapper, 0, m_particleCount-1, renderQueue); + m_renderer->Render(*this, mapper, 0, m_particleCount - 1, renderQueue); } } + /*! + * \brief Applies the controllers + * + * \param mapper Mapper containing layout information of each particle + * \param particleCount Number of particles + * \param elapsedTime Delta time between the previous frame + */ + void ParticleSystem::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) { m_processing = true; - // Pour éviter un verrouillage en cas d'exception + // To avoid a lock in case of exception CallOnExit onExit([this]() { m_processing = false; }); for (ParticleController* controller : m_controllers) - controller->Apply(*this, mapper, 0, particleCount-1, elapsedTime); + controller->Apply(*this, mapper, 0, particleCount - 1, elapsedTime); onExit.CallAndReset(); - // On tue maintenant les particules mortes durant la mise à jour + // We only kill now the dead particles during the update if (m_dyingParticles.size() < m_particleCount) { - // On tue les particules depuis la dernière vers la première (en terme de place), le std::set étant trié via std::greater - // La raison est simple, étant donné que la mort d'une particule signifie le déplacement de la dernière particule du buffer, - // sans cette solution certaines particules pourraient échapper à la mort + // We kill them in reverse order, std::set sorting them via std::greater + // The reason is simple, as the death of a particle means the move of the last particle in the buffer, + // without this solution, certain particles could avoid the death for (unsigned int index : m_dyingParticles) KillParticle(index); } else - KillParticles(); // Toutes les particules sont mortes, ceci est beaucoup plus rapide + KillParticles(); // Every particles are dead, this is way faster m_dyingParticles.clear(); } + /*! + * \brief Creates one particle + * \return Pointer to the particle memory buffer + */ + void* ParticleSystem::CreateParticle() { return CreateParticles(1); } + /*! + * \brief Creates multiple particles + * \return Pointer to the first particle memory buffer + */ + void* ParticleSystem::CreateParticles(unsigned int count) { if (count == 0) @@ -133,14 +211,24 @@ namespace Nz unsigned int particlesIndex = m_particleCount; m_particleCount += count; - return &m_buffer[particlesIndex*m_particleSize]; + return &m_buffer[particlesIndex * m_particleSize]; } + /*! + * \brief Generates one particle + * \return Pointer to the particle memory buffer + */ + void* ParticleSystem::GenerateParticle() { return GenerateParticles(1); } + /*! + * \brief Generates multiple particles + * \return Pointer to the first particle memory buffer + */ + void* ParticleSystem::GenerateParticles(unsigned int count) { void* ptr = CreateParticles(count); @@ -149,57 +237,108 @@ namespace Nz ParticleMapper mapper(ptr, m_declaration); for (ParticleGenerator* generator : m_generators) - generator->Generate(*this, mapper, 0, count-1); + generator->Generate(*this, mapper, 0, count - 1); return ptr; } + /*! + * \brief Gets the particle declaration + * \return Particle declaration + */ + const ParticleDeclarationConstRef& ParticleSystem::GetDeclaration() const { return m_declaration; } + /*! + * \brief Gets the fixed step size + * \return Current fixed step size + */ + float ParticleSystem::GetFixedStepSize() const { return m_stepSize; } + /*! + * \brief Gets the maximum number of particles + * \return Current maximum number + */ + unsigned int ParticleSystem::GetMaxParticleCount() const { return m_maxParticleCount; } + /*! + * \brief Gets the number of particles + * \return Current number + */ + unsigned int ParticleSystem::GetParticleCount() const { return m_particleCount; } + /*! + * \brief Gets the size of particles + * \return Current size + */ + unsigned int ParticleSystem::GetParticleSize() const { return m_particleSize; } + /*! + * \brief Checks whether the fixed step is enabled + * \return true If it is the case + */ + + bool ParticleSystem::IsFixedStepEnabled() const + { + return m_fixedStepEnabled; + } + + /*! + * \brief Kills one particle + * + * \param index Index of the particle + */ + void ParticleSystem::KillParticle(unsigned int index) { - ///FIXME: Vérifier index + ///FIXME: Verify the index if (m_processing) { - // Le buffer est en train d'être modifié, nous ne pouvons pas réduire sa taille, on place alors la particule dans une liste d'attente + // The buffer is being modified, we can not reduce its size, we put the particle in the waiting list m_dyingParticles.insert(index); return; } - // On déplace la dernière particule vivante à la place de celle-ci + // We move the last alive particle to the place of this one if (--m_particleCount > 0) - std::memcpy(&m_buffer[index*m_particleSize], &m_buffer[m_particleCount*m_particleSize], m_particleSize); + std::memcpy(&m_buffer[index * m_particleSize], &m_buffer[m_particleCount * m_particleSize], m_particleSize); } + /*! + * \brief Kills every particles + */ + void ParticleSystem::KillParticles() { m_particleCount = 0; } + /*! + * \brief Removes a controller to the particles + * + * \param controller Controller for the particles to remove + */ + void ParticleSystem::RemoveController(ParticleController* controller) { auto it = std::find(m_controllers.begin(), m_controllers.end(), controller); @@ -207,6 +346,12 @@ namespace Nz m_controllers.erase(it); } + /*! + * \brief Removes an emitter to the particles + * + * \param emitter Emitter for the particles to remove + */ + void ParticleSystem::RemoveEmitter(ParticleEmitter* emitter) { auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter); @@ -214,6 +359,12 @@ namespace Nz m_emitters.erase(it); } + /*! + * \brief Removes a generator to the particles + * + * \param generator Generator for the particles to remove + */ + void ParticleSystem::RemoveGenerator(ParticleGenerator* generator) { auto it = std::find(m_generators.begin(), m_generators.end(), generator); @@ -221,31 +372,55 @@ namespace Nz m_generators.erase(it); } + /*! + * \brief Sets the fixed step size + * + * \param stepSize Fixed step size + */ + void ParticleSystem::SetFixedStepSize(float stepSize) { m_stepSize = stepSize; } + /*! + * \brief Sets the renderer of the particles + * + * \param renderer Renderer for the particles + */ + void ParticleSystem::SetRenderer(ParticleRenderer* renderer) { m_renderer = renderer; } + /*! + * \brief Updates the system + * + * \param elapsedTime Delta time between the previous frame + */ + void ParticleSystem::Update(float elapsedTime) { - // Émission + // Emission for (ParticleEmitter* emitter : m_emitters) emitter->Emit(*this, elapsedTime); - // Mise à jour + // Update if (m_particleCount > 0) { - ///TODO: Mettre à jour en utilisant des threads + ///TODO: Update using threads ParticleMapper mapper(m_buffer.data(), m_declaration); ApplyControllers(mapper, m_particleCount, elapsedTime); } } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + */ + void ParticleSystem::UpdateBoundingVolume(const Matrix4f& transformMatrix) { NazaraUnused(transformMatrix); @@ -253,6 +428,13 @@ namespace Nz // Nothing to do here (our bounding volume is global) } + /*! + * \brief Sets the current particle system with the content of the other one + * \return A reference to this + * + * \param system The other ParticleSystem + */ + ParticleSystem& ParticleSystem::operator=(const ParticleSystem& system) { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -268,29 +450,39 @@ namespace Nz m_renderer = system.m_renderer; m_stepSize = system.m_stepSize; - // La copie ne peut pas (ou plutôt ne devrait pas) avoir lieu pendant une mise à jour, inutile de copier + // The copy can not (or should not) happen during the update, there is no use to copy m_dyingParticles.clear(); m_processing = false; m_stepAccumulator = 0.f; - m_buffer.clear(); // Pour éviter une recopie lors du resize() qui ne servira pas à grand chose + m_buffer.clear(); // To avoid a copy due to resize() which will be pointless ResizeBuffer(); - // On ne copie que les particules vivantes - std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); + // We only copy alive particles + std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount * m_particleSize); return *this; } + /*! + * \brief Makes the bounding volume of this text + */ + void ParticleSystem::MakeBoundingVolume() const { - ///TODO: Calculer l'AABB (prendre la taille des particules en compte s'il y a) + ///TODO: Compute the AABB (taking into account the size of particles) m_boundingVolume.MakeInfinite(); } + /*! + * \brief Resizes the internal buffer + * + * \remark Produces a NazaraError if resize did not work + */ + void ParticleSystem::ResizeBuffer() { - // Histoire de décrire un peu mieux l'erreur en cas d'échec + // Just to have a better description of our problem in case of error try { m_buffer.resize(m_maxParticleCount*m_particleSize); diff --git a/src/Nazara/Graphics/RenderTechniques.cpp b/src/Nazara/Graphics/RenderTechniques.cpp index df3eb5582..46d84d9c4 100644 --- a/src/Nazara/Graphics/RenderTechniques.cpp +++ b/src/Nazara/Graphics/RenderTechniques.cpp @@ -23,7 +23,7 @@ namespace Nz "User" }; - static_assert(sizeof(techniquesName)/sizeof(const char*) == RenderTechniqueType_Max+1, "Render technique type name array is incomplete"); + static_assert(sizeof(techniquesName) / sizeof(const char*) == RenderTechniqueType_Max + 1, "Render technique type name array is incomplete"); struct RenderTechnique { @@ -34,6 +34,22 @@ namespace Nz std::unordered_map s_renderTechniques; } + /*! + * \ingroup graphics + * \class Nz::RenderTechniques + * \brief Graphics class that represents the techniques used in rendering + */ + + /*! + * \brief Gets the technique by enumeration + * \return A reference to the newly created technique + * + * \param renderTechnique Enumeration of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if renderTechnique does not exist + */ + AbstractRenderTechnique* RenderTechniques::GetByEnum(RenderTechniqueType renderTechnique, int* techniqueRanking) { #ifdef NAZARA_DEBUG @@ -47,6 +63,16 @@ namespace Nz return GetByName(techniquesName[renderTechnique], techniqueRanking); } + /*! + * \brief Gets the technique by index + * \return A reference to the newly created technique + * + * \param index Index of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if index is out or range + */ + AbstractRenderTechnique* RenderTechniques::GetByIndex(unsigned int index, int* techniqueRanking) { #if NAZARA_GRAPHICS_SAFE @@ -66,6 +92,16 @@ namespace Nz return it->second.factory(); } + /*! + * \brief Gets the technique by name + * \return A reference to the newly created technique + * + * \param name Name of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if name does not exist or is invalid + */ + AbstractRenderTechnique* RenderTechniques::GetByName(const String& name, int* techniqueRanking) { #if NAZARA_GRAPHICS_SAFE @@ -89,6 +125,16 @@ namespace Nz return it->second.factory(); } + /*! + * \brief Gets the technique by ranking + * \return A reference to the newly created technique + * + * \param maxRanking Ranking maximum of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if name does not exist or is invalid + */ + AbstractRenderTechnique* RenderTechniques::GetByRanking(int maxRanking, int* techniqueRanking) { if (maxRanking < 0) @@ -119,11 +165,28 @@ namespace Nz return technique->factory(); } + /*! + * \brief Gets the number of techniques available + * \return Number of techniques + */ + unsigned int RenderTechniques::GetCount() { return s_renderTechniques.size(); } + /*! + * \brief Registers a technique + * + * \param name Name of the technique + * \param ranking Ranking of the technique + * \param factory Factory to create the technique + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if name is empty + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if ranking is negative + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if factory is invalid is invalid + */ + void RenderTechniques::Register(const String& name, int ranking, RenderTechniqueFactory factory) { #if NAZARA_GRAPHICS_SAFE @@ -149,6 +212,15 @@ namespace Nz s_renderTechniques[name] = {factory, ranking}; } + /*! + * \brief Converts the enumeration to string + * \return String symbolizing the technique + * + * \param renderTechnique Enumeration of the technique + * + * \remark Produces a NazaraError if renderTechnique does not exist and returns "Error" + */ + String RenderTechniques::ToString(RenderTechniqueType renderTechnique) { #ifdef NAZARA_DEBUG @@ -162,6 +234,12 @@ namespace Nz return techniquesName[renderTechnique]; } + /*! + * \brief Unregisters a technique + * + * \param name Name of the technique + */ + void RenderTechniques::Unregister(const String& name) { s_renderTechniques.erase(name); diff --git a/src/Nazara/Graphics/Renderable.cpp b/src/Nazara/Graphics/Renderable.cpp index 932a8d127..5b02cd5cb 100644 --- a/src/Nazara/Graphics/Renderable.cpp +++ b/src/Nazara/Graphics/Renderable.cpp @@ -7,8 +7,24 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Renderable + * \brief Graphics class that represents a renderable element for our scene + * + * \remark This class is abstract + */ + Renderable::~Renderable() = default; + /*! + * \brief Culls the model if not in the frustum + * \return true If renderable is in the frustum + * + * \param frustum Symbolizing the field of view + * \param transformMatrix Matrix transformation for our object + */ + bool Renderable::Cull(const Frustumf& frustum, const Matrix4f& transformMatrix) const { NazaraUnused(transformMatrix); @@ -16,6 +32,11 @@ namespace Nz return frustum.Contains(m_boundingVolume); } + /*! + * \brief Gets the bounding volume + * \return Bounding volume of the renderable element + */ + const BoundingVolumef& Renderable::GetBoundingVolume() const { EnsureBoundingVolumeUpdated(); @@ -23,6 +44,12 @@ namespace Nz return m_boundingVolume; } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + */ + void Renderable::UpdateBoundingVolume(const Matrix4f& transformMatrix) { m_boundingVolume.Update(transformMatrix); diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index 12bf10b6d..b91ac0076 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -14,6 +14,17 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::SkeletalModel + * \brief Graphics class that represents a model with a skeleton + */ + + /*! + * \brief Checks whether the parameters for the skeletal mesh are correct + * \return true If parameters are valid + */ + bool SkeletalModelParameters::IsValid() const { if (!ModelParameters::IsValid()) @@ -25,12 +36,23 @@ namespace Nz return true; } + /*! + * \brief Constructs a SkeletalModel object by default + */ + SkeletalModel::SkeletalModel() : m_currentSequence(nullptr), m_animationEnabled(true) { } + /*! + * \brief Adds the skeletal mesh to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void SkeletalModel::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_mesh) @@ -51,6 +73,14 @@ namespace Nz } } + /*! + * \brief Updates the animation of the mesh + * + * \param elapsedTime Delta time between two frames + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if there is no animation + */ + void SkeletalModel::AdvanceAnimation(float elapsedTime) { #if NAZARA_GRAPHICS_SAFE @@ -67,7 +97,7 @@ namespace Nz m_interpolation -= 1.f; unsigned lastFrame = m_currentSequence->firstFrame + m_currentSequence->frameCount - 1; - if (m_nextFrame+1 > lastFrame) + if (m_nextFrame + 1 > lastFrame) { if (m_animation->IsLoopPointInterpolationEnabled()) { @@ -77,7 +107,7 @@ namespace Nz else { m_currentFrame = m_currentSequence->firstFrame; - m_nextFrame = m_currentFrame+1; + m_nextFrame = m_currentFrame + 1; } } else @@ -92,26 +122,52 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Clones this skeletal model + * \return Pointer to newly allocated SkeletalModel + */ + SkeletalModel* SkeletalModel::Clone() const { return new SkeletalModel(*this); } + /*! + * \brief Creates a default skeletal model + * \return Pointer to newly allocated SkeletalModel + */ + SkeletalModel* SkeletalModel::Create() const { return new SkeletalModel; } + /*! + * \brief Enables the animation of the model + * + * \param animation Should the model be animated + */ + void SkeletalModel::EnableAnimation(bool animation) { m_animationEnabled = animation; } + /*! + * \brief Gets the animation of the model + * \return Pointer to the animation + */ + Animation* SkeletalModel::GetAnimation() const { return m_animation; } + /*! + * \brief Gets the skeleton of the model + * \return Pointer to the skeleton + */ + Skeleton* SkeletalModel::GetSkeleton() { InvalidateBoundingVolume(); @@ -119,41 +175,96 @@ namespace Nz return &m_skeleton; } + /*! + * \brief Gets the skeleton of the model + * \return Constant pointer to the skeleton + */ + const Skeleton* SkeletalModel::GetSkeleton() const { return &m_skeleton; } + /*! + * \brief Checks whether the skeleton has an animation + * \return true If it is the case + * + * \see IsAnimated, IsAnimationEnabled + */ + bool SkeletalModel::HasAnimation() const { return m_animation != nullptr; } + /*! + * \brief Checks whether the skeleton is animated + * \return true + * + * \see HasAnimation, IsAnimationEnabled + */ + bool SkeletalModel::IsAnimated() const { return true; } + /*! + * \brief Checks whether the skeleton is currently animated + * \return true If it is the case + * + * \see HasAnimation, IsAnimated + */ + bool SkeletalModel::IsAnimationEnabled() const { return m_animationEnabled; } + /*! + * \brief Loads the skeleton model from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the skeleton model + */ + bool SkeletalModel::LoadFromFile(const String& filePath, const SkeletalModelParameters& params) { return SkeletalModelLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the skeleton model from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the skeleton model + */ + bool SkeletalModel::LoadFromMemory(const void* data, std::size_t size, const SkeletalModelParameters& params) { return SkeletalModelLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the skeleton model from stream + * \return true if loading is successful + * + * \param stream Stream to the skeleton model + * \param params Parameters for the skeleton model + */ + bool SkeletalModel::LoadFromStream(Stream& stream, const SkeletalModelParameters& params) { return SkeletalModelLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Resets the model + */ + void SkeletalModel::Reset() { Model::Reset(); @@ -161,6 +272,16 @@ namespace Nz m_skeleton.Destroy(); } + /*! + * \brief Sets the animation for the model + * \return true If successful + * + * \param animation Animation for the model + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if animation is invalid + */ + bool SkeletalModel::SetAnimation(Animation* animation) { #if NAZARA_GRAPHICS_SAFE @@ -204,6 +325,14 @@ namespace Nz return true; } + /*! + * \brief Sets the mesh for the model + * + * \param mesh Mesh for the model + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh or if invalid + */ + void SkeletalModel::SetMesh(Mesh* mesh) { #if NAZARA_GRAPHICS_SAFE @@ -224,13 +353,23 @@ namespace Nz SetAnimation(nullptr); } - m_skeleton = *m_mesh->GetSkeleton(); // Copie du squelette template + m_skeleton = *m_mesh->GetSkeleton(); // Copy of skeleton template } } + /*! + * \brief Sets the sequence for the model + * \return true If successful + * + * \param sequenceName Name for the sequence animation + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation + */ + bool SkeletalModel::SetSequence(const String& sequenceName) { - ///TODO: Rendre cette erreur "safe" avec le nouveau système de gestions d'erreur (No-log) + ///TODO: Make this error "safe" with the new system of error handling (No-log) #if NAZARA_GRAPHICS_SAFE if (!m_animation) { @@ -240,11 +379,13 @@ namespace Nz #endif const Sequence* currentSequence = m_animation->GetSequence(sequenceName); + #if NAZARA_GRAPHICS_SAFE if (!currentSequence) { NazaraError("Sequence not found"); return false; } + #endif m_currentSequence = currentSequence; m_nextFrame = m_currentSequence->firstFrame; @@ -252,6 +393,15 @@ namespace Nz return true; } + /*! + * \brief Sets the sequence for the model + * + * \param sequenceIndex Index for the sequence animation + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation + */ + void SkeletalModel::SetSequence(unsigned int sequenceIndex) { #if NAZARA_GRAPHICS_SAFE @@ -275,13 +425,22 @@ namespace Nz m_nextFrame = m_currentSequence->firstFrame; } + /* + * \brief Makes the bounding volume of this text + */ + void SkeletalModel::MakeBoundingVolume() const { m_boundingVolume.Set(m_skeleton.GetAABB()); } + /*! + * \brief Updates the model + */ + void SkeletalModel::Update() { + ///TODO /*if (m_animationEnabled && m_animation) AdvanceAnimation(m_scene->GetUpdateTime());*/ } diff --git a/src/Nazara/Graphics/SkinningManager.cpp b/src/Nazara/Graphics/SkinningManager.cpp index 0f4b3140a..7391eeea6 100644 --- a/src/Nazara/Graphics/SkinningManager.cpp +++ b/src/Nazara/Graphics/SkinningManager.cpp @@ -46,6 +46,13 @@ namespace Nz SkeletonMap s_cache; std::vector s_skinningQueue; + /*! + * \brief Skins the mesh for a single thread context + * + * \param mesh Skeletal mesh to get vertex buffer from + * \param skeleton Skeleton to consider for getting data + * \param buffer Vertex buffer symbolizing the transition + */ void Skin_MonoCPU(const SkeletalMesh* mesh, const Skeleton* skeleton, VertexBuffer* buffer) { @@ -60,6 +67,14 @@ namespace Nz SkinPositionNormalTangent(skinningData, 0, mesh->GetVertexCount()); } + /*! + * \brief Skins the mesh for a multi-threaded context + * + * \param mesh Skeletal mesh to get vertex buffer from + * \param skeleton Skeleton to consider for getting data + * \param buffer Vertex buffer symbolizing the transition + */ + void Skin_MultiCPU(const SkeletalMesh* mesh, const Skeleton* skeleton, VertexBuffer* buffer) { BufferMapper inputMapper(mesh->GetVertexBuffer(), BufferAccess_ReadOnly); @@ -70,8 +85,8 @@ namespace Nz skinningData.outputVertex = static_cast(outputMapper.GetPointer()); skinningData.joints = skeleton->GetJoints(); - // Afin d'empêcher les différents threads de vouloir mettre à jour la même matrice en même temps, - // on se charge de la mettre à jour avant de les lancer + // To avoid different threads to update the same matrix at the same time + // We try to update them before launching the tasks unsigned int jointCount = skeleton->GetJointCount(); for (unsigned int i = 0; i < jointCount; ++i) skinningData.joints[i].EnsureSkinningMatrixUpdate(); @@ -87,6 +102,23 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::SkinningManager + * \brief Graphics class that represents the management of skinning + */ + + /*! + * \brief Gets the vertex buffer from a skeletal mesh with its skeleton + * \return A pointer to the vertex buffer newly created + * + * \param mesh Skeletal mesh to get vertex buffer from + * \param skeleton Skeleton to consider for getting data + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if mesh is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skeleton is invalid + */ + VertexBuffer* SkinningManager::GetBuffer(const SkeletalMesh* mesh, const Skeleton* skeleton) { #if NAZARA_GRAPHICS_SAFE @@ -149,6 +181,10 @@ namespace Nz return buffer; } + /*! + * \brief Skins the skeletal mesh + */ + void SkinningManager::Skin() { for (QueueData& data : s_skinningQueue) @@ -157,6 +193,11 @@ namespace Nz s_skinningQueue.clear(); } + /*! + * \brief Initializes the skinning librairies + * \return true + */ + bool SkinningManager::Initialize() { ///TODO: GPU Skinning @@ -165,9 +206,15 @@ namespace Nz else s_skinFunc = Skin_MonoCPU; - return true; // Rien de particulier à faire + return true; // Nothing particular to do } + /*! + * \brief Handle the destruction of a skeletal mesh + * + * \param mesh SkeletalMesh being destroyed + */ + void SkinningManager::OnSkeletalMeshDestroy(const SkeletalMesh* mesh) { for (auto& pair : s_cache) @@ -177,17 +224,33 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a skeletal mesh + * + * \param mesh SkeletalMesh being invalidated + */ + void SkinningManager::OnSkeletonInvalidated(const Skeleton* skeleton) { for (auto& pair : s_cache.at(skeleton).meshMap) pair.second.updated = false; } + /*! + * \brief Handle the release of a skeletal mesh + * + * \param skeleton SkeletalMesh being released + */ + void SkinningManager::OnSkeletonRelease(const Skeleton* skeleton) { s_cache.erase(skeleton); } + /*! + * \brief Uninitializes the skinning librairies + */ + void SkinningManager::Uninitialize() { s_cache.clear(); diff --git a/src/Nazara/Graphics/SkyboxBackground.cpp b/src/Nazara/Graphics/SkyboxBackground.cpp index a70a9dd2d..75bc0cc12 100644 --- a/src/Nazara/Graphics/SkyboxBackground.cpp +++ b/src/Nazara/Graphics/SkyboxBackground.cpp @@ -22,6 +22,18 @@ namespace Nz static VertexBufferRef s_vertexBuffer; } + /*! + * \ingroup graphics + * \class Nz::SkyboxBackground + * \brief Graphics class that represents a background with a cubemap texture + */ + + /*! + * \brief Constructs a SkyboxBackground object with a cubemap texture + * + * \param cubemapTexture Cubemap texture + */ + SkyboxBackground::SkyboxBackground(TextureRef cubemapTexture) : m_movementOffset(Vector3f::Zero()), m_movementScale(0.f) @@ -31,6 +43,12 @@ namespace Nz SetTexture(std::move(cubemapTexture)); } + /*! + * \brief Draws this relatively to the viewer + * + * \param viewer Viewer for the background + */ + void SkyboxBackground::Draw(const AbstractViewer* viewer) const { Matrix4f skyboxMatrix(viewer->GetViewMatrix()); @@ -65,14 +83,26 @@ namespace Nz Renderer::SetMatrix(MatrixType_View, viewer->GetViewMatrix()); } + /*! + * \brief Gets the background type + * \return Type of background + */ + BackgroundType SkyboxBackground::GetBackgroundType() const { return BackgroundType_Skybox; } + /*! + * \brief Initializes the skybox + * \return true If successful + * + * \remark Produces a NazaraError if initialization failed + */ + bool SkyboxBackground::Initialize() { - const UInt16 indices[6*6] = + const UInt16 indices[6 * 6] = { 0, 1, 2, 0, 2, 3, 3, 2, 6, 3, 6, 7, @@ -170,6 +200,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the skybox + */ + void SkyboxBackground::Uninitialize() { s_indexBuffer.Reset(); diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index fd4ab758f..76bf5fff2 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -11,6 +11,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Sprite + * \brief Graphics class that represents the rendering of a sprite + */ + + /*! + * \brief Adds the sprite to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void Sprite::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_material) @@ -20,11 +33,21 @@ namespace Nz renderQueue->AddSprites(instanceData.renderOrder, m_material, vertices, 1); } + /*! + * \brief Makes the bounding volume of this text + */ + void Sprite::MakeBoundingVolume() const { m_boundingVolume.Set(Vector3f(0.f), m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); } + /*! + * \brief Updates the data of the sprite + * + * \param instanceData Data of the instance + */ + void Sprite::UpdateData(InstanceData* instanceData) const { instanceData->data.resize(4 * sizeof(VertexStruct_XYZ_Color_UV)); @@ -51,6 +74,13 @@ namespace Nz *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } + /*! + * \brief Initializes the sprite librairies + * \return true If successful + * + * \remark Produces a NazaraError if the sprite library failed to be initialized + */ + bool Sprite::Initialize() { if (!SpriteLibrary::Initialize()) @@ -62,6 +92,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the sprite librairies + */ + void Sprite::Uninitialize() { SpriteLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 6d0e41f52..3459b22cd 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -13,6 +13,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::TextSprite + * \brief Graphics class that represents the rendering of a sprite containing text + */ + + /*! + * \brief Adds the text to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void TextSprite::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_material) @@ -26,11 +39,19 @@ namespace Nz if (indices.count > 0) { const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(instanceData.data.data()); - renderQueue->AddSprites(instanceData.renderOrder, m_material, &vertices[indices.first*4], indices.count, overlay); + renderQueue->AddSprites(instanceData.renderOrder, m_material, &vertices[indices.first * 4], indices.count, overlay); } } } + /*! + * \brief Updates the text + * + * \param drawer Drawer used to compose the text + * + * \remark Produces a NazaraAssert if atlas does not use a hardware storage + */ + void TextSprite::Update(const AbstractTextDrawer& drawer) { CallOnExit clearOnFail([this]() @@ -138,8 +159,8 @@ namespace Nz // First, compute the uv coordinates from our atlas rect Vector2ui size(texture->GetSize()); - float invWidth = 1.f/size.x; - float invHeight = 1.f/size.y; + float invWidth = 1.f / size.x; + float invHeight = 1.f / size.y; Rectf uvRect(glyph.atlasRect); uvRect.x *= invWidth; @@ -155,9 +176,9 @@ namespace Nz for (unsigned int j = 0; j < 4; ++j) { // Remember that indices->count is a counter here, not a count value - m_localVertices[indices->count*4 + j].color = glyph.color; - m_localVertices[indices->count*4 + j].position.Set(glyph.corners[j]); - m_localVertices[indices->count*4 + j].uv.Set(uvRect.GetCorner((glyph.flipped) ? flippedCorners[j] : normalCorners[j])); + m_localVertices[indices->count * 4 + j].color = glyph.color; + m_localVertices[indices->count * 4 + j].position.Set(glyph.corners[j]); + m_localVertices[indices->count * 4 + j].uv.Set(uvRect.GetCorner((glyph.flipped) ? flippedCorners[j] : normalCorners[j])); } // Increment the counter, go to next glyph @@ -172,15 +193,25 @@ namespace Nz clearOnFail.Reset(); } + /* + * \brief Makes the bounding volume of this text + */ + void TextSprite::MakeBoundingVolume() const { Rectf bounds(m_localBounds); Vector2f max = bounds.GetMaximum(); Vector2f min = bounds.GetMinimum(); - m_boundingVolume.Set(min.x*Vector3f::Right() + min.y*Vector3f::Down(), max.x*Vector3f::Right() + max.y*Vector3f::Down()); + m_boundingVolume.Set(min.x * Vector3f::Right() + min.y * Vector3f::Down(), max.x * Vector3f::Right() + max.y * Vector3f::Down()); } + /*! + * \brief Handle the invalidation of an atlas + * + * \param atlas Atlas being invalidated + */ + void TextSprite::OnAtlasInvalidated(const AbstractAtlas* atlas) { #ifdef NAZARA_DEBUG @@ -195,6 +226,14 @@ namespace Nz Clear(); } + /*! + * \brief Handle the invalidation of an atlas layer + * + * \param atlas Atlas being invalidated + * \param oldLayer Pointer to the previous layer + * \param newLayer Pointer to the new layer + */ + void TextSprite::OnAtlasLayerChange(const AbstractAtlas* atlas, AbstractImage* oldLayer, AbstractImage* newLayer) { NazaraUnused(atlas); @@ -207,23 +246,23 @@ namespace Nz } #endif - // La texture d'un atlas vient d'être recréée (changement de taille) - // nous devons ajuster les coordonnées de textures et la texture du rendu + // The texture of an atlas have just been recreated (size change) + // we have to adjust the coordinates of the texture and the rendering texture Texture* oldTexture = static_cast(oldLayer); Texture* newTexture = static_cast(newLayer); - // Il est possible que nous n'utilisions pas la texture en question (l'atlas nous prévenant pour chacun de ses layers) + // It is possible that we don't use the texture (the atlas warning us for each of its layers) auto it = m_renderInfos.find(oldTexture); if (it != m_renderInfos.end()) { - // Nous utilisons bien cette texture, nous devons mettre à jour les coordonnées de texture + // We indeed use this texture, we have to update its coordinates RenderIndices indices = std::move(it->second); Vector2ui oldSize(oldTexture->GetSize()); Vector2ui newSize(newTexture->GetSize()); - Vector2f scale = Vector2f(oldSize)/Vector2f(newSize); // ratio ancienne et nouvelle taille + Vector2f scale = Vector2f(oldSize) / Vector2f(newSize); // ratio of the old one to the new one - // On va maintenant parcourir toutes les coordonnées de texture concernées pour les multiplier par ce ratio + // Now we will iterate through each coordinates of the concerned texture to multiply them by the ratio SparsePtr texCoordPtr(&m_localVertices[indices.first].uv, sizeof(VertexStruct_XYZ_Color_UV)); for (unsigned int i = 0; i < indices.count; ++i) { @@ -231,12 +270,18 @@ namespace Nz m_localVertices[i*4 + j].uv *= scale; } - // Nous enlevons l'ancienne texture et rajoutons la nouvelle à sa place (pour les mêmes indices) + // We get rid off the old texture and we set the new one at the place (same for indices) m_renderInfos.erase(it); m_renderInfos.insert(std::make_pair(newTexture, std::move(indices))); } } + /*! + * \brief Updates the data of the sprite + * + * \param instanceData Data of the instance + */ + void TextSprite::UpdateData(InstanceData* instanceData) const { instanceData->data.resize(m_localVertices.size() * sizeof(VertexStruct_XYZ_Color_UV)); @@ -246,18 +291,18 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); - // Nous allons maintenant initialiser les sommets finaux (ceux envoyés à la RenderQueue) - // à l'aide du repère, de la matrice et de notre attribut de couleur + // We will not initialize the final vertices (those send to the RenderQueue) + // With the help of the coordinates axis, the matrix and our color attribute for (auto& pair : m_renderInfos) { RenderIndices& indices = pair.second; if (indices.count == 0) continue; //< Ignore empty render indices - SparsePtr color = colorPtr + indices.first*4; - SparsePtr pos = posPtr + indices.first*4; - SparsePtr uv = texCoordPtr + indices.first*4; - VertexStruct_XY_Color_UV* localVertex = &m_localVertices[indices.first*4]; + SparsePtr color = colorPtr + indices.first * 4; + SparsePtr pos = posPtr + indices.first * 4; + SparsePtr uv = texCoordPtr + indices.first * 4; + VertexStruct_XY_Color_UV* localVertex = &m_localVertices[indices.first * 4]; for (unsigned int i = 0; i < indices.count; ++i) { for (unsigned int j = 0; j < 4; ++j) diff --git a/src/Nazara/Graphics/TextureBackground.cpp b/src/Nazara/Graphics/TextureBackground.cpp index 9ceb633e6..1b2e53e72 100644 --- a/src/Nazara/Graphics/TextureBackground.cpp +++ b/src/Nazara/Graphics/TextureBackground.cpp @@ -11,6 +11,11 @@ namespace Nz { namespace { + /*! + * \brief Defines render states + * \return RenderStates for the color background + */ + RenderStates BuildRenderStates() { RenderStates states; @@ -24,6 +29,18 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::TextureBackground + * \brief Graphics class that represents a background with a texture + */ + + /*! + * \brief Constructs a TextureBackground object with a texture + * + * \param texture Texture + */ + TextureBackground::TextureBackground(TextureRef texture) { m_uberShader = UberShaderLibrary::Get("Basic"); @@ -43,6 +60,12 @@ namespace Nz SetTexture(std::move(texture)); } + /*! + * \brief Draws this relatively to the viewer + * + * \param viewer Viewer for the background + */ + void TextureBackground::Draw(const AbstractViewer* viewer) const { NazaraUnused(viewer); @@ -62,6 +85,11 @@ namespace Nz Renderer::DrawFullscreenQuad(); } + /*! + * \brief Gets the background type + * \return Type of background + */ + BackgroundType TextureBackground::GetBackgroundType() const { return BackgroundType_Texture; diff --git a/tests/Engine/Graphics/Billboard.cpp b/tests/Engine/Graphics/Billboard.cpp new file mode 100644 index 000000000..5136e3af6 --- /dev/null +++ b/tests/Engine/Graphics/Billboard.cpp @@ -0,0 +1,34 @@ +#include +#include + +SCENARIO("Billboard", "[GRAPHICS][BILLBOARD]") +{ + GIVEN("A default billboard") + { + Nz::Billboard billboard; + + WHEN("We assign it to another") + { + Nz::MaterialRef materialRef = Nz::Material::New(); + materialRef->LoadFromFile("resources/Engine/Graphics/Nazara.png"); + Nz::Color materialColor = materialRef->GetDiffuseColor(); + Nz::BillboardRef otherBillboard = Nz::Billboard::New(materialRef); + + billboard = *otherBillboard; + + THEN("The old one has the same properties than the new one") + { + REQUIRE(billboard.GetColor() == materialColor); + REQUIRE(billboard.GetMaterial().Get() == materialRef.Get()); + REQUIRE(billboard.GetRotation() == Approx(0.f)); + REQUIRE(billboard.GetSize() == Nz::Vector2f(64.f, 64.f)); // Default sizes + } + + THEN("We set it with our new material and ask for its real size") + { + billboard.SetMaterial(materialRef, true); + REQUIRE(billboard.GetSize() == Nz::Vector2f(765.f, 212.f)); // Nazara.png sizes + } + } + } +} diff --git a/tests/Engine/Graphics/ColorBackground.cpp b/tests/Engine/Graphics/ColorBackground.cpp new file mode 100644 index 000000000..f4a88eb30 --- /dev/null +++ b/tests/Engine/Graphics/ColorBackground.cpp @@ -0,0 +1,20 @@ +#include +#include + +SCENARIO("ColorBackground", "[GRAPHICS][COLORBACKGROUND]") +{ + GIVEN("A default color background") + { + Nz::ColorBackground colorBackground; + + WHEN("We assign it a color") + { + colorBackground.SetColor(Nz::Color::Red); + + THEN("We can get it") + { + REQUIRE(colorBackground.GetColor() == Nz::Color::Red); + } + } + } +} diff --git a/tests/Engine/Graphics/DeferredRenderTechnique.cpp b/tests/Engine/Graphics/DeferredRenderTechnique.cpp new file mode 100644 index 000000000..f61c9800c --- /dev/null +++ b/tests/Engine/Graphics/DeferredRenderTechnique.cpp @@ -0,0 +1,29 @@ +#include +#include + +SCENARIO("DeferredRenderTechnique", "[GRAPHICS][DEFERREDRENDERTECHNIQUE]") +{ + GIVEN("A default deferred render technique") + { + Nz::DeferredRenderTechnique deferredRenderTechnique; + + WHEN("We can disable a pass") + { + REQUIRE(deferredRenderTechnique.IsPassEnabled(Nz::RenderPassType::RenderPassType_AA, 0)); + deferredRenderTechnique.EnablePass(Nz::RenderPassType::RenderPassType_AA, 0, false); + + THEN("It is disabled") + { + REQUIRE(!deferredRenderTechnique.IsPassEnabled(Nz::RenderPassType::RenderPassType_AA, 0)); + } + + AND_THEN("We reset it, it is disabled and not the same as the old one") + { + Nz::DeferredRenderPass* oldPass = deferredRenderTechnique.GetPass(Nz::RenderPassType::RenderPassType_AA, 0); + deferredRenderTechnique.ResetPass(Nz::RenderPassType::RenderPassType_AA, 0); + REQUIRE(!deferredRenderTechnique.IsPassEnabled(Nz::RenderPassType::RenderPassType_AA, 0)); + REQUIRE(deferredRenderTechnique.GetPass(Nz::RenderPassType::RenderPassType_AA, 0) != oldPass); + } + } + } +} diff --git a/tests/Engine/Graphics/Light.cpp b/tests/Engine/Graphics/Light.cpp new file mode 100644 index 000000000..bd5f1c7f9 --- /dev/null +++ b/tests/Engine/Graphics/Light.cpp @@ -0,0 +1,31 @@ +#include +#include + +SCENARIO("Light", "[GRAPHICS][LIGHT]") +{ + GIVEN("Different light") + { + Nz::Light directionalLight(Nz::LightType_Directional); + Nz::Light pointLight(Nz::LightType_Point); + Nz::Light spotLight(Nz::LightType_Spot); + + WHEN("We try to cull") + { + Nz::Frustumf frustum; + frustum.Build(90.f, 16.f / 9.f, 1.f, 1000.f, Nz::Vector3f::Zero(), Nz::Vector3f::UnitX()); + Nz::Matrix4f Unit3InX = Nz::Matrix4f::Translate(Nz::Vector3f::UnitX() * 3.f); + Nz::Matrix4f rotationTowardsY = Unit3InX * Nz::Matrix4f::Rotate(Nz::EulerAnglesf(Nz::FromDegrees(90.f), 0.f, 0.f).ToQuaternion()); + + THEN("These results are expected") + { + REQUIRE(directionalLight.Cull(frustum, Unit3InX)); + REQUIRE(pointLight.Cull(frustum, Unit3InX)); + REQUIRE(!spotLight.Cull(frustum, Unit3InX)); + + REQUIRE(directionalLight.Cull(frustum, rotationTowardsY)); + REQUIRE(pointLight.Cull(frustum, rotationTowardsY)); + REQUIRE(!spotLight.Cull(frustum, rotationTowardsY)); + } + } + } +} diff --git a/tests/Engine/Graphics/Model.cpp b/tests/Engine/Graphics/Model.cpp new file mode 100644 index 000000000..d67a261bb --- /dev/null +++ b/tests/Engine/Graphics/Model.cpp @@ -0,0 +1,24 @@ +#include +#include + +SCENARIO("Model", "[GRAPHICS][MODEL]") +{ + GIVEN("The standford dragon model") + { + WHEN("We get general informations") + { + THEN("These results are expected") + { + Nz::ModelRef model = Nz::Model::New(); + REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj")); + + REQUIRE(model->GetMaterialCount() == 2); + REQUIRE(model->GetSkin() == 0); + REQUIRE(model->GetSkinCount() == 1); + + Nz::Material* material = model->GetMaterial(0); + REQUIRE(material->GetAmbientColor() == Nz::Color(128)); + } + } + } +} diff --git a/tests/Engine/Graphics/ParticleDeclaration.cpp b/tests/Engine/Graphics/ParticleDeclaration.cpp new file mode 100644 index 000000000..1bc1739d3 --- /dev/null +++ b/tests/Engine/Graphics/ParticleDeclaration.cpp @@ -0,0 +1,29 @@ +#include +#include + +SCENARIO("ParticleDeclaration", "[GRAPHICS][PARTICLEDECLARATION]") +{ + GIVEN("A particle declaration of a model") + { + Nz::ParticleDeclaration* particleDeclaration = Nz::ParticleDeclaration::Get(Nz::ParticleLayout_Model); + + WHEN("We disable a component") + { + bool enabled; + Nz::ComponentType type; + unsigned int offset; + particleDeclaration->GetComponent(Nz::ParticleComponent_Position, &enabled, &type, &offset); + REQUIRE(enabled); + unsigned int oldStride = particleDeclaration->GetStride(); + + particleDeclaration->DisableComponent(Nz::ParticleComponent_Position); + REQUIRE(oldStride != particleDeclaration->GetStride()); + + THEN("We can enable it and the stride is back") + { + particleDeclaration->EnableComponent(Nz::ParticleComponent_Position, type, offset); + REQUIRE(oldStride == particleDeclaration->GetStride()); + } + } + } +} diff --git a/tests/Engine/Graphics/ParticleSystem.cpp b/tests/Engine/Graphics/ParticleSystem.cpp new file mode 100644 index 000000000..32f5f01f9 --- /dev/null +++ b/tests/Engine/Graphics/ParticleSystem.cpp @@ -0,0 +1,103 @@ +#include +#include + +#include +#include + +class TestParticleController : public Nz::ParticleController +{ + public: + // Be aware that the interval is [startId, endId] and NOT [startId, endId) + void Apply(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override + { + Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); + Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); + Nz::SparsePtr lifePtr = mapper.GetComponentPtr(Nz::ParticleComponent_Life); + + for (unsigned int i = startId; i <= endId; ++i) + { + Nz::Vector3f& particlePosition = positionPtr[i]; + Nz::Vector3f& particleVelocity = velocityPtr[i]; + float& particleLife = lifePtr[i]; + + particleLife -= elapsedTime; + if (particleLife <= 0.f) + system.KillParticle(i); + } + } +}; + +class TestParticleEmitter : public Nz::ParticleEmitter +{ + public: + ~TestParticleEmitter() override = default; + + void Emit(Nz::ParticleSystem& system, float elapsedTime) const override + { + system.GenerateParticles(GetEmissionCount()); + } + + private: + void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override + { + } +}; + +class TestParticleGenerator : public Nz::ParticleGenerator +{ + public: + ~TestParticleGenerator() override = default; + + // Be aware that the interval is [startId, endId] and NOT [startId, endId) + void Generate(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override + { + Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); + Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); + Nz::SparsePtr lifePtr = mapper.GetComponentPtr(Nz::ParticleComponent_Life); + + for (unsigned int i = startId; i <= endId; ++i) + { + Nz::Vector3f& particlePosition = positionPtr[i]; + Nz::Vector3f& particleVelocity = velocityPtr[i]; + float& particleLife = lifePtr[i]; + + particlePosition = Nz::Vector3f::Zero(); + particleVelocity = Nz::Vector3f::UnitX(); + particleLife = 1.3f; + } + } +}; + +SCENARIO("ParticleSystem", "[GRAPHICS][PARTICLESYSTEM]") +{ + GIVEN("A particle system of maximum 10 billboards with its generators") + { + // These need to be alive longer than the particle system + TestParticleController particleController; + TestParticleGenerator particleGenerator; + Nz::ParticleSystem particleSystem(10, Nz::ParticleLayout_Billboard); + + particleSystem.AddController(&particleController); + TestParticleEmitter particleEmitter; + particleEmitter.SetEmissionCount(10); + particleSystem.AddEmitter(&particleEmitter); + + particleSystem.AddGenerator(&particleGenerator); + + WHEN("We update to generate 10 particles") + { + particleSystem.Update(1.f); + + THEN("There must be 10 particles") + { + REQUIRE(particleSystem.GetParticleCount() == 10); + } + + AND_THEN("We update to make them die") + { + particleSystem.Update(2.f); + REQUIRE(particleSystem.GetParticleCount() == 0); + } + } + } +} diff --git a/tests/Engine/Graphics/RenderTechniques.cpp b/tests/Engine/Graphics/RenderTechniques.cpp new file mode 100644 index 000000000..ac5849da9 --- /dev/null +++ b/tests/Engine/Graphics/RenderTechniques.cpp @@ -0,0 +1,47 @@ +#include +#include + +#include +#include + +SCENARIO("RenderTechniques", "[GRAPHICS][RENDERTECHNIQUES]") +{ + GIVEN("Nothing") + { + WHEN("We try to get a technique") + { + THEN("We should get it") + { + std::unique_ptr forwardByEnum(Nz::RenderTechniques::GetByEnum(Nz::RenderTechniqueType_BasicForward)); + REQUIRE(forwardByEnum->GetType() == Nz::RenderTechniqueType_BasicForward); + + std::unique_ptr forwardByIndex(Nz::RenderTechniques::GetByIndex(1)); + REQUIRE(forwardByIndex->GetType() == Nz::RenderTechniqueType_BasicForward); + + std::unique_ptr forwardByName(Nz::RenderTechniques::GetByName(Nz::RenderTechniques::ToString(Nz::RenderTechniqueType_BasicForward))); + REQUIRE(forwardByName->GetType() == Nz::RenderTechniqueType_BasicForward); + } + + THEN("We can register a render technique") + { + unsigned int previousCount = Nz::RenderTechniques::GetCount(); + + Nz::RenderTechniques::Register("test", 23, []() -> Nz::AbstractRenderTechnique* { + return new Nz::ForwardRenderTechnique; + }); + + REQUIRE(previousCount < Nz::RenderTechniques::GetCount()); + + std::unique_ptr forwardByRanking(Nz::RenderTechniques::GetByRanking(23)); + REQUIRE(forwardByRanking->GetType() == Nz::RenderTechniqueType_BasicForward); + + std::unique_ptr forwardByName(Nz::RenderTechniques::GetByName("test")); + REQUIRE(forwardByName->GetType() == Nz::RenderTechniqueType_BasicForward); + + Nz::RenderTechniques::Unregister("test"); + + REQUIRE(previousCount == Nz::RenderTechniques::GetCount()); + } + } + } +} \ No newline at end of file diff --git a/tests/Engine/Graphics/SkeletalModel.cpp b/tests/Engine/Graphics/SkeletalModel.cpp new file mode 100644 index 000000000..87d2e43f1 --- /dev/null +++ b/tests/Engine/Graphics/SkeletalModel.cpp @@ -0,0 +1,26 @@ +#include +#include + +SCENARIO("SkeletalModel", "[GRAPHICS][SKELETALMODEL]") +{ + GIVEN("A default skeletal model") + { + Nz::SkeletalModel skeletalModel; + Nz::AnimationRef animation = Nz::Animation::New(); + + WHEN("We can load the bob lamp") + { + REQUIRE(skeletalModel.LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5mesh")); + REQUIRE(animation->LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5anim")); + skeletalModel.SetAnimation(animation); + + THEN("We can enable its animation") + { + REQUIRE(skeletalModel.HasAnimation()); + skeletalModel.EnableAnimation(true); + skeletalModel.AdvanceAnimation(0.10f); + REQUIRE(skeletalModel.IsAnimationEnabled()); + } + } + } +} diff --git a/tests/Engine/Graphics/SkyboxBackground.cpp b/tests/Engine/Graphics/SkyboxBackground.cpp new file mode 100644 index 000000000..36ceb0db5 --- /dev/null +++ b/tests/Engine/Graphics/SkyboxBackground.cpp @@ -0,0 +1,25 @@ +#include +#include + +SCENARIO("SkyboxBackground", "[GRAPHICS][SKYBOXBACKGROUND]") +{ + GIVEN("A skybox background with a loaded image") + { + Nz::TextureRef textureRef = Nz::Texture::New(); + textureRef->LoadCubemapFromFile("resources/Engine/Graphics/skybox.png"); + Nz::SkyboxBackgroundRef skyboxBackgroundRef = Nz::SkyboxBackground::New(textureRef); + + WHEN("We assign it parameters") + { + skyboxBackgroundRef->SetMovementOffset(Nz::Vector3f::Unit()); + skyboxBackgroundRef->SetMovementScale(1.f); + + THEN("We can get it") + { + REQUIRE(skyboxBackgroundRef->GetMovementOffset() == Nz::Vector3f::Unit()); + REQUIRE(skyboxBackgroundRef->GetMovementScale() == Approx(1.f)); + REQUIRE(skyboxBackgroundRef->GetTexture().Get() == textureRef.Get()); + } + } + } +} diff --git a/tests/Engine/Graphics/TextureBackground.cpp b/tests/Engine/Graphics/TextureBackground.cpp new file mode 100644 index 000000000..33178d87f --- /dev/null +++ b/tests/Engine/Graphics/TextureBackground.cpp @@ -0,0 +1,20 @@ +#include +#include + +SCENARIO("TextureBackground", "[GRAPHICS][TEXTUREBACKGROUND]") +{ + GIVEN("A default texture background") + { + Nz::TextureRef textureRef = Nz::Texture::New(); + textureRef->LoadFromFile("resources/Engine/Graphics/skybox.png"); + Nz::TextureBackgroundRef textureBackgroundRef = Nz::TextureBackground::New(textureRef); + + WHEN("We assign it parameters") + { + THEN("We can get it") + { + REQUIRE(textureBackgroundRef->GetTexture().Get() == textureRef.Get()); + } + } + } +} \ No newline at end of file diff --git a/tests/Engine/Math/Sphere.cpp b/tests/Engine/Math/Sphere.cpp index 1820acd35..ef13ffb38 100644 --- a/tests/Engine/Math/Sphere.cpp +++ b/tests/Engine/Math/Sphere.cpp @@ -39,14 +39,14 @@ SCENARIO("Sphere", "[MATH][SPHERE]") WHEN("We ask for distance") { - THEN("These results are expected") + THEN("These results are expected because we don't take into account the border") { - REQUIRE(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX()) == Approx(1.f)); - REQUIRE(firstCenterAndUnit.SquaredDistance(Nz::Vector3f::UnitX()) == Approx(1.f)); + REQUIRE(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f)); + REQUIRE(firstCenterAndUnit.SquaredDistance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f)); Nz::Spheref tmp(Nz::Vector3f::UnitX(), 1.f); - REQUIRE(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Approx(3.f)); - REQUIRE(tmp.SquaredDistance(Nz::Vector3f::UnitX() * 4.f) == Approx(9.f)); + REQUIRE(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Approx(2.f)); + REQUIRE(tmp.SquaredDistance(Nz::Vector3f::UnitX() * 4.f) == Approx(4.f)); } } @@ -84,7 +84,7 @@ SCENARIO("Sphere", "[MATH][SPHERE]") THEN("Sphere must contain it and distance should be good") { CHECK(firstCenterAndUnit.Contains(point)); - REQUIRE(firstCenterAndUnit.Distance(point) == 2.f); + REQUIRE(firstCenterAndUnit.Distance(point) == 1.f); } } diff --git a/tests/main.cpp b/tests/main.cpp index 7be81a57e..5ba9e8e01 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,2 +1,16 @@ -#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_RUNNER #include + +#include +#include +#include +#include + +int main(int argc, char* const argv[]) +{ + Nz::Initializer modules; + + int result = Catch::Session().run(argc, argv); + + return result; +} diff --git a/tests/resources/Engine/Graphics/Bob lamp/Readme.txt b/tests/resources/Engine/Graphics/Bob lamp/Readme.txt new file mode 100644 index 000000000..bd605ec7d --- /dev/null +++ b/tests/resources/Engine/Graphics/Bob lamp/Readme.txt @@ -0,0 +1,24 @@ +############################# +MD5 sample mesh and animation +############################# + +INFORMATION & USAGE +=================== +File includes *.blend source files and TGA format textures for MD5 animated mesh testing. +For extensive information and usage instructions visit http://www.katsbits.com/smforum/index.php?topic=178.0 + + - bob_lamp_update.blend contain mesh and armature as would be prior to preparation for export. + - bob_lamp_update_export contains triangulated mesh ready for export. + +NOTES +===== +Included files are for use in **Blender 2.69** or above; opening files in older versions may result in errors dues to internal differences between Blender versions. +Files and media are provided "as is" without any warranties of functionality. + +COPYRIGHT & DISTRIBUTION +======================== +Copyright © 2014 KatsBits. All Rights Reserved. +For more information visit http://www.katsbits.com/ or email info@katsbits.com + +For NON-COMMERCIAL USE ONLY. This file and/or its contents and/or associated materials may not be reproduced, duplicated, distributed or otherwise 'monetised' without prior consent. +Contact info@katsbits.com or visit http://copyright.katsbits.com/ for further details regarding this material and/or distribution/copyright. diff --git a/tests/resources/Engine/Graphics/copyrights.txt b/tests/resources/Engine/Graphics/copyrights.txt new file mode 100644 index 000000000..7cd13413c --- /dev/null +++ b/tests/resources/Engine/Graphics/copyrights.txt @@ -0,0 +1,82 @@ +skybox.png + +https://commons.wikimedia.org/wiki/File:Skybox_example.png + +Original file: +Skybox example.ogg ‎(Ogg Vorbis sound file, length 1 min 3 s, 378 kbps) + +Summary: + +Description: English: An example of a skybox and how the faces can be aligned +Date: 8 June 2011 +Source: Own work +Author: Creator:Arieee + +Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3. +Date: 19 October 2004 +Source: http://www.navyband.navy.mil/anthems/national_anthems.htm +Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald + +Licencing: + +This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. + + You are free: + + to share – to copy, distribute and transmit the work + to remix – to adapt the work + + Under the following conditions: + + attribution – You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). + share alike – If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. + +------------------------------------------------------------------------------------------------- + +Bob lamp + +http://www.katsbits.com/download/models/md5-example.php + +Original file: +bob_lamp_update.zip (Animated MD5 sample file) + +Summary: + +Description: Updated version of "Bob", a low-poly character mesh for general export and testing of MD5 mesh and animation - "*.md5mesh" and "*.md5anim". File and it's contents should be opened in Blender 2.69 or above to avoid compatibility issues with older versions of Blender and/or resulting MD5 exports (md5mesh & md5anim). + +File includes two versions of the source file, one 'working' - mesh is intact with surfaces in 'quad' form; and one 'prepped' (exported) - mesh has been tessilated (triangulated) for export. +Date: Januari 2014 +Source: http://www.katsbits.com/download/models/md5-example.php +Author: KatsBits + +Licencing: + +Please, refer to "Bob lamp/Readme.txt" file. + +------------------------------------------------------------------------------------------------- + +Standford dragon + +http://graphics.stanford.edu/data/3Dscanrep/ + +Original file: +dragon_recon.tar.gz (PLY files) + +Summary: + +Dragon +Source: Stanford University Computer Graphics Laboratory +Scanner: Cyberware 3030 MS + spacetime analysis +Number of scans: ~70 +Total size of scans: 2,748,318 points (about 5,500,000 triangles) +Reconstruction: vrip (conservatively decimated) +Size of reconstruction: 566,098 vertices, 1,132,830 triangles +Comments: contains numerous small holes +Date: 1996 +Source: http://graphics.stanford.edu/data/3Dscanrep/ +Author: Stanford University Computer Graphics Laboratory + +Licencing: + +Please be sure to acknowledge the source of the data and models you take from this repository. In each of the listings below, we have cited the source of the range data and reconstructed models. You are welcome to use the data and models for research purposes. You are also welcome to mirror or redistribute them for free. Finally, you may publish images made using these models, or the images on this web site, in a scholarly article or book - as long as credit is given to the Stanford Computer Graphics Laboratory. However, such models or images are not to be used for commercial purposes, nor should they appear in a product for sale (with the exception of scholarly journals or books), without our permission. +Please, refer to "dragon_recon/README" file. diff --git a/tests/resources/Engine/Graphics/dragon_recon/README b/tests/resources/Engine/Graphics/dragon_recon/README new file mode 100644 index 000000000..af64a50fe --- /dev/null +++ b/tests/resources/Engine/Graphics/dragon_recon/README @@ -0,0 +1,27 @@ + Surface Reconstructions + + Stanford Range Repository + Computer Graphics Laboratory + Stanford University + + August 4, 1996 + + +These files are the result of reconstructing a set of range images +using the "vrip" program. The first file is the high resolution +result, while the "_res*" files are decimated versions. Note that +these decimations were performed using a crude algorithm that does not +necessarily preserve mesh topology. While they are not beautiful, +they are suitable for interactive rendering. + +Note that this model is a decimated version of the original which was +constructed at the voxel resolution of 0.35 mm. The original model +has no holes in it, however, the decimated model has some holes that +we detected with software, but not by inspection. Apparently, the +decimation software introduced these holes. + +For more information, consult the web pages of the Stanford Graphics +Laboratory: + + http://www-graphics.stanford.edu + From e212c8ce85571fd6d74512c60ac4f286b0aa2c9d Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:22:31 +0200 Subject: [PATCH 014/235] Documentation for module: Network Former-commit-id: cb5674c011d3d6895848cab77bb2e4a05e5d9b7b --- include/Nazara/Network/AbstractSocket.inl | 31 ++++ include/Nazara/Network/Config.hpp | 15 +- include/Nazara/Network/ConfigCheck.hpp | 4 +- include/Nazara/Network/DebugOff.hpp | 2 +- include/Nazara/Network/IpAddress.inl | 164 ++++++++++++++++++++- include/Nazara/Network/NetPacket.inl | 93 ++++++++++++ include/Nazara/Network/RUdpConnection.inl | 87 ++++++++++- include/Nazara/Network/TcpClient.hpp | 2 +- include/Nazara/Network/TcpClient.inl | 35 +++++ include/Nazara/Network/TcpServer.inl | 31 ++++ include/Nazara/Network/UdpSocket.hpp | 1 - include/Nazara/Network/UdpSocket.inl | 53 ++++++- src/Nazara/Network/AbstractSocket.cpp | 68 +++++++++ src/Nazara/Network/AlgorithmNetwork.cpp | 42 +++++- src/Nazara/Network/IpAddress.cpp | 50 +++++++ src/Nazara/Network/NetPacket.cpp | 70 +++++++++ src/Nazara/Network/Network.cpp | 27 +++- src/Nazara/Network/RUdpConnection.cpp | 157 +++++++++++++++++++- src/Nazara/Network/TcpClient.cpp | 168 ++++++++++++++++++++++ src/Nazara/Network/TcpServer.cpp | 34 +++++ src/Nazara/Network/UdpSocket.cpp | 84 +++++++++++ tests/Engine/Network/IpAddress.cpp | 47 ++++++ tests/Engine/Network/RUdpConnection.cpp | 40 ++++++ tests/Engine/Network/TCP.cpp | 49 +++++++ tests/Engine/Network/UdpSocket.cpp | 39 +++++ 25 files changed, 1368 insertions(+), 25 deletions(-) create mode 100644 tests/Engine/Network/IpAddress.cpp create mode 100644 tests/Engine/Network/RUdpConnection.cpp create mode 100644 tests/Engine/Network/TCP.cpp create mode 100644 tests/Engine/Network/UdpSocket.cpp diff --git a/include/Nazara/Network/AbstractSocket.inl b/include/Nazara/Network/AbstractSocket.inl index 8bebabfdb..5b5174b98 100644 --- a/include/Nazara/Network/AbstractSocket.inl +++ b/include/Nazara/Network/AbstractSocket.inl @@ -6,31 +6,62 @@ namespace Nz { + /*! + * \brief Gets the last error + * \return Socket error + */ + inline SocketError AbstractSocket::GetLastError() const { return m_lastError; } + /*! + * \brief Gets the internal socket handle + * \return Socket handle + */ + inline SocketHandle AbstractSocket::GetNativeHandle() const { return m_handle; } + /*! + * \brief Gets the internal state + * \return Socket state + */ + inline SocketState AbstractSocket::GetState() const { return m_state; } + /*! + * \brief Gets the internal type + * \return Socket type + */ + inline SocketType AbstractSocket::GetType() const { return m_type; } + /*! + * \brief Checks whether the blocking is enabled + * \return true If successful + */ + inline bool AbstractSocket::IsBlockingEnabled() const { return m_isBlockingEnabled; } + /*! + * \brief Updates the state of the socket + * + * \param newState Next state for the socket + */ + inline void AbstractSocket::UpdateState(SocketState newState) { if (m_state != newState) diff --git a/include/Nazara/Network/Config.hpp b/include/Nazara/Network/Config.hpp index 727108061..2d73c26bb 100644 --- a/include/Nazara/Network/Config.hpp +++ b/include/Nazara/Network/Config.hpp @@ -27,17 +27,22 @@ #ifndef NAZARA_CONFIG_NETWORK_HPP #define NAZARA_CONFIG_NETWORK_HPP -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci +/*! +* \defgroup network (NazaraNetwork) Network module +* Network/System module including classes to handle networking elements... +*/ -// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +/// Each modification of a paramater of the module needs a recompilation of the unit + +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) #define NAZARA_NETWORK_MANAGE_MEMORY 0 -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) +// Activate the security tests based on the code (Advised for development) #define NAZARA_NETWORK_SAFE 1 -/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code +/// Each modification of a parameter following implies a modification (often minor) of the code -/// Vérification des valeurs et types de certaines constantes +/// Checking the values and types of certain constants #include #if defined(NAZARA_STATIC) diff --git a/include/Nazara/Network/ConfigCheck.hpp b/include/Nazara/Network/ConfigCheck.hpp index 73513ebc9..2f1ba1dc8 100644 --- a/include/Nazara/Network/ConfigCheck.hpp +++ b/include/Nazara/Network/ConfigCheck.hpp @@ -7,11 +7,11 @@ #ifndef NAZARA_CONFIG_CHECK_NETWORK_HPP #define NAZARA_CONFIG_CHECK_NETWORK_HPP -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp +/// This file is used to check the constant values defined in Config.hpp #include -// On force la valeur de MANAGE_MEMORY en mode debug +// We fore the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_NETWORK_MANAGE_MEMORY #undef NAZARA_NETWORK_MANAGE_MEMORY #define NAZARA_NETWORK_MANAGE_MEMORY 0 diff --git a/include/Nazara/Network/DebugOff.hpp b/include/Nazara/Network/DebugOff.hpp index dd45ac45c..e9df99f1f 100644 --- a/include/Nazara/Network/DebugOff.hpp +++ b/include/Nazara/Network/DebugOff.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +// We suppose that Debug.hpp is already included, same goes for Config.hpp #if NAZARA_NETWORK_MANAGE_MEMORY #undef delete #undef new diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index 3184bd34d..2fc9ac2bd 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -9,11 +9,22 @@ namespace Nz { + /*! + * \brief Constructs a IpAddress object by default + */ + inline IpAddress::IpAddress() : m_isValid(false) { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv4 address + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const IPv4& ip, UInt16 port) : m_ipv4(ip), m_protocol(NetProtocol_IPv4), @@ -22,6 +33,13 @@ namespace Nz { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv6 address + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const IPv6& ip, UInt16 port) : m_ipv6(ip), m_protocol(NetProtocol_IPv6), @@ -30,46 +48,100 @@ namespace Nz { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv4 address (a.b.c.d) + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const UInt8& a, const UInt8& b, const UInt8& c, const UInt8& d, UInt16 port) : IpAddress(IPv4{a, b, c, d}, port) { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv6 address (a.b.c.d.e.f.g.h) + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const UInt16& a, const UInt16& b, const UInt16& c, const UInt16& d, const UInt16& e, const UInt16& f, const UInt16& g, const UInt16& h, UInt16 port) : IpAddress(IPv6{a, b, c, d, e, f, g, h}, port) { } + /*! + * Constructs a IpAddress object with a C-string + * + * \param address Hostname or textual IP address + */ + inline IpAddress::IpAddress(const char* address) { BuildFromAddress(address); } + /*! + * Constructs a IpAddress object with a string + * + * \param address Hostname or textual IP address + */ + inline IpAddress::IpAddress(const String& address) { BuildFromAddress(address.GetConstBuffer()); } + /*! + * \brief Gets the port + * \return Port attached to the IP address + */ + inline UInt16 IpAddress::GetPort() const { return m_port; } + /*! + * \brief Gets the net protocol + * \return Protocol attached to the IP address + */ + inline NetProtocol IpAddress::GetProtocol() const { return m_protocol; } + /*! + * \brief Checks whether the IP address is valid + * \return true If successful + */ + inline bool IpAddress::IsValid() const { return m_isValid; } + /*! + * \brief Sets the port + * + * \param port Port attached to the IP address + */ + inline void IpAddress::SetPort(UInt16 port) { m_port = port; } + /*! + * \brief Converts IpAddress to IPv4 + * \return Corresponding IPv4 + * + * \remark Produces a NazaraAssert if net protocol is not IPv4 + */ + inline IpAddress::IPv4 IpAddress::ToIPv4() const { NazaraAssert(m_isValid && m_protocol == NetProtocol_IPv4, "Address is not a valid IPv4"); @@ -77,6 +149,13 @@ namespace Nz return m_ipv4; } + /*! + * \brief Converts IpAddress to IPv6 + * \return Corresponding IPv6 + * + * \remark Produces a NazaraAssert if net protocol is not IPv6 + */ + inline IpAddress::IPv6 IpAddress::ToIPv6() const { NazaraAssert(m_isValid && m_protocol == NetProtocol_IPv6, "IP is not a valid IPv6"); @@ -84,6 +163,13 @@ namespace Nz return m_ipv6; } + /*! + * \brief Converts IpAddress to UInt32 + * \return Corresponding UInt32 + * + * \remark Produces a NazaraAssert if net protocol is not IPv4 + */ + inline UInt32 IpAddress::ToUInt32() const { NazaraAssert(m_isValid && m_protocol == NetProtocol_IPv4, "Address is not a valid IPv4"); @@ -94,17 +180,40 @@ namespace Nz UInt32(m_ipv4[3]) << 0; } + /*! + * \brief Converts IpAddress to boolean + * \return true If IpAddress is valid + * + * \see IsValid + */ + inline IpAddress::operator bool() const { return IsValid(); } + /*! + * \brief Output operator + * \return The stream + * + * \param out The stream + * \param address The address to output + */ + inline std::ostream& operator<<(std::ostream& out, const IpAddress& address) { out << "IpAddress(" << address.ToString() << ')'; return out; } + /*! + * \brief Compares the IpAddress to other one + * \return true if the ip addresses are the same + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator==(const IpAddress& first, const IpAddress& second) { // We need to check the validity of each address before comparing them @@ -146,11 +255,27 @@ namespace Nz return true; } + /*! + * \brief Compares the IpAddress to other one + * \return false if the ip addresses are the same + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator!=(const IpAddress& first, const IpAddress& second) { return !operator==(first, second); } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is inferior to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator<(const IpAddress& first, const IpAddress& second) { // If the second address is invalid, there's no way we're lower than it @@ -196,16 +321,40 @@ namespace Nz return false; //< Same address } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is inferior or equal to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator<=(const IpAddress& first, const IpAddress& second) { return !operator<(second, first); } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is greather to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator>(const IpAddress& first, const IpAddress& second) { return second < first; } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is greather or equal to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator>=(const IpAddress& first, const IpAddress& second) { return !operator<(first, second); @@ -217,6 +366,13 @@ namespace std template<> struct hash { + /*! + * \brief Converts IpAddress to hash + * \return Hash of the IpAddress + * + * \param ip IpAddress to hash + */ + size_t operator()(const Nz::IpAddress& ip) const { if (!ip) @@ -224,7 +380,7 @@ namespace std // This is SDBM adapted for IP addresses, tested to generate the least collisions possible // (It doesn't mean it cannot be improved though) - std::size_t h = 0; + std::size_t hash = 0; switch (ip.GetProtocol()) { case Nz::NetProtocol_Any: @@ -233,20 +389,20 @@ namespace std case Nz::NetProtocol_IPv4: { - h = ip.ToUInt32() + (h << 6) + (h << 16) - h; + hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash; break; } case Nz::NetProtocol_IPv6: { Nz::IpAddress::IPv6 v6 = ip.ToIPv6(); for (std::size_t i = 0; i < v6.size(); i++) - h = v6[i] + (h << 6) + (h << 16) - h; + hash = v6[i] + (hash << 6) + (hash << 16) - hash; break; } } - return ip.GetPort() + (h << 6) + (h << 16) - h; + return ip.GetPort() + (hash << 6) + (hash << 16) - hash; } }; } diff --git a/include/Nazara/Network/NetPacket.inl b/include/Nazara/Network/NetPacket.inl index c9bbed681..e9765c9dc 100644 --- a/include/Nazara/Network/NetPacket.inl +++ b/include/Nazara/Network/NetPacket.inl @@ -9,21 +9,46 @@ namespace Nz { + /*! + * \brief Constructs a NetPacket object by default + */ + inline NetPacket::NetPacket() : m_netCode(NetCode_Invalid) { } + /*! + * \brief Constructs a NetPacket object with a packet number and a minimal capacity + * + * \param netCode Packet number + * \param minCapacity Minimal capacity of the packet + */ + inline NetPacket::NetPacket(UInt16 netCode, std::size_t minCapacity) { Reset(netCode, minCapacity); } + /*! + * \brief Constructs a NetPacket object with a packet number and raw memory + * + * \param netCode Packet number + * \param ptr Raw memory + * \param size Size of the memory + */ + inline NetPacket::NetPacket(UInt16 netCode, const void* ptr, std::size_t size) { Reset(netCode, ptr, size); } + /*! + * \brief Constructs a NetPacket object with another one by move semantic + * + * \param packet NetPacket to move into this + */ + inline NetPacket::NetPacket(NetPacket&& packet) : ByteStream(std::move(packet)), m_buffer(std::move(packet.m_buffer)), @@ -35,12 +60,23 @@ namespace Nz SetStream(&m_memoryStream); } + /*! + * \brief Destructs the object + */ + inline NetPacket::~NetPacket() { FlushBits(); //< Needs to be done here as the stream will be freed before ByteStream calls it FreeStream(); } + /*! + * \brief Gets the raw buffer + * \return Constant raw buffer + * + * \remark Produces a NazaraAssert if internal buffer is invalid + */ + inline const UInt8* NetPacket::GetConstData() const { NazaraAssert(m_buffer, "Invalid buffer"); @@ -48,6 +84,13 @@ namespace Nz return m_buffer->GetConstBuffer(); } + /*! + * \brief Gets the raw buffer + * \return Raw buffer + * + * \remark Produces a NazaraAssert if internal buffer is invalid + */ + inline UInt8* NetPacket::GetData() const { NazaraAssert(m_buffer, "Invalid buffer"); @@ -55,6 +98,11 @@ namespace Nz return m_buffer->GetBuffer(); } + /*! + * \brief Gets the size of the data + * \return Size of the data + */ + inline size_t NetPacket::GetDataSize() const { if (m_buffer) @@ -63,22 +111,46 @@ namespace Nz return 0; } + /*! + * \brief Gets the packet number + * \return Packet number + */ + inline UInt16 NetPacket::GetNetCode() const { return m_netCode; } + /*! + * \brief Resets the packet + */ + inline void NetPacket::Reset() { FreeStream(); } + /*! + * \brief Resets the packet with a packet number and a minimal capacity + * + * \param netCode Packet number + * \param minCapacity Minimal capacity of the packet + */ + inline void NetPacket::Reset(UInt16 netCode, std::size_t minCapacity) { InitStream(HeaderSize + minCapacity, HeaderSize, OpenMode_ReadWrite); m_netCode = netCode; } + /*! + * \brief Resets the packet with a packet number and raw memory + * + * \param netCode Packet number + * \param ptr Raw memory + * \param size Size of the memory + */ + inline void NetPacket::Reset(UInt16 netCode, const void* ptr, std::size_t size) { InitStream(HeaderSize + size, HeaderSize, OpenMode_ReadOnly); @@ -88,6 +160,14 @@ namespace Nz m_netCode = netCode; } + /*! + * \brief Resizes the packet + * + * \param newSize Size for the resizing operation + * + * \remark Produces a NazaraAssert if internal buffer is invalid + */ + inline void NetPacket::Resize(std::size_t newSize) { NazaraAssert(m_buffer, "Invalid buffer"); @@ -95,11 +175,24 @@ namespace Nz m_buffer->Resize(newSize); } + /*! + * \brief Sets the packet number + * + * \param netCode Packet number + */ + inline void NetPacket::SetNetCode(UInt16 netCode) { m_netCode = netCode; } + /*! + * \brief Moves the NetPacket into this + * \return A reference to this + * + * \param packet NetPacket to move in this + */ + inline NetPacket& Nz::NetPacket::operator=(NetPacket&& packet) { FreeStream(); diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index b2372285d..53e797b59 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -8,31 +8,66 @@ namespace Nz { + /*! + * \brief Closes the connection + */ + inline void RUdpConnection::Close() { m_socket.Close(); } + /*! + * \brief Disconnects the connection + * + * \see Close + */ + inline void RUdpConnection::Disconnect() { Close(); } + /*! + * \brief Gets the bound address + * \return IpAddress we are linked to + */ + inline IpAddress RUdpConnection::GetBoundAddress() const { return m_socket.GetBoundAddress(); } + /*! + * \brief Gets the port of the bound address + * \return Port we are linked to + */ + inline UInt16 RUdpConnection::GetBoundPort() const { return m_socket.GetBoundPort(); } + /*! + * \brief Gets the last error + * \return Socket error + */ + inline SocketError RUdpConnection::GetLastError() const { return m_lastError; } + /*! + * \brief Listens to a socket + * \return true If successfully bound + * + * \param protocol Net protocol to listen to + * \param port Port to listen to + * + * \remark Produces a NazaraAssert if protocol is unknown or any + */ + inline bool RUdpConnection::Listen(NetProtocol protocol, UInt16 port) { NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO @@ -59,16 +94,36 @@ namespace Nz return Listen(any); } + /*! + * \brief Sets the protocol id + * + * \param protocolId Protocol ID like NNet + */ + inline void RUdpConnection::SetProtocolId(UInt32 protocolId) { m_protocol = protocolId; } + /*! + * \brief Sets the time before ack + * + * \param Time before acking to send many together (in ms) + */ + inline void RUdpConnection::SetTimeBeforeAck(UInt32 ms) { m_forceAckSendTime = ms * 1000; //< Store in microseconds for easier handling } - + + /*! + * \brief Computes the difference of sequence + * \return Delta between the two sequences + * + * \param sequence First sequence + * \param sequence2 Second sequence + */ + inline unsigned int RUdpConnection::ComputeSequenceDifference(SequenceIndex sequence, SequenceIndex sequence2) { unsigned int difference; @@ -80,6 +135,13 @@ namespace Nz return 0; } + /*! + * \brief Checks whether the peer has pending packets + * \return true If it is the case + * + * \param peer Data relative to the peer + */ + inline bool RUdpConnection::HasPendingPackets(PeerData& peer) { for (unsigned int priority = PacketPriority_Highest; priority <= PacketPriority_Lowest; ++priority) @@ -94,6 +156,14 @@ namespace Nz return false; } + /*! + * \brief Checks whether the ack is more recent + * \return true If it is the case + * + * \param ack First sequence + * \param ack2 Second sequence + */ + inline bool RUdpConnection::IsAckMoreRecent(SequenceIndex ack, SequenceIndex ack2) { constexpr SequenceIndex maxDifference = std::numeric_limits::max() / 2; @@ -106,6 +176,13 @@ namespace Nz return false; ///< Same ack } + /*! + * \brief Checks whether the connection is reliable + * \return true If it is the case + * + * \remark Produces a NazaraError if enumeration is invalid + */ + inline bool RUdpConnection::IsReliable(PacketReliability reliability) { switch (reliability) @@ -122,6 +199,14 @@ namespace Nz return false; } + /*! + * \brief Simulates the loss of packets on network + * + * \param packetLoss Ratio of packet loss according to bernoulli distribution + * + * \remark Produces a NazaraAssert if packetLoss is not in between 0.0 and 1.0 + */ + inline void RUdpConnection::SimulateNetwork(double packetLoss) { NazaraAssert(packetLoss >= 0.0 && packetLoss <= 1.0, "Packet loss must be in range [0..1]"); diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index 0fcedcf39..fda4671f9 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -79,8 +79,8 @@ namespace Nz PendingPacket m_pendingPacket; UInt64 m_keepAliveInterval; UInt64 m_keepAliveTime; - bool m_isKeepAliveEnabled; bool m_isLowDelayEnabled; + bool m_isKeepAliveEnabled; }; } diff --git a/include/Nazara/Network/TcpClient.inl b/include/Nazara/Network/TcpClient.inl index da292b982..23f5412da 100644 --- a/include/Nazara/Network/TcpClient.inl +++ b/include/Nazara/Network/TcpClient.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a TcpClient object by default + */ + inline TcpClient::TcpClient() : AbstractSocket(SocketType_TCP), Stream(StreamOption_Sequential), @@ -17,31 +21,62 @@ namespace Nz { } + /*! + * \brief Disconnects the connection + * + * \see Close + */ + inline void TcpClient::Disconnect() { Close(); } + /*! + * \brief Gets the interval between two keep alive pings + * \return Interval in milliseconds between two pings + */ + inline UInt64 TcpClient::GetKeepAliveInterval() const { return m_keepAliveInterval; } + /*! + * \brief Gets the time before expiration of connection + * \return Time in milliseconds before expiration + */ + inline UInt64 TcpClient::GetKeepAliveTime() const { return m_keepAliveTime; } + /*! + * \brief Gets the remote address + * \return Address of peer + */ + inline IpAddress TcpClient::GetRemoteAddress() const { return m_peerAddress; } + /*! + * \brief Checks whether low delay is enabled + * \return true If it is the case + */ + inline bool TcpClient::IsLowDelayEnabled() const { return m_isLowDelayEnabled; } + /*! + * \brief Checks whether the keep alive flag is enabled + * \return true If it is the case + */ + inline bool TcpClient::IsKeepAliveEnabled() const { return m_isKeepAliveEnabled; diff --git a/include/Nazara/Network/TcpServer.inl b/include/Nazara/Network/TcpServer.inl index 5350a58ee..1fcb4eb32 100644 --- a/include/Nazara/Network/TcpServer.inl +++ b/include/Nazara/Network/TcpServer.inl @@ -7,27 +7,58 @@ namespace Nz { + /*! + * \brief Constructs a TcpServer object by default + */ + inline TcpServer::TcpServer() : AbstractSocket(SocketType_TCP) { } + /*! + * \brief Constructs a TcpServer object with another one by move semantic + * + * \param tcpServer TcpServer to move into this + */ + inline TcpServer::TcpServer(TcpServer&& tcpServer) : AbstractSocket(std::move(tcpServer)), m_boundAddress(std::move(tcpServer.m_boundAddress)) { } + /*! + * \brief Gets the bound address + * \return IpAddress we are linked to + */ + inline IpAddress TcpServer::GetBoundAddress() const { return m_boundAddress; } + /*! + * \brief Gets the port of the bound address + * \return Port we are linked to + */ + inline UInt16 TcpServer::GetBoundPort() const { return m_boundAddress.GetPort(); } + /*! + * \brief Listens to a socket + * \return State of the socket + * + * \param protocol Net protocol to listen to + * \param port Port to listen to + * \param queueSize Size of the queue + * + * \remark Produces a NazaraAssert if protocol is unknown or any + */ + inline SocketState TcpServer::Listen(NetProtocol protocol, UInt16 port, unsigned int queueSize) { NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index 96c391436..2aac124af 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -49,7 +49,6 @@ namespace Nz void OnOpened() override; IpAddress m_boundAddress; - SocketState m_state; bool m_isBroadCastingEnabled; }; } diff --git a/include/Nazara/Network/UdpSocket.inl b/include/Nazara/Network/UdpSocket.inl index 9ad4d067b..4096d8c04 100644 --- a/include/Nazara/Network/UdpSocket.inl +++ b/include/Nazara/Network/UdpSocket.inl @@ -6,24 +6,46 @@ namespace Nz { + /*! + * \brief Constructs a UdpSocket object by default + */ + inline UdpSocket::UdpSocket() : AbstractSocket(SocketType_UDP) { } + /*! + * \brief Constructs a UdpSocket object with a net protocol + * + * \param protocol Net protocol to use + */ + inline UdpSocket::UdpSocket(NetProtocol protocol) : UdpSocket() { Create(protocol); } + /*! + * \brief Constructs a UdpSocket object with another one by move semantic + * + * \param udpSocket UdpSocket to move into this + */ + inline UdpSocket::UdpSocket(UdpSocket&& udpSocket) : AbstractSocket(std::move(udpSocket)), - m_boundAddress(std::move(udpSocket.m_boundAddress)), - m_state(udpSocket.m_state) + m_boundAddress(std::move(udpSocket.m_boundAddress)) { } + /*! + * \brief Binds a specific port + * \return State of the socket + * + * \param port Port to bind + */ + inline SocketState UdpSocket::Bind(UInt16 port) { IpAddress any; @@ -47,6 +69,13 @@ namespace Nz return Bind(any); } + /*! + * \brief Creates a UDP socket + * \return true If successful + * + * \param protocol Net protocol to use + */ + bool UdpSocket::Create(NetProtocol protocol) { NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol"); @@ -54,21 +83,41 @@ namespace Nz return Open(protocol); } + /*! + * \brief Gets the bound address + * \return IpAddress we are linked to + */ + inline IpAddress UdpSocket::GetBoundAddress() const { return m_boundAddress; } + /*! + * \brief Gets the port of the bound address + * \return Port we are linked to + */ + inline UInt16 UdpSocket::GetBoundPort() const { return m_boundAddress.GetPort(); } + /*! + * \brief Gets the state of the socket + * \return State of the socket + */ + inline SocketState UdpSocket::GetState() const { return m_state; } + /*! + * \brief Checks whether the broadcasting is enabled + * \return true If it is the case + */ + inline bool UdpSocket::IsBroadcastingEnabled() const { return m_isBroadCastingEnabled; diff --git a/src/Nazara/Network/AbstractSocket.cpp b/src/Nazara/Network/AbstractSocket.cpp index e46a5906a..516364373 100644 --- a/src/Nazara/Network/AbstractSocket.cpp +++ b/src/Nazara/Network/AbstractSocket.cpp @@ -17,6 +17,18 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::AbstractSocket + * \brief Network class that represents the base of socket + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a AbstractSocket object with a type + */ + AbstractSocket::AbstractSocket(SocketType type) : m_lastError(SocketError_NoError), m_handle(SocketImpl::InvalidHandle), @@ -26,6 +38,12 @@ namespace Nz { } + /*! + * \brief Constructs a AbstractSocket object with another one by move semantic + * + * \param abstractSocket AbstractSocket to move into this + */ + AbstractSocket::AbstractSocket(AbstractSocket&& abstractSocket) : m_protocol(abstractSocket.m_protocol), m_lastError(abstractSocket.m_lastError), @@ -37,11 +55,21 @@ namespace Nz abstractSocket.m_handle = SocketImpl::InvalidHandle; } + /*! + * \brief Destructs the object and calls Close + * + * \see Close + */ + AbstractSocket::~AbstractSocket() { Close(); } + /*! + * \brief Closes the socket + */ + void AbstractSocket::Close() { if (m_handle != SocketImpl::InvalidHandle) @@ -53,6 +81,12 @@ namespace Nz } } + /*! + * \brief Enables blocking + * + * \param blocking Should the read block + */ + void AbstractSocket::EnableBlocking(bool blocking) { if (m_isBlockingEnabled != blocking) @@ -64,6 +98,11 @@ namespace Nz } } + /*! + * \brief Queries the available bytes + * \return Number of bytes which can be read + */ + std::size_t AbstractSocket::QueryAvailableBytes() const { if (m_handle == SocketImpl::InvalidHandle) @@ -72,11 +111,21 @@ namespace Nz return SocketImpl::QueryAvailableBytes(m_handle); } + /*! + * \brief Operation to do when closing socket + */ + void AbstractSocket::OnClose() { UpdateState(SocketState_NotConnected); } + /*! + * \brief Operation to do when opening socket + * + * \remark Produces a NazaraWarning if blocking failed + */ + void AbstractSocket::OnOpened() { SocketError errorCode; @@ -84,6 +133,11 @@ namespace Nz NazaraWarning("Failed to set socket blocking mode (0x" + String::Number(errorCode, 16) + ')'); } + /*! + * \brief Opens the socket according to a net protocol + * \return true If successful + */ + bool AbstractSocket::Open(NetProtocol protocol) { if (m_handle == SocketImpl::InvalidHandle || m_protocol != protocol) @@ -99,6 +153,13 @@ namespace Nz return true; } + /*! + * \brief Opens the socket according to a socket handle + * \return true If successful + * + * \remark Produces a NazaraAssert if handle is invalid + */ + void AbstractSocket::Open(SocketHandle handle) { NazaraAssert(handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -109,6 +170,13 @@ namespace Nz OnOpened(); } + /*! + * \brief Moves the AbstractSocket into this + * \return A reference to this + * + * \param abstractSocket AbstractSocket to move in this + */ + AbstractSocket& AbstractSocket::operator=(AbstractSocket&& abstractSocket) { Close(); diff --git a/src/Nazara/Network/AlgorithmNetwork.cpp b/src/Nazara/Network/AlgorithmNetwork.cpp index 273169005..307ac679a 100644 --- a/src/Nazara/Network/AlgorithmNetwork.cpp +++ b/src/Nazara/Network/AlgorithmNetwork.cpp @@ -11,6 +11,15 @@ namespace Nz { namespace Detail { + /*! + * \brief Parses a decimal number + * \return true If successful + * + * \param str C-string symbolizing the string to parse + * \param number Optional argument to return the number parsed + * \param endOfRead Optional argument to determine where parsing stopped + */ + bool ParseDecimal(const char* str, unsigned int* number, const char** endOfRead) { const char* ptr = str; @@ -35,6 +44,15 @@ namespace Nz return true; } + /*! + * \brief Parses a hexadecimal number + * \return true If successful + * + * \param str C-string symbolizing the string to parse + * \param number Optional argument to return the number parsed + * \param endOfRead Optional argument to determine where parsing stopped + */ + bool ParseHexadecimal(const char* str, unsigned int* number, const char** endOfRead) { const char* ptr = str; @@ -60,10 +78,26 @@ namespace Nz } } - // From http://rosettacode.org/wiki/Parse_an_IP_Address - // Parse a textual IPv4 or IPv6 address, optionally with port, into a binary - // array (for the address, in host order), and an optionally provided port. - // Also, indicate which of those forms (4 or 6) was parsed. + /*! + * \ingroup network + * \brief Parse a textual IPv4 or IPv6 address + * \return true If successful + * + * From http://rosettacode.org/wiki/Parse_an_IP_Address + * Parse a textual IPv4 or IPv6 address, optionally with port, into a binary + * array (for the address, in host order), and an optionally provided port. + * Also, indicate which of those forms (4 or 6) was parsed. + * + * \param addressPtr C-string which symbolizes the ip adress + * \param result Byte array to return the result in + * \param port Optional argument to resolve according to a specific port + * \param isIPv6 Optional argument to determine if the address is IPv6 + * \param endOfRead Optional argument to determine where parsing stopped + * + * \remark Produces a NazaraAssert if addressPtr is invalid + * \remark Produces a NazaraAssert if result is invalid + */ + bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port, bool* isIPv6, const char** endOfRead) { NazaraAssert(addressPtr, "Invalid address string"); diff --git a/src/Nazara/Network/IpAddress.cpp b/src/Nazara/Network/IpAddress.cpp index d40e2a581..29be756ea 100644 --- a/src/Nazara/Network/IpAddress.cpp +++ b/src/Nazara/Network/IpAddress.cpp @@ -22,6 +22,19 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::IpAddress + * \brief Network class that represents an IP address + */ + + /*! + * \brief Builds the IP from a hostname + * \return true If successful + * + * \remark address C-string symbolizing the IP address or hostname + */ + bool IpAddress::BuildFromAddress(const char* address) { m_isValid = false; @@ -50,6 +63,13 @@ namespace Nz return true; } + /*! + * \brief Checks whether the IP address is loopback + * \return true If it is the case + * + * \remark Produces a NazaraAssert if internal protocol is invalid (should never happen) + */ + bool IpAddress::IsLoopback() const { if (!m_isValid) @@ -73,6 +93,13 @@ namespace Nz return false; } + /*! + * \brief Gives a string representation + * \return A string representation of the object + * + * \remark Produces a NazaraAssert if internal protocol is invalid (should never happen) + */ + String IpAddress::ToString() const { StringStream stream; @@ -153,6 +180,17 @@ namespace Nz return stream; } + /*! + * \brief Resolves the address based on the IP + * \return Hostname of the address + * + * \param address IP address to resolve + * \param service Optional argument to specify the protocol used + * \param error Optional argument to get the error + * + * \remark Produces a NazaraAssert if address is invalid + */ + String IpAddress::ResolveAddress(const IpAddress& address, String* service, ResolveError* error) { NazaraAssert(address.IsValid(), "Invalid address"); @@ -163,6 +201,18 @@ namespace Nz return hostname; } + /*! + * \brief Resolves the address based on the hostname + * \return Informations about the host: IP(s) of the address, names, ... + * + * \param protocol Net protocol to use + * \param hostname Hostname to resolve + * \param service Specify the service used (http, ...) + * \param error Optional argument to get the error + * + * \remark Produces a NazaraAssert if net protocol is set to unknown + */ + std::vector IpAddress::ResolveHostname(NetProtocol protocol, const String& hostname, const String& service, ResolveError* error) { NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol"); diff --git a/src/Nazara/Network/NetPacket.cpp b/src/Nazara/Network/NetPacket.cpp index 7a1c0d7f5..0823f5258 100644 --- a/src/Nazara/Network/NetPacket.cpp +++ b/src/Nazara/Network/NetPacket.cpp @@ -9,11 +9,36 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::NetPacket + * \brief Network class that represents a packet + */ + + /*! + * \brief Operation to do when receiving data + * + * \param netCode Packet number + * \param data Raw memory + * \param size Size of the memory + */ + void NetPacket::OnReceive(UInt16 netCode, const void* data, std::size_t size) { Reset(netCode, data, size); } + /*! + * \brief Operation to do when sending data + * \return Beggining of the raw memory + * + * \param newSize Size of the memory to send + * + * \remark Produces a NazaraAssert if newSize is invalid + * \remark Produces a NazaraAssert if net code is invalid + * \remark Produces a NazaraError if header could not be encoded + */ + const void* NetPacket::OnSend(std::size_t* newSize) const { NazaraAssert(newSize, "Invalid size pointer"); @@ -30,6 +55,15 @@ namespace Nz return m_buffer->GetBuffer(); } + /*! + * \brief Decodes the header of the packet + * \return true If successful + * + * \param data Raw memory + * \param packetSize Size of the packet + * \param netCode Packet number + */ + bool NetPacket::DecodeHeader(const void* data, UInt16* packetSize, UInt16* netCode) { MemoryView stream(data, HeaderSize); @@ -40,6 +74,15 @@ namespace Nz return Unserialize(context, packetSize) && Unserialize(context, netCode); } + /*! + * \brief Encodes the header of the packet + * \return true If successful + * + * \param data Raw memory + * \param packetSize Size of the packet + * \param netCode Packet number + */ + bool NetPacket::EncodeHeader(void* data, UInt16 packetSize, UInt16 netCode) { MemoryView stream(data, HeaderSize); @@ -50,11 +93,19 @@ namespace Nz return Serialize(context, packetSize) && Serialize(context, netCode); } + /*! + * \brief Operation to do when stream is empty + */ + void NetPacket::OnEmptyStream() { Reset(0); } + /*! + * \brief Frees the stream + */ + void NetPacket::FreeStream() { if (!m_buffer) @@ -66,6 +117,16 @@ namespace Nz s_availableBuffers.emplace_back(std::make_pair(size, std::move(m_buffer))); } + /*! + * \brief Inits the internal stream + * + * \param minCapacity Minimal capacity of the stream + * \param cursorPos Position of the cursor in the stream + * \param openMode Flag of the stream + * + * \remark Produces a NazaraAssert if cursor position is greather than the capacity + */ + void NetPacket::InitStream(std::size_t minCapacity, UInt64 cursorPos, UInt32 openMode) { NazaraAssert(minCapacity >= cursorPos, "Cannot init stream with a smaller capacity than wanted cursor pos"); @@ -92,12 +153,21 @@ namespace Nz SetStream(&m_memoryStream); } + /*! + * \brief Initializes the NetPacket class + * \return true If initialization is successful + */ + bool NetPacket::Initialize() { s_availableBuffersMutex = std::make_unique(); return true; } + /*! + * \brief Uninitializes the NetPacket class + */ + void NetPacket::Uninitialize() { s_availableBuffers.clear(); diff --git a/src/Nazara/Network/Network.cpp b/src/Nazara/Network/Network.cpp index 41868b79b..fa3813dd4 100644 --- a/src/Nazara/Network/Network.cpp +++ b/src/Nazara/Network/Network.cpp @@ -24,9 +24,23 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::Network + * \brief Network class that represents the module initializer of Network + */ + + /*! + * \brief Initializes the Network module + * \return true if initialization is successful + * + * \remark Produces a NazaraNotice + * \remark Produces a NazaraError if one submodule failed + */ + bool Network::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; return true; // Already initialized @@ -68,11 +82,22 @@ namespace Nz return true; } + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + bool Network::IsInitialized() { return s_moduleReferenceCounter != 0; } + /*! + * \brief Uninitializes the Core module + * + * \remark Produces a NazaraNotice + */ + void Network::Uninitialize() { if (s_moduleReferenceCounter != 1) diff --git a/src/Nazara/Network/RUdpConnection.cpp b/src/Nazara/Network/RUdpConnection.cpp index 451d08f1e..1b374d604 100644 --- a/src/Nazara/Network/RUdpConnection.cpp +++ b/src/Nazara/Network/RUdpConnection.cpp @@ -10,6 +10,16 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::RUdpConnection + * \brief Network class that represents a reliable UDP connection + */ + + /*! + * \brief Constructs a RUdpConnection object by default + */ + RUdpConnection::RUdpConnection() : m_peerIterator(0), m_forceAckSendTime(10'000), //< 10ms @@ -23,9 +33,20 @@ namespace Nz { } + /*! + * \brief Connects to the IpAddress + * \return true + * + * \param remoteAddress Address to connect to + * + * \remark Produces a NazaraAssert if socket is not bound + * \remark Produces a NazaraAssert if remote is invalid + * \remark Produces a NazaraAssert if port is not specified + */ + bool RUdpConnection::Connect(const IpAddress& remoteAddress) { - NazaraAssert(m_socket.GetState() != SocketState_Bound, "Socket must be bound first"); + NazaraAssert(m_socket.GetState() == SocketState_Bound, "Socket must be bound first"); NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); NazaraAssert(remoteAddress.GetPort() != 0, "Remote address has no port"); @@ -39,6 +60,16 @@ namespace Nz return true; } + /*! + * \brief Connects to the hostname + * \return true If successful + * + * \param hostName Hostname of the remote + * \param protocol Net protocol to use + * \param service Specify the protocol used + * \param error Optional argument to get the error + */ + bool RUdpConnection::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error) { std::vector results = IpAddress::ResolveHostname(protocol, hostName, service, error); @@ -64,6 +95,13 @@ namespace Nz return Connect(hostnameAddress); } + /*! + * \brief Listens to a socket + * \return true If successfully bound + * + * \param remoteAddress Address to listen to + */ + bool RUdpConnection::Listen(const IpAddress& address) { if (!InitSocket(address.GetProtocol())) @@ -72,8 +110,19 @@ namespace Nz return m_socket.Bind(address) == SocketState_Bound; } + /*! + * \brief Polls the message + * \return true If there is a message + * + * \param message Message to poll + * + * \remark Produces a NazaraAssert if message is invalid + */ + bool RUdpConnection::PollMessage(RUdpMessage* message) { + NazaraAssert(message, "Invalid message"); + if (m_receivedMessages.empty()) return false; @@ -82,6 +131,16 @@ namespace Nz return true; } + /*! + * \brief Sends the packet to a peer + * \return true If peer exists (false may result from disconnected client) + * + * \param peerIp IpAddress of the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + bool RUdpConnection::Send(const IpAddress& peerIp, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) { auto it = m_peerByIP.find(peerIp); @@ -92,6 +151,10 @@ namespace Nz return true; } + /*! + * \brief Updates the reliable connection + */ + void RUdpConnection::Update() { m_currentTime = m_clock.GetMicroseconds(); @@ -156,6 +219,14 @@ namespace Nz //m_activeClients.Reset(); } + /*! + * \brief Disconnects a peer + * + * \param peerIndex Index of the peer + * + * \remark Produces a NazaraNotice + */ + void RUdpConnection::DisconnectPeer(std::size_t peerIndex) { PeerData& peer = m_peers[peerIndex]; @@ -193,6 +264,15 @@ namespace Nz m_peers.pop_back(); } + /*! + * \brief Enqueues a packet in the sending list + * + * \param peer Data relative to the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + void RUdpConnection::EnqueuePacket(PeerData& peer, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) { UInt16 protocolBegin = static_cast(m_protocol & 0xFFFF); @@ -208,6 +288,15 @@ namespace Nz EnqueuePacketInternal(peer, priority, reliability, std::move(data)); } + /*! + * \brief Enqueues internally a packet in the sending list + * + * \param peer Data relative to the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + void RUdpConnection::EnqueuePacketInternal(PeerData& peer, PacketPriority priority, PacketReliability reliability, NetPacket&& data) { PendingPacket pendingPacket; @@ -219,6 +308,13 @@ namespace Nz m_activeClients.UnboundedSet(peer.index); } + /*! + * \brief Inits the internal socket + * \return true If successful + * + * \param protocol Net protocol to use + */ + bool RUdpConnection::InitSocket(NetProtocol protocol) { CallOnExit updateLastError([this] @@ -233,6 +329,14 @@ namespace Nz return true; } + /*! + * \brief Processes the acks + * + * \param peer Data relative to the peer + * \param lastAck Last index of the ack + * \param ackBits Bits for acking + */ + void RUdpConnection::ProcessAcks(PeerData& peer, SequenceIndex lastAck, UInt32 ackBits) { auto it = peer.pendingAckQueue.begin(); @@ -257,6 +361,14 @@ namespace Nz } } + /*! + * \brief Registers a peer + * \return Data relative to the peer + * + * \param address Address of the peer + * \param state Status of the peer + */ + RUdpConnection::PeerData& RUdpConnection::RegisterPeer(const IpAddress& address, PeerState state) { PeerData data; @@ -266,7 +378,7 @@ namespace Nz data.index = m_peers.size(); data.lastPacketTime = m_currentTime; data.lastPingTime = m_currentTime; - data.roundTripTime = 1000000; ///< Okay that's quite a lot + data.roundTripTime = 1'000'000; ///< Okay that's quite a lot data.state = state; m_activeClients.UnboundedSet(data.index); @@ -276,6 +388,14 @@ namespace Nz return m_peers.back(); } + /*! + * \brief Operation to do when client requests a connection + * + * \param address Address of the peer + * \param sequenceId Sequence index for the ack + * \param token Token for connection + */ + void RUdpConnection::OnClientRequestingConnection(const IpAddress& address, SequenceIndex sequenceId, UInt64 token) { // Call hook to check if client should be accepted or not @@ -292,6 +412,13 @@ namespace Nz EnqueuePacket(client, PacketPriority_Immediate, PacketReliability_Reliable, connectionAcceptedPacket); } + /*! + * \brief Operation to do when a packet is lost + * + * \param peer Data relative to the peer + * \param packet Pending packet + */ + void RUdpConnection::OnPacketLost(PeerData& peer, PendingAckPacket&& packet) { //NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Lost packet " + String::Number(packet.sequenceId)); @@ -300,6 +427,14 @@ namespace Nz EnqueuePacketInternal(peer, packet.priority, packet.reliability, std::move(packet.data)); } + /*! + * \brief Operation to do when receiving a packet + * + * \param peerIndex Index of the peer + * + * \remark Produces a NazaraNotice + */ + void RUdpConnection::OnPacketReceived(const IpAddress& peerIp, NetPacket&& packet) { UInt16 protocolBegin; @@ -436,6 +571,13 @@ namespace Nz } } + /*! + * \brief Sends a packet to a peer + * + * \param peer Data relative to the peer + * \param packet Pending packet + */ + void RUdpConnection::SendPacket(PeerData& peer, PendingPacket&& packet) { if (peer.state == PeerState_WillAck) @@ -448,7 +590,7 @@ namespace Nz { if (ack == remoteSequence) continue; - + unsigned int difference = ComputeSequenceDifference(remoteSequence, ack); if (difference <= 32U) previousAcks |= (1U << (difference - 1)); @@ -473,6 +615,11 @@ namespace Nz peer.pendingAckQueue.emplace_back(std::move(pendingAckPacket)); } + /*! + * \brief Initializes the RUdpConnection class + * \return true + */ + bool RUdpConnection::Initialize() { std::random_device device; @@ -481,6 +628,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the RUdpConnection class + */ + void RUdpConnection::Uninitialize() { } diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index a134cf870..cf123ff89 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -20,6 +20,22 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::TcpClient + * \brief Network class that represents a client in a TCP connection + */ + + /*! + * \brief Connects to the IpAddress + * \return State of the socket + * + * \param remoteAddress Address to connect to + * + * \remark Produces a NazaraAssert if remote is invalid + * \remark Produces a NazaraAssert if remote's port is not specified + */ + SocketState TcpClient::Connect(const IpAddress& remoteAddress) { NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); @@ -45,6 +61,17 @@ namespace Nz return state; } + + /*! + * \brief Connects to the hostname + * \return State of the socket + * + * \param hostName Hostname of the remote + * \param protocol Net protocol to use + * \param service Specify the protocol used + * \param error Optional argument to get the error + */ + SocketState TcpClient::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error) { UpdateState(SocketState_Resolving); @@ -73,6 +100,14 @@ namespace Nz return Connect(hostnameAddress); } + /*! + * \brief Enables low delay in emitting + * + * \param lowDelay Should low delay be used + * + * \remark This may produce lag + */ + void TcpClient::EnableLowDelay(bool lowDelay) { if (m_isLowDelayEnabled != lowDelay) @@ -84,6 +119,14 @@ namespace Nz } } + /*! + * \brief Enables the keep alive flag + * + * \param keepAlive Should the connection be kept alive + * \param msTime Time in milliseconds before expiration + * \param msInterval Interval in milliseconds between two pings + */ + void TcpClient::EnableKeepAlive(bool keepAlive, UInt64 msTime, UInt64 msInterval) { if (m_isKeepAliveEnabled != keepAlive || m_keepAliveTime != msTime || m_keepAliveInterval != msInterval) @@ -97,22 +140,51 @@ namespace Nz } } + /*! + * \brief Checks whether the stream reached the end of the stream + * \return true if there is no more available bytes + */ + bool TcpClient::EndOfStream() const { return QueryAvailableBytes() == 0; } + /*! + * \brief Gets the position of the cursor + * \return 0 + * + * \remark Produces a NazaraError because it is a special stream + */ + UInt64 TcpClient::GetCursorPos() const { NazaraError("GetCursorPos() cannot be used on sequential streams"); return 0; } + /*! + * \brief Gets the size of the raw memory available + * \return Size of the memory available + */ + UInt64 TcpClient::GetSize() const { return QueryAvailableBytes(); } + /*! + * \brief Receives the data available + * \return true If data received + * + * \param buffer Raw memory to write + * \param size Size of the buffer + * \param received Optional argument to get the number of bytes received + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool TcpClient::Receive(void* buffer, std::size_t size, std::size_t* received) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -142,6 +214,17 @@ namespace Nz return true; } + /*! + * \brief Receives the packet available + * \return true If packet received + * + * \param packet Packet to receive + * + * \remark Produces a NazaraAssert if packet is invalid + * \remark Produces a NazaraAssert if packet size is inferior to the header size + * \remark Produces a NazaraWarning if packet's header is invalid + */ + bool TcpClient::ReceivePacket(NetPacket* packet) { //TODO: Every packet requires at least two Receive call, using an internal buffer of a fixed size would prevent this @@ -157,6 +240,7 @@ namespace Nz m_pendingPacket.received += received; + //TODO: Should never happen in production ! NazaraAssert(m_pendingPacket.received <= NetPacket::HeaderSize, "Received more data than header size"); if (m_pendingPacket.received >= NetPacket::HeaderSize) { @@ -185,6 +269,7 @@ namespace Nz m_pendingPacket.received += received; + //TODO: Should never happen in production ! NazaraAssert(m_pendingPacket.received <= packetSize, "Received more data than packet size"); if (m_pendingPacket.received >= packetSize) { @@ -202,6 +287,19 @@ namespace Nz return false; } + /*! + * \brief Sends the data available + * \return true If data sended + * + * \param buffer Raw memory to read + * \param size Size of the buffer + * \param sent Optional argument to get the number of bytes sent + * + * \remark Large sending are handled, you do not need to call this multiple time + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool TcpClient::Send(const void* buffer, std::size_t size, std::size_t* sent) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -244,6 +342,15 @@ namespace Nz return true; } + /*! + * \brief Sends the packet available + * \return true If packet sent + * + * \param packet Packet to send + * + * \remark Produces a NazaraError if packet could not be prepared for sending + */ + bool TcpClient::SendPacket(const NetPacket& packet) { std::size_t size = 0; @@ -258,12 +365,30 @@ namespace Nz return Send(ptr, size, nullptr); } + /*! + * \brief Sets the position of the cursor + * \return false + * + * \param offset Offset according to the beginning of the stream + * + * \remark Produces a NazaraError because it is a special stream + */ + bool TcpClient::SetCursorPos(UInt64 offset) { NazaraError("SetCursorPos() cannot be used on sequential streams"); return false; } + /*! + * \brief Waits for being connected before time out + * \return true If connection is successful + * + * \param msTimeout Time in milliseconds before time out + * + * \remark Produces a NazaraAssert if socket is invalid + */ + bool TcpClient::WaitForConnected(UInt64 msTimeout) { switch (m_state) @@ -308,10 +433,18 @@ namespace Nz return false; } + /*! + * \brief Flushes the stream + */ + void TcpClient::FlushStream() { } + /*! + * \brief Operation to do when closing socket + */ + void TcpClient::OnClose() { AbstractSocket::OnClose(); @@ -320,6 +453,12 @@ namespace Nz m_peerAddress = IpAddress::Invalid; } + /*! + * \brief Operation to do when opening socket + * + * \remark Produces a NazaraWarning if delay mode or keep alive failed + */ + void TcpClient::OnOpened() { AbstractSocket::OnOpened(); @@ -336,6 +475,16 @@ namespace Nz m_openMode = OpenMode_ReadWrite; } + /*! + * \brief Reads blocks + * \return Number of blocks read + * + * \param buffer Preallocated buffer to contain information read + * \param size Size of the read and thus of the buffer + * + * \remark Produces a NazaraAssert if socket is invalid + */ + std::size_t TcpClient::ReadBlock(void* buffer, std::size_t size) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -357,6 +506,13 @@ namespace Nz return received; } + /*! + * \brief Resets the connection with a new socket and a peer address + * + * \param handle Socket to connect + * \param peerAddress Address to connect to + */ + void TcpClient::Reset(SocketHandle handle, const IpAddress& peerAddress) { Open(handle); @@ -365,8 +521,20 @@ namespace Nz UpdateState(SocketState_Connected); } + /*! + * \brief Writes blocks + * \return Number of blocks written + * + * \param buffer Preallocated buffer containing information to write + * \param size Size of the writting and thus of the buffer + * + * \remark Produces a NazaraAssert if buffer is nullptr + * \remark Produces a NazaraAssert if socket is invalid + */ + std::size_t TcpClient::WriteBlock(const void* buffer, std::size_t size) { + NazaraAssert(buffer, "Invalid buffer"); NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); CallOnExit restoreBlocking; diff --git a/src/Nazara/Network/TcpServer.cpp b/src/Nazara/Network/TcpServer.cpp index b5995b6f5..7a33c066b 100644 --- a/src/Nazara/Network/TcpServer.cpp +++ b/src/Nazara/Network/TcpServer.cpp @@ -19,6 +19,22 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::TcpServer + * \brief Network class that represents a server in a TCP connection + */ + + /*! + * \brief Accepts a client + * \return true If client'socket is valid + * + * \param newClient Client connection + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if newClient is invalid + */ + bool TcpServer::AcceptClient(TcpClient* newClient) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Server isn't listening"); @@ -35,6 +51,16 @@ namespace Nz return false; } + /*! + * \brief Listens to a socket + * \return State of the socket + * + * \param address Address to listen to + * \param queueSize Size of the queue + * + * \remark Produces a NazaraAssert if address is invalid + */ + SocketState TcpServer::Listen(const IpAddress& address, unsigned int queueSize) { NazaraAssert(address.IsValid(), "Invalid address"); @@ -49,6 +75,10 @@ namespace Nz return state; } + /*! + * \brief Operation to do when closing socket + */ + void TcpServer::OnClose() { AbstractSocket::OnClose(); @@ -56,6 +86,10 @@ namespace Nz m_boundAddress = IpAddress::Invalid; } + /*! + * \brief Operation to do when opening socket + */ + void TcpServer::OnOpened() { AbstractSocket::OnOpened(); diff --git a/src/Nazara/Network/UdpSocket.cpp b/src/Nazara/Network/UdpSocket.cpp index a233881ea..b49aedcf3 100644 --- a/src/Nazara/Network/UdpSocket.cpp +++ b/src/Nazara/Network/UdpSocket.cpp @@ -17,6 +17,16 @@ namespace Nz { + /*! + * \brief Binds a specific IpAddress + * \return State of the socket + * + * \param address Address to bind + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if address is invalid + */ + SocketState UdpSocket::Bind(const IpAddress& address) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket hasn't been created"); @@ -30,6 +40,14 @@ namespace Nz return state; } + /*! + * \brief Enables broadcasting + * + * \param broadcasting Should the UDP broadcast + * + * \remark Produces a NazaraAssert if socket is invalid + */ + void UdpSocket::EnableBroadcasting(bool broadcasting) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -41,6 +59,13 @@ namespace Nz } } + /*! + * \brief Gets the maximum datagram size allowed + * \return Number of bytes + * + * \remark Produces a NazaraAssert if socket is invalid + */ + std::size_t UdpSocket::QueryMaxDatagramSize() { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket hasn't been created"); @@ -48,8 +73,22 @@ namespace Nz return SocketImpl::QueryMaxDatagramSize(m_handle, &m_lastError); } + /*! + * \brief Receives the data available + * \return true If data received + * + * \param buffer Raw memory to write + * \param size Size of the buffer + * \param from IpAddress of the peer + * \param received Optional argument to get the number of bytes received + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool UdpSocket::Receive(void* buffer, std::size_t size, IpAddress* from, std::size_t* received) { + NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket hasn't been created"); NazaraAssert(buffer && size > 0, "Invalid buffer"); int read; @@ -62,8 +101,21 @@ namespace Nz return true; } + /*! + * \brief Receives the packet available + * \return true If packet received + * + * \param packet Packet to receive + * \param from IpAddress of the peer + * + * \remark Produces a NazaraAssert if packet is invalid + * \remark Produces a NazaraWarning if packet's header is invalid + */ + bool UdpSocket::ReceivePacket(NetPacket* packet, IpAddress* from) { + NazaraAssert(packet, "Invalid packet"); + // I'm not sure what's the best between having a 65k bytes buffer ready for any datagram size // or querying the next datagram size every time, for now I'll leave it as is packet->Reset(NetCode_Invalid, std::numeric_limits::max()); @@ -97,6 +149,20 @@ namespace Nz return true; } + /*! + * \brief Sends the data available + * \return true If data sended + * + * \param to IpAddress of the peer + * \param buffer Raw memory to read + * \param size Size of the buffer + * \param sent Optional argument to get the number of bytes sent + * + * \remark Produces a NazaraAssert if peer address is invalid + * \remark Produces a NazaraAssert if protocol of communication is not the same than the peer + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool UdpSocket::Send(const IpAddress& to, const void* buffer, std::size_t size, std::size_t* sent) { NazaraAssert(to.IsValid(), "Invalid ip address"); @@ -113,6 +179,16 @@ namespace Nz return true; } + /*! + * \brief Sends the packet available + * \return true If packet sent + * + * \param to IpAddress of the peer + * \param packet Packet to send + * + * \remark Produces a NazaraError if packet could not be prepared for sending + */ + bool UdpSocket::SendPacket(const IpAddress& to, const NetPacket& packet) { std::size_t size = 0; @@ -127,6 +203,10 @@ namespace Nz return Send(to, ptr, size, nullptr); } + /*! + * \brief Operation to do when closing socket + */ + void UdpSocket::OnClose() { AbstractSocket::OnClose(); @@ -134,6 +214,10 @@ namespace Nz m_boundAddress = IpAddress::Invalid; } + /*! + * \brief Operation to do when opening socket + */ + void UdpSocket::OnOpened() { AbstractSocket::OnOpened(); diff --git a/tests/Engine/Network/IpAddress.cpp b/tests/Engine/Network/IpAddress.cpp new file mode 100644 index 000000000..8bb3e7d16 --- /dev/null +++ b/tests/Engine/Network/IpAddress.cpp @@ -0,0 +1,47 @@ +#include +#include + +SCENARIO("IpAddress", "[NETWORK][IPADDRESS]") +{ + GIVEN("Two default IpAddress") + { + Nz::IpAddress ipAddressV4; + Nz::IpAddress ipAddressV6; + + WHEN("We parse localhost") + { + Nz::String localhostIPv4 = "127.0.0.1"; + Nz::String localhostIPv6 = "::1"; + REQUIRE(ipAddressV4.BuildFromAddress(localhostIPv4.GetConstBuffer())); + REQUIRE(ipAddressV6.BuildFromAddress(localhostIPv6.GetConstBuffer())); + + THEN("It's the loop back") + { + REQUIRE(ipAddressV4.IsLoopback()); + REQUIRE(ipAddressV6.IsLoopback()); + } + } + } + + GIVEN("No IpAddress") + { + WHEN("We get the IP of Nazara") + { + std::vector hostnameInfos = Nz::IpAddress::ResolveHostname(Nz::NetProtocol_IPv4, "nazara.digitalpulsesoftware.net"); + + THEN("Result is not null") + { + REQUIRE(!hostnameInfos.empty()); + } + } + + WHEN("We convert IP to hostname") + { + Nz::IpAddress google(8, 8, 8, 8); + THEN("Google (DNS) is 8.8.8.8") + { + REQUIRE(Nz::IpAddress::ResolveAddress(google) == "google-public-dns-a.google.com"); + } + } + } +} diff --git a/tests/Engine/Network/RUdpConnection.cpp b/tests/Engine/Network/RUdpConnection.cpp new file mode 100644 index 000000000..a39100e94 --- /dev/null +++ b/tests/Engine/Network/RUdpConnection.cpp @@ -0,0 +1,40 @@ +#include +#include + +#include + +SCENARIO("RUdpConnection", "[NETWORK][RUDPCONNECTION]") +{ + GIVEN("Two RUdpConnection, one client, one server") + { + Nz::UInt16 port = 64266; + Nz::RUdpConnection server; + REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port)); + Nz::IpAddress serverIP = server.GetBoundAddress(); + REQUIRE(serverIP.IsValid()); + Nz::RUdpConnection client; + REQUIRE(client.Listen(Nz::NetProtocol_IPv4, port + 1)); + Nz::IpAddress clientIP = client.GetBoundAddress(); + REQUIRE(client.Connect(serverIP)); + REQUIRE(clientIP.IsValid()); + + WHEN("We send data from client") + { + Nz::NetPacket packet(1); + Nz::Vector3f vector123(1.f, 2.f, 3.f); + packet << vector123; + REQUIRE(client.Send(serverIP, Nz::PacketPriority_Immediate, Nz::PacketReliability_Reliable, packet)); + client.Update(); + + THEN("We should get it on the server") + { + Nz::RUdpMessage rudpMessage; + server.Update(); + REQUIRE(server.PollMessage(&rudpMessage)); + Nz::Vector3f result; + rudpMessage.data >> result; + REQUIRE(result == vector123); + } + } + } +} diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp new file mode 100644 index 000000000..63b4fe2df --- /dev/null +++ b/tests/Engine/Network/TCP.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +#include +#include + +#include + +SCENARIO("TCP", "[NETWORK][TCP]") +{ + GIVEN("Two TCP, one client, one server") + { + // Avoid reusing the same socket + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dis(1025, 64245); + + Nz::UInt16 port = dis(gen); + Nz::TcpServer server; + REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound); + Nz::IpAddress serverIP = server.GetBoundAddress(); + REQUIRE(serverIP.IsValid()); + Nz::TcpClient client; + REQUIRE(client.Connect(serverIP) == Nz::SocketState_Connecting); + Nz::IpAddress clientIP = client.GetRemoteAddress(); + REQUIRE(clientIP.IsValid()); + + Nz::TcpClient serverToClient; + REQUIRE(server.AcceptClient(&serverToClient)); + + WHEN("We send data from client") + { + Nz::NetPacket packet(1); + Nz::Vector3f vector123(1.f, 2.f, 3.f); + packet << vector123; + REQUIRE(client.SendPacket(packet)); + + THEN("We should get it on the server") + { + Nz::NetPacket resultPacket; + REQUIRE(serverToClient.ReceivePacket(&resultPacket)); + Nz::Vector3f result; + resultPacket >> result; + REQUIRE(result == vector123); + } + } + } +} diff --git a/tests/Engine/Network/UdpSocket.cpp b/tests/Engine/Network/UdpSocket.cpp new file mode 100644 index 000000000..3f199f09e --- /dev/null +++ b/tests/Engine/Network/UdpSocket.cpp @@ -0,0 +1,39 @@ +#include +#include + +#include +#include + +SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]") +{ + GIVEN("Two UdpSocket, one client, one server") + { + Nz::UInt16 port = 64256; + Nz::UdpSocket server(Nz::NetProtocol_IPv4); + REQUIRE(server.Bind(port) == Nz::SocketState_Bound); + Nz::IpAddress serverIP = server.GetBoundAddress(); + REQUIRE(serverIP.IsValid()); + Nz::UdpSocket client(Nz::NetProtocol_IPv4); + REQUIRE(client.Bind(port + 1) == Nz::SocketState_Bound); + Nz::IpAddress clientIP = client.GetBoundAddress(); + REQUIRE(clientIP.IsValid()); + + WHEN("We send data from client") + { + Nz::NetPacket packet(1); + Nz::Vector3f vector123(1.f, 2.f, 3.f); + packet << vector123; + REQUIRE(client.SendPacket(serverIP, packet)); + + THEN("We should get it on the server") + { + Nz::NetPacket resultPacket; + Nz::IpAddress fromIp; + REQUIRE(server.ReceivePacket(&resultPacket, &fromIp)); + Nz::Vector3f result; + resultPacket >> result; + REQUIRE(result == vector123); + } + } + } +} From 73c6f36494ce3a95275ee0f92a7360aa5e4e6c78 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:26:32 +0200 Subject: [PATCH 015/235] Fix loading of MD5 Former-commit-id: 551c26d193748e079a5049d87fc3a5c743694d33 --- src/Nazara/Utility/Animation.cpp | 2 ++ src/Nazara/Utility/Formats/MD5AnimParser.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index bbd57b1df..62591344b 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -37,6 +37,8 @@ namespace Nz Animation::~Animation() { OnAnimationRelease(this); + + Destroy(); } bool Animation::AddSequence(const Sequence& sequence) diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index 321ee8692..9cd930c2e 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -285,7 +285,8 @@ namespace Nz if (!Advance()) return false; - if (std::sscanf(&m_currentLine[0], "( %f %f %f ) ( %f %f %f )", &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, + // Space is important for the buffer of \n + if (std::sscanf(&m_currentLine[0], " ( %f %f %f ) ( %f %f %f )", &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 6) { UnrecognizedLine(true); @@ -324,7 +325,8 @@ namespace Nz return false; Vector3f min, max; - if (std::sscanf(&m_currentLine[0], "( %f %f %f ) ( %f %f %f )", &min.x, &min.y, &min.z, &max.x, &max.y, &max.z) != 6) + // Space is important for the buffer of \n + if (std::sscanf(&m_currentLine[0], " ( %f %f %f ) ( %f %f %f )", &min.x, &min.y, &min.z, &max.x, &max.y, &max.z) != 6) { UnrecognizedLine(true); return false; From 53ce22711c56c882efae82ad1a1aa036f51a862a Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:27:07 +0200 Subject: [PATCH 016/235] Slightly faster (about 5%) Former-commit-id: 286f14bbe625aeca31822ee2d0ec6221ab85b525 --- src/Nazara/Utility/AlgorithmUtility.cpp | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index 7f4dbaf44..c13d393dd 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -105,9 +105,9 @@ namespace Nz for (unsigned int i = 0; i < recursionLevel; ++i) { std::size_t triangleCount = triangles.size(); - for (std::size_t j = 0; j < triangleCount; ++j) + for (std::size_t i = 0; i < triangleCount; ++i) { - Vector3ui& triangle = triangles[j]; + Vector3ui& triangle = triangles[i]; unsigned int a = GetMiddleVertex(triangle.x, triangle.y); unsigned int b = GetMiddleVertex(triangle.y, triangle.z); @@ -333,21 +333,20 @@ namespace Nz } private: - float CalculateVertexScore(unsigned int vertex) const + float CalculateVertexScore(VertexCacheData& vertex) const { - const VertexCacheData* v = &m_vertices[vertex]; - if (v->remaining_valence <= 0) + if (vertex.remaining_valence <= 0) // No tri needs this vertex! return -1.0f; float ret = 0.0f; - if (v->position_in_cache < 0) + if (vertex.position_in_cache < 0) { // Vertex is not in FIFO cache - no score. } else { - if (v->position_in_cache < 3) + if (vertex.position_in_cache < 3) { // This vertex was used in the last triangle, // so it has a fixed score, whichever of the three @@ -360,14 +359,14 @@ namespace Nz { // Points for being high in the cache. const float Scaler = 1.0f / (32 - 3); - ret = 1.0f - (v->position_in_cache - 3) * Scaler; + ret = 1.0f - (vertex.position_in_cache - 3) * Scaler; ret = std::pow(ret, m_cacheDecayPower); } } // Bonus points for having a low number of tris still to // use the vert, so we get rid of lone verts quickly. - float valence_boost = std::pow(static_cast(v->remaining_valence), -m_valenceBoostPower); + float valence_boost = std::pow(static_cast(vertex.remaining_valence), -m_valenceBoostPower); ret += m_valenceBoostScale * valence_boost; return ret; @@ -378,8 +377,8 @@ namespace Nz int FullScoreRecalculation() { // calculate score for all vertices - for (unsigned int i = 0; i < m_vertices.size(); ++i) - m_vertices[i].current_score = CalculateVertexScore(i); + for (VertexCacheData& vertex : m_vertices) + vertex.current_score = CalculateVertexScore(vertex); // calculate scores for all active triangles float max_score = std::numeric_limits::lowest(); @@ -548,13 +547,13 @@ namespace Nz float sum = 0.f; for (unsigned int i = 0; i < 3; ++i) { - VertexCacheData* v = &m_vertices[t->verts[i]]; - float sc = v->current_score; - if (!v->calculated) - sc = CalculateVertexScore(t->verts[i]); + VertexCacheData& v = m_vertices[t->verts[i]]; + float sc = v.current_score; + if (!v.calculated) + sc = CalculateVertexScore(v); - v->current_score = sc; - v->calculated = true; + v.current_score = sc; + v.calculated = true; sum += sc; } From 482665c470775b61da9ad98a11663a18c9c5c081 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:27:31 +0200 Subject: [PATCH 017/235] Default behaviour without precision on name Former-commit-id: 612548b83a95f26f4480b18a3906521542b175d8 --- src/Nazara/Graphics/Formats/MeshLoader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index ffd2b423e..6769072bb 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -27,6 +27,12 @@ namespace Nz String filePath; if (matData.GetStringParameter(MaterialData::FilePath, &filePath)) { + if (!File::Exists(filePath)) + { + NazaraWarning("Shader name does not refer to an existing file, \".tga\" is used by default"); + filePath += ".tga"; + } + MaterialRef material = Material::New(); if (material->LoadFromFile(filePath, parameters.material)) model->SetMaterial(i, std::move(material)); From 56f98162d9283c741a07dd358669d93c5934a18a Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 20:43:27 +0200 Subject: [PATCH 018/235] Fail in copy-paste Former-commit-id: 98eab6094b00370c45213e0df33635dc08bb3064 --- src/Nazara/Utility/AlgorithmUtility.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index c13d393dd..d82af98af 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -105,9 +105,9 @@ namespace Nz for (unsigned int i = 0; i < recursionLevel; ++i) { std::size_t triangleCount = triangles.size(); - for (std::size_t i = 0; i < triangleCount; ++i) + for (std::size_t j = 0; j < triangleCount; ++j) { - Vector3ui& triangle = triangles[i]; + Vector3ui& triangle = triangles[j]; unsigned int a = GetMiddleVertex(triangle.x, triangle.y); unsigned int b = GetMiddleVertex(triangle.y, triangle.z); From c208da71e4813710b3a6cb6b45ce543f7d12f551 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 31 May 2016 09:02:35 +0200 Subject: [PATCH 019/235] Physics: Upgrade Newton to 3.13 Former-commit-id: d47450f1a5f04c50514993de1eda228ac8e5545b --- include/Nazara/Physics/Geom.hpp | 2 +- include/Nazara/Physics/PhysObject.hpp | 2 +- include/Nazara/Physics/PhysWorld.hpp | 2 +- src/Nazara/Physics/PhysObject.cpp | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/Nazara/Physics/Geom.hpp b/include/Nazara/Physics/Geom.hpp index 34b6c58ba..23a02c72b 100644 --- a/include/Nazara/Physics/Geom.hpp +++ b/include/Nazara/Physics/Geom.hpp @@ -20,7 +20,7 @@ #include #include -struct NewtonCollision; +class NewtonCollision; namespace Nz { diff --git a/include/Nazara/Physics/PhysObject.hpp b/include/Nazara/Physics/PhysObject.hpp index 7df72b1d1..d4d9c61b7 100644 --- a/include/Nazara/Physics/PhysObject.hpp +++ b/include/Nazara/Physics/PhysObject.hpp @@ -15,7 +15,7 @@ #include #include -struct NewtonBody; +class NewtonBody; namespace Nz { diff --git a/include/Nazara/Physics/PhysWorld.hpp b/include/Nazara/Physics/PhysWorld.hpp index b6fd7eae3..0300048b5 100644 --- a/include/Nazara/Physics/PhysWorld.hpp +++ b/include/Nazara/Physics/PhysWorld.hpp @@ -12,7 +12,7 @@ #include #include -struct NewtonWorld; +class NewtonWorld; namespace Nz { diff --git a/src/Nazara/Physics/PhysObject.cpp b/src/Nazara/Physics/PhysObject.cpp index 1b4816ee6..1ee4a44d5 100644 --- a/src/Nazara/Physics/PhysObject.cpp +++ b/src/Nazara/Physics/PhysObject.cpp @@ -68,7 +68,7 @@ namespace Nz PhysObject::~PhysObject() { if (m_body) - NewtonDestroyBody(m_world->GetHandle(), m_body); + NewtonDestroyBody(m_body); } void PhysObject::AddForce(const Vector3f& force, CoordSys coordSys) @@ -304,11 +304,13 @@ namespace Nz Vector3f min, max; NewtonBodyGetAABB(m_body, min, max); - NewtonWorldForEachBodyInAABBDo(m_world->GetHandle(), min, max, [](const NewtonBody* const body, void* const userData) + NewtonWorldForEachBodyInAABBDo(m_world->GetHandle(), min, max, [](const NewtonBody* const body, void* const userData) -> int { NazaraUnused(userData); NewtonBodySetSleepState(body, 0); - }, nullptr); + return 1; + }, + nullptr); } /*for (std::set::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) (*it)->PhysObjectOnUpdate(this);*/ @@ -317,7 +319,7 @@ namespace Nz PhysObject& PhysObject::operator=(PhysObject&& object) { if (m_body) - NewtonDestroyBody(m_world->GetHandle(), m_body); + NewtonDestroyBody(m_body); m_body = object.m_body; m_forceAccumulator = std::move(object.m_forceAccumulator); From 08037b220eea011bf8df220f0cbe3091a820a6b9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 31 May 2016 09:06:24 +0200 Subject: [PATCH 020/235] Physics: Add new libraries for Windows Former-commit-id: 14a29031ab11b20d73fb6ada6d0e834056c80306 --- build/scripts/modules/physics.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/modules/physics.lua b/build/scripts/modules/physics.lua index fbf6f39c8..f6d485a67 100644 --- a/build/scripts/modules/physics.lua +++ b/build/scripts/modules/physics.lua @@ -2,5 +2,5 @@ MODULE.Name = "Physics" MODULE.Libraries = { "NazaraCore", - "newton" + "Newton" } From c18e2a81a93fbf5df1472da54066dce62db66686 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Tue, 31 May 2016 21:50:31 +0200 Subject: [PATCH 023/235] Fix for problems signaled by clang static analyzer Former-commit-id: 4ed4c9c3f39bc1769c4b79f62401266a842e8d8b --- include/Nazara/Network/RUdpConnection.inl | 2 +- src/Nazara/Core/Posix/FileImpl.cpp | 13 +++++++- src/Nazara/Core/String.cpp | 31 ++++++-------------- src/Nazara/Graphics/DepthRenderTechnique.cpp | 3 +- tests/Engine/Core/String.cpp | 20 +++++++++++++ 5 files changed, 43 insertions(+), 26 deletions(-) diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index 53e797b59..48173bd77 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -132,7 +132,7 @@ namespace Nz else difference = sequence - sequence2; - return 0; + return difference; } /*! diff --git a/src/Nazara/Core/Posix/FileImpl.cpp b/src/Nazara/Core/Posix/FileImpl.cpp index f6e8b3bcc..b9a6b0a31 100644 --- a/src/Nazara/Core/Posix/FileImpl.cpp +++ b/src/Nazara/Core/Posix/FileImpl.cpp @@ -143,7 +143,18 @@ namespace Nz return false; } - mode_t permissions; // TODO : get permission from first file + mode_t permissions; + struct stat sb; + if (fstat(fd1, &sb) == -1) // get permission from first file + { + NazaraWarning("Could not get permissions of source file"); + permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + } + else + { + permissions = sb.st_mode & ~S_IFMT; // S_IFMT: bit mask for the file type bit field -> ~S_IFMT: general permissions + } + int fd2 = open64(targetPath.GetConstBuffer(), O_WRONLY | O_TRUNC, permissions); if (fd2 == -1) { diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index a57d89861..20d1c1897 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -2827,21 +2827,15 @@ namespace Nz { const char* c = oldCharacters; char character = Detail::ToLower(*ptr); - bool found = false; + + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + EnsureOwnership(); + ptr = &m_sharedString->string[offset]; + do { if (character == Detail::ToLower(*c)) { - if (!found) - { - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - - EnsureOwnership(); - - ptr = &m_sharedString->string[offset]; - found = true; - } - *ptr = replaceCharacter; ++count; break; @@ -2853,19 +2847,12 @@ namespace Nz } else { - bool found = false; + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + EnsureOwnership(); + ptr = &m_sharedString->string[offset]; + while ((ptr = std::strpbrk(ptr, oldCharacters)) != nullptr) { - if (!found) - { - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - - EnsureOwnership(); - - ptr = &m_sharedString->string[offset]; - found = true; - } - *ptr++ = replaceCharacter; ++count; } diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 233eb9c72..8badefcc9 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -464,7 +464,6 @@ namespace Nz void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; - const ShaderUniforms* shaderUniforms = nullptr; for (auto& matIt : layer.opaqueModels) { @@ -488,7 +487,7 @@ namespace Nz if (shader != lastShader) { // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); + GetShaderUniforms(shader); lastShader = shader; } diff --git a/tests/Engine/Core/String.cpp b/tests/Engine/Core/String.cpp index eac5eaef6..fe9c80c30 100644 --- a/tests/Engine/Core/String.cpp +++ b/tests/Engine/Core/String.cpp @@ -122,5 +122,25 @@ SCENARIO("String", "[CORE][STRING]") } } }*/ + + GIVEN("A string") + { + Nz::String replaceAny("abapeilomuky"); + Nz::String replaceAnyWithCase("abapEilOmuky"); + + WHEN("We replace any of vowels after character 3") + { + unsigned int nbrOfChanges = replaceAny.ReplaceAny("aeiouy", '$', 3); + unsigned int nbrOfChangesWithCase = replaceAnyWithCase.ReplaceAny("AEIOUY", '$', 3); + + THEN("These results are expected") + { + REQUIRE(replaceAny == "abap$$l$m$k$"); + REQUIRE(nbrOfChanges == 5); + REQUIRE(replaceAnyWithCase == "abap$il$muky"); + REQUIRE(nbrOfChangesWithCase == 2); + } + } + } } From e4449392d64125f58f8fc076cb16ece8b44ee9e6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 08:34:44 +0200 Subject: [PATCH 024/235] Sdk: Fix uninitialization of components and systems Former-commit-id: 9efda10439d00075c1c3df74216b03a4d079a46e [formerly 0d8ac4dda719e46b02f8b8b04216de1f602c4ebb] Former-commit-id: f1f00bf978ea87e977752aef2d2f7936fdaec15b --- SDK/src/NDK/Sdk.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 21bfd236f..7f29bb18e 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -112,6 +112,12 @@ namespace Ndk // Uninitialize the SDK s_referenceCounter = 0; + // Components + BaseComponent::Uninitialize(); + + // Systems + BaseSystem::Uninitialize(); + // Uninitialize the engine #ifndef NDK_SERVER From fcc85519b8c647b2946f8801e0d9238f3f733d55 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 09:34:42 +0200 Subject: [PATCH 025/235] Remove Visual Studio 2015 database file Former-commit-id: d94f9a39860013a2ad989c373672fa61ae104bc9 [formerly 221e90d473f96dca1377ca8352e9cafe6a824146] Former-commit-id: b7a15475d0586f39a5fd677b02956ff549b962c1 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 258594792..f3b8b2bbd 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ build/**/*.vcxprojResolveAssemblyReference.cache build/**/*.nativecodeanalysis.all.xml build/**/*.nativecodeanalysis.xml build/**/*.VC.opendb +build/**/*.VC.db # Compiled Object files build/**/*.slo From f9d2c6c9e0a1de2285f8ef638ef598eecbd64199 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 09:36:01 +0200 Subject: [PATCH 026/235] Build/Vulkan: Fix compilation under Linux Former-commit-id: 4bbb666b21a08c6937d96245beb7444122918a91 [formerly 045c8090c3aec06323a15cd8622547d0f62e7979] Former-commit-id: 553d2be42ae0387537e4b63f9ac4e1a1127a3a3c --- build/scripts/modules/vulkan.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/scripts/modules/vulkan.lua b/build/scripts/modules/vulkan.lua index a8e674d03..760a4e58c 100644 --- a/build/scripts/modules/vulkan.lua +++ b/build/scripts/modules/vulkan.lua @@ -10,10 +10,10 @@ MODULE.Libraries = { } MODULE.OsDefines.Linux = { - "VK_USE_PLATFORM_MIR_KHR", - "VK_USE_PLATFORM_XCB_KHR", - "VK_USE_PLATFORM_XLIB_KHR", - "VK_USE_PLATFORM_WAYLAND_KHR" +-- "VK_USE_PLATFORM_MIR_KHR", + "VK_USE_PLATFORM_XCB_KHR" +-- "VK_USE_PLATFORM_XLIB_KHR", +-- "VK_USE_PLATFORM_WAYLAND_KHR" } MODULE.OsDefines.BSD = MODULE.OsDefines.Linux From 9fc83b2dfab2438546bc798add5a99581f249176 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:06:32 +0200 Subject: [PATCH 027/235] Vulkan/Surface: Fix compilation under Linux Former-commit-id: 626775e610905a3a0de8c1b03cc57bf5dfa76985 [formerly d4c8c980bf6504eb89d4a550fc132858c24001fd] Former-commit-id: a02bcd151ce6ab0c19f3834a74f1c6a753cffd89 --- include/Nazara/Vulkan/VkSurface.inl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl index b6cb3a28f..f64c24af0 100644 --- a/include/Nazara/Vulkan/VkSurface.inl +++ b/include/Nazara/Vulkan/VkSurface.inl @@ -34,7 +34,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_ANDROID_KHR inline bool Surface::Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateAndroidSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateAndroidSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } @@ -55,7 +55,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_MIR_KHR inline bool Surface::Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateMirSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateMirSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } @@ -77,7 +77,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_XCB_KHR inline bool Surface::Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateXcbSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateXcbSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } @@ -99,7 +99,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_XLIB_KHR inline bool Surface::Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateXlibSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateXlibSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } From 514ce36e0761e32e386f61d1b1b53fbe4105a36c Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:08:13 +0200 Subject: [PATCH 028/235] Vulkan/CommandBuffer: Fix warning for GCC Former-commit-id: 5129610debed09b5daa5dcc5517f352fff243627 [formerly 5370294e6811d7a0a8d690b5f57ae2ed0734b7c7] Former-commit-id: 96eae602a4d73535382952bb361dc7d0e14ee540 --- include/Nazara/Vulkan/VkCommandBuffer.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index d9944e33b..d2d6f50d7 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -77,7 +77,7 @@ namespace Nz renderPass, subpass, framebuffer, - (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), queryFlags, pipelineStatistics }; @@ -102,7 +102,7 @@ namespace Nz VK_NULL_HANDLE, 0, VK_NULL_HANDLE, - (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), queryFlags, pipelineStatistics }; From 37f32bdb13f56e98b468a7a2c78926fe750d6426 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:51:32 +0200 Subject: [PATCH 029/235] Build: Add server option, allows to compile only the server-side part of Nazara Former-commit-id: 15080ac65f3186acf31967ae275d1aceeb2bd0dc [formerly 8eb6896afe9c6d63b5772a4c2237a6bf81c5b524] Former-commit-id: 8f75843edf54398dcd74487829cf2af857704524 --- SDK/include/NDK/Components.hpp | 13 ++--- .../NDK/Components/CameraComponent.hpp | 2 + .../NDK/Components/GraphicsComponent.hpp | 2 + SDK/include/NDK/Components/LightComponent.hpp | 2 + .../NDK/Components/ListenerComponent.hpp | 2 + SDK/include/NDK/Systems.hpp | 9 +-- SDK/include/NDK/Systems/ListenerSystem.hpp | 2 + SDK/include/NDK/Systems/RenderSystem.hpp | 2 + build/scripts/common.lua | 57 +++++++++++++++---- build/scripts/modules/audio.lua | 2 + build/scripts/modules/renderer.lua | 2 + build/scripts/modules/vulkan.lua | 2 + build/scripts/tools/ndk.lua | 19 +++---- build/scripts/tools/ndk_server.lua | 19 ++++--- 14 files changed, 92 insertions(+), 43 deletions(-) diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp index 46392ab7c..ca993b5b6 100644 --- a/SDK/include/NDK/Components.hpp +++ b/SDK/include/NDK/Components.hpp @@ -1,20 +1,17 @@ -// This file was automatically generated on 03 Mar 2016 at 14:09:12 +// This file was automatically generated on 01 Jun 2016 at 13:11:09 #pragma once #ifndef NDK_COMPONENTS_GLOBAL_HPP #define NDK_COMPONENTS_GLOBAL_HPP +#include #include +#include +#include +#include #include #include #include -#ifndef NDK_SERVER -#include -#include -#include -#include -#endif - #endif // NDK_COMPONENTS_GLOBAL_HPP diff --git a/SDK/include/NDK/Components/CameraComponent.hpp b/SDK/include/NDK/Components/CameraComponent.hpp index d5951109b..af2245b11 100644 --- a/SDK/include/NDK/Components/CameraComponent.hpp +++ b/SDK/include/NDK/Components/CameraComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_CAMERACOMPONENT_HPP #define NDK_COMPONENTS_CAMERACOMPONENT_HPP @@ -108,3 +109,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_CAMERACOMPONENT_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index f8fa2bf66..86cefb782 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP #define NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP @@ -80,3 +81,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/LightComponent.hpp b/SDK/include/NDK/Components/LightComponent.hpp index c55ae57bb..80f84a759 100644 --- a/SDK/include/NDK/Components/LightComponent.hpp +++ b/SDK/include/NDK/Components/LightComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_LIGHTCOMPONENT_HPP #define NDK_COMPONENTS_LIGHTCOMPONENT_HPP @@ -28,3 +29,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_LIGHTCOMPONENT_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/ListenerComponent.hpp b/SDK/include/NDK/Components/ListenerComponent.hpp index bee1ac14a..3d472bed3 100644 --- a/SDK/include/NDK/Components/ListenerComponent.hpp +++ b/SDK/include/NDK/Components/ListenerComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_LISTENERCOMPONENT_HPP #define NDK_COMPONENTS_LISTENERCOMPONENT_HPP @@ -30,3 +31,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_LISTENERCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp index 193438b5e..176a956ee 100644 --- a/SDK/include/NDK/Systems.hpp +++ b/SDK/include/NDK/Systems.hpp @@ -1,16 +1,13 @@ -// This file was automatically generated on 03 Mar 2016 at 14:09:12 +// This file was automatically generated on 01 Jun 2016 at 13:11:09 #pragma once #ifndef NDK_SYSTEMS_GLOBAL_HPP #define NDK_SYSTEMS_GLOBAL_HPP +#include #include +#include #include -#ifndef NDK_SERVER -#include -#include -#endif - #endif // NDK_SYSTEMS_GLOBAL_HPP diff --git a/SDK/include/NDK/Systems/ListenerSystem.hpp b/SDK/include/NDK/Systems/ListenerSystem.hpp index 6f40fcdf9..bb166a4c1 100644 --- a/SDK/include/NDK/Systems/ListenerSystem.hpp +++ b/SDK/include/NDK/Systems/ListenerSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_LISTENERSYSTEM_HPP #define NDK_SYSTEMS_LISTENERSYSTEM_HPP @@ -27,3 +28,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_LISTENERSYSTEM_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 72aa1efb1..f2fbc7a65 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP #define NDK_SYSTEMS_RENDERSYSTEM_HPP @@ -70,3 +71,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_RENDERSYSTEM_HPP +#endif // NDK_SERVER diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 822067ea2..6cf0025ba 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -196,9 +196,7 @@ function NazaraBuild:Execute() targetdir("../lib/" .. makeLibDir .. "/x64") -- Copy the module binaries to the example folder - if (os.is("windows")) then - self:MakeCopyAfterBuild(moduleTable) - end + self:MakeCopyAfterBuild(moduleTable) configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") @@ -310,7 +308,7 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end - -- Copy the module binaries to the example folder + -- Copy the tool binaries to the example folder if (toolTable.CopyTargetToExampleDir) then self:MakeCopyAfterBuild(toolTable) end @@ -450,6 +448,11 @@ end function NazaraBuild:Initialize() -- Commençons par les options + newoption({ + trigger = "server", + description = "Excludes client-only modules/tools/examples" + }) + newoption({ trigger = "united", description = "Builds all the modules as one united library" @@ -605,13 +608,20 @@ function NazaraBuild:Initialize() self.OrderedExtLibs = {} self.OrderedModules = {} self.OrderedTools = {} - local tables = {self.Examples, self.ExtLibs, self.Modules, self.Tools} - local orderedTables = {self.OrderedExamples, self.OrderedExtLibs, self.OrderedModules, self.OrderedTools} + local tables = {self.ExtLibs, self.Modules, self.Tools, self.Examples} + local orderedTables = {self.OrderedExtLibs, self.OrderedModules, self.OrderedTools, self.OrderedExamples} for k,projects in ipairs(tables) do + -- Begin by resolving every project (because of dependencies in the same category) for projectId,projectTable in pairs(projects) do - self:Process(projectTable) - - table.insert(orderedTables[k], projectTable) + self:Resolve(projectTable) + end + + for projectId,projectTable in pairs(projects) do + if (self:Process(projectTable)) then + table.insert(orderedTables[k], projectTable) + else + print("Rejected client-only " .. projectTable.Name .. " " .. projectTable.Type) + end end table.sort(orderedTables[k], function (a, b) return a.Name < b.Name end) @@ -772,13 +782,22 @@ local PosixOSes = { } function NazaraBuild:Process(infoTable) - local libraries = {} + if (infoTable.ClientOnly and _OPTIONS["server"]) then + return false + end + + local libraries = {} for k, library in pairs(infoTable.Libraries) do local moduleName = library:match("Nazara(%w+)") local moduleTable = moduleName and self.Modules[moduleName:lower()] local toolTable = moduleName and self.Tools[moduleName:lower()] if (moduleTable) then + if (moduleTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + if (_OPTIONS["united"]) then library = "NazaraEngine" else @@ -794,6 +813,11 @@ function NazaraBuild:Process(infoTable) else local extLibTable = self.ExtLibs[library:lower()] if (extLibTable) then + if (extLibTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + library = extLibTable.Name table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") @@ -802,6 +826,11 @@ function NazaraBuild:Process(infoTable) table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") else if (toolTable and toolTable.Kind == "library") then + if (toolTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + library = "Nazara" .. toolTable.Name -- Import tools includes @@ -862,6 +891,14 @@ function NazaraBuild:Process(infoTable) end end end + + return true +end + +function NazaraBuild:Resolve(infoTable) + if (type(infoTable.Libraries) == "function") then + infoTable.Libraries = infoTable.Libraries() + end end function NazaraBuild:MakeCopyAfterBuild(infoTable) diff --git a/build/scripts/modules/audio.lua b/build/scripts/modules/audio.lua index 27e49a08c..509972dc3 100644 --- a/build/scripts/modules/audio.lua +++ b/build/scripts/modules/audio.lua @@ -1,5 +1,7 @@ MODULE.Name = "Audio" +MODULE.ClientOnly = true + MODULE.Defines = { "NAZARA_AUDIO_OPENAL" } diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index 7e3edadbe..bbc472b75 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -1,5 +1,7 @@ MODULE.Name = "Renderer" +MODULE.ClientOnly = true + MODULE.Defines = { "NAZARA_RENDERER_OPENGL" } diff --git a/build/scripts/modules/vulkan.lua b/build/scripts/modules/vulkan.lua index 760a4e58c..62a00a745 100644 --- a/build/scripts/modules/vulkan.lua +++ b/build/scripts/modules/vulkan.lua @@ -1,5 +1,7 @@ MODULE.Name = "Vulkan" +MODULE.ClientOnly = true + MODULE.Defines = { "VK_NO_PROTOTYPES" } diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 5a1084f48..961fa6d7f 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -22,14 +22,11 @@ TOOL.Files = { "../SDK/src/NDK/**.cpp" } -TOOL.Libraries = { - "NazaraCore", - "NazaraAudio", - "NazaraLua", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility", - "NazaraRenderer", - "NazaraGraphics" -} +TOOL.Libraries = function() + local libraries = {} + for k,v in pairs(NazaraBuild.Modules) do + table.insert(libraries, "Nazara" .. v.Name) + end + + return libraries +end \ No newline at end of file diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 978d620be..b1a71453e 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -37,11 +37,14 @@ TOOL.FilesExcluded = { "../SDK/**/LuaBinding_Renderer.*" } -TOOL.Libraries = { - "NazaraCore", - "NazaraLua", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility" -} + +TOOL.Libraries = function() + local libraries = {} + for k,v in pairs(NazaraBuild.Modules) do + if (not v.ClientOnly) then + table.insert(libraries, "Nazara" .. v.Name) + end + end + + return libraries +end From e846934960bb9e50d7b7d2c111fc614f4e500990 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:52:59 +0200 Subject: [PATCH 030/235] Build: Fix with-extlibs option being required for compilation Former-commit-id: 41219e06c9f0a05221440eefb6268222757af8e1 [formerly fdb27339a5b90fce1bbea576012c72c433615e23] Former-commit-id: e979847fb2bc6d6f80b9fc02956d08113bae1e39 --- build/scripts/common.lua | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 6cf0025ba..7e3cb2c33 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -15,7 +15,7 @@ function NazaraBuild:Execute() if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" - if (#self.OrderedExtLibs > 0) then + if (_OPTIONS["with-extlibs"]) then workspace("NazaraExtlibs") platforms(platformData) @@ -494,26 +494,24 @@ function NazaraBuild:Initialize() ACTION = nil -- Extern libraries - if (_OPTIONS["with-extlibs"]) then - local extlibs = os.matchfiles("../extlibs/build/*.lua") - for k,v in pairs(extlibs) do - local f, err = loadfile(v) - if (f) then - LIBRARY = {} - self:SetupInfoTable(LIBRARY) + local extlibs = os.matchfiles("../extlibs/build/*.lua") + for k,v in pairs(extlibs) do + local f, err = loadfile(v) + if (f) then + LIBRARY = {} + self:SetupInfoTable(LIBRARY) - f() + f() - local succeed, err = self:RegisterExternLibrary(LIBRARY) - if (not succeed) then - print("Unable to register extern library: " .. err) - end - else - print("Unable to load extern library file: " .. err) - end - end - LIBRARY = nil - end + local succeed, err = self:RegisterExternLibrary(LIBRARY) + if (not succeed) then + print("Unable to register extern library: " .. err) + end + else + print("Unable to load extern library file: " .. err) + end + end + LIBRARY = nil -- Then the modules local modules = os.matchfiles("scripts/modules/*.lua") From b934eef2a3d1b2ac5ee8837c795a9f4afeebe939 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 14:11:58 +0200 Subject: [PATCH 031/235] Sdk/World: Fix compilation error when submitting arguments on system creation Former-commit-id: c46b7be1d998d5bdf87c25b1f4acc97de771ac9a [formerly e39dce0eaeb275d5ca62dfb8980869a7cc68c857] Former-commit-id: c799b611b8faefe26cfe6c06a77072c51f3c9c28 --- SDK/include/NDK/World.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index 91ebc3922..ba2b33bd4 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -44,7 +44,7 @@ namespace Ndk static_assert(std::is_base_of::value, "SystemType is not a component"); // Allocation et affectation du component - std::unique_ptr ptr(new SystemType(std::forward(args)...)); + std::unique_ptr ptr(new SystemType(std::forward(args)...)); return static_cast(AddSystem(std::move(ptr))); } From 0ee76b30a9a154f2c6e53eb5586ac321b9e1ec60 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Jun 2016 13:49:30 +0200 Subject: [PATCH 032/235] Graphics: Prevent shadow-mapping code to compile without shadow-mapping Temporary fix for OpenGL 3.3 Former-commit-id: 52d8ae54ee861f85e0cd2c66848c933227d02041 [formerly 3a43b5badc40d76aeca49795ad36d6475510ae68] Former-commit-id: 39bf34c0ae386859a5bc74106ffccca5adf78475 --- src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h | 2 +- src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag | 2 ++ src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h | 2 +- src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h b/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h index 993c7291b..7c3081f31 100644 --- a/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h +++ b/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h @@ -1 +1 @@ -47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,10,35,101,108,115,101,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,35,101,110,100,105,102,10,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,10,35,101,108,115,101,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,10,35,101,110,100,105,102,10,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,10,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,10,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,10,9,35,101,108,115,101,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,10,9,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,9,35,101,110,100,105,102,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,10,35,101,108,115,101,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,108,115,101,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,110,100,105,102,10,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,116,101,120,67,111,111,114,100,115,41,59,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,116,101,120,67,111,111,114,100,115,41,59,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index 94184d6ab..61ed69632 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -94,6 +94,7 @@ float VectorToDepthValue(vec3 vec, float zNear, float zFar) return (normZ + 1.0) * 0.5; } +#if SHADOW_MAPPING float CalculateDirectionalShadowFactor(int lightIndex) { vec4 lightSpacePos = vLightSpacePos[lightIndex]; @@ -119,6 +120,7 @@ float CalculateSpotShadowFactor(int lightIndex) return visibility; } +#endif void main() { diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index b3c3f2c63..6f1495308 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,10,35,101,110,100,105,102,10,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,99,111,108,111,114,59,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,10,125,59,10,10,47,47,32,76,117,109,105,195,168,114,101,115,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,10,47,47,32,77,97,116,195,169,114,105,97,117,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,47,47,32,65,117,116,114,101,115,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,10,123,10,9,118,101,99,51,32,99,111,108,111,114,59,10,10,9,102,32,42,61,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,10,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,10,125,10,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,10,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,10,123,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,10,125,10,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,10,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,10,9,102,108,111,97,116,32,120,44,121,59,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,10,9,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,10,125,10,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,10,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,35,101,108,115,101,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,10,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,10,35,101,110,100,105,102,10,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,9,35,101,110,100,105,102,10,9,9,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,10,10,9,35,105,102,32,76,73,71,72,84,73,78,71,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,9,35,101,110,100,105,102,10,10,9,47,42,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,10,9,42,47,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,10,9,35,101,108,115,101,32,47,47,32,76,73,71,72,84,73,78,71,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,10,9,35,101,110,100,105,102,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,76,73,71,72,84,73,78,71,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,9,35,101,110,100,105,102,10,9,9,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,10,9,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,125,10,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,9,35,101,108,115,101,32,47,47,32,76,73,71,72,84,73,78,71,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h index fbdd39607..c1611105a 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h @@ -1 +1 @@ -47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,10,35,101,108,115,101,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,35,101,110,100,105,102,10,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,10,35,101,108,115,101,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,10,35,101,110,100,105,102,10,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,10,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,10,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,10,9,35,101,108,115,101,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,10,9,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,9,35,101,110,100,105,102,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,10,35,101,108,115,101,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,108,115,101,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,110,100,105,102,10,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,10,10,35,105,102,32,76,73,71,72,84,73,78,71,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,10,9,35,101,108,115,101,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,10,9,35,101,110,100,105,102,10,9,10,9,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,10,9,35,101,108,115,101,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,10,35,101,110,100,105,102,10,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,10,9,35,101,110,100,105,102,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,13,10,9,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,13,10,9,35,101,110,100,105,102,13,10,9,13,10,9,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,13,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file From a3d681b80257719d643342b351a0387f13d4323a Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Jun 2016 19:10:33 +0200 Subject: [PATCH 033/235] Utility/PixelFormat: Fix ComputeSize for DXT formats Former-commit-id: fbc4390a2ff6747a2e7047a10d0a47c64fa59d1c [formerly d9df1b4535857c96ab396b8afcb69658528093f7] Former-commit-id: cb591414508a1d4b5ebc217b4b063a795020309e --- include/Nazara/Utility/PixelFormat.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index e30701d3d..e384d8574 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -156,7 +156,7 @@ namespace Nz case PixelFormatType_DXT1: case PixelFormatType_DXT3: case PixelFormatType_DXT5: - return (((width + 3) / 4) * ((height + 3) / 4) * (format == PixelFormatType_DXT1) ? 8 : 16) * depth; + return (((width + 3) / 4) * ((height + 3) / 4) * ((format == PixelFormatType_DXT1) ? 8 : 16)) * depth; default: NazaraError("Unsupported format"); From 575e308cf450ab9881eed2cb297fea431f5a1b94 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 12:58:04 +0200 Subject: [PATCH 036/235] Network/Windows: Fix build on compilers with outdated windows.h Former-commit-id: 96643108e3393c569bead44fb9783af1ada1b89d [formerly c04dd5024e87898f5dd1b6de53c28373558c4bf9] Former-commit-id: 13d6954d0185499fa86239106dd01be82303ea9f --- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 ++ src/Nazara/Network/Win32/IpAddressImpl.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 9f3918574..54d8ee4f5 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -100,6 +100,7 @@ namespace Nz return IpAddress::Invalid; } + #if NAZARA_CORE_WINDOWS_VISTA IpAddress IpAddressImpl::FromAddrinfo(const addrinfoW* info) { switch (info->ai_family) @@ -121,6 +122,7 @@ namespace Nz return IpAddress::Invalid; } + #endif IpAddress IpAddressImpl::FromSockAddr(const sockaddr* address) { diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index 4b27bef32..960092839 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -17,7 +17,9 @@ namespace Nz ~IpAddressImpl() = delete; static IpAddress FromAddrinfo(const addrinfo* info); + #if NAZARA_CORE_WINDOWS_VISTA static IpAddress FromAddrinfo(const addrinfoW* info); + #endif static IpAddress FromSockAddr(const sockaddr* address); static IpAddress FromSockAddr(const sockaddr_in* addressv4); static IpAddress FromSockAddr(const sockaddr_in6* addressv6); From f799ef654b795c012bb70de2785f89c3f4938368 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 12:58:04 +0200 Subject: [PATCH 037/235] Network/Windows: Fix build on compilers with outdated windows.h (Fixes 63) Former-commit-id: 8ef1d9bc867d0413c12e14e1c41042a73bc239a6 [formerly 4e07c16b7ea58c6d0afd6b91511c1856af155375] Former-commit-id: 1e36f93d085a06a06e9e7179f18d32284b79ee5a --- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 ++ src/Nazara/Network/Win32/IpAddressImpl.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 9f3918574..54d8ee4f5 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -100,6 +100,7 @@ namespace Nz return IpAddress::Invalid; } + #if NAZARA_CORE_WINDOWS_VISTA IpAddress IpAddressImpl::FromAddrinfo(const addrinfoW* info) { switch (info->ai_family) @@ -121,6 +122,7 @@ namespace Nz return IpAddress::Invalid; } + #endif IpAddress IpAddressImpl::FromSockAddr(const sockaddr* address) { diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index 4b27bef32..960092839 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -17,7 +17,9 @@ namespace Nz ~IpAddressImpl() = delete; static IpAddress FromAddrinfo(const addrinfo* info); + #if NAZARA_CORE_WINDOWS_VISTA static IpAddress FromAddrinfo(const addrinfoW* info); + #endif static IpAddress FromSockAddr(const sockaddr* address); static IpAddress FromSockAddr(const sockaddr_in* addressv4); static IpAddress FromSockAddr(const sockaddr_in6* addressv6); From 6d4768f46d450e9a23098731ccc6de4aec8e0cca Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Wed, 8 Jun 2016 14:13:19 +0200 Subject: [PATCH 038/235] Revert changes Former-commit-id: 7ad63a3ebfa604eed86ec7bfd57a5423389f0cbd [formerly 8b657a9850128e4e46c3234ad275d9c5d1369360] Former-commit-id: 85ac94dca00f84c309ad473ebae5862cee610124 --- src/Nazara/Core/String.cpp | 31 ++++++++++++++------ src/Nazara/Graphics/DepthRenderTechnique.cpp | 3 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 20d1c1897..a57d89861 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -2827,15 +2827,21 @@ namespace Nz { const char* c = oldCharacters; char character = Detail::ToLower(*ptr); - - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - EnsureOwnership(); - ptr = &m_sharedString->string[offset]; - + bool found = false; do { if (character == Detail::ToLower(*c)) { + if (!found) + { + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + + EnsureOwnership(); + + ptr = &m_sharedString->string[offset]; + found = true; + } + *ptr = replaceCharacter; ++count; break; @@ -2847,12 +2853,19 @@ namespace Nz } else { - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - EnsureOwnership(); - ptr = &m_sharedString->string[offset]; - + bool found = false; while ((ptr = std::strpbrk(ptr, oldCharacters)) != nullptr) { + if (!found) + { + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + + EnsureOwnership(); + + ptr = &m_sharedString->string[offset]; + found = true; + } + *ptr++ = replaceCharacter; ++count; } diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 8badefcc9..233eb9c72 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -464,6 +464,7 @@ namespace Nz void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; + const ShaderUniforms* shaderUniforms = nullptr; for (auto& matIt : layer.opaqueModels) { @@ -487,7 +488,7 @@ namespace Nz if (shader != lastShader) { // Index of uniforms in the shader - GetShaderUniforms(shader); + shaderUniforms = GetShaderUniforms(shader); lastShader = shader; } From 77d895d9f5d9d7ad2b969239957ca6b81d9a106a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 18:45:56 +0200 Subject: [PATCH 039/235] Network/Windows: Fix build on some plateforms (Hi MinGW) Former-commit-id: 009ba7af27ba937beb9a96a9eb197472a913d02d [formerly 5f0054863311431861703e8bcabb624af8f5ba82] Former-commit-id: abeb92f066cb2e7d7999ed7f27e234fead395908 --- src/Nazara/Network/Win32/IpAddressImpl.cpp | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 54d8ee4f5..0fd5cd88a 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -84,16 +84,21 @@ namespace Nz { sockaddr_in* ipv4 = reinterpret_cast(info->ai_addr); - auto& rawIpV4 = ipv4->sin_addr.S_un.S_un_b; - return IpAddress(rawIpV4.s_b1, rawIpV4.s_b2, rawIpV4.s_b3, rawIpV4.s_b4, ntohs(ipv4->sin_port)); + auto& rawIpV4 = ipv4->sin_addr; + return IpAddress(rawIpV4.s_net, rawIpV4.s_host, rawIpV4.s_lh, rawIpV4.s_impno, ntohs(ipv4->sin_port)); } case AF_INET6: { sockaddr_in6* ipv6 = reinterpret_cast(info->ai_addr); - auto& rawIpV6 = ipv6->sin6_addr.u.Word; - return IpAddress(rawIpV6[0], rawIpV6[1], rawIpV6[2], rawIpV6[3], rawIpV6[4], rawIpV6[5], rawIpV6[6], rawIpV6[7], ntohs(ipv6->sin6_port)); + auto& rawIpV6 = ipv6->sin6_addr.s6_addr; + + IpAddress::IPv6 structIpV6; + for (unsigned int i = 0; i < 8; ++i) + structIpV6[i] = UInt16(rawIpV6[i * 2]) << 8 | UInt16(rawIpV6[i * 2 + 1]); + + return IpAddress(structIpV6, ntohs(ipv6->sin6_port)); } } @@ -146,8 +151,13 @@ namespace Nz IpAddress IpAddressImpl::FromSockAddr(const sockaddr_in6* addressv6) { - auto& rawIpV6 = addressv6->sin6_addr.u.Word; - return IpAddress(rawIpV6[0], rawIpV6[1], rawIpV6[2], rawIpV6[3], rawIpV6[4], rawIpV6[5], rawIpV6[6], rawIpV6[7], ntohs(addressv6->sin6_port)); + auto& rawIpV6 = addressv6->sin6_addr.s6_addr; + + IpAddress::IPv6 ipv6; + for (unsigned int i = 0; i < 8; ++i) + ipv6[i] = rawIpV6[i*2] << 8 | rawIpV6[i*2+1]; + + return IpAddress(ipv6, ntohs(addressv6->sin6_port)); } bool IpAddressImpl::ResolveAddress(const IpAddress& ipAddress, String* hostname, String* service, ResolveError* error) @@ -223,7 +233,7 @@ namespace Nz std::memset(socketAddress, 0, sizeof(sockaddr_in)); socketAddress->sin_family = AF_INET; socketAddress->sin_port = htons(ipAddress.GetPort()); - socketAddress->sin_addr.S_un.S_addr = htonl(ipAddress.ToUInt32()); + socketAddress->sin_addr.s_addr = htonl(ipAddress.ToUInt32()); return sizeof(sockaddr_in); } @@ -238,7 +248,10 @@ namespace Nz IpAddress::IPv6 address = ipAddress.ToIPv6(); for (unsigned int i = 0; i < 8; ++i) - socketAddress->sin6_addr.u.Word[i] = htons(address[i]); + { + socketAddress->sin6_addr.s6_addr[i * 2 + 0] = htons(address[i]) >> 8; + socketAddress->sin6_addr.s6_addr[i * 2 + 1] = htons(address[i]) >> 0; + } return sizeof(sockaddr_in6); } From 33dbf6ffa0426b65e624028f913e6a649c057a74 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:46:44 +0200 Subject: [PATCH 040/235] Utility/Mesh: Replace scale by transform matrix Former-commit-id: 5f1d121a44a86fac59e32b993a015c4e0d464618 [formerly 2ba88d2c6c0a6913fee3d8945ab5870b163d654a] Former-commit-id: 84b306c8bf7abaee0161eb4a8e4e2d46da7698ac --- SDK/include/NDK/LuaAPI.inl | 2 +- include/Nazara/Utility/Mesh.hpp | 4 ++-- plugins/Assimp/Plugin.cpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 13 +++++++------ src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 5 +++-- src/Nazara/Utility/Formats/OBJLoader.cpp | 3 +-- src/Nazara/Utility/Mesh.cpp | 6 +++--- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index a42479cae..a09d6c459 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -100,8 +100,8 @@ namespace Nz params->animated = instance.CheckField("Animated", params->animated); params->center = instance.CheckField("Center", params->center); params->flipUVs = instance.CheckField("FlipUVs", params->flipUVs); + //params->matrix = instance.CheckField("Matrix", params->matrix); params->optimizeIndexBuffers = instance.CheckField("OptimizeIndexBuffers", params->optimizeIndexBuffers); - params->scale = instance.CheckField("Scale", params->scale); return 1; } diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index ff11b5d4d..865a228a9 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -29,8 +29,8 @@ namespace Nz { MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement) - // La mise à l'échelle éventuelle que subira le mesh - Vector3f scale = Vector3f::Unit(); + // La transformation appliquée à tous les sommets du mesh + Matrix4f matrix = Matrix4f::Identity(); // Si ceci sera le stockage utilisé par les buffers UInt32 storage = DataStorage_Hardware; diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 68c443b29..d571e1ef6 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -209,7 +209,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) aiVector3D tangent = (iMesh->HasTangentsAndBitangents()) ? iMesh->mTangents[j] : aiVector3D(0.f, 1.f, 0.f); aiVector3D uv = (iMesh->HasTextureCoords(0)) ? iMesh->mTextureCoords[0][j] : aiVector3D(0.f); - vertex->position = parameters.scale * Vector3f(position.x, position.y, position.z); + vertex->position = parameters.matrix * Vector3f(position.x, position.y, position.z); vertex->normal.Set(normal.x, normal.y, normal.z); vertex->tangent.Set(tangent.x, tangent.y, tangent.z); vertex->uv.Set(uv.x, uv.y); diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index eef4ac63d..126eeaa35 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -188,11 +188,10 @@ namespace Nz SwapBytes(&translate.z, sizeof(float)); #endif - // Un personnage de taille moyenne fait ~50 unités de haut dans Quake 2 - // Avec Nazara, 1 unité = 1 mètre, nous devons donc adapter l'échelle - Vector3f s(parameters.scale/29.f); // 50/29 = 1.72 (Soit 1.72 mètre, proche de la taille moyenne d'un individu) - scale *= s; - translate *= s; + constexpr float ScaleAdjust = 1.f / 27.8f; // Make a 50 Quake 2 units character a 1.8 unit long + + scale *= ScaleAdjust; + translate *= ScaleAdjust; BufferMapper vertexMapper(vertexBuffer, BufferAccess_DiscardAndWrite); MeshVertex* vertex = static_cast(vertexMapper.GetPointer()); @@ -215,11 +214,13 @@ namespace Nz /// Chargement des positions // Pour que le modèle soit correctement aligné, on génère un quaternion que nous appliquerons à chacune des vertices Quaternionf rotationQuat = EulerAnglesf(-90.f, 90.f, 0.f); + Nz::Matrix4f matrix = Matrix4f::Transform(translate, rotationQuat, scale); + matrix *= parameters.matrix; for (unsigned int v = 0; v < header.num_vertices; ++v) { const MD2_Vertex& vert = vertices[v]; - Vector3f position = rotationQuat * Vector3f(vert.x*scale.x + translate.x, vert.y*scale.y + translate.y, vert.z*scale.z + translate.z); + Vector3f position = matrix * Vector3f(vert.x, vert.y, vert.z); vertex->position = position; vertex->normal = rotationQuat * md2Normals[vert.n]; diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index cda183313..ce56b136a 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -48,7 +48,8 @@ namespace Nz // Le hellknight de Doom 3 fait ~120 unités, et il est dit qu'il fait trois mètres // Nous réduisons donc la taille générale des fichiers MD5 de 1/40 - Vector3f scale(parameters.scale/40.f); + Matrix4f matrix = Matrix4f::Transform(Nz::Vector3f::Zero(), rotationQuat, Vector3f(1.f / 40.f)); + matrix *= parameters.matrix; const MD5MeshParser::Joint* joints = parser.GetJoints(); const MD5MeshParser::Mesh* meshes = parser.GetMeshes(); @@ -267,7 +268,7 @@ namespace Nz } // On retourne le modèle dans le bon sens - vertex->position = scale * (rotationQuat * finalPos); + vertex->position = matrix * finalPos; vertex->uv.Set(md5Vertex.uv.x, (parameters.flipUVs) ? 1.f - md5Vertex.uv.y : md5Vertex.uv.y); // Inversion des UV si demandé vertex++; } diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 75b5ba22f..05b39f81f 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -234,8 +234,7 @@ namespace Nz MeshVertex& vertex = meshVertices[index]; const Vector4f& vec = positions[vertexIndices.position]; - vertex.position.Set(vec.x, vec.y, vec.z); - vertex.position *= parameters.scale/vec.w; + vertex.position = Vector3f(parameters.matrix * vec); if (vertexIndices.normal >= 0) vertex.normal = normals[vertexIndices.normal]; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index fca38e415..f41f67440 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -39,9 +39,9 @@ namespace Nz return false; } - if (scale == Vector3f::Zero()) + if (matrix == Matrix4f::Zero()) { - NazaraError("Invalid scale"); + NazaraError("Invalid matrix"); return false; } @@ -111,7 +111,7 @@ namespace Nz VertexBufferRef vertexBuffer; Matrix4f matrix(primitive.matrix); - matrix.ApplyScale(params.scale); + matrix *= params.matrix; VertexDeclaration* declaration = VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent); From 03494f21e6c5d84e8d8afe226b965036ab4c1d89 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:47:08 +0200 Subject: [PATCH 041/235] Utility/MaterialData: Add Material name information Former-commit-id: 3336fab5ebf757eaf57efcf67b06161af6ce3b32 [formerly 536e0c8e4f3759ccd2c66998d90f94c7e8811b5a] Former-commit-id: 32dd536b3e3c5193271b85a8487b51b4079afa24 --- include/Nazara/Utility/MaterialData.hpp | 1 + plugins/Assimp/Plugin.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index 0f69c9846..ea8ffd0f5 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -41,6 +41,7 @@ namespace Nz static constexpr const char* HeightTexturePath = "MatHeightTexturePath"; static constexpr const char* Lighting = "MatLighting"; static constexpr const char* LineWidth = "MatLineWidth"; + static constexpr const char* Name = "MatName"; static constexpr const char* NormalTexturePath = "MatNormalTexturePath"; static constexpr const char* PointSize = "MatPointSize"; static constexpr const char* ScissorTest = "MatScissorTest"; diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index d571e1ef6..f82d51f7b 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -291,6 +291,10 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) ConvertTexture(aiTextureType_OPACITY, MaterialData::AlphaTexturePath); ConvertTexture(aiTextureType_SPECULAR, MaterialData::SpecularTexturePath, MaterialData::SpecularWrap); + aiString name; + if (aiGetMaterialString(aiMat, AI_MATKEY_NAME, &name) == aiReturn_SUCCESS) + matData.SetParameter(MaterialData::Name, String(name.data, name.length)); + int iValue; if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue)) matData.SetParameter(MaterialData::FaceCulling, !iValue); From d46a170177e1c6e230222194b3eb3f54853fe9ae Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:47:43 +0200 Subject: [PATCH 042/235] Plugins/Assimp: Fix FaceCulling parameter retrieval Former-commit-id: 09e9478c01468ba7f5f707ab71693ca75ab412f3 [formerly 9a50f8efce4a1a1fba8bf28a38570c700f9b7d3d] Former-commit-id: a4f95b58fbbdf4138980bc072e9ff6fdbf840d79 --- plugins/Assimp/Plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index f82d51f7b..312bbf48e 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -296,7 +296,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) matData.SetParameter(MaterialData::Name, String(name.data, name.length)); int iValue; - if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue)) + if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue) == aiReturn_SUCCESS) matData.SetParameter(MaterialData::FaceCulling, !iValue); matIt = materials.insert(std::make_pair(iMesh->mMaterialIndex, std::make_pair(materials.size(), std::move(matData)))).first; From 26475973e220561a4e6db198124a8b7d96d646b7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:48:04 +0200 Subject: [PATCH 043/235] Graphics/Material: Ugly spaces to tabs Former-commit-id: c7cd3feda3f3d8d8e27f9732f3aebcffa4dbd2dc [formerly 1480fcc5e873656a6975cd8fa6e8233292e9960b] Former-commit-id: 32cafba52a1e1e7d558483d3c416cd14a253eeba --- src/Nazara/Graphics/Material.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 44ec0310d..0b4b887c3 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -442,22 +442,22 @@ namespace Nz s_defaultMaterial->SetFaceFilling(FaceFilling_Line); MaterialLibrary::Register("Default", s_defaultMaterial); - MaterialRef mat; + MaterialRef mat; - mat = New(); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - MaterialLibrary::Register("Basic2D", std::move(mat)); + mat = New(); + mat->Enable(RendererParameter_DepthWrite, false); + mat->Enable(RendererParameter_FaceCulling, false); + mat->EnableLighting(false); + MaterialLibrary::Register("Basic2D", std::move(mat)); - mat = New(); - mat->Enable(RendererParameter_Blend, true); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - mat->SetDstBlend(BlendFunc_InvSrcAlpha); - mat->SetSrcBlend(BlendFunc_SrcAlpha); - MaterialLibrary::Register("Translucent2D", std::move(mat)); + mat = New(); + mat->Enable(RendererParameter_Blend, true); + mat->Enable(RendererParameter_DepthWrite, false); + mat->Enable(RendererParameter_FaceCulling, false); + mat->EnableLighting(false); + mat->SetDstBlend(BlendFunc_InvSrcAlpha); + mat->SetSrcBlend(BlendFunc_SrcAlpha); + MaterialLibrary::Register("Translucent2D", std::move(mat)); return true; } From 2007edd3986b0bc2a5abc2ffbcccd1a1a06f0bd5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:48:35 +0200 Subject: [PATCH 044/235] Sdk/Application: Add MakeExitOnLastWindowClosed At least it's explicit Former-commit-id: e5bf5064222934b4f9dade56aab74b8f29367ed8 [formerly 5d7aa20615adf39407b95096a2da8c4888111fef] Former-commit-id: b404314721413e7d9b6d0307f7316f22ac5f81fb --- SDK/include/NDK/Application.hpp | 4 ++++ SDK/include/NDK/Application.inl | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 5d918ef8e..6a375776c 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -33,6 +33,10 @@ namespace Ndk bool Run(); + #ifndef NDK_SERVER + inline void MakeExitOnLastWindowClosed(bool exitOnClosedWindows); + #endif + inline void Quit(); Application& operator=(const Application&) = delete; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index f44ff9e8c..96e8768ce 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -61,6 +61,13 @@ namespace Ndk return m_updateTime; } + #ifndef NDK_SERVER + inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows) + { + m_exitOnClosedWindows = exitOnClosedWindows; + } + #endif + inline void Application::Quit() { m_shouldQuit = true; From e9d540ada5a7c4d42c7bfe07a1082214dba70818 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:49:01 +0200 Subject: [PATCH 045/235] Graphics/Material: Add errors when failed to query texture Former-commit-id: 6fe358b14a97c06c7567b0d7183bbc0950bd260b [formerly 45ddf7a31a0ad369717547aac624bdca493d2554] Former-commit-id: 5aa41ca25d104d90a9f60acec5daa9958b9c0ca7 --- include/Nazara/Graphics/Material.inl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index c8559e11f..d348d7581 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -289,7 +289,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get alpha map \"" + textureName + "\""); return false; + } } SetAlphaMap(std::move(texture)); @@ -335,7 +338,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get diffuse map \"" + textureName + "\""); return false; + } } SetDiffuseMap(std::move(texture)); @@ -366,7 +372,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get emissive map \"" + textureName + "\""); return false; + } } SetEmissiveMap(std::move(texture)); @@ -397,7 +406,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get height map \"" + textureName + "\""); return false; + } } SetHeightMap(std::move(texture)); @@ -418,7 +430,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get normal map \"" + textureName + "\""); return false; + } } SetNormalMap(std::move(texture)); @@ -471,7 +486,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get specular map \"" + textureName + "\""); return false; + } } SetSpecularMap(std::move(texture)); From 799b44ee3f6a4d41fef1c9ab781411cb56185914 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 12:32:04 +0200 Subject: [PATCH 046/235] Build: Fix build on Premake4 Former-commit-id: 3b02c5be8d00056d0d1f1074d87f8026c17d258d [formerly 2a93ebe2625da9241b1dec2b353cae8f97e1e4e1] Former-commit-id: f2a5f42b6be6fa748381746454cfc5a0cd150e0c --- build/scripts/common.lua | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 7e3cb2c33..5124dcace 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -7,9 +7,9 @@ function NazaraBuild:Execute() local platformData if (os.is64bit()) then - platformData = {"x64", "x86"} + platformData = {"x64", "x32"} else - platformData = {"x86", "x64"} + platformData = {"x32", "x64"} end if (self.Actions[_ACTION] == nil) then @@ -30,13 +30,13 @@ function NazaraBuild:Execute() location(_ACTION) kind("StaticLib") - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") targetdir("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -47,7 +47,7 @@ function NazaraBuild:Execute() configuration("vs*") buildoptions("/MP") - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") targetdir("../extlibs/lib/msvc/x86") @@ -55,7 +55,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x64") targetdir("../extlibs/lib/msvc/x64") - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../extlibs/lib/xcode/x86") targetdir("../extlibs/lib/xcode/x86") @@ -178,14 +178,14 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") targetdir("../lib/" .. makeLibDir .. "/x86") @@ -198,7 +198,7 @@ function NazaraBuild:Execute() -- Copy the module binaries to the example folder self:MakeCopyAfterBuild(moduleTable) - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") targetdir("../lib/msvc/x86") @@ -208,7 +208,7 @@ function NazaraBuild:Execute() libdirs("../lib/msvc/x64") targetdir("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") targetdir("../lib/xcode/x86") @@ -283,14 +283,14 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then @@ -313,7 +313,7 @@ function NazaraBuild:Execute() self:MakeCopyAfterBuild(toolTable) end - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") if (toolTable.Kind == "library") then @@ -331,7 +331,7 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x64") end - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") if (toolTable.Kind == "library") then @@ -411,26 +411,26 @@ function NazaraBuild:Execute() includedirs(exampleTable.Includes) links(exampleTable.Libraries) - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../lib/" .. makeLibDir .. "/x86") configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../lib/" .. makeLibDir .. "/x64") - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../lib/msvc/x86") configuration({"vs*", "x64"}) libdirs("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../lib/xcode/x86") configuration({"xcode3 or xcode4", "x64"}) @@ -906,8 +906,8 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do local paths = {} - table.insert(paths, {"x86", "../extlibs/lib/common/x86/" .. v .. ".dll"}) - table.insert(paths, {"x86", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) + table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) + table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) From 7c7e602dc104648b498ae429bf8a33831012b17f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 13:02:02 +0200 Subject: [PATCH 047/235] Fix compilation for CodeBlocks 16.01 ! (Fixes #65) Former-commit-id: 866d4b0fe5b9c00c0c1a540402137b24fca3ce19 [formerly 0a8f011fd6c53a4da5cbcc55b8c13dc9c279f879] Former-commit-id: 8a43b0610624a37de2395b703cbf3de4024393e5 --- build/scripts/common.lua | 6 +++++- src/Nazara/Network/Win32/SocketImpl.cpp | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 5124dcace..f08828e3b 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -83,7 +83,7 @@ function NazaraBuild:Execute() targetsuffix("-s") configuration("codeblocks or codelite or gmake or xcode3 or xcode4") - buildoptions({"-fPIC", "-std=c++14"}) + buildoptions({"-fPIC", "-std=c++14", "-U__STRICT_ANSI__"}) for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) @@ -900,6 +900,10 @@ function NazaraBuild:Resolve(infoTable) end function NazaraBuild:MakeCopyAfterBuild(infoTable) + if (PremakeVersion < 50) then + return + end + if (os.is("windows")) then configuration({}) postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 35d4b2371..9e5846471 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -6,7 +6,22 @@ #include #include #include -#include + +#include +#ifdef NAZARA_COMPILER_MINGW +// MinGW is lacking Mstcpip.h and that's too bad +struct tcp_keepalive +{ + u_long onoff; + u_long keepalivetime; + u_long keepaliveinterval; +}; + +#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) +#else + #include +#endif // NAZARA_COMPILER_MINGW + #include namespace Nz @@ -93,7 +108,7 @@ namespace Nz IpAddressImpl::SockAddrBuffer nameBuffer; int bufferLength = IpAddressImpl::ToSockAddr(address, nameBuffer.data()); - + if (error) *error = SocketError_NoError; @@ -365,7 +380,7 @@ namespace Nz return IpAddress(); } - + if (error) *error = SocketError_NoError; @@ -566,7 +581,7 @@ namespace Nz return true; } - + bool SocketImpl::SetBroadcasting(SocketHandle handle, bool broadcasting, SocketError* error) { NazaraAssert(handle != InvalidHandle, "Invalid handle"); From 2d6b8fe2c6373e55d5197c1c548473474b143b80 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Jun 2016 12:40:31 +0200 Subject: [PATCH 048/235] Network/RUdpConnection: Remove useless line Former-commit-id: b37a1b011d5039c8c591fe0d9c29ae95cb3c3447 [formerly 4735aabc1802bc1d51997b5d414bc5ae1be87d4e] Former-commit-id: ad25d576c31b7e8c9991fafc83e1aecbf6717389 --- include/Nazara/Network/RUdpConnection.inl | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index 48173bd77..2960cbced 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -149,8 +149,6 @@ namespace Nz std::vector& pendingPackets = peer.pendingPackets[priority]; if (!pendingPackets.empty()) return true; - - pendingPackets.clear(); } return false; From d2790f099252286b175273aa108f1d8f1ce5db27 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 11 Jun 2016 13:13:53 +0200 Subject: [PATCH 049/235] Math/Algorithm: Fix IntegralLog2Pot case with sizeof(T) > 4 and %32 bits Former-commit-id: b0fe4ada8100dd2ecc0fe403fa111df0b672dc7a [formerly b51e0281a72a3b42e663de8953307fa8b6dbdede] Former-commit-id: 304402304696550c7ffb71b41015ef62c03f9a94 --- include/Nazara/Math/Algorithm.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index e7e205e45..524f0bd4c 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -90,7 +90,7 @@ namespace Nz // Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse unsigned int log2 = IntegralLog2Pot(val); - if (log2) + if (log2 || val == 1) return log2 + i*8; } From 36a02ee92daa2d9c4b4814c851956e9f234096a1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:03:05 +0200 Subject: [PATCH 050/235] Build: Remake exclusion system Allows to excludes pretty much everything and now also excludes projects relying on an excluded dependency Former-commit-id: 4ee05227cbddfca9b42816d4571ef09ce6977093 [formerly d1885a398214640f22abf949ae45c18acb13440b] Former-commit-id: 3a10037c0f732aa76b3ddeb438abd86d5e5ff478 --- build/scripts/common.lua | 110 +++++++++++++++++---------------- build/scripts/modules/core.lua | 3 +- 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index f08828e3b..a6de8fca7 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -519,28 +519,19 @@ function NazaraBuild:Initialize() local moduleName = v:match(".*/(.*).lua") local moduleNameLower = moduleName:lower() - if (moduleNameLower ~= "core") then -- exclure le noyau n'aurait aucun sens - newoption({ - trigger = "exclude-" .. moduleNameLower, - description = "Exclude the " .. moduleName .. " module from the build system" - }) - end + local f, err = loadfile(v) + if (f) then + MODULE = {} + self:SetupInfoTable(MODULE) - if (not _OPTIONS["exclude-" .. moduleNameLower]) then - local f, err = loadfile(v) - if (f) then - MODULE = {} - self:SetupInfoTable(MODULE) + f() - f() - - local succeed, err = self:RegisterModule(MODULE) - if (not succeed) then - print("Unable to register module: " .. err) - end - else - print("Unable to load module file: " .. err) + local succeed, err = self:RegisterModule(MODULE) + if (not succeed) then + print("Unable to register module: " .. err) end + else + print("Unable to load module file: " .. err) end end MODULE = nil @@ -551,26 +542,19 @@ function NazaraBuild:Initialize() local toolName = v:match(".*/(.*).lua") local toolNameLower = toolName:lower() - newoption({ - trigger = "exclude-" .. toolNameLower, - description = "Exclude the " .. toolName .. " tool from the build system" - }) + local f, err = loadfile(v) + if (f) then + TOOL = {} + self:SetupInfoTable(TOOL) - if (not _OPTIONS["exclude-" .. toolNameLower]) then - local f, err = loadfile(v) - if (f) then - TOOL = {} - self:SetupInfoTable(TOOL) + f() - f() - - local succeed, err = self:RegisterTool(TOOL) - if (not succeed) then - print("Unable to register tool: " .. err) - end - else - print("Unable to load tool file: " .. err) + local succeed, err = self:RegisterTool(TOOL) + if (not succeed) then + print("Unable to register tool: " .. err) end + else + print("Unable to load tool file: " .. err) end end TOOL = nil @@ -616,9 +600,9 @@ function NazaraBuild:Initialize() for projectId,projectTable in pairs(projects) do if (self:Process(projectTable)) then - table.insert(orderedTables[k], projectTable) + table.insert(orderedTables[k], projectTable) else - print("Rejected client-only " .. projectTable.Name .. " " .. projectTable.Type) + print("Rejected " .. projectTable.Name .. " " .. string.lower(projectTable.Type) .. ": " .. projectTable.ExcludeReason) end end @@ -780,20 +764,17 @@ local PosixOSes = { } function NazaraBuild:Process(infoTable) - if (infoTable.ClientOnly and _OPTIONS["server"]) then - return false - end - local libraries = {} for k, library in pairs(infoTable.Libraries) do - local moduleName = library:match("Nazara(%w+)") - local moduleTable = moduleName and self.Modules[moduleName:lower()] - local toolTable = moduleName and self.Tools[moduleName:lower()] + local projectName = library:match("Nazara(%w+)") + local moduleTable = projectName and self.Modules[projectName:lower()] + local toolTable = projectName and self.Tools[projectName:lower()] if (moduleTable) then - if (moduleTable.ClientOnly and _OPTIONS["server"]) then - infoTable.ClientOnly = true - return false -- We depend on a client-only library + if (moduleTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module" + return false end if (_OPTIONS["united"]) then @@ -811,9 +792,10 @@ function NazaraBuild:Process(infoTable) else local extLibTable = self.ExtLibs[library:lower()] if (extLibTable) then - if (extLibTable.ClientOnly and _OPTIONS["server"]) then - infoTable.ClientOnly = true - return false -- We depend on a client-only library + if (extLibTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library" + return false end library = extLibTable.Name @@ -824,9 +806,10 @@ function NazaraBuild:Process(infoTable) table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") else if (toolTable and toolTable.Kind == "library") then - if (toolTable.ClientOnly and _OPTIONS["server"]) then - infoTable.ClientOnly = true - return false -- We depend on a client-only library + if (toolTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool" + return false end library = "Nazara" .. toolTable.Name @@ -894,6 +877,24 @@ function NazaraBuild:Process(infoTable) end function NazaraBuild:Resolve(infoTable) + if (infoTable.ClientOnly and _OPTIONS["server"]) then + infoTable.Excluded = true + infoTable.ExcludeReason = "excluded by command-line options (client-only)" + end + + if (infoTable.Excludable) then + local optionName = "excludes-" .. string.lower(infoTable.Type .. "-" .. infoTable.Name) + newoption({ + trigger = optionName, + description = "Excludes the " .. infoTable.Name .. " " .. string.lower(infoTable.Type) .. " and projects relying on it" + }) + + if (_OPTIONS[optionName]) then + infoTable.Excluded = true + infoTable.ExcludeReason = "excluded by command-line options" + end + end + if (type(infoTable.Libraries) == "function") then infoTable.Libraries = infoTable.Libraries() end @@ -932,6 +933,7 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) end function NazaraBuild:SetupInfoTable(infoTable) + infoTable.Excludable = true infoTable.ConfigurationLibraries = {} infoTable.ConfigurationLibraries.DebugStatic = {} infoTable.ConfigurationLibraries.ReleaseStatic = {} diff --git a/build/scripts/modules/core.lua b/build/scripts/modules/core.lua index 7156ef2f6..b33c0b61f 100644 --- a/build/scripts/modules/core.lua +++ b/build/scripts/modules/core.lua @@ -1,6 +1,7 @@ MODULE.Name = "Core" +MODULE.Excludable = false -- Excluding the core makes no sense as everything relies on it -MODULE.Files = { -- Les autres fichiers seront ajoutés automatiquement +MODULE.Files = { -- Other files will be automatically added "../include/Nazara/Prerequesites.hpp", "../include/Nazara/Math/**.hpp", "../include/Nazara/Math/**.inl", From ff4275dd1ca2ba666f3b9f3db2ac7dc02b84453e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:03:39 +0200 Subject: [PATCH 051/235] Build: Remove -fPIC on Windows Former-commit-id: 9e466b02938c8acc45546322f626a3fb4da8901b [formerly 7df8219ca32705a8465f9254831bf930936ad7c5] Former-commit-id: 87993d189c4d1014bb07312a874e58575ccd7d8a --- build/scripts/common.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index a6de8fca7..056f5c022 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -82,8 +82,11 @@ function NazaraBuild:Execute() configuration("ReleaseStatic") targetsuffix("-s") + configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"}) + buildoptions("-fPIC") + configuration("codeblocks or codelite or gmake or xcode3 or xcode4") - buildoptions({"-fPIC", "-std=c++14", "-U__STRICT_ANSI__"}) + buildoptions({"-std=c++14", "-U__STRICT_ANSI__"}) for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) From 6d70d5c5623eba3936456a92c88933f410cbd16e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:06:27 +0200 Subject: [PATCH 052/235] Build: Convert spaces to tabs Former-commit-id: 012a57ead09735cf346b2157b5342879eedd7f02 [formerly a57f164e5a38c7c8978163b6cd9feb527588dc38] Former-commit-id: efbc1d0f7043207c1f59d671f9d44a9a7ca1b663 --- build/scripts/common.lua | 142 +++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 056f5c022..e51729268 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -11,11 +11,11 @@ function NazaraBuild:Execute() else platformData = {"x32", "x64"} end - + if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" - - if (_OPTIONS["with-extlibs"]) then + + if (_OPTIONS["with-extlibs"]) then workspace("NazaraExtlibs") platforms(platformData) @@ -68,9 +68,9 @@ function NazaraBuild:Execute() configuration("Release*") flags("NoFramePointer") - optimize("Speed") - rtti("Off") - vectorextensions("SSE2") + optimize("Speed") + rtti("Off") + vectorextensions("SSE2") configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"}) buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants @@ -82,7 +82,7 @@ function NazaraBuild:Execute() configuration("ReleaseStatic") targetsuffix("-s") - configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"}) + configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"}) buildoptions("-fPIC") configuration("codeblocks or codelite or gmake or xcode3 or xcode4") @@ -90,7 +90,7 @@ function NazaraBuild:Execute() for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) - + language(libTable.Language) location(_ACTION .. "/extlibs") @@ -106,7 +106,7 @@ function NazaraBuild:Execute() configuration(k) links(v) end - + configuration({}) end end @@ -130,10 +130,10 @@ function NazaraBuild:Execute() flags("Symbols") configuration("Release*") - flags("NoFramePointer") - optimize("Speed") - rtti("Off") - vectorextensions("SSE2") + flags("NoFramePointer") + optimize("Speed") + rtti("Off") + vectorextensions("SSE2") configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"}) buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants @@ -250,17 +250,17 @@ function NazaraBuild:Execute() configuration(k) links(v) end - + configuration({}) end - + -- Tools for k, toolTable in ipairs(self.OrderedTools) do local prefix = "Nazara" if (toolTable.Kind == "plugin") then prefix = "Plugin" end - + project(prefix .. toolTable.Name) location(_ACTION .. "/tools") @@ -358,7 +358,7 @@ function NazaraBuild:Execute() configuration("*Dynamic") kind("SharedLib") - + configuration("DebugStatic") targetsuffix("-s-d") @@ -443,7 +443,7 @@ function NazaraBuild:Execute() configuration(k) links(v) end - + configuration({}) end end @@ -497,24 +497,24 @@ function NazaraBuild:Initialize() ACTION = nil -- Extern libraries - local extlibs = os.matchfiles("../extlibs/build/*.lua") - for k,v in pairs(extlibs) do - local f, err = loadfile(v) - if (f) then - LIBRARY = {} - self:SetupInfoTable(LIBRARY) + local extlibs = os.matchfiles("../extlibs/build/*.lua") + for k,v in pairs(extlibs) do + local f, err = loadfile(v) + if (f) then + LIBRARY = {} + self:SetupInfoTable(LIBRARY) - f() + f() - local succeed, err = self:RegisterExternLibrary(LIBRARY) - if (not succeed) then - print("Unable to register extern library: " .. err) - end - else - print("Unable to load extern library file: " .. err) - end - end - LIBRARY = nil + local succeed, err = self:RegisterExternLibrary(LIBRARY) + if (not succeed) then + print("Unable to register extern library: " .. err) + end + else + print("Unable to load extern library file: " .. err) + end + end + LIBRARY = nil -- Then the modules local modules = os.matchfiles("scripts/modules/*.lua") @@ -587,7 +587,7 @@ function NazaraBuild:Initialize() end EXAMPLE = nil end - + -- Once everything is registred, let's process all the tables self.OrderedExamples = {} self.OrderedExtLibs = {} @@ -596,19 +596,19 @@ function NazaraBuild:Initialize() local tables = {self.ExtLibs, self.Modules, self.Tools, self.Examples} local orderedTables = {self.OrderedExtLibs, self.OrderedModules, self.OrderedTools, self.OrderedExamples} for k,projects in ipairs(tables) do - -- Begin by resolving every project (because of dependencies in the same category) + -- Begin by resolving every project (because of dependencies in the same category) for projectId,projectTable in pairs(projects) do - self:Resolve(projectTable) - end + self:Resolve(projectTable) + end for projectId,projectTable in pairs(projects) do if (self:Process(projectTable)) then table.insert(orderedTables[k], projectTable) - else - print("Rejected " .. projectTable.Name .. " " .. string.lower(projectTable.Type) .. ": " .. projectTable.ExcludeReason) - end + else + print("Rejected " .. projectTable.Name .. " " .. string.lower(projectTable.Type) .. ": " .. projectTable.ExcludeReason) + end end - + table.sort(orderedTables[k], function (a, b) return a.Name < b.Name end) end end @@ -668,13 +668,13 @@ function NazaraBuild:RegisterExample(exampleTable) if (#exampleTable.Files == 0) then return false, "This example has no files" end - + local files = {} for k, file in ipairs(exampleTable.Files) do table.insert(files, "../examples/" .. exampleTable.Directory .. "/" .. file) end exampleTable.Files = files - + exampleTable.Type = "Example" self.Examples[lowerCaseName] = exampleTable return true @@ -719,7 +719,7 @@ function NazaraBuild:RegisterModule(moduleTable) table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.hpp") table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl") table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp") - + if (_OPTIONS["united"] and lowerCaseName ~= "core") then table.insert(moduleTable.FilesExcluded, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp") end @@ -767,18 +767,18 @@ local PosixOSes = { } function NazaraBuild:Process(infoTable) - local libraries = {} + local libraries = {} for k, library in pairs(infoTable.Libraries) do local projectName = library:match("Nazara(%w+)") local moduleTable = projectName and self.Modules[projectName:lower()] local toolTable = projectName and self.Tools[projectName:lower()] - + if (moduleTable) then - if (moduleTable.Excluded) then + if (moduleTable.Excluded) then infoTable.Excluded = true infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module" - return false - end + return false + end if (_OPTIONS["united"]) then library = "NazaraEngine" @@ -795,38 +795,38 @@ function NazaraBuild:Process(infoTable) else local extLibTable = self.ExtLibs[library:lower()] if (extLibTable) then - if (extLibTable.Excluded) then + if (extLibTable.Excluded) then infoTable.Excluded = true infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library" - return false - end + return false + end library = extLibTable.Name - + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") else if (toolTable and toolTable.Kind == "library") then - if (toolTable.Excluded) then + if (toolTable.Excluded) then infoTable.Excluded = true infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool" - return false - end + return false + end library = "Nazara" .. toolTable.Name - + -- Import tools includes for k,v in ipairs(toolTable.Includes) do table.insert(infoTable.Includes, v) end - + -- And libraries for k, v in pairs(toolTable.Libraries) do table.insert(infoTable.Libraries, v) end - + for config, libs in pairs(toolTable.ConfigurationLibraries) do for k,v in pairs(libs) do table.insert(infoTable.ConfigurationLibraries[config], v) @@ -876,14 +876,14 @@ function NazaraBuild:Process(infoTable) end end - return true + return true end function NazaraBuild:Resolve(infoTable) - if (infoTable.ClientOnly and _OPTIONS["server"]) then + if (infoTable.ClientOnly and _OPTIONS["server"]) then infoTable.Excluded = true infoTable.ExcludeReason = "excluded by command-line options (client-only)" - end + end if (infoTable.Excludable) then local optionName = "excludes-" .. string.lower(infoTable.Type .. "-" .. infoTable.Name) @@ -891,22 +891,22 @@ function NazaraBuild:Resolve(infoTable) trigger = optionName, description = "Excludes the " .. infoTable.Name .. " " .. string.lower(infoTable.Type) .. " and projects relying on it" }) - + if (_OPTIONS[optionName]) then infoTable.Excluded = true infoTable.ExcludeReason = "excluded by command-line options" end end - if (type(infoTable.Libraries) == "function") then - infoTable.Libraries = infoTable.Libraries() - end + if (type(infoTable.Libraries) == "function") then + infoTable.Libraries = infoTable.Libraries() + end end function NazaraBuild:MakeCopyAfterBuild(infoTable) - if (PremakeVersion < 50) then - return - end + if (PremakeVersion < 50) then + return + end if (os.is("windows")) then configuration({}) @@ -942,7 +942,7 @@ function NazaraBuild:SetupInfoTable(infoTable) infoTable.ConfigurationLibraries.ReleaseStatic = {} infoTable.ConfigurationLibraries.DebugDynamic = {} infoTable.ConfigurationLibraries.ReleaseDynamic = {} - + local infos = {"Defines", "DynLib", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"} for k,v in ipairs(infos) do infoTable[v] = {} From 3c44253685ccb64b162200bf30567ed46129efaf Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:14:36 +0200 Subject: [PATCH 053/235] Build: Remove duplicate Former-commit-id: 4539c4439bc95450c25a5313717f7127e2df9bcc [formerly 7763558ed34a29a17c95a8d764d5a4aa3e5f110b] Former-commit-id: 4dbe1d56f3fdbd3d35e7108da0487c95749bbe57 --- build/scripts/common.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index e51729268..c359a60c4 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -148,9 +148,6 @@ function NazaraBuild:Execute() configuration({"linux or bsd or macosx", "gmake"}) buildoptions("-fvisibility=hidden") - configuration({"linux or bsd or macosx", "gmake"}) - buildoptions("-fvisibility=hidden") - configuration("vs*") buildoptions("/MP") -- Multiprocessus build flags("NoMinimalRebuild") From ee553f350a3629b548852945f2828ec6ba4db8d6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 11:39:31 +0200 Subject: [PATCH 054/235] Build: Remake install system Former-commit-id: a1d7d75ffefb60273d190e7355df500267429538 [formerly 6ab4c02f186ce23201d15a8677a66e5babc05a41] Former-commit-id: 2a820557c58fbc70c2cecad9e4404db09d5e219c --- build/scripts/common.lua | 122 ++++++++++++++++++++++------- build/scripts/tools/assimp.lua | 2 - build/scripts/tools/ndk.lua | 2 - build/scripts/tools/ndk_server.lua | 4 +- build/scripts/tools/unittests.lua | 3 +- examples/DopplerEffect/build.lua | 2 +- examples/FirstScene/build.lua | 2 +- examples/MeshInfos/build.lua | 2 +- examples/Tut00/build.lua | 2 +- examples/Tut01/build.lua | 2 +- 10 files changed, 102 insertions(+), 41 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index c359a60c4..e7d4929c5 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -1,5 +1,14 @@ NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table +function NazaraBuild:AddExecutablePath(path) + self.ExecutableDir[path] = true + self.InstallDir[path] = true +end + +function NazaraBuild:AddInstallPath(path) + self.InstallDir[path] = true +end + function NazaraBuild:Execute() if (_ACTION == nil) then -- Si aucune action n'est spécifiée return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien @@ -196,7 +205,7 @@ function NazaraBuild:Execute() targetdir("../lib/" .. makeLibDir .. "/x64") -- Copy the module binaries to the example folder - self:MakeCopyAfterBuild(moduleTable) + self:MakeInstallCommands(moduleTable) configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") @@ -265,12 +274,16 @@ function NazaraBuild:Execute() if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then kind("SharedLib") - elseif (toolTable.Kind == "consoleapp") then + + -- Copy the tool binaries to the example folder + self:MakeInstallCommands(toolTable) + elseif (toolTable.Kind == "application") then debugdir(toolTable.Directory) - kind("ConsoleApp") - elseif (toolTable.Kind == "windowapp") then - debugdir(toolTable.Directory) - kind("WindowedApp") + if (toolTable.EnableConsole) then + kind("ConsoleApp") + else + kind("WindowedApp") + end else assert(false, "Invalid tool Kind") end @@ -308,11 +321,6 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end - -- Copy the tool binaries to the example folder - if (toolTable.CopyTargetToExampleDir) then - self:MakeCopyAfterBuild(toolTable) - end - configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") @@ -385,23 +393,34 @@ function NazaraBuild:Execute() end for k, exampleTable in ipairs(self.OrderedExamples) do + local destPath = "../examples/bin" + project("Demo" .. exampleTable.Name) location(_ACTION .. "/examples") - if (exampleTable.Console) then - kind("ConsoleApp") + if (exampleTable.Kind == "plugin" or exampleTable.Kind == "library") then + kind("SharedLib") + + self:MakeInstallCommands(toolTable) + elseif (exampleTable.Kind == "application") then + debugdir(exampleTable.Directory) + if (exampleTable.EnableConsole) then + kind("ConsoleApp") + else + kind("WindowedApp") + end else - kind("Window") + assert(false, "Invalid tool Kind") end - debugdir("../examples/bin") + debugdir(destPath) includedirs({ "../include", "../extlibs/include" }) libdirs("../lib") - targetdir("../examples/bin") + targetdir(destPath) files(exampleTable.Files) excludes(exampleTable.FilesExcluded) @@ -448,6 +467,11 @@ end function NazaraBuild:Initialize() -- Commençons par les options + newoption({ + trigger = "install-path", + description = "Setup additionnals install directories (library binaries will be copied there)" + }) + newoption({ trigger = "server", description = "Excludes client-only modules/tools/examples" @@ -470,9 +494,18 @@ function NazaraBuild:Initialize() self.Actions = {} self.Examples = {} + self.ExecutableDir = {} self.ExtLibs = {} + self.InstallDir = {} self.Modules = {} self.Tools = {} + + if (_OPTIONS["install-path"]) then + local paths = string.explode(_OPTIONS["install-path"], ";") + for k,v in pairs(paths) do + self:AddInstallPath(v) + end + end -- Actions modules = os.matchfiles("scripts/actions/*.lua") @@ -499,7 +532,7 @@ function NazaraBuild:Initialize() local f, err = loadfile(v) if (f) then LIBRARY = {} - self:SetupInfoTable(LIBRARY) + self:SetupExtlibTable(LIBRARY) f() @@ -522,7 +555,7 @@ function NazaraBuild:Initialize() local f, err = loadfile(v) if (f) then MODULE = {} - self:SetupInfoTable(MODULE) + self:SetupModuleTable(MODULE) f() @@ -545,7 +578,7 @@ function NazaraBuild:Initialize() local f, err = loadfile(v) if (f) then TOOL = {} - self:SetupInfoTable(TOOL) + self:SetupToolTable(TOOL) f() @@ -569,7 +602,7 @@ function NazaraBuild:Initialize() if (f) then EXAMPLE = {} EXAMPLE.Directory = dirName - self:SetupInfoTable(EXAMPLE) + self:SetupExampleTable(EXAMPLE) f() @@ -745,7 +778,7 @@ function NazaraBuild:RegisterTool(toolTable) end local lowerCaseKind = toolTable.Kind:lower() - if (lowerCaseKind == "library" or lowerCaseKind == "plugin" or lowerCaseKind == "consoleapp" or lowerCaseKind == "windowapp") then + if (lowerCaseKind == "library" or lowerCaseKind == "plugin" or lowerCaseKind == "application") then toolTable.Kind = lowerCaseKind else return false, "Invalid tool type" @@ -873,6 +906,10 @@ function NazaraBuild:Process(infoTable) end end + if (infoTable.Kind == "application") then + self:AddExecutablePath(infoTable.Directory) + end + return true end @@ -900,14 +937,18 @@ function NazaraBuild:Resolve(infoTable) end end -function NazaraBuild:MakeCopyAfterBuild(infoTable) +function NazaraBuild:MakeInstallCommands(infoTable) if (PremakeVersion < 50) then return end if (os.is("windows")) then configuration({}) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) + + for k,v in pairs(self.InstallDir) do + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]}) + end for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do local paths = {} @@ -918,14 +959,18 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) for k,v in pairs(paths) do local config = v[1] - local path = v[2] - if (os.isfile(path)) then + local srcPath = v[2] + if (os.isfile(srcPath)) then if (infoTable.Kind == "plugin") then - path = "../../" .. path + srcPath = "../../" .. srcPath end configuration(config) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. path .. [[")}" "..\..\..\examples\bin\" /E /Y]]}) + + for k,v in pairs(self.ExecutableDir) do + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}" "]] .. destPath .. [[\" /E /Y]]}) + end end end end @@ -945,4 +990,25 @@ function NazaraBuild:SetupInfoTable(infoTable) infoTable[v] = {} infoTable["Os" .. v] = {} end -end \ No newline at end of file +end + +function NazaraBuild:SetupExampleTable(infoTable) + self:SetupInfoTable(infoTable) + + infoTable.Directory = "../example/bin" + infoTable.Kind = "application" +end + +function NazaraBuild:SetupExtlibTable(infoTable) + self:SetupInfoTable(infoTable) + + infoTable.Kind = "library" +end + +function NazaraBuild:SetupModuleTable(infoTable) + self:SetupInfoTable(infoTable) + + infoTable.Kind = "library" +end + +NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable \ No newline at end of file diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index 3a1ca093b..0eecbcd54 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -3,8 +3,6 @@ TOOL.Name = "Assimp" TOOL.Directory = "../SDK/lib" TOOL.Kind = "Plugin" -TOOL.CopyTargetToExampleDir = true - TOOL.Includes = { "../include", "../plugins/Assimp" diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 961fa6d7f..d2038342b 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -1,7 +1,5 @@ TOOL.Name = "SDK" -TOOL.CopyTargetToExampleDir = true - TOOL.Directory = "../SDK/lib" TOOL.Kind = "Library" diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index b1a71453e..91a0fd170 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -1,7 +1,5 @@ TOOL.Name = "SDKServer" -TOOL.CopyTargetToExampleDir = true - TOOL.Directory = "../SDK/lib" TOOL.Kind = "Library" @@ -23,7 +21,7 @@ TOOL.Files = { "../SDK/src/NDK/**.cpp" } --- Exlude client-only files +-- Excludes client-only files TOOL.FilesExcluded = { "../SDK/**/CameraComponent.*", "../SDK/**/Console.*", diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index cc6051297..349932cb6 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -1,7 +1,8 @@ TOOL.Name = "UnitTests" TOOL.Directory = "../tests" -TOOL.Kind = "ConsoleApp" +TOOL.EnableConsole = true +TOOL.Kind = "Application" TOOL.Defines = { } diff --git a/examples/DopplerEffect/build.lua b/examples/DopplerEffect/build.lua index 8298ef526..302011b81 100644 --- a/examples/DopplerEffect/build.lua +++ b/examples/DopplerEffect/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "DopplerEffect" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/FirstScene/build.lua b/examples/FirstScene/build.lua index 14bf8a42f..612965b5a 100644 --- a/examples/FirstScene/build.lua +++ b/examples/FirstScene/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "FirstScene" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/MeshInfos/build.lua b/examples/MeshInfos/build.lua index 9372ef5c1..4e26f318b 100644 --- a/examples/MeshInfos/build.lua +++ b/examples/MeshInfos/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "MeshInfos" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/Tut00/build.lua b/examples/Tut00/build.lua index d0c499df6..ed5ea5995 100644 --- a/examples/Tut00/build.lua +++ b/examples/Tut00/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "Tut00_EmptyProject" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/Tut01/build.lua b/examples/Tut01/build.lua index c12dc35b5..c195cbc1b 100644 --- a/examples/Tut01/build.lua +++ b/examples/Tut01/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "Tut01_HelloWorld" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" From b30faa83cac19c7b08edd868b5066c78d04f2d33 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 12:46:38 +0200 Subject: [PATCH 055/235] Update .gitignore Former-commit-id: bd4389752d2b1764622146b92826f43dc98275cd [formerly 75c6a61ec48703c7efa44dc0644eddffb1baf825] Former-commit-id: 19a2aca49b22c0117096cede45cab1f90aef1684 --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f3b8b2bbd..c930343f4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ examples/bin/*.dll examples/bin/*.so tests/*.exe tests/*.pdb +tests/*.dll +tests/*.so lib/* # Feature page From 3ab0192300011532a5cec4840507cfa83a7cd56c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 12:46:56 +0200 Subject: [PATCH 056/235] Build: Fix typo Former-commit-id: c6e701b0d0d00de1eb3c4d56dda0d9e91b06e269 [formerly 0edba6686872452fef0254c062dbc437f1d7c84c] Former-commit-id: d6d30517f3427e503a405ac79ca7a148f09c1b2b --- build/scripts/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index e7d4929c5..66aa12513 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -995,7 +995,7 @@ end function NazaraBuild:SetupExampleTable(infoTable) self:SetupInfoTable(infoTable) - infoTable.Directory = "../example/bin" + infoTable.Directory = "../examples/bin" infoTable.Kind = "application" end From 086de1f71ccf591c07fdcbd3f0a8b52e40043d58 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 21:09:55 +0200 Subject: [PATCH 057/235] Fix a shitload of warnings in 64 bits mode Former-commit-id: d3d40b9f364a0a27a3411586e62a16443ee5de00 [formerly 71282c40087232985fa19b8dcbd0d75bd4fcd97b] Former-commit-id: c11c69d4c1f40bdd33f721cb33c68c4144771510 --- SDK/include/NDK/BaseComponent.inl | 2 +- .../NDK/Components/GraphicsComponent.hpp | 2 +- SDK/src/NDK/Components/GraphicsComponent.cpp | 2 +- build/scripts/common.lua | 4 +- include/Nazara/Core/Bitset.hpp | 50 ++++---- include/Nazara/Core/Bitset.inl | 114 +++++++++--------- include/Nazara/Core/Endianness.inl | 4 +- include/Nazara/Core/ResourceLoader.hpp | 2 +- include/Nazara/Core/ResourceLoader.inl | 2 +- include/Nazara/Lua/LuaInstance.hpp | 12 +- include/Nazara/Renderer/Texture.hpp | 4 +- include/Nazara/Utility/AbstractAtlas.hpp | 2 +- include/Nazara/Utility/AbstractImage.hpp | 4 +- include/Nazara/Utility/AbstractTextDrawer.hpp | 8 +- include/Nazara/Utility/Font.hpp | 4 +- .../Nazara/Utility/Formats/MD5AnimParser.hpp | 8 +- .../Nazara/Utility/Formats/MD5MeshParser.hpp | 4 +- .../Nazara/Utility/GuillotineImageAtlas.hpp | 13 +- include/Nazara/Utility/Image.hpp | 4 +- include/Nazara/Utility/PixelFormat.inl | 4 +- include/Nazara/Utility/SimpleTextDrawer.hpp | 8 +- src/Nazara/Core/Win32/FileImpl.cpp | 8 +- src/Nazara/Core/Win32/TaskSchedulerImpl.cpp | 8 +- src/Nazara/Core/Win32/TaskSchedulerImpl.hpp | 2 +- src/Nazara/Graphics/TextSprite.cpp | 8 +- src/Nazara/Lua/LuaInstance.cpp | 16 +-- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 +- src/Nazara/Network/Win32/SocketImpl.cpp | 2 +- src/Nazara/Renderer/Renderer.cpp | 6 +- src/Nazara/Renderer/Texture.cpp | 4 +- src/Nazara/Utility/Font.cpp | 6 +- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 10 +- src/Nazara/Utility/Formats/MD5AnimParser.cpp | 8 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 18 +-- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 4 +- src/Nazara/Utility/GuillotineImageAtlas.cpp | 2 +- src/Nazara/Utility/Image.cpp | 4 +- src/Nazara/Utility/SimpleTextDrawer.cpp | 8 +- src/Nazara/Utility/Win32/WindowImpl.cpp | 6 +- 39 files changed, 191 insertions(+), 188 deletions(-) diff --git a/SDK/include/NDK/BaseComponent.inl b/SDK/include/NDK/BaseComponent.inl index 71f8ee2c1..341ddb651 100644 --- a/SDK/include/NDK/BaseComponent.inl +++ b/SDK/include/NDK/BaseComponent.inl @@ -26,7 +26,7 @@ namespace Ndk inline ComponentIndex BaseComponent::RegisterComponent(ComponentId id, Factory factoryFunc) { // Nous allons rajouter notre composant à la fin - ComponentIndex index = s_entries.size(); + ComponentIndex index = static_cast(s_entries.size()); s_entries.resize(index + 1); // On récupère et on affecte diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 86cefb782..c94cec4ab 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -40,7 +40,7 @@ namespace Ndk private: inline void InvalidateBoundingVolume(); - void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index); + void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index); inline void InvalidateRenderables(); inline void InvalidateTransformMatrix(); diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index e345bdb85..88ccd4ca1 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -9,7 +9,7 @@ namespace Ndk { - void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index) + void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index) { NazaraAssert(index < m_renderables.size(), "Invalid renderable index"); NazaraUnused(renderable); diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 66aa12513..12aa13d70 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -54,7 +54,7 @@ function NazaraBuild:Execute() targetdir("../extlibs/lib/" .. makeLibDir .. "/x64") configuration("vs*") - buildoptions("/MP") + buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") @@ -158,7 +158,7 @@ function NazaraBuild:Execute() buildoptions("-fvisibility=hidden") configuration("vs*") - buildoptions("/MP") -- Multiprocessus build + buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj flags("NoMinimalRebuild") defines("_CRT_SECURE_NO_WARNINGS") defines("_SCL_SECURE_NO_WARNINGS") diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index 3b440278c..e4e2d8042 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -26,9 +26,9 @@ namespace Nz class Bit; Bitset(); - explicit Bitset(unsigned int bitCount, bool val); + explicit Bitset(std::size_t bitCount, bool val); explicit Bitset(const char* bits); - Bitset(const char* bits, unsigned int bitCount); + Bitset(const char* bits, std::size_t bitCount); Bitset(const Bitset& bitset) = default; explicit Bitset(const String& bits); template Bitset(T value); @@ -36,16 +36,16 @@ namespace Nz ~Bitset() noexcept = default; void Clear() noexcept; - unsigned int Count() const; + std::size_t Count() const; void Flip(); - unsigned int FindFirst() const; - unsigned int FindNext(unsigned int bit) const; + std::size_t FindFirst() const; + std::size_t FindNext(std::size_t bit) const; - Block GetBlock(unsigned int i) const; - unsigned int GetBlockCount() const; - unsigned int GetCapacity() const; - unsigned int GetSize() const; + Block GetBlock(std::size_t i) const; + std::size_t GetBlockCount() const; + std::size_t GetCapacity() const; + std::size_t GetSize() const; void PerformsAND(const Bitset& a, const Bitset& b); void PerformsNOT(const Bitset& a); @@ -54,19 +54,19 @@ namespace Nz bool Intersects(const Bitset& bitset) const; - void Reserve(unsigned int bitCount); - void Resize(unsigned int bitCount, bool defaultVal = false); + void Reserve(std::size_t bitCount); + void Resize(std::size_t bitCount, bool defaultVal = false); void Reset(); - void Reset(unsigned int bit); + void Reset(std::size_t bit); void Set(bool val = true); - void Set(unsigned int bit, bool val = true); - void SetBlock(unsigned int i, Block block); + void Set(std::size_t bit, bool val = true); + void SetBlock(std::size_t i, Block block); void Swap(Bitset& bitset); - bool Test(unsigned int bit) const; + bool Test(std::size_t bit) const; bool TestAll() const; bool TestAny() const; bool TestNone() const; @@ -74,9 +74,9 @@ namespace Nz template T To() const; String ToString() const; - void UnboundedReset(unsigned int bit); - void UnboundedSet(unsigned int bit, bool val = true); - bool UnboundedTest(unsigned int bit) const; + void UnboundedReset(std::size_t bit); + void UnboundedSet(std::size_t bit, bool val = true); + bool UnboundedTest(std::size_t bit) const; Bit operator[](int index); bool operator[](int index) const; @@ -93,20 +93,20 @@ namespace Nz Bitset& operator^=(const Bitset& bitset); static constexpr Block fullBitMask = std::numeric_limits::max(); - static constexpr unsigned int bitsPerBlock = std::numeric_limits::digits; - static constexpr unsigned int npos = std::numeric_limits::max(); + static constexpr std::size_t bitsPerBlock = std::numeric_limits::digits; + static constexpr std::size_t npos = std::numeric_limits::max(); private: - unsigned int FindFirstFrom(unsigned int blockIndex) const; + std::size_t FindFirstFrom(std::size_t blockIndex) const; Block GetLastBlockMask() const; void ResetExtraBits(); - static unsigned int ComputeBlockCount(unsigned int bitCount); - static unsigned int GetBitIndex(unsigned int bit); - static unsigned int GetBlockIndex(unsigned int bit); + static std::size_t ComputeBlockCount(std::size_t bitCount); + static std::size_t GetBitIndex(std::size_t bit); + static std::size_t GetBlockIndex(std::size_t bit); std::vector m_blocks; - unsigned int m_bitCount; + std::size_t m_bitCount; }; template diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index f7256bdbb..21457d7c7 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -42,7 +42,7 @@ namespace Nz */ template - Bitset::Bitset(unsigned int bitCount, bool val) : + Bitset::Bitset(std::size_t bitCount, bool val) : Bitset() { Resize(bitCount, val); @@ -72,11 +72,11 @@ namespace Nz */ template - Bitset::Bitset(const char* bits, unsigned int bitCount) : + Bitset::Bitset(const char* bits, std::size_t bitCount) : m_blocks(ComputeBlockCount(bitCount), 0U), m_bitCount(bitCount) { - for (unsigned int i = 0; i < bitCount; ++i) + for (std::size_t i = 0; i < bitCount; ++i) { switch (*bits++) { @@ -126,7 +126,7 @@ namespace Nz else { // Note: I was kinda tired when I wrote this, there's probably a much easier method than checking bits to write bits - for (unsigned int bitPos = 0; bitPos < std::numeric_limits::digits; bitPos++) + for (std::size_t bitPos = 0; bitPos < std::numeric_limits::digits; bitPos++) { if (value & (T(1U) << bitPos)) UnboundedSet(bitPos, true); @@ -153,13 +153,13 @@ namespace Nz */ template - unsigned int Bitset::Count() const + std::size_t Bitset::Count() const { if (m_blocks.empty()) return 0; - unsigned int count = 0; - for (unsigned int i = 0; i < m_blocks.size(); ++i) + std::size_t count = 0; + for (std::size_t i = 0; i < m_blocks.size(); ++i) count += CountBits(m_blocks[i]); return count; @@ -184,7 +184,7 @@ namespace Nz */ template - unsigned int Bitset::FindFirst() const + std::size_t Bitset::FindFirst() const { return FindFirstFrom(0); } @@ -199,7 +199,7 @@ namespace Nz */ template - unsigned int Bitset::FindNext(unsigned int bit) const + std::size_t Bitset::FindNext(std::size_t bit) const { NazaraAssert(bit < m_bitCount, "Bit index out of range"); @@ -207,8 +207,8 @@ namespace Nz return npos; // The block of the bit and its index - unsigned int blockIndex = GetBlockIndex(bit); - unsigned int bitIndex = GetBitIndex(bit); + std::size_t blockIndex = GetBlockIndex(bit); + std::size_t bitIndex = GetBitIndex(bit); // We get the block Block block = m_blocks[blockIndex]; @@ -233,7 +233,7 @@ namespace Nz */ template - Block Bitset::GetBlock(unsigned int i) const + Block Bitset::GetBlock(std::size_t i) const { NazaraAssert(i < m_blocks.size(), "Block index out of range"); @@ -246,7 +246,7 @@ namespace Nz */ template - unsigned int Bitset::GetBlockCount() const + std::size_t Bitset::GetBlockCount() const { return m_blocks.size(); } @@ -257,7 +257,7 @@ namespace Nz */ template - unsigned int Bitset::GetCapacity() const + std::size_t Bitset::GetCapacity() const { return m_blocks.capacity()*bitsPerBlock; } @@ -268,7 +268,7 @@ namespace Nz */ template - unsigned int Bitset::GetSize() const + std::size_t Bitset::GetSize() const { return m_bitCount; } @@ -285,7 +285,7 @@ namespace Nz template void Bitset::PerformsAND(const Bitset& a, const Bitset& b) { - std::pair minmax = std::minmax(a.GetBlockCount(), b.GetBlockCount()); + std::pair minmax = std::minmax(a.GetBlockCount(), b.GetBlockCount()); // We reinitialise our blocks with zero m_blocks.clear(); @@ -293,7 +293,7 @@ namespace Nz m_bitCount = std::max(a.GetSize(), b.GetSize()); // In case of the "AND", we can stop with the smallest size (because x & 0 = 0) - for (unsigned int i = 0; i < minmax.first; ++i) + for (std::size_t i = 0; i < minmax.first; ++i) m_blocks[i] = a.GetBlock(i) & b.GetBlock(i); ResetExtraBits(); @@ -311,7 +311,7 @@ namespace Nz m_blocks.resize(a.GetBlockCount()); m_bitCount = a.GetSize(); - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) m_blocks[i] = ~a.GetBlock(i); ResetExtraBits(); @@ -332,15 +332,15 @@ namespace Nz const Bitset& greater = (a.GetSize() > b.GetSize()) ? a : b; const Bitset& lesser = (a.GetSize() > b.GetSize()) ? b : a; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); m_blocks.resize(maxBlockCount); m_bitCount = greater.GetSize(); - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) m_blocks[i] = a.GetBlock(i) | b.GetBlock(i); - for (unsigned int i = minBlockCount; i < maxBlockCount; ++i) + for (std::size_t i = minBlockCount; i < maxBlockCount; ++i) m_blocks[i] = greater.GetBlock(i); // (x | 0 = x) ResetExtraBits(); @@ -361,15 +361,15 @@ namespace Nz const Bitset& greater = (a.GetSize() > b.GetSize()) ? a : b; const Bitset& lesser = (a.GetSize() > b.GetSize()) ? b : a; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); m_blocks.resize(maxBlockCount); m_bitCount = greater.GetSize(); - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) m_blocks[i] = a.GetBlock(i) ^ b.GetBlock(i); - for (unsigned int i = minBlockCount; i < maxBlockCount; ++i) + for (std::size_t i = minBlockCount; i < maxBlockCount; ++i) m_blocks[i] = greater.GetBlock(i); // (x ^ 0 = x) ResetExtraBits(); @@ -385,8 +385,8 @@ namespace Nz bool Bitset::Intersects(const Bitset& bitset) const { // We only test the blocks in common - unsigned int sharedBlocks = std::min(GetBlockCount(), bitset.GetBlockCount()); - for (unsigned int i = 0; i < sharedBlocks; ++i) + std::size_t sharedBlocks = std::min(GetBlockCount(), bitset.GetBlockCount()); + for (std::size_t i = 0; i < sharedBlocks; ++i) { Block a = GetBlock(i); Block b = bitset.GetBlock(i); @@ -404,7 +404,7 @@ namespace Nz */ template - void Bitset::Reserve(unsigned int bitCount) + void Bitset::Reserve(std::size_t bitCount) { m_blocks.reserve(ComputeBlockCount(bitCount)); } @@ -417,13 +417,13 @@ namespace Nz */ template - void Bitset::Resize(unsigned int bitCount, bool defaultVal) + void Bitset::Resize(std::size_t bitCount, bool defaultVal) { // We begin with changing the size of container, with the correct value of initialisation - unsigned int lastBlockIndex = m_blocks.size() - 1; + std::size_t lastBlockIndex = m_blocks.size() - 1; m_blocks.resize(ComputeBlockCount(bitCount), (defaultVal) ? fullBitMask : 0U); - unsigned int remainingBits = GetBitIndex(m_bitCount); + std::size_t remainingBits = GetBitIndex(m_bitCount); if (bitCount > m_bitCount && remainingBits > 0 && defaultVal) // Initialisation of unused bits in the last block before the size change m_blocks[lastBlockIndex] |= fullBitMask << remainingBits; @@ -451,7 +451,7 @@ namespace Nz */ template - void Bitset::Reset(unsigned int bit) + void Bitset::Reset(std::size_t bit) { Set(bit, false); } @@ -482,7 +482,7 @@ namespace Nz */ template - void Bitset::Set(unsigned int bit, bool val) + void Bitset::Set(std::size_t bit, bool val) { NazaraAssert(bit < m_bitCount, "Bit index out of range"); @@ -503,7 +503,7 @@ namespace Nz * \remark Produce a NazaraAssert if i is greather than number of blocks in bitset */ template - void Bitset::SetBlock(unsigned int i, Block block) + void Bitset::SetBlock(std::size_t i, Block block) { NazaraAssert(i < m_blocks.size(), "Block index out of range"); @@ -537,7 +537,7 @@ namespace Nz */ template - bool Bitset::Test(unsigned int bit) const + bool Bitset::Test(std::size_t bit) const { NazaraAssert(bit < m_bitCount, "Bit index out of range"); @@ -555,7 +555,7 @@ namespace Nz // Special case for the last block Block lastBlockMask = GetLastBlockMask(); - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) { Block mask = (i == m_blocks.size() - 1) ? lastBlockMask : fullBitMask; if (m_blocks[i] == mask) // The extra bits are set to zero, thus we can't test without proceeding with a mask @@ -576,7 +576,7 @@ namespace Nz if (m_blocks.empty()) return false; - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) { if (m_blocks[i]) return true; @@ -612,7 +612,7 @@ namespace Nz NazaraAssert(m_bitCount <= std::numeric_limits::digits, "Bit count cannot be greater than T bit count"); T value = 0; - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) value |= static_cast(m_blocks[i]) << i*bitsPerBlock; return value; @@ -628,7 +628,7 @@ namespace Nz { String str(m_bitCount, '0'); - for (unsigned int i = 0; i < m_bitCount; ++i) + for (std::size_t i = 0; i < m_bitCount; ++i) { if (Test(i)) str[m_bitCount - i - 1] = '1'; // Inversion de l'indice @@ -648,7 +648,7 @@ namespace Nz */ template - void Bitset::UnboundedReset(unsigned int bit) + void Bitset::UnboundedReset(std::size_t bit) { UnboundedSet(bit, false); } @@ -665,7 +665,7 @@ namespace Nz */ template - void Bitset::UnboundedSet(unsigned int bit, bool val) + void Bitset::UnboundedSet(std::size_t bit, bool val) { if (bit < m_bitCount) Set(bit, val); @@ -687,7 +687,7 @@ namespace Nz */ template - bool Bitset::UnboundedTest(unsigned int bit) const + bool Bitset::UnboundedTest(std::size_t bit) const { if (bit < m_bitCount) return Test(bit); @@ -816,13 +816,13 @@ namespace Nz */ template - unsigned int Bitset::FindFirstFrom(unsigned int blockIndex) const + std::size_t Bitset::FindFirstFrom(std::size_t blockIndex) const { if (blockIndex >= m_blocks.size()) return npos; // We are looking for the first non-null block - unsigned int i = blockIndex; + std::size_t i = blockIndex; for (; i < m_blocks.size(); ++i) { if (m_blocks[i]) @@ -868,7 +868,7 @@ namespace Nz */ template - unsigned int Bitset::ComputeBlockCount(unsigned int bitCount) + std::size_t Bitset::ComputeBlockCount(std::size_t bitCount) { return GetBlockIndex(bitCount) + ((GetBitIndex(bitCount) != 0U) ? 1U : 0U); } @@ -879,7 +879,7 @@ namespace Nz */ template - unsigned int Bitset::GetBitIndex(unsigned int bit) + std::size_t Bitset::GetBitIndex(std::size_t bit) { return bit & (bitsPerBlock - 1U); // bit % bitsPerBlock } @@ -890,7 +890,7 @@ namespace Nz */ template - unsigned int Bitset::GetBlockIndex(unsigned int bit) + std::size_t Bitset::GetBlockIndex(std::size_t bit) { return bit / bitsPerBlock; } @@ -1106,18 +1106,18 @@ namespace Nz const Bitset& greater = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? lhs : rhs; const Bitset& lesser = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? rhs : lhs; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); // We test the blocks in common to check the equality of bits - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) { if (lhs.GetBlock(i) != rhs.GetBlock(i)) return false; } // Now we check for the blocks that only the biggest bitset owns, and to be equal, they must be set to '0' - for (unsigned int i = minBlockCount; i < maxBlockCount; ++i) + for (std::size_t i = minBlockCount; i < maxBlockCount; ++i) if (greater.GetBlock(i)) return false; @@ -1152,20 +1152,20 @@ namespace Nz const Bitset& greater = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? lhs : rhs; const Bitset& lesser = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? rhs : lhs; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); // If the greatest bitset has a single bit active in a block outside the lesser bitset range, then it is greater - for (unsigned int i = maxBlockCount; i > minBlockCount; ++i) + for (std::size_t i = maxBlockCount; i > minBlockCount; ++i) { if (greater.GetBlock(i)) return lhs.GetBlockCount() < rhs.GetBlockCount(); } // Compare the common blocks - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) { - unsigned int index = (minBlockCount - i - 1); // Compare from the most significant block to the less significant block + std::size_t index = (minBlockCount - i - 1); // Compare from the most significant block to the less significant block if (lhs.GetBlock(index) < rhs.GetBlock(index)) return true; } diff --git a/include/Nazara/Core/Endianness.inl b/include/Nazara/Core/Endianness.inl index ee0d094ca..67df87c45 100644 --- a/include/Nazara/Core/Endianness.inl +++ b/include/Nazara/Core/Endianness.inl @@ -33,8 +33,8 @@ namespace Nz inline void SwapBytes(void* buffer, std::size_t size) { UInt8* bytes = static_cast(buffer); - unsigned int i = 0; - unsigned int j = size - 1; + std::size_t i = 0; + std::size_t j = size - 1; while (i < j) std::swap(bytes[i++], bytes[j--]); diff --git a/include/Nazara/Core/ResourceLoader.hpp b/include/Nazara/Core/ResourceLoader.hpp index b0640dcbc..8af3e3cd3 100644 --- a/include/Nazara/Core/ResourceLoader.hpp +++ b/include/Nazara/Core/ResourceLoader.hpp @@ -39,7 +39,7 @@ namespace Nz static bool IsExtensionSupported(const String& extension); static bool LoadFromFile(Type* resource, const String& filePath, const Parameters& parameters = Parameters()); - static bool LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters = Parameters()); + static bool LoadFromMemory(Type* resource, const void* data, std::size_t size, const Parameters& parameters = Parameters()); static bool LoadFromStream(Type* resource, Stream& stream, const Parameters& parameters = Parameters()); static void RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr); diff --git a/include/Nazara/Core/ResourceLoader.inl b/include/Nazara/Core/ResourceLoader.inl index 74e59067d..2ac72c6df 100644 --- a/include/Nazara/Core/ResourceLoader.inl +++ b/include/Nazara/Core/ResourceLoader.inl @@ -160,7 +160,7 @@ namespace Nz * \remark Produces a NazaraError if all loaders failed or no loader was found */ template - bool ResourceLoader::LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters) + bool ResourceLoader::LoadFromMemory(Type* resource, const void* data, std::size_t size, const Parameters& parameters) { NazaraAssert(resource, "Invalid resource"); NazaraAssert(data, "Invalid data pointer"); diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index b924f6a05..9affe6f87 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -84,7 +84,7 @@ namespace Nz bool Execute(const String& code); bool ExecuteFromFile(const String& filePath); - bool ExecuteFromMemory(const void* data, unsigned int size); + bool ExecuteFromMemory(const void* data, std::size_t size); bool ExecuteFromStream(Stream& stream); int GetAbsIndex(int index) const; @@ -142,10 +142,10 @@ namespace Nz void PushNumber(double value) const; void PushReference(int ref) const; void PushString(const char* str) const; - void PushString(const char* str, unsigned int size) const; + void PushString(const char* str, std::size_t size) const; void PushString(const String& str) const; void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0) const; - void* PushUserdata(unsigned int size) const; + void* PushUserdata(std::size_t size) const; void PushValue(int index) const; void Remove(int index) const; @@ -158,7 +158,7 @@ namespace Nz void SetMetatable(const char* tname) const; void SetMetatable(const String& tname) const; void SetMetatable(int index) const; - void SetMemoryLimit(UInt32 memoryLimit); + void SetMemoryLimit(std::size_t memoryLimit); void SetTable(int index = -3) const; void SetTimeLimit(UInt32 timeLimit); @@ -185,8 +185,8 @@ namespace Nz static int ProxyFunc(lua_State* state); static void TimeLimiter(lua_State* state, lua_Debug* debug); - UInt32 m_memoryLimit; - UInt32 m_memoryUsage; + std::size_t m_memoryLimit; + std::size_t m_memoryUsage; UInt32 m_timeLimit; Clock m_clock; String m_lastError; diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index 73069aa37..2fd368b53 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -59,8 +59,8 @@ namespace Nz unsigned int GetHeight(UInt8 level = 0) const; UInt8 GetLevelCount() const; UInt8 GetMaxLevel() const; - unsigned int GetMemoryUsage() const; - unsigned int GetMemoryUsage(UInt8 level) const; + std::size_t GetMemoryUsage() const; + std::size_t GetMemoryUsage(UInt8 level) const; Vector3ui GetSize(UInt8 level = 0) const; ImageType GetType() const; unsigned int GetWidth(UInt8 level = 0) const; diff --git a/include/Nazara/Utility/AbstractAtlas.hpp b/include/Nazara/Utility/AbstractAtlas.hpp index 4d135d465..16d09235f 100644 --- a/include/Nazara/Utility/AbstractAtlas.hpp +++ b/include/Nazara/Utility/AbstractAtlas.hpp @@ -29,7 +29,7 @@ namespace Nz virtual void Clear() = 0; virtual void Free(SparsePtr rects, SparsePtr layers, unsigned int count) = 0; virtual AbstractImage* GetLayer(unsigned int layerIndex) const = 0; - virtual unsigned int GetLayerCount() const = 0; + virtual std::size_t GetLayerCount() const = 0; virtual UInt32 GetStorage() const = 0; virtual bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex) = 0; diff --git a/include/Nazara/Utility/AbstractImage.hpp b/include/Nazara/Utility/AbstractImage.hpp index 3a09f3a06..93821e105 100644 --- a/include/Nazara/Utility/AbstractImage.hpp +++ b/include/Nazara/Utility/AbstractImage.hpp @@ -28,8 +28,8 @@ namespace Nz virtual unsigned int GetHeight(UInt8 level = 0) const = 0; virtual UInt8 GetLevelCount() const = 0; virtual UInt8 GetMaxLevel() const = 0; - virtual unsigned int GetMemoryUsage() const = 0; - virtual unsigned int GetMemoryUsage(UInt8 level) const = 0; + virtual std::size_t GetMemoryUsage() const = 0; + virtual std::size_t GetMemoryUsage(UInt8 level) const = 0; virtual Vector3ui GetSize(UInt8 level = 0) const = 0; virtual ImageType GetType() const = 0; virtual unsigned int GetWidth(UInt8 level = 0) const = 0; diff --git a/include/Nazara/Utility/AbstractTextDrawer.hpp b/include/Nazara/Utility/AbstractTextDrawer.hpp index ffd704f6a..9f941b9c9 100644 --- a/include/Nazara/Utility/AbstractTextDrawer.hpp +++ b/include/Nazara/Utility/AbstractTextDrawer.hpp @@ -27,10 +27,10 @@ namespace Nz virtual ~AbstractTextDrawer(); virtual const Recti& GetBounds() const = 0; - virtual Font* GetFont(unsigned int index) const = 0; - virtual unsigned int GetFontCount() const = 0; - virtual const Glyph& GetGlyph(unsigned int index) const = 0; - virtual unsigned int GetGlyphCount() const = 0; + virtual Font* GetFont(std::size_t index) const = 0; + virtual std::size_t GetFontCount() const = 0; + virtual const Glyph& GetGlyph(std::size_t index) const = 0; + virtual std::size_t GetGlyphCount() const = 0; struct Glyph { diff --git a/include/Nazara/Utility/Font.hpp b/include/Nazara/Utility/Font.hpp index 257e91245..9a226d91e 100644 --- a/include/Nazara/Utility/Font.hpp +++ b/include/Nazara/Utility/Font.hpp @@ -61,8 +61,8 @@ namespace Nz bool ExtractGlyph(unsigned int characterSize, char32_t character, UInt32 style, FontGlyph* glyph) const; const std::shared_ptr& GetAtlas() const; - unsigned int GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const; - unsigned int GetCachedGlyphCount() const; + std::size_t GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const; + std::size_t GetCachedGlyphCount() const; String GetFamilyName() const; int GetKerning(unsigned int characterSize, char32_t first, char32_t second) const; const Glyph& GetGlyph(unsigned int characterSize, UInt32 style, char32_t character) const; diff --git a/include/Nazara/Utility/Formats/MD5AnimParser.hpp b/include/Nazara/Utility/Formats/MD5AnimParser.hpp index cfba9fdc4..558608142 100644 --- a/include/Nazara/Utility/Formats/MD5AnimParser.hpp +++ b/include/Nazara/Utility/Formats/MD5AnimParser.hpp @@ -47,12 +47,12 @@ namespace Nz Ternary Check(); - unsigned int GetAnimatedComponentCount() const; + std::size_t GetAnimatedComponentCount() const; const Frame* GetFrames() const; - unsigned int GetFrameCount() const; - unsigned int GetFrameRate() const; + std::size_t GetFrameCount() const; + std::size_t GetFrameRate() const; const Joint* GetJoints() const; - unsigned int GetJointCount() const; + std::size_t GetJointCount() const; bool Parse(); diff --git a/include/Nazara/Utility/Formats/MD5MeshParser.hpp b/include/Nazara/Utility/Formats/MD5MeshParser.hpp index 5d114bdbb..cd2d19309 100644 --- a/include/Nazara/Utility/Formats/MD5MeshParser.hpp +++ b/include/Nazara/Utility/Formats/MD5MeshParser.hpp @@ -58,9 +58,9 @@ namespace Nz Ternary Check(); const Joint* GetJoints() const; - unsigned int GetJointCount() const; + std::size_t GetJointCount() const; const Mesh* GetMeshes() const; - unsigned int GetMeshCount() const; + std::size_t GetMeshCount() const; bool Parse(); diff --git a/include/Nazara/Utility/GuillotineImageAtlas.hpp b/include/Nazara/Utility/GuillotineImageAtlas.hpp index f26ae13ea..318b92d6b 100644 --- a/include/Nazara/Utility/GuillotineImageAtlas.hpp +++ b/include/Nazara/Utility/GuillotineImageAtlas.hpp @@ -23,16 +23,17 @@ namespace Nz GuillotineImageAtlas(); virtual ~GuillotineImageAtlas(); - void Clear(); - void Free(SparsePtr rects, SparsePtr layers, unsigned int count); + void Clear() override; + + void Free(SparsePtr rects, SparsePtr layers, unsigned int count) override; GuillotineBinPack::FreeRectChoiceHeuristic GetRectChoiceHeuristic() const; GuillotineBinPack::GuillotineSplitHeuristic GetRectSplitHeuristic() const; - AbstractImage* GetLayer(unsigned int layerIndex) const; - unsigned int GetLayerCount() const; - UInt32 GetStorage() const; + AbstractImage* GetLayer(unsigned int layerIndex) const override; + std::size_t GetLayerCount() const override; + UInt32 GetStorage() const override; - bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex); + bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex) override; void SetRectChoiceHeuristic(GuillotineBinPack::FreeRectChoiceHeuristic heuristic); void SetRectSplitHeuristic(GuillotineBinPack::GuillotineSplitHeuristic heuristic); diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index 65c03d6bd..d936ee4d8 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -84,8 +84,8 @@ namespace Nz unsigned int GetHeight(UInt8 level = 0) const; UInt8 GetLevelCount() const; UInt8 GetMaxLevel() const; - unsigned int GetMemoryUsage() const; - unsigned int GetMemoryUsage(UInt8 level) const; + std::size_t GetMemoryUsage() const; + std::size_t GetMemoryUsage(UInt8 level) const; Color GetPixelColor(unsigned int x, unsigned int y = 0, unsigned int z = 0) const; UInt8* GetPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0); Vector3ui GetSize(UInt8 level = 0) const; diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index e384d8574..bf827c4c0 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -100,7 +100,7 @@ namespace Nz counter |= blueMask; counter |= alphaMask; - bitsPerPixel = counter.Count(); + bitsPerPixel = static_cast(counter.Count()); } inline bool PixelFormatInfo::Validate() const @@ -116,7 +116,7 @@ namespace Nz for (unsigned int i = 0; i < 4; ++i) { - unsigned int usedBits = masks[i]->Count(); + UInt8 usedBits = static_cast(masks[i]->Count()); if (usedBits == 0) continue; diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index f5532ca8f..b2f2bf4f9 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -32,10 +32,10 @@ namespace Nz unsigned int GetCharacterSize() const; const Color& GetColor() const; Font* GetFont() const; - Font* GetFont(unsigned int index) const override; - unsigned int GetFontCount() const override; - const Glyph& GetGlyph(unsigned int index) const override; - unsigned int GetGlyphCount() const override; + Font* GetFont(std::size_t index) const override; + std::size_t GetFontCount() const override; + const Glyph& GetGlyph(std::size_t index) const override; + std::size_t GetGlyphCount() const override; UInt32 GetStyle() const; const String& GetText() const; diff --git a/src/Nazara/Core/Win32/FileImpl.cpp b/src/Nazara/Core/Win32/FileImpl.cpp index dcce3d29a..5ed051adb 100644 --- a/src/Nazara/Core/Win32/FileImpl.cpp +++ b/src/Nazara/Core/Win32/FileImpl.cpp @@ -96,7 +96,7 @@ namespace Nz //UInt64 oldCursorPos = GetCursorPos(); DWORD read = 0; - if (ReadFile(m_handle, buffer, size, &read, nullptr)) + if (ReadFile(m_handle, buffer, static_cast(size), &read, nullptr)) { m_endOfFile = (read != size); m_endOfFileUpdated = true; @@ -191,9 +191,9 @@ namespace Nz LARGE_INTEGER cursorPos; cursorPos.QuadPart = GetCursorPos(); - LockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, size, 0); - WriteFile(m_handle, buffer, size, &written, nullptr); - UnlockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, size, 0); + LockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, static_cast(size), 0); + WriteFile(m_handle, buffer, static_cast(size), &written, nullptr); + UnlockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, static_cast(size), 0); m_endOfFileUpdated = false; diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp index 5b5d7153d..ef83e4b28 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp @@ -24,7 +24,7 @@ namespace Nz } #endif - s_workerCount = workerCount; + s_workerCount = static_cast(workerCount); s_doneEvents.reset(new HANDLE[workerCount]); s_workers.reset(new Worker[workerCount]); s_workerThreads.reset(new HANDLE[workerCount]); @@ -64,7 +64,7 @@ namespace Nz // On s'assure que des tâches ne sont pas déjà en cours WaitForMultipleObjects(s_workerCount, &s_doneEvents[0], true, INFINITE); - std::ldiv_t div = std::ldiv(count, s_workerCount); // Division et modulo en une opération, y'a pas de petit profit + std::lldiv_t div = std::lldiv(count, s_workerCount); // Division et modulo en une opération, y'a pas de petit profit for (std::size_t i = 0; i < s_workerCount; ++i) { // On va maintenant répartir les tâches entre chaque worker et les envoyer dans la queue de chacun @@ -78,7 +78,7 @@ namespace Nz } // On les lance une fois qu'ils sont tous initialisés (pour éviter qu'un worker ne passe en pause détectant une absence de travaux) - for (unsigned int i = 0; i < s_workerCount; ++i) + for (std::size_t i = 0; i < s_workerCount; ++i) { ResetEvent(s_doneEvents[i]); SetEvent(s_workers[i].wakeEvent); @@ -244,5 +244,5 @@ namespace Nz std::unique_ptr TaskSchedulerImpl::s_doneEvents; // Doivent être contigus std::unique_ptr TaskSchedulerImpl::s_workers; std::unique_ptr TaskSchedulerImpl::s_workerThreads; // Doivent être contigus - std::size_t TaskSchedulerImpl::s_workerCount; + DWORD TaskSchedulerImpl::s_workerCount; } diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp index 00fdec634..aabd58b86 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp @@ -44,7 +44,7 @@ namespace Nz static std::unique_ptr s_doneEvents; // Doivent être contigus static std::unique_ptr s_workers; static std::unique_ptr s_workerThreads; // Doivent être contigus - static std::size_t s_workerCount; + static DWORD s_workerCount; }; } diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 3459b22cd..42dba4aaf 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -64,8 +64,8 @@ namespace Nz pair.second.used = false; // ... until they are marked as used by the drawer - unsigned int fontCount = drawer.GetFontCount(); - for (unsigned int i = 0; i < fontCount; ++i) + std::size_t fontCount = drawer.GetFontCount(); + for (std::size_t i = 0; i < fontCount; ++i) { Font* font = drawer.GetFont(i); const AbstractAtlas* atlas = font->GetAtlas().get(); @@ -95,7 +95,7 @@ namespace Nz ++atlasIt; } - unsigned int glyphCount = drawer.GetGlyphCount(); + std::size_t glyphCount = drawer.GetGlyphCount(); m_localVertices.resize(glyphCount * 4); // Reset glyph count for every texture to zero @@ -105,7 +105,7 @@ namespace Nz // Count glyph count for each texture Texture* lastTexture = nullptr; unsigned int* count = nullptr; - for (unsigned int i = 0; i < glyphCount; ++i) + for (std::size_t i = 0; i < glyphCount; ++i) { const AbstractTextDrawer::Glyph& glyph = drawer.GetGlyph(i); diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 23f852921..0ecf4c063 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -401,7 +401,7 @@ namespace Nz return false; } - unsigned int length = static_cast(file.GetSize()); + std::size_t length = static_cast(file.GetSize()); String source(length, '\0'); @@ -416,7 +416,7 @@ namespace Nz return Execute(source); } - bool LuaInstance::ExecuteFromMemory(const void* data, unsigned int size) + bool LuaInstance::ExecuteFromMemory(const void* data, std::size_t size) { MemoryView stream(data, size); return ExecuteFromStream(stream); @@ -679,7 +679,7 @@ namespace Nz lua_pushstring(m_state, str); } - void LuaInstance::PushString(const char* str, unsigned int size) const + void LuaInstance::PushString(const char* str, std::size_t size) const { lua_pushlstring(m_state, str, size); } @@ -694,7 +694,7 @@ namespace Nz lua_createtable(m_state, sequenceElementCount, arrayElementCount); } - void* LuaInstance::PushUserdata(unsigned int size) const + void* LuaInstance::PushUserdata(std::size_t size) const { return lua_newuserdata(m_state, size); } @@ -749,7 +749,7 @@ namespace Nz lua_setmetatable(m_state, index); } - void LuaInstance::SetMemoryLimit(UInt32 memoryLimit) + void LuaInstance::SetMemoryLimit(std::size_t memoryLimit) { m_memoryLimit = memoryLimit; } @@ -860,8 +860,8 @@ namespace Nz void* LuaInstance::MemoryAllocator(void* ud, void* ptr, std::size_t osize, std::size_t nsize) { LuaInstance* instance = static_cast(ud); - UInt32& memoryLimit = instance->m_memoryLimit; - UInt32& memoryUsage = instance->m_memoryUsage; + std::size_t& memoryLimit = instance->m_memoryLimit; + std::size_t& memoryUsage = instance->m_memoryUsage; if (nsize == 0) { @@ -872,7 +872,7 @@ namespace Nz } else { - UInt32 usage = memoryUsage + nsize; + std::size_t usage = memoryUsage + nsize; if (ptr) usage -= osize; diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 0fd5cd88a..cbcebb83b 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -56,7 +56,7 @@ namespace Nz std::array hostnameBuffer; std::array serviceBuffer; - int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), hostnameBuffer.size(), serviceBuffer.data(), serviceBuffer.size(), flags); + int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); if (result == 0) { if (hostname) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 9e5846471..ab7ba7fe3 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -328,7 +328,7 @@ namespace Nz return code == TRUE; } - unsigned int SocketImpl::QueryMaxDatagramSize(SocketHandle handle, SocketError* error) + std::size_t SocketImpl::QueryMaxDatagramSize(SocketHandle handle, SocketError* error) { unsigned int code; int codeLength = sizeof(code); diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 1093f1fd1..e49db2cec 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -227,7 +227,8 @@ namespace Nz } GLenum type; - UInt8* offset = reinterpret_cast(s_indexBuffer->GetStartOffset()); + UInt8* offset = nullptr; + offset += s_indexBuffer->GetStartOffset(); if (s_indexBuffer->HasLargeIndices()) { @@ -290,7 +291,8 @@ namespace Nz } GLenum type; - UInt8* offset = reinterpret_cast(s_indexBuffer->GetStartOffset()); + UInt8* offset = nullptr; + offset += s_indexBuffer->GetStartOffset(); if (s_indexBuffer->HasLargeIndices()) { diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index 835dce85e..b8bed61a0 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -364,7 +364,7 @@ namespace Nz return Image::GetMaxLevel(m_impl->type, m_impl->width, m_impl->height, m_impl->depth); } - unsigned int Texture::GetMemoryUsage() const + std::size_t Texture::GetMemoryUsage() const { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -399,7 +399,7 @@ namespace Nz return size * PixelFormat::GetBytesPerPixel(m_impl->format); } - unsigned int Texture::GetMemoryUsage(UInt8 level) const + std::size_t Texture::GetMemoryUsage(UInt8 level) const { #if NAZARA_UTILITY_SAFE if (!m_impl) diff --git a/src/Nazara/Utility/Font.cpp b/src/Nazara/Utility/Font.cpp index a29d28671..b5914aa58 100644 --- a/src/Nazara/Utility/Font.cpp +++ b/src/Nazara/Utility/Font.cpp @@ -127,7 +127,7 @@ namespace Nz return m_atlas; } - unsigned int Font::GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const + std::size_t Font::GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const { UInt64 key = ComputeKey(characterSize, style); auto it = m_glyphes.find(key); @@ -137,9 +137,9 @@ namespace Nz return it->second.size(); } - unsigned int Font::GetCachedGlyphCount() const + std::size_t Font::GetCachedGlyphCount() const { - unsigned int count = 0; + std::size_t count = 0; for (auto& pair : m_glyphes) count += pair.second.size(); diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index d079dc426..e61f6dda2 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -37,10 +37,10 @@ namespace Nz } const MD5AnimParser::Frame* frames = parser.GetFrames(); - unsigned int frameCount = parser.GetFrameCount(); - unsigned int frameRate = parser.GetFrameRate(); + std::size_t frameCount = parser.GetFrameCount(); + std::size_t frameRate = parser.GetFrameRate(); const MD5AnimParser::Joint* joints = parser.GetJoints(); - unsigned int jointCount = parser.GetJointCount(); + std::size_t jointCount = parser.GetJointCount(); // À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation animation->CreateSkeletal(frameCount, jointCount); @@ -59,10 +59,10 @@ namespace Nz Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) * Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { int parent = joints[i].parent; - for (unsigned int j = 0; j < frameCount; ++j) + for (std::size_t j = 0; j < frameCount; ++j) { SequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i]; diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index 9cd930c2e..105944858 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -48,7 +48,7 @@ namespace Nz return Ternary_False; } - unsigned int MD5AnimParser::GetAnimatedComponentCount() const + std::size_t MD5AnimParser::GetAnimatedComponentCount() const { return m_animatedComponents.size(); } @@ -58,12 +58,12 @@ namespace Nz return m_frames.data(); } - unsigned int MD5AnimParser::GetFrameCount() const + std::size_t MD5AnimParser::GetFrameCount() const { return m_frames.size(); } - unsigned int MD5AnimParser::GetFrameRate() const + std::size_t MD5AnimParser::GetFrameRate() const { return m_frameRate; } @@ -73,7 +73,7 @@ namespace Nz return m_joints.data(); } - unsigned int MD5AnimParser::GetJointCount() const + std::size_t MD5AnimParser::GetJointCount() const { return m_joints.size(); } diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index ce56b136a..cd8a6813a 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -53,15 +53,15 @@ namespace Nz const MD5MeshParser::Joint* joints = parser.GetJoints(); const MD5MeshParser::Mesh* meshes = parser.GetMeshes(); - unsigned int jointCount = parser.GetJointCount(); - unsigned int meshCount = parser.GetMeshCount(); + std::size_t jointCount = parser.GetJointCount(); + std::size_t meshCount = parser.GetMeshCount(); if (parameters.animated) { mesh->CreateSkeletal(jointCount); Skeleton* skeleton = mesh->GetSkeleton(); - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { Joint* joint = skeleton->GetJoint(i); @@ -82,12 +82,12 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (unsigned int i = 0; i < meshCount; ++i) + for (std::size_t i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; - unsigned int indexCount = md5Mesh.triangles.size()*3; - unsigned int vertexCount = md5Mesh.vertices.size(); + std::size_t indexCount = md5Mesh.triangles.size()*3; + std::size_t vertexCount = md5Mesh.vertices.size(); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -227,11 +227,11 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (unsigned int i = 0; i < meshCount; ++i) + for (std::size_t i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; - unsigned int indexCount = md5Mesh.triangles.size()*3; - unsigned int vertexCount = md5Mesh.vertices.size(); + std::size_t indexCount = md5Mesh.triangles.size()*3; + std::size_t vertexCount = md5Mesh.vertices.size(); // Index buffer bool largeIndices = (vertexCount > std::numeric_limits::max()); diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index 56e384bf0..b4fd04a33 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -58,7 +58,7 @@ namespace Nz return m_joints.data(); } - unsigned int MD5MeshParser::GetJointCount() const + std::size_t MD5MeshParser::GetJointCount() const { return m_joints.size(); } @@ -68,7 +68,7 @@ namespace Nz return m_meshes.data(); } - unsigned int MD5MeshParser::GetMeshCount() const + std::size_t MD5MeshParser::GetMeshCount() const { return m_meshes.size(); } diff --git a/src/Nazara/Utility/GuillotineImageAtlas.cpp b/src/Nazara/Utility/GuillotineImageAtlas.cpp index 35beab566..b3e630921 100644 --- a/src/Nazara/Utility/GuillotineImageAtlas.cpp +++ b/src/Nazara/Utility/GuillotineImageAtlas.cpp @@ -70,7 +70,7 @@ namespace Nz return layer.image.get(); } - unsigned int GuillotineImageAtlas::GetLayerCount() const + std::size_t GuillotineImageAtlas::GetLayerCount() const { return m_layers.size(); } diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index c8f3e49f1..9e0213cf6 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -666,7 +666,7 @@ namespace Nz return GetMaxLevel(m_sharedImage->type, m_sharedImage->width, m_sharedImage->height, m_sharedImage->depth); } - unsigned int Image::GetMemoryUsage() const + std::size_t Image::GetMemoryUsage() const { unsigned int width = m_sharedImage->width; unsigned int height = m_sharedImage->height; @@ -693,7 +693,7 @@ namespace Nz return size * PixelFormat::GetBytesPerPixel(m_sharedImage->format); } - unsigned int Image::GetMemoryUsage(UInt8 level) const + std::size_t Image::GetMemoryUsage(UInt8 level) const { return PixelFormat::ComputeSize(m_sharedImage->format, GetLevelSize(m_sharedImage->width, level), GetLevelSize(m_sharedImage->height, level), ((m_sharedImage->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level))); } diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index ae2dc8762..03a95f35a 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -72,19 +72,19 @@ namespace Nz return m_font; } - Font* SimpleTextDrawer::GetFont(unsigned int index) const + Font* SimpleTextDrawer::GetFont(std::size_t index) const { NazaraAssert(index == 0, "Font index out of range"); return m_font; } - unsigned int SimpleTextDrawer::GetFontCount() const + std::size_t SimpleTextDrawer::GetFontCount() const { return 1; } - const AbstractTextDrawer::Glyph& SimpleTextDrawer::GetGlyph(unsigned int index) const + const AbstractTextDrawer::Glyph& SimpleTextDrawer::GetGlyph(std::size_t index) const { if (!m_glyphUpdated) UpdateGlyphs(); @@ -94,7 +94,7 @@ namespace Nz return m_glyphs[index]; } - unsigned int SimpleTextDrawer::GetGlyphCount() const + std::size_t SimpleTextDrawer::GetGlyphCount() const { if (!m_glyphUpdated) UpdateGlyphs(); diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index 2bf9c9d02..b494a7789 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -394,7 +394,7 @@ namespace Nz void WindowImpl::SetMaximumSize(int width, int height) { RECT rect = {0, 0, width, height}; - AdjustWindowRect(&rect, GetWindowLongPtr(m_handle, GWL_STYLE), false); + AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); if (width != -1) m_maxSize.x = rect.right-rect.left; @@ -410,7 +410,7 @@ namespace Nz void WindowImpl::SetMinimumSize(int width, int height) { RECT rect = {0, 0, width, height}; - AdjustWindowRect(&rect, GetWindowLongPtr(m_handle, GWL_STYLE), false); + AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); if (width != -1) m_minSize.x = rect.right-rect.left; @@ -432,7 +432,7 @@ namespace Nz { // SetWindowPos demande la taille totale de la fenêtre RECT rect = {0, 0, static_cast(width), static_cast(height)}; - AdjustWindowRect(&rect, GetWindowLongPtr(m_handle, GWL_STYLE), false); + AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); SetWindowPos(m_handle, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER); } From 328eb1eff9d070a146151d2482bf75eb9b6bf0f2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 21:19:12 +0200 Subject: [PATCH 058/235] Build: Fix example path Former-commit-id: c104dbdfccac0d7d7077892ba0b032a65e48148c [formerly 8473fbaa59917b99ee9f056703465b15cf1be59a] Former-commit-id: 6f7b90b6d834ec10135549fbe7fed952393cf3c6 --- build/scripts/common.lua | 12 ++++++------ build/scripts/tools/assimp.lua | 3 ++- build/scripts/tools/ndk.lua | 3 ++- build/scripts/tools/ndk_server.lua | 3 ++- build/scripts/tools/unittests.lua | 1 + 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 12aa13d70..2b4906569 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -270,7 +270,7 @@ function NazaraBuild:Execute() project(prefix .. toolTable.Name) location(_ACTION .. "/tools") - targetdir(toolTable.Directory) + targetdir(toolTable.TargetDirectory) if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then kind("SharedLib") @@ -278,7 +278,7 @@ function NazaraBuild:Execute() -- Copy the tool binaries to the example folder self:MakeInstallCommands(toolTable) elseif (toolTable.Kind == "application") then - debugdir(toolTable.Directory) + debugdir(toolTable.TargetDirectory) if (toolTable.EnableConsole) then kind("ConsoleApp") else @@ -404,7 +404,7 @@ function NazaraBuild:Execute() self:MakeInstallCommands(toolTable) elseif (exampleTable.Kind == "application") then - debugdir(exampleTable.Directory) + debugdir(exampleTable.TargetDirectory) if (exampleTable.EnableConsole) then kind("ConsoleApp") else @@ -769,7 +769,7 @@ function NazaraBuild:RegisterTool(toolTable) return false, "This tool name is already in use" end - if (toolTable.Directory == nil or type(toolTable.Directory) ~= "string" or string.len(toolTable.Directory) == 0) then + if (toolTable.TargetDirectory == nil or type(toolTable.TargetDirectory) ~= "string" or string.len(toolTable.TargetDirectory) == 0) then return false, "Invalid tool directory" end @@ -907,7 +907,7 @@ function NazaraBuild:Process(infoTable) end if (infoTable.Kind == "application") then - self:AddExecutablePath(infoTable.Directory) + self:AddExecutablePath(infoTable.TargetDirectory) end return true @@ -995,8 +995,8 @@ end function NazaraBuild:SetupExampleTable(infoTable) self:SetupInfoTable(infoTable) - infoTable.Directory = "../examples/bin" infoTable.Kind = "application" + infoTable.TargetDirectory = "../examples/bin" end function NazaraBuild:SetupExtlibTable(infoTable) diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index 0eecbcd54..08688ef72 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -1,7 +1,8 @@ TOOL.Name = "Assimp" -TOOL.Directory = "../SDK/lib" +TOOL.Directory = "../plugins/Assimp" TOOL.Kind = "Plugin" +TOOL.TargetDirectory = "../SDK/lib" TOOL.Includes = { "../include", diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index d2038342b..8a40ea170 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -1,7 +1,8 @@ TOOL.Name = "SDK" -TOOL.Directory = "../SDK/lib" +TOOL.Directory = "../SDK" TOOL.Kind = "Library" +TOOL.TargetDirectory = "../SDK/lib" TOOL.Defines = { "NDK_BUILD" diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 91a0fd170..2881c56fc 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -1,7 +1,8 @@ TOOL.Name = "SDKServer" -TOOL.Directory = "../SDK/lib" +TOOL.Directory = "../SDK" TOOL.Kind = "Library" +TOOL.TargetDirectory = "../SDK/lib" TOOL.Defines = { "NDK_BUILD", diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index 349932cb6..fc0f4bad6 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -3,6 +3,7 @@ TOOL.Name = "UnitTests" TOOL.Directory = "../tests" TOOL.EnableConsole = true TOOL.Kind = "Application" +TOOL.TargetDirectory = TOOL.Directory TOOL.Defines = { } From d9562cd05eb5eb1fcab7dd5490799e1d6f36a7be Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 17 Jun 2016 22:30:29 +0200 Subject: [PATCH 059/235] Fix some more warnings Former-commit-id: df01ca2e346151b96d30ddf3534e6733a3cac6ef [formerly 63b2adaf06924d1e65cfd31425c3bd4472d611fa] Former-commit-id: b3c3d328f99f1a0099a335ff4080bb9de7029128 --- SDK/src/NDK/Entity.cpp | 10 +++++----- SDK/src/NDK/World.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 17730a234..f037e5f9a 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -51,7 +51,7 @@ namespace Ndk BaseComponent& component = *m_components[index].get(); component.SetEntity(this); - for (unsigned int i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) { if (i != index) m_components[i]->OnComponentAttached(component); @@ -73,8 +73,8 @@ namespace Ndk void Entity::RemoveAllComponents() { - for (unsigned int i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) - RemoveComponent(i); + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + RemoveComponent(static_cast(i)); NazaraAssert(m_componentBits.TestNone(), "All components should be gone"); @@ -90,7 +90,7 @@ namespace Ndk { // On récupère le component et on informe les composants du détachement BaseComponent& component = *m_components[index].get(); - for (unsigned int i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) { if (i != index) m_components[i]->OnComponentDetached(component); @@ -114,7 +114,7 @@ namespace Ndk void Entity::Destroy() { // On informe chaque système - for (SystemIndex index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) + for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) { if (m_world->HasSystem(index)) { diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index fc53143dd..e95785896 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -94,7 +94,7 @@ namespace Ndk void World::Update() { // Gestion des entités tuées depuis le dernier appel - for (unsigned int i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) + for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) { EntityBlock& block = m_entities[i]; Entity& entity = block.entity; @@ -127,7 +127,7 @@ namespace Ndk m_killedEntities.Reset(); // Gestion des entités nécessitant une mise à jour de leurs systèmes - for (unsigned int i = m_dirtyEntities.FindFirst(); i != m_dirtyEntities.npos; i = m_dirtyEntities.FindNext(i)) + for (std::size_t i = m_dirtyEntities.FindFirst(); i != m_dirtyEntities.npos; i = m_dirtyEntities.FindNext(i)) { NazaraAssert(i < m_entities.size(), "Entity index out of range"); From a05e0ba815c173109e7af5d89278357b679a7ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 18 Jun 2016 07:04:15 +0200 Subject: [PATCH 060/235] Examples: Fix compilation of FirstScene Former-commit-id: 5ed18ab59660acd2360d716a35280daf3eae5634 [formerly ba9c109c5d6face8332704f07c3a118ea89106b7] Former-commit-id: c2d47a67cac35243ad811488afd488bd015f3bb3 --- examples/FirstScene/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 24fef574f..385b054e0 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -29,7 +29,7 @@ Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& ta int main() { - // Pour commencer, nous initialisons le SDK de Nazara, celui-ci va préparer le terrain en initialisant le moteur, + // Pour commencer, nous initialisons le SDK de Nazara, celui-ci va préparer le terrain en initialisant le moteur, // les composants, systèmes, etc. // NzInitializer est une classe RAII appelant Initialize dans son constructeur et Uninitialize dans son destructeur. // Autrement dit, une fois ceci fait nous n'avons plus à nous soucier de la libération du moteur. @@ -101,7 +101,7 @@ int main() // Le format OBJ ne précise aucune échelle pour ses données, contrairement à Nazara (une unité = un mètre en 3D). // Comme le vaisseau est très grand (Des centaines de mètres de long), nous allons le rendre plus petit pour les besoins de la démo. // Ce paramètre sert à indiquer la mise à l'échelle désirée lors du chargement du modèle. - params.mesh.scale.Set(0.01f); // Un centième de la taille originelle + params.mesh.matrix.MakeScale(Nz::Vector3f(0.01f)); // Un centième de la taille originelle // Les UVs de ce fichier sont retournées (repère OpenGL, origine coin bas-gauche) par rapport à ce que le moteur attend (haut-gauche) // Nous devons donc indiquer au moteur de les retourner lors du chargement @@ -156,7 +156,7 @@ int main() // Nous devons donc lui rajouter les composants que nous voulons. // Un NodeComponent donne à notre entité une position, rotation, échelle, et nous permet de l'attacher à d'autres entités (ce que nous ne ferons pas ici). - // Étant donné que par défaut, un NodeComponent se place en (0,0,0) sans rotation et avec une échelle de 1,1,1 et que cela nous convient, + // Étant donné que par défaut, un NodeComponent se place en (0,0,0) sans rotation et avec une échelle de 1,1,1 et que cela nous convient, // nous n'avons pas besoin d'agir sur le composant créé. spaceship->AddComponent(); From 2f6ec2bd2c3b90c54d5691ed8478eb95213eac8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 18 Jun 2016 07:52:33 +0200 Subject: [PATCH 061/235] Noise: Refresh module using ZNoise https://github.com/Overdrivr/ZNoise Former-commit-id: 843916c55738cd6188fe452e610613469eb0e2e3 [formerly 00c5836482dd408da622486b885adad65a77aabd] Former-commit-id: c5992f7852fb8ac76de673ca4149b2a51856c20c --- include/Nazara/Noise/Abstract2DNoise.hpp | 26 - include/Nazara/Noise/Abstract3DNoise.hpp | 26 - include/Nazara/Noise/Abstract4DNoise.hpp | 26 - include/Nazara/Noise/ComplexNoiseBase.hpp | 41 -- include/Nazara/Noise/Config.hpp | 2 +- include/Nazara/Noise/ConfigCheck.hpp | 2 +- include/Nazara/Noise/Debug.hpp | 2 +- include/Nazara/Noise/DebugOff.hpp | 2 +- include/Nazara/Noise/Enums.hpp | 18 + include/Nazara/Noise/FBM.hpp | 30 ++ include/Nazara/Noise/FBM2D.hpp | 31 -- include/Nazara/Noise/FBM3D.hpp | 32 -- include/Nazara/Noise/FBM4D.hpp | 32 -- include/Nazara/Noise/HybridMultiFractal.hpp | 34 ++ include/Nazara/Noise/HybridMultiFractal2D.hpp | 36 -- include/Nazara/Noise/HybridMultiFractal3D.hpp | 36 -- include/Nazara/Noise/HybridMultiFractal4D.hpp | 36 -- include/Nazara/Noise/MappedNoiseBase.hpp | 35 -- include/Nazara/Noise/MixerBase.hpp | 38 ++ include/Nazara/Noise/Noise.hpp | 2 +- include/Nazara/Noise/NoiseBase.hpp | 36 +- include/Nazara/Noise/NoiseTools.hpp | 14 + include/Nazara/Noise/Perlin.hpp | 36 ++ include/Nazara/Noise/Perlin2D.hpp | 39 -- include/Nazara/Noise/Perlin3D.hpp | 40 -- include/Nazara/Noise/Perlin4D.hpp | 39 -- include/Nazara/Noise/Simplex.hpp | 43 ++ include/Nazara/Noise/Simplex2D.hpp | 42 -- include/Nazara/Noise/Simplex3D.hpp | 42 -- include/Nazara/Noise/Simplex4D.hpp | 44 -- include/Nazara/Noise/Worley.hpp | 41 ++ src/Nazara/Noise/Abstract2DNoise.cpp | 24 - src/Nazara/Noise/Abstract3DNoise.cpp | 24 - src/Nazara/Noise/Abstract4DNoise.cpp | 24 - src/Nazara/Noise/ComplexNoiseBase.cpp | 83 ---- src/Nazara/Noise/FBM.cpp | 31 ++ src/Nazara/Noise/FBM2D.cpp | 54 --- src/Nazara/Noise/FBM3D.cpp | 54 --- src/Nazara/Noise/FBM4D.cpp | 54 --- src/Nazara/Noise/HybridMultiFractal.cpp | 42 ++ src/Nazara/Noise/HybridMultiFractal3D.cpp | 67 --- src/Nazara/Noise/HybridMultiFractal4D.cpp | 67 --- src/Nazara/Noise/HybridMultifractal2D.cpp | 67 --- src/Nazara/Noise/MappedNoiseBase.cpp | 56 --- src/Nazara/Noise/MixerBase.cpp | 56 +++ src/Nazara/Noise/NoiseBase.cpp | 68 +-- src/Nazara/Noise/NoiseTools.cpp | 28 ++ src/Nazara/Noise/Perlin.cpp | 325 +++++++++++++ src/Nazara/Noise/Perlin2D.cpp | 75 --- src/Nazara/Noise/Perlin3D.cpp | 98 ---- src/Nazara/Noise/Perlin4D.cpp | 156 ------ src/Nazara/Noise/Simplex.cpp | 459 ++++++++++++++++++ src/Nazara/Noise/Simplex2D.cpp | 94 ---- src/Nazara/Noise/Simplex3D.cpp | 176 ------- src/Nazara/Noise/Simplex4D.cpp | 169 ------- src/Nazara/Noise/Worley.cpp | 171 +++++++ 56 files changed, 1408 insertions(+), 2017 deletions(-) delete mode 100644 include/Nazara/Noise/Abstract2DNoise.hpp delete mode 100644 include/Nazara/Noise/Abstract3DNoise.hpp delete mode 100644 include/Nazara/Noise/Abstract4DNoise.hpp delete mode 100644 include/Nazara/Noise/ComplexNoiseBase.hpp create mode 100644 include/Nazara/Noise/Enums.hpp create mode 100644 include/Nazara/Noise/FBM.hpp delete mode 100644 include/Nazara/Noise/FBM2D.hpp delete mode 100644 include/Nazara/Noise/FBM3D.hpp delete mode 100644 include/Nazara/Noise/FBM4D.hpp create mode 100644 include/Nazara/Noise/HybridMultiFractal.hpp delete mode 100644 include/Nazara/Noise/HybridMultiFractal2D.hpp delete mode 100644 include/Nazara/Noise/HybridMultiFractal3D.hpp delete mode 100644 include/Nazara/Noise/HybridMultiFractal4D.hpp delete mode 100644 include/Nazara/Noise/MappedNoiseBase.hpp create mode 100644 include/Nazara/Noise/MixerBase.hpp create mode 100644 include/Nazara/Noise/NoiseTools.hpp create mode 100644 include/Nazara/Noise/Perlin.hpp delete mode 100644 include/Nazara/Noise/Perlin2D.hpp delete mode 100644 include/Nazara/Noise/Perlin3D.hpp delete mode 100644 include/Nazara/Noise/Perlin4D.hpp create mode 100644 include/Nazara/Noise/Simplex.hpp delete mode 100644 include/Nazara/Noise/Simplex2D.hpp delete mode 100644 include/Nazara/Noise/Simplex3D.hpp delete mode 100644 include/Nazara/Noise/Simplex4D.hpp create mode 100644 include/Nazara/Noise/Worley.hpp delete mode 100644 src/Nazara/Noise/Abstract2DNoise.cpp delete mode 100644 src/Nazara/Noise/Abstract3DNoise.cpp delete mode 100644 src/Nazara/Noise/Abstract4DNoise.cpp delete mode 100644 src/Nazara/Noise/ComplexNoiseBase.cpp create mode 100644 src/Nazara/Noise/FBM.cpp delete mode 100644 src/Nazara/Noise/FBM2D.cpp delete mode 100644 src/Nazara/Noise/FBM3D.cpp delete mode 100644 src/Nazara/Noise/FBM4D.cpp create mode 100644 src/Nazara/Noise/HybridMultiFractal.cpp delete mode 100644 src/Nazara/Noise/HybridMultiFractal3D.cpp delete mode 100644 src/Nazara/Noise/HybridMultiFractal4D.cpp delete mode 100644 src/Nazara/Noise/HybridMultifractal2D.cpp delete mode 100644 src/Nazara/Noise/MappedNoiseBase.cpp create mode 100644 src/Nazara/Noise/MixerBase.cpp create mode 100644 src/Nazara/Noise/NoiseTools.cpp create mode 100644 src/Nazara/Noise/Perlin.cpp delete mode 100644 src/Nazara/Noise/Perlin2D.cpp delete mode 100644 src/Nazara/Noise/Perlin3D.cpp delete mode 100644 src/Nazara/Noise/Perlin4D.cpp create mode 100644 src/Nazara/Noise/Simplex.cpp delete mode 100644 src/Nazara/Noise/Simplex2D.cpp delete mode 100644 src/Nazara/Noise/Simplex3D.cpp delete mode 100644 src/Nazara/Noise/Simplex4D.cpp create mode 100644 src/Nazara/Noise/Worley.cpp diff --git a/include/Nazara/Noise/Abstract2DNoise.hpp b/include/Nazara/Noise/Abstract2DNoise.hpp deleted file mode 100644 index 0eb5c23e5..000000000 --- a/include/Nazara/Noise/Abstract2DNoise.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ABSTRACT2DNOISE_HPP -#define NAZARA_ABSTRACT2DNOISE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Abstract2DNoise : public MappedNoiseBase - { - public: - virtual ~Abstract2DNoise(); - - float GetBasicValue(float x, float y); - float GetMappedValue(float x, float y); - virtual float GetValue(float x, float y, float resolution) = 0; - }; -} - -#endif // NAZARA_ABSTRACT2DNOISE_HPP diff --git a/include/Nazara/Noise/Abstract3DNoise.hpp b/include/Nazara/Noise/Abstract3DNoise.hpp deleted file mode 100644 index 19a0c765c..000000000 --- a/include/Nazara/Noise/Abstract3DNoise.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ABSTRACT3DNOISE_HPP -#define NAZARA_ABSTRACT3DNOISE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Abstract3DNoise : public MappedNoiseBase - { - public: - virtual ~Abstract3DNoise(); - - float GetBasicValue(float x, float y, float z); - float GetMappedValue(float x, float y, float z); - virtual float GetValue(float x, float y, float z, float resolution) = 0; - }; -} - -#endif // NAZARA_ABSTRACT3DNOISE_HPP diff --git a/include/Nazara/Noise/Abstract4DNoise.hpp b/include/Nazara/Noise/Abstract4DNoise.hpp deleted file mode 100644 index 631228020..000000000 --- a/include/Nazara/Noise/Abstract4DNoise.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ABSTRACT4DNOISE_HPP -#define NAZARA_ABSTRACT4DNOISE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Abstract4DNoise : public MappedNoiseBase - { - public: - virtual ~Abstract4DNoise(); - - float GetBasicValue(float x, float y, float z, float w); - float GetMappedValue(float x, float y, float z, float w); - virtual float GetValue(float x, float y, float z, float w, float resolution) = 0; - }; -} - -#endif // NAZARA_ABSTRACT4DNOISE_HPP diff --git a/include/Nazara/Noise/ComplexNoiseBase.hpp b/include/Nazara/Noise/ComplexNoiseBase.hpp deleted file mode 100644 index 6be8667a5..000000000 --- a/include/Nazara/Noise/ComplexNoiseBase.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef COMPLEXNOISEBASE_HPP -#define COMPLEXNOISEBASE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API ComplexNoiseBase - { - public: - ComplexNoiseBase(); - ~ComplexNoiseBase() = default; - - float GetHurstParameter() const; - float GetLacunarity() const; - float GetOctaveNumber() const; - void SetHurstParameter(float h); - void SetLacunarity(float lacunarity); - void SetOctavesNumber(float octaves); - void RecomputeExponentArray(); - - protected: - float m_lacunarity; - float m_hurst; - float m_octaves; - std::array m_exponent_array; - float m_sum; - - private: - bool m_parametersModified; - }; -} - -#endif // COMPLEXNOISEBASE_HPP diff --git a/include/Nazara/Noise/Config.hpp b/include/Nazara/Noise/Config.hpp index 5df2d6dc4..afe6d577e 100644 --- a/include/Nazara/Noise/Config.hpp +++ b/include/Nazara/Noise/Config.hpp @@ -1,7 +1,7 @@ /* Nazara Engine - Noise module - Copyright (C) 2015 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) + Copyright (C) 2016 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Noise/ConfigCheck.hpp b/include/Nazara/Noise/ConfigCheck.hpp index f7682bd28..9c6df7851 100644 --- a/include/Nazara/Noise/ConfigCheck.hpp +++ b/include/Nazara/Noise/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Debug.hpp b/include/Nazara/Noise/Debug.hpp index 377ae7b1c..4696c79b9 100644 --- a/include/Nazara/Noise/Debug.hpp +++ b/include/Nazara/Noise/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/DebugOff.hpp b/include/Nazara/Noise/DebugOff.hpp index 75903b6cc..4b368b6ea 100644 --- a/include/Nazara/Noise/DebugOff.hpp +++ b/include/Nazara/Noise/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Enums.hpp b/include/Nazara/Noise/Enums.hpp new file mode 100644 index 000000000..7962d8415 --- /dev/null +++ b/include/Nazara/Noise/Enums.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_ENUMS_NOISE_HPP +#define NAZARA_ENUMS_NOISE_HPP + +namespace Nz +{ + enum WorleyFunction + { + WorleyFunction_F1 = 0, + WorleyFunction_F2 = 1, + WorleyFunction_F3 = 2, + WorleyFunction_F4 = 3 + }; +} +#endif // NAZARA_ENUMS_NOISE_HPP diff --git a/include/Nazara/Noise/FBM.hpp b/include/Nazara/Noise/FBM.hpp new file mode 100644 index 000000000..ded4aa069 --- /dev/null +++ b/include/Nazara/Noise/FBM.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_FBM_HPP +#define NAZARA_FBM_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API FBM : public MixerBase + { + public: + FBM(const NoiseBase& source); + FBM(const FBM&) = delete; + ~FBM() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + FBM& operator=(const FBM&) = delete; + + private: + const NoiseBase& m_source; + }; +} + +#endif // NAZARA_FBM_HPP diff --git a/include/Nazara/Noise/FBM2D.hpp b/include/Nazara/Noise/FBM2D.hpp deleted file mode 100644 index 9b456de0a..000000000 --- a/include/Nazara/Noise/FBM2D.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef FBM2D_HPP -#define FBM2D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API FBM2D : public Abstract2DNoise, public ComplexNoiseBase - { - public: - FBM2D(NoiseType source, unsigned int seed); - float GetValue(float x, float y, float resolution); - ~FBM2D(); - - private: - Abstract2DNoise* m_source; - float m_value; - float m_remainder; - NoiseType m_noiseType; - }; -} - -#endif // FBM2D_HPP diff --git a/include/Nazara/Noise/FBM3D.hpp b/include/Nazara/Noise/FBM3D.hpp deleted file mode 100644 index 722ad843d..000000000 --- a/include/Nazara/Noise/FBM3D.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef FBM3D_HPP -#define FBM3D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API FBM3D : public Abstract3DNoise, public ComplexNoiseBase - { - public: - FBM3D(NoiseType source, unsigned int seed); - float GetValue(float x, float y, float z, float resolution); - ~FBM3D(); - - private: - Abstract3DNoise* m_source; - float m_value; - float m_remainder; - NoiseType m_noiseType; - }; -} - -#endif // FBM3D_HPP - diff --git a/include/Nazara/Noise/FBM4D.hpp b/include/Nazara/Noise/FBM4D.hpp deleted file mode 100644 index e18c93111..000000000 --- a/include/Nazara/Noise/FBM4D.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef FBM4D_HPP -#define FBM4D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API FBM4D : public Abstract4DNoise, public ComplexNoiseBase - { - public: - FBM4D(NoiseType source, unsigned int seed); - float GetValue(float x, float y, float z, float w, float resolution); - ~FBM4D(); - - private: - Abstract4DNoise* m_source; - float m_value; - float m_remainder; - NoiseType m_noiseType; - }; -} - -#endif // FBM4D_HPP - diff --git a/include/Nazara/Noise/HybridMultiFractal.hpp b/include/Nazara/Noise/HybridMultiFractal.hpp new file mode 100644 index 000000000..a211a4767 --- /dev/null +++ b/include/Nazara/Noise/HybridMultiFractal.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_HYBRIDMULTIFRACTAL_HPP +#define NAZARA_HYBRIDMULTIFRACTAL_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API HybridMultiFractal : public MixerBase + { + public: + HybridMultiFractal(const NoiseBase & source); + HybridMultiFractal(const HybridMultiFractal&) = delete; + ~HybridMultiFractal() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + HybridMultiFractal& operator=(const HybridMultiFractal&) = delete; + + private: + const NoiseBase& m_source; + float m_value; + float m_remainder; + float m_offset; + float m_weight; + float m_signal; + }; +} + +#endif // NAZARA_HYBRIDMULTIFRACTAL_HPP diff --git a/include/Nazara/Noise/HybridMultiFractal2D.hpp b/include/Nazara/Noise/HybridMultiFractal2D.hpp deleted file mode 100644 index 4b0ad9bc6..000000000 --- a/include/Nazara/Noise/HybridMultiFractal2D.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef HYBRIDMULTIFRACTAL2D_HPP -#define HYBRIDMULTIFRACTAL2D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API HybridMultiFractal2D : public Abstract2DNoise, public ComplexNoiseBase - { - public: - HybridMultiFractal2D(NoiseType source, unsigned int seed); - ~HybridMultiFractal2D(); - - float GetValue(float x, float y, float resolution); - - private: - Abstract2DNoise* m_source; - float m_value; - float m_remainder; - float m_offset; - float m_weight; - float m_signal; - NoiseType m_noiseType; - }; -} - -#endif // HYBRIDMULTIFRACTAL2D_HPP - diff --git a/include/Nazara/Noise/HybridMultiFractal3D.hpp b/include/Nazara/Noise/HybridMultiFractal3D.hpp deleted file mode 100644 index 34d554292..000000000 --- a/include/Nazara/Noise/HybridMultiFractal3D.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef HYBRIDMULTIFRACTAL3D_HPP -#define HYBRIDMULTIFRACTAL3D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API HybridMultiFractal3D : public Abstract3DNoise, public ComplexNoiseBase - { - public: - HybridMultiFractal3D(NoiseType source, unsigned int seed); - ~HybridMultiFractal3D(); - - float GetValue(float x, float y, float z, float resolution); - - private: - Abstract3DNoise* m_source; - float m_value; - float m_remainder; - float m_offset; - float m_weight; - float m_signal; - NoiseType m_noiseType; - }; -} - -#endif // HYBRIDMULTIFRACTAL3D_HPP - diff --git a/include/Nazara/Noise/HybridMultiFractal4D.hpp b/include/Nazara/Noise/HybridMultiFractal4D.hpp deleted file mode 100644 index 859ed8087..000000000 --- a/include/Nazara/Noise/HybridMultiFractal4D.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef HYBRIDMULTIFRACTAL4D_HPP -#define HYBRIDMULTIFRACTAL4D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API HybridMultiFractal4D : public Abstract4DNoise, public ComplexNoiseBase - { - public: - HybridMultiFractal4D(NoiseType source, unsigned int seed); - ~HybridMultiFractal4D(); - - float GetValue(float x, float y, float z, float w, float resolution); - - private: - Abstract4DNoise* m_source; - float m_value; - float m_remainder; - float m_offset; - float m_weight; - float m_signal; - NoiseType m_noiseType; - }; -} - -#endif // HYBRIDMULTIFRACTAL4D_HPP - diff --git a/include/Nazara/Noise/MappedNoiseBase.hpp b/include/Nazara/Noise/MappedNoiseBase.hpp deleted file mode 100644 index 7e5106a31..000000000 --- a/include/Nazara/Noise/MappedNoiseBase.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_MAPPEDNOISEBASE_HPP -#define NAZARA_MAPPEDNOISEBASE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API MappedNoiseBase : public NoiseBase - { - public: - MappedNoiseBase(); - ~MappedNoiseBase() = default; - - float GetGain() const; - float GetOffset() const; - float GetResolution() const; - void SetGain(float gain); - void SetOffset(float offset); - void SetResolution(float resolution); - - protected: - float m_gain; - float m_offset; - float m_resolution; - }; -} - -#endif // NAZARA_MAPPEDNOISEBASE_HPP diff --git a/include/Nazara/Noise/MixerBase.hpp b/include/Nazara/Noise/MixerBase.hpp new file mode 100644 index 000000000..3c7a131b0 --- /dev/null +++ b/include/Nazara/Noise/MixerBase.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_MIXERBASE_HPP +#define NAZARA_MIXERBASE_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API MixerBase + { + public: + MixerBase(); + ~MixerBase() = default; + + float GetHurstParameter() const; + float GetLacunarity() const; + float GetOctaveNumber() const; + + void SetParameters(float hurst, float lacunarity, float octaves); + + protected: + float m_hurst; + float m_lacunarity; + float m_octaves; + std::vector m_exponent_array; + float m_sum; + + private: + void Recompute(); + }; +} + +#endif // NAZARA_MIXERBASE_HPP diff --git a/include/Nazara/Noise/Noise.hpp b/include/Nazara/Noise/Noise.hpp index a1e5b7d11..c1ec5b1da 100644 --- a/include/Nazara/Noise/Noise.hpp +++ b/include/Nazara/Noise/Noise.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp index bd268ee8c..6a5c5c37f 100644 --- a/include/Nazara/Noise/NoiseBase.hpp +++ b/include/Nazara/Noise/NoiseBase.hpp @@ -1,48 +1,38 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp -#pragma once - -#ifndef NOISEBASE_HPP -#define NOISEBASE_HPP +#ifndef NAZARA_NOISEBASE_HPP +#define NAZARA_NOISEBASE_HPP #include #include +#include namespace Nz { - enum NoiseType - { - PERLIN, - SIMPLEX, - CELL - }; - class NAZARA_NOISE_API NoiseBase { public: NoiseBase(unsigned int seed = 0); ~NoiseBase() = default; - void SetNewSeed(unsigned int seed); + virtual float Get(std::initializer_list coordinates, float scale) const = 0; + float GetScale(); - void ShufflePermutationTable(); + void SetScale(float scale); + void SetSeed(unsigned int seed); - unsigned int GetUniformRandomValue(); - - int fastfloor(float n); - int JenkinsHash(int a, int b, int c); + void Shuffle(); + void Shuffle(unsigned int amount); protected: unsigned int perm[512]; + float m_scale; private: - unsigned int Ua, Uc, Um; - unsigned int UcurrentSeed; - unsigned int Uprevious, Ulast; - + std::default_random_engine generator; }; } -#endif // NOISEBASE_HPP +#endif // NAZARA_NOISEBASE_HPP diff --git a/include/Nazara/Noise/NoiseTools.hpp b/include/Nazara/Noise/NoiseTools.hpp new file mode 100644 index 000000000..6238caec3 --- /dev/null +++ b/include/Nazara/Noise/NoiseTools.hpp @@ -0,0 +1,14 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_NOISETOOLS_HPP +#define NAZARA_NOISETOOLS_HPP + +namespace Nz +{ + int fastfloor(float n); + int JenkinsHash(int a, int b, int c); +} + +#endif // NAZARA_NOISETOOLS_HPP diff --git a/include/Nazara/Noise/Perlin.hpp b/include/Nazara/Noise/Perlin.hpp new file mode 100644 index 000000000..058a3ada5 --- /dev/null +++ b/include/Nazara/Noise/Perlin.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_PERLIN_HPP +#define NAZARA_PERLIN_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API Perlin : public NoiseBase + { + public: + Perlin(); + Perlin(unsigned int seed); + ~Perlin() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + protected: + float _2D(std::initializer_list coordinates, float scale) const; + float _3D(std::initializer_list coordinates, float scale) const; + float _4D(std::initializer_list coordinates, float scale) const; + + private: + const float gradient2[8][2]; + const float gradient3[16][3]; + const float gradient4[32][4]; + }; +} + +#endif // NAZARA_PERLIN_HPP diff --git a/include/Nazara/Noise/Perlin2D.hpp b/include/Nazara/Noise/Perlin2D.hpp deleted file mode 100644 index 88a98155b..000000000 --- a/include/Nazara/Noise/Perlin2D.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef PERLIN2D_HPP -#define PERLIN2D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Perlin2D : public Abstract2DNoise - { - public: - Perlin2D(); - Perlin2D(unsigned int seed); - ~Perlin2D() = default; - - float GetValue(float x, float y, float resolution); - - private: - int x0, y0; - int gi0,gi1,gi2,gi3; - int ii, jj; - float gradient2[8][2]; - float s,t,u,v; - float Cx,Cy; - float Li1, Li2; - Vector2 temp; - }; -} - -#endif // PERLIN2D_HPP - diff --git a/include/Nazara/Noise/Perlin3D.hpp b/include/Nazara/Noise/Perlin3D.hpp deleted file mode 100644 index 47be7f29b..000000000 --- a/include/Nazara/Noise/Perlin3D.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef PERLIN3D_HPP -#define PERLIN3D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Perlin3D : public Abstract3DNoise - { - public: - Perlin3D(); - Perlin3D(unsigned int seed); - ~Perlin3D() = default; - - float GetValue(float x, float y, float z, float resolution); - - private: - int x0,y0,z0; - int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; - int ii,jj,kk; - float gradient3[16][3]; - float Li1,Li2,Li3,Li4,Li5,Li6; - float s[2],t[2],u[2],v[2]; - float Cx,Cy,Cz; - float nx,ny,nz; - float tmp; - Vector3 temp; - }; -} - -#endif // PERLIN3D_HPP diff --git a/include/Nazara/Noise/Perlin4D.hpp b/include/Nazara/Noise/Perlin4D.hpp deleted file mode 100644 index 66d7a1b7b..000000000 --- a/include/Nazara/Noise/Perlin4D.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef PERLIN4D_HPP -#define PERLIN4D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Perlin4D : public Abstract4DNoise - { - public: - Perlin4D(); - Perlin4D(unsigned int seed); - ~Perlin4D() = default; - - float GetValue(float x, float y, float z, float w, float resolution); - - private: - int x0,y0,z0,w0; - int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; - int ii,jj,kk,ll; - float gradient4[32][4]; - float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; - float s[4],t[4],u[4],v[4]; - float Cx,Cy,Cz,Cw; - float tmp; - Vector4 temp; - }; -} - -#endif // PERLIN4D_HPP diff --git a/include/Nazara/Noise/Simplex.hpp b/include/Nazara/Noise/Simplex.hpp new file mode 100644 index 000000000..f131387b6 --- /dev/null +++ b/include/Nazara/Noise/Simplex.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef SIMPLEX_HPP +#define SIMPLE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API Simplex : public NoiseBase + { + public: + Simplex(); + Simplex(unsigned int seed); + ~Simplex() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + protected: + float _2D(std::initializer_list coordinates, float scale) const; + float _3D(std::initializer_list coordinates, float scale) const; + float _4D(std::initializer_list coordinates, float scale) const; + + private: + const float gradient2[8][2]; + const float gradient3[16][3]; + const float gradient4[32][4]; + const float UnskewCoeff2D; + const float SkewCoeff2D; + const float UnskewCoeff3D; + const float SkewCoeff3D; + const float UnskewCoeff4D; + const float SkewCoeff4D; + const int lookupTable4D[64][4]; + }; +} + +#endif // SIMPLEX_HPP diff --git a/include/Nazara/Noise/Simplex2D.hpp b/include/Nazara/Noise/Simplex2D.hpp deleted file mode 100644 index 69a73478d..000000000 --- a/include/Nazara/Noise/Simplex2D.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef SIMPLEX2D_HPP -#define SIMPLEX2D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Simplex2D : public Abstract2DNoise - { - public: - Simplex2D(); - Simplex2D(unsigned int seed); - virtual ~Simplex2D() = default; - - float GetValue(float x, float y, float resolution); - - private: - int ii,jj; - int gi0,gi1,gi2; - Vector2i skewedCubeOrigin,off1; - float n1,n2,n3; - float c1,c2,c3; - float gradient2[8][2]; - float UnskewCoeff2D; - float SkewCoeff2D; - float sum; - Vector2 unskewedCubeOrigin, unskewedDistToOrigin; - Vector2 d1,d2,d3; - }; -} - -#endif // SIMPLEX2D_HPP - diff --git a/include/Nazara/Noise/Simplex3D.hpp b/include/Nazara/Noise/Simplex3D.hpp deleted file mode 100644 index ecfc4c2a4..000000000 --- a/include/Nazara/Noise/Simplex3D.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef SIMPLEX3D_HPP -#define SIMPLEX3D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Simplex3D : public Abstract3DNoise - { - public: - Simplex3D(); - Simplex3D(unsigned int seed); - ~Simplex3D() = default; - - float GetValue(float x, float y, float z, float resolution); - - private: - int ii,jj,kk; - int gi0,gi1,gi2,gi3; - Vector3i skewedCubeOrigin,off1,off2; - float n1,n2,n3,n4; - float c1,c2,c3,c4; - float gradient3[12][3]; - float UnskewCoeff3D; - float SkewCoeff3D; - float sum; - Vector3 unskewedCubeOrigin, unskewedDistToOrigin; - Vector3 d1,d2,d3,d4; - }; -} - -#endif // SIMPLEX3D_HPP - diff --git a/include/Nazara/Noise/Simplex4D.hpp b/include/Nazara/Noise/Simplex4D.hpp deleted file mode 100644 index 545c5f290..000000000 --- a/include/Nazara/Noise/Simplex4D.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef SIMPLEX4D_HPP -#define SIMPLEX4D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Simplex4D : public Abstract4DNoise - { - public: - Simplex4D(); - Simplex4D(unsigned int seed); - ~Simplex4D() = default; - - float GetValue(float x, float y, float z, float w, float resolution); - - private: - int ii,jj,kk,ll; - int gi0,gi1,gi2,gi3,gi4; - Vector4i skewedCubeOrigin,off1,off2,off3; - int lookupTable4D[64][4]; - int c; - float n1,n2,n3,n4,n5; - float c1,c2,c3,c4,c5,c6; - float gradient4[32][4]; - float UnskewCoeff4D; - float SkewCoeff4D; - float sum; - Vector4 unskewedCubeOrigin, unskewedDistToOrigin; - Vector4 d1,d2,d3,d4,d5; - }; -} - -#endif // SIMPLEX4D_H - diff --git a/include/Nazara/Noise/Worley.hpp b/include/Nazara/Noise/Worley.hpp new file mode 100644 index 000000000..249da999f --- /dev/null +++ b/include/Nazara/Noise/Worley.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_WORLEY_HPP +#define NAZARA_WORLEY_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API Worley : public NoiseBase + { + public: + Worley(); + Worley(unsigned int seed); + ~Worley() = default; + + void Set(WorleyFunction func); + + float Get(std::initializer_list coordinates, float scale) const; + + protected: + float _2D(std::initializer_list coordinates, float scale) const; + float _3D(std::initializer_list coordinates, float scale) const; + float _4D(std::initializer_list coordinates, float scale) const; + void _SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const; + + private: + const float scales[4]; + WorleyFunction function; + }; +} + +#endif // NAZARA_WORLEY_HPP diff --git a/src/Nazara/Noise/Abstract2DNoise.cpp b/src/Nazara/Noise/Abstract2DNoise.cpp deleted file mode 100644 index 51cfeddcc..000000000 --- a/src/Nazara/Noise/Abstract2DNoise.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - Abstract2DNoise::~Abstract2DNoise() = default; - - float Abstract2DNoise::GetBasicValue(float x, float y) - { - return this->GetValue(x,y,m_resolution); - } - - float Abstract2DNoise::GetMappedValue(float x, float y) - { - return (this->GetValue(x,y,m_resolution) + m_offset) * m_gain; - } -} diff --git a/src/Nazara/Noise/Abstract3DNoise.cpp b/src/Nazara/Noise/Abstract3DNoise.cpp deleted file mode 100644 index 6456babec..000000000 --- a/src/Nazara/Noise/Abstract3DNoise.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - Abstract3DNoise::~Abstract3DNoise() = default; - - float Abstract3DNoise::GetBasicValue(float x, float y, float z) - { - return this->GetValue(x,y,z,m_resolution); - } - - float Abstract3DNoise::GetMappedValue(float x, float y, float z) - { - return (this->GetValue(x,y,z,m_resolution) + m_offset) * m_gain ; - } -} diff --git a/src/Nazara/Noise/Abstract4DNoise.cpp b/src/Nazara/Noise/Abstract4DNoise.cpp deleted file mode 100644 index 44bde3b0f..000000000 --- a/src/Nazara/Noise/Abstract4DNoise.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - Abstract4DNoise::~Abstract4DNoise() = default; - - float Abstract4DNoise::GetBasicValue(float x, float y, float z, float w) - { - return this->GetValue(x,y,z,w,m_resolution); - } - - float Abstract4DNoise::GetMappedValue(float x, float y, float z, float w) - { - return (this->GetValue(x,y,z,w,m_resolution) + m_offset) * m_gain ; - } -} diff --git a/src/Nazara/Noise/ComplexNoiseBase.cpp b/src/Nazara/Noise/ComplexNoiseBase.cpp deleted file mode 100644 index c62ad8a8f..000000000 --- a/src/Nazara/Noise/ComplexNoiseBase.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - ComplexNoiseBase::ComplexNoiseBase() - { - m_parametersModified = true; - m_lacunarity = 5.0f; - m_hurst = 1.2f; - m_octaves = 3.0f; - - for (int i(0) ; i < m_octaves; ++i) - { - m_exponent_array[i] = 0; - } - } - - float ComplexNoiseBase::GetLacunarity() const - { - - return m_lacunarity; - } - - float ComplexNoiseBase::GetHurstParameter() const - { - return m_hurst; - } - - float ComplexNoiseBase::GetOctaveNumber() const - { - return m_octaves; - } - - void ComplexNoiseBase::SetLacunarity(float lacunarity) - { - m_lacunarity = lacunarity; - m_parametersModified = true; - - } - - void ComplexNoiseBase::SetHurstParameter(float h) - { - m_hurst = h; - m_parametersModified = true; - } - - void ComplexNoiseBase::SetOctavesNumber(float octaves) - { - if(octaves <= 30.0f) - m_octaves = octaves; - else - m_octaves = 30.0f; - - m_parametersModified = true; - } - - void ComplexNoiseBase::RecomputeExponentArray() - { - if(m_parametersModified) - { - float frequency = 1.0; - m_sum = 0.f; - for (int i(0) ; i < static_cast(m_octaves) ; ++i) - { - - m_exponent_array[i] = std::pow( frequency, -m_hurst ); - frequency *= m_lacunarity; - - m_sum += m_exponent_array[i]; - - } - m_parametersModified = false; - } - } -} diff --git a/src/Nazara/Noise/FBM.cpp b/src/Nazara/Noise/FBM.cpp new file mode 100644 index 000000000..f61bf8f44 --- /dev/null +++ b/src/Nazara/Noise/FBM.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + FBM::FBM(const NoiseBase & source): m_source(source) + { + } + + float FBM::Get(std::initializer_list coordinates, float scale) const + { + float value = 0.0; + + for(int i(0); i < m_octaves; ++i) + { + value += m_source.Get(coordinates,scale) * m_exponent_array.at(i); + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if(std::fabs(remainder) > 0.01f) + value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum; + } +} diff --git a/src/Nazara/Noise/FBM2D.cpp b/src/Nazara/Noise/FBM2D.cpp deleted file mode 100644 index 5a4670b80..000000000 --- a/src/Nazara/Noise/FBM2D.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - FBM2D::FBM2D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin2D(); - break; - - default: - m_source = new Simplex2D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float FBM2D::GetValue(float x, float y, float resolution) - { - this->RecomputeExponentArray(); - - m_value = 0.0; - - for (int i(0); i < m_octaves; ++i) - { - m_value += m_source->GetValue(x,y,resolution) * m_exponent_array[i]; - resolution *= m_lacunarity; - } - m_remainder = m_octaves - static_cast(m_octaves); - - if(!NumberEquals(m_remainder, static_cast(0.0))) - m_value += m_remainder * m_source->GetValue(x,y,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum; - } - - FBM2D::~FBM2D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/FBM3D.cpp b/src/Nazara/Noise/FBM3D.cpp deleted file mode 100644 index f0ee6143e..000000000 --- a/src/Nazara/Noise/FBM3D.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - FBM3D::FBM3D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin3D(); - break; - - default: - m_source = new Simplex3D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float FBM3D::GetValue(float x, float y, float z, float resolution) - { - this->RecomputeExponentArray(); - - m_value = 0.0; - - for (int i(0); i < m_octaves; ++i) - { - m_value += m_source->GetValue(x,y,z,resolution) * m_exponent_array[i]; - resolution *= m_lacunarity; - } - m_remainder = m_octaves - static_cast(m_octaves); - - if(!NumberEquals(m_remainder, static_cast(0.0))) - m_value += m_remainder * m_source->GetValue(x,y,z,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum; - } - - FBM3D::~FBM3D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/FBM4D.cpp b/src/Nazara/Noise/FBM4D.cpp deleted file mode 100644 index dace704d7..000000000 --- a/src/Nazara/Noise/FBM4D.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - FBM4D::FBM4D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin4D(); - break; - - default: - m_source = new Simplex4D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float FBM4D::GetValue(float x, float y, float z, float w, float resolution) - { - this->RecomputeExponentArray(); - - m_value = 0.0; - - for (int i(0); i < m_octaves; ++i) - { - m_value += m_source->GetValue(x,y,z,w,resolution) * m_exponent_array[i]; - resolution *= m_lacunarity; - } - m_remainder = m_octaves - static_cast(m_octaves); - - if(!NumberEquals(m_remainder, static_cast(0.0))) - m_value += m_remainder * m_source->GetValue(x,y,z,w,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum; - } - - FBM4D::~FBM4D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/HybridMultiFractal.cpp b/src/Nazara/Noise/HybridMultiFractal.cpp new file mode 100644 index 000000000..3f20809d3 --- /dev/null +++ b/src/Nazara/Noise/HybridMultiFractal.cpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + HybridMultiFractal::HybridMultiFractal(const NoiseBase & source) : + m_source(source) + { + } + + float HybridMultiFractal::Get(std::initializer_list coordinates, float scale) const + { + float offset = 1.0f; + float value = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(0); + float weight = value; + float signal = 0.f; + + scale *= m_lacunarity; + + for(int i(1) ; i < m_octaves; ++i) + { + if (weight > 1.f) + weight = 1.f; + + signal = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(i); + value += weight * signal; + weight *= signal; + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if (remainder > 0.f) + value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum - offset; + } +} diff --git a/src/Nazara/Noise/HybridMultiFractal3D.cpp b/src/Nazara/Noise/HybridMultiFractal3D.cpp deleted file mode 100644 index e97ce3497..000000000 --- a/src/Nazara/Noise/HybridMultiFractal3D.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HybridMultiFractal3D::HybridMultiFractal3D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin3D(); - break; - - default: - m_source = new Simplex3D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float HybridMultiFractal3D::GetValue(float x, float y, float z, float resolution) - { - this->RecomputeExponentArray(); - - m_offset = 1.0f; - - m_value = (m_source->GetValue(x,y,z,resolution) + m_offset) * m_exponent_array[0]; - m_weight = m_value; - m_signal = 0.f; - - resolution *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (m_weight > 1.f) - m_weight = 1.f; - - m_signal = (m_source->GetValue(x,y,z,resolution) + m_offset) * m_exponent_array[i]; - m_value += m_weight * m_signal; - - m_weight *= m_signal; - - resolution *= m_lacunarity; - } - - m_remainder = m_octaves - static_cast(m_octaves); - if (m_remainder > 0.f) - m_value += m_remainder * m_source->GetValue(x,y,z,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum - m_offset; - } - - HybridMultiFractal3D::~HybridMultiFractal3D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/HybridMultiFractal4D.cpp b/src/Nazara/Noise/HybridMultiFractal4D.cpp deleted file mode 100644 index 06ddf87a1..000000000 --- a/src/Nazara/Noise/HybridMultiFractal4D.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HybridMultiFractal4D::HybridMultiFractal4D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin4D(); - break; - - default: - m_source = new Simplex4D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float HybridMultiFractal4D::GetValue(float x, float y, float z, float w, float resolution) - { - this->RecomputeExponentArray(); - - m_offset = 1.0f; - - m_value = (m_source->GetValue(x,y,z,w,resolution) + m_offset) * m_exponent_array[0]; - m_weight = m_value; - m_signal = 0.f; - - resolution *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (m_weight > 1.f) - m_weight = 1.f; - - m_signal = (m_source->GetValue(x,y,z,w,resolution) + m_offset) * m_exponent_array[i]; - m_value += m_weight * m_signal; - - m_weight *= m_signal; - - resolution *= m_lacunarity; - } - - m_remainder = m_octaves - static_cast(m_octaves); - if (m_remainder > 0.f) - m_value += m_remainder * m_source->GetValue(x,y,z,w,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum - m_offset; - } - - HybridMultiFractal4D::~HybridMultiFractal4D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/HybridMultifractal2D.cpp b/src/Nazara/Noise/HybridMultifractal2D.cpp deleted file mode 100644 index 007ff78d0..000000000 --- a/src/Nazara/Noise/HybridMultifractal2D.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HybridMultiFractal2D::HybridMultiFractal2D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin2D(); - break; - - default: - m_source = new Simplex2D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float HybridMultiFractal2D::GetValue(float x, float y, float resolution) - { - this->RecomputeExponentArray(); - - m_offset = 1.0f; - - m_value = (m_source->GetValue(x,y,resolution) + m_offset) * m_exponent_array[0]; - m_weight = m_value; - m_signal = 0.f; - - resolution *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (m_weight > 1.f) - m_weight = 1.f; - - m_signal = (m_source->GetValue(x,y,resolution) + m_offset) * m_exponent_array[i]; - m_value += m_weight * m_signal; - - m_weight *= m_signal; - - resolution *= m_lacunarity; - } - - m_remainder = m_octaves - static_cast(m_octaves); - if (m_remainder > 0.f) - m_value += m_remainder * m_source->GetValue(x,y,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum - m_offset; - } - - HybridMultiFractal2D::~HybridMultiFractal2D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/MappedNoiseBase.cpp b/src/Nazara/Noise/MappedNoiseBase.cpp deleted file mode 100644 index 77d8e0eb3..000000000 --- a/src/Nazara/Noise/MappedNoiseBase.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - MappedNoiseBase::MappedNoiseBase() : m_gain(1.f), m_offset(0.f), m_resolution(30.f) - { - - } - - float MappedNoiseBase::GetGain() const - { - return m_gain; - } - - float MappedNoiseBase::GetOffset() const - { - return m_offset; - } - - float MappedNoiseBase::GetResolution() const - { - return m_resolution; - } - - void MappedNoiseBase::SetGain(float gain) - { - m_gain = gain; - } - - void MappedNoiseBase::SetOffset(float offset) - { - m_offset = offset; - } - - void MappedNoiseBase::SetResolution(float resolution) - { - if (NumberEquals(resolution, 0.f)) - { - StringStream ss; - ss << __FILE__ << ':' << __LINE__ << " : resolution cannot be 0.0f"; - - throw std::domain_error(ss.ToString()); - } - m_resolution = resolution; - } -} diff --git a/src/Nazara/Noise/MixerBase.cpp b/src/Nazara/Noise/MixerBase.cpp new file mode 100644 index 000000000..d3dd82acc --- /dev/null +++ b/src/Nazara/Noise/MixerBase.cpp @@ -0,0 +1,56 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + MixerBase::MixerBase() : + m_hurst(1.2f), + m_lacunarity(5.f), + m_octaves(3.f) + { + Recompute(); + } + + float MixerBase::GetHurstParameter() const + { + return m_hurst; + } + + float MixerBase::GetLacunarity() const + { + return m_lacunarity; + } + + float MixerBase::GetOctaveNumber() const + { + return m_octaves; + } + + void MixerBase::SetParameters(float hurst, float lacunarity, float octaves) + { + m_hurst = hurst; + m_lacunarity = lacunarity; + m_octaves = octaves; + + Recompute(); + } + + void MixerBase::Recompute() + { + float frequency = 1.0; + m_sum = 0.f; + m_exponent_array.clear(); + + for (int i(0) ; i < static_cast(m_octaves) ; ++i) + { + m_exponent_array.push_back(std::pow( frequency, -m_hurst )); + frequency *= m_lacunarity; + m_sum += m_exponent_array.at(i); + } + } +} diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp index 550579227..0cbee9eec 100644 --- a/src/Nazara/Noise/NoiseBase.cpp +++ b/src/Nazara/Noise/NoiseBase.cpp @@ -1,43 +1,37 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include -#include #include namespace Nz { NoiseBase::NoiseBase(unsigned int seed) { - Ua = 16807; - Uc = 0; - Um = 2147483647; - UcurrentSeed = 0; - Uprevious = 0; + SetSeed(seed); + m_scale = 0.05f; - SetNewSeed(seed); - - for(int i(0) ; i < 512 ; i++) + for(unsigned int i(0) ; i < 512; ++i) perm[i] = i & 255; - } - void NoiseBase::SetNewSeed(unsigned int seed) + float NoiseBase::GetScale() { - Uprevious = seed; - UcurrentSeed = seed; + return m_scale; } - unsigned int NoiseBase::GetUniformRandomValue() + void NoiseBase::SetScale(float scale) { - Ulast = Ua*Uprevious + Uc%Um; - Uprevious = Ulast; - return Ulast; + m_scale = scale; } - void NoiseBase::ShufflePermutationTable() + void NoiseBase::SetSeed(unsigned int seed) + { + generator.seed(seed); + } + + void NoiseBase::Shuffle() { int xchanger; unsigned int ncase; @@ -45,35 +39,21 @@ namespace Nz for(unsigned int i(0) ; i < 256 ; i++) perm[i] = i; - for(unsigned int j(0) ; j < 20 ; ++j) - for (unsigned int i(0); i < 256 ; ++i) - { - ncase = this->GetUniformRandomValue() & 255; - xchanger = perm[i]; - perm[i] = perm[ncase]; - perm[ncase] = xchanger; - } + for (unsigned int i(0); i < 256 ; ++i) + { + ncase = generator() & 255; + xchanger = perm[i]; + perm[i] = perm[ncase]; + perm[ncase] = xchanger; + } for(unsigned int i(256) ; i < 512; ++i) perm[i] = perm[i & 255]; } - int NoiseBase::fastfloor(float n) + void NoiseBase::Shuffle(unsigned int amount) { - return (n >= 0) ? static_cast(n) : static_cast(n-1); - } - - int NoiseBase::JenkinsHash(int a, int b, int c) - { - a = a-b; a = a - c; a = a^(static_cast(c) >> 13); - b = b-c; b = b - a; b = b^(a << 8); - c = c-a; c = c - b; c = c^(static_cast(b) >> 13); - a = a-b; a = a - c; a = a^(static_cast(c) >> 12); - b = b-c; b = b - a; b = b^(a << 16); - c = c-a; c = c - b; c = c^(static_cast(b) >> 5); - a = a-b; a = a - c; a = a^(static_cast(c) >> 3); - b = b-c; b = b - a; b = b^(a << 10); - c = c-a; c = c - b; c = c^(static_cast(b) >> 15); - return c; + for(unsigned int j(0) ; j < amount ; ++j) + Shuffle(); } } diff --git a/src/Nazara/Noise/NoiseTools.cpp b/src/Nazara/Noise/NoiseTools.cpp new file mode 100644 index 000000000..9cf6efd39 --- /dev/null +++ b/src/Nazara/Noise/NoiseTools.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + int fastfloor(float n) + { + return (n >= 0) ? static_cast(n) : static_cast(n-1); + } + + int JenkinsHash(int a, int b, int c) + { + a = a-b; a = a - c; a = a^(static_cast(c) >> 13); + b = b-c; b = b - a; b = b^(a << 8); + c = c-a; c = c - b; c = c^(static_cast(b) >> 13); + a = a-b; a = a - c; a = a^(static_cast(c) >> 12); + b = b-c; b = b - a; b = b^(a << 16); + c = c-a; c = c - b; c = c^(static_cast(b) >> 5); + a = a-b; a = a - c; a = a^(static_cast(c) >> 3); + b = b-c; b = b - a; b = b^(a << 10); + c = c-a; c = c - b; c = c^(static_cast(b) >> 15); + return c; + } +} diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp new file mode 100644 index 000000000..f184702de --- /dev/null +++ b/src/Nazara/Noise/Perlin.cpp @@ -0,0 +1,325 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + Perlin::Perlin() : + gradient2{ + {1.f,1.f},{-1.f,1.f},{1.f,-1.f},{-1.f,-1.f}, + {1.f,0.f},{-1.f,0.f},{0.f,1.f},{0.f,-1.f} + }, + gradient3{ + {1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}, + {1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1}, + {0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}, + {1,1,0},{-1,1,0},{0,-1,1},{0,-1,-1} + }, + gradient4{ + {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, + {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, + {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, + {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, + {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, + {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, + {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, + {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} + } + { + + } + + Perlin::Perlin(unsigned int seed) : Perlin() + { + SetSeed(seed); + Shuffle(); + } + + float Perlin::Get(std::initializer_list coordinates, float scale) const + { + switch(coordinates.size()) + { + case 2: + return this->_2D(coordinates,scale); + case 3: + return this->_3D(coordinates,scale); + case 4: + return this->_4D(coordinates,scale); + default: + throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + } + } + + float Perlin::_2D(std::initializer_list coordinates, float scale) const + { + thread_local float xc, yc; + thread_local int x0, y0; + thread_local int gi0,gi1,gi2,gi3; + thread_local int ii, jj; + + thread_local float s,t,u,v; + thread_local float Cx,Cy; + thread_local float Li1, Li2; + thread_local float tempx,tempy; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + + ii = x0 & 255; + jj = y0 & 255; + + gi0 = perm[ii + perm[jj]] & 7; + gi1 = perm[ii + 1 + perm[jj]] & 7; + gi2 = perm[ii + perm[jj + 1]] & 7; + gi3 = perm[ii + 1 + perm[jj + 1]] & 7; + + tempx = xc - x0; + tempy = yc - y0; + + Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); + Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); + + s = gradient2[gi0][0]*tempx + gradient2[gi0][1]*tempy; + + tempx = xc - (x0 + 1); + t = gradient2[gi1][0]*tempx + gradient2[gi1][1]*tempy; + + tempy = yc - (y0 + 1); + v = gradient2[gi3][0]*tempx + gradient2[gi3][1]*tempy; + + tempx = xc - x0; + u = gradient2[gi2][0]*tempx + gradient2[gi2][1]*tempy; + + Li1 = s + Cx*(t-s); + Li2 = u + Cx*(v-u); + + return Li1 + Cy*(Li2-Li1); + } + + float Perlin::_3D(std::initializer_list coordinates, float scale) const + { + thread_local float xc, yc, zc; + thread_local int x0, y0, z0; + thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; + thread_local int ii, jj, kk; + + thread_local float Li1,Li2,Li3,Li4,Li5,Li6; + thread_local float s[2],t[2],u[2],v[2]; + thread_local float Cx,Cy,Cz; + thread_local float nx,ny,nz; + + thread_local float tmp; + thread_local float tempx,tempy,tempz; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + zc = *(++it) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + z0 = fastfloor(zc); + + ii = x0 & 255; + jj = y0 & 255; + kk = z0 & 255; + + gi0 = perm[ii + perm[jj + perm[kk]]] & 15; + gi1 = perm[ii + 1 + perm[jj + perm[kk]]] & 15; + gi2 = perm[ii + perm[jj + 1 + perm[kk]]] & 15; + gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk]]] & 15; + + gi4 = perm[ii + perm[jj + perm[kk + 1]]] & 15; + gi5 = perm[ii + 1 + perm[jj + perm[kk + 1]]] & 15; + gi6 = perm[ii + perm[jj + 1 + perm[kk + 1]]] & 15; + gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1]]] & 15; + + tempx = xc - x0; + tempy = yc - y0; + tempz = zc - z0; + + Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); + Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); + Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); + + s[0] = gradient3[gi0][0]*tempx + gradient3[gi0][1]*tempy + gradient3[gi0][2]*tempz; + + tempx = xc - (x0 + 1); + t[0] = gradient3[gi1][0]*tempx + gradient3[gi1][1]*tempy + gradient3[gi1][2]*tempz; + + tempy = yc - (y0 + 1); + v[0] = gradient3[gi3][0]*tempx + gradient3[gi3][1]*tempy + gradient3[gi3][2]*tempz; + + tempx = xc - x0; + u[0] = gradient3[gi2][0]*tempx + gradient3[gi2][1]*tempy + gradient3[gi2][2]*tempz; + + tempy = yc - y0; + tempz = zc - (z0 + 1); + s[1] = gradient3[gi4][0]*tempx + gradient3[gi4][1]*tempy + gradient3[gi4][2]*tempz; + + tempx = xc - (x0 + 1); + t[1] = gradient3[gi5][0]*tempx + gradient3[gi5][1]*tempy + gradient3[gi5][2]*tempz; + + tempy = yc - (y0 + 1); + v[1] = gradient3[gi7][0]*tempx + gradient3[gi7][1]*tempy + gradient3[gi7][2]*tempz; + + tempx = xc - x0; + u[1] = gradient3[gi6][0]*tempx + gradient3[gi6][1]*tempy + gradient3[gi6][2]*tempz; + + Li1 = s[0] + Cx*(t[0]-s[0]); + Li2 = u[0] + Cx*(v[0]-u[0]); + Li3 = s[1] + Cx*(t[1]-s[1]); + Li4 = u[1] + Cx*(v[1]-u[1]); + + Li5 = Li1 + Cy * (Li2-Li1); + Li6 = Li3 + Cy * (Li4-Li3); + + return Li5 + Cz * (Li6-Li5); + } + + float Perlin::_4D(std::initializer_list coordinates, float scale) const + { + thread_local float xc,yc,zc,wc; + thread_local int x0,y0,z0,w0; + thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; + thread_local int ii,jj,kk,ll; + + thread_local float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; + thread_local float s[4],t[4],u[4],v[4]; + thread_local float Cx,Cy,Cz,Cw; + + thread_local float tmp; + thread_local float tempx,tempy,tempz,tempw; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + zc = *(++it) * scale; + wc = *(++it) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + z0 = fastfloor(zc); + w0 = fastfloor(wc); + + ii = x0 & 255; + jj = y0 & 255; + kk = z0 & 255; + ll = w0 & 255; + + gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; + gi1 = perm[ii + 1 + perm[jj + perm[kk + perm[ll]]]] & 31; + gi2 = perm[ii + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; + gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; + + gi4 = perm[ii + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; + gi5 = perm[ii + 1 + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; + gi6 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; + gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; + + gi8 = perm[ii + perm[jj + perm[kk + perm[ll + 1]]]] & 31; + gi9 = perm[ii + 1 + perm[jj + perm[kk + perm[ll + 1]]]] & 31; + gi10 = perm[ii + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; + gi11 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; + + gi12 = perm[ii + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi13 = perm[ii + 1 + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi14 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi15 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; + + tempx = xc - x0; + tempy = yc - y0; + tempz = zc - z0; + tempw = wc - w0; + + Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); + Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); + Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); + Cw = tempw * tempw * tempw * (tempw * (tempw * 6 - 15) + 10); + + s[0] = gradient4[gi0][0]*tempx + gradient4[gi0][1]*tempy + gradient4[gi0][2]*tempz + gradient4[gi0][3]*tempw; + + tempx = xc - (x0+1); + t[0] = gradient4[gi1][0]*tempx + gradient4[gi1][1]*tempy + gradient4[gi1][2]*tempz + gradient4[gi1][3]*tempw; + + tempy = yc - (y0+1); + v[0] = gradient4[gi3][0]*tempx + gradient4[gi3][1]*tempy + gradient4[gi3][2]*tempz + gradient4[gi3][3]*tempw; + + tempx = xc - x0; + u[0] = gradient4[gi2][0]*tempx + gradient4[gi2][1]*tempy + gradient4[gi2][2]*tempz + gradient4[gi2][3]*tempw; + + tempy = yc - y0; + tempz = zc - (z0+1); + s[1] = gradient4[gi4][0]*tempx + gradient4[gi4][1]*tempy + gradient4[gi4][2]*tempz + gradient4[gi4][3]*tempw; + + tempx = xc - (x0+1); + t[1] = gradient4[gi5][0]*tempx + gradient4[gi5][1]*tempy + gradient4[gi5][2]*tempz + gradient4[gi5][3]*tempw; + + tempy = yc - (y0+1); + v[1] = gradient4[gi7][0]*tempx + gradient4[gi7][1]*tempy + gradient4[gi7][2]*tempz + gradient4[gi7][3]*tempw; + + tempx = xc - x0; + u[1] = gradient4[gi6][0]*tempx + gradient4[gi6][1]*tempy + gradient4[gi6][2]*tempz + gradient4[gi6][3]*tempw; + + + tempy = yc - y0; + tempz = zc - z0; + tempw = wc - (w0+1); + s[2] = gradient4[gi8][0]*tempx + gradient4[gi8][1]*tempy + gradient4[gi8][2]*tempz + gradient4[gi8][3]*tempw; + + tempx = xc - (x0+1); + t[2] = gradient4[gi9][0]*tempx + gradient4[gi9][1]*tempy + gradient4[gi9][2]*tempz + gradient4[gi9][3]*tempw; + + tempy = yc - (y0+1); + v[2] = gradient4[gi11][0]*tempx + gradient4[gi11][1]*tempy + gradient4[gi11][2]*tempz + gradient4[gi11][3]*tempw; + + tempx = xc - x0; + u[2] = gradient4[gi10][0]*tempx + gradient4[gi10][1]*tempy + gradient4[gi10][2]*tempz + gradient4[gi10][3]*tempw; + + + tempy = yc - y0; + tempz = zc - (z0+1); + s[3] = gradient4[gi12][0]*tempx + gradient4[gi12][1]*tempy + gradient4[gi12][2]*tempz + gradient4[gi12][3]*tempw; + + tempx = xc - (x0+1); + t[3] = gradient4[gi13][0]*tempx + gradient4[gi13][1]*tempy + gradient4[gi13][2]*tempz + gradient4[gi13][3]*tempw; + + tempy = yc - (y0+1); + v[3] = gradient4[gi15][0]*tempx + gradient4[gi15][1]*tempy + gradient4[gi15][2]*tempz + gradient4[gi15][3]*tempw; + + tempx = xc - x0; + u[3] = gradient4[gi14][0]*tempx + gradient4[gi14][1]*tempy + gradient4[gi14][2]*tempz + gradient4[gi14][3]*tempw; + + Li1 = s[0] + Cx*(t[0]-s[0]); + Li2 = u[0] + Cx*(v[0]-u[0]); + Li3 = s[1] + Cx*(t[1]-s[1]); + Li4 = u[1] + Cx*(v[1]-u[1]); + Li5 = s[2] + Cx*(t[2]-s[2]); + Li6 = u[2] + Cx*(v[2]-u[2]); + Li7 = s[3] + Cx*(t[3]-s[3]); + Li8 = u[3] + Cx*(v[3]-u[3]); + + Li9 = Li1 + Cy*(Li2-Li1); + Li10 = Li3 + Cy*(Li4-Li3); + Li11 = Li5 + Cy*(Li6-Li5); + Li12 = Li7 + Cy*(Li8-Li7); + + Li13 = Li9 + Cz*(Li10-Li9); + Li14 = Li11 + Cz*(Li12-Li11); + + return Li13 + Cw*(Li14-Li13); + } +} diff --git a/src/Nazara/Noise/Perlin2D.cpp b/src/Nazara/Noise/Perlin2D.cpp deleted file mode 100644 index 1d26c01e2..000000000 --- a/src/Nazara/Noise/Perlin2D.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Perlin2D::Perlin2D() - { - float grad2Temp[][2] = { - {1.f,1.f}, - {-1.f,1.f}, - {1.f,-1.f}, - {-1.f,-1.f}, - - {1.f,0.f}, - {-1.f,0.f}, - {0.f,1.f}, - {0.f,-1.f} - }; - - for(int i(0) ; i < 8 ; ++i) - for(int j(0) ; j < 2 ; ++j) - gradient2[i][j] = grad2Temp[i][j]; - } - - Perlin2D::Perlin2D(unsigned int seed) : Perlin2D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Perlin2D::GetValue(float x, float y, float resolution) - { - x *= resolution; - y *= resolution; - - x0 = fastfloor(x); - y0 = fastfloor(y); - - ii = x0 & 255; - jj = y0 & 255; - - gi0 = perm[ii + perm[jj]] & 7; - gi1 = perm[ii + 1 + perm[jj]] & 7; - gi2 = perm[ii + perm[jj + 1]] & 7; - gi3 = perm[ii + 1 + perm[jj + 1]] & 7; - - temp.x = x-x0; - temp.y = y-y0; - - Cx = temp.x * temp.x * temp.x * (temp.x * (temp.x * 6 - 15) + 10); - Cy = temp.y * temp.y * temp.y * (temp.y * (temp.y * 6 - 15) + 10); - - s = gradient2[gi0][0]*temp.x + gradient2[gi0][1]*temp.y; - - temp.x = x-(x0+1); - t = gradient2[gi1][0]*temp.x + gradient2[gi1][1]*temp.y; - - temp.y = y-(y0+1); - v = gradient2[gi3][0]*temp.x + gradient2[gi3][1]*temp.y; - - temp.x = x-x0; - u = gradient2[gi2][0]*temp.x + gradient2[gi2][1]*temp.y; - - Li1 = s + Cx*(t-s); - Li2 = u + Cx*(v-u); - - return Li1 + Cy*(Li2-Li1); - } -} diff --git a/src/Nazara/Noise/Perlin3D.cpp b/src/Nazara/Noise/Perlin3D.cpp deleted file mode 100644 index 2e91154f6..000000000 --- a/src/Nazara/Noise/Perlin3D.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Perlin3D::Perlin3D() - { - float grad3Temp[][3] = { - {1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}, - {1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1}, - {0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}, - {1,1,0},{-1,1,0},{0,-1,1},{0,-1,-1} - }; - - for(int i(0) ; i < 16 ; ++i) - for(int j(0) ; j < 3 ; ++j) - gradient3[i][j] = grad3Temp[i][j]; - } - - Perlin3D::Perlin3D(unsigned int seed) : Perlin3D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Perlin3D::GetValue(float x, float y, float z, float resolution) - { - x /= resolution; - y /= resolution; - z /= resolution; - - x0 = fastfloor(x); - y0 = fastfloor(y); - z0 = fastfloor(z); - - ii = x0 & 255; - jj = y0 & 255; - kk = z0 & 255; - - gi0 = perm[ii + perm[jj + perm[kk]]] & 15; - gi1 = perm[ii + 1 + perm[jj + perm[kk]]] & 15; - gi2 = perm[ii + perm[jj + 1 + perm[kk]]] & 15; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk]]] & 15; - - gi4 = perm[ii + perm[jj + perm[kk + 1]]] & 15; - gi5 = perm[ii + 1 + perm[jj + perm[kk + 1]]] & 15; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1]]] & 15; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1]]] & 15; - - temp.x = x-x0; - temp.y = y-y0; - temp.z = z-z0; - - Cx = temp.x * temp.x * temp.x * (temp.x * (temp.x * 6 - 15) + 10); - Cy = temp.y * temp.y * temp.y * (temp.y * (temp.y * 6 - 15) + 10); - Cz = temp.z * temp.z * temp.z * (temp.z * (temp.z * 6 - 15) + 10); - - s[0] = gradient3[gi0][0]*temp.x + gradient3[gi0][1]*temp.y + gradient3[gi0][2]*temp.z; - - temp.x = x-(x0+1); - t[0] = gradient3[gi1][0]*temp.x + gradient3[gi1][1]*temp.y + gradient3[gi1][2]*temp.z; - - temp.y = y-(y0+1); - v[0] = gradient3[gi3][0]*temp.x + gradient3[gi3][1]*temp.y + gradient3[gi3][2]*temp.z; - - temp.x = x-x0; - u[0] = gradient3[gi2][0]*temp.x + gradient3[gi2][1]*temp.y + gradient3[gi2][2]*temp.z; - - temp.y = y-y0; - temp.z = z-(z0+1); - s[1] = gradient3[gi4][0]*temp.x + gradient3[gi4][1]*temp.y + gradient3[gi4][2]*temp.z; - - temp.x = x-(x0+1); - t[1] = gradient3[gi5][0]*temp.x + gradient3[gi5][1]*temp.y + gradient3[gi5][2]*temp.z; - - temp.y = y-(y0+1); - v[1] = gradient3[gi7][0]*temp.x + gradient3[gi7][1]*temp.y + gradient3[gi7][2]*temp.z; - - temp.x = x-x0; - u[1] = gradient3[gi6][0]*temp.x + gradient3[gi6][1]*temp.y + gradient3[gi6][2]*temp.z; - - Li1 = s[0] + Cx*(t[0]-s[0]); - Li2 = u[0] + Cx*(v[0]-u[0]); - Li3 = s[1] + Cx*(t[1]-s[1]); - Li4 = u[1] + Cx*(v[1]-u[1]); - - Li5 = Li1 + Cy*(Li2-Li1); - Li6 = Li3 + Cy*(Li4-Li3); - - return Li5 + Cz*(Li6-Li5); - } -} diff --git a/src/Nazara/Noise/Perlin4D.cpp b/src/Nazara/Noise/Perlin4D.cpp deleted file mode 100644 index b321616f6..000000000 --- a/src/Nazara/Noise/Perlin4D.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Perlin4D::Perlin4D() - { - float grad4Temp[][4] = - { - {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, - {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, - {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, - {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, - {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, - {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, - {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, - {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} - }; - - for(int i(0) ; i < 32 ; ++i) - for(int j(0) ; j < 4 ; ++j) - gradient4[i][j] = grad4Temp[i][j]; - } - - Perlin4D::Perlin4D(unsigned int seed) : Perlin4D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Perlin4D::GetValue(float x, float y, float z, float w, float resolution) - { - x *= resolution; - y *= resolution; - z *= resolution; - w *= resolution; - - x0 = fastfloor(x); - y0 = fastfloor(y); - z0 = fastfloor(z); - w0 = fastfloor(w); - - ii = x0 & 255; - jj = y0 & 255; - kk = z0 & 255; - ll = w0 & 255; - - gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; - gi1 = perm[ii + 1 + perm[jj + perm[kk + perm[ll]]]] & 31; - gi2 = perm[ii + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; - - gi4 = perm[ii + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi5 = perm[ii + 1 + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; - - gi8 = perm[ii + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi9 = perm[ii + 1 + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi10 = perm[ii + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; - gi11 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; - - gi12 = perm[ii + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi13 = perm[ii + 1 + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi14 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi15 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; - - temp.x = x-x0; - temp.y = y-y0; - temp.z = z-z0; - temp.w = w-w0; - - Cx = temp.x * temp.x * temp.x * (temp.x * (temp.x * 6 - 15) + 10); - Cy = temp.y * temp.y * temp.y * (temp.y * (temp.y * 6 - 15) + 10); - Cz = temp.z * temp.z * temp.z * (temp.z * (temp.z * 6 - 15) + 10); - Cw = temp.w * temp.w * temp.w * (temp.w * (temp.w * 6 - 15) + 10); - - s[0] = gradient4[gi0][0]*temp.x + gradient4[gi0][1]*temp.y + gradient4[gi0][2]*temp.z + gradient4[gi0][3]*temp.w; - - temp.x = x-(x0+1); - t[0] = gradient4[gi1][0]*temp.x + gradient4[gi1][1]*temp.y + gradient4[gi1][2]*temp.z + gradient4[gi1][3]*temp.w; - - temp.y = y-(y0+1); - v[0] = gradient4[gi3][0]*temp.x + gradient4[gi3][1]*temp.y + gradient4[gi3][2]*temp.z + gradient4[gi3][3]*temp.w; - - temp.x = x-x0; - u[0] = gradient4[gi2][0]*temp.x + gradient4[gi2][1]*temp.y + gradient4[gi2][2]*temp.z + gradient4[gi2][3]*temp.w; - - temp.y = y-y0; - temp.z = z-(z0+1); - s[1] = gradient4[gi4][0]*temp.x + gradient4[gi4][1]*temp.y + gradient4[gi4][2]*temp.z + gradient4[gi4][3]*temp.w; - - temp.x = x-(x0+1); - t[1] = gradient4[gi5][0]*temp.x + gradient4[gi5][1]*temp.y + gradient4[gi5][2]*temp.z + gradient4[gi5][3]*temp.w; - - temp.y = y-(y0+1); - v[1] = gradient4[gi7][0]*temp.x + gradient4[gi7][1]*temp.y + gradient4[gi7][2]*temp.z + gradient4[gi7][3]*temp.w; - - temp.x = x-x0; - u[1] = gradient4[gi6][0]*temp.x + gradient4[gi6][1]*temp.y + gradient4[gi6][2]*temp.z + gradient4[gi6][3]*temp.w; - - - temp.y = y-y0; - temp.z = z-z0; - temp.w = w-(w0+1); - s[2] = gradient4[gi8][0]*temp.x + gradient4[gi8][1]*temp.y + gradient4[gi8][2]*temp.z + gradient4[gi8][3]*temp.w; - - temp.x = x-(x0+1); - t[2] = gradient4[gi9][0]*temp.x + gradient4[gi9][1]*temp.y + gradient4[gi9][2]*temp.z + gradient4[gi9][3]*temp.w; - - temp.y = y-(y0+1); - v[2] = gradient4[gi11][0]*temp.x + gradient4[gi11][1]*temp.y + gradient4[gi11][2]*temp.z + gradient4[gi11][3]*temp.w; - - temp.x = x-x0; - u[2] = gradient4[gi10][0]*temp.x + gradient4[gi10][1]*temp.y + gradient4[gi10][2]*temp.z + gradient4[gi10][3]*temp.w; - - - temp.y = y-y0; - temp.z = z-(z0+1); - s[3] = gradient4[gi12][0]*temp.x + gradient4[gi12][1]*temp.y + gradient4[gi12][2]*temp.z + gradient4[gi12][3]*temp.w; - - temp.x = x-(x0+1); - t[3] = gradient4[gi13][0]*temp.x + gradient4[gi13][1]*temp.y + gradient4[gi13][2]*temp.z + gradient4[gi13][3]*temp.w; - - temp.y = y-(y0+1); - v[3] = gradient4[gi15][0]*temp.x + gradient4[gi15][1]*temp.y + gradient4[gi15][2]*temp.z + gradient4[gi15][3]*temp.w; - - temp.x = x-x0; - u[3] = gradient4[gi14][0]*temp.x + gradient4[gi14][1]*temp.y + gradient4[gi14][2]*temp.z + gradient4[gi14][3]*temp.w; - - Li1 = s[0] + Cx*(t[0]-s[0]); - Li2 = u[0] + Cx*(v[0]-u[0]); - Li3 = s[1] + Cx*(t[1]-s[1]); - Li4 = u[1] + Cx*(v[1]-u[1]); - Li5 = s[2] + Cx*(t[2]-s[2]); - Li6 = u[2] + Cx*(v[2]-u[2]); - Li7 = s[3] + Cx*(t[3]-s[3]); - Li8 = u[3] + Cx*(v[3]-u[3]); - - Li9 = Li1 + Cy*(Li2-Li1); - Li10 = Li3 + Cy*(Li4-Li3); - Li11 = Li5 + Cy*(Li6-Li5); - Li12 = Li7 + Cy*(Li8-Li7); - - Li13 = Li9 + Cz*(Li10-Li9); - Li14 = Li11 + Cz*(Li12-Li11); - - return Li13 + Cw*(Li14-Li13); - } -} diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp new file mode 100644 index 000000000..c93a226d4 --- /dev/null +++ b/src/Nazara/Noise/Simplex.cpp @@ -0,0 +1,459 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + Simplex::Simplex() : + gradient2{ + {1,1},{-1,1},{1,-1},{-1,-1}, + {1,0},{-1,0},{0,1},{0,-1} + }, + gradient3{ + {1.f,1.f,0.f},{-1.f,1.f,0.f},{1.f,-1.f,0.f},{-1.f,-1.f,0.f}, + {1.f,0.f,1.f},{-1.f,0.f,1.f},{1.f,0.f,-1.f},{-1.f,0.f,-1.f}, + {0.f,1.f,1.f},{0.f,-1.f,1.f},{0.f,1.f,-1.f},{0.f,-1.f,-1.f} + }, + gradient4{ + {0.f,1.f,1.f,1.f}, {0.f,1.f,1.f,-1.f}, {0.f,1.f,-1.f,1.f}, {0.f,1.f,-1.f,-1.f}, + {0.f,-1.f,1.f,1.f},{0.f,-1.f,1.f,-1.f},{0.f,-1.f,-1.f,1.f},{0.f,-1.f,-1.f,-1.f}, + {1.f,0.f,1.f,1.f}, {1.f,0.f,1.f,-1.f}, {1.f,0.f,-1.f,1.f}, {1.f,0.f,-1.f,-1.f}, + {-1.f,0.f,1.f,1.f},{-1.f,0.f,1.f,-1.f},{-1.f,0.f,-1.f,1.f},{-1.f,0.f,-1.f,-1.f}, + {1.f,1.f,0.f,1.f}, {1.f,1.f,0.f,-1.f}, {1.f,-1.f,0.f,1.f}, {1.f,-1.f,0.f,-1.f}, + {-1.f,1.f,0.f,1.f},{-1.f,1.f,0.f,-1.f},{-1.f,-1.f,0.f,1.f},{-1.f,-1.f,0.f,-1.f}, + {1.f,1.f,1.f,0.f}, {1.f,1.f,-1.f,0.f}, {1.f,-1.f,1.f,0.f}, {1.f,-1.f,-1.f,0.f}, + {-1.f,1.f,1.f,0.f},{-1.f,1.f,-1.f,0.f},{-1.f,-1.f,1.f,0.f},{-1.f,-1.f,-1.f,0.f} + }, + lookupTable4D{ + {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, + {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, + {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, + {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, + {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, + {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, + {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, + {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0} + }, + SkewCoeff2D (0.5f*(std::sqrt(3.f) - 1.f)), + UnskewCoeff2D((3.f-std::sqrt(3.f))/6.f), + SkewCoeff3D (1/3.f), + UnskewCoeff3D (1/6.f), + SkewCoeff4D ((std::sqrt(5.f) - 1.f)/4.f), + UnskewCoeff4D ((5.f - std::sqrt(5.f))/20.f) + { + + } + + Simplex::Simplex(unsigned int seed) : Simplex() + { + SetSeed(seed); + Shuffle(); + } + + float Simplex::Get(std::initializer_list coordinates, float scale) const + { + switch(coordinates.size()) + { + case 2: + return this->_2D(coordinates,scale); + case 3: + return this->_3D(coordinates,scale); + case 4: + return this->_4D(coordinates,scale); + default: + throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + } + } + + float Simplex::_2D(std::initializer_list coordinates, float scale) const + { + thread_local float xc,yc; + thread_local int ii,jj; + thread_local int gi0,gi1,gi2; + thread_local int skewedCubeOriginx,skewedCubeOriginy; + thread_local int off1x,off1y; + thread_local float n1,n2,n3; + thread_local float c1,c2,c3; + thread_local float sum; + thread_local float unskewedCubeOriginx,unskewedCubeOriginy; + thread_local float unskewedDistToOriginx,unskewedDistToOriginy; + thread_local float d1x,d1y; + thread_local float d2x,d2y; + thread_local float d3x,d3y; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + + sum = (xc + yc) * SkewCoeff2D; + skewedCubeOriginx = fastfloor(xc + sum); + skewedCubeOriginy = fastfloor(yc + sum); + + sum = (skewedCubeOriginx + skewedCubeOriginy) * UnskewCoeff2D; + unskewedCubeOriginx = skewedCubeOriginx - sum; + unskewedCubeOriginy = skewedCubeOriginy - sum; + + unskewedDistToOriginx = xc - unskewedCubeOriginx;// Difference with 3d and 4d + unskewedDistToOriginy = yc - unskewedCubeOriginy; + + if(unskewedDistToOriginx > unskewedDistToOriginy) + { + off1x = 1; + off1y = 0; + } + else + { + off1x = 0; + off1y = 1; + } + + d1x = - unskewedDistToOriginx; + d1y = - unskewedDistToOriginy; + + d2x = d1x + off1x - UnskewCoeff2D; + d2y = d1y + off1y - UnskewCoeff2D; + + d3x = d1x + 1.f - 2.f * UnskewCoeff2D; + d3y = d1y + 1.f - 2.f * UnskewCoeff2D; + + ii = skewedCubeOriginx & 255; + jj = skewedCubeOriginy & 255; + + gi0 = perm[ii + perm[jj ]] & 7; + gi1 = perm[ii + off1x + perm[jj + off1y ]] & 7; + gi2 = perm[ii + 1 + perm[jj + 1 ]] & 7; + + c1 = 0.5f - d1x * d1x - d1y * d1y; + c2 = 0.5f - d2x * d2x - d2y * d2y; + c3 = 0.5f - d3x * d3x - d3y * d3y; + + if(c1 < 0) + n1 = 0; + else + n1 = c1*c1*c1*c1*(gradient2[gi0][0] * d1x + gradient2[gi0][1] * d1y); + + if(c2 < 0) + n2 = 0; + else + n2 = c2*c2*c2*c2*(gradient2[gi1][0] * d2x + gradient2[gi1][1] * d2y); + + if(c3 < 0) + n3 = 0; + else + n3 = c3*c3*c3*c3*(gradient2[gi2][0] * d3x + gradient2[gi2][1] * d3y); + + return (n1+n2+n3)*70.f; + } + + float Simplex::_3D(std::initializer_list coordinates, float scale) const + { + thread_local float xc, yc, zc; + thread_local float x,y,z; + thread_local int ii,jj,kk; + thread_local int gi0,gi1,gi2,gi3; + thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz; + + thread_local int off1x,off1y,off1z; + thread_local int off2x,off2y,off2z; + thread_local float n1,n2,n3,n4; + thread_local float c1,c2,c3,c4; + + thread_local float sum; + thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz; + thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz; + thread_local float d1x,d1y,d1z; + thread_local float d2x,d2y,d2z; + thread_local float d3x,d3y,d3z; + thread_local float d4x,d4y,d4z; + + std::initializer_list::const_iterator it = coordinates.begin(); + + x = *(it ); + y = *(++it); + z = *(++it); + + xc = x * scale; + yc = y * scale; + zc = z * scale; + + sum = (xc + yc + zc) * SkewCoeff3D; + skewedCubeOriginx = fastfloor(xc + sum); + skewedCubeOriginy = fastfloor(yc + sum); + skewedCubeOriginz = fastfloor(zc + sum); + + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz) * UnskewCoeff3D; + unskewedCubeOriginx = skewedCubeOriginx - sum; + unskewedCubeOriginy = skewedCubeOriginy - sum; + unskewedCubeOriginz = skewedCubeOriginz - sum; + + unskewedDistToOriginx = xc - unskewedCubeOriginx; + unskewedDistToOriginy = yc - unskewedCubeOriginy; + unskewedDistToOriginz = zc - unskewedCubeOriginz; + + if(unskewedDistToOriginx >= unskewedDistToOriginy) + { + if(unskewedDistToOriginy >= unskewedDistToOriginz) + { + off1x = 1; + off1y = 0; + off1z = 0; + off2x = 1; + off2y = 1; + off2z = 0; + } + else if(unskewedDistToOriginx >= unskewedDistToOriginz) + { + off1x = 1; + off1y = 0; + off1z = 0; + off2x = 1; + off2y = 0; + off2z = 1; + } + else + { + off1x = 0; + off1y = 0; + off1z = 1; + off2x = 1; + off2y = 0; + off2z = 1; + } + } + else + { + if(unskewedDistToOriginy < unskewedDistToOriginz) + { + off1x = 0; + off1y = 0; + off1z = 1; + off2x = 0; + off2y = 1; + off2z = 1; + } + else if(unskewedDistToOriginx < unskewedDistToOriginz) + { + off1x = 0; + off1y = 1; + off1z = 0; + off2x = 0; + off2y = 1; + off2z = 1; + } + else + { + off1x = 0; + off1y = 1; + off1z = 0; + off2x = 1; + off2y = 1; + off2z = 0; + } + } + + d1x = unskewedDistToOriginx; + d1y = unskewedDistToOriginy; + d1z = unskewedDistToOriginz; + + d2x = d1x - off1x + UnskewCoeff3D; + d2y = d1y - off1y + UnskewCoeff3D; + d2z = d1z - off1z + UnskewCoeff3D; + + d3x = d1x - off2x + 2.f*UnskewCoeff3D; + d3y = d1y - off2y + 2.f*UnskewCoeff3D; + d3z = d1z - off2z + 2.f*UnskewCoeff3D; + + d4x = d1x - 1.f + 3.f*UnskewCoeff3D; + d4y = d1y - 1.f + 3.f*UnskewCoeff3D; + d4z = d1z - 1.f + 3.f*UnskewCoeff3D; + + ii = skewedCubeOriginx & 255; + jj = skewedCubeOriginy & 255; + kk = skewedCubeOriginz & 255; + + gi0 = perm[ii + perm[jj + perm[kk ]]] % 12; + gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z ]]] % 12; + gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z ]]] % 12; + gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 ]]] % 12; + + c1 = 0.6f - d1x * d1x - d1y * d1y - d1z * d1z; + c2 = 0.6f - d2x * d2x - d2y * d2y - d2z * d2z; + c3 = 0.6f - d3x * d3x - d3y * d3y - d3z * d3z; + c4 = 0.6f - d4x * d4x - d4y * d4y - d4z * d4z; + + if(c1 < 0) + n1 = 0; + else + n1 = c1*c1*c1*c1*(gradient3[gi0][0] * d1x + gradient3[gi0][1] * d1y + gradient3[gi0][2] * d1z); + + if(c2 < 0) + n2 = 0; + else + n2 = c2*c2*c2*c2*(gradient3[gi1][0] * d2x + gradient3[gi1][1] * d2y + gradient3[gi1][2] * d2z); + + if(c3 < 0) + n3 = 0; + else + n3 = c3*c3*c3*c3*(gradient3[gi2][0] * d3x + gradient3[gi2][1] * d3y + gradient3[gi2][2] * d3z); + + if(c4 < 0) + n4 = 0; + else + n4 = c4*c4*c4*c4*(gradient3[gi3][0] * d4x + gradient3[gi3][1] * d4y + gradient3[gi3][2] * d4z); + + return (n1+n2+n3+n4)*32; + } + + float Simplex::_4D(std::initializer_list coordinates, float scale) const + { + thread_local float xc,yc,zc,wc; + thread_local float x,y,z,w; + thread_local int ii,jj,kk,ll; + thread_local int gi0,gi1,gi2,gi3,gi4; + thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz,skewedCubeOriginw; + + thread_local int off1x,off1y,off1z,off1w; + thread_local int off2x,off2y,off2z,off2w; + thread_local int off3x,off3y,off3z,off3w; + + thread_local int c; + thread_local float n1,n2,n3,n4,n5; + thread_local float c1,c2,c3,c4,c5,c6; + + thread_local float sum; + thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; + thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz,unskewedDistToOriginw; + thread_local float d1x,d2x,d3x,d4x,d5x; + thread_local float d1y,d2y,d3y,d4y,d5y; + thread_local float d1z,d2z,d3z,d4z,d5z; + thread_local float d1w,d2w,d3w,d4w,d5w; + + std::initializer_list::const_iterator it = coordinates.begin(); + + x = *(it ); + y = *(++it); + z = *(++it); + w = *(++it); + + xc = x * scale; + yc = y * scale; + zc = z * scale; + wc = w * scale; + + sum = (xc + yc + zc + wc) * SkewCoeff4D; + skewedCubeOriginx = fastfloor(xc + sum); + skewedCubeOriginy = fastfloor(yc + sum); + skewedCubeOriginz = fastfloor(zc + sum); + skewedCubeOriginw = fastfloor(wc + sum); + + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz + skewedCubeOriginw) * UnskewCoeff4D; + unskewedCubeOriginx = skewedCubeOriginx - sum; + unskewedCubeOriginy = skewedCubeOriginy - sum; + unskewedCubeOriginz = skewedCubeOriginz - sum; + unskewedCubeOriginw = skewedCubeOriginw - sum; + + unskewedDistToOriginx = xc - unskewedCubeOriginx; + unskewedDistToOriginy = yc - unskewedCubeOriginy; + unskewedDistToOriginz = zc - unskewedCubeOriginz; + unskewedDistToOriginw = wc - unskewedCubeOriginw; + + c1 = (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0; + c2 = (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0; + c3 = (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0; + c4 = (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0; + c5 = (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0; + c6 = (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; + c = c1 + c2 + c3 + c4 + c5 + c6; + + off1x = lookupTable4D[c][0] >= 3 ? 1 : 0; + off1y = lookupTable4D[c][1] >= 3 ? 1 : 0; + off1z = lookupTable4D[c][2] >= 3 ? 1 : 0; + off1w = lookupTable4D[c][3] >= 3 ? 1 : 0; + + off2x = lookupTable4D[c][0] >= 2 ? 1 : 0; + off2y = lookupTable4D[c][1] >= 2 ? 1 : 0; + off2z = lookupTable4D[c][2] >= 2 ? 1 : 0; + off2w = lookupTable4D[c][3] >= 2 ? 1 : 0; + + off3x = lookupTable4D[c][0] >= 1 ? 1 : 0; + off3y = lookupTable4D[c][1] >= 1 ? 1 : 0; + off3z = lookupTable4D[c][2] >= 1 ? 1 : 0; + off3w = lookupTable4D[c][3] >= 1 ? 1 : 0; + + d1x = unskewedDistToOriginx; + d1y = unskewedDistToOriginy; + d1z = unskewedDistToOriginz; + d1w = unskewedDistToOriginw; + + d2x = d1x - off1x + UnskewCoeff4D; + d2y = d1y - off1y + UnskewCoeff4D; + d2z = d1z - off1z + UnskewCoeff4D; + d2w = d1w - off1w + UnskewCoeff4D; + + d3x = d1x - off2x + 2.f*UnskewCoeff4D; + d3y = d1y - off2y + 2.f*UnskewCoeff4D; + d3z = d1z - off2z + 2.f*UnskewCoeff4D; + d3w = d1w - off2w + 2.f*UnskewCoeff4D; + + d4x = d1x - off3x + 3.f*UnskewCoeff4D; + d4y = d1y - off3y + 3.f*UnskewCoeff4D; + d4z = d1z - off3z + 3.f*UnskewCoeff4D; + d4w = d1w - off3w + 3.f*UnskewCoeff4D; + + d5x = d1x - 1.f + 4*UnskewCoeff4D; + d5y = d1y - 1.f + 4*UnskewCoeff4D; + d5z = d1z - 1.f + 4*UnskewCoeff4D; + d5w = d1w - 1.f + 4*UnskewCoeff4D; + + ii = skewedCubeOriginx & 255; + jj = skewedCubeOriginy & 255; + kk = skewedCubeOriginz & 255; + ll = skewedCubeOriginw & 255; + + gi0 = perm[ii + perm[jj + perm[kk + perm[ll ]]]] & 31; + gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z + perm[ll + off1w]]]] & 31; + gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z + perm[ll + off2w]]]] & 31; + gi3 = perm[ii + off3x + perm[jj + off3y + perm[kk + off3z + perm[ll + off3w]]]] & 31; + gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1 ]]]] % 32; + + c1 = 0.6f - d1x*d1x - d1y*d1y - d1z*d1z - d1w*d1w; + c2 = 0.6f - d2x*d2x - d2y*d2y - d2z*d2z - d2w*d2w; + c3 = 0.6f - d3x*d3x - d3y*d3y - d3z*d3z - d3w*d3w; + c4 = 0.6f - d4x*d4x - d4y*d4y - d4z*d4z - d4w*d4w; + c5 = 0.6f - d5x*d5x - d5y*d5y - d5z*d5z - d5w*d5w; + + if(c1 < 0) + n1 = 0; + else + n1 = c1*c1*c1*c1*(gradient4[gi0][0]*d1x + gradient4[gi0][1]*d1y + gradient4[gi0][2]*d1z + gradient4[gi0][3]*d1w); + + if(c2 < 0) + n2 = 0; + else + n2 = c2*c2*c2*c2*(gradient4[gi1][0]*d2x + gradient4[gi1][1]*d2y + gradient4[gi1][2]*d2z + gradient4[gi1][3]*d2w); + + if(c3 < 0) + n3 = 0; + else + n3 = c3*c3*c3*c3*(gradient4[gi2][0]*d3x + gradient4[gi2][1]*d3y + gradient4[gi2][2]*d3z + gradient4[gi2][3]*d3w); + + if(c4 < 0) + n4 = 0; + else + n4 = c4*c4*c4*c4*(gradient4[gi3][0]*d4x + gradient4[gi3][1]*d4y + gradient4[gi3][2]*d4z + gradient4[gi3][3]*d4w); + + if(c5 < 0) + n5 = 0; + else + n5 = c5*c5*c5*c5*(gradient4[gi4][0]*d5x + gradient4[gi4][1]*d5y + gradient4[gi4][2]*d5z + gradient4[gi4][3]*d5w); + + return (n1+n2+n3+n4+n5)*27.f; + } +} diff --git a/src/Nazara/Noise/Simplex2D.cpp b/src/Nazara/Noise/Simplex2D.cpp deleted file mode 100644 index b5e50c996..000000000 --- a/src/Nazara/Noise/Simplex2D.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Simplex2D::Simplex2D() - { - float grad2Temp[][2] = {{1,1},{-1,1},{1,-1},{-1,-1}, - {1,0},{-1,0},{0,1},{0,-1}}; - - for(int i(0) ; i < 8 ; ++i) - for(int j(0) ; j < 2 ; ++j) - gradient2[i][j] = grad2Temp[i][j]; - - SkewCoeff2D = 0.5f*(std::sqrt(3.f) - 1.f); - UnskewCoeff2D = (3.f-std::sqrt(3.f))/6.f; - } - - Simplex2D::Simplex2D(unsigned int seed) : Simplex2D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Simplex2D::GetValue(float x, float y, float resolution) - { - x *= resolution; - y *= resolution; - - sum = (x + y) * SkewCoeff2D; - skewedCubeOrigin.x = fastfloor(x + sum); - skewedCubeOrigin.y = fastfloor(y + sum); - - sum = (skewedCubeOrigin.x + skewedCubeOrigin.y) * UnskewCoeff2D; - unskewedCubeOrigin.x = skewedCubeOrigin.x - sum; - unskewedCubeOrigin.y = skewedCubeOrigin.y - sum; - - unskewedDistToOrigin.x = x - unskewedCubeOrigin.x; - unskewedDistToOrigin.y = y - unskewedCubeOrigin.y; - - if(unskewedDistToOrigin.x > unskewedDistToOrigin.y) - { - off1.x = 1; - off1.y = 0; - } - else - { - off1.x = 0; - off1.y = 1; - } - - d1 = - unskewedDistToOrigin; - - d2.x = d1.x + off1.x - UnskewCoeff2D; - d2.y = d1.y + off1.y - UnskewCoeff2D; - - d3.x = d1.x + 1.f - 2.f * UnskewCoeff2D; - d3.y = d1.y + 1.f - 2.f * UnskewCoeff2D; - - ii = skewedCubeOrigin.x & 255; - jj = skewedCubeOrigin.y & 255; - - gi0 = perm[ii + perm[jj ]] & 7; - gi1 = perm[ii + off1.x + perm[jj + off1.y]] & 7; - gi2 = perm[ii + 1 + perm[jj + 1 ]] & 7; - - c1 = 0.5f - d1.x * d1.x - d1.y * d1.y; - c2 = 0.5f - d2.x * d2.x - d2.y * d2.y; - c3 = 0.5f - d3.x * d3.x - d3.y * d3.y; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient2[gi0][0] * d1.x + gradient2[gi0][1] * d1.y); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient2[gi1][0] * d2.x + gradient2[gi1][1] * d2.y); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient2[gi2][0] * d3.x + gradient2[gi2][1] * d3.y); - - return (n1+n2+n3)*70.f; - } -} diff --git a/src/Nazara/Noise/Simplex3D.cpp b/src/Nazara/Noise/Simplex3D.cpp deleted file mode 100644 index 5848f38ce..000000000 --- a/src/Nazara/Noise/Simplex3D.cpp +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Simplex3D::Simplex3D() - { - SkewCoeff3D = 1/3.f; - UnskewCoeff3D = 1/6.f; - - float grad3Temp[][3] = { - {1.f,1.f,0.f}, - {-1.f,1.f,0.f}, - {1.f,-1.f,0.f}, - {-1.f,-1.f,0.f}, - - {1.f,0.f,1.f}, - {-1.f,0.f,1.f}, - {1.f,0.f,-1.f}, - {-1.f,0.f,-1.f}, - - {0.f,1.f,1.f}, - {0.f,-1.f,1.f}, - {0.f,1.f,-1.f}, - {0.f,-1.f,-1.f} - }; - - for(int i(0) ; i < 12 ; ++i) - for(int j(0) ; j < 3 ; ++j) - gradient3[i][j] = grad3Temp[i][j]; - } - - Simplex3D::Simplex3D(unsigned int seed) : Simplex3D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Simplex3D::GetValue(float x, float y, float z, float resolution) - { - x *= resolution; - y *= resolution; - z *= resolution; - - sum = (x + y + z) * SkewCoeff3D; - skewedCubeOrigin.x = fastfloor(x + sum); - skewedCubeOrigin.y = fastfloor(y + sum); - skewedCubeOrigin.z = fastfloor(z + sum); - - sum = (skewedCubeOrigin.x + skewedCubeOrigin.y + skewedCubeOrigin.z) * UnskewCoeff3D; - unskewedCubeOrigin.x = skewedCubeOrigin.x - sum; - unskewedCubeOrigin.y = skewedCubeOrigin.y - sum; - unskewedCubeOrigin.z = skewedCubeOrigin.z - sum; - - unskewedDistToOrigin.x = x - unskewedCubeOrigin.x; - unskewedDistToOrigin.y = y - unskewedCubeOrigin.y; - unskewedDistToOrigin.z = z - unskewedCubeOrigin.z; - - if(unskewedDistToOrigin.x >= unskewedDistToOrigin.y) - { - if(unskewedDistToOrigin.y >= unskewedDistToOrigin.z) - { - off1.x = 1; - off1.y = 0; - off1.z = 0; - off2.x = 1; - off2.y = 1; - off2.z = 0; - } - else if(unskewedDistToOrigin.x >= unskewedDistToOrigin.z) - { - off1.x = 1; - off1.y = 0; - off1.z = 0; - off2.x = 1; - off2.y = 0; - off2.z = 1; - } - else - { - off1.x = 0; - off1.y = 0; - off1.z = 1; - off2.x = 1; - off2.y = 0; - off2.z = 1; - } - } - else - { - if(unskewedDistToOrigin.y < unskewedDistToOrigin.z) - { - off1.x = 0; - off1.y = 0; - off1.z = 1; - off2.x = 0; - off2.y = 1; - off2.z = 1; - } - else if(unskewedDistToOrigin.x < unskewedDistToOrigin.z) - { - off1.x = 0; - off1.y = 1; - off1.z = 0; - off2.x = 0; - off2.y = 1; - off2.z = 1; - } - else - { - off1.x = 0; - off1.y = 1; - off1.z = 0; - off2.x = 1; - off2.y = 1; - off2.z = 0; - } - } - - d1 = unskewedDistToOrigin; - - d2.x = d1.x - off1.x + UnskewCoeff3D; - d2.y = d1.y - off1.y + UnskewCoeff3D; - d2.z = d1.z - off1.z + UnskewCoeff3D; - - d3.x = d1.x - off2.x + 2.f*UnskewCoeff3D; - d3.y = d1.y - off2.y + 2.f*UnskewCoeff3D; - d3.z = d1.z - off2.z + 2.f*UnskewCoeff3D; - - d4.x = d1.x - 1.f + 3.f*UnskewCoeff3D; - d4.y = d1.y - 1.f + 3.f*UnskewCoeff3D; - d4.z = d1.z - 1.f + 3.f*UnskewCoeff3D; - - ii = skewedCubeOrigin.x & 255; - jj = skewedCubeOrigin.y & 255; - kk = skewedCubeOrigin.z & 255; - - gi0 = perm[ii + perm[jj + perm[kk ]]] % 12; - gi1 = perm[ii + off1.x + perm[jj + off1.y + perm[kk + off1.z]]] % 12; - gi2 = perm[ii + off2.x + perm[jj + off2.y + perm[kk + off2.z]]] % 12; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 ]]] % 12; - - c1 = 0.6f - d1.x * d1.x - d1.y * d1.y - d1.z * d1.z; - c2 = 0.6f - d2.x * d2.x - d2.y * d2.y - d2.z * d2.z; - c3 = 0.6f - d3.x * d3.x - d3.y * d3.y - d3.z * d3.z; - c4 = 0.6f - d4.x * d4.x - d4.y * d4.y - d4.z * d4.z; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient3[gi0][0] * d1.x + gradient3[gi0][1] * d1.y + gradient3[gi0][2] * d1.z); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient3[gi1][0] * d2.x + gradient3[gi1][1] * d2.y + gradient3[gi1][2] * d2.z); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient3[gi2][0] * d3.x + gradient3[gi2][1] * d3.y + gradient3[gi2][2] * d3.z); - - if(c4 < 0) - n4 = 0; - else - n4 = c4*c4*c4*c4*(gradient3[gi3][0] * d4.x + gradient3[gi3][1] * d4.y + gradient3[gi3][2] * d4.z); - - return (n1+n2+n3+n4)*32; - } -} diff --git a/src/Nazara/Noise/Simplex4D.cpp b/src/Nazara/Noise/Simplex4D.cpp deleted file mode 100644 index b515d5958..000000000 --- a/src/Nazara/Noise/Simplex4D.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Simplex4D::Simplex4D() - { - SkewCoeff4D = (std::sqrt(5.f) - 1.f)/4.f; - UnskewCoeff4D = (5.f - std::sqrt(5.f))/20.f; - - int lookupTemp4D[][4] = - { - {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, - {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, - {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, - {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0} - }; - - for(int i(0) ; i < 64 ; ++i) - for(int j(0) ; j < 4 ; ++j) - lookupTable4D[i][j] = lookupTemp4D[i][j]; - - float grad4Temp[][4] = - { - {0.f,1.f,1.f,1.f}, {0.f,1.f,1.f,-1.f}, {0.f,1.f,-1.f,1.f}, {0.f,1.f,-1.f,-1.f}, - {0.f,-1.f,1.f,1.f},{0.f,-1.f,1.f,-1.f},{0.f,-1.f,-1.f,1.f},{0.f,-1.f,-1.f,-1.f}, - {1.f,0.f,1.f,1.f}, {1.f,0.f,1.f,-1.f}, {1.f,0.f,-1.f,1.f}, {1.f,0.f,-1.f,-1.f}, - {-1.f,0.f,1.f,1.f},{-1.f,0.f,1.f,-1.f},{-1.f,0.f,-1.f,1.f},{-1.f,0.f,-1.f,-1.f}, - {1.f,1.f,0.f,1.f}, {1.f,1.f,0.f,-1.f}, {1.f,-1.f,0.f,1.f}, {1.f,-1.f,0.f,-1.f}, - {-1.f,1.f,0.f,1.f},{-1.f,1.f,0.f,-1.f},{-1.f,-1.f,0.f,1.f},{-1.f,-1.f,0.f,-1.f}, - {1.f,1.f,1.f,0.f}, {1.f,1.f,-1.f,0.f}, {1.f,-1.f,1.f,0.f}, {1.f,-1.f,-1.f,0.f}, - {-1.f,1.f,1.f,0.f},{-1.f,1.f,-1.f,0.f},{-1.f,-1.f,1.f,0.f},{-1.f,-1.f,-1.f,0.f} - }; - - for(int i(0) ; i < 32 ; ++i) - for(int j(0) ; j < 4 ; ++j) - gradient4[i][j] = grad4Temp[i][j]; - } - - Simplex4D::Simplex4D(unsigned int seed) : Simplex4D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Simplex4D::GetValue(float x, float y, float z, float w, float resolution) - { - x *= resolution; - y *= resolution; - z *= resolution; - w *= resolution; - - sum = (x + y + z + w) * SkewCoeff4D; - skewedCubeOrigin.x = fastfloor(x + sum); - skewedCubeOrigin.y = fastfloor(y + sum); - skewedCubeOrigin.z = fastfloor(z + sum); - skewedCubeOrigin.w = fastfloor(w + sum); - - sum = (skewedCubeOrigin.x + skewedCubeOrigin.y + skewedCubeOrigin.z + skewedCubeOrigin.w) * UnskewCoeff4D; - unskewedCubeOrigin.x = skewedCubeOrigin.x - sum; - unskewedCubeOrigin.y = skewedCubeOrigin.y - sum; - unskewedCubeOrigin.z = skewedCubeOrigin.z - sum; - unskewedCubeOrigin.w = skewedCubeOrigin.w - sum; - - unskewedDistToOrigin.x = x - unskewedCubeOrigin.x; - unskewedDistToOrigin.y = y - unskewedCubeOrigin.y; - unskewedDistToOrigin.z = z - unskewedCubeOrigin.z; - unskewedDistToOrigin.w = w - unskewedCubeOrigin.w; - - c1 = (unskewedDistToOrigin.x > unskewedDistToOrigin.y) ? 32 : 0; - c2 = (unskewedDistToOrigin.x > unskewedDistToOrigin.z) ? 16 : 0; - c3 = (unskewedDistToOrigin.y > unskewedDistToOrigin.z) ? 8 : 0; - c4 = (unskewedDistToOrigin.x > unskewedDistToOrigin.w) ? 4 : 0; - c5 = (unskewedDistToOrigin.y > unskewedDistToOrigin.w) ? 2 : 0; - c6 = (unskewedDistToOrigin.z > unskewedDistToOrigin.w) ? 1 : 0; - c = c1 + c2 + c3 + c4 + c5 + c6; - - off1.x = lookupTable4D[c][0] >= 3 ? 1 : 0; - off1.y = lookupTable4D[c][1] >= 3 ? 1 : 0; - off1.z = lookupTable4D[c][2] >= 3 ? 1 : 0; - off1.w = lookupTable4D[c][3] >= 3 ? 1 : 0; - - off2.x = lookupTable4D[c][0] >= 2 ? 1 : 0; - off2.y = lookupTable4D[c][1] >= 2 ? 1 : 0; - off2.z = lookupTable4D[c][2] >= 2 ? 1 : 0; - off2.w = lookupTable4D[c][3] >= 2 ? 1 : 0; - - off3.x = lookupTable4D[c][0] >= 1 ? 1 : 0; - off3.y = lookupTable4D[c][1] >= 1 ? 1 : 0; - off3.z = lookupTable4D[c][2] >= 1 ? 1 : 0; - off3.w = lookupTable4D[c][3] >= 1 ? 1 : 0; - - d1 = unskewedDistToOrigin; - - d2.x = d1.x - off1.x + UnskewCoeff4D; - d2.y = d1.y - off1.y + UnskewCoeff4D; - d2.z = d1.z - off1.z + UnskewCoeff4D; - d2.w = d1.w - off1.w + UnskewCoeff4D; - - d3.x = d1.x - off2.x + 2.f*UnskewCoeff4D; - d3.y = d1.y - off2.y + 2.f*UnskewCoeff4D; - d3.z = d1.z - off2.z + 2.f*UnskewCoeff4D; - d3.w = d1.w - off2.w + 2.f*UnskewCoeff4D; - - d4.x = d1.x - off3.x + 3.f*UnskewCoeff4D; - d4.y = d1.y - off3.y + 3.f*UnskewCoeff4D; - d4.z = d1.z - off3.z + 3.f*UnskewCoeff4D; - d4.w = d1.w - off3.w + 3.f*UnskewCoeff4D; - - d5.x = d1.x - 1.f + 4*UnskewCoeff4D; - d5.y = d1.y - 1.f + 4*UnskewCoeff4D; - d5.z = d1.z - 1.f + 4*UnskewCoeff4D; - d5.w = d1.w - 1.f + 4*UnskewCoeff4D; - - ii = skewedCubeOrigin.x & 255; - jj = skewedCubeOrigin.y & 255; - kk = skewedCubeOrigin.z & 255; - ll = skewedCubeOrigin.w & 255; - - gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; - gi1 = perm[ii + off1.x + perm[jj + off1.y + perm[kk + off1.z + perm[ll + off1.w]]]] & 31; - gi2 = perm[ii + off2.x + perm[jj + off2.y + perm[kk + off2.z + perm[ll + off2.w]]]] & 31; - gi3 = perm[ii + off3.x + perm[jj + off3.y + perm[kk + off3.z + perm[ll + off3.w]]]] & 31; - gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32; - - c1 = 0.6f - d1.x*d1.x - d1.y*d1.y - d1.z*d1.z - d1.w*d1.w; - c2 = 0.6f - d2.x*d2.x - d2.y*d2.y - d2.z*d2.z - d2.w*d2.w; - c3 = 0.6f - d3.x*d3.x - d3.y*d3.y - d3.z*d3.z - d3.w*d3.w; - c4 = 0.6f - d4.x*d4.x - d4.y*d4.y - d4.z*d4.z - d4.w*d4.w; - c5 = 0.6f - d5.x*d5.x - d5.y*d5.y - d5.z*d5.z - d5.w*d5.w; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient4[gi0][0]*d1.x + gradient4[gi0][1]*d1.y + gradient4[gi0][2]*d1.z + gradient4[gi0][3]*d1.w); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient4[gi1][0]*d2.x + gradient4[gi1][1]*d2.y + gradient4[gi1][2]*d2.z + gradient4[gi1][3]*d2.w); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient4[gi2][0]*d3.x + gradient4[gi2][1]*d3.y + gradient4[gi2][2]*d3.z + gradient4[gi2][3]*d3.w); - - if(c4 < 0) - n4 = 0; - else - n4 = c4*c4*c4*c4*(gradient4[gi3][0]*d4.x + gradient4[gi3][1]*d4.y + gradient4[gi3][2]*d4.z + gradient4[gi3][3]*d4.w); - - if(c5 < 0) - n5 = 0; - else - n5 = c5*c5*c5*c5*(gradient4[gi4][0]*d5.x + gradient4[gi4][1]*d5.y + gradient4[gi4][2]*d5.z + gradient4[gi4][3]*d5.w); - - return (n1+n2+n3+n4+n5)*27.f; - } -} diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp new file mode 100644 index 000000000..603820706 --- /dev/null +++ b/src/Nazara/Noise/Worley.cpp @@ -0,0 +1,171 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + Worley::Worley() : + scales{ + 1.f / std::sqrt(2), + 0.5f / std::sqrt(2), + 0.5f / std::sqrt(2), + 0.5f / std::sqrt(2) + } + { + function = WorleyFunction_F1; + } + + Worley::Worley(unsigned int seed) : Worley() + { + SetSeed(seed); + Shuffle(); + } + + void Worley::Set(WorleyFunction func) + { + function = func; + } + + float Worley::Get(std::initializer_list coordinates, float scale) const + { + switch(coordinates.size()) + { + case 2: + return this->_2D(coordinates,scale); + case 3: + return this->_3D(coordinates,scale); + case 4: + return this->_4D(coordinates,scale); + default: + throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + } + } + + float Worley::_2D(std::initializer_list coordinates, float scale) const + { + std::map featurePoints; + std::map::iterator it; + + float xc, yc; + int x0, y0; + float fractx, fracty; + + std::initializer_list::const_iterator c = coordinates.begin(); + + xc = *(c ) * scale; + yc = *(++c) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + + fractx = xc - static_cast(x0); + fracty = yc - static_cast(y0); + + featurePoints.clear(); + + _SquareTest(x0,y0,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fractx < it->first) + _SquareTest(x0 - 1,y0,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fractx < it->first) + _SquareTest(x0 + 1,y0,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fracty < it->first) + _SquareTest(x0,y0 - 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fracty < it->first) + _SquareTest(x0,y0 + 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fractx < it->first && + fracty < it->first) + _SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fractx < it->first && + fracty < it->first) + _SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fractx < it->first && + 1.f - fracty < it->first) + _SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fractx < it->first && + 1.f - fracty < it->first) + _SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + return it->first * scales[function]; + } + + float Worley::_3D(std::initializer_list coordinates, float scale) const + { + throw std::runtime_error("Worley 3D not available yet."); + } + + float Worley::_4D(std::initializer_list coordinates, float scale) const + { + throw std::runtime_error("Worley 4D not available yet."); + } + + + void Worley::_SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const + { + int ii = xi & 255; + int jj = yi & 255; + + int seed = perm[ii + perm[jj]]; + + //On initialise notre rng avec seed + std::minstd_rand0 randomNumberGenerator(seed); + + //On prend un nombre de points à déterminer dans le cube, compris entre 1 et 8 + unsigned int m = (seed & 7) + 1; + + //On calcule les emplacements des différents points + for(unsigned int i(0) ; i < m ; ++i) + { + Nz::Vector2f featurePoint; + featurePoint.x = (randomNumberGenerator() & 1023) / 1023.f + static_cast(xi); + featurePoint.y = (randomNumberGenerator() & 1023) / 1023.f + static_cast(yi); + + // TODO : Check order is correct + float distance = std::sqrt((featurePoint.x - x) * (featurePoint.x - x) + + (featurePoint.y - y) * (featurePoint.y - y)); + + //Insertion dans la liste triée + featurePoints[distance] = featurePoint; + } + } +} From 56e9e7bae65712a1ab4b2d06cd899046a5882ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 18 Jun 2016 12:36:20 +0200 Subject: [PATCH 062/235] Noise: First pass of refactoring Former-commit-id: 17c1cf4be282b0ebecf291b4c7858009376a3ad0 [formerly 8ff8938e7afcecdd5e677640d59608c8103e5558] Former-commit-id: c88bb53bf67cd1997a6c40df757aededc0067f9f --- include/Nazara/Math/Algorithm.hpp | 5 + include/Nazara/Noise/FBM.hpp | 4 +- include/Nazara/Noise/HybridMultiFractal.hpp | 4 +- include/Nazara/Noise/MixerBase.hpp | 4 + include/Nazara/Noise/NoiseBase.hpp | 17 +- include/Nazara/Noise/Perlin.hpp | 20 +- include/Nazara/Noise/Simplex.hpp | 27 +- include/Nazara/Noise/Worley.hpp | 23 +- src/Nazara/Noise/FBM.cpp | 45 ++- src/Nazara/Noise/HybridMultiFractal.cpp | 64 +++- src/Nazara/Noise/NoiseBase.cpp | 62 ++-- src/Nazara/Noise/Perlin.cpp | 239 +++++------- src/Nazara/Noise/Simplex.cpp | 388 ++++++++------------ src/Nazara/Noise/Worley.cpp | 118 +++--- 14 files changed, 485 insertions(+), 535 deletions(-) diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp index 74cc45593..45281bb50 100644 --- a/include/Nazara/Math/Algorithm.hpp +++ b/include/Nazara/Math/Algorithm.hpp @@ -1,3 +1,4 @@ + // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -28,6 +29,10 @@ #define M_SQRT3 1.7320508075688772935274463 #endif +#ifndef M_SQRT5 +#define M_SQRT5 2.23606797749979 +#endif + namespace Nz { template /*constexpr*/ T Approach(T value, T objective, T increment); diff --git a/include/Nazara/Noise/FBM.hpp b/include/Nazara/Noise/FBM.hpp index ded4aa069..584fb3a10 100644 --- a/include/Nazara/Noise/FBM.hpp +++ b/include/Nazara/Noise/FBM.hpp @@ -18,7 +18,9 @@ namespace Nz FBM(const FBM&) = delete; ~FBM() = default; - float Get(std::initializer_list coordinates, float scale) const; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; FBM& operator=(const FBM&) = delete; diff --git a/include/Nazara/Noise/HybridMultiFractal.hpp b/include/Nazara/Noise/HybridMultiFractal.hpp index a211a4767..c73dafc73 100644 --- a/include/Nazara/Noise/HybridMultiFractal.hpp +++ b/include/Nazara/Noise/HybridMultiFractal.hpp @@ -17,7 +17,9 @@ namespace Nz HybridMultiFractal(const HybridMultiFractal&) = delete; ~HybridMultiFractal() = default; - float Get(std::initializer_list coordinates, float scale) const; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; HybridMultiFractal& operator=(const HybridMultiFractal&) = delete; diff --git a/include/Nazara/Noise/MixerBase.hpp b/include/Nazara/Noise/MixerBase.hpp index 3c7a131b0..8b7a99d56 100644 --- a/include/Nazara/Noise/MixerBase.hpp +++ b/include/Nazara/Noise/MixerBase.hpp @@ -17,6 +17,10 @@ namespace Nz MixerBase(); ~MixerBase() = default; + virtual float Get(float x, float y, float scale) const = 0; + virtual float Get(float x, float y, float z, float scale) const = 0; + virtual float Get(float x, float y, float z, float w, float scale) const = 0; + float GetHurstParameter() const; float GetLacunarity() const; float GetOctaveNumber() const; diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp index 6a5c5c37f..f7f9eba09 100644 --- a/include/Nazara/Noise/NoiseBase.hpp +++ b/include/Nazara/Noise/NoiseBase.hpp @@ -6,7 +6,11 @@ #define NAZARA_NOISEBASE_HPP #include +#include +#include +#include #include +#include #include namespace Nz @@ -17,21 +21,26 @@ namespace Nz NoiseBase(unsigned int seed = 0); ~NoiseBase() = default; - virtual float Get(std::initializer_list coordinates, float scale) const = 0; + virtual float Get(float x, float y, float scale) const = 0; + virtual float Get(float x, float y, float z, float scale) const = 0; + virtual float Get(float x, float y, float z, float w, float scale) const = 0; float GetScale(); void SetScale(float scale); void SetSeed(unsigned int seed); void Shuffle(); - void Shuffle(unsigned int amount); protected: - unsigned int perm[512]; + std::array m_permutations; float m_scale; + static std::array s_gradients2; + static std::array s_gradients3; + static std::array s_gradients4; + private: - std::default_random_engine generator; + std::default_random_engine m_randomEngine; }; } diff --git a/include/Nazara/Noise/Perlin.hpp b/include/Nazara/Noise/Perlin.hpp index 058a3ada5..781d03148 100644 --- a/include/Nazara/Noise/Perlin.hpp +++ b/include/Nazara/Noise/Perlin.hpp @@ -15,21 +15,13 @@ namespace Nz class NAZARA_NOISE_API Perlin : public NoiseBase { public: - Perlin(); - Perlin(unsigned int seed); - ~Perlin() = default; + Perlin() = default; + Perlin(unsigned int seed); + ~Perlin() = default; - float Get(std::initializer_list coordinates, float scale) const; - - protected: - float _2D(std::initializer_list coordinates, float scale) const; - float _3D(std::initializer_list coordinates, float scale) const; - float _4D(std::initializer_list coordinates, float scale) const; - - private: - const float gradient2[8][2]; - const float gradient3[16][3]; - const float gradient4[32][4]; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; }; } diff --git a/include/Nazara/Noise/Simplex.hpp b/include/Nazara/Noise/Simplex.hpp index f131387b6..ae018f7bf 100644 --- a/include/Nazara/Noise/Simplex.hpp +++ b/include/Nazara/Noise/Simplex.hpp @@ -15,28 +15,13 @@ namespace Nz class NAZARA_NOISE_API Simplex : public NoiseBase { public: - Simplex(); - Simplex(unsigned int seed); - ~Simplex() = default; + Simplex() = default; + Simplex(unsigned int seed); + ~Simplex() = default; - float Get(std::initializer_list coordinates, float scale) const; - - protected: - float _2D(std::initializer_list coordinates, float scale) const; - float _3D(std::initializer_list coordinates, float scale) const; - float _4D(std::initializer_list coordinates, float scale) const; - - private: - const float gradient2[8][2]; - const float gradient3[16][3]; - const float gradient4[32][4]; - const float UnskewCoeff2D; - const float SkewCoeff2D; - const float UnskewCoeff3D; - const float SkewCoeff3D; - const float UnskewCoeff4D; - const float SkewCoeff4D; - const int lookupTable4D[64][4]; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; }; } diff --git a/include/Nazara/Noise/Worley.hpp b/include/Nazara/Noise/Worley.hpp index 249da999f..6b9f21f73 100644 --- a/include/Nazara/Noise/Worley.hpp +++ b/include/Nazara/Noise/Worley.hpp @@ -18,23 +18,20 @@ namespace Nz class NAZARA_NOISE_API Worley : public NoiseBase { public: - Worley(); - Worley(unsigned int seed); - ~Worley() = default; + Worley(); + Worley(unsigned int seed); + ~Worley() = default; - void Set(WorleyFunction func); + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; - float Get(std::initializer_list coordinates, float scale) const; - - protected: - float _2D(std::initializer_list coordinates, float scale) const; - float _3D(std::initializer_list coordinates, float scale) const; - float _4D(std::initializer_list coordinates, float scale) const; - void _SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const; + void Set(WorleyFunction func); private: - const float scales[4]; - WorleyFunction function; + void SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const; + + WorleyFunction m_function; }; } diff --git a/src/Nazara/Noise/FBM.cpp b/src/Nazara/Noise/FBM.cpp index f61bf8f44..96126ec60 100644 --- a/src/Nazara/Noise/FBM.cpp +++ b/src/Nazara/Noise/FBM.cpp @@ -11,20 +11,51 @@ namespace Nz { } - float FBM::Get(std::initializer_list coordinates, float scale) const + ///TODO: Handle with variadic templates + float FBM::Get(float x, float y, float scale) const { - float value = 0.0; - - for(int i(0); i < m_octaves; ++i) + float value = 0.f; + for(int i = 0; i < m_octaves; ++i) { - value += m_source.Get(coordinates,scale) * m_exponent_array.at(i); + value += m_source.Get(x, y, scale) * m_exponent_array.at(i); scale *= m_lacunarity; } float remainder = m_octaves - static_cast(m_octaves); - if(std::fabs(remainder) > 0.01f) - value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + value += remainder * m_source.Get(x, y, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum; + } + + float FBM::Get(float x, float y, float z, float scale) const + { + float value = 0.f; + for(int i = 0; i < m_octaves; ++i) + { + value += m_source.Get(x, y, z, scale) * m_exponent_array.at(i); + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + if(std::fabs(remainder) > 0.01f) + value += remainder * m_source.Get(x, y, z, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum; + } + + float FBM::Get(float x, float y, float z, float w, float scale) const + { + float value = 0.f; + for(int i = 0; i < m_octaves; ++i) + { + value += m_source.Get(x, y, z, w, scale) * m_exponent_array.at(i); + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + if(std::fabs(remainder) > 0.01f) + value += remainder * m_source.Get(x, y, z, w, scale) * m_exponent_array.at(static_cast(m_octaves-1)); return value / m_sum; } diff --git a/src/Nazara/Noise/HybridMultiFractal.cpp b/src/Nazara/Noise/HybridMultiFractal.cpp index 3f20809d3..4278d23b2 100644 --- a/src/Nazara/Noise/HybridMultiFractal.cpp +++ b/src/Nazara/Noise/HybridMultiFractal.cpp @@ -12,10 +12,10 @@ namespace Nz { } - float HybridMultiFractal::Get(std::initializer_list coordinates, float scale) const + float HybridMultiFractal::Get(float x, float y, float scale) const { float offset = 1.0f; - float value = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(0); + float value = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(0); float weight = value; float signal = 0.f; @@ -26,7 +26,7 @@ namespace Nz if (weight > 1.f) weight = 1.f; - signal = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(i); + signal = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(i); value += weight * signal; weight *= signal; scale *= m_lacunarity; @@ -35,7 +35,63 @@ namespace Nz float remainder = m_octaves - static_cast(m_octaves); if (remainder > 0.f) - value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + value += remainder * m_source.Get(x, y, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum - offset; + } + + float HybridMultiFractal::Get(float x, float y, float z, float scale) const + { + float offset = 1.0f; + float value = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(0); + float weight = value; + float signal = 0.f; + + scale *= m_lacunarity; + + for(int i(1) ; i < m_octaves; ++i) + { + if (weight > 1.f) + weight = 1.f; + + signal = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(i); + value += weight * signal; + weight *= signal; + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if (remainder > 0.f) + value += remainder * m_source.Get(x, y, z, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum - offset; + } + + float HybridMultiFractal::Get(float x, float y, float z, float w, float scale) const + { + float offset = 1.0f; + float value = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(0); + float weight = value; + float signal = 0.f; + + scale *= m_lacunarity; + + for(int i(1) ; i < m_octaves; ++i) + { + if (weight > 1.f) + weight = 1.f; + + signal = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(i); + value += weight * signal; + weight *= signal; + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if (remainder > 0.f) + value += remainder * m_source.Get(x, y, z, w, scale) * m_exponent_array.at(static_cast(m_octaves-1)); return value / m_sum - offset; } diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp index 0cbee9eec..fa5a2c92f 100644 --- a/src/Nazara/Noise/NoiseBase.cpp +++ b/src/Nazara/Noise/NoiseBase.cpp @@ -7,13 +7,13 @@ namespace Nz { - NoiseBase::NoiseBase(unsigned int seed) + NoiseBase::NoiseBase(unsigned int seed) : + m_scale(0.05f) { SetSeed(seed); - m_scale = 0.05f; - for(unsigned int i(0) ; i < 512; ++i) - perm[i] = i & 255; + // Fill permutations with initial values + std::iota(m_permutations.begin(), m_permutations.begin() + 256, 0); } float NoiseBase::GetScale() @@ -28,32 +28,46 @@ namespace Nz void NoiseBase::SetSeed(unsigned int seed) { - generator.seed(seed); + m_randomEngine.seed(seed); } void NoiseBase::Shuffle() { - int xchanger; - unsigned int ncase; + std::shuffle(m_permutations.begin(), m_permutations.begin() + 256, m_randomEngine); - for(unsigned int i(0) ; i < 256 ; i++) - perm[i] = i; - - for (unsigned int i(0); i < 256 ; ++i) - { - ncase = generator() & 255; - xchanger = perm[i]; - perm[i] = perm[ncase]; - perm[ncase] = xchanger; - } - - for(unsigned int i(256) ; i < 512; ++i) - perm[i] = perm[i & 255]; + for(std::size_t i = 1; i < (m_permutations.size() / 256); ++i) + std::copy(m_permutations.begin(), m_permutations.begin() + 256, m_permutations.begin() + 256 * i); } - void NoiseBase::Shuffle(unsigned int amount) + std::array NoiseBase::s_gradients2 = { - for(unsigned int j(0) ; j < amount ; ++j) - Shuffle(); - } + { + {1.f, 1.f}, {-1.f, 1.f}, {1.f, -1.f}, {-1.f, -1.f}, + {1.f, 0.f}, {-1.f, 0.f}, {0.f, 1.f}, { 0.f, -1.f} + } + }; + + std::array NoiseBase::s_gradients3 = + { + { + {1.f,1.f,0.f}, {-1.f, 1.f, 0.f}, {1.f, -1.f, 0.f}, {-1.f, -1.f, 0.f}, + {1.f,0.f,1.f}, {-1.f, 0.f, 1.f}, {1.f, 0.f, -1.f}, {-1.f, 0.f, -1.f}, + {0.f,1.f,1.f}, { 0.f, -1.f, 1.f}, {0.f, 1.f, -1.f}, {0.f, -1.f, -1.f}, + {1.f,1.f,0.f}, {-1.f, 1.f, 0.f}, {0.f, -1.f, 1.f}, {0.f, -1.f, -1.f} + } + }; + + std::array NoiseBase::s_gradients4 = + { + { + {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, + {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, + {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, + {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, + {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, + {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, + {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, + {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} + } + }; } diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp index f184702de..e6440eb3d 100644 --- a/src/Nazara/Noise/Perlin.cpp +++ b/src/Nazara/Noise/Perlin.cpp @@ -10,68 +10,27 @@ namespace Nz { - Perlin::Perlin() : - gradient2{ - {1.f,1.f},{-1.f,1.f},{1.f,-1.f},{-1.f,-1.f}, - {1.f,0.f},{-1.f,0.f},{0.f,1.f},{0.f,-1.f} - }, - gradient3{ - {1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}, - {1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1}, - {0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}, - {1,1,0},{-1,1,0},{0,-1,1},{0,-1,-1} - }, - gradient4{ - {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, - {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, - {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, - {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, - {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, - {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, - {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, - {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} - } - { - - } - - Perlin::Perlin(unsigned int seed) : Perlin() + Perlin::Perlin(unsigned int seed) : + Perlin() { SetSeed(seed); Shuffle(); } - float Perlin::Get(std::initializer_list coordinates, float scale) const + float Perlin::Get(float x, float y, float scale) const { - switch(coordinates.size()) - { - case 2: - return this->_2D(coordinates,scale); - case 3: - return this->_3D(coordinates,scale); - case 4: - return this->_4D(coordinates,scale); - default: - throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); - } - } + float xc, yc; + int x0, y0; + int gi0,gi1,gi2,gi3; + int ii, jj; - float Perlin::_2D(std::initializer_list coordinates, float scale) const - { - thread_local float xc, yc; - thread_local int x0, y0; - thread_local int gi0,gi1,gi2,gi3; - thread_local int ii, jj; + float s,t,u,v; + float Cx,Cy; + float Li1, Li2; + float tempx,tempy; - thread_local float s,t,u,v; - thread_local float Cx,Cy; - thread_local float Li1, Li2; - thread_local float tempx,tempy; - - std::initializer_list::const_iterator it = coordinates.begin(); - - xc = *(it ) * scale; - yc = *(++it) * scale; + xc = x * scale; + yc = y * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -79,10 +38,10 @@ namespace Nz ii = x0 & 255; jj = y0 & 255; - gi0 = perm[ii + perm[jj]] & 7; - gi1 = perm[ii + 1 + perm[jj]] & 7; - gi2 = perm[ii + perm[jj + 1]] & 7; - gi3 = perm[ii + 1 + perm[jj + 1]] & 7; + gi0 = m_permutations[ii + m_permutations[jj]] & 7; + gi1 = m_permutations[ii + 1 + m_permutations[jj]] & 7; + gi2 = m_permutations[ii + m_permutations[jj + 1]] & 7; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1]] & 7; tempx = xc - x0; tempy = yc - y0; @@ -90,16 +49,16 @@ namespace Nz Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); - s = gradient2[gi0][0]*tempx + gradient2[gi0][1]*tempy; + s = s_gradients2[gi0][0]*tempx + s_gradients2[gi0][1]*tempy; tempx = xc - (x0 + 1); - t = gradient2[gi1][0]*tempx + gradient2[gi1][1]*tempy; + t = s_gradients2[gi1][0]*tempx + s_gradients2[gi1][1]*tempy; tempy = yc - (y0 + 1); - v = gradient2[gi3][0]*tempx + gradient2[gi3][1]*tempy; + v = s_gradients2[gi3][0]*tempx + s_gradients2[gi3][1]*tempy; tempx = xc - x0; - u = gradient2[gi2][0]*tempx + gradient2[gi2][1]*tempy; + u = s_gradients2[gi2][0]*tempx + s_gradients2[gi2][1]*tempy; Li1 = s + Cx*(t-s); Li2 = u + Cx*(v-u); @@ -107,26 +66,24 @@ namespace Nz return Li1 + Cy*(Li2-Li1); } - float Perlin::_3D(std::initializer_list coordinates, float scale) const + float Perlin::Get(float x, float y, float z, float scale) const { - thread_local float xc, yc, zc; - thread_local int x0, y0, z0; - thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; - thread_local int ii, jj, kk; + float xc, yc, zc; + int x0, y0, z0; + int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; + int ii, jj, kk; - thread_local float Li1,Li2,Li3,Li4,Li5,Li6; - thread_local float s[2],t[2],u[2],v[2]; - thread_local float Cx,Cy,Cz; - thread_local float nx,ny,nz; + float Li1,Li2,Li3,Li4,Li5,Li6; + float s[2],t[2],u[2],v[2]; + float Cx,Cy,Cz; + float nx,ny,nz; - thread_local float tmp; - thread_local float tempx,tempy,tempz; + float tmp; + float tempx,tempy,tempz; - std::initializer_list::const_iterator it = coordinates.begin(); - - xc = *(it ) * scale; - yc = *(++it) * scale; - zc = *(++it) * scale; + xc = x * scale; + yc = y * scale; + zc = z * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -136,15 +93,15 @@ namespace Nz jj = y0 & 255; kk = z0 & 255; - gi0 = perm[ii + perm[jj + perm[kk]]] & 15; - gi1 = perm[ii + 1 + perm[jj + perm[kk]]] & 15; - gi2 = perm[ii + perm[jj + 1 + perm[kk]]] & 15; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk]]] & 15; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk]]] & 15; + gi1 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk]]] & 15; + gi2 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk]]] & 15; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk]]] & 15; - gi4 = perm[ii + perm[jj + perm[kk + 1]]] & 15; - gi5 = perm[ii + 1 + perm[jj + perm[kk + 1]]] & 15; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1]]] & 15; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1]]] & 15; + gi4 = m_permutations[ii + m_permutations[jj + m_permutations[kk + 1]]] & 15; + gi5 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + 1]]] & 15; + gi6 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1]]] & 15; + gi7 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1]]] & 15; tempx = xc - x0; tempy = yc - y0; @@ -154,29 +111,29 @@ namespace Nz Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); - s[0] = gradient3[gi0][0]*tempx + gradient3[gi0][1]*tempy + gradient3[gi0][2]*tempz; + s[0] = s_gradients3[gi0][0]*tempx + s_gradients3[gi0][1]*tempy + s_gradients3[gi0][2]*tempz; tempx = xc - (x0 + 1); - t[0] = gradient3[gi1][0]*tempx + gradient3[gi1][1]*tempy + gradient3[gi1][2]*tempz; + t[0] = s_gradients3[gi1][0]*tempx + s_gradients3[gi1][1]*tempy + s_gradients3[gi1][2]*tempz; tempy = yc - (y0 + 1); - v[0] = gradient3[gi3][0]*tempx + gradient3[gi3][1]*tempy + gradient3[gi3][2]*tempz; + v[0] = s_gradients3[gi3][0]*tempx + s_gradients3[gi3][1]*tempy + s_gradients3[gi3][2]*tempz; tempx = xc - x0; - u[0] = gradient3[gi2][0]*tempx + gradient3[gi2][1]*tempy + gradient3[gi2][2]*tempz; + u[0] = s_gradients3[gi2][0]*tempx + s_gradients3[gi2][1]*tempy + s_gradients3[gi2][2]*tempz; tempy = yc - y0; tempz = zc - (z0 + 1); - s[1] = gradient3[gi4][0]*tempx + gradient3[gi4][1]*tempy + gradient3[gi4][2]*tempz; + s[1] = s_gradients3[gi4][0]*tempx + s_gradients3[gi4][1]*tempy + s_gradients3[gi4][2]*tempz; tempx = xc - (x0 + 1); - t[1] = gradient3[gi5][0]*tempx + gradient3[gi5][1]*tempy + gradient3[gi5][2]*tempz; + t[1] = s_gradients3[gi5][0]*tempx + s_gradients3[gi5][1]*tempy + s_gradients3[gi5][2]*tempz; tempy = yc - (y0 + 1); - v[1] = gradient3[gi7][0]*tempx + gradient3[gi7][1]*tempy + gradient3[gi7][2]*tempz; + v[1] = s_gradients3[gi7][0]*tempx + s_gradients3[gi7][1]*tempy + s_gradients3[gi7][2]*tempz; tempx = xc - x0; - u[1] = gradient3[gi6][0]*tempx + gradient3[gi6][1]*tempy + gradient3[gi6][2]*tempz; + u[1] = s_gradients3[gi6][0]*tempx + s_gradients3[gi6][1]*tempy + s_gradients3[gi6][2]*tempz; Li1 = s[0] + Cx*(t[0]-s[0]); Li2 = u[0] + Cx*(v[0]-u[0]); @@ -189,26 +146,24 @@ namespace Nz return Li5 + Cz * (Li6-Li5); } - float Perlin::_4D(std::initializer_list coordinates, float scale) const + float Perlin::Get(float x, float y, float z, float w, float scale) const { - thread_local float xc,yc,zc,wc; - thread_local int x0,y0,z0,w0; - thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; - thread_local int ii,jj,kk,ll; + float xc,yc,zc,wc; + int x0,y0,z0,w0; + int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; + int ii,jj,kk,ll; - thread_local float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; - thread_local float s[4],t[4],u[4],v[4]; - thread_local float Cx,Cy,Cz,Cw; + float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; + float s[4],t[4],u[4],v[4]; + float Cx,Cy,Cz,Cw; - thread_local float tmp; - thread_local float tempx,tempy,tempz,tempw; + float tmp; + float tempx,tempy,tempz,tempw; - std::initializer_list::const_iterator it = coordinates.begin(); - - xc = *(it ) * scale; - yc = *(++it) * scale; - zc = *(++it) * scale; - wc = *(++it) * scale; + xc = x * scale; + yc = y * scale; + zc = z * scale; + wc = w * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -220,25 +175,25 @@ namespace Nz kk = z0 & 255; ll = w0 & 255; - gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; - gi1 = perm[ii + 1 + perm[jj + perm[kk + perm[ll]]]] & 31; - gi2 = perm[ii + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll]]]] & 31; + gi1 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + m_permutations[ll]]]] & 31; + gi2 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll]]]] & 31; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll]]]] & 31; - gi4 = perm[ii + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi5 = perm[ii + 1 + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; + gi4 = m_permutations[ii + m_permutations[jj + + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; + gi5 = m_permutations[ii + 1 + m_permutations[jj + + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; + gi6 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; + gi7 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; - gi8 = perm[ii + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi9 = perm[ii + 1 + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi10 = perm[ii + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; - gi11 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; + gi8 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll + 1]]]] & 31; + gi9 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + m_permutations[ll + 1]]]] & 31; + gi10 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll + 1]]]] & 31; + gi11 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll + 1]]]] & 31; - gi12 = perm[ii + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi13 = perm[ii + 1 + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi14 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi15 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi12 = m_permutations[ii + m_permutations[jj + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; + gi13 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; + gi14 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; + gi15 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; tempx = xc - x0; tempy = yc - y0; @@ -250,58 +205,58 @@ namespace Nz Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); Cw = tempw * tempw * tempw * (tempw * (tempw * 6 - 15) + 10); - s[0] = gradient4[gi0][0]*tempx + gradient4[gi0][1]*tempy + gradient4[gi0][2]*tempz + gradient4[gi0][3]*tempw; + s[0] = s_gradients4[gi0][0]*tempx + s_gradients4[gi0][1]*tempy + s_gradients4[gi0][2]*tempz + s_gradients4[gi0][3]*tempw; tempx = xc - (x0+1); - t[0] = gradient4[gi1][0]*tempx + gradient4[gi1][1]*tempy + gradient4[gi1][2]*tempz + gradient4[gi1][3]*tempw; + t[0] = s_gradients4[gi1][0]*tempx + s_gradients4[gi1][1]*tempy + s_gradients4[gi1][2]*tempz + s_gradients4[gi1][3]*tempw; tempy = yc - (y0+1); - v[0] = gradient4[gi3][0]*tempx + gradient4[gi3][1]*tempy + gradient4[gi3][2]*tempz + gradient4[gi3][3]*tempw; + v[0] = s_gradients4[gi3][0]*tempx + s_gradients4[gi3][1]*tempy + s_gradients4[gi3][2]*tempz + s_gradients4[gi3][3]*tempw; tempx = xc - x0; - u[0] = gradient4[gi2][0]*tempx + gradient4[gi2][1]*tempy + gradient4[gi2][2]*tempz + gradient4[gi2][3]*tempw; + u[0] = s_gradients4[gi2][0]*tempx + s_gradients4[gi2][1]*tempy + s_gradients4[gi2][2]*tempz + s_gradients4[gi2][3]*tempw; tempy = yc - y0; tempz = zc - (z0+1); - s[1] = gradient4[gi4][0]*tempx + gradient4[gi4][1]*tempy + gradient4[gi4][2]*tempz + gradient4[gi4][3]*tempw; + s[1] = s_gradients4[gi4][0]*tempx + s_gradients4[gi4][1]*tempy + s_gradients4[gi4][2]*tempz + s_gradients4[gi4][3]*tempw; tempx = xc - (x0+1); - t[1] = gradient4[gi5][0]*tempx + gradient4[gi5][1]*tempy + gradient4[gi5][2]*tempz + gradient4[gi5][3]*tempw; + t[1] = s_gradients4[gi5][0]*tempx + s_gradients4[gi5][1]*tempy + s_gradients4[gi5][2]*tempz + s_gradients4[gi5][3]*tempw; tempy = yc - (y0+1); - v[1] = gradient4[gi7][0]*tempx + gradient4[gi7][1]*tempy + gradient4[gi7][2]*tempz + gradient4[gi7][3]*tempw; + v[1] = s_gradients4[gi7][0]*tempx + s_gradients4[gi7][1]*tempy + s_gradients4[gi7][2]*tempz + s_gradients4[gi7][3]*tempw; tempx = xc - x0; - u[1] = gradient4[gi6][0]*tempx + gradient4[gi6][1]*tempy + gradient4[gi6][2]*tempz + gradient4[gi6][3]*tempw; + u[1] = s_gradients4[gi6][0]*tempx + s_gradients4[gi6][1]*tempy + s_gradients4[gi6][2]*tempz + s_gradients4[gi6][3]*tempw; tempy = yc - y0; tempz = zc - z0; tempw = wc - (w0+1); - s[2] = gradient4[gi8][0]*tempx + gradient4[gi8][1]*tempy + gradient4[gi8][2]*tempz + gradient4[gi8][3]*tempw; + s[2] = s_gradients4[gi8][0]*tempx + s_gradients4[gi8][1]*tempy + s_gradients4[gi8][2]*tempz + s_gradients4[gi8][3]*tempw; tempx = xc - (x0+1); - t[2] = gradient4[gi9][0]*tempx + gradient4[gi9][1]*tempy + gradient4[gi9][2]*tempz + gradient4[gi9][3]*tempw; + t[2] = s_gradients4[gi9][0]*tempx + s_gradients4[gi9][1]*tempy + s_gradients4[gi9][2]*tempz + s_gradients4[gi9][3]*tempw; tempy = yc - (y0+1); - v[2] = gradient4[gi11][0]*tempx + gradient4[gi11][1]*tempy + gradient4[gi11][2]*tempz + gradient4[gi11][3]*tempw; + v[2] = s_gradients4[gi11][0]*tempx + s_gradients4[gi11][1]*tempy + s_gradients4[gi11][2]*tempz + s_gradients4[gi11][3]*tempw; tempx = xc - x0; - u[2] = gradient4[gi10][0]*tempx + gradient4[gi10][1]*tempy + gradient4[gi10][2]*tempz + gradient4[gi10][3]*tempw; + u[2] = s_gradients4[gi10][0]*tempx + s_gradients4[gi10][1]*tempy + s_gradients4[gi10][2]*tempz + s_gradients4[gi10][3]*tempw; tempy = yc - y0; tempz = zc - (z0+1); - s[3] = gradient4[gi12][0]*tempx + gradient4[gi12][1]*tempy + gradient4[gi12][2]*tempz + gradient4[gi12][3]*tempw; + s[3] = s_gradients4[gi12][0]*tempx + s_gradients4[gi12][1]*tempy + s_gradients4[gi12][2]*tempz + s_gradients4[gi12][3]*tempw; tempx = xc - (x0+1); - t[3] = gradient4[gi13][0]*tempx + gradient4[gi13][1]*tempy + gradient4[gi13][2]*tempz + gradient4[gi13][3]*tempw; + t[3] = s_gradients4[gi13][0]*tempx + s_gradients4[gi13][1]*tempy + s_gradients4[gi13][2]*tempz + s_gradients4[gi13][3]*tempw; tempy = yc - (y0+1); - v[3] = gradient4[gi15][0]*tempx + gradient4[gi15][1]*tempy + gradient4[gi15][2]*tempz + gradient4[gi15][3]*tempw; + v[3] = s_gradients4[gi15][0]*tempx + s_gradients4[gi15][1]*tempy + s_gradients4[gi15][2]*tempz + s_gradients4[gi15][3]*tempw; tempx = xc - x0; - u[3] = gradient4[gi14][0]*tempx + gradient4[gi14][1]*tempy + gradient4[gi14][2]*tempz + gradient4[gi14][3]*tempw; + u[3] = s_gradients4[gi14][0]*tempx + s_gradients4[gi14][1]*tempy + s_gradients4[gi14][2]*tempz + s_gradients4[gi14][3]*tempw; Li1 = s[0] + Cx*(t[0]-s[0]); Li2 = u[0] + Cx*(v[0]-u[0]); diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp index c93a226d4..c2ce28c3f 100644 --- a/src/Nazara/Noise/Simplex.cpp +++ b/src/Nazara/Noise/Simplex.cpp @@ -10,185 +10,95 @@ namespace Nz { - Simplex::Simplex() : - gradient2{ - {1,1},{-1,1},{1,-1},{-1,-1}, - {1,0},{-1,0},{0,1},{0,-1} - }, - gradient3{ - {1.f,1.f,0.f},{-1.f,1.f,0.f},{1.f,-1.f,0.f},{-1.f,-1.f,0.f}, - {1.f,0.f,1.f},{-1.f,0.f,1.f},{1.f,0.f,-1.f},{-1.f,0.f,-1.f}, - {0.f,1.f,1.f},{0.f,-1.f,1.f},{0.f,1.f,-1.f},{0.f,-1.f,-1.f} - }, - gradient4{ - {0.f,1.f,1.f,1.f}, {0.f,1.f,1.f,-1.f}, {0.f,1.f,-1.f,1.f}, {0.f,1.f,-1.f,-1.f}, - {0.f,-1.f,1.f,1.f},{0.f,-1.f,1.f,-1.f},{0.f,-1.f,-1.f,1.f},{0.f,-1.f,-1.f,-1.f}, - {1.f,0.f,1.f,1.f}, {1.f,0.f,1.f,-1.f}, {1.f,0.f,-1.f,1.f}, {1.f,0.f,-1.f,-1.f}, - {-1.f,0.f,1.f,1.f},{-1.f,0.f,1.f,-1.f},{-1.f,0.f,-1.f,1.f},{-1.f,0.f,-1.f,-1.f}, - {1.f,1.f,0.f,1.f}, {1.f,1.f,0.f,-1.f}, {1.f,-1.f,0.f,1.f}, {1.f,-1.f,0.f,-1.f}, - {-1.f,1.f,0.f,1.f},{-1.f,1.f,0.f,-1.f},{-1.f,-1.f,0.f,1.f},{-1.f,-1.f,0.f,-1.f}, - {1.f,1.f,1.f,0.f}, {1.f,1.f,-1.f,0.f}, {1.f,-1.f,1.f,0.f}, {1.f,-1.f,-1.f,0.f}, - {-1.f,1.f,1.f,0.f},{-1.f,1.f,-1.f,0.f},{-1.f,-1.f,1.f,0.f},{-1.f,-1.f,-1.f,0.f} - }, - lookupTable4D{ - {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, - {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, - {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, - {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0} - }, - SkewCoeff2D (0.5f*(std::sqrt(3.f) - 1.f)), - UnskewCoeff2D((3.f-std::sqrt(3.f))/6.f), - SkewCoeff3D (1/3.f), - UnskewCoeff3D (1/6.f), - SkewCoeff4D ((std::sqrt(5.f) - 1.f)/4.f), - UnskewCoeff4D ((5.f - std::sqrt(5.f))/20.f) + namespace { - + constexpr float s_SkewCoeff2D = 0.5f * (M_SQRT3 - 1.f); + constexpr float s_UnskewCoeff2D = (3.f - M_SQRT3)/6.f; + constexpr float s_SkewCoeff3D = 1.f / 3.f; + constexpr float s_UnskewCoeff3D = 1.f / 6.f; + constexpr float s_SkewCoeff4D = (M_SQRT5 - 1.f)/4.f; + constexpr float s_UnskewCoeff4D = (5.f - M_SQRT5)/20.f; } - Simplex::Simplex(unsigned int seed) : Simplex() + Simplex::Simplex(unsigned int seed) { SetSeed(seed); Shuffle(); } - float Simplex::Get(std::initializer_list coordinates, float scale) const + float Simplex::Get(float x, float y, float scale) const { - switch(coordinates.size()) + float xc = x * scale; + float yc = y * scale; + + float sum = (xc + yc) * s_SkewCoeff2D; + Vector2i skewedCubeOrigin(fastfloor(xc + sum), fastfloor(yc + sum)); + + sum = (skewedCubeOrigin.x + skewedCubeOrigin.y) * s_UnskewCoeff2D; + Vector2f unskewedCubeOrigin(skewedCubeOrigin.x - sum, skewedCubeOrigin.y - sum); + + Vector2f unskewedDistToOrigin(xc - unskewedCubeOrigin.x, yc - unskewedCubeOrigin.y); + + Vector2f off1; + if(unskewedDistToOrigin.x > unskewedDistToOrigin.y) + off1.Set(1, 0); + else + off1.Set(0, 1); + + std::array d; + d[0] = -unskewedDistToOrigin; + d[1] = d[0] + off1 - Vector2f(s_UnskewCoeff2D); + d[2] = d[0] + Vector2f(1.f - 2.f * s_UnskewCoeff2D); + + Vector2i offset(skewedCubeOrigin.x & 255, skewedCubeOrigin.y & 255); + std::array gi = { - case 2: - return this->_2D(coordinates,scale); - case 3: - return this->_3D(coordinates,scale); - case 4: - return this->_4D(coordinates,scale); - default: - throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + m_permutations[offset.x + m_permutations[offset.y]] & 7, + m_permutations[offset.x + off1.x + m_permutations[offset.y + off1.y]] & 7, + m_permutations[offset.x + 1 + m_permutations[offset.y + 1]] & 7 + }; + + float n = 0.f; + for (unsigned int i = 0; i < 3; ++i) + { + float c = 0.5f - d[i].x * d[i].x - d[i].y *d[i].y; + if (c > 0.f) + n += c * c * c * c * (s_gradients2[gi[i]].x * d[i].x + s_gradients2[gi[i]].y * d[i].y); } + + return n*70.f; } - float Simplex::_2D(std::initializer_list coordinates, float scale) const + float Simplex::Get(float x, float y, float z, float scale) const { - thread_local float xc,yc; - thread_local int ii,jj; - thread_local int gi0,gi1,gi2; - thread_local int skewedCubeOriginx,skewedCubeOriginy; - thread_local int off1x,off1y; - thread_local float n1,n2,n3; - thread_local float c1,c2,c3; - thread_local float sum; - thread_local float unskewedCubeOriginx,unskewedCubeOriginy; - thread_local float unskewedDistToOriginx,unskewedDistToOriginy; - thread_local float d1x,d1y; - thread_local float d2x,d2y; - thread_local float d3x,d3y; + float xc, yc, zc; + int ii,jj,kk; + int gi0,gi1,gi2,gi3; + int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz; - std::initializer_list::const_iterator it = coordinates.begin(); + int off1x,off1y,off1z; + int off2x,off2y,off2z; + float n1,n2,n3,n4; + float c1,c2,c3,c4; - xc = *(it ) * scale; - yc = *(++it) * scale; - - sum = (xc + yc) * SkewCoeff2D; - skewedCubeOriginx = fastfloor(xc + sum); - skewedCubeOriginy = fastfloor(yc + sum); - - sum = (skewedCubeOriginx + skewedCubeOriginy) * UnskewCoeff2D; - unskewedCubeOriginx = skewedCubeOriginx - sum; - unskewedCubeOriginy = skewedCubeOriginy - sum; - - unskewedDistToOriginx = xc - unskewedCubeOriginx;// Difference with 3d and 4d - unskewedDistToOriginy = yc - unskewedCubeOriginy; - - if(unskewedDistToOriginx > unskewedDistToOriginy) - { - off1x = 1; - off1y = 0; - } - else - { - off1x = 0; - off1y = 1; - } - - d1x = - unskewedDistToOriginx; - d1y = - unskewedDistToOriginy; - - d2x = d1x + off1x - UnskewCoeff2D; - d2y = d1y + off1y - UnskewCoeff2D; - - d3x = d1x + 1.f - 2.f * UnskewCoeff2D; - d3y = d1y + 1.f - 2.f * UnskewCoeff2D; - - ii = skewedCubeOriginx & 255; - jj = skewedCubeOriginy & 255; - - gi0 = perm[ii + perm[jj ]] & 7; - gi1 = perm[ii + off1x + perm[jj + off1y ]] & 7; - gi2 = perm[ii + 1 + perm[jj + 1 ]] & 7; - - c1 = 0.5f - d1x * d1x - d1y * d1y; - c2 = 0.5f - d2x * d2x - d2y * d2y; - c3 = 0.5f - d3x * d3x - d3y * d3y; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient2[gi0][0] * d1x + gradient2[gi0][1] * d1y); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient2[gi1][0] * d2x + gradient2[gi1][1] * d2y); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient2[gi2][0] * d3x + gradient2[gi2][1] * d3y); - - return (n1+n2+n3)*70.f; - } - - float Simplex::_3D(std::initializer_list coordinates, float scale) const - { - thread_local float xc, yc, zc; - thread_local float x,y,z; - thread_local int ii,jj,kk; - thread_local int gi0,gi1,gi2,gi3; - thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz; - - thread_local int off1x,off1y,off1z; - thread_local int off2x,off2y,off2z; - thread_local float n1,n2,n3,n4; - thread_local float c1,c2,c3,c4; - - thread_local float sum; - thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz; - thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz; - thread_local float d1x,d1y,d1z; - thread_local float d2x,d2y,d2z; - thread_local float d3x,d3y,d3z; - thread_local float d4x,d4y,d4z; - - std::initializer_list::const_iterator it = coordinates.begin(); - - x = *(it ); - y = *(++it); - z = *(++it); + float sum; + float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz; + float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz; + float d1x,d1y,d1z; + float d2x,d2y,d2z; + float d3x,d3y,d3z; + float d4x,d4y,d4z; xc = x * scale; yc = y * scale; zc = z * scale; - sum = (xc + yc + zc) * SkewCoeff3D; + sum = (xc + yc + zc) * s_SkewCoeff3D; skewedCubeOriginx = fastfloor(xc + sum); skewedCubeOriginy = fastfloor(yc + sum); skewedCubeOriginz = fastfloor(zc + sum); - sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz) * UnskewCoeff3D; + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz) * s_UnskewCoeff3D; unskewedCubeOriginx = skewedCubeOriginx - sum; unskewedCubeOriginy = skewedCubeOriginy - sum; unskewedCubeOriginz = skewedCubeOriginz - sum; @@ -262,26 +172,26 @@ namespace Nz d1y = unskewedDistToOriginy; d1z = unskewedDistToOriginz; - d2x = d1x - off1x + UnskewCoeff3D; - d2y = d1y - off1y + UnskewCoeff3D; - d2z = d1z - off1z + UnskewCoeff3D; + d2x = d1x - off1x + s_UnskewCoeff3D; + d2y = d1y - off1y + s_UnskewCoeff3D; + d2z = d1z - off1z + s_UnskewCoeff3D; - d3x = d1x - off2x + 2.f*UnskewCoeff3D; - d3y = d1y - off2y + 2.f*UnskewCoeff3D; - d3z = d1z - off2z + 2.f*UnskewCoeff3D; + d3x = d1x - off2x + 2.f*s_UnskewCoeff3D; + d3y = d1y - off2y + 2.f*s_UnskewCoeff3D; + d3z = d1z - off2z + 2.f*s_UnskewCoeff3D; - d4x = d1x - 1.f + 3.f*UnskewCoeff3D; - d4y = d1y - 1.f + 3.f*UnskewCoeff3D; - d4z = d1z - 1.f + 3.f*UnskewCoeff3D; + d4x = d1x - 1.f + 3.f*s_UnskewCoeff3D; + d4y = d1y - 1.f + 3.f*s_UnskewCoeff3D; + d4z = d1z - 1.f + 3.f*s_UnskewCoeff3D; ii = skewedCubeOriginx & 255; jj = skewedCubeOriginy & 255; kk = skewedCubeOriginz & 255; - gi0 = perm[ii + perm[jj + perm[kk ]]] % 12; - gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z ]]] % 12; - gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z ]]] % 12; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 ]]] % 12; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk ]]] % 12; + gi1 = m_permutations[ii + off1x + m_permutations[jj + off1y + m_permutations[kk + off1z ]]] % 12; + gi2 = m_permutations[ii + off2x + m_permutations[jj + off2y + m_permutations[kk + off2z ]]] % 12; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 ]]] % 12; c1 = 0.6f - d1x * d1x - d1y * d1y - d1z * d1z; c2 = 0.6f - d2x * d2x - d2y * d2y - d2z * d2z; @@ -291,69 +201,75 @@ namespace Nz if(c1 < 0) n1 = 0; else - n1 = c1*c1*c1*c1*(gradient3[gi0][0] * d1x + gradient3[gi0][1] * d1y + gradient3[gi0][2] * d1z); + n1 = c1*c1*c1*c1*(s_gradients3[gi0][0] * d1x + s_gradients3[gi0][1] * d1y + s_gradients3[gi0][2] * d1z); if(c2 < 0) n2 = 0; else - n2 = c2*c2*c2*c2*(gradient3[gi1][0] * d2x + gradient3[gi1][1] * d2y + gradient3[gi1][2] * d2z); + n2 = c2*c2*c2*c2*(s_gradients3[gi1][0] * d2x + s_gradients3[gi1][1] * d2y + s_gradients3[gi1][2] * d2z); if(c3 < 0) n3 = 0; else - n3 = c3*c3*c3*c3*(gradient3[gi2][0] * d3x + gradient3[gi2][1] * d3y + gradient3[gi2][2] * d3z); + n3 = c3*c3*c3*c3*(s_gradients3[gi2][0] * d3x + s_gradients3[gi2][1] * d3y + s_gradients3[gi2][2] * d3z); if(c4 < 0) n4 = 0; else - n4 = c4*c4*c4*c4*(gradient3[gi3][0] * d4x + gradient3[gi3][1] * d4y + gradient3[gi3][2] * d4z); + n4 = c4*c4*c4*c4*(s_gradients3[gi3][0] * d4x + s_gradients3[gi3][1] * d4y + s_gradients3[gi3][2] * d4z); return (n1+n2+n3+n4)*32; } - float Simplex::_4D(std::initializer_list coordinates, float scale) const + float Simplex::Get(float x, float y, float z, float w, float scale) const { - thread_local float xc,yc,zc,wc; - thread_local float x,y,z,w; - thread_local int ii,jj,kk,ll; - thread_local int gi0,gi1,gi2,gi3,gi4; - thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz,skewedCubeOriginw; + static std::array lookupTable = + { + { + {0,1,2,3}, {0,1,3,2}, {0,0,0,0}, {0,2,3,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,2,3,0}, + {0,2,1,3}, {0,0,0,0}, {0,3,1,2}, {0,3,2,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,3,2,0}, + {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, + {1,2,0,3}, {0,0,0,0}, {1,3,0,2}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,3,0,1}, {2,3,1,0}, + {1,0,2,3}, {1,0,3,2}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,0,3,1}, {0,0,0,0}, {2,1,3,0}, + {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, + {2,0,1,3}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {3,0,1,2}, {3,0,2,1}, {0,0,0,0}, {3,1,2,0}, + {2,1,0,3}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {3,1,0,2}, {0,0,0,0}, {3,2,0,1}, {3,2,1,0} + } + }; - thread_local int off1x,off1y,off1z,off1w; - thread_local int off2x,off2y,off2z,off2w; - thread_local int off3x,off3y,off3z,off3w; + float xc,yc,zc,wc; + int ii,jj,kk,ll; + int gi0,gi1,gi2,gi3,gi4; + int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz,skewedCubeOriginw; - thread_local int c; - thread_local float n1,n2,n3,n4,n5; - thread_local float c1,c2,c3,c4,c5,c6; + int off1x,off1y,off1z,off1w; + int off2x,off2y,off2z,off2w; + int off3x,off3y,off3z,off3w; - thread_local float sum; - thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; - thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz,unskewedDistToOriginw; - thread_local float d1x,d2x,d3x,d4x,d5x; - thread_local float d1y,d2y,d3y,d4y,d5y; - thread_local float d1z,d2z,d3z,d4z,d5z; - thread_local float d1w,d2w,d3w,d4w,d5w; + int c; + float n1,n2,n3,n4,n5; + float c1,c2,c3,c4,c5,c6; - std::initializer_list::const_iterator it = coordinates.begin(); - - x = *(it ); - y = *(++it); - z = *(++it); - w = *(++it); + float sum; + float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; + float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz,unskewedDistToOriginw; + float d1x,d2x,d3x,d4x,d5x; + float d1y,d2y,d3y,d4y,d5y; + float d1z,d2z,d3z,d4z,d5z; + float d1w,d2w,d3w,d4w,d5w; xc = x * scale; yc = y * scale; zc = z * scale; wc = w * scale; - sum = (xc + yc + zc + wc) * SkewCoeff4D; + sum = (xc + yc + zc + wc) * s_SkewCoeff4D; skewedCubeOriginx = fastfloor(xc + sum); skewedCubeOriginy = fastfloor(yc + sum); skewedCubeOriginz = fastfloor(zc + sum); skewedCubeOriginw = fastfloor(wc + sum); - sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz + skewedCubeOriginw) * UnskewCoeff4D; + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz + skewedCubeOriginw) * s_UnskewCoeff4D; unskewedCubeOriginx = skewedCubeOriginx - sum; unskewedCubeOriginy = skewedCubeOriginy - sum; unskewedCubeOriginz = skewedCubeOriginz - sum; @@ -372,56 +288,56 @@ namespace Nz c6 = (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; c = c1 + c2 + c3 + c4 + c5 + c6; - off1x = lookupTable4D[c][0] >= 3 ? 1 : 0; - off1y = lookupTable4D[c][1] >= 3 ? 1 : 0; - off1z = lookupTable4D[c][2] >= 3 ? 1 : 0; - off1w = lookupTable4D[c][3] >= 3 ? 1 : 0; + off1x = lookupTable[c][0] >= 3 ? 1 : 0; + off1y = lookupTable[c][1] >= 3 ? 1 : 0; + off1z = lookupTable[c][2] >= 3 ? 1 : 0; + off1w = lookupTable[c][3] >= 3 ? 1 : 0; - off2x = lookupTable4D[c][0] >= 2 ? 1 : 0; - off2y = lookupTable4D[c][1] >= 2 ? 1 : 0; - off2z = lookupTable4D[c][2] >= 2 ? 1 : 0; - off2w = lookupTable4D[c][3] >= 2 ? 1 : 0; + off2x = lookupTable[c][0] >= 2 ? 1 : 0; + off2y = lookupTable[c][1] >= 2 ? 1 : 0; + off2z = lookupTable[c][2] >= 2 ? 1 : 0; + off2w = lookupTable[c][3] >= 2 ? 1 : 0; - off3x = lookupTable4D[c][0] >= 1 ? 1 : 0; - off3y = lookupTable4D[c][1] >= 1 ? 1 : 0; - off3z = lookupTable4D[c][2] >= 1 ? 1 : 0; - off3w = lookupTable4D[c][3] >= 1 ? 1 : 0; + off3x = lookupTable[c][0] >= 1 ? 1 : 0; + off3y = lookupTable[c][1] >= 1 ? 1 : 0; + off3z = lookupTable[c][2] >= 1 ? 1 : 0; + off3w = lookupTable[c][3] >= 1 ? 1 : 0; d1x = unskewedDistToOriginx; d1y = unskewedDistToOriginy; d1z = unskewedDistToOriginz; d1w = unskewedDistToOriginw; - d2x = d1x - off1x + UnskewCoeff4D; - d2y = d1y - off1y + UnskewCoeff4D; - d2z = d1z - off1z + UnskewCoeff4D; - d2w = d1w - off1w + UnskewCoeff4D; + d2x = d1x - off1x + s_UnskewCoeff4D; + d2y = d1y - off1y + s_UnskewCoeff4D; + d2z = d1z - off1z + s_UnskewCoeff4D; + d2w = d1w - off1w + s_UnskewCoeff4D; - d3x = d1x - off2x + 2.f*UnskewCoeff4D; - d3y = d1y - off2y + 2.f*UnskewCoeff4D; - d3z = d1z - off2z + 2.f*UnskewCoeff4D; - d3w = d1w - off2w + 2.f*UnskewCoeff4D; + d3x = d1x - off2x + 2.f*s_UnskewCoeff4D; + d3y = d1y - off2y + 2.f*s_UnskewCoeff4D; + d3z = d1z - off2z + 2.f*s_UnskewCoeff4D; + d3w = d1w - off2w + 2.f*s_UnskewCoeff4D; - d4x = d1x - off3x + 3.f*UnskewCoeff4D; - d4y = d1y - off3y + 3.f*UnskewCoeff4D; - d4z = d1z - off3z + 3.f*UnskewCoeff4D; - d4w = d1w - off3w + 3.f*UnskewCoeff4D; + d4x = d1x - off3x + 3.f*s_UnskewCoeff4D; + d4y = d1y - off3y + 3.f*s_UnskewCoeff4D; + d4z = d1z - off3z + 3.f*s_UnskewCoeff4D; + d4w = d1w - off3w + 3.f*s_UnskewCoeff4D; - d5x = d1x - 1.f + 4*UnskewCoeff4D; - d5y = d1y - 1.f + 4*UnskewCoeff4D; - d5z = d1z - 1.f + 4*UnskewCoeff4D; - d5w = d1w - 1.f + 4*UnskewCoeff4D; + d5x = d1x - 1.f + 4*s_UnskewCoeff4D; + d5y = d1y - 1.f + 4*s_UnskewCoeff4D; + d5z = d1z - 1.f + 4*s_UnskewCoeff4D; + d5w = d1w - 1.f + 4*s_UnskewCoeff4D; ii = skewedCubeOriginx & 255; jj = skewedCubeOriginy & 255; kk = skewedCubeOriginz & 255; ll = skewedCubeOriginw & 255; - gi0 = perm[ii + perm[jj + perm[kk + perm[ll ]]]] & 31; - gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z + perm[ll + off1w]]]] & 31; - gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z + perm[ll + off2w]]]] & 31; - gi3 = perm[ii + off3x + perm[jj + off3y + perm[kk + off3z + perm[ll + off3w]]]] & 31; - gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1 ]]]] % 32; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll ]]]] & 31; + gi1 = m_permutations[ii + off1x + m_permutations[jj + off1y + m_permutations[kk + off1z + m_permutations[ll + off1w]]]] & 31; + gi2 = m_permutations[ii + off2x + m_permutations[jj + off2y + m_permutations[kk + off2z + m_permutations[ll + off2w]]]] & 31; + gi3 = m_permutations[ii + off3x + m_permutations[jj + off3y + m_permutations[kk + off3z + m_permutations[ll + off3w]]]] & 31; + gi4 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1 ]]]] % 32; c1 = 0.6f - d1x*d1x - d1y*d1y - d1z*d1z - d1w*d1w; c2 = 0.6f - d2x*d2x - d2y*d2y - d2z*d2z - d2w*d2w; @@ -432,27 +348,27 @@ namespace Nz if(c1 < 0) n1 = 0; else - n1 = c1*c1*c1*c1*(gradient4[gi0][0]*d1x + gradient4[gi0][1]*d1y + gradient4[gi0][2]*d1z + gradient4[gi0][3]*d1w); + n1 = c1*c1*c1*c1*(s_gradients4[gi0][0]*d1x + s_gradients4[gi0][1]*d1y + s_gradients4[gi0][2]*d1z + s_gradients4[gi0][3]*d1w); if(c2 < 0) n2 = 0; else - n2 = c2*c2*c2*c2*(gradient4[gi1][0]*d2x + gradient4[gi1][1]*d2y + gradient4[gi1][2]*d2z + gradient4[gi1][3]*d2w); + n2 = c2*c2*c2*c2*(s_gradients4[gi1][0]*d2x + s_gradients4[gi1][1]*d2y + s_gradients4[gi1][2]*d2z + s_gradients4[gi1][3]*d2w); if(c3 < 0) n3 = 0; else - n3 = c3*c3*c3*c3*(gradient4[gi2][0]*d3x + gradient4[gi2][1]*d3y + gradient4[gi2][2]*d3z + gradient4[gi2][3]*d3w); + n3 = c3*c3*c3*c3*(s_gradients4[gi2][0]*d3x + s_gradients4[gi2][1]*d3y + s_gradients4[gi2][2]*d3z + s_gradients4[gi2][3]*d3w); if(c4 < 0) n4 = 0; else - n4 = c4*c4*c4*c4*(gradient4[gi3][0]*d4x + gradient4[gi3][1]*d4y + gradient4[gi3][2]*d4z + gradient4[gi3][3]*d4w); + n4 = c4*c4*c4*c4*(s_gradients4[gi3][0]*d4x + s_gradients4[gi3][1]*d4y + s_gradients4[gi3][2]*d4z + s_gradients4[gi3][3]*d4w); if(c5 < 0) n5 = 0; else - n5 = c5*c5*c5*c5*(gradient4[gi4][0]*d5x + gradient4[gi4][1]*d5y + gradient4[gi4][2]*d5z + gradient4[gi4][3]*d5w); + n5 = c5*c5*c5*c5*(s_gradients4[gi4][0]*d5x + s_gradients4[gi4][1]*d5y + s_gradients4[gi4][2]*d5z + s_gradients4[gi4][3]*d5w); return (n1+n2+n3+n4+n5)*27.f; } diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp index 603820706..9d262f6b1 100644 --- a/src/Nazara/Noise/Worley.cpp +++ b/src/Nazara/Noise/Worley.cpp @@ -10,56 +10,38 @@ namespace Nz { - Worley::Worley() : - scales{ - 1.f / std::sqrt(2), - 0.5f / std::sqrt(2), - 0.5f / std::sqrt(2), - 0.5f / std::sqrt(2) - } + namespace + { + static constexpr std::array m_functionScales = + { + 1.f / M_SQRT2, + 0.5f / M_SQRT2, + 0.5f / M_SQRT2, + 0.5f / M_SQRT2 + }; + } + Worley::Worley() : + m_function(WorleyFunction_F1) { - function = WorleyFunction_F1; } - Worley::Worley(unsigned int seed) : Worley() + Worley::Worley(unsigned int seed) : + Worley() { SetSeed(seed); Shuffle(); } - void Worley::Set(WorleyFunction func) - { - function = func; - } - - float Worley::Get(std::initializer_list coordinates, float scale) const - { - switch(coordinates.size()) - { - case 2: - return this->_2D(coordinates,scale); - case 3: - return this->_3D(coordinates,scale); - case 4: - return this->_4D(coordinates,scale); - default: - throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); - } - } - - float Worley::_2D(std::initializer_list coordinates, float scale) const + float Worley::Get(float x, float y, float scale) const { std::map featurePoints; - std::map::iterator it; float xc, yc; int x0, y0; float fractx, fracty; - std::initializer_list::const_iterator c = coordinates.begin(); - - xc = *(c ) * scale; - yc = *(++c) * scale; + xc = x * scale; + yc = y * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -69,83 +51,83 @@ namespace Nz featurePoints.clear(); - _SquareTest(x0,y0,xc,yc,featurePoints); + SquareTest(x0,y0,xc,yc,featurePoints); - it = featurePoints.begin(); - std::advance(it,function); + auto it = featurePoints.begin(); + std::advance(it, m_function); if(fractx < it->first) - _SquareTest(x0 - 1,y0,xc,yc,featurePoints); + SquareTest(x0 - 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); if(1.f - fractx < it->first) - _SquareTest(x0 + 1,y0,xc,yc,featurePoints); + SquareTest(x0 + 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); if(fracty < it->first) - _SquareTest(x0,y0 - 1,xc,yc,featurePoints); + SquareTest(x0,y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(1.f - fracty < it->first) - _SquareTest(x0,y0 + 1,xc,yc,featurePoints); + if (1.f - fracty < it->first) + SquareTest(x0,y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(fractx < it->first && - fracty < it->first) - _SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); + if (fractx < it->first && fracty < it->first) + SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(1.f - fractx < it->first && - fracty < it->first) - _SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); + if (1.f - fractx < it->first && fracty < it->first) + SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(fractx < it->first && - 1.f - fracty < it->first) - _SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); + if (fractx < it->first && 1.f - fracty < it->first) + SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(1.f - fractx < it->first && - 1.f - fracty < it->first) - _SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); + if(1.f - fractx < it->first && 1.f - fracty < it->first) + SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - return it->first * scales[function]; + return it->first * m_functionScales[m_function]; } - float Worley::_3D(std::initializer_list coordinates, float scale) const + float Worley::Get(float x, float y, float z, float scale) const { throw std::runtime_error("Worley 3D not available yet."); } - float Worley::_4D(std::initializer_list coordinates, float scale) const + float Worley::Get(float x, float y, float z, float w, float scale) const { throw std::runtime_error("Worley 4D not available yet."); } + void Worley::Set(WorleyFunction func) + { + m_function = func; + } - void Worley::_SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const + void Worley::SquareTest(int xi, int yi, float x, float y, std::map& featurePoints) const { int ii = xi & 255; int jj = yi & 255; - int seed = perm[ii + perm[jj]]; + int seed = m_permutations[ii + m_permutations[jj]]; //On initialise notre rng avec seed std::minstd_rand0 randomNumberGenerator(seed); From fbc963402c2d4c7379b533537cec44c4ad1ef95f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Jun 2016 16:09:22 +0200 Subject: [PATCH 063/235] Noise: Fix errors/warnings Former-commit-id: 946222b65928a154fa877aec46ec95c12c90905f [formerly 8f1cf976da353022689e328806e67d86e9c86a99] Former-commit-id: 4703db19b368a382922219ea49d48224bb82a6e9 --- src/Nazara/Noise/NoiseBase.cpp | 1 + src/Nazara/Noise/Perlin.cpp | 4 ---- src/Nazara/Noise/Simplex.cpp | 28 ++++++++++++------------- src/Nazara/Noise/Worley.cpp | 38 ++++++++++++++++++---------------- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp index fa5a2c92f..1dc74595a 100644 --- a/src/Nazara/Noise/NoiseBase.cpp +++ b/src/Nazara/Noise/NoiseBase.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp index e6440eb3d..a400972ff 100644 --- a/src/Nazara/Noise/Perlin.cpp +++ b/src/Nazara/Noise/Perlin.cpp @@ -76,9 +76,6 @@ namespace Nz float Li1,Li2,Li3,Li4,Li5,Li6; float s[2],t[2],u[2],v[2]; float Cx,Cy,Cz; - float nx,ny,nz; - - float tmp; float tempx,tempy,tempz; xc = x * scale; @@ -157,7 +154,6 @@ namespace Nz float s[4],t[4],u[4],v[4]; float Cx,Cy,Cz,Cw; - float tmp; float tempx,tempy,tempz,tempw; xc = x * scale; diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp index c2ce28c3f..8d4748bff 100644 --- a/src/Nazara/Noise/Simplex.cpp +++ b/src/Nazara/Noise/Simplex.cpp @@ -12,12 +12,12 @@ namespace Nz { namespace { - constexpr float s_SkewCoeff2D = 0.5f * (M_SQRT3 - 1.f); - constexpr float s_UnskewCoeff2D = (3.f - M_SQRT3)/6.f; + constexpr float s_SkewCoeff2D = 0.5f * (float(M_SQRT3) - 1.f); + constexpr float s_UnskewCoeff2D = (3.f - float(M_SQRT3))/6.f; constexpr float s_SkewCoeff3D = 1.f / 3.f; constexpr float s_UnskewCoeff3D = 1.f / 6.f; - constexpr float s_SkewCoeff4D = (M_SQRT5 - 1.f)/4.f; - constexpr float s_UnskewCoeff4D = (5.f - M_SQRT5)/20.f; + constexpr float s_SkewCoeff4D = (float(M_SQRT5) - 1.f)/4.f; + constexpr float s_UnskewCoeff4D = (5.f - float(M_SQRT5))/20.f; } Simplex::Simplex(unsigned int seed) @@ -39,7 +39,7 @@ namespace Nz Vector2f unskewedDistToOrigin(xc - unskewedCubeOrigin.x, yc - unskewedCubeOrigin.y); - Vector2f off1; + Vector2ui off1; if(unskewedDistToOrigin.x > unskewedDistToOrigin.y) off1.Set(1, 0); else @@ -47,7 +47,7 @@ namespace Nz std::array d; d[0] = -unskewedDistToOrigin; - d[1] = d[0] + off1 - Vector2f(s_UnskewCoeff2D); + d[1] = d[0] + Vector2f(off1) - Vector2f(s_UnskewCoeff2D); d[2] = d[0] + Vector2f(1.f - 2.f * s_UnskewCoeff2D); Vector2i offset(skewedCubeOrigin.x & 255, skewedCubeOrigin.y & 255); @@ -248,7 +248,7 @@ namespace Nz int c; float n1,n2,n3,n4,n5; - float c1,c2,c3,c4,c5,c6; + float c1,c2,c3,c4,c5; float sum; float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; @@ -280,13 +280,13 @@ namespace Nz unskewedDistToOriginz = zc - unskewedCubeOriginz; unskewedDistToOriginw = wc - unskewedCubeOriginw; - c1 = (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0; - c2 = (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0; - c3 = (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0; - c4 = (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0; - c5 = (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0; - c6 = (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; - c = c1 + c2 + c3 + c4 + c5 + c6; + c = 0; + c += (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0; + c += (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0; + c += (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0; + c += (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0; + c += (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0; + c += (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; off1x = lookupTable[c][0] >= 3 ? 1 : 0; off1y = lookupTable[c][1] >= 3 ? 1 : 0; diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp index 9d262f6b1..cc98fa378 100644 --- a/src/Nazara/Noise/Worley.cpp +++ b/src/Nazara/Noise/Worley.cpp @@ -14,10 +14,10 @@ namespace Nz { static constexpr std::array m_functionScales = { - 1.f / M_SQRT2, - 0.5f / M_SQRT2, - 0.5f / M_SQRT2, - 0.5f / M_SQRT2 + 1.f / float(M_SQRT2), + 0.5f / float(M_SQRT2), + 0.5f / float(M_SQRT2), + 0.5f / float(M_SQRT2) }; } Worley::Worley() : @@ -53,58 +53,60 @@ namespace Nz SquareTest(x0,y0,xc,yc,featurePoints); + std::size_t functionIndex = static_cast(m_function); + auto it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(fractx < it->first) SquareTest(x0 - 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(1.f - fractx < it->first) SquareTest(x0 + 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(fracty < it->first) SquareTest(x0,y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (1.f - fracty < it->first) SquareTest(x0,y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (fractx < it->first && fracty < it->first) SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (1.f - fractx < it->first && fracty < it->first) SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (fractx < it->first && 1.f - fracty < it->first) SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(1.f - fractx < it->first && 1.f - fracty < it->first) SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); - return it->first * m_functionScales[m_function]; + return it->first * m_functionScales[functionIndex]; } float Worley::Get(float x, float y, float z, float scale) const @@ -127,16 +129,16 @@ namespace Nz int ii = xi & 255; int jj = yi & 255; - int seed = m_permutations[ii + m_permutations[jj]]; + std::size_t seed = m_permutations[ii + m_permutations[jj]]; //On initialise notre rng avec seed - std::minstd_rand0 randomNumberGenerator(seed); + std::minstd_rand0 randomNumberGenerator(static_cast(seed)); //On prend un nombre de points à déterminer dans le cube, compris entre 1 et 8 - unsigned int m = (seed & 7) + 1; + std::size_t m = (seed & 7) + 1; //On calcule les emplacements des différents points - for(unsigned int i(0) ; i < m ; ++i) + for(std::size_t i(0) ; i < m; ++i) { Nz::Vector2f featurePoint; featurePoint.x = (randomNumberGenerator() & 1023) / 1023.f + static_cast(xi); From 23e9a9cb6610b0c2094e04005b1e470122f49033 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 09:05:22 +0200 Subject: [PATCH 064/235] Examples/FirstScene: Add console and Ndk::Application Former-commit-id: 7d29f56e8835498e8b0d995770bc8eca80e7cba6 [formerly b8a6abdfacad3cc83a890e86b376fa6baaeb9c50] Former-commit-id: 1bcd65259f23ef18e410e67970b7d0dc55829a80 --- examples/FirstScene/main.cpp | 212 +++++++++++++++++++++++------------ 1 file changed, 142 insertions(+), 70 deletions(-) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 385b054e0..07e26cd1c 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -1,25 +1,27 @@ /* -** FirstScene - Première scène graphique -** Prérequis: Aucun -** Utilisation du module utilitaire et graphique -** Présente: -** - Création et gestion d'une fenêtre (Traitement des évènements clavier/souris) -** - Gestion du clavier (Récupération de l'état d'une touche) -** - Des outils pour afficher une scène basique via le chargement d'un modèle (et son affichage) -** - Éclairage directionnel -** - Gestion d'une caméra free-fly (Avec déplacement fluide) -** - Gestion basique d'une horloge +* FirstScene - Première scène graphique +* Prérequis: Aucun +* Utilisation du module utilitaire et graphique +** Présente : + * -Création et gestion d'une fenêtre (Traitement des évènements clavier/souris) + * -Gestion du clavier(Récupération de l'état d'une touche) + * -Des outils pour afficher une scène basique via le chargement d'un modèle (et son affichage) + * -Éclairage directionnel + * -Gestion d'une caméra free-fly (Avec déplacement fluide) + * -Gestion basique d'une horloge + * -Console */ #include // Horloges +#include // Module de scripting #include // Module graphique #include // Module de rendu #include // Module utilitaire -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -29,26 +31,15 @@ Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& ta int main() { - // Pour commencer, nous initialisons le SDK de Nazara, celui-ci va préparer le terrain en initialisant le moteur, - // les composants, systèmes, etc. - // NzInitializer est une classe RAII appelant Initialize dans son constructeur et Uninitialize dans son destructeur. - // Autrement dit, une fois ceci fait nous n'avons plus à nous soucier de la libération du moteur. - Nz::Initializer nazara; - if (!nazara) - { - // Une erreur s'est produite dans l'initialisation d'un des modules - std::cout << "Failed to initialize Nazara, see NazaraLog.log for further informations" << std::endl; - std::getchar(); // On laise le temps de voir l'erreur - - return EXIT_FAILURE; - } + // Ndk::Application est une classe s'occupant de l'initialisation du moteur ainsi que de la gestion de beaucoup de choses + Ndk::Application application; // Nazara étant initialisé, nous pouvons créer le monde pour contenir notre scène. // Dans un ECS, le monde représente bien ce que son nom indique, c'est l'ensemble de ce qui existe au niveau de l'application. // Il contient les systèmes et les entités, ces dernières contiennent les composants. // Il est possible d'utiliser plusieurs mondes au sein d'une même application, par exemple pour gérer un mélange de 2D et de 3D, // mais nous verrons cela dans un prochain exemple. - Ndk::World world; + Ndk::WorldHandle world = application.AddWorld().CreateHandle(); // Nous pouvons maintenant ajouter des systèmes, mais dans cet exemple nous nous contenterons de ceux de base. @@ -73,7 +64,7 @@ int main() Nz::SkyboxBackgroundRef skybox = Nz::SkyboxBackground::New(std::move(texture)); // Accédons maintenant au système de rendu faisant partie du monde - Ndk::RenderSystem& renderSystem = world.GetSystem(); // Une assertion valide la précondition "le système doit faire partie du monde" + Ndk::RenderSystem& renderSystem = world->GetSystem(); // Une assertion valide la précondition "le système doit faire partie du monde" // Nous assignons ensuite notre skybox comme "fond par défaut" du système // La notion "par défaut" existe parce qu'une caméra pourrait utiliser son propre fond lors du rendu, @@ -146,7 +137,7 @@ int main() // Bien, nous avons un modèle valide, mais celui-ci ne consiste qu'en des informations de rendu, de matériaux et de textures. // Commençons donc par créer une entité vide, cela se fait en demandant au monde de générer une nouvelle entité. - Ndk::EntityHandle spaceship = world.CreateEntity(); + Ndk::EntityHandle spaceship = world->CreateEntity(); // Note: Nous ne récupérons pas l'entité directement mais un "handle" vers elle, ce dernier est un pointeur intelligent non-propriétaire. // Pour des raisons techniques, le pointeur de l'entité peut venir à changer, ou l'entité être simplement détruite pour n'importe quelle raison. @@ -159,6 +150,7 @@ int main() // Étant donné que par défaut, un NodeComponent se place en (0,0,0) sans rotation et avec une échelle de 1,1,1 et que cela nous convient, // nous n'avons pas besoin d'agir sur le composant créé. spaceship->AddComponent(); + //spaceship->AddComponent().linearVelocity.Set(-1.f, 0.f, 0.f); // Bien, notre entité nouvellement créé dispose maintenant d'une position dans la scène, mais est toujours invisible // Nous lui ajoutons donc un GraphicsComponent @@ -178,7 +170,7 @@ int main() // Nous créons donc une seconde entité // Note: La création d'entité est une opération légère au sein du moteur, mais plus vous aurez d'entités et plus le processeur devra travailler. - Ndk::EntityHandle camera = world.CreateEntity(); + Ndk::EntityHandle camera = world->CreateEntity(); // Notre caméra a elle aussi besoin d'être positionnée dans la scène Ndk::NodeComponent& cameraNode = camera->AddComponent(); @@ -188,6 +180,9 @@ int main() // Et dispose d'un composant pour chaque point de vue de la scène, le CameraComponent Ndk::CameraComponent& cameraComp = camera->AddComponent(); + // Ajoutons un composant écouteur, si nous venions à avoir du son + camera->AddComponent(); + // Et on n'oublie pas de définir les plans délimitant le champs de vision // (Seul ce qui se trouvera entre les deux plans sera rendu) @@ -208,7 +203,7 @@ int main() // Nous allons créer une lumière directionnelle pour représenter la nébuleuse de notre skybox // Encore une fois, nous créons notre entité - Ndk::EntityHandle nebulaLight = world.CreateEntity(); + Ndk::EntityHandle nebulaLight = world->CreateEntity(); // Lui ajoutons une position dans la scène Ndk::NodeComponent& nebulaLightNode = nebulaLight->AddComponent(); @@ -246,7 +241,7 @@ int main() Nz::RenderTargetParameters parameters; parameters.antialiasingLevel = 4; - Nz::RenderWindow window(mode, windowTitle, style, parameters); + Nz::RenderWindow& window = application.AddWindow(mode, windowTitle, style, parameters); if (!window.IsValid()) { std::cout << "Failed to create render window" << std::endl; @@ -272,8 +267,70 @@ int main() bool smoothMovement = true; Nz::Vector3f targetPos = cameraNode.GetPosition(); - // Début de la boucle de rendu du programme - while (window.IsOpen()) + // Pour ajouter une console à notre application, nous avons besoin d'un monde 2D pour gérer ces rendus + Ndk::WorldHandle world2D = application.AddWorld().CreateHandle(); + world2D->GetSystem().SetDefaultBackground(nullptr); + world2D->GetSystem().SetGlobalUp(Nz::Vector3f::Down()); + + // Nous ajoutons une caméra comme précédement + Ndk::EntityHandle viewEntity = world2D->CreateEntity(); + viewEntity->AddComponent(); + + // À la différence que celui-ci effectuera une projection orthogonale + Ndk::CameraComponent& viewer = viewEntity->AddComponent(); + viewer.SetTarget(&window); + viewer.SetProjectionType(Nz::ProjectionType_Orthogonal); + + // Nous créons un environnement Lua pour gérer nos scripts + Nz::LuaInstance lua; + + // Faisons en sorte d'enregistrer les classes du moteur dans cet environnement + Ndk::LuaAPI::RegisterClasses(lua); + + // Ensuite nous créons la console en elle-même + Ndk::Console console(*world2D, Nz::Vector2f(window.GetWidth(), window.GetHeight() / 4), lua); + + // Nous redirigeons les logs vers cette console + Nz::Log::OnLogWriteType::ConnectionGuard logGuard = Nz::Log::OnLogWrite.Connect([&console] (const Nz::String& str) + { + console.AddLine(str); + }); + + // Nous réécrivons la fonction "print" du Lua pour la rediriger vers la console + lua.PushFunction([&console] (Nz::LuaInstance& instance) + { + Nz::StringStream stream; + + unsigned int argCount = instance.GetStackTop(); + instance.GetGlobal("tostring"); + for (unsigned int i = 1; i <= argCount; ++i) + { + instance.PushValue(-1); // ToString + instance.PushValue(i); // Arg + instance.Call(1, 1); + + std::size_t length; + const char* str = instance.CheckString(-1, &length); + if (i > 1) + stream << '\t'; + + stream << Nz::String(str, length); + instance.Pop(1); + } + + console.AddLine(stream); + return 0; + }); + lua.SetGlobal("print"); + + // Définissons quelques variables de base + lua.PushGlobal("Application", Ndk::Application::Instance()); + lua.PushGlobal("Console", console.CreateHandle()); + lua.PushGlobal("Spaceship", spaceship->CreateHandle()); + lua.PushGlobal("World", world->CreateHandle()); + + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) + while (application.Run()) { // Ensuite nous allons traiter les évènements (Étape indispensable pour la fenêtre) Nz::WindowEvent event; @@ -283,6 +340,9 @@ int main() { case Nz::WindowEventType_MouseMoved: // La souris a bougé { + if (console.IsVisible()) + break; + // Gestion de la caméra free-fly (Rotation) float sensitivity = 0.3f; // Sensibilité de la souris @@ -297,15 +357,18 @@ int main() // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved - Nz::Mouse::SetPosition(window.GetWidth()/2, window.GetHeight()/2, window); + Nz::Mouse::SetPosition(window.GetWidth() / 2, window.GetHeight() / 2, window); break; } case Nz::WindowEventType_Quit: // L'utilisateur a cliqué sur la croix, ou l'OS veut terminer notre programme - window.Close(); // On demande la fermeture de la fenêtre (Qui aura lieu au prochain tour de boucle) + application.Quit(); break; case Nz::WindowEventType_KeyPressed: // Une touche a été pressée ! + if (console.IsVisible()) + console.SendEvent(event); + if (event.key.code == Nz::Keyboard::Key::Escape) window.Close(); else if (event.key.code == Nz::Keyboard::F1) @@ -318,6 +381,19 @@ int main() else smoothMovement = true; } + else if (event.key.code == Nz::Keyboard::F9) + console.Show(!console.IsVisible()); + break; + + case Nz::WindowEventType_TextEntered: + { + if (console.IsVisible()) + console.SendCharacter(event.text.character); + break; + } + + case Nz::WindowEventType_Resized: + console.SetSize({float(event.size.width), event.size.height / 4.f}); break; default: @@ -337,52 +413,48 @@ int main() { // Le temps écoulé en seconde depuis la dernière fois que ce bloc a été exécuté float elapsedTime = updateAccumulator / 1000000.f; - std::cout << elapsedTime << std::endl; // Vitesse de déplacement de la caméra float cameraSpeed = 3.f * elapsedTime; // Trois mètres par seconde - // Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space)) - cameraSpeed *= 2.f; + if (!console.IsVisible()) + { + // Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space)) + cameraSpeed *= 2.f; - // Pour que nos déplacement soient liés à la rotation de la caméra, nous allons utiliser - // les directions locales de la caméra + // Pour que nos déplacement soient liés à la rotation de la caméra, nous allons utiliser + // les directions locales de la caméra - // Si la flèche du haut ou la touche Z (vive ZQSD) est pressée, on avance - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z)) - targetPos += cameraNode.GetForward() * cameraSpeed; + // Si la flèche du haut ou la touche Z (vive ZQSD) est pressée, on avance + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z)) + targetPos += cameraNode.GetForward() * cameraSpeed; - // Si la flèche du bas ou la touche S est pressée, on recule - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S)) - targetPos += cameraNode.GetBackward() * cameraSpeed; + // Si la flèche du bas ou la touche S est pressée, on recule + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S)) + targetPos += cameraNode.GetBackward() * cameraSpeed; - // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q)) - targetPos += cameraNode.GetLeft() * cameraSpeed; + // Etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q)) + targetPos += cameraNode.GetLeft() * cameraSpeed; - // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D)) - targetPos += cameraNode.GetRight() * cameraSpeed; + // Etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D)) + targetPos += cameraNode.GetRight() * cameraSpeed; - // Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation) - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) - targetPos += Nz::Vector3f::Up() * cameraSpeed; + // Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) + targetPos += Nz::Vector3f::Up() * cameraSpeed; - // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl)) - targetPos += Nz::Vector3f::Down() * cameraSpeed; + // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl)) + targetPos += Nz::Vector3f::Down() * cameraSpeed; + } cameraNode.SetPosition((smoothMovement) ? DampedString(cameraNode.GetPosition(), targetPos, elapsedTime) : targetPos, Nz::CoordSys_Global); - updateAccumulator = 0; } - // Et maintenant pour rendre la scène, il nous suffit de mettre à jour le monde en lui envoyant le temps depuis la dernière mise à jour - // Note: La plupart des systèmes, à l'exception de celui de rendu, ont une fréquence de mise à jour fixe (modifiable) - // Il n'est donc pas nécessaire de limiter vous-même les mises à jour du monde - world.Update(elapsedUS / 1000000.f); - // Après avoir dessiné sur la fenêtre, il faut s'assurer qu'elle affiche cela // Cet appel ne fait rien d'autre qu'échanger les buffers de rendu (Double Buffering) window.Display(); @@ -410,7 +482,7 @@ int main() } } - return EXIT_SUCCESS; + return EXIT_SUCCESS; } Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& targetPos, float frametime, float springStrength) @@ -430,7 +502,7 @@ Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& ta if (Nz::NumberEquals(displacementLength, 0.f)) return currentPos; - float invDisplacementLength = 1.f/displacementLength; + float invDisplacementLength = 1.f / displacementLength; const float dampConstant = 0.000065f; // Something v.small to offset 1/ displacement length From daf1dadda0103261c3d806c07eeaf926bac9940e Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 13:10:09 +0200 Subject: [PATCH 065/235] Core/ObjectRef: Add comparison operators Former-commit-id: 74028870996d72cb0fa707c27342c892168f8fe4 [formerly 0eb6bb74988e76213f9e534a376b1c0af14a7c92] Former-commit-id: 006289f7a338a263f91832039850751e685b9ceb --- include/Nazara/Core/ObjectRef.hpp | 29 +++- include/Nazara/Core/ObjectRef.inl | 235 ++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/ObjectRef.hpp b/include/Nazara/Core/ObjectRef.hpp index 6f3ccab9a..d1cd13ec0 100644 --- a/include/Nazara/Core/ObjectRef.hpp +++ b/include/Nazara/Core/ObjectRef.hpp @@ -44,8 +44,33 @@ namespace Nz T* m_object; }; - template struct PointedType> {typedef T type;}; - template struct PointedType const> {typedef T type;}; + template bool operator==(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator==(const T& lhs, const ObjectRef& rhs); + template bool operator==(const ObjectRef& lhs, const T& rhs); + + template bool operator!=(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator!=(const T& lhs, const ObjectRef& rhs); + template bool operator!=(const ObjectRef& lhs, const T& rhs); + + template bool operator<(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator<(const T& lhs, const ObjectRef& rhs); + template bool operator<(const ObjectRef& lhs, const T& rhs); + + template bool operator<=(const ObjectRef, const ObjectRef& rhs); + template bool operator<=(const T& lhs, const ObjectRef& rhs); + template bool operator<=(const ObjectRef& lhs, const T& rhs); + + template bool operator>(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator>(const T& lhs, const ObjectRef& rhs); + template bool operator>(const ObjectRef& lhs, const T& rhs); + + template bool operator>=(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator>=(const T& lhs, const ObjectRef& rhs); + template bool operator>=(const ObjectRef& lhs, const T& rhs); + + + template struct PointedType> { typedef T type; }; + template struct PointedType const> { typedef T type; }; } #include diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index ad74b4f2e..8dab06948 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -245,6 +245,241 @@ namespace Nz return *this; } + + + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator==(const ObjectRef& lhs, const ObjectRef& rhs) + { + return lhs.Get() == rhs.Get(); + } + + /*! + * \brief Checks whether the object is equal to the second object handle + * \return true if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator==(const T& lhs, const ObjectRef& rhs) + { + return &lhs == rhs.Get(); + } + + /*! + * \brief Checks whether the object handle is equal to the second object + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second Object to compare in right hand side + */ + template + bool operator==(const ObjectRef& lhs, const T& rhs) + { + return lhs.Get() == &rhs; + } + + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return false if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator!=(const ObjectRef& lhs, const ObjectRef& rhs) + { + return !(lhs == rhs); + } + + /*! + * \brief Checks whether the object is equal to the second object handle + * \return false if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator!=(const T& lhs, const ObjectRef& rhs) + { + return !(lhs == rhs); + } + + /*! + * \brief Checks whether the object handle is equal to the second object + * \return false if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second Object to compare in right hand side + */ + template + bool operator!=(const ObjectRef& lhs, const T& rhs) + { + return !(lhs == rhs); + } + + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<(const ObjectRef& lhs, const ObjectRef& rhs) + { + return lhs.m_object < rhs.m_object; + } + + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<(const T& lhs, const ObjectRef& rhs) + { + return &lhs < rhs.m_object; + } + + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<(const ObjectRef& lhs, const T& rhs) + { + return lhs.m_object < &rhs; + } + + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<=(const ObjectRef& lhs, const ObjectRef& rhs) + { + return !(lhs > rhs); + } + + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<=(const T& lhs, const ObjectRef& rhs) + { + return !(lhs > rhs); + } + + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<=(const ObjectRef& lhs, const T& rhs) + { + return !(lhs > rhs); + } + + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>(const ObjectRef& lhs, const ObjectRef& rhs) + { + return rhs < lhs; + } + + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>(const T& lhs, const ObjectRef& rhs) + { + return rhs < lhs; + } + + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>(const ObjectRef& lhs, const T& rhs) + { + return rhs < lhs; + } + + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>=(const ObjectRef& lhs, const ObjectRef& rhs) + { + return !(lhs < rhs); + } + + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>=(const T& lhs, const ObjectRef& rhs) + { + return !(lhs < rhs); + } + + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>=(const ObjectRef& lhs, const T& rhs) + { + return !(lhs < rhs); + } } namespace std From 31f052d405f09c837cf24eb43a21f8bc347cd970 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 13:11:31 +0200 Subject: [PATCH 066/235] Sdk/GraphicsComponent: Add Detach method Former-commit-id: 08d5c0fa0d1cd09d6f58a0dfe75a3d952b62cae6 [formerly 75463d92e087e8791feda751fe2514c18fedf942] Former-commit-id: aebd5945083f9339294077701093184f7700704b --- .../NDK/Components/GraphicsComponent.hpp | 18 ++++++++++++++++++ .../NDK/Components/GraphicsComponent.inl | 13 +++++++++++++ .../Nazara/Graphics/InstancedRenderable.hpp | 17 +++++++++++++++-- src/Nazara/Core/String.cpp | 2 +- src/Nazara/Graphics/Billboard.cpp | 2 +- src/Nazara/Graphics/InstancedRenderable.cpp | 2 +- src/Nazara/Graphics/Model.cpp | 2 +- src/Nazara/Graphics/SkeletalModel.cpp | 2 +- src/Nazara/Graphics/Sprite.cpp | 8 ++++---- src/Nazara/Graphics/TextSprite.cpp | 2 +- 10 files changed, 56 insertions(+), 12 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index c94cec4ab..f079303b8 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -31,6 +31,8 @@ namespace Ndk inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); + inline void Detach(Nz::InstancedRenderableRef renderable); + inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; @@ -63,6 +65,22 @@ namespace Ndk { } + Renderable(Renderable&& renderable) noexcept : + data(std::move(renderable.data)), + renderable(std::move(renderable.renderable)), + dataUpdated(renderable.dataUpdated) + { + } + + Renderable& operator=(Renderable&& r) noexcept + { + data = std::move(r.data); + dataUpdated = r.dataUpdated; + renderable = std::move(r.renderable); + + return *this; + } + NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot); mutable Nz::InstancedRenderable::InstanceData data; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index c330da5eb..c736ecc48 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include "GraphicsComponent.hpp" namespace Ndk { @@ -46,6 +47,18 @@ namespace Ndk InvalidateBoundingVolume(); } + inline void GraphicsComponent::Detach(Nz::InstancedRenderableRef renderable) + { + for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) + { + if (it->renderable == renderable) + { + m_renderables.erase(it); + break; + } + } + } + inline void GraphicsComponent::EnsureBoundingVolumeUpdate() const { if (!m_boundingVolumeUpdated) diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index 561cc4c97..d1c07bf9b 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -55,14 +55,27 @@ namespace Nz struct InstanceData { InstanceData(Matrix4f& referenceMatrix) : - transformMatrix(referenceMatrix), + transformMatrix(&referenceMatrix), flags(0) { } + InstanceData(InstanceData&& instanceData) noexcept = default; + + InstanceData& operator=(InstanceData&& instanceData) noexcept + { + data = std::move(instanceData.data); + flags = instanceData.flags; + renderOrder = instanceData.renderOrder; + transformMatrix = instanceData.transformMatrix; + volume = instanceData.volume; + + return *this; + } + std::vector data; BoundingVolumef volume; - Matrix4f& transformMatrix; + Matrix4f* transformMatrix; UInt32 flags; int renderOrder; }; diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index a57d89861..21831bcdf 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -211,7 +211,7 @@ namespace Nz */ String::String(const std::string& string) : - String(string.c_str(), string.size()) + String(string.data(), string.size()) { } diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 6f47e9847..e06d3c921 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -30,7 +30,7 @@ namespace Nz if (!m_material) return; - renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix.GetTranslation(), m_size, m_sinCos, m_color); + renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix->GetTranslation(), m_size, m_sinCos, m_color); } /* diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index ef5f62b96..03da17984 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -80,7 +80,7 @@ namespace Nz NazaraAssert(instanceData, "Invalid instance data"); NazaraUnused(instanceData); - instanceData->volume.Update(instanceData->transformMatrix); + instanceData->volume.Update(*instanceData->transformMatrix); } /*! diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index d382c77d9..2b9e03cc1 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -82,7 +82,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = mesh->GetVertexBuffer(); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), *instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index b91ac0076..8621d1fce 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -69,7 +69,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = SkinningManager::GetBuffer(mesh, &m_skeleton); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), *instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 76bf5fff2..4bf076183 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -58,19 +58,19 @@ namespace Nz SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(0.f)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 42dba4aaf..2f1d733b4 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -310,7 +310,7 @@ namespace Nz Vector3f localPos = localVertex->position.x*Vector3f::Right() + localVertex->position.y*Vector3f::Down(); localPos *= m_scale; - *pos++ = instanceData->transformMatrix.Transform(localPos); + *pos++ = instanceData->transformMatrix->Transform(localPos); *color++ = m_color * localVertex->color; *uv++ = localVertex->uv; From 8162c2f80f28df73004508bf74f2666d9198c0e0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 13:12:09 +0200 Subject: [PATCH 067/235] Renderer/RenderWindow: Fix visibility of OnWindow*() events Former-commit-id: 87e307e9d7872c9d4d1b8012813d9d9f59ae67d2 [formerly 3eb2b440d85ada54bd4a5e67cc05f1651e7c1e4d] Former-commit-id: 227258c9b7ebdc06563909bd30e37ef10eeae51b --- include/Nazara/Renderer/RenderWindow.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index d9889d803..1cda9d63d 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -65,12 +65,11 @@ namespace Nz protected: bool Activate() const override; void EnsureTargetUpdated() const override; - - private: bool OnWindowCreated() override; void OnWindowDestroy() override; void OnWindowResized() override; + private: mutable std::vector m_buffer; Clock m_clock; ContextParameters m_parameters; From 6f822d108e51af1f0f591c0e395ba19662803e0d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 21 Jun 2016 19:14:29 +0200 Subject: [PATCH 068/235] Sdk/GraphicsComponent: Add Clear method Former-commit-id: 7a00890f7ac8d3e41a292c40729cbf82d67e36bf [formerly 4f374228719546822f1aca22740cad962b77725e] Former-commit-id: d10271976c1128f0f9479fb1c9b245d1189e3604 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 4 +++- SDK/include/NDK/Components/GraphicsComponent.inl | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index f079303b8..aed427105 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -31,7 +31,9 @@ namespace Ndk inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); - inline void Detach(Nz::InstancedRenderableRef renderable); + inline void Clear(); + + inline void Detach(const Nz::InstancedRenderableRef& renderable); inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index c736ecc48..9ca100d0e 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -47,12 +47,20 @@ namespace Ndk InvalidateBoundingVolume(); } - inline void GraphicsComponent::Detach(Nz::InstancedRenderableRef renderable) + inline void GraphicsComponent::Clear() + { + m_renderables.clear(); + + InvalidateBoundingVolume(); + } + + inline void GraphicsComponent::Detach(const Nz::InstancedRenderableRef& renderable) { for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) { if (it->renderable == renderable) { + InvalidateBoundingVolume(); m_renderables.erase(it); break; } From ca534dde21580915521c5117db7109ec806558f4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 23 Jun 2016 00:37:32 +0200 Subject: [PATCH 069/235] Core/PluginManager: Fix usage of Mount(Plugin) Former-commit-id: 309a437a34b1bd9e1937a4df957603b9d5f8d3e3 [formerly 1f7e9d45a97e3b177e9b70e60f067b617fe93c41] Former-commit-id: 299fa6ff478ccf12fe007cdc800167904aa6ebbc --- src/Nazara/Core/PluginManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Core/PluginManager.cpp b/src/Nazara/Core/PluginManager.cpp index 24fbafcfb..b71af6677 100644 --- a/src/Nazara/Core/PluginManager.cpp +++ b/src/Nazara/Core/PluginManager.cpp @@ -19,8 +19,7 @@ namespace Nz String s_pluginFiles[] = { - "NazaraAssimp", // Plugin_Assimp - "NazaraFreetype" // Plugin_FreeType + "PluginAssimp", // Plugin_Assimp }; } @@ -80,7 +79,13 @@ namespace Nz bool PluginManager::Mount(Plugin plugin) { - return Mount(s_pluginFiles[plugin]); + Nz::String pluginName = s_pluginFiles[plugin]; + #ifdef NAZARA_DEBUG + if (Mount(pluginName + "-d", true)) + return true; + #endif + + return Mount(pluginName, true); } /*! From af2b394454af8474c5f8fa63f657c2d50cf2fde4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:56:18 +0200 Subject: [PATCH 070/235] Graphics/Material: Add SaveToParameters Former-commit-id: 9e306a5d78bd32b95fccd586872d248be2679f16 [formerly 87e583f68b3ef903311573e88d2b3f6a2969184d] Former-commit-id: c7eced4bfcc44228c8466fefe05955c4a152974d --- include/Nazara/Graphics/Material.hpp | 2 + src/Nazara/Graphics/Material.cpp | 100 ++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 85c4d315c..b30c215c1 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -120,6 +120,8 @@ namespace Nz void Reset(); + void SaveToParameters(ParameterList* matData); + inline bool SetAlphaMap(const String& textureName); inline void SetAlphaMap(TextureRef alphaMap); inline void SetAlphaThreshold(float alphaThreshold); diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index bfc6ee88a..14da83eb0 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -310,10 +310,108 @@ namespace Nz SetShader(matParams.shaderName); } + void Material::SaveToParameters(ParameterList* matData) + { + NazaraAssert(matData, "Invalid ParameterList"); + + matData->SetParameter(MaterialData::AlphaTest, IsAlphaTestEnabled()); + matData->SetParameter(MaterialData::AlphaThreshold, GetAlphaThreshold()); + matData->SetParameter(MaterialData::AmbientColor, GetAmbientColor()); + matData->SetParameter(MaterialData::CullingSide, int(GetFaceCulling())); + matData->SetParameter(MaterialData::DepthFunc, int(GetDepthFunc())); + matData->SetParameter(MaterialData::DepthSorting, IsDepthSortingEnabled()); + matData->SetParameter(MaterialData::DiffuseColor, GetDiffuseColor()); + matData->SetParameter(MaterialData::DstBlend, int(GetDstBlend())); + matData->SetParameter(MaterialData::FaceFilling, int(GetFaceFilling())); + matData->SetParameter(MaterialData::Lighting, IsLightingEnabled()); + matData->SetParameter(MaterialData::LineWidth, GetRenderStates().lineWidth); + matData->SetParameter(MaterialData::PointSize, GetRenderStates().pointSize); + matData->SetParameter(MaterialData::Shininess, GetShininess()); + matData->SetParameter(MaterialData::SpecularColor, GetSpecularColor()); + matData->SetParameter(MaterialData::SrcBlend, int(GetSrcBlend())); + matData->SetParameter(MaterialData::Transform, IsTransformEnabled()); + + // RendererParameter + matData->SetParameter(MaterialData::Blending, GetRenderStates().parameters[RendererParameter_Blend]); + matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().parameters[RendererParameter_ColorWrite]); + matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().parameters[RendererParameter_DepthBuffer]); + matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().parameters[RendererParameter_DepthWrite]); + matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().parameters[RendererParameter_FaceCulling]); + matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().parameters[RendererParameter_ScissorTest]); + matData->SetParameter(MaterialData::StencilTest, GetRenderStates().parameters[RendererParameter_StencilTest]); + + // Samplers + matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, int(GetDiffuseSampler().GetAnisotropicLevel())); + matData->SetParameter(MaterialData::DiffuseFilter, int(GetDiffuseSampler().GetFilterMode())); + matData->SetParameter(MaterialData::DiffuseWrap, int(GetDiffuseSampler().GetWrapMode())); + + matData->SetParameter(MaterialData::SpecularAnisotropyLevel, int(GetSpecularSampler().GetAnisotropicLevel())); + matData->SetParameter(MaterialData::SpecularFilter, int(GetSpecularSampler().GetFilterMode())); + matData->SetParameter(MaterialData::SpecularWrap, int(GetSpecularSampler().GetWrapMode())); + + // Stencil + matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().frontFace.stencilCompare)); + matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().frontFace.stencilFail)); + matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().frontFace.stencilPass)); + matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().frontFace.stencilZFail)); + matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().frontFace.stencilMask)); + matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().frontFace.stencilReference)); + + // Stencil (back) + matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().backFace.stencilCompare)); + matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().backFace.stencilFail)); + matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().backFace.stencilPass)); + matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().backFace.stencilZFail)); + matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().backFace.stencilMask)); + matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().backFace.stencilReference)); + + // Textures + if (HasAlphaMap()) + { + const String& path = GetAlphaMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::AlphaTexturePath, path); + } + + if (HasDiffuseMap()) + { + const String& path = GetDiffuseMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::DiffuseTexturePath, path); + } + + if (HasEmissiveMap()) + { + const String& path = GetEmissiveMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::EmissiveTexturePath, path); + } + + if (HasHeightMap()) + { + const String& path = GetHeightMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::HeightTexturePath, path); + } + + if (HasNormalMap()) + { + const String& path = GetNormalMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::NormalTexturePath, path); + } + + if (HasSpecularMap()) + { + const String& path = GetSpecularMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::SpecularTexturePath, path); + } + } + /*! * \brief Resets the material, cleans everything */ - void Material::Reset() { OnMaterialReset(this); From b82b291de84b27a8dd17314da770b24034895db6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:56:45 +0200 Subject: [PATCH 071/235] Core/StringStream: Add Clear and GetBufferSize methods Former-commit-id: 946de91235bfc52a887f9607346c246482fb2535 [formerly 63a5cb1e59bf0a6d880b9d819196d71d99e8f6ac] Former-commit-id: 270a12bf160b5d87304e8c6beb2a21ec0bc09e83 --- include/Nazara/Core/StringStream.hpp | 4 +++ src/Nazara/Core/StringStream.cpp | 41 +++++++++++++--------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/Nazara/Core/StringStream.hpp b/include/Nazara/Core/StringStream.hpp index da68e8b27..f727ed35c 100644 --- a/include/Nazara/Core/StringStream.hpp +++ b/include/Nazara/Core/StringStream.hpp @@ -22,6 +22,10 @@ namespace Nz StringStream(const StringStream&) = default; StringStream(StringStream&&) noexcept = default; + void Clear(); + + std::size_t GetBufferSize() const; + String ToString() const; StringStream& operator=(const StringStream&) = default; diff --git a/src/Nazara/Core/StringStream.cpp b/src/Nazara/Core/StringStream.cpp index ebd509c65..14d35799d 100644 --- a/src/Nazara/Core/StringStream.cpp +++ b/src/Nazara/Core/StringStream.cpp @@ -1,3 +1,4 @@ +#include "..\..\..\include\Nazara\Core\StringStream.hpp" // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -16,7 +17,6 @@ namespace Nz /*! * \brief Constructs a StringStream object by default */ - StringStream::StringStream() : m_bufferSize(0) { @@ -27,18 +27,34 @@ namespace Nz * * \param str First value of the stream */ - StringStream::StringStream(const String& str) : m_bufferSize(str.GetSize()) { m_strings.push_back(str); } + /*! + * \brief Resets the state of the stream, erasing every contained text + */ + void StringStream::Clear() + { + m_bufferSize = 0; + m_strings.clear(); + } + + /*! + * \brief Get the current buffer size + * \return The internal accumulation buffer size, this is equivalent to the size of the final string + */ + std::size_t StringStream::GetBufferSize() const + { + return m_bufferSize; + } + /*! * \brief Gives a string representation * \return A string representation of the object where every objects of the stream has been converted with Nz::String */ - String StringStream::ToString() const { String string; @@ -56,7 +72,6 @@ namespace Nz * * \param boolean Boolean value */ - StringStream& StringStream::operator<<(bool boolean) { m_strings.push_back(String::Boolean(boolean)); @@ -71,7 +86,6 @@ namespace Nz * * \param number Short value */ - StringStream& StringStream::operator<<(short number) { m_strings.push_back(String::Number(number)); @@ -86,7 +100,6 @@ namespace Nz * * \param number Short value */ - StringStream& StringStream::operator<<(unsigned short number) { m_strings.push_back(String::Number(number)); @@ -101,7 +114,6 @@ namespace Nz * * \param number Int value */ - StringStream& StringStream::operator<<(int number) { m_strings.push_back(String::Number(number)); @@ -116,7 +128,6 @@ namespace Nz * * \param number Int value */ - StringStream& StringStream::operator<<(unsigned int number) { m_strings.push_back(String::Number(number)); @@ -131,7 +142,6 @@ namespace Nz * * \param number Long value */ - StringStream& StringStream::operator<<(long number) { m_strings.push_back(String::Number(number)); @@ -146,7 +156,6 @@ namespace Nz * * \param number Long value */ - StringStream& StringStream::operator<<(unsigned long number) { m_strings.push_back(String::Number(number)); @@ -161,7 +170,6 @@ namespace Nz * * \param number Long long value */ - StringStream& StringStream::operator<<(long long number) { m_strings.push_back(String::Number(number)); @@ -176,7 +184,6 @@ namespace Nz * * \param number Long long value */ - StringStream& StringStream::operator<<(unsigned long long number) { m_strings.push_back(String::Number(number)); @@ -191,7 +198,6 @@ namespace Nz * * \param number Float value */ - StringStream& StringStream::operator<<(float number) { m_strings.push_back(String::Number(number)); @@ -206,7 +212,6 @@ namespace Nz * * \param number Double value */ - StringStream& StringStream::operator<<(double number) { m_strings.push_back(String::Number(number)); @@ -221,7 +226,6 @@ namespace Nz * * \param number Long double value */ - StringStream& StringStream::operator<<(long double number) { m_strings.push_back(String::Number(number)); @@ -236,7 +240,6 @@ namespace Nz * * \param character Char value */ - StringStream& StringStream::operator<<(char character) { m_strings.push_back(String(character)); @@ -251,7 +254,6 @@ namespace Nz * * \param character Char value */ - StringStream& StringStream::operator<<(unsigned char character) { m_strings.push_back(String(static_cast(character))); @@ -266,7 +268,6 @@ namespace Nz * * \param string String value */ - StringStream& StringStream::operator<<(const char* string) { m_strings.push_back(string); @@ -281,7 +282,6 @@ namespace Nz * * \param string String value */ - StringStream& StringStream::operator<<(const std::string& string) { m_strings.push_back(string); @@ -296,7 +296,6 @@ namespace Nz * * \param string String value */ - StringStream& StringStream::operator<<(const String& string) { m_strings.push_back(string); @@ -311,7 +310,6 @@ namespace Nz * * \param ptr Pointer value */ - StringStream& StringStream::operator<<(const void* ptr) { m_strings.push_back(String::Pointer(ptr)); @@ -324,7 +322,6 @@ namespace Nz * \brief Converts this to Nz::String * \return The string representation of the stream */ - StringStream::operator String() const { return ToString(); From 57b03bd9ed06b511fee42d24800c454af2547f08 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:57:11 +0200 Subject: [PATCH 072/235] Utility/MaterialData: Fix FaceCulling being used for FaceSide Former-commit-id: 7529332749a01512188dce36ec0486354e0e7e8f [formerly 7154109a1a828509720e5a0039b8efc3fde4727d] Former-commit-id: f9e43b017d8750abf43ba83f6565c1dcbab4cef6 --- include/Nazara/Utility/MaterialData.hpp | 1 + src/Nazara/Graphics/Material.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index ea8ffd0f5..66df97689 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -22,6 +22,7 @@ namespace Nz static constexpr const char* BackFaceStencilReference = "MatBackFaceStencilReference"; static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail"; static constexpr const char* Blending = "MatBlending"; + static constexpr const char* CullingSide = "MatCullingSide"; static constexpr const char* CustomDefined = "MatCustomDefined"; static constexpr const char* ColorWrite = "MatColorWrite"; static constexpr const char* DepthBuffer = "MatDepthBuffer"; diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 14da83eb0..651f2581c 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -170,6 +170,9 @@ namespace Nz if (matData.GetColorParameter(MaterialData::AmbientColor, &color)) SetAmbientColor(color); + if (matData.GetIntegerParameter(MaterialData::CullingSide, &iValue)) + SetFaceCulling(static_cast(iValue)); + if (matData.GetIntegerParameter(MaterialData::DepthFunc, &iValue)) SetDepthFunc(static_cast(iValue)); @@ -182,9 +185,6 @@ namespace Nz if (matData.GetIntegerParameter(MaterialData::DstBlend, &iValue)) SetDstBlend(static_cast(iValue)); - if (matData.GetIntegerParameter(MaterialData::FaceCulling, &iValue)) - SetFaceCulling(static_cast(iValue)); - if (matData.GetIntegerParameter(MaterialData::FaceFilling, &iValue)) SetFaceFilling(static_cast(iValue)); From 3968e54d8ce4be06d16edd027e40e0bb2ea8a20a Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:57:29 +0200 Subject: [PATCH 073/235] Renderer/Texture: Remember FilePath when loading from an image Former-commit-id: 76fb68894320da3b0d3c3501843c238e353e922d [formerly b9ce288c206a844b6f905d06463092a9d0e0cc4b] Former-commit-id: 19a47609ab1267a18925099318aae1ea9de96ca8 --- src/Nazara/Renderer/Texture.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index b8bed61a0..458fb9992 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -582,6 +582,9 @@ namespace Nz } } + // Keep resource path info + SetFilePath(image.GetFilePath()); + destroyOnExit.Reset(); return true; From 00a38184896840194334d174041b961b7de2590d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 09:00:35 +0200 Subject: [PATCH 074/235] Utility/OBJParser: Optimized loading Former-commit-id: 5cdc92ab6636438e5bd24f9bc51ebe78786792ea [formerly f1ae2ff8233cc96f4abf098f8d9d17eedbfbab3e] Former-commit-id: c896b757f7b0bda31763ce69ba20a65671c0243d --- include/Nazara/Utility/Formats/OBJParser.hpp | 50 ++-- include/Nazara/Utility/Formats/OBJParser.inl | 88 +++++++ src/Nazara/Utility/Formats/OBJLoader.cpp | 22 +- src/Nazara/Utility/Formats/OBJParser.cpp | 253 +++++++------------ 4 files changed, 222 insertions(+), 191 deletions(-) create mode 100644 include/Nazara/Utility/Formats/OBJParser.inl diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 90e653f93..64fd0ce4c 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -29,51 +29,59 @@ namespace Nz struct Face { - std::vector vertices; + std::size_t firstVertex; + std::size_t vertexCount; }; struct Mesh { std::vector faces; + std::vector vertices; String name; - unsigned int material; + std::size_t material; }; - OBJParser(Stream& stream$); - ~OBJParser(); + OBJParser() = default; + ~OBJParser() = default; - const String* GetMaterials() const; - unsigned int GetMaterialCount() const; - const Mesh* GetMeshes() const; - unsigned int GetMeshCount() const; - const String& GetMtlLib() const; - const Vector3f* GetNormals() const; - unsigned int GetNormalCount() const; - const Vector4f* GetPositions() const; - unsigned int GetPositionCount() const; - const Vector3f* GetTexCoords() const; - unsigned int GetTexCoordCount() const; + inline const String* GetMaterials() const; + inline unsigned int GetMaterialCount() const; + inline const Mesh* GetMeshes() const; + inline unsigned int GetMeshCount() const; + inline const String& GetMtlLib() const; + inline const Vector3f* GetNormals() const; + inline unsigned int GetNormalCount() const; + inline const Vector4f* GetPositions() const; + inline unsigned int GetPositionCount() const; + inline const Vector3f* GetTexCoords() const; + inline unsigned int GetTexCoordCount() const; - bool Parse(std::size_t reservedVertexCount = 100); + bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); private: bool Advance(bool required = true); - void Error(const String& message); - void Warning(const String& message); - void UnrecognizedLine(bool error = false); + template void Emit(const T& text) const; + inline void EmitLine() const; + template void EmitLine(const T& line) const; + inline void Error(const String& message); + inline void Flush() const; + inline void Warning(const String& message); + inline void UnrecognizedLine(bool error = false); std::vector m_meshes; std::vector m_materials; std::vector m_normals; std::vector m_positions; std::vector m_texCoords; - Stream& m_stream; + mutable Stream* m_currentStream; String m_currentLine; String m_mtlLib; + mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; - unsigned int m_streamFlags; }; } +#include + #endif // NAZARA_FORMATS_OBJPARSER_HPP diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl new file mode 100644 index 000000000..c8ea75e8c --- /dev/null +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -0,0 +1,88 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline const String* OBJParser::GetMaterials() const + { + return m_materials.data(); + } + + inline unsigned int OBJParser::GetMaterialCount() const + { + return m_materials.size(); + } + + inline const OBJParser::Mesh* OBJParser::GetMeshes() const + { + return m_meshes.data(); + } + + inline unsigned int OBJParser::GetMeshCount() const + { + return m_meshes.size(); + } + + inline const String& OBJParser::GetMtlLib() const + { + return m_mtlLib; + } + + inline const Vector3f* OBJParser::GetNormals() const + { + return m_normals.data(); + } + + inline unsigned int OBJParser::GetNormalCount() const + { + return m_normals.size(); + } + + inline const Vector4f* OBJParser::GetPositions() const + { + return m_positions.data(); + } + + inline unsigned int OBJParser::GetPositionCount() const + { + return m_positions.size(); + } + + inline const Vector3f* OBJParser::GetTexCoords() const + { + return m_texCoords.data(); + } + + inline unsigned int OBJParser::GetTexCoordCount() const + { + return m_texCoords.size(); + } + + + inline void OBJParser::Error(const String& message) + { + NazaraError(message + " at line #" + String::Number(m_lineCount)); + } + + inline void OBJParser::Warning(const String& message) + { + NazaraWarning(message + " at line #" + String::Number(m_lineCount)); + } + + inline void OBJParser::UnrecognizedLine(bool error) + { + String message = "Unrecognized \"" + m_currentLine + '"'; + + if (error) + Error(message); + else + Warning(message); + } +} + +#include diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 05b39f81f..720b5ec5d 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -123,8 +123,8 @@ namespace Nz if (!parameters.custom.GetIntegerParameter("NativeOBJLoader_VertexCount", &reservedVertexCount)) reservedVertexCount = 100; - OBJParser parser(stream); - if (!parser.Parse(reservedVertexCount)) + OBJParser parser; + if (!parser.Parse(stream, reservedVertexCount)) { NazaraError("OBJ parser failed"); return false; @@ -177,23 +177,24 @@ namespace Nz { bool operator()(const OBJParser::FaceVertex& lhs, const OBJParser::FaceVertex& rhs) const { - return lhs.normal == rhs.normal && + return lhs.normal == rhs.normal && lhs.position == rhs.position && lhs.texCoord == rhs.texCoord; } }; std::unordered_map vertices; + vertices.reserve(meshes[i].vertices.size()); unsigned int vertexCount = 0; for (unsigned int j = 0; j < faceCount; ++j) { - unsigned int faceVertexCount = meshes[i].faces[j].vertices.size(); + unsigned int faceVertexCount = meshes[i].faces[j].vertexCount; faceIndices.resize(faceVertexCount); for (unsigned int k = 0; k < faceVertexCount; ++k) { - const OBJParser::FaceVertex& vertex = meshes[i].faces[j].vertices[k]; + const OBJParser::FaceVertex& vertex = meshes[i].vertices[meshes[i].faces[j].firstVertex + k]; auto it = vertices.find(vertex); if (it == vertices.end()) @@ -202,6 +203,7 @@ namespace Nz faceIndices[k] = it->second; } + // Triangulation for (unsigned int k = 1; k < faceVertexCount-1; ++k) { indices.push_back(faceIndices[0]); @@ -233,17 +235,17 @@ namespace Nz MeshVertex& vertex = meshVertices[index]; - const Vector4f& vec = positions[vertexIndices.position]; + const Vector4f& vec = positions[vertexIndices.position-1]; vertex.position = Vector3f(parameters.matrix * vec); - if (vertexIndices.normal >= 0) - vertex.normal = normals[vertexIndices.normal]; + if (vertexIndices.normal > 0) + vertex.normal = normals[vertexIndices.normal-1]; else hasNormals = false; - if (vertexIndices.texCoord >= 0) + if (vertexIndices.texCoord > 0) { - const Vector3f& uvw = texCoords[vertexIndices.texCoord]; + const Vector3f& uvw = texCoords[vertexIndices.texCoord-1]; vertex.uv.Set(uvw.x, (parameters.flipUVs) ? 1.f - uvw.y : uvw.y); // Inversion des UVs si demandé } else diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index c0daf1f84..03a251d5a 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include #include #include @@ -13,77 +13,22 @@ namespace Nz { - OBJParser::OBJParser(Stream& stream) : - m_stream(stream), - m_streamFlags(stream.GetStreamOptions()) //< Saves stream flags + bool OBJParser::Parse(Nz::Stream& stream, std::size_t reservedVertexCount) { - m_stream.EnableTextMode(true); - } + m_currentStream = &stream; - OBJParser::~OBJParser() - { - // Reset stream flags - if ((m_streamFlags & StreamOption_Text) == 0) - m_stream.EnableTextMode(false); - } + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); - const String* OBJParser::GetMaterials() const - { - return m_materials.data(); - } + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } - unsigned int OBJParser::GetMaterialCount() const - { - return m_materials.size(); - } - - const OBJParser::Mesh* OBJParser::GetMeshes() const - { - return m_meshes.data(); - } - - unsigned int OBJParser::GetMeshCount() const - { - return m_meshes.size(); - } - - const String& OBJParser::GetMtlLib() const - { - return m_mtlLib; - } - - const Vector3f* OBJParser::GetNormals() const - { - return m_normals.data(); - } - - unsigned int OBJParser::GetNormalCount() const - { - return m_normals.size(); - } - - const Vector4f* OBJParser::GetPositions() const - { - return m_positions.data(); - } - - unsigned int OBJParser::GetPositionCount() const - { - return m_positions.size(); - } - - const Vector3f* OBJParser::GetTexCoords() const - { - return m_texCoords.data(); - } - - unsigned int OBJParser::GetTexCoordCount() const - { - return m_texCoords.size(); - } - - bool OBJParser::Parse(std::size_t reservedVertexCount) - { String matName, meshName; matName = meshName = "default"; m_keepLastLine = false; @@ -100,32 +45,56 @@ namespace Nz m_positions.reserve(reservedVertexCount); m_texCoords.reserve(reservedVertexCount); - // On va regrouper les meshs par nom et par matériau - using FaceVec = std::vector; - using MatPair = std::pair; - std::unordered_map> meshes; + // Sort meshes by material and group + using MatPair = std::pair; + std::unordered_map> meshesByName; - unsigned int matIndex = 0; - auto GetMaterial = [&meshes, &matIndex] (const String& mesh, const String& material) -> FaceVec* + std::size_t faceReserve = 0; + std::size_t vertexReserve = 0; + unsigned int matCount = 0; + auto GetMaterial = [&] (const String& meshName, const String& matName) -> Mesh* { - auto& map = meshes[mesh]; - auto it = map.find(material); + auto& map = meshesByName[meshName]; + auto it = map.find(matName); if (it == map.end()) - it = map.insert(std::make_pair(material, MatPair(FaceVec(), matIndex++))).first; + it = map.insert(std::make_pair(matName, MatPair(Mesh(), matCount++))).first; + + Mesh& mesh = it->second.first; + + mesh.faces.reserve(faceReserve); + mesh.vertices.reserve(vertexReserve); + faceReserve = 0; + vertexReserve = 0; return &(it->second.first); }; // On prépare le mesh par défaut - FaceVec* currentMesh = nullptr; + Mesh* currentMesh = nullptr; while (Advance(false)) { switch (std::tolower(m_currentLine[0])) { - case 'f': // Une face + case '#': //< Comment + // Some softwares write comments to gives the number of vertex/faces an importer can expect + std::size_t data; + if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %zu", &data) == 1) + m_positions.reserve(data); + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %zu", &data) == 1) + m_normals.reserve(data); + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %zu", &data) == 1) + m_texCoords.reserve(data); + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %zu", &data) == 1) + faceReserve = data; + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %zu", &data) == 1) + vertexReserve = data; + + break; + + case 'f': //< Face { - if (m_currentLine.GetSize() < 7) // Le minimum syndical pour définir une face de trois sommets (f 1 2 3) + if (m_currentLine.GetSize() < 7) // Since we only treat triangles, this is the minimum length of a face line (f 1 2 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); @@ -142,17 +111,23 @@ namespace Nz break; } + if (!currentMesh) + currentMesh = GetMaterial(meshName, matName); + Face face; - face.vertices.resize(vertexCount); + face.firstVertex = currentMesh->vertices.size(); + face.vertexCount = vertexCount; + + currentMesh->vertices.resize(face.firstVertex + vertexCount, FaceVertex{0, 0, 0}); bool error = false; unsigned int pos = 2; for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - int& n = face.vertices[i].normal; - int& p = face.vertices[i].position; - int& t = face.vertices[i].texCoord; + int& n = currentMesh->vertices[face.firstVertex + i].normal; + int& p = currentMesh->vertices[face.firstVertex + i].position; + int& t = currentMesh->vertices[face.firstVertex + i].texCoord; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { @@ -168,22 +143,13 @@ namespace Nz error = true; break; } - else - { - n = 0; - t = 0; - } } - else - n = 0; } - else - t = 0; } if (p < 0) { - p += m_positions.size(); + p += m_positions.size() - 1; if (p < 0) { Error("Vertex index out of range (" + String::Number(p) + " < 0"); @@ -191,48 +157,42 @@ namespace Nz break; } } - else - p--; if (n < 0) { - n += m_normals.size(); + n += m_normals.size() - 1; if (n < 0) { - Error("Vertex index out of range (" + String::Number(n) + " < 0"); + Error("Normal index out of range (" + String::Number(n) + " < 0"); error = true; break; } } - else - n--; if (t < 0) { - t += m_texCoords.size(); + t += m_texCoords.size() - 1; if (t < 0) { - Error("Vertex index out of range (" + String::Number(t) + " < 0"); + Error("Texture coordinates index out of range (" + String::Number(t) + " < 0"); error = true; break; } } - else - t--; - if (static_cast(p) >= m_positions.size()) + if (static_cast(p) > m_positions.size()) { Error("Vertex index out of range (" + String::Number(p) + " >= " + String::Number(m_positions.size()) + ')'); error = true; break; } - else if (n >= 0 && static_cast(n) >= m_normals.size()) + else if (n != 0 && static_cast(n) > m_normals.size()) { Error("Normal index out of range (" + String::Number(n) + " >= " + String::Number(m_normals.size()) + ')'); error = true; break; } - else if (t >= 0 && static_cast(t) >= m_texCoords.size()) + else if (t != 0 && static_cast(t) > m_texCoords.size()) { Error("TexCoord index out of range (" + String::Number(t) + " >= " + String::Number(m_texCoords.size()) + ')'); error = true; @@ -243,17 +203,14 @@ namespace Nz } if (!error) - { - if (!currentMesh) - currentMesh = GetMaterial(meshName, matName); - - currentMesh->push_back(std::move(face)); - } + currentMesh->faces.push_back(std::move(face)); + else + currentMesh->vertices.resize(face.firstVertex); //< Remove vertices break; } - case 'm': + case 'm': //< MTLLib #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0).ToLower() != "mtllib") UnrecognizedLine(); @@ -262,8 +219,8 @@ namespace Nz m_mtlLib = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); break; - case 'g': - case 'o': + case 'g': //< Group (inside a mesh) + case 'o': //< Object (defines a mesh) { if (m_currentLine.GetSize() <= 2 || m_currentLine[1] != ' ') { @@ -283,12 +240,12 @@ namespace Nz } meshName = objectName; - currentMesh = GetMaterial(meshName, matName); + currentMesh = nullptr; break; } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - case 's': + case 's': //< Smooth if (m_currentLine.GetSize() <= 2 || m_currentLine[1] == ' ') { String param = m_currentLine.SubString(2); @@ -298,15 +255,16 @@ namespace Nz else UnrecognizedLine(); break; - #endif + #endif - case 'u': + case 'u': //< Usemtl #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0) != "usemtl") UnrecognizedLine(); #endif matName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); + currentMesh = nullptr; if (matName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING @@ -314,18 +272,16 @@ namespace Nz #endif break; } - - currentMesh = GetMaterial(meshName, matName); break; - case 'v': + case 'v': //< Position/Normal/Texcoords { String word = m_currentLine.GetWord(0).ToLower(); if (word == 'v') { Vector4f vertex(Vector3f::Zero(), 1.f); unsigned int paramCount = std::sscanf(&m_currentLine[2], "%f %f %f %f", &vertex.x, &vertex.y, &vertex.z, &vertex.w); - if (paramCount >= 3) + if (paramCount >= 1) m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else @@ -371,26 +327,24 @@ namespace Nz } std::unordered_map materials; - m_materials.resize(matIndex); + m_materials.resize(matCount); - for (auto& meshIt : meshes) + for (auto& meshPair : meshesByName) { - for (auto& matIt : meshIt.second) + for (auto& matPair : meshPair.second) { - auto& faceVec = matIt.second.first; - unsigned int index = matIt.second.second; - if (!faceVec.empty()) + Mesh& mesh = matPair.second.first; + unsigned int index = matPair.second.second; + if (!mesh.faces.empty()) { - Mesh mesh; - mesh.faces = std::move(faceVec); - mesh.name = meshIt.first; + mesh.name = meshPair.first; - auto it = materials.find(matIt.first); + auto it = materials.find(matPair.first); if (it == materials.end()) { mesh.material = index; - materials[matIt.first] = index; - m_materials[index] = matIt.first; + materials[matPair.first] = index; + m_materials[index] = matPair.first; } else mesh.material = it->second; @@ -415,7 +369,7 @@ namespace Nz { do { - if (m_stream.EndOfStream()) + if (m_currentStream->EndOfStream()) { if (required) Error("Incomplete OBJ file"); @@ -425,9 +379,8 @@ namespace Nz m_lineCount++; - m_currentLine = m_stream.ReadLine(); - m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires - m_currentLine.Simplify(); // Pour un traitement plus simple + m_currentLine = m_currentStream->ReadLine(); + m_currentLine.Simplify(); // Simplify lines (convert multiple blanks into a single space and trims) } while (m_currentLine.IsEmpty()); } @@ -436,24 +389,4 @@ namespace Nz return true; } - - void OBJParser::Error(const String& message) - { - NazaraError(message + " at line #" + String::Number(m_lineCount)); - } - - void OBJParser::Warning(const String& message) - { - NazaraWarning(message + " at line #" + String::Number(m_lineCount)); - } - - void OBJParser::UnrecognizedLine(bool error) - { - String message = "Unrecognized \"" + m_currentLine + '"'; - - if (error) - Error(message); - else - Warning(message); - } } From 62ae81821e36150a31b4fe3f3b80364c146cf547 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 09:00:50 +0200 Subject: [PATCH 075/235] Utility/OBJParser: Add saving Former-commit-id: 5fa9694afeed1cdb19b17dca2642d391e628a25e [formerly 47991e12efca44a545a464f7d623019687e9bfa9] Former-commit-id: 4635953b18b9b1a48c1375f55a0d907536de3c85 --- include/Nazara/Utility/Formats/OBJParser.hpp | 2 + include/Nazara/Utility/Formats/OBJParser.inl | 25 ++++ src/Nazara/Utility/Formats/OBJParser.cpp | 142 +++++++++++++++++++ 3 files changed, 169 insertions(+) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 64fd0ce4c..79aa1824a 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -58,6 +58,8 @@ namespace Nz bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); + bool Save(Stream& stream) const; + private: bool Advance(bool required = true); template void Emit(const T& text) const; diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index c8ea75e8c..7cd0060b4 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -63,12 +63,37 @@ namespace Nz return m_texCoords.size(); } + template + void OBJParser::Emit(const T& text) const + { + m_outputStream << text; + if (m_outputStream.GetBufferSize() > 1024 * 1024) + Flush(); + } + + inline void OBJParser::EmitLine() const + { + Emit('\n'); + } + + template + void OBJParser::EmitLine(const T& line) const + { + Emit(line); + Emit('\n'); + } inline void OBJParser::Error(const String& message) { NazaraError(message + " at line #" + String::Number(m_lineCount)); } + inline void OBJParser::Flush() const + { + m_currentStream->Write(m_outputStream); + m_outputStream.Clear(); + } + inline void OBJParser::Warning(const String& message) { NazaraWarning(message + " at line #" + String::Number(m_lineCount)); diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 03a251d5a..a05ef6960 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -363,6 +363,148 @@ namespace Nz return true; } + bool OBJParser::Save(Stream& stream) const + { + m_currentStream = &stream; + + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); + + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } + + m_outputStream.Clear(); + + EmitLine("# Exported by Nazara Engine"); + + if (!m_mtlLib.IsEmpty()) + { + Emit("mtlib "); + EmitLine(m_mtlLib); + EmitLine(); + } + + Emit("# position count: "); + EmitLine(m_positions.size()); + + for (const Nz::Vector4f& position : m_positions) + { + Emit("v "); + Emit(position.x); + Emit(' '); + Emit(position.y); + if (!NumberEquals(position.z, 0.f) || !NumberEquals(position.w, 1.f)) + { + Emit(' '); + Emit(position.z); + + if (!NumberEquals(position.w, 1.f)) + { + Emit(' '); + Emit(position.w); + } + } + EmitLine(); + } + EmitLine(); + + Emit("# normal count: "); + EmitLine(m_normals.size()); + + for (const Nz::Vector3f& normal : m_normals) + { + Emit("vn "); + Emit(normal.x); + Emit(' '); + Emit(normal.y); + Emit(' '); + Emit(normal.y); + EmitLine(); + } + EmitLine(); + + Emit("# texcoords count: "); + EmitLine(m_texCoords.size()); + + for (const Nz::Vector3f& uvw : m_texCoords) + { + Emit("vt "); + Emit(uvw.x); + Emit(' '); + Emit(uvw.y); + if (NumberEquals(uvw.z, 0.f)) + { + Emit(' '); + Emit(uvw.z); + } + EmitLine(); + } + EmitLine(); + + std::unordered_map /* meshes*/> meshesByMaterials; + std::size_t meshIndex = 0; + for (const Mesh& mesh : m_meshes) + meshesByMaterials[mesh.material].push_back(meshIndex++); + + for (auto& pair : meshesByMaterials) + { + Emit("usemtl "); + EmitLine(m_materials[pair.first]); + Emit("# groups count: "); + EmitLine(pair.second.size()); + EmitLine(); + + for (std::size_t meshIndex : pair.second) + { + const Mesh& mesh = m_meshes[meshIndex]; + + Emit("g "); + EmitLine(mesh.name); + EmitLine(); + + Emit("# face count: "); + EmitLine(mesh.faces.size()); + Emit("# vertex count: "); + EmitLine(mesh.vertices.size()); + + for (const Face& face : mesh.faces) + { + Emit('f'); + for (std::size_t i = 0; i < face.vertexCount; ++i) + { + Emit(' '); + const FaceVertex& faceVertex = mesh.vertices[face.firstVertex + i]; + Emit(faceVertex.position); + if (faceVertex.texCoord != 0 || faceVertex.normal != 0) + { + Emit('/'); + if (faceVertex.texCoord != 0) + Emit(faceVertex.texCoord); + + if (faceVertex.normal != 0) + { + Emit('/'); + Emit(faceVertex.normal); + } + } + } + EmitLine(); + } + } + EmitLine(); + } + + Flush(); + + return true; + } + bool OBJParser::Advance(bool required) { if (!m_keepLastLine) From 9984c9cc228092032e4312fc6068e7a358e8635f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 09:01:08 +0200 Subject: [PATCH 076/235] Math/Vector4: Fix w value when converting from Vector3 Former-commit-id: c23ecefc1a7f961605018a18e1f66cfceacf94b1 [formerly e7aef39f688d3d5c2e88d194539c451a225ae7cd] Former-commit-id: 30db24c6f9090a750637ca7c5dd3ffa8f4aeb638 --- include/Nazara/Math/Vector4.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index d1e51433a..b84a4cb17 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -28,7 +28,7 @@ namespace Nz explicit Vector4(T scale); Vector4(const T vec[4]); Vector4(const Vector2& vec, T Z = 0.0, T W = 1.0); - Vector4(const Vector3& vec, T W = 0.0); + Vector4(const Vector3& vec, T W = 1.0); template explicit Vector4(const Vector4& vec); Vector4(const Vector4& vec) = default; ~Vector4() = default; From 3851a7a5de6920f65e6b0c84f1490b661aabb217 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:07:43 +0200 Subject: [PATCH 077/235] Ndk/GraphicsComponent: Add GetAttachedRenderables Former-commit-id: 85db4fcb96064c99ca62cc1a366fa00b69375b04 [formerly 810e4d539fb3eed287fe6ba37a496430c371b076] Former-commit-id: e185b0344fb914e541e370430971c2aff390e280 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 5 +++++ SDK/include/NDK/Components/GraphicsComponent.inl | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index aed427105..4ea76d0d8 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -23,6 +23,8 @@ namespace Ndk friend class RenderSystem; public: + using RenderableList = std::vector; + GraphicsComponent() = default; inline GraphicsComponent(const GraphicsComponent& graphicsComponent); ~GraphicsComponent() = default; @@ -38,6 +40,9 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; + inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline std::size_t GetAttachedRenderableCount() const; + inline const Nz::BoundingVolumef& GetBoundingVolume() const; static ComponentIndex componentIndex; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 9ca100d0e..b38ce6dd6 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -79,6 +79,20 @@ namespace Ndk UpdateTransformMatrix(); } + inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const + { + NazaraAssert(renderables, "Invalid renderable list"); + + renderables->reserve(renderables->size() + m_renderables.size()); + for (const Renderable& r : m_renderables) + renderables->push_back(r.renderable); + } + + inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const + { + return m_renderables.size(); + } + inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const { EnsureBoundingVolumeUpdate(); From 6a3f19676bb04e46967e14904260d7cc556646a5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:17:18 +0200 Subject: [PATCH 078/235] Fix typo Former-commit-id: 8671567360ef11755b236114670b4c7c6f97df27 [formerly 353927e53477e0468adc94cf9e179db89fd6ab66] Former-commit-id: d8ab62cb9e26ceb208ff7e780813b2db93acf16b --- SDK/include/NDK/Components/GraphicsComponent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 4ea76d0d8..a7ac3ebc2 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -40,7 +40,7 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; - inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline void GetAttachedRenderables(RenderableList* renderables) const; inline std::size_t GetAttachedRenderableCount() const; inline const Nz::BoundingVolumef& GetBoundingVolume() const; From 77b2badcbc34678cc15bde5ffde8f2124a028465 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:34:45 +0200 Subject: [PATCH 079/235] Utility/OBJParser: Prepare for saving Former-commit-id: ae724ed4c7f89e6b4a4b096eada8551297f07b79 [formerly 287cf1712a73656613a6cf03ce92e6d78c528102] Former-commit-id: 0bd0cab46f1865e0b719e7fc7675146b28e69a0f --- include/Nazara/Utility/Formats/OBJParser.hpp | 67 ++++++++++++-------- include/Nazara/Utility/Formats/OBJParser.inl | 64 +++++++++++++++++++ src/Nazara/Utility/Formats/OBJLoader.cpp | 4 +- src/Nazara/Utility/Formats/OBJLoader.hpp | 4 +- src/Nazara/Utility/Formats/OBJParser.cpp | 10 ++- 5 files changed, 117 insertions(+), 32 deletions(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 79aa1824a..b9c5e41c3 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -20,12 +20,41 @@ namespace Nz class NAZARA_UTILITY_API OBJParser { public: - struct FaceVertex - { - int normal; - int position; - int texCoord; - }; + struct Face; + struct FaceVertex; + struct Mesh; + + OBJParser() = default; + ~OBJParser() = default; + + inline void Clear(); + + inline String* GetMaterials(); + inline const String* GetMaterials() const; + inline unsigned int GetMaterialCount() const; + inline Mesh* GetMeshes(); + inline const Mesh* GetMeshes() const; + inline unsigned int GetMeshCount() const; + inline const String& GetMtlLib() const; + inline Vector3f* GetNormals(); + inline const Vector3f* GetNormals() const; + inline unsigned int GetNormalCount() const; + inline Vector4f* GetPositions(); + inline const Vector4f* GetPositions() const; + inline unsigned int GetPositionCount() const; + inline Vector3f* GetTexCoords(); + inline const Vector3f* GetTexCoords() const; + inline unsigned int GetTexCoordCount() const; + + bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); + + bool Save(Stream& stream) const; + + inline String* SetMaterialCount(std::size_t materialCount); + inline Mesh* SetMeshCount(std::size_t meshCount); + inline Vector3f* SetNormalCount(std::size_t normalCount); + inline Vector4f* SetPositionCount(std::size_t positionCount); + inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); struct Face { @@ -33,6 +62,13 @@ namespace Nz std::size_t vertexCount; }; + struct FaceVertex + { + std::size_t normal; + std::size_t position; + std::size_t texCoord; + }; + struct Mesh { std::vector faces; @@ -41,25 +77,6 @@ namespace Nz std::size_t material; }; - OBJParser() = default; - ~OBJParser() = default; - - inline const String* GetMaterials() const; - inline unsigned int GetMaterialCount() const; - inline const Mesh* GetMeshes() const; - inline unsigned int GetMeshCount() const; - inline const String& GetMtlLib() const; - inline const Vector3f* GetNormals() const; - inline unsigned int GetNormalCount() const; - inline const Vector4f* GetPositions() const; - inline unsigned int GetPositionCount() const; - inline const Vector3f* GetTexCoords() const; - inline unsigned int GetTexCoordCount() const; - - bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); - - bool Save(Stream& stream) const; - private: bool Advance(bool required = true); template void Emit(const T& text) const; diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 7cd0060b4..a4fcffaec 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -8,6 +8,20 @@ namespace Nz { + inline void OBJParser::Clear() + { + m_materials.clear(); + m_meshes.clear(); + m_positions.clear(); + m_normals.clear(); + m_texCoords.clear(); + } + + inline String* OBJParser::GetMaterials() + { + return m_materials.data(); + } + inline const String* OBJParser::GetMaterials() const { return m_materials.data(); @@ -18,6 +32,11 @@ namespace Nz return m_materials.size(); } + inline OBJParser::Mesh* OBJParser::GetMeshes() + { + return m_meshes.data(); + } + inline const OBJParser::Mesh* OBJParser::GetMeshes() const { return m_meshes.data(); @@ -33,6 +52,11 @@ namespace Nz return m_mtlLib; } + inline Vector3f* OBJParser::GetNormals() + { + return m_normals.data(); + } + inline const Vector3f* OBJParser::GetNormals() const { return m_normals.data(); @@ -43,6 +67,11 @@ namespace Nz return m_normals.size(); } + inline Vector4f* OBJParser::GetPositions() + { + return m_positions.data(); + } + inline const Vector4f* OBJParser::GetPositions() const { return m_positions.data(); @@ -53,6 +82,11 @@ namespace Nz return m_positions.size(); } + inline Vector3f* OBJParser::GetTexCoords() + { + return m_texCoords.data(); + } + inline const Vector3f* OBJParser::GetTexCoords() const { return m_texCoords.data(); @@ -63,6 +97,36 @@ namespace Nz return m_texCoords.size(); } + inline String* OBJParser::SetMaterialCount(std::size_t materialCount) + { + m_materials.resize(materialCount); + return m_materials.data(); + } + + inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount) + { + m_meshes.resize(meshCount); + return m_meshes.data(); + } + + inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) + { + m_normals.resize(normalCount); + return m_normals.data(); + } + + inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount) + { + m_positions.resize(positionCount); + return m_positions.data(); + } + + inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount) + { + m_texCoords.resize(texCoordCount); + return m_texCoords.data(); + } + template void OBJParser::Emit(const T& text) const { diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 720b5ec5d..a8d5d68ec 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -298,12 +298,12 @@ namespace Nz namespace Loaders { - void RegisterOBJ() + void RegisterOBJLoader() { MeshLoader::RegisterLoader(IsSupported, Check, Load); } - void UnregisterOBJ() + void UnregisterOBJLoader() { MeshLoader::UnregisterLoader(IsSupported, Check, Load); } diff --git a/src/Nazara/Utility/Formats/OBJLoader.hpp b/src/Nazara/Utility/Formats/OBJLoader.hpp index 05a3efdff..46dd8d976 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.hpp +++ b/src/Nazara/Utility/Formats/OBJLoader.hpp @@ -13,8 +13,8 @@ namespace Nz { namespace Loaders { - void RegisterOBJ(); - void UnregisterOBJ(); + void RegisterOBJLoader(); + void UnregisterOBJLoader(); } } diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index a05ef6960..5c941e938 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - int& n = currentMesh->vertices[face.firstVertex + i].normal; - int& p = currentMesh->vertices[face.firstVertex + i].position; - int& t = currentMesh->vertices[face.firstVertex + i].texCoord; + std::size_t n = 0; + std::size_t p = 0; + std::size_t t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { @@ -199,6 +199,10 @@ namespace Nz break; } + currentMesh->vertices[face.firstVertex + i].normal = static_cast(n); + currentMesh->vertices[face.firstVertex + i].position = static_cast(p); + currentMesh->vertices[face.firstVertex + i].texCoord = static_cast(t); + pos += offset; } From 7460131cdb76e1a264ea64497b5d0c6cb963b289 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:35:36 +0200 Subject: [PATCH 080/235] Utility/IndexMapper: Makes it work without index buffers (sequential mode) Former-commit-id: 805f95b42ef40b122074eb0b8305d5d52cc019fd [formerly bdc844eb63e4f0fe94c42c714a8d5ec8d0032da4] Former-commit-id: 0eb451037196a079228def2549e9ca7c194fd3f1 --- include/Nazara/Utility/IndexMapper.hpp | 7 +- src/Nazara/Utility/IndexMapper.cpp | 89 +++++++++++++++----------- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/include/Nazara/Utility/IndexMapper.hpp b/include/Nazara/Utility/IndexMapper.hpp index 9dd6a5c46..7f632f196 100644 --- a/include/Nazara/Utility/IndexMapper.hpp +++ b/include/Nazara/Utility/IndexMapper.hpp @@ -23,9 +23,10 @@ namespace Nz class NAZARA_UTILITY_API IndexMapper { public: - IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite); - IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly); - IndexMapper(const SubMesh* subMesh); + IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite, std::size_t indexCount = 0); + IndexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite); + IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly, std::size_t indexCount = 0); + IndexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly); ~IndexMapper() = default; UInt32 Get(unsigned int i) const; diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index adf80a764..5a664128c 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -12,6 +12,13 @@ namespace Nz { namespace { + UInt32 GetterSequential(const void* buffer, unsigned int i) + { + NazaraUnused(buffer); + + return i; + } + UInt32 Getter16(const void* buffer, unsigned int i) { const UInt16* ptr = static_cast(buffer); @@ -42,61 +49,67 @@ namespace Nz } } - IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access) : - m_indexCount(indexBuffer->GetIndexCount()) + IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) : + m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount()) { - #if NAZARA_UTILITY_SAFE - if (!indexBuffer) - { - NazaraError("Index buffer must be valid"); - return; - } - #endif + NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer"); - if (!m_mapper.Map(indexBuffer, access)) - NazaraError("Failed to map buffer"); ///TODO: Unexcepted - - if (indexBuffer->HasLargeIndices()) + if (indexBuffer) { - m_getter = Getter32; - if (access != BufferAccess_ReadOnly) - m_setter = Setter32; + if (!m_mapper.Map(indexBuffer, access)) + NazaraError("Failed to map buffer"); ///TODO: Unexcepted + + if (indexBuffer->HasLargeIndices()) + { + m_getter = Getter32; + if (access != BufferAccess_ReadOnly) + m_setter = Setter32; + else + m_setter = SetterError; + } else - m_setter = SetterError; + { + m_getter = Getter16; + if (access != BufferAccess_ReadOnly) + m_setter = Setter16; + else + m_setter = SetterError; + } } else { - m_getter = Getter16; - if (access != BufferAccess_ReadOnly) - m_setter = Setter16; - else - m_setter = SetterError; + m_getter = GetterSequential; + m_setter = SetterError; } } - IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access) : + IndexMapper::IndexMapper(SubMesh* subMesh, BufferAccess access) : + IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount()) + { + } + + IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) : m_setter(SetterError), - m_indexCount(indexBuffer->GetIndexCount()) + m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount()) { - #if NAZARA_UTILITY_SAFE - if (!indexBuffer) + NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer"); + + if (indexBuffer) { - NazaraError("Index buffer must be valid"); - return; + if (!m_mapper.Map(indexBuffer, access)) + NazaraError("Failed to map buffer"); ///TODO: Unexcepted + + if (indexBuffer->HasLargeIndices()) + m_getter = Getter32; + else + m_getter = Getter16; } - #endif - - if (!m_mapper.Map(indexBuffer, access)) - NazaraError("Failed to map buffer"); ///TODO: Unexcepted - - if (indexBuffer->HasLargeIndices()) - m_getter = Getter32; else - m_getter = Getter16; + m_getter = GetterSequential; } - IndexMapper::IndexMapper(const SubMesh* subMesh) : - IndexMapper(subMesh->GetIndexBuffer()) + IndexMapper::IndexMapper(const SubMesh* subMesh, BufferAccess access) : + IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount()) { } From c839413723e0ea7fb6e961b3871c96b8df35a31e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:35:48 +0200 Subject: [PATCH 081/235] Utility: Fix an oopsie Former-commit-id: adc5e394b3ca8e1ecf93cc2fee8fda21c7841a69 [formerly b17bfd26c9222be98d12d12795b364751e7956b3] Former-commit-id: 3603eb4b56752afcbc4cb22bea50871edbc4bc76 --- src/Nazara/Utility/Utility.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 78553ce54..ae5b5066d 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -124,7 +124,7 @@ namespace Nz Loaders::RegisterMD5Anim(); // Loader de fichiers .md5anim (v10) // Mesh (text) - Loaders::RegisterOBJ(); + Loaders::RegisterOBJLoader(); // Mesh Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8) @@ -162,7 +162,7 @@ namespace Nz Loaders::UnregisterMD2(); Loaders::UnregisterMD5Anim(); Loaders::UnregisterMD5Mesh(); - Loaders::UnregisterOBJ(); + Loaders::UnregisterOBJLoader(); Loaders::UnregisterPCX(); Loaders::UnregisterSTBLoader(); Loaders::UnregisterSTBSaver(); From f9901561ac80a2cb08d0dd19543727e94dcc1d5e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:36:42 +0200 Subject: [PATCH 082/235] Utility: Allow TriangleIterator and VertexMapper to take constant submesh Former-commit-id: aa0b6deee520437f5b484428e077df95983df117 [formerly 5464cd28f30dc4305368fedd5639ad216ba43a49] Former-commit-id: 01a16afe0218787fe5edd7b9078908297452b453 --- include/Nazara/Utility/TriangleIterator.hpp | 2 +- include/Nazara/Utility/VertexMapper.hpp | 2 ++ src/Nazara/Utility/TriangleIterator.cpp | 13 ++++++-- src/Nazara/Utility/VertexMapper.cpp | 36 +++++++++++++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Utility/TriangleIterator.hpp b/include/Nazara/Utility/TriangleIterator.hpp index 0addb1836..32c9ceb07 100644 --- a/include/Nazara/Utility/TriangleIterator.hpp +++ b/include/Nazara/Utility/TriangleIterator.hpp @@ -19,7 +19,7 @@ namespace Nz { public: TriangleIterator(PrimitiveMode primitiveMode, const IndexBuffer* indexBuffer); - TriangleIterator(SubMesh* subMesh); + TriangleIterator(const SubMesh* subMesh); ~TriangleIterator() = default; bool Advance(); diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index 3dc9accdb..e18250d7c 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -22,6 +22,8 @@ namespace Nz public: VertexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite); VertexMapper(VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadWrite); + VertexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly); + VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly); ~VertexMapper(); template SparsePtr GetComponentPtr(VertexComponent component); diff --git a/src/Nazara/Utility/TriangleIterator.cpp b/src/Nazara/Utility/TriangleIterator.cpp index 0c6830c87..53086ddb8 100644 --- a/src/Nazara/Utility/TriangleIterator.cpp +++ b/src/Nazara/Utility/TriangleIterator.cpp @@ -17,12 +17,19 @@ namespace Nz m_triangleIndices[1] = m_indexMapper.Get(1); m_triangleIndices[2] = m_indexMapper.Get(2); - m_indexCount = indexBuffer->GetIndexCount(); + m_indexCount = m_indexMapper.GetIndexCount(); } - TriangleIterator::TriangleIterator(SubMesh* subMesh) : - TriangleIterator(subMesh->GetPrimitiveMode(), subMesh->GetIndexBuffer()) + TriangleIterator::TriangleIterator(const SubMesh* subMesh) : + m_primitiveMode(subMesh->GetPrimitiveMode()), + m_indexMapper(subMesh, BufferAccess_ReadOnly) { + m_currentIndex = 3; + m_triangleIndices[0] = m_indexMapper.Get(0); + m_triangleIndices[1] = m_indexMapper.Get(1); + m_triangleIndices[2] = m_indexMapper.Get(2); + + m_indexCount = m_indexMapper.GetIndexCount(); } bool TriangleIterator::Advance() diff --git a/src/Nazara/Utility/VertexMapper.cpp b/src/Nazara/Utility/VertexMapper.cpp index 1edbdc7f8..158dae801 100644 --- a/src/Nazara/Utility/VertexMapper.cpp +++ b/src/Nazara/Utility/VertexMapper.cpp @@ -47,6 +47,42 @@ namespace Nz ErrorFlags flags(ErrorFlag_ThrowException, true); m_mapper.Map(vertexBuffer, access); } + + VertexMapper::VertexMapper(const SubMesh* subMesh, BufferAccess access) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + + const VertexBuffer* buffer = nullptr; + switch (subMesh->GetAnimationType()) + { + case AnimationType_Skeletal: + { + const SkeletalMesh* skeletalMesh = static_cast(subMesh); + buffer = skeletalMesh->GetVertexBuffer(); + break; + } + + case AnimationType_Static: + { + const StaticMesh* staticMesh = static_cast(subMesh); + buffer = staticMesh->GetVertexBuffer(); + break; + } + } + + if (!buffer) + { + NazaraInternalError("Animation type not handled (0x" + String::Number(subMesh->GetAnimationType(), 16) + ')'); + } + + m_mapper.Map(buffer, access); + } + + VertexMapper::VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + m_mapper.Map(vertexBuffer, access); + } VertexMapper::~VertexMapper() = default; From ef3a356f7ed6b74a15d1acadfd76a5e0c7bf38de Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:36:54 +0200 Subject: [PATCH 083/235] Utility/STBSaver: Fix error message Former-commit-id: 358a92a83c014a568619d3847f0121b69156e74a [formerly 768526f91a496057df86b46e84b5d3adc9c2ad67] Former-commit-id: 4fcccfc4c912293f7407795017c3175384bfb066 --- src/Nazara/Utility/Formats/STBSaver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Utility/Formats/STBSaver.cpp b/src/Nazara/Utility/Formats/STBSaver.cpp index 4166de86f..1b65312fe 100644 --- a/src/Nazara/Utility/Formats/STBSaver.cpp +++ b/src/Nazara/Utility/Formats/STBSaver.cpp @@ -121,7 +121,7 @@ namespace Nz ImageType type = image.GetType(); if (type != ImageType_1D && type != ImageType_2D) { - NazaraError("Image type 0x" + String::Number(type, 16) + " is not "); + NazaraError("Image type 0x" + String::Number(type, 16) + " is not in a supported format"); return false; } From 3b57197e448a18ed8334cc2ff43d2b2e90a5071c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:37:22 +0200 Subject: [PATCH 084/235] Utility/Mesh: Add MeshSaver Former-commit-id: 2fa56a6f6a1ea10ae93613e57d8355055d46c798 [formerly c74c834ef594c16356d58a458d68d2e528f1aa78] Former-commit-id: c47fcbeeeac1a98e9c0cc52244b7220e7ce03234 --- include/Nazara/Utility/Mesh.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 865a228a9..11e7c14bd 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ namespace Nz using MeshLoader = ResourceLoader; using MeshManager = ResourceManager; using MeshRef = ObjectRef; + using MeshSaver = ResourceSaver; struct MeshImpl; From 9cd41a9478af23619e39ac47fee9c7a1209d43bc Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:38:34 +0200 Subject: [PATCH 085/235] Utility/OBJParser: Fix mistake Former-commit-id: dfbb9c42d27863bb1cbe5e1502ee13a77bf2a271 [formerly 5d69c11843ffbe0420045742fbb9e23e2392c9c6] Former-commit-id: c3ee677975dbe8212f6b4bb9b6dd7fca4a0aa0dc --- src/Nazara/Utility/Formats/OBJParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 5c941e938..cec716442 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - std::size_t n = 0; - std::size_t p = 0; - std::size_t t = 0; + int n = 0; + int p = 0; + int t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { From 0d9a87b1abe2da0ee2ac6e7c0832771db0ba43dd Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:40:51 +0200 Subject: [PATCH 086/235] Utility/Mesh: Fix linking Former-commit-id: a8f79e5517098679f921b6506d9171347633fc67 [formerly d2d917813e98060ac733a04cba2fa4f346b3c0b3] Former-commit-id: 47f9671788753c2b4a265a5a9a02407684e3a717 --- src/Nazara/Utility/Mesh.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index f41f67440..0401a9a10 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -697,4 +697,5 @@ namespace Nz MeshLoader::LoaderList Mesh::s_loaders; MeshManager::ManagerMap Mesh::s_managerMap; MeshManager::ManagerParams Mesh::s_managerParameters; + MeshSaver::SaverList Mesh::s_savers; } From 09ea615c8abb2f8501a05085287fc9c15a2d3be5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 12:40:25 +0200 Subject: [PATCH 088/235] Utility/Mesh: Fix error Former-commit-id: 5d4c7ae3741ec59a0463775290f7878310e7c9e7 [formerly 371cf43770cd57a4a0c2ac25ad9bc7d0f1ef844d] Former-commit-id: a10d6777c4f7e5400f1f231b511b591528aa9a7f --- include/Nazara/Utility/Mesh.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 11e7c14bd..36798e689 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -148,6 +148,7 @@ namespace Nz static MeshLoader::LoaderList s_loaders; static MeshManager::ManagerMap s_managerMap; static MeshManager::ManagerParams s_managerParameters; + static MeshSaver::SaverList s_savers; }; } From c6ea158b835baf5a8abc83341404b36da8b2478c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 18:02:19 +0200 Subject: [PATCH 089/235] Core/ParameterList: Fix GetIntegerParameter Former-commit-id: c01f1ecf33e605b55e1300713e0a34087e298ab3 [formerly 6f6d58c6c8f0f71bb154b0ee4d3c5b8eb4cd07df] Former-commit-id: d261bbb99a14e1292064fdcbaf45a8b103cac759 --- src/Nazara/Core/ParameterList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index abe93c640..bda37b4d4 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -249,7 +249,7 @@ namespace Nz case ParameterType_Integer: *value = it->second.value.intVal; - return false; + return true; case ParameterType_String: { From 3b47180be2b8e23456ff6a61ef4bd835f7955220 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:34:45 +0200 Subject: [PATCH 090/235] Utility/OBJParser: Prepare for saving Former-commit-id: 4a1ea0666302052899dac99549d3f51cb9748178 [formerly d904abd5862d5f5712b7327522e374b8f620dce8] Former-commit-id: 71c511e8aec3c20258e01008ea3a8cde4bbee28e --- src/Nazara/Utility/Formats/OBJParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index cec716442..5c941e938 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - int n = 0; - int p = 0; - int t = 0; + std::size_t n = 0; + std::size_t p = 0; + std::size_t t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { From 1c4e3f92fb6c74878cb32c29d5d2f553d1f7824e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:38:34 +0200 Subject: [PATCH 091/235] Utility/OBJParser: Fix mistake Former-commit-id: e955c47ebc04ca4320a8f0ec280a9b8066608f8a [formerly 31c8d33788b0d5c6655df773411402c3c456ed1a] Former-commit-id: 52efa60e16a99ad6e6ee74f20fe6d58d9f3b49cc --- src/Nazara/Utility/Formats/OBJParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 5c941e938..cec716442 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - std::size_t n = 0; - std::size_t p = 0; - std::size_t t = 0; + int n = 0; + int p = 0; + int t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { From 9745187823446fbb2893204de4155385a5b62fd5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:09:31 +0200 Subject: [PATCH 092/235] Core/ResourceSaver: Truncate output file Former-commit-id: a17e091703b0006376eb6d8b0b8b3cd3177977ed [formerly bba3cfc762df4c303f1eadd26df604f38f8ac4ea] Former-commit-id: 3b91fd6f08559afee2587c907705610135d533e3 --- include/Nazara/Core/ResourceSaver.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/ResourceSaver.inl b/include/Nazara/Core/ResourceSaver.inl index 11d3f2a44..85f95fd3a 100644 --- a/include/Nazara/Core/ResourceSaver.inl +++ b/include/Nazara/Core/ResourceSaver.inl @@ -84,7 +84,7 @@ namespace Nz } else { - if (!file.Open(OpenMode_WriteOnly)) + if (!file.Open(OpenMode_WriteOnly | OpenMode_Truncate)) { NazaraError("Failed to save to file: unable to open \"" + filePath + "\" in write mode"); return false; From 6a1b444a02613b729b4c61d5a5e355bc29668900 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:09:42 +0200 Subject: [PATCH 093/235] Build/Examples: Fix HardwareInfo console Former-commit-id: 310af35aa1f2a7094841cf4791eff8542e74d532 [formerly 1b84ab1fb38ca1e1c141e430238591488dd078ca] Former-commit-id: a94ef3bbd03b899e49746f3d3f08686ebd088693 --- examples/HardwareInfo/build.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/HardwareInfo/build.lua b/examples/HardwareInfo/build.lua index e1b487bd6..afcc7b544 100644 --- a/examples/HardwareInfo/build.lua +++ b/examples/HardwareInfo/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "HardwareInfo" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Defines = { "NAZARA_RENDERER_OPENGL" From 72128c971f6a0919386b2db40f423fbf2db98d8a Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:10:12 +0200 Subject: [PATCH 094/235] Utility/Formats: Make MD2Loader specify diffuse texture path instead of material filepath Former-commit-id: 9762163f8d052ad086f4ef1142bd12ceff0c71d2 [formerly 33e678ab869854e080228e7736f0e3a4868c7e18] Former-commit-id: 8b6d2b2af75a4e5ff3c78379f5ca62a17279ff5f --- src/Nazara/Utility/Formats/MD2Loader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index 126eeaa35..d1d03cf52 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -102,7 +102,8 @@ namespace Nz stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::FilePath, baseDir + skin); + matData.SetParameter(MaterialData::CustomDefined, true); + matData.SetParameter(MaterialData::DiffuseTexturePath, baseDir + skin); mesh->SetMaterialData(i, std::move(matData)); } From b44cf8d36164574d86ce297415c390865ce862a8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:11:03 +0200 Subject: [PATCH 095/235] Utility: Add MTL exporting Former-commit-id: 6174df9379702cac1eac0b348143004022bc6c59 [formerly 8efc71bc323e64c88a1927d4d88453db41786b55] Former-commit-id: d713cb74ac26873e6ac6664145e78eed286c022f --- include/Nazara/Utility/Formats/MTLParser.hpp | 39 +++- include/Nazara/Utility/Formats/MTLParser.inl | 83 +++++++ include/Nazara/Utility/Formats/OBJParser.hpp | 1 + include/Nazara/Utility/Formats/OBJParser.inl | 5 + src/Nazara/Utility/Formats/MTLParser.cpp | 234 +++++++++++++------ src/Nazara/Utility/Formats/OBJLoader.cpp | 28 ++- src/Nazara/Utility/Formats/OBJParser.cpp | 17 +- 7 files changed, 316 insertions(+), 91 deletions(-) create mode 100644 include/Nazara/Utility/Formats/MTLParser.inl diff --git a/include/Nazara/Utility/Formats/MTLParser.hpp b/include/Nazara/Utility/Formats/MTLParser.hpp index d58148ec7..9c5b49828 100644 --- a/include/Nazara/Utility/Formats/MTLParser.hpp +++ b/include/Nazara/Utility/Formats/MTLParser.hpp @@ -19,6 +19,22 @@ namespace Nz class NAZARA_UTILITY_API MTLParser { public: + struct Material; + + MTLParser() = default; + ~MTLParser() = default; + + inline Material* AddMaterial(const String& matName); + + inline void Clear(); + + inline const Material* GetMaterial(const String& materialName) const; + inline const std::unordered_map& GetMaterials() const; + + bool Parse(Stream& stream); + + bool Save(Stream& stream) const; + struct Material { Color ambient = Color::White; @@ -39,27 +55,26 @@ namespace Nz unsigned int illumModel = 0; }; - MTLParser(Stream& stream$); - ~MTLParser(); - - const Material* GetMaterial(const String& materialName) const; - const std::unordered_map& GetMaterials() const; - - bool Parse(); - private: bool Advance(bool required = true); - void Error(const String& message); - void Warning(const String& message); - void UnrecognizedLine(bool error = false); + template void Emit(const T& text) const; + inline void EmitLine() const; + template void EmitLine(const T& line) const; + inline void Error(const String& message); + inline void Flush() const; + inline void Warning(const String& message); + inline void UnrecognizedLine(bool error = false); std::unordered_map m_materials; - Stream& m_stream; + mutable Stream* m_currentStream; String m_currentLine; + mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; unsigned int m_streamFlags; }; } +#include + #endif // NAZARA_FORMATS_MTLPARSER_HPP diff --git a/include/Nazara/Utility/Formats/MTLParser.inl b/include/Nazara/Utility/Formats/MTLParser.inl new file mode 100644 index 000000000..0f8cd4f66 --- /dev/null +++ b/include/Nazara/Utility/Formats/MTLParser.inl @@ -0,0 +1,83 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline MTLParser::Material* MTLParser::AddMaterial(const String& matName) + { + return &m_materials[matName]; + } + + inline void MTLParser::Clear() + { + m_materials.clear(); + } + + inline const MTLParser::Material* MTLParser::GetMaterial(const String& materialName) const + { + auto it = m_materials.find(materialName); + if (it != m_materials.end()) + return &it->second; + else + return nullptr; + } + + inline const std::unordered_map& MTLParser::GetMaterials() const + { + return m_materials; + } + + template + void MTLParser::Emit(const T& text) const + { + m_outputStream << text; + if (m_outputStream.GetBufferSize() > 1024 * 1024) + Flush(); + } + + inline void MTLParser::EmitLine() const + { + Emit('\n'); + } + + template + void MTLParser::EmitLine(const T& line) const + { + Emit(line); + Emit('\n'); + } + + inline void MTLParser::Error(const String& message) + { + NazaraError(message + " at line #" + String::Number(m_lineCount)); + } + + inline void MTLParser::Flush() const + { + m_currentStream->Write(m_outputStream); + m_outputStream.Clear(); + } + + inline void MTLParser::Warning(const String& message) + { + NazaraWarning(message + " at line #" + String::Number(m_lineCount)); + } + + inline void MTLParser::UnrecognizedLine(bool error) + { + String message = "Unrecognized \"" + m_currentLine + '"'; + + if (error) + Error(message); + else + Warning(message); + } +} + +#include +#include "MTLParser.hpp" diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index b9c5e41c3..50fa58900 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -52,6 +52,7 @@ namespace Nz inline String* SetMaterialCount(std::size_t materialCount); inline Mesh* SetMeshCount(std::size_t meshCount); + inline void SetMtlLib(const String& mtlLib); inline Vector3f* SetNormalCount(std::size_t normalCount); inline Vector4f* SetPositionCount(std::size_t positionCount); inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index a4fcffaec..9d961d54f 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -109,6 +109,11 @@ namespace Nz return m_meshes.data(); } + inline void OBJParser::SetMtlLib(const String& mtlLib) + { + m_mtlLib = mtlLib; + } + inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) { m_normals.resize(normalCount); diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 2398ccb3f..6685bcd04 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -12,36 +13,22 @@ namespace Nz { - MTLParser::MTLParser(Stream& stream) : - m_stream(stream), - m_streamFlags(stream.GetStreamOptions()) //< Saves stream flags + bool MTLParser::Parse(Stream& stream) { - m_stream.EnableTextMode(true); - } + m_currentStream = &stream; - MTLParser::~MTLParser() - { - // Reset stream flags - if ((m_streamFlags & StreamOption_Text) == 0) - m_stream.EnableTextMode(false); - } + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); - const MTLParser::Material* MTLParser::GetMaterial(const String& materialName) const - { - auto it = m_materials.find(materialName); - if (it != m_materials.end()) - return &it->second; - else - return nullptr; - } + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } - const std::unordered_map& MTLParser::GetMaterials() const - { - return m_materials; - } - - bool MTLParser::Parse() - { m_keepLastLine = false; m_lineCount = 0; m_materials.clear(); @@ -57,7 +44,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->ambient = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); } @@ -72,7 +59,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->diffuse = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); } @@ -87,7 +74,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->specular = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); } @@ -102,7 +89,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f", &density) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->refractionIndex = density; } @@ -117,7 +104,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f", &coef) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->shininess = coef; } @@ -132,7 +119,7 @@ namespace Nz if (std::sscanf(&m_currentLine[(keyword[0] == 'd') ? 2 : 3], "%f", &alpha) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->alpha = alpha; } @@ -147,7 +134,7 @@ namespace Nz if (std::sscanf(&m_currentLine[(keyword[0] == 'd') ? 2 : 3], "%f", &alpha) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->alpha = 1.f - alpha; // tr vaut pour la "valeur de transparence", 0 = opaque } @@ -162,7 +149,7 @@ namespace Nz if (std::sscanf(&m_currentLine[6], "%u", &model) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->illumModel = model; } @@ -178,7 +165,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->ambientMap = map; } @@ -190,7 +177,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->diffuseMap = map; } @@ -202,7 +189,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->specularMap = map; } @@ -214,7 +201,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->bumpMap = map; } @@ -226,7 +213,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->alphaMap = map; } @@ -238,7 +225,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->decalMap = map; } @@ -250,7 +237,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->displacementMap = map; } @@ -262,7 +249,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->reflectionMap = map; } @@ -271,7 +258,7 @@ namespace Nz { String materialName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); if (!materialName.IsEmpty()) - currentMaterial = &m_materials[materialName]; + currentMaterial = AddMaterial(materialName); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else UnrecognizedLine(); @@ -286,13 +273,150 @@ namespace Nz return true; } + bool MTLParser::Save(Stream& stream) const + { + m_currentStream = &stream; + + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); + + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } + + m_outputStream.Clear(); + + EmitLine("# Exported by Nazara Engine"); + EmitLine(); + + Emit("# material count: "); + Emit(m_materials.size()); + EmitLine(); + + for (auto& pair : m_materials) + { + const String& matName = pair.first; + const Material& mat = pair.second; + + Emit("newmtl "); + EmitLine(pair.first); + EmitLine(); + + Emit("Ka "); + Emit(mat.ambient.r / 255.f); + Emit(' '); + Emit(mat.ambient.g / 255.f); + Emit(' '); + Emit(mat.ambient.b / 255.f); + EmitLine(); + + Emit("Kd "); + Emit(mat.diffuse.r / 255.f); + Emit(' '); + Emit(mat.diffuse.g / 255.f); + Emit(' '); + Emit(mat.diffuse.b / 255.f); + EmitLine(); + + Emit("Ks "); + Emit(mat.specular.r / 255.f); + Emit(' '); + Emit(mat.specular.g / 255.f); + Emit(' '); + Emit(mat.specular.b / 255.f); + EmitLine(); + + if (mat.alpha != 1.f) + { + Emit("d "); + EmitLine(mat.alpha); + } + + if (mat.refractionIndex != 1.f) + { + Emit("ni "); + EmitLine(mat.refractionIndex); + } + + if (mat.shininess != 1.f) + { + Emit("ns "); + EmitLine(mat.shininess); + } + + if (mat.illumModel != 0) + { + Emit("illum "); + EmitLine(mat.illumModel); + } + + if (!mat.ambientMap.IsEmpty()) + { + Emit("map_Ka "); + EmitLine(mat.ambientMap); + } + + if (!mat.diffuseMap.IsEmpty()) + { + Emit("map_Kd "); + EmitLine(mat.diffuseMap); + } + + if (!mat.specularMap.IsEmpty()) + { + Emit("map_Ks "); + EmitLine(mat.specularMap); + } + + if (!mat.bumpMap.IsEmpty()) + { + Emit("map_bump "); + EmitLine(mat.bumpMap); + } + + if (!mat.alphaMap.IsEmpty()) + { + Emit("map_d "); + EmitLine(mat.alphaMap); + } + + if (!mat.decalMap.IsEmpty()) + { + Emit("map_decal "); + EmitLine(mat.decalMap); + } + + if (!mat.displacementMap.IsEmpty()) + { + Emit("map_disp "); + EmitLine(mat.displacementMap); + } + + if (!mat.reflectionMap.IsEmpty()) + { + Emit("map_refl "); + EmitLine(mat.reflectionMap); + } + EmitLine(); + } + + Flush(); + + return true; + } + bool MTLParser::Advance(bool required) { if (!m_keepLastLine) { do { - if (m_stream.EndOfStream()) + if (m_currentStream->EndOfStream()) { if (required) Error("Incomplete MTL file"); @@ -302,7 +426,7 @@ namespace Nz m_lineCount++; - m_currentLine = m_stream.ReadLine(); + m_currentLine = m_currentStream->ReadLine(); m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires m_currentLine.Simplify(); // Pour un traitement plus simple } @@ -313,24 +437,4 @@ namespace Nz return true; } - - void MTLParser::Error(const String& message) - { - NazaraError(message + " at line #" + String::Number(m_lineCount)); - } - - void MTLParser::Warning(const String& message) - { - NazaraWarning(message + " at line #" + String::Number(m_lineCount)); - } - - void MTLParser::UnrecognizedLine(bool error) - { - String message = "Unrecognized \"" + m_currentLine + '"'; - - if (error) - Error(message); - else - Warning(message); - } } diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index a8d5d68ec..1b1835b2b 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -49,8 +49,8 @@ namespace Nz return false; } - MTLParser materialParser(file); - if (!materialParser.Parse()) + MTLParser materialParser; + if (!materialParser.Parse(file)) { NazaraError("MTL parser failed"); return false; @@ -90,13 +90,31 @@ namespace Nz data.SetParameter(MaterialData::SpecularColor, specularColor); if (!mtlMat->alphaMap.IsEmpty()) - data.SetParameter(MaterialData::AlphaTexturePath, baseDir + mtlMat->alphaMap); + { + String fullPath = mtlMat->alphaMap; + if (!Nz::File::IsAbsolute(fullPath)) + fullPath.Prepend(baseDir); + + data.SetParameter(MaterialData::AlphaTexturePath, fullPath); + } if (!mtlMat->diffuseMap.IsEmpty()) - data.SetParameter(MaterialData::DiffuseTexturePath, baseDir + mtlMat->diffuseMap); + { + String fullPath = mtlMat->diffuseMap; + if (!Nz::File::IsAbsolute(fullPath)) + fullPath.Prepend(baseDir); + + data.SetParameter(MaterialData::DiffuseTexturePath, fullPath); + } if (!mtlMat->specularMap.IsEmpty()) - data.SetParameter(MaterialData::SpecularTexturePath, baseDir + mtlMat->specularMap); + { + String fullPath = mtlMat->specularMap; + if (!Nz::File::IsAbsolute(fullPath)) + fullPath.Prepend(baseDir); + + data.SetParameter(MaterialData::SpecularTexturePath, fullPath); + } // If we either have an alpha value or an alpha map, let's configure the material for transparency if (alphaValue != 255 || !mtlMat->alphaMap.IsEmpty()) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index cec716442..bd189305f 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -386,10 +386,11 @@ namespace Nz m_outputStream.Clear(); EmitLine("# Exported by Nazara Engine"); + EmitLine(); if (!m_mtlLib.IsEmpty()) { - Emit("mtlib "); + Emit("mtllib "); EmitLine(m_mtlLib); EmitLine(); } @@ -403,17 +404,15 @@ namespace Nz Emit(position.x); Emit(' '); Emit(position.y); - if (!NumberEquals(position.z, 0.f) || !NumberEquals(position.w, 1.f)) + Emit(' '); + Emit(position.z); + + if (!NumberEquals(position.w, 1.f)) { Emit(' '); - Emit(position.z); - - if (!NumberEquals(position.w, 1.f)) - { - Emit(' '); - Emit(position.w); - } + Emit(position.w); } + EmitLine(); } EmitLine(); From b99e945ef39450242470a576783dd04cb3c5e179 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:11:25 +0200 Subject: [PATCH 096/235] Utility/Mesh: Add MeshSaver properly Former-commit-id: 1f6f19faaa6b7cbd978dbdee1351683e2ba05a2b [formerly 1ea64fb952d6eb8b5ba0d6cbe672767a6e7c703d] Former-commit-id: 9e84e1c65ef9acebf90ca58d861cb118ea201c8d --- include/Nazara/Utility/Mesh.hpp | 4 ++++ src/Nazara/Utility/Mesh.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 36798e689..62a372384 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -71,6 +71,7 @@ namespace Nz friend MeshLibrary; friend MeshLoader; friend MeshManager; + friend MeshSaver; friend class Utility; public: @@ -126,6 +127,9 @@ namespace Nz void RemoveSubMesh(const String& identifier); void RemoveSubMesh(unsigned int index); + bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams()); + bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams()); + void SetAnimation(const String& animationPath); void SetMaterialCount(unsigned int matCount); void SetMaterialData(unsigned int matIndex, ParameterList data); diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 0401a9a10..84559abda 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -606,6 +606,16 @@ namespace Nz InvalidateAABB(); } + bool Mesh::SaveToFile(const String& filePath, const MeshParams& params) + { + return MeshSaver::SaveToFile(*this, filePath, params); + } + + bool Mesh::SaveToStream(Stream& stream, const String& format, const MeshParams& params) + { + return MeshSaver::SaveToStream(*this, stream, format, params); + } + void Mesh::SetAnimation(const String& animationPath) { NazaraAssert(m_impl, "Mesh should be created first"); From 3dde6ede29728c4d44b516bf4308bbda1922e3e3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:11:50 +0200 Subject: [PATCH 097/235] Utility/Formats: Add OBJSaver (WIP) Former-commit-id: 737c530fef69e965e1e10e0859d0751f0f0f97cc [formerly 9ea0f491a9312e752ec854f9424534ed429760ac] Former-commit-id: 315e6c7ed6bf22d9b4b61fda67ba58b634b90640 --- src/Nazara/Utility/Formats/OBJSaver.cpp | 228 ++++++++++++++++++++++++ src/Nazara/Utility/Formats/OBJSaver.hpp | 21 +++ src/Nazara/Utility/Utility.cpp | 4 + 3 files changed, 253 insertions(+) create mode 100644 src/Nazara/Utility/Formats/OBJSaver.cpp create mode 100644 src/Nazara/Utility/Formats/OBJSaver.hpp diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp new file mode 100644 index 000000000..4fe468135 --- /dev/null +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -0,0 +1,228 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + template + class VertexCache + { + public: + VertexCache(T* ptr) : + m_count(0), + m_buffer(ptr) + { + } + + std::size_t GetCount() const + { + return m_count; + } + + std::size_t Insert(const T& data) + { + auto it = m_cache.find(data); + if (it == m_cache.end()) + { + it = m_cache.insert(std::make_pair(data, m_count)).first; + m_buffer[m_count] = data; + m_count++; + } + + return it->second + 1; + } + + private: + std::size_t m_count; + std::map m_cache; + T* m_buffer; + }; + + bool IsSupported(const String& extension) + { + return (extension == "obj"); + } + + bool SaveToStream(const Mesh& mesh, const String& format, Stream& stream, const MeshParams& parameters) + { + if (!mesh.IsValid()) + { + NazaraError("Invalid mesh"); + return false; + } + + if (mesh.IsAnimable()) + { + NazaraError("An animated mesh cannot be saved to " + format + " format"); + return false; + } + + std::size_t worstCacheVertexCount = mesh.GetVertexCount(); + OBJParser objFormat; + objFormat.SetNormalCount(worstCacheVertexCount); + objFormat.SetPositionCount(worstCacheVertexCount); + objFormat.SetTexCoordCount(worstCacheVertexCount); + + String mtlPath = stream.GetPath(); + if (!mtlPath.IsEmpty()) + { + mtlPath.Replace(".obj", ".mtl"); + String fileName = mtlPath.SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true); + if (!fileName.IsEmpty()) + objFormat.SetMtlLib(fileName); + } + + VertexCache normalCache(objFormat.GetNormals()); + VertexCache positionCache(objFormat.GetPositions()); + VertexCache texCoordsCache(objFormat.GetTexCoords()); + + // Materials + MTLParser mtlFormat; + std::unordered_set registredMaterials; + + std::size_t matCount = mesh.GetMaterialCount(); + String* materialNames = objFormat.SetMaterialCount(matCount); + for (std::size_t i = 0; i < matCount; ++i) + { + const ParameterList& matData = mesh.GetMaterialData(i); + + String name; + if (!matData.GetStringParameter(MaterialData::Name, &name)) + name = "material_" + String::Number(i); + + // Makes sure we only have one material of that name + while (registredMaterials.find(name) != registredMaterials.end()) + name += '_'; + + registredMaterials.insert(name); + materialNames[i] = name; + + MTLParser::Material* material = mtlFormat.AddMaterial(name); + + bool bValue; + String strVal; + if (matData.GetBooleanParameter(MaterialData::CustomDefined, &bValue) && bValue) + { + Color colorVal; + float fValue; + + if (matData.GetColorParameter(MaterialData::AmbientColor, &colorVal)) + material->ambient = colorVal; + + if (matData.GetColorParameter(MaterialData::DiffuseColor, &colorVal)) + material->diffuse = colorVal; + + if (matData.GetColorParameter(MaterialData::SpecularColor, &colorVal)) + material->specular = colorVal; + + if (matData.GetFloatParameter(MaterialData::Shininess, &fValue)) + material->shininess = fValue; + + if (matData.GetStringParameter(MaterialData::AlphaTexturePath, &strVal)) + material->alphaMap = strVal; + + if (matData.GetStringParameter(MaterialData::DiffuseTexturePath, &strVal)) + material->diffuseMap = strVal; + + if (matData.GetStringParameter(MaterialData::SpecularTexturePath, &strVal)) + material->specularMap = strVal; + } + else if (matData.GetStringParameter(MaterialData::FilePath, &strVal)) + material->diffuseMap = strVal; + } + + // Meshes + std::size_t meshCount = mesh.GetSubMeshCount(); + OBJParser::Mesh* meshes = objFormat.SetMeshCount(meshCount); + for (std::size_t i = 0; i < meshCount; ++i) + { + const StaticMesh* staticMesh = static_cast(mesh.GetSubMesh(i)); + + std::size_t triangleCount = staticMesh->GetTriangleCount(); + std::size_t vertexCount = staticMesh->GetVertexCount(); + + meshes[i].faces.resize(triangleCount); + meshes[i].vertices.resize(triangleCount * 3); + + { + VertexMapper vertexMapper(staticMesh); + + SparsePtr normalPtr = vertexMapper.GetComponentPtr(VertexComponent_Normal); + SparsePtr positionPtr = vertexMapper.GetComponentPtr(VertexComponent_Position); + SparsePtr texCoordsPtr = vertexMapper.GetComponentPtr(VertexComponent_TexCoord); + + std::size_t faceIndex = 0; + TriangleIterator triangle(staticMesh); + do + { + OBJParser::Face& face = meshes[i].faces[faceIndex]; + face.firstVertex = faceIndex * 3; + face.vertexCount = 3; + + for (std::size_t j = 0; j < 3; ++j) + { + OBJParser::FaceVertex& vertexIndices = meshes[i].vertices[face.firstVertex + j]; + + std::size_t index = triangle[j]; + vertexIndices.normal = normalCache.Insert(normalPtr[index]); + vertexIndices.position = positionCache.Insert(positionPtr[index]); + vertexIndices.texCoord = texCoordsCache.Insert(texCoordsPtr[index]); + } + + faceIndex++; + } + while (triangle.Advance()); + } + } + + objFormat.SetNormalCount(normalCache.GetCount()); + objFormat.SetPositionCount(positionCache.GetCount()); + objFormat.SetTexCoordCount(texCoordsCache.GetCount()); + + objFormat.Save(stream); + + if (!mtlPath.IsEmpty()) + { + File mtlFile(mtlPath, OpenMode_WriteOnly | OpenMode_Truncate); + if (mtlFile.IsOpen()) + mtlFormat.Save(mtlFile); + } + + return true; + } + } + + namespace Loaders + { + void RegisterOBJSaver() + { + MeshSaver::RegisterSaver(IsSupported, SaveToStream); + } + + void UnregisterOBJSaver() + { + MeshSaver::UnregisterSaver(IsSupported, SaveToStream); + } + } +} diff --git a/src/Nazara/Utility/Formats/OBJSaver.hpp b/src/Nazara/Utility/Formats/OBJSaver.hpp new file mode 100644 index 000000000..ed909f165 --- /dev/null +++ b/src/Nazara/Utility/Formats/OBJSaver.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_FORMATS_OBJSAVER_HPP +#define NAZARA_FORMATS_OBJSAVER_HPP + +#include + +namespace Nz +{ + namespace Loaders + { + void RegisterOBJSaver(); + void UnregisterOBJSaver(); + } +} + +#endif // NAZARA_FORMATS_OBJSAVER_HPP diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index ae5b5066d..6b2f66353 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -125,10 +126,12 @@ namespace Nz // Mesh (text) Loaders::RegisterOBJLoader(); + Loaders::RegisterOBJSaver(); // Mesh Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8) Loaders::RegisterMD5Mesh(); // Loader de fichiers .md5mesh (v10) + Loaders::RegisterOBJLoader(); // Loader de fichiers .md5mesh (v10) // Image Loaders::RegisterPCX(); // Loader de fichiers .pcx (1, 4, 8, 24 bits) @@ -163,6 +166,7 @@ namespace Nz Loaders::UnregisterMD5Anim(); Loaders::UnregisterMD5Mesh(); Loaders::UnregisterOBJLoader(); + Loaders::UnregisterOBJSaver(); Loaders::UnregisterPCX(); Loaders::UnregisterSTBLoader(); Loaders::UnregisterSTBSaver(); From 9bd6d07d04ed5d1c82bac9a68a7c14b3a5103894 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 17:16:20 +0200 Subject: [PATCH 098/235] Delete Image.inl.save-failed Former-commit-id: 830baf88d81513f7cbf498d728186f896077d0ed [formerly edf52cb3946dbe72e007fa5d3c895903f01758b8] Former-commit-id: 4d6cdde8c24c8692569fc5bac03a44997a173607 --- include/Nazara/Utility/Image.inl.save-failed | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 include/Nazara/Utility/Image.inl.save-failed diff --git a/include/Nazara/Utility/Image.inl.save-failed b/include/Nazara/Utility/Image.inl.save-failed deleted file mode 100644 index 5cb8ef42f..000000000 --- a/include/Nazara/Utility/Image.inl.save-failed +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Utility module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - template - ImageRef Image::New(Args&&... args) - { - std::unique_ptr object(new Image(std::forward(args)...)); - object->SetPersistent(false); - - return object.release(); - } -} - -#include From 26f829b38fcbd6e2e74d1aedf416ca591fa61fe2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:26:38 +0200 Subject: [PATCH 099/235] Prevent GitHub to count external libraries into the project files Former-commit-id: ba4fac7bbbb5117e6652e8060e9669a5d0cb8444 [formerly a333ba5db7fb9b8a3088b2f714ad193fdc519e84] Former-commit-id: fd23c132d9116e70bed38d000a454c9865480e78 --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index dfe077042..a788acb7e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ # Auto detect text files and perform LF normalization * text=auto +extlibs/* linguist-vendored +NazaraModuleTemplate/* linguist-vendored From 2f40b06aced09e381998c530b2c0b3b7e9c36164 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:27:30 +0200 Subject: [PATCH 100/235] Update global headers Former-commit-id: b3bec2ef174998d9089d103f57879ca6e77c87d8 [formerly 5a2966fd284484fc0a8dee3c8fedfed8593d6ee5] Former-commit-id: afccf777a79843b2991afe20e69148ff17326239 --- include/Nazara/Graphics.hpp | 4 +++- include/Nazara/Noise.hpp | 29 ++++++++++------------------- include/Nazara/Utility.hpp | 3 ++- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 465aeb999..17b10e9a1 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 17 Nov 2015 at 13:20:45 +// This file was automatically generated on 12 Jul 2016 at 17:44:43 /* Nazara Engine - Graphics module @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/include/Nazara/Noise.hpp b/include/Nazara/Noise.hpp index 45b240378..e1d14460e 100644 --- a/include/Nazara/Noise.hpp +++ b/include/Nazara/Noise.hpp @@ -1,9 +1,9 @@ -// This file was automatically generated on 17 Nov 2015 at 13:20:45 +// This file was automatically generated on 12 Jul 2016 at 17:44:43 /* Nazara Engine - Noise module - Copyright (C) 2015 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) + Copyright (C) 2016 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -29,25 +29,16 @@ #ifndef NAZARA_GLOBAL_NOISE_HPP #define NAZARA_GLOBAL_NOISE_HPP -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #endif // NAZARA_GLOBAL_NOISE_HPP diff --git a/include/Nazara/Utility.hpp b/include/Nazara/Utility.hpp index 156ca6389..d7676277e 100644 --- a/include/Nazara/Utility.hpp +++ b/include/Nazara/Utility.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 24 Jun 2015 at 13:55:50 +// This file was automatically generated on 12 Jul 2016 at 17:44:43 /* Nazara Engine - Utility module @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include From 8db95df32ec6b6c0cbc0b53d8cb1050b23c09ba9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 17 Jul 2016 21:10:20 +0200 Subject: [PATCH 101/235] Utility/OBJSaver: Fix multiple materials saving Former-commit-id: 27c24c6bd755a98a1be41208cdb5055aa51a6110 [formerly 3820670cc464da0888433eb41ab8156d9023fac3] Former-commit-id: 25982ac2cbe28413fb837f3184b9585ed8172cdc --- src/Nazara/Utility/Formats/MD2Loader.cpp | 2 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index d1d03cf52..c61dffd09 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -102,7 +102,7 @@ namespace Nz stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::CustomDefined, true); + matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(MaterialData::DiffuseTexturePath, baseDir + skin); mesh->SetMaterialData(i, std::move(matData)); diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 4fe468135..9a79638bc 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -122,7 +122,7 @@ namespace Nz bool bValue; String strVal; - if (matData.GetBooleanParameter(MaterialData::CustomDefined, &bValue) && bValue) + if (matData.HasParameter(MaterialData::CustomDefined)) { Color colorVal; float fValue; @@ -160,9 +160,10 @@ namespace Nz const StaticMesh* staticMesh = static_cast(mesh.GetSubMesh(i)); std::size_t triangleCount = staticMesh->GetTriangleCount(); - std::size_t vertexCount = staticMesh->GetVertexCount(); meshes[i].faces.resize(triangleCount); + meshes[i].material = staticMesh->GetMaterialIndex(); + meshes[i].name = "mesh_" + String::Number(i); meshes[i].vertices.resize(triangleCount * 3); { From 1d8fad14580f3fed313d9df54e379165daf56cf2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 18 Jul 2016 19:07:12 +0200 Subject: [PATCH 102/235] Build/Assimp: Fix compilation error because of missing includes Former-commit-id: ab3e7aba2991f3ff5812fd8bb404ad6a455381db [formerly ce78cfec8f0b646a163b73eac048b2b66f6b50ed] Former-commit-id: dca1919097a544973831e058266f6f91ab6bfb12 --- build/scripts/tools/assimp.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index 08688ef72..c810d6c0a 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -5,6 +5,7 @@ TOOL.Kind = "Plugin" TOOL.TargetDirectory = "../SDK/lib" TOOL.Includes = { + "../extlibs/include", "../include", "../plugins/Assimp" } From 887432b3ce47e6a097692f5ed3b9b9ab48b47171 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 21 Jul 2016 23:00:09 +0200 Subject: [PATCH 103/235] Renderer/RenderStates: Update RenderStates structure (preparing for renderer update) Former-commit-id: 8a6545bd9d4145f092bc0d90650c75e79c5298c9 [formerly 82499bdba825dfc5fff8f15be285a1ae5c4a2c41] Former-commit-id: d1c39e221b96a0e032e113691bcb1c0c68f5899e --- include/Nazara/Graphics/Material.inl | 62 +++++++++- include/Nazara/Renderer/RenderStates.hpp | 84 +++++++++---- include/Nazara/Renderer/RenderStates.inl | 42 +------ src/Nazara/Graphics/ColorBackground.cpp | 8 +- src/Nazara/Graphics/DeferredBloomPass.cpp | 2 +- src/Nazara/Graphics/DeferredDOFPass.cpp | 2 +- src/Nazara/Graphics/DeferredFXAAPass.cpp | 2 +- src/Nazara/Graphics/DeferredFinalPass.cpp | 2 +- src/Nazara/Graphics/DeferredFogPass.cpp | 2 +- src/Nazara/Graphics/DeferredGeometryPass.cpp | 10 +- .../Graphics/DeferredPhongLightingPass.cpp | 30 ++--- src/Nazara/Graphics/Material.cpp | 66 +++++----- src/Nazara/Graphics/SkyboxBackground.cpp | 8 +- src/Nazara/Graphics/TextureBackground.cpp | 8 +- src/Nazara/Renderer/DebugDrawer.cpp | 6 +- src/Nazara/Renderer/OpenGL.cpp | 113 ++++++++++-------- src/Nazara/Renderer/Renderer.cpp | 110 ++++++++++++----- 17 files changed, 339 insertions(+), 218 deletions(-) diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 1e59e6157..6d5315640 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -53,7 +53,36 @@ namespace Nz { NazaraAssert(renderParameter <= RendererParameter_Max, "Renderer parameter out of enum"); - m_states.parameters[renderParameter] = enable; + switch (renderParameter) + { + case RendererParameter_Blend: + m_states.blending = enable; + return; + + case RendererParameter_ColorWrite: + m_states.colorWrite = enable; + return; + + case RendererParameter_DepthBuffer: + m_states.depthBuffer = enable; + return; + + case RendererParameter_DepthWrite: + m_states.depthWrite = enable; + return; + + case RendererParameter_FaceCulling: + m_states.faceCulling = enable; + return; + + case RendererParameter_ScissorTest: + m_states.scissorTest = enable; + return; + + case RendererParameter_StencilTest: + m_states.stencilTest = enable; + return; + } } /*! @@ -257,7 +286,7 @@ namespace Nz inline FaceSide Material::GetFaceCulling() const { - return m_states.faceCulling; + return m_states.cullingSide; } /*! @@ -489,7 +518,32 @@ namespace Nz { NazaraAssert(parameter <= RendererParameter_Max, "Renderer parameter out of enum"); - return m_states.parameters[parameter]; + switch (parameter) + { + case RendererParameter_Blend: + return m_states.blending; + + case RendererParameter_ColorWrite: + return m_states.colorWrite; + + case RendererParameter_DepthBuffer: + return m_states.depthBuffer; + + case RendererParameter_DepthWrite: + return m_states.depthWrite; + + case RendererParameter_FaceCulling: + return m_states.faceCulling; + + case RendererParameter_ScissorTest: + return m_states.scissorTest; + + case RendererParameter_StencilTest: + return m_states.stencilTest; + } + + NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); + return false; } /*! @@ -778,7 +832,7 @@ namespace Nz inline void Material::SetFaceCulling(FaceSide faceSide) { - m_states.faceCulling = faceSide; + m_states.cullingSide = faceSide; } /*! diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index 4040bec55..a885b2a7d 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -8,37 +8,75 @@ #define NAZARA_RENDERSTATES_HPP #include +#include namespace Nz { struct RenderStates { - RenderStates(); - RenderStates(const RenderStates& states); - ~RenderStates() = default; + BlendFunc dstBlend = BlendFunc_Zero; + BlendFunc srcBlend = BlendFunc_One; + FaceFilling faceFilling = FaceFilling_Fill; + FaceSide cullingSide = FaceSide_Back; + RendererComparison depthFunc = RendererComparison_Less; - RenderStates& operator=(const RenderStates& states); - - struct Face + struct { - RendererComparison stencilCompare; - StencilOperation stencilFail; - StencilOperation stencilPass; - StencilOperation stencilZFail; - UInt32 stencilMask; - unsigned int stencilReference; - }; + RendererComparison back = RendererComparison_Always; + RendererComparison front = RendererComparison_Always; + } stencilCompare; - Face backFace; - Face frontFace; - BlendFunc dstBlend; - BlendFunc srcBlend; - FaceFilling faceFilling; - FaceSide faceCulling; - RendererComparison depthFunc; - bool parameters[RendererParameter_Max+1]; - float lineWidth; - float pointSize; + struct + { + UInt32 back = 0xFFFFFFFF; + UInt32 front = 0xFFFFFFFF; + } stencilCompareMask; + + struct + { + StencilOperation back = StencilOperation_Keep; + StencilOperation front = StencilOperation_Keep; + } stencilDepthFail; + + struct + { + StencilOperation back = StencilOperation_Keep; + StencilOperation front = StencilOperation_Keep; + } stencilFail; + + struct + { + StencilOperation back = StencilOperation_Keep; + StencilOperation front = StencilOperation_Keep; + } stencilPass; + + struct + { + UInt32 back = 0U; + UInt32 front = 0U; + } stencilReference; + + struct + { + UInt32 back = 0xFFFFFFFF; + UInt32 front = 0xFFFFFFFF; + } stencilWriteMask; + + bool blending = false; + bool colorWrite = true; + bool depthBuffer = false; + bool depthWrite = true; + bool faceCulling = false; + bool scissorTest = false; + bool stencilTest = false; + + float lineWidth = 1.f; + float pointSize = 1.f; + }; + + struct RenderPipeline : RenderStates + { + ShaderConstRef shader; }; } diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 6840d3b5f..1f7564166 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -2,52 +2,12 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include namespace Nz { - inline RenderStates::RenderStates() : - dstBlend(BlendFunc_Zero), - srcBlend(BlendFunc_One), - faceFilling(FaceFilling_Fill), - faceCulling(FaceSide_Back), - depthFunc(RendererComparison_Less), - lineWidth(1.f), - pointSize(1.f) - { - parameters[RendererParameter_Blend] = false; - parameters[RendererParameter_ColorWrite] = true; - parameters[RendererParameter_DepthBuffer] = false; - parameters[RendererParameter_DepthWrite] = true; - parameters[RendererParameter_FaceCulling] = false; - parameters[RendererParameter_ScissorTest] = false; - parameters[RendererParameter_StencilTest] = false; - - for (unsigned int i = 0; i < 2; ++i) - { - Face& face = (i == 0) ? backFace : frontFace; - - face.stencilCompare = RendererComparison_Always; - face.stencilFail = StencilOperation_Keep; - face.stencilMask = 0xFFFFFFFF; - face.stencilPass = StencilOperation_Keep; - face.stencilReference = 0; - face.stencilZFail = StencilOperation_Keep; - } - } - - inline RenderStates::RenderStates(const RenderStates& states) - { - std::memcpy(this, &states, sizeof(RenderStates)); - } - - inline RenderStates& RenderStates::operator=(const RenderStates& states) - { - std::memcpy(this, &states, sizeof(RenderStates)); - - return *this; - } } #include diff --git a/src/Nazara/Graphics/ColorBackground.cpp b/src/Nazara/Graphics/ColorBackground.cpp index 33c282390..dcacb1a46 100644 --- a/src/Nazara/Graphics/ColorBackground.cpp +++ b/src/Nazara/Graphics/ColorBackground.cpp @@ -19,11 +19,11 @@ namespace Nz RenderStates BuildRenderStates() { RenderStates states; + states.cullingSide = FaceSide_Back; states.depthFunc = RendererComparison_Equal; - states.faceCulling = FaceSide_Back; - states.parameters[RendererParameter_DepthBuffer] = true; - states.parameters[RendererParameter_DepthWrite] = false; - states.parameters[RendererParameter_FaceCulling] = true; + states.depthBuffer = true; + states.depthWrite = false; + states.faceCulling = true; return states; } diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index c902c7615..9cf39831a 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -32,7 +32,7 @@ namespace Nz m_bloomBrightShader = ShaderLibrary::Get("DeferredBloomBright"); m_bloomFinalShader = ShaderLibrary::Get("DeferredBloomFinal"); - m_bloomStates.parameters[RendererParameter_DepthBuffer] = false; + m_bloomStates.depthBuffer = false; m_gaussianBlurShader = ShaderLibrary::Get("DeferredGaussianBlur"); m_gaussianBlurShaderFilterLocation = m_gaussianBlurShader->GetUniformLocation("Filter"); diff --git a/src/Nazara/Graphics/DeferredDOFPass.cpp b/src/Nazara/Graphics/DeferredDOFPass.cpp index 63df2c400..b39085400 100644 --- a/src/Nazara/Graphics/DeferredDOFPass.cpp +++ b/src/Nazara/Graphics/DeferredDOFPass.cpp @@ -127,7 +127,7 @@ namespace Nz m_pointSampler.SetFilterMode(SamplerFilter_Nearest); m_pointSampler.SetWrapMode(SamplerWrap_Clamp); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; } DeferredDOFPass::~DeferredDOFPass() = default; diff --git a/src/Nazara/Graphics/DeferredFXAAPass.cpp b/src/Nazara/Graphics/DeferredFXAAPass.cpp index 3f1e9395a..d4ba72ddf 100644 --- a/src/Nazara/Graphics/DeferredFXAAPass.cpp +++ b/src/Nazara/Graphics/DeferredFXAAPass.cpp @@ -28,7 +28,7 @@ namespace Nz m_pointSampler.SetFilterMode(SamplerFilter_Nearest); m_pointSampler.SetWrapMode(SamplerWrap_Clamp); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; } DeferredFXAAPass::~DeferredFXAAPass() = default; diff --git a/src/Nazara/Graphics/DeferredFinalPass.cpp b/src/Nazara/Graphics/DeferredFinalPass.cpp index 091c95af6..c4ab348eb 100644 --- a/src/Nazara/Graphics/DeferredFinalPass.cpp +++ b/src/Nazara/Graphics/DeferredFinalPass.cpp @@ -26,7 +26,7 @@ namespace Nz m_pointSampler.SetFilterMode(SamplerFilter_Nearest); m_pointSampler.SetWrapMode(SamplerWrap_Clamp); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; m_uberShader = UberShaderLibrary::Get("Basic"); diff --git a/src/Nazara/Graphics/DeferredFogPass.cpp b/src/Nazara/Graphics/DeferredFogPass.cpp index f64521daf..f47a4ea56 100644 --- a/src/Nazara/Graphics/DeferredFogPass.cpp +++ b/src/Nazara/Graphics/DeferredFogPass.cpp @@ -141,7 +141,7 @@ namespace Nz m_shader = BuildFogShader(); m_shaderEyePositionLocation = m_shader->GetUniformLocation("EyePosition"); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; } DeferredFogPass::~DeferredFogPass() = default; diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 08b111a70..86815558c 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -31,12 +31,12 @@ namespace Nz DeferredGeometryPass::DeferredGeometryPass() { m_clearShader = ShaderLibrary::Get("DeferredGBufferClear"); - m_clearStates.parameters[RendererParameter_DepthBuffer] = true; - m_clearStates.parameters[RendererParameter_FaceCulling] = true; - m_clearStates.parameters[RendererParameter_StencilTest] = true; + m_clearStates.depthBuffer = true; + m_clearStates.faceCulling = true; + m_clearStates.stencilTest = true; m_clearStates.depthFunc = RendererComparison_Always; - m_clearStates.frontFace.stencilCompare = RendererComparison_Always; - m_clearStates.frontFace.stencilPass = StencilOperation_Zero; + m_clearStates.stencilCompare.front = RendererComparison_Always; + m_clearStates.stencilPass.front = StencilOperation_Zero; } DeferredGeometryPass::~DeferredGeometryPass() = default; diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index efcc88e75..afe17ed13 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -120,9 +120,9 @@ namespace Nz RenderStates lightStates; lightStates.dstBlend = BlendFunc_One; lightStates.srcBlend = BlendFunc_One; - lightStates.parameters[RendererParameter_Blend] = true; - lightStates.parameters[RendererParameter_DepthBuffer] = false; - lightStates.parameters[RendererParameter_DepthWrite] = false; + lightStates.blending = true; + lightStates.depthBuffer = false; + lightStates.depthWrite = false; // Directional lights if (!m_renderQueue->directionalLights.empty()) @@ -146,18 +146,18 @@ namespace Nz if (!m_renderQueue->pointLights.empty() || !m_renderQueue->spotLights.empty()) { // http://www.altdevblogaday.com/2011/08/08/stencil-buffer-optimisation-for-deferred-lights/ - lightStates.parameters[RendererParameter_StencilTest] = true; - lightStates.faceCulling = FaceSide_Front; - lightStates.backFace.stencilMask = 0xFF; - lightStates.backFace.stencilReference = 0; - lightStates.backFace.stencilFail = StencilOperation_Keep; - lightStates.backFace.stencilPass = StencilOperation_Keep; - lightStates.backFace.stencilZFail = StencilOperation_Invert; - lightStates.frontFace.stencilMask = 0xFF; - lightStates.frontFace.stencilReference = 0; - lightStates.frontFace.stencilFail = StencilOperation_Keep; - lightStates.frontFace.stencilPass = StencilOperation_Keep; - lightStates.frontFace.stencilZFail = StencilOperation_Invert; + lightStates.cullingSide = FaceSide_Front; + lightStates.stencilTest = true; + lightStates.stencilDepthFail.back = StencilOperation_Invert; + lightStates.stencilDepthFail.front = StencilOperation_Invert; + lightStates.stencilFail.back = StencilOperation_Keep; + lightStates.stencilFail.front = StencilOperation_Keep; + lightStates.stencilPass.back = StencilOperation_Keep; + lightStates.stencilPass.front = StencilOperation_Keep; + lightStates.stencilReference.back = 0; + lightStates.stencilReference.front = 0; + lightStates.stencilWriteMask.back = 0xFF; + lightStates.stencilWriteMask.front = 0xFF; Renderer::SetRenderStates(lightStates); diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 651f2581c..53e0e3e3e 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -252,41 +252,41 @@ namespace Nz // Stencil if (matData.GetIntegerParameter(MaterialData::StencilCompare, &iValue)) - m_states.frontFace.stencilCompare = static_cast(iValue); + m_states.stencilCompare.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilFail, &iValue)) - m_states.frontFace.stencilFail = static_cast(iValue); + m_states.stencilFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilPass, &iValue)) - m_states.frontFace.stencilPass = static_cast(iValue); + m_states.stencilPass.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilZFail, &iValue)) - m_states.frontFace.stencilZFail = static_cast(iValue); + m_states.stencilDepthFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilMask, &iValue)) - m_states.frontFace.stencilMask = static_cast(iValue); + m_states.stencilWriteMask.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilReference, &iValue)) - m_states.frontFace.stencilReference = static_cast(iValue); + m_states.stencilReference.front = static_cast(iValue); // Stencil (back) if (matData.GetIntegerParameter(MaterialData::BackFaceStencilCompare, &iValue)) - m_states.backFace.stencilCompare = static_cast(iValue); + m_states.stencilCompare.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilFail, &iValue)) - m_states.backFace.stencilFail = static_cast(iValue); + m_states.stencilFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilPass, &iValue)) - m_states.backFace.stencilPass = static_cast(iValue); + m_states.stencilPass.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilZFail, &iValue)) - m_states.backFace.stencilZFail = static_cast(iValue); + m_states.stencilDepthFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilMask, &iValue)) - m_states.backFace.stencilMask = static_cast(iValue); + m_states.stencilWriteMask.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilReference, &iValue)) - m_states.backFace.stencilReference = static_cast(iValue); + m_states.stencilReference.back = static_cast(iValue); // Textures if (matParams.loadAlphaMap && matData.GetStringParameter(MaterialData::AlphaTexturePath, &path)) @@ -332,13 +332,13 @@ namespace Nz matData->SetParameter(MaterialData::Transform, IsTransformEnabled()); // RendererParameter - matData->SetParameter(MaterialData::Blending, GetRenderStates().parameters[RendererParameter_Blend]); - matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().parameters[RendererParameter_ColorWrite]); - matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().parameters[RendererParameter_DepthBuffer]); - matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().parameters[RendererParameter_DepthWrite]); - matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().parameters[RendererParameter_FaceCulling]); - matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().parameters[RendererParameter_ScissorTest]); - matData->SetParameter(MaterialData::StencilTest, GetRenderStates().parameters[RendererParameter_StencilTest]); + matData->SetParameter(MaterialData::Blending, GetRenderStates().blending); + matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().colorWrite); + matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().depthBuffer); + matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().depthWrite); + matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().faceCulling); + matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().scissorTest); + matData->SetParameter(MaterialData::StencilTest, GetRenderStates().stencilTest); // Samplers matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, int(GetDiffuseSampler().GetAnisotropicLevel())); @@ -350,20 +350,20 @@ namespace Nz matData->SetParameter(MaterialData::SpecularWrap, int(GetSpecularSampler().GetWrapMode())); // Stencil - matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().frontFace.stencilCompare)); - matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().frontFace.stencilFail)); - matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().frontFace.stencilPass)); - matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().frontFace.stencilZFail)); - matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().frontFace.stencilMask)); - matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().frontFace.stencilReference)); + matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().stencilCompare.front)); + matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().stencilFail.front)); + matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().stencilPass.front)); + matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().stencilDepthFail.front)); + matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().stencilWriteMask.front)); + matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().stencilReference.front)); // Stencil (back) - matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().backFace.stencilCompare)); - matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().backFace.stencilFail)); - matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().backFace.stencilPass)); - matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().backFace.stencilZFail)); - matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().backFace.stencilMask)); - matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().backFace.stencilReference)); + matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().stencilCompare.back)); + matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().stencilFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().stencilPass.back)); + matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().stencilDepthFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().stencilWriteMask.back)); + matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().stencilReference.back)); // Textures if (HasAlphaMap()) @@ -441,8 +441,8 @@ namespace Nz m_specularColor = Color::White; m_specularSampler = TextureSampler(); m_states = RenderStates(); - m_states.parameters[RendererParameter_DepthBuffer] = true; - m_states.parameters[RendererParameter_FaceCulling] = true; + m_states.depthBuffer = true; + m_states.faceCulling = true; m_transformEnabled = true; SetShader("Basic"); diff --git a/src/Nazara/Graphics/SkyboxBackground.cpp b/src/Nazara/Graphics/SkyboxBackground.cpp index 75bc0cc12..fa7faefac 100644 --- a/src/Nazara/Graphics/SkyboxBackground.cpp +++ b/src/Nazara/Graphics/SkyboxBackground.cpp @@ -181,10 +181,10 @@ namespace Nz // Renderstates s_renderStates.depthFunc = RendererComparison_Equal; - s_renderStates.faceCulling = FaceSide_Front; - s_renderStates.parameters[RendererParameter_DepthBuffer] = true; - s_renderStates.parameters[RendererParameter_DepthWrite] = false; - s_renderStates.parameters[RendererParameter_FaceCulling] = true; + s_renderStates.cullingSide = FaceSide_Front; + s_renderStates.depthBuffer = true; + s_renderStates.depthWrite = false; + s_renderStates.faceCulling = true; // Exception-free zone s_indexBuffer = std::move(indexBuffer); diff --git a/src/Nazara/Graphics/TextureBackground.cpp b/src/Nazara/Graphics/TextureBackground.cpp index 1b2e53e72..a990f4af6 100644 --- a/src/Nazara/Graphics/TextureBackground.cpp +++ b/src/Nazara/Graphics/TextureBackground.cpp @@ -20,10 +20,10 @@ namespace Nz { RenderStates states; states.depthFunc = RendererComparison_Equal; - states.faceCulling = FaceSide_Back; - states.parameters[RendererParameter_DepthBuffer] = true; - states.parameters[RendererParameter_DepthWrite] = false; - states.parameters[RendererParameter_FaceCulling] = true; + states.cullingSide = FaceSide_Back; + states.depthBuffer = true; + states.depthWrite = false; + states.faceCulling = true; return states; } diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index 5623e6e8d..9f06c880f 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -652,7 +652,7 @@ namespace Nz void DebugDrawer::EnableDepthBuffer(bool depthBuffer) { - s_renderStates.parameters[RendererParameter_DepthBuffer] = depthBuffer; + s_renderStates.depthBuffer = depthBuffer; } float DebugDrawer::GetLineWidth() @@ -698,7 +698,7 @@ namespace Nz } s_primaryColor = Color::Red; - s_renderStates.parameters[RendererParameter_DepthBuffer] = true; + s_renderStates.depthBuffer = true; s_secondaryColor = Color::Green; s_initialized = true; @@ -709,7 +709,7 @@ namespace Nz bool DebugDrawer::IsDepthBufferEnabled() { - return s_renderStates.parameters[RendererParameter_DepthBuffer]; + return s_renderStates.depthBuffer; } void DebugDrawer::SetLineWidth(float width) diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index b77319997..ba17fe015 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -158,7 +158,7 @@ namespace Nz RenderStates& currentRenderStates = s_contextStates->renderStates; // Les fonctions de blend n'a aucun intérêt sans blending - if (states.parameters[RendererParameter_Blend]) + if (states.blending) { if (currentRenderStates.dstBlend != states.dstBlend || currentRenderStates.srcBlend != states.srcBlend) @@ -169,7 +169,7 @@ namespace Nz } } - if (states.parameters[RendererParameter_DepthBuffer]) + if (states.depthBuffer) { // La comparaison de profondeur n'a aucun intérêt sans depth buffer if (currentRenderStates.depthFunc != states.depthFunc) @@ -179,20 +179,20 @@ namespace Nz } // Le DepthWrite n'a aucune importance si le DepthBuffer est désactivé - if (currentRenderStates.parameters[RendererParameter_DepthWrite] != states.parameters[RendererParameter_DepthWrite]) + if (currentRenderStates.depthWrite != states.depthWrite) { - glDepthMask((states.parameters[RendererParameter_DepthWrite]) ? GL_TRUE : GL_FALSE); - currentRenderStates.parameters[RendererParameter_DepthWrite] = states.parameters[RendererParameter_DepthWrite]; + glDepthMask((states.depthWrite) ? GL_TRUE : GL_FALSE); + currentRenderStates.depthWrite = states.depthWrite; } } // Inutile de changer le mode de face culling s'il n'est pas actif - if (states.parameters[RendererParameter_FaceCulling]) + if (states.faceCulling) { - if (currentRenderStates.faceCulling != states.faceCulling) + if (currentRenderStates.cullingSide != states.cullingSide) { - glCullFace(FaceSide[states.faceCulling]); - currentRenderStates.faceCulling = states.faceCulling; + glCullFace(FaceSide[states.cullingSide]); + currentRenderStates.cullingSide = states.cullingSide; } } @@ -203,33 +203,46 @@ namespace Nz } // Ici encore, ça ne sert à rien de se soucier des fonctions de stencil sans qu'il soit activé - if (states.parameters[RendererParameter_StencilTest]) + if (states.stencilTest) { - for (unsigned int i = 0; i < 2; ++i) + if (currentRenderStates.stencilCompare.back != states.stencilCompare.back || + currentRenderStates.stencilReference.back != states.stencilReference.back || + currentRenderStates.stencilWriteMask.back != states.stencilWriteMask.back) { - GLenum face = (i == 0) ? GL_BACK : GL_FRONT; - const RenderStates::Face& srcStates = (i == 0) ? states.backFace : states.frontFace; - RenderStates::Face& dstStates = (i == 0) ? currentRenderStates.backFace : currentRenderStates.frontFace; + glStencilFuncSeparate(GL_BACK, RendererComparison[states.stencilCompare.back], states.stencilReference.back, states.stencilWriteMask.back); + currentRenderStates.stencilCompare.back = states.stencilCompare.back; + currentRenderStates.stencilReference.back = states.stencilReference.back; + currentRenderStates.stencilWriteMask.back = states.stencilWriteMask.back; + } - if (dstStates.stencilCompare != srcStates.stencilCompare || - dstStates.stencilMask != srcStates.stencilMask || - dstStates.stencilReference != srcStates.stencilReference) - { - glStencilFuncSeparate(face, RendererComparison[srcStates.stencilCompare], srcStates.stencilReference, srcStates.stencilMask); - dstStates.stencilCompare = srcStates.stencilCompare; - dstStates.stencilMask = srcStates.stencilMask; - dstStates.stencilReference = srcStates.stencilReference; - } + if (currentRenderStates.stencilDepthFail.back != states.stencilDepthFail.back || + currentRenderStates.stencilFail.back != states.stencilFail.back || + currentRenderStates.stencilPass.back != states.stencilPass.back) + { + glStencilOpSeparate(GL_BACK, StencilOperation[states.stencilFail.back], StencilOperation[states.stencilDepthFail.back], StencilOperation[states.stencilPass.back]); + currentRenderStates.stencilDepthFail.back = states.stencilDepthFail.back; + currentRenderStates.stencilFail.back = states.stencilFail.back; + currentRenderStates.stencilPass.back = states.stencilPass.back; + } - if (dstStates.stencilFail != srcStates.stencilFail || - dstStates.stencilPass != srcStates.stencilPass || - dstStates.stencilZFail != srcStates.stencilZFail) - { - glStencilOpSeparate(face, StencilOperation[srcStates.stencilFail], StencilOperation[srcStates.stencilZFail], StencilOperation[srcStates.stencilPass]); - dstStates.stencilFail = srcStates.stencilFail; - dstStates.stencilPass = srcStates.stencilPass; - dstStates.stencilZFail = srcStates.stencilZFail; - } + if (currentRenderStates.stencilCompare.front != states.stencilCompare.front || + currentRenderStates.stencilReference.front != states.stencilReference.front || + currentRenderStates.stencilWriteMask.front != states.stencilWriteMask.front) + { + glStencilFuncSeparate(GL_FRONT, RendererComparison[states.stencilCompare.front], states.stencilReference.front, states.stencilWriteMask.front); + currentRenderStates.stencilCompare.front = states.stencilCompare.front; + currentRenderStates.stencilReference.front = states.stencilReference.front; + currentRenderStates.stencilWriteMask.front = states.stencilWriteMask.front; + } + + if (currentRenderStates.stencilDepthFail.front != states.stencilDepthFail.front || + currentRenderStates.stencilFail.front != states.stencilFail.front || + currentRenderStates.stencilPass.front != states.stencilPass.front) + { + glStencilOpSeparate(GL_FRONT, StencilOperation[states.stencilFail.front], StencilOperation[states.stencilDepthFail.front], StencilOperation[states.stencilPass.front]); + currentRenderStates.stencilDepthFail.front = states.stencilDepthFail.front; + currentRenderStates.stencilFail.front = states.stencilFail.front; + currentRenderStates.stencilPass.front = states.stencilPass.front; } } @@ -246,62 +259,62 @@ namespace Nz } // Paramètres de rendu - if (currentRenderStates.parameters[RendererParameter_Blend] != states.parameters[RendererParameter_Blend]) + if (currentRenderStates.blending != states.blending) { - if (states.parameters[RendererParameter_Blend]) + if (states.blending) glEnable(GL_BLEND); else glDisable(GL_BLEND); - currentRenderStates.parameters[RendererParameter_Blend] = states.parameters[RendererParameter_Blend]; + currentRenderStates.blending = states.blending; } - if (currentRenderStates.parameters[RendererParameter_ColorWrite] != states.parameters[RendererParameter_ColorWrite]) + if (currentRenderStates.colorWrite != states.colorWrite) { - GLboolean param = (states.parameters[RendererParameter_ColorWrite]) ? GL_TRUE : GL_FALSE; + GLboolean param = (states.colorWrite) ? GL_TRUE : GL_FALSE; glColorMask(param, param, param, param); - currentRenderStates.parameters[RendererParameter_ColorWrite] = states.parameters[RendererParameter_ColorWrite]; + currentRenderStates.colorWrite = states.colorWrite; } - if (currentRenderStates.parameters[RendererParameter_DepthBuffer] != states.parameters[RendererParameter_DepthBuffer]) + if (currentRenderStates.depthBuffer != states.depthBuffer) { - if (states.parameters[RendererParameter_DepthBuffer]) + if (states.depthBuffer) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); - currentRenderStates.parameters[RendererParameter_DepthBuffer] = states.parameters[RendererParameter_DepthBuffer]; + currentRenderStates.depthBuffer = states.depthBuffer; } - if (currentRenderStates.parameters[RendererParameter_FaceCulling] != states.parameters[RendererParameter_FaceCulling]) + if (currentRenderStates.faceCulling != states.faceCulling) { - if (states.parameters[RendererParameter_FaceCulling]) + if (states.faceCulling) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); - currentRenderStates.parameters[RendererParameter_FaceCulling] = states.parameters[RendererParameter_FaceCulling]; + currentRenderStates.faceCulling = states.faceCulling; } - if (currentRenderStates.parameters[RendererParameter_ScissorTest] != states.parameters[RendererParameter_ScissorTest]) + if (currentRenderStates.scissorTest != states.scissorTest) { - if (states.parameters[RendererParameter_ScissorTest]) + if (states.scissorTest) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST); - currentRenderStates.parameters[RendererParameter_ScissorTest] = states.parameters[RendererParameter_ScissorTest]; + currentRenderStates.scissorTest = states.scissorTest; } - if (currentRenderStates.parameters[RendererParameter_StencilTest] != states.parameters[RendererParameter_StencilTest]) + if (currentRenderStates.stencilTest != states.stencilTest) { - if (states.parameters[RendererParameter_StencilTest]) + if (states.stencilTest) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST); - currentRenderStates.parameters[RendererParameter_StencilTest] = states.parameters[RendererParameter_StencilTest]; + currentRenderStates.stencilTest = states.stencilTest; } } diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index e49db2cec..028f7513f 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -396,7 +396,38 @@ namespace Nz } #endif - s_states.parameters[parameter] = enable; + switch (parameter) + { + case RendererParameter_Blend: + s_states.blending = enable; + return; + + case RendererParameter_ColorWrite: + s_states.colorWrite = enable; + return; + + case RendererParameter_DepthBuffer: + s_states.depthBuffer = enable; + return; + + case RendererParameter_DepthWrite: + s_states.depthWrite = enable; + return; + + case RendererParameter_FaceCulling: + s_states.faceCulling = enable; + return; + + case RendererParameter_ScissorTest: + s_states.scissorTest = enable; + return; + + case RendererParameter_StencilTest: + s_states.stencilTest = enable; + return; + } + + NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); } void Renderer::EndCondition() @@ -762,7 +793,32 @@ namespace Nz } #endif - return s_states.parameters[parameter]; + switch (parameter) + { + case RendererParameter_Blend: + return s_states.blending; + + case RendererParameter_ColorWrite: + return s_states.colorWrite; + + case RendererParameter_DepthBuffer: + return s_states.depthBuffer; + + case RendererParameter_DepthWrite: + return s_states.depthWrite; + + case RendererParameter_FaceCulling: + return s_states.faceCulling; + + case RendererParameter_ScissorTest: + return s_states.scissorTest; + + case RendererParameter_StencilTest: + return s_states.stencilTest; + } + + NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); + return false; } bool Renderer::IsInitialized() @@ -865,7 +921,7 @@ namespace Nz } #endif - s_states.faceCulling = faceSide; + s_states.cullingSide = faceSide; } void Renderer::SetFaceFilling(FaceFilling fillingMode) @@ -1042,16 +1098,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilCompare = compareFunc; + s_states.stencilCompare.back = compareFunc; break; case FaceSide_Front: - s_states.frontFace.stencilCompare = compareFunc; + s_states.stencilCompare.front = compareFunc; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilCompare = compareFunc; - s_states.frontFace.stencilCompare = compareFunc; + s_states.stencilCompare.back = compareFunc; + s_states.stencilCompare.front = compareFunc; break; } } @@ -1075,16 +1131,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilFail = failOperation; + s_states.stencilFail.back = failOperation; break; case FaceSide_Front: - s_states.frontFace.stencilFail = failOperation; + s_states.stencilFail.front = failOperation; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilFail = failOperation; - s_states.frontFace.stencilFail = failOperation; + s_states.stencilFail.back = failOperation; + s_states.stencilFail.front = failOperation; break; } } @@ -1102,16 +1158,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilMask = mask; + s_states.stencilWriteMask.back = mask; break; case FaceSide_Front: - s_states.frontFace.stencilMask = mask; + s_states.stencilWriteMask.front = mask; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilMask = mask; - s_states.frontFace.stencilMask = mask; + s_states.stencilWriteMask.back = mask; + s_states.stencilWriteMask.front = mask; break; } } @@ -1135,16 +1191,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilPass = passOperation; + s_states.stencilPass.back = passOperation; break; case FaceSide_Front: - s_states.frontFace.stencilPass = passOperation; + s_states.stencilPass.front = passOperation; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilPass = passOperation; - s_states.frontFace.stencilPass = passOperation; + s_states.stencilPass.back = passOperation; + s_states.stencilPass.front = passOperation; break; } } @@ -1162,16 +1218,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilReference = refValue; + s_states.stencilReference.back = refValue; break; case FaceSide_Front: - s_states.frontFace.stencilReference = refValue; + s_states.stencilReference.front = refValue; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilReference = refValue; - s_states.frontFace.stencilReference = refValue; + s_states.stencilReference.back = refValue; + s_states.stencilReference.front = refValue; break; } } @@ -1195,16 +1251,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilZFail = zfailOperation; + s_states.stencilDepthFail.back = zfailOperation; break; case FaceSide_Front: - s_states.frontFace.stencilZFail = zfailOperation; + s_states.stencilDepthFail.front = zfailOperation; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilZFail = zfailOperation; - s_states.frontFace.stencilZFail = zfailOperation; + s_states.stencilDepthFail.back = zfailOperation; + s_states.stencilDepthFail.front = zfailOperation; break; } } From 8e12e5a7b380aae45fedbd8eada82f07ba9bbaf3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 Jul 2016 18:06:17 +0200 Subject: [PATCH 104/235] Graphics: Add TileMap class Former-commit-id: 49ca959a0ac207a0ebc37dbdd84ecae26d3bac6f [formerly 49e3dc1607dbcc7b6315328dac84be5a86d7727d] Former-commit-id: 564963a44d5afc05a90c773cb73c5c2e6c7f85d0 --- include/Nazara/Graphics/TileMap.hpp | 97 ++++++ include/Nazara/Graphics/TileMap.inl | 441 ++++++++++++++++++++++++++++ src/Nazara/Graphics/Graphics.cpp | 8 + src/Nazara/Graphics/TileMap.cpp | 110 +++++++ 4 files changed, 656 insertions(+) create mode 100644 include/Nazara/Graphics/TileMap.hpp create mode 100644 include/Nazara/Graphics/TileMap.inl create mode 100644 src/Nazara/Graphics/TileMap.cpp diff --git a/include/Nazara/Graphics/TileMap.hpp b/include/Nazara/Graphics/TileMap.hpp new file mode 100644 index 000000000..89a901b9a --- /dev/null +++ b/include/Nazara/Graphics/TileMap.hpp @@ -0,0 +1,97 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_TILEMAP_HPP +#define NAZARA_TILEMAP_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class TileMap; + + using TileMapConstRef = ObjectRef; + using TileMapLibrary = ObjectLibrary; + using TileMapRef = ObjectRef; + + class NAZARA_GRAPHICS_API TileMap : public InstancedRenderable + { + friend TileMapLibrary; + friend class Graphics; + + public: + struct Tile; + + inline TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount = 1); + TileMap(const TileMap& TileMap) = default; + TileMap(TileMap&&) = delete; + ~TileMap() = default; + + void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; + + inline void DisableTile(const Vector2ui& tilePos); + inline void DisableTiles(); + inline void DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount); + + inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); + + inline const MaterialRef& GetMaterial(std::size_t index) const; + inline std::size_t GetMaterialCount() const; + inline const Vector2ui& GetMapSize() const; + inline Vector2f GetSize() const; + inline const Tile& GetTile(const Vector2ui& tilePos) const; + inline const Vector2f& GetTileSize() const; + + inline void SetMaterial(std::size_t index, MaterialRef material); + + inline TileMap& operator=(const TileMap& TileMap); + TileMap& operator=(TileMap&& TileMap) = delete; + + template static TileMapRef New(Args&&... args); + + struct Tile + { + std::size_t layerIndex = 0U; + Color color = Color::White; + Rectf textureCoords = Rectf::Zero(); + bool enabled = false; + }; + + private: + void MakeBoundingVolume() const override; + void UpdateData(InstanceData* instanceData) const override; + + static bool Initialize(); + static void Uninitialize(); + + struct Layer + { + MaterialRef material; + std::set tiles; + }; + + std::vector m_tiles; + std::vector m_layers; + Vector2ui m_mapSize; + Vector2f m_tileSize; + + static TileMapLibrary::LibraryMap s_library; + }; +} + +#include + +#endif // NAZARA_TILEMAP_HPP diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl new file mode 100644 index 000000000..684b21387 --- /dev/null +++ b/include/Nazara/Graphics/TileMap.inl @@ -0,0 +1,441 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + /*! + * \brief Constructs a TileMap object, containing mapSize tileSize-sized tiles + * + * \param mapSize Number of tiles in each dimension, must be + * \param tileSize Size of each tile of the TileMap + * \param materialCount The maximum number of differents Material this TileMap will use + * + * \remark When constructed, a TileMap has no tile active and will not be rendered + * To use it, you have to enable some tiles. + * + * \remark The default material is used for every material requested + */ + inline TileMap::TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount) : + m_tiles(mapSize.x * mapSize.y), + m_layers(materialCount), + m_mapSize(mapSize), + m_tileSize(tileSize) + { + NazaraAssert(m_tiles.size() != 0U, "Invalid map size"); + NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size"); + NazaraAssert(m_layers.size() != 0U, "Invalid material count"); + + for (Layer& layer : m_layers) + layer.material = Material::GetDefault(); + + InvalidateBoundingVolume(); + } + + /*! + * \brief Disable the tile at position tilePos, disabling rendering at this location + * + * \param tilePos Position of the tile to disable + * + * \seealso DisableTiles + */ + inline void TileMap::DisableTile(const Vector2ui& tilePos) + { + NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds"); + + std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x; + Tile& tile = m_tiles[tileIndex]; + tile.enabled = false; + + m_layers[tile.layerIndex].tiles.erase(tileIndex); + + InvalidateInstanceData(1U << tile.layerIndex); + } + + /*! + * \brief Disable all tiles + */ + inline void TileMap::DisableTiles() + { + for (Tile& tile : m_tiles) + tile.enabled = false; + + for (Layer& layer : m_layers) + layer.tiles.clear(); + + InvalidateInstanceData(0xFFFFFFFF); + } + + /*! + * \brief Disable tileCount tiles at positions contained at tilesPos location, disabling rendering at those locations + * + * This is equivalent to calling tileCount times DisableTile with the positions contained at tilesPos + * + * \param tilesPos Pointer to a valid array of at least tileCount positions + * \param tileCount Number of tiles to disable + * + * \remark if tileCount is zero, this is a no-op and the value of tilesPos is not used + * + * \seealso DisableTile + */ + inline void TileMap::DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount) + { + NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount"); + + UInt32 invalidatedLayers = 0; + + for (std::size_t i = 0; i < tileCount; ++i) + { + NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds"); + + std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x; + Tile& tile = m_tiles[tileIndex]; + tile.enabled = false; + + m_layers[tile.layerIndex].tiles.erase(tileIndex); + + invalidatedLayers |= 1U << tile.layerIndex; + + tilesPos++; + } + + if (tileCount > 0) + InvalidateInstanceData(invalidatedLayers); + } + + /*! + * \brief Enable and sets the tile at position tilePos + * + * Setup the tile at position tilePos using color, normalized coordinates coords and materialIndex + * + * \param tilePos Position of the tile to enable + * \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \seealso EnableTiles + */ + inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color, std::size_t materialIndex) + { + NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds"); + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + UInt32 invalidatedLayers = 1U << materialIndex; + + std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x; + Tile& tile = m_tiles[tilePos.y * m_mapSize.x + tilePos.x]; + + if (!tile.enabled) + m_layers[materialIndex].tiles.insert(tileIndex); + else if (materialIndex != tile.layerIndex) + { + m_layers[materialIndex].tiles.erase(tileIndex); + m_layers[tile.layerIndex].tiles.insert(tileIndex); + + invalidatedLayers |= 1U << tile.layerIndex; + } + + tile.enabled = true; + tile.color = color; + tile.textureCoords = coords; + tile.layerIndex = materialIndex; + + InvalidateInstanceData(invalidatedLayers); + } + + /*! + * \brief Enable and sets the tile at position tilePos + * + * Setup the tile at position tilePos using color, unnormalized coordinates rect and materialIndex + * + * \param tilePos Position of the tile to enable + * \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTiles + */ + inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map"); + + Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); + + Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); + EnableTile(tilePos, unnormalizedCoords, color, materialIndex); + } + + /*! + * \brief Enable and sets all the tiles + * + * Setup all tiles using color, normalized coordinates coords and materialIndex + * + * \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Rectf& coords, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + for (Layer& layer : m_layers) + layer.tiles.clear(); + + std::size_t tileIndex = 0; + for (Tile& tile : m_tiles) + { + tile.enabled = true; + tile.color = color; + tile.textureCoords = coords; + tile.layerIndex = materialIndex; + + m_layers[materialIndex].tiles.insert(tileIndex++); + } + + InvalidateInstanceData(0xFFFFFFFF); + } + + /*! + * \brief Enable and sets all the tiles + * + * Setup all tiles using color, unnormalized coordinates coords and materialIndex + * + * \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Rectui& rect, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); + + Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); + EnableTiles(unnormalizedCoords, color, materialIndex); + } + + /*! + * \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations + * + * Setup all tiles using color, normalized coordinates coords and materialIndex + * + * \param tilesPos Pointer to a valid array of at least tileCount positions + * \param tileCount Number of tiles to enable + * \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color, std::size_t materialIndex) + { + NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount"); + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + UInt32 invalidatedLayers = 1U << materialIndex; + + for (std::size_t i = 0; i < tileCount; ++i) + { + NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds"); + + std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x; + Tile& tile = m_tiles[tileIndex]; + + if (!tile.enabled) + m_layers[materialIndex].tiles.insert(tileIndex); + else if (materialIndex != tile.layerIndex) + { + m_layers[materialIndex].tiles.erase(tileIndex); + m_layers[tile.layerIndex].tiles.insert(tileIndex); + + invalidatedLayers |= 1U << tile.layerIndex; + } + + tile.enabled = true; + tile.color = color; + tile.textureCoords = coords; + tile.layerIndex = materialIndex; + tilesPos++; + } + + if (tileCount > 0) + InvalidateInstanceData(invalidatedLayers); + } + + /*! + * \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations + * + * Setup all tiles using color, unnormalized coordinates coords and materialIndex + * + * \param tilesPos Pointer to a valid array of at least tileCount positions + * \param tileCount Number of tiles to enable + * \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map"); + + Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); + + Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); + EnableTiles(tilesPos, tileCount, unnormalizedCoords, color, materialIndex); + } + + /*! + * \brief Gets the material at position index used by the TileMap + * + * \param index Index of the material to query + * + * \return Material at index + */ + inline const MaterialRef& TileMap::GetMaterial(std::size_t index) const + { + NazaraAssert(index < m_layers.size(), "Material out of bounds"); + + return m_layers[index].material; + } + + /*! + * \brief Gets the maximum material count this TileMap can use + * \return Material count + */ + inline std::size_t TileMap::GetMaterialCount() const + { + return m_layers.size(); + } + + /*! + * \brief Gets the tilemap size (i.e. number of tiles in each dimension) + * \return Number of tiles in each dimension + * + * \seealso GetSize + * \seealso GetTileSize + */ + inline const Vector2ui& TileMap::GetMapSize() const + { + return m_mapSize; + } + + /*! + * \brief Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize()) + * \return Maximum size in units occupied by this tilemap + * + * \seealso GetMapSize + * \seealso GetTileSize + */ + inline Vector2f TileMap::GetSize() const + { + return Vector2f(m_mapSize) * m_tileSize; + } + + /*! + * \brief Returns informations about a particular tile + * + * \param tilePos Position of the tile to get (enabled or not) + * + * \return Maximum size in units occupied by this tilemap + */ + inline const TileMap::Tile& TileMap::GetTile(const Vector2ui& tilePos) const + { + NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds"); + + return m_tiles[tilePos.y * m_mapSize.x + tilePos.x]; + } + + /*! + * \brief Gets the tile size (i.e. number of units occupied by a tile in each dimension) + * \return Tile size in each dimension + * + * \seealso GetMapSize + * \seealso GetSize + */ + inline const Vector2f& TileMap::GetTileSize() const + { + return m_tileSize; + } + + /*! + * \brief Sets a material of the TileMap + * + * \param index Index of the material to change + * \param material Material for the TileMap + */ + inline void TileMap::SetMaterial(std::size_t index, MaterialRef material) + { + NazaraAssert(index < m_layers.size(), "Material out of bounds"); + + m_layers[index].material = std::move(material); + } + + /*! + * \brief Sets the current TileMap with the content of the other one + * \return A reference to this + * + * \param TileMap The other TileMap + */ + inline TileMap& TileMap::operator=(const TileMap& TileMap) + { + InstancedRenderable::operator=(TileMap); + + m_layers = TileMap.m_layers; + m_mapSize = TileMap.m_mapSize; + m_tiles = TileMap.m_tiles; + m_tileSize = TileMap.m_tileSize; + + // We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated + InvalidateBoundingVolume(); + InvalidateInstanceData(0xFFFFFFFF); + + return *this; + } + + /*! + * \brief Creates a new TileMap from the arguments + * \return A reference to the newly created TileMap + * + * \param args Arguments for the TileMap + */ + template + TileMapRef TileMap::New(Args&&... args) + { + std::unique_ptr object(new TileMap(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index c9cc652a8..5e6cd72b7 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -110,6 +111,12 @@ namespace Nz return false; } + if (!TileMap::Initialize()) + { + NazaraError("Failed to initialize tilemaps"); + return false; + } + // Generic loaders Loaders::RegisterMesh(); Loaders::RegisterTexture(); @@ -217,6 +224,7 @@ namespace Nz Material::Uninitialize(); SkyboxBackground::Uninitialize(); Sprite::Uninitialize(); + TileMap::Uninitialize(); NazaraNotice("Uninitialized: Graphics module"); diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp new file mode 100644 index 000000000..9d835cb24 --- /dev/null +++ b/src/Nazara/Graphics/TileMap.cpp @@ -0,0 +1,110 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::TileMap + * \brief Graphics class that represent several tiles of the same size assembled into a grid + * This class is far more efficient than using a sprite for every tile + */ + + /*! + * \brief Adds the TileMap to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void TileMap::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const + { + const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(instanceData.data.data()); + + std::size_t spriteCount = 0; + for (const Layer& layer : m_layers) + { + if (layer.material) + renderQueue->AddSprites(instanceData.renderOrder, layer.material, &vertices[spriteCount], layer.tiles.size()); + + spriteCount += layer.tiles.size(); + } + } + + void TileMap::MakeBoundingVolume() const + { + Nz::Vector2f size = GetSize(); + m_boundingVolume.Set(Vector3f(0.f), size.x*Vector3f::Right() + size.y*Vector3f::Down()); + } + + void TileMap::UpdateData(InstanceData* instanceData) const + { + std::size_t spriteCount = 0; + for (const Layer& layer : m_layers) + spriteCount += layer.tiles.size(); + + instanceData->data.resize(4 * spriteCount * sizeof(VertexStruct_XYZ_Color_UV)); + VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(instanceData->data.data()); + + spriteCount = 0; + for (const Layer& layer : m_layers) + { + SparsePtr colorPtr(&vertices[spriteCount].color, sizeof(VertexStruct_XYZ_Color_UV)); + SparsePtr posPtr(&vertices[spriteCount].position, sizeof(VertexStruct_XYZ_Color_UV)); + SparsePtr texCoordPtr(&vertices[spriteCount].uv, sizeof(VertexStruct_XYZ_Color_UV)); + + for (std::size_t tileIndex : layer.tiles) + { + const Tile& tile = m_tiles[tileIndex]; + NazaraAssert(tile.enabled, "Tile specified for rendering is not enabled"); + + std::size_t x = tileIndex % m_mapSize.x; + std::size_t y = tileIndex / m_mapSize.x; + Vector3f tileLeftCorner(x * m_tileSize.x, y * -m_tileSize.y, 0.f); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftTop); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right()); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightTop); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.y * Vector3f::Down()); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftBottom); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right() + m_tileSize.y * Vector3f::Down()); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightBottom); + } + spriteCount += layer.tiles.size(); + } + } + + bool TileMap::Initialize() + { + if (!TileMapLibrary::Initialize()) + { + NazaraError("Failed to initialise library"); + return false; + } + + return true; + } + + void TileMap::Uninitialize() + { + TileMapLibrary::Uninitialize(); + } + + TileMapLibrary::LibraryMap TileMap::s_library; +} From 7864d81066e2f7fe311ba1542944e96a099fd09f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 Jul 2016 18:24:27 +0200 Subject: [PATCH 105/235] Doc: Fix \see Former-commit-id: 93bf7d532461f8a7e0fe06fea1cb85ec4ea769db [formerly 586693e59d2cddbc792c37fe89f6412ab6a814b3] Former-commit-id: e510c486f24bb07429624ee4c0cfa7d3c80a6a3d --- include/Nazara/Core/ResourceSaver.inl | 4 ++-- include/Nazara/Graphics/TileMap.inl | 28 +++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/Nazara/Core/ResourceSaver.inl b/include/Nazara/Core/ResourceSaver.inl index 85f95fd3a..a22c29d60 100644 --- a/include/Nazara/Core/ResourceSaver.inl +++ b/include/Nazara/Core/ResourceSaver.inl @@ -48,7 +48,7 @@ namespace Nz * \remark The previous file content will be discarded, to prevent this behavior you should use SaveToStream * \remark The file extension will be used as format for the saver ("image.png" => "png", to write a specified format to a user-specified extension you should use SaveToStream * - * \seealso SaveToStream + * \see SaveToStream */ template bool ResourceSaver::SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters) @@ -114,7 +114,7 @@ namespace Nz * \param format Data format to save the resource to * \param parameters Parameters for the saving * - * \seealso SaveToFile + * \see SaveToFile */ template bool ResourceSaver::SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters) diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 684b21387..405683f40 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -42,7 +42,7 @@ namespace Nz * * \param tilePos Position of the tile to disable * - * \seealso DisableTiles + * \see DisableTiles */ inline void TileMap::DisableTile(const Vector2ui& tilePos) { @@ -81,7 +81,7 @@ namespace Nz * * \remark if tileCount is zero, this is a no-op and the value of tilesPos is not used * - * \seealso DisableTile + * \see DisableTile */ inline void TileMap::DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount) { @@ -118,7 +118,7 @@ namespace Nz * \param color The multiplicative color applied to the tile * \param materialIndex The material which will be used for rendering this tile * - * \seealso EnableTiles + * \see EnableTiles */ inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color, std::size_t materialIndex) { @@ -161,7 +161,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTiles + * \see EnableTiles */ inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color, std::size_t materialIndex) { @@ -188,7 +188,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Rectf& coords, const Color& color, std::size_t materialIndex) { @@ -223,7 +223,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Rectui& rect, const Color& color, std::size_t materialIndex) { @@ -248,7 +248,7 @@ namespace Nz * \param color The multiplicative color applied to the tile * \param materialIndex The material which will be used for rendering this tile * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color, std::size_t materialIndex) { @@ -299,7 +299,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color, std::size_t materialIndex) { @@ -341,8 +341,8 @@ namespace Nz * \brief Gets the tilemap size (i.e. number of tiles in each dimension) * \return Number of tiles in each dimension * - * \seealso GetSize - * \seealso GetTileSize + * \see GetSize + * \see GetTileSize */ inline const Vector2ui& TileMap::GetMapSize() const { @@ -353,8 +353,8 @@ namespace Nz * \brief Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize()) * \return Maximum size in units occupied by this tilemap * - * \seealso GetMapSize - * \seealso GetTileSize + * \see GetMapSize + * \see GetTileSize */ inline Vector2f TileMap::GetSize() const { @@ -379,8 +379,8 @@ namespace Nz * \brief Gets the tile size (i.e. number of units occupied by a tile in each dimension) * \return Tile size in each dimension * - * \seealso GetMapSize - * \seealso GetSize + * \see GetMapSize + * \see GetSize */ inline const Vector2f& TileMap::GetTileSize() const { From ae0d085f993a5462bc7cb233a7890f8ed2ea83ed Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 Jul 2016 12:11:36 +0200 Subject: [PATCH 106/235] Add LICENSE file Former-commit-id: bdc62f3c4c93bce7f56bc2ab6829cfa2faa2c33b [formerly 1f6ca663392691d5c7399b3b70cf94b52ba392f9] Former-commit-id: 3c63841a7845b1921e34dff632b65e9014a1248c --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..aa1920df5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Jérôme Leclercq + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 32a58b2029dc86a85b4bade41bfb7124571c596f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 Jul 2016 21:00:39 +0200 Subject: [PATCH 107/235] Build/UnitTest: Fix linking against Network module Former-commit-id: 17370ab2dbe2f9f6b6c3ec84ba2c9d45de832ee0 [formerly a07cdfb9393322e9a145b171835a4270fcf2953d] Former-commit-id: c88597b66d47ecdcbc9a279b96fa840de859634b --- build/scripts/tools/unittests.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index fc0f4bad6..0d3dcc7d2 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -21,9 +21,10 @@ TOOL.Libraries = { "NazaraCore", "NazaraAudio", "NazaraLua", + "NazaraGraphics", + "NazaraRenderer", + "NazaraNetwork", "NazaraNoise", "NazaraPhysics", - "NazaraUtility", - "NazaraRenderer", - "NazaraGraphics" + "NazaraUtility" } From 84fdd6170233b136ab2911ec5440bcbe998d9bc1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 Jul 2016 21:07:20 +0200 Subject: [PATCH 108/235] Sdk/State: Make destructor virtual Former-commit-id: 1a2085fdfd415c7510dfb328a9bb76c3a396df06 [formerly d6f114767ebf264c4ea916aa08841a3973558834] Former-commit-id: adb5050379b9b2f1d795c1f0b7528f7b713c833e --- SDK/include/NDK/State.hpp | 2 +- SDK/src/NDK/State.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 SDK/src/NDK/State.cpp diff --git a/SDK/include/NDK/State.hpp b/SDK/include/NDK/State.hpp index 613a504ab..f60cd6c4d 100644 --- a/SDK/include/NDK/State.hpp +++ b/SDK/include/NDK/State.hpp @@ -17,7 +17,7 @@ namespace Ndk { public: State() = default; - ~State() = default; + virtual ~State(); virtual void Enter(StateMachine& fsm) = 0; virtual void Leave(StateMachine& fsm) = 0; diff --git a/SDK/src/NDK/State.cpp b/SDK/src/NDK/State.cpp new file mode 100644 index 000000000..e256a7f1c --- /dev/null +++ b/SDK/src/NDK/State.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2016 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 + +namespace Ndk +{ + State::~State() = default; +} From 34bce2d1fbd74e6826d14259b8113ef363acd69c Mon Sep 17 00:00:00 2001 From: Ardakaniz Date: Wed, 27 Jul 2016 20:33:42 +0200 Subject: [PATCH 109/235] Sdk/State: Fix State link error Former-commit-id: 1ceeaffc7a9d0eeaf240d7f57efe5ae1ca44c1c4 [formerly 0cd1c65c5c003e695601afa945c1b11c38e7ff62] Former-commit-id: 73ec87f686293677e90ae9aa4bcd4f17d9b2b97a --- SDK/include/NDK/State.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/State.hpp b/SDK/include/NDK/State.hpp index f60cd6c4d..621227fbe 100644 --- a/SDK/include/NDK/State.hpp +++ b/SDK/include/NDK/State.hpp @@ -13,7 +13,7 @@ namespace Ndk { class StateMachine; - class State + class NDK_API State { public: State() = default; From d4b4e3f5656a69b2a4fe725e87bd809472176099 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Thu, 28 Jul 2016 19:22:41 +0200 Subject: [PATCH 110/235] Various fixes Former-commit-id: b375cb70e49effc001fb781028bd8b7d07044941 [formerly cbdadfbabd56bed8ffadbf3cbd7175e95908452f] Former-commit-id: 224bc14061ba65eff9b9d779104c5df95e63e905 --- include/Nazara/Core/Algorithm.inl | 3 +- include/Nazara/Core/ByteArray.inl | 38 ++++++------- include/Nazara/Core/ObjectHandle.inl | 75 +++++++++++++------------- include/Nazara/Core/ObjectRef.inl | 74 ++++++++++++------------- include/Nazara/Core/String.inl | 15 +++--- include/Nazara/Graphics/Renderable.inl | 4 +- include/Nazara/Math/Algorithm.inl | 6 +-- include/Nazara/Math/BoundingVolume.hpp | 1 + include/Nazara/Math/Box.hpp | 1 + include/Nazara/Math/Box.inl | 2 +- include/Nazara/Math/EulerAngles.hpp | 1 + include/Nazara/Math/Frustum.hpp | 2 + include/Nazara/Math/Matrix4.inl | 8 +-- include/Nazara/Math/OrientedBox.hpp | 1 + include/Nazara/Math/OrientedBox.inl | 2 +- include/Nazara/Math/Plane.hpp | 2 + include/Nazara/Math/Ray.hpp | 1 + include/Nazara/Math/Rect.hpp | 1 + include/Nazara/Math/Rect.inl | 10 ++-- include/Nazara/Math/Sphere.hpp | 1 + include/Nazara/Math/Vector2.hpp | 1 + include/Nazara/Math/Vector3.hpp | 1 + include/Nazara/Math/Vector4.hpp | 1 + src/Nazara/Core/File.cpp | 6 +-- src/Nazara/Core/StringStream.cpp | 1 - src/Nazara/Utility/Image.cpp | 9 ++++ 26 files changed, 141 insertions(+), 126 deletions(-) diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 6997f8d1e..c77a5c3bb 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -78,7 +78,7 @@ namespace Nz * \param v Object to hash * * \remark a HashAppend specialization for type T is required - * + * * \see ComputeHash */ template @@ -124,6 +124,7 @@ namespace Nz template constexpr std::size_t CountOf(T(&name)[N]) noexcept { + NazaraUnused(name); return N; } diff --git a/include/Nazara/Core/ByteArray.inl b/include/Nazara/Core/ByteArray.inl index 1ff9bf185..068bee4b6 100644 --- a/include/Nazara/Core/ByteArray.inl +++ b/include/Nazara/Core/ByteArray.inl @@ -23,10 +23,10 @@ namespace Nz /*! * \brief Constructs a ByteArray object with a raw memory and a size * - * \param ptr Pointer to raw memory + * \param buffer Pointer to raw memory * \param n Size that can be accessed * - * \remark If preallocated space of ptr is less than the size, the behaviour is undefined + * \remark If preallocated space of buffer is less than the size, the behaviour is undefined */ inline ByteArray::ByteArray(const void* buffer, size_type n) : @@ -62,10 +62,10 @@ namespace Nz /*! * \brief Appends the content of raw memory * - * \param ptr Constant pointer to raw memory + * \param buffer Constant pointer to raw memory * \param n Size that can be read * - * \remark If preallocated space of ptr is less than the size, the behaviour is undefined + * \remark If preallocated space of buffer is less than the size, the behaviour is undefined * * \see Insert */ @@ -298,11 +298,11 @@ namespace Nz } /*! - * \brief Inserts n times the same value at the iterator position + * \brief Inserts n times the same byte at the iterator position * * \param pos Iterator to the position * \param n Number of repetitions - * \param value Value to repeat + * \param byte Value to repeat */ inline ByteArray::iterator ByteArray::Insert(const_iterator pos, size_type n, value_type byte) @@ -359,10 +359,10 @@ namespace Nz /*! * \brief Prepends the content of raw memory * - * \param ptr Constant pointer to raw memory + * \param buffer Constant pointer to raw memory * \param n Size that can be read * - * \remark If preallocated space of ptr is less than the size, the behaviour is undefined + * \remark If preallocated space of buffer is less than the size, the behaviour is undefined * * \see Insert */ @@ -682,8 +682,7 @@ namespace Nz * \brief Checks whether the first byte array is equal to the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator==(const ByteArray& rhs) const @@ -695,8 +694,7 @@ namespace Nz * \brief Checks whether the first byte array is equal to the second byte array * \return false if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator!=(const ByteArray& rhs) const @@ -708,8 +706,7 @@ namespace Nz * \brief Checks whether the first byte array is less than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator<(const ByteArray& rhs) const @@ -721,8 +718,7 @@ namespace Nz * \brief Checks whether the first byte array is less or equal than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator<=(const ByteArray& rhs) const @@ -731,11 +727,10 @@ namespace Nz } /*! - * \brief Checks whether the first byte array is greather than the second byte array + * \brief Checks whether the first byte array is greater than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator>(const ByteArray& rhs) const @@ -744,11 +739,10 @@ namespace Nz } /*! - * \brief Checks whether the first byte array is greather or equal than the second byte array + * \brief Checks whether the first byte array is greater or equal than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator>=(const ByteArray& rhs) const diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index ee6e26268..d5badc964 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -291,15 +291,16 @@ namespace Nz template std::ostream& operator<<(std::ostream& out, const ObjectHandle& handle) { - return handle.ToString(); + out << handle.ToString(); + return out; } /*! * \brief Checks whether the first object handle is equal to the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator==(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -311,8 +312,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return true if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator==(const T& lhs, const ObjectHandle& rhs) @@ -324,8 +325,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator==(const ObjectHandle& lhs, const T& rhs) @@ -337,8 +338,8 @@ namespace Nz * \brief Checks whether the first object handle is equal to the second object handle * \return false if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator!=(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -350,8 +351,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return false if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator!=(const T& lhs, const ObjectHandle& rhs) @@ -363,8 +364,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return false if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator!=(const ObjectHandle& lhs, const T& rhs) @@ -376,8 +377,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -389,8 +390,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<(const T& lhs, const ObjectHandle& rhs) @@ -402,8 +403,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<(const ObjectHandle& lhs, const T& rhs) @@ -415,8 +416,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<=(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -428,8 +429,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<=(const T& lhs, const ObjectHandle& rhs) @@ -441,8 +442,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<=(const ObjectHandle& lhs, const T& rhs) @@ -454,8 +455,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -467,8 +468,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>(const T& lhs, const ObjectHandle& rhs) @@ -480,8 +481,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>(const ObjectHandle& lhs, const T& rhs) @@ -493,8 +494,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>=(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -506,8 +507,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>=(const T& lhs, const ObjectHandle& rhs) @@ -519,8 +520,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>=(const ObjectHandle& lhs, const T& rhs) diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index 8dab06948..85baff8bf 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -184,7 +184,7 @@ namespace Nz { return m_object; } - + /*! * \brief Assigns the object into this * \return A reference to this @@ -251,8 +251,8 @@ namespace Nz * \brief Checks whether the first object handle is equal to the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator==(const ObjectRef& lhs, const ObjectRef& rhs) @@ -264,8 +264,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return true if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator==(const T& lhs, const ObjectRef& rhs) @@ -277,8 +277,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator==(const ObjectRef& lhs, const T& rhs) @@ -290,8 +290,8 @@ namespace Nz * \brief Checks whether the first object handle is equal to the second object handle * \return false if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator!=(const ObjectRef& lhs, const ObjectRef& rhs) @@ -303,8 +303,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return false if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator!=(const T& lhs, const ObjectRef& rhs) @@ -316,8 +316,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return false if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator!=(const ObjectRef& lhs, const T& rhs) @@ -329,8 +329,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<(const ObjectRef& lhs, const ObjectRef& rhs) @@ -342,8 +342,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<(const T& lhs, const ObjectRef& rhs) @@ -355,8 +355,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<(const ObjectRef& lhs, const T& rhs) @@ -368,8 +368,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<=(const ObjectRef& lhs, const ObjectRef& rhs) @@ -381,8 +381,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<=(const T& lhs, const ObjectRef& rhs) @@ -394,8 +394,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<=(const ObjectRef& lhs, const T& rhs) @@ -407,8 +407,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>(const ObjectRef& lhs, const ObjectRef& rhs) @@ -420,8 +420,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>(const T& lhs, const ObjectRef& rhs) @@ -433,8 +433,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>(const ObjectRef& lhs, const T& rhs) @@ -446,8 +446,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>=(const ObjectRef& lhs, const ObjectRef& rhs) @@ -459,8 +459,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>=(const T& lhs, const ObjectRef& rhs) @@ -472,8 +472,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>=(const ObjectRef& lhs, const T& rhs) diff --git a/include/Nazara/Core/String.inl b/include/Nazara/Core/String.inl index aa4343371..a5e099a3c 100644 --- a/include/Nazara/Core/String.inl +++ b/include/Nazara/Core/String.inl @@ -45,7 +45,7 @@ namespace Nz */ inline String::SharedString::SharedString(std::size_t strSize) : - capacity(strSize), + capacity(strSize), size(strSize), string(new char[strSize + 1]) { @@ -84,16 +84,15 @@ namespace Nz namespace std { - /*! - * \brief Specialisation of std to hash - * \return Result of the hash - * - * \param str String to hash - */ - template<> struct hash { + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param str String to hash + */ size_t operator()(const Nz::String& str) const { // Algorithme DJB2 diff --git a/include/Nazara/Graphics/Renderable.inl b/include/Nazara/Graphics/Renderable.inl index 9a69329a5..804567814 100644 --- a/include/Nazara/Graphics/Renderable.inl +++ b/include/Nazara/Graphics/Renderable.inl @@ -24,9 +24,7 @@ namespace Nz } /*! - * \brief Updates the bounding volume by a matrix - * - * \param transformMatrix Matrix transformation for our bounding volume + * \brief Updates the bounding volume */ inline void Renderable::UpdateBoundingVolume() const diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 524f0bd4c..2c865ad1b 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -105,7 +105,7 @@ namespace Nz * * \param value Initial value * \param objective Target value - * \parma increment One step value + * \param increment One step value */ template @@ -412,7 +412,7 @@ namespace Nz * \brief Gets the log in base 2 of integral number, only works for power of two ! * \return Log of the number * - * \param number To get log in base 2 + * \param pot To get log in base 2 * * \remark Only works for power of two * \remark If number is 0, 0 is returned @@ -431,7 +431,7 @@ namespace Nz * \return base^exponent for integral * * \param base Base of the exponentation - * \parma exponent Power for the base + * \param exponent Power for the base */ //TODO: Mark as constexpr when supported by all major compilers diff --git a/include/Nazara/Math/BoundingVolume.hpp b/include/Nazara/Math/BoundingVolume.hpp index 6f1f4b804..6c863b729 100644 --- a/include/Nazara/Math/BoundingVolume.hpp +++ b/include/Nazara/Math/BoundingVolume.hpp @@ -53,6 +53,7 @@ namespace Nz void Update(const Vector3& translation); BoundingVolume operator*(T scalar) const; + BoundingVolume& operator=(const BoundingVolume& other) = default; BoundingVolume& operator*=(T scalar); diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index a2a6f25d1..25e9a8069 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -79,6 +79,7 @@ namespace Nz Box operator*(T scalar) const; Box operator*(const Vector3& vec) const; + Box& operator=(const Box& other) = default; Box& operator*=(T scalar); Box& operator*=(const Vector3& vec); diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index a6200cbe4..71c98a70b 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -787,7 +787,7 @@ namespace Nz * \brief Multiplies the lengths with the scalar * \return A box where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar * - * \param scale The scalar to multiply width, height and depth with + * \param scalar The scalar to multiply width, height and depth with */ template diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index 6ada39982..ab267e81f 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -47,6 +47,7 @@ namespace Nz EulerAngles operator-(const EulerAngles& angles) const; /*EulerAngles operator*(const EulerAngles& angles) const; EulerAngles operator/(const EulerAngles& angles) const;*/ + EulerAngles& operator=(const EulerAngles& other) = default; EulerAngles& operator+=(const EulerAngles& angles); EulerAngles& operator-=(const EulerAngles& angles); diff --git a/include/Nazara/Math/Frustum.hpp b/include/Nazara/Math/Frustum.hpp index 2e51c0bd6..96c78004c 100644 --- a/include/Nazara/Math/Frustum.hpp +++ b/include/Nazara/Math/Frustum.hpp @@ -50,6 +50,8 @@ namespace Nz IntersectionSide Intersect(const Sphere& sphere) const; IntersectionSide Intersect(const Vector3* points, unsigned int pointCount) const; + Frustum& operator=(const Frustum& other) = default; + Frustum& Set(const Frustum& frustum); template Frustum& Set(const Frustum& frustum); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index b0decee2a..4cf2eaa6e 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -750,7 +750,7 @@ namespace Nz * \brief Inverts this matrix * \return A reference to this matrix inverted * - * \param bool Optional argument to know if matrix has been successfully inverted + * \param succeeded Optional argument to know if matrix has been successfully inverted * * \see InverseAffine */ @@ -769,7 +769,7 @@ namespace Nz * \brief Inverts this matrix * \return A reference to this matrix inverted * - * \param bool Optional argument to know if matrix has been successfully inverted + * \param succeeded Optional argument to know if matrix has been successfully inverted * * \see Inverse */ @@ -1487,7 +1487,7 @@ namespace Nz * \brief Compares the matrix to other one * \return true if the matrices are the same * - * \param matrix Other matrix to compare with + * \param mat Other matrix to compare with */ template @@ -1504,7 +1504,7 @@ namespace Nz * \brief Compares the matrix to other one * \return false if the matrices are the same * - * \param matrix Other matrix to compare with + * \param mat Other matrix to compare with */ template diff --git a/include/Nazara/Math/OrientedBox.hpp b/include/Nazara/Math/OrientedBox.hpp index 43d4b1aaf..2b806e56b 100644 --- a/include/Nazara/Math/OrientedBox.hpp +++ b/include/Nazara/Math/OrientedBox.hpp @@ -52,6 +52,7 @@ namespace Nz Vector3 operator()(unsigned int i) const; OrientedBox operator*(T scalar) const; + OrientedBox& operator=(const OrientedBox& other) = default; OrientedBox& operator*=(T scalar); diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index 9bcd94e1d..3320dce1a 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -340,7 +340,7 @@ namespace Nz * \brief Multiplies the lengths with the scalar * \return A OrientedBox where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar * - * \param scale The scalar to multiply width, height and depth with + * \param scalar The scalar to multiply width, height and depth with */ template diff --git a/include/Nazara/Math/Plane.hpp b/include/Nazara/Math/Plane.hpp index f37fc90c7..0eb201123 100644 --- a/include/Nazara/Math/Plane.hpp +++ b/include/Nazara/Math/Plane.hpp @@ -45,6 +45,8 @@ namespace Nz String ToString() const; + Plane& operator=(const Plane& other) = default; + bool operator==(const Plane& plane) const; bool operator!=(const Plane& plane) const; diff --git a/include/Nazara/Math/Ray.hpp b/include/Nazara/Math/Ray.hpp index b391ad866..7e8c0790a 100644 --- a/include/Nazara/Math/Ray.hpp +++ b/include/Nazara/Math/Ray.hpp @@ -61,6 +61,7 @@ namespace Nz String ToString() const; Vector3 operator*(T lambda) const; + Ray& operator=(const Ray& other) = default; bool operator==(const Ray& ray) const; bool operator!=(const Ray& ray) const; diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index 393d8d116..843ff6126 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -71,6 +71,7 @@ namespace Nz Rect operator*(const Vector2& vec) const; Rect operator/(T scalar) const; Rect operator/(const Vector2& vec) const; + Rect& operator=(const Rect& other) = default; Rect& operator*=(T scalar); Rect& operator*=(const Vector2& vec); diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index f53dd0c0f..21d0e7e93 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -629,7 +629,7 @@ namespace Nz * \brief Multiplies the lengths with the scalar * \return A rectangle where the position is the same and width and height are the product of the old width and height and the scalar * - * \param scale The scalar to multiply width and height with + * \param scalar The scalar to multiply width and height with */ template @@ -655,13 +655,13 @@ namespace Nz * \brief Divides the lengths with the scalar * \return A rectangle where the position is the same and width and height are the quotient of the old width and height and the scalar * - * \param scale The scalar to divide width and height with + * \param scalar The scalar to divide width and height with */ template Rect Rect::operator/(T scalar) const { - return Rect(x, y, width/scalar, height/scalar); + return Rect(x, y, width / scalar, height / scalar); } /*! @@ -745,7 +745,7 @@ namespace Nz * \brief Compares the rectangle to other one * \return true if the rectangles are the same * - * \param rec Other rectangle to compare with + * \param rect Other rectangle to compare with */ template @@ -759,7 +759,7 @@ namespace Nz * \brief Compares the rectangle to other one * \return false if the rectangles are the same * - * \param rec Other rectangle to compare with + * \param rect Other rectangle to compare with */ template diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index 929c1ec71..8f7ac9e14 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -67,6 +67,7 @@ namespace Nz T operator[](unsigned int i) const; Sphere operator*(T scalar) const; + Sphere& operator=(const Sphere& other) = default; Sphere& operator*=(T scalar); diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index b275d0544..e0ac1d68d 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -76,6 +76,7 @@ namespace Nz Vector2 operator*(T scale) const; Vector2 operator/(const Vector2& vec) const; Vector2 operator/(T scale) const; + Vector2& operator=(const Vector2& other) = default; Vector2& operator+=(const Vector2& vec); Vector2& operator-=(const Vector2& vec); diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 7743e7a35..4e6da14ec 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -87,6 +87,7 @@ namespace Nz Vector3 operator*(T scale) const; Vector3 operator/(const Vector3& vec) const; Vector3 operator/(T scale) const; + Vector3& operator=(const Vector3& vec) = default; Vector3& operator+=(const Vector3& vec); Vector3& operator-=(const Vector3& vec); diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index b84a4cb17..0f8e907fc 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -74,6 +74,7 @@ namespace Nz Vector4 operator*(T scale) const; Vector4 operator/(const Vector4& vec) const; Vector4 operator/(T scale) const; + Vector4& operator=(const Vector4& other) = default; Vector4& operator+=(const Vector4& vec); Vector4& operator-=(const Vector4& vec); diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 97504b0ee..131ceb7f3 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -385,7 +385,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param pos Position of the cursor @@ -404,7 +404,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param offset Offset according to the cursor begin position @@ -725,7 +725,7 @@ namespace Nz return true; else if (path.Match("\\\\*")) // Ex: \\Laptop return true; - else if (path.StartsWith('\\')) // Special : '\' refering to the root + else if (path.StartsWith('\\')) // Special : '\' referring to the root return true; else return false; diff --git a/src/Nazara/Core/StringStream.cpp b/src/Nazara/Core/StringStream.cpp index 14d35799d..0b27077e5 100644 --- a/src/Nazara/Core/StringStream.cpp +++ b/src/Nazara/Core/StringStream.cpp @@ -1,4 +1,3 @@ -#include "..\..\..\include\Nazara\Core\StringStream.hpp" // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 9e0213cf6..4b780eef1 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -1352,6 +1352,15 @@ namespace Nz void Image::Copy(UInt8* destination, const UInt8* source, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, unsigned int dstWidth, unsigned int dstHeight, unsigned int srcWidth, unsigned int srcHeight) { + #if NAZARA_UTILITY_SAFE + if (width == 0) + NazaraError("Width must be greater than zero"); + if (height == 0) + NazaraError("Height must be greater than zero"); + if (depth == 0) + NazaraError("Depth must be greater than zero"); + #endif + if (dstWidth == 0) dstWidth = width; From 44bec7f44b9fd74049cab0c4cc87c4244a2bbb13 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:24:19 +0200 Subject: [PATCH 111/235] Graphics: Rename ParticleSystem to ParticleGroup Preparing for integration into the ECS Former-commit-id: dbed63966f6c5e888a8b4f1c8f804c98d1c75458 [formerly cb6fa165276003b8d68932a95632025794557682] Former-commit-id: ebce6b98f3e2ef8c5fc8d598b6cdc9e96fd0becc --- include/Nazara/Graphics.hpp | 2 +- .../Nazara/Graphics/ParticleController.hpp | 4 +- include/Nazara/Graphics/ParticleEmitter.hpp | 4 +- include/Nazara/Graphics/ParticleGenerator.hpp | 4 +- .../{ParticleSystem.hpp => ParticleGroup.hpp} | 18 ++--- include/Nazara/Graphics/ParticleRenderer.hpp | 4 +- src/Nazara/Graphics/ParticleEmitter.cpp | 4 +- .../{ParticleSystem.cpp => ParticleGroup.cpp} | 66 +++++++++---------- .../{ParticleSystem.cpp => ParticleGroup.cpp} | 26 ++++---- 9 files changed, 66 insertions(+), 66 deletions(-) rename include/Nazara/Graphics/{ParticleSystem.hpp => ParticleGroup.hpp} (84%) rename src/Nazara/Graphics/{ParticleSystem.cpp => ParticleGroup.cpp} (83%) rename tests/Engine/Graphics/{ParticleSystem.cpp => ParticleGroup.cpp} (75%) diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 17b10e9a1..4809d9481 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -63,10 +63,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/include/Nazara/Graphics/ParticleController.hpp b/include/Nazara/Graphics/ParticleController.hpp index 17e4ac9e1..05537ba55 100644 --- a/include/Nazara/Graphics/ParticleController.hpp +++ b/include/Nazara/Graphics/ParticleController.hpp @@ -18,7 +18,7 @@ namespace Nz { class ParticleController; class ParticleMapper; - class ParticleSystem; + class ParticleGroup; using ParticleControllerConstRef = ObjectRef; using ParticleControllerLibrary = ObjectLibrary; @@ -34,7 +34,7 @@ namespace Nz ParticleController(const ParticleController& controller); virtual ~ParticleController(); - virtual void Apply(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0; + virtual void Apply(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0; // Signals: NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/); diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index d5e3c8ea8..b6acee156 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -14,7 +14,7 @@ namespace Nz { class ParticleMapper; - class ParticleSystem; + class ParticleGroup; class NAZARA_GRAPHICS_API ParticleEmitter : public Node { @@ -24,7 +24,7 @@ namespace Nz ParticleEmitter(ParticleEmitter&& emitter) = default; virtual ~ParticleEmitter(); - virtual void Emit(ParticleSystem& system, float elapsedTime) const; + virtual void Emit(ParticleGroup& system, float elapsedTime) const; void EnableLagCompensation(bool enable); diff --git a/include/Nazara/Graphics/ParticleGenerator.hpp b/include/Nazara/Graphics/ParticleGenerator.hpp index d9d2a789a..d072ae346 100644 --- a/include/Nazara/Graphics/ParticleGenerator.hpp +++ b/include/Nazara/Graphics/ParticleGenerator.hpp @@ -18,7 +18,7 @@ namespace Nz { class ParticleGenerator; class ParticleMapper; - class ParticleSystem; + class ParticleGroup; using ParticleGeneratorConstRef = ObjectRef; using ParticleGeneratorLibrary = ObjectLibrary; @@ -34,7 +34,7 @@ namespace Nz ParticleGenerator(const ParticleGenerator& generator); virtual ~ParticleGenerator(); - virtual void Generate(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0; + virtual void Generate(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0; // Signals: NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/); diff --git a/include/Nazara/Graphics/ParticleSystem.hpp b/include/Nazara/Graphics/ParticleGroup.hpp similarity index 84% rename from include/Nazara/Graphics/ParticleSystem.hpp rename to include/Nazara/Graphics/ParticleGroup.hpp index 76b834f6e..aaa65bb7f 100644 --- a/include/Nazara/Graphics/ParticleSystem.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_PARTICLESYSTEM_HPP -#define NAZARA_PARTICLESYSTEM_HPP +#ifndef NAZARA_PARTICLEGROUP_HPP +#define NAZARA_PARTICLEGROUP_HPP #include #include @@ -22,13 +22,13 @@ namespace Nz { - class NAZARA_GRAPHICS_API ParticleSystem : public Renderable + class NAZARA_GRAPHICS_API ParticleGroup : public Renderable { public: - ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout); - ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration); - ParticleSystem(const ParticleSystem& emitter); - ~ParticleSystem(); + ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout); + ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration); + ParticleGroup(const ParticleGroup& emitter); + ~ParticleGroup(); void AddController(ParticleControllerRef controller); void AddEmitter(ParticleEmitter* emitter); @@ -66,7 +66,7 @@ namespace Nz void Update(float elapsedTime); void UpdateBoundingVolume(const Matrix4f& transformMatrix) override; - ParticleSystem& operator=(const ParticleSystem& emitter); + ParticleGroup& operator=(const ParticleGroup& emitter); private: void MakeBoundingVolume() const override; @@ -89,4 +89,4 @@ namespace Nz }; } -#endif // NAZARA_PARTICLESYSTEM_HPP +#endif // NAZARA_PARTICLEGROUP_HPP diff --git a/include/Nazara/Graphics/ParticleRenderer.hpp b/include/Nazara/Graphics/ParticleRenderer.hpp index d79d448f2..2ddca18b3 100644 --- a/include/Nazara/Graphics/ParticleRenderer.hpp +++ b/include/Nazara/Graphics/ParticleRenderer.hpp @@ -19,7 +19,7 @@ namespace Nz class AbstractRenderQueue; class ParticleMapper; class ParticleRenderer; - class ParticleSystem; + class ParticleGroup; using ParticleRendererConstRef = ObjectRef; using ParticleRendererLibrary = ObjectLibrary; @@ -35,7 +35,7 @@ namespace Nz ParticleRenderer(const ParticleRenderer& renderer); virtual ~ParticleRenderer(); - virtual void Render(const ParticleSystem& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0; + virtual void Render(const ParticleGroup& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0; // Signals: NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/); diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index ded77d80e..b11cfdfe9 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleEmitter::Emit(ParticleSystem& system, float elapsedTime) const + void ParticleEmitter::Emit(ParticleGroup& system, float elapsedTime) const { if (m_emissionRate > 0.f) { diff --git a/src/Nazara/Graphics/ParticleSystem.cpp b/src/Nazara/Graphics/ParticleGroup.cpp similarity index 83% rename from src/Nazara/Graphics/ParticleSystem.cpp rename to src/Nazara/Graphics/ParticleGroup.cpp index 0783dd7fd..08fb03f39 100644 --- a/src/Nazara/Graphics/ParticleSystem.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -26,8 +26,8 @@ namespace Nz * \param layout Enumeration for the layout of data information for the particles */ - ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout) : - ParticleSystem(maxParticleCount, ParticleDeclaration::Get(layout)) + ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout) : + ParticleGroup(maxParticleCount, ParticleDeclaration::Get(layout)) { } @@ -38,7 +38,7 @@ namespace Nz * \param declaration Data information for the particles */ - ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : + ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : m_declaration(std::move(declaration)), m_processing(false), m_maxParticleCount(maxParticleCount), @@ -58,7 +58,7 @@ namespace Nz * \param system ParticleSystem to copy into this */ - ParticleSystem::ParticleSystem(const ParticleSystem& system) : + ParticleGroup::ParticleGroup(const ParticleGroup& system) : Renderable(system), m_controllers(system.m_controllers), m_generators(system.m_generators), @@ -77,7 +77,7 @@ namespace Nz std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); } - ParticleSystem::~ParticleSystem() = default; + ParticleGroup::~ParticleGroup() = default; /*! * \brief Adds a controller to the particles @@ -87,7 +87,7 @@ namespace Nz * \remark Produces a NazaraAssert if controller is invalid */ - void ParticleSystem::AddController(ParticleControllerRef controller) + void ParticleGroup::AddController(ParticleControllerRef controller) { NazaraAssert(controller, "Invalid particle controller"); @@ -102,7 +102,7 @@ namespace Nz * \remark Produces a NazaraAssert if emitter is invalid */ - void ParticleSystem::AddEmitter(ParticleEmitter* emitter) + void ParticleGroup::AddEmitter(ParticleEmitter* emitter) { NazaraAssert(emitter, "Invalid particle emitter"); @@ -117,7 +117,7 @@ namespace Nz * \remark Produces a NazaraAssert if generator is invalid */ - void ParticleSystem::AddGenerator(ParticleGeneratorRef generator) + void ParticleGroup::AddGenerator(ParticleGeneratorRef generator) { NazaraAssert(generator, "Invalid particle generator"); @@ -134,7 +134,7 @@ namespace Nz * \remark Produces a NazaraAssert if renderQueue is invalid */ - void ParticleSystem::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const + void ParticleGroup::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const { NazaraAssert(m_renderer, "Invalid particle renderer"); NazaraAssert(renderQueue, "Invalid renderqueue"); @@ -155,7 +155,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleSystem::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) + void ParticleGroup::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) { m_processing = true; @@ -190,7 +190,7 @@ namespace Nz * \return Pointer to the particle memory buffer */ - void* ParticleSystem::CreateParticle() + void* ParticleGroup::CreateParticle() { return CreateParticles(1); } @@ -200,7 +200,7 @@ namespace Nz * \return Pointer to the first particle memory buffer */ - void* ParticleSystem::CreateParticles(unsigned int count) + void* ParticleGroup::CreateParticles(unsigned int count) { if (count == 0) return nullptr; @@ -219,7 +219,7 @@ namespace Nz * \return Pointer to the particle memory buffer */ - void* ParticleSystem::GenerateParticle() + void* ParticleGroup::GenerateParticle() { return GenerateParticles(1); } @@ -229,7 +229,7 @@ namespace Nz * \return Pointer to the first particle memory buffer */ - void* ParticleSystem::GenerateParticles(unsigned int count) + void* ParticleGroup::GenerateParticles(unsigned int count) { void* ptr = CreateParticles(count); if (!ptr) @@ -247,7 +247,7 @@ namespace Nz * \return Particle declaration */ - const ParticleDeclarationConstRef& ParticleSystem::GetDeclaration() const + const ParticleDeclarationConstRef& ParticleGroup::GetDeclaration() const { return m_declaration; } @@ -257,7 +257,7 @@ namespace Nz * \return Current fixed step size */ - float ParticleSystem::GetFixedStepSize() const + float ParticleGroup::GetFixedStepSize() const { return m_stepSize; } @@ -267,7 +267,7 @@ namespace Nz * \return Current maximum number */ - unsigned int ParticleSystem::GetMaxParticleCount() const + unsigned int ParticleGroup::GetMaxParticleCount() const { return m_maxParticleCount; } @@ -277,7 +277,7 @@ namespace Nz * \return Current number */ - unsigned int ParticleSystem::GetParticleCount() const + unsigned int ParticleGroup::GetParticleCount() const { return m_particleCount; } @@ -287,7 +287,7 @@ namespace Nz * \return Current size */ - unsigned int ParticleSystem::GetParticleSize() const + unsigned int ParticleGroup::GetParticleSize() const { return m_particleSize; } @@ -297,7 +297,7 @@ namespace Nz * \return true If it is the case */ - bool ParticleSystem::IsFixedStepEnabled() const + bool ParticleGroup::IsFixedStepEnabled() const { return m_fixedStepEnabled; } @@ -308,7 +308,7 @@ namespace Nz * \param index Index of the particle */ - void ParticleSystem::KillParticle(unsigned int index) + void ParticleGroup::KillParticle(unsigned int index) { ///FIXME: Verify the index @@ -328,7 +328,7 @@ namespace Nz * \brief Kills every particles */ - void ParticleSystem::KillParticles() + void ParticleGroup::KillParticles() { m_particleCount = 0; } @@ -339,7 +339,7 @@ namespace Nz * \param controller Controller for the particles to remove */ - void ParticleSystem::RemoveController(ParticleController* controller) + void ParticleGroup::RemoveController(ParticleController* controller) { auto it = std::find(m_controllers.begin(), m_controllers.end(), controller); if (it != m_controllers.end()) @@ -352,7 +352,7 @@ namespace Nz * \param emitter Emitter for the particles to remove */ - void ParticleSystem::RemoveEmitter(ParticleEmitter* emitter) + void ParticleGroup::RemoveEmitter(ParticleEmitter* emitter) { auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter); if (it != m_emitters.end()) @@ -365,7 +365,7 @@ namespace Nz * \param generator Generator for the particles to remove */ - void ParticleSystem::RemoveGenerator(ParticleGenerator* generator) + void ParticleGroup::RemoveGenerator(ParticleGenerator* generator) { auto it = std::find(m_generators.begin(), m_generators.end(), generator); if (it != m_generators.end()) @@ -378,7 +378,7 @@ namespace Nz * \param stepSize Fixed step size */ - void ParticleSystem::SetFixedStepSize(float stepSize) + void ParticleGroup::SetFixedStepSize(float stepSize) { m_stepSize = stepSize; } @@ -389,7 +389,7 @@ namespace Nz * \param renderer Renderer for the particles */ - void ParticleSystem::SetRenderer(ParticleRenderer* renderer) + void ParticleGroup::SetRenderer(ParticleRenderer* renderer) { m_renderer = renderer; } @@ -400,7 +400,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleSystem::Update(float elapsedTime) + void ParticleGroup::Update(float elapsedTime) { // Emission for (ParticleEmitter* emitter : m_emitters) @@ -421,7 +421,7 @@ namespace Nz * \param transformMatrix Matrix transformation for our bounding volume */ - void ParticleSystem::UpdateBoundingVolume(const Matrix4f& transformMatrix) + void ParticleGroup::UpdateBoundingVolume(const Matrix4f& transformMatrix) { NazaraUnused(transformMatrix); @@ -435,7 +435,7 @@ namespace Nz * \param system The other ParticleSystem */ - ParticleSystem& ParticleSystem::operator=(const ParticleSystem& system) + ParticleGroup& ParticleGroup::operator=(const ParticleGroup& system) { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -468,7 +468,7 @@ namespace Nz * \brief Makes the bounding volume of this text */ - void ParticleSystem::MakeBoundingVolume() const + void ParticleGroup::MakeBoundingVolume() const { ///TODO: Compute the AABB (taking into account the size of particles) m_boundingVolume.MakeInfinite(); @@ -480,7 +480,7 @@ namespace Nz * \remark Produces a NazaraError if resize did not work */ - void ParticleSystem::ResizeBuffer() + void ParticleGroup::ResizeBuffer() { // Just to have a better description of our problem in case of error try diff --git a/tests/Engine/Graphics/ParticleSystem.cpp b/tests/Engine/Graphics/ParticleGroup.cpp similarity index 75% rename from tests/Engine/Graphics/ParticleSystem.cpp rename to tests/Engine/Graphics/ParticleGroup.cpp index 32f5f01f9..36ad2cb0b 100644 --- a/tests/Engine/Graphics/ParticleSystem.cpp +++ b/tests/Engine/Graphics/ParticleGroup.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,7 +8,7 @@ class TestParticleController : public Nz::ParticleController { public: // Be aware that the interval is [startId, endId] and NOT [startId, endId) - void Apply(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override + void Apply(Nz::ParticleGroup& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override { Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); @@ -32,7 +32,7 @@ class TestParticleEmitter : public Nz::ParticleEmitter public: ~TestParticleEmitter() override = default; - void Emit(Nz::ParticleSystem& system, float elapsedTime) const override + void Emit(Nz::ParticleGroup& system, float elapsedTime) const override { system.GenerateParticles(GetEmissionCount()); } @@ -49,7 +49,7 @@ class TestParticleGenerator : public Nz::ParticleGenerator ~TestParticleGenerator() override = default; // Be aware that the interval is [startId, endId] and NOT [startId, endId) - void Generate(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override + void Generate(Nz::ParticleGroup& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override { Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); @@ -68,35 +68,35 @@ class TestParticleGenerator : public Nz::ParticleGenerator } }; -SCENARIO("ParticleSystem", "[GRAPHICS][PARTICLESYSTEM]") +SCENARIO("ParticleGroup", "[GRAPHICS][PARTICLEGROUP]") { GIVEN("A particle system of maximum 10 billboards with its generators") { // These need to be alive longer than the particle system TestParticleController particleController; TestParticleGenerator particleGenerator; - Nz::ParticleSystem particleSystem(10, Nz::ParticleLayout_Billboard); + Nz::ParticleGroup particleGroup(10, Nz::ParticleLayout_Billboard); - particleSystem.AddController(&particleController); + particleGroup.AddController(&particleController); TestParticleEmitter particleEmitter; particleEmitter.SetEmissionCount(10); - particleSystem.AddEmitter(&particleEmitter); + particleGroup.AddEmitter(&particleEmitter); - particleSystem.AddGenerator(&particleGenerator); + particleGroup.AddGenerator(&particleGenerator); WHEN("We update to generate 10 particles") { - particleSystem.Update(1.f); + particleGroup.Update(1.f); THEN("There must be 10 particles") { - REQUIRE(particleSystem.GetParticleCount() == 10); + REQUIRE(particleGroup.GetParticleCount() == 10); } AND_THEN("We update to make them die") { - particleSystem.Update(2.f); - REQUIRE(particleSystem.GetParticleCount() == 0); + particleGroup.Update(2.f); + REQUIRE(particleGroup.GetParticleCount() == 0); } } } From df828cd0df91ead0ce1ef4f8e00830f32d560880 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:37:44 +0200 Subject: [PATCH 112/235] Utility/OBJParser: Abort parsing when there's more than one error per two line Former-commit-id: 5b4cad994aa57293e8099c006619d3fb0c7429b1 [formerly 79c2ce8fe15176f91d2078866798ddd6f78ce044] Former-commit-id: 12e75819f8d65b980199a803f0f8138061ea644d --- include/Nazara/Utility/Formats/OBJParser.hpp | 3 +- include/Nazara/Utility/Formats/OBJParser.inl | 12 ++++- src/Nazara/Utility/Formats/OBJParser.cpp | 53 ++++++++++++-------- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 50fa58900..114f72635 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -86,7 +86,7 @@ namespace Nz inline void Error(const String& message); inline void Flush() const; inline void Warning(const String& message); - inline void UnrecognizedLine(bool error = false); + inline bool UnrecognizedLine(bool error = false); std::vector m_meshes; std::vector m_materials; @@ -99,6 +99,7 @@ namespace Nz mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; + unsigned int m_errorCount; }; } diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 9d961d54f..054d57754 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -168,7 +168,7 @@ namespace Nz NazaraWarning(message + " at line #" + String::Number(m_lineCount)); } - inline void OBJParser::UnrecognizedLine(bool error) + inline bool OBJParser::UnrecognizedLine(bool error) { String message = "Unrecognized \"" + m_currentLine + '"'; @@ -176,6 +176,16 @@ namespace Nz Error(message); else Warning(message); + + m_errorCount++; + + if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50) + { + NazaraError("Aborting parsing because of error percentage"); + return false; //< Abort parsing if error percentage is too high + } + + return true; } } diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index bd189305f..7d3019c39 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -97,7 +97,8 @@ namespace Nz if (m_currentLine.GetSize() < 7) // Since we only treat triangles, this is the minimum length of a face line (f 1 2 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -106,7 +107,8 @@ namespace Nz if (vertexCount < 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -138,7 +140,8 @@ namespace Nz if (std::sscanf(&m_currentLine[pos], "%d%n", &p, &offset) != 1) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif error = true; break; @@ -217,7 +220,8 @@ namespace Nz case 'm': //< MTLLib #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0).ToLower() != "mtllib") - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif m_mtlLib = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); @@ -229,7 +233,8 @@ namespace Nz if (m_currentLine.GetSize() <= 2 || m_currentLine[1] != ' ') { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -238,7 +243,8 @@ namespace Nz if (objectName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -254,17 +260,20 @@ namespace Nz { String param = m_currentLine.SubString(2); if (param != "all" && param != "on" && param != "off" && !param.IsNumber()) - UnrecognizedLine(); + { + if (!UnrecognizedLine()) + return false; + } } - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + return false; break; #endif case 'u': //< Usemtl #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - if (m_currentLine.GetWord(0) != "usemtl") - UnrecognizedLine(); + if (m_currentLine.GetWord(0) != "usemtl" && !UnrecognizedLine()) + return false; #endif matName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); @@ -272,7 +281,8 @@ namespace Nz if (matName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -288,8 +298,8 @@ namespace Nz if (paramCount >= 1) m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif } else if (word == "vn") @@ -299,8 +309,8 @@ namespace Nz if (paramCount == 3) m_normals.push_back(normal); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif } else if (word == "vt") @@ -310,13 +320,13 @@ namespace Nz if (paramCount >= 2) m_texCoords.push_back(uvw); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif break; @@ -324,7 +334,8 @@ namespace Nz default: #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } From e7d2cd9842038049ad80dca7e3784e891123d81a Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:38:00 +0200 Subject: [PATCH 113/235] UnitTests: Fix blocking case Former-commit-id: 9bb17734f853246eadfdd547bbfdc8c54638cf0d [formerly ca377bfec10cb158b91d050af6a1f59835d04cce] Former-commit-id: 27d29d41082f8f796518c36d063e7b3afd6768e1 --- tests/Engine/Graphics/Model.cpp | 5 ++++- tests/Engine/Network/TCP.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Engine/Graphics/Model.cpp b/tests/Engine/Graphics/Model.cpp index d67a261bb..b363a0be2 100644 --- a/tests/Engine/Graphics/Model.cpp +++ b/tests/Engine/Graphics/Model.cpp @@ -9,8 +9,11 @@ SCENARIO("Model", "[GRAPHICS][MODEL]") { THEN("These results are expected") { + Nz::ModelParameters params; + params.mesh.optimizeIndexBuffers = false; + Nz::ModelRef model = Nz::Model::New(); - REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj")); + REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj", params)); REQUIRE(model->GetMaterialCount() == 2); REQUIRE(model->GetSkin() == 0); diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp index 63b4fe2df..a613cf0c6 100644 --- a/tests/Engine/Network/TCP.cpp +++ b/tests/Engine/Network/TCP.cpp @@ -18,6 +18,8 @@ SCENARIO("TCP", "[NETWORK][TCP]") Nz::UInt16 port = dis(gen); Nz::TcpServer server; + server.EnableBlocking(false); + REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound); Nz::IpAddress serverIP = server.GetBoundAddress(); REQUIRE(serverIP.IsValid()); From be37c628910b3099647ebb58b2d0409d0c5c0651 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:55:59 +0200 Subject: [PATCH 114/235] Graphics/ParticleGroup: Remove fixed step parameter (wasn't used) Former-commit-id: d509e708c3619525b215f88099fd5e77ced7ad10 [formerly 07829fd18d35427e2c912a11358333a5e77bf4c1] Former-commit-id: 6a2e95c4f310c4d5a48ae78757e557613cb4eb2e --- include/Nazara/Graphics/ParticleGroup.hpp | 9 ------ src/Nazara/Graphics/ParticleGroup.cpp | 38 ++--------------------- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index aaa65bb7f..412b94511 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -40,19 +40,14 @@ namespace Nz void* CreateParticle(); void* CreateParticles(unsigned int count); - void EnableFixedStep(bool fixedStep); - void* GenerateParticle(); void* GenerateParticles(unsigned int count); const ParticleDeclarationConstRef& GetDeclaration() const; - float GetFixedStepSize() const; unsigned int GetMaxParticleCount() const; unsigned int GetParticleCount() const; unsigned int GetParticleSize() const; - bool IsFixedStepEnabled() const; - void KillParticle(unsigned int index); void KillParticles(); @@ -60,7 +55,6 @@ namespace Nz void RemoveEmitter(ParticleEmitter* emitter); void RemoveGenerator(ParticleGenerator* generator); - void SetFixedStepSize(float stepSize); void SetRenderer(ParticleRenderer* renderer); void Update(float elapsedTime); @@ -79,10 +73,7 @@ namespace Nz std::vector m_generators; ParticleDeclarationConstRef m_declaration; ParticleRendererRef m_renderer; - bool m_fixedStepEnabled; bool m_processing; - float m_stepAccumulator; - float m_stepSize; unsigned int m_maxParticleCount; unsigned int m_particleCount; unsigned int m_particleSize; diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index 08fb03f39..d93c085db 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -154,7 +154,6 @@ namespace Nz * \param particleCount Number of particles * \param elapsedTime Delta time between the previous frame */ - void ParticleGroup::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) { m_processing = true; @@ -174,8 +173,8 @@ namespace Nz if (m_dyingParticles.size() < m_particleCount) { // We kill them in reverse order, std::set sorting them via std::greater - // The reason is simple, as the death of a particle means the move of the last particle in the buffer, - // without this solution, certain particles could avoid the death + // The reason is simple, as the death of a particle means moving the last particle in the buffer, + // without this solution, certain particles could avoid death for (unsigned int index : m_dyingParticles) KillParticle(index); } @@ -252,16 +251,6 @@ namespace Nz return m_declaration; } - /*! - * \brief Gets the fixed step size - * \return Current fixed step size - */ - - float ParticleGroup::GetFixedStepSize() const - { - return m_stepSize; - } - /*! * \brief Gets the maximum number of particles * \return Current maximum number @@ -292,16 +281,6 @@ namespace Nz return m_particleSize; } - /*! - * \brief Checks whether the fixed step is enabled - * \return true If it is the case - */ - - bool ParticleGroup::IsFixedStepEnabled() const - { - return m_fixedStepEnabled; - } - /*! * \brief Kills one particle * @@ -372,17 +351,6 @@ namespace Nz m_generators.erase(it); } - /*! - * \brief Sets the fixed step size - * - * \param stepSize Fixed step size - */ - - void ParticleGroup::SetFixedStepSize(float stepSize) - { - m_stepSize = stepSize; - } - /*! * \brief Sets the renderer of the particles * @@ -448,12 +416,10 @@ namespace Nz m_particleCount = system.m_particleCount; m_particleSize = system.m_particleSize; m_renderer = system.m_renderer; - m_stepSize = system.m_stepSize; // The copy can not (or should not) happen during the update, there is no use to copy m_dyingParticles.clear(); m_processing = false; - m_stepAccumulator = 0.f; m_buffer.clear(); // To avoid a copy due to resize() which will be pointless ResizeBuffer(); From ed7aa0e07a516f4a2b309ffbf92b8800e6ec5193 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 18:49:16 +0200 Subject: [PATCH 115/235] SDK/ListenerComponent: Fix warnings Former-commit-id: 0ce5a9a2fb8ed2c7f03ae6d283811cf7868a9f78 [formerly 6014927c58523edb88b22f43d3019b3fd66d2888] Former-commit-id: d0332173c8906c7a58102b62d5c6a0f04435fbd6 --- SDK/include/NDK/Components/ListenerComponent.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Components/ListenerComponent.hpp b/SDK/include/NDK/Components/ListenerComponent.hpp index 3d472bed3..a2b9d59d2 100644 --- a/SDK/include/NDK/Components/ListenerComponent.hpp +++ b/SDK/include/NDK/Components/ListenerComponent.hpp @@ -15,11 +15,11 @@ namespace Ndk class NDK_API ListenerComponent : public Component { public: - ListenerComponent(); + inline ListenerComponent(); ~ListenerComponent() = default; - bool IsActive() const; - void SetActive(bool active = true); + inline bool IsActive() const; + inline void SetActive(bool active = true); static ComponentIndex componentIndex; From bd5d29bfdaf27f3c92f7066d4d4f160a2351e3df Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 23:47:09 +0200 Subject: [PATCH 116/235] Build: Add a separate config file and library/binary search paths support Former-commit-id: c5b7ea15c0bd997ad50635f4490351fd6ca7f13c [formerly 2ba3f77346f260ec75a3e3e981511cbe62cc88a8] Former-commit-id: d439e3c333c1ce1a1c215b42af51258532258199 --- build/config.lua | 17 ++ build/scripts/common.lua | 500 ++++++++++++++++++++++----------------- 2 files changed, 304 insertions(+), 213 deletions(-) create mode 100644 build/config.lua diff --git a/build/config.lua b/build/config.lua new file mode 100644 index 000000000..8370331c7 --- /dev/null +++ b/build/config.lua @@ -0,0 +1,17 @@ +-- This file contains special configurations values, such as directories to extern libraries (Qt) +-- Editing this file is not required to use/compile the engine, as default values should be enough + +-- Builds Nazara extern libraries (such as lua/STB) +BuildDependencies = true + +-- Builds Nazara examples +BuildExamples = true + +-- Setup additionnals install directories, separated by a semi-colon ; (library binaries will be copied there) +--InstallDir = "/usr/local/lib64" + +-- Excludes client-only modules/tools/examples +ServerMode = false + +-- Builds modules as one united library (useless on POSIX systems) +UniteModules = false diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 2b4906569..66345ef7e 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -24,7 +24,7 @@ function NazaraBuild:Execute() if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" - if (_OPTIONS["with-extlibs"]) then + if (self.Config["BuildDependencies"]) then workspace("NazaraExtlibs") platforms(platformData) @@ -39,12 +39,6 @@ function NazaraBuild:Execute() location(_ACTION) kind("StaticLib") - configuration("x32") - libdirs("../extlibs/lib/common/x86") - - configuration("x64") - libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") targetdir("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -111,6 +105,12 @@ function NazaraBuild:Execute() includedirs(libTable.Includes) links(libTable.Libraries) + configuration("x32") + libdirs(libTable.LibraryPaths.x86) + + configuration("x64") + libdirs(libTable.LibraryPaths.x64) + for k,v in pairs(libTable.ConfigurationLibraries) do configuration(k) links(v) @@ -188,11 +188,11 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/common") configuration("x32") - libdirs("../extlibs/lib/common/x86") + libdirs(moduleTable.LibraryPaths.x86) configuration("x64") defines("NAZARA_PLATFORM_x64") - libdirs("../extlibs/lib/common/x64") + libdirs(moduleTable.LibraryPaths.x64) configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -297,11 +297,11 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/common") configuration("x32") - libdirs("../extlibs/lib/common/x86") + libdirs(toolTable.LibraryPaths.x86) configuration("x64") defines("NAZARA_PLATFORM_x64") - libdirs("../extlibs/lib/common/x64") + libdirs(toolTable.LibraryPaths.x64) configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -431,11 +431,11 @@ function NazaraBuild:Execute() links(exampleTable.Libraries) configuration("x32") - libdirs("../extlibs/lib/common/x86") + libdirs(exampleTable.LibraryPaths.x86) configuration("x64") defines("NAZARA_PLATFORM_x64") - libdirs("../extlibs/lib/common/x64") + libdirs(exampleTable.LibraryPaths.x64) configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../lib/" .. makeLibDir .. "/x86") @@ -465,33 +465,29 @@ function NazaraBuild:Execute() end end +function NazaraBuild:GetConfig() + return self.Config +end + +function NazaraBuild:GetDependency(infoTable, name) + local projectName = name:match("Nazara(%w+)") + if (projectName) then + -- tool or module + local moduleTable = self.Modules[projectName:lower()] + if (moduleTable) then + return moduleTable + else + local toolTable = self.Tools[projectName:lower()] + if (toolTable) then + return toolTable + end + end + else + return self.ExtLibs[name:lower()] + end +end + function NazaraBuild:Initialize() - -- Commençons par les options - newoption({ - trigger = "install-path", - description = "Setup additionnals install directories (library binaries will be copied there)" - }) - - newoption({ - trigger = "server", - description = "Excludes client-only modules/tools/examples" - }) - - newoption({ - trigger = "united", - description = "Builds all the modules as one united library" - }) - - newoption({ - trigger = "with-extlibs", - description = "Builds the extern libraries" - }) - - newoption({ - trigger = "with-examples", - description = "Builds the examples" - }) - self.Actions = {} self.Examples = {} self.ExecutableDir = {} @@ -500,12 +496,8 @@ function NazaraBuild:Initialize() self.Modules = {} self.Tools = {} - if (_OPTIONS["install-path"]) then - local paths = string.explode(_OPTIONS["install-path"], ";") - for k,v in pairs(paths) do - self:AddInstallPath(v) - end - end + self.Config = {} + self:LoadConfig() -- Actions modules = os.matchfiles("scripts/actions/*.lua") @@ -593,7 +585,7 @@ function NazaraBuild:Initialize() TOOL = nil -- Examples - if (_OPTIONS["with-examples"]) then + if (self.Config["BuildExamples"]) then local examples = os.matchdirs("../examples/*") for k,v in pairs(examples) do local dirName = v:match(".*/(.*)") @@ -643,6 +635,236 @@ function NazaraBuild:Initialize() end end +function NazaraBuild:LoadConfig() + local f = io.open("config.lua", "r") + if (not f) then + print("Failed to open config.lua") + return + end + + local content = f:read("*a") + f:close() + + local func, err = loadstring(content) + if (not func) then + print("Failed to parse config.lua: " .. err) + return + end + + setfenv(func, self.Config) + + local status, err = pcall(func) + if (not status) then + print("Failed to load config.lua: " .. err) + return + end + + local configTable = self.Config + local AddBoolOption = function (option, name, description) + newoption({ + trigger = name, + description = description + }) + + local str = _OPTIONS[name] + if (str) then + if (#str == 0 or str == "1" or str == "yes" or str == "true") then + configTable[option] = true + elseif (str == "0" or str == "no" or str == "false") then + configTable[option] = false + else + error("Invalid entry for " .. name .. " option: \"" .. str .. "\"") + end + end + end + + AddBoolOption("BuildDependencies", "with-extlibs", "Builds the extern libraries") + AddBoolOption("BuildExamples", "with-examples", "Builds the examples") + AddBoolOption("ServerMode", "server", "Excludes client-only modules/tools/examples") + AddBoolOption("UniteModules", "united", "Builds all the modules as one united library") + + -- InstallDir + newoption({ + trigger = "install-path", + description = "Setup additionnals install directories (library binaries will be copied there)" + }) + + self.Config["InstallDir"] = self.Config["InstallDir"] or "" + if (_OPTIONS["install-path"] ~= nil) then + self.Config["InstallDir"] = self.Config["InstallDir"] .. ";" .. _OPTIONS["install-path"] + end + + local paths = string.explode(self.Config["InstallDir"], ";") + for k,v in pairs(paths) do + self:AddInstallPath(v) + end +end + +function NazaraBuild:MakeInstallCommands(infoTable) + if (PremakeVersion < 50) then + return + end + + if (os.is("windows")) then + configuration({}) + + for k,v in pairs(self.InstallDir) do + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]}) + end + + for k,fileName in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do + local paths = {} + for k,v in pairs(infoTable.BinaryPaths.x86) do + table.insert(paths, {"x32", v .. "/" .. fileName .. ".dll"}) + table.insert(paths, {"x32", v .. "/lib" .. fileName .. ".dll"}) + end + + for k,v in pairs(infoTable.BinaryPaths.x64) do + table.insert(paths, {"x64", v .. "/" .. fileName .. ".dll"}) + table.insert(paths, {"x64", v .. "/lib" .. fileName .. ".dll"}) + end + + for k,v in pairs(paths) do + local config = v[1] + local srcPath = v[2] + if (os.isfile(srcPath)) then + if (infoTable.Kind == "plugin") then + srcPath = "../../" .. srcPath + end + + configuration(config) + + for k,v in pairs(self.ExecutableDir) do + local srcPath = path.isabsolute(srcPath) and path.translate(srcPath) or [[%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}]] + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "]] .. srcPath .. [[" "]] .. destPath .. [[\" /E /Y]]}) + end + end + end + end + end +end + +local PosixOSes = { + ["bsd"] = true, + ["linux"] = true, + ["macosx"] = true, + ["solaris"] = true +} + +function NazaraBuild:Process(infoTable) + local libraries = {} + for k, library in pairs(infoTable.Libraries) do + local libraryTable = self:GetDependency(infoTable, library) + if (libraryTable) then + if (libraryTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. library .. " " .. libraryTable.Type:lower() + return false + end + + if (libraryTable.Type == "Module") then + if (_OPTIONS["united"]) then + library = "NazaraEngine" + else + library = "Nazara" .. libraryTable.Name + end + + if (not self.Config["UniteModules"] or infoTable.Type ~= "Module") then + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) + end + elseif (libraryTable.Type == "ExternLib") then + library = libraryTable.Name + + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") + elseif (libraryTable.Type == "Tool") then + library = "Nazara" .. libraryTable.Name + + -- Import tools includes + for k,v in ipairs(libraryTable.Includes) do + table.insert(infoTable.Includes, v) + end + + -- And libraries + for k, v in pairs(libraryTable.Libraries) do + table.insert(infoTable.Libraries, v) + end + + for config, libs in pairs(libraryTable.ConfigurationLibraries) do + for k,v in pairs(libs) do + table.insert(infoTable.ConfigurationLibraries[config], v) + end + end + + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) + else + infoTable.Excluded = true + infoTable.ExcludeReason = "dependency " .. library .. " has invalid type \"" .. libraryTable.Type .. "\"" + return false + end + else + table.insert(libraries, library) + end + end + infoTable.Libraries = libraries + + for k,v in pairs(infoTable) do + local target = k:match("Os(%w+)") + if (target) then + local targetTable = infoTable[target] + if (targetTable) then + local excludeTargetTable = infoTable[target .. "Excluded"] + for platform, defineTable in pairs(v) do + platform = string.lower(platform) + if (platform == "posix") then + local osname = os.get() + if (PosixOSes[osname]) then + platform = osname + end + end + + if (os.is(platform)) then + for k,v in ipairs(defineTable) do + table.insert(targetTable, v) + end + elseif (excludeTargetTable) then + for k,v in ipairs(defineTable) do + table.insert(excludeTargetTable, v) + end + end + end + + infoTable[k] = nil + end + end + end + + if (infoTable.Kind == "application") then + self:AddExecutablePath(infoTable.TargetDirectory) + end + + if (infoTable.Validate) then + local ret, err = infoTable:Validate() + if (not ret) then + infoTable.Excluded = true + infoTable.ExcludeReason = "validation failed: " .. err + return false + end + end + + return true +end + function NazaraBuild:RegisterAction(actionTable) if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then return false, "Invalid action name" @@ -750,7 +972,7 @@ function NazaraBuild:RegisterModule(moduleTable) table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl") table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp") - if (_OPTIONS["united"] and lowerCaseName ~= "core") then + if (self.Config["UniteModules"] and lowerCaseName ~= "core") then table.insert(moduleTable.FilesExcluded, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp") end @@ -789,132 +1011,8 @@ function NazaraBuild:RegisterTool(toolTable) return true end -local PosixOSes = { - ["bsd"] = true, - ["linux"] = true, - ["macosx"] = true, - ["solaris"] = true -} - -function NazaraBuild:Process(infoTable) - local libraries = {} - for k, library in pairs(infoTable.Libraries) do - local projectName = library:match("Nazara(%w+)") - local moduleTable = projectName and self.Modules[projectName:lower()] - local toolTable = projectName and self.Tools[projectName:lower()] - - if (moduleTable) then - if (moduleTable.Excluded) then - infoTable.Excluded = true - infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module" - return false - end - - if (_OPTIONS["united"]) then - library = "NazaraEngine" - else - library = "Nazara" .. moduleTable.Name - end - - if (not _OPTIONS["united"] or infoTable.Type ~= "Module") then - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) - end - else - local extLibTable = self.ExtLibs[library:lower()] - if (extLibTable) then - if (extLibTable.Excluded) then - infoTable.Excluded = true - infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library" - return false - end - - library = extLibTable.Name - - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") - else - if (toolTable and toolTable.Kind == "library") then - if (toolTable.Excluded) then - infoTable.Excluded = true - infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool" - return false - end - - library = "Nazara" .. toolTable.Name - - -- Import tools includes - for k,v in ipairs(toolTable.Includes) do - table.insert(infoTable.Includes, v) - end - - -- And libraries - for k, v in pairs(toolTable.Libraries) do - table.insert(infoTable.Libraries, v) - end - - for config, libs in pairs(toolTable.ConfigurationLibraries) do - for k,v in pairs(libs) do - table.insert(infoTable.ConfigurationLibraries[config], v) - end - end - - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) - else - table.insert(libraries, library) - end - end - end - end - infoTable.Libraries = libraries - - for k,v in pairs(infoTable) do - local target = k:match("Os(%w+)") - if (target) then - local targetTable = infoTable[target] - if (targetTable) then - local excludeTargetTable = infoTable[target .. "Excluded"] - for platform, defineTable in pairs(v) do - platform = string.lower(platform) - if (platform == "posix") then - local osname = os.get() - if (PosixOSes[osname]) then - platform = osname - end - end - - if (os.is(platform)) then - for k,v in ipairs(defineTable) do - table.insert(targetTable, v) - end - elseif (excludeTargetTable) then - for k,v in ipairs(defineTable) do - table.insert(excludeTargetTable, v) - end - end - end - - infoTable[k] = nil - end - end - end - - if (infoTable.Kind == "application") then - self:AddExecutablePath(infoTable.TargetDirectory) - end - - return true -end - function NazaraBuild:Resolve(infoTable) - if (infoTable.ClientOnly and _OPTIONS["server"]) then + if (infoTable.ClientOnly and self.Config["ServerMode"]) then infoTable.Excluded = true infoTable.ExcludeReason = "excluded by command-line options (client-only)" end @@ -937,53 +1035,19 @@ function NazaraBuild:Resolve(infoTable) end end -function NazaraBuild:MakeInstallCommands(infoTable) - if (PremakeVersion < 50) then - return - end - - if (os.is("windows")) then - configuration({}) - - for k,v in pairs(self.InstallDir) do - local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]}) - end - - for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do - local paths = {} - table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) - table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) - table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) - table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) - - for k,v in pairs(paths) do - local config = v[1] - local srcPath = v[2] - if (os.isfile(srcPath)) then - if (infoTable.Kind == "plugin") then - srcPath = "../../" .. srcPath - end - - configuration(config) - - for k,v in pairs(self.ExecutableDir) do - local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}" "]] .. destPath .. [[\" /E /Y]]}) - end - end - end - end - end -end - function NazaraBuild:SetupInfoTable(infoTable) - infoTable.Excludable = true + infoTable.BinaryPaths = {} + infoTable.BinaryPaths.x86 = {} + infoTable.BinaryPaths.x64 = {} infoTable.ConfigurationLibraries = {} infoTable.ConfigurationLibraries.DebugStatic = {} infoTable.ConfigurationLibraries.ReleaseStatic = {} infoTable.ConfigurationLibraries.DebugDynamic = {} infoTable.ConfigurationLibraries.ReleaseDynamic = {} + infoTable.Excludable = true + infoTable.LibraryPaths = {} + infoTable.LibraryPaths.x86 = {} + infoTable.LibraryPaths.x64 = {} local infos = {"Defines", "DynLib", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"} for k,v in ipairs(infos) do @@ -1003,12 +1067,22 @@ function NazaraBuild:SetupExtlibTable(infoTable) self:SetupInfoTable(infoTable) infoTable.Kind = "library" + + table.insert(infoTable.BinaryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.BinaryPaths.x64, "../extlibs/lib/common/x64") + table.insert(infoTable.LibraryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64") end function NazaraBuild:SetupModuleTable(infoTable) self:SetupInfoTable(infoTable) infoTable.Kind = "library" + + table.insert(infoTable.BinaryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.BinaryPaths.x64, "../extlibs/lib/common/x64") + table.insert(infoTable.LibraryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64") end NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable \ No newline at end of file From 6c4c709f07bfcf356a26c3d781e6334030960928 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 23:56:38 +0200 Subject: [PATCH 117/235] Add build/config.lua to .gitignore Former-commit-id: d6a63c4189676ea69deffa663046cd3c513ee30e [formerly b565543b7a226862638eca5bb2d5923c5b2d219d] Former-commit-id: 545bf30297594d289f256c677d6dd64c820c1d8d --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c930343f4..463291bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Nazara build +build/config.lua examples/bin/*.exe examples/bin/*.pdb examples/bin/*.dll From ab89c2e7e9336659a474b1ce1136e42def502a6b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 14:06:29 +0200 Subject: [PATCH 118/235] Build: Remove "united" shortcuts (since we have config.lua now) Former-commit-id: 372d5a085df242d6a28eac3f70612d0860bd323b [formerly d53b34f0589249dbab3fd0b4de957989a8787165] Former-commit-id: 67390b05e4c7a8c3a5faa596d66ad6e95825d084 --- build/Build_CodeBlocks.bat | 2 +- build/Build_CodeBlocks_OneLibrary.bat | 1 - build/Build_CodeLite.bat | 2 +- build/Build_CodeLite_OneLibrary.bat | 1 - build/Build_VS2015.bat | 2 +- build/Build_VS2015_OneLibrary.bat | 1 - 6 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 build/Build_CodeBlocks_OneLibrary.bat delete mode 100644 build/Build_CodeLite_OneLibrary.bat delete mode 100644 build/Build_VS2015_OneLibrary.bat diff --git a/build/Build_CodeBlocks.bat b/build/Build_CodeBlocks.bat index 983c7ae80..439c5efac 100644 --- a/build/Build_CodeBlocks.bat +++ b/build/Build_CodeBlocks.bat @@ -1 +1 @@ -premake4 --with-extlibs --with-examples codeblocks \ No newline at end of file +premake4 codeblocks \ No newline at end of file diff --git a/build/Build_CodeBlocks_OneLibrary.bat b/build/Build_CodeBlocks_OneLibrary.bat deleted file mode 100644 index b7c5ab4c9..000000000 --- a/build/Build_CodeBlocks_OneLibrary.bat +++ /dev/null @@ -1 +0,0 @@ -premake4 --united --with-extlibs --with-examples codeblocks \ No newline at end of file diff --git a/build/Build_CodeLite.bat b/build/Build_CodeLite.bat index 8584e6d9b..170e7a451 100644 --- a/build/Build_CodeLite.bat +++ b/build/Build_CodeLite.bat @@ -1 +1 @@ -premake5 --with-extlibs --with-examples codelite \ No newline at end of file +premake5 codelite \ No newline at end of file diff --git a/build/Build_CodeLite_OneLibrary.bat b/build/Build_CodeLite_OneLibrary.bat deleted file mode 100644 index 52a80f504..000000000 --- a/build/Build_CodeLite_OneLibrary.bat +++ /dev/null @@ -1 +0,0 @@ -premake5 --united --with-extlibs --with-examples codelite \ No newline at end of file diff --git a/build/Build_VS2015.bat b/build/Build_VS2015.bat index 2dd6e578a..6d0726faf 100644 --- a/build/Build_VS2015.bat +++ b/build/Build_VS2015.bat @@ -1 +1 @@ -premake5 --with-extlibs --with-examples vs2015 \ No newline at end of file +premake5 vs2015 \ No newline at end of file diff --git a/build/Build_VS2015_OneLibrary.bat b/build/Build_VS2015_OneLibrary.bat deleted file mode 100644 index aaab1938c..000000000 --- a/build/Build_VS2015_OneLibrary.bat +++ /dev/null @@ -1 +0,0 @@ -premake5 --united --with-extlibs --with-examples vs2015 \ No newline at end of file From 6890dc1c812e60d881e03c4143c237f770715d4f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 15:50:02 +0200 Subject: [PATCH 119/235] Sdk: Components no longer need to be default-constructibles Former-commit-id: 71a7ec05389b77844b17effed45d415cbde2923f [formerly cb3cec5cdcf1aa7d8caff80d8de9b6ec61e5d82d] Former-commit-id: dd47985855712c5906b5bf051673714fff51b20c --- SDK/include/NDK/Component.inl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SDK/include/NDK/Component.inl b/SDK/include/NDK/Component.inl index e39091224..833395957 100644 --- a/SDK/include/NDK/Component.inl +++ b/SDK/include/NDK/Component.inl @@ -28,13 +28,11 @@ namespace Ndk template ComponentIndex Component::RegisterComponent(ComponentId id) { - // Il faut que notre composant possède un constructeur par défaut (pour la factory) - static_assert(std::is_default_constructible::value, "ComponentType must be default-constructible"); - // On utilise les lambda pour créer une fonction factory auto factory = []() -> BaseComponent* { - return new ComponentType; + return nullptr; //< Temporary workaround to allow non-default-constructed components, will be updated for serialization + //return new ComponentType; }; return BaseComponent::RegisterComponent(id, factory); From b5d715f0cf27b9d5fcc8e7a957713d1eb8133129 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 15:50:41 +0200 Subject: [PATCH 120/235] Graphics/ParticleEmitter: No longer inherit from Node Former-commit-id: 8041233753f93d886c2b65b2f13d4bdfdd87480a [formerly e0be3ff26527e13e4dbaef76512c243e2ef276e6] Former-commit-id: 66e5ad7353a32b6e8d9649d3ae32f42b35bf6a62 --- include/Nazara/Graphics/ParticleEmitter.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index b6acee156..7e2c6a7f8 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -9,14 +9,13 @@ #include #include -#include namespace Nz { class ParticleMapper; class ParticleGroup; - class NAZARA_GRAPHICS_API ParticleEmitter : public Node + class NAZARA_GRAPHICS_API ParticleEmitter { public: ParticleEmitter(); From 84614958315600b485d99e139a3c05ed75c5cdf4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 15:51:46 +0200 Subject: [PATCH 121/235] Sdk: Integrate particles Former-commit-id: ff0535cb992dd9b09e67ea0affb74c50e9a5ff7f [formerly b91580468f5658ed265ec89e5c997d2ba8f26001] Former-commit-id: 76c852a32a56f98dbdefd9aab0c938e50408a5a5 --- SDK/include/NDK/Components.hpp | 4 +- .../Components/ParticleEmitterComponent.hpp | 45 ++++++++++++++ .../Components/ParticleEmitterComponent.inl | 18 ++++++ .../NDK/Components/ParticleGroupComponent.hpp | 35 +++++++++++ .../NDK/Components/ParticleGroupComponent.inl | 17 ++++++ SDK/include/NDK/Systems.hpp | 3 +- SDK/include/NDK/Systems/ParticleSystem.hpp | 29 +++++++++ SDK/include/NDK/Systems/ParticleSystem.inl | 3 + SDK/include/NDK/Systems/RenderSystem.hpp | 1 + .../Components/ParticleEmitterComponent.cpp | 59 +++++++++++++++++++ .../NDK/Components/ParticleGroupComponent.cpp | 10 ++++ SDK/src/NDK/Sdk.cpp | 6 ++ SDK/src/NDK/Systems/ParticleSystem.cpp | 26 ++++++++ SDK/src/NDK/Systems/RenderSystem.cpp | 16 +++++ SDK/src/NDK/World.cpp | 2 + 15 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 SDK/include/NDK/Components/ParticleEmitterComponent.hpp create mode 100644 SDK/include/NDK/Components/ParticleEmitterComponent.inl create mode 100644 SDK/include/NDK/Components/ParticleGroupComponent.hpp create mode 100644 SDK/include/NDK/Components/ParticleGroupComponent.inl create mode 100644 SDK/include/NDK/Systems/ParticleSystem.hpp create mode 100644 SDK/include/NDK/Systems/ParticleSystem.inl create mode 100644 SDK/src/NDK/Components/ParticleEmitterComponent.cpp create mode 100644 SDK/src/NDK/Components/ParticleGroupComponent.cpp create mode 100644 SDK/src/NDK/Systems/ParticleSystem.cpp diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp index ca993b5b6..79bc196f7 100644 --- a/SDK/include/NDK/Components.hpp +++ b/SDK/include/NDK/Components.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 01 Jun 2016 at 13:11:09 +// This file was automatically generated on 30 Jul 2016 at 15:29:16 #pragma once @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp new file mode 100644 index 000000000..add138ee9 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -0,0 +1,45 @@ +// 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_SERVER +#ifndef NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP +#define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP + +#include +#include + +namespace Ndk +{ + class NDK_API ParticleEmitterComponent : public Component, public Nz::ParticleEmitter + { + public: + using SetupFunc = std::function; + + ParticleEmitterComponent(Nz::ParticleGroup* group); + ParticleEmitterComponent(const ParticleEmitterComponent& emitter); + ~ParticleEmitterComponent(); + + inline bool IsActive() const; + + void SetActive(bool active = true); + void SetGroup(Nz::ParticleGroup* group); + inline void SetSetupFunc(SetupFunc func); + + static ComponentIndex componentIndex; + + private: + void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override; + + SetupFunc m_setupFunc; + Nz::ParticleGroup* m_particleGroup; + bool m_isActive; + }; +} + +#include + +#endif // NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NDK/Components/ParticleEmitterComponent.inl new file mode 100644 index 000000000..6cc9e8c29 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.inl @@ -0,0 +1,18 @@ +// 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 + +namespace Ndk +{ + inline bool ParticleEmitterComponent::IsActive() const + { + return m_isActive; + } + + inline void Ndk::ParticleEmitterComponent::SetSetupFunc(SetupFunc func) + { + m_setupFunc = std::move(func); + } +} diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NDK/Components/ParticleGroupComponent.hpp new file mode 100644 index 000000000..638f877d3 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleGroupComponent.hpp @@ -0,0 +1,35 @@ +// 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_SERVER +#ifndef NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP +#define NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP + +#include +#include + +namespace Ndk +{ + class ParticleGroupComponent; + + using ParticleGroupComponentHandle = Nz::ObjectHandle; + + class NDK_API ParticleGroupComponent : public Component, public Nz::ParticleGroup + { + public: + inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout); + inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration); + ParticleGroupComponent(const ParticleGroupComponent&) = default; + ~ParticleGroupComponent() = default; + + static ComponentIndex componentIndex; + }; +} + +#include + +#endif // NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NDK/Components/ParticleGroupComponent.inl new file mode 100644 index 000000000..7aefdad56 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleGroupComponent.inl @@ -0,0 +1,17 @@ +#include "ParticleGroupComponent.hpp" +// 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 +{ + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) : + ParticleGroup(maxParticleCount, layout) + { + } + + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration) : + ParticleGroup(maxParticleCount, std::move(declaration)) + { + } +} diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp index 176a956ee..269bead6f 100644 --- a/SDK/include/NDK/Systems.hpp +++ b/SDK/include/NDK/Systems.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 01 Jun 2016 at 13:11:09 +// This file was automatically generated on 30 Jul 2016 at 15:29:16 #pragma once @@ -6,6 +6,7 @@ #define NDK_SYSTEMS_GLOBAL_HPP #include +#include #include #include #include diff --git a/SDK/include/NDK/Systems/ParticleSystem.hpp b/SDK/include/NDK/Systems/ParticleSystem.hpp new file mode 100644 index 000000000..3ae00a995 --- /dev/null +++ b/SDK/include/NDK/Systems/ParticleSystem.hpp @@ -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_SYSTEMS_PARTICLESYSTEM_HPP +#define NDK_SYSTEMS_PARTICLESYSTEM_HPP + +#include + +namespace Ndk +{ + class NDK_API ParticleSystem : public System + { + public: + ParticleSystem(); + ~ParticleSystem() = default; + + static SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override; + }; +} + +#include + +#endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP diff --git a/SDK/include/NDK/Systems/ParticleSystem.inl b/SDK/include/NDK/Systems/ParticleSystem.inl new file mode 100644 index 000000000..e5f296d27 --- /dev/null +++ b/SDK/include/NDK/Systems/ParticleSystem.inl @@ -0,0 +1,3 @@ +// 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 diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index f2fbc7a65..82e558773 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -60,6 +60,7 @@ namespace Ndk EntityList m_directionalLights; EntityList m_lights; EntityList m_pointSpotLights; + EntityList m_particleGroups; Nz::BackgroundRef m_background; Nz::DepthRenderTechnique m_shadowTechnique; Nz::Matrix4f m_coordinateSystemMatrix; diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp new file mode 100644 index 000000000..6a3cfeb7e --- /dev/null +++ b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp @@ -0,0 +1,59 @@ +// 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 +#include + +namespace Ndk +{ + ParticleEmitterComponent::ParticleEmitterComponent(Nz::ParticleGroup* group) : + m_particleGroup(group), + m_isActive(true) + { + if (m_particleGroup) + m_particleGroup->AddEmitter(this); + } + + ParticleEmitterComponent::ParticleEmitterComponent(const ParticleEmitterComponent& emitter) : + m_particleGroup(emitter.m_particleGroup), + m_isActive(emitter.m_isActive) + { + if (m_isActive) + m_particleGroup->AddEmitter(this); + } + + ParticleEmitterComponent::~ParticleEmitterComponent() + { + m_particleGroup->RemoveEmitter(this); + } + + inline void Ndk::ParticleEmitterComponent::SetActive(bool active) + { + if (m_isActive != active) + { + if (active) + m_particleGroup->AddEmitter(this); + else + m_particleGroup->RemoveEmitter(this); + } + } + + void ParticleEmitterComponent::SetGroup(Nz::ParticleGroup* group) + { + if (m_particleGroup) + m_particleGroup->RemoveEmitter(this); + + m_particleGroup = group; + if (m_particleGroup && m_isActive) + m_particleGroup = group; + } + + inline void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const + { + if (m_setupFunc) + m_setupFunc(m_entity, mapper, count); + } + + ComponentIndex ParticleEmitterComponent::componentIndex; +} diff --git a/SDK/src/NDK/Components/ParticleGroupComponent.cpp b/SDK/src/NDK/Components/ParticleGroupComponent.cpp new file mode 100644 index 000000000..4e0845871 --- /dev/null +++ b/SDK/src/NDK/Components/ParticleGroupComponent.cpp @@ -0,0 +1,10 @@ +// 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 + +namespace Ndk +{ + ComponentIndex ParticleGroupComponent::componentIndex; +} diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 7f29bb18e..964913bf8 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include #endif @@ -71,6 +74,8 @@ namespace Ndk InitializeComponent("NdkLight"); InitializeComponent("NdkList"); InitializeComponent("NdkGfx"); + InitializeComponent("NdkPaEmi"); + InitializeComponent("NdkPaGrp"); #endif // Systems @@ -84,6 +89,7 @@ namespace Ndk #ifndef NDK_SERVER // Client systems InitializeSystem(); + InitializeSystem(); InitializeSystem(); #endif diff --git a/SDK/src/NDK/Systems/ParticleSystem.cpp b/SDK/src/NDK/Systems/ParticleSystem.cpp new file mode 100644 index 000000000..a9f63cb6c --- /dev/null +++ b/SDK/src/NDK/Systems/ParticleSystem.cpp @@ -0,0 +1,26 @@ +// 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 +#include + +namespace Ndk +{ + ParticleSystem::ParticleSystem() + { + Requires(); + } + + void ParticleSystem::OnUpdate(float elapsedTime) + { + for (const Ndk::EntityHandle& entity : GetEntities()) + { + ParticleGroupComponent& group = entity->GetComponent(); + + group.Update(elapsedTime); + } + } + + SystemIndex ParticleSystem::systemIndex; +} diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index 7b90761b6..fcfd5c6a5 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace Ndk { @@ -25,8 +26,11 @@ namespace Ndk void RenderSystem::OnEntityRemoved(Entity* entity) { m_cameras.Remove(entity); + m_directionalLights.Remove(entity); m_drawables.Remove(entity); m_lights.Remove(entity); + m_particleGroups.Remove(entity); + m_pointSpotLights.Remove(entity); } void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded) @@ -71,6 +75,11 @@ namespace Ndk m_lights.Remove(entity); m_pointSpotLights.Remove(entity); } + + if (entity->HasComponent()) + m_particleGroups.Insert(entity); + else + m_particleGroups.Remove(entity); } void RenderSystem::OnUpdate(float elapsedTime) @@ -118,6 +127,13 @@ namespace Ndk lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix())); } + for (const Ndk::EntityHandle& particleGroup : m_particleGroups) + { + ParticleGroupComponent& groupComponent = particleGroup->GetComponent(); + + groupComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::Identity()); //< ParticleGroup doesn't use Matrix4f + } + camComponent.ApplyView(); Nz::SceneData sceneData; diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index e95785896..5d0e4900b 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -9,6 +9,7 @@ #ifndef NDK_SERVER #include +#include #include #endif @@ -27,6 +28,7 @@ namespace Ndk #ifndef NDK_SERVER AddSystem(); + AddSystem(); AddSystem(); #endif } From 57883a7b4545b7f85c1f72cc8f1390bd5c371832 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 31 Jul 2016 11:01:07 +0200 Subject: [PATCH 122/235] Build: Fix command line arguments being ignored if config.lua loading failed Former-commit-id: a470b669576a19af85ad21a72aac5278a5854235 [formerly 35cbe605f6afaf9eb360485722970eddda1c0a2e] Former-commit-id: e227cb5319776be03179e4a2233bbbe24bc819ac --- build/scripts/common.lua | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 66345ef7e..fa610e85c 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -637,28 +637,25 @@ end function NazaraBuild:LoadConfig() local f = io.open("config.lua", "r") - if (not f) then + if (f) then + local content = f:read("*a") + f:close() + + local func, err = loadstring(content) + if (func) then + setfenv(func, self.Config) + + local status, err = pcall(func) + if (not status) then + print("Failed to load config.lua: " .. err) + end + else + print("Failed to parse config.lua: " .. err) + end + else print("Failed to open config.lua") - return end - local content = f:read("*a") - f:close() - - local func, err = loadstring(content) - if (not func) then - print("Failed to parse config.lua: " .. err) - return - end - - setfenv(func, self.Config) - - local status, err = pcall(func) - if (not status) then - print("Failed to load config.lua: " .. err) - return - end - local configTable = self.Config local AddBoolOption = function (option, name, description) newoption({ From 487bc7383c0e241f05760cfd86566bea8ee15d67 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 31 Jul 2016 11:01:47 +0200 Subject: [PATCH 123/235] Build/NDKServer: Fix dependencies, allowing it to exists in server mode Former-commit-id: e917ce65aaea2567e4cb261777f458c3ea8ecdad [formerly a2f437b555af173f06b75f78bfe89ee14de7ba9f] Former-commit-id: 83d69a7152c45f02ae5a344c7f8be574cded2318 --- build/scripts/tools/ndk_server.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 2881c56fc..e536f1036 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -37,13 +37,11 @@ TOOL.FilesExcluded = { } -TOOL.Libraries = function() - local libraries = {} - for k,v in pairs(NazaraBuild.Modules) do - if (not v.ClientOnly) then - table.insert(libraries, "Nazara" .. v.Name) - end - end - - return libraries -end +TOOL.Libraries = { + "NazaraCore", + "NazaraLua", + "NazaraNetwork", + "NazaraNoise", + "NazaraPhysics", + "NazaraUtility" +} From 3eceba177072b65a04519820bd6fe86abd069c94 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 31 Jul 2016 12:59:04 +0200 Subject: [PATCH 124/235] Build: Fix empty install commands Former-commit-id: b1bc095ab7394364acbeaf672f6d4c6dcbfc2c71 [formerly 1b44b6b1fea962ed28b401f36c2ad12a8324ef2a] Former-commit-id: b2193ae86ce18618874827a440ab23abeb83a5e6 --- .../Components/ParticleEmitterComponent.hpp | 5 ++++ build/scripts/common.lua | 4 +++- include/Nazara/Graphics/ParticleEmitter.hpp | 9 +++++-- include/Nazara/Graphics/ParticleGroup.hpp | 4 ++++ src/Nazara/Graphics/ParticleEmitter.cpp | 24 ++++++++++++++++++- src/Nazara/Graphics/ParticleGroup.cpp | 5 +++- 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp index add138ee9..b874e0818 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -20,6 +20,7 @@ namespace Ndk ParticleEmitterComponent(Nz::ParticleGroup* group); ParticleEmitterComponent(const ParticleEmitterComponent& emitter); + ParticleEmitterComponent(ParticleEmitterComponent&& emitter); ~ParticleEmitterComponent(); inline bool IsActive() const; @@ -31,8 +32,12 @@ namespace Ndk static ComponentIndex componentIndex; private: + void OnParticleGroupRelease(const Nz::ParticleGroup* particleGroup); + void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override; + NazaraSlot(Nz::ParticleGroup, OnParticleGroupRelease, m_particleGroupRelease); + SetupFunc m_setupFunc; Nz::ParticleGroup* m_particleGroup; bool m_isActive; diff --git a/build/scripts/common.lua b/build/scripts/common.lua index fa610e85c..b467eb9c5 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -693,7 +693,9 @@ function NazaraBuild:LoadConfig() local paths = string.explode(self.Config["InstallDir"], ";") for k,v in pairs(paths) do - self:AddInstallPath(v) + if (#v > 0) then + self:AddInstallPath(v) + end end end diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index 7e2c6a7f8..b7a168262 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -8,6 +8,7 @@ #define NAZARA_PARTICLEEMITTER_HPP #include +#include #include namespace Nz @@ -20,7 +21,7 @@ namespace Nz public: ParticleEmitter(); ParticleEmitter(const ParticleEmitter& emitter) = default; - ParticleEmitter(ParticleEmitter&& emitter) = default; + ParticleEmitter(ParticleEmitter&& emitter); virtual ~ParticleEmitter(); virtual void Emit(ParticleGroup& system, float elapsedTime) const; @@ -36,7 +37,11 @@ namespace Nz void SetEmissionRate(float rate); ParticleEmitter& operator=(const ParticleEmitter& emitter) = default; - ParticleEmitter& operator=(ParticleEmitter&& emitter) = default; + ParticleEmitter& operator=(ParticleEmitter&& emitter); + + // Signals: + NazaraSignal(OnParticleEmitterMove, const ParticleEmitter* /*oldParticleEmitter*/, const ParticleEmitter* /*newParticleEmitter*/); + NazaraSignal(OnParticleEmitterRelease, const ParticleEmitter* /*particleEmitter*/); private: virtual void SetupParticles(ParticleMapper& mapper, unsigned int count) const = 0; diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 412b94511..4d4704171 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -8,6 +8,7 @@ #define NAZARA_PARTICLEGROUP_HPP #include +#include #include #include #include @@ -62,6 +63,9 @@ namespace Nz ParticleGroup& operator=(const ParticleGroup& emitter); + // Signals: + NazaraSignal(OnParticleGroupRelease, const ParticleGroup* /*particleGroup*/); + private: void MakeBoundingVolume() const override; void ResizeBuffer(); diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index b11cfdfe9..10f057dce 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -32,7 +32,19 @@ namespace Nz { } - ParticleEmitter::~ParticleEmitter() = default; + ParticleEmitter::ParticleEmitter(ParticleEmitter&& emitter) : + m_lagCompensationEnabled(emitter.m_lagCompensationEnabled), + m_emissionAccumulator(0.f), + m_emissionRate(emitter.m_emissionRate), + m_emissionCount(emitter.m_emissionCount) + { + OnParticleEmitterMove(&emitter, this); + } + + ParticleEmitter::~ParticleEmitter() + { + OnParticleEmitterRelease(this); + } /*! * \brief Emits particles according to the delta time between the previous frame @@ -141,4 +153,14 @@ namespace Nz { m_emissionRate = rate; } + + ParticleEmitter& ParticleEmitter::operator=(ParticleEmitter && emitter) + { + m_emissionCount = emitter.m_emissionCount; + m_emissionRate = emitter.m_emissionRate; + m_lagCompensationEnabled = emitter.m_lagCompensationEnabled; + + OnParticleEmitterMove(&emitter, this); + return *this; + } } diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index d93c085db..87dbb390c 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -77,7 +77,10 @@ namespace Nz std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); } - ParticleGroup::~ParticleGroup() = default; + ParticleGroup::~ParticleGroup() + { + OnParticleGroupRelease(this); + } /*! * \brief Adds a controller to the particles From 2674657d025a0a8fba720fcee9adb4650426991a Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 1 Aug 2016 12:04:15 +0200 Subject: [PATCH 125/235] SDK/ParticleEmitterComponent: Fix missing include Former-commit-id: acd40e087c5626ed81b4beeae2478defadcf07fc [formerly 6cfe657fd9e154e8f77db4ffa206a8ab23e4d5c1] Former-commit-id: da09547499f6f12665937b7e1d7488ddc75eb3cd --- SDK/include/NDK/Components/ParticleEmitterComponent.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp index b874e0818..8d93e0495 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -9,6 +9,7 @@ #define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP #include +#include #include namespace Ndk From b7a08a6aa7dc3227326e8b975da26bd1e2732cc0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 12:52:49 +0200 Subject: [PATCH 126/235] Core/RefCounted: Remove persistent boolean Former-commit-id: b5681c26fc30db38b94f9c1ecc9c12ee699af767 [formerly aeebf599245261644fd5fb54fe9f64067a63afc9] Former-commit-id: f7bcc658c93cc3977ffa91a617b7ca4d463b4aca --- include/Nazara/Audio/SoundBuffer.inl | 2 - include/Nazara/Core/RefCounted.hpp | 7 +--- include/Nazara/Graphics/Billboard.inl | 2 - include/Nazara/Graphics/ColorBackground.inl | 2 - include/Nazara/Graphics/Material.inl | 2 - include/Nazara/Graphics/Model.inl | 2 - include/Nazara/Graphics/SkyboxBackground.inl | 2 - include/Nazara/Graphics/Sprite.inl | 2 - include/Nazara/Graphics/TextSprite.inl | 2 - include/Nazara/Graphics/TextureBackground.inl | 2 - include/Nazara/Graphics/TileMap.inl | 2 - include/Nazara/Physics/Geom.inl | 16 -------- include/Nazara/Renderer/RenderBuffer.inl | 2 - include/Nazara/Renderer/Shader.inl | 2 - include/Nazara/Renderer/Texture.inl | 2 - .../Renderer/UberShaderPreprocessor.inl | 2 - include/Nazara/Utility/Animation.inl | 2 - include/Nazara/Utility/Buffer.inl | 2 - include/Nazara/Utility/Font.inl | 2 - include/Nazara/Utility/Image.inl | 2 - include/Nazara/Utility/IndexBuffer.inl | 2 - include/Nazara/Utility/Mesh.inl | 2 - include/Nazara/Utility/SkeletalMesh.inl | 2 - include/Nazara/Utility/Skeleton.inl | 2 - include/Nazara/Utility/StaticMesh.inl | 2 - include/Nazara/Utility/VertexBuffer.inl | 2 - include/Nazara/Utility/VertexDeclaration.inl | 2 - src/Nazara/Core/RefCounted.cpp | 41 ++----------------- 28 files changed, 4 insertions(+), 110 deletions(-) diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index a4c42be69..22ed4b19a 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -18,8 +18,6 @@ namespace Nz SoundBufferRef SoundBuffer::New(Args&&... args) { std::unique_ptr object(new SoundBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index 542784787..42936ff7e 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -22,7 +22,7 @@ namespace Nz class NAZARA_CORE_API RefCounted { public: - RefCounted(bool persistent = true); + RefCounted(); RefCounted(const RefCounted&) = delete; RefCounted(RefCounted&&) = default; virtual ~RefCounted(); @@ -31,17 +31,12 @@ namespace Nz unsigned int GetReferenceCount() const; - bool IsPersistent() const; - bool RemoveReference() const; - bool SetPersistent(bool persistent = true, bool checkReferenceCount = false); - RefCounted& operator=(const RefCounted&) = delete; RefCounted& operator=(RefCounted&&) = default; private: - std::atomic_bool m_persistent; mutable std::atomic_uint m_referenceCount; }; } diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 6c4a1e0a9..95a0e5b87 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -234,8 +234,6 @@ namespace Nz BillboardRef Billboard::New(Args&&... args) { std::unique_ptr object(new Billboard(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 67b1f2558..49efd4874 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -18,8 +18,6 @@ namespace Nz ColorBackgroundRef ColorBackground::New(Args&&... args) { std::unique_ptr object(new ColorBackground(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 6d5315640..801e341ae 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -1099,8 +1099,6 @@ namespace Nz MaterialRef Material::New(Args&&... args) { std::unique_ptr object(new Material(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index a2b4c3967..fba9655ec 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -18,8 +18,6 @@ namespace Nz ModelRef Model::New(Args&&... args) { std::unique_ptr object(new Model(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 6171f1e28..15d3eb137 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -119,8 +119,6 @@ namespace Nz SkyboxBackgroundRef SkyboxBackground::New(Args&&... args) { std::unique_ptr object(new SkyboxBackground(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 840a930e6..166807f2b 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -271,8 +271,6 @@ namespace Nz SpriteRef Sprite::New(Args&&... args) { std::unique_ptr object(new Sprite(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index baeeb50db..48b0c061b 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -210,8 +210,6 @@ namespace Nz TextSpriteRef TextSprite::New(Args&&... args) { std::unique_ptr object(new TextSprite(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index 31067f36c..423ab5a81 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -41,8 +41,6 @@ namespace Nz TextureBackgroundRef TextureBackground::New(Args&&... args) { std::unique_ptr object(new TextureBackground(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 405683f40..0f7c8faca 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -432,8 +432,6 @@ namespace Nz TileMapRef TileMap::New(Args&&... args) { std::unique_ptr object(new TileMap(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Physics/Geom.inl b/include/Nazara/Physics/Geom.inl index 9699cac96..0a21fbd23 100644 --- a/include/Nazara/Physics/Geom.inl +++ b/include/Nazara/Physics/Geom.inl @@ -11,8 +11,6 @@ namespace Nz BoxGeomRef BoxGeom::New(Args&&... args) { std::unique_ptr object(new BoxGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -20,8 +18,6 @@ namespace Nz CapsuleGeomRef CapsuleGeom::New(Args&&... args) { std::unique_ptr object(new CapsuleGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -29,8 +25,6 @@ namespace Nz CompoundGeomRef CompoundGeom::New(Args&&... args) { std::unique_ptr object(new CompoundGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -38,8 +32,6 @@ namespace Nz ConeGeomRef ConeGeom::New(Args&&... args) { std::unique_ptr object(new ConeGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -47,8 +39,6 @@ namespace Nz ConvexHullGeomRef ConvexHullGeom::New(Args&&... args) { std::unique_ptr object(new ConvexHullGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -56,8 +46,6 @@ namespace Nz CylinderGeomRef CylinderGeom::New(Args&&... args) { std::unique_ptr object(new CylinderGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -65,8 +53,6 @@ namespace Nz NullGeomRef NullGeom::New(Args&&... args) { std::unique_ptr object(new NullGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -74,8 +60,6 @@ namespace Nz SphereGeomRef SphereGeom::New(Args&&... args) { std::unique_ptr object(new SphereGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl index bd81e7a17..59a9a5dd8 100644 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -11,8 +11,6 @@ namespace Nz RenderBufferRef RenderBuffer::New(Args&&... args) { std::unique_ptr object(new RenderBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Renderer/Shader.inl b/include/Nazara/Renderer/Shader.inl index b868c540e..0e8309008 100644 --- a/include/Nazara/Renderer/Shader.inl +++ b/include/Nazara/Renderer/Shader.inl @@ -11,8 +11,6 @@ namespace Nz ShaderRef Shader::New(Args&&... args) { std::unique_ptr object(new Shader(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl index 4dc53464b..c9813ac73 100644 --- a/include/Nazara/Renderer/Texture.inl +++ b/include/Nazara/Renderer/Texture.inl @@ -11,8 +11,6 @@ namespace Nz TextureRef Texture::New(Args&&... args) { std::unique_ptr object(new Texture(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.inl b/include/Nazara/Renderer/UberShaderPreprocessor.inl index 1e6528775..fb9477030 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.inl +++ b/include/Nazara/Renderer/UberShaderPreprocessor.inl @@ -11,8 +11,6 @@ namespace Nz UberShaderPreprocessorRef UberShaderPreprocessor::New(Args&&... args) { std::unique_ptr object(new UberShaderPreprocessor(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Animation.inl b/include/Nazara/Utility/Animation.inl index 0ae58c0f4..f742e4c0e 100644 --- a/include/Nazara/Utility/Animation.inl +++ b/include/Nazara/Utility/Animation.inl @@ -11,8 +11,6 @@ namespace Nz AnimationRef Animation::New(Args&&... args) { std::unique_ptr object(new Animation(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Buffer.inl b/include/Nazara/Utility/Buffer.inl index 8703fd82c..39c1960f7 100644 --- a/include/Nazara/Utility/Buffer.inl +++ b/include/Nazara/Utility/Buffer.inl @@ -11,8 +11,6 @@ namespace Nz BufferRef Buffer::New(Args&&... args) { std::unique_ptr object(new Buffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Font.inl b/include/Nazara/Utility/Font.inl index 241915a3e..5f8e94c2c 100644 --- a/include/Nazara/Utility/Font.inl +++ b/include/Nazara/Utility/Font.inl @@ -11,8 +11,6 @@ namespace Nz FontRef Font::New(Args&&... args) { std::unique_ptr object(new Font(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Image.inl b/include/Nazara/Utility/Image.inl index 5cb8ef42f..ca111f9e9 100644 --- a/include/Nazara/Utility/Image.inl +++ b/include/Nazara/Utility/Image.inl @@ -11,8 +11,6 @@ namespace Nz ImageRef Image::New(Args&&... args) { std::unique_ptr object(new Image(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index 1c1d16a18..789019f91 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -11,8 +11,6 @@ namespace Nz IndexBufferRef IndexBuffer::New(Args&&... args) { std::unique_ptr object(new IndexBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Mesh.inl b/include/Nazara/Utility/Mesh.inl index 4877e03fe..21d52bf7d 100644 --- a/include/Nazara/Utility/Mesh.inl +++ b/include/Nazara/Utility/Mesh.inl @@ -11,8 +11,6 @@ namespace Nz MeshRef Mesh::New(Args&&... args) { std::unique_ptr object(new Mesh(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/SkeletalMesh.inl b/include/Nazara/Utility/SkeletalMesh.inl index 69119dc87..f6a590902 100644 --- a/include/Nazara/Utility/SkeletalMesh.inl +++ b/include/Nazara/Utility/SkeletalMesh.inl @@ -11,8 +11,6 @@ namespace Nz SkeletalMeshRef SkeletalMesh::New(Args&&... args) { std::unique_ptr object(new SkeletalMesh(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Skeleton.inl b/include/Nazara/Utility/Skeleton.inl index 4c0ef4546..839227462 100644 --- a/include/Nazara/Utility/Skeleton.inl +++ b/include/Nazara/Utility/Skeleton.inl @@ -11,8 +11,6 @@ namespace Nz SkeletonRef Skeleton::New(Args&&... args) { std::unique_ptr object(new Skeleton(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/StaticMesh.inl b/include/Nazara/Utility/StaticMesh.inl index 06afcec95..a18ae32f5 100644 --- a/include/Nazara/Utility/StaticMesh.inl +++ b/include/Nazara/Utility/StaticMesh.inl @@ -11,8 +11,6 @@ namespace Nz StaticMeshRef StaticMesh::New(Args&&... args) { std::unique_ptr object(new StaticMesh(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index 24268e9cb..a4ebef1be 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -11,8 +11,6 @@ namespace Nz VertexBufferRef VertexBuffer::New(Args&&... args) { std::unique_ptr object(new VertexBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index beed900d5..f74e29a7c 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -11,8 +11,6 @@ namespace Nz VertexDeclarationRef VertexDeclaration::New(Args&&... args) { std::unique_ptr object(new VertexDeclaration(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/src/Nazara/Core/RefCounted.cpp b/src/Nazara/Core/RefCounted.cpp index 31e749515..f37300c32 100644 --- a/src/Nazara/Core/RefCounted.cpp +++ b/src/Nazara/Core/RefCounted.cpp @@ -23,13 +23,10 @@ namespace Nz */ /*! - * \brief Constructs a RefCounted object with a persistance aspect - * - * \param persistent if false, object is destroyed when no more referenced + * \brief Constructs a RefCounted object */ - RefCounted::RefCounted(bool persistent) : - m_persistent(persistent), + RefCounted::RefCounted() : m_referenceCount(0) { } @@ -67,16 +64,6 @@ namespace Nz return m_referenceCount; } - /*! - * \brief Checks whether the object is persistent - * \return true if object is not destroyed when no more referenced - */ - - bool RefCounted::IsPersistent() const - { - return m_persistent; - } - /*! * \brief Removes a reference to the object * \return true if object is deleted because no more referenced @@ -94,7 +81,7 @@ namespace Nz } #endif - if (--m_referenceCount == 0 && !m_persistent) + if (--m_referenceCount == 0) { delete this; // Suicide @@ -103,26 +90,4 @@ namespace Nz else return false; } - - /*! - * \brief Sets the persistence of the object - * \return true if object is deleted because no more referenced - * - * \param persistent Sets the persistence of the object - * \param checkReferenceCount Checks if the object should be destroyed if true - */ - - bool RefCounted::SetPersistent(bool persistent, bool checkReferenceCount) - { - m_persistent = persistent; - - if (checkReferenceCount && !persistent && m_referenceCount == 0) - { - delete this; - - return true; - } - else - return false; - } } From 2af2f05681193bbb648b7af94015ddde8d92a4a7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 12:56:03 +0200 Subject: [PATCH 127/235] Fix compile Former-commit-id: 7a6e8f01499fee2e915d39d7617588691fcac33a [formerly 6ef3e9d5f4baf27e90d8c5611f40039ab9269d43] Former-commit-id: 50296e41b4f6eca86a0e505d8a2154bf63e7bad6 --- src/Nazara/Utility/SubMesh.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index 8b0589808..fd706e7a6 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -15,7 +15,6 @@ namespace Nz { SubMesh::SubMesh(const Mesh* parent) : - RefCounted(false), // Un SubMesh n'est pas persistant par défaut m_primitiveMode(PrimitiveMode_TriangleList), m_parent(parent), m_matIndex(0) From e5e212747a99ceb6b29977ac8be1196c4cf194f8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 13:20:31 +0200 Subject: [PATCH 128/235] Revert "Fix compile" This reverts commit df4e466ee49accc9c19b2fe6da3c14e2779ca12b [formerly 752e14ea33208e0a1298a21b2be1c6aee56dfde1] [formerly a3eb1f7d2f090e0a63f64b3451198631e8d2c47e [formerly 4b89c5fafdc15330f909c62fd75a23885c7364e1]] [formerly 0b09aea025e4d8df0bdf33917571e81f1fe5c6a2 [formerly e192bf206e80f55897d26faf541bcc5afa0437fc] [formerly e9f0b2cd7d7dd709f6a0419b3ea4f6a599cbb823 [formerly 273f4a73bfed75ebec68969db3ae235ccec8600c]]]. Former-commit-id: 10bb5f512cf03b8fc0c089234a7459e23cc3c7b0 [formerly 3902bf47b5e1c3b633fc7c7987a669fa20ef16bd] [formerly e34fd396e99c2eef708c3416381b809803535ac7 [formerly 459d967e5fe1ab219dde6fecb46ce9753454e667]] Former-commit-id: ba65031880a9546329da12d9827a1d2a138caf27 [formerly bbf398fd7cd29afc5dfb4cec870e8db7b2781d61] Former-commit-id: dffc0fb70ec6e7f0f0656253d8e3bfb1f87d3ef2 --- src/Nazara/Utility/SubMesh.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index fd706e7a6..8b0589808 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -15,6 +15,7 @@ namespace Nz { SubMesh::SubMesh(const Mesh* parent) : + RefCounted(false), // Un SubMesh n'est pas persistant par défaut m_primitiveMode(PrimitiveMode_TriangleList), m_parent(parent), m_matIndex(0) From 76818335ff9ca3348ef4714122bb6f34d903c95f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 13:20:34 +0200 Subject: [PATCH 129/235] Revert "Core/RefCounted: Remove persistent boolean" This reverts commit db2ef3e90c3871290d114a9e6437b412e96c65aa [formerly a3f6ff88a25e63374eb6ce5b18269da2ba743b06] [formerly cfa12604fbb0da76fc27288b210ee1254a8b3a38 [formerly dee6ce858398e2de38ef1af00c1c630fd0126e09]] [formerly 1a23f0fddcd80ac33030061b7a00a3cfd43cb7fe [formerly d3cb17069c71449ae3f1cba6de55ea70f509e7a4] [formerly b2f8f82e9f3427310204f2e8a61d7bdfd96202d2 [formerly 5d117720d08d6d6243b3428d4b3f8aea1abef845]]]. Former-commit-id: fcbfc6cb2fac86f6f10ff5def148cc5635082c83 [formerly 6bcf746c9b6f35aff6786da950001da11cedfc48] [formerly 9d219f350ddebbfa60eaa9c382d8d811d963ac15 [formerly 75f534e850802526877b811e8f6ca510bb7f2c16]] Former-commit-id: b5ca8fa1bde036ccb4f7be17a98ef8275ab5cf2a [formerly ee166858dad5c8cd00249894266b13e8ce1a153e] Former-commit-id: 2a601076664aebc1107654dd80f3b53f7acbc044 --- include/Nazara/Audio/SoundBuffer.inl | 2 + include/Nazara/Core/RefCounted.hpp | 7 +++- include/Nazara/Graphics/Billboard.inl | 2 + include/Nazara/Graphics/ColorBackground.inl | 2 + include/Nazara/Graphics/Material.inl | 2 + include/Nazara/Graphics/Model.inl | 2 + include/Nazara/Graphics/SkyboxBackground.inl | 2 + include/Nazara/Graphics/Sprite.inl | 2 + include/Nazara/Graphics/TextSprite.inl | 2 + include/Nazara/Graphics/TextureBackground.inl | 2 + include/Nazara/Graphics/TileMap.inl | 2 + include/Nazara/Physics/Geom.inl | 16 ++++++++ include/Nazara/Renderer/RenderBuffer.inl | 2 + include/Nazara/Renderer/Shader.inl | 2 + include/Nazara/Renderer/Texture.inl | 2 + .../Renderer/UberShaderPreprocessor.inl | 2 + include/Nazara/Utility/Animation.inl | 2 + include/Nazara/Utility/Buffer.inl | 2 + include/Nazara/Utility/Font.inl | 2 + include/Nazara/Utility/Image.inl | 2 + include/Nazara/Utility/IndexBuffer.inl | 2 + include/Nazara/Utility/Mesh.inl | 2 + include/Nazara/Utility/SkeletalMesh.inl | 2 + include/Nazara/Utility/Skeleton.inl | 2 + include/Nazara/Utility/StaticMesh.inl | 2 + include/Nazara/Utility/VertexBuffer.inl | 2 + include/Nazara/Utility/VertexDeclaration.inl | 2 + src/Nazara/Core/RefCounted.cpp | 41 +++++++++++++++++-- 28 files changed, 110 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index 22ed4b19a..a4c42be69 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -18,6 +18,8 @@ namespace Nz SoundBufferRef SoundBuffer::New(Args&&... args) { std::unique_ptr object(new SoundBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index 42936ff7e..542784787 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -22,7 +22,7 @@ namespace Nz class NAZARA_CORE_API RefCounted { public: - RefCounted(); + RefCounted(bool persistent = true); RefCounted(const RefCounted&) = delete; RefCounted(RefCounted&&) = default; virtual ~RefCounted(); @@ -31,12 +31,17 @@ namespace Nz unsigned int GetReferenceCount() const; + bool IsPersistent() const; + bool RemoveReference() const; + bool SetPersistent(bool persistent = true, bool checkReferenceCount = false); + RefCounted& operator=(const RefCounted&) = delete; RefCounted& operator=(RefCounted&&) = default; private: + std::atomic_bool m_persistent; mutable std::atomic_uint m_referenceCount; }; } diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 95a0e5b87..6c4a1e0a9 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -234,6 +234,8 @@ namespace Nz BillboardRef Billboard::New(Args&&... args) { std::unique_ptr object(new Billboard(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 49efd4874..67b1f2558 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -18,6 +18,8 @@ namespace Nz ColorBackgroundRef ColorBackground::New(Args&&... args) { std::unique_ptr object(new ColorBackground(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 801e341ae..6d5315640 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -1099,6 +1099,8 @@ namespace Nz MaterialRef Material::New(Args&&... args) { std::unique_ptr object(new Material(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index fba9655ec..a2b4c3967 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -18,6 +18,8 @@ namespace Nz ModelRef Model::New(Args&&... args) { std::unique_ptr object(new Model(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 15d3eb137..6171f1e28 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -119,6 +119,8 @@ namespace Nz SkyboxBackgroundRef SkyboxBackground::New(Args&&... args) { std::unique_ptr object(new SkyboxBackground(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 166807f2b..840a930e6 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -271,6 +271,8 @@ namespace Nz SpriteRef Sprite::New(Args&&... args) { std::unique_ptr object(new Sprite(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index 48b0c061b..baeeb50db 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -210,6 +210,8 @@ namespace Nz TextSpriteRef TextSprite::New(Args&&... args) { std::unique_ptr object(new TextSprite(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index 423ab5a81..31067f36c 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -41,6 +41,8 @@ namespace Nz TextureBackgroundRef TextureBackground::New(Args&&... args) { std::unique_ptr object(new TextureBackground(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 0f7c8faca..405683f40 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -432,6 +432,8 @@ namespace Nz TileMapRef TileMap::New(Args&&... args) { std::unique_ptr object(new TileMap(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Physics/Geom.inl b/include/Nazara/Physics/Geom.inl index 0a21fbd23..9699cac96 100644 --- a/include/Nazara/Physics/Geom.inl +++ b/include/Nazara/Physics/Geom.inl @@ -11,6 +11,8 @@ namespace Nz BoxGeomRef BoxGeom::New(Args&&... args) { std::unique_ptr object(new BoxGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -18,6 +20,8 @@ namespace Nz CapsuleGeomRef CapsuleGeom::New(Args&&... args) { std::unique_ptr object(new CapsuleGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -25,6 +29,8 @@ namespace Nz CompoundGeomRef CompoundGeom::New(Args&&... args) { std::unique_ptr object(new CompoundGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -32,6 +38,8 @@ namespace Nz ConeGeomRef ConeGeom::New(Args&&... args) { std::unique_ptr object(new ConeGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -39,6 +47,8 @@ namespace Nz ConvexHullGeomRef ConvexHullGeom::New(Args&&... args) { std::unique_ptr object(new ConvexHullGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -46,6 +56,8 @@ namespace Nz CylinderGeomRef CylinderGeom::New(Args&&... args) { std::unique_ptr object(new CylinderGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -53,6 +65,8 @@ namespace Nz NullGeomRef NullGeom::New(Args&&... args) { std::unique_ptr object(new NullGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -60,6 +74,8 @@ namespace Nz SphereGeomRef SphereGeom::New(Args&&... args) { std::unique_ptr object(new SphereGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl index 59a9a5dd8..bd81e7a17 100644 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -11,6 +11,8 @@ namespace Nz RenderBufferRef RenderBuffer::New(Args&&... args) { std::unique_ptr object(new RenderBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Renderer/Shader.inl b/include/Nazara/Renderer/Shader.inl index 0e8309008..b868c540e 100644 --- a/include/Nazara/Renderer/Shader.inl +++ b/include/Nazara/Renderer/Shader.inl @@ -11,6 +11,8 @@ namespace Nz ShaderRef Shader::New(Args&&... args) { std::unique_ptr object(new Shader(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl index c9813ac73..4dc53464b 100644 --- a/include/Nazara/Renderer/Texture.inl +++ b/include/Nazara/Renderer/Texture.inl @@ -11,6 +11,8 @@ namespace Nz TextureRef Texture::New(Args&&... args) { std::unique_ptr object(new Texture(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.inl b/include/Nazara/Renderer/UberShaderPreprocessor.inl index fb9477030..1e6528775 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.inl +++ b/include/Nazara/Renderer/UberShaderPreprocessor.inl @@ -11,6 +11,8 @@ namespace Nz UberShaderPreprocessorRef UberShaderPreprocessor::New(Args&&... args) { std::unique_ptr object(new UberShaderPreprocessor(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Animation.inl b/include/Nazara/Utility/Animation.inl index f742e4c0e..0ae58c0f4 100644 --- a/include/Nazara/Utility/Animation.inl +++ b/include/Nazara/Utility/Animation.inl @@ -11,6 +11,8 @@ namespace Nz AnimationRef Animation::New(Args&&... args) { std::unique_ptr object(new Animation(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Buffer.inl b/include/Nazara/Utility/Buffer.inl index 39c1960f7..8703fd82c 100644 --- a/include/Nazara/Utility/Buffer.inl +++ b/include/Nazara/Utility/Buffer.inl @@ -11,6 +11,8 @@ namespace Nz BufferRef Buffer::New(Args&&... args) { std::unique_ptr object(new Buffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Font.inl b/include/Nazara/Utility/Font.inl index 5f8e94c2c..241915a3e 100644 --- a/include/Nazara/Utility/Font.inl +++ b/include/Nazara/Utility/Font.inl @@ -11,6 +11,8 @@ namespace Nz FontRef Font::New(Args&&... args) { std::unique_ptr object(new Font(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Image.inl b/include/Nazara/Utility/Image.inl index ca111f9e9..5cb8ef42f 100644 --- a/include/Nazara/Utility/Image.inl +++ b/include/Nazara/Utility/Image.inl @@ -11,6 +11,8 @@ namespace Nz ImageRef Image::New(Args&&... args) { std::unique_ptr object(new Image(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index 789019f91..1c1d16a18 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -11,6 +11,8 @@ namespace Nz IndexBufferRef IndexBuffer::New(Args&&... args) { std::unique_ptr object(new IndexBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Mesh.inl b/include/Nazara/Utility/Mesh.inl index 21d52bf7d..4877e03fe 100644 --- a/include/Nazara/Utility/Mesh.inl +++ b/include/Nazara/Utility/Mesh.inl @@ -11,6 +11,8 @@ namespace Nz MeshRef Mesh::New(Args&&... args) { std::unique_ptr object(new Mesh(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/SkeletalMesh.inl b/include/Nazara/Utility/SkeletalMesh.inl index f6a590902..69119dc87 100644 --- a/include/Nazara/Utility/SkeletalMesh.inl +++ b/include/Nazara/Utility/SkeletalMesh.inl @@ -11,6 +11,8 @@ namespace Nz SkeletalMeshRef SkeletalMesh::New(Args&&... args) { std::unique_ptr object(new SkeletalMesh(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Skeleton.inl b/include/Nazara/Utility/Skeleton.inl index 839227462..4c0ef4546 100644 --- a/include/Nazara/Utility/Skeleton.inl +++ b/include/Nazara/Utility/Skeleton.inl @@ -11,6 +11,8 @@ namespace Nz SkeletonRef Skeleton::New(Args&&... args) { std::unique_ptr object(new Skeleton(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/StaticMesh.inl b/include/Nazara/Utility/StaticMesh.inl index a18ae32f5..06afcec95 100644 --- a/include/Nazara/Utility/StaticMesh.inl +++ b/include/Nazara/Utility/StaticMesh.inl @@ -11,6 +11,8 @@ namespace Nz StaticMeshRef StaticMesh::New(Args&&... args) { std::unique_ptr object(new StaticMesh(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index a4ebef1be..24268e9cb 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -11,6 +11,8 @@ namespace Nz VertexBufferRef VertexBuffer::New(Args&&... args) { std::unique_ptr object(new VertexBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index f74e29a7c..beed900d5 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -11,6 +11,8 @@ namespace Nz VertexDeclarationRef VertexDeclaration::New(Args&&... args) { std::unique_ptr object(new VertexDeclaration(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/src/Nazara/Core/RefCounted.cpp b/src/Nazara/Core/RefCounted.cpp index f37300c32..31e749515 100644 --- a/src/Nazara/Core/RefCounted.cpp +++ b/src/Nazara/Core/RefCounted.cpp @@ -23,10 +23,13 @@ namespace Nz */ /*! - * \brief Constructs a RefCounted object + * \brief Constructs a RefCounted object with a persistance aspect + * + * \param persistent if false, object is destroyed when no more referenced */ - RefCounted::RefCounted() : + RefCounted::RefCounted(bool persistent) : + m_persistent(persistent), m_referenceCount(0) { } @@ -64,6 +67,16 @@ namespace Nz return m_referenceCount; } + /*! + * \brief Checks whether the object is persistent + * \return true if object is not destroyed when no more referenced + */ + + bool RefCounted::IsPersistent() const + { + return m_persistent; + } + /*! * \brief Removes a reference to the object * \return true if object is deleted because no more referenced @@ -81,7 +94,7 @@ namespace Nz } #endif - if (--m_referenceCount == 0) + if (--m_referenceCount == 0 && !m_persistent) { delete this; // Suicide @@ -90,4 +103,26 @@ namespace Nz else return false; } + + /*! + * \brief Sets the persistence of the object + * \return true if object is deleted because no more referenced + * + * \param persistent Sets the persistence of the object + * \param checkReferenceCount Checks if the object should be destroyed if true + */ + + bool RefCounted::SetPersistent(bool persistent, bool checkReferenceCount) + { + m_persistent = persistent; + + if (checkReferenceCount && !persistent && m_referenceCount == 0) + { + delete this; + + return true; + } + else + return false; + } } From 5b83ac044b75b712020efeefc8ce0b1c7bd73f39 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 13:31:09 +0200 Subject: [PATCH 130/235] Improved declarations Former-commit-id: 19169e7acc6fd5d7ea7399ec9b2614c028a1dfd2 [formerly c383d9fbf62f8868d0834dcdd08a1f7b7f3ff81a] [formerly 4633f0bfb8c049bc2ce10ea2aa47684c7ae7a030 [formerly 4a92fd2e96b20daedf2d04006053e7600c60cd79]] Former-commit-id: fcb2bfac13cdc0d6cf5d7b9c19a5cf11b04874c1 [formerly b631d69d2d2795c3bd60bc89085579087df6b73b] Former-commit-id: 105a4d1bb3e05266c8c5cde7f87e14444a5de49c --- .../Nazara/Graphics/ParticleDeclaration.hpp | 8 ++++++-- .../Nazara/Graphics/ParticleDeclaration.inl | 18 ++++++++++++++++++ include/Nazara/Utility/VertexDeclaration.hpp | 7 ++++--- src/Nazara/Graphics/ParticleDeclaration.cpp | 14 ++++---------- src/Nazara/Utility/Formats/OBJSaver.cpp | 1 - src/Nazara/Utility/VertexDeclaration.cpp | 14 ++++---------- 6 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 include/Nazara/Graphics/ParticleDeclaration.inl diff --git a/include/Nazara/Graphics/ParticleDeclaration.hpp b/include/Nazara/Graphics/ParticleDeclaration.hpp index 0edfba85f..278d25961 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.hpp +++ b/include/Nazara/Graphics/ParticleDeclaration.hpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace Nz { @@ -46,6 +47,7 @@ namespace Nz static ParticleDeclaration* Get(ParticleLayout layout); static bool IsTypeSupported(ComponentType type); + template static ParticleDeclarationRef New(Args&&... args); // Signals: NazaraSignal(OnParticleDeclarationRelease, const ParticleDeclaration* /*particleDeclaration*/); @@ -68,12 +70,14 @@ namespace Nz */ }; - Component m_components[ParticleComponent_Max + 1]; + std::array m_components; unsigned int m_stride; - static ParticleDeclaration s_declarations[ParticleLayout_Max + 1]; + static std::array s_declarations; static ParticleDeclarationLibrary::LibraryMap s_library; }; } +#include + #endif // NAZARA_PARTICLEDECLARATION_HPP diff --git a/include/Nazara/Graphics/ParticleDeclaration.inl b/include/Nazara/Graphics/ParticleDeclaration.inl new file mode 100644 index 000000000..27cd92a22 --- /dev/null +++ b/include/Nazara/Graphics/ParticleDeclaration.inl @@ -0,0 +1,18 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + template + ParticleDeclarationRef ParticleDeclaration::New(Args&&... args) + { + std::unique_ptr object(new ParticleDeclaration(std::forward(args)...)); + return object.release(); + } +} + +#include diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index f5dea6457..8c1e4b55a 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace Nz { @@ -69,14 +70,14 @@ namespace Nz */ }; - Component m_components[VertexComponent_Max+1]; + std::array m_components; std::size_t m_stride; - static VertexDeclaration s_declarations[VertexLayout_Max+1]; + static std::array s_declarations; static VertexDeclarationLibrary::LibraryMap s_library; }; } -#include +#include #endif // NAZARA_VERTEXDECLARATION_HPP diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index ecd09c752..62cf321ab 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -38,9 +38,9 @@ namespace Nz ParticleDeclaration::ParticleDeclaration(const ParticleDeclaration& declaration) : RefCounted(), + m_components(declaration.m_components), m_stride(declaration.m_stride) { - std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); } /*! @@ -205,7 +205,7 @@ namespace Nz ParticleDeclaration& ParticleDeclaration::operator=(const ParticleDeclaration& declaration) { - std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); + m_components = declaration.m_components; m_stride = declaration.m_stride; return *this; @@ -222,13 +222,7 @@ namespace Nz ParticleDeclaration* ParticleDeclaration::Get(ParticleLayout layout) { - #ifdef NAZARA_DEBUG - if (layout > ParticleLayout_Max) - { - NazaraError("Particle layout out of enum"); - return nullptr; - } - #endif + NazaraAssert(layout <= ParticleLayout_Max, "Particle layout out of enum"); return &s_declarations[layout]; } @@ -338,6 +332,6 @@ namespace Nz ParticleDeclarationLibrary::Uninitialize(); } - ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max + 1]; + std::array ParticleDeclaration::s_declarations; ParticleDeclarationLibrary::LibraryMap ParticleDeclaration::s_library; } diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 9a79638bc..baf54e44b 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -120,7 +120,6 @@ namespace Nz MTLParser::Material* material = mtlFormat.AddMaterial(name); - bool bValue; String strVal; if (matData.HasParameter(MaterialData::CustomDefined)) { diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 998f12f8b..945888406 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -22,9 +22,9 @@ namespace Nz VertexDeclaration::VertexDeclaration(const VertexDeclaration& declaration) : RefCounted(), + m_components(declaration.m_components), m_stride(declaration.m_stride) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(VertexComponent_Max+1)); } VertexDeclaration::~VertexDeclaration() @@ -133,7 +133,7 @@ namespace Nz VertexDeclaration& VertexDeclaration::operator=(const VertexDeclaration& declaration) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(VertexComponent_Max+1)); + m_components = declaration.m_components; m_stride = declaration.m_stride; return *this; @@ -141,13 +141,7 @@ namespace Nz VertexDeclaration* VertexDeclaration::Get(VertexLayout layout) { - #ifdef NAZARA_DEBUG - if (layout > VertexLayout_Max) - { - NazaraError("Vertex layout out of enum"); - return nullptr; - } - #endif + NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum"); return &s_declarations[layout]; } @@ -301,6 +295,6 @@ namespace Nz VertexDeclarationLibrary::Uninitialize(); } - VertexDeclaration VertexDeclaration::s_declarations[VertexLayout_Max+1]; + std::array VertexDeclaration::s_declarations; VertexDeclarationLibrary::LibraryMap VertexDeclaration::s_library; } From e03f281f435413d437ee6daed2f87fed59027782 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Aug 2016 13:46:42 +0200 Subject: [PATCH 131/235] SDK/StateMachine: Add GetCurrentState function Former-commit-id: 03f3085f56a0f547b21cd7bea75ff61541b0a8a5 [formerly 62183cea1c4c98a06a97de841f65bea108b9819d] [formerly ac9e462b7e2ccd7b5077dcdc315a97c42f5c2079 [formerly bf058e12205e1162a34dedabafe07390528edfb2]] Former-commit-id: 4fe43ca55388960e6506d978d5c82ed3cc696f14 [formerly 5084e4ffbe140a04855374d5f8c9bedbb6cc6b5a] Former-commit-id: c64604994a460fd8356bca46207b3e0d324b7ec4 --- SDK/include/NDK/StateMachine.hpp | 2 ++ SDK/include/NDK/StateMachine.inl | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/SDK/include/NDK/StateMachine.hpp b/SDK/include/NDK/StateMachine.hpp index 8e7ad2f64..c36464fea 100644 --- a/SDK/include/NDK/StateMachine.hpp +++ b/SDK/include/NDK/StateMachine.hpp @@ -23,6 +23,8 @@ namespace Ndk inline void ChangeState(std::shared_ptr state); + inline const std::shared_ptr& GetCurrentState() const; + inline bool Update(float elapsedTime); inline StateMachine& operator=(StateMachine&& fsm) = default; diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NDK/StateMachine.inl index fc4c7f787..7b5109ab5 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NDK/StateMachine.inl @@ -26,6 +26,11 @@ namespace Ndk m_nextState = std::move(state); } + inline const std::shared_ptr& StateMachine::GetCurrentState() const + { + return m_currentState; + } + inline bool StateMachine::Update(float elapsedTime) { if (m_nextState) From e4211b13a0da0e2cf3255e383a58273961e0ab9e Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Aug 2016 13:47:17 +0200 Subject: [PATCH 132/235] Graphics: Change ParticleStruct_Sprite position and velocity type from Vector2f to Vector3f Former-commit-id: 5a2e3b02fced8d8ef08a55edf6cc246d30ec2436 [formerly b628e1509d43b8e47d3fdddb5d4ea56e49ed1c07] [formerly f35249524a6f3079ea7cb042e552c10d902afefe [formerly 23cbf8238b8d7d610352c6b159543c86e4de9cbf]] Former-commit-id: 851b59b1079848fbdc5ddd4af59dbbe8c0b78fe7 [formerly 577851856f53246120e73e55ab3b848df6156078] Former-commit-id: 0b2af1ee989dd5184199b0caf6be9c39fa08bbf3 --- include/Nazara/Graphics/ParticleStruct.hpp | 4 ++-- src/Nazara/Graphics/ParticleDeclaration.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Graphics/ParticleStruct.hpp b/include/Nazara/Graphics/ParticleStruct.hpp index b68836935..72ce961b9 100644 --- a/include/Nazara/Graphics/ParticleStruct.hpp +++ b/include/Nazara/Graphics/ParticleStruct.hpp @@ -35,8 +35,8 @@ namespace Nz struct ParticleStruct_Sprite { Color color; - Vector2f position; - Vector2f velocity; + Vector3f position; + Vector3f velocity; UInt32 life; float rotation; }; diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index 62cf321ab..dff382d2c 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -308,9 +308,9 @@ namespace Nz declaration = &s_declarations[ParticleLayout_Sprite]; declaration->EnableComponent(ParticleComponent_Color, ComponentType_Color, NazaraOffsetOf(ParticleStruct_Sprite, color)); declaration->EnableComponent(ParticleComponent_Life, ComponentType_Int1, NazaraOffsetOf(ParticleStruct_Sprite, life)); - declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float2, NazaraOffsetOf(ParticleStruct_Sprite, position)); + declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Sprite, position)); declaration->EnableComponent(ParticleComponent_Rotation, ComponentType_Float1, NazaraOffsetOf(ParticleStruct_Sprite, rotation)); - declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float2, NazaraOffsetOf(ParticleStruct_Sprite, velocity)); + declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Sprite, velocity)); NazaraAssert(declaration->GetStride() == sizeof(ParticleStruct_Sprite), "Invalid stride for declaration ParticleLayout_Sprite"); } From 0c533d378fc1c22c124338fdd4a8746dbc472e16 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Aug 2016 01:12:06 +0200 Subject: [PATCH 133/235] Utility/MaterialData: Remove CustomDefined Former-commit-id: 3dc61fac4aa014daa8ccb2732bd3010c9b7a3013 [formerly 911c0c99570971d97e69d4a7d544ec1666432c26] [formerly cd5daaf8eb34d687da378f2531714d794b193a42 [formerly 5f58954832a234a14396585247dd18e1101f2918]] Former-commit-id: 22a69eb53fb4e400203bcbf0222a7b338de70ab1 [formerly 3f66b581a5b1c55c288a9226a7791981877ea68e] Former-commit-id: 921e4fe70ce1240e92c0c057ffe4a7678fc58a0b --- examples/MeshInfos/main.cpp | 7 +------ include/Nazara/Utility/MaterialData.hpp | 1 - plugins/Assimp/Plugin.cpp | 3 --- src/Nazara/Graphics/Formats/MeshLoader.cpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 1 - src/Nazara/Utility/Formats/OBJLoader.cpp | 2 -- src/Nazara/Utility/Formats/OBJSaver.cpp | 6 +++--- 7 files changed, 5 insertions(+), 17 deletions(-) diff --git a/examples/MeshInfos/main.cpp b/examples/MeshInfos/main.cpp index 73864abaa..e95a2a4c2 100644 --- a/examples/MeshInfos/main.cpp +++ b/examples/MeshInfos/main.cpp @@ -173,12 +173,7 @@ int main() Nz::String data; if (!matData.GetStringParameter(Nz::MaterialData::FilePath, &data)) - { - if (matData.HasParameter(Nz::MaterialData::CustomDefined)) - data = ""; - else - data = ""; - } + data = ""; std::cout << "\t" << (i+1) << ": " << data << std::endl; } diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index 66df97689..0c1e28cdd 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -23,7 +23,6 @@ namespace Nz static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail"; static constexpr const char* Blending = "MatBlending"; static constexpr const char* CullingSide = "MatCullingSide"; - static constexpr const char* CustomDefined = "MatCustomDefined"; static constexpr const char* ColorWrite = "MatColorWrite"; static constexpr const char* DepthBuffer = "MatDepthBuffer"; static constexpr const char* DepthFunc = "MatDepthfunc"; diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 312bbf48e..39b645c65 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -237,8 +237,6 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) aiColor4D color; if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS) { - matData.SetParameter(MaterialData::CustomDefined); - matData.SetParameter(colorKey, Color(static_cast(color.r * 255), static_cast(color.g * 255), static_cast(color.b * 255), static_cast(color.a * 255))); } }; @@ -249,7 +247,6 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) aiTextureMapMode mapMode[3]; if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS) { - matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length)); if (wrapKey) diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index 6769072bb..38f836e90 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -39,7 +39,7 @@ namespace Nz else NazaraWarning("Failed to load material from file " + String::Number(i)); } - else if (matData.HasParameter(MaterialData::CustomDefined)) + else { MaterialRef material = Material::New(); material->BuildFromParameters(matData, parameters.material); diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index c61dffd09..dde203482 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -102,7 +102,6 @@ namespace Nz stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(MaterialData::DiffuseTexturePath, baseDir + skin); mesh->SetMaterialData(i, std::move(matData)); diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 1b1835b2b..405c845ea 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -73,8 +73,6 @@ namespace Nz { ParameterList data; - data.SetParameter(MaterialData::CustomDefined); - UInt8 alphaValue = static_cast(mtlMat->alpha*255.f); Color ambientColor(mtlMat->ambient); diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index baf54e44b..a7a2cda0b 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -121,7 +121,9 @@ namespace Nz MTLParser::Material* material = mtlFormat.AddMaterial(name); String strVal; - if (matData.HasParameter(MaterialData::CustomDefined)) + if (matData.GetStringParameter(MaterialData::FilePath, &strVal)) + material->diffuseMap = strVal; + else { Color colorVal; float fValue; @@ -147,8 +149,6 @@ namespace Nz if (matData.GetStringParameter(MaterialData::SpecularTexturePath, &strVal)) material->specularMap = strVal; } - else if (matData.GetStringParameter(MaterialData::FilePath, &strVal)) - material->diffuseMap = strVal; } // Meshes From de22ad450138637fec315b9975a05213a4bdb09c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Aug 2016 01:12:17 +0200 Subject: [PATCH 134/235] Plugins/Assimp: Handle assimp errors Former-commit-id: c46023f21ac221190cc3dc4427ea84f93c96b033 [formerly c574f97c73ec25d67225203b6f3f700c93a9b171] [formerly 190c1447d21b9f76306e4f20b828556d01a2bb01 [formerly 6c945658cd34d1abca6f3ff347a829da705dc37f]] Former-commit-id: c13be95acf766003c2e01e2dfe50df9a3388d196 [formerly 0aaaeb93d55e4d66e94ea90851f3bed8caebcbbe] Former-commit-id: a37edd23f01db3f2c8d886603068ad0aa0c03627 --- plugins/Assimp/Plugin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 39b645c65..d1d0ace26 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -23,6 +23,7 @@ SOFTWARE. */ #include +#include #include #include #include @@ -130,6 +131,12 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties); aiReleasePropertyStore(properties); + if (!scene) + { + NazaraError("Assimp failed to import file: " + Nz::String(aiGetErrorString())); + return false; + } + std::set joints; bool animatedMesh = false; From 4fa9e5ab2975db9a6a812030461cdd29e2830f55 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 09:08:45 +0200 Subject: [PATCH 135/235] Core/String: Consider tabspace as separator Former-commit-id: a15a66ac8c23717734c961bc7aac9479d88621a7 [formerly df30d651398ea93b5e3964444191436da9f7726a] [formerly c75730b6abba7c231bc9410b3a92ae25c36c4aa8 [formerly 5bda01ba054858356c19727db1e83ab969ad0500]] Former-commit-id: 16b20194bf04ff5954a784bc4dcdd8d0a3a4c143 [formerly 102dffcf4982c8c1ec2b92d42f4e39e18cf96c7f] Former-commit-id: 97361a9cf56ac8347535f09dbc372b6287055445 --- src/Nazara/Core/String.cpp | 91 ++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 21831bcdf..fbd29c97c 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -23,6 +23,11 @@ namespace Nz { namespace Detail { + inline bool IsSpace(char32_t character) + { + return character == '\t' || Unicode::GetCategory(character) & Unicode::Category_Separator; + } + // This algorithm is inspired by the documentation of Qt inline std::size_t GetNewSize(std::size_t newSize) { @@ -1379,7 +1384,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1391,7 +1396,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1421,7 +1426,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1433,7 +1438,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1465,7 +1470,7 @@ namespace Nz if (ptr != m_sharedString->string.get()) { --ptr; - if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*ptr++)) continue; } @@ -1475,7 +1480,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr-m_sharedString->string.get(); else break; @@ -1503,7 +1508,7 @@ namespace Nz if (ptr != m_sharedString->string.get()) { --ptr; - if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*ptr++)) continue; } @@ -1513,7 +1518,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr-m_sharedString->string.get(); else break; @@ -1579,7 +1584,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1591,7 +1596,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1621,7 +1626,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1633,7 +1638,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1664,7 +1669,7 @@ namespace Nz if (Detail::ToLower(*ptr) == c) { char nextC = *(ptr + 1); - if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0) + if (nextC != '\0' && (Detail::IsSpace(nextC)) == 0) continue; const char* p = &string.m_sharedString->string[string.m_sharedString->size-1]; @@ -1675,7 +1680,7 @@ namespace Nz if (p == &string.m_sharedString->string[0]) { - if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) + if (ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr-1))) return ptr-m_sharedString->string.get(); else break; @@ -1695,7 +1700,7 @@ namespace Nz if (*ptr == string.m_sharedString->string[string.m_sharedString->size-1]) { char nextC = *(ptr + 1); - if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0) + if (nextC != '\0' && !Detail::IsSpace(nextC)) continue; const char* p = &string.m_sharedString->string[string.m_sharedString->size-1]; @@ -1706,7 +1711,7 @@ namespace Nz if (p == &string.m_sharedString->string[0]) { - if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator_Space) + if (ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr - 1))) return ptr-m_sharedString->string.get(); else break; @@ -1766,7 +1771,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1778,7 +1783,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -1806,7 +1811,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1818,7 +1823,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -1844,7 +1849,7 @@ namespace Nz { if (Detail::ToLower(*ptr) == c) { - if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator) == 0) + if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr - 1))) continue; const char* p = &string[1]; @@ -1853,7 +1858,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr - m_sharedString->string.get(); else break; @@ -1875,7 +1880,7 @@ namespace Nz { if (*ptr == string[0]) { - if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator) == 0) + if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr-1))) continue; const char* p = &string[1]; @@ -1884,7 +1889,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr - m_sharedString->string.get(); else break; @@ -1947,7 +1952,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1959,7 +1964,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -1987,7 +1992,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1999,7 +2004,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -2026,7 +2031,7 @@ namespace Nz { if (Detail::ToLower(*ptr) == c) { - if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) == 0) + if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr-1))) continue; const char* p = &string.m_sharedString->string[1]; @@ -2035,7 +2040,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator_Space) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr - m_sharedString->string.get(); else break; @@ -2056,7 +2061,7 @@ namespace Nz while ((ptr = std::strstr(ptr, string.GetConstBuffer())) != nullptr) { // If the word is really alone - if ((ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) && (*(ptr+m_sharedString->size) == '\0' || Unicode::GetCategory(*(ptr+m_sharedString->size)) & Unicode::Category_Separator_Space)) + if ((ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr-1))) && (*(ptr+m_sharedString->size) == '\0' || Detail::IsSpace(*(ptr+m_sharedString->size)))) return ptr - m_sharedString->string.get(); ptr++; @@ -2219,7 +2224,7 @@ namespace Nz utf8::unchecked::iterator it(ptr); do { - if (Unicode::GetCategory(*it) & Unicode::Category_Separator) + if (Detail::IsSpace(*it)) { endPos = static_cast(it.base() - m_sharedString->string.get() - 1); break; @@ -2231,7 +2236,7 @@ namespace Nz { do { - if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator) + if (Detail::IsSpace(*ptr)) { endPos = static_cast(ptr - m_sharedString->string.get() - 1); break; @@ -2265,7 +2270,7 @@ namespace Nz utf8::unchecked::iterator it(ptr); do { - if (Unicode::GetCategory(*it) & Unicode::Category_Separator) + if (Detail::IsSpace(*it)) inWord = false; else { @@ -2283,7 +2288,7 @@ namespace Nz { do { - if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator) + if (Detail::IsSpace(*ptr)) inWord = false; else { @@ -3414,7 +3419,7 @@ namespace Nz utf8::unchecked::iterator it(ptr); do { - if (Unicode::GetCategory(*it) & Unicode::Category_Separator) + if (Detail::IsSpace(*it)) { if (inword) { @@ -3435,7 +3440,7 @@ namespace Nz const char* limit = &m_sharedString->string[m_sharedString->size]; do { - if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator) + if (Detail::IsSpace(*ptr)) { if (inword) { @@ -4240,7 +4245,7 @@ namespace Nz utf8::unchecked::iterator it(m_sharedString->string.get()); do { - if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) + if (!Detail::IsSpace(*it)) break; } while (*++it); @@ -4255,7 +4260,7 @@ namespace Nz utf8::unchecked::iterator it(&m_sharedString->string[m_sharedString->size]); while ((it--).base() != m_sharedString->string.get()) { - if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) + if (!Detail::IsSpace(*it)) break; } @@ -4271,8 +4276,8 @@ namespace Nz { for (; startPos < m_sharedString->size; ++startPos) { - char c = m_sharedString->string[startPos]; - if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0) + char c = m_sharedString->string[startPos]; + if (!Detail::IsSpace(c)) break; } } @@ -4282,8 +4287,8 @@ namespace Nz { for (; endPos > 0; --endPos) { - char c = m_sharedString->string[endPos]; - if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0) + char c = m_sharedString->string[endPos]; + if (!Detail::IsSpace(c)) break; } } From d5c02bf43d058b0f13aebf54da9e3d7ab986109d Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 09:08:56 +0200 Subject: [PATCH 136/235] Graphics/Model: Add AddToRenderQueue(renderQueue, matrix, order) overload Former-commit-id: 84e4c22e9258c89e3b4f67fdd8427cbde6b0bc14 [formerly 7c51c3128ccc083461a5e356373c1ba77c038d3c] [formerly 49faee43ee1701bed909ae89cfc4d5c6a1df90a8 [formerly 81c535d074e9f5806ba01c39347770d08b8133a8]] Former-commit-id: a02d7cc0b59cad0d5b6875d14ff4068bc1e98b41 [formerly c4c7643fa3c420a337d6a637dfc92a2ed70e98b3] Former-commit-id: 8a4dbcacdf612510a4a999aec54be913896e3cf4 --- include/Nazara/Graphics/Model.hpp | 1 + include/Nazara/Graphics/Model.inl | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index f119072c8..b1755c7d8 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -45,6 +45,7 @@ namespace Nz virtual ~Model(); void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; + inline void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder = 0); Material* GetMaterial(const String& subMeshName) const; Material* GetMaterial(unsigned int matIndex) const; diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index a2b4c3967..243611fb5 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -7,6 +7,22 @@ namespace Nz { + /*! + * \brief Adds this model to a render queue, using user-specified transform matrix and render order + * + * This can be useful when drawing particles + * + * \param renderQueue Queue to be added + * \param transformMatrix Transform matrix to be used for rendering the model + * \param renderOrder Specify the renderqueue layer to be used + */ + inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder) + { + InstanceData instanceData(transformMatrix); + instanceData.renderOrder = renderOrder; + return AddToRenderQueue(renderQueue, instanceData); + } + /*! * \brief Creates a new Model from the arguments * \return A reference to the newly created model From 93725d90f5f07e9111a3dcb9861a8f23b025c451 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 09:09:14 +0200 Subject: [PATCH 137/235] Graphics/InstancedRenderable: Take a const reference to the matrix instead of a non-const one Former-commit-id: a2c84a7e8f1c3f91bb53e60eb95aec43c77bdce9 [formerly 966bf202d970596c9917805c3bb54dd04f84891f] [formerly 7372d35968df90baea6655c6439d545f454cd549 [formerly edc986573b5aa4e26805d484aa25dc98db1b99c1]] Former-commit-id: 0a81a7c0eb3bb9c3ca45060f1348f7d0e944c473 [formerly 60dda05c845ed52fc0d54976ad06f2261496b105] Former-commit-id: 6b3e85831f9631220837194f1f684f3350a93bc3 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 2 +- include/Nazara/Graphics/InstancedRenderable.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index a7ac3ebc2..92aeeed2f 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -66,7 +66,7 @@ namespace Ndk struct Renderable { - Renderable(Nz::Matrix4f& transformMatrix) : + Renderable(const Nz::Matrix4f& transformMatrix) : data(transformMatrix), dataUpdated(false) { diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index d1c07bf9b..d854a41d6 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -54,7 +54,7 @@ namespace Nz struct InstanceData { - InstanceData(Matrix4f& referenceMatrix) : + InstanceData(const Matrix4f& referenceMatrix) : transformMatrix(&referenceMatrix), flags(0) { @@ -75,7 +75,7 @@ namespace Nz std::vector data; BoundingVolumef volume; - Matrix4f* transformMatrix; + const Matrix4f* transformMatrix; UInt32 flags; int renderOrder; }; From d4d3a64b77a43ae7cefeabcc2079b84c82aa5e46 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 21:55:26 +0200 Subject: [PATCH 138/235] Graphics/AbstractRenderQueue: Remove AddBillboard method Former-commit-id: 3e11163f2d30ae5ab2d7ae2a7981fcae8ce237e9 [formerly 211b23847708041a3f2ce0db14e2b7ba2a3ce042] [formerly 0143c53ed84d58fcb33169dfbef413f012b4be5d [formerly 45cf1b6ff91cc33e845f211c1b88de01e9b520e9]] Former-commit-id: 7dc0ddb861e0a761804b21c41ee3fbf4e264e575 [formerly e589f05b875f1e1199395166014f84c0c82c1572] Former-commit-id: 6a26680c92d6e14a7b564410afe7d2ba40596686 --- .../Nazara/Graphics/AbstractRenderQueue.hpp | 1 - .../Nazara/Graphics/DeferredRenderQueue.hpp | 1 - include/Nazara/Graphics/DepthRenderQueue.hpp | 1 - .../Nazara/Graphics/ForwardRenderQueue.hpp | 1 - src/Nazara/Graphics/Billboard.cpp | 3 +- src/Nazara/Graphics/DeferredRenderQueue.cpp | 16 --------- src/Nazara/Graphics/DepthRenderQueue.cpp | 29 ---------------- src/Nazara/Graphics/ForwardRenderQueue.cpp | 34 ------------------- 8 files changed, 2 insertions(+), 84 deletions(-) diff --git a/include/Nazara/Graphics/AbstractRenderQueue.hpp b/include/Nazara/Graphics/AbstractRenderQueue.hpp index 50c6e0832..a245787ab 100644 --- a/include/Nazara/Graphics/AbstractRenderQueue.hpp +++ b/include/Nazara/Graphics/AbstractRenderQueue.hpp @@ -38,7 +38,6 @@ namespace Nz // Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards, // mais je n'ai pas d'autre solution tout aussi performante pour le moment... - virtual void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) = 0; virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) = 0; virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) = 0; virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) = 0; diff --git a/include/Nazara/Graphics/DeferredRenderQueue.hpp b/include/Nazara/Graphics/DeferredRenderQueue.hpp index fecd507be..6ac8e8c6c 100644 --- a/include/Nazara/Graphics/DeferredRenderQueue.hpp +++ b/include/Nazara/Graphics/DeferredRenderQueue.hpp @@ -29,7 +29,6 @@ namespace Nz DeferredRenderQueue(ForwardRenderQueue* forwardQueue); ~DeferredRenderQueue() = default; - void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) override; diff --git a/include/Nazara/Graphics/DepthRenderQueue.hpp b/include/Nazara/Graphics/DepthRenderQueue.hpp index 0b8a1fc5d..81ec921c0 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.hpp +++ b/include/Nazara/Graphics/DepthRenderQueue.hpp @@ -26,7 +26,6 @@ namespace Nz DepthRenderQueue(); ~DepthRenderQueue() = default; - void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) override; diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index c358e331c..7f88e80bf 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -31,7 +31,6 @@ namespace Nz ForwardRenderQueue() = default; ~ForwardRenderQueue() = default; - void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) override; diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index e06d3c921..17a2ad065 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -30,7 +30,8 @@ namespace Nz if (!m_material) return; - renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix->GetTranslation(), m_size, m_sinCos, m_color); + Nz::Vector3f position = instanceData.transformMatrix->GetTranslation(); + renderQueue->AddBillboards(instanceData.renderOrder, m_material, 1, &position, &m_size, &m_sinCos, &m_color); } /* diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 738e7b799..0b15c5a44 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -29,22 +29,6 @@ namespace Nz { } - /*! - * \brief Adds billboard to the queue - * - * \param renderOrder Order of rendering - * \param material Material of the billboard - * \param position Position of the billboard - * \param size Sizes of the billboard - * \param sinCos Rotation of the billboard - * \param color Color of the billboard - */ - - void DeferredRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) - { - m_forwardQueue->AddBillboard(renderOrder, material, position, size, sinCos, color); - } - /*! * \brief Adds multiple billboards to the queue * diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index dc31d2a45..c658fe7bd 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -28,35 +28,6 @@ namespace Nz //m_baseMaterial->SetFaceCulling(FaceSide_Front); } - /*! - * \brief Adds billboard to the queue - * - * \param renderOrder Order of rendering - * \param material Material of the billboard - * \param position Position of the billboard - * \param size Sizes of the billboard - * \param sinCos Rotation of the billboard - * \param color Color of the billboard - * - * \remark Produces a NazaraAssert if material is invalid - */ - - void DepthRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) - { - NazaraAssert(material, "Invalid material"); - NazaraUnused(renderOrder); - - if (!IsMaterialSuitable(material)) - return; - - if (material->HasDepthMaterial()) - material = material->GetDepthMaterial(); - else - material = m_baseMaterial; - - ForwardRenderQueue::AddBillboard(0, material, position, size, sinCos, color); - } - /*! * \brief Adds multiple billboards to the queue * diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 0f182a185..b9077e1b9 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -17,40 +17,6 @@ namespace Nz * \brief Graphics class that represents the rendering queue for forward rendering */ - /*! - * \brief Adds billboard to the queue - * - * \param renderOrder Order of rendering - * \param material Material of the billboard - * \param position Position of the billboard - * \param size Sizes of the billboard - * \param sinCos Rotation of the billboard - * \param color Color of the billboard - * - * \remark Produces a NazaraAssert if material is invalid - */ - - void ForwardRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) - { - NazaraAssert(material, "Invalid material"); - - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - billboardVector.push_back(BillboardData{color, position, size, sinCos}); - } - /*! * \brief Adds multiple billboards to the queue * From a7ce82c2c9bd52e1c0f6f3c874336a722fb831a1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 22:09:39 +0200 Subject: [PATCH 139/235] Graphics: Separate pipeline state from Material into a new class, MaterialPipeline This allows much more efficient batching, along with pipeline reusage and preparation for the Vulkan API Former-commit-id: 0b7e82d78d15e8b5e128f1856df3b28e6d7aaa44 [formerly 828c211f472b1fd2c839a0436ce43b4189a9f50a] [formerly 2e56582c87a8e2b0949ee946319655792e925f4a [formerly e6626b101b2c29f10e0025325a29463807504b3c]] Former-commit-id: 0cabdfb1e5e38c21e11407d19b8543578f0aa260 [formerly 91fbd0ab2fb10de6802962ec9e6e5819f0391b94] Former-commit-id: dc3fff253a97c2e78ce9c3500c81f66788e3480f --- SDK/src/NDK/Console.cpp | 4 +- include/Nazara/Graphics.hpp | 3 +- include/Nazara/Graphics/Billboard.inl | 3 +- .../Nazara/Graphics/DeferredRenderQueue.hpp | 29 +- include/Nazara/Graphics/DepthRenderQueue.inl | 2 +- .../Nazara/Graphics/DepthRenderTechnique.hpp | 1 + .../Nazara/Graphics/ForwardRenderQueue.hpp | 66 +- .../Graphics/ForwardRenderTechnique.hpp | 1 + include/Nazara/Graphics/Material.hpp | 64 +- include/Nazara/Graphics/Material.inl | 783 ++++++++++++------ include/Nazara/Graphics/MaterialPipeline.hpp | 95 +++ include/Nazara/Graphics/MaterialPipeline.inl | 143 ++++ include/Nazara/Graphics/Sprite.inl | 3 +- include/Nazara/Graphics/TextSprite.inl | 7 +- include/Nazara/Renderer/RenderPipeline.hpp | 42 + include/Nazara/Renderer/RenderPipeline.inl | 48 ++ include/Nazara/Renderer/RenderStates.hpp | 7 +- include/Nazara/Renderer/RenderStates.inl | 134 ++- src/Nazara/Graphics/DeferredGeometryPass.cpp | 192 +++-- src/Nazara/Graphics/DeferredRenderQueue.cpp | 129 +-- src/Nazara/Graphics/DepthRenderQueue.cpp | 4 +- src/Nazara/Graphics/DepthRenderTechnique.cpp | 502 ++++++----- src/Nazara/Graphics/ForwardRenderQueue.cpp | 223 +++-- .../Graphics/ForwardRenderTechnique.cpp | 632 +++++++------- src/Nazara/Graphics/Graphics.cpp | 26 +- src/Nazara/Graphics/Material.cpp | 302 ++----- src/Nazara/Graphics/MaterialPipeline.cpp | 168 ++++ .../Resources/Shaders/PhongLighting/core.frag | 36 +- .../Shaders/PhongLighting/core.frag.h | 2 +- .../Resources/Shaders/PhongLighting/core.vert | 18 +- .../Shaders/PhongLighting/core.vert.h | 2 +- 31 files changed, 2249 insertions(+), 1422 deletions(-) create mode 100644 include/Nazara/Graphics/MaterialPipeline.hpp create mode 100644 include/Nazara/Graphics/MaterialPipeline.inl create mode 100644 include/Nazara/Renderer/RenderPipeline.hpp create mode 100644 include/Nazara/Renderer/RenderPipeline.inl create mode 100644 src/Nazara/Graphics/MaterialPipeline.cpp diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 48ad10196..d157d7dbe 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -28,8 +28,8 @@ namespace Ndk m_characterSize(24) { Nz::MaterialRef backgroundMaterial = Nz::Material::New(); - backgroundMaterial->Enable(Nz::RendererParameter_Blend, true); - backgroundMaterial->Enable(Nz::RendererParameter_DepthBuffer, false); + backgroundMaterial->EnableBlending(true); + backgroundMaterial->EnableDepthBuffer(false); backgroundMaterial->SetDstBlend(Nz::BlendFunc_InvSrcAlpha); backgroundMaterial->SetSrcBlend(Nz::BlendFunc_SrcAlpha); diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 4809d9481..0195c123c 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 12 Jul 2016 at 17:44:43 +// This file was automatically generated on 20 Jul 2016 at 13:49:17 /* Nazara Engine - Graphics module @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 6c4a1e0a9..45c2ef918 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -121,8 +121,7 @@ namespace Nz inline void Billboard::SetDefaultMaterial() { MaterialRef material = Material::New(); - material->Enable(RendererParameter_FaceCulling, true); - material->EnableLighting(false); + material->EnableFaceCulling(true); SetMaterial(std::move(material)); } diff --git a/include/Nazara/Graphics/DeferredRenderQueue.hpp b/include/Nazara/Graphics/DeferredRenderQueue.hpp index 6ac8e8c6c..922174df6 100644 --- a/include/Nazara/Graphics/DeferredRenderQueue.hpp +++ b/include/Nazara/Graphics/DeferredRenderQueue.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -21,8 +21,6 @@ namespace Nz { - class ForwardRenderQueue; - class NAZARA_GRAPHICS_API DeferredRenderQueue : public AbstractRenderQueue { public: @@ -43,11 +41,6 @@ namespace Nz void Clear(bool fully = false) override; - struct MeshDataComparator - { - bool operator()(const MeshData& data1, const MeshData& data2) const; - }; - struct MeshInstanceEntry { NazaraSlot(IndexBuffer, OnIndexBufferRelease, indexBufferReleaseSlot); @@ -56,12 +49,7 @@ namespace Nz std::vector instances; }; - typedef std::map MeshInstanceContainer; - - struct BatchedModelMaterialComparator - { - bool operator()(const Material* mat1, const Material* mat2) const; - }; + typedef std::map MeshInstanceContainer; struct BatchedModelEntry { @@ -69,14 +57,21 @@ namespace Nz MeshInstanceContainer meshMap; bool enabled = false; - bool instancingEnabled = false; }; - typedef std::map ModelBatches; + typedef std::map MeshMaterialBatches; + + struct BatchedMaterialEntry + { + std::size_t maxInstanceCount = 0; + MeshMaterialBatches materialMap; + }; + + typedef std::map MeshPipelineBatches; struct Layer { - ModelBatches opaqueModels; + MeshPipelineBatches opaqueModels; unsigned int clearCount = 0; }; diff --git a/include/Nazara/Graphics/DepthRenderQueue.inl b/include/Nazara/Graphics/DepthRenderQueue.inl index a8a8da45e..8fbce164b 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.inl +++ b/include/Nazara/Graphics/DepthRenderQueue.inl @@ -18,7 +18,7 @@ namespace Nz { NazaraAssert(material, "Invalid material"); - return material->HasDepthMaterial() || (material->IsEnabled(RendererParameter_DepthBuffer) && material->IsEnabled(RendererParameter_DepthWrite) && material->IsShadowCastingEnabled()); + return material->HasDepthMaterial() || (material->IsDepthBufferEnabled() && material->IsDepthWriteEnabled() && material->IsShadowCastingEnabled()); } } diff --git a/include/Nazara/Graphics/DepthRenderTechnique.hpp b/include/Nazara/Graphics/DepthRenderTechnique.hpp index 42b7f6e0a..9d4ba601f 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.hpp +++ b/include/Nazara/Graphics/DepthRenderTechnique.hpp @@ -63,6 +63,7 @@ namespace Nz mutable std::unordered_map m_shaderUniforms; Buffer m_vertexBuffer; mutable DepthRenderQueue m_renderQueue; + Texture m_whiteTexture; VertexBuffer m_billboardPointBuffer; VertexBuffer m_spriteBuffer; diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index 7f88e80bf..99be2743e 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -47,6 +47,16 @@ namespace Nz void Sort(const AbstractViewer* viewer); + struct MaterialComparator + { + bool operator()(const Material* mat1, const Material* mat2) const; + }; + + struct MaterialPipelineComparator + { + bool operator()(const MaterialPipeline* pipeline1, const MaterialPipeline* pipeline2) const; + }; + /// Billboards struct BillboardData { @@ -56,11 +66,6 @@ namespace Nz Vector2f sinCos; }; - struct BatchedBillboardComparator - { - bool operator()(const Material* mat1, const Material* mat2) const; - }; - struct BatchedBillboardEntry { NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot); @@ -68,7 +73,15 @@ namespace Nz std::vector billboards; }; - typedef std::map BatchedBillboardContainer; + typedef std::map BatchedBillboardContainer; + + struct BatchedBillboardPipelineEntry + { + BatchedBillboardContainer materialMap; + bool enabled = false; + }; + + typedef std::map BillboardPipelineBatches; /// Sprites struct SpriteChain_XYZ_Color_UV @@ -84,22 +97,25 @@ namespace Nz std::vector spriteChains; }; - struct BatchedSpriteMaterialComparator - { - bool operator()(const Material* mat1, const Material* mat2); - }; - - typedef std::map BasicSpriteOverlayContainer; + typedef std::map SpriteOverlayBatches; struct BatchedBasicSpriteEntry { NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot); - BasicSpriteOverlayContainer overlayMap; + SpriteOverlayBatches overlayMap; bool enabled = false; }; - typedef std::map BasicSpriteBatches; + typedef std::map SpriteMaterialBatches; + + struct BatchedSpritePipelineEntry + { + SpriteMaterialBatches materialMap; + bool enabled = false; + }; + + typedef std::map SpritePipelineBatches; /// Meshes struct MeshDataComparator @@ -118,21 +134,23 @@ namespace Nz typedef std::map MeshInstanceContainer; - struct BatchedModelMaterialComparator - { - bool operator()(const Material* mat1, const Material* mat2) const; - }; - struct BatchedModelEntry { NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot); MeshInstanceContainer meshMap; bool enabled = false; - bool instancingEnabled = false; }; - typedef std::map ModelBatches; + typedef std::map MeshMaterialBatches; + + struct BatchedMaterialEntry + { + std::size_t maxInstanceCount = 0; + MeshMaterialBatches materialMap; + }; + + typedef std::map MeshPipelineBatches; struct TransparentModelData { @@ -146,9 +164,9 @@ namespace Nz struct Layer { - BatchedBillboardContainer billboards; - BasicSpriteBatches basicSprites; - ModelBatches opaqueModels; + BillboardPipelineBatches billboards; + SpritePipelineBatches basicSprites; + MeshPipelineBatches opaqueModels; TransparentModelContainer transparentModels; std::vector transparentModelData; std::vector otherDrawables; diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index 21b3a0899..5d82c4bf9 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -84,6 +84,7 @@ namespace Nz mutable std::vector m_lights; Buffer m_vertexBuffer; mutable ForwardRenderQueue m_renderQueue; + Texture m_whiteTexture; VertexBuffer m_billboardPointBuffer; VertexBuffer m_spriteBuffer; unsigned int m_maxLightPassPerObject; diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index b30c215c1..f7d15d6fe 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -58,20 +58,33 @@ namespace Nz public: inline Material(); + inline Material(const MaterialPipeline* pipeline); + inline Material(const MaterialPipelineInfo& pipelineInfo); + inline Material(const String& pipelineName); inline Material(const Material& material); inline ~Material(); - const Shader* Apply(UInt32 shaderFlags = 0, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const; + void Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const; void BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams = MaterialParams()); - inline void Enable(RendererParameter renderParameter, bool enable); + inline void Configure(const MaterialPipeline* pipeline); + inline void Configure(const MaterialPipelineInfo& pipelineInfo); + inline bool Configure(const String& pipelineName); + inline void EnableAlphaTest(bool alphaTest); + inline void EnableBlending(bool blending); + inline void EnableColorWrite(bool colorWrite); + inline void EnableDepthBuffer(bool depthBuffer); inline void EnableDepthSorting(bool depthSorting); - inline void EnableLighting(bool lighting); + inline void EnableDepthWrite(bool depthWrite); + inline void EnableFaceCulling(bool faceCulling); + inline void EnableScissorTest(bool scissorTest); inline void EnableShadowCasting(bool castShadows); inline void EnableShadowReceive(bool receiveShadows); - inline void EnableTransform(bool transform); + inline void EnableStencilTest(bool stencilTest); + + inline void EnsurePipelineUpdate() const; inline const TextureRef& GetAlphaMap() const; inline float GetAlphaThreshold() const; @@ -87,10 +100,12 @@ namespace Nz inline FaceSide GetFaceCulling() const; inline FaceFilling GetFaceFilling() const; inline const TextureRef& GetHeightMap() const; + inline float GetLineWidth() const; inline const TextureRef& GetNormalMap() const; - inline const RenderStates& GetRenderStates() const; + inline const MaterialPipeline* GetPipeline() const; + inline const MaterialPipelineInfo& GetPipelineInfo() const; + inline float GetPointSize() const; inline const UberShader* GetShader() const; - inline const UberShaderInstance* GetShaderInstance(UInt32 flags = ShaderFlags_None) const; inline float GetShininess() const; inline Color GetSpecularColor() const; inline const TextureRef& GetSpecularMap() const; @@ -107,12 +122,16 @@ namespace Nz inline bool HasSpecularMap() const; inline bool IsAlphaTestEnabled() const; + inline bool IsBlendingEnabled() const; + inline bool IsColorWriteEnabled() const; + inline bool IsDepthBufferEnabled() const; inline bool IsDepthSortingEnabled() const; - inline bool IsEnabled(RendererParameter renderParameter) const; - inline bool IsLightingEnabled() const; + inline bool IsDepthWriteEnabled() const; + inline bool IsFaceCullingEnabled() const; + inline bool IsScissorTestEnabled() const; + inline bool IsStencilTestEnabled() const; inline bool IsShadowCastingEnabled() const; inline bool IsShadowReceiveEnabled() const; - inline bool IsTransformEnabled() const; inline bool LoadFromFile(const String& filePath, const MaterialParams& params = MaterialParams()); inline bool LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params = MaterialParams()); @@ -139,9 +158,10 @@ namespace Nz inline void SetFaceFilling(FaceFilling filling); inline bool SetHeightMap(const String& textureName); inline void SetHeightMap(TextureRef textureName); + inline void SetLineWidth(float lineWidth); inline bool SetNormalMap(const String& textureName); inline void SetNormalMap(TextureRef textureName); - inline void SetRenderStates(const RenderStates& states); + inline void SetPointSize(float pointSize); inline void SetShader(UberShaderConstRef uberShader); inline bool SetShader(const String& uberShaderName); inline void SetShininess(float shininess); @@ -161,16 +181,9 @@ namespace Nz NazaraSignal(OnMaterialReset, const Material* /*material*/); private: - struct ShaderInstance - { - const Shader* shader; - UberShaderInstance* uberInstance = nullptr; - int uniforms[MaterialUniform_Max + 1]; - }; - void Copy(const Material& material); - void GenerateShader(UInt32 flags) const; - inline void InvalidateShaders(); + inline void InvalidatePipeline(); + inline void UpdatePipeline() const; static bool Initialize(); static void Uninitialize(); @@ -179,7 +192,8 @@ namespace Nz Color m_diffuseColor; Color m_specularColor; MaterialRef m_depthMaterial; //< Materialception - RenderStates m_states; + mutable const MaterialPipeline* m_pipeline; + MaterialPipelineInfo m_pipelineInfo; TextureSampler m_diffuseSampler; TextureSampler m_specularSampler; TextureRef m_alphaMap; @@ -188,14 +202,8 @@ namespace Nz TextureRef m_heightMap; TextureRef m_normalMap; TextureRef m_specularMap; - UberShaderConstRef m_uberShader; - mutable ShaderInstance m_shaders[ShaderFlags_Max + 1]; - bool m_alphaTestEnabled; - bool m_depthSortingEnabled; - bool m_lightingEnabled; + mutable bool m_pipelineUpdated; bool m_shadowCastingEnabled; - bool m_shadowReceiveEnabled; - bool m_transformEnabled; float m_alphaThreshold; float m_shininess; diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 6d5315640..cec965e6e 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -2,26 +2,74 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include namespace Nz { /*! - * \brief Constructs a Material object by default + * \brief Constructs a Material object with default states + * + * \see Reset */ - inline Material::Material() { Reset(); } + /*! + * \brief Constructs a Material object using a MaterialPipeline + * + * Calls Configure with the pipeline parameter + * + * \see Configure + */ + inline Material::Material(const MaterialPipeline* pipeline) + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + Reset(); + Configure(pipeline); + } + + /*! + * \brief Constructs a Material object using a MaterialPipelineInfo + * + * Calls Configure with the pipelineInfo parameter + * + * \see Configure + */ + inline Material::Material(const MaterialPipelineInfo& pipelineInfo) + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + Reset(); + Configure(pipelineInfo); + } + + /*! + * \brief Constructs a Material object using a MaterialPipeline name + * + * Calls Configure with the pipelineName parameter + * + * \remark In case of error (ie. named pipeline is not registered), throw an exception + * + * \see Configure + */ + inline Material::Material(const String& pipelineName) + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + Reset(); + Configure(pipelineName); + } + /*! * \brief Constructs a Material object by assignation * * \param material Material to copy into this */ - inline Material::Material(const Material& material) : RefCounted(), Resource(material) @@ -34,156 +82,325 @@ namespace Nz * * \see OnMaterialRelease */ - inline Material::~Material() { OnMaterialRelease(this); } /*! - * \brief Enables a renderer parameter + * \brief Reset material pipeline state * - * \param renderParameter Parameter for the rendering - * \param enable Should the parameter be enabled + * Sets the material pipeline * - * \remark Produces a NazaraAssert if enumeration is invalid + * \remark pipeline must be valid + * + * \see Configure */ - - inline void Material::Enable(RendererParameter renderParameter, bool enable) + inline void Material::Configure(const MaterialPipeline* pipeline) { - NazaraAssert(renderParameter <= RendererParameter_Max, "Renderer parameter out of enum"); + NazaraAssert(pipeline, "Invalid material pipeline"); - switch (renderParameter) - { - case RendererParameter_Blend: - m_states.blending = enable; - return; - - case RendererParameter_ColorWrite: - m_states.colorWrite = enable; - return; - - case RendererParameter_DepthBuffer: - m_states.depthBuffer = enable; - return; - - case RendererParameter_DepthWrite: - m_states.depthWrite = enable; - return; - - case RendererParameter_FaceCulling: - m_states.faceCulling = enable; - return; - - case RendererParameter_ScissorTest: - m_states.scissorTest = enable; - return; - - case RendererParameter_StencilTest: - m_states.stencilTest = enable; - return; - } + m_pipeline = pipeline; + m_pipelineInfo = m_pipeline->GetInfo(); + m_pipelineUpdated = true; } /*! - * \brief Enables the alpha test + * \brief Reset material pipeline state * - * \param alphaTest Should the parameter be enabled + * Sets the material pipeline using pipeline info * - * \remark Invalidates the shaders + * \remark pipeline must be valid + * + * \see Configure */ + inline void Material::Configure(const MaterialPipelineInfo& pipelineInfo) + { + m_pipelineInfo = pipelineInfo; + InvalidatePipeline(); + } + + /*! + * \brief Reset material pipeline state + * + * Sets the material pipeline using a name to lookup in the MaterialPipelineLibrary + * + * \return True if the material pipeline was found in the library + * + * \see Configure + */ + inline bool Material::Configure(const String& pipelineName) + { + MaterialPipelineRef pipeline = MaterialPipelineLibrary::Query(pipelineName); + if (!pipeline) + { + NazaraError("Failed to get pipeline \"" + pipelineName + "\""); + return false; + } + + Configure(std::move(pipeline)); + return true; + } + + /*! + * \brief Enable/Disable alpha test for this material + * + * When enabled, all objects using this material will be rendered using alpha testing, + * rejecting pixels if their alpha component is under a defined threshold. + * This allows some kind of transparency with a much cheaper cost as it doesn't prevent any optimization (as deferred rendering or batching). + * + * \param alphaTest Defines if this material will use alpha testing + * + * \remark Invalidates the pipeline + * + * \see IsAlphaTestEnabled + * \see SetAlphaThreshold + */ inline void Material::EnableAlphaTest(bool alphaTest) { - m_alphaTestEnabled = alphaTest; + m_pipelineInfo.alphaTest = alphaTest; - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Enables the depth sorting + * \brief Enable/Disable blending for this material * - * \param depthSorting Should the parameter be enabled + * When enabled, all objects using this material will be rendered using blending, obeying the dstBlend and srcBlend parameters + * This is useful with translucent objects, but will reduces performance as it prevents some optimizations (as deferred rendering) + * + * \param blending Defines if this material will use blending + * + * \remark Invalidates the pipeline + * + * \see IsBlendingEnabled + * \see SetDstBlend + * \see SetSrcBlend */ + inline void Material::EnableBlending(bool blending) + { + m_pipelineInfo.blending = blending; + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable color writing for this material + * + * \param colorWrite Defines if this material will use color writing + * + * \remark Invalidates the pipeline + * + * \see IsColorWritingEnabled + */ + inline void Material::EnableColorWrite(bool colorWrite) + { + m_pipelineInfo.colorWrite = colorWrite; + + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable depth buffer for this material + * + * When enabled, all objects using this material will be rendered using a depth buffer, if the RenderTarget has one. + * This will enable Depth Test, preventing further fragments to render on top of closer ones. + * + * This parameter is required for depth writing. + * + * In order to enable depth writing without enabling depth test, set the depth comparison function to RendererComparison_Never + * + * \param depthBuffer Defines if this material will use depth buffer + * + * \remark Invalidates the pipeline + * + * \see EnableDepthWrite + * \see IsDepthBufferEnabled + * \see SetDepthFunc + */ + inline void Material::EnableDepthBuffer(bool depthBuffer) + { + m_pipelineInfo.depthBuffer = depthBuffer; + + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable depth sorting for this material + * + * When enabled, all objects using this material will be rendered far from near + * This is useful with translucent objects, but will reduces performance as it breaks batching + * + * \param depthSorting Defines if this material will use depth sorting + * + * \remark Depth sorting may not be perfect (may be object-sorting instead of triangle-sorting) + * \remark Invalidates the pipeline + * + * \see IsDepthSortingEnabled + */ inline void Material::EnableDepthSorting(bool depthSorting) { - // Has no influence on shaders - m_depthSortingEnabled = depthSorting; + m_pipelineInfo.depthSorting = depthSorting; + + InvalidatePipeline(); } /*! - * \brief Enables the lighting + * \brief Enable/Disable depth writing for this material * - * \param lighting Should the parameter be enabled + * When enabled, and if depth buffer is enabled and present, all fragments generated with this material will write + * to the depth buffer if they pass depth test. * - * \remark Invalidates the shaders + * This is usually disabled with translucent objects, as depth test is wanted to prevent them from rendering on top of opaque objects but + * not depth writing (which could make other translucent fragments to fail depth test) + * + * \param depthBuffer Defines if this material will use depth write + * + * \remark Invalidates the pipeline + * + * \see EnableDepthBuffer + * \see IsDepthWriteEnabled */ - - inline void Material::EnableLighting(bool lighting) + inline void Material::EnableDepthWrite(bool depthWrite) { - m_lightingEnabled = lighting; + m_pipelineInfo.depthWrite = depthWrite; - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Enables the shadow casting + * \brief Enable/Disable face culling for this material * - * \param castShadows Should shadow casting be enabled + * When enabled, the material prevents front and/or back faces from rendering. + * This is commonly used as an optimization to prevent processing of hidden faces by the rendering device. + * + * Use SetFaceCulling to control which side will be eliminated. + * + * \param faceCulling Defines if this material will use face culling + * + * \remark Invalidates the pipeline + * + * \see IsFaceCullingEnabled + * \see SetFaceCulling */ + inline void Material::EnableFaceCulling(bool faceCulling) + { + m_pipelineInfo.faceCulling = faceCulling; + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable scissor test for this material + * + * When enabled, the material prevents fragments out of the scissor box to be rendered. + * This can be useful with GUI, where widgets must not be rendered outside of their parent rendering area. + * + * \param scissorTest Defines if this material will use scissor test + * + * \remark Invalidates the pipeline + * + * \see IsScissorTestEnabled + */ + inline void Material::EnableScissorTest(bool scissorTest) + { + m_pipelineInfo.scissorTest = scissorTest; + + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable shadow casting for this material + * + * When enabled, all objects using this material will be allowed to cast shadows upon any objects using a material with shadow receiving enabled. + * The depth material replaces this one when rendering shadows. + * + * \param castShadows Defines if this material will be allowed to cast shadows + * + * \remark Does not invalidate the pipeline + * + * \see EnableShadowReceive + * \see IsShadowCastingEnabled + * \see SetDepthMaterial + */ inline void Material::EnableShadowCasting(bool castShadows) { - // Has no influence on shaders + // Has no influence on pipeline m_shadowCastingEnabled = castShadows; } /*! - * \brief Enables the shadow on receiving object + * \brief Enable/Disable shadow receiving for this material * - * \param receiveShadow Should receiving object have shadows enabled + * When enabled, all objects using this material will be allowed to be casted shadows upon themselves + * Disabling this can be helpful to prevent some rendering artifacts (especially with translucent objects) * - * \remark Invalidates the shaders + * \param receiveShadows Defines if this material will be able to receive shadows + * + * \remark Invalidates the pipeline + * + * \see IsShadowReceiveEnabled */ - inline void Material::EnableShadowReceive(bool receiveShadows) { - m_shadowReceiveEnabled = receiveShadows; + m_pipelineInfo.shadowReceive = receiveShadows; - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Enables the transformation + * \brief Enable/Disable stencil test for this material * - * \param transform Should the parameter be enabled + * When enabled, all fragments must pass the stencil test to be rendered. * - * \remark Invalidates the shaders + * \param scissorTest Defines if this material will use stencil test + * + * \remark Invalidates the pipeline + * + * \see IsStencilTestEnabled */ - - inline void Material::EnableTransform(bool transform) + inline void Material::EnableStencilTest(bool stencilTest) { - m_transformEnabled = transform; + m_pipelineInfo.stencilTest = stencilTest; - InvalidateShaders(); + InvalidatePipeline(); + } + + /*! + * \brief Ensures the pipeline gets updated + * + * When the pipeline gets invalidated, it's not updated until required (per example by calling GetPipeline). + * Using this function forces the pipeline update, making GetPipeline thread-safe as long as the pipeline does not get invalidated. + * + * \see GetPipeline + */ + inline void Material::EnsurePipelineUpdate() const + { + if (!m_pipelineUpdated) + UpdatePipeline(); } /*! * \brief Gets the alpha map + * * \return Constant reference to the current texture + * + * \see SetAlphaMap */ - inline const TextureRef& Material::GetAlphaMap() const { return m_alphaMap; } /*! - * \brief Gets the alpha threshold - * \return The threshold value for the alpha + * \brief Gets the alpha test threshold + * + * \return The threshold value for the alpha test + * + * \see EnableAlphaTest + * \see SetAlphaThreshold */ - inline float Material::GetAlphaThreshold() const { return m_alphaThreshold; @@ -191,9 +408,11 @@ namespace Nz /*! * \brief Gets the ambient color + * * \return Ambient color + * + * \see SetAmbientColor */ - inline Color Material::GetAmbientColor() const { return m_ambientColor; @@ -201,19 +420,24 @@ namespace Nz /*! * \brief Gets the function to compare depth + * * \return Function comparing the depth of two materials + * + * \see EnableDepthTest + * \see SetAmbientColor */ - inline RendererComparison Material::GetDepthFunc() const { - return m_states.depthFunc; + return m_pipelineInfo.depthFunc; } /*! * \brief Gets the depth material + * * \return Constant reference to the depth material + * + * \see EnableShadowCasting */ - inline const MaterialRef& Material::GetDepthMaterial() const { return m_depthMaterial; @@ -221,9 +445,11 @@ namespace Nz /*! * \brief Gets the diffuse color + * * \return Diffuse color + * + * \see SetDiffuseColor */ - inline Color Material::GetDiffuseColor() const { return m_diffuseColor; @@ -231,9 +457,11 @@ namespace Nz /*! * \brief Gets the diffuse sampler + * * \return Reference to the current texture sampler for the diffuse + * + * \see SetDiffuseSampler */ - inline TextureSampler& Material::GetDiffuseSampler() { return m_diffuseSampler; @@ -241,9 +469,11 @@ namespace Nz /*! * \brief Gets the diffuse sampler + * * \return Constant reference to the current texture sampler for the diffuse + * + * \see SetDiffuseSampler */ - inline const TextureSampler& Material::GetDiffuseSampler() const { return m_diffuseSampler; @@ -251,9 +481,11 @@ namespace Nz /*! * \brief Gets the diffuse map + * * \return Constant reference to the texture + * + * \see SetDiffuseMap */ - const TextureRef& Material::GetDiffuseMap() const { return m_diffuseMap; @@ -261,19 +493,23 @@ namespace Nz /*! * \brief Gets the dst in blend + * * \return Function for dst blending + * + * \see SetDstBlend */ - inline BlendFunc Material::GetDstBlend() const { - return m_states.dstBlend; + return m_pipelineInfo.dstBlend; } /*! * \brief Gets the emissive map + * * \return Constant reference to the texture + * + * \see SetEmissiveMap */ - inline const TextureRef& Material::GetEmissiveMap() const { return m_emissiveMap; @@ -281,34 +517,43 @@ namespace Nz /*! * \brief Gets the face culling + * * \return Current face culling side + * + * \see SetFaceCulling */ - inline FaceSide Material::GetFaceCulling() const { - return m_states.cullingSide; + return m_pipelineInfo.cullingSide; } /*! * \brief Gets the face filling * \return Current face filling */ - inline FaceFilling Material::GetFaceFilling() const { - return m_states.faceFilling; + return m_pipelineInfo.faceFilling; } /*! * \brief Gets the height map * \return Constant reference to the texture */ - inline const TextureRef& Material::GetHeightMap() const { return m_heightMap; } + /*! + * \brief Gets the line width of this material + * \return Line width + */ + inline float Material::GetLineWidth() const + { + return m_pipelineInfo.lineWidth; + } + /*! * \brief Gets the normal map * \return Constant reference to the texture @@ -323,43 +568,44 @@ namespace Nz * \brief Gets the render states * \return Constant reference to the render states */ - - inline const RenderStates& Material::GetRenderStates() const + inline const MaterialPipeline* Material::GetPipeline() const { - return m_states; + EnsurePipelineUpdate(); + + return m_pipeline; } /*! - * \brief Gets the shader of this material - * \return Constant pointer to the ubershader used + * \brief Gets the pipeline informations + * \return Constant reference to the pipeline info */ + inline const MaterialPipelineInfo& Material::GetPipelineInfo() const + { + return m_pipelineInfo; + } + /*! + * \brief Gets the point size of this material + * \return Point size + */ + inline float Material::GetPointSize() const + { + return m_pipelineInfo.pointSize; + } + + /*! + * \brief Gets the über-shader used by this material + * \return Constant pointer to the über-shader used + */ inline const UberShader* Material::GetShader() const { - return m_uberShader; - } - - /*! - * \brief Gets the shader instance based on the flag - * \return Constant pointer to the ubershader instance - * - * \param flags Flag of the shader - */ - - inline const UberShaderInstance* Material::GetShaderInstance(UInt32 flags) const - { - const ShaderInstance& instance = m_shaders[flags]; - if (!instance.uberInstance) - GenerateShader(flags); - - return instance.uberInstance; + return m_pipelineInfo.uberShader; } /*! * \brief Gets the shininess * \return Current shininess */ - inline float Material::GetShininess() const { return m_shininess; @@ -369,7 +615,6 @@ namespace Nz * \brief Gets the specular color * \return Specular color */ - inline Color Material::GetSpecularColor() const { return m_specularColor; @@ -379,7 +624,6 @@ namespace Nz * \brief Gets the specular map * \return Constant reference to the texture */ - inline const TextureRef& Material::GetSpecularMap() const { return m_specularMap; @@ -389,7 +633,6 @@ namespace Nz * \brief Gets the specular sampler * \return Reference to the current texture sampler for the specular */ - inline TextureSampler& Material::GetSpecularSampler() { return m_specularSampler; @@ -399,7 +642,6 @@ namespace Nz * \brief Gets the specular sampler * \return Constant reference to the current texture sampler for the specular */ - inline const TextureSampler& Material::GetSpecularSampler() const { return m_specularSampler; @@ -409,17 +651,15 @@ namespace Nz * \brief Gets the src in blend * \return Function for src blending */ - inline BlendFunc Material::GetSrcBlend() const { - return m_states.srcBlend; + return m_pipelineInfo.srcBlend; } /*! * \brief Checks whether this material has an alpha map * \return true If it is the case */ - inline bool Material::HasAlphaMap() const { return m_alphaMap.IsValid(); @@ -429,7 +669,6 @@ namespace Nz * \brief Checks whether this material has a depth material * \return true If it is the case */ - inline bool Material::HasDepthMaterial() const { return m_depthMaterial.IsValid(); @@ -439,7 +678,6 @@ namespace Nz * \brief Checks whether this material has a diffuse map * \return true If it is the case */ - inline bool Material::HasDiffuseMap() const { return m_diffuseMap.IsValid(); @@ -449,7 +687,6 @@ namespace Nz * \brief Checks whether this material has a emissive map * \return true If it is the case */ - inline bool Material::HasEmissiveMap() const { return m_emissiveMap.IsValid(); @@ -459,7 +696,6 @@ namespace Nz * \brief Checks whether this material has a height map * \return true If it is the case */ - inline bool Material::HasHeightMap() const { return m_heightMap.IsValid(); @@ -469,7 +705,6 @@ namespace Nz * \brief Checks whether this material has a normal map * \return true If it is the case */ - inline bool Material::HasNormalMap() const { return m_normalMap.IsValid(); @@ -479,7 +714,6 @@ namespace Nz * \brief Checks whether this material has a specular map * \return true If it is the case */ - inline bool Material::HasSpecularMap() const { return m_specularMap.IsValid(); @@ -489,78 +723,87 @@ namespace Nz * \brief Checks whether this material has alpha test enabled * \return true If it is the case */ - inline bool Material::IsAlphaTestEnabled() const { - return m_alphaTestEnabled; + return m_pipelineInfo.alphaTest; + } + + /*! + * \brief Checks whether this material has blending enabled + * \return true If it is the case + */ + inline bool Material::IsBlendingEnabled() const + { + return m_pipelineInfo.blending; + } + + /*! + * \brief Checks whether this material has color write enabled + * \return true If it is the case + */ + inline bool Material::IsColorWriteEnabled() const + { + return m_pipelineInfo.colorWrite; + } + + /*! + * \brief Checks whether this material has depth buffer enabled + * \return true If it is the case + */ + inline bool Material::IsDepthBufferEnabled() const + { + return m_pipelineInfo.depthBuffer; } /*! * \brief Checks whether this material has depth sorting enabled * \return true If it is the case */ - inline bool Material::IsDepthSortingEnabled() const { - return m_depthSortingEnabled; + return m_pipelineInfo.depthSorting; } /*! - * \brief Checks whether this material has the render parameter enabled + * \brief Checks whether this material has depth writing enabled * \return true If it is the case - * - * \param parameter Parameter for the rendering - * - * \remark Produces a NazaraAssert if enumeration is invalid */ - - inline bool Material::IsEnabled(RendererParameter parameter) const + inline bool Material::IsDepthWriteEnabled() const { - NazaraAssert(parameter <= RendererParameter_Max, "Renderer parameter out of enum"); - - switch (parameter) - { - case RendererParameter_Blend: - return m_states.blending; - - case RendererParameter_ColorWrite: - return m_states.colorWrite; - - case RendererParameter_DepthBuffer: - return m_states.depthBuffer; - - case RendererParameter_DepthWrite: - return m_states.depthWrite; - - case RendererParameter_FaceCulling: - return m_states.faceCulling; - - case RendererParameter_ScissorTest: - return m_states.scissorTest; - - case RendererParameter_StencilTest: - return m_states.stencilTest; - } - - NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); - return false; + return m_pipelineInfo.depthWrite; } /*! - * \brief Checks whether this material has lightning enabled + * \brief Checks whether this material has face culling enabled * \return true If it is the case */ - - inline bool Material::IsLightingEnabled() const + inline bool Material::IsFaceCullingEnabled() const { - return m_lightingEnabled; + return m_pipelineInfo.faceCulling; + } + + /*! + * \brief Checks whether this material has scissor test enabled + * \return true If it is the case + */ + inline bool Material::IsScissorTestEnabled() const + { + return m_pipelineInfo.scissorTest; + } + + /*! + * \brief Checks whether this material has stencil test enabled + * \return true If it is the case + */ + inline bool Material::IsStencilTestEnabled() const + { + return m_pipelineInfo.stencilTest; } /*! * \brief Checks whether this material cast shadow * \return true If it is the case */ - inline bool Material::IsShadowCastingEnabled() const { return m_shadowCastingEnabled; @@ -570,20 +813,9 @@ namespace Nz * \brief Checks whether this material receive shadow * \return true If it is the case */ - inline bool Material::IsShadowReceiveEnabled() const { - return m_shadowReceiveEnabled; - } - - /*! - * \brief Checks whether this material has transformation enabled - * \return true If it is the case - */ - - inline bool Material::IsTransformEnabled() const - { - return m_transformEnabled; + return m_pipelineInfo.shadowReceive; } /*! @@ -593,7 +825,6 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the material */ - inline bool Material::LoadFromFile(const String& filePath, const MaterialParams& params) { return MaterialLoader::LoadFromFile(this, filePath, params); @@ -607,7 +838,6 @@ namespace Nz * \param size Size of the memory * \param params Parameters for the material */ - inline bool Material::LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params) { return MaterialLoader::LoadFromMemory(this, data, size, params); @@ -620,7 +850,6 @@ namespace Nz * \param stream Stream to the material * \param params Parameters for the material */ - inline bool Material::LoadFromStream(Stream& stream, const MaterialParams& params) { return MaterialLoader::LoadFromStream(this, stream, params); @@ -632,7 +861,6 @@ namespace Nz * * \param textureName Named texture */ - inline bool Material::SetAlphaMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -656,14 +884,14 @@ namespace Nz * * \param alphaMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline */ - inline void Material::SetAlphaMap(TextureRef alphaMap) { m_alphaMap = std::move(alphaMap); + m_pipelineInfo.hasAlphaMap = m_alphaMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! @@ -671,7 +899,6 @@ namespace Nz * * \param alphaThreshold Threshold for the alpha */ - inline void Material::SetAlphaThreshold(float alphaThreshold) { m_alphaThreshold = alphaThreshold; @@ -682,7 +909,6 @@ namespace Nz * * \param ambient Color for ambient */ - inline void Material::SetAmbientColor(const Color& ambient) { m_ambientColor = ambient; @@ -692,11 +918,14 @@ namespace Nz * \brief Sets the depth functor * * \param depthFunc + * + * \remark Invalidates the pipeline */ - inline void Material::SetDepthFunc(RendererComparison depthFunc) { - m_states.depthFunc = depthFunc; + m_pipelineInfo.depthFunc = depthFunc; + + InvalidatePipeline(); } /*! @@ -705,7 +934,6 @@ namespace Nz * * \param depthMaterial Material for depth */ - inline void Material::SetDepthMaterial(MaterialRef depthMaterial) { m_depthMaterial = std::move(depthMaterial); @@ -716,7 +944,6 @@ namespace Nz * * \param diffuse Color for diffuse */ - inline void Material::SetDiffuseColor(const Color& diffuse) { m_diffuseColor = diffuse; @@ -727,8 +954,9 @@ namespace Nz * \return true If successful * * \param textureName Named texture + * + * \remark Invalidates the pipeline */ - inline bool Material::SetDiffuseMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -752,14 +980,14 @@ namespace Nz * * \param diffuseMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline */ - inline void Material::SetDiffuseMap(TextureRef diffuseMap) { m_diffuseMap = std::move(diffuseMap); + m_pipelineInfo.hasDiffuseMap = m_diffuseMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! @@ -777,11 +1005,14 @@ namespace Nz * \brief Sets the dst in blend * * \param func Function for dst blending + * + * \remark Invalidates the pipeline */ - inline void Material::SetDstBlend(BlendFunc func) { - m_states.dstBlend = func; + m_pipelineInfo.dstBlend = func; + + InvalidatePipeline(); } /*! @@ -789,8 +1020,9 @@ namespace Nz * \return true If successful * * \param textureName Named texture + * + * \see GetEmissiveMap */ - inline bool Material::SetEmissiveMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -814,45 +1046,52 @@ namespace Nz * * \param emissiveMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline */ - inline void Material::SetEmissiveMap(TextureRef emissiveMap) { m_emissiveMap = std::move(emissiveMap); + m_pipelineInfo.hasEmissiveMap = m_emissiveMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! * \brief Sets the face culling * * \param faceSide Face to cull + * + * \remark Invalidates the pipeline */ - inline void Material::SetFaceCulling(FaceSide faceSide) { - m_states.cullingSide = faceSide; + m_pipelineInfo.cullingSide = faceSide; + + InvalidatePipeline(); } /*! * \brief Sets the face filling * * \param filling Face to fill + * + * \remark Invalidates the pipeline */ - inline void Material::SetFaceFilling(FaceFilling filling) { - m_states.faceFilling = filling; + m_pipelineInfo.faceFilling = filling; + + InvalidatePipeline(); } /*! - * \brief Sets the height map by name + * \brief Sets the height map by path or name * \return true If successful * * \param textureName Named texture + * + * \see GetHeightMap */ - inline bool Material::SetHeightMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -872,27 +1111,49 @@ namespace Nz /*! * \brief Sets the height map with a reference to a texture - * \return true If successful * * \param heightMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetHeightMap */ - inline void Material::SetHeightMap(TextureRef heightMap) { m_heightMap = std::move(heightMap); + m_pipelineInfo.hasHeightMap = m_heightMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Sets the normal map by name + * \brief Sets the line width for this material + * + * This parameter is used when rendering lines, to define the width (in pixels) the line will take on the framebuffer + * + * \param lineWidth Width of the line + * + * \remark Invalidates the pipeline + * + * \see GetLineWidth + */ + inline void Material::SetLineWidth(float lineWidth) + { + m_pipelineInfo.lineWidth = lineWidth; + + InvalidatePipeline(); + } + + /*! + * \brief Sets the normal map by path or name * \return true If successful * * \param textureName Named texture + * + * \remark Invalidates the pipeline + * + * \see GetNormalMap */ - inline bool Material::SetNormalMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -916,25 +1177,34 @@ namespace Nz * * \param normalMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetNormalMap */ - inline void Material::SetNormalMap(TextureRef normalMap) { m_normalMap = std::move(normalMap); + m_pipelineInfo.hasNormalMap = m_normalMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Sets the render states + * \brief Sets the point size for this material * - * \param states States for the rendering + * This parameter is used when rendering points, to define the size (in pixels) the point will take on the framebuffer + * + * \param pointSize Size of the point + * + * \remark Invalidates the pipeline + * + * \see GetPointSize */ - - inline void Material::SetRenderStates(const RenderStates& states) + inline void Material::SetPointSize(float pointSize) { - m_states = states; + m_pipelineInfo.pointSize = pointSize; + + InvalidatePipeline(); } /*! @@ -942,14 +1212,15 @@ namespace Nz * * \param uberShader Uber shader to apply * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetShader */ - inline void Material::SetShader(UberShaderConstRef uberShader) { - m_uberShader = std::move(uberShader); + m_pipelineInfo.uberShader = std::move(uberShader); - InvalidateShaders(); + InvalidatePipeline(); } /*! @@ -958,7 +1229,6 @@ namespace Nz * * \param uberShaderName Named shader */ - inline bool Material::SetShader(const String& uberShaderName) { UberShaderConstRef uberShader = UberShaderLibrary::Get(uberShaderName); @@ -974,7 +1244,6 @@ namespace Nz * * \param shininess Value of the shininess */ - inline void Material::SetShininess(float shininess) { m_shininess = shininess; @@ -985,7 +1254,6 @@ namespace Nz * * \param specular Color */ - inline void Material::SetSpecularColor(const Color& specular) { m_specularColor = specular; @@ -996,8 +1264,9 @@ namespace Nz * \return true If successful * * \param textureName Named texture + * + * \remark Invalidates the pipeline */ - inline bool Material::SetSpecularMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -1021,22 +1290,25 @@ namespace Nz * * \param specularMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetSpecularMap */ - inline void Material::SetSpecularMap(TextureRef specularMap) { m_specularMap = std::move(specularMap); + m_pipelineInfo.hasSpecularMap = m_specularMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! * \brief Sets the specular sampler * * \param sampler Specular sample + * + * \see GetSpecularSampler */ - inline void Material::SetSpecularSampler(const TextureSampler& sampler) { m_specularSampler = sampler; @@ -1046,11 +1318,16 @@ namespace Nz * \brief Sets the src in blend * * \param func Function for src blending + * + * \remark Invalidates the pipeline + * + * \see GetSrcBlend */ - inline void Material::SetSrcBlend(BlendFunc func) { - m_states.srcBlend = func; + m_pipelineInfo.srcBlend = func; + + InvalidatePipeline(); } /*! @@ -1059,7 +1336,6 @@ namespace Nz * * \param material The other Material */ - inline Material& Material::operator=(const Material& material) { Resource::operator=(material); @@ -1070,22 +1346,25 @@ namespace Nz /*! * \brief Gets the default material + * * \return Reference to the default material + * + * \remark This material should NOT be modified as it would affect all objects using it */ - inline MaterialRef Material::GetDefault() { return s_defaultMaterial; } - /*! - * \brief Invalidates the shaders - */ - - inline void Material::InvalidateShaders() + inline void Material::InvalidatePipeline() { - for (ShaderInstance& instance : m_shaders) - instance.uberInstance = nullptr; + m_pipelineUpdated = false; + } + + inline void Material::UpdatePipeline() const + { + m_pipeline = MaterialPipeline::GetPipeline(m_pipelineInfo); + m_pipelineUpdated = true; } /*! @@ -1094,7 +1373,6 @@ namespace Nz * * \param args Arguments for the material */ - template MaterialRef Material::New(Args&&... args) { @@ -1106,3 +1384,4 @@ namespace Nz } #include +#include "Material.hpp" diff --git a/include/Nazara/Graphics/MaterialPipeline.hpp b/include/Nazara/Graphics/MaterialPipeline.hpp new file mode 100644 index 000000000..cf64d5e40 --- /dev/null +++ b/include/Nazara/Graphics/MaterialPipeline.hpp @@ -0,0 +1,95 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_MATERIALPIPELINE_HPP +#define NAZARA_MATERIALPIPELINE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + struct MaterialPipelineInfo : RenderStates + { + bool alphaTest = false; + bool depthSorting = false; + bool hasAlphaMap = false; + bool hasDiffuseMap = false; + bool hasEmissiveMap = false; + bool hasHeightMap = false; + bool hasNormalMap = false; + bool hasSpecularMap = false; + bool shadowReceive = true; + + UberShaderConstRef uberShader; + }; + + inline bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs); + inline bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs); + + class MaterialPipeline; + + using MaterialPipelineConstRef = ObjectRef; + using MaterialPipelineLibrary = ObjectLibrary; + using MaterialPipelineRef = ObjectRef; + + class NAZARA_GRAPHICS_API MaterialPipeline : public RefCounted + { + friend class Graphics; + friend MaterialPipelineLibrary; + + public: + struct Instance; + + MaterialPipeline(const MaterialPipeline&) = delete; + MaterialPipeline(MaterialPipeline&&) = delete; + ~MaterialPipeline() = default; + + inline const Instance& Apply(UInt32 flags = ShaderFlags_None) const; + + MaterialPipeline& operator=(const MaterialPipeline&) = delete; + MaterialPipeline& operator=(MaterialPipeline&&) = delete; + + inline const MaterialPipelineInfo& GetInfo() const; + inline const Instance& GetInstance(UInt32 flags = ShaderFlags_None) const; + + static MaterialPipelineRef GetPipeline(const MaterialPipelineInfo& pipelineInfo); + + struct Instance + { + RenderPipeline renderPipeline; + UberShaderInstance* uberInstance = nullptr; + std::array uniforms; + }; + + private: + inline MaterialPipeline(const MaterialPipelineInfo& pipelineInfo); + + void GenerateRenderPipeline(UInt32 flags) const; + + static bool Initialize(); + template static MaterialPipelineRef New(Args&&... args); + static void Uninitialize(); + + MaterialPipelineInfo m_pipelineInfo; + mutable std::array m_instances; + + using PipelineCache = std::unordered_map; + static PipelineCache s_pipelineCache; + + static MaterialPipelineLibrary::LibraryMap s_library; + }; +} + +#include + +#endif // NAZARA_MATERIALPIPELINE_HPP diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl new file mode 100644 index 000000000..ebd94a9ee --- /dev/null +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -0,0 +1,143 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + inline MaterialPipeline::MaterialPipeline(const MaterialPipelineInfo& pipelineInfo) : + m_pipelineInfo(pipelineInfo) + { + } + + /*! + * \brief Enable pipeline states for rendering + * + * \param flags Shader flags + */ + inline const MaterialPipeline::Instance& MaterialPipeline::Apply(UInt32 flags) const + { + const Instance& instance = GetInstance(flags); + instance.uberInstance->Activate(); + + Renderer::SetRenderStates(m_pipelineInfo); + + return instance; + } + + /*! + * \brief Retrieve a MaterialPipelineInfo object describing this pipeline + * + * \return Pipeline informations + */ + const MaterialPipelineInfo& MaterialPipeline::GetInfo() const + { + return m_pipelineInfo; + } + + /*! + * \brief Retrieve (and generate if required) a pipeline instance using shader flags without applying it + * + * \param flags Shader flags + * + * \return Pipeline instance + */ + inline const MaterialPipeline::Instance& MaterialPipeline::GetInstance(UInt32 flags) const + { + const Instance& instance = m_instances[flags]; + if (!instance.uberInstance) + GenerateRenderPipeline(flags); + + return instance; + } + + bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs) + { + if (!operator==(static_cast(lhs), static_cast(rhs))) + return false; + + #define NazaraPipelineMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraPipelineBoolMember NazaraPipelineMember + + NazaraPipelineBoolMember(alphaTest); + NazaraPipelineBoolMember(depthSorting); + NazaraPipelineBoolMember(hasAlphaMap); + NazaraPipelineBoolMember(hasDiffuseMap); + NazaraPipelineBoolMember(hasEmissiveMap); + NazaraPipelineBoolMember(hasHeightMap); + NazaraPipelineBoolMember(hasNormalMap); + NazaraPipelineBoolMember(hasSpecularMap); + NazaraPipelineBoolMember(shadowReceive); + + NazaraPipelineMember(uberShader); + + #undef NazaraPipelineMember + #undef NazaraPipelineBoolMember + + return true; + } + + bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs) + { + return !operator==(lhs, rhs); + } + + /*! + * \brief Creates a new MaterialPipeline from the arguments + * \return A reference to the newly created material pipeline + * + * \param args Arguments for the material pipeline + */ + template + MaterialPipelineRef MaterialPipeline::New(Args&&... args) + { + std::unique_ptr object(new MaterialPipeline(std::forward(args)...)); + return object.release(); + } +} + +namespace std +{ + template<> + struct hash + { + size_t operator()(const Nz::MaterialPipelineInfo& pipelineInfo) const + { + hash parentHash; + + std::size_t seed = parentHash(pipelineInfo); + + Nz::UInt16 parameterHash = 0; + Nz::UInt16 parameterIndex = 0; + + #define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.##member) + #define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + + NazaraPipelineBoolMember(alphaTest); + NazaraPipelineBoolMember(depthSorting); + NazaraPipelineBoolMember(hasAlphaMap); + NazaraPipelineBoolMember(hasDiffuseMap); + NazaraPipelineBoolMember(hasEmissiveMap); + NazaraPipelineBoolMember(hasHeightMap); + NazaraPipelineBoolMember(hasNormalMap); + NazaraPipelineBoolMember(hasSpecularMap); + NazaraPipelineBoolMember(shadowReceive); + + NazaraPipelineMember(uberShader); + + #undef NazaraPipelineMember + #undef NazaraPipelineBoolMember + + Nz::HashCombine(seed, parameterHash); + + return seed; + } + }; +} + +#include diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 840a930e6..f0e05c5a2 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -123,8 +123,7 @@ namespace Nz inline void Sprite::SetDefaultMaterial() { MaterialRef material = Material::New(); - material->Enable(RendererParameter_FaceCulling, false); - material->EnableLighting(false); + material->EnableFaceCulling(false); SetMaterial(std::move(material)); } diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index baeeb50db..2ed880a38 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -119,10 +119,9 @@ namespace Nz inline void TextSprite::SetDefaultMaterial() { MaterialRef material = Material::New(); - material->Enable(RendererParameter_Blend, true); - material->Enable(RendererParameter_DepthWrite, false); - material->Enable(RendererParameter_FaceCulling, false); - material->EnableLighting(false); + material->EnableBlending(true); + material->EnableDepthWrite(false); + material->EnableFaceCulling(false); material->SetDstBlend(BlendFunc_InvSrcAlpha); material->SetSrcBlend(BlendFunc_SrcAlpha); diff --git a/include/Nazara/Renderer/RenderPipeline.hpp b/include/Nazara/Renderer/RenderPipeline.hpp new file mode 100644 index 000000000..aee5584b7 --- /dev/null +++ b/include/Nazara/Renderer/RenderPipeline.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERPIPELINE_HPP +#define NAZARA_RENDERPIPELINE_HPP + +#include +#include +#include + +namespace Nz +{ + struct RenderPipelineInfo : RenderStates + { + ShaderConstRef shader; + }; + + class RenderPipeline + { + public: + inline RenderPipeline(); + inline ~RenderPipeline(); + + inline bool Create(const RenderPipelineInfo& pipelineInfo); + inline void Destroy(); + + inline const RenderPipelineInfo& GetInfo() const; + + inline bool IsValid() const; + + private: + RenderPipelineInfo m_pipelineInfo; + bool m_valid; + }; +} + +#include + +#endif // NAZARA_RENDERPIPELINE_HPP diff --git a/include/Nazara/Renderer/RenderPipeline.inl b/include/Nazara/Renderer/RenderPipeline.inl new file mode 100644 index 000000000..5982b0562 --- /dev/null +++ b/include/Nazara/Renderer/RenderPipeline.inl @@ -0,0 +1,48 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline RenderPipeline::RenderPipeline() : + m_valid(false) + { + } + + inline RenderPipeline::~RenderPipeline() + { + } + + inline bool RenderPipeline::Create(const RenderPipelineInfo& pipelineInfo) + { + NazaraAssert(pipelineInfo.shader, "Invalid shader"); + + m_pipelineInfo = pipelineInfo; + m_valid = true; + + return true; + } + + inline void RenderPipeline::Destroy() + { + m_valid = false; + } + + inline const RenderPipelineInfo& RenderPipeline::GetInfo() const + { + NazaraAssert(m_valid, "Invalid pipeline info"); + + return m_pipelineInfo; + } + + inline bool RenderPipeline::IsValid() const + { + return m_valid; + } +} + +#include diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index a885b2a7d..fc4d10eeb 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -7,8 +7,8 @@ #ifndef NAZARA_RENDERSTATES_HPP #define NAZARA_RENDERSTATES_HPP +#include #include -#include namespace Nz { @@ -74,10 +74,7 @@ namespace Nz float pointSize = 1.f; }; - struct RenderPipeline : RenderStates - { - ShaderConstRef shader; - }; + inline bool operator==(const RenderStates& lhs, const RenderStates& rhs); } #include diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 1f7564166..d9b6bfc31 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -3,11 +3,143 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include +#include +#include #include namespace Nz { + bool operator==(const RenderStates& lhs, const RenderStates& rhs) + { + #define NazaraRenderStateMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraRenderStateBoolMember NazaraRenderStateMember + #define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.##field, rhs.##field, maxDiff)) return false + + NazaraRenderStateBoolMember(blending); + NazaraRenderStateBoolMember(colorWrite); + NazaraRenderStateBoolMember(depthBuffer); + NazaraRenderStateBoolMember(faceCulling); + NazaraRenderStateBoolMember(scissorTest); + NazaraRenderStateBoolMember(stencilTest); + + if (lhs.depthBuffer) + NazaraRenderStateBoolMember(depthWrite); + + NazaraRenderStateMember(faceFilling); + + if (lhs.blending) //< Remember, at this time we know lhs.blending == rhs.blending + { + NazaraRenderStateMember(dstBlend); + NazaraRenderStateMember(srcBlend); + } + + if (lhs.depthBuffer) + NazaraRenderStateMember(depthFunc); + + if (lhs.faceCulling) + NazaraRenderStateMember(cullingSide); + + if (lhs.stencilTest) + { + NazaraRenderStateMember(stencilCompare.back); + NazaraRenderStateMember(stencilCompare.front); + NazaraRenderStateMember(stencilCompareMask.back); + NazaraRenderStateMember(stencilCompareMask.front); + NazaraRenderStateMember(stencilDepthFail.back); + NazaraRenderStateMember(stencilDepthFail.front); + NazaraRenderStateMember(stencilFail.back); + NazaraRenderStateMember(stencilFail.front); + NazaraRenderStateMember(stencilPass.back); + NazaraRenderStateMember(stencilPass.front); + NazaraRenderStateMember(stencilReference.back); + NazaraRenderStateMember(stencilReference.front); + NazaraRenderStateMember(stencilWriteMask.back); + NazaraRenderStateMember(stencilWriteMask.front); + } + + NazaraRenderStateFloatMember(lineWidth, 0.001f); + NazaraRenderStateFloatMember(pointSize, 0.001f); + + #undef NazaraRenderStateMember + #undef NazaraRenderStateBoolMember + #undef NazaraRenderStateFloatMember + + return true; + } +} + +namespace std +{ + template<> + struct hash + { + size_t operator()(const Nz::RenderStates& pipelineInfo) const + { + std::size_t seed = 0; + + Nz::UInt8 parameterHash = 0; + Nz::UInt8 parameterIndex = 0; + + #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.##member) + #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.##dependency && pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.##member / maxDiff) * maxDiff) + + NazaraRenderStateBoolMember(blending); + NazaraRenderStateBoolMember(colorWrite); + NazaraRenderStateBoolMember(depthBuffer); + NazaraRenderStateBoolMember(faceCulling); + NazaraRenderStateBoolMember(scissorTest); + NazaraRenderStateBoolMember(stencilTest); + + NazaraRenderStateBoolMemberDep(depthBuffer, depthWrite); + + NazaraRenderStateMember(faceFilling); + + if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending + { + NazaraRenderStateMember(dstBlend); + NazaraRenderStateMember(srcBlend); + } + + if (pipelineInfo.depthBuffer) + NazaraRenderStateMember(depthFunc); + + if (pipelineInfo.faceCulling) + NazaraRenderStateMember(cullingSide); + + if (pipelineInfo.stencilTest) + { + NazaraRenderStateMember(stencilCompare.back); + NazaraRenderStateMember(stencilCompare.front); + NazaraRenderStateMember(stencilCompareMask.back); + NazaraRenderStateMember(stencilCompareMask.front); + NazaraRenderStateMember(stencilDepthFail.back); + NazaraRenderStateMember(stencilDepthFail.front); + NazaraRenderStateMember(stencilFail.back); + NazaraRenderStateMember(stencilFail.front); + NazaraRenderStateMember(stencilPass.back); + NazaraRenderStateMember(stencilPass.front); + NazaraRenderStateMember(stencilReference.back); + NazaraRenderStateMember(stencilReference.front); + NazaraRenderStateMember(stencilWriteMask.back); + NazaraRenderStateMember(stencilWriteMask.front); + } + + NazaraRenderStateFloatMember(lineWidth, 0.001f); + NazaraRenderStateFloatMember(pointSize, 0.001f); + + #undef NazaraRenderStateMember + #undef NazaraRenderStateBoolMember + #undef NazaraRenderStateBoolMemberDep + #undef NazaraRenderStateFloatMember + + Nz::HashCombine(seed, parameterHash); + + return seed; + } + }; } #include diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 86815558c..3cdcb99fe 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -73,122 +73,132 @@ namespace Nz const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; - for (auto& pair : m_renderQueue->layers) + for (auto& layerPair : m_renderQueue->layers) { - DeferredRenderQueue::Layer& layer = pair.second; - - for (auto& matIt : layer.opaqueModels) + for (auto& pipelinePair : layerPair.second.opaqueModels) { - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.maxInstanceCount > 0) { - DeferredRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; + bool instancing = (pipelineEntry.maxInstanceCount > NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT); - if (!meshInstances.empty()) + UInt32 flags = ShaderFlags_Deferred; + if (instancing) + flags |= ShaderFlags_Instancing; + + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(flags); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Material* material = matIt.first; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - bool useInstancing = instancingEnabled && matEntry.instancingEnabled; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // We begin by getting the program for materials - UInt32 flags = ShaderFlags_Deferred; - if (useInstancing) - flags |= ShaderFlags_Instancing; + lastShader = shader; + } - const Shader* shader = material->Apply(flags); + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; - // The uniforms are conserved in our program, there's no point to send them back if they don't change - if (shader != lastShader) + if (matEntry.enabled) { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); + DeferredRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; - // Ambient color for the scene - shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - - lastShader = shader; - } - - // Meshes - for (auto& meshIt : meshInstances) - { - const MeshData& meshData = meshIt.first; - auto& meshEntry = meshIt.second; - - std::vector& instances = meshEntry.instances; - if (!instances.empty()) + if (!meshInstances.empty()) { - const IndexBuffer* indexBuffer = meshData.indexBuffer; - const VertexBuffer* vertexBuffer = meshData.vertexBuffer; + material->Apply(pipelineInstance); - // Handle draw call before rendering loop - Renderer::DrawCall drawFunc; - Renderer::DrawCallInstanced instancedDrawFunc; - unsigned int indexCount; - - if (indexBuffer) + // Meshes + for (auto& meshIt : meshInstances) { - drawFunc = Renderer::DrawIndexedPrimitives; - instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; - indexCount = indexBuffer->GetIndexCount(); - } - else - { - drawFunc = Renderer::DrawPrimitives; - instancedDrawFunc = Renderer::DrawPrimitivesInstanced; - indexCount = vertexBuffer->GetVertexCount(); - } + const MeshData& meshData = meshIt.first; + auto& meshEntry = meshIt.second; - Renderer::SetIndexBuffer(indexBuffer); - Renderer::SetVertexBuffer(vertexBuffer); - - if (useInstancing) - { - // We get the buffer for instance of Renderer and we configure it to work with matrices - VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); - instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - - const Matrix4f* instanceMatrices = &instances[0]; - unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer - - while (instanceCount > 0) + std::vector& instances = meshEntry.instances; + if (!instances.empty()) { - // We compute the number of instances that we will be able to show this time (Depending on the instance buffer size) - unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); - instanceCount -= renderedInstanceCount; + const IndexBuffer* indexBuffer = meshData.indexBuffer; + const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // We fill the instancing buffer with our world matrices - instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); - instanceMatrices += renderedInstanceCount; + // Handle draw call before rendering loop + Renderer::DrawCall drawFunc; + Renderer::DrawCallInstanced instancedDrawFunc; + unsigned int indexCount; - // And we show - instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + if (indexBuffer) + { + drawFunc = Renderer::DrawIndexedPrimitives; + instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; + indexCount = indexBuffer->GetIndexCount(); + } + else + { + drawFunc = Renderer::DrawPrimitives; + instancedDrawFunc = Renderer::DrawPrimitivesInstanced; + indexCount = vertexBuffer->GetVertexCount(); + } + + Renderer::SetIndexBuffer(indexBuffer); + Renderer::SetVertexBuffer(vertexBuffer); + + if (instancing) + { + // We get the buffer for instance of Renderer and we configure it to work with matrices + VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); + instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); + + const Matrix4f* instanceMatrices = &instances[0]; + unsigned int instanceCount = instances.size(); + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer + + while (instanceCount > 0) + { + // We compute the number of instances that we will be able to show this time (Depending on the instance buffer size) + unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); + instanceCount -= renderedInstanceCount; + + // We fill the instancing buffer with our world matrices + instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); + instanceMatrices += renderedInstanceCount; + + // And we show + instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + } + } + else + { + // Without instancing, we must do one draw call for each instance + // This may be faster than instancing under a threshold + // Due to the time to modify the instancing buffer + for (const Matrix4f& matrix : instances) + { + Renderer::SetMatrix(MatrixType_World, matrix); + drawFunc(meshData.primitiveMode, 0, indexCount); + } + } + + instances.clear(); } } - else - { - // Without instancing, we must do one draw call for each instance - // This may be faster than instancing under a threshold - // Due to the time to modify the instancing buffer - for (const Matrix4f& matrix : instances) - { - Renderer::SetMatrix(MatrixType_World, matrix); - drawFunc(meshData.primitiveMode, 0, indexCount); - } - } - - instances.clear(); } + + // And we set it back data to zero + matEntry.enabled = false; } } - // Abd we set it back data to zero - matEntry.enabled = false; - matEntry.instancingEnabled = false; + pipelineEntry.maxInstanceCount = 0; } } } diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 0b15c5a44..8623904a6 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -191,27 +191,39 @@ namespace Nz void DeferredRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { - if (material->IsEnabled(RendererParameter_Blend)) + if (material->IsBlendingEnabled()) // One transparent material ? I don't like it, go see if I'm in the forward queue m_forwardQueue->AddMesh(renderOrder, material, meshData, meshAABB, transformMatrix); else { Layer& currentLayer = GetLayer(renderOrder); - auto& opaqueModels = currentLayer.opaqueModels; + MeshPipelineBatches& opaqueModels = currentLayer.opaqueModels; - auto it = opaqueModels.find(material); - if (it == opaqueModels.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = opaqueModels.find(materialPipeline); + if (pipelineIt == opaqueModels.end()) + { + BatchedMaterialEntry materialEntry; + pipelineIt = opaqueModels.insert(MeshPipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + } + + BatchedMaterialEntry& materialEntry = pipelineIt->second; + MeshMaterialBatches& materialMap = materialEntry.materialMap; + + auto materialIt = materialMap.find(material); + if (materialIt == materialMap.end()) { BatchedModelEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &DeferredRenderQueue::OnMaterialInvalidation); - it = opaqueModels.insert(std::make_pair(material, std::move(entry))).first; + materialIt = materialMap.insert(MeshMaterialBatches::value_type(material, std::move(entry))).first; } - BatchedModelEntry& entry = it->second; + BatchedModelEntry& entry = materialIt->second; entry.enabled = true; - auto& meshMap = entry.meshMap; + MeshInstanceContainer& meshMap = entry.meshMap; auto it2 = meshMap.find(meshData); if (it2 == meshMap.end()) @@ -225,13 +237,8 @@ namespace Nz it2 = meshMap.insert(std::make_pair(meshData, std::move(instanceEntry))).first; } - // We add matrices to the list of instances of this object std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - - // Do we have enough instances to perform instancing ? - if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Thus we can activate it } } @@ -293,7 +300,7 @@ namespace Nz return layer; } - + /*! * \brief Handle the invalidation of an index buffer * @@ -306,16 +313,19 @@ namespace Nz { Layer& layer = pair.second; - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.indexBuffer == indexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.indexBuffer == indexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } @@ -333,7 +343,8 @@ namespace Nz { Layer& layer = pair.second; - layer.opaqueModels.erase(material); + for (auto& pipelineEntry : layer.opaqueModels) + pipelineEntry.second.materialMap.erase(material); } } @@ -348,73 +359,21 @@ namespace Nz for (auto& pair : layers) { Layer& layer = pair.second; - - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.vertexBuffer == vertexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.vertexBuffer == vertexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } } - - /*! - * \brief Functor to compare two batched model with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool DeferredRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const - { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance(ShaderFlags_Deferred)->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance(ShaderFlags_Deferred)->GetShader(); - if (shader1 != shader2) - return shader1 < shader2; - - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); - const Texture* diffuseMap2 = mat2->GetDiffuseMap(); - if (diffuseMap1 != diffuseMap2) - return diffuseMap1 < diffuseMap2; - - return mat1 < mat2; - } - - /*! - * \brief Functor to compare two mesh data - * \return true If first mesh is "smaller" than the second one - * - * \param data1 First mesh to compare - * \param data2 Second mesh to compare - */ - - bool DeferredRenderQueue::MeshDataComparator::operator()(const MeshData& data1, const MeshData& data2) const - { - const Buffer* buffer1; - const Buffer* buffer2; - - buffer1 = (data1.indexBuffer) ? data1.indexBuffer->GetBuffer() : nullptr; - buffer2 = (data2.indexBuffer) ? data2.indexBuffer->GetBuffer() : nullptr; - if (buffer1 != buffer2) - return buffer1 < buffer2; - - buffer1 = data1.vertexBuffer->GetBuffer(); - buffer2 = data2.vertexBuffer->GetBuffer(); - if (buffer1 != buffer2) - return buffer1 < buffer2; - - return data1.primitiveMode < data2.primitiveMode; - } } diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index c658fe7bd..fbc24bb19 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -23,8 +23,8 @@ namespace Nz { // Material m_baseMaterial = Material::New(); - m_baseMaterial->Enable(RendererParameter_ColorWrite, false); - m_baseMaterial->Enable(RendererParameter_FaceCulling, false); + m_baseMaterial->EnableColorWrite(false); + m_baseMaterial->EnableFaceCulling(false); //m_baseMaterial->SetFaceCulling(FaceSide_Front); } diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 233eb9c72..46b1c3407 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -52,6 +52,10 @@ namespace Nz { ErrorFlags flags(ErrorFlag_ThrowException, true); + std::array whitePixel = {255, 255, 255, 255}; + m_whiteTexture.Create(ImageType_2D, PixelFormatType_RGBA8, 1, 1); + m_whiteTexture.Update(whitePixel.data()); + m_vertexBuffer.Create(s_vertexBufferSize, DataStorage_Hardware, BufferUsage_Dynamic); m_billboardPointBuffer.Reset(&s_billboardVertexDeclaration, &m_vertexBuffer); @@ -208,6 +212,8 @@ namespace Nz void DepthRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { + NazaraAssert(sceneData.viewer, "Invalid viewer"); + const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; @@ -215,95 +221,102 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); Renderer::SetVertexBuffer(&m_spriteBuffer); - for (auto& matIt : layer.basicSprites) + for (auto& pipelinePair : layer.basicSprites) { - const Material* material = matIt.first; - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.enabled) { - auto& overlayMap = matEntry.overlayMap; - for (auto& overlayIt : overlayMap) + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_TextureOverlay | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Texture* overlay = overlayIt.first; - auto& spriteChainVector = overlayIt.second.spriteChains; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - unsigned int spriteChainCount = spriteChainVector.size(); - if (spriteChainCount > 0) - { - // We begin to apply the material (and get the shader activated doing so) - UInt32 flags = 0; - if (overlay) - flags |= ShaderFlags_TextureOverlay; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - UInt8 overlayUnit; - const Shader* shader = material->Apply(flags, 0, &overlayUnit); - - if (overlay) - { - overlayUnit++; - Renderer::SetTexture(overlayUnit, overlay); - Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); - } - - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) - { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); - - // Overlay - shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); - - lastShader = shader; - } - - unsigned int spriteChain = 0; // Which chain of sprites are we treating - unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain - - do - { - // We open the buffer in writing mode - BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); - VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(vertexMapper.GetPointer()); - - unsigned int spriteCount = 0; - unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount()/4); - - do - { - ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; - unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); - - std::memcpy(vertices, currentChain.vertices + spriteChainOffset*4, 4*count*sizeof(VertexStruct_XYZ_Color_UV)); - vertices += count*4; - - spriteCount += count; - spriteChainOffset += count; - - // Have we treated the entire chain ? - if (spriteChainOffset == currentChain.spriteCount) - { - spriteChain++; - spriteChainOffset = 0; - } - } - while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); - - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount*6); - } - while (spriteChain < spriteChainCount); - - spriteChainVector.clear(); - } + lastShader = shader; } - // On remet à zéro - matEntry.enabled = false; + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + UInt8 overlayUnit; + material->Apply(pipelineInstance, 0, &overlayUnit); + overlayUnit++; + + shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); + + Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); + + auto& overlayMap = matEntry.overlayMap; + for (auto& overlayIt : overlayMap) + { + const Texture* overlay = overlayIt.first; + auto& spriteChainVector = overlayIt.second.spriteChains; + + unsigned int spriteChainCount = spriteChainVector.size(); + if (spriteChainCount > 0) + { + Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); + + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain + + do + { + // We open the buffer in writing mode + BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); + VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); + + unsigned int spriteCount = 0; + unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); + + do + { + ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; + unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); + + std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); + vertices += count * 4; + + spriteCount += count; + spriteChainOffset += count; + + // Have we treated the entire chain ? + if (spriteChainOffset == currentChain.spriteCount) + { + spriteChain++; + spriteChainOffset = 0; + } + } while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); + } while (spriteChain < spriteChainCount); + + spriteChainVector.clear(); + } + } + + // We set it back to zero + matEntry.enabled = false; + } + } + pipelineEntry.enabled = false; } } } @@ -314,9 +327,11 @@ namespace Nz * \param sceneData Data of the scene * \param layer Layer of the rendering */ - + void DepthRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { + NazaraAssert(sceneData.viewer, "Invalid viewer"); + const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; @@ -327,17 +342,16 @@ namespace Nz Renderer::SetVertexBuffer(&s_quadVertexBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -345,27 +359,43 @@ namespace Nz // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - instanceBuffer->Fill(data, 0, renderedBillboardCount, true); - data += renderedBillboardCount; + unsigned int billboardCount = billboardVector.size(); + if (billboardCount > 0) + { + // We begin to apply the material (and get the shader activated doing so) + material->Apply(pipelineInstance); - Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); + do + { + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; + + instanceBuffer->Fill(data, 0, renderedBillboardCount, true); + data += renderedBillboardCount; + + Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + } + while (billboardCount > 0); + + billboardVector.clear(); + } } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -374,17 +404,16 @@ namespace Nz Renderer::SetIndexBuffer(&s_quadIndexBuffer); Renderer::SetVertexBuffer(&m_billboardPointBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -392,63 +421,73 @@ namespace Nz // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount()/4); - - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount*4); - BillboardPoint* vertices = reinterpret_cast(vertexMapper.GetPointer()); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); - for (unsigned int i = 0; i < renderedBillboardCount; ++i) + unsigned int billboardCount = billboardVector.size(); + do { - const ForwardRenderQueue::BillboardData& billboard = *data++; + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 1.f); - vertices++; + BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); + BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 1.f); - vertices++; + for (unsigned int i = 0; i < renderedBillboardCount; ++i) + { + const ForwardRenderQueue::BillboardData& billboard = *data++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 1.f); + vertices++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 1.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 0.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 0.f); + vertices++; + } + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); } + while (billboardCount > 0); - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount*6); + billboardVector.clear(); } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -460,116 +499,131 @@ namespace Nz * \param sceneData Data of the scene * \param layer Layer of the rendering */ - + void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { + NazaraAssert(sceneData.viewer, "Invalid viewer"); + const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; - for (auto& matIt : layer.opaqueModels) + for (auto& pipelinePair : layer.opaqueModels) { - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.maxInstanceCount > 0) { - ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; + bool instancing = (pipelineEntry.maxInstanceCount > NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply((instancing) ? ShaderFlags_Instancing : 0); - if (!meshInstances.empty()) + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Material* material = matIt.first; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - bool instancing = m_instancingEnabled && matEntry.instancingEnabled; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // We begin to apply the material (and get the shader activated doing so) - UInt8 freeTextureUnit; - const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); + lastShader = shader; + } - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); - lastShader = shader; - } + UInt8 freeTextureUnit; + material->Apply(pipelineInstance, 0, &freeTextureUnit); - // Meshes - for (auto& meshIt : meshInstances) - { - const MeshData& meshData = meshIt.first; - auto& meshEntry = meshIt.second; + ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; - const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; - std::vector& instances = meshEntry.instances; - - if (!instances.empty()) + // Meshes + for (auto& meshIt : meshInstances) { - const IndexBuffer* indexBuffer = meshData.indexBuffer; - const VertexBuffer* vertexBuffer = meshData.vertexBuffer; + const MeshData& meshData = meshIt.first; + auto& meshEntry = meshIt.second; - // Handle draw call before rendering loop - Renderer::DrawCall drawFunc; - Renderer::DrawCallInstanced instancedDrawFunc; - unsigned int indexCount; + const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; + std::vector& instances = meshEntry.instances; - if (indexBuffer) + if (!instances.empty()) { - drawFunc = Renderer::DrawIndexedPrimitives; - instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; - indexCount = indexBuffer->GetIndexCount(); - } - else - { - drawFunc = Renderer::DrawPrimitives; - instancedDrawFunc = Renderer::DrawPrimitivesInstanced; - indexCount = vertexBuffer->GetVertexCount(); - } + const IndexBuffer* indexBuffer = meshData.indexBuffer; + const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - Renderer::SetIndexBuffer(indexBuffer); - Renderer::SetVertexBuffer(vertexBuffer); + // Handle draw call before rendering loop + Renderer::DrawCall drawFunc; + Renderer::DrawCallInstanced instancedDrawFunc; + unsigned int indexCount; - if (instancing) - { - // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); - instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); + if (indexBuffer) + { + drawFunc = Renderer::DrawIndexedPrimitives; + instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; + indexCount = indexBuffer->GetIndexCount(); + } + else + { + drawFunc = Renderer::DrawPrimitives; + instancedDrawFunc = Renderer::DrawPrimitivesInstanced; + indexCount = vertexBuffer->GetVertexCount(); + } - const Matrix4f* instanceMatrices = &instances[0]; - unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The maximum number of instances in one batch + Renderer::SetIndexBuffer(indexBuffer); + Renderer::SetVertexBuffer(vertexBuffer); - while (instanceCount > 0) + if (instancing) { // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); - instanceCount -= renderedInstanceCount; + VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); + instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - // We fill the instancing buffer with our world matrices - instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); - instanceMatrices += renderedInstanceCount; + const Matrix4f* instanceMatrices = &instances[0]; + unsigned int instanceCount = instances.size(); + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch - // And we draw - instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + while (instanceCount > 0) + { + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) + unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); + instanceCount -= renderedInstanceCount; + + // We fill the instancing buffer with our world matrices + instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); + instanceMatrices += renderedInstanceCount; + + // And we draw + instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + } } - } - else - { - // Without instancing, we must do a draw call for each instance + else + { + // Without instancing, we must do a draw call for each instance // This may be faster than instancing under a certain number // Due to the time to modify the instancing buffer - for (const Matrix4f& matrix : instances) - { - Renderer::SetMatrix(MatrixType_World, matrix); - drawFunc(meshData.primitiveMode, 0, indexCount); + for (const Matrix4f& matrix : instances) + { + Renderer::SetMatrix(MatrixType_World, matrix); + drawFunc(meshData.primitiveMode, 0, indexCount); + } } + instances.clear(); } - instances.clear(); } + + matEntry.enabled = false; } } - // And we set the data back to zero - matEntry.enabled = false; - matEntry.instancingEnabled = false; + pipelineEntry.maxInstanceCount = 0; } } } diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index b9077e1b9..882a6f61e 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -372,12 +372,11 @@ namespace Nz * * \remark Produces a NazaraAssert if material is invalid */ - void ForwardRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { NazaraAssert(material, "Invalid material"); - if (material->IsEnabled(RendererParameter_Blend)) + if (material->IsBlendingEnabled()) { Layer& currentLayer = GetLayer(renderOrder); auto& transparentModels = currentLayer.transparentModels; @@ -398,21 +397,33 @@ namespace Nz else { Layer& currentLayer = GetLayer(renderOrder); - auto& opaqueModels = currentLayer.opaqueModels; + MeshPipelineBatches& opaqueModels = currentLayer.opaqueModels; - auto it = opaqueModels.find(material); - if (it == opaqueModels.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = opaqueModels.find(materialPipeline); + if (pipelineIt == opaqueModels.end()) + { + BatchedMaterialEntry materialEntry; + pipelineIt = opaqueModels.insert(MeshPipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + } + + BatchedMaterialEntry& materialEntry = pipelineIt->second; + MeshMaterialBatches& materialMap = materialEntry.materialMap; + + auto materialIt = materialMap.find(material); + if (materialIt == materialMap.end()) { BatchedModelEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - it = opaqueModels.insert(std::make_pair(material, std::move(entry))).first; + materialIt = materialMap.insert(MeshMaterialBatches::value_type(material, std::move(entry))).first; } - BatchedModelEntry& entry = it->second; + BatchedModelEntry& entry = materialIt->second; entry.enabled = true; - auto& meshMap = entry.meshMap; + MeshInstanceContainer& meshMap = entry.meshMap; auto it2 = meshMap.find(meshData); if (it2 == meshMap.end()) @@ -431,9 +442,7 @@ namespace Nz std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - // Do we have enough instances to perform instancing ? - if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Thus we can activate it + materialEntry.maxInstanceCount = std::max(materialEntry.maxInstanceCount, instances.size()); } } @@ -448,21 +457,34 @@ namespace Nz * * \remark Produces a NazaraAssert if material is invalid */ - void ForwardRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { NazaraAssert(material, "Invalid material"); Layer& currentLayer = GetLayer(renderOrder); - auto& basicSprites = currentLayer.basicSprites; + SpritePipelineBatches& basicSprites = currentLayer.basicSprites; - auto matIt = basicSprites.find(material); - if (matIt == basicSprites.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = basicSprites.find(materialPipeline); + if (pipelineIt == basicSprites.end()) + { + BatchedSpritePipelineEntry materialEntry; + pipelineIt = basicSprites.insert(SpritePipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + } + + BatchedSpritePipelineEntry& pipelineEntry = pipelineIt->second; + pipelineEntry.enabled = true; + + SpriteMaterialBatches& materialMap = pipelineEntry.materialMap; + + auto matIt = materialMap.find(material); + if (matIt == materialMap.end()) { BatchedBasicSpriteEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - matIt = basicSprites.insert(std::make_pair(material, std::move(entry))).first; + matIt = materialMap.insert(SpriteMaterialBatches::value_type(material, std::move(entry))).first; } BatchedBasicSpriteEntry& entry = matIt->second; @@ -541,19 +563,22 @@ namespace Nz return nearPlane.Distance(position1) > nearPlane.Distance(position2); }); - for (auto& pair : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* mat = pair.first; - - if (mat->IsDepthSortingEnabled()) + for (auto& matPair : pipelinePair.second.materialMap) { - BatchedBillboardEntry& entry = pair.second; - auto& billboardVector = entry.billboards; + const Material* mat = matPair.first; - std::sort(billboardVector.begin(), billboardVector.end(), [&viewerPos] (const BillboardData& data1, const BillboardData& data2) + if (mat->IsDepthSortingEnabled()) { - return viewerPos.SquaredDistance(data1.center) > viewerPos.SquaredDistance(data2.center); - }); + BatchedBillboardEntry& entry = matPair.second; + auto& billboardVector = entry.billboards; + + std::sort(billboardVector.begin(), billboardVector.end(), [&viewerPos] (const BillboardData& data1, const BillboardData& data2) + { + return viewerPos.SquaredDistance(data1.center) > viewerPos.SquaredDistance(data2.center); + }); + } } } } @@ -571,13 +596,26 @@ namespace Nz { auto& billboards = GetLayer(renderOrder).billboards; - auto it = billboards.find(material); - if (it == billboards.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = billboards.find(materialPipeline); + if (pipelineIt == billboards.end()) + { + BatchedBillboardPipelineEntry pipelineEntry; + pipelineIt = billboards.insert(BillboardPipelineBatches::value_type(materialPipeline, std::move(pipelineEntry))).first; + } + BatchedBillboardPipelineEntry& pipelineEntry = pipelineIt->second; + pipelineEntry.enabled = true; + + BatchedBillboardContainer& materialMap = pipelineEntry.materialMap; + + auto it = materialMap.find(material); + if (it == materialMap.end()) { BatchedBillboardEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - it = billboards.insert(std::make_pair(material, std::move(entry))).first; + it = materialMap.insert(BatchedBillboardContainer::value_type(material, std::move(entry))).first; } BatchedBillboardEntry& entry = it->second; @@ -620,16 +658,19 @@ namespace Nz { Layer& layer = pair.second; - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.indexBuffer == indexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.indexBuffer == indexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } @@ -647,9 +688,14 @@ namespace Nz { Layer& layer = pair.second; - layer.basicSprites.erase(material); - layer.billboards.erase(material); - layer.opaqueModels.erase(material); + for (auto& pipelineEntry : layer.basicSprites) + pipelineEntry.second.materialMap.erase(material); + + for (auto& pipelineEntry : layer.billboards) + pipelineEntry.second.materialMap.erase(material); + + for (auto& pipelineEntry : layer.opaqueModels) + pipelineEntry.second.materialMap.erase(material); } } @@ -664,10 +710,10 @@ namespace Nz for (auto& pair : layers) { Layer& layer = pair.second; - for (auto matIt = layer.basicSprites.begin(); matIt != layer.basicSprites.end(); ++matIt) + for (auto& pipelineEntry : layer.basicSprites) { - auto& overlayMap = matIt->second.overlayMap; - overlayMap.erase(texture); + for (auto& materialEntry : pipelineEntry.second.materialMap) + materialEntry.second.overlayMap.erase(texture); } } } @@ -683,41 +729,26 @@ namespace Nz for (auto& pair : layers) { Layer& layer = pair.second; - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.vertexBuffer == vertexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.vertexBuffer == vertexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } } - /*! - * \brief Functor to compare two batched billboard with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool ForwardRenderQueue::BatchedBillboardComparator::operator()(const Material* mat1, const Material* mat2) const + bool ForwardRenderQueue::MaterialComparator::operator()(const Material* mat1, const Material* mat2) const { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance(ShaderFlags_Billboard | ShaderFlags_VertexColor)->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance(ShaderFlags_Billboard | ShaderFlags_VertexColor)->GetShader(); - if (shader1 != shader2) - return shader1 < shader2; - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); const Texture* diffuseMap2 = mat2->GetDiffuseMap(); if (diffuseMap1 != diffuseMap2) @@ -726,60 +757,14 @@ namespace Nz return mat1 < mat2; } - /*! - * \brief Functor to compare two batched model with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool ForwardRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const + bool ForwardRenderQueue::MaterialPipelineComparator::operator()(const MaterialPipeline* pipeline1, const MaterialPipeline* pipeline2) const { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance()->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance()->GetShader(); + const Shader* shader1 = pipeline1->GetInstance().renderPipeline.GetInfo().shader; + const Shader* shader2 = pipeline2->GetInstance().renderPipeline.GetInfo().shader; if (shader1 != shader2) return shader1 < shader2; - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); - const Texture* diffuseMap2 = mat2->GetDiffuseMap(); - if (diffuseMap1 != diffuseMap2) - return diffuseMap1 < diffuseMap2; - - return mat1 < mat2; - } - - /*! - * \brief Functor to compare two batched sprites with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool ForwardRenderQueue::BatchedSpriteMaterialComparator::operator()(const Material* mat1, const Material* mat2) - { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance()->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance()->GetShader(); - if (shader1 != shader2) - return shader1 < shader2; - - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); - const Texture* diffuseMap2 = mat2->GetDiffuseMap(); - if (diffuseMap1 != diffuseMap2) - return diffuseMap1 < diffuseMap2; - - return mat1 < mat2; + return pipeline1 < pipeline2; } /*! diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 482852347..aad29ab88 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -53,6 +53,10 @@ namespace Nz { ErrorFlags flags(ErrorFlag_ThrowException, true); + std::array whitePixel = {255, 255, 255, 255}; + m_whiteTexture.Create(ImageType_2D, PixelFormatType_RGBA8, 1, 1); + m_whiteTexture.Update(whitePixel.data()); + m_vertexBuffer.Create(s_vertexBufferSize, DataStorage_Hardware, BufferUsage_Dynamic); m_billboardPointBuffer.Reset(&s_billboardVertexDeclaration, &m_vertexBuffer); @@ -297,97 +301,102 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); Renderer::SetVertexBuffer(&m_spriteBuffer); - for (auto& matIt : layer.basicSprites) + for (auto& pipelinePair : layer.basicSprites) { - const Material* material = matIt.first; - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.enabled) { - auto& overlayMap = matEntry.overlayMap; - for (auto& overlayIt : overlayMap) + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_TextureOverlay | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Texture* overlay = overlayIt.first; - auto& spriteChainVector = overlayIt.second.spriteChains; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - unsigned int spriteChainCount = spriteChainVector.size(); - if (spriteChainCount > 0) - { - // We begin to apply the material (and get the shader activated doing so) - UInt32 flags = ShaderFlags_VertexColor; - if (overlay) - flags |= ShaderFlags_TextureOverlay; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - UInt8 overlayUnit; - const Shader* shader = material->Apply(flags, 0, &overlayUnit); - - if (overlay) - { - overlayUnit++; - Renderer::SetTexture(overlayUnit, overlay); - Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); - } - - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) - { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); - - // Ambiant color of the scene - shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Overlay - shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - - lastShader = shader; - } - - unsigned int spriteChain = 0; // Which chain of sprites are we treating - unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain - - do - { - // We open the buffer in writing mode - BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); - VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); - - unsigned int spriteCount = 0; - unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); - - do - { - ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; - unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); - - std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); - vertices += count * 4; - - spriteCount += count; - spriteChainOffset += count; - - // Have we treated the entire chain ? - if (spriteChainOffset == currentChain.spriteCount) - { - spriteChain++; - spriteChainOffset = 0; - } - } - while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); - - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); - } - while (spriteChain < spriteChainCount); - - spriteChainVector.clear(); - } + lastShader = shader; } - // We set it back to zero - matEntry.enabled = false; + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + UInt8 overlayUnit; + material->Apply(pipelineInstance, 0, &overlayUnit); + overlayUnit++; + + shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); + + Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); + + auto& overlayMap = matEntry.overlayMap; + for (auto& overlayIt : overlayMap) + { + const Texture* overlay = overlayIt.first; + auto& spriteChainVector = overlayIt.second.spriteChains; + + unsigned int spriteChainCount = spriteChainVector.size(); + if (spriteChainCount > 0) + { + Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); + + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain + + do + { + // We open the buffer in writing mode + BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); + VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); + + unsigned int spriteCount = 0; + unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); + + do + { + ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; + unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); + + std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); + vertices += count * 4; + + spriteCount += count; + spriteChainOffset += count; + + // Have we treated the entire chain ? + if (spriteChainOffset == currentChain.spriteCount) + { + spriteChain++; + spriteChainOffset = 0; + } + } while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); + } while (spriteChain < spriteChainCount); + + spriteChainVector.clear(); + } + } + + // We set it back to zero + matEntry.enabled = false; + } + } + pipelineEntry.enabled = false; } } } @@ -415,17 +424,16 @@ namespace Nz Renderer::SetVertexBuffer(&s_quadVertexBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -441,21 +449,35 @@ namespace Nz lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - instanceBuffer->Fill(data, 0, renderedBillboardCount, true); - data += renderedBillboardCount; + unsigned int billboardCount = billboardVector.size(); + if (billboardCount > 0) + { + // We begin to apply the material (and get the shader activated doing so) + material->Apply(pipelineInstance); - Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); + do + { + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; + + instanceBuffer->Fill(data, 0, renderedBillboardCount, true); + data += renderedBillboardCount; + + Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + } + while (billboardCount > 0); + + billboardVector.clear(); + } } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -464,17 +486,16 @@ namespace Nz Renderer::SetIndexBuffer(&s_quadIndexBuffer); Renderer::SetVertexBuffer(&m_billboardPointBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -490,57 +511,65 @@ namespace Nz lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); - - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); - BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); - for (unsigned int i = 0; i < renderedBillboardCount; ++i) + unsigned int billboardCount = billboardVector.size(); + do { - const ForwardRenderQueue::BillboardData& billboard = *data++; + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 1.f); - vertices++; + BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); + BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 1.f); - vertices++; + for (unsigned int i = 0; i < renderedBillboardCount; ++i) + { + const ForwardRenderQueue::BillboardData& billboard = *data++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 1.f); + vertices++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 1.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 0.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 0.f); + vertices++; + } + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); } + while (billboardCount > 0); - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); + billboardVector.clear(); } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -562,158 +591,98 @@ namespace Nz const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; - for (auto& matIt : layer.opaqueModels) + for (auto& pipelinePair : layer.opaqueModels) { - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.maxInstanceCount > 0) { - ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; + bool instancing = (pipelineEntry.maxInstanceCount > NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply((instancing) ? ShaderFlags_Instancing : 0); - if (!meshInstances.empty()) + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Material* material = matIt.first; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - // We only use instancing when no light (other than directional) is active - // This is because instancing is not compatible with the search of nearest lights - // Deferred shading does not have this problem - bool noPointSpotLight = m_renderQueue.pointLights.empty() && m_renderQueue.spotLights.empty(); - bool instancing = m_instancingEnabled && (!material->IsLightingEnabled() || noPointSpotLight) && matEntry.instancingEnabled; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // We begin to apply the material (and get the shader activated doing so) - UInt8 freeTextureUnit; - const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); + lastShader = shader; + } - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); + UInt8 freeTextureUnit; + material->Apply(pipelineInstance, 0, &freeTextureUnit); - // Ambiant color of the scene - shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); + ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; - lastShader = shader; - } - - // Meshes - for (auto& meshIt : meshInstances) - { - const MeshData& meshData = meshIt.first; - auto& meshEntry = meshIt.second; - - const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; - std::vector& instances = meshEntry.instances; - - if (!instances.empty()) + // Meshes + for (auto& meshIt : meshInstances) { - const IndexBuffer* indexBuffer = meshData.indexBuffer; - const VertexBuffer* vertexBuffer = meshData.vertexBuffer; + const MeshData& meshData = meshIt.first; + auto& meshEntry = meshIt.second; - // Handle draw call before rendering loop - Renderer::DrawCall drawFunc; - Renderer::DrawCallInstanced instancedDrawFunc; - unsigned int indexCount; + const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; + std::vector& instances = meshEntry.instances; - if (indexBuffer) + if (!instances.empty()) { - drawFunc = Renderer::DrawIndexedPrimitives; - instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; - indexCount = indexBuffer->GetIndexCount(); - } - else - { - drawFunc = Renderer::DrawPrimitives; - instancedDrawFunc = Renderer::DrawPrimitivesInstanced; - indexCount = vertexBuffer->GetVertexCount(); - } + const IndexBuffer* indexBuffer = meshData.indexBuffer; + const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - Renderer::SetIndexBuffer(indexBuffer); - Renderer::SetVertexBuffer(vertexBuffer); + // Handle draw call before rendering loop + Renderer::DrawCall drawFunc; + Renderer::DrawCallInstanced instancedDrawFunc; + unsigned int indexCount; - if (instancing) - { - // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); - instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - - // With instancing, impossible to select the lights for each object - // So, it's only activated for directional lights - unsigned int lightCount = m_renderQueue.directionalLights.size(); - unsigned int lightIndex = 0; - RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); - - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; - for (unsigned int pass = 0; pass < passCount; ++pass) + if (indexBuffer) { - if (shaderUniforms->hasLightUniforms) - { - unsigned int renderedLightCount = std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); - lightCount -= renderedLightCount; - - if (pass == 1) - { - // To add the result of light computations - // We won't interfeer with materials parameters because we only render opaques objects - // (A.K.A., without blending) - // About the depth function, it must be applied only the first time - Renderer::Enable(RendererParameter_Blend, true); - Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); - Renderer::SetDepthFunc(RendererComparison_Equal); - } - - // Sends the uniforms - for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); - - // And we give them to draw - drawFunc(meshData.primitiveMode, 0, indexCount); - } - - const Matrix4f* instanceMatrices = &instances[0]; - unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch - - while (instanceCount > 0) - { - // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); - instanceCount -= renderedInstanceCount; - - // We fill the instancing buffer with our world matrices - instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); - instanceMatrices += renderedInstanceCount; - - // And we draw - instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); - } + drawFunc = Renderer::DrawIndexedPrimitives; + instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; + indexCount = indexBuffer->GetIndexCount(); + } + else + { + drawFunc = Renderer::DrawPrimitives; + instancedDrawFunc = Renderer::DrawPrimitivesInstanced; + indexCount = vertexBuffer->GetVertexCount(); } - // We don't forget to disable the blending to avoid to interfeer with the rest of the rendering - Renderer::Enable(RendererParameter_Blend, false); - Renderer::SetDepthFunc(oldDepthFunc); - } - else - { - if (shaderUniforms->hasLightUniforms) + Renderer::SetIndexBuffer(indexBuffer); + Renderer::SetVertexBuffer(vertexBuffer); + + if (instancing) { - for (const Matrix4f& matrix : instances) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) + VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); + instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); + + // With instancing, impossible to select the lights for each object + // So, it's only activated for directional lights + unsigned int lightCount = m_renderQueue.directionalLights.size(); + unsigned int lightIndex = 0; + RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); + + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + for (unsigned int pass = 0; pass < passCount; ++pass) { - // Choose the lights depending on an object position and apparent radius - ChooseLights(Spheref(matrix.GetTranslation() + squaredBoundingSphere.GetPosition(), squaredBoundingSphere.radius)); - - unsigned int lightCount = m_lights.size(); - - Renderer::SetMatrix(MatrixType_World, matrix); - unsigned int lightIndex = 0; - RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it - - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; - for (unsigned int pass = 0; pass < passCount; ++pass) + if (shaderUniforms->hasLightUniforms) { - lightCount -= std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); + unsigned int renderedLightCount = std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); + lightCount -= renderedLightCount; if (pass == 1) { @@ -726,38 +695,98 @@ namespace Nz Renderer::SetDepthFunc(RendererComparison_Equal); } - // Sends the light uniforms to the shader + // Sends the uniforms for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); - - // And we draw - drawFunc(meshData.primitiveMode, 0, indexCount); + SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); } - Renderer::Enable(RendererParameter_Blend, false); - Renderer::SetDepthFunc(oldDepthFunc); + const Matrix4f* instanceMatrices = &instances[0]; + unsigned int instanceCount = instances.size(); + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch + + while (instanceCount > 0) + { + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) + unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); + instanceCount -= renderedInstanceCount; + + // We fill the instancing buffer with our world matrices + instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); + instanceMatrices += renderedInstanceCount; + + // And we draw + instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + } } + + // We don't forget to disable the blending to avoid to interferering with the rest of the rendering + Renderer::Enable(RendererParameter_Blend, false); + Renderer::SetDepthFunc(oldDepthFunc); } else { - // Without instancing, we must do a draw call for each instance - // This may be faster than instancing under a certain number - // Due to the time to modify the instancing buffer - for (const Matrix4f& matrix : instances) + if (shaderUniforms->hasLightUniforms) { - Renderer::SetMatrix(MatrixType_World, matrix); - drawFunc(meshData.primitiveMode, 0, indexCount); + for (const Matrix4f& matrix : instances) + { + // Choose the lights depending on an object position and apparent radius + ChooseLights(Spheref(matrix.GetTranslation() + squaredBoundingSphere.GetPosition(), squaredBoundingSphere.radius)); + + unsigned int lightCount = m_lights.size(); + + Renderer::SetMatrix(MatrixType_World, matrix); + unsigned int lightIndex = 0; + RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it + + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + for (unsigned int pass = 0; pass < passCount; ++pass) + { + lightCount -= std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); + + if (pass == 1) + { + // To add the result of light computations + // We won't interfeer with materials parameters because we only render opaques objects + // (A.K.A., without blending) + // About the depth function, it must be applied only the first time + Renderer::Enable(RendererParameter_Blend, true); + Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); + Renderer::SetDepthFunc(RendererComparison_Equal); + } + + // Sends the light uniforms to the shader + for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) + SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); + + // And we draw + drawFunc(meshData.primitiveMode, 0, indexCount); + } + + Renderer::Enable(RendererParameter_Blend, false); + Renderer::SetDepthFunc(oldDepthFunc); + } + } + else + { + // Without instancing, we must do a draw call for each instance + // This may be faster than instancing under a certain number + // Due to the time to modify the instancing buffer + for (const Matrix4f& matrix : instances) + { + Renderer::SetMatrix(MatrixType_World, matrix); + drawFunc(meshData.primitiveMode, 0, indexCount); + } } } + instances.clear(); } - instances.clear(); } + + matEntry.enabled = false; } } - // And we set the data back to zero - matEntry.enabled = false; - matEntry.instancingEnabled = false; + pipelineEntry.maxInstanceCount = 0; } } } @@ -775,6 +804,8 @@ namespace Nz { NazaraAssert(sceneData.viewer, "Invalid viewer"); + const MaterialPipeline* lastPipeline = nullptr; + const MaterialPipeline::Instance* pipelineInstance = nullptr; const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; unsigned int lightCount = 0; @@ -786,9 +817,16 @@ namespace Nz // Material const Material* material = modelData.material; + const MaterialPipeline* pipeline = material->GetPipeline(); + if (pipeline != lastPipeline) + { + pipelineInstance = &pipeline->Apply(); + lastPipeline = pipeline; + } + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; - const Shader* shader = material->Apply(0, 0, &freeTextureUnit); + const Shader* shader = material->Apply(*pipelineInstance, 0, &freeTextureUnit); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index 5e6cd72b7..6e1c3ee5f 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -63,12 +63,20 @@ namespace Nz // Initialisation of the module CallOnExit onExit(Graphics::Uninitialize); + // Materials + if (!MaterialPipeline::Initialize()) + { + NazaraError("Failed to initialize material pipelines"); + return false; + } + if (!Material::Initialize()) { NazaraError("Failed to initialize materials"); return false; } + // Renderables if (!ParticleController::Initialize()) { NazaraError("Failed to initialize particle controllers"); @@ -121,7 +129,7 @@ namespace Nz Loaders::RegisterMesh(); Loaders::RegisterTexture(); - // RenderTechniques + // Render techniques if (!DepthRenderTechnique::Initialize()) { NazaraError("Failed to initialize Depth Rendering"); @@ -213,19 +221,25 @@ namespace Nz Loaders::UnregisterMesh(); Loaders::UnregisterTexture(); - DeferredRenderTechnique::Uninitialize(); - DepthRenderTechnique::Uninitialize(); - ForwardRenderTechnique::Uninitialize(); - SkinningManager::Uninitialize(); + // Renderables ParticleRenderer::Uninitialize(); ParticleGenerator::Uninitialize(); ParticleDeclaration::Uninitialize(); ParticleController::Uninitialize(); - Material::Uninitialize(); SkyboxBackground::Uninitialize(); Sprite::Uninitialize(); TileMap::Uninitialize(); + // Render techniques + DeferredRenderTechnique::Uninitialize(); + DepthRenderTechnique::Uninitialize(); + ForwardRenderTechnique::Uninitialize(); + SkinningManager::Uninitialize(); + + // Materials + Material::Uninitialize(); + MaterialPipeline::Uninitialize(); + NazaraNotice("Uninitialized: Graphics module"); // Free of dependances diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 53e0e3e3e..b81bd82b4 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -2,40 +2,15 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#ifndef NAZARA_RENDERER_OPENGL -#define NAZARA_RENDERER_OPENGL // Mandatory to include the OpenGL headers -#endif - #include #include -#include #include -#include #include #include #include namespace Nz { - namespace - { - const UInt8 r_basicFragmentShader[] = { - #include - }; - - const UInt8 r_basicVertexShader[] = { - #include - }; - - const UInt8 r_phongLightingFragmentShader[] = { - #include - }; - - const UInt8 r_phongLightingVertexShader[] = { - #include - }; - } - /*! * \ingroup graphics * \class Nz::Material @@ -46,7 +21,6 @@ namespace Nz * \brief Checks whether the parameters for the material are correct * \return true If parameters are valid */ - bool MaterialParams::IsValid() const { if (!UberShaderLibrary::Has(shaderName)) @@ -57,41 +31,35 @@ namespace Nz /*! * \brief Applies shader to the material - * \return Constant pointer to the shader * - * \param shaderFlags Flags for the shader + * \param instance Pipeline instance to update * \param textureUnit Unit for the texture GL_TEXTURE"i" * \param lastUsedUnit Optional argument to get the last texture unit */ - - const Shader* Material::Apply(UInt32 shaderFlags, UInt8 textureUnit, UInt8* lastUsedUnit) const + void Material::Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit, UInt8* lastUsedUnit) const { - const ShaderInstance& instance = m_shaders[shaderFlags]; - if (!instance.uberInstance) - GenerateShader(shaderFlags); - - instance.uberInstance->Activate(); + const Shader* shader = instance.renderPipeline.GetInfo().shader; if (instance.uniforms[MaterialUniform_AlphaThreshold] != -1) - instance.shader->SendFloat(instance.uniforms[MaterialUniform_AlphaThreshold], m_alphaThreshold); + shader->SendFloat(instance.uniforms[MaterialUniform_AlphaThreshold], m_alphaThreshold); if (instance.uniforms[MaterialUniform_Ambient] != -1) - instance.shader->SendColor(instance.uniforms[MaterialUniform_Ambient], m_ambientColor); + shader->SendColor(instance.uniforms[MaterialUniform_Ambient], m_ambientColor); if (instance.uniforms[MaterialUniform_Diffuse] != -1) - instance.shader->SendColor(instance.uniforms[MaterialUniform_Diffuse], m_diffuseColor); + shader->SendColor(instance.uniforms[MaterialUniform_Diffuse], m_diffuseColor); if (instance.uniforms[MaterialUniform_Shininess] != -1) - instance.shader->SendFloat(instance.uniforms[MaterialUniform_Shininess], m_shininess); + shader->SendFloat(instance.uniforms[MaterialUniform_Shininess], m_shininess); if (instance.uniforms[MaterialUniform_Specular] != -1) - instance.shader->SendColor(instance.uniforms[MaterialUniform_Specular], m_specularColor); + shader->SendColor(instance.uniforms[MaterialUniform_Specular], m_specularColor); if (m_alphaMap && instance.uniforms[MaterialUniform_AlphaMap] != -1) { Renderer::SetTexture(textureUnit, m_alphaMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], textureUnit); textureUnit++; } @@ -99,7 +67,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_diffuseMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], textureUnit); textureUnit++; } @@ -107,7 +75,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_emissiveMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_EmissiveMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_EmissiveMap], textureUnit); textureUnit++; } @@ -115,7 +83,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_heightMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], textureUnit); textureUnit++; } @@ -123,7 +91,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_normalMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], textureUnit); textureUnit++; } @@ -131,25 +99,20 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_specularMap); Renderer::SetTextureSampler(textureUnit, m_specularSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_SpecularMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_SpecularMap], textureUnit); textureUnit++; } - Renderer::SetRenderStates(m_states); - if (lastUsedUnit) *lastUsedUnit = textureUnit; - - return instance.shader; } /*! - * \brief Builds the material from parameters + * \brief Builds the material from a parameter list * * \param matData Data information for the material - * \param matParams Parameters for the material + * \param matParams Additional parameters for the material */ - void Material::BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams) { Color color; @@ -160,7 +123,6 @@ namespace Nz ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled, true); - if (matData.GetFloatParameter(MaterialData::AlphaThreshold, &fValue)) SetAlphaThreshold(fValue); @@ -188,14 +150,11 @@ namespace Nz if (matData.GetIntegerParameter(MaterialData::FaceFilling, &iValue)) SetFaceFilling(static_cast(iValue)); - if (matData.GetBooleanParameter(MaterialData::Lighting, &isEnabled)) - EnableLighting(isEnabled); - if (matData.GetFloatParameter(MaterialData::LineWidth, &fValue)) - m_states.lineWidth = fValue; + SetLineWidth(fValue); if (matData.GetFloatParameter(MaterialData::PointSize, &fValue)) - m_states.pointSize = fValue; + SetPointSize(fValue); if (matData.GetColorParameter(MaterialData::SpecularColor, &color)) SetSpecularColor(color); @@ -206,30 +165,27 @@ namespace Nz if (matData.GetIntegerParameter(MaterialData::SrcBlend, &iValue)) SetSrcBlend(static_cast(iValue)); - if (matData.GetBooleanParameter(MaterialData::Transform, &isEnabled)) - EnableTransform(isEnabled); - // RendererParameter if (matData.GetBooleanParameter(MaterialData::Blending, &isEnabled)) - Enable(RendererParameter_Blend, isEnabled); + EnableBlending(isEnabled); if (matData.GetBooleanParameter(MaterialData::ColorWrite, &isEnabled)) - Enable(RendererParameter_ColorWrite, isEnabled); + EnableColorWrite(isEnabled); if (matData.GetBooleanParameter(MaterialData::DepthBuffer, &isEnabled)) - Enable(RendererParameter_DepthBuffer, isEnabled); + EnableDepthBuffer(isEnabled); if (matData.GetBooleanParameter(MaterialData::DepthWrite, &isEnabled)) - Enable(RendererParameter_DepthWrite, isEnabled); + EnableDepthWrite(isEnabled); if (matData.GetBooleanParameter(MaterialData::FaceCulling, &isEnabled)) - Enable(RendererParameter_FaceCulling, isEnabled); + EnableFaceCulling(isEnabled); if (matData.GetBooleanParameter(MaterialData::ScissorTest, &isEnabled)) - Enable(RendererParameter_ScissorTest, isEnabled); + EnableScissorTest(isEnabled); if (matData.GetBooleanParameter(MaterialData::StencilTest, &isEnabled)) - Enable(RendererParameter_StencilTest, isEnabled); + EnableStencilTest(isEnabled); // Samplers if (matData.GetIntegerParameter(MaterialData::DiffuseAnisotropyLevel, &iValue)) @@ -252,41 +208,43 @@ namespace Nz // Stencil if (matData.GetIntegerParameter(MaterialData::StencilCompare, &iValue)) - m_states.stencilCompare.front = static_cast(iValue); + m_pipelineInfo.stencilCompare.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilFail, &iValue)) - m_states.stencilFail.front = static_cast(iValue); + m_pipelineInfo.stencilFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilPass, &iValue)) - m_states.stencilPass.front = static_cast(iValue); + m_pipelineInfo.stencilPass.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilZFail, &iValue)) - m_states.stencilDepthFail.front = static_cast(iValue); + m_pipelineInfo.stencilDepthFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilMask, &iValue)) - m_states.stencilWriteMask.front = static_cast(iValue); + m_pipelineInfo.stencilWriteMask.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilReference, &iValue)) - m_states.stencilReference.front = static_cast(iValue); + m_pipelineInfo.stencilReference.front = static_cast(iValue); // Stencil (back) if (matData.GetIntegerParameter(MaterialData::BackFaceStencilCompare, &iValue)) - m_states.stencilCompare.back = static_cast(iValue); + m_pipelineInfo.stencilCompare.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilFail, &iValue)) - m_states.stencilFail.back = static_cast(iValue); + m_pipelineInfo.stencilFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilPass, &iValue)) - m_states.stencilPass.back = static_cast(iValue); + m_pipelineInfo.stencilPass.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilZFail, &iValue)) - m_states.stencilDepthFail.back = static_cast(iValue); + m_pipelineInfo.stencilDepthFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilMask, &iValue)) - m_states.stencilWriteMask.back = static_cast(iValue); + m_pipelineInfo.stencilWriteMask.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilReference, &iValue)) - m_states.stencilReference.back = static_cast(iValue); + m_pipelineInfo.stencilReference.back = static_cast(iValue); + + InvalidatePipeline(); // Textures if (matParams.loadAlphaMap && matData.GetStringParameter(MaterialData::AlphaTexturePath, &path)) @@ -310,6 +268,11 @@ namespace Nz SetShader(matParams.shaderName); } + /*! + * \brief Builds a ParameterList with material data + * + * \param matData Destination parameter list which will receive material data + */ void Material::SaveToParameters(ParameterList* matData) { NazaraAssert(matData, "Invalid ParameterList"); @@ -323,22 +286,20 @@ namespace Nz matData->SetParameter(MaterialData::DiffuseColor, GetDiffuseColor()); matData->SetParameter(MaterialData::DstBlend, int(GetDstBlend())); matData->SetParameter(MaterialData::FaceFilling, int(GetFaceFilling())); - matData->SetParameter(MaterialData::Lighting, IsLightingEnabled()); - matData->SetParameter(MaterialData::LineWidth, GetRenderStates().lineWidth); - matData->SetParameter(MaterialData::PointSize, GetRenderStates().pointSize); + matData->SetParameter(MaterialData::LineWidth, GetLineWidth()); + matData->SetParameter(MaterialData::PointSize, GetPointSize()); matData->SetParameter(MaterialData::Shininess, GetShininess()); matData->SetParameter(MaterialData::SpecularColor, GetSpecularColor()); matData->SetParameter(MaterialData::SrcBlend, int(GetSrcBlend())); - matData->SetParameter(MaterialData::Transform, IsTransformEnabled()); // RendererParameter - matData->SetParameter(MaterialData::Blending, GetRenderStates().blending); - matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().colorWrite); - matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().depthBuffer); - matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().depthWrite); - matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().faceCulling); - matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().scissorTest); - matData->SetParameter(MaterialData::StencilTest, GetRenderStates().stencilTest); + matData->SetParameter(MaterialData::Blending, IsBlendingEnabled()); + matData->SetParameter(MaterialData::ColorWrite, IsColorWriteEnabled()); + matData->SetParameter(MaterialData::DepthBuffer, IsDepthBufferEnabled()); + matData->SetParameter(MaterialData::DepthWrite, IsDepthWriteEnabled()); + matData->SetParameter(MaterialData::FaceCulling, IsFaceCullingEnabled()); + matData->SetParameter(MaterialData::ScissorTest, IsScissorTestEnabled()); + matData->SetParameter(MaterialData::StencilTest, IsStencilTestEnabled()); // Samplers matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, int(GetDiffuseSampler().GetAnisotropicLevel())); @@ -350,20 +311,20 @@ namespace Nz matData->SetParameter(MaterialData::SpecularWrap, int(GetSpecularSampler().GetWrapMode())); // Stencil - matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().stencilCompare.front)); - matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().stencilFail.front)); - matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().stencilPass.front)); - matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().stencilDepthFail.front)); - matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().stencilWriteMask.front)); - matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().stencilReference.front)); + matData->SetParameter(MaterialData::StencilCompare, int(GetPipelineInfo().stencilCompare.front)); + matData->SetParameter(MaterialData::StencilFail, int(GetPipelineInfo().stencilFail.front)); + matData->SetParameter(MaterialData::StencilPass, int(GetPipelineInfo().stencilPass.front)); + matData->SetParameter(MaterialData::StencilZFail, int(GetPipelineInfo().stencilDepthFail.front)); + matData->SetParameter(MaterialData::StencilMask, int(GetPipelineInfo().stencilWriteMask.front)); + matData->SetParameter(MaterialData::StencilReference, int(GetPipelineInfo().stencilReference.front)); // Stencil (back) - matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().stencilCompare.back)); - matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().stencilFail.back)); - matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().stencilPass.back)); - matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().stencilDepthFail.back)); - matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().stencilWriteMask.back)); - matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().stencilReference.back)); + matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetPipelineInfo().stencilCompare.back)); + matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetPipelineInfo().stencilFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetPipelineInfo().stencilPass.back)); + matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetPipelineInfo().stencilDepthFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetPipelineInfo().stencilWriteMask.back)); + matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetPipelineInfo().stencilReference.back)); // Textures if (HasAlphaMap()) @@ -411,6 +372,8 @@ namespace Nz /*! * \brief Resets the material, cleans everything + * + * \remark Invalidates the pipeline */ void Material::Reset() { @@ -423,29 +386,22 @@ namespace Nz m_heightMap.Reset(); m_normalMap.Reset(); m_specularMap.Reset(); - m_uberShader.Reset(); - - for (ShaderInstance& instance : m_shaders) - instance.uberInstance = nullptr; m_alphaThreshold = 0.2f; - m_alphaTestEnabled = false; m_ambientColor = Color(128, 128, 128); - m_depthSortingEnabled = false; m_diffuseColor = Color::White; m_diffuseSampler = TextureSampler(); - m_lightingEnabled = true; m_shadowCastingEnabled = true; - m_shadowReceiveEnabled = true; m_shininess = 50.f; m_specularColor = Color::White; m_specularSampler = TextureSampler(); - m_states = RenderStates(); - m_states.depthBuffer = true; - m_states.faceCulling = true; - m_transformEnabled = true; + m_pipelineInfo = MaterialPipelineInfo(); + m_pipelineInfo.depthBuffer = true; + m_pipelineInfo.faceCulling = true; SetShader("Basic"); + + InvalidatePipeline(); } /*! @@ -453,24 +409,18 @@ namespace Nz * * \param material Material to copy into this */ - void Material::Copy(const Material& material) { // Copy of base states - m_alphaTestEnabled = material.m_alphaTestEnabled; m_alphaThreshold = material.m_alphaThreshold; m_ambientColor = material.m_ambientColor; - m_depthSortingEnabled = material.m_depthSortingEnabled; m_diffuseColor = material.m_diffuseColor; m_diffuseSampler = material.m_diffuseSampler; - m_lightingEnabled = material.m_lightingEnabled; + m_pipelineInfo = material.m_pipelineInfo; m_shininess = material.m_shininess; m_shadowCastingEnabled = material.m_shadowCastingEnabled; - m_shadowReceiveEnabled = material.m_shadowReceiveEnabled; m_specularColor = material.m_specularColor; m_specularSampler = material.m_specularSampler; - m_states = material.m_states; - m_transformEnabled = material.m_transformEnabled; // Copy of reference to the textures m_alphaMap = material.m_alphaMap; @@ -480,61 +430,8 @@ namespace Nz m_heightMap = material.m_heightMap; m_normalMap = material.m_normalMap; m_specularMap = material.m_specularMap; - m_uberShader = material.m_uberShader; - // We copy the instances of the shader too - std::memcpy(&m_shaders[0], &material.m_shaders[0], (ShaderFlags_Max + 1) * sizeof(ShaderInstance)); - } - - /*! - * \brief Generates the shader based on flag - * - * \param flags Flag for the shaer - */ - - void Material::GenerateShader(UInt32 flags) const - { - ParameterList list; - list.SetParameter("ALPHA_MAPPING", m_alphaMap.IsValid()); - list.SetParameter("ALPHA_TEST", m_alphaTestEnabled); - list.SetParameter("COMPUTE_TBNMATRIX", m_normalMap.IsValid() || m_heightMap.IsValid()); - list.SetParameter("DIFFUSE_MAPPING", m_diffuseMap.IsValid()); - list.SetParameter("EMISSIVE_MAPPING", m_emissiveMap.IsValid()); - list.SetParameter("LIGHTING", m_lightingEnabled); - list.SetParameter("NORMAL_MAPPING", m_normalMap.IsValid()); - list.SetParameter("PARALLAX_MAPPING", m_heightMap.IsValid()); - list.SetParameter("SHADOW_MAPPING", m_shadowReceiveEnabled); - list.SetParameter("SPECULAR_MAPPING", m_specularMap.IsValid()); - list.SetParameter("TEXTURE_MAPPING", m_alphaMap.IsValid() || m_diffuseMap.IsValid() || m_emissiveMap.IsValid() || - m_normalMap.IsValid() || m_heightMap.IsValid() || m_specularMap.IsValid() || - flags & ShaderFlags_TextureOverlay); - list.SetParameter("TRANSFORM", m_transformEnabled); - - list.SetParameter("FLAG_BILLBOARD", static_cast((flags & ShaderFlags_Billboard) != 0)); - list.SetParameter("FLAG_DEFERRED", static_cast((flags & ShaderFlags_Deferred) != 0)); - list.SetParameter("FLAG_INSTANCING", static_cast((flags & ShaderFlags_Instancing) != 0)); - list.SetParameter("FLAG_TEXTUREOVERLAY", static_cast((flags & ShaderFlags_TextureOverlay) != 0)); - list.SetParameter("FLAG_VERTEXCOLOR", static_cast((flags & ShaderFlags_VertexColor) != 0)); - - ShaderInstance& instance = m_shaders[flags]; - instance.uberInstance = m_uberShader->Get(list); - instance.shader = instance.uberInstance->GetShader(); - - #define CacheUniform(name) instance.uniforms[MaterialUniform_##name] = instance.shader->GetUniformLocation("Material" #name) - - CacheUniform(AlphaMap); - CacheUniform(AlphaThreshold); - CacheUniform(Ambient); - CacheUniform(Diffuse); - CacheUniform(DiffuseMap); - CacheUniform(EmissiveMap); - CacheUniform(HeightMap); - CacheUniform(NormalMap); - CacheUniform(Shininess); - CacheUniform(Specular); - CacheUniform(SpecularMap); - - #undef CacheUniform + InvalidatePipeline(); } /*! @@ -543,7 +440,6 @@ namespace Nz * * \remark Produces a NazaraError if the material library failed to be initialized */ - bool Material::Initialize() { if (!MaterialLibrary::Initialize()) @@ -558,67 +454,21 @@ namespace Nz return false; } - // Basic shader - { - UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); - - String fragmentShader(reinterpret_cast(r_basicFragmentShader), sizeof(r_basicFragmentShader)); - String vertexShader(reinterpret_cast(r_basicVertexShader), sizeof(r_basicVertexShader)); - - uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING"); - uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_INSTANCING FLAG_VERTEXCOLOR TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); - - UberShaderLibrary::Register("Basic", uberShader); - } - - // PhongLighting shader - { - UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); - - String fragmentShader(reinterpret_cast(r_phongLightingFragmentShader), sizeof(r_phongLightingFragmentShader)); - String vertexShader(reinterpret_cast(r_phongLightingVertexShader), sizeof(r_phongLightingVertexShader)); - - uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_DEFERRED FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING EMISSIVE_MAPPING LIGHTING NORMAL_MAPPING PARALLAX_MAPPING SHADOW_MAPPING SPECULAR_MAPPING"); - uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_DEFERRED FLAG_INSTANCING FLAG_VERTEXCOLOR COMPUTE_TBNMATRIX LIGHTING PARALLAX_MAPPING SHADOW_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); - - UberShaderLibrary::Register("PhongLighting", uberShader); - } - - // Once the base shaders are registered, we can now set some default materials s_defaultMaterial = New(); - s_defaultMaterial->Enable(RendererParameter_FaceCulling, false); + s_defaultMaterial->EnableFaceCulling(false); s_defaultMaterial->SetFaceFilling(FaceFilling_Line); MaterialLibrary::Register("Default", s_defaultMaterial); - MaterialRef mat; - - mat = New(); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - MaterialLibrary::Register("Basic2D", std::move(mat)); - - mat = New(); - mat->Enable(RendererParameter_Blend, true); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - mat->SetDstBlend(BlendFunc_InvSrcAlpha); - mat->SetSrcBlend(BlendFunc_SrcAlpha); - MaterialLibrary::Register("Translucent2D", std::move(mat)); - return true; } /*! * \brief Uninitializes the material librairies */ - void Material::Uninitialize() { s_defaultMaterial.Reset(); - UberShaderLibrary::Unregister("PhongLighting"); - UberShaderLibrary::Unregister("Basic"); + MaterialManager::Uninitialize(); MaterialLibrary::Uninitialize(); } diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp new file mode 100644 index 000000000..01e9ffe5d --- /dev/null +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -0,0 +1,168 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include + +#ifndef NAZARA_RENDERER_OPENGL +#define NAZARA_RENDERER_OPENGL // Mandatory to include the OpenGL headers +#endif + +#include +#include +#include + +namespace Nz +{ + namespace + { + const UInt8 r_basicFragmentShader[] = { + #include + }; + + const UInt8 r_basicVertexShader[] = { + #include + }; + + const UInt8 r_phongLightingFragmentShader[] = { + #include + }; + + const UInt8 r_phongLightingVertexShader[] = { + #include + }; + } + + /*! + * \ingroup graphics + * \class Nz::MaterialPipeline + * + * \brief Graphics class used to contains all rendering states that are not allowed to change individually on rendering devices + */ + + /*! + * \brief Returns a reference to a MaterialPipeline built with MaterialPipelineInfo + * + * This function is using a cache, calling it multiples times with the same MaterialPipelineInfo will returns references to a single MaterialPipeline + * + * \param pipelineInfo Pipeline informations used to build/retrieve a MaterialPipeline object + */ + MaterialPipelineRef MaterialPipeline::GetPipeline(const MaterialPipelineInfo& pipelineInfo) + { + auto it = s_pipelineCache.lower_bound(pipelineInfo); + if (it == s_pipelineCache.end() || it->first != pipelineInfo) + it = s_pipelineCache.insert(it, PipelineCache::value_type(pipelineInfo, New(pipelineInfo))); + + return it->second; + } + + void MaterialPipeline::GenerateRenderPipeline(UInt32 flags) const + { + ParameterList list; + list.SetParameter("ALPHA_MAPPING", m_pipelineInfo.hasAlphaMap); + list.SetParameter("ALPHA_TEST", m_pipelineInfo.alphaTest); + list.SetParameter("COMPUTE_TBNMATRIX", m_pipelineInfo.hasNormalMap || m_pipelineInfo.hasHeightMap); + list.SetParameter("DIFFUSE_MAPPING", m_pipelineInfo.hasDiffuseMap); + list.SetParameter("EMISSIVE_MAPPING", m_pipelineInfo.hasEmissiveMap); + list.SetParameter("NORMAL_MAPPING", m_pipelineInfo.hasNormalMap); + list.SetParameter("PARALLAX_MAPPING", m_pipelineInfo.hasHeightMap); + list.SetParameter("SHADOW_MAPPING", m_pipelineInfo.shadowReceive); + list.SetParameter("SPECULAR_MAPPING", m_pipelineInfo.hasSpecularMap); + list.SetParameter("TEXTURE_MAPPING", m_pipelineInfo.hasAlphaMap || m_pipelineInfo.hasDiffuseMap || m_pipelineInfo.hasEmissiveMap || + m_pipelineInfo.hasNormalMap || m_pipelineInfo.hasHeightMap || m_pipelineInfo.hasSpecularMap || + flags & ShaderFlags_TextureOverlay); + list.SetParameter("TRANSFORM", true); + + list.SetParameter("FLAG_BILLBOARD", static_cast((flags & ShaderFlags_Billboard) != 0)); + list.SetParameter("FLAG_DEFERRED", static_cast((flags & ShaderFlags_Deferred) != 0)); + list.SetParameter("FLAG_INSTANCING", static_cast((flags & ShaderFlags_Instancing) != 0)); + list.SetParameter("FLAG_TEXTUREOVERLAY", static_cast((flags & ShaderFlags_TextureOverlay) != 0)); + list.SetParameter("FLAG_VERTEXCOLOR", static_cast((flags & ShaderFlags_VertexColor) != 0)); + + Instance& instance = m_instances[flags]; + instance.uberInstance = m_pipelineInfo.uberShader->Get(list); + + RenderPipelineInfo renderPipelineInfo; + static_cast(renderPipelineInfo).operator=(m_pipelineInfo); // Not my proudest line + + renderPipelineInfo.shader = instance.uberInstance->GetShader(); + + instance.renderPipeline.Create(renderPipelineInfo); + + #define CacheUniform(name) instance.uniforms[MaterialUniform_##name] = renderPipelineInfo.shader->GetUniformLocation("Material" #name) + + CacheUniform(AlphaMap); + CacheUniform(AlphaThreshold); + CacheUniform(Ambient); + CacheUniform(Diffuse); + CacheUniform(DiffuseMap); + CacheUniform(EmissiveMap); + CacheUniform(HeightMap); + CacheUniform(NormalMap); + CacheUniform(Shininess); + CacheUniform(Specular); + CacheUniform(SpecularMap); + + #undef CacheUniform + } + + bool MaterialPipeline::Initialize() + { + // Basic shader + { + UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); + + String fragmentShader(reinterpret_cast(r_basicFragmentShader), sizeof(r_basicFragmentShader)); + String vertexShader(reinterpret_cast(r_basicVertexShader), sizeof(r_basicVertexShader)); + + uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING"); + uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_INSTANCING FLAG_VERTEXCOLOR TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); + + UberShaderLibrary::Register("Basic", uberShader); + } + + // PhongLighting shader + { + UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); + + String fragmentShader(reinterpret_cast(r_phongLightingFragmentShader), sizeof(r_phongLightingFragmentShader)); + String vertexShader(reinterpret_cast(r_phongLightingVertexShader), sizeof(r_phongLightingVertexShader)); + + uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_DEFERRED FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING EMISSIVE_MAPPING NORMAL_MAPPING PARALLAX_MAPPING SHADOW_MAPPING SPECULAR_MAPPING"); + uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_DEFERRED FLAG_INSTANCING FLAG_VERTEXCOLOR COMPUTE_TBNMATRIX PARALLAX_MAPPING SHADOW_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); + + UberShaderLibrary::Register("PhongLighting", uberShader); + } + + // Once the base shaders are registered, we can now set some default materials + MaterialPipelineInfo pipelineInfo; + + // Basic 2D - No depth write/face culling + pipelineInfo.depthWrite = false; + pipelineInfo.faceCulling = false; + + MaterialPipelineLibrary::Register("Basic2D", GetPipeline(pipelineInfo)); + + // Translucent 2D - Alpha blending with no depth write/face culling + pipelineInfo.blending = false; + pipelineInfo.depthWrite = false; + pipelineInfo.faceCulling = false; + pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; + pipelineInfo.srcBlend = BlendFunc_SrcAlpha; + + MaterialPipelineLibrary::Register("Translucent2D", GetPipeline(pipelineInfo)); + + return true; + } + + void MaterialPipeline::Uninitialize() + { + s_pipelineCache.clear(); + UberShaderLibrary::Unregister("PhongLighting"); + UberShaderLibrary::Unregister("Basic"); + MaterialPipelineLibrary::Uninitialize(); + } + + MaterialPipelineLibrary::LibraryMap MaterialPipeline::s_library; + MaterialPipeline::PipelineCache MaterialPipeline::s_pipelineCache; +} \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index 61ed69632..a3391be91 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -132,7 +132,7 @@ void main() vec2 texCoord = vTexCoord; #endif -#if LIGHTING && PARALLAX_MAPPING +#if PARALLAX_MAPPING float height = texture(MaterialHeightMap, texCoord).r; float v = height*ParallaxScale + ParallaxBias; @@ -159,17 +159,16 @@ void main() discard; #endif // ALPHA_TEST - #if LIGHTING - #if NORMAL_MAPPING + #if NORMAL_MAPPING vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0)); - #else + #else vec3 normal = normalize(vNormal); - #endif // NORMAL_MAPPING + #endif // NORMAL_MAPPING vec3 specularColor = MaterialSpecular.rgb; - #if SPECULAR_MAPPING + #if SPECULAR_MAPPING specularColor *= texture(MaterialSpecularMap, texCoord).rgb; - #endif + #endif /* Texture0: Diffuse Color + Specular @@ -179,9 +178,6 @@ void main() RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11))); RenderTarget1 = vec4(EncodeNormal(normal)); RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf - #else // LIGHTING - RenderTarget0 = vec4(diffuseColor.rgb, 0.0); - #endif #else // FLAG_DEFERRED #if ALPHA_MAPPING diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r; @@ -192,16 +188,15 @@ void main() discard; #endif - #if LIGHTING vec3 lightAmbient = vec3(0.0); vec3 lightDiffuse = vec3(0.0); vec3 lightSpecular = vec3(0.0); - #if NORMAL_MAPPING + #if NORMAL_MAPPING vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0)); - #else + #else vec3 normal = normalize(vNormal); - #endif + #endif if (MaterialShininess > 0.0) { @@ -459,24 +454,21 @@ void main() } lightSpecular *= MaterialSpecular.rgb; - #if SPECULAR_MAPPING + #if SPECULAR_MAPPING lightSpecular *= texture(MaterialSpecularMap, texCoord).rgb; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens - #endif + #endif vec3 lightColor = (lightAmbient + lightDiffuse + lightSpecular); vec4 fragmentColor = vec4(lightColor, 1.0) * diffuseColor; - #if EMISSIVE_MAPPING + #if EMISSIVE_MAPPING float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11)); vec3 emissionColor = MaterialDiffuse.rgb * texture(MaterialEmissiveMap, texCoord).rgb; RenderTarget0 = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a); - #else - RenderTarget0 = fragmentColor; - #endif // EMISSIVE_MAPPING #else - RenderTarget0 = diffuseColor; - #endif // LIGHTING + RenderTarget0 = fragmentColor; + #endif // EMISSIVE_MAPPING #endif // FLAG_DEFERRED } diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index 6f1495308..c77a33db2 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,9,35,101,108,115,101,32,47,47,32,76,73,71,72,84,73,78,71,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,10,35,101,110,100,105,102,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,99,111,108,111,114,59,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,10,125,59,10,10,47,47,32,76,117,109,105,195,168,114,101,115,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,10,47,47,32,77,97,116,195,169,114,105,97,117,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,47,47,32,65,117,116,114,101,115,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,10,123,10,9,118,101,99,51,32,99,111,108,111,114,59,10,10,9,102,32,42,61,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,10,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,10,125,10,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,10,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,10,123,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,10,125,10,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,10,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,10,125,10,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,10,9,102,108,111,97,116,32,120,44,121,59,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,10,9,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,10,125,10,35,101,110,100,105,102,10,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,10,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,35,101,108,115,101,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,10,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,10,35,101,110,100,105,102,10,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,9,35,101,110,100,105,102,10,9,9,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,35,101,110,100,105,102,10,10,9,47,42,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,10,9,42,47,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,10,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,35,101,110,100,105,102,10,9,9,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,125,10,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert index 0f4c869a6..8943c5935 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert @@ -12,6 +12,7 @@ in vec3 VertexPosition; in vec3 VertexNormal; in vec3 VertexTangent; in vec2 VertexTexCoord; +in vec4 VertexUserdata0; /********************Sortant********************/ out vec4 vColor; @@ -27,6 +28,7 @@ uniform vec3 EyePosition; uniform mat4 InvViewMatrix; uniform mat4 LightViewProjMatrix[3]; uniform float VertexDepth; +uniform mat4 ViewMatrix; uniform mat4 ViewProjMatrix; uniform mat4 WorldMatrix; uniform mat4 WorldViewProjMatrix; @@ -107,21 +109,19 @@ void main() vColor = color; -#if LIGHTING - #if FLAG_INSTANCING +#if FLAG_INSTANCING mat3 rotationMatrix = mat3(InstanceData0); - #else +#else mat3 rotationMatrix = mat3(WorldMatrix); - #endif +#endif - #if COMPUTE_TBNMATRIX +#if COMPUTE_TBNMATRIX vec3 binormal = cross(VertexNormal, VertexTangent); vLightToWorld[0] = normalize(rotationMatrix * VertexTangent); vLightToWorld[1] = normalize(rotationMatrix * binormal); vLightToWorld[2] = normalize(rotationMatrix * VertexNormal); - #else +#else vNormal = normalize(rotationMatrix * VertexNormal); - #endif #endif #if SHADOW_MAPPING @@ -133,12 +133,12 @@ void main() vTexCoord = VertexTexCoord; #endif -#if LIGHTING && PARALLAX_MAPPING +#if PARALLAX_MAPPING vViewDir = EyePosition - VertexPosition; vViewDir *= vLightToWorld; #endif -#if LIGHTING && !FLAG_DEFERRED +#if !FLAG_DEFERRED #if FLAG_INSTANCING vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0)); #else diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h index c1611105a..bed6edcab 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h @@ -1 +1 @@ -47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,13,10,9,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,13,10,9,35,101,110,100,105,102,13,10,9,13,10,9,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,13,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,13,10,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,13,10,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,13,10,35,101,110,100,105,102,13,10,9,13,10,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,13,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file From 82a082341c5713fcfe58fdb1e17ca318a2393ac0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 22:58:14 +0200 Subject: [PATCH 140/235] Graphics: Fix build Former-commit-id: cd9330ad49ce39306e27467fa59a680cbdd1b18f [formerly ff3f48136855717fcb83813c5da97cc98626680c] [formerly dd21940dc6c23459b3c7ba44d1ae1f911779e0c9 [formerly 9cb35278aacc1f07935bface1cc59f617448c2d2]] Former-commit-id: 744562fcd5ff9501b8d7003d56cde60b52ae25ad [formerly e49b23beeb93595203783ec375f471773497d50c] Former-commit-id: 9b3b5e63ff32a20779e2599e45a97b618cf95f93 --- src/Nazara/Graphics/ForwardRenderTechnique.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index aad29ab88..91507ee68 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -824,11 +824,12 @@ namespace Nz lastPipeline = pipeline; } - // We begin to apply the material (and get the shader activated doing so) + // We begin to apply the material UInt8 freeTextureUnit; - const Shader* shader = material->Apply(*pipelineInstance, 0, &freeTextureUnit); + material->Apply(*pipelineInstance, 0, &freeTextureUnit); // Uniforms are conserved in our program, there's no point to send them back until they change + const Shader* shader = pipelineInstance->uberInstance->GetShader(); if (shader != lastShader) { // Index of uniforms in the shader From cf287b1eb25aba96d7360cb8810f0216b0602848 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 6 Aug 2016 01:07:09 +0200 Subject: [PATCH 141/235] Graphics/ParticleGroup: Emitters are now updated in case of move and removed in case of release Former-commit-id: 6603dd15dd55be43181a2682d0357c6b0371a9f6 [formerly dcd942ae41237a51e6a4e51838f7ccbab26453a7] [formerly 6c0e05bb3e1f9c22a2db8ab7c41b61701918b0dc [formerly c104626f082f38cfc48ee3bce67ffb7f2eea0715]] Former-commit-id: 5315a5a45cc3087df6938e95723b288d44e5a33d [formerly bd0898d00b042e3271927b063224709c5b43a05c] Former-commit-id: c80f244a446823cb043ad8fa4f362ccbf989e36d --- include/Nazara/Graphics/ParticleEmitter.hpp | 4 +- include/Nazara/Graphics/ParticleGroup.hpp | 12 +++++- src/Nazara/Graphics/ParticleEmitter.cpp | 8 ++++ src/Nazara/Graphics/ParticleGroup.cpp | 42 ++++++++++++++++++--- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index b7a168262..8bd26a4bd 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -20,7 +20,7 @@ namespace Nz { public: ParticleEmitter(); - ParticleEmitter(const ParticleEmitter& emitter) = default; + ParticleEmitter(const ParticleEmitter& emitter); ParticleEmitter(ParticleEmitter&& emitter); virtual ~ParticleEmitter(); @@ -40,7 +40,7 @@ namespace Nz ParticleEmitter& operator=(ParticleEmitter&& emitter); // Signals: - NazaraSignal(OnParticleEmitterMove, const ParticleEmitter* /*oldParticleEmitter*/, const ParticleEmitter* /*newParticleEmitter*/); + NazaraSignal(OnParticleEmitterMove, ParticleEmitter* /*oldParticleEmitter*/, ParticleEmitter* /*newParticleEmitter*/); NazaraSignal(OnParticleEmitterRelease, const ParticleEmitter* /*particleEmitter*/); private: diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 4d4704171..9e48d5797 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -68,12 +68,22 @@ namespace Nz private: void MakeBoundingVolume() const override; + void OnEmitterMove(ParticleEmitter* oldEmitter, ParticleEmitter* newEmitter); + void OnEmitterRelease(const ParticleEmitter* emitter); void ResizeBuffer(); + struct EmitterEntry + { + NazaraSlot(ParticleEmitter, OnParticleEmitterMove, moveSlot); + NazaraSlot(ParticleEmitter, OnParticleEmitterRelease, releaseSlot); + + ParticleEmitter* emitter; + }; + std::set> m_dyingParticles; mutable std::vector m_buffer; std::vector m_controllers; - std::vector m_emitters; + std::vector m_emitters; std::vector m_generators; ParticleDeclarationConstRef m_declaration; ParticleRendererRef m_renderer; diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index 10f057dce..fe27575e7 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -32,6 +32,14 @@ namespace Nz { } + ParticleEmitter::ParticleEmitter(const ParticleEmitter& emitter) : + m_lagCompensationEnabled(emitter.m_lagCompensationEnabled), + m_emissionAccumulator(0.f), + m_emissionRate(emitter.m_emissionRate), + m_emissionCount(emitter.m_emissionCount) + { + } + ParticleEmitter::ParticleEmitter(ParticleEmitter&& emitter) : m_lagCompensationEnabled(emitter.m_lagCompensationEnabled), m_emissionAccumulator(0.f), diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index 87dbb390c..5aca6c2b4 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -109,7 +109,12 @@ namespace Nz { NazaraAssert(emitter, "Invalid particle emitter"); - m_emitters.emplace_back(emitter); + EmitterEntry entry; + entry.emitter = emitter; + entry.moveSlot.Connect(emitter->OnParticleEmitterMove, this, &ParticleGroup::OnEmitterMove); + entry.releaseSlot.Connect(emitter->OnParticleEmitterRelease, this, &ParticleGroup::OnEmitterRelease); + + m_emitters.emplace_back(std::move(entry)); } /*! @@ -336,9 +341,14 @@ namespace Nz void ParticleGroup::RemoveEmitter(ParticleEmitter* emitter) { - auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter); - if (it != m_emitters.end()) - m_emitters.erase(it); + for (auto it = m_emitters.begin(); it != m_emitters.end(); ++it) + { + if (it->emitter == emitter) + { + m_emitters.erase(it); + break; + } + } } /*! @@ -374,8 +384,8 @@ namespace Nz void ParticleGroup::Update(float elapsedTime) { // Emission - for (ParticleEmitter* emitter : m_emitters) - emitter->Emit(*this, elapsedTime); + for (const EmitterEntry& entry : m_emitters) + entry.emitter->Emit(*this, elapsedTime); // Update if (m_particleCount > 0) @@ -443,6 +453,26 @@ namespace Nz m_boundingVolume.MakeInfinite(); } + void ParticleGroup::OnEmitterMove(ParticleEmitter* oldEmitter, ParticleEmitter* newEmitter) + { + for (EmitterEntry& entry : m_emitters) + { + if (entry.emitter == oldEmitter) + entry.emitter = newEmitter; + } + } + + void ParticleGroup::OnEmitterRelease(const ParticleEmitter* emitter) + { + for (auto it = m_emitters.begin(); it != m_emitters.end();) + { + if (it->emitter == emitter) + it = m_emitters.erase(it); + else + ++it; + } + } + /*! * \brief Resizes the internal buffer * From 7f707e12508d274e6054115f3389a842b982d62c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 6 Aug 2016 01:09:13 +0200 Subject: [PATCH 142/235] Sdk/ParticleEmitterComponent: Update emitter (they are no longer attached to groups) They are no longer attached to groups, groups attach emitters Former-commit-id: fa4c2eb69147c7a19e9d77f952fdeaec0fdafc24 [formerly 981a7cfe37867842b4fe275cae6b04ab9f8a33c9] [formerly bc3c128bdfdb36eaf09f8f8a650c07e00d7e877c [formerly 1dc92772e589d80f59e8dab5d315387c7c57f886]] Former-commit-id: 6420a724b368ab2e72e67154e76566c7eda9f7a5 [formerly b3912e18e589bff75f8f9a1870fbebffe208f653] Former-commit-id: 1598b8cfb892285daee6dac7cd3283ba8447a032 --- .../Components/ParticleEmitterComponent.hpp | 17 +++---- .../Components/ParticleEmitterComponent.inl | 10 ++++ .../Components/ParticleEmitterComponent.cpp | 46 +------------------ 3 files changed, 18 insertions(+), 55 deletions(-) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp index 8d93e0495..6ad3e3981 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -19,28 +19,23 @@ namespace Ndk public: using SetupFunc = std::function; - ParticleEmitterComponent(Nz::ParticleGroup* group); - ParticleEmitterComponent(const ParticleEmitterComponent& emitter); - ParticleEmitterComponent(ParticleEmitterComponent&& emitter); - ~ParticleEmitterComponent(); + inline ParticleEmitterComponent(); + ParticleEmitterComponent(const ParticleEmitterComponent& emitter) = default; + ParticleEmitterComponent(ParticleEmitterComponent&& emitter) = default; + ~ParticleEmitterComponent() = default; + + void Enable(bool active = true); inline bool IsActive() const; - void SetActive(bool active = true); - void SetGroup(Nz::ParticleGroup* group); inline void SetSetupFunc(SetupFunc func); static ComponentIndex componentIndex; private: - void OnParticleGroupRelease(const Nz::ParticleGroup* particleGroup); - void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override; - NazaraSlot(Nz::ParticleGroup, OnParticleGroupRelease, m_particleGroupRelease); - SetupFunc m_setupFunc; - Nz::ParticleGroup* m_particleGroup; bool m_isActive; }; } diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NDK/Components/ParticleEmitterComponent.inl index 6cc9e8c29..342b5e56f 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.inl +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.inl @@ -6,6 +6,16 @@ namespace Ndk { + inline ParticleEmitterComponent::ParticleEmitterComponent() : + m_isActive(true) + { + } + + inline void Ndk::ParticleEmitterComponent::Enable(bool active) + { + m_isActive = active; + } + inline bool ParticleEmitterComponent::IsActive() const { return m_isActive; diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp index 6a3cfeb7e..2ae4365e6 100644 --- a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp +++ b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp @@ -7,51 +7,9 @@ namespace Ndk { - ParticleEmitterComponent::ParticleEmitterComponent(Nz::ParticleGroup* group) : - m_particleGroup(group), - m_isActive(true) + void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const { - if (m_particleGroup) - m_particleGroup->AddEmitter(this); - } - - ParticleEmitterComponent::ParticleEmitterComponent(const ParticleEmitterComponent& emitter) : - m_particleGroup(emitter.m_particleGroup), - m_isActive(emitter.m_isActive) - { - if (m_isActive) - m_particleGroup->AddEmitter(this); - } - - ParticleEmitterComponent::~ParticleEmitterComponent() - { - m_particleGroup->RemoveEmitter(this); - } - - inline void Ndk::ParticleEmitterComponent::SetActive(bool active) - { - if (m_isActive != active) - { - if (active) - m_particleGroup->AddEmitter(this); - else - m_particleGroup->RemoveEmitter(this); - } - } - - void ParticleEmitterComponent::SetGroup(Nz::ParticleGroup* group) - { - if (m_particleGroup) - m_particleGroup->RemoveEmitter(this); - - m_particleGroup = group; - if (m_particleGroup && m_isActive) - m_particleGroup = group; - } - - inline void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const - { - if (m_setupFunc) + if (m_isActive && m_setupFunc) m_setupFunc(m_entity, mapper, count); } From d93676213b5144b42b5d45da26b017096277438e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 6 Aug 2016 01:11:05 +0200 Subject: [PATCH 143/235] Sdk/LuaBinding: Fix Vector3 constructor Former-commit-id: 3143ebbac02b23c06afc8dfc0a41ee448d6ddcc0 [formerly a8a7456f407dc3a33dcb20ac7a122a5ced670608] [formerly c2749be82c1b62d84462b549bc60f819ce08feac [formerly 7b2e7ec464ac0a9bd893b35a89670cedc60048fd]] Former-commit-id: 820cd7cab67ef0fe5fb0420155d20df82368133f [formerly 8b51babc28e1bdcb620e363a183924afd8d0458d] Former-commit-id: 0a91f61d6a46c2cbe7760e220a6a875050f0dd69 --- SDK/src/NDK/LuaBinding_Math.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index 7db9ae9e2..c1d7b487e 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -205,7 +205,7 @@ namespace Ndk { case Nz::LuaType_Number: { - long long index = lua.CheckInteger(1); + auto index = lua.CheckBoundInteger(1); if (index < 1 || index > 4) return false; @@ -258,7 +258,7 @@ namespace Ndk { case Nz::LuaType_Number: { - long long index = lua.CheckInteger(1); + auto index = lua.CheckBoundInteger(1); if (index < 1 || index > 4) return false; @@ -537,11 +537,12 @@ namespace Ndk case 0: case 3: Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0)); + return true; case 1: { if (lua.IsOfType(1, Nz::LuaType_Number)) - Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.ToUserdata(1))); + Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(1, "Vector2"))); else if (lua.IsOfType(1, "Vector2")) Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); else if (lua.IsOfType(1, "Vector3")) From ad473504995fd2c9134340318eaa6928db58cdd7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 9 Aug 2016 00:08:31 +0200 Subject: [PATCH 144/235] Utility/OBJParser: Fix failure to load some OBJ because of their "high error rate" Former-commit-id: b843560802e9e94693e3009a2bb2fa5b999943b2 [formerly f8d90aced86d82320c6b204df6095d4e90d5d096] [formerly 71eae479386c14f1a849f5298a4273b777591668 [formerly 91000e7d5641e27fce88710737d0fd0852a467fa]] Former-commit-id: 45a6f0bf8ecf22fbbf9413f8d915ccd3010b4556 [formerly 1a1cc33d6ec5afef38988f9b12331ca52c24213b] Former-commit-id: 55c29ffe310d91590fb39c2894817dd8ff862cdb --- include/Nazara/Utility/Formats/OBJParser.inl | 2 +- src/Nazara/Utility/Formats/OBJParser.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 054d57754..b04506fdf 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -179,7 +179,7 @@ namespace Nz m_errorCount++; - if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50) + if (m_errorCount > 10 && (m_errorCount * 100 / m_lineCount) > 50) { NazaraError("Aborting parsing because of error percentage"); return false; //< Abort parsing if error percentage is too high diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 7d3019c39..403950a97 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -31,6 +31,7 @@ namespace Nz String matName, meshName; matName = meshName = "default"; + m_errorCount = 0; m_keepLastLine = false; m_lineCount = 0; m_meshes.clear(); From 957b6162d664760b27e653d568083879b584e106 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 9 Aug 2016 00:08:57 +0200 Subject: [PATCH 145/235] SDK/VelocitySystem: Make VelocitySystem move the node in the global space Former-commit-id: e9606a2ab22e8cf83958ee86b3615b88ef3b3e4b [formerly cd7a2faa614e7052831ad6358956371edb310f00] [formerly dd5570feefd02088d526dc26321edf5d676d06f4 [formerly 410c33af9e42065747ed2b31f3f0cc5c9a8bb247]] Former-commit-id: 2c1ca0aed7d3a7d7e95fbe3bc578cbbbf06417ce [formerly e1e0a73b7dea6b81d8ac45794c879023078c0f6a] Former-commit-id: c35b82110d33f4107b3a662163add6c3b95c26b6 --- SDK/src/NDK/Systems/VelocitySystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/Systems/VelocitySystem.cpp b/SDK/src/NDK/Systems/VelocitySystem.cpp index 882b45728..2d3264039 100644 --- a/SDK/src/NDK/Systems/VelocitySystem.cpp +++ b/SDK/src/NDK/Systems/VelocitySystem.cpp @@ -22,7 +22,7 @@ namespace Ndk NodeComponent& node = entity->GetComponent(); const VelocityComponent& velocity = entity->GetComponent(); - node.Move(velocity.linearVelocity * elapsedTime); + node.Move(velocity.linearVelocity * elapsedTime, Nz::CoordSys_Global); } } From 4efa269502d7573622af14154db9ef2a6498f86a Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 9 Aug 2016 14:10:07 +0200 Subject: [PATCH 146/235] Sdk/BaseWidget: Fix problem with pipeline update Former-commit-id: e068975aa2901fa50bd6f1d96dcb247369c68c6d [formerly e052e8f3d20559d0d8d3f4c00612e103ae3f8d91] [formerly 481d1d386eea41466da421a1cd16747843cea61e [formerly a84c4b38748634526b5b43c02cafc8b16c80fecb]] Former-commit-id: 6bc636bf665ef1a96f2ba1838a554183510294ab [formerly 8465c265f85b5c1af3b43e762015f156f708fd7a] Former-commit-id: 1551828a5fcc5c45c0593787852193c8053f017b --- SDK/src/NDK/BaseWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index acb1270c7..774a36b25 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -24,7 +24,7 @@ namespace Ndk { m_backgroundSprite = Nz::Sprite::New(); m_backgroundSprite->SetColor(m_backgroundColor); - m_backgroundSprite->SetMaterial(Nz::MaterialLibrary::Get((m_backgroundColor.IsOpaque()) ? "Basic2D" : "Translucent2D")); + m_backgroundSprite->SetMaterial(Nz::Material::New((m_backgroundColor.IsOpaque()) ? "Basic2D" : "Translucent2D")); m_backgroundEntity = m_world->CreateEntity(); m_backgroundEntity->AddComponent().Attach(m_backgroundSprite, -1); From 2c076ae1c53145075f501097e5e3d2e77bd92aa5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 14:08:20 +0200 Subject: [PATCH 147/235] Graphics: Deferred Shading is back! Former-commit-id: 7548832de10b4240ff026d2884b9f3db6d48e212 [formerly cb255ac8457c43bd516f8e360527fef7ca898641] [formerly cb64b1420c6b75fdae8b1918b9f1dfbb257a9c75 [formerly 79174685d3af9dd158235728726a05332c5f18ac]] Former-commit-id: aa6beaab51e7f18a587f8a7342e3f92a2af44998 [formerly e0e3c03197aad458a0b36ccfb6138b2e37451131] Former-commit-id: a9c0837e8e81e5a5c1ddfcaf39a881c2480b1c3a --- src/Nazara/Graphics/DeferredRenderQueue.cpp | 2 ++ src/Nazara/Renderer/RenderTexture.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 8623904a6..7d214b217 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -239,6 +239,8 @@ namespace Nz std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); + + materialEntry.maxInstanceCount = std::max(materialEntry.maxInstanceCount, instances.size()); } } diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index c6e78df86..647b8ff91 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -588,7 +588,7 @@ namespace Nz std::memcpy(&m_impl->colorTargets[0], targets, targetCount*sizeof(UInt8)); m_impl->userDefinedTargets = true; - InvalidateDrawBuffers(); + InvalidateTargets(); } void RenderTexture::SetColorTargets(const std::initializer_list& targets) const @@ -614,7 +614,7 @@ namespace Nz *ptr++ = index; m_impl->userDefinedTargets = true; - InvalidateDrawBuffers(); + InvalidateTargets(); } void RenderTexture::Unlock() const From cb4fbe08943bf47bcc98e70fe7e205ea79030dfc Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 14:09:48 +0200 Subject: [PATCH 148/235] Sdk/RenderSystem: Make ChangeRenderTechnique return a reference to the render technique Former-commit-id: bffd29fae1ec56fbf9769e9d98c6482dcf953233 [formerly 8efbb3be17fa259e5b7a0529c21d89ca66cb92fe] [formerly a6908831f5568b0d9c5c94c2085722513e240acb [formerly 24501e9445e2f64303751ca34af2df5170af4248]] Former-commit-id: c8da7e4bd2680ddc942b6f06c7b528a1007fe1df [formerly a66ad334b5e9032f35d58c25ba3b5affc97d72da] Former-commit-id: f67f457a615944e276e19e5551107333c4c4dd8f --- SDK/include/NDK/Systems/RenderSystem.hpp | 4 ++-- SDK/include/NDK/Systems/RenderSystem.inl | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 82e558773..488d1a7d4 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -28,8 +28,8 @@ namespace Ndk inline RenderSystem(const RenderSystem& renderSystem); ~RenderSystem() = default; - template void ChangeRenderTechnique(); - inline void ChangeRenderTechnique(std::unique_ptr&& renderTechnique); + template T& ChangeRenderTechnique(); + inline Nz::AbstractRenderTechnique& ChangeRenderTechnique(std::unique_ptr&& renderTechnique); inline const Nz::BackgroundRef& GetDefaultBackground() const; inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const; diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NDK/Systems/RenderSystem.inl index b85ace59f..ada237615 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NDK/Systems/RenderSystem.inl @@ -10,14 +10,15 @@ namespace Ndk } template - inline void RenderSystem::ChangeRenderTechnique() + inline T& RenderSystem::ChangeRenderTechnique() { - ChangeRenderTechnique(std::make_unique()); + return *static_cast(ChangeRenderTechnique(std::make_unique())); } - inline void RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) + inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) { m_renderTechnique = std::move(renderTechnique); + return *m_renderTechnique.get(); } inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const From 256c67099c0d73eec20fb1180850cece8de70d73 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 19:10:40 +0200 Subject: [PATCH 149/235] SDK/RenderSystem: Fix an oopsie Former-commit-id: f5a5b9410128a9156336268a4f00fb6afba9e4a6 [formerly 30af713ddc19d64e705160025b188706a24fb88f] [formerly d3870ff10df9cbd862d47e47c940dcda8346c295 [formerly dd082645670ee873087f6730a8c7e5858d6f5ded]] Former-commit-id: 87358be88eaa6c53337c0c12abe8df11aeb2d6aa [formerly 156a76761c21de5a32578c4a7e6250081cab447a] Former-commit-id: eb382e3c9c1af7f8871d1d7ce777b15f0d87138b --- SDK/include/NDK/Systems/RenderSystem.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NDK/Systems/RenderSystem.inl index ada237615..4f7afe63d 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NDK/Systems/RenderSystem.inl @@ -12,7 +12,7 @@ namespace Ndk template inline T& RenderSystem::ChangeRenderTechnique() { - return *static_cast(ChangeRenderTechnique(std::make_unique())); + return static_cast(ChangeRenderTechnique(std::make_unique())); } inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) From 3913ead4bfeb0caf3f99ddee614965f9484a1009 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 22:17:55 +0200 Subject: [PATCH 150/235] Fix compilation with GCC/Clang Thanks to @Gawaboumga Former-commit-id: 7f8ecb5aa4d03297c0f2a70cb0f31984a7d31a62 [formerly fcaf6069180a973507da5b4d92d9bb0885707327] [formerly 92afa50ce2827d97a771bf2c74250141a94f1bcb [formerly 1c1a8435853fffabd8ef6d31a24a312d96930bd8]] Former-commit-id: 341e8fc6faf6318f6ea1a0656f79b1b47cfd15f4 [formerly c2f0ba53e3d2f700f5109b25fa71838ebe6527bd] Former-commit-id: 3526c10e8e8ba9cc0f38373ed8c5df6634248831 --- SDK/include/NDK/Systems/ParticleSystem.hpp | 2 ++ build/scripts/tools/ndk_server.lua | 2 ++ include/Nazara/Core/Algorithm.inl | 2 +- include/Nazara/Graphics/MaterialPipeline.inl | 6 +++--- src/Nazara/Graphics/MaterialPipeline.cpp | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/SDK/include/NDK/Systems/ParticleSystem.hpp b/SDK/include/NDK/Systems/ParticleSystem.hpp index 3ae00a995..61149b206 100644 --- a/SDK/include/NDK/Systems/ParticleSystem.hpp +++ b/SDK/include/NDK/Systems/ParticleSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_PARTICLESYSTEM_HPP #define NDK_SYSTEMS_PARTICLESYSTEM_HPP @@ -27,3 +28,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP +#endif // NDK_SERVER diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index e536f1036..aa8548b80 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -30,6 +30,8 @@ TOOL.FilesExcluded = { "../SDK/**/LightComponent.*", "../SDK/**/ListenerComponent.*", "../SDK/**/ListenerSystem.*", + "../SDK/**/Particle*Component.*", + "../SDK/**/ParticleSystem.*", "../SDK/**/RenderSystem.*", "../SDK/**/LuaBinding_Audio.*", "../SDK/**/LuaBinding_Graphics.*", diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index c77a5c3bb..0cadd1631 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -124,7 +124,7 @@ namespace Nz template constexpr std::size_t CountOf(T(&name)[N]) noexcept { - NazaraUnused(name); + // NazaraUnused(name); //< Because "body of function is not a return-statement" >.> return N; } diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl index ebd94a9ee..ce937883d 100644 --- a/include/Nazara/Graphics/MaterialPipeline.inl +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -61,7 +61,7 @@ namespace Nz if (!operator==(static_cast(lhs), static_cast(rhs))) return false; - #define NazaraPipelineMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraPipelineMember(field) if (lhs.field != rhs.field) return false #define NazaraPipelineBoolMember NazaraPipelineMember NazaraPipelineBoolMember(alphaTest); @@ -115,8 +115,8 @@ namespace std Nz::UInt16 parameterHash = 0; Nz::UInt16 parameterIndex = 0; - #define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.##member) - #define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + #define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.member) + #define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) NazaraPipelineBoolMember(alphaTest); NazaraPipelineBoolMember(depthSorting); diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 01e9ffe5d..4cbd56274 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -49,8 +49,8 @@ namespace Nz */ MaterialPipelineRef MaterialPipeline::GetPipeline(const MaterialPipelineInfo& pipelineInfo) { - auto it = s_pipelineCache.lower_bound(pipelineInfo); - if (it == s_pipelineCache.end() || it->first != pipelineInfo) + auto it = s_pipelineCache.find(pipelineInfo); + if (it == s_pipelineCache.end()) it = s_pipelineCache.insert(it, PipelineCache::value_type(pipelineInfo, New(pipelineInfo))); return it->second; From ded4d6c35d86d6e9aac8e845c75a751b5b141428 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 22:52:29 +0200 Subject: [PATCH 151/235] SDK/ParticleGroupComponent: Add [Add|Remove]Emitter methods taking an entity The entity must have a ParticleEmitterComponent Former-commit-id: cc5fcde30bf8085b28aba18974854768f3ef5a46 [formerly 94cd3ac4099952d7186a49bf61b9fa1a9051484f] [formerly 8253250c28e3c890893072cf06ac032c55f95381 [formerly a2d435c184491dd50cd3fb2fd0174ee96a50321d]] Former-commit-id: 80dd6d0c2ea2f0229aacbf51cabd0067b5903b1f [formerly 42ca331d5712afca14f444f595fd14c2b3d3e1dd] Former-commit-id: 3c716c6d7ec3fb1e4ec5f4cf435c3fcc8a9dec8e --- .../NDK/Components/ParticleGroupComponent.hpp | 6 +++++ .../NDK/Components/ParticleGroupComponent.inl | 23 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NDK/Components/ParticleGroupComponent.hpp index 638f877d3..0dce5dd23 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.hpp +++ b/SDK/include/NDK/Components/ParticleGroupComponent.hpp @@ -25,6 +25,12 @@ namespace Ndk ParticleGroupComponent(const ParticleGroupComponent&) = default; ~ParticleGroupComponent() = default; + void AddEmitter(Entity* emitter); + using ParticleGroup::AddEmitter; + + void RemoveEmitter(Entity* emitter); + using ParticleGroup::RemoveEmitter; + static ComponentIndex componentIndex; }; } diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NDK/Components/ParticleGroupComponent.inl index 7aefdad56..c6e0cba7b 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.inl +++ b/SDK/include/NDK/Components/ParticleGroupComponent.inl @@ -1,8 +1,11 @@ -#include "ParticleGroupComponent.hpp" // 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 +#include +#include + namespace Ndk { inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) : @@ -14,4 +17,22 @@ namespace Ndk ParticleGroup(maxParticleCount, std::move(declaration)) { } + + inline void ParticleGroupComponent::AddEmitter(Entity* emitter) + { + NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); + NazaraAssert(emitter->HasComponent(), "Entity must have a NodeComponent"); + + auto& emitterComponent = emitter->GetComponent(); + ParticleGroup::AddEmitter(&emitterComponent); + } + + inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter) + { + NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); + NazaraAssert(emitter->HasComponent(), "Entity must have a NodeComponent"); + + auto& emitterComponent = emitter->GetComponent(); + ParticleGroup::RemoveEmitter(&emitterComponent); + } } From c22fff67407d3dfdad9fcb939f526b7a9ff3ab2b Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:12:22 +0200 Subject: [PATCH 152/235] Renderer/RenderStates: Fix compilation with GCC/Clang Former-commit-id: cb3e1bb2288fb54641b9c37aa834d86d16bfc6a7 [formerly d8cd853dd7e5aa4f3863dab42f3f68d65ef53ed7] [formerly 8f64028937689f0472e3febd94f189bc9e461c1e [formerly ac5f3bb11f52d985f1336a3a51d40fc9d24f3c59]] Former-commit-id: 3bf5abc062b8d38241d829709d9867b40c140e84 [formerly e94c3d9f980d526b6a0dbf8dbe64e88eec0ba876] Former-commit-id: c1dcb29cd3998e6eecd236bc86892fef240c4527 --- include/Nazara/Renderer/RenderStates.inl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index d9b6bfc31..9b7c1be62 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -12,9 +12,9 @@ namespace Nz { bool operator==(const RenderStates& lhs, const RenderStates& rhs) { - #define NazaraRenderStateMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraRenderStateMember(field) if (lhs.field != rhs.field) return false #define NazaraRenderStateBoolMember NazaraRenderStateMember - #define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.##field, rhs.##field, maxDiff)) return false + #define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.field, rhs.field, maxDiff)) return false NazaraRenderStateBoolMember(blending); NazaraRenderStateBoolMember(colorWrite); @@ -81,10 +81,10 @@ namespace std Nz::UInt8 parameterHash = 0; Nz::UInt8 parameterIndex = 0; - #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.##member) - #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.##dependency && pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.##member / maxDiff) * maxDiff) + #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.member) + #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) NazaraRenderStateBoolMember(blending); NazaraRenderStateBoolMember(colorWrite); From 6e89d34c9d9d567bcaf0dc2d88ce584cbf24e5cf Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:17:25 +0200 Subject: [PATCH 153/235] Ditto Former-commit-id: f365cc8672d2eab20f121cf9ab10da5caec8a970 [formerly 24946be5b1045755d9d9d0bee0496feb7c58ff27] [formerly 7a3e46294df8577d38074589aabdc1786a46ee07 [formerly 9f97ef85ec4e440da265b2501d1423a986f033ee]] Former-commit-id: 69a61ef34ec687d786e6c5bbc40fb27b20960c21 [formerly fd94316370437cd7ed97778772b20e1cb1fa4249] Former-commit-id: e0f6c22e3dfd0a3ff88c7fdf1f746db7f0fafbf5 --- include/Nazara/Renderer/RenderStates.inl | 72 ++++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 9b7c1be62..525491162 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -81,59 +81,59 @@ namespace std Nz::UInt8 parameterHash = 0; Nz::UInt8 parameterIndex = 0; - #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.member) - #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) + #define NazaraRenderStateBool(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateBoolDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateEnum(member) Nz::HashCombine(seed, static_cast(pipelineInfo.member)) + #define NazaraRenderStateFloat(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) - NazaraRenderStateBoolMember(blending); - NazaraRenderStateBoolMember(colorWrite); - NazaraRenderStateBoolMember(depthBuffer); - NazaraRenderStateBoolMember(faceCulling); - NazaraRenderStateBoolMember(scissorTest); - NazaraRenderStateBoolMember(stencilTest); + NazaraRenderStateBool(blending); + NazaraRenderStateBool(colorWrite); + NazaraRenderStateBool(depthBuffer); + NazaraRenderStateBool(faceCulling); + NazaraRenderStateBool(scissorTest); + NazaraRenderStateBool(stencilTest); - NazaraRenderStateBoolMemberDep(depthBuffer, depthWrite); + NazaraRenderStateBoolDep(depthBuffer, depthWrite); - NazaraRenderStateMember(faceFilling); + NazaraRenderStateEnum(faceFilling); if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending { - NazaraRenderStateMember(dstBlend); - NazaraRenderStateMember(srcBlend); + NazaraRenderStateEnum(dstBlend); + NazaraRenderStateEnum(srcBlend); } if (pipelineInfo.depthBuffer) - NazaraRenderStateMember(depthFunc); + NazaraRenderStateEnum(depthFunc); if (pipelineInfo.faceCulling) - NazaraRenderStateMember(cullingSide); + NazaraRenderStateEnum(cullingSide); if (pipelineInfo.stencilTest) { - NazaraRenderStateMember(stencilCompare.back); - NazaraRenderStateMember(stencilCompare.front); - NazaraRenderStateMember(stencilCompareMask.back); - NazaraRenderStateMember(stencilCompareMask.front); - NazaraRenderStateMember(stencilDepthFail.back); - NazaraRenderStateMember(stencilDepthFail.front); - NazaraRenderStateMember(stencilFail.back); - NazaraRenderStateMember(stencilFail.front); - NazaraRenderStateMember(stencilPass.back); - NazaraRenderStateMember(stencilPass.front); - NazaraRenderStateMember(stencilReference.back); - NazaraRenderStateMember(stencilReference.front); - NazaraRenderStateMember(stencilWriteMask.back); - NazaraRenderStateMember(stencilWriteMask.front); + NazaraRenderStateEnum(stencilCompare.back); + NazaraRenderStateEnum(stencilCompare.front); + NazaraRenderStateEnum(stencilCompareMask.back); + NazaraRenderStateEnum(stencilCompareMask.front); + NazaraRenderStateEnum(stencilDepthFail.back); + NazaraRenderStateEnum(stencilDepthFail.front); + NazaraRenderStateEnum(stencilFail.back); + NazaraRenderStateEnum(stencilFail.front); + NazaraRenderStateEnum(stencilPass.back); + NazaraRenderStateEnum(stencilPass.front); + NazaraRenderStateEnum(stencilReference.back); + NazaraRenderStateEnum(stencilReference.front); + NazaraRenderStateEnum(stencilWriteMask.back); + NazaraRenderStateEnum(stencilWriteMask.front); } - NazaraRenderStateFloatMember(lineWidth, 0.001f); - NazaraRenderStateFloatMember(pointSize, 0.001f); + NazaraRenderStateFloat(lineWidth, 0.001f); + NazaraRenderStateFloat(pointSize, 0.001f); - #undef NazaraRenderStateMember - #undef NazaraRenderStateBoolMember - #undef NazaraRenderStateBoolMemberDep - #undef NazaraRenderStateFloatMember + #undef NazaraRenderStateBool + #undef NazaraRenderStateBoolDep + #undef NazaraRenderStateEnum + #undef NazaraRenderStateFloat Nz::HashCombine(seed, parameterHash); From 0deb88bc56222a562b7a595a8bd815706390f46b Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:18:49 +0200 Subject: [PATCH 154/235] Graphics/ParticleGroup: Fix include name Former-commit-id: a94df9e58137722fb26d2b40c843c2d8123007b7 [formerly 0b8531c0a77d6bb935dc08555e03873a9a3ee150] [formerly 5864739711d444cf8e76235a6ba0f6830204b4f9 [formerly 781eca23d939a898e180052dbd910cbf76f900f7]] Former-commit-id: 26c52ef0a66e24ee30c6651ed97e56cd236f9f78 [formerly f4bb29f07cdcc91ebc605e58da49bc49842e55e7] Former-commit-id: 896eefc9d9398d655d8df945ba54f1045da0919d --- include/Nazara/Graphics/ParticleGroup.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 9e48d5797..409090284 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -8,7 +8,7 @@ #define NAZARA_PARTICLEGROUP_HPP #include -#include +#include #include #include #include From 888e39444ae9bca67a73e768738e9eacfe98c1a4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:50:51 +0200 Subject: [PATCH 155/235] Core/Log: Fix errors not being written in NazaraLog.log >.> Former-commit-id: 178df6de929a9269991b1276e5d4de4b97abc974 [formerly 42a2f2ab62d3ccad0e2982a885119d253860eb47] [formerly 6f243004c44cb890d64e4ca1095363cce72a00f1 [formerly 93410e519d31e1beefe518ee0d6eb5287434d0fc]] Former-commit-id: 6c5e62f253e14369e62bd025a135dd945830b380 [formerly 3767c7055d270997c92da6bb728fa348be7c4f3b] Former-commit-id: 2090b4f271a392ab46101021173cee951a9e93ad --- include/Nazara/Core/Signal.hpp | 2 +- include/Nazara/Core/Signal.inl | 7 +++++++ src/Nazara/Core/AbstractLogger.cpp | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index 613502f80..b7aebe591 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -34,7 +34,7 @@ namespace Nz Signal(); Signal(const Signal&) = delete; Signal(Signal&& signal); - ~Signal() = default; + ~Signal(); void Clear(); diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index 466d87537..d8ea871c6 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -36,6 +36,12 @@ namespace Nz operator=(std::move(signal)); } + template + Signal::~Signal() + { + NazaraWarning("~Signal(" + String::Pointer(this) + ')'); + } + /*! * \brief Clears the list of actions attached to the signal */ @@ -429,3 +435,4 @@ namespace Nz } #include +#include "Signal.hpp" diff --git a/src/Nazara/Core/AbstractLogger.cpp b/src/Nazara/Core/AbstractLogger.cpp index ceac9eff8..a1bf859a7 100644 --- a/src/Nazara/Core/AbstractLogger.cpp +++ b/src/Nazara/Core/AbstractLogger.cpp @@ -47,5 +47,7 @@ namespace Nz if (line != 0 && file && function) stream << " (" << file << ':' << line << ": " << function << ')'; + + Write(stream); } } From b0de2364a5a270c4b518911ae1a92fdfb256e919 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 00:04:10 +0200 Subject: [PATCH 156/235] Graphics: Allow OpenGL 3.3 to use the engine (with shadow disabled) I still have a figure a better solution Former-commit-id: b3ec42f07411f1c92f67b1a0bcba59d1cdbd68a6 [formerly 9c4d8e27a0e7a2182a0229e3313e44a442f91f85] [formerly 8c105a9e2769c56d8f89ea8eeb50fb1f10409913 [formerly 9d66d3c4f613d6a2d841ed2106468895464562f5]] Former-commit-id: 6294d304178787f40860e5e603af7a0d82a9a895 [formerly 5cd271ac68b26853c648c4f7e8611acfaa028270] Former-commit-id: 54af050a382daa92216dd512596040e5496f453f --- .../Graphics/Resources/Shaders/PhongLighting/core.frag | 7 +++++++ .../Graphics/Resources/Shaders/PhongLighting/core.frag.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index a3391be91..d5eef7a3c 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -2,6 +2,13 @@ layout(early_fragment_tests) in; #endif +// HACK UNTIL PROPER FIX +#if GLSL_VERSION < 400 + #undef SHADOW_MAPPING + #define SHADOW_MAPPING 0 +#endif +// HACK + #define LIGHT_DIRECTIONAL 0 #define LIGHT_POINT 1 #define LIGHT_SPOT 2 diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index c77a33db2..650b62ccd 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,10,35,101,110,100,105,102,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,99,111,108,111,114,59,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,10,125,59,10,10,47,47,32,76,117,109,105,195,168,114,101,115,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,10,47,47,32,77,97,116,195,169,114,105,97,117,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,47,47,32,65,117,116,114,101,115,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,10,123,10,9,118,101,99,51,32,99,111,108,111,114,59,10,10,9,102,32,42,61,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,10,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,10,125,10,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,10,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,10,123,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,10,125,10,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,10,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,10,125,10,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,10,9,102,108,111,97,116,32,120,44,121,59,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,10,9,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,10,125,10,35,101,110,100,105,102,10,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,10,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,35,101,108,115,101,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,10,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,10,35,101,110,100,105,102,10,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,9,35,101,110,100,105,102,10,9,9,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,35,101,110,100,105,102,10,10,9,47,42,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,10,9,42,47,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,10,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,35,101,110,100,105,102,10,9,9,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,125,10,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,47,47,32,72,65,67,75,32,85,78,84,73,76,32,80,82,79,80,69,82,32,70,73,88,13,10,35,105,102,32,71,76,83,76,95,86,69,82,83,73,79,78,32,60,32,52,48,48,13,10,9,35,117,110,100,101,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,35,100,101,102,105,110,101,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,32,48,13,10,35,101,110,100,105,102,13,10,47,47,32,72,65,67,75,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file From e22355db191f809f8479dbe21948c921cd8e6cf8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:02:40 +0200 Subject: [PATCH 157/235] SDK/Entity: Delay component removal until world update Allows system to freely remove components while updating Former-commit-id: f567d3344f764a0909abc2c4a8f69a580aa585b3 [formerly 77379f40a7773443420058a342dec4c02e563053] [formerly 1313a164a686c915c8c54e1dfb367757499b45e9 [formerly f69b0a2a5fd0c3a640c19409baa3f467d231b566]] Former-commit-id: 19aeaebcb33056b67e788d5ef485179ed17b2fd8 [formerly fe85c2fcf3851834f70d0573617a15be31e02e50] Former-commit-id: 527c9fd9571f405b0963123c158ef1e4b42f28ad --- SDK/include/NDK/Entity.hpp | 9 ++++-- SDK/include/NDK/Entity.inl | 19 +++++++++++++ SDK/src/NDK/Entity.cpp | 56 +++++++++++++++----------------------- SDK/src/NDK/World.cpp | 5 ++++ 4 files changed, 53 insertions(+), 36 deletions(-) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index 6069a13c0..ae6b1acf5 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -52,8 +52,8 @@ namespace Ndk inline bool IsEnabled() const; inline bool IsValid() const; - void RemoveAllComponents(); - void RemoveComponent(ComponentIndex index); + inline void RemoveAllComponents(); + inline void RemoveComponent(ComponentIndex index); template void RemoveComponent(); inline Nz::String ToString() const; @@ -67,6 +67,10 @@ namespace Ndk void Create(); void Destroy(); + void DestroyComponent(ComponentIndex index); + + inline Nz::Bitset<>& GetRemovedComponentBits(); + inline void RegisterSystem(SystemIndex index); inline void SetWorld(World* world) noexcept; @@ -75,6 +79,7 @@ namespace Ndk std::vector> m_components; Nz::Bitset<> m_componentBits; + Nz::Bitset<> m_removedComponentBits; Nz::Bitset<> m_systemBits; EntityId m_id; World* m_world; diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index 799ffd97e..c7937b786 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -103,12 +103,31 @@ namespace Ndk RemoveComponent(index); } + inline void Entity::RemoveAllComponents() + { + m_removedComponentBits = m_componentBits; + + Invalidate(); + } + + inline void Entity::RemoveComponent(ComponentIndex index) + { + m_removedComponentBits.UnboundedSet(index); + + Invalidate(); + } + inline Nz::String Entity::ToString() const { Nz::StringStream ss; return ss << "Entity(" << GetId() << ')'; } + inline Nz::Bitset<>& Entity::GetRemovedComponentBits() + { + return m_removedComponentBits; + } + inline void Entity::RegisterSystem(SystemIndex index) { m_systemBits.UnboundedSet(index); diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index f037e5f9a..680ff56d9 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -44,6 +44,7 @@ namespace Ndk // Affectation et retour du component m_components[index] = std::move(componentPtr); m_componentBits.UnboundedSet(index); + m_removedComponentBits.UnboundedReset(index); Invalidate(); @@ -71,40 +72,6 @@ namespace Ndk m_world->Invalidate(m_id); } - void Entity::RemoveAllComponents() - { - for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) - RemoveComponent(static_cast(i)); - - NazaraAssert(m_componentBits.TestNone(), "All components should be gone"); - - m_components.clear(); - - Invalidate(); - } - - void Entity::RemoveComponent(ComponentIndex index) - { - ///DOC: N'a aucun effet si le component n'est pas présent - if (HasComponent(index)) - { - // On récupère le component et on informe les composants du détachement - BaseComponent& component = *m_components[index].get(); - for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) - { - if (i != index) - m_components[i]->OnComponentDetached(component); - } - - component.SetEntity(nullptr); - - m_components[index].reset(); - m_componentBits.Reset(index); - - Invalidate(); - } - } - void Entity::Create() { m_enabled = true; @@ -128,4 +95,25 @@ namespace Ndk m_valid = false; } + + void Entity::DestroyComponent(ComponentIndex index) + { + ///DOC: N'a aucun effet si le component n'est pas présent + if (HasComponent(index)) + { + // On récupère le component et on informe les composants du détachement + BaseComponent& component = *m_components[index].get(); + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + { + if (i != index) + m_components[i]->OnComponentDetached(component); + } + + component.SetEntity(nullptr); + + m_components[index].reset(); + m_componentBits.Reset(index); + } + } + } diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 5d0e4900b..e5b2d874a 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -139,6 +139,11 @@ namespace Ndk if (!entity->IsValid()) continue; + Nz::Bitset<>& removedComponents = entity->GetRemovedComponentBits(); + for (std::size_t j = removedComponents.FindFirst(); j != m_dirtyEntities.npos; j = removedComponents.FindNext(j)) + entity->DestroyComponent(j); + removedComponents.Reset(); + for (auto& system : m_systems) { // Ignore non-existent systems From 5095630d707f1fb14865e914c11be1217f0037ec Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:03:53 +0200 Subject: [PATCH 158/235] SDK/GraphicsComponent: Fix invalidation slot disconnection in case Detach has been called Former-commit-id: fac026c7d261e04d8eb8917f02d3a46395a6e56d [formerly dcdf872f4eaee1dc1fc233e7f3493bb748368dd3] [formerly b097f3fa371eaa1b99614abd5752cff34393eb26 [formerly 47d61b32b37091c6c407b5337a93d1d056fffc06]] Former-commit-id: b6acb3795bec98d7c11f29970f3530c0a3c00fe2 [formerly df3ebb81912426ea81e1b94ff751437ce5cdbc46] Former-commit-id: 7c085e0d37dbe2fecfc9db5507985ae64f861767 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 6 ++++-- SDK/include/NDK/Components/GraphicsComponent.inl | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 92aeeed2f..6e0e78604 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -35,7 +35,7 @@ namespace Ndk inline void Clear(); - inline void Detach(const Nz::InstancedRenderableRef& renderable); + inline void Detach(const Nz::InstancedRenderable* renderable); inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; @@ -75,7 +75,8 @@ namespace Ndk Renderable(Renderable&& renderable) noexcept : data(std::move(renderable.data)), renderable(std::move(renderable.renderable)), - dataUpdated(renderable.dataUpdated) + dataUpdated(renderable.dataUpdated), + renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)), { } @@ -84,6 +85,7 @@ namespace Ndk data = std::move(r.data); dataUpdated = r.dataUpdated; renderable = std::move(r.renderable); + renderableInvalidationSlot = std::move(r.renderableInvalidationSlot); return *this; } diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index b38ce6dd6..a835c845d 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -54,7 +54,7 @@ namespace Ndk InvalidateBoundingVolume(); } - inline void GraphicsComponent::Detach(const Nz::InstancedRenderableRef& renderable) + inline void GraphicsComponent::Detach(const Nz::InstancedRenderable* renderable) { for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) { From 7802183be040e4692ee3da7b65866ca3e346b5fd Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:06:21 +0200 Subject: [PATCH 159/235] Core/Signal: Remove debug log that got accidentaly commited Former-commit-id: d2ff15494cf6fa9bb1f052ed72616e99bc48926d [formerly fc3c365c5cb96d33d7fe746654cd88b88f5d7a38] [formerly ba321a669460aa9775d981de526b276e5b737273 [formerly 4d25dea9712386c76a018437e6612e44f5598b81]] Former-commit-id: 4e28a6543ac1aab3e57c0343bca7ef5b35ea874c [formerly d9872404e8c3cd38a973ecc4b7945ac25918c572] Former-commit-id: 2a8ceba2ad1be284ccc229f5af202ee878800002 --- include/Nazara/Core/Signal.hpp | 2 +- include/Nazara/Core/Signal.inl | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index b7aebe591..613502f80 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -34,7 +34,7 @@ namespace Nz Signal(); Signal(const Signal&) = delete; Signal(Signal&& signal); - ~Signal(); + ~Signal() = default; void Clear(); diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index d8ea871c6..93e0166c0 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include #include @@ -36,12 +37,6 @@ namespace Nz operator=(std::move(signal)); } - template - Signal::~Signal() - { - NazaraWarning("~Signal(" + String::Pointer(this) + ')'); - } - /*! * \brief Clears the list of actions attached to the signal */ @@ -435,4 +430,3 @@ namespace Nz } #include -#include "Signal.hpp" From fd874098f9548606884d286a23e3e5cf16cead05 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:07:46 +0200 Subject: [PATCH 160/235] SDK/GraphicsComponent: Makes component watch over renderable destruction Allows to use persistent (not using the internal counter) InstancedRenderable Former-commit-id: cc511c6da80a57126f48c2f1dbc0f7c1b4ee0d18 [formerly 803948db3b98db6d47f8c2a3d6dee73274f90bb7] [formerly 86a3c484eac16f58263d2c22a8992d088af383c9 [formerly d0d78ebee97f2d309b28f734f176814f9c9a3d22]] Former-commit-id: f9b885450c133524597d2a81119af311f6755789 [formerly 195b15dc4c47f6783c91383ef5d9f01cf67abb42] Former-commit-id: 820d52038de469dc89d040f9718378249495d474 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 9 +++++++++ SDK/include/NDK/Components/GraphicsComponent.inl | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 6e0e78604..ec16ba593 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -77,20 +77,29 @@ namespace Ndk renderable(std::move(renderable.renderable)), dataUpdated(renderable.dataUpdated), renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)), + renderableReleaseSlot(std::move(renderable.renderableReleaseSlot)) { } + ~Renderable() + { + // Disconnect release slot before releasing instanced renderable reference + renderableReleaseSlot.Disconnect(); + } + Renderable& operator=(Renderable&& r) noexcept { data = std::move(r.data); dataUpdated = r.dataUpdated; renderable = std::move(r.renderable); renderableInvalidationSlot = std::move(r.renderableInvalidationSlot); + renderableReleaseSlot = std::move(r.renderableReleaseSlot); return *this; } NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot); + NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableRelease, renderableReleaseSlot); mutable Nz::InstancedRenderable::InstanceData data; Nz::InstancedRenderableRef renderable; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index a835c845d..0d9cb7af4 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -42,7 +42,8 @@ namespace Ndk Renderable& r = m_renderables.back(); r.data.renderOrder = renderOrder; r.renderable = std::move(renderable); - r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1)); + 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); InvalidateBoundingVolume(); } From 4fff7abf61dbb99bfb25035a92fad9a66106bfdb Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 22:00:05 +0200 Subject: [PATCH 161/235] SDK/Entity: Add entity cloning Former-commit-id: 3cc9457d125991c6ac98a6e2559aab220446f9cf [formerly 721b19c23c3431e002604e4b201a63a74ddc8404] [formerly b8026d485a23968df3a768ae31afe09e80e31d69 [formerly 892cbc899b0ce57a905b807d5f9cb0747336fe0c]] Former-commit-id: 3bfafaf90dd5db34f1fce455c67ba51f5be3174d [formerly 6f2ab5632b943089fc3e6ad1f06266054740f1e8] Former-commit-id: e2694c2f25769068f64dc437d06e4c53525c0c6c --- SDK/include/NDK/Entity.hpp | 2 ++ SDK/include/NDK/World.hpp | 2 ++ SDK/src/NDK/Entity.cpp | 8 ++++++++ SDK/src/NDK/World.cpp | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index ae6b1acf5..33661eb50 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -34,6 +34,8 @@ namespace Ndk BaseComponent& AddComponent(std::unique_ptr&& component); template ComponentType& AddComponent(Args&&... args); + const EntityHandle& Clone() const; + inline void Enable(bool enable); inline BaseComponent& GetComponent(ComponentIndex index); diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index 40508e8e4..2e20d03a9 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -44,6 +44,8 @@ namespace Ndk void Clear() noexcept; + const EntityHandle& CloneEntity(EntityId id); + const EntityHandle& GetEntity(EntityId id); inline const EntityList& GetEntities(); inline BaseSystem& GetSystem(SystemIndex index); diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 680ff56d9..ecd74ebc0 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -61,6 +61,14 @@ namespace Ndk return component; } + const EntityHandle& Entity::Clone() const + { + ///DOC: The clone is enabled by default, even if the original entity is disabled + NazaraAssert(IsValid(), "Invalid entity"); + + return m_world->CloneEntity(m_id); + } + void Entity::Kill() { m_world->KillEntity(this); diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index e5b2d874a..8e5ff99f0 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -74,6 +75,27 @@ namespace Ndk m_killedEntities.Clear(); } + const EntityHandle& World::CloneEntity(EntityId id) + { + EntityHandle original = GetEntity(id); + if (!original) + { + NazaraError("Invalid entity ID"); + return EntityHandle::InvalidHandle; + } + + EntityHandle clone = CreateEntity(); + + const Nz::Bitset<>& componentBits = original->GetComponentBits(); + for (std::size_t i = componentBits.FindFirst(); i != componentBits.npos; i = componentBits.FindNext(i)) + { + std::unique_ptr component(original->GetComponent(ComponentIndex(i)).Clone()); + clone->AddComponent(std::move(component)); + } + + return GetEntity(clone->GetId()); + } + void World::KillEntity(Entity* entity) { ///DOC: Ignoré si l'entité est invalide From fa86f4345e9eba35c43d3f6dcb6df037dc15a379 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 13 Aug 2016 01:23:30 +0200 Subject: [PATCH 162/235] Utility/OBJParser: Fix a missing word.. hue Former-commit-id: 06544480f0f2c8089b68fa264a8ffb63d5befce1 [formerly 4ac71561b164551c4fa5d7d04765550983283efa] [formerly 6d237f50af7fa43cd3f610d2f0f76abbbd3936fc [formerly 2d6841776d075febe4e386260c8e907fe012a191]] Former-commit-id: 44d1076a425fd5684791f42b3154614627fb203a [formerly f5047bca3872d4d4ae51a0366ae85abb2ea88764] Former-commit-id: f1aae2ba16c89ff45e54db33eeae8fd6597cae17 --- src/Nazara/Utility/Formats/OBJParser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 403950a97..e2b63b467 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -300,7 +300,7 @@ namespace Nz m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif } else if (word == "vn") @@ -311,7 +311,7 @@ namespace Nz m_normals.push_back(normal); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif } else if (word == "vt") @@ -322,12 +322,12 @@ namespace Nz m_texCoords.push_back(uvw); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif break; From 3933af597fa99f026353223014252eca0e114b6a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:54:37 +0200 Subject: [PATCH 163/235] Graphics/Particles: Add wrappers on functions controller/generator/renderer Former-commit-id: 05ad40899814194286c3f038362a58d788dca0d5 [formerly c592befc3a534a67dfe0554fd7bde86a736bbb91] [formerly 42f3c9d1e1dc9575277f225da71e29430ac096c6 [formerly 62c0d364d496348c476d8b88168e14b2da17d778]] Former-commit-id: 8a4fa558e6bd09fbd55912f78dbb1bd0dcc2cb9d [formerly 94030181beae8c8d8dd4834e7373d470df8be56d] Former-commit-id: 967bbd78527ac1fce82ab692b3bd19dda20df9c2 --- .../Graphics/ParticleFunctionController.hpp | 45 ++++++++++++++++++ .../Graphics/ParticleFunctionController.inl | 46 +++++++++++++++++++ .../Graphics/ParticleFunctionGenerator.hpp | 45 ++++++++++++++++++ .../Graphics/ParticleFunctionGenerator.inl | 46 +++++++++++++++++++ .../Graphics/ParticleFunctionRenderer.hpp | 45 ++++++++++++++++++ .../Graphics/ParticleFunctionRenderer.inl | 46 +++++++++++++++++++ .../Graphics/ParticleFunctionController.cpp | 29 ++++++++++++ .../Graphics/ParticleFunctionGenerator.cpp | 28 +++++++++++ .../Graphics/ParticleFunctionRenderer.cpp | 29 ++++++++++++ 9 files changed, 359 insertions(+) create mode 100644 include/Nazara/Graphics/ParticleFunctionController.hpp create mode 100644 include/Nazara/Graphics/ParticleFunctionController.inl create mode 100644 include/Nazara/Graphics/ParticleFunctionGenerator.hpp create mode 100644 include/Nazara/Graphics/ParticleFunctionGenerator.inl create mode 100644 include/Nazara/Graphics/ParticleFunctionRenderer.hpp create mode 100644 include/Nazara/Graphics/ParticleFunctionRenderer.inl create mode 100644 src/Nazara/Graphics/ParticleFunctionController.cpp create mode 100644 src/Nazara/Graphics/ParticleFunctionGenerator.cpp create mode 100644 src/Nazara/Graphics/ParticleFunctionRenderer.cpp diff --git a/include/Nazara/Graphics/ParticleFunctionController.hpp b/include/Nazara/Graphics/ParticleFunctionController.hpp new file mode 100644 index 000000000..6b3c4a974 --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionController.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP +#define NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP + +#include +#include +#include + +namespace Nz +{ + class ParticleFunctionController; + + using ParticleFunctionControllerConstRef = ObjectRef; + using ParticleFunctionControllerRef = ObjectRef; + + class NAZARA_GRAPHICS_API ParticleFunctionController : public ParticleController + { + public: + using Controller = std::function; + + inline ParticleFunctionController(Controller controller); + ParticleFunctionController(const ParticleFunctionController&) = default; + ~ParticleFunctionController() = default; + + void Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override final; + + inline const Controller& GetController() const; + + inline void SetController(Controller controller); + + template static ParticleFunctionControllerRef New(Args&&... args); + + private: + Controller m_controller; + }; +} + +#include + +#endif // NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP diff --git a/include/Nazara/Graphics/ParticleFunctionController.inl b/include/Nazara/Graphics/ParticleFunctionController.inl new file mode 100644 index 000000000..eb4365fda --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionController.inl @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline ParticleFunctionController::ParticleFunctionController(Controller controller) : + m_controller(std::move(controller)) + { + } + + /*! + * \brief Gets the controller function + * + * \return Controller function responsible for particle update + */ + inline const ParticleFunctionController::Controller& ParticleFunctionController::GetController() const + { + return m_controller; + } + + /*! + * \brief Sets the controller function + * + * \remark The controller function must be valid + */ + inline void ParticleFunctionController::SetController(Controller controller) + { + m_controller = std::move(controller); + } + + template + ParticleFunctionControllerRef ParticleFunctionController::New(Args&&... args) + { + std::unique_ptr object(new ParticleFunctionController(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.hpp b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp new file mode 100644 index 000000000..7aa5bb9f3 --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_PARTICLEFUNCTIONGENERATOR_HPP +#define NAZARA_PARTICLEFUNCTIONGENERATOR_HPP + +#include +#include +#include + +namespace Nz +{ + class ParticleFunctionGenerator; + + using ParticleFunctionGeneratorConstRef = ObjectRef; + using ParticleFunctionGeneratorRef = ObjectRef; + + class NAZARA_GRAPHICS_API ParticleFunctionGenerator : public ParticleGenerator + { + public: + using Generator = std::function; + + inline ParticleFunctionGenerator(Generator controller); + ParticleFunctionGenerator(const ParticleFunctionGenerator&) = default; + ~ParticleFunctionGenerator() = default; + + void Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId) override final; + + inline const Generator& GetGenerator() const; + + inline void SetGenerator(Generator generator); + + template static ParticleFunctionGeneratorRef New(Args&&... args); + + private: + Generator m_generator; + }; +} + +#include + +#endif // NAZARA_PARTICLEFUNCTIONGENERATOR_HPP diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.inl b/include/Nazara/Graphics/ParticleFunctionGenerator.inl new file mode 100644 index 000000000..9cb11683c --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.inl @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline ParticleFunctionGenerator::ParticleFunctionGenerator(Generator generator) : + m_generator(std::move(generator)) + { + } + + /*! + * \brief Gets the generator function + * + * \return Generator function responsible for particle creation + */ + inline const ParticleFunctionGenerator::Generator& ParticleFunctionGenerator::GetGenerator() const + { + return m_generator; + } + + /*! + * \brief Sets the generator function + * + * \remark The generator function must be valid + */ + inline void ParticleFunctionGenerator::SetGenerator(Generator generator) + { + m_generator = std::move(generator); + } + + template + ParticleFunctionGeneratorRef ParticleFunctionGenerator::New(Args&&... args) + { + std::unique_ptr object(new ParticleFunctionGenerator(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.hpp b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp new file mode 100644 index 000000000..810027ae9 --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_PARTICLEFUNCTIONRENDERER_HPP +#define NAZARA_PARTICLEFUNCTIONRENDERER_HPP + +#include +#include +#include + +namespace Nz +{ + class ParticleFunctionRenderer; + + using ParticleFunctionRendererConstRef = ObjectRef; + using ParticleFunctionRendererRef = ObjectRef; + + class NAZARA_GRAPHICS_API ParticleFunctionRenderer : public ParticleRenderer + { + public: + using Renderer = std::function; + + inline ParticleFunctionRenderer(Renderer renderer); + ParticleFunctionRenderer(const ParticleFunctionRenderer&) = default; + ~ParticleFunctionRenderer() = default; + + void Render(const ParticleGroup& group, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) override final; + + inline const Renderer& GetRenderer() const; + + inline void SetRenderer(Renderer renderer); + + template static ParticleFunctionRendererRef New(Args&&... args); + + private: + Renderer m_renderer; + }; +} + +#include + +#endif // NAZARA_PARTICLEFUNCTIONRENDERER_HPP diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.inl b/include/Nazara/Graphics/ParticleFunctionRenderer.inl new file mode 100644 index 000000000..cf859fbfe --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.inl @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline ParticleFunctionRenderer::ParticleFunctionRenderer(Renderer renderer) : + m_renderer(std::move(renderer)) + { + } + + /*! + * \brief Gets the renderer function + * + * \return Renderer function responsible for particle rendering + */ + inline const ParticleFunctionRenderer::Renderer& ParticleFunctionRenderer::GetRenderer() const + { + return m_renderer; + } + + /*! + * \brief Sets the renderer function + * + * \remark The renderer function must be valid + */ + inline void ParticleFunctionRenderer::SetRenderer(Renderer renderer) + { + m_renderer = std::move(renderer); + } + + template + ParticleFunctionRendererRef ParticleFunctionRenderer::New(Args&&... args) + { + std::unique_ptr object(new ParticleFunctionRenderer(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/src/Nazara/Graphics/ParticleFunctionController.cpp b/src/Nazara/Graphics/ParticleFunctionController.cpp new file mode 100644 index 000000000..9b300f450 --- /dev/null +++ b/src/Nazara/Graphics/ParticleFunctionController.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::ParticleFunctionController + * \brief Helper class used to provide a function as a particle controller without going in the process of making a new class + */ + + /*! + * \brief Calls the controller function + * + * \param group Particle group responsible of the particles + * \param mapper Particle mapper, allowing access to the particle data + * \param startId The first ID of the particle to update (inclusive) + * \param endId The last ID of the particle to update (inclusive) + * \param elapsedTime Elapsed time in seconds since the last update + */ + void ParticleFunctionController::Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) + { + m_controller(group, mapper, startId, endId, elapsedTime); + } +} diff --git a/src/Nazara/Graphics/ParticleFunctionGenerator.cpp b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp new file mode 100644 index 000000000..67d43770d --- /dev/null +++ b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::ParticleFunctionGenerator + * \brief Helper class used to provide a function as a particle generator without going in the process of making a new class + */ + + /*! + * \brief Calls the generator function + * + * \param group Particle group responsible of the particles + * \param mapper Particle mapper, allowing access to the particle data + * \param startId The first ID of the particle to update (inclusive) + * \param endId The last ID of the particle to update (inclusive) + */ + void ParticleFunctionGenerator::Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId) + { + m_generator(group, mapper, startId, endId); + } +} diff --git a/src/Nazara/Graphics/ParticleFunctionRenderer.cpp b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp new file mode 100644 index 000000000..36dfea3df --- /dev/null +++ b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::ParticleFunctionRenderer + * \brief Helper class used to provide a function as a particle renderer without going in the process of making a new class + */ + + /*! + * \brief Calls the renderer function + * + * \param group Particle group responsible of the particles + * \param mapper Particle mapper, allowing constant access to the particle data + * \param startId The first ID of the particle to update (inclusive) + * \param endId The last ID of the particle to update (inclusive) + * \param renderQueue The concerned render queue that will receive drawable informations + */ + void ParticleFunctionRenderer::Render(const ParticleGroup& group, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) + { + m_renderer(group, mapper, startId, endId, renderQueue); + } +} From d29813de02d10b43e7e70cb675e685c1fecd8c59 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:56:01 +0200 Subject: [PATCH 164/235] SDK/System: Add possibility to disable systems without destroying them Former-commit-id: 7f5c006d80ba2e7f0babf67c908216b9ca190c70 [formerly 66eab17e82f0cbe6ff89506096573ffd33ccf241] [formerly fadc95f707e00f1cfc9542c7b5aca2e1643aaeec [formerly 8f0f812c57785cad50bd0977c3c592e42b79c5a7]] Former-commit-id: 07a07da0bc9436fa7035e8265c7a2f4aaec26ef2 [formerly e577306b868cdf3186f1c417c7396d237fb9a08b] Former-commit-id: 5bd70063f389a01d704f484350b48fe0674f4b7e --- SDK/include/NDK/BaseSystem.hpp | 5 +++++ SDK/include/NDK/BaseSystem.inl | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/SDK/include/NDK/BaseSystem.hpp b/SDK/include/NDK/BaseSystem.hpp index 8e828149d..969f2b773 100644 --- a/SDK/include/NDK/BaseSystem.hpp +++ b/SDK/include/NDK/BaseSystem.hpp @@ -27,6 +27,8 @@ namespace Ndk BaseSystem(BaseSystem&&) noexcept = default; virtual ~BaseSystem(); + inline void Enable(bool enable = true); + virtual BaseSystem* Clone() const = 0; bool Filters(const Entity* entity) const; @@ -36,6 +38,8 @@ namespace Ndk inline float GetUpdateRate() const; inline World& GetWorld() const; + inline bool IsEnabled() const; + inline bool HasEntity(const Entity* entity) const; inline void SetUpdateRate(float updatePerSecond); @@ -86,6 +90,7 @@ namespace Ndk Nz::Bitset<> m_requiredComponents; SystemIndex m_systemIndex; World* m_world; + bool m_updateEnabled; float m_updateCounter; float m_updateRate; diff --git a/SDK/include/NDK/BaseSystem.inl b/SDK/include/NDK/BaseSystem.inl index 0c2811ac0..490b32e76 100644 --- a/SDK/include/NDK/BaseSystem.inl +++ b/SDK/include/NDK/BaseSystem.inl @@ -2,12 +2,14 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include namespace Ndk { inline BaseSystem::BaseSystem(SystemIndex systemId) : + m_updateEnabled(true), m_systemIndex(systemId) { SetUpdateRate(30); @@ -17,11 +19,17 @@ namespace Ndk m_excludedComponents(system.m_excludedComponents), m_requiredComponents(system.m_requiredComponents), m_systemIndex(system.m_systemIndex), + m_updateEnabled(system.m_updateEnabled), m_updateCounter(0.f), m_updateRate(system.m_updateRate) { } + inline void BaseSystem::Enable(bool enable) + { + m_updateEnabled = enable; + } + inline const std::vector& BaseSystem::GetEntities() const { return m_entities; @@ -42,6 +50,11 @@ namespace Ndk return *m_world; } + inline bool BaseSystem::IsEnabled() const + { + return m_updateEnabled; + } + inline bool BaseSystem::HasEntity(const Entity* entity) const { if (!entity) @@ -58,6 +71,9 @@ namespace Ndk inline void BaseSystem::Update(float elapsedTime) { + if (!IsEnabled()) + return; + if (m_updateRate > 0.f) { m_updateCounter += elapsedTime; From 079c2db408d8ec6d227faf6da38ac372815545c4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:56:36 +0200 Subject: [PATCH 165/235] SDK/ParticleGroupComponent: Fix ParticleGroupComponent not being a handled object Former-commit-id: 5b9da942f722e5346392c5a68c9d6b8eee703446 [formerly 32a18bc118dc5bf61fc8b1bd3e1708c4aca732f3] [formerly 7af7c88829c78e89b3138da1121aa5d0e12f245e [formerly d655301ce12411b9a13b3bec703b4590370d1e1b]] Former-commit-id: 9db87b3fec6af71501e434fde3f840ad65f1089a [formerly 8fc0513356e655f376cb7cc72f00839c4008fbf4] Former-commit-id: ec3b527603d3c772539fa6e67d05331777d555a7 --- SDK/include/NDK/Components/ParticleGroupComponent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NDK/Components/ParticleGroupComponent.hpp index 0dce5dd23..549a6df5c 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.hpp +++ b/SDK/include/NDK/Components/ParticleGroupComponent.hpp @@ -17,7 +17,7 @@ namespace Ndk using ParticleGroupComponentHandle = Nz::ObjectHandle; - class NDK_API ParticleGroupComponent : public Component, public Nz::ParticleGroup + class NDK_API ParticleGroupComponent : public Component, public Nz::ParticleGroup, public Nz::HandledObject { public: inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout); From c30209d44a135b4824925794f36dab2bc754df64 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:57:53 +0200 Subject: [PATCH 166/235] Graphics/ParticleDeclaration: Fix particle declarations leak Former-commit-id: 65c214cb6c146b45b1d87acc08ae08069db81981 [formerly 0802da76594b3201ccaa5c8e769803f80e42d218] [formerly d7bcfa5d1ed177e447381e83486ff3efea2fb967 [formerly 9eb5085f2222eced1a1e0183f57926509aebf449]] Former-commit-id: 23a5b28452c101057761dd497f115e6b86fe0613 [formerly 815e03ee77dd4af22ade6e76343eeb789b3f7078] Former-commit-id: 82ea1338a25422a8bca677e32b01e3fbc86a25e6 --- include/Nazara/Graphics/ParticleDeclaration.inl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Graphics/ParticleDeclaration.inl b/include/Nazara/Graphics/ParticleDeclaration.inl index 27cd92a22..dafa2653a 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.inl +++ b/include/Nazara/Graphics/ParticleDeclaration.inl @@ -11,6 +11,8 @@ namespace Nz ParticleDeclarationRef ParticleDeclaration::New(Args&&... args) { std::unique_ptr object(new ParticleDeclaration(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } From b2f8fc2701e1a6ce8c8e37bb096597c1636496f6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:58:38 +0200 Subject: [PATCH 167/235] Graphics/MaterialPipeline: Fix default pipeline not having an ubershader Former-commit-id: db0ee5afb38004d856fcec24b17eb1a5e588b1eb [formerly daed416404ab75182de5b90b2963b7cf291d404c] [formerly e0662145c3acac11590b804dd95754fa9fa2e284 [formerly e373d5aed8818a7bd7b574915f96bedb81e62643]] Former-commit-id: a3c3ea331053d1e697ec76f1adda0ff5797cb66e [formerly 0034ddafa68e6810fdb2e64daf79c7e4a127f5a4] Former-commit-id: a5027780263c62009f4a34df8110b50960465059 --- src/Nazara/Graphics/MaterialPipeline.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 4cbd56274..c3d35504f 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -58,6 +58,8 @@ namespace Nz void MaterialPipeline::GenerateRenderPipeline(UInt32 flags) const { + NazaraAssert(m_pipelineInfo.uberShader, "Material pipeline has no uber shader"); + ParameterList list; list.SetParameter("ALPHA_MAPPING", m_pipelineInfo.hasAlphaMap); list.SetParameter("ALPHA_TEST", m_pipelineInfo.alphaTest); @@ -136,6 +138,7 @@ namespace Nz // Once the base shaders are registered, we can now set some default materials MaterialPipelineInfo pipelineInfo; + pipelineInfo.uberShader = UberShaderLibrary::Get("Basic"); // Basic 2D - No depth write/face culling pipelineInfo.depthWrite = false; From d145abf73f13bf288be476eb0658d1adc6b8c0bf Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:58:54 +0200 Subject: [PATCH 168/235] Graphics/MaterialPipeline: Fix Translucent2D material not having blending enabled Former-commit-id: 699ad67cb35408eb29abccdbddbb6f550915ef7a [formerly c95de0861832ad43774b607bb189951d75d65423] [formerly 455c5598a4040549181fd0b71a73a19b996d56ac [formerly 5561a644387aab2bc0f3f49500092fd9d6f959cf]] Former-commit-id: 14d87b3000e23f50c13a5314b2b1c790223af6d4 [formerly d065624a5f3fbcd43f6fe98c19bfda21813a5616] Former-commit-id: fdcbfe590b55d2f039f9584567175082284cf59b --- src/Nazara/Graphics/MaterialPipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index c3d35504f..2ca062ad6 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -147,7 +147,7 @@ namespace Nz MaterialPipelineLibrary::Register("Basic2D", GetPipeline(pipelineInfo)); // Translucent 2D - Alpha blending with no depth write/face culling - pipelineInfo.blending = false; + pipelineInfo.blending = true; pipelineInfo.depthWrite = false; pipelineInfo.faceCulling = false; pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; From 4e2f33a8af1563644a10971d5c5e3ce2aa9de9c5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 18:00:38 +0200 Subject: [PATCH 169/235] Graphics/MaterialPipeline: Add Translucent3D pipeline Former-commit-id: a863ae8b6a6f3747b7afb4dd944e5fc5eb925b36 [formerly bd3f68d9fafb0d54c63c82d0299d9f9a71b2594a] [formerly 72b10e7b299a0a34199d8c1367b9a1d0cbec4da5 [formerly c9dadb1dd4c4d1ae3bf2f22da3d6cc54e335256c]] Former-commit-id: aed4a47fb81a9c4626f4b41acaa00a6ecf059e5d [formerly 147148e81d885ac5ceff0beec2826ff7cf4b1daf] Former-commit-id: 726e9868b032636c32f8d55eadd8616b8be8e890 --- src/Nazara/Graphics/MaterialPipeline.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 2ca062ad6..07865c4cd 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -155,6 +155,16 @@ namespace Nz MaterialPipelineLibrary::Register("Translucent2D", GetPipeline(pipelineInfo)); + // Translucent 3D - Alpha blending with depth buffer and no depth write/face culling + pipelineInfo.blending = true; + pipelineInfo.depthBuffer = true; + pipelineInfo.depthWrite = false; + pipelineInfo.faceCulling = false; + pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; + pipelineInfo.srcBlend = BlendFunc_SrcAlpha; + + MaterialPipelineLibrary::Register("Translucent3D", GetPipeline(pipelineInfo)); + return true; } From 17512b2b8e408214f63d2856a32ffb1203195c56 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 18:01:23 +0200 Subject: [PATCH 170/235] SDK/Entity: Add constant component getter Former-commit-id: 602e3d136124f7a49270d95f191eeda0f78179d4 [formerly 1666ac8477467e91e8763109cb91e6cb2074d223] [formerly 3c27a318695a98bb97bbcceb2879f8b9b6da90bf [formerly 3f2b769579af5c103102a9a3d1f0c6a6c7bbbf32]] Former-commit-id: 791755b458c83193eb1849ed3eabf9b41da564bf [formerly 8fc83ec409b57a67999bb0f7a4e25a87d96024a2] Former-commit-id: 58a87205503d734ce877800da06daa1fee838bfa --- SDK/include/NDK/Entity.hpp | 2 ++ SDK/include/NDK/Entity.inl | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index 33661eb50..5aeeb8226 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -40,6 +40,8 @@ namespace Ndk inline BaseComponent& GetComponent(ComponentIndex index); template ComponentType& GetComponent(); + inline const BaseComponent& GetComponent(ComponentIndex index) const; + template const ComponentType& GetComponent() const; inline const Nz::Bitset<>& GetComponentBits() const; inline EntityId GetId() const; inline const Nz::Bitset<>& GetSystemBits() const; diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index c7937b786..a03130b0d 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include #include @@ -50,6 +51,27 @@ namespace Ndk return static_cast(GetComponent(index)); } + inline const BaseComponent& Entity::GetComponent(ComponentIndex index) const + { + ///DOC: Le component doit être présent + NazaraAssert(HasComponent(index), "This component is not part of the entity"); + + BaseComponent* component = m_components[index].get(); + NazaraAssert(component, "Invalid component pointer"); + + return *component; + } + + template + const ComponentType& Entity::GetComponent() const + { + ///DOC: Le component doit être présent + static_assert(std::is_base_of::value, "ComponentType is not a component"); + + ComponentIndex index = GetComponentIndex(); + return static_cast(GetComponent(index)); + } + inline const Nz::Bitset<>& Entity::GetComponentBits() const { return m_componentBits; From 7f70b72285d5ccb3260c494b34394545c82b7bab Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 18:02:30 +0200 Subject: [PATCH 171/235] Graphics/DeferredBloomPass: *bloom intensifies* Former-commit-id: 310eec47f5da32eac58669952f0df734efa61cde [formerly 0667d852c378ce51e728a2513616eb16cee48d76] [formerly f05fa1a7ab43e4ecddbb52d26ee4a76c0b90a2b7 [formerly 37fbfd37f1cedbb3fd110e93533dc8a373504eff]] Former-commit-id: 7568e214571332cbe06ed7f33091c5b73102f13f [formerly 6012a91140a9d0462286f9c4defe594575577db7] Former-commit-id: 7c307c92e41a739815201ac2631f5c01fa3f0195 --- src/Nazara/Graphics/DeferredBloomPass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index 9cf39831a..643024ead 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -23,7 +23,7 @@ namespace Nz m_uniformUpdated(false), m_brightLuminance(0.8f), m_brightMiddleGrey(0.5f), - m_brightThreshold(0.8f), + m_brightThreshold(0.4f), m_blurPassCount(5) { m_bilinearSampler.SetAnisotropyLevel(1); From 63d2077c7b0cd411494d3047a03095fb145bf622 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 15 Aug 2016 01:27:33 +0200 Subject: [PATCH 172/235] Graphics/DeferredRenderTechnique: Optimize Deferred Shading No longer copies depth twice Former-commit-id: 2ce14c38902520e5793434d3cc132bade991afb7 [formerly 0ce2807aab00a0ae73ab565f47591fc8d942ca98] [formerly e1c3f5f4c89f6f57389ad76a9fc8b5facfc9adee [formerly 77787d0fe1f4487404e4a4733775f5a347ba41b0]] Former-commit-id: 36e2dffbbe70861b13b5a471a56a1b32ab17daea [formerly b1fed395ecaf9ec4ec12e6c87a754675bc91c042] Former-commit-id: 0c862f6f2937edc07e7761229b098b4cd7c0b9b6 --- include/Nazara/Graphics/DeferredRenderPass.hpp | 2 +- .../Nazara/Graphics/DeferredRenderTechnique.hpp | 6 +++--- src/Nazara/Graphics/DeferredGeometryPass.cpp | 6 +++--- .../Graphics/DeferredPhongLightingPass.cpp | 3 +++ src/Nazara/Graphics/DeferredRenderPass.cpp | 2 +- src/Nazara/Graphics/DeferredRenderTechnique.cpp | 8 +++++--- .../Shaders/DirectionalLight.frag | 9 ++------- .../Shaders/DirectionalLight.frag.h | 2 +- .../DeferredShading/Shaders/PointSpotLight.frag | 3 ++- .../Shaders/PointSpotLight.frag.h | 2 +- .../Resources/Shaders/PhongLighting/core.frag | 17 +---------------- .../Resources/Shaders/PhongLighting/core.frag.h | 2 +- 12 files changed, 24 insertions(+), 38 deletions(-) diff --git a/include/Nazara/Graphics/DeferredRenderPass.hpp b/include/Nazara/Graphics/DeferredRenderPass.hpp index 34a4020a6..7053bbaa5 100644 --- a/include/Nazara/Graphics/DeferredRenderPass.hpp +++ b/include/Nazara/Graphics/DeferredRenderPass.hpp @@ -47,9 +47,9 @@ namespace Nz Vector2ui m_dimensions; DeferredRenderTechnique* m_deferredTechnique; DeferredRenderQueue* m_renderQueue; - RenderBuffer* m_depthStencilBuffer; RenderTexture* m_GBufferRTT; RenderTexture* m_workRTT; + Texture* m_depthStencilTexture; Texture* m_GBuffer[4]; Texture* m_workTextures[2]; diff --git a/include/Nazara/Graphics/DeferredRenderTechnique.hpp b/include/Nazara/Graphics/DeferredRenderTechnique.hpp index e9e357184..36ac47c8b 100644 --- a/include/Nazara/Graphics/DeferredRenderTechnique.hpp +++ b/include/Nazara/Graphics/DeferredRenderTechnique.hpp @@ -37,7 +37,7 @@ namespace Nz void EnablePass(RenderPassType renderPass, int position, bool enable); - RenderBuffer* GetDepthStencilBuffer() const; + Texture* GetDepthStencilTexture() const; Texture* GetGBuffer(unsigned int i) const; RenderTexture* GetGBufferRTT() const; const ForwardRenderTechnique* GetForwardTechnique() const; @@ -69,14 +69,14 @@ namespace Nz std::map>, RenderPassComparator> m_passes; ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue DeferredRenderQueue m_renderQueue; - mutable RenderBufferRef m_depthStencilBuffer; + mutable TextureRef m_depthStencilTexture; mutable RenderTexture m_GBufferRTT; mutable RenderTexture m_workRTT; mutable TextureRef m_GBuffer[4]; mutable TextureRef m_workTextures[2]; mutable Vector2ui m_GBufferSize; const RenderTarget* m_viewerTarget; -}; + }; } #endif // NAZARA_FORWARDRENDERTECHNIQUE_HPP diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 3cdcb99fe..1c4f8b8bb 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -232,7 +232,7 @@ namespace Nz unsigned int width = dimensions.x; unsigned int height = dimensions.y; - m_depthStencilBuffer->Create(PixelFormatType_Depth24Stencil8, width, height); + m_depthStencilTexture->Create(ImageType_2D, PixelFormatType_Depth24Stencil8, width, height); m_GBuffer[0]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular m_GBuffer[1]->Create(ImageType_2D, PixelFormatType_RG16F, width, height); // Texture 1 : Encoded normal @@ -246,7 +246,7 @@ namespace Nz // Texture 3 : Emission map ? - m_GBufferRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer); + m_GBufferRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture); m_GBufferRTT->Unlock(); @@ -258,7 +258,7 @@ namespace Nz m_workRTT->AttachTexture(AttachmentPoint_Color, i, m_workTextures[i]); } - m_workRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer); + m_workRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture); m_workRTT->Unlock(); diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index afe17ed13..8f83f9a6b 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -114,6 +114,9 @@ namespace Nz Renderer::SetTexture(2, m_GBuffer[2]); Renderer::SetTextureSampler(2, m_pointSampler); + Renderer::SetTexture(3, m_depthStencilTexture); + Renderer::SetTextureSampler(3, m_pointSampler); + Renderer::SetClearColor(Color::Black); Renderer::Clear(RendererBuffer_Color); diff --git a/src/Nazara/Graphics/DeferredRenderPass.cpp b/src/Nazara/Graphics/DeferredRenderPass.cpp index da40c01da..280f6658c 100644 --- a/src/Nazara/Graphics/DeferredRenderPass.cpp +++ b/src/Nazara/Graphics/DeferredRenderPass.cpp @@ -48,7 +48,7 @@ namespace Nz m_deferredTechnique = technique; m_renderQueue = static_cast(technique->GetRenderQueue()); - m_depthStencilBuffer = technique->GetDepthStencilBuffer(); + m_depthStencilTexture = technique->GetDepthStencilTexture(); m_GBufferRTT = technique->GetGBufferRTT(); for (unsigned int i = 0; i < 3; ++i) diff --git a/src/Nazara/Graphics/DeferredRenderTechnique.cpp b/src/Nazara/Graphics/DeferredRenderTechnique.cpp index 585091406..45c8bf7c3 100644 --- a/src/Nazara/Graphics/DeferredRenderTechnique.cpp +++ b/src/Nazara/Graphics/DeferredRenderTechnique.cpp @@ -136,7 +136,7 @@ namespace Nz m_renderQueue(static_cast(m_forwardTechnique.GetRenderQueue())), m_GBufferSize(0U) { - m_depthStencilBuffer = RenderBuffer::New(); + m_depthStencilTexture = Texture::New(); for (unsigned int i = 0; i < 2; ++i) m_workTextures[i] = Texture::New(); @@ -305,9 +305,9 @@ namespace Nz * \return Pointer to the rendering buffer */ - RenderBuffer* DeferredRenderTechnique::GetDepthStencilBuffer() const + Texture* DeferredRenderTechnique::GetDepthStencilTexture() const { - return m_depthStencilBuffer; + return m_depthStencilTexture; } /*! @@ -652,6 +652,7 @@ namespace Nz shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0); shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1); shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2); + shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3); shader = RegisterDeferredShader("DeferredPointSpotLight", r_fragmentSource_PointSpotLight, sizeof(r_fragmentSource_PointSpotLight), basicVertexStage, &error); @@ -664,6 +665,7 @@ namespace Nz shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0); shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1); shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2); + shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3); // Shaders optionnels (S'ils ne sont pas présents, le rendu minimal sera quand même assuré) diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag index dfadac50e..fabb0e6f5 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag @@ -11,17 +11,12 @@ uniform vec4 LightDirection; uniform sampler2D GBuffer0; uniform sampler2D GBuffer1; uniform sampler2D GBuffer2; +uniform sampler2D DepthBuffer; uniform mat4 InvViewProjMatrix; uniform vec2 InvTargetSize; uniform vec4 SceneAmbient; -float ColorToFloat(vec3 color) -{ - const vec3 byte_to_float = vec3(1.0, 1.0/256, 1.0/(256*256)); - return dot(color, byte_to_float); -} - #define kPI 3.1415926536 vec3 DecodeNormal(in vec4 encodedNormal) @@ -44,7 +39,7 @@ void main() vec3 diffuseColor = gVec0.xyz; vec3 normal = DecodeNormal(gVec1); float specularMultiplier = gVec0.w; - float depth = ColorToFloat(gVec2.xyz); + float depth = textureLod(DepthBuffer, texCoord, 0.0).r; float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5); vec3 lightDir = -LightDirection.xyz; diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h index ef67feeb4..b8ba80ab6 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h @@ -1 +1 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,102,108,111,97,116,32,67,111,108,111,114,84,111,70,108,111,97,116,40,118,101,99,51,32,99,111,108,111,114,41,13,10,123,32,9,13,10,9,99,111,110,115,116,32,118,101,99,51,32,98,121,116,101,95,116,111,95,102,108,111,97,116,32,61,32,118,101,99,51,40,49,46,48,44,32,49,46,48,47,50,53,54,44,32,49,46,48,47,40,50,53,54,42,50,53,54,41,41,59,13,10,9,114,101,116,117,114,110,32,100,111,116,40,99,111,108,111,114,44,32,98,121,116,101,95,116,111,95,102,108,111,97,116,41,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,9,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,32,32,32,32,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,32,32,32,32,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,32,32,32,32,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,67,111,108,111,114,84,111,70,108,111,97,116,40,103,86,101,99,50,46,120,121,122,41,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,68,105,114,101,99,116,105,111,110,46,120,121,122,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file +35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,101,112,116,104,66,117,102,102,101,114,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,9,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,32,32,32,32,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,32,32,32,32,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,32,32,32,32,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,116,101,120,116,117,114,101,76,111,100,40,68,101,112,116,104,66,117,102,102,101,114,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,46,114,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,68,105,114,101,99,116,105,111,110,46,120,121,122,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag index bb85cbbe6..37b3f5e1a 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag @@ -19,6 +19,7 @@ uniform vec2 LightParameters3; uniform sampler2D GBuffer0; uniform sampler2D GBuffer1; uniform sampler2D GBuffer2; +uniform sampler2D DepthBuffer; uniform mat4 InvViewProjMatrix; uniform vec2 InvTargetSize; @@ -57,7 +58,7 @@ void main() vec3 diffuseColor = gVec0.xyz; vec3 normal = DecodeNormal(gVec1); float specularMultiplier = gVec0.w; - float depth = ColorToFloat(gVec2.xyz); + float depth = textureLod(DepthBuffer, texCoord, 0.0).r; float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5); vec3 viewSpace = vec3(texCoord*2.0 - 1.0, depth*2.0 - 1.0); diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h index 14376fb95..7f0de77ea 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h @@ -1 +1 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,105,110,116,32,76,105,103,104,116,84,121,112,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,98,111,111,108,32,68,105,115,99,97,114,100,32,61,32,102,97,108,115,101,59,13,10,13,10,102,108,111,97,116,32,67,111,108,111,114,84,111,70,108,111,97,116,40,118,101,99,51,32,99,111,108,111,114,41,13,10,123,32,9,13,10,9,99,111,110,115,116,32,118,101,99,51,32,98,121,116,101,95,116,111,95,102,108,111,97,116,32,61,32,118,101,99,51,40,49,46,48,44,32,49,46,48,47,50,53,54,44,32,49,46,48,47,40,50,53,54,42,50,53,54,41,41,59,13,10,9,114,101,116,117,114,110,32,100,111,116,40,99,111,108,111,114,44,32,98,121,116,101,95,116,111,95,102,108,111,97,116,41,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,9,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,9,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,105,102,32,40,68,105,115,99,97,114,100,41,13,10,9,9,114,101,116,117,114,110,59,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,67,111,108,111,114,84,111,70,108,111,97,116,40,103,86,101,99,50,46,120,121,122,41,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,59,13,10,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,59,13,10,9,108,105,103,104,116,68,105,114,32,47,61,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,13,10,13,10,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,119,42,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,97,116,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,105,102,32,40,76,105,103,104,116,84,121,112,101,32,61,61,32,76,73,71,72,84,95,83,80,79,84,41,13,10,9,123,13,10,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,13,10,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,13,10,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,9,125,13,10,9,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file +35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,105,110,116,32,76,105,103,104,116,84,121,112,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,101,112,116,104,66,117,102,102,101,114,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,98,111,111,108,32,68,105,115,99,97,114,100,32,61,32,102,97,108,115,101,59,13,10,13,10,102,108,111,97,116,32,67,111,108,111,114,84,111,70,108,111,97,116,40,118,101,99,51,32,99,111,108,111,114,41,13,10,123,32,9,13,10,9,99,111,110,115,116,32,118,101,99,51,32,98,121,116,101,95,116,111,95,102,108,111,97,116,32,61,32,118,101,99,51,40,49,46,48,44,32,49,46,48,47,50,53,54,44,32,49,46,48,47,40,50,53,54,42,50,53,54,41,41,59,13,10,9,114,101,116,117,114,110,32,100,111,116,40,99,111,108,111,114,44,32,98,121,116,101,95,116,111,95,102,108,111,97,116,41,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,9,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,9,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,105,102,32,40,68,105,115,99,97,114,100,41,13,10,9,9,114,101,116,117,114,110,59,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,116,101,120,116,117,114,101,76,111,100,40,68,101,112,116,104,66,117,102,102,101,114,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,46,114,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,59,13,10,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,59,13,10,9,108,105,103,104,116,68,105,114,32,47,61,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,13,10,13,10,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,119,42,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,97,116,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,105,102,32,40,76,105,103,104,116,84,121,112,101,32,61,61,32,76,73,71,72,84,95,83,80,79,84,41,13,10,9,123,13,10,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,13,10,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,13,10,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,9,125,13,10,9,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index d5eef7a3c..e37df3fa3 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -68,21 +68,6 @@ uniform vec4 SceneAmbient; uniform sampler2D TextureOverlay; /********************Fonctions********************/ -vec3 FloatToColor(float f) -{ - vec3 color; - - f *= 256.0; - color.x = floor(f); - - f = (f - color.x) * 256.0; - color.y = floor(f); - - color.z = f - color.y; - color.xy *= 0.00390625; // *= 1.0/256 - - return color; -} #define kPI 3.1415926536 @@ -184,7 +169,7 @@ void main() */ RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11))); RenderTarget1 = vec4(EncodeNormal(normal)); - RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf + RenderTarget2 = vec4(0.0, 0.0, 0.0, (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf #else // FLAG_DEFERRED #if ALPHA_MAPPING diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r; diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index 650b62ccd..b9e39fa11 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,47,47,32,72,65,67,75,32,85,78,84,73,76,32,80,82,79,80,69,82,32,70,73,88,13,10,35,105,102,32,71,76,83,76,95,86,69,82,83,73,79,78,32,60,32,52,48,48,13,10,9,35,117,110,100,101,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,35,100,101,102,105,110,101,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,32,48,13,10,35,101,110,100,105,102,13,10,47,47,32,72,65,67,75,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,47,47,32,72,65,67,75,32,85,78,84,73,76,32,80,82,79,80,69,82,32,70,73,88,13,10,35,105,102,32,71,76,83,76,95,86,69,82,83,73,79,78,32,60,32,52,48,48,13,10,9,35,117,110,100,101,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,35,100,101,102,105,110,101,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,32,48,13,10,35,101,110,100,105,102,13,10,47,47,32,72,65,67,75,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,48,46,48,44,32,48,46,48,44,32,48,46,48,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file From 2c213b38eca34504f1a07ad6e1f11f98aab5ca8a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 12:20:58 +0200 Subject: [PATCH 173/235] Build: Remove Vulkan from modules list Since Vulkan support is not yet finished and pushing it to master was a mistake, I see no reason everyone should link against this module when using the engine. Former-commit-id: fd98c841ca2e775f821b428b61b8abd394446c28 [formerly d715266824d544de6c0134ad94db7cbb3a2abd65] [formerly 6620f08cc5a26b06193fc6f5ecee139dbac6e3ac [formerly dd768c134d274560322d7548ae54002b1f578da6]] Former-commit-id: 72f04f965fc2fdd940d7394e8fa446dd8150740f [formerly c1d0ef0a063b5713c66515ed0b1b24c4948cd8b6] Former-commit-id: 0a3cd8ad69e02a3faab6a51dd94bef9a44c557d5 --- build/scripts/modules/vulkan.lua | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 build/scripts/modules/vulkan.lua diff --git a/build/scripts/modules/vulkan.lua b/build/scripts/modules/vulkan.lua deleted file mode 100644 index 62a00a745..000000000 --- a/build/scripts/modules/vulkan.lua +++ /dev/null @@ -1,31 +0,0 @@ -MODULE.Name = "Vulkan" - -MODULE.ClientOnly = true - -MODULE.Defines = { - "VK_NO_PROTOTYPES" -} - -MODULE.Libraries = { - "NazaraCore", - "NazaraUtility" -} - -MODULE.OsDefines.Linux = { --- "VK_USE_PLATFORM_MIR_KHR", - "VK_USE_PLATFORM_XCB_KHR" --- "VK_USE_PLATFORM_XLIB_KHR", --- "VK_USE_PLATFORM_WAYLAND_KHR" -} - -MODULE.OsDefines.BSD = MODULE.OsDefines.Linux -MODULE.OsDefines.Solaris = MODULE.OsDefines.Linux - -MODULE.OsDefines.Windows = { - "VK_USE_PLATFORM_WIN32_KHR" -} - -MODULE.OsFiles.Windows = { - "../src/Nazara/Vulkan/Win32/**.hpp", - "../src/Nazara/Vulkan/Win32/**.cpp" -} From d9423b873b4d93b37ca8551c6696f75bb6732c32 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 12:59:12 +0200 Subject: [PATCH 174/235] Build: Fix TargetDirectory not being taken into account Former-commit-id: 34c501043fa1c585f0773b662725ff58673ab589 [formerly 44f9516100c88cb4170123b4ddab01f449aeb5ed] [formerly 3e07d12226333e80ee24280ada1b57e31f15d4cd [formerly 86f8902caefeb9a7112fe1ff9c9617173f6a67bb]] Former-commit-id: 5cdbb7ea7193e3a8caa74154e86941df4f5571b1 [formerly 4719afc062ad3de9317863b505c7facd76a1b8d8] Former-commit-id: 94fba8a695ddcc5f70de6e1607fd4782f468d851 --- build/scripts/common.lua | 18 +++++++++--------- build/scripts/tools/assimp.lua | 1 - build/scripts/tools/ndk.lua | 2 +- build/scripts/tools/ndk_server.lua | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index b467eb9c5..498b64ee0 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -270,7 +270,6 @@ function NazaraBuild:Execute() project(prefix .. toolTable.Name) location(_ACTION .. "/tools") - targetdir(toolTable.TargetDirectory) if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then kind("SharedLib") @@ -296,6 +295,8 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") + targetdir(toolTable.TargetDirectory) + configuration("x32") libdirs(toolTable.LibraryPaths.x86) @@ -305,18 +306,17 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") - libdirs("../lib/" .. makeLibDir .. "/x86") + libdirs(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then - targetdir("../lib/" .. makeLibDir .. "/x86") + targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x86") end configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") - libdirs("../lib/" .. makeLibDir .. "/x64") if (toolTable.Kind == "library") then - targetdir("../lib/" .. makeLibDir .. "/x64") + targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end @@ -325,7 +325,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") if (toolTable.Kind == "library") then - targetdir("../lib/msvc/x86") + targetdir(toolTable.TargetDirectory .. "/msvc/x86") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x86") end @@ -334,7 +334,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x64") libdirs("../lib/msvc/x64") if (toolTable.Kind == "library") then - targetdir("../lib/msvc/x64") + targetdir(toolTable.TargetDirectory .. "/msvc/x64") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x64") end @@ -343,7 +343,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") if (toolTable.Kind == "library") then - targetdir("../lib/xcode/x86") + targetdir(toolTable.TargetDirectory .. "/xcode/x86") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/xcode/x86") end @@ -352,7 +352,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/xcode/x64") libdirs("../lib/xcode/x64") if (toolTable.Kind == "library") then - targetdir("../lib/xcode/x64") + targetdir(toolTable.TargetDirectory .. "/xcode/x64") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/xcode/x64") end diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index c810d6c0a..f834d6d11 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -2,7 +2,6 @@ TOOL.Name = "Assimp" TOOL.Directory = "../plugins/Assimp" TOOL.Kind = "Plugin" -TOOL.TargetDirectory = "../SDK/lib" TOOL.Includes = { "../extlibs/include", diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 8a40ea170..66dcf9a17 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -2,7 +2,7 @@ TOOL.Name = "SDK" TOOL.Directory = "../SDK" TOOL.Kind = "Library" -TOOL.TargetDirectory = "../SDK/lib" +TOOL.TargetDirectory = "../lib" TOOL.Defines = { "NDK_BUILD" diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index aa8548b80..cebd158c6 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -2,7 +2,7 @@ TOOL.Name = "SDKServer" TOOL.Directory = "../SDK" TOOL.Kind = "Library" -TOOL.TargetDirectory = "../SDK/lib" +TOOL.TargetDirectory = "../lib" TOOL.Defines = { "NDK_BUILD", From bd048291ad8091eee1ece6384162840b5531c88e Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 13:00:03 +0200 Subject: [PATCH 175/235] Remove Vulkan from master branch Former-commit-id: 074820c44945e44980bf0e54a781663361d9c3b2 [formerly 33744f3366ad3dc3b66252e3d82334f1b9b6b0c8] [formerly 14e9ab43b945f031cc28beddfcbcf6a10862ad22 [formerly 6dbeef7ce53354b0c988deb608052b876c2526fa]] Former-commit-id: a90e168da4507644dcd1867259fcba63cc3eb627 [formerly 28399f83c3329d2193eb430878112234fdb053f5] Former-commit-id: e21a219220f057e327935271200eeba3f07b4831 --- include/Nazara/Vulkan/Config.hpp | 53 ---- include/Nazara/Vulkan/ConfigCheck.hpp | 22 -- include/Nazara/Vulkan/Debug.hpp | 8 - include/Nazara/Vulkan/DebugOff.hpp | 9 - include/Nazara/Vulkan/VkCommandBuffer.hpp | 58 ---- include/Nazara/Vulkan/VkCommandBuffer.inl | 150 ----------- include/Nazara/Vulkan/VkCommandPool.hpp | 53 ---- include/Nazara/Vulkan/VkCommandPool.inl | 53 ---- include/Nazara/Vulkan/VkDevice.hpp | 202 -------------- include/Nazara/Vulkan/VkDevice.inl | 96 ------- include/Nazara/Vulkan/VkDeviceObject.hpp | 50 ---- include/Nazara/Vulkan/VkDeviceObject.inl | 89 ------- include/Nazara/Vulkan/VkInstance.hpp | 141 ---------- include/Nazara/Vulkan/VkInstance.inl | 128 --------- include/Nazara/Vulkan/VkLoader.hpp | 52 ---- include/Nazara/Vulkan/VkLoader.inl | 19 -- include/Nazara/Vulkan/VkQueue.hpp | 52 ---- include/Nazara/Vulkan/VkQueue.inl | 102 ------- include/Nazara/Vulkan/VkSemaphore.hpp | 42 --- include/Nazara/Vulkan/VkSemaphore.inl | 41 --- include/Nazara/Vulkan/VkSurface.hpp | 94 ------- include/Nazara/Vulkan/VkSurface.inl | 311 ---------------------- include/Nazara/Vulkan/VkSwapchain.hpp | 51 ---- include/Nazara/Vulkan/VkSwapchain.inl | 90 ------- include/Nazara/Vulkan/Vulkan.hpp | 33 --- src/Nazara/Vulkan/Debug/NewOverload.cpp | 31 --- src/Nazara/Vulkan/VkCommandPool.cpp | 53 ---- src/Nazara/Vulkan/VkDevice.cpp | 178 ------------- src/Nazara/Vulkan/VkInstance.cpp | 193 -------------- src/Nazara/Vulkan/VkLoader.cpp | 117 -------- src/Nazara/Vulkan/Vulkan.cpp | 70 ----- 31 files changed, 2641 deletions(-) delete mode 100644 include/Nazara/Vulkan/Config.hpp delete mode 100644 include/Nazara/Vulkan/ConfigCheck.hpp delete mode 100644 include/Nazara/Vulkan/Debug.hpp delete mode 100644 include/Nazara/Vulkan/DebugOff.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandBuffer.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandBuffer.inl delete mode 100644 include/Nazara/Vulkan/VkCommandPool.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandPool.inl delete mode 100644 include/Nazara/Vulkan/VkDevice.hpp delete mode 100644 include/Nazara/Vulkan/VkDevice.inl delete mode 100644 include/Nazara/Vulkan/VkDeviceObject.hpp delete mode 100644 include/Nazara/Vulkan/VkDeviceObject.inl delete mode 100644 include/Nazara/Vulkan/VkInstance.hpp delete mode 100644 include/Nazara/Vulkan/VkInstance.inl delete mode 100644 include/Nazara/Vulkan/VkLoader.hpp delete mode 100644 include/Nazara/Vulkan/VkLoader.inl delete mode 100644 include/Nazara/Vulkan/VkQueue.hpp delete mode 100644 include/Nazara/Vulkan/VkQueue.inl delete mode 100644 include/Nazara/Vulkan/VkSemaphore.hpp delete mode 100644 include/Nazara/Vulkan/VkSemaphore.inl delete mode 100644 include/Nazara/Vulkan/VkSurface.hpp delete mode 100644 include/Nazara/Vulkan/VkSurface.inl delete mode 100644 include/Nazara/Vulkan/VkSwapchain.hpp delete mode 100644 include/Nazara/Vulkan/VkSwapchain.inl delete mode 100644 include/Nazara/Vulkan/Vulkan.hpp delete mode 100644 src/Nazara/Vulkan/Debug/NewOverload.cpp delete mode 100644 src/Nazara/Vulkan/VkCommandPool.cpp delete mode 100644 src/Nazara/Vulkan/VkDevice.cpp delete mode 100644 src/Nazara/Vulkan/VkInstance.cpp delete mode 100644 src/Nazara/Vulkan/VkLoader.cpp delete mode 100644 src/Nazara/Vulkan/Vulkan.cpp diff --git a/include/Nazara/Vulkan/Config.hpp b/include/Nazara/Vulkan/Config.hpp deleted file mode 100644 index d5f616214..000000000 --- a/include/Nazara/Vulkan/Config.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - Nazara Engine - Vulkan - - Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_CONFIG_VULKAN_HPP -#define NAZARA_CONFIG_VULKAN_HPP - -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci - -// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) -#define NAZARA_VULKAN_MANAGE_MEMORY 0 - -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) -#define NAZARA_VULKAN_SAFE 1 - -/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code - -/// Vérification des valeurs et types de certaines constantes -#include - -#if !defined(NAZARA_STATIC) - #ifdef NAZARA_VULKAN_BUILD - #define NAZARA_VULKAN_API NAZARA_EXPORT - #else - #define NAZARA_VULKAN_API NAZARA_IMPORT - #endif -#else - #define NAZARA_VULKAN_API -#endif - -#endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/Vulkan/ConfigCheck.hpp b/include/Nazara/Vulkan/ConfigCheck.hpp deleted file mode 100644 index 22f334c6f..000000000 --- a/include/Nazara/Vulkan/ConfigCheck.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONFIG_CHECK_VULKANE_HPP -#define NAZARA_CONFIG_CHECK_VULKANE_HPP - -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp - -#include -#define CheckType(name, type, err) static_assert(std::is_ ##type ::value, #type err) -#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) - -// On force la valeur de MANAGE_MEMORY en mode debug -#if defined(NAZARA_DEBUG) && !NAZARA_VULKAN_MANAGE_MEMORY - #undef NAZARA_MODULENAME_MANAGE_MEMORY - #define NAZARA_MODULENAME_MANAGE_MEMORY 0 -#endif - -#endif // NAZARA_CONFIG_CHECK_VULKAN_HPP diff --git a/include/Nazara/Vulkan/Debug.hpp b/include/Nazara/Vulkan/Debug.hpp deleted file mode 100644 index b5e44efae..000000000 --- a/include/Nazara/Vulkan/Debug.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_MODULENAME_MANAGE_MEMORY - #include -#endif diff --git a/include/Nazara/Vulkan/DebugOff.hpp b/include/Nazara/Vulkan/DebugOff.hpp deleted file mode 100644 index e57a2b946..000000000 --- a/include/Nazara/Vulkan/DebugOff.hpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp -#if NAZARA_MODULENAME_MANAGE_MEMORY - #undef delete - #undef new -#endif diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp deleted file mode 100644 index 2dea341dd..000000000 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKCOMMANDBUFFER_HPP -#define NAZARA_VULKAN_VKCOMMANDBUFFER_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API CommandBuffer - { - friend CommandPool; - - public: - CommandBuffer(const CommandBuffer&) = delete; - CommandBuffer(CommandBuffer&& commandBuffer); - inline ~CommandBuffer(); - - inline bool Begin(const VkCommandBufferBeginInfo& info); - inline bool Begin(VkCommandBufferUsageFlags flags); - inline bool Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo); - inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); - inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); - - inline bool End(); - - inline void Free(); - - inline VkResult GetLastErrorCode() const; - - CommandBuffer& operator=(const CommandBuffer&) = delete; - CommandBuffer& operator=(CommandBuffer&&) = delete; - - inline operator VkCommandBuffer(); - - private: - inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); - - CommandPoolHandle m_pool; - VkAllocationCallbacks m_allocator; - VkCommandBuffer m_handle; - VkResult m_lastErrorCode; - - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKCOMMANDBUFFER_HPP diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl deleted file mode 100644 index d2d6f50d7..000000000 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline CommandBuffer::CommandBuffer(CommandPool& pool, VkCommandBuffer handle) : - m_pool(&pool), - m_handle(handle) - { - } - - inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) : - m_pool(std::move(commandBuffer.m_pool)), - m_allocator(commandBuffer.m_allocator), - m_handle(commandBuffer.m_handle), - m_lastErrorCode(commandBuffer.m_lastErrorCode) - { - commandBuffer.m_handle = VK_NULL_HANDLE; - } - - inline CommandBuffer::~CommandBuffer() - { - Free(); - } - - inline bool CommandBuffer::Begin(const VkCommandBufferBeginInfo& info) - { - m_lastErrorCode = m_pool->GetDevice().vkBeginCommandBuffer(m_handle, &info); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to begin command buffer"); - return false; - } - - return true; - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags) - { - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - nullptr - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo) - { - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) - { - NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); - - VkCommandBufferInheritanceInfo inheritanceInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, - nullptr, - renderPass, - subpass, - framebuffer, - VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), - queryFlags, - pipelineStatistics - }; - - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) - { - NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); - - VkCommandBufferInheritanceInfo inheritanceInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, - nullptr, - VK_NULL_HANDLE, - 0, - VK_NULL_HANDLE, - VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), - queryFlags, - pipelineStatistics - }; - - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::End() - { - m_lastErrorCode = m_pool->GetDevice().vkEndCommandBuffer(m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to end command buffer"); - return false; - } - - return true; - } - - inline void CommandBuffer::Free() - { - if (m_handle) - m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); - } - - inline VkResult CommandBuffer::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline CommandBuffer::operator VkCommandBuffer() - { - return m_handle; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkCommandPool.hpp b/include/Nazara/Vulkan/VkCommandPool.hpp deleted file mode 100644 index b51061bb2..000000000 --- a/include/Nazara/Vulkan/VkCommandPool.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKCOMMANDPOOL_HPP -#define NAZARA_VULKAN_VKCOMMANDPOOL_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class CommandBuffer; - class CommandPool; - - using CommandPoolHandle = ObjectHandle; - - class NAZARA_VULKAN_API CommandPool : public DeviceObject, public HandledObject - { - friend DeviceObject; - - public: - inline CommandPool(Device& instance); - CommandPool(const CommandPool&) = delete; - CommandPool(CommandPool&&) = default; - ~CommandPool() = default; - - CommandBuffer AllocateCommandBuffer(VkCommandBufferLevel level); - std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); - - using DeviceObject::Create; - inline bool Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - - inline bool Reset(VkCommandPoolResetFlags flags); - - CommandPool& operator=(const CommandPool&) = delete; - CommandPool& operator=(CommandPool&&) = delete; - - private: - static inline VkResult CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); - static inline void DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKCOMMANDPOOL_HPP diff --git a/include/Nazara/Vulkan/VkCommandPool.inl b/include/Nazara/Vulkan/VkCommandPool.inl deleted file mode 100644 index 61cfeaa43..000000000 --- a/include/Nazara/Vulkan/VkCommandPool.inl +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline CommandPool::CommandPool(Device& device) : - DeviceObject(device) - { - } - - inline bool CommandPool::Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) - { - VkCommandPoolCreateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, - nullptr, - flags, - queueFamilyIndex - }; - - return Create(createInfo, allocator); - } - - inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) - { - m_lastErrorCode = m_device.vkResetCommandPool(m_device, m_handle, flags); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline VkResult CommandPool::CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) - { - return device.vkCreateCommandPool(device, createInfo, allocator, handle); - } - - inline void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyCommandPool(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp deleted file mode 100644 index 1b9d3a470..000000000 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKDEVICE_HPP -#define NAZARA_VULKAN_VKDEVICE_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Device; - class Queue; - class Instance; - - using DeviceHandle = ObjectHandle; - - class NAZARA_VULKAN_API Device : public HandledObject - { - public: - inline Device(Instance& instance); - Device(const Device&) = delete; - Device(Device&&) = delete; - inline ~Device(); - - bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); - inline Instance& GetInstance(); - inline const Instance& GetInstance() const; - inline VkResult GetLastErrorCode() const; - - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); - - inline bool WaitForIdle(); - - Device& operator=(const Device&) = delete; - Device& operator=(Device&&) = delete; - - inline operator VkDevice(); - - // Vulkan functions - #define NAZARA_VULKAN_DEVICE_FUNCTION(func) PFN_##func func - - // Vulkan core - NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBindBufferMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBindImageMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBeginQuery); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBeginRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindIndexBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindPipeline); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindVertexBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBlitImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearAttachments); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearColorImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearDepthStencilImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyBufferToImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyImageToBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyQueryPoolResults); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDispatch); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDispatchIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDraw); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexed); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdEndQuery); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdEndRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdExecuteCommands); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdFillBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdNextSubpass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdPipelineBarrier); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdPushConstants); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResetQueryPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResolveImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetBlendConstants); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBias); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBounds); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetLineWidth); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetScissor); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilCompareMask); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilReference); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilWriteMask); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetViewport); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdUpdateBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdWaitEvents); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdWriteTimestamp); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateBufferView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateComputePipelines); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateDescriptorSetLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateFramebuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateGraphicsPipelines); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImageView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreatePipelineLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSampler); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSemaphore); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateShaderModule); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyBufferView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDevice); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyFramebuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImageView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipeline); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipelineLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySampler); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySemaphore); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyShaderModule); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDeviceWaitIdle); - NAZARA_VULKAN_DEVICE_FUNCTION(vkEndCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeCommandBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFlushMappedMemoryRanges); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetBufferMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetDeviceMemoryCommitment); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetDeviceQueue); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetEventStatus); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetFenceStatus); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageSparseMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageSubresourceLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetRenderAreaGranularity); - NAZARA_VULKAN_DEVICE_FUNCTION(vkInvalidateMappedMemoryRanges); - NAZARA_VULKAN_DEVICE_FUNCTION(vkMapMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkMergePipelineCaches); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueueSubmit); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueueWaitIdle); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetFences); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkSetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkUnmapMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkUpdateDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkWaitForFences); - - // VK_KHR_display_swapchain - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSharedSwapchainsKHR); - - // VK_KHR_surface - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_KHR_swapchain - NAZARA_VULKAN_DEVICE_FUNCTION(vkAcquireNextImageKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSwapchainKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySwapchainKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetSwapchainImagesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueuePresentKHR); - - #undef NAZARA_VULKAN_DEVICE_FUNCTION - - private: - inline PFN_vkVoidFunction GetProcAddr(const char* name); - - Instance& m_instance; - VkAllocationCallbacks m_allocator; - VkDevice m_device; - VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKDEVICE_HPP diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl deleted file mode 100644 index 77dc1e254..000000000 --- a/include/Nazara/Vulkan/VkDevice.inl +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Device::Device(Instance& instance) : - m_instance(instance), - m_device(nullptr) - { - } - - inline Device::~Device() - { - Destroy(); - } - - inline void Device::Destroy() - { - if (m_device) - { - vkDeviceWaitIdle(m_device); - vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - } - - inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) - { - VkQueue queue; - vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - - return Queue(*this, queue); - } - - inline Instance& Device::GetInstance() - { - return m_instance; - } - - inline const Instance& Device::GetInstance() const - { - return m_instance; - } - - inline VkResult Device::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Device::IsExtensionLoaded(const String& extensionName) - { - return m_loadedExtensions.count(extensionName) > 0; - } - - inline bool Device::IsLayerLoaded(const String& layerName) - { - return m_loadedLayers.count(layerName) > 0; - } - - inline bool Device::WaitForIdle() - { - m_lastErrorCode = vkDeviceWaitIdle(m_device); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to wait for device idle"); - return false; - } - - return true; - } - - inline Device::operator VkDevice() - { - return m_device; - } - - inline PFN_vkVoidFunction Device::GetProcAddr(const char* name) - { - PFN_vkVoidFunction func = m_instance.GetDeviceProcAddr(m_device, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp deleted file mode 100644 index dd9da38c9..000000000 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKDEVICEOBJECT_HPP -#define NAZARA_VULKAN_VKDEVICEOBJECT_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - template - class DeviceObject - { - public: - inline DeviceObject(Device& instance); - DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&&); - inline ~DeviceObject(); - - inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - inline Device& GetDevice(); - inline const Device& GetDevice() const; - inline VkResult GetLastErrorCode() const; - - DeviceObject& operator=(const DeviceObject&) = delete; - DeviceObject& operator=(DeviceObject&&) = delete; - - inline operator VkType(); - - protected: - Device& m_device; - VkAllocationCallbacks m_allocator; - VkType m_handle; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl deleted file mode 100644 index a3136156c..000000000 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - template - inline DeviceObject::DeviceObject(Device& device) : - m_device(device), - m_handle(VK_NULL_HANDLE) - { - } - - template - inline DeviceObject::DeviceObject(DeviceObject&& object) : - m_device(object.m_device), - m_allocator(object.m_allocator), - m_handle(object.m_handle), - m_lastErrorCode(object.m_lastErrorCode) - { - object.m_handle = VK_NULL_HANDLE; - } - - template - inline DeviceObject::~DeviceObject() - { - Destroy(); - } - - template - inline bool DeviceObject::Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan object"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - - template - inline void DeviceObject::Destroy() - { - if (m_handle != VK_NULL_HANDLE) - C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - template - inline Device& DeviceObject::GetDevice() - { - return m_device; - } - - template - inline const Device& DeviceObject::GetDevice() const - { - return m_device; - } - - template - inline VkResult DeviceObject::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - template - inline DeviceObject::operator VkType() - { - return m_handle; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkInstance.hpp b/include/Nazara/Vulkan/VkInstance.hpp deleted file mode 100644 index ded2b0ef7..000000000 --- a/include/Nazara/Vulkan/VkInstance.hpp +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKINSTANCE_HPP -#define NAZARA_VULKAN_VKINSTANCE_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API Instance - { - public: - inline Instance(); - Instance(const Instance&) = delete; - Instance(Instance&&) = delete; - inline ~Instance(); - - bool Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(const String& appName, UInt32 appVersion, const String& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - bool EnumeratePhysicalDevices(std::vector* physicalDevices); - - inline PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* name); - - inline void GetPhysicalDeviceFeatures(VkPhysicalDevice device, VkPhysicalDeviceFeatures* features); - inline void GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format, VkFormatProperties* formatProperties); - inline bool GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties); - inline void GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device, VkPhysicalDeviceMemoryProperties* properties); - inline void GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties* properties); - bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties); - - inline VkResult GetLastErrorCode() const; - - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); - - Instance& operator=(const Instance&) = delete; - Instance& operator=(Instance&&) = delete; - - inline operator VkInstance(); - - // Vulkan functions - #define NAZARA_VULKAN_INSTANCE_FUNCTION(func) PFN_##func func - - // Vulkan core - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDevice); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroyInstance); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDeviceProcAddr); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties); - - // VK_KHR_display - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDisplayModeKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayModePropertiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR); - - // VK_KHR_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_EXT_debug_report - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDebugReportMessageEXT); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateMirSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMirPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateXcbSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceXcbPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateXlibSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceXlibPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateWaylandSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateWin32SurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceWin32PresentationSupportKHR); - #endif - - #undef NAZARA_VULKAN_INSTANCE_FUNCTION - - private: - inline PFN_vkVoidFunction GetProcAddr(const char* name); - - VkAllocationCallbacks m_allocator; - VkInstance m_instance; - VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKINSTANCE_HPP diff --git a/include/Nazara/Vulkan/VkInstance.inl b/include/Nazara/Vulkan/VkInstance.inl deleted file mode 100644 index 801691855..000000000 --- a/include/Nazara/Vulkan/VkInstance.inl +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Instance::Instance() : - m_instance(nullptr) - { - } - - inline Instance::~Instance() - { - Destroy(); - } - - inline bool Instance::Create(const String& appName, UInt32 appVersion, const String& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator) - { - VkApplicationInfo appInfo = - { - VK_STRUCTURE_TYPE_APPLICATION_INFO, - nullptr, - appName.GetConstBuffer(), - appVersion, - engineName.GetConstBuffer(), - engineVersion - }; - - VkInstanceCreateInfo instanceInfo = - { - VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - nullptr, - 0, - &appInfo, - static_cast(layers.size()), - (!layers.empty()) ? layers.data() : nullptr, - static_cast(extensions.size()), - (!extensions.empty()) ? extensions.data() : nullptr - }; - - return Create(instanceInfo, allocator); - } - - inline void Instance::Destroy() - { - if (m_instance) - vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) - { - PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - - inline VkResult Instance::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Instance::IsExtensionLoaded(const String& extensionName) - { - return m_loadedExtensions.count(extensionName) > 0; - } - - inline bool Instance::IsLayerLoaded(const String& layerName) - { - return m_loadedLayers.count(layerName) > 0; - } - - inline Instance::operator VkInstance() - { - return m_instance; - } - - inline void Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device, VkPhysicalDeviceFeatures* features) - { - return vkGetPhysicalDeviceFeatures(device, features); - } - - inline void Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format, VkFormatProperties* formatProperties) - { - return vkGetPhysicalDeviceFormatProperties(device, format, formatProperties); - } - - inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) - { - m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get physical device image format properties"); - return false; - } - - return true; - } - - inline void Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device, VkPhysicalDeviceMemoryProperties* memoryProperties) - { - return vkGetPhysicalDeviceMemoryProperties(device, memoryProperties); - } - - inline void Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties* properties) - { - return vkGetPhysicalDeviceProperties(device, properties); - } - - inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) - { - PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkLoader.hpp b/include/Nazara/Vulkan/VkLoader.hpp deleted file mode 100644 index f12429b28..000000000 --- a/include/Nazara/Vulkan/VkLoader.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKLOADER_HPP -#define NAZARA_VULKAN_VKLOADER_HPP - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API Loader - { - public: - Loader() = delete; - ~Loader() = delete; - - static bool EnumerateInstanceExtensionProperties(std::vector* properties, const char* layerName = nullptr); - static bool EnumerateInstanceLayerProperties(std::vector* properties); - - static inline PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name); - - static bool Initialize(); - static void Uninitialize(); - - // Vulkan functions - #define NAZARA_VULKAN_GLOBAL_FUNCTION(func) static PFN_##func func - - NAZARA_VULKAN_GLOBAL_FUNCTION(vkCreateInstance); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkGetInstanceProcAddr); - - #undef NAZARA_VULKAN_GLOBAL_FUNCTION - - private: - static DynLib s_vulkanLib; - static VkResult s_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKLOADER_HPP diff --git a/include/Nazara/Vulkan/VkLoader.inl b/include/Nazara/Vulkan/VkLoader.inl deleted file mode 100644 index 49467366d..000000000 --- a/include/Nazara/Vulkan/VkLoader.inl +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - namespace Vk - { - inline PFN_vkVoidFunction Loader::GetInstanceProcAddr(VkInstance instance, const char* name) - { - return vkGetInstanceProcAddr(instance, name); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp deleted file mode 100644 index 35c8d16e0..000000000 --- a/include/Nazara/Vulkan/VkQueue.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKQUEUE_HPP -#define NAZARA_VULKAN_VKQUEUE_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Queue - { - public: - inline Queue(Device& device, VkQueue queue); - inline Queue(const Queue& queue); - inline Queue(Queue&& queue); - inline ~Queue() = default; - - inline Device& GetDevice(); - inline VkResult GetLastErrorCode() const; - - inline bool Present(const VkPresentInfoKHR& presentInfo); - inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); - - inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE); - inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE); - - inline bool WaitIdle(); - - Queue& operator=(const Queue& queue) = delete; - Queue& operator=(Queue&&) = delete; - - inline operator VkQueue(); - - protected: - Device& m_device; - VkQueue m_handle; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKQUEUE_HPP diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl deleted file mode 100644 index a47918da3..000000000 --- a/include/Nazara/Vulkan/VkQueue.inl +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Queue::Queue(Device& device, VkQueue queue) : - m_device(device), - m_handle(queue), - m_lastErrorCode(VkResult::VK_SUCCESS) - { - } - - inline Queue::Queue(const Queue& queue) : - m_device(queue.m_device), - m_handle(queue.m_handle), - m_lastErrorCode(queue.m_lastErrorCode) - { - } - - inline Queue::Queue(Queue&& queue) : - m_device(queue.m_device), - m_handle(queue.m_handle), - m_lastErrorCode(queue.m_lastErrorCode) - { - } - - inline Device& Queue::GetDevice() - { - return m_device; - } - - inline VkResult Queue::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) - { - m_lastErrorCode = m_device.vkQueuePresentKHR(m_handle, &presentInfo); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) - { - VkPresentInfoKHR presentInfo = - { - VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, - nullptr, - (waitSemaphore) ? 1U : 0U, - &waitSemaphore, - 1U, - &swapchain, - &imageIndex, - nullptr - }; - - return Present(presentInfo); - } - - inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) - { - return Submit(1, &submit, fence); - } - - inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) - { - m_lastErrorCode = m_device.vkQueueSubmit(m_handle, submitCount, submits, fence); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline bool Queue::WaitIdle() - { - m_lastErrorCode = m_device.vkQueueWaitIdle(m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline Queue::operator VkQueue() - { - return m_handle; - } - - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp deleted file mode 100644 index 138d726be..000000000 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKSEMAPHORE_HPP -#define NAZARA_VULKAN_VKSEMAPHORE_HPP - -#include -#include - -namespace Nz -{ - namespace Vk - { - class Semaphore : public DeviceObject - { - friend DeviceObject; - - public: - inline Semaphore(Device& instance); - Semaphore(const Semaphore&) = delete; - Semaphore(Semaphore&&) = default; - ~Semaphore() = default; - - using DeviceObject::Create; - inline bool Create(VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - - Semaphore& operator=(const Semaphore&) = delete; - Semaphore& operator=(Semaphore&&) = delete; - - private: - static VkResult CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); - static void DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSEMAPHORE_HPP diff --git a/include/Nazara/Vulkan/VkSemaphore.inl b/include/Nazara/Vulkan/VkSemaphore.inl deleted file mode 100644 index fd2bf3427..000000000 --- a/include/Nazara/Vulkan/VkSemaphore.inl +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Semaphore::Semaphore(Device& device) : - DeviceObject(device) - { - } - - inline bool Semaphore::Create(VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) - { - VkSemaphoreCreateInfo createInfo = - { - VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, - nullptr, - flags - }; - - return Create(createInfo, allocator); - } - - VkResult Semaphore::CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) - { - return device.vkCreateSemaphore(device, createInfo, allocator, handle); - } - - void Semaphore::DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroySemaphore(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp deleted file mode 100644 index 03a57d2fe..000000000 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKSURFACE_HPP -#define NAZARA_VULKAN_VKSURFACE_HPP - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Instance; - - class Surface - { - public: - inline Surface(Instance& instance); - Surface(const Surface&) = delete; - Surface(Surface&& surface); - inline ~Surface(); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - inline bool Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(ANativeWindow* window, VkAndroidSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - inline bool Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(MirConnection* connection, MirSurface* surface, VkMirSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - inline bool Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(xcb_connection_t* connection, xcb_window_t window, VkXcbSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - inline bool Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(Display* display, Window window, VkXlibSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - inline bool Create(const VkWaylandSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(wl_display* display, wl_surface* surface, VkWaylandSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - inline bool Create(const VkWin32SurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(HINSTANCE instance, HWND handle, VkWin32SurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - inline void Destroy(); - - bool GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities); - bool GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats); - bool GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes); - bool GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported); - - inline bool IsSupported() const; - - inline VkResult GetLastErrorCode() const; - - Surface& operator=(const Surface&) = delete; - Surface& operator=(Surface&&) = delete; - - inline operator VkSurfaceKHR(); - - private: - inline bool Create(const VkAllocationCallbacks* allocator); - - Instance& m_instance; - VkAllocationCallbacks m_allocator; - VkSurfaceKHR m_surface; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSURFACE_HPP diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl deleted file mode 100644 index f64c24af0..000000000 --- a/include/Nazara/Vulkan/VkSurface.inl +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Surface::Surface(Instance& instance) : - m_instance(instance), - m_surface(VK_NULL_HANDLE) - { - } - - inline Surface::Surface(Surface&& surface) : - m_instance(surface.m_instance), - m_allocator(surface.m_allocator), - m_surface(surface.m_surface), - m_lastErrorCode(surface.m_lastErrorCode) - { - surface.m_surface = VK_NULL_HANDLE; - } - - inline Surface::~Surface() - { - Destroy(); - } - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - inline bool Surface::Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateAndroidSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(ANativeWindow* window, VkAndroidSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkAndroidSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - inline bool Surface::Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateMirSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(MirConnection* connection, MirSurface* surface, VkMirSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkMirSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - connection, - surface - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - inline bool Surface::Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateXcbSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(xcb_connection_t* connection, xcb_window_t window, VkXcbSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkXcbSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - connection, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - inline bool Surface::Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateXlibSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(Display* display, Window window, VkXlibSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkXlibSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - display, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - inline bool Surface::Create(const VkWaylandSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateWaylandSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(wl_display* display, wl_surface* surface, VkWaylandSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkWaylandSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - display, - surface - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - inline bool Surface::Create(const VkWin32SurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateWin32SurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(HINSTANCE instance, HWND handle, VkWin32SurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkWin32SurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - instance, - handle - }; - - return Create(createInfo, allocator); - } - #endif - - inline void Surface::Destroy() - { - if (m_surface != VK_NULL_HANDLE) - m_instance.vkDestroySurfaceKHR(m_instance, m_surface, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - inline VkResult Surface::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Surface::GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) - { - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surface, surfaceCapabilities); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query surface capabilities"); - return false; - } - - return true; - } - - inline bool Surface::GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) - { - // First, query format count - UInt32 surfaceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || surfaceCount == 0) - { - NazaraError("Failed to query format count"); - return false; - } - - // Now we can get the list of the available physical device - surfaceFormats->resize(surfaceCount); - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, surfaceFormats->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query formats"); - return false; - } - - return true; - } - - inline bool Surface::GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) - { - // First, query present modes count - UInt32 presentModeCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || presentModeCount == 0) - { - NazaraError("Failed to query present mode count"); - return false; - } - - // Now we can get the list of the available physical device - presentModes->resize(presentModeCount); - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, presentModes->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query present modes"); - return false; - } - - return true; - } - - inline bool Surface::GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) - { - VkBool32 presentationSupported = VK_FALSE; - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, m_surface, &presentationSupported); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query surface capabilities"); - return false; - } - - *supported = (presentationSupported == VK_TRUE); - - return true; - } - - inline bool Surface::IsSupported() const - { - if (!m_instance.IsExtensionLoaded("VK_KHR_surface")) - return false; - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_android_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_mir_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_xcb_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_xlib_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_wayland_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_win32_surface")) - return true; - #endif - - return false; - } - - inline Surface::operator VkSurfaceKHR() - { - return m_surface; - } - - inline bool Surface::Create(const VkAllocationCallbacks* allocator) - { - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan surface"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp deleted file mode 100644 index 374ad88e6..000000000 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKSWAPCHAIN_HPP -#define NAZARA_VULKAN_VKSWAPCHAIN_HPP - -#include -#include - -namespace Nz -{ - namespace Vk - { - class Swapchain : public DeviceObject - { - friend DeviceObject; - - public: - inline Swapchain(Device& instance); - Swapchain(const Swapchain&) = delete; - Swapchain(Swapchain&&) = default; - ~Swapchain() = default; - - inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex); - - inline bool Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - - inline VkImage GetImage(UInt32 index) const; - inline const std::vector& GetImages() const; - inline UInt32 GetImageCount() const; - - inline bool IsSupported() const; - - Swapchain& operator=(const Swapchain&) = delete; - Swapchain& operator=(Swapchain&&) = delete; - - private: - static VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); - static void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); - - std::vector m_images; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSWAPCHAIN_HPP diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl deleted file mode 100644 index 8865012e4..000000000 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Swapchain::Swapchain(Device& device) : - DeviceObject(device) - { - } - - inline bool Swapchain::AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) - { - m_lastErrorCode = m_device.vkAcquireNextImageKHR(m_device, m_handle, timeout, semaphore, fence, imageIndex); - switch (m_lastErrorCode) - { - case VkResult::VK_SUBOPTIMAL_KHR: - case VkResult::VK_SUCCESS: - return true; - - default: - return false; - } - } - - inline bool Swapchain::Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - if (!DeviceObject::Create(createInfo, allocator)) - return false; - - UInt32 imageCount = 0; - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || imageCount == 0) - { - NazaraError("Failed to query swapchain image count"); - return false; - } - - m_images.resize(imageCount); - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, m_images.data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query swapchain images"); - return false; - } - - return true; - } - - inline VkImage Swapchain::GetImage(UInt32 index) const - { - return m_images[index]; - } - - inline const std::vector& Swapchain::GetImages() const - { - return m_images; - } - - inline UInt32 Swapchain::GetImageCount() const - { - return m_images.size(); - } - - inline bool Swapchain::IsSupported() const - { - if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) - return false; - } - - VkResult Swapchain::CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) - { - return device.vkCreateSwapchainKHR(device, createInfo, allocator, handle); - } - - void Swapchain::DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroySwapchainKHR(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp deleted file mode 100644 index 9d90202c2..000000000 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_HPP -#define NAZARA_VULKAN_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_VULKAN_API Vulkan - { - public: - Vulkan() = delete; - ~Vulkan() = delete; - - static bool Initialize(); - - static bool IsInitialized(); - - static void Uninitialize(); - - private: - static unsigned int s_moduleReferenceCounter; - }; -} - -#endif // NAZARA_VULKAN_HPP diff --git a/src/Nazara/Vulkan/Debug/NewOverload.cpp b/src/Nazara/Vulkan/Debug/NewOverload.cpp deleted file mode 100644 index 410a53c76..000000000 --- a/src/Nazara/Vulkan/Debug/NewOverload.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2014 AUTHORS -// This file is part of the "Nazara Engine - Module name" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_VULKAN_MANAGE_MEMORY - -#include -#include // Nécessaire ? - -void* operator new(std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, false); -} - -void* operator new[](std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, true); -} - -void operator delete(void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, false); -} - -void operator delete[](void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, true); -} - -#endif // NAZARA_VULKAN_MANAGE_MEMORY diff --git a/src/Nazara/Vulkan/VkCommandPool.cpp b/src/Nazara/Vulkan/VkCommandPool.cpp deleted file mode 100644 index 3ee53ab6f..000000000 --- a/src/Nazara/Vulkan/VkCommandPool.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - CommandBuffer CommandPool::AllocateCommandBuffer(VkCommandBufferLevel level) - { - VkCommandBufferAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - nullptr, - m_handle, - level, - 1U - }; - - VkCommandBuffer handle = VK_NULL_HANDLE; - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, &handle); - - return CommandBuffer(*this, handle); - } - - std::vector CommandPool::AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level) - { - VkCommandBufferAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - nullptr, - m_handle, - level, - 1U - }; - - std::vector handles(commandBufferCount, VK_NULL_HANDLE); - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, handles.data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return std::vector(); - - std::vector commandBuffers; - for (UInt32 i = 0; i < commandBufferCount; ++i) - commandBuffers.emplace_back(CommandBuffer(*this, handles[i])); - - return commandBuffers; - } - } -} diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp deleted file mode 100644 index c2f39da76..000000000 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan device"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - // Parse extensions and layers - for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i) - m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]); - - for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) - m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); - - #define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) - - try - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - - NAZARA_VULKAN_LOAD_DEVICE(vkAllocateCommandBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkAllocateMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkBeginCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkBindBufferMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkBindImageMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBeginQuery); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBeginRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindIndexBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindPipeline); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindVertexBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBlitImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearAttachments); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearColorImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearDepthStencilImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyBufferToImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyImageToBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyQueryPoolResults); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDispatch); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDispatchIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDraw); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndexed); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndexedIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdEndQuery); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdEndRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdExecuteCommands); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdFillBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdNextSubpass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdPipelineBarrier); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdPushConstants); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResetQueryPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResolveImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetBlendConstants); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetDepthBias); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetDepthBounds); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetLineWidth); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetScissor); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilCompareMask); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilReference); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilWriteMask); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetViewport); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdUpdateBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdWaitEvents); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdWriteTimestamp); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateBufferView); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateComputePipelines); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateDescriptorSetLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateFramebuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateGraphicsPipelines); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateImageView); - NAZARA_VULKAN_LOAD_DEVICE(vkCreatePipelineLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSampler); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSemaphore); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateShaderModule); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyBufferView); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDescriptorSetLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDevice); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyFramebuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImage); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImageView); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipeline); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipelineLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySampler); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySemaphore); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyShaderModule); - NAZARA_VULKAN_LOAD_DEVICE(vkDeviceWaitIdle); - NAZARA_VULKAN_LOAD_DEVICE(vkEndCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeCommandBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkFlushMappedMemoryRanges); - NAZARA_VULKAN_LOAD_DEVICE(vkGetBufferMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetDeviceMemoryCommitment); - NAZARA_VULKAN_LOAD_DEVICE(vkGetDeviceQueue); - NAZARA_VULKAN_LOAD_DEVICE(vkGetEventStatus); - NAZARA_VULKAN_LOAD_DEVICE(vkGetFenceStatus); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageSparseMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageSubresourceLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkGetRenderAreaGranularity); - NAZARA_VULKAN_LOAD_DEVICE(vkInvalidateMappedMemoryRanges); - NAZARA_VULKAN_LOAD_DEVICE(vkMapMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkMergePipelineCaches); - NAZARA_VULKAN_LOAD_DEVICE(vkQueueSubmit); - NAZARA_VULKAN_LOAD_DEVICE(vkQueueWaitIdle); - NAZARA_VULKAN_LOAD_DEVICE(vkResetCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkResetCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkResetDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkResetFences); - NAZARA_VULKAN_LOAD_DEVICE(vkResetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkSetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkUnmapMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkUpdateDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkWaitForFences); - - // VK_KHR_display_swapchain - if (IsExtensionLoaded("VK_KHR_display_swapchain")) - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSharedSwapchainsKHR); - - // VK_KHR_swapchain - if (IsExtensionLoaded("VK_KHR_swapchain")) - { - NAZARA_VULKAN_LOAD_DEVICE(vkAcquireNextImageKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSwapchainKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySwapchainKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkGetSwapchainImagesKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkQueuePresentKHR); - } - } - catch (const std::exception& e) - { - NazaraError(String("Failed to query device function: ") + e.what()); - return false; - } - - #undef NAZARA_VULKAN_LOAD_DEVICE - - return true; - } - } -} diff --git a/src/Nazara/Vulkan/VkInstance.cpp b/src/Nazara/Vulkan/VkInstance.cpp deleted file mode 100644 index 35378a699..000000000 --- a/src/Nazara/Vulkan/VkInstance.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - bool Instance::Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = Loader::vkCreateInstance(&createInfo, allocator, &m_instance); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan instance"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - // Parse extensions and layers - for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i) - m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]); - - for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) - m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); - - // And now load everything - #define NAZARA_VULKAN_LOAD_INSTANCE(func) func = reinterpret_cast(GetProcAddr(#func)) - - try - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - - // Vulkan core - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDevice); - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroyInstance); - NAZARA_VULKAN_LOAD_INSTANCE(vkEnumeratePhysicalDevices); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDeviceProcAddr); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceFeatures); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceQueueFamilyProperties); - - // VK_KHR_display - if (IsExtensionLoaded("VK_KHR_display")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDisplayModeKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayModePropertiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPropertiesKHR); - } - - // VK_KHR_surface - if (IsExtensionLoaded("VK_KHR_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroySurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceSupportKHR); - } - - // VK_EXT_debug_report - if (IsExtensionLoaded("VK_EXT_debug_report")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDebugReportCallbackEXT); - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKAN_LOAD_INSTANCE(vkDebugReportMessageEXT); - } - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - if (IsExtensionLoaded("VK_KHR_android_surface")) - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - if (IsExtensionLoaded("VK_KHR_mir_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateMirSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceMirPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - if (IsExtensionLoaded("VK_KHR_xcb_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateXcbSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceXcbPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - if (IsExtensionLoaded("VK_KHR_xlib_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateXlibSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceXlibPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - if (IsExtensionLoaded("VK_KHR_wayland_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateWaylandSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - if (IsExtensionLoaded("VK_KHR_win32_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateWin32SurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceWin32PresentationSupportKHR); - } - #endif - } - catch (const std::exception& e) - { - NazaraError(String("Failed to query instance function: ") + e.what()); - return false; - } - - #undef NAZARA_VULKAN_LOAD_INSTANCE - - return true; - } - - bool Instance::EnumeratePhysicalDevices(std::vector* devices) - { - NazaraAssert(devices, "Invalid device vector"); - - // First, query physical device count - UInt32 deviceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || deviceCount == 0) - { - NazaraError("Failed to query physical device count"); - return false; - } - - // Now we can get the list of the available physical device - devices->resize(deviceCount); - m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query physical devices"); - return false; - } - - return true; - } - - bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties) - { - NazaraAssert(queueFamilyProperties, "Invalid device vector"); - - // First, query physical device count - UInt32 queueFamiliesCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, nullptr); - if (queueFamiliesCount == 0) - { - NazaraError("Failed to query physical device count"); - return false; - } - - // Now we can get the list of the available physical device - queueFamilyProperties->resize(queueFamiliesCount); - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, queueFamilyProperties->data()); - - return true; - } - - } -} diff --git a/src/Nazara/Vulkan/VkLoader.cpp b/src/Nazara/Vulkan/VkLoader.cpp deleted file mode 100644 index c9d2a360d..000000000 --- a/src/Nazara/Vulkan/VkLoader.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - namespace Vk - { - bool Loader::EnumerateInstanceExtensionProperties(std::vector* properties, const char* layerName) - { - NazaraAssert(properties, "Invalid device vector"); - - // First, query physical device count - UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get instance extension properties count"); - return false; - } - - // Now we can get the list of the available physical device - properties->resize(propertyCount); - s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to enumerate instance extension properties"); - return false; - } - - return true; - } - - bool Loader::EnumerateInstanceLayerProperties(std::vector* properties) - { - NazaraAssert(properties, "Invalid device vector"); - - // First, query physical device count - UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get instance layer properties count"); - return false; - } - - // Now we can get the list of the available physical device - properties->resize(propertyCount); - s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to enumerate instance layer properties"); - return false; - } - - return true; - } - - bool Loader::Initialize() - { - #ifdef NAZARA_PLATFORM_WINDOWS - s_vulkanLib.Load("vulkan-1.dll"); - #elif defined(NAZARA_PLATFORM_LINUX) - s_vulkanLib.Load("libvulkan.so"); - #else - #error Unhandled platform - #endif - - if (!s_vulkanLib.IsLoaded()) - { - NazaraError("Failed to open vulkan library: " + s_vulkanLib.GetLastError()); - return false; - } - - // vkGetInstanceProcAddr is the only function that's garantee to be exported - vkGetInstanceProcAddr = reinterpret_cast(s_vulkanLib.GetSymbol("vkGetInstanceProcAddr")); - if (!vkGetInstanceProcAddr) - { - NazaraError("Failed to get symbol \"vkGetInstanceProcAddr\": " + s_vulkanLib.GetLastError()); - return false; - } - - // all other functions should be loaded using vkGetInstanceProcAddr - #define NAZARA_VULKAN_LOAD_GLOBAL(func) func = reinterpret_cast(vkGetInstanceProcAddr(nullptr, #func)) - - NAZARA_VULKAN_LOAD_GLOBAL(vkCreateInstance); - NAZARA_VULKAN_LOAD_GLOBAL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_LOAD_GLOBAL(vkEnumerateInstanceLayerProperties); - - #undef NAZARA_VULKAN_LOAD_GLOBAL - - s_lastErrorCode = VkResult::VK_SUCCESS; - - return true; - } - - #define NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(func) PFN_##func Loader::func = nullptr - - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkCreateInstance); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceLayerProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkGetInstanceProcAddr); - - #undef NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL - - DynLib Loader::s_vulkanLib; - VkResult Loader::s_lastErrorCode; - - void Loader::Uninitialize() - { - s_vulkanLib.Unload(); - } - } -} diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp deleted file mode 100644 index 00bb55337..000000000 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - bool Vulkan::Initialize() - { - if (s_moduleReferenceCounter > 0) - { - s_moduleReferenceCounter++; - return true; // Already initialized - } - - // Initialize module dependencies - if (!Utility::Initialize()) - { - NazaraError("Failed to initialize utility module"); - return false; - } - - s_moduleReferenceCounter++; - - CallOnExit onExit(Vulkan::Uninitialize); - - // Initialize module here - - onExit.Reset(); - - NazaraNotice("Initialized: Vulkan module"); - return true; - } - - bool Vulkan::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - void Vulkan::Uninitialize() - { - if (s_moduleReferenceCounter != 1) - { - // Either the module is not initialized, either it was initialized multiple times - if (s_moduleReferenceCounter > 1) - s_moduleReferenceCounter--; - - return; - } - - s_moduleReferenceCounter = 0; - - // Uninitialize module here - - NazaraNotice("Uninitialized: Vulkan module"); - - // Free module dependencies - Utility::Uninitialize(); - } - - unsigned int Vulkan::s_moduleReferenceCounter = 0; -} - From 62ebc3e8cf5b2f8dc45b0c43a927a5e22d7d4a6b Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 13:05:41 +0200 Subject: [PATCH 176/235] Build/Assimp: Fix assimp rejection Former-commit-id: 0565c70bb35215b3bcda0368d709730055161827 [formerly 5272f3ad85542d2f45e0314bf399d12a6d656fff] [formerly 39a37805566ce1dea9f8a0bccdfebe989ba50142 [formerly 827c3b178b687946ef7559735d4325b4d4f7bd42]] Former-commit-id: 0796fc3248fb234361eb6bef14a76faa0a824056 [formerly b96bbddabdf7708aa8522632b0e860590a0d7db4] Former-commit-id: 7377a548aa94c75f22d8d3c420df8fb7e33b0d2b --- build/scripts/common.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 498b64ee0..b8ca27e70 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -576,10 +576,10 @@ function NazaraBuild:Initialize() local succeed, err = self:RegisterTool(TOOL) if (not succeed) then - print("Unable to register tool: " .. err) + print("Unable to register tool " .. tostring(TOOL.Name) .. ": " .. err) end else - print("Unable to load tool file: " .. err) + print("Unable to load tool file " .. v .. ": " .. err) end end TOOL = nil @@ -990,10 +990,6 @@ function NazaraBuild:RegisterTool(toolTable) return false, "This tool name is already in use" end - if (toolTable.TargetDirectory == nil or type(toolTable.TargetDirectory) ~= "string" or string.len(toolTable.TargetDirectory) == 0) then - return false, "Invalid tool directory" - end - if (toolTable.Kind == nil or type(toolTable.Kind) ~= "string" or string.len(toolTable.Kind) == 0) then return false, "Invalid tool type" end @@ -1005,6 +1001,10 @@ function NazaraBuild:RegisterTool(toolTable) return false, "Invalid tool type" end + if (lowerCaseKind ~= "plugin" and (toolTable.TargetDirectory == nil or type(toolTable.TargetDirectory) ~= "string" or string.len(toolTable.TargetDirectory) == 0)) then + return false, "Invalid tool directory" + end + toolTable.Type = "Tool" self.Tools[lowerCaseName] = toolTable return true From ef0ddb5ef1ebdebb4af52d8f90c663e5a7081459 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 13:11:52 +0200 Subject: [PATCH 177/235] Build: Fix an oopsie Former-commit-id: d1411c2e1f1ee8ce5d2773c0834e2e9c06732a21 [formerly 0dff837b8db9c262dd71dec1ba83fe4f36b98de7] [formerly 70f74c0e185d1a8bbd791ddd1316b5b2df92a50a [formerly 95ff56ebb91662f7e9211c79d7af9e14f6a3f403]] Former-commit-id: f5e08860c71fc922d7aab1ea584b22b99862773b [formerly 76482eaed8258fdc0ebe82736a52d6cf6b711201] Former-commit-id: 5b7c4ba98d7f9bb5485dbca7bb24cc9890125cd9 --- build/scripts/common.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index b8ca27e70..b20d213fa 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -278,6 +278,7 @@ function NazaraBuild:Execute() self:MakeInstallCommands(toolTable) elseif (toolTable.Kind == "application") then debugdir(toolTable.TargetDirectory) + targetdir(toolTable.TargetDirectory) if (toolTable.EnableConsole) then kind("ConsoleApp") else @@ -295,8 +296,6 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - targetdir(toolTable.TargetDirectory) - configuration("x32") libdirs(toolTable.LibraryPaths.x86) @@ -306,7 +305,7 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") - libdirs(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") + libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") elseif (toolTable.Kind == "plugin") then @@ -315,6 +314,7 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") + libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64") elseif (toolTable.Kind == "plugin") then From 99b631d82f868d3ab4dffe8154928aad3a582f58 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 19 Aug 2016 01:49:36 +0200 Subject: [PATCH 178/235] Fixed linking of tools on GCC 64bits Former-commit-id: b6191b5aabb5378a242f271e7faa511ea09feebd [formerly 68387e1786d721c8eb657c0217bf4c80422b7c51] [formerly e2e5f1c8a221f350e695829c669a4c6af16c2635 [formerly c7b894f99a2d70988792b12914a1f411d4112855]] Former-commit-id: 3a873af915fd03188b03c1a9c5215b1568f2e333 [formerly a12848832f2df0e659f99741958ed970e8a42c46] Former-commit-id: 8273bf5e11447fb9628bf17c517be9f3ffec0bd8 --- build/scripts/common.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index b20d213fa..cf6fa6560 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -314,7 +314,7 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") - libdirs("../lib/" .. makeLibDir .. "/x86") + libdirs("../lib/" .. makeLibDir .. "/x64") if (toolTable.Kind == "library") then targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64") elseif (toolTable.Kind == "plugin") then @@ -1084,4 +1084,4 @@ function NazaraBuild:SetupModuleTable(infoTable) table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64") end -NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable \ No newline at end of file +NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable From a130846efac9f515bcc3def237018d9fe5b4a6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 20 Aug 2016 17:12:20 +0200 Subject: [PATCH 179/235] Example/HardwareInfo: Fix generated file Former-commit-id: fc3d1f86313f4041102e1c0a95b07ef98b315942 [formerly bcca61fe71a9b1feae53b55bee728d9f2765e898] [formerly cc91f7aaa0f7a39f57b114781847fcfea8e6ea44 [formerly 285f8bf93ce25d27ac416413e7f04b906ab0a919]] Former-commit-id: adefe47d8d1613f1cc5b5f99d4230ed4dbb81547 [formerly 7db967dc9d1e2d2d866d10fe79867f77759b92ea] Former-commit-id: 2c16388727277916329cb36b8dd2319c7f71c19c --- .gitignore | 3 +++ examples/HardwareInfo/main.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 463291bc4..6266c2b6b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ tests/*.dll tests/*.so lib/* +# Example generated files +examples/bin/HardwareInfo.txt + # Feature page build/scripts/features/index.html diff --git a/examples/HardwareInfo/main.cpp b/examples/HardwareInfo/main.cpp index 401224315..820f42a62 100644 --- a/examples/HardwareInfo/main.cpp +++ b/examples/HardwareInfo/main.cpp @@ -94,7 +94,7 @@ int main() std::cout << oss.str() << std::endl; - Nz::File reportFile("RapportNz::HardwareInfo.txt"); + Nz::File reportFile("HardwareInfo.txt"); if (reportFile.Open(Nz::OpenMode_Text | Nz::OpenMode_Truncate | Nz::OpenMode_WriteOnly)) { reportFile.Write(oss.str()); // Conversion implicite en Nz::String From 8cc117e3903b2506167ebc28deae28361e011f24 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 21 Aug 2016 13:47:43 +0200 Subject: [PATCH 180/235] Fix memory leak Former-commit-id: 904c564c7653ff4a402757356c4695d757363bbe [formerly a008f1b67d81cf9ef036e3866542d776ccc14808] [formerly c9de13c9b6c5073ad5fb8cea1a4338a737e5bde0 [formerly 5eb53f8fd1cc27af892cd391fb02f9f0a4c0e49d]] Former-commit-id: 3fc0d3e76bff7c06e5f5c3239c9e7c5b62908994 [formerly da494d6b74c8329b1e8e1f82c1ca29dd2903d07a] Former-commit-id: 686a0f1a6a894400d188a59abe7e175b8f62f0b0 --- include/Nazara/Graphics/MaterialPipeline.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl index ce937883d..0cbea4e61 100644 --- a/include/Nazara/Graphics/MaterialPipeline.inl +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -97,6 +97,7 @@ namespace Nz MaterialPipelineRef MaterialPipeline::New(Args&&... args) { std::unique_ptr object(new MaterialPipeline(std::forward(args)...)); + object->SetPersistent(false); return object.release(); } } From c8c19f5845235f585e6afe471ecbf4e1096247ee Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 21 Aug 2016 13:48:52 +0200 Subject: [PATCH 182/235] Documentation for module 'NDK' Former-commit-id: 7d8a51d8ad14bfb16a76b8d77c92c776bfb694ab [formerly 1dac8450f2eddf175b3eb2b6675621ea0b2a0df7] [formerly bb4300770d267df0eed5c509ec748c6866f36376 [formerly d15a100319ffc8805c7f93c9bcd936e204dad40b]] Former-commit-id: 83a4715ed2a3220b7ef4718401d50ce584d275fc [formerly a941a150d510a51daed4322723795d90b6d56724] Former-commit-id: f46308abb0bc577d73447f6a574ec091a50a9cca --- SDK/include/NDK/Algorithm.inl | 50 +- SDK/include/NDK/Application.inl | 48 +- SDK/include/NDK/BaseComponent.hpp | 2 +- SDK/include/NDK/BaseComponent.inl | 47 +- SDK/include/NDK/BaseSystem.hpp | 2 +- SDK/include/NDK/BaseSystem.inl | 153 +++++- SDK/include/NDK/Component.hpp | 2 +- SDK/include/NDK/Component.inl | 35 +- .../NDK/Components/CameraComponent.inl | 174 ++++++- .../NDK/Components/CollisionComponent.inl | 29 ++ .../NDK/Components/GraphicsComponent.inl | 67 +++ SDK/include/NDK/Components/LightComponent.inl | 4 + .../NDK/Components/ListenerComponent.inl | 15 + SDK/include/NDK/Components/NodeComponent.inl | 9 + .../Components/ParticleEmitterComponent.inl | 21 + .../NDK/Components/ParticleGroupComponent.inl | 39 ++ .../NDK/Components/PhysicsComponent.inl | 187 +++++++- .../NDK/Components/VelocityComponent.inl | 19 + SDK/include/NDK/Console.inl | 40 ++ SDK/include/NDK/Entity.inl | 173 ++++++- SDK/include/NDK/EntityList.inl | 42 +- SDK/include/NDK/EntityOwner.inl | 36 ++ SDK/include/NDK/LuaAPI.inl | 443 +++++++++++++++++- SDK/include/NDK/LuaBinding.inl | 28 ++ SDK/include/NDK/Prerequesites.hpp | 6 +- SDK/include/NDK/Sdk.inl | 5 + SDK/include/NDK/StateMachine.inl | 38 ++ SDK/include/NDK/System.hpp | 4 +- SDK/include/NDK/System.inl | 29 +- SDK/include/NDK/Systems/PhysicsSystem.inl | 10 + SDK/include/NDK/Systems/RenderSystem.inl | 77 +++ SDK/include/NDK/World.hpp | 1 - SDK/include/NDK/World.inl | 136 +++++- SDK/src/NDK/Application.cpp | 10 + SDK/src/NDK/BaseComponent.cpp | 28 ++ SDK/src/NDK/BaseSystem.cpp | 44 +- SDK/src/NDK/Components/CameraComponent.cpp | 88 ++++ SDK/src/NDK/Components/CollisionComponent.cpp | 43 +- SDK/src/NDK/Components/GraphicsComponent.cpp | 54 ++- .../Components/ParticleEmitterComponent.cpp | 13 + SDK/src/NDK/Components/PhysicsComponent.cpp | 32 ++ SDK/src/NDK/Console.cpp | 88 ++++ SDK/src/NDK/Entity.cpp | 80 +++- SDK/src/NDK/LuaAPI.cpp | 21 + SDK/src/NDK/LuaBinding.cpp | 16 + SDK/src/NDK/LuaBinding_Audio.cpp | 10 + SDK/src/NDK/LuaBinding_Core.cpp | 10 + SDK/src/NDK/LuaBinding_Graphics.cpp | 10 + SDK/src/NDK/LuaBinding_Math.cpp | 10 + SDK/src/NDK/LuaBinding_Network.cpp | 10 + SDK/src/NDK/LuaBinding_Renderer.cpp | 10 + SDK/src/NDK/LuaBinding_SDK.cpp | 18 + SDK/src/NDK/LuaBinding_Utility.cpp | 10 + SDK/src/NDK/Sdk.cpp | 19 + SDK/src/NDK/State.cpp | 6 + SDK/src/NDK/Systems/ListenerSystem.cpp | 26 +- SDK/src/NDK/Systems/ParticleSystem.cpp | 18 + SDK/src/NDK/Systems/PhysicsSystem.cpp | 40 +- SDK/src/NDK/Systems/RenderSystem.cpp | 44 ++ SDK/src/NDK/Systems/VelocitySystem.cpp | 19 + SDK/src/NDK/World.cpp | 95 +++- build/scripts/tools/unittests.lua | 13 +- tests/SDK/NDK/Application.cpp | 22 + tests/SDK/NDK/BaseSystem.cpp | 64 +++ tests/SDK/NDK/Component.cpp | 31 ++ tests/SDK/NDK/Entity.cpp | 101 ++++ tests/SDK/NDK/EntityList.cpp | 41 ++ tests/SDK/NDK/EntityOwner.cpp | 29 ++ tests/SDK/NDK/StateMachine.cpp | 48 ++ tests/SDK/NDK/System.cpp | 42 ++ tests/SDK/NDK/Systems/ListenerSystem.cpp | 43 ++ tests/SDK/NDK/Systems/PhysicsSystem.cpp | 34 ++ tests/SDK/NDK/Systems/RenderSystem.cpp | 44 ++ tests/SDK/NDK/Systems/VelocitySystem.cpp | 28 ++ tests/SDK/NDK/World.cpp | 103 ++++ 75 files changed, 3374 insertions(+), 112 deletions(-) create mode 100644 tests/SDK/NDK/Application.cpp create mode 100644 tests/SDK/NDK/BaseSystem.cpp create mode 100644 tests/SDK/NDK/Component.cpp create mode 100644 tests/SDK/NDK/Entity.cpp create mode 100644 tests/SDK/NDK/EntityList.cpp create mode 100644 tests/SDK/NDK/EntityOwner.cpp create mode 100644 tests/SDK/NDK/StateMachine.cpp create mode 100644 tests/SDK/NDK/System.cpp create mode 100644 tests/SDK/NDK/Systems/ListenerSystem.cpp create mode 100644 tests/SDK/NDK/Systems/PhysicsSystem.cpp create mode 100644 tests/SDK/NDK/Systems/RenderSystem.cpp create mode 100644 tests/SDK/NDK/Systems/VelocitySystem.cpp create mode 100644 tests/SDK/NDK/World.cpp diff --git a/SDK/include/NDK/Algorithm.inl b/SDK/include/NDK/Algorithm.inl index dd5f49cd4..fbdad365b 100644 --- a/SDK/include/NDK/Algorithm.inl +++ b/SDK/include/NDK/Algorithm.inl @@ -6,7 +6,15 @@ namespace Ndk { - ///TODO: constexpr avec le C++14 + /*! + * \ingroup NDK + * \brief Builds a component id based on a name + * \return Identifier for the component + * + * \param name Name to generate id from + */ + + ///TODO: constexpr with the C++14 template ComponentId BuildComponentId(const char (&name)[N]) { @@ -19,18 +27,38 @@ namespace Ndk return componentId; } + /*! + * \ingroup NDK + * \brief Gets the component id of a component + * \return Identifier for the component + */ + template ComponentIndex GetComponentIndex() { return ComponentType::componentIndex; } + /*! + * \ingroup NDK + * \brief Gets the system id of a system + * \return Identifier for the system + */ + template SystemIndex GetSystemIndex() { return SystemType::systemIndex; } + /*! + * \ingroup NDK + * \brief Initializes the a component + * \return Identifier for the component + * + * \param name Name to generate id from + */ + template ComponentIndex InitializeComponent(const char (&name)[N]) { @@ -38,6 +66,12 @@ namespace Ndk return ComponentType::componentIndex; } + /*! + * \ingroup NDK + * \brief Initializes the a system + * \return Identifier for the system + */ + template SystemIndex InitializeSystem() { @@ -45,12 +79,26 @@ namespace Ndk return SystemType::systemIndex; } + /*! + * \brief Checks whether the parameter is a component + * \return true If it is the case + * + * \param component Component to check + */ + template bool IsComponent(C& component) { return component.GetIndex() == GetComponentIndex(); } + /*! + * \brief Checks whether the parameter is a system + * \return true If it is the case + * + * \param system System to check + */ + template bool IsSystem(S& system) { diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 96e8768ce..0d21d1b94 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -8,6 +8,12 @@ namespace Ndk { + /*! + * \brief Constructs an Application object by default + * + * \remark Produces a NazaraAssert if there's more than one application instance currently running + */ + inline Application::Application() : #ifndef NDK_SERVER m_exitOnClosedWindows(true), @@ -24,6 +30,10 @@ namespace Ndk Sdk::Initialize(); } + /*! + * \brief Destructs the object + */ + inline Application::~Application() { m_worlds.clear(); @@ -31,13 +41,20 @@ namespace Ndk m_windows.clear(); #endif - // Libération du SDK + // Free of SDK Sdk::Uninitialize(); - // Libération automatique des modules + // Automatic free of modules s_application = nullptr; } + /*! + * \brief Adds a window to the application + * \return A reference to the newly created windows + * + * \param args Arguments used to create the window + */ + #ifndef NDK_SERVER template T& Application::AddWindow(Args&&... args) @@ -49,6 +66,13 @@ namespace Ndk } #endif + /*! + * \brief Adds a world to the application + * \return A reference to the newly created world + * + * \param args Arguments used to create the world + */ + template World& Application::AddWorld(Args&&... args) { @@ -56,11 +80,22 @@ namespace Ndk return m_worlds.back(); } + /*! + * \brief Gets the update time of the application + * \return Update rate + */ + inline float Application::GetUpdateTime() const { return m_updateTime; } + /*! + * \brief Makes the application exit when there's no more open window + * + * \param exitOnClosedWindows Should exit be called when no more window is open + */ + #ifndef NDK_SERVER inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows) { @@ -68,11 +103,20 @@ namespace Ndk } #endif + /*! + * \brief Quits the application + */ + inline void Application::Quit() { m_shouldQuit = true; } + /*! + * \brief Gets the singleton instance of the application + * \return Singleton application + */ + inline Application* Application::Instance() { return s_application; diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index f045ae2a6..0a48c394d 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -27,7 +27,7 @@ namespace Ndk BaseComponent(BaseComponent&&) = default; virtual ~BaseComponent(); - virtual BaseComponent* Clone() const = 0; + virtual std::unique_ptr Clone() const = 0; ComponentIndex GetIndex() const; diff --git a/SDK/include/NDK/BaseComponent.inl b/SDK/include/NDK/BaseComponent.inl index 341ddb651..0e8af931f 100644 --- a/SDK/include/NDK/BaseComponent.inl +++ b/SDK/include/NDK/BaseComponent.inl @@ -7,34 +7,60 @@ namespace Ndk { + /*! + * \brief Constructs a BaseComponent object with an index + * + * \param index Index of the component + */ + inline BaseComponent::BaseComponent(ComponentIndex index) : m_componentIndex(index), m_entity(nullptr) { } + /*! + * \brief Gets the index of the component + * \return Index of the component + */ + inline ComponentIndex BaseComponent::GetIndex() const { return m_componentIndex; } + /*! + * \brief Gets the maximal index of the components + * \return Index of the maximal component + */ + inline ComponentIndex BaseComponent::GetMaxComponentIndex() { return static_cast(s_entries.size()); } + /*! + * \brief Registers a component + * \return Index of the registered component + * + * \param id Index of the component + * \param factory Factory to create the component + * + * \remark Produces a NazaraAssert if the identifier is already in use + */ + inline ComponentIndex BaseComponent::RegisterComponent(ComponentId id, Factory factoryFunc) { - // Nous allons rajouter notre composant à la fin + // We add our component to the end ComponentIndex index = static_cast(s_entries.size()); s_entries.resize(index + 1); - // On récupère et on affecte + // We retrieve it and affect it ComponentEntry& entry = s_entries.back(); entry.factory = factoryFunc; entry.id = id; - // Une petite assertion pour s'assurer que l'identifiant n'est pas déjà utilisé + // We ensure that id is not already in use NazaraAssert(s_idToIndex.find(id) == s_idToIndex.end(), "This id is already in use"); s_idToIndex[id] = index; @@ -42,6 +68,10 @@ namespace Ndk return index; } + /*! + * \brief Sets the entity on which the component operates + */ + inline void BaseComponent::SetEntity(Entity* entity) { if (m_entity != entity) @@ -55,12 +85,21 @@ namespace Ndk } } + /*! + * \brief Initializes the BaseComponent + * \return true + */ + inline bool BaseComponent::Initialize() { - // Rien à faire + // Nothing to do return true; } + /*! + * \brief Uninitializes the BaseComponent + */ + inline void BaseComponent::Uninitialize() { s_entries.clear(); diff --git a/SDK/include/NDK/BaseSystem.hpp b/SDK/include/NDK/BaseSystem.hpp index 969f2b773..a4ff0bf41 100644 --- a/SDK/include/NDK/BaseSystem.hpp +++ b/SDK/include/NDK/BaseSystem.hpp @@ -29,7 +29,7 @@ namespace Ndk inline void Enable(bool enable = true); - virtual BaseSystem* Clone() const = 0; + virtual std::unique_ptr Clone() const = 0; bool Filters(const Entity* entity) const; diff --git a/SDK/include/NDK/BaseSystem.inl b/SDK/include/NDK/BaseSystem.inl index 490b32e76..1afc242c0 100644 --- a/SDK/include/NDK/BaseSystem.inl +++ b/SDK/include/NDK/BaseSystem.inl @@ -8,6 +8,12 @@ namespace Ndk { + /*! + * \brief Constructs a BaseSystem object with an index + * + * \param systemId Index of the system + */ + inline BaseSystem::BaseSystem(SystemIndex systemId) : m_updateEnabled(true), m_systemIndex(systemId) @@ -15,6 +21,12 @@ namespace Ndk SetUpdateRate(30); } + /*! + * \brief Constructs a BaseSystem object by copy semantic + * + * \param system System to copy + */ + inline BaseSystem::BaseSystem(const BaseSystem& system) : m_excludedComponents(system.m_excludedComponents), m_requiredComponents(system.m_requiredComponents), @@ -25,36 +37,74 @@ namespace Ndk { } + /*! + * \brief Enables the system + * + * \param enable Should the system be enabled + */ + inline void BaseSystem::Enable(bool enable) { m_updateEnabled = enable; } + /*! + * \brief Gets every entities that system handle + * \return A constant reference to the list of entities + */ + inline const std::vector& BaseSystem::GetEntities() const { return m_entities; } + /*! + * \brief Gets the index of the system + * \return Index of the system + */ + inline SystemIndex BaseSystem::GetIndex() const { return m_systemIndex; } + /*! + * \brief Gets the rate of update for the system + * \return Update rate + */ + inline float BaseSystem::GetUpdateRate() const { return (m_updateRate > 0.f) ? 1.f / m_updateRate : 0.f; } + /*! + * \brief Gets the world on which the system operate + * \return World in which the system is + */ + inline World& BaseSystem::GetWorld() const { return *m_world; } + /*! + * \brief Checks whether or not the system is enabled + * \return true If it is the case + */ + inline bool BaseSystem::IsEnabled() const { return m_updateEnabled; } + /*! + * \brief Checks whether or not the system has the entity + * \return true If it is the case + * + * \param entity Pointer to the entity + */ + inline bool BaseSystem::HasEntity(const Entity* entity) const { if (!entity) @@ -63,12 +113,24 @@ namespace Ndk return m_entityBits.UnboundedTest(entity->GetId()); } + /*! + * \brief Sets the rate of update for the system + * + * \param updatePerSecond Update rate, 0 means as much as possible + */ + inline void BaseSystem::SetUpdateRate(float updatePerSecond) { m_updateCounter = 0.f; m_updateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit } + /*! + * \brief Updates the system + * + * \param elapsedTime Delta time used for the update + */ + inline void BaseSystem::Update(float elapsedTime) { if (!IsEnabled()) @@ -88,6 +150,10 @@ namespace Ndk OnUpdate(elapsedTime); } + /*! + * \brief Excludes some component from the system + */ + template void BaseSystem::Excludes() { @@ -96,6 +162,10 @@ namespace Ndk ExcludesComponent(GetComponentIndex()); } + /*! + * \brief Excludes some components from the system + */ + template void BaseSystem::Excludes() { @@ -103,16 +173,31 @@ namespace Ndk Excludes(); } + /*! + * \brief Excludes some component from the system by index + * + * \param index Index of the component + */ + inline void BaseSystem::ExcludesComponent(ComponentIndex index) { m_excludedComponents.UnboundedSet(index); } + /*! + * \brief Gets the next index for the system + * \return Next unique index for the system + */ + inline SystemIndex BaseSystem::GetNextIndex() { return s_nextIndex++; } + /*! + * \brief Requires some component from the system + */ + template void BaseSystem::Requires() { @@ -121,6 +206,10 @@ namespace Ndk RequiresComponent(GetComponentIndex()); } + /*! + * \brief Requires some components from the system + */ + template void BaseSystem::Requires() { @@ -128,11 +217,21 @@ namespace Ndk Requires(); } + /*! + * \brief Requires some component for the system by index + * + * \param index Index of the component + */ + inline void BaseSystem::RequiresComponent(ComponentIndex index) { m_requiredComponents.UnboundedSet(index); } + /*! + * \brief Requires any component from the system + */ + template void BaseSystem::RequiresAny() { @@ -141,6 +240,10 @@ namespace Ndk RequiresAnyComponent(GetComponentIndex()); } + /*! + * \brief Requires any components from the system + */ + template void BaseSystem::RequiresAny() { @@ -148,11 +251,25 @@ namespace Ndk RequiresAny(); } + /*! + * \brief Requires any component for the system by index + * + * \param index Index of the component + */ + inline void BaseSystem::RequiresAnyComponent(ComponentIndex index) { m_requiredAnyComponents.UnboundedSet(index); } + /*! + * \brief Adds an entity to a system + * + * \param entity Pointer to the entity + * + * \remark Produces a NazaraAssert if entity is invalid + */ + inline void BaseSystem::AddEntity(Entity* entity) { NazaraAssert(entity, "Invalid entity"); @@ -165,6 +282,14 @@ namespace Ndk OnEntityAdded(entity); } + /*! + * \brief Removes an entity to a system + * + * \param entity Pointer to the entity + * + * \remark Produces a NazaraAssert if entity is invalid + */ + inline void BaseSystem::RemoveEntity(Entity* entity) { NazaraAssert(entity, "Invalid entity"); @@ -172,16 +297,25 @@ namespace Ndk auto it = std::find(m_entities.begin(), m_entities.end(), *entity); NazaraAssert(it != m_entities.end(), "Entity is not part of this system"); - // Pour éviter de déplacer beaucoup de handles, on swap le dernier avec celui à supprimer + // To avoid moving a lot of handles, we swap and pop std::swap(*it, m_entities.back()); - m_entities.pop_back(); // On le sort du vector + m_entities.pop_back(); // We get it out of the vector m_entityBits.Reset(entity->GetId()); entity->UnregisterSystem(m_systemIndex); - OnEntityRemoved(entity); // Et on appelle le callback + OnEntityRemoved(entity); // And we alert our callback } + /*! + * \brief Validates an entity to a system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + * + * \remark Produces a NazaraAssert if entity is invalid or if system does not hold this entity + */ + inline void BaseSystem::ValidateEntity(Entity* entity, bool justAdded) { NazaraAssert(entity, "Invalid entity"); @@ -190,11 +324,20 @@ namespace Ndk OnEntityValidation(entity, justAdded); } + /*! + * \brief Sets the world on which the system operates + */ + inline void BaseSystem::SetWorld(World* world) noexcept { m_world = world; } + /*! + * \brief Initializes the BaseSystem + * \return true + */ + inline bool BaseSystem::Initialize() { s_nextIndex = 0; @@ -202,6 +345,10 @@ namespace Ndk return true; } + /*! + * \brief Uninitializes the BaseSystem + */ + inline void BaseSystem::Uninitialize() { // Nothing to do diff --git a/SDK/include/NDK/Component.hpp b/SDK/include/NDK/Component.hpp index e3026dbad..b0f61fd92 100644 --- a/SDK/include/NDK/Component.hpp +++ b/SDK/include/NDK/Component.hpp @@ -18,7 +18,7 @@ namespace Ndk Component(); virtual ~Component(); - BaseComponent* Clone() const override; + std::unique_ptr Clone() const override; static ComponentIndex RegisterComponent(ComponentId id); diff --git a/SDK/include/NDK/Component.inl b/SDK/include/NDK/Component.inl index 833395957..6ca3f1944 100644 --- a/SDK/include/NDK/Component.inl +++ b/SDK/include/NDK/Component.inl @@ -7,6 +7,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Component + * \brief NDK class that represents a component for an entity which interacts with a system + * + * \remark This class is meant to be derived as CRTP: "Component" + */ + + /*! + * \brief Constructs a Component object by default + */ + template Component::Component() : BaseComponent(GetComponentIndex()) @@ -16,19 +28,30 @@ namespace Ndk template Component::~Component() = default; + /*! + * \brief Clones the component + * \return The clone newly created + * + * \remark The component to clone should be trivially copy constructible + */ + template - BaseComponent* Component::Clone() const + std::unique_ptr Component::Clone() const { ///FIXME: Pas encore supporté par GCC (4.9.2) //static_assert(std::is_trivially_copy_constructible::value, "ComponentType must be copy-constructible"); - return new ComponentType(static_cast(*this)); + return std::make_unique(static_cast(*this)); } + /*! + * \brief Registers the component by assigning it an index + */ + template ComponentIndex Component::RegisterComponent(ComponentId id) { - // On utilise les lambda pour créer une fonction factory + //We use the lambda to create a factory function auto factory = []() -> BaseComponent* { return nullptr; //< Temporary workaround to allow non-default-constructed components, will be updated for serialization @@ -38,11 +61,15 @@ namespace Ndk return BaseComponent::RegisterComponent(id, factory); } + /*! + * \brief Registers the component by assigning it an index based on the name + */ + template template ComponentIndex Component::RegisterComponent(const char (&name)[N]) { - // On récupère la chaîne de caractère sous la forme d'un nombre qui servira d'identifiant unique + // We convert the string to a number which will be used as unique identifier ComponentId id = BuildComponentId(name); return RegisterComponent(id); } diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index d91c357eb..d42d0e152 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -8,6 +8,10 @@ namespace Ndk { + /*! + * \brief Constructs an CameraComponent object by default + */ + inline CameraComponent::CameraComponent() : m_projectionType(Nz::ProjectionType_Perspective), m_targetRegion(0.f, 0.f, 1.f, 1.f), @@ -25,6 +29,12 @@ namespace Ndk { } + /*! + * \brief Constructs a CameraComponent object by copy semantic + * + * \param camera CameraComponent to copy + */ + inline CameraComponent::CameraComponent(const CameraComponent& camera) : Component(camera), AbstractViewer(camera), @@ -45,30 +55,51 @@ namespace Ndk SetTarget(camera.m_target); } + /*! + * \brief Ensures the frustum is up to date + */ + inline void CameraComponent::EnsureFrustumUpdate() const { if (!m_frustumUpdated) UpdateFrustum(); } + /*! + * \brief Ensures the projection matrix is up to date + */ + inline void CameraComponent::EnsureProjectionMatrixUpdate() const { if (!m_projectionMatrixUpdated) UpdateProjectionMatrix(); } + /*! + * \brief Ensures the view matrix is up to date + */ + inline void CameraComponent::EnsureViewMatrixUpdate() const { if (!m_viewMatrixUpdated) UpdateViewMatrix(); } + /*! + * \brief Ensures the view port is up to date + */ + inline void CameraComponent::EnsureViewportUpdate() const { if (!m_viewportUpdated) UpdateViewport(); } + /*! + * \brief Gets the aspect ratio of the camera + * \return Aspect ratio of the camera + */ + inline float CameraComponent::GetAspectRatio() const { EnsureViewportUpdate(); @@ -76,11 +107,21 @@ namespace Ndk return m_aspectRatio; } + /*! + * \brief Gets the field of view of the camera + * \return Field of view of the camera + */ + inline 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(); @@ -88,11 +129,21 @@ namespace Ndk return m_frustum; } + /*! + * \brief Gets the layer of the camera + * \return Layer of the camera + */ + inline unsigned int CameraComponent::GetLayer() const { 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(); @@ -100,26 +151,51 @@ namespace Ndk return m_projectionMatrix; } + /*! + * \brief Gets the projection type of the camera + * \return Projection type of the camera + */ + inline Nz::ProjectionType CameraComponent::GetProjectionType() const { return m_projectionType; } + /*! + * \brief Gets the size of the camera + * \return Size of the camera + */ + inline const Nz::Vector2f & CameraComponent::GetSize() const { 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 + */ + inline const Nz::Rectf& CameraComponent::GetTargetRegion() const { 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(); @@ -127,6 +203,11 @@ namespace Ndk 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(); @@ -134,16 +215,34 @@ namespace Ndk 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 + * + * \param fov Field of view of the camera + * + * \remark Produces a NazaraAssert if angle is zero + */ + inline void CameraComponent::SetFOV(float fov) { NazaraAssert(!Nz::NumberEquals(fov, 0.f), "FOV must be different from zero"); @@ -152,6 +251,12 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the projection type of the camera + * + * \param projectionType Projection type of the camera + */ + inline void CameraComponent::SetProjectionType(Nz::ProjectionType projectionType) { m_projectionType = projectionType; @@ -159,6 +264,12 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the size of the camera + * + * \param size Size of the camera + */ + inline void CameraComponent::SetSize(const Nz::Vector2f& size) { m_size = size; @@ -166,11 +277,24 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the size of the camera + * + * \param width Size in X of the camera + * \param height Size in Y of the camera + */ + inline void CameraComponent::SetSize(float width, float height) { SetSize({width, height}); } + /*! + * \brief Sets the target of the camera + * + * \param renderTarget A constant reference to the render target of the camera + */ + inline void CameraComponent::SetTarget(const Nz::RenderTarget* renderTarget) { m_target = renderTarget; @@ -186,6 +310,12 @@ namespace Ndk } } + /*! + * \brief Sets the target region of the camera + * + * \param region A constant reference to the target region of the camera + */ + inline void CameraComponent::SetTargetRegion(const Nz::Rectf& region) { m_targetRegion = region; @@ -193,17 +323,31 @@ namespace Ndk InvalidateViewport(); } + /*! + * \brief Sets the view port of the camera + * + * \param viewport A constant reference to the view port of the camera + * + * \remark Produces a NazaraAssert if the camera has no target + */ + inline void CameraComponent::SetViewport(const Nz::Recti& viewport) { NazaraAssert(m_target, "Component has no render target"); - // On calcule la région nécessaire pour produire ce viewport avec la taille actuelle de la cible - float invWidth = 1.f/m_target->GetWidth(); - float invHeight = 1.f/m_target->GetHeight(); + // We compute the region necessary to make this view port with the actual size of the target + float invWidth = 1.f / m_target->GetWidth(); + float invHeight = 1.f / m_target->GetHeight(); SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height)); } + /*! + * \brief Sets the Z far distance of the camera + * + * \param zFar Z far distance of the camera + */ + inline void CameraComponent::SetZFar(float zFar) { m_zFar = zFar; @@ -211,6 +355,14 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the Z near distance of the camera + * + * \param zNear Z near distance of the camera + * + * \remark Produces a NazaraAssert if zNear is zero + */ + inline void CameraComponent::SetZNear(float zNear) { NazaraAssert(!Nz::NumberEquals(zNear, 0.f), "zNear cannot be zero"); @@ -219,23 +371,39 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Invalidates the frustum + */ + inline void CameraComponent::InvalidateFrustum() const { m_frustumUpdated = false; } + /*! + * \brief Invalidates the projection matrix + */ + inline void CameraComponent::InvalidateProjectionMatrix() const { m_frustumUpdated = false; m_projectionMatrixUpdated = false; } + /*! + * \brief Invalidates the view matrix + */ + inline void CameraComponent::InvalidateViewMatrix() const { m_frustumUpdated = false; m_viewMatrixUpdated = false; } + /*! + * \brief Invalidates the view port + */ + inline void CameraComponent::InvalidateViewport() const { m_frustumUpdated = false; diff --git a/SDK/include/NDK/Components/CollisionComponent.inl b/SDK/include/NDK/Components/CollisionComponent.inl index 58356ac9e..b08e7054e 100644 --- a/SDK/include/NDK/Components/CollisionComponent.inl +++ b/SDK/include/NDK/Components/CollisionComponent.inl @@ -9,23 +9,47 @@ namespace Ndk { + /*! + * \brief Constructs a CollisionComponent object with a geometry + * + * \param geom Reference to a geometry symbolizing the entity + */ + inline CollisionComponent::CollisionComponent(Nz::PhysGeomRef geom) : m_geom(std::move(geom)), m_bodyUpdated(false) { } + /*! + * \brief Constructs a CollisionComponent object by copy semantic + * + * \param collision CollisionComponent to copy + */ + inline CollisionComponent::CollisionComponent(const CollisionComponent& 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::PhysGeomRef& CollisionComponent::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 CollisionComponent& CollisionComponent::operator=(Nz::PhysGeomRef geom) { SetGeom(geom); @@ -33,6 +57,11 @@ namespace Ndk return *this; } + /*! + * \brief Gets the static body used by the entity + * \return A pointer to the entity + */ + inline Nz::PhysObject* CollisionComponent::GetStaticBody() { return m_staticBody.get(); diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 0d9cb7af4..01cd7a2e3 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -7,6 +7,12 @@ namespace Ndk { + /*! + * \brief Constructs a GraphicsComponent object by copy semantic + * + * \param graphicsComponent GraphicsComponent to copy + */ + inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) : Component(graphicsComponent), HandledObject(graphicsComponent), @@ -20,6 +26,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 { EnsureTransformMatrixUpdate(); @@ -36,6 +48,13 @@ namespace Ndk } } + /*! + * \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) { m_renderables.emplace_back(m_transformMatrix); @@ -48,6 +67,10 @@ namespace Ndk InvalidateBoundingVolume(); } + /*! + * \brief Clears every renderable elements + */ + inline void GraphicsComponent::Clear() { m_renderables.clear(); @@ -55,6 +78,12 @@ namespace Ndk InvalidateBoundingVolume(); } + /*! + * \brief Detaches a renderable to the entity + * + * \param renderable Reference to a renderable element + */ + inline void GraphicsComponent::Detach(const Nz::InstancedRenderable* renderable) { for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) @@ -68,18 +97,34 @@ namespace Ndk } } + /*! + * \brief Ensures the bounding volume is up to date + */ + inline void GraphicsComponent::EnsureBoundingVolumeUpdate() const { if (!m_boundingVolumeUpdated) UpdateBoundingVolume(); } + /*! + * \brief Ensures the transformation matrix is up to date + */ + inline void GraphicsComponent::EnsureTransformMatrixUpdate() const { if (!m_transformMatrixUpdated) UpdateTransformMatrix(); } + /*! + * \brief Gets the set of renderable elements + * + * \param renderables Pointer to the list of renderables + * + * \remark Produces a NazaraAssert if renderables is invalid + */ + inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const { NazaraAssert(renderables, "Invalid renderable list"); @@ -89,11 +134,21 @@ namespace Ndk renderables->push_back(r.renderable); } + /*! + * \brief Gets the number of renderable elements attached to the entity + * \return Number of renderable elements + */ + inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const { return m_renderables.size(); } + /*! + * \brief Gets the bouding volume of the entity + * \return A constant reference to the bounding volume + */ + inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const { EnsureBoundingVolumeUpdate(); @@ -101,17 +156,29 @@ namespace Ndk return m_boundingVolume; } + /*! + * \brief Invalidates the bounding volume + */ + inline void GraphicsComponent::InvalidateBoundingVolume() { m_boundingVolumeUpdated = false; } + /*! + * \brief Invalidates every renderable elements + */ + inline void GraphicsComponent::InvalidateRenderables() { for (Renderable& r : m_renderables) r.dataUpdated = false; } + /*! + * \brief Invalidates the transformation matrix + */ + inline void GraphicsComponent::InvalidateTransformMatrix() { m_boundingVolumeUpdated = false; diff --git a/SDK/include/NDK/Components/LightComponent.inl b/SDK/include/NDK/Components/LightComponent.inl index f06fcb24c..ba11703c5 100644 --- a/SDK/include/NDK/Components/LightComponent.inl +++ b/SDK/include/NDK/Components/LightComponent.inl @@ -4,6 +4,10 @@ namespace Ndk { + /*! + * \brief Constructs an LightComponent object with a light type + */ + inline LightComponent::LightComponent(Nz::LightType lightType) : Nz::Light(lightType) { diff --git a/SDK/include/NDK/Components/ListenerComponent.inl b/SDK/include/NDK/Components/ListenerComponent.inl index 7dc7b0391..f2276e439 100644 --- a/SDK/include/NDK/Components/ListenerComponent.inl +++ b/SDK/include/NDK/Components/ListenerComponent.inl @@ -4,16 +4,31 @@ namespace Ndk { + /*! + * \brief Constructs an ListenerComponent object by default + */ + inline ListenerComponent::ListenerComponent() : m_isActive(true) { } + /*! + * \brief Checks whether the listener is activated + * \param true If it is the case + */ + inline bool ListenerComponent::IsActive() const { return m_isActive; } + /*! + * \brief Enables the listener + * + * \param active Should the listener be active + */ + inline void ListenerComponent::SetActive(bool active) { m_isActive = active; diff --git a/SDK/include/NDK/Components/NodeComponent.inl b/SDK/include/NDK/Components/NodeComponent.inl index e6d49c9a9..0150cbbfa 100644 --- a/SDK/include/NDK/Components/NodeComponent.inl +++ b/SDK/include/NDK/Components/NodeComponent.inl @@ -7,6 +7,15 @@ namespace Ndk { + /*! + * \brief Sets the parent node of the entity + * + * \param entity Pointer to the entity considered as parent + * \param keepDerived Should this component considered as a derived + * + * \remark Produces a NazaraAssert if entity has no component NodeComponent + */ + inline void NodeComponent::SetParent(Entity* entity, bool keepDerived) { if (entity) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NDK/Components/ParticleEmitterComponent.inl index 342b5e56f..7f8e62cd8 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.inl +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.inl @@ -6,21 +6,42 @@ namespace Ndk { + /*! + * \brief Constructs an ParticleEmitterComponent object by default + */ + inline ParticleEmitterComponent::ParticleEmitterComponent() : m_isActive(true) { } + /*! + * \brief Enables the emission of particles + * + * \param active Should the emitter be active + */ + inline void Ndk::ParticleEmitterComponent::Enable(bool active) { m_isActive = active; } + /*! + * \brief Checks whether the emission of particles is activated + * \param true If it is the case + */ + inline bool ParticleEmitterComponent::IsActive() const { return m_isActive; } + /*! + * \brief Sets the function use for setting up particles + * + * \param func Function to set up particles + */ + inline void Ndk::ParticleEmitterComponent::SetSetupFunc(SetupFunc func) { m_setupFunc = std::move(func); diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NDK/Components/ParticleGroupComponent.inl index c6e0cba7b..591e78605 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.inl +++ b/SDK/include/NDK/Components/ParticleGroupComponent.inl @@ -8,16 +8,45 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ParticleGroupComponent + * \brief NDK class that represents the component for a group of particles + */ + + /*! + * \brief Constructs a ParticleGroupComponent object with a maximal number of particles and a layout + * + * \param maxParticleCount Maximum number of particles to generate + * \param layout Enumeration for the layout of data information for the particles + */ + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) : ParticleGroup(maxParticleCount, layout) { } + /*! + * \brief Constructs a ParticleGroupComponent object with a maximal number of particles and a particle declaration + * + * \param maxParticleCount Maximum number of particles to generate + * \param declaration Data information for the particles + */ + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration) : ParticleGroup(maxParticleCount, std::move(declaration)) { } + /*! + * \brief Adds an emitter to the particles + * + * \param emitter Emitter for the particles + * + * \remark Produces a NazaraAssert if emitter is invalid + * \remark Produces a NazaraAssert if entity has no component of type ParticleEmitterComponent + */ + inline void ParticleGroupComponent::AddEmitter(Entity* emitter) { NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); @@ -27,6 +56,16 @@ namespace Ndk ParticleGroup::AddEmitter(&emitterComponent); } + + /*! + * \brief Removes an emitter to the particles + * + * \param emitter Emitter for the particles to remove + * + * \remark Produces a NazaraAssert if emitter is invalid + * \remark Produces a NazaraAssert if entity has no component of type ParticleEmitterComponent + */ + inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter) { NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); diff --git a/SDK/include/NDK/Components/PhysicsComponent.inl b/SDK/include/NDK/Components/PhysicsComponent.inl index f0847842d..5682603e0 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.inl +++ b/SDK/include/NDK/Components/PhysicsComponent.inl @@ -6,12 +6,27 @@ namespace Ndk { + /*! + * \brief Constructs a PhysicsComponent object by copy semantic + * + * \param physics PhysicsComponent to copy + */ + inline PhysicsComponent::PhysicsComponent(const PhysicsComponent& physics) { - // Pas de copie de l'objet physique (étant donné que nous n'allons le créer qu'une fois attaché à une entité) + // No copy of physical object (because we only create it when attached to an entity) NazaraUnused(physics); } + /*! + * \brief Applies a 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 PhysicsComponent::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); @@ -19,6 +34,16 @@ namespace Ndk m_object->AddForce(force, coordSys); } + /*! + * \brief Applies a 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 PhysicsComponent::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); @@ -26,13 +51,30 @@ namespace Ndk m_object->AddForce(force, point, coordSys); } + /*! + * \brief Applies a torque to the entity + * + * \param torque Torque to apply on the entity + * \param coordSys System coordinates to consider + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); - m_object->AddForce(torque, coordSys); + m_object->AddTorque(torque, coordSys); } + /*! + * \brief Enables auto sleep of physics object + * + * \param autoSleep Should the physics of the object be disabled when too far from others + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::EnableAutoSleep(bool autoSleep) { NazaraAssert(m_object, "Invalid physics object"); @@ -40,6 +82,13 @@ namespace Ndk m_object->EnableAutoSleep(autoSleep); } + /*! + * \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::Boxf PhysicsComponent::GetAABB() const { NazaraAssert(m_object, "Invalid physics object"); @@ -47,6 +96,13 @@ namespace Ndk 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 Nz::Vector3f PhysicsComponent::GetAngularVelocity() const { NazaraAssert(m_object, "Invalid physics object"); @@ -54,6 +110,13 @@ namespace Ndk return m_object->GetAngularVelocity(); } + /*! + * \brief Gets the gravity factor of the physics object + * \return Gravity factor of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline float PhysicsComponent::GetGravityFactor() const { NazaraAssert(m_object, "Invalid physics object"); @@ -61,6 +124,13 @@ namespace Ndk return m_object->GetGravityFactor(); } + /*! + * \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 PhysicsComponent::GetMass() const { NazaraAssert(m_object, "Invalid physics object"); @@ -68,6 +138,15 @@ namespace Ndk return m_object->GetMass(); } + /*! + * \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::Vector3f PhysicsComponent::GetMassCenter(Nz::CoordSys coordSys) const { NazaraAssert(m_object, "Invalid physics object"); @@ -75,6 +154,13 @@ namespace Ndk return m_object->GetMassCenter(coordSys); } + /*! + * \brief Gets the matrix of the physics object + * \return Matrix of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline const Nz::Matrix4f& PhysicsComponent::GetMatrix() const { NazaraAssert(m_object, "Invalid physics object"); @@ -82,6 +168,13 @@ namespace Ndk return m_object->GetMatrix(); } + /*! + * \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::Vector3f PhysicsComponent::GetPosition() const { NazaraAssert(m_object, "Invalid physics object"); @@ -89,6 +182,13 @@ namespace Ndk 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 Nz::Quaternionf PhysicsComponent::GetRotation() const { NazaraAssert(m_object, "Invalid physics object"); @@ -96,6 +196,13 @@ namespace Ndk 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::Vector3f PhysicsComponent::GetVelocity() const { NazaraAssert(m_object, "Invalid physics object"); @@ -103,6 +210,13 @@ namespace Ndk return m_object->GetVelocity(); } + /*! + * \brief Checks whether the auto sleep is enabled + * \return true If it is the case + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline bool PhysicsComponent::IsAutoSleepEnabled() const { NazaraAssert(m_object, "Invalid physics object"); @@ -110,6 +224,13 @@ namespace Ndk return m_object->IsAutoSleepEnabled(); } + /*! + * \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 PhysicsComponent::IsSleeping() const { NazaraAssert(m_object, "Invalid physics object"); @@ -117,6 +238,14 @@ namespace Ndk 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 PhysicsComponent::SetAngularVelocity(const Nz::Vector3f& angularVelocity) { NazaraAssert(m_object, "Invalid physics object"); @@ -124,6 +253,14 @@ namespace Ndk m_object->SetAngularVelocity(angularVelocity); } + /*! + * \brief Sets the gravity factor of the physics object + * + * \param gravityFactor Gravity factor of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::SetGravityFactor(float gravityFactor) { NazaraAssert(m_object, "Invalid physics object"); @@ -131,6 +268,15 @@ namespace Ndk m_object->SetGravityFactor(gravityFactor); } + /*! + * \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 PhysicsComponent::SetMass(float mass) { NazaraAssert(m_object, "Invalid physics object"); @@ -139,6 +285,14 @@ namespace Ndk 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 PhysicsComponent::SetMassCenter(const Nz::Vector3f& center) { NazaraAssert(m_object, "Invalid physics object"); @@ -146,6 +300,14 @@ namespace Ndk 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 PhysicsComponent::SetPosition(const Nz::Vector3f& position) { NazaraAssert(m_object, "Invalid physics object"); @@ -153,6 +315,14 @@ namespace Ndk 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 PhysicsComponent::SetRotation(const Nz::Quaternionf& rotation) { NazaraAssert(m_object, "Invalid physics object"); @@ -160,6 +330,14 @@ namespace Ndk 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 PhysicsComponent::SetVelocity(const Nz::Vector3f& velocity) { NazaraAssert(m_object, "Invalid physics object"); @@ -167,6 +345,11 @@ namespace Ndk m_object->SetVelocity(velocity); } + /*! + * \brief Gets the underlying physics object + * \return A reference to the physics object + */ + inline Nz::PhysObject& PhysicsComponent::GetPhysObject() { return *m_object.get(); diff --git a/SDK/include/NDK/Components/VelocityComponent.inl b/SDK/include/NDK/Components/VelocityComponent.inl index 1c2f0ed87..e72eca8b7 100644 --- a/SDK/include/NDK/Components/VelocityComponent.inl +++ b/SDK/include/NDK/Components/VelocityComponent.inl @@ -7,11 +7,30 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::VelocityComponent + * \brief NDK class that represents the component for velocity + */ + + /*! + * \brief Constructs a VelocityComponent object with a velocity + * + * \param velocity Linear velocity + */ + inline VelocityComponent::VelocityComponent(const Nz::Vector3f& velocity) : linearVelocity(velocity) { } + /*! + * \brief Assigns the velocity to this component + * \return A reference to this + * + * \param vel Linear velocity + */ + inline VelocityComponent& VelocityComponent::operator=(const Nz::Vector3f& vel) { linearVelocity = vel; diff --git a/SDK/include/NDK/Console.inl b/SDK/include/NDK/Console.inl index 5fb16bb1b..94a6daf91 100644 --- a/SDK/include/NDK/Console.inl +++ b/SDK/include/NDK/Console.inl @@ -7,41 +7,81 @@ namespace Ndk { + /*! + * \brief Gets the character size + * \return Height of the character + */ + inline unsigned int Console::GetCharacterSize() const { return m_characterSize; } + /*! + * \brief Gets the entity representing the history of the console + * \return History of the console + */ + inline const EntityHandle& Console::GetHistory() const { return m_history; } + /*! + * \brief Gets the entity representing the background of the console's history + * \return Background history of the console + */ + inline const EntityHandle& Console::GetHistoryBackground() const { return m_historyBackground; } + /*! + * \brief Gets the entity representing the input of the console + * \return Input of the console + */ + inline const EntityHandle& Console::GetInput() const { return m_input; } + /*! + * \brief Gets the entity representing the background of the console's input + * \return Background input of the console + */ + inline const EntityHandle& Console::GetInputBackground() const { return m_inputBackground; } + /*! + * \brief Gets the size of the console + * \return Size (Width, Height) of the console + */ + inline const Nz::Vector2f& Console::GetSize() const { return m_size; } + /*! + * \brief Gets the font used by the console + * \return A reference to the font currenty used + */ + inline const Nz::FontRef& Console::GetTextFont() const { return m_defaultFont; } + /*! + * \brief Checks whether the console is visible + * \return true If it is the case + */ + inline bool Console::IsVisible() const { return m_opened; diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index a03130b0d..535f2c1f4 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -11,16 +11,29 @@ namespace Ndk { + /*! + * \brief Adds a component to the entity + * \return A reference to the newly added component + * + * \param args Arguments to create in place the component to add to the entity + */ + template ComponentType& Entity::AddComponent(Args&&... args) { static_assert(std::is_base_of::value, "ComponentType is not a component"); - // Allocation et affectation du component + // Affectation and return of the component std::unique_ptr ptr(new ComponentType(std::forward(args)...)); return static_cast(AddComponent(std::move(ptr))); } + /*! + * \brief Enables the entity + * + * \param enable Should the entity be enabled + */ + inline void Entity::Enable(bool enable) { if (m_enabled != enable) @@ -30,9 +43,17 @@ namespace Ndk } } + /*! + * \brief Gets a component in the entity by index + * \return A reference to the component + * + * \param index Index of the component + * + * \remark Produces a NazaraAssert if component is not available in this entity or is invalid + */ + inline BaseComponent& Entity::GetComponent(ComponentIndex index) { - ///DOC: Le component doit être présent NazaraAssert(HasComponent(index), "This component is not part of the entity"); BaseComponent* component = m_components[index].get(); @@ -41,19 +62,33 @@ namespace Ndk return *component; } + /*! + * \brief Gets a component in the entity by type + * \return A reference to the component + * + * \remark Produces a NazaraAssert if component is not available in this entity + */ + template ComponentType& Entity::GetComponent() { - ///DOC: Le component doit être présent static_assert(std::is_base_of::value, "ComponentType is not a component"); ComponentIndex index = GetComponentIndex(); return static_cast(GetComponent(index)); } + /*! + * \brief Gets a component in the entity by index + * \return A constant reference to the component + * + * \param index Index of the component + * + * \remark Produces a NazaraAssert if component is not available in this entity or is invalid + */ + inline const BaseComponent& Entity::GetComponent(ComponentIndex index) const { - ///DOC: Le component doit être présent NazaraAssert(HasComponent(index), "This component is not part of the entity"); BaseComponent* component = m_components[index].get(); @@ -62,41 +97,79 @@ namespace Ndk return *component; } + /*! + * \brief Gets a component in the entity by type + * \return A constant reference to the component + * + * \remark Produces a NazaraAssert if component is not available in this entity + */ + template const ComponentType& Entity::GetComponent() const { - ///DOC: Le component doit être présent static_assert(std::is_base_of::value, "ComponentType is not a component"); ComponentIndex index = GetComponentIndex(); return static_cast(GetComponent(index)); } + /*! + * \brief Gets the bits representing the components in the entiy + * \return A constant reference to the set of component's bits + */ + inline const Nz::Bitset<>& Entity::GetComponentBits() const { return m_componentBits; } + /*! + * \brief Gets the identifier of the entity + * \return Identifier of the entity + */ + inline EntityId Entity::GetId() const { return m_id; } + /*! + * \brief Gets the bits representing the systems in the entiy + * \return A constant reference to the set of system's bits + */ + inline const Nz::Bitset<>& Entity::GetSystemBits() const { return m_systemBits; } + /*! + * \brief Gets the world in which the entity is + * \return Pointer to the world + */ + inline World* Entity::GetWorld() const { return m_world; } + /*! + * \brief Checks whether or not a component is present in the entity by index + * \return true If it is the case + * + * \param index Index of the component + */ + inline bool Entity::HasComponent(ComponentIndex index) const { return m_componentBits.UnboundedTest(index); } + /*! + * \brief Checks whether or not a component is present in the entity by type + * \return true If it is the case + */ + template bool Entity::HasComponent() const { @@ -106,16 +179,54 @@ namespace Ndk return HasComponent(index); } + /*! + * \brief Checks whether or not the entity is enabled + * \return true If it is the case + */ + inline bool Entity::IsEnabled() const { return m_enabled; } + /*! + * \brief Checks whether or not the entity is valid + * \return true If it is the case + */ + inline bool Entity::IsValid() const { return m_valid; } + /*! + * \brief Removes every components + */ + + inline void Entity::RemoveAllComponents() + { + m_removedComponentBits = m_componentBits; + + Invalidate(); + } + + /*! + * \brief Removes a component in the entity by index + * + * \param index Index of the component + */ + + inline void Entity::RemoveComponent(ComponentIndex index) + { + m_removedComponentBits.UnboundedSet(index); + + Invalidate(); + } + + /*! + * \brief Removes a component in the entity by type + */ + template void Entity::RemoveComponent() { @@ -125,19 +236,10 @@ namespace Ndk RemoveComponent(index); } - inline void Entity::RemoveAllComponents() - { - m_removedComponentBits = m_componentBits; - - Invalidate(); - } - - inline void Entity::RemoveComponent(ComponentIndex index) - { - m_removedComponentBits.UnboundedSet(index); - - Invalidate(); - } + /*! + * \brief Gives a string representation + * \return A string representation of the object: "Entity(GetId())" + */ inline Nz::String Entity::ToString() const { @@ -145,16 +247,35 @@ namespace Ndk return ss << "Entity(" << GetId() << ')'; } + /*! + * \brief Gets the bits representing the removed components in the entiy + * \return A constant reference to the set of remove component's bits + */ + inline Nz::Bitset<>& Entity::GetRemovedComponentBits() { return m_removedComponentBits; } + /*! + * \brief Registers a system for the entity + * + * \param index Index of the system + */ + inline void Entity::RegisterSystem(SystemIndex index) { m_systemBits.UnboundedSet(index); } + /*! + * \brief Sets the world of the entity + * + * \param world World in which the entity will be + * + * \remark Produces a NazaraAssert if world is invalid + */ + inline void Entity::SetWorld(World* world) noexcept { NazaraAssert(world, "An entity must be attached to a world at any time"); @@ -162,6 +283,12 @@ namespace Ndk m_world = world; } + /*! + * \brief Unregisters a system for the entity + * + * \param index Index of the system + */ + inline void Entity::UnregisterSystem(SystemIndex index) { m_systemBits.UnboundedReset(index); @@ -173,10 +300,16 @@ namespace std template<> struct hash { + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param handle Entity to hash + */ size_t operator()(const Ndk::EntityHandle& handle) const { - // Hasher le pointeur fonctionnerait jusqu'à ce que l'entité soit mise à jour et déplacée - // pour cette raison, nous devons hasher l'ID de l'entité (qui reste constante) + // Hash the pointer will work until the entity is updated and moved + // so, we have to hash the ID of the entity (which is constant) Ndk::EntityId id = (handle.IsValid()) ? handle->GetId() : std::numeric_limits::max(); return hash()(id); diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index 94fa3472f..224fdd1dc 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -7,22 +7,54 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::EntityList + * \brief NDK class that represents a set of entities to help performing batch operations + */ + + /*! + * \brief Clears the set from every entities + */ + inline void EntityList::Clear() { m_entities.clear(); m_entityBits.Clear(); } + /*! + * \brief Checks whether or not the set contains the entity + * \return true If it is the case + * + * \param entity Pointer to the entity + */ + inline bool EntityList::Has(const Entity* entity) { return entity && entity->IsValid() && Has(entity->GetId()); } + /*! + * \brief Checks whether or not the set contains the entity by id + * \return true If it is the case + * + * \param id Identifier of the entity + */ + inline bool EntityList::Has(EntityId entity) { return m_entityBits.UnboundedTest(entity); } + /*! + * \brief Inserts the entity into the set + * + * \param entity Pointer to the entity + * + * \remark If entity is already contained, no action is performed + */ + inline void EntityList::Insert(Entity* entity) { if (!Has(entity)) @@ -32,6 +64,14 @@ namespace Ndk } } + /*! + * \brief Removes the entity from the set + * + * \param entity Pointer to the entity + * + * \remark If entity is not contained, no action is performed + */ + inline void EntityList::Remove(Entity* entity) { if (Has(entity)) @@ -40,7 +80,7 @@ namespace Ndk NazaraAssert(it != m_entities.end(), "Entity should be part of the vector"); std::swap(*it, m_entities.back()); - m_entities.pop_back(); // On le sort du vector + m_entities.pop_back(); // We get it out of the vector m_entityBits.UnboundedSet(entity->GetId(), false); } } diff --git a/SDK/include/NDK/EntityOwner.inl b/SDK/include/NDK/EntityOwner.inl index 6efc2b30e..2cb64f1e8 100644 --- a/SDK/include/NDK/EntityOwner.inl +++ b/SDK/include/NDK/EntityOwner.inl @@ -8,17 +8,41 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::EntityOwner + * \brief NDK class that represents the owner of the entity and so its lifetime + */ + + /*! + * \brief Constructs a EntityOwner object + * + * \param entity Entity to own + */ + inline EntityOwner::EntityOwner(Entity* entity) : EntityOwner() { Reset(entity); } + /*! + * \brief Destructs the object and calls Reset + * + * \see Reset + */ + inline EntityOwner::~EntityOwner() { Reset(nullptr); } + /*! + * \brief Resets the ownership of the entity, previous is killed + * + * \param entity Entity to own + */ + inline void EntityOwner::Reset(Entity* entity) { if (m_object) @@ -27,12 +51,24 @@ namespace Ndk EntityHandle::Reset(entity); } + /*! + * \brief Resets the ownership of the entity by move semantic + * + * \param handle EntityOwner to move into this + */ + inline void EntityOwner::Reset(EntityOwner&& handle) { Reset(handle.GetObject()); handle.m_object = nullptr; } + /*! + * \brief Resets the ownership of the entity to the affected one + * + * \param entity Entity to own + */ + inline EntityOwner& EntityOwner::operator=(Entity* entity) { Reset(entity); diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index a09d6c459..6f1b73234 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -26,6 +26,11 @@ namespace Ndk { + /*! + * \brief Gets the internal binding for Lua + * \return A pointer to the binding + */ + inline LuaBinding* LuaAPI::GetBinding() { return s_binding; @@ -34,6 +39,15 @@ namespace Ndk 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) { instance.CheckType(index, Nz::LuaType_Table); @@ -46,6 +60,15 @@ 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) { switch (instance.GetType(index)) @@ -66,6 +89,15 @@ 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) { EulerAnglesd anglesDouble; @@ -75,6 +107,15 @@ 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 = *static_cast(instance.CheckUserdata(index, "Font")); @@ -82,6 +123,15 @@ 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) { NazaraUnused(params); @@ -93,6 +143,15 @@ 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 mesh + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MeshParams* params, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); @@ -106,6 +165,15 @@ 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, Rectd* rect, TypeTag) { instance.CheckType(index, LuaType_Table); @@ -118,6 +186,15 @@ 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) { Rectd rectDouble; @@ -127,6 +204,15 @@ 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, Rectui* rect, TypeTag) { Rectd rectDouble; @@ -136,6 +222,15 @@ 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 quat Resulting quaternion + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag) { switch (instance.GetType(index)) @@ -156,6 +251,15 @@ 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) { Quaterniond quatDouble; @@ -165,6 +269,15 @@ 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 address Resulting IP address + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, IpAddress* address, TypeTag) { switch (instance.GetType(index)) @@ -179,6 +292,15 @@ 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, Vector2d* vec, TypeTag) { switch (instance.GetType(index)) @@ -200,6 +322,15 @@ 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) { Vector2d vecDouble; @@ -209,6 +340,15 @@ 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) { Vector2d vecDouble; @@ -218,6 +358,15 @@ 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) { switch (instance.GetType(index)) @@ -239,6 +388,15 @@ 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) { Vector3d vecDouble; @@ -248,6 +406,15 @@ 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) { Vector3d vecDouble; @@ -257,6 +424,15 @@ 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) { *handle = *static_cast(instance.CheckUserdata(index, "Entity")); @@ -264,6 +440,15 @@ 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) { *handle = *static_cast(instance.CheckUserdata(index, "World")); @@ -272,6 +457,16 @@ 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) { if (instance.IsOfType(index, "InstancedRenderable")) @@ -281,6 +476,15 @@ 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) { instance.CheckType(index, Nz::LuaType_Table); @@ -295,6 +499,15 @@ 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) { instance.CheckType(index, Nz::LuaType_Table); @@ -307,6 +520,15 @@ 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) { instance.CheckType(index, Nz::LuaType_Table); @@ -316,6 +538,15 @@ 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) { instance.CheckType(index, Nz::LuaType_Table); @@ -324,9 +555,16 @@ namespace Nz 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 euler angles + */ inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesd&& val, TypeTag) { @@ -334,18 +572,42 @@ 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, EulerAnglesf&& val, TypeTag) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushTable(); @@ -357,114 +619,266 @@ 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 quaternion + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond&& val, TypeTag) { instance.PushInstance("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) { instance.PushInstance("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 IP address + */ + inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress&& val, TypeTag) { instance.PushInstance("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, Rectd&& val, TypeTag) { instance.PushInstance("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) { instance.PushInstance("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, Rectui&& val, TypeTag) { instance.PushInstance("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 vector2D + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d&& val, TypeTag) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("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) { instance.PushInstance("World", handle); @@ -472,22 +886,49 @@ 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 console + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::ConsoleHandle&& handle, TypeTag) { instance.PushInstance("Console", 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 graphics component + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle&& handle, TypeTag) { instance.PushInstance("GraphicsComponent", 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) { instance.PushInstance("SoundBuffer", val); return 1; } + #endif + } diff --git a/SDK/include/NDK/LuaBinding.inl b/SDK/include/NDK/LuaBinding.inl index 64e3eb453..e4ae72254 100644 --- a/SDK/include/NDK/LuaBinding.inl +++ b/SDK/include/NDK/LuaBinding.inl @@ -6,6 +6,14 @@ namespace Ndk { + /*! + * \brief Binds a component to a name + * + * \param name Name used to retrieve the component + * + * \remark Produces a NazaraAssert if name is empty + */ + template void LuaBinding::BindComponent(const Nz::String& name) { @@ -24,6 +32,16 @@ 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 int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle) { @@ -34,6 +52,16 @@ 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 int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component) { diff --git a/SDK/include/NDK/Prerequesites.hpp b/SDK/include/NDK/Prerequesites.hpp index d75ed0eb0..f3532c70d 100644 --- a/SDK/include/NDK/Prerequesites.hpp +++ b/SDK/include/NDK/Prerequesites.hpp @@ -27,11 +27,11 @@ #include -// Version du SDK +// Version of SDK #define NDK_VERSION_MAJOR 0 #define NDK_VERSION_MINOR 1 -// Importation/Exportation de l'API +// Importation/Exportation of the API #if defined(NAZARA_PLATFORM_WINDOWS) #if !defined(NDK_STATIC) #ifdef NDK_BUILD @@ -49,7 +49,7 @@ #define NDK_API #endif #else - // À commenter pour tenter quand même une compilation + // To comment to force a compilation #error This operating system is not fully supported by the Nazara Development Kit #define NDK_API diff --git a/SDK/include/NDK/Sdk.inl b/SDK/include/NDK/Sdk.inl index 0bdc1e2cd..3cbafab66 100644 --- a/SDK/include/NDK/Sdk.inl +++ b/SDK/include/NDK/Sdk.inl @@ -4,6 +4,11 @@ namespace Ndk { + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + inline bool Sdk::IsInitialized() { return s_referenceCounter != 0; diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NDK/StateMachine.inl index 7b5109ab5..c522f5431 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NDK/StateMachine.inl @@ -8,6 +8,21 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::StateMachine + * \brief NDK class that represents a state machine, to represent the multiple states of your program + */ + + /*! + * \brief Constructs a StateMachine object with an original state + * + * \param originalState State which is the entry point of the application + * + * \remark Calls "Enter" on the state + * \remark Produces a NazaraAssert if nullptr is given + */ + inline StateMachine::StateMachine(std::shared_ptr originalState) : m_currentState(std::move(originalState)) { @@ -15,22 +30,45 @@ namespace Ndk m_currentState->Enter(*this); } + /*! + * \brief Destructs the object + * + * \remark Calls "Leave" on the state + */ + inline StateMachine::~StateMachine() { m_currentState->Leave(*this); } + /*! + * \brief Changes the current state of the machine + * + * \param state Next state to represent + */ inline void StateMachine::ChangeState(std::shared_ptr state) { m_nextState = std::move(state); } + /*! + * \brief Gets the current state of the machine + * \return A constant reference to the state + */ + inline const std::shared_ptr& StateMachine::GetCurrentState() const { return m_currentState; } + /*! + * \brief Updates the state + * \return True if update is successful + * + * \param elapsedTime Delta time used for the update + */ + inline bool StateMachine::Update(float elapsedTime) { if (m_nextState) diff --git a/SDK/include/NDK/System.hpp b/SDK/include/NDK/System.hpp index 6d1d423dc..b5a50f76f 100644 --- a/SDK/include/NDK/System.hpp +++ b/SDK/include/NDK/System.hpp @@ -11,7 +11,7 @@ namespace Ndk { - template + template class System : public BaseSystem { public: @@ -20,7 +20,7 @@ namespace Ndk System(System&&) = default; virtual ~System(); - BaseSystem* Clone() const override; + std::unique_ptr Clone() const override; System& operator=(const System&) = delete; System& operator=(System&&) = default; diff --git a/SDK/include/NDK/System.inl b/SDK/include/NDK/System.inl index 9b382d924..d0359cc63 100644 --- a/SDK/include/NDK/System.inl +++ b/SDK/include/NDK/System.inl @@ -7,6 +7,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::System + * \brief NDK class that represents a system which interacts on a world + * + * \remark This class is meant to be derived as CRTP: "System" + */ + + /*! + * \brief Constructs a System object by default + */ + template System::System() : BaseSystem(GetSystemIndex()) @@ -16,15 +28,26 @@ namespace Ndk template System::~System() = default; + /*! + * \brief Clones the system + * \return The clone newly created + * + * \remark The system to clone should be trivially copy constructible + */ + template - BaseSystem* System::Clone() const + std::unique_ptr System::Clone() const { - ///FIXME: Pas encore supporté par GCC (4.9.2) + ///FIXME: Not fully supported in GCC (4.9.2) //static_assert(std::is_trivially_copy_constructible::value, "SystemType should be copy-constructible"); - return new SystemType(static_cast(*this)); + return std::make_unique(static_cast(*this)); } + /*! + * \brief Registers the system by assigning it an index + */ + template SystemIndex System::RegisterSystem() { diff --git a/SDK/include/NDK/Systems/PhysicsSystem.inl b/SDK/include/NDK/Systems/PhysicsSystem.inl index e9fb52c49..bfe886cb1 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem.inl +++ b/SDK/include/NDK/Systems/PhysicsSystem.inl @@ -4,11 +4,21 @@ namespace Ndk { + /*! + * \brief Gets the physical world + * \return A reference to the physical world + */ + inline Nz::PhysWorld& PhysicsSystem::GetWorld() { return m_world; } + /*! + * \brief Gets the physical world + * \return A constant reference to the physical world + */ + inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const { return m_world; diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NDK/Systems/RenderSystem.inl index 4f7afe63d..4b758aa92 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NDK/Systems/RenderSystem.inl @@ -4,58 +4,119 @@ namespace Ndk { + /*! + * \brief Constructs a RenderSystem object by copy semantic + * + * \param renderSystem RenderSystem to copy + */ + inline RenderSystem::RenderSystem(const RenderSystem& renderSystem) : System(renderSystem) { } + /*! + * \brief Changes the render technique used for the system + * \return A reference to the render technique type + */ + template inline T& RenderSystem::ChangeRenderTechnique() { + static_assert(std::is_base_of::value, "RenderTechnique is not a subtype of AbstractRenderTechnique"); return static_cast(ChangeRenderTechnique(std::make_unique())); } + /*! + * \brief Changes the render technique used for the system + * \return A reference to the abstract render technique + * + * \param renderTechnique Render technique to use + */ + inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) { m_renderTechnique = std::move(renderTechnique); return *m_renderTechnique.get(); } + /*! + * \brief Gets the background used for rendering + * \return A reference to the background + */ + inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const { return m_background; } + /*! + * \brief Gets the coordinates matrix used for rendering + * \return A constant reference to the matrix of coordinates + */ + inline const Nz::Matrix4f& RenderSystem::GetCoordinateSystemMatrix() const { return m_coordinateSystemMatrix; } + /*! + * \brief Gets the "forward" global direction + * \return The forward direction, by default, it's -UnitZ() (Right hand coordinates) + */ + inline Nz::Vector3f RenderSystem::GetGlobalForward() const { return Nz::Vector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33); } + /*! + * \brief Gets the "right" global direction + * \return The right direction, by default, it's UnitX() (Right hand coordinates) + */ + inline Nz::Vector3f RenderSystem::GetGlobalRight() const { return Nz::Vector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31); } + /*! + * \brief Gets the "up" global direction + * \return The up direction, by default, it's UnitY() (Right hand coordinates) + */ + inline Nz::Vector3f RenderSystem::GetGlobalUp() const { return Nz::Vector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32); } + /*! + * \brief Gets the render technique used for rendering + * \return A reference to the abstract render technique being used + */ + inline Nz::AbstractRenderTechnique& RenderSystem::GetRenderTechnique() const { return *m_renderTechnique.get(); } + /*! + * \brief Sets the background used for rendering + * + * \param background A reference to the background + */ + inline void RenderSystem::SetDefaultBackground(Nz::BackgroundRef background) { m_background = std::move(background); } + /*! + * \brief Sets the "forward" global direction + * + * \param direction The new forward direction + */ + inline void RenderSystem::SetGlobalForward(const Nz::Vector3f& direction) { m_coordinateSystemMatrix.m13 = -direction.x; @@ -65,6 +126,12 @@ namespace Ndk InvalidateCoordinateSystem(); } + /*! + * \brief Sets the "right" global direction + * + * \param direction The new right direction + */ + inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction) { m_coordinateSystemMatrix.m11 = direction.x; @@ -74,6 +141,12 @@ namespace Ndk InvalidateCoordinateSystem(); } + /*! + * \brief Sets the "up" global direction + * + * \param direction The new up direction + */ + inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction) { m_coordinateSystemMatrix.m12 = direction.x; @@ -83,6 +156,10 @@ namespace Ndk InvalidateCoordinateSystem(); } + /*! + * \brief Invalidates the matrix of coordinates for the system + */ + inline void RenderSystem::InvalidateCoordinateSystem() { m_coordinateSystemInvalidated = true; diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index 2e20d03a9..5d1dabb77 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -43,7 +43,6 @@ namespace Ndk inline EntityList CreateEntities(unsigned int count); void Clear() noexcept; - const EntityHandle& CloneEntity(EntityId id); const EntityHandle& GetEntity(EntityId id); diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index ba2b33bd4..9960aef05 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -7,47 +7,80 @@ namespace Ndk { + /*! + * \brief Constructs a World object + * + * \param addDefaultSystems Should default provided systems be used + */ + inline World::World(bool addDefaultSystems) { if (addDefaultSystems) AddDefaultSystems(); } + /*! + * \brief Constructs a World object by move semantic + * + * \param world World to move into this + */ + inline World::World(World&& world) noexcept : HandledObject(std::move(world)) { operator=(std::move(world)); } + /*! + * \brief Adds a system to the world + * \return A reference to the newly created system + * + * \param system System to add to the world + */ + inline BaseSystem& World::AddSystem(std::unique_ptr&& system) { NazaraAssert(system, "System must be valid"); SystemIndex index = system->GetIndex(); - // Nous nous assurons que le vecteur de component est suffisamment grand pour contenir le nouveau component + // We must ensure that the vector is big enough to hold the new system if (index >= m_systems.size()) m_systems.resize(index + 1); - // Affectation et retour du système + // Affectation and return of system m_systems[index] = std::move(system); m_systems[index]->SetWorld(this); - Invalidate(); // On force une mise à jour de toutes les entités + Invalidate(); // We force an update for every entities return *m_systems[index].get(); } + /*! + * \brief Adds a system to the world + * \return A reference to the newly created system + * + * \param args Arguments used to create the system + */ + template SystemType& World::AddSystem(Args&&... args) { static_assert(std::is_base_of::value, "SystemType is not a component"); - // Allocation et affectation du component + // Allocation and affectation of the system std::unique_ptr ptr(new SystemType(std::forward(args)...)); return static_cast(AddSystem(std::move(ptr))); } + /*! + * \brief Creates multiple entities in the world + * \return The set of entities created + * + * \param count Number of entities to create + */ + inline World::EntityList World::CreateEntities(unsigned int count) { EntityList list; @@ -59,14 +92,27 @@ namespace Ndk return list; } + /*! + * \brief Gets every entities in the world + * \return A constant reference to the entities + */ + inline const World::EntityList& World::GetEntities() { return m_aliveEntities; } + /*! + * \brief Gets a system in the world by index + * \return A reference to the system + * + * \param index Index of the system + * + * \remark Produces a NazaraAssert if system is not available in this world + */ + inline BaseSystem& World::GetSystem(SystemIndex index) { - ///DOC: Le système doit être présent NazaraAssert(HasSystem(index), "This system is not part of the world"); BaseSystem* system = m_systems[index].get(); @@ -75,21 +121,39 @@ namespace Ndk return *system; } + /*! + * \brief Gets a system in the world by type + * \return A reference to the system + * + * \remark Produces a NazaraAssert if system is not available in this world + */ + template SystemType& World::GetSystem() { - ///DOC: Le système doit être présent static_assert(std::is_base_of::value, "SystemType is not a system"); SystemIndex index = GetSystemIndex(); return static_cast(GetSystem(index)); } + /*! + * \brief Checks whether or not a system is present in the world by index + * \return true If it is the case + * + * \param index Index of the system + */ + inline bool World::HasSystem(SystemIndex index) const { return index < m_systems.size() && m_systems[index]; } + /*! + * \brief Checks whether or not a system is present in the world by type + * \return true If it is the case + */ + template bool World::HasSystem() const { @@ -99,34 +163,69 @@ namespace Ndk return HasSystem(index); } + /*! + * \brief Kills a set of entities + * + * \param list Set of entities to kill + */ + inline void World::KillEntities(const EntityList& list) { for (const EntityHandle& entity : list) KillEntity(entity); } + /*! + * \brief Checks whether or not an entity is valid + * \return true If it is the case + * + * \param entity Pointer to the entity + */ + inline bool World::IsEntityValid(const Entity* entity) const { return entity && entity->GetWorld() == this && IsEntityIdValid(entity->GetId()); } + /*! + * \brief Checks whether or not an entity is valid + * \return true If it is the case + * + * \param id Identifier of the entity + */ + inline bool World::IsEntityIdValid(EntityId id) const { return id < m_entities.size() && m_entities[id].entity.IsValid(); } + /*! + * \brief Removes each system from the world + */ + inline void World::RemoveAllSystems() { m_systems.clear(); } + /*! + * \brief Removes a system from the world by index + * + * \param index Index of the system + * + * \remark No change is done if system is not present + */ + inline void World::RemoveSystem(SystemIndex index) { - ///DOC: N'a aucun effet si le système n'est pas présent if (HasSystem(index)) m_systems[index].reset(); } + /*! + * \brief Removes a system from the world by type + */ + template void World::RemoveSystem() { @@ -136,6 +235,12 @@ namespace Ndk RemoveSystem(index); } + /*! + * \brief Updates the world + * + * \param elapsedTime Delta time used for the update + */ + inline void World::Update(float elapsedTime) { Update(); //< Update entities @@ -148,17 +253,32 @@ namespace Ndk } } + /*! + * \brief Invalidates each entity in the world + */ + inline void World::Invalidate() { m_dirtyEntities.Resize(m_entities.size(), false); - m_dirtyEntities.Set(true); // Activation de tous les bits + 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); } + /*! + * \brief Moves a world into another world object + * \return A reference to the object + */ + inline World& World::operator=(World&& world) noexcept { m_aliveEntities = std::move(world.m_aliveEntities); diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index df2dfa12c..5e3331d73 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -6,6 +6,16 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Application + * \brief NDK class that represents the application, it offers a set of tools to ease the development + */ + + /*! + * \brief Runs the application by updating worlds, taking care about windows, ... + */ + bool Application::Run() { #ifndef NDK_SERVER diff --git a/SDK/src/NDK/BaseComponent.cpp b/SDK/src/NDK/BaseComponent.cpp index 1a0b85168..39d67d211 100644 --- a/SDK/src/NDK/BaseComponent.cpp +++ b/SDK/src/NDK/BaseComponent.cpp @@ -6,22 +6,50 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::BaseComponent + * \brief NDK class that represents the common base of all components + * + * \remark This class is meant to be purely abstract, for type erasure + */ + BaseComponent::~BaseComponent() = default; + /*! + * \brief Operation to perform when component is attached to an entity + */ + void BaseComponent::OnAttached() { } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void BaseComponent::OnComponentAttached(BaseComponent& component) { NazaraUnused(component); } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void BaseComponent::OnComponentDetached(BaseComponent& component) { NazaraUnused(component); } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void BaseComponent::OnDetached() { } diff --git a/SDK/src/NDK/BaseSystem.cpp b/SDK/src/NDK/BaseSystem.cpp index a69f13550..8a2a9dce5 100644 --- a/SDK/src/NDK/BaseSystem.cpp +++ b/SDK/src/NDK/BaseSystem.cpp @@ -6,12 +6,31 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::BaseSystem + * \brief NDK class that represents the common base of all systems + * + * \remark This class is meant to be purely abstract, for type erasure + */ + + /*! + * \brief Destructs the object and unregisters it-self on every entities + */ + BaseSystem::~BaseSystem() { for (const EntityHandle& entity : m_entities) entity->UnregisterSystem(m_systemIndex); } + /*! + * \brief Checks whether the key of the entity matches the lock of the system + * \return true If it is the case + * + * \param Pointer to the entity + */ + bool BaseSystem::Filters(const Entity* entity) const { if (!entity) @@ -21,13 +40,13 @@ namespace Ndk m_filterResult.PerformsAND(m_requiredComponents, components); if (m_filterResult != m_requiredComponents) - return false; // Au moins un component requis n'est pas présent + return false; // At least one required component is not available m_filterResult.PerformsAND(m_excludedComponents, components); if (m_filterResult.TestAny()) - return false; // Au moins un component exclu est présent + return false; // At least one excluded component is available - // Si nous avons une liste de composants nécessaires + // If we have a list of needed components if (m_requiredAnyComponents.TestAny()) { if (!m_requiredAnyComponents.Intersects(components)) @@ -37,16 +56,35 @@ namespace Ndk return true; } + /*! + * \brief Operation to perform when entity is added to the system + * + * \param Pointer to the entity + */ + void BaseSystem::OnEntityAdded(Entity* entity) { NazaraUnused(entity); } + /*! + * \brief Operation to perform when entity is removed to the system + * + * \param Pointer to the entity + */ + void BaseSystem::OnEntityRemoved(Entity* entity) { NazaraUnused(entity); } + /*! + * \brief Operation to perform when entity is validated for the system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + */ + void BaseSystem::OnEntityValidation(Entity* entity, bool justAdded) { NazaraUnused(entity); diff --git a/SDK/src/NDK/Components/CameraComponent.cpp b/SDK/src/NDK/Components/CameraComponent.cpp index 1b7a3e06d..71c653823 100644 --- a/SDK/src/NDK/Components/CameraComponent.cpp +++ b/SDK/src/NDK/Components/CameraComponent.cpp @@ -9,6 +9,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::CameraComponent + * \brief NDK class that represents the component for camera + */ + + /*! + * \brief Applys the view of the camera + * + * \remark Produces a NazaraAssert if the camera has no target + */ + void CameraComponent::ApplyView() const { NazaraAssert(m_target, "CameraComponent has no target"); @@ -23,6 +35,12 @@ namespace Ndk Nz::Renderer::SetViewport(m_viewport); } + /*! + * \brief Gets the eye position of the camera + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + Nz::Vector3f CameraComponent::GetEyePosition() const { NazaraAssert(m_entity && m_entity->HasComponent(), "CameraComponent requires NodeComponent"); @@ -30,6 +48,12 @@ namespace Ndk return m_entity->GetComponent().GetPosition(); } + /*! + * \brief Gets the forward direction of the camera + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + Nz::Vector3f CameraComponent::GetForward() const { NazaraAssert(m_entity && m_entity->HasComponent(), "CameraComponent requires NodeComponent"); @@ -37,6 +61,12 @@ namespace Ndk return m_entity->GetComponent().GetForward(); } + /*! + * \brief Sets the layer of the camera in case of multiples fields + * + * \param layer Layer of the camera + */ + void CameraComponent::SetLayer(unsigned int layer) { m_layer = layer; @@ -44,6 +74,10 @@ namespace Ndk m_entity->Invalidate(); // Invalidate the entity to make it passes through RenderSystem validation } + /*! + * \brief Operation to perform when component is attached to an entity + */ + void CameraComponent::OnAttached() { if (m_entity->HasComponent()) @@ -52,6 +86,12 @@ namespace Ndk InvalidateViewMatrix(); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void CameraComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) @@ -63,6 +103,12 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void CameraComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) @@ -73,6 +119,10 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void CameraComponent::OnDetached() { m_nodeInvalidationSlot.Disconnect(); @@ -80,6 +130,12 @@ namespace Ndk InvalidateViewMatrix(); } + /*! + * \brief Operation to perform when the node is invalidated + * + * \param node Pointer to the node + */ + void CameraComponent::OnNodeInvalidated(const Nz::Node* node) { NazaraUnused(node); @@ -88,6 +144,12 @@ namespace Ndk InvalidateViewMatrix(); } + /*! + * \brief Operation to perform when the render target is released + * + * \param renderTarget Pointer to the RenderTarget + */ + void CameraComponent::OnRenderTargetRelease(const Nz::RenderTarget* renderTarget) { if (renderTarget == m_target) @@ -96,6 +158,12 @@ namespace Ndk NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget)); } + /*! + * \brief Operation to perform when the render target has its size changed + * + * \param renderTarget Pointer to the RenderTarget + */ + void CameraComponent::OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget) { if (renderTarget == m_target) @@ -104,6 +172,10 @@ namespace Ndk NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget)); } + /*! + * \brief Updates the frustum of the camera + */ + void CameraComponent::UpdateFrustum() const { EnsureProjectionMatrixUpdate(); @@ -114,6 +186,10 @@ namespace Ndk m_frustumUpdated = true; } + /*! + * \brief Updates the project matrix of the camera + */ + void CameraComponent::UpdateProjectionMatrix() const { switch (m_projectionType) @@ -139,6 +215,12 @@ namespace Ndk m_projectionMatrixUpdated = true; } + /*! + * \brief Updates the view matrix of the camera + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + void CameraComponent::UpdateViewMatrix() const { NazaraAssert(m_entity && m_entity->HasComponent(), "CameraComponent requires NodeComponent"); @@ -150,6 +232,12 @@ namespace Ndk m_viewMatrixUpdated = true; } + /*! + * \brief Updates the view port of the camera + * + * \remark Produces a NazaraAssert if entity has no target + */ + void CameraComponent::UpdateViewport() const { NazaraAssert(m_target, "CameraComponent has no target"); diff --git a/SDK/src/NDK/Components/CollisionComponent.cpp b/SDK/src/NDK/Components/CollisionComponent.cpp index 49e8d8328..0f812e73b 100644 --- a/SDK/src/NDK/Components/CollisionComponent.cpp +++ b/SDK/src/NDK/Components/CollisionComponent.cpp @@ -11,13 +11,27 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::CollisionComponent + * \brief NDK class that represents the component for collision (meant for static objects) + */ + + /*! + * \brief Sets geometry for the entity + * + * \param geom Geometry used for collisions + * + * \remark Produces a NazaraAssert if the entity has no physics component and has no static body + */ + void CollisionComponent::SetGeom(Nz::PhysGeomRef geom) { m_geom = std::move(geom); if (m_entity->HasComponent()) { - // On met à jour la géométrie du PhysObject associé au PhysicsComponent + // We update the geometry of the PhysiscsObject linked to the PhysicsComponent PhysicsComponent& physComponent = m_entity->GetComponent(); physComponent.GetPhysObject().SetGeom(m_geom); } @@ -28,6 +42,13 @@ namespace Ndk } } + /*! + * \brief Initializes the static body + * + * \remark Produces a NazaraAssert if entity is invalid + * \remark Produces a NazaraAssert if entity is not linked to a world, or the world has no physics system + */ + void CollisionComponent::InitializeStaticBody() { NazaraAssert(m_entity, "Invalid entity"); @@ -41,24 +62,44 @@ namespace Ndk m_staticBody->EnableAutoSleep(false); } + /*! + * \brief Operation to perform when component is attached to an entity + */ + void CollisionComponent::OnAttached() { if (!m_entity->HasComponent()) InitializeStaticBody(); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void CollisionComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) m_staticBody.reset(); } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void CollisionComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) InitializeStaticBody(); } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void CollisionComponent::OnDetached() { m_staticBody.reset(); diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index 88ccd4ca1..759d3f24b 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -9,7 +9,23 @@ namespace Ndk { - void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index) + /*! + * \ingroup NDK + * \class Ndk::GraphicsComponent + * \brief NDK class that represents the component for graphics + */ + + /*! + * \brief Invalidates the data for renderable + * + * \param renderable Renderable to invalidate + * \param flags Flags for the instance + * \param index Index of the renderable to invalidate + * + * \remark Produces a NazaraAssert if index is out of bound + */ + + void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable , Nz::UInt32 flags, std::size_t index) { NazaraAssert(index < m_renderables.size(), "Invalid renderable index"); NazaraUnused(renderable); @@ -19,6 +35,10 @@ namespace Ndk r.renderable->InvalidateData(&r.data, flags); } + /*! + * \brief Operation to perform when component is attached to an entity + */ + void GraphicsComponent::OnAttached() { if (m_entity->HasComponent()) @@ -27,6 +47,12 @@ namespace Ndk InvalidateTransformMatrix(); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void GraphicsComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) @@ -38,6 +64,12 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void GraphicsComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) @@ -48,6 +80,10 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void GraphicsComponent::OnDetached() { m_nodeInvalidationSlot.Disconnect(); @@ -55,6 +91,12 @@ namespace Ndk InvalidateTransformMatrix(); } + /*! + * \brief Operation to perform when the node is invalidated + * + * \param node Pointer to the node + */ + void GraphicsComponent::OnNodeInvalidated(const Nz::Node* node) { NazaraUnused(node); @@ -63,6 +105,10 @@ namespace Ndk InvalidateTransformMatrix(); } + /*! + * \brief Updates the bounding volume + */ + void GraphicsComponent::UpdateBoundingVolume() const { EnsureTransformMatrixUpdate(); @@ -75,6 +121,12 @@ namespace Ndk m_boundingVolumeUpdated = true; } + /*! + * \brief Updates the transform matrix of the renderable + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + void GraphicsComponent::UpdateTransformMatrix() const { NazaraAssert(m_entity && m_entity->HasComponent(), "GraphicsComponent requires NodeComponent"); diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp index 2ae4365e6..e700b6497 100644 --- a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp +++ b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp @@ -7,6 +7,19 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ParticleEmitterComponent + * \brief NDK class that represents the component emitter of particles + */ + + /*! + * \brief Sets up the particles + * + * \param mapper Mapper containing layout information of each particle + * \param count Number of particles + */ + void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const { if (m_isActive && m_setupFunc) diff --git a/SDK/src/NDK/Components/PhysicsComponent.cpp b/SDK/src/NDK/Components/PhysicsComponent.cpp index cc23c0954..6cfd1077d 100644 --- a/SDK/src/NDK/Components/PhysicsComponent.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent.cpp @@ -12,6 +12,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::PhysicsComponent + * \brief NDK class that represents the component for physics (meant for dynamic objects) + */ + + /*! + * \brief Operation to perform when component is attached to an entity + * + * \remark Produces a NazaraAssert if the world does not have a physics system + */ + void PhysicsComponent::OnAttached() { World* entityWorld = m_entity->GetWorld(); @@ -33,6 +45,14 @@ namespace Ndk m_object->SetMass(1.f); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + * + * \remark Produces a NazaraAssert if physical object is invalid + */ + void PhysicsComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) @@ -42,6 +62,14 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + * + * \remark Produces a NazaraAssert if physical object is invalid + */ + void PhysicsComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) @@ -51,6 +79,10 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void PhysicsComponent::OnDetached() { m_object.reset(); diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index d157d7dbe..dd379cd4a 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -19,6 +19,20 @@ namespace Ndk constexpr std::size_t s_inputPrefixSize = Nz::CountOf(s_inputPrefix) - 1; } + /*! + * \ingroup NDK + * \class Ndk::Console + * \brief NDK class that represents a console to help development with Lua scripting + */ + + /*! + * \brief Constructs a Console object with a world to interact with + * + * \param world World to interact with + * \param size (Width, Height) of the console + * \param instance Lua instance that will interact with the world + */ + Console::Console(World& world, const Nz::Vector2f& size, Nz::LuaInstance& instance) : m_historyPosition(0), m_defaultFont(Nz::Font::GetDefault()), @@ -86,18 +100,35 @@ namespace Ndk Layout(); } + /*! + * \brief Adds a line to the console + * + * \param text New line of text + * \param color Color for the text + */ + void Console::AddLine(const Nz::String& text, const Nz::Color& color) { AddLineInternal(text, color); RefreshHistory(); } + /*! + * \brief Clears the console + */ + void Console::Clear() { m_historyLines.clear(); RefreshHistory(); } + /*! + * \brief Sends a character to the console + * + * \param character Character that will be added to the console + */ + void Console::SendCharacter(char32_t character) { switch (character) @@ -131,6 +162,12 @@ namespace Ndk m_inputTextSprite->Update(m_inputDrawer); } + /*! + * \brief Sends an event to the console + * + * \param event Event to be takin into consideration by the console + */ + void Console::SendEvent(Nz::WindowEvent event) { switch (event.type) @@ -170,6 +207,12 @@ namespace Ndk } } + /*! + * \brief Sets the character size + * + * \param size Size of the font + */ + void Console::SetCharacterSize(unsigned int size) { m_characterSize = size; @@ -182,6 +225,12 @@ namespace Ndk Layout(); } + /*! + * \brief Sets the console size + * + * \param size (Width, Height) of the console + */ + void Console::SetSize(const Nz::Vector2f& size) { m_size = size; @@ -189,6 +238,14 @@ namespace Ndk Layout(); } + /*! + * \brief Sets the text font + * + * \param font Reference to a valid font + * + * \remark Produces a NazaraAssert if font is invalid or null + */ + void Console::SetTextFont(Nz::FontRef font) { NazaraAssert(font && font->IsValid(), "Invalid font"); @@ -200,6 +257,12 @@ namespace Ndk Layout(); } + /*! + * \brief Shows the console + * + * \param show Should the console be showed + */ + void Console::Show(bool show) { if (m_opened != show) @@ -213,11 +276,22 @@ namespace Ndk } } + /*! + * \brief Adds a line to the history of the console + * + * \param text New line of text + * \param color Color for the text + */ + void Console::AddLineInternal(const Nz::String& text, const Nz::Color& color) { m_historyLines.emplace_back(Line{color, text}); } + /*! + * \brief Performs this action when an input is added to the console + */ + void Console::ExecuteInput() { Nz::String input = m_inputDrawer.GetText(); @@ -237,12 +311,18 @@ namespace Ndk RefreshHistory(); } + /*! + * \brief Places the console according to its layout + */ + void Console::Layout() { unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight; Ndk::NodeComponent& inputNode = m_input->GetComponent(); + NazaraError(inputNode.GetPosition().ToString()); inputNode.SetPosition(0.f, m_size.y - lineHeight - 5.f); + NazaraError(inputNode.GetPosition().ToString()); float historyHeight = m_size.y - lineHeight - 5.f - 2.f; m_historyBackgroundSprite->SetSize(m_size.x, historyHeight); @@ -250,14 +330,22 @@ namespace Ndk m_maxHistoryLines = static_cast(std::ceil(historyHeight / lineHeight)); Ndk::NodeComponent& historyNode = m_history->GetComponent(); + NazaraError(historyNode.GetPosition().ToString()); historyNode.SetPosition(0.f, historyHeight - m_maxHistoryLines * lineHeight); + NazaraError(historyNode.GetPosition().ToString()); Ndk::NodeComponent& inputBackgroundNode = m_inputBackground->GetComponent(); + NazaraError(inputBackgroundNode.GetPosition().ToString()); inputBackgroundNode.SetPosition(0.f, historyHeight + 2.f); + NazaraError(inputBackgroundNode.GetPosition().ToString()); m_inputBackgroundSprite->SetSize(m_size.x, m_size.y - historyHeight); } + /*! + * \brief Refreshes the history of the console + */ + void Console::RefreshHistory() { m_historyDrawer.Clear(); diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index ecd74ebc0..815d0dc1b 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -8,6 +8,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Entity + * \brief NDK class that represents an entity in a world + */ + + /*! + * \brief Constructs a Entity object by move semantic + * + * \param entity Entity to move into this + */ + Entity::Entity(Entity&& entity) : HandledObject(std::move(entity)), m_components(std::move(entity.m_components)), @@ -20,35 +32,57 @@ namespace Ndk { } + /*! + * \brief Constructs a Entity object linked to a world and with an id + * + * \param world World in which the entity interact + * \param id Identifier of the entity + */ + Entity::Entity(World* world, EntityId id) : m_id(id), m_world(world) { } + /*! + * \brief Destructs the object and calls Destroy + * + * \see Destroy + */ + Entity::~Entity() { Destroy(); } + /*! + * \brief Adds a component to the entity + * \return A reference to the newly added component + * + * \param componentPtr Component to add to the entity + * + * \remark Produces a NazaraAssert if component is nullptr + */ + BaseComponent& Entity::AddComponent(std::unique_ptr&& componentPtr) { NazaraAssert(componentPtr, "Component must be valid"); ComponentIndex index = componentPtr->GetIndex(); - // Nous nous assurons que le vecteur de component est suffisamment grand pour contenir le nouveau component + // We ensure that the vector has enough space if (index >= m_components.size()) m_components.resize(index + 1); - // Affectation et retour du component + // Affectation and return of the component m_components[index] = std::move(componentPtr); m_componentBits.UnboundedSet(index); m_removedComponentBits.UnboundedReset(index); Invalidate(); - // On récupère le component et on informe les composants existants du nouvel arrivant + // We get the new component and we alert other existing components of the new one BaseComponent& component = *m_components[index].get(); component.SetEntity(this); @@ -61,34 +95,57 @@ namespace Ndk return component; } + /*! + * \brief Clones the entity + * \return The clone newly created + * + * \remark The close is enable by default, even if the original is disabled + * \remark Produces a NazaraAssert if the entity is not valid + */ + const EntityHandle& Entity::Clone() const { - ///DOC: The clone is enabled by default, even if the original entity is disabled NazaraAssert(IsValid(), "Invalid entity"); return m_world->CloneEntity(m_id); } + /*! + * \brief Kills the entity + */ + void Entity::Kill() { m_world->KillEntity(this); } + /*! + * \brief Invalidates the entity + */ + void Entity::Invalidate() { - // On informe le monde que nous avons besoin d'une mise à jour + // We alert everyone that we have been updated m_world->Invalidate(m_id); } + /*! + * \brief Creates the entity + */ + void Entity::Create() { m_enabled = true; m_valid = true; } + /*! + * \brief Destroys the entity + */ + void Entity::Destroy() { - // On informe chaque système + // We alert each system for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) { if (m_world->HasSystem(index)) @@ -104,12 +161,19 @@ namespace Ndk m_valid = false; } + /*! + * \brief Destroys a component by index + * + * \param index Index of the component + * + * \remark If component is not available, no action is performed + */ + void Entity::DestroyComponent(ComponentIndex index) { - ///DOC: N'a aucun effet si le component n'est pas présent if (HasComponent(index)) { - // On récupère le component et on informe les composants du détachement + // We get the component and we alert existing components of the deleted one BaseComponent& component = *m_components[index].get(); for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) { diff --git a/SDK/src/NDK/LuaAPI.cpp b/SDK/src/NDK/LuaAPI.cpp index a1b84bf5d..1bf4eec35 100644 --- a/SDK/src/NDK/LuaAPI.cpp +++ b/SDK/src/NDK/LuaAPI.cpp @@ -5,12 +5,29 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::LuaAPI + * \brief NDK class that represents the api used for Lua + */ + + /*! + * \brief Initializes the LuaAPI module + * \return true if initialization is successful + */ + bool LuaAPI::Initialize() { s_binding = new LuaBinding; return true; } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the engine & SDK + */ + void LuaAPI::RegisterClasses(Nz::LuaInstance& instance) { if (!s_binding && !Initialize()) @@ -22,6 +39,10 @@ namespace Ndk s_binding->RegisterClasses(instance); } + /*! + * \brief Uninitializes the LuaAPI module + */ + void LuaAPI::Uninitialize() { delete s_binding; diff --git a/SDK/src/NDK/LuaBinding.cpp b/SDK/src/NDK/LuaBinding.cpp index 6acc05a46..822654a39 100644 --- a/SDK/src/NDK/LuaBinding.cpp +++ b/SDK/src/NDK/LuaBinding.cpp @@ -4,6 +4,16 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::LuaBinding + * \brief NDK class that represents the binding between the engine & the SDK with the Lua scripting + */ + + /*! + * \brief Binds modules to Lua + */ + LuaBinding::LuaBinding() : // Core clockClass("Clock"), @@ -65,6 +75,12 @@ namespace Ndk #endif } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the engine & SDK + */ + void LuaBinding::RegisterClasses(Nz::LuaInstance& instance) { RegisterCore(instance); diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index 89452d720..b825b1876 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Audio module to Lua + */ + void LuaBinding::BindAudio() { /*********************************** Nz::Music **********************************/ @@ -164,6 +168,12 @@ namespace Ndk soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Audio classes + */ + void LuaBinding::RegisterAudio(Nz::LuaInstance& instance) { musicClass.Register(instance); diff --git a/SDK/src/NDK/LuaBinding_Core.cpp b/SDK/src/NDK/LuaBinding_Core.cpp index 09cbda604..78c73eea1 100644 --- a/SDK/src/NDK/LuaBinding_Core.cpp +++ b/SDK/src/NDK/LuaBinding_Core.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Core module to Lua + */ + void LuaBinding::BindCore() { /*********************************** Nz::Clock **********************************/ @@ -254,6 +258,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Core classes + */ + void LuaBinding::RegisterCore(Nz::LuaInstance& instance) { // Classes diff --git a/SDK/src/NDK/LuaBinding_Graphics.cpp b/SDK/src/NDK/LuaBinding_Graphics.cpp index 289002746..4c9288428 100644 --- a/SDK/src/NDK/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/LuaBinding_Graphics.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Graphics module to Lua + */ + void LuaBinding::BindGraphics() { /*********************************** Nz::InstancedRenderable ***********************************/ @@ -40,6 +44,12 @@ namespace Ndk modelClass.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Graphics classes + */ + void LuaBinding::RegisterGraphics(Nz::LuaInstance& instance) { instancedRenderable.Register(instance); diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index c1d7b487e..1c53caa69 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -7,6 +7,10 @@ namespace Ndk { + /*! + * \brief Binds Math module to Lua + */ + void LuaBinding::BindMath() { /*********************************** Nz::EulerAngles **********************************/ @@ -673,6 +677,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Math classes + */ + void LuaBinding::RegisterMath(Nz::LuaInstance& instance) { eulerAnglesClass.Register(instance); diff --git a/SDK/src/NDK/LuaBinding_Network.cpp b/SDK/src/NDK/LuaBinding_Network.cpp index dc17c5d00..67f40cb4d 100644 --- a/SDK/src/NDK/LuaBinding_Network.cpp +++ b/SDK/src/NDK/LuaBinding_Network.cpp @@ -5,6 +5,10 @@ namespace Ndk { + /*! + * \brief Binds Network module to Lua + */ + void LuaBinding::BindNetwork() { /*********************************** Nz::AbstractSocket **********************************/ @@ -132,6 +136,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Network classes + */ + void LuaBinding::RegisterNetwork(Nz::LuaInstance& instance) { // Classes diff --git a/SDK/src/NDK/LuaBinding_Renderer.cpp b/SDK/src/NDK/LuaBinding_Renderer.cpp index 78b9fe561..79f1780a3 100644 --- a/SDK/src/NDK/LuaBinding_Renderer.cpp +++ b/SDK/src/NDK/LuaBinding_Renderer.cpp @@ -7,10 +7,20 @@ namespace Ndk { + /*! + * \brief Binds Renderer module to Lua + */ + void LuaBinding::BindRenderer() { } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Renderer classes + */ + void LuaBinding::RegisterRenderer(Nz::LuaInstance& instance) { } diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index b371e76e3..5b6ad7dc9 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -7,6 +7,10 @@ namespace Ndk { + /*! + * \brief Binds SDK module to Lua + */ + void LuaBinding::BindSDK() { /*********************************** Ndk::Application **********************************/ @@ -143,6 +147,12 @@ namespace Ndk #endif } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the SDK classes + */ + void LuaBinding::RegisterSDK(Nz::LuaInstance& instance) { // Classes @@ -173,6 +183,14 @@ namespace Ndk instance.SetGlobal("ComponentType"); } + /*! + * \brief Gets the index of the component + * \return A pointer to the binding linked to a component + * + * \param instance Lua instance that will interact with the component + * \param argIndex Index of the component + */ + LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex) { switch (instance.GetType(argIndex)) diff --git a/SDK/src/NDK/LuaBinding_Utility.cpp b/SDK/src/NDK/LuaBinding_Utility.cpp index 4ccb18fa6..416662b23 100644 --- a/SDK/src/NDK/LuaBinding_Utility.cpp +++ b/SDK/src/NDK/LuaBinding_Utility.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Utility module to Lua + */ + void LuaBinding::BindUtility() { /*********************************** Nz::AbstractImage **********************************/ @@ -308,6 +312,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Utility classes + */ + void LuaBinding::RegisterUtility(Nz::LuaInstance& instance) { abstractImage.Register(instance); diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 964913bf8..bd3bf33e4 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -34,6 +34,19 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Sdk + * \brief NDK class that represents the software development kit, a set of tools made to ease the conception of application + */ + + /*! + * \brief Initializes the Sdk module + * \return true if initialization is successful + * + * \remark Produces a NazaraNotice + */ + bool Sdk::Initialize() { if (s_referenceCounter++ > 0) @@ -104,6 +117,12 @@ namespace Ndk } } + /*! + * \brief Uninitializes the Sdk module + * + * \remark Produces a NazaraNotice + */ + void Sdk::Uninitialize() { if (s_referenceCounter != 1) diff --git a/SDK/src/NDK/State.cpp b/SDK/src/NDK/State.cpp index e256a7f1c..701b98565 100644 --- a/SDK/src/NDK/State.cpp +++ b/SDK/src/NDK/State.cpp @@ -6,5 +6,11 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::State + * \brief NDK class that represents a state of your application + */ + State::~State() = default; } diff --git a/SDK/src/NDK/Systems/ListenerSystem.cpp b/SDK/src/NDK/Systems/ListenerSystem.cpp index 28fce2e0a..9c7333d34 100644 --- a/SDK/src/NDK/Systems/ListenerSystem.cpp +++ b/SDK/src/NDK/Systems/ListenerSystem.cpp @@ -10,11 +10,29 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ListenerSystem + * \brief NDK class that represents the audio system + * + * \remark This system is enabled if the entity owns the trait: ListenerComponent and NodeComponent + */ + + /*! + * \brief Constructs an ListenerSystem object by default + */ + ListenerSystem::ListenerSystem() { Requires(); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void ListenerSystem::OnUpdate(float elapsedTime) { NazaraUnused(elapsedTime); @@ -23,18 +41,18 @@ namespace Ndk for (const Ndk::EntityHandle& entity : GetEntities()) { - // Le listener est-il actif ? + // Is the listener actif ? const ListenerComponent& listener = entity->GetComponent(); if (!listener.IsActive()) continue; - // On récupère la position et la rotation pour les affecter au listener + // We get the position and the rotation to affect these to the listener const NodeComponent& node = entity->GetComponent(); Nz::Audio::SetListenerPosition(node.GetPosition(Nz::CoordSys_Global)); Nz::Audio::SetListenerRotation(node.GetRotation(Nz::CoordSys_Global)); - // On vérifie la présence d'une donnée de vitesse, et on l'affecte - // (La vitesse du listener Audio ne le fait pas se déplacer, mais affecte par exemple l'effet Doppler) + // We verify the presence of a component of velocity + // (The listener'speed does not move it, but disturbs the sound like Doppler effect) if (entity->HasComponent()) { const VelocityComponent& velocity = entity->GetComponent(); diff --git a/SDK/src/NDK/Systems/ParticleSystem.cpp b/SDK/src/NDK/Systems/ParticleSystem.cpp index a9f63cb6c..9321c0ec2 100644 --- a/SDK/src/NDK/Systems/ParticleSystem.cpp +++ b/SDK/src/NDK/Systems/ParticleSystem.cpp @@ -7,11 +7,29 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ParticleSystem + * \brief NDK class that represents the particle system + * + * \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: ParticleGroupComponent + */ + + /*! + * \brief Constructs an ParticleSystem object by default + */ + ParticleSystem::ParticleSystem() { Requires(); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void ParticleSystem::OnUpdate(float elapsedTime) { for (const Ndk::EntityHandle& entity : GetEntities()) diff --git a/SDK/src/NDK/Systems/PhysicsSystem.cpp b/SDK/src/NDK/Systems/PhysicsSystem.cpp index 3d429a686..442784c22 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem.cpp @@ -10,24 +10,50 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::PhysicsSystem + * \brief NDK class that represents the physics system + * + * \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: CollisionComponent or PhysicsComponent + * \remark Static objects do not have a velocity specified by the physical engine + */ + + /*! + * \brief Constructs an PhysicsSystem object by default + */ + PhysicsSystem::PhysicsSystem() { Requires(); RequiresAny(); } + /*! + * \brief Constructs a PhysicsSystem object by copy semantic + * + * \param system PhysicsSystem to copy + */ + PhysicsSystem::PhysicsSystem(const PhysicsSystem& system) : System(system), m_world() { } + /*! + * \brief Operation to perform when entity is validated for the system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + */ + void PhysicsSystem::OnEntityValidation(Entity* entity, bool justAdded) { - // Si l'entité ne vient pas d'être ajoutée au système, il est possible qu'elle fasse partie du mauvais tableau + // If entity has not been just added to the system, it is possible that it does not own to the right array if (!justAdded) { - // On prend le tableau inverse de celui dont l'entité devrait faire partie + // We take the inverted array from which the entity should belong to auto& entities = (entity->HasComponent()) ? m_staticObjects : m_dynamicObjects; entities.Remove(entity); } @@ -36,6 +62,12 @@ namespace Ndk entities.Insert(entity); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void PhysicsSystem::OnUpdate(float elapsedTime) { m_world.Step(elapsedTime); @@ -63,8 +95,8 @@ namespace Ndk Nz::Quaternionf newRotation = node.GetRotation(Nz::CoordSys_Global); Nz::Vector3f newPosition = node.GetPosition(Nz::CoordSys_Global); - // Pour déplacer des objets statiques et assurer les collisions, il faut leur définir une vitesse - // (note importante: le moteur physique n'applique pas la vitesse sur les objets statiques) + // To move static objects and ensure their collisions, we have to specify them a velocity + // (/!\: the physical motor does not apply the speed on static objects) if (newPosition != oldPosition) { physObj->SetPosition(newPosition); diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index fcfd5c6a5..107676206 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -14,6 +14,21 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::RenderSystem + * \brief NDK class that represents the rendering system + * + * \remark This system is enabled if the entity is a 'camera' with the trait: CameraComponent and NodeComponent + * or a drawable element with trait: GraphicsComponent and NodeComponent + * or a light element with trait: LightComponent and NodeComponent + * or a set of particles with trait: ParticleGroupComponent + */ + + /*! + * \brief Constructs an RenderSystem object by default + */ + RenderSystem::RenderSystem() : m_coordinateSystemMatrix(Nz::Matrix4f::Identity()), m_coordinateSystemInvalidated(true) @@ -23,6 +38,12 @@ namespace Ndk SetUpdateRate(0.f); } + /*! + * \brief Operation to perform when an entity is removed + * + * \param entity Pointer to the entity + */ + void RenderSystem::OnEntityRemoved(Entity* entity) { m_cameras.Remove(entity); @@ -33,6 +54,13 @@ namespace Ndk m_pointSpotLights.Remove(entity); } + /*! + * \brief Operation to perform when entity is validated for the system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + */ + void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded) { NazaraUnused(justAdded); @@ -82,6 +110,12 @@ namespace Ndk m_particleGroups.Remove(entity); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void RenderSystem::OnUpdate(float elapsedTime) { NazaraUnused(elapsedTime); @@ -146,6 +180,12 @@ namespace Ndk } } + /*! + * \brief Updates the directional shadow maps according to the position of the viewer + * + * \param viewer Viewer of the scene + */ + void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer) { if (!m_shadowRT.IsValid()) @@ -191,6 +231,10 @@ namespace Ndk } } + /*! + * \brief Updates the point spot shadow maps + */ + void RenderSystem::UpdatePointSpotShadowMaps() { if (!m_shadowRT.IsValid()) diff --git a/SDK/src/NDK/Systems/VelocitySystem.cpp b/SDK/src/NDK/Systems/VelocitySystem.cpp index 2d3264039..e8cfe2f23 100644 --- a/SDK/src/NDK/Systems/VelocitySystem.cpp +++ b/SDK/src/NDK/Systems/VelocitySystem.cpp @@ -9,12 +9,31 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::VelocitySystem + * \brief NDK class that represents the velocity system + * + * \remark This system is enabled if the entity owns the trait: NodeComponent and VelocityComponent + * but it's disabled with the trait: PhysicsComponent + */ + + /*! + * \brief Constructs an VelocitySystem object by default + */ + VelocitySystem::VelocitySystem() { Requires(); Excludes(); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void VelocitySystem::OnUpdate(float elapsedTime) { for (const Ndk::EntityHandle& entity : GetEntities()) diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 8e5ff99f0..938722feb 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -16,12 +16,28 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::World + * \brief NDK class that represents a world + */ + + /*! + * \brief Destructs the object and calls Clear + * + * \see Clear + */ + World::~World() noexcept { - // La destruction doit se faire dans un ordre précis + // The destruct must be done in an ordered way Clear(); } + /*! + * \brief Adds default systems to the world + */ + void World::AddDefaultSystems() { AddSystem(); @@ -34,40 +50,49 @@ namespace Ndk #endif } + /*! + * \brief Creates an entity in the world + * \return The entity created + */ + const EntityHandle& World::CreateEntity() { EntityId id; if (!m_freeIdList.empty()) { - // On récupère un identifiant + // We get an identifier id = m_freeIdList.back(); m_freeIdList.pop_back(); } else { - // On alloue une nouvelle entité + // We allocate a new entity id = m_entities.size(); - // Impossible d'utiliser emplace_back à cause de la portée + // We can't use emplace_back due to the scope m_entities.push_back(Entity(this, id)); } - // On initialise l'entité et on l'ajoute à la liste des entités vivantes + // We initialise the entity and we add it to the list of alive entities Entity& entity = m_entities[id].entity; entity.Create(); m_aliveEntities.emplace_back(&entity); - m_entities[id].aliveIndex = m_aliveEntities.size()-1; + m_entities[id].aliveIndex = m_aliveEntities.size() - 1; return m_aliveEntities.back(); } + /*! + * \brief Clears the world from every entities + * + * \remark Every handles are correctly invalidated, entities are immediately invalidated + */ + void World::Clear() noexcept { - ///DOC: Tous les handles sont correctement invalidés, les entités sont immédiatement invalidées - - // Destruction des entités d'abord, et des handles ensuite - // ceci pour éviter que les handles n'informent les entités inutilement lors de leur destruction + // First, destruction of entities, then handles + // This is made to avoid that handle warn uselessly entities before their destruction m_entities.clear(); m_aliveEntities.clear(); @@ -75,6 +100,15 @@ namespace Ndk m_killedEntities.Clear(); } + /*! + * \brief Clones the entity + * \return The clone newly created + * + * \param id Identifier of the entity + * + * \remark Produces a NazaraError if the entity to clone does not exist + */ + const EntityHandle& World::CloneEntity(EntityId id) { EntityHandle original = GetEntity(id); @@ -96,14 +130,29 @@ namespace Ndk return GetEntity(clone->GetId()); } + /*! + * \brief Kills an entity + * + * \param Pointer to the entity + * + * \remark No change is done if entity is invalid + */ + void World::KillEntity(Entity* entity) { - ///DOC: Ignoré si l'entité est invalide - if (IsEntityValid(entity)) m_killedEntities.UnboundedSet(entity->GetId(), true); } + /*! + * \brief Gets an entity + * \return A constant reference to the modified entity + * + * \param id Identifier of the entity + * + * \remark Produces a NazaraError if entity identifier is not valid + */ + const EntityHandle& World::GetEntity(EntityId id) { if (IsEntityIdValid(id)) @@ -115,9 +164,15 @@ namespace Ndk } } + /*! + * \brief Updates the world + * + * \remark Produces a NazaraAssert if an entity is invalid + */ + void World::Update() { - // Gestion des entités tuées depuis le dernier appel + // Handle killed entities before last call for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) { EntityBlock& block = m_entities[i]; @@ -125,32 +180,32 @@ namespace Ndk NazaraAssert(entity.IsValid(), "Entity must be valid"); - // Remise en file d'attente de l'identifiant d'entité + // Send back the identifier of the entity to the free queue m_freeIdList.push_back(entity.GetId()); - // Destruction de l'entité (invalidation du handle par la même occasion) + // Destruction of the entity (invalidation of handle by the same way) entity.Destroy(); - // Nous allons sortir le handle de la liste des entités vivantes - // en swappant le handle avec le dernier handle, avant de pop + // We take out the handle from the list of alive entities + // With the idiom swap and pop NazaraAssert(block.aliveIndex < m_aliveEntities.size(), "Alive index out of range"); - if (block.aliveIndex < m_aliveEntities.size()-1) // S'il ne s'agit pas du dernier handle + if (block.aliveIndex < m_aliveEntities.size() - 1) // If it's not the last handle { EntityHandle& lastHandle = m_aliveEntities.back(); EntityHandle& myHandle = m_aliveEntities[block.aliveIndex]; myHandle = std::move(lastHandle); - // On n'oublie pas de corriger l'indice associé à l'entité + // We don't forget to update the index associated to the entity m_entities[myHandle->GetId()].aliveIndex = block.aliveIndex; } m_aliveEntities.pop_back(); } m_killedEntities.Reset(); - // Gestion des entités nécessitant une mise à jour de leurs systèmes + // Handle of entities which need an update from the systems for (std::size_t i = m_dirtyEntities.FindFirst(); i != m_dirtyEntities.npos; i = m_dirtyEntities.FindNext(i)) { NazaraAssert(i < m_entities.size(), "Entity index out of range"); diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index 0d3dcc7d2..b423b390f 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -14,17 +14,10 @@ TOOL.Includes = { TOOL.Files = { "../tests/main.cpp", - "../tests/Engine/**.cpp" + "../tests/Engine/**.cpp", + "../tests/SDK/**.cpp" } TOOL.Libraries = { - "NazaraCore", - "NazaraAudio", - "NazaraLua", - "NazaraGraphics", - "NazaraRenderer", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility" + "NazaraSDK" } diff --git a/tests/SDK/NDK/Application.cpp b/tests/SDK/NDK/Application.cpp new file mode 100644 index 000000000..994bd022b --- /dev/null +++ b/tests/SDK/NDK/Application.cpp @@ -0,0 +1,22 @@ +#include +#include + +SCENARIO("Application", "[NDK][APPLICATION]") +{ + GIVEN("An application") + { + Ndk::Application application; + application.AddWorld(); + Nz::Window& window = application.AddWindow(); + + WHEN("We close the open window") + { + window.Close(); + + THEN("Application should close") + { + REQUIRE(!application.Run()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/BaseSystem.cpp b/tests/SDK/NDK/BaseSystem.cpp new file mode 100644 index 000000000..e4ca2e1c9 --- /dev/null +++ b/tests/SDK/NDK/BaseSystem.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include + +namespace +{ + class TestSystem : public Ndk::System + { + public: + TestSystem() + { + Requires(); + Excludes(); + } + + ~TestSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + } + }; + + Ndk::SystemIndex TestSystem::systemIndex; +} + +SCENARIO("BaseSystem", "[NDK][BASESYSTEM]") +{ + GIVEN("Our TestSystem") + { + Ndk::World world; + Ndk::BaseSystem& system = world.AddSystem(); + REQUIRE(&system.GetWorld() == &world); + + WHEN("We add an entity") + { + const Ndk::EntityHandle& entity = world.CreateEntity(); + entity->AddComponent(); + + THEN("System should have it") + { + world.Update(1.f); + REQUIRE(system.HasEntity(entity)); + } + } + + WHEN("We add an entity with excluded component") + { + const Ndk::EntityHandle& entity = world.CreateEntity(); + entity->AddComponent(); + entity->AddComponent(); + + THEN("System should not have it") + { + world.Update(1.f); + REQUIRE(!system.HasEntity(entity)); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Component.cpp b/tests/SDK/NDK/Component.cpp new file mode 100644 index 000000000..f00bb9006 --- /dev/null +++ b/tests/SDK/NDK/Component.cpp @@ -0,0 +1,31 @@ +#include +#include + +namespace +{ + class TestComponent : public Ndk::Component + { + public: + static Ndk::ComponentIndex componentIndex; + }; + + Ndk::ComponentIndex TestComponent::componentIndex; +} + +SCENARIO("Component", "[NDK][COMPONENT]") +{ + GIVEN("Our TestComponent") + { + TestComponent testComponent; + + WHEN("We clone it") + { + std::unique_ptr clone = testComponent.Clone(); + + THEN("We should get a copy") + { + REQUIRE(dynamic_cast(clone.get()) != nullptr); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Entity.cpp b/tests/SDK/NDK/Entity.cpp new file mode 100644 index 000000000..d784e28ad --- /dev/null +++ b/tests/SDK/NDK/Entity.cpp @@ -0,0 +1,101 @@ +#include +#include +#include + +namespace +{ + class UpdatableComponent : public Ndk::Component + { + public: + bool IsUpdated() + { + return m_updated; + } + + void SetUpdated() + { + m_updated = true; + } + + static Ndk::ComponentIndex componentIndex; + + private: + bool m_updated = false; + }; + + Ndk::ComponentIndex UpdatableComponent::componentIndex; + + class UpdateSystem : public Ndk::System + { + public: + UpdateSystem() + { + Requires(); + } + + ~UpdateSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + for (const Ndk::EntityHandle& entity : GetEntities()) + { + UpdatableComponent& updatable = entity->GetComponent(); + updatable.SetUpdated(); + } + } + }; + + Ndk::SystemIndex UpdateSystem::systemIndex; +} + +SCENARIO("Entity", "[NDK][ENTITY]") +{ + GIVEN("A world & an entity") + { + Ndk::World world; + Ndk::BaseSystem& system = world.AddSystem(); + const Ndk::EntityHandle& entity = world.CreateEntity(); + + WHEN("We add our UpdateComponent") + { + UpdatableComponent& updatableComponent = entity->AddComponent(); + REQUIRE(!updatableComponent.IsUpdated()); + + THEN("Update the world should update the entity's component") + { + world.Update(1.f); + UpdatableComponent& updatableComponentGet = entity->GetComponent(); + REQUIRE(updatableComponentGet.IsUpdated()); + } + + THEN("Update the world should not update the entity's component if it's disabled") + { + entity->Enable(false); + world.Update(1.f); + UpdatableComponent& updatableComponentGet = entity->GetComponent(); + REQUIRE(!updatableComponentGet.IsUpdated()); + } + + THEN("We can remove its component") + { + entity->RemoveComponent(Ndk::GetComponentIndex()); + world.Update(1.f); + REQUIRE(!entity->HasComponent()); + } + } + + WHEN("We kill our entity") + { + entity->Kill(); + world.Update(1.f); + + THEN("It's no more valid") + { + REQUIRE(!world.IsEntityValid(entity)); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/EntityList.cpp b/tests/SDK/NDK/EntityList.cpp new file mode 100644 index 000000000..4b76766d5 --- /dev/null +++ b/tests/SDK/NDK/EntityList.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +SCENARIO("EntityList", "[NDK][ENTITYLIST]") +{ + GIVEN("A world & a set of entities") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityList entityList; + entityList.Insert(entity); + + WHEN("We ask if entity is in there") + { + THEN("These results are expected") + { + REQUIRE(entityList.Has(entity->GetId())); + const Ndk::EntityHandle& entity = world.CreateEntity(); + REQUIRE(!entityList.Has(entity->GetId())); + } + } + + WHEN("We remove then insert") + { + entityList.Remove(*entityList.begin()); + + THEN("Set should be empty") + { + REQUIRE(entityList.empty()); + } + + entityList.Insert(entity); + + THEN("With one element") + { + REQUIRE(!entityList.empty()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/EntityOwner.cpp b/tests/SDK/NDK/EntityOwner.cpp new file mode 100644 index 000000000..eb9a29edf --- /dev/null +++ b/tests/SDK/NDK/EntityOwner.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]") +{ + GIVEN("A world & an entity") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + + WHEN("We set the ownership of the entity to our owner") + { + Ndk::EntityOwner entityOwner(entity); + + THEN("Entity is still valid") + { + REQUIRE(entity.IsValid()); + } + + THEN("Resetting or getting out of scope is no more valid") + { + entityOwner.Reset(); + world.Update(1.f); + REQUIRE(!entity.IsValid()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/StateMachine.cpp b/tests/SDK/NDK/StateMachine.cpp new file mode 100644 index 000000000..604aa6f9f --- /dev/null +++ b/tests/SDK/NDK/StateMachine.cpp @@ -0,0 +1,48 @@ +#include +#include + +class TestState : public Ndk::State +{ + public: + void Enter(Ndk::StateMachine& fsm) override + { + m_isUpdated = false; + } + + bool IsUpdated() const + { + return m_isUpdated; + } + + void Leave(Ndk::StateMachine& fsm) override + { + } + + bool Update(Ndk::StateMachine& fsm, float elapsedTime) override + { + m_isUpdated = true; + } + + private: + bool m_isUpdated; +}; + +SCENARIO("State & StateMachine", "[NDK][STATE]") +{ + GIVEN("A statemachine with our TestState") + { + std::shared_ptr testState = std::make_shared(); + Ndk::StateMachine stateMachine(testState); + REQUIRE(!testState->IsUpdated()); + + WHEN("We update our machine") + { + stateMachine.Update(1.f); + + THEN("Our state has been updated") + { + REQUIRE(testState->IsUpdated()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/System.cpp b/tests/SDK/NDK/System.cpp new file mode 100644 index 000000000..ca1917124 --- /dev/null +++ b/tests/SDK/NDK/System.cpp @@ -0,0 +1,42 @@ +#include +#include + +namespace +{ + class TestSystem : public Ndk::System + { + public: + TestSystem() + { + } + + ~TestSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + } + }; + + Ndk::SystemIndex TestSystem::systemIndex; +} + +SCENARIO("System", "[NDK][SYSTEM]") +{ + GIVEN("Our TestSystem") + { + TestSystem testSystem; + + WHEN("We clone it") + { + std::unique_ptr clone = testSystem.Clone(); + + THEN("We should get a copy") + { + REQUIRE(dynamic_cast(clone.get()) != nullptr); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/ListenerSystem.cpp b/tests/SDK/NDK/Systems/ListenerSystem.cpp new file mode 100644 index 000000000..2792dbc25 --- /dev/null +++ b/tests/SDK/NDK/Systems/ListenerSystem.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include + +SCENARIO("ListenerSystem", "[NDK][LISTENERSYSTEM]") +{ + GIVEN("A world and an entity with listener & node components") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::ListenerComponent& listenerComponent = entity->AddComponent(); + Ndk::NodeComponent& nodeComponent = entity->AddComponent(); + + WHEN("We move our entity") + { + Nz::Vector3f position = Nz::Vector3f::Unit() * 3.f; + nodeComponent.SetPosition(position); + Nz::Quaternionf rotation = Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::Up()); + nodeComponent.SetRotation(rotation); + world.Update(1.f); + + THEN("Our listener should have moved") + { + REQUIRE(Nz::Audio::GetListenerPosition() == position); + REQUIRE(Nz::Audio::GetListenerRotation() == rotation); + } + + THEN("With a component of velocity") + { + Ndk::VelocityComponent& velocityComponent = entity->AddComponent(); + Nz::Vector3f velocity = Nz::Vector3f::Unit() * 2.f; + velocityComponent.linearVelocity = velocity; + + world.Update(1.f); + REQUIRE(Nz::Audio::GetListenerVelocity() == velocity); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/PhysicsSystem.cpp b/tests/SDK/NDK/Systems/PhysicsSystem.cpp new file mode 100644 index 000000000..2aa3c313e --- /dev/null +++ b/tests/SDK/NDK/Systems/PhysicsSystem.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include + +SCENARIO("PhysicsSystem", "[NDK][PHYSICSSYSTEM]") +{ + GIVEN("A world and a static entity & a dynamic entity") + { + Ndk::World world; + const Ndk::EntityHandle& staticEntity = world.CreateEntity(); + Ndk::CollisionComponent& collisionComponentStatic = staticEntity->AddComponent(); + Ndk::NodeComponent& nodeComponentStatic = staticEntity->AddComponent(); + + const Ndk::EntityHandle& dynamicEntity = world.CreateEntity(); + Ndk::NodeComponent& nodeComponentDynamic = dynamicEntity->AddComponent(); + Ndk::PhysicsComponent& physicsComponentDynamic = dynamicEntity->AddComponent(); + + WHEN("We make collide these two entities") + { + nodeComponentDynamic.SetPosition(-Nz::Vector3f::UnitZ()); + physicsComponentDynamic.AddForce(Nz::Vector3f::UnitZ()); + + THEN("The dynamic entity should have hit the static one") + { + world.Update(1.f); // On origin + world.Update(1.f); // On origin due to collision + REQUIRE(nodeComponentStatic.GetPosition().SquaredDistance(nodeComponentDynamic.GetPosition()) < 0.2f); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/RenderSystem.cpp b/tests/SDK/NDK/Systems/RenderSystem.cpp new file mode 100644 index 000000000..f106b3aae --- /dev/null +++ b/tests/SDK/NDK/Systems/RenderSystem.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +SCENARIO("RenderSystem", "[NDK][RenderSystem]") +{ + GIVEN("A world with a camera, a drawable, a light and some particles") + { + Ndk::World world; + const Ndk::EntityHandle& cameraEntity = world.CreateEntity(); + Ndk::CameraComponent& cameraComponentCamera = cameraEntity->AddComponent(); + Ndk::NodeComponent& nodeComponentCamera = cameraEntity->AddComponent(); + + const Ndk::EntityHandle& drawableEntity = world.CreateEntity(); + Ndk::GraphicsComponent& graphicsComponentDrawable = drawableEntity->AddComponent(); + Nz::SpriteRef sprite = Nz::Sprite::New(); + graphicsComponentDrawable.Attach(sprite); + Ndk::NodeComponent& nodeComponentDrawable = drawableEntity->AddComponent(); + + const Ndk::EntityHandle& lightEntity = world.CreateEntity(); + Ndk::LightComponent& lightComponentLight = lightEntity->AddComponent(); + Ndk::NodeComponent& nodeComponentLight = lightEntity->AddComponent(); + + const Ndk::EntityHandle& particlesEntity = world.CreateEntity(); + Ndk::ParticleGroupComponent& particleGroupComponentParticles = particlesEntity->AddComponent(1, Nz::ParticleLayout_Sprite); + + WHEN("We change the render technique to ForwardRenderTechnique") + { + Ndk::RenderSystem& renderSystem = world.GetSystem(); + renderSystem.ChangeRenderTechnique(); + + THEN("The render system should be ForwardRenderTechnique") + { + REQUIRE(renderSystem.GetRenderTechnique().GetType() == Nz::RenderTechniqueType_BasicForward); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/VelocitySystem.cpp b/tests/SDK/NDK/Systems/VelocitySystem.cpp new file mode 100644 index 000000000..bfde34896 --- /dev/null +++ b/tests/SDK/NDK/Systems/VelocitySystem.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include + +SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]") +{ + GIVEN("A world and an entity with velocity & node components") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::VelocityComponent& velocityComponent = entity->AddComponent(); + Ndk::NodeComponent& nodeComponent = entity->AddComponent(); + + WHEN("We give a speed to our entity") + { + Nz::Vector3f velocity = Nz::Vector3f::Unit() * 2.f; + velocityComponent.linearVelocity = velocity; + world.Update(1.f); + + THEN("Our entity should have moved") + { + REQUIRE(nodeComponent.GetPosition().SquaredDistance(velocity) < 0.2f); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/World.cpp b/tests/SDK/NDK/World.cpp new file mode 100644 index 000000000..431490490 --- /dev/null +++ b/tests/SDK/NDK/World.cpp @@ -0,0 +1,103 @@ +#include +#include +#include + +namespace +{ + class UpdatableComponent : public Ndk::Component + { + public: + bool IsUpdated() + { + return m_updated; + } + + void SetUpdated() + { + m_updated = true; + } + + static Ndk::ComponentIndex componentIndex; + + private: + bool m_updated = false; + }; + + Ndk::ComponentIndex UpdatableComponent::componentIndex; + + class UpdateSystem : public Ndk::System + { + public: + UpdateSystem() + { + Requires(); + } + + ~UpdateSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + for (const Ndk::EntityHandle& entity : GetEntities()) + { + UpdatableComponent& updatable = entity->GetComponent(); + updatable.SetUpdated(); + } + } + }; + + Ndk::SystemIndex UpdateSystem::systemIndex; +} + +SCENARIO("World", "[NDK][WORLD]") +{ + GIVEN("A brave new world and the update system") + { + Ndk::World world; + Ndk::BaseSystem& system = world.AddSystem(); + + WHEN("We had a new entity with an updatable component and a system") + { + const Ndk::EntityHandle& entity = world.CreateEntity(); + UpdatableComponent& component = entity->AddComponent(); + + THEN("We can get our entity and our system") + { + const Ndk::EntityHandle& fetchedEntity = world.GetEntity(entity->GetId()); + REQUIRE(fetchedEntity->GetWorld() == &world); + } + + THEN("We can clone it") + { + const Ndk::EntityHandle& clone = world.CloneEntity(entity->GetId()); + REQUIRE(world.IsEntityValid(clone)); + } + } + + AND_WHEN("We update our world with our entity") + { + REQUIRE(&world.GetSystem(UpdateSystem::systemIndex) == &world.GetSystem()); + const Ndk::EntityHandle& entity = world.CreateEntity(); + UpdatableComponent& component = entity->AddComponent(); + + THEN("Our entity component must be updated") + { + world.Update(1.f); + + REQUIRE(component.IsUpdated()); + } + + THEN("We kill our entity") + { + REQUIRE(entity->IsValid()); + + world.KillEntity(entity); + world.Update(1.f); + + REQUIRE(!world.IsEntityValid(entity)); + } + } + } +} \ No newline at end of file From 1f7dd1dae4ce0f1f1a5b5598c9610787d4cdf06a Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 21 Aug 2016 13:49:24 +0200 Subject: [PATCH 183/235] Fix documentation Former-commit-id: c11854f38304c8c1db43d740b85d262f999e960d [formerly 1a02bb65c7dd7a3fdcef9f2efed1aa041365b929] [formerly 86ec65871b28639a3a475671297ebef6e75833a5 [formerly e5064e4cd1661344b3beb785d085756deb3dccf4]] Former-commit-id: 09a97462c981a214dcd274047c5057805bb9aca4 [formerly 1f0c58d1b2e3e0641d50cf113809c3c11a1cc500] Former-commit-id: cb2e1f2b5c9cd84124eaab9c401076fa4a586858 --- include/Nazara/Math/Algorithm.inl | 83 ++++++++++++++++--------------- src/Nazara/Graphics/Sprite.cpp | 4 +- src/Nazara/Graphics/TileMap.cpp | 11 ++++ src/Nazara/Network/Network.cpp | 2 +- 4 files changed, 56 insertions(+), 44 deletions(-) diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 2c865ad1b..b61d82916 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -45,20 +45,21 @@ namespace Nz } template - // Les parenthèses autour de la condition sont nécesaires pour que GCC compile ça + // The parentheses are needed for GCC typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2(T number) { static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed"); - // L'algorithme pour le logarithme base 2 (au dessus) ne fonctionne qu'avec des nombres au plus 32bits - // ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting + // Masking and shifting bits to the right (to bring it back to 32 bits) + + // Call of the function with 32 bits number, if the result is non-null we have our answer for (int i = sizeof(T)-sizeof(UInt32); i >= 0; i -= sizeof(UInt32)) { - // Le masque 32 bits sur la partie du nombre qu'on traite actuellement + // The 32 bits mask on the part we are treating T mask = T(std::numeric_limits::max()) << i*8; - T val = (number & mask) >> i*8; // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits) + T val = (number & mask) >> i*8; // Masking and shifting bits to the right (to bring it back to 32 bits) - // Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse + // Call of the function with 32 bits number, if the result is non-null we have our answer unsigned int log2 = IntegralLog2(val); if (log2) return log2 + i*8; @@ -75,20 +76,20 @@ namespace Nz } template - // Les parenthèses autour de la condition sont nécesaires pour que GCC compile ça + // The parentheses are needed for GCC typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2Pot(T number) { static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed"); - // L'algorithme pour le logarithme base 2 (au dessus) ne fonctionne qu'avec des nombres au plus 32bits - // ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting + // The algorithm for logarithm in base 2 only works with numbers greather than 32 bits + // This code subdivides the biggest number into 32 bits ones for (int i = sizeof(T)-sizeof(UInt32); i >= 0; i -= sizeof(UInt32)) { - // Le masque 32 bits sur la partie du nombre qu'on traite actuellement + // The 32 bits mask on the part we are treating T mask = T(std::numeric_limits::max()) << i*8; - UInt32 val = UInt32((number & mask) >> i*8); // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits) + UInt32 val = UInt32((number & mask) >> i*8); // Masking and shifting bits to the right (to bring it back to 32 bits) - // Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse + // Call of the function with 32 bits number, if the result is non-null we have our answer unsigned int log2 = IntegralLog2Pot(val); if (log2 || val == 1) return log2 + i*8; @@ -99,7 +100,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Approaches the objective, beginning with value and with increment * \return The nearest value of the objective you can get with the value and the increment for one step * @@ -121,7 +122,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Clamps value between min and max and returns the expected value * \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval * @@ -137,7 +138,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets number of bits set in the number * \return The number of bits set to 1 * @@ -160,7 +161,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts degree to radian * \return The representation in radian of the angle in degree (0..2*pi) * @@ -174,7 +175,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the unit from degree and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express the degrees * @@ -192,7 +193,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the unit from radian and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express the radians * @@ -210,7 +211,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the nearest power of two for the number * \return First power of two containing the number * @@ -229,7 +230,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -257,7 +258,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -279,7 +280,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -295,7 +296,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -312,7 +313,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -328,7 +329,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -345,7 +346,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits + 1 for the dot * @@ -360,7 +361,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits + 1 for the dot * @@ -375,7 +376,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits + 1 for the dot * @@ -390,7 +391,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the log in base 2 of integral number * \return Log of the number (floor) * @@ -408,7 +409,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the log in base 2 of integral number, only works for power of two ! * \return Log of the number * @@ -426,7 +427,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the power of integrals * \return base^exponent for integral * @@ -445,7 +446,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Interpolates the value to other one with a factor of interpolation * \return A new value which is the interpolation of two values * @@ -466,7 +467,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Multiplies X and Y, then add Z * \return The result of X * Y + Z * @@ -508,7 +509,7 @@ namespace Nz #endif /*! - * \ingroup math + * \ingroup math * \brief Normalizes the angle * \return Normalized value between 0..2*(pi if radian or 180 if degrees) * @@ -534,7 +535,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Checks whether two numbers are equal * \return true if they are equal within a certain epsilon * @@ -550,7 +551,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Checks whether two numbers are equal * \return true if they are equal within the max difference * @@ -571,7 +572,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts the number to String * \return String representation of the number * @@ -623,7 +624,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts radian to degree * \return The representation in degree of the angle in radian (0..360) * @@ -637,7 +638,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts the string to number * \return Number which is represented by the string * @@ -699,7 +700,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express in degrees * @@ -717,7 +718,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the radian from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express in radians * diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 4bf076183..5ef82cddf 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -75,7 +75,7 @@ namespace Nz } /*! - * \brief Initializes the sprite librairies + * \brief Initializes the sprite library * \return true If successful * * \remark Produces a NazaraError if the sprite library failed to be initialized @@ -93,7 +93,7 @@ namespace Nz } /*! - * \brief Uninitializes the sprite librairies + * \brief Uninitializes the sprite library */ void Sprite::Uninitialize() diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index 9d835cb24..2c6e26aa4 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -90,6 +90,13 @@ namespace Nz } } + /*! + * \brief Initializes the tilemap library + * \return true If successful + * + * \remark Produces a NazaraError if the tilemap library failed to be initialized + */ + bool TileMap::Initialize() { if (!TileMapLibrary::Initialize()) @@ -101,6 +108,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the tilemap library + */ + void TileMap::Uninitialize() { TileMapLibrary::Uninitialize(); diff --git a/src/Nazara/Network/Network.cpp b/src/Nazara/Network/Network.cpp index fa3813dd4..3e798e681 100644 --- a/src/Nazara/Network/Network.cpp +++ b/src/Nazara/Network/Network.cpp @@ -93,7 +93,7 @@ namespace Nz } /*! - * \brief Uninitializes the Core module + * \brief Uninitializes the Network module * * \remark Produces a NazaraNotice */ From 044ecf325b7079632d54db91ae7a56354c4dd444 Mon Sep 17 00:00:00 2001 From: S6066 Date: Tue, 23 Aug 2016 16:49:47 +0200 Subject: [PATCH 184/235] Update Entity.hpp Former-commit-id: 235ba4e526bbfd099ffe3f70579f5bf6143197f2 [formerly 1a80f70248e9512ebf995ea59bc18e63185896c0] [formerly e57b34dc18114250d575caabd7d8163eb227b43d [formerly d1525c1a67c741e9af763cc50951d29489751571]] Former-commit-id: a53a0c100c3beff71414ee4d257e7683fe7b75aa [formerly 28701c5d4907386523c9b553f5f7ce3d70fa1b75] Former-commit-id: 81f6862f1de2c7c00efa40ed482a66a8078291ce --- SDK/include/NDK/Entity.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index 5aeeb8226..dbe77815c 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -36,7 +36,7 @@ namespace Ndk const EntityHandle& Clone() const; - inline void Enable(bool enable); + inline void Enable(bool enable = true); inline BaseComponent& GetComponent(ComponentIndex index); template ComponentType& GetComponent(); From 7fa2bb7529a2673ae1085f067c4452972bf61b17 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 23 Aug 2016 18:22:09 +0200 Subject: [PATCH 185/235] Sdk/Binding: Fix Entity::Enable default argument Former-commit-id: d1281afb8243a7337aa261a8ef098aecda3b0c66 [formerly 0c0a6397d76ae937520348a2b22dbef881f86a4b] [formerly f207bfb2fabb906a5a2ba5ac2d2fbc01f936478e [formerly ea7baeb60b77f8aab1d0aba780ad7d0aa39cb5b2]] Former-commit-id: 9a3dee07d5ee7acb93925447e7d0289be90de1db [formerly 684247f442cca23d1bc987ab30e9d7a05e6a2b05] Former-commit-id: 7da21d62cacb4e4cbf67a434b52304e950c92a1f --- SDK/src/NDK/LuaBinding_SDK.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 5b6ad7dc9..bf66cbf00 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -57,7 +57,7 @@ namespace Ndk #endif /*********************************** Ndk::Entity **********************************/ - entityClass.BindMethod("Enable", &Entity::Enable); + entityClass.BindMethod("Enable", &Entity::Enable, true); entityClass.BindMethod("GetId", &Entity::GetId); entityClass.BindMethod("GetWorld", &Entity::GetWorld); entityClass.BindMethod("Kill", &Entity::Kill); From 7c7364d1dc2dd9201428e6bf0e012ee7c5c6355f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 23 Aug 2016 18:25:10 +0200 Subject: [PATCH 186/235] Sdk/Console: Remove debug error Former-commit-id: b1b3e3183e7c2d8318d53504b2f9c106ad5deaf0 [formerly f0b80e347ec153fa2b0b65ff52f7057a5513986a] [formerly 551d06d6d1421053ddecafcbebd47853b7c63a00 [formerly c0a1ddc82df5e2954586e43d97a3704a4ac7e1ad]] Former-commit-id: 133fad81f092220d099cb872d7d5a15d74c34fdc [formerly 7deeb4cae2f8c7b8e01215c67e733151e3e3ac80] Former-commit-id: 95b8dfe324277e1892591412ecfe4f5eb51a8c01 --- SDK/src/NDK/Console.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index dd379cd4a..94a80b749 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -320,9 +320,7 @@ namespace Ndk unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight; Ndk::NodeComponent& inputNode = m_input->GetComponent(); - NazaraError(inputNode.GetPosition().ToString()); inputNode.SetPosition(0.f, m_size.y - lineHeight - 5.f); - NazaraError(inputNode.GetPosition().ToString()); float historyHeight = m_size.y - lineHeight - 5.f - 2.f; m_historyBackgroundSprite->SetSize(m_size.x, historyHeight); @@ -330,14 +328,10 @@ namespace Ndk m_maxHistoryLines = static_cast(std::ceil(historyHeight / lineHeight)); Ndk::NodeComponent& historyNode = m_history->GetComponent(); - NazaraError(historyNode.GetPosition().ToString()); historyNode.SetPosition(0.f, historyHeight - m_maxHistoryLines * lineHeight); - NazaraError(historyNode.GetPosition().ToString()); Ndk::NodeComponent& inputBackgroundNode = m_inputBackground->GetComponent(); - NazaraError(inputBackgroundNode.GetPosition().ToString()); inputBackgroundNode.SetPosition(0.f, historyHeight + 2.f); - NazaraError(inputBackgroundNode.GetPosition().ToString()); m_inputBackgroundSprite->SetSize(m_size.x, m_size.y - historyHeight); } From c04b03797f71c2e2bae8bec749cca1c37f5921ab Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 25 Aug 2016 13:07:19 +0200 Subject: [PATCH 187/235] Doc: Parse SDK files Former-commit-id: af800bc47141c6d9cad22d1cdc5be6f12f79ddef [formerly b272c76d0cba668aba950dbf9e4981de38d160ac] [formerly 0c5ff7a31e9dcdbcc57a8fbf9d2dfe14450a1838 [formerly f0716e23b7dc42966ae3ca8137c1d752a42901ac]] Former-commit-id: 8773cca3dcac5fa8c9fd4f0c862b62dd59e61cb5 [formerly b499b5dd07756ad385c51e80ad970c4602e67f61] Former-commit-id: 51ac1220a9af7d756a013ac712bc20f9f3f4d5a7 --- Doxyfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doxyfile b/Doxyfile index 7ac8e5f8c..47af03df4 100644 --- a/Doxyfile +++ b/Doxyfile @@ -776,7 +776,9 @@ WARN_LOGFILE = # Note: If this tag is empty the current directory is searched. INPUT = include \ - src + src \ + SDK/include \ + SDK/src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses From 1d179c4f9901b26c88b2011bb38c76d503670c34 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 25 Aug 2016 16:28:25 +0200 Subject: [PATCH 188/235] Test/StateMachine: Fix compilation Former-commit-id: 8bae2463a80f57c10758af26bae23b2fc5c38eb3 [formerly 27831c3a673deb90d402d76bfac33c9c1c45f1fb] [formerly 40c188bae9bcf7c79592e61b1d6dd19eebcf27bc [formerly 4f69ef25f21ef9ee385044c1dd86c51a0e44fc0d]] Former-commit-id: bedf58687a28842fa11dfa7abb1667fc72a7789b [formerly fda4ac3ef072a3ed0ef85d158d739b15850f04cd] Former-commit-id: 88f150190da78ec9b76a5feac34634b800b4d3e2 --- tests/SDK/NDK/StateMachine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/SDK/NDK/StateMachine.cpp b/tests/SDK/NDK/StateMachine.cpp index 604aa6f9f..44b0e0dfd 100644 --- a/tests/SDK/NDK/StateMachine.cpp +++ b/tests/SDK/NDK/StateMachine.cpp @@ -21,6 +21,7 @@ class TestState : public Ndk::State bool Update(Ndk::StateMachine& fsm, float elapsedTime) override { m_isUpdated = true; + return true; } private: @@ -45,4 +46,4 @@ SCENARIO("State & StateMachine", "[NDK][STATE]") } } } -} \ No newline at end of file +} From 326db9fa30898c5b3461c6303db62b67874546c5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:08:38 +0200 Subject: [PATCH 189/235] Utility/Window: Add new event system, based on signals Old pooling-based system remains for now but is now deprecated Former-commit-id: 9482b37fb19041399b7c26181319e1c00e7678fd [formerly 516aa322ca7f656e3e7c66010248b63068eec723] [formerly 6fdb81e8d59fef7d6e10e58898878d3e1a796188 [formerly c999fe23b149e14bdeeefed5436839fe44e1ebc3]] Former-commit-id: fb35c9017bc2c7d15e31ccadb3f943ca2f0332df [formerly 005fa120540dc1a2d09e30c2de9611c4cb98aecf] Former-commit-id: d51482384fffb5d1b339f3ce39df1a1ed6018228 --- SDK/src/NDK/Application.cpp | 2 + examples/Tut01/main.cpp | 8 +-- include/Nazara/Utility/EventHandler.hpp | 47 ++++++++++++++ include/Nazara/Utility/EventHandler.inl | 82 +++++++++++++++++++++++++ include/Nazara/Utility/Window.hpp | 13 ++-- include/Nazara/Utility/Window.inl | 58 +++++++++-------- src/Nazara/Utility/Window.cpp | 9 +++ 7 files changed, 181 insertions(+), 38 deletions(-) create mode 100644 include/Nazara/Utility/EventHandler.hpp create mode 100644 include/Nazara/Utility/EventHandler.inl diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 5e3331d73..63e834bd0 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -26,6 +26,8 @@ namespace Ndk { Nz::Window& window = **it; + window.ProcessEvents(); + if (!window.IsOpen(true)) { it = m_windows.erase(it); diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index d1ebcd5d4..f5fca94a0 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -16,6 +16,7 @@ int main() Nz::RenderWindow& mainWindow = application.AddWindow(); mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test"); + Ndk::World& world = application.AddWorld(); world.GetSystem().SetGlobalUp(Nz::Vector3f::Down()); world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(192, 100, 100))); @@ -43,13 +44,6 @@ int main() while (application.Run()) { - Nz::WindowEvent event; - while (mainWindow.PollEvent(&event)) - { - if (event.type == Nz::WindowEventType_Quit) - application.Quit(); - } - mainWindow.Display(); } diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp new file mode 100644 index 000000000..b35ef96cf --- /dev/null +++ b/include/Nazara/Utility/EventHandler.hpp @@ -0,0 +1,47 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_EVENTHANDLER_HPP +#define NAZARA_EVENTHANDLER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class EventHandler + { + public: + EventHandler() = default; + EventHandler(const EventHandler&); + EventHandler(EventHandler&&) = default; + ~EventHandler() = default; + + inline void Dispatch(const WindowEvent& event); + + NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/); + NazaraSignal(OnLostFocus, const EventHandler* /*eventHandler*/); + NazaraSignal(OnKeyPressed, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/); + NazaraSignal(OnKeyReleased, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/); + NazaraSignal(OnMouseButtonDoubleClicked, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/); + NazaraSignal(OnMouseButtonPressed, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/); + NazaraSignal(OnMouseButtonReleased, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/); + NazaraSignal(OnMouseEntered, const EventHandler* /*eventHandler*/); + NazaraSignal(OnMouseLeft, const EventHandler* /*eventHandler*/); + NazaraSignal(OnMouseMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseMoveEvent& /*event*/); + NazaraSignal(OnMouseWheelMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseWheelEvent& /*event*/); + NazaraSignal(OnMoved, const EventHandler* /*eventHandler*/, const WindowEvent::PositionEvent& /*event*/); + NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/); + NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/); + NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/); + }; +} + +#include + +#endif // NAZARA_EVENTHANDLER_HPP diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl new file mode 100644 index 000000000..4fadf6b43 --- /dev/null +++ b/include/Nazara/Utility/EventHandler.inl @@ -0,0 +1,82 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline EventHandler::EventHandler(const EventHandler&) + { + } + + inline void EventHandler::Dispatch(const WindowEvent& event) + { + switch (event.type) + { + case WindowEventType_GainedFocus: + OnGainedFocus(this); + break; + + case WindowEventType_KeyPressed: + OnKeyPressed(this, event.key); + break; + + case WindowEventType_KeyReleased: + OnKeyReleased(this, event.key); + break; + + case WindowEventType_LostFocus: + OnLostFocus(this); + break; + + case WindowEventType_MouseButtonDoubleClicked: + OnMouseButtonDoubleClicked(this, event.mouseButton); + break; + + case WindowEventType_MouseButtonPressed: + OnMouseButtonPressed(this, event.mouseButton); + break; + + case WindowEventType_MouseButtonReleased: + OnMouseButtonPressed(this, event.mouseButton); + break; + + case WindowEventType_MouseEntered: + OnMouseEntered(this); + break; + + case WindowEventType_MouseLeft: + OnMouseLeft(this); + break; + + case WindowEventType_MouseMoved: + OnMouseMoved(this, event.mouseMove); + break; + + case WindowEventType_MouseWheelMoved: + OnMouseWheelMoved(this, event.mouseWheel); + break; + + case WindowEventType_Moved: + OnMoved(this, event.position); + break; + + case WindowEventType_Quit: + OnQuit(this); + break; + + case WindowEventType_Resized: + OnResized(this, event.size); + break; + + case WindowEventType_TextEntered: + OnTextEntered(this, event.text); + break; + } + } +} + +#include diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index af23be7f1..ba67c17cb 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,9 +52,11 @@ namespace Nz void Destroy(); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable); void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); + EventHandler& GetEventHandler(); WindowHandle GetHandle() const; unsigned int GetHeight() const; Vector2i GetPosition() const; @@ -71,7 +73,9 @@ namespace Nz inline bool IsValid() const; bool IsVisible() const; - bool PollEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") bool PollEvent(WindowEvent* event); + + void ProcessEvents(bool block = false); void SetCursor(WindowCursor cursor); void SetCursor(const Cursor& cursor); @@ -90,7 +94,7 @@ namespace Nz void SetTitle(const String& title); void SetVisible(bool visible); - bool WaitEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")bool WaitEvent(WindowEvent* event); Window& operator=(const Window&) = delete; inline Window& operator=(Window&& window); @@ -114,10 +118,11 @@ namespace Nz ConditionVariable m_eventCondition; Mutex m_eventMutex; Mutex m_eventConditionMutex; - bool m_eventListener; bool m_waitForEvent; #endif + EventHandler m_eventHandler; bool m_closed; + bool m_eventPolling; bool m_ownsWindow; }; } diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index ebf5dfbee..349328e55 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -11,39 +11,24 @@ namespace Nz /*! * \class Nz::Window */ - inline Window::Window() : - #if NAZARA_UTILITY_THREADED_WINDOW m_impl(nullptr), - m_eventListener(true), - m_waitForEvent(false) - #else - m_impl(nullptr) + #if NAZARA_UTILITY_THREADED_WINDOW + m_waitForEvent(false), #endif + m_eventPolling(false) { } inline Window::Window(VideoMode mode, const String& title, UInt32 style) : - #if NAZARA_UTILITY_THREADED_WINDOW - m_impl(nullptr), - m_eventListener(true), - m_waitForEvent(false) - #else - m_impl(nullptr) - #endif + Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); Create(mode, title, style); } inline Window::Window(WindowHandle handle) : - #if NAZARA_UTILITY_THREADED_WINDOW - m_impl(nullptr), - m_eventListener(true), - m_waitForEvent(false) - #else - m_impl(nullptr) - #endif + Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); Create(handle); @@ -59,7 +44,7 @@ namespace Nz m_eventCondition(std::move(window.m_eventCondition)), m_eventMutex(std::move(window.m_eventMutex)), m_eventConditionMutex(std::move(window.m_eventConditionMutex)), - m_eventListener(window.m_eventListener), + m_eventPolling(window.m_eventPolling), m_waitForEvent(window.m_waitForEvent), #endif m_closed(window.m_closed), @@ -78,6 +63,21 @@ namespace Nz m_closed = true; // The window will be closed at the next non-const IsOpen() call } + inline void Window::EnableEventPolling(bool enable) + { + m_eventPolling = enable; + if (!m_eventPolling) + { + while (!m_events.empty()) + m_events.pop(); + } + } + + inline EventHandler& Nz::Window::GetEventHandler() + { + return m_eventHandler; + } + inline bool Window::IsOpen(bool checkClosed) { if (!m_impl) @@ -108,7 +108,11 @@ namespace Nz m_eventMutex.Lock(); #endif - m_events.push(event); + if (m_eventPolling) + m_events.push(event); + + m_eventHandler.Dispatch(event); + if (event.type == WindowEventType_Resized) OnWindowResized(); @@ -132,10 +136,11 @@ namespace Nz { Destroy(); - m_closed = window.m_closed; - m_impl = window.m_impl; - m_events = std::move(window.m_events); - m_ownsWindow = window.m_ownsWindow; + m_closed = window.m_closed; + m_eventPolling = window.m_eventPolling; + m_impl = window.m_impl; + m_events = std::move(window.m_events); + m_ownsWindow = window.m_ownsWindow; window.m_impl = nullptr; @@ -143,7 +148,6 @@ namespace Nz m_eventCondition = std::move(window.m_eventCondition); m_eventMutex = std::move(window.m_eventMutex); m_eventConditionMutex = std::move(window.m_eventConditionMutex); - m_eventListener = window.m_eventListener; m_waitForEvent = window.m_waitForEvent; #endif diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index e246144d2..02ed0f40a 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -325,6 +325,15 @@ namespace Nz return false; } + void Window::ProcessEvents(bool block) + { + NazaraAssert(m_impl, "Window not created"); + + #if !NAZARA_UTILITY_THREADED_WINDOW + m_impl->ProcessEvents(block); + #endif + } + void Window::SetCursor(WindowCursor cursor) { #if NAZARA_UTILITY_SAFE From f16187674c729bc74529d6e88d869ccb14236622 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:09:15 +0200 Subject: [PATCH 190/235] Utility/Window: Window now automatically close on quit event Former-commit-id: 727311111afc6108dc1d2140ea1b4de46158160a [formerly 2d54d14f17deb75d949c63bd1f84b697fd7338ba] [formerly 5567a99268b022010d70c18d28e16d09dde8dd65 [formerly 6db94dce7ebfa5110d0279868ebda4728e20cc95]] Former-commit-id: 864263f18501629c2f5bc50453a41d5a24e8cf2a [formerly f065aa1bebdc2bc3b3eb455f90381b3e990530c2] Former-commit-id: f21791c84c9f024db8e12a6985b22e07d01a0a27 --- include/Nazara/Utility/Window.hpp | 2 ++ include/Nazara/Utility/Window.inl | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index ba67c17cb..b46efd6b9 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -52,6 +52,7 @@ namespace Nz void Destroy(); + inline void EnableCloseOnQuit(bool closeOnQuit); NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable); void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); @@ -122,6 +123,7 @@ namespace Nz #endif EventHandler m_eventHandler; bool m_closed; + bool m_closeOnQuit; bool m_eventPolling; bool m_ownsWindow; }; diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index 349328e55..39c530e24 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -16,6 +16,7 @@ namespace Nz #if NAZARA_UTILITY_THREADED_WINDOW m_waitForEvent(false), #endif + m_closeOnQuit(true), m_eventPolling(false) { } @@ -44,10 +45,11 @@ namespace Nz m_eventCondition(std::move(window.m_eventCondition)), m_eventMutex(std::move(window.m_eventMutex)), m_eventConditionMutex(std::move(window.m_eventConditionMutex)), - m_eventPolling(window.m_eventPolling), m_waitForEvent(window.m_waitForEvent), #endif m_closed(window.m_closed), + m_closeOnQuit(window.m_closeOnQuit), + m_eventPolling(window.m_eventPolling), m_ownsWindow(window.m_ownsWindow) { window.m_impl = nullptr; @@ -63,6 +65,11 @@ namespace Nz m_closed = true; // The window will be closed at the next non-const IsOpen() call } + inline void Window::EnableCloseOnQuit(bool closeOnQuit) + { + m_closeOnQuit = closeOnQuit; + } + inline void Window::EnableEventPolling(bool enable) { m_eventPolling = enable; @@ -116,6 +123,9 @@ namespace Nz if (event.type == WindowEventType_Resized) OnWindowResized(); + if (event.type == WindowEventType_Quit && m_closeOnQuit) + Close(); + #if NAZARA_UTILITY_THREADED_WINDOW m_eventMutex.Unlock(); @@ -137,6 +147,7 @@ namespace Nz Destroy(); m_closed = window.m_closed; + m_closeOnQuit = window.m_closeOnQuit; m_eventPolling = window.m_eventPolling; m_impl = window.m_impl; m_events = std::move(window.m_events); From 07bc00d3198706beba729d8087710596ac0eea4a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:09:40 +0200 Subject: [PATCH 191/235] Network/SocketImpl: Fix compilation for recent MinGW versions Former-commit-id: 51fee7d3e9ec5a596f6fb685c3492b361d624d7d [formerly bd30704cfef75b86250d68c264a654e3e051d912] [formerly 06023deb981e80179580188f5ca40fdae1400749 [formerly 9bc876eb82c92aed1c663b9bd40ebbb19564c6c6]] Former-commit-id: ef78dee1cdee3a55a4d263b0c69ec9fe2ee4a344 [formerly 568c4e6c69febd08057496b12ac3238f5cb80189] Former-commit-id: 544b6476f43a6f3091a1786d20aaf84bb907e8f5 --- src/Nazara/Network/Win32/SocketImpl.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index ab7ba7fe3..f35a4a078 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -8,8 +8,9 @@ #include #include -#ifdef NAZARA_COMPILER_MINGW -// MinGW is lacking Mstcpip.h and that's too bad + +// Some compilers (olders versions of MinGW) are lacking Mstcpip.h which defines the following struct/#define +// Define them ourself for now struct tcp_keepalive { u_long onoff; @@ -18,9 +19,6 @@ struct tcp_keepalive }; #define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) -#else - #include -#endif // NAZARA_COMPILER_MINGW #include From f9b73881174f2be879e9e6b3121e9ca49550f628 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:20:31 +0200 Subject: [PATCH 192/235] Utility/Window: Improve visibility of deprecated methods Former-commit-id: f4958fda41386fa92643d8f9c01c0156d8a20aff [formerly 817600d539699d39236547bb379ed41d800709a7] [formerly 68f1014e6f06349b9fc7e6fd263b7452cbea63b1 [formerly b805752338a28bd6a832979e05b8dd321aac1f21]] Former-commit-id: 9c085fdff76b4cc79bb01a39b0f778c5208862be [formerly efb1b5904b1819f5e230e5899a5faa48d1a04f90] Former-commit-id: 2713d32759a8df3ee3e6e02d8db4167a9e52fa56 --- include/Nazara/Utility/Window.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index b46efd6b9..e544093c5 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -53,7 +53,10 @@ namespace Nz void Destroy(); inline void EnableCloseOnQuit(bool closeOnQuit); - NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable); + + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") + inline void EnableEventPolling(bool enable); + void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); @@ -74,7 +77,8 @@ namespace Nz inline bool IsValid() const; bool IsVisible() const; - NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") bool PollEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") + bool PollEvent(WindowEvent* event); void ProcessEvents(bool block = false); @@ -95,7 +99,8 @@ namespace Nz void SetTitle(const String& title); void SetVisible(bool visible); - NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")bool WaitEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") + bool WaitEvent(WindowEvent* event); Window& operator=(const Window&) = delete; inline Window& operator=(Window&& window); From 64db72e411940cb97c8942ef47a928290b916014 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:22:47 +0200 Subject: [PATCH 193/235] Example/FirstScene: Fix event handling Former-commit-id: 89a72412977ea333a3155b00fa3cb111f4a42e4a [formerly bfa9281f48267e6ae349966762659dcdcf5ba796] [formerly 3d3094abcd7528948700ca1308339fb1cc898f1e [formerly 73ffc05cf55efac076b24bc3077c7c7fbbc239ad]] Former-commit-id: b684eb3a14a7b0527ff7597958eae8784bff3151 [formerly c452a9edde7b5b26002dc0014c0e0ef10111114d] Former-commit-id: d30dda921cdfa3c8435b4f24090efeaf76e44d09 --- examples/FirstScene/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 07e26cd1c..0a471acee 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -329,6 +329,8 @@ int main() lua.PushGlobal("Spaceship", spaceship->CreateHandle()); lua.PushGlobal("World", world->CreateHandle()); + window.EnableEventPolling(true); // Déprécié + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) while (application.Run()) { From 2093b0173de533d93b6a3948816d10a54e59ad7a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:02:07 +0200 Subject: [PATCH 194/235] Utility/EventHandler: Add OnEvent signal Former-commit-id: cbbd3b12bd39eb5864d36b4e65170537dd3ca556 [formerly 80427bae4f2fef2233e41b85deaeba918e255093] [formerly 214fdf978a17f2d0aaa322f5d2258dbc8e7e2165 [formerly 141936940313f2f7ab16ab40e9ef0b02d3774b35]] Former-commit-id: 16629755c17ea100d6baacf9ebf8ebf34d8010a6 [formerly 26d4be9f6128fa9eb1546f7b57cada10b7c2a0f1] Former-commit-id: 019fbb16bcc12f9bd9644eb14aa8a4743618746e --- include/Nazara/Utility/EventHandler.hpp | 3 ++- include/Nazara/Utility/EventHandler.inl | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp index b35ef96cf..2464d5e72 100644 --- a/include/Nazara/Utility/EventHandler.hpp +++ b/include/Nazara/Utility/EventHandler.hpp @@ -18,12 +18,13 @@ namespace Nz { public: EventHandler() = default; - EventHandler(const EventHandler&); + explicit EventHandler(const EventHandler&); EventHandler(EventHandler&&) = default; ~EventHandler() = default; inline void Dispatch(const WindowEvent& event); + NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/); NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/); NazaraSignal(OnLostFocus, const EventHandler* /*eventHandler*/); NazaraSignal(OnKeyPressed, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/); diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl index 4fadf6b43..c066b6810 100644 --- a/include/Nazara/Utility/EventHandler.inl +++ b/include/Nazara/Utility/EventHandler.inl @@ -14,6 +14,8 @@ namespace Nz inline void EventHandler::Dispatch(const WindowEvent& event) { + OnEvent(this, event); + switch (event.type) { case WindowEventType_GainedFocus: From b2d1055c596953a96e95f547b4e92390aef1a91e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:10:09 +0200 Subject: [PATCH 195/235] Sdk/Application: Add Console and FPSCounter overlays This allows any Nazara-powered application to enable a ready-to-use console or a working FPS counter Former-commit-id: 87845d0983bb2a72255845b5f83a447a2f7c7c2f [formerly 964c60603b8a6c54e0171b648b9a271fb5af993f] [formerly 3018a4286e2e27cd0ede008c1fe6ecde3441253d [formerly a6b82b63dbfb62d537b626bfd46f5cfe6c946b07]] Former-commit-id: 1d602cad3381dba43ddb236a991b7653e713ae68 [formerly 581b57b5a5f533415163302391612f88bc22fbf3] Former-commit-id: f1a7ef57cd4dd648a5da708133dba875821278e5 --- SDK/include/NDK/Application.hpp | 76 +++++++++++- SDK/include/NDK/Application.inl | 199 ++++++++++++++++++++++++++++++-- SDK/src/NDK/Application.cpp | 132 ++++++++++++++++++++- SDK/src/NDK/LuaBinding_SDK.cpp | 7 ++ examples/FirstScene/main.cpp | 129 ++++----------------- 5 files changed, 423 insertions(+), 120 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 6a375776c..5eca90961 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -8,18 +8,34 @@ #define NDK_APPLICATION_HPP #include +#include #include #include -#include #include +#include #include +#ifndef NDK_SERVER +#include +#include +#include +#include +#include +#include +#endif + namespace Ndk { class NDK_API Application { public: + #ifndef NDK_SERVER + struct ConsoleOverlay; + struct FPSCounterOverlay; + #endif + inline Application(); + inline Application(int argc, const char* argv[]); Application(const Application&) = delete; Application(Application&&) = delete; inline ~Application(); @@ -29,8 +45,21 @@ namespace Ndk #endif template World& AddWorld(Args&&... args); + #ifndef NDK_SERVER + inline void EnableConsole(bool enable); + inline void EnableFPSCounter(bool enable); + + inline ConsoleOverlay& GetConsoleOverlay(std::size_t windowIndex = 0U); + inline FPSCounterOverlay& GetFPSCounterOverlay(std::size_t windowIndex = 0U); + #endif + inline float GetUpdateTime() const; + #ifndef NDK_SERVER + inline bool IsConsoleEnabled() const; + inline bool IsFPSCounterEnabled() const; + #endif + bool Run(); #ifndef NDK_SERVER @@ -44,13 +73,56 @@ namespace Ndk inline static Application* Instance(); + #ifndef NDK_SERVER + struct ConsoleOverlay + { + std::unique_ptr console; + Nz::LuaInstance lua; + + NazaraSlot(Nz::EventHandler, OnEvent, eventSlot); + NazaraSlot(Nz::EventHandler, OnKeyPressed, keyPressedSlot); + NazaraSlot(Nz::EventHandler, OnResized, resizedSlot); + NazaraSlot(Nz::Log, OnLogWrite, logSlot); + }; + + struct FPSCounterOverlay + { + Nz::TextSpriteRef sprite; + EntityOwner entity; + float elapsedTime = 0.f; + unsigned int frameCount = 0; + }; + #endif + private: #ifndef NDK_SERVER - std::vector> m_windows; + enum OverlayFlags + { + OverlayFlags_Console = 0x1, + OverlayFlags_FPSCounter = 0x2 + }; + + struct WindowInfo + { + inline WindowInfo(std::unique_ptr&& window); + + Nz::RenderTarget* renderTarget; + std::unique_ptr window; + std::unique_ptr console; + std::unique_ptr fpsCounter; + std::unique_ptr overlayWorld; + }; + + void SetupConsole(WindowInfo& info); + void SetupFPSCounter(WindowInfo& info); + void SetupOverlay(WindowInfo& info); + + std::vector m_windows; #endif std::list m_worlds; Nz::Clock m_updateClock; #ifndef NDK_SERVER + Nz::UInt32 m_overlayFlags; bool m_exitOnClosedWindows; #endif bool m_shouldQuit; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 0d21d1b94..19013c778 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include #include @@ -9,13 +10,15 @@ namespace Ndk { /*! - * \brief Constructs an Application object by default + * \brief Constructs an Application object without passing command-line arguments * - * \remark Produces a NazaraAssert if there's more than one application instance currently running + * This calls Sdk::Initialize() + * + * \remark Only one Application instance can exist at a time */ - inline Application::Application() : #ifndef NDK_SERVER + m_overlayFlags(0U), m_exitOnClosedWindows(true), #endif m_shouldQuit(false), @@ -31,9 +34,26 @@ namespace Ndk } /*! - * \brief Destructs the object + * \brief Constructs an Application object with command-line arguments + * + * Pass the argc and argv arguments from the main function. + * + * Command-line arguments can be retrieved by application methods + * + * This calls Sdk::Initialize() + * + * \remark Only one Application instance can exist at a time */ + inline Application::Application(int argc, const char* argv[]) : + Application() + { + } + /*! + * \brief Destructs the application object + * + * This destroy all worlds and windows and then calls Sdk::Uninitialize + */ inline Application::~Application() { m_worlds.clear(); @@ -61,8 +81,28 @@ namespace Ndk { static_assert(std::is_base_of::value, "Type must inherit Window"); - m_windows.emplace_back(new T(std::forward(args)...)); - return static_cast(*m_windows.back().get()); + m_windows.emplace_back(std::make_unique(std::forward(args)...)); + WindowInfo& info = m_windows.back(); + + T& window = static_cast(*info.window.get()); //< Warning: ugly + + if (std::is_base_of()) + { + info.renderTarget = &window; + + if (m_overlayFlags) + { + SetupOverlay(info); + + if (m_overlayFlags & OverlayFlags_Console) + SetupConsole(info); + + if (m_overlayFlags & OverlayFlags_FPSCounter) + SetupFPSCounter(info); + } + } + + return window; } #endif @@ -80,22 +120,159 @@ namespace Ndk return m_worlds.back(); } + /*! + * \brief Enable/disable debug console + * + * \param enable Should the console overlay be enabled + */ + inline void Application::EnableConsole(bool enable) + { + if (enable != ((m_overlayFlags & OverlayFlags_Console) != 0)) + { + if (enable) + { + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + SetupOverlay(info); + } + + for (WindowInfo& info : m_windows) + SetupConsole(info); + + m_overlayFlags |= OverlayFlags_Console; + + } + else + { + for (WindowInfo& info : m_windows) + info.console.reset(); + + m_overlayFlags &= ~OverlayFlags_Console; + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + info.overlayWorld.reset(); + } + } + } + } + + /*! + * \brief Enable/disable debug FPS counter + * + * \param enable Should the FPS counter be displayed + */ + inline void Application::EnableFPSCounter(bool enable) + { + if (enable != ((m_overlayFlags & OverlayFlags_FPSCounter) != 0)) + { + if (enable) + { + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + SetupOverlay(info); + } + + for (WindowInfo& info : m_windows) + SetupFPSCounter(info); + + m_overlayFlags |= OverlayFlags_FPSCounter; + + } + else + { + for (WindowInfo& info : m_windows) + info.fpsCounter.reset(); + + m_overlayFlags &= ~OverlayFlags_FPSCounter; + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + info.overlayWorld.reset(); + } + } + } + } + + /*! + * \brief Gets the console overlay for a specific window + * + * \param windowIndex Index of the window to get + * + * \remark The console overlay must be enabled + * + * \return A reference to the console overlay of the window + * + * \see IsConsoleOverlayEnabled + */ + inline Application::ConsoleOverlay& Application::GetConsoleOverlay(std::size_t windowIndex) + { + NazaraAssert(m_overlayFlags & OverlayFlags_Console, "Console overlay is not enabled"); + NazaraAssert(windowIndex <= m_windows.size(), "Window index is out of range"); + + return *m_windows[windowIndex].console; + } + + /*! + * \brief Gets the console overlay for a specific window + * + * \param windowIndex Index of the window to get + * + * \remark The console overlay must be enabled + * + * \return A reference to the console overlay of the window + * + * \see IsFPSCounterEnabled + */ + inline Application::FPSCounterOverlay& Application::GetFPSCounterOverlay(std::size_t windowIndex) + { + NazaraAssert(m_overlayFlags & OverlayFlags_FPSCounter, "FPS counter overlay is not enabled"); + NazaraAssert(windowIndex <= m_windows.size(), "Window index is out of range"); + + return *m_windows[windowIndex].fpsCounter; + } + /*! * \brief Gets the update time of the application * \return Update rate */ - inline float Application::GetUpdateTime() const { return m_updateTime; } + /*! + * \brief Checks if the console overlay is enabled + * + * \remark This has nothing to do with the visibility state of the console + * + * \return True if the console overlay is enabled + * + * \see GetConsoleOverlay + */ + inline bool Application::IsConsoleEnabled() const + { + return (m_overlayFlags & OverlayFlags_Console) != 0; + } + + /*! + * \brief Checks if the FPS counter overlay is enabled + * \return True if the FPS counter overlay is enabled + * + * \see GetFPSCounterOverlay + */ + inline bool Application::IsFPSCounterEnabled() const + { + return (m_overlayFlags & OverlayFlags_FPSCounter) != 0; + } + /*! * \brief Makes the application exit when there's no more open window * * \param exitOnClosedWindows Should exit be called when no more window is open */ - #ifndef NDK_SERVER inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows) { @@ -121,4 +298,10 @@ namespace Ndk { return s_application; } + + inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : + window(std::move(window)), + renderTarget(nullptr) + { + } } diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 63e834bd0..c4492eb0f 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -4,6 +4,15 @@ #include +#ifndef NDK_SERVER +#include +#include +#include +#include +#include +#include +#endif + namespace Ndk { /*! @@ -15,7 +24,6 @@ namespace Ndk /*! * \brief Runs the application by updating worlds, taking care about windows, ... */ - bool Application::Run() { #ifndef NDK_SERVER @@ -24,7 +32,7 @@ namespace Ndk auto it = m_windows.begin(); while (it != m_windows.end()) { - Nz::Window& window = **it; + Nz::Window& window = *it->window; window.ProcessEvents(); @@ -54,8 +62,128 @@ namespace Ndk for (World& world : m_worlds) world.Update(m_updateTime); + #ifndef NDK_SERVER + for (WindowInfo& info : m_windows) + { + if (info.fpsCounter) + { + FPSCounterOverlay& fpsCounter = *info.fpsCounter; + + fpsCounter.frameCount++; + + fpsCounter.elapsedTime += m_updateTime; + if (fpsCounter.elapsedTime >= 1.f) + { + fpsCounter.sprite->Update(Nz::SimpleTextDrawer::Draw("FPS: " + Nz::String::Number(fpsCounter.frameCount), 36)); + fpsCounter.frameCount = 0; + fpsCounter.elapsedTime = 0.f; + } + } + + info.overlayWorld->Update(m_updateTime); + } + #endif + return true; } + void Application::SetupConsole(WindowInfo& info) + { + std::unique_ptr overlay = std::make_unique(); + + overlay->console = std::make_unique(*info.overlayWorld, Nz::Vector2f(Nz::Vector2ui(info.window->GetWidth(), info.window->GetHeight() / 4)), overlay->lua); + + Console& consoleRef = *overlay->console; + // Redirect logs toward the console + overlay->logSlot.Connect(Nz::Log::OnLogWrite, [&consoleRef] (const Nz::String& str) + { + consoleRef.AddLine(str); + }); + + LuaAPI::RegisterClasses(overlay->lua); + + // Override "print" function to add a line in the console + overlay->lua.PushFunction([&consoleRef] (Nz::LuaInstance& instance) + { + Nz::StringStream stream; + + unsigned int argCount = instance.GetStackTop(); + instance.GetGlobal("tostring"); + for (unsigned int i = 1; i <= argCount; ++i) + { + instance.PushValue(-1); // tostring function + instance.PushValue(i); // argument + instance.Call(1, 1); + + std::size_t length; + const char* str = instance.CheckString(-1, &length); + if (i > 1) + stream << '\t'; + + stream << Nz::String(str, length); + instance.Pop(1); + } + + consoleRef.AddLine(stream); + return 0; + }); + overlay->lua.SetGlobal("print"); + + // Define a few base variables to allow our interface to interact with the application + overlay->lua.PushGlobal("Application", Ndk::Application::Instance()); + overlay->lua.PushGlobal("Console", consoleRef.CreateHandle()); + + // Setup a few event callback to handle the console + Nz::EventHandler& eventHandler = info.window->GetEventHandler(); + + overlay->eventSlot.Connect(eventHandler.OnEvent, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent& event) + { + if (consoleRef.IsVisible()) + consoleRef.SendEvent(event); + }); + + overlay->keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& event) + { + if (event.code == Nz::Keyboard::F9) + consoleRef.Show(!consoleRef.IsVisible()); + }); + + overlay->resizedSlot.Connect(eventHandler.OnResized, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::SizeEvent& event) + { + consoleRef.SetSize({float(event.width), event.height / 4.f}); + }); + + info.console = std::move(overlay); + } + + void Application::SetupFPSCounter(WindowInfo& info) + { + std::unique_ptr fpsCounter = std::make_unique(); + fpsCounter->sprite = Nz::TextSprite::New(); + + fpsCounter->entity = info.overlayWorld->CreateEntity(); + fpsCounter->entity->AddComponent(); + fpsCounter->entity->AddComponent().Attach(fpsCounter->sprite); + + info.fpsCounter = std::move(fpsCounter); + } + + void Application::SetupOverlay(WindowInfo& info) + { + info.overlayWorld = std::make_unique(false); //< No default system + + RenderSystem& renderSystem = info.overlayWorld->AddSystem(); + renderSystem.ChangeRenderTechnique(); + renderSystem.SetDefaultBackground(nullptr); + renderSystem.SetGlobalUp(Nz::Vector3f::Down()); + + EntityHandle viewer = info.overlayWorld->CreateEntity(); + CameraComponent& camComponent = viewer->AddComponent(); + viewer->AddComponent(); + + camComponent.SetProjectionType(Nz::ProjectionType_Orthogonal); + camComponent.SetTarget(info.renderTarget); + } + Application* Application::s_application = nullptr; } \ No newline at end of file diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index bf66cbf00..35c59ae68 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -17,7 +17,14 @@ namespace Ndk #ifndef NDK_SERVER //application.SetMethod("AddWindow", &Application::AddWindow); + + application.BindMethod("EnableConsole", &Application::EnableConsole); + application.BindMethod("EnableFPSCounter", &Application::EnableFPSCounter); + + application.BindMethod("IsConsoleEnabled", &Application::IsConsoleEnabled); + application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled); #endif + application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application) -> int { instance.Push(application->AddWorld().CreateHandle()); diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 0a471acee..b1e7e2a64 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -256,81 +256,19 @@ int main() // On lie la caméra à la fenêtre cameraComp.SetTarget(&window); - // Et on créé deux horloges pour gérer le temps - Nz::Clock secondClock, updateClock; + // Et on créé une horloge pour gérer le temps + Nz::Clock updateClock; Nz::UInt64 updateAccumulator = 0; - // Ainsi qu'un compteur de FPS improvisé - unsigned int fps = 0; - // Quelques variables de plus pour notre caméra bool smoothMovement = true; Nz::Vector3f targetPos = cameraNode.GetPosition(); - // Pour ajouter une console à notre application, nous avons besoin d'un monde 2D pour gérer ces rendus - Ndk::WorldHandle world2D = application.AddWorld().CreateHandle(); - world2D->GetSystem().SetDefaultBackground(nullptr); - world2D->GetSystem().SetGlobalUp(Nz::Vector3f::Down()); - - // Nous ajoutons une caméra comme précédement - Ndk::EntityHandle viewEntity = world2D->CreateEntity(); - viewEntity->AddComponent(); - - // À la différence que celui-ci effectuera une projection orthogonale - Ndk::CameraComponent& viewer = viewEntity->AddComponent(); - viewer.SetTarget(&window); - viewer.SetProjectionType(Nz::ProjectionType_Orthogonal); - - // Nous créons un environnement Lua pour gérer nos scripts - Nz::LuaInstance lua; - - // Faisons en sorte d'enregistrer les classes du moteur dans cet environnement - Ndk::LuaAPI::RegisterClasses(lua); - - // Ensuite nous créons la console en elle-même - Ndk::Console console(*world2D, Nz::Vector2f(window.GetWidth(), window.GetHeight() / 4), lua); - - // Nous redirigeons les logs vers cette console - Nz::Log::OnLogWriteType::ConnectionGuard logGuard = Nz::Log::OnLogWrite.Connect([&console] (const Nz::String& str) - { - console.AddLine(str); - }); - - // Nous réécrivons la fonction "print" du Lua pour la rediriger vers la console - lua.PushFunction([&console] (Nz::LuaInstance& instance) - { - Nz::StringStream stream; - - unsigned int argCount = instance.GetStackTop(); - instance.GetGlobal("tostring"); - for (unsigned int i = 1; i <= argCount; ++i) - { - instance.PushValue(-1); // ToString - instance.PushValue(i); // Arg - instance.Call(1, 1); - - std::size_t length; - const char* str = instance.CheckString(-1, &length); - if (i > 1) - stream << '\t'; - - stream << Nz::String(str, length); - instance.Pop(1); - } - - console.AddLine(stream); - return 0; - }); - lua.SetGlobal("print"); - - // Définissons quelques variables de base - lua.PushGlobal("Application", Ndk::Application::Instance()); - lua.PushGlobal("Console", console.CreateHandle()); - lua.PushGlobal("Spaceship", spaceship->CreateHandle()); - lua.PushGlobal("World", world->CreateHandle()); - window.EnableEventPolling(true); // Déprécié + application.EnableConsole(true); + application.EnableFPSCounter(true); + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) while (application.Run()) { @@ -342,8 +280,12 @@ int main() { case Nz::WindowEventType_MouseMoved: // La souris a bougé { - if (console.IsVisible()) - break; + if (application.IsConsoleEnabled()) + { + Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay(); + if (consoleOverlay.console->IsVisible()) + break; + } // Gestion de la caméra free-fly (Rotation) float sensitivity = 0.3f; // Sensibilité de la souris @@ -368,9 +310,6 @@ int main() break; case Nz::WindowEventType_KeyPressed: // Une touche a été pressée ! - if (console.IsVisible()) - console.SendEvent(event); - if (event.key.code == Nz::Keyboard::Key::Escape) window.Close(); else if (event.key.code == Nz::Keyboard::F1) @@ -383,19 +322,6 @@ int main() else smoothMovement = true; } - else if (event.key.code == Nz::Keyboard::F9) - console.Show(!console.IsVisible()); - break; - - case Nz::WindowEventType_TextEntered: - { - if (console.IsVisible()) - console.SendCharacter(event.text.character); - break; - } - - case Nz::WindowEventType_Resized: - console.SetSize({float(event.size.width), event.size.height / 4.f}); break; default: @@ -419,7 +345,16 @@ int main() // Vitesse de déplacement de la caméra float cameraSpeed = 3.f * elapsedTime; // Trois mètres par seconde - if (!console.IsVisible()) + bool move = true; + + if (application.IsConsoleEnabled()) + { + Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay(); + if (consoleOverlay.console->IsVisible()) + move = false; + } + + if (move) { // Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space)) @@ -460,28 +395,6 @@ int main() // Après avoir dessiné sur la fenêtre, il faut s'assurer qu'elle affiche cela // Cet appel ne fait rien d'autre qu'échanger les buffers de rendu (Double Buffering) window.Display(); - - // On incrémente le compteur de FPS improvisé - fps++; - - if (secondClock.GetMilliseconds() >= 1000) // Toutes les secondes - { - // Et on insère ces données dans le titre de la fenêtre - window.SetTitle(windowTitle + " - " + Nz::String::Number(fps) + " FPS"); - - /* - Note: En C++11 il est possible d'insérer de l'Unicode de façon standard, quel que soit l'encodage du fichier, - via quelque chose de similaire à u8"Cha\u00CEne de caract\u00E8res". - Cependant, si le code source est encodé en UTF-8 (Comme c'est le cas dans ce fichier), - cela fonctionnera aussi comme ceci : "Chaîne de caractères". - */ - - // Et on réinitialise le compteur de FPS - fps = 0; - - // Et on relance l'horloge pour refaire ça dans une seconde - secondClock.Restart(); - } } return EXIT_SUCCESS; From d3bbb5ad0ec7fe1d2e0d788e9d1c82ed79a742c9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:16:35 +0200 Subject: [PATCH 196/235] SdkServer: Fix compilation Former-commit-id: a8e8b1dd6f0bd802bb24ac84e051cccad9cc1881 [formerly b8ad8f0ee7a608cbf73b9da5861cd82a88aff874] [formerly edb70d0a9816e68a7b2cf5879000bd15f828cedc [formerly 8b34081fe01f07cbbe2b9949537b0bbd99b44c4b]] Former-commit-id: 48ca3e2769468218c5f6b2683800a184dbf534bc [formerly 372eeb7d1ed17d6dd63d81bf0e7e4f52e30746c0] Former-commit-id: b138abe876b0e6e9f4394fe90cb0b8de2d0e31d6 --- SDK/include/NDK/Application.inl | 15 ++++++++++++++- SDK/src/NDK/Application.cpp | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 19013c778..d7e0325d9 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -74,7 +74,6 @@ namespace Ndk * * \param args Arguments used to create the window */ - #ifndef NDK_SERVER template T& Application::AddWindow(Args&&... args) @@ -125,6 +124,7 @@ namespace Ndk * * \param enable Should the console overlay be enabled */ + #ifndef NDK_SERVER inline void Application::EnableConsole(bool enable) { if (enable != ((m_overlayFlags & OverlayFlags_Console) != 0)) @@ -157,12 +157,14 @@ namespace Ndk } } } + #endif /*! * \brief Enable/disable debug FPS counter * * \param enable Should the FPS counter be displayed */ + #ifndef NDK_SERVER inline void Application::EnableFPSCounter(bool enable) { if (enable != ((m_overlayFlags & OverlayFlags_FPSCounter) != 0)) @@ -195,6 +197,7 @@ namespace Ndk } } } + #endif /*! * \brief Gets the console overlay for a specific window @@ -207,6 +210,7 @@ namespace Ndk * * \see IsConsoleOverlayEnabled */ + #ifndef NDK_SERVER inline Application::ConsoleOverlay& Application::GetConsoleOverlay(std::size_t windowIndex) { NazaraAssert(m_overlayFlags & OverlayFlags_Console, "Console overlay is not enabled"); @@ -214,6 +218,7 @@ namespace Ndk return *m_windows[windowIndex].console; } + #endif /*! * \brief Gets the console overlay for a specific window @@ -226,6 +231,7 @@ namespace Ndk * * \see IsFPSCounterEnabled */ + #ifndef NDK_SERVER inline Application::FPSCounterOverlay& Application::GetFPSCounterOverlay(std::size_t windowIndex) { NazaraAssert(m_overlayFlags & OverlayFlags_FPSCounter, "FPS counter overlay is not enabled"); @@ -233,6 +239,7 @@ namespace Ndk return *m_windows[windowIndex].fpsCounter; } + #endif /*! * \brief Gets the update time of the application @@ -252,10 +259,12 @@ namespace Ndk * * \see GetConsoleOverlay */ + #ifndef NDK_SERVER inline bool Application::IsConsoleEnabled() const { return (m_overlayFlags & OverlayFlags_Console) != 0; } + #endif /*! * \brief Checks if the FPS counter overlay is enabled @@ -263,10 +272,12 @@ namespace Ndk * * \see GetFPSCounterOverlay */ + #ifndef NDK_SERVER inline bool Application::IsFPSCounterEnabled() const { return (m_overlayFlags & OverlayFlags_FPSCounter) != 0; } + #endif /*! * \brief Makes the application exit when there's no more open window @@ -299,9 +310,11 @@ namespace Ndk return s_application; } + #ifndef NDK_SERVER inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : window(std::move(window)), renderTarget(nullptr) { } + #endif } diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index c4492eb0f..bce62093a 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -87,6 +87,7 @@ namespace Ndk return true; } + #ifndef NDK_SERVER void Application::SetupConsole(WindowInfo& info) { std::unique_ptr overlay = std::make_unique(); @@ -184,6 +185,7 @@ namespace Ndk camComponent.SetProjectionType(Nz::ProjectionType_Orthogonal); camComponent.SetTarget(info.renderTarget); } + #endif Application* Application::s_application = nullptr; } \ No newline at end of file From 5639422e076613a33b9de1b66dfee0f7fcbd4359 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:26:35 +0200 Subject: [PATCH 197/235] Example/FirstScene: Setup Spaceship and World lua variables Former-commit-id: 7f093d97c1dc0745adf24cdb18a5158655f60731 [formerly a02df9014928696f8ccbdc227fc21a0284bd8f09] [formerly 289a9528be967e1c2da499a5bf4561953e2ac419 [formerly 788d4ddfd4cb8aa135f4437b1792fd061beed5fd]] Former-commit-id: a988435b3336fbc459d6403d7cb5576f6c21a338 [formerly 76549542dfd1f801a7942f36352f7791f76ebf1b] Former-commit-id: 7defd9313e4ac9b782849153a850fadae1774624 --- examples/FirstScene/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index b1e7e2a64..e7c5b2c90 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -269,6 +269,10 @@ int main() application.EnableConsole(true); application.EnableFPSCounter(true); + Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay(); + consoleOverlay.lua.PushGlobal("Spaceship", spaceship->CreateHandle()); + consoleOverlay.lua.PushGlobal("World", world->CreateHandle()); + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) while (application.Run()) { From a3e9a303b6804fc2aaff5cf103fed59031a651df Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 19:03:43 +0200 Subject: [PATCH 198/235] Lua/LuaInstance: Add move constructor/operator Former-commit-id: 269dae9bec070b32c13ccfe206a9952ce4fe72d4 [formerly 0e7d285bfa29137724f395c2fcdfa3b9b34f47ba] [formerly 7301944fc18b0fb00c731c35a395359a12250aa5 [formerly 580622587a38bf7d14b215061c0371997bb22dc1]] Former-commit-id: 1af27d8ee779851974cb5a6b5e9ebbd18df56afb [formerly dae4bd81771043dea92460a6431550dec214949d] Former-commit-id: 0722749673de04fd3c9f3bafd7287fa82ef01b94 --- include/Nazara/Lua/LuaInstance.hpp | 4 ++-- include/Nazara/Lua/LuaInstance.inl | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 9affe6f87..e3bc517f8 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -31,7 +31,7 @@ namespace Nz public: LuaInstance(); LuaInstance(const LuaInstance&) = delete; - LuaInstance(LuaInstance&&) = delete; ///TODO + inline LuaInstance(LuaInstance&& instance) noexcept; ~LuaInstance(); void ArgCheck(bool condition, unsigned int argNum, const char* error); @@ -172,7 +172,7 @@ namespace Nz void* ToUserdata(int index, const String& tname) const; LuaInstance& operator=(const LuaInstance&) = delete; - LuaInstance& operator=(LuaInstance&&) = delete; ///TODO + inline LuaInstance& operator=(LuaInstance&& instance) noexcept; static int GetIndexOfUpValue(int upValue); static LuaInstance* GetInstance(lua_State* state); diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index 24d4fcf34..f9f5e662f 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -13,6 +13,33 @@ namespace Nz { + inline LuaInstance::LuaInstance(LuaInstance&& instance) noexcept : + m_memoryLimit(instance.m_memoryLimit), + m_memoryUsage(instance.m_memoryUsage), + m_timeLimit(m_timeLimit), + m_clock(std::move(m_clock)), + m_lastError(std::move(m_lastError)), + m_state(m_state), + m_level(m_level) + { + instance.m_state = nullptr; + } + + inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept + { + m_clock = std::move(m_clock); + m_lastError = std::move(m_lastError); + m_level = m_level; + m_memoryLimit = instance.m_memoryLimit; + m_memoryUsage = instance.m_memoryUsage; + m_state = m_state; + m_timeLimit = m_timeLimit; + + instance.m_state = nullptr; + + return *this; + } + // Functions args inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag) { From ab69578e724a3fafcf186ca1b4a0c98bd276776d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 19:53:38 +0200 Subject: [PATCH 199/235] Sdk/Application: Fix AddWindow Former-commit-id: 8ba1293663fe64f767043ec9b3d92b870cf9878d [formerly 07a62d5cc914005a8815ca3368d30e52f91ca7c7] [formerly cc643f08cfaa9c437c1583a6a364fe933fef14d4 [formerly f672cabe9b31d72381d086476106e210a509debb]] Former-commit-id: 89ae61c98b8c74acbdbae64f7c2143c399e97075 [formerly b9596061ae9a3f92a2ad8760b51f031aa5f7bf50] Former-commit-id: 465fbf70964ef0add7bdcb7ca976026be430d025 --- SDK/include/NDK/Application.hpp | 3 +++ SDK/include/NDK/Application.inl | 48 +++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 5eca90961..7f4af6679 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -117,6 +117,9 @@ namespace Ndk void SetupFPSCounter(WindowInfo& info); void SetupOverlay(WindowInfo& info); + template void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/); + template void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/); + std::vector m_windows; #endif std::list m_worlds; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index d7e0325d9..a36ee3a13 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -85,21 +85,7 @@ namespace Ndk T& window = static_cast(*info.window.get()); //< Warning: ugly - if (std::is_base_of()) - { - info.renderTarget = &window; - - if (m_overlayFlags) - { - SetupOverlay(info); - - if (m_overlayFlags & OverlayFlags_Console) - SetupConsole(info); - - if (m_overlayFlags & OverlayFlags_FPSCounter) - SetupFPSCounter(info); - } - } + SetupWindow(info, &window, std::is_base_of()); return window; } @@ -138,7 +124,10 @@ namespace Ndk } for (WindowInfo& info : m_windows) - SetupConsole(info); + { + if (info.renderTarget) + SetupConsole(info); + } m_overlayFlags |= OverlayFlags_Console; @@ -178,7 +167,10 @@ namespace Ndk } for (WindowInfo& info : m_windows) - SetupFPSCounter(info); + { + if (info.renderTarget) + SetupFPSCounter(info); + } m_overlayFlags |= OverlayFlags_FPSCounter; @@ -310,6 +302,28 @@ namespace Ndk return s_application; } + template + inline void Application::SetupWindow(WindowInfo& info, T* renderTarget, std::true_type) + { + info.renderTarget = renderTarget; + + if (m_overlayFlags) + { + SetupOverlay(info); + + if (m_overlayFlags & OverlayFlags_Console) + SetupConsole(info); + + if (m_overlayFlags & OverlayFlags_FPSCounter) + SetupFPSCounter(info); + } + } + + template + inline void Application::SetupWindow(WindowInfo&, T*, std::false_type) + { + } + #ifndef NDK_SERVER inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : window(std::move(window)), From 517b2bbaaf98f8c234647e5fa2702036af34aae9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 21:47:29 +0200 Subject: [PATCH 200/235] Sdk/Application: Add command-line arguments handling Former-commit-id: 40feef03dfa4e0537490689cc1af8f68131007c7 [formerly ea93fa9625bce277d27cb1747ee34ee884fdfc28] [formerly 721b1b3400e2e6aed984b37f61cd54986e5c0e2e [formerly 50614ac42a3d1a2564e4c38d9c7c0675e44b2fb8]] Former-commit-id: d64cc60dbd82cffc23e081f270d0e173b9e2a6a5 [formerly a9ff7af1ab1ebbd1687d120a8e8e036e6c6926b5] Former-commit-id: 45f34e16b8d6a91d407df30c36e598ff3270e50f --- SDK/include/NDK/Application.hpp | 11 ++++- SDK/include/NDK/Application.inl | 80 ++++++++++++++++++++++++++------- SDK/src/NDK/Application.cpp | 49 ++++++++++++++++++++ examples/Tut00/main.cpp | 16 +++---- examples/Tut01/main.cpp | 4 +- 5 files changed, 132 insertions(+), 28 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 7f4af6679..84b331e95 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,7 @@ namespace Ndk #endif inline Application(); - inline Application(int argc, const char* argv[]); + Application(int argc, char* argv[]); Application(const Application&) = delete; Application(Application&&) = delete; inline ~Application(); @@ -53,8 +54,14 @@ namespace Ndk inline FPSCounterOverlay& GetFPSCounterOverlay(std::size_t windowIndex = 0U); #endif + inline const std::set& GetOptions() const; + inline const std::map& GetParameters() const; + inline float GetUpdateTime() const; + inline bool HasOption(const Nz::String& option) const; + inline bool HasParameter(const Nz::String& key, Nz::String* value) const; + #ifndef NDK_SERVER inline bool IsConsoleEnabled() const; inline bool IsFPSCounterEnabled() const; @@ -120,6 +127,8 @@ namespace Ndk template void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/); template void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/); + std::map m_parameters; + std::set m_options; std::vector m_windows; #endif std::list m_worlds; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index a36ee3a13..7701160c5 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -33,22 +33,6 @@ namespace Ndk Sdk::Initialize(); } - /*! - * \brief Constructs an Application object with command-line arguments - * - * Pass the argc and argv arguments from the main function. - * - * Command-line arguments can be retrieved by application methods - * - * This calls Sdk::Initialize() - * - * \remark Only one Application instance can exist at a time - */ - inline Application::Application(int argc, const char* argv[]) : - Application() - { - } - /*! * \brief Destructs the application object * @@ -233,6 +217,30 @@ namespace Ndk } #endif + /*! + * \brief Gets the options used to start the application + * + * Options are defined as "-optionName" in command-line and are always lower-case + * + * \return Command-line options + */ + inline const std::set& Application::GetOptions() const + { + return m_options; + } + + /*! + * \brief Gets the parameters used to start the application + * + * Parameters are defined as "-key=value" in command-line, their key is lower-case but value capitals are kept. + * + * \return Command-line parameters + */ + inline const std::map& Application::GetParameters() const + { + return m_parameters; + } + /*! * \brief Gets the update time of the application * \return Update rate @@ -242,6 +250,46 @@ namespace Ndk return m_updateTime; } + /*! + * \brief Query for a command-line option + * + * \param option Option name + * + * \remark option must be lower-case + * + * \return True if option is present + * + * \see GetOptions + */ + inline bool Application::HasOption(const Nz::String& option) const + { + return m_options.count(option) != 0; + } + + /*! + * \brief Query for a command-line option + * + * \param key Parameter name + * \param value Optional string to receive the parameter value + * + * \remark key must be lower-case + * + * \return True if parameter is present + * + * \see GetParameters + */ + inline bool Application::HasParameter(const Nz::String& key, Nz::String* value) const + { + auto it = m_parameters.find(key); + if (it == m_parameters.end()) + return false; + + if (value) + *value = it->second; + + return true; + } + /*! * \brief Checks if the console overlay is enabled * diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index bce62093a..71301a13b 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include #ifndef NDK_SERVER #include @@ -21,6 +22,54 @@ namespace Ndk * \brief NDK class that represents the application, it offers a set of tools to ease the development */ + /*! + * \brief Constructs an Application object with command-line arguments + * + * Pass the argc and argv arguments from the main function. + * + * Command-line arguments can be retrieved by application methods + * + * This calls Sdk::Initialize() + * + * \remark Only one Application instance can exist at a time + */ + inline Application::Application(int argc, char* argv[]) : + Application() + { + std::regex optionRegex(R"(-(\w+))"); + std::regex valueRegex(R"(-(\w+)\s*=\s*(.+))"); + + std::smatch results; + + for (int i = 1; i < argc; ++i) + { + std::string argument(argv[i]); + if (std::regex_match(argument, results, valueRegex)) + { + Nz::String key(results[1].str()); + Nz::String value(results[2].str()); + + m_parameters[key.ToLower()] = value; + NazaraDebug("Registred parameter from command-line: " + key.ToLower() + "=" + value); + } + else if (std::regex_match(argument, results, optionRegex)) + { + Nz::String option(results[1].str()); + + m_options.insert(option); + NazaraDebug("Registred option from command-line: " + option); + } + else + NazaraWarning("Ignored command-line argument #" + Nz::String::Number(i) + " \"" + argument + '"'); + } + + if (HasOption("console")) + EnableConsole(true); + + if (HasOption("fpscounter")) + EnableFPSCounter(true); + } + /*! * \brief Runs the application by updating worlds, taking care about windows, ... */ diff --git a/examples/Tut00/main.cpp b/examples/Tut00/main.cpp index 472db3148..cfffa4c59 100644 --- a/examples/Tut00/main.cpp +++ b/examples/Tut00/main.cpp @@ -9,16 +9,14 @@ #include #include #include -#include -#include -int main() +int main(int argc, char* argv[]) { - // This "example" has only one purpose: Giving an empty project for you to test whatever you want - // If you wish to have multiple test projects, you only have to copy/paste this directory and change the name in the build.lua - Ndk::Application app; + // This "example" has only one purpose: Giving an empty project for you to test whatever you want + // If you wish to have multiple test projects, you only have to copy/paste this directory and change the name in the build.lua + Ndk::Application application(argc, argv); - // Do what you want here - - return EXIT_SUCCESS; + // Do what you want here + + return EXIT_SUCCESS; } \ No newline at end of file diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index f5fca94a0..9c33f6859 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -9,9 +9,9 @@ #include #include -int main() +int main(int argc, char* argv[]) { - Ndk::Application application; + Ndk::Application application(argc, argv); Nz::RenderWindow& mainWindow = application.AddWindow(); mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test"); From d6c381fee9cc89f4d10afb8ec52a1e5ff00e590f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 21:47:46 +0200 Subject: [PATCH 201/235] Sdk/Application: Fix crash when debug overlay are not used Former-commit-id: 6346b4d8474f88ebd189d18a921baaf9a7582943 [formerly 55c3d48b9090a28057ca7de79fbfd0a3c15dbb58] [formerly 71bd19d44ccd319878f66af8d823ae5cb1ce1d78 [formerly 56a5f8ab2da10a9679cce5b382204cdb08decd77]] Former-commit-id: 889925527eade5795174cd9750f996162cfac38e [formerly c9708ea0bb5140aea49694488c259442ae6b1031] Former-commit-id: 1147ab892f4e0d6fc42ed390336f8489b81d26d7 --- SDK/src/NDK/Application.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 71301a13b..8ecb5d454 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -114,6 +114,9 @@ namespace Ndk #ifndef NDK_SERVER for (WindowInfo& info : m_windows) { + if (!info.overlayWorld) + continue; + if (info.fpsCounter) { FPSCounterOverlay& fpsCounter = *info.fpsCounter; From f5f6b4035d9ece9b78ed41a9101ed8ed1b1b6e74 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 02:33:57 +0200 Subject: [PATCH 202/235] SDK: Fix console layer having trouble with late constructed windows Former-commit-id: 133d95cfd48f629cc9902c06861f3e6a73723a53 [formerly 7dde3eef66fc5274daf95b76b61d2b81fc6c9d16] [formerly e8e97d8cbaf703353b263a15cf51ed590f926818 [formerly f01a48da96b3fb545bb4d42d35e443c79f1bdfa0]] Former-commit-id: 67a9b3b9591490f94185b8ec917b5e1aab1a8e4e [formerly 90badb351e6406eb175dab65d9bb76f4f13bfd63] Former-commit-id: 37de44e5597c8cea7fcbd7455136eef8cb4cfee0 --- SDK/include/NDK/Application.hpp | 2 +- SDK/src/NDK/Application.cpp | 13 ++++++++++--- src/Nazara/Utility/Window.cpp | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 84b331e95..8c0eb18a9 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -88,7 +88,7 @@ namespace Ndk NazaraSlot(Nz::EventHandler, OnEvent, eventSlot); NazaraSlot(Nz::EventHandler, OnKeyPressed, keyPressedSlot); - NazaraSlot(Nz::EventHandler, OnResized, resizedSlot); + NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, resizedSlot); NazaraSlot(Nz::Log, OnLogWrite, logSlot); }; diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 8ecb5d454..68396f128 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -144,9 +144,16 @@ namespace Ndk { std::unique_ptr overlay = std::make_unique(); - overlay->console = std::make_unique(*info.overlayWorld, Nz::Vector2f(Nz::Vector2ui(info.window->GetWidth(), info.window->GetHeight() / 4)), overlay->lua); + Nz::Vector2ui windowDimensions; + if (info.window->IsValid()) + windowDimensions.Set(info.window->GetWidth(), info.window->GetHeight() / 4); + else + windowDimensions.MakeZero(); + + overlay->console = std::make_unique(*info.overlayWorld, Nz::Vector2f(windowDimensions), overlay->lua); Console& consoleRef = *overlay->console; + // Redirect logs toward the console overlay->logSlot.Connect(Nz::Log::OnLogWrite, [&consoleRef] (const Nz::String& str) { @@ -201,9 +208,9 @@ namespace Ndk consoleRef.Show(!consoleRef.IsVisible()); }); - overlay->resizedSlot.Connect(eventHandler.OnResized, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::SizeEvent& event) + overlay->resizedSlot.Connect(info.renderTarget->OnRenderTargetSizeChange, [&consoleRef] (const Nz::RenderTarget* renderTarget) { - consoleRef.SetSize({float(event.width), event.height / 4.f}); + consoleRef.SetSize({float(renderTarget->GetWidth()), renderTarget->GetHeight() / 4.f}); }); info.console = std::move(overlay); diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 02ed0f40a..7ba78dcb9 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -60,25 +61,22 @@ namespace Nz else if (style & WindowStyle_Closable || style & WindowStyle_Resizable) style |= WindowStyle_Titlebar; - m_impl = new WindowImpl(this); - if (!m_impl->Create(mode, title, style)) + std::unique_ptr impl = std::make_unique(this); + if (!impl->Create(mode, title, style)) { NazaraError("Failed to create window implementation"); - delete m_impl; - m_impl = nullptr; - return false; } + m_impl = impl.release(); + CallOnExit destroyOnFailure([this] () { Destroy(); }); + m_closed = false; m_ownsWindow = true; if (!OnWindowCreated()) { NazaraError("Failed to initialize window extension"); - delete m_impl; - m_impl = nullptr; - return false; } @@ -93,6 +91,10 @@ namespace Nz if (opened) m_impl->SetPosition(position.x, position.y); + OnWindowResized(); + + destroyOnFailure.Reset(); + return true; } From 973f50ddc5d675ebf24456f2e16cefb7c8564c64 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 02:34:08 +0200 Subject: [PATCH 203/235] Lua/LuaInstance: Fix crash on moving Former-commit-id: 414f0e22bae44d30b7e0e16c087ca2a5e1a8ad42 [formerly bc94f58405d370a52510802c54c0b1a981eee7f3] [formerly f7ae44003dafded389e5088a76e3cb20a7d60115 [formerly 3a82b7f24eef9b4480c675967a68eed497d8c1d0]] Former-commit-id: 9304480e9c22cbdb24740e8d60b331b3f4580db0 [formerly 51fcf70b3c37ae3766b207524edd2d93d768b4f1] Former-commit-id: 1f7973f35f53e7267ae53e01633070fd826626c7 --- src/Nazara/Lua/LuaInstance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 0ecf4c063..f31c6fe83 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -145,7 +145,8 @@ namespace Nz LuaInstance::~LuaInstance() { - lua_close(m_state); + if (m_state) + lua_close(m_state); } void LuaInstance::ArgCheck(bool condition, unsigned int argNum, const char* error) From c94048d8c36c12a9178ca9f7336e7851677fc72a Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 13:32:16 +0200 Subject: [PATCH 204/235] Example/Tut01: Improve background color Former-commit-id: b761ac19ba3e57a1f55ce96fdaaa95e9f66fc63d [formerly dc635e12aa832e18dd621701d06f23aa4765cb4e] [formerly 7a7fb9b66042870253374cbc9b3d4496f62ff113 [formerly e11cb226ea4a699bd5003c00e94ee4151b6b1969]] Former-commit-id: 0ec2ee1954521daed6fa31100243f3f916c1d9ab [formerly cb397680ca3bd67b83ef7b67c313ac0d5eeede65] Former-commit-id: d71b4e6262d53715d13b75db82e52c542aace323 --- examples/Tut01/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index 9c33f6859..b5e07074d 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) Ndk::World& world = application.AddWorld(); world.GetSystem().SetGlobalUp(Nz::Vector3f::Down()); - world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(192, 100, 100))); + world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(117, 122, 214))); Ndk::EntityHandle viewEntity = world.CreateEntity(); From fe539d33ef14408bccc85a90b163b72b7ff1f1fe Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 18:16:33 +0200 Subject: [PATCH 205/235] Sdk/Application: Fix compilation in server mode Former-commit-id: f22b42bca6bd277e08739e73e93a330943d41385 [formerly ad21870d5a8a0a5ddc69be18de7d815a492e197e] [formerly 8c313395815420b252b4b902c56dd2a950049eb5 [formerly add61b18ad8c4059e410a311aeb3eeaa9572c551]] Former-commit-id: e01dc9b1b7dd6a686d748988967e19f828027664 [formerly e7665c8d40d3f6402b3730ceca27cefb90a08c22] Former-commit-id: 81aa4614b0704b6996165553abed7f7c40386f44 --- SDK/include/NDK/Application.hpp | 6 ++++-- SDK/include/NDK/Application.inl | 2 +- SDK/src/NDK/Application.cpp | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 8c0eb18a9..b3f803fe1 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -127,12 +127,14 @@ namespace Ndk template void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/); template void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/); - std::map m_parameters; - std::set m_options; std::vector m_windows; #endif + + std::map m_parameters; + std::set m_options; std::list m_worlds; Nz::Clock m_updateClock; + #ifndef NDK_SERVER Nz::UInt32 m_overlayFlags; bool m_exitOnClosedWindows; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 7701160c5..2c74acb19 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -350,6 +350,7 @@ namespace Ndk return s_application; } + #ifndef NDK_SERVER template inline void Application::SetupWindow(WindowInfo& info, T* renderTarget, std::true_type) { @@ -372,7 +373,6 @@ namespace Ndk { } - #ifndef NDK_SERVER inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : window(std::move(window)), renderTarget(nullptr) diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 68396f128..3cdff6978 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include #include #ifndef NDK_SERVER @@ -63,11 +64,13 @@ namespace Ndk NazaraWarning("Ignored command-line argument #" + Nz::String::Number(i) + " \"" + argument + '"'); } + #ifndef NDK_SERVER if (HasOption("console")) EnableConsole(true); if (HasOption("fpscounter")) EnableFPSCounter(true); + #endif } /*! From 822eb197f417c58cf268c48d9214c692348ffec0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 18:20:23 +0200 Subject: [PATCH 206/235] Core/HardwareInfo: Fix indentation (Windows) Former-commit-id: e722e9377f1ff2029f0206bc92c3a930cad42929 [formerly c0f38cc656abc307bc7548ab5502ef1a9f66544e] [formerly 66ebb2287517d27c153de9f4cb62967526a629cd [formerly 2bc51321d6a1c187743937a7e9e7027e8cf71e44]] Former-commit-id: 63dcdeedc0aaec9d6fa52cfb41d548debd75c679 [formerly cdce876914c2ecec66a1884730bc8f6e9aaf8d74] Former-commit-id: 578acacf54563a0dc831ea1e70cbfa3428ee98d8 --- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 30 +++++++++---------- .../Shaders/LightScatteringFinal.frag | 18 +++++++++++ .../Shaders/LightScatteringFinal.frag.h | 1 + src/Nazara/Graphics/Sprite.cpp | 10 ++++--- 4 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag create mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 7ce5e10a1..62b86bf91 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -76,25 +76,25 @@ namespace Nz #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) int supported; asm volatile (" pushfl\n" - " pop %%eax\n" - " mov %%eax, %%ecx\n" - " xor $0x200000, %%eax\n" - " push %%eax\n" - " popfl\n" - " pushfl\n" - " pop %%eax\n" - " xor %%ecx, %%eax\n" - " mov %%eax, %0\n" - " push %%ecx\n" - " popfl" - : "=m" (supported) // output - : // input - : "eax", "ecx", "memory"); // clobbered register + " pop %%eax\n" + " mov %%eax, %%ecx\n" + " xor $0x200000, %%eax\n" + " push %%eax\n" + " popfl\n" + " pushfl\n" + " pop %%eax\n" + " xor %%ecx, %%eax\n" + " mov %%eax, %0\n" + " push %%ecx\n" + " popfl" + : "=m" (supported) // output + : // input + : "eax", "ecx", "memory"); // clobbered register return supported != 0; #else return false; #endif #endif -} + } } diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag new file mode 100644 index 000000000..82a05410b --- /dev/null +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag @@ -0,0 +1,18 @@ +#version 140 + +out vec4 RenderTarget0; + +uniform float exposure = 0.92; +uniform sampler2D AccumulationTexture; +uniform sampler2D ColorTexture; +uniform vec2 InvTargetSize; + +void main() +{ + vec2 texCoord = gl_FragCoord.xy * InvTargetSize; + + vec4 color = texture(ColorTexture, texCoord); + vec4 lightScattering = texture(AccumulationTexture, texCoord); + + RenderTarget0 = vec4(lightScattering.rgb * exposure, 1.0) + color * 1.1; +} diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h new file mode 100644 index 000000000..0b0b3fe9d --- /dev/null +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h @@ -0,0 +1 @@ +35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,101,120,112,111,115,117,114,101,32,61,32,48,46,57,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,67,111,108,111,114,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,116,101,120,116,117,114,101,40,67,111,108,111,114,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,9,118,101,99,52,32,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,32,61,32,116,101,120,116,117,114,101,40,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,46,114,103,98,32,42,32,101,120,112,111,115,117,114,101,44,32,49,46,48,41,32,43,32,99,111,108,111,114,32,42,32,49,46,49,59,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 5ef82cddf..23fd28181 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -57,20 +57,22 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); + const Nz::Vector3f origin(m_size.x / 2.f, m_size.y / -2.f, 0.f); + *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 377fae2ea10d21c220a03b65ee4854e98c240e57 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 19:16:03 +0200 Subject: [PATCH 207/235] Revert "Core/HardwareInfo: Fix indentation (Windows)" This reverts commit a4019076ff9afd3cb7e2d98a54c9788fd2df1457 [formerly 3a39cd2e8a3aa8bb46f9f1465923f2abb8fc19a1] [formerly a23f6beee25e408579609874672806b124bf5fc0 [formerly be4cec088d5683bc18e54fd5daa2805134a88bb9]] [formerly dd94bfecaf16a96cdc39de9abd3c0749f17bf824 [formerly 539605da0eb694cbad2fb52fdb49b9a79c3a0d04] [formerly 00917e0bb4766a6f19f303040241c81a92778185 [formerly 48c4b5219e3d1f74f04099f164712c2baddf1d4b]]]. Former-commit-id: 4d853fb7aca7af266a8f4a8b093923a515f73f91 [formerly ec71333603cb30452d05a416241131764a0903ba] [formerly 418de7f39eddfc7826b12dc15dd47a8e5af146b0 [formerly 074a0313d402ec669e309c38ed225a16338bf952]] Former-commit-id: a03666d46956845e61dee50e8628216232b851ed [formerly 356c2cd3a0fc44c6ddb982d10941ad747a3f1312] Former-commit-id: 3c9dbcc77309da3ef5da8999a0fd5716fcdff28b --- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 30 +++++++++---------- .../Shaders/LightScatteringFinal.frag | 18 ----------- .../Shaders/LightScatteringFinal.frag.h | 1 - src/Nazara/Graphics/Sprite.cpp | 10 +++---- 4 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag delete mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 62b86bf91..7ce5e10a1 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -76,25 +76,25 @@ namespace Nz #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) int supported; asm volatile (" pushfl\n" - " pop %%eax\n" - " mov %%eax, %%ecx\n" - " xor $0x200000, %%eax\n" - " push %%eax\n" - " popfl\n" - " pushfl\n" - " pop %%eax\n" - " xor %%ecx, %%eax\n" - " mov %%eax, %0\n" - " push %%ecx\n" - " popfl" - : "=m" (supported) // output - : // input - : "eax", "ecx", "memory"); // clobbered register + " pop %%eax\n" + " mov %%eax, %%ecx\n" + " xor $0x200000, %%eax\n" + " push %%eax\n" + " popfl\n" + " pushfl\n" + " pop %%eax\n" + " xor %%ecx, %%eax\n" + " mov %%eax, %0\n" + " push %%ecx\n" + " popfl" + : "=m" (supported) // output + : // input + : "eax", "ecx", "memory"); // clobbered register return supported != 0; #else return false; #endif #endif - } +} } diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag deleted file mode 100644 index 82a05410b..000000000 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 140 - -out vec4 RenderTarget0; - -uniform float exposure = 0.92; -uniform sampler2D AccumulationTexture; -uniform sampler2D ColorTexture; -uniform vec2 InvTargetSize; - -void main() -{ - vec2 texCoord = gl_FragCoord.xy * InvTargetSize; - - vec4 color = texture(ColorTexture, texCoord); - vec4 lightScattering = texture(AccumulationTexture, texCoord); - - RenderTarget0 = vec4(lightScattering.rgb * exposure, 1.0) + color * 1.1; -} diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h deleted file mode 100644 index 0b0b3fe9d..000000000 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h +++ /dev/null @@ -1 +0,0 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,101,120,112,111,115,117,114,101,32,61,32,48,46,57,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,67,111,108,111,114,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,116,101,120,116,117,114,101,40,67,111,108,111,114,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,9,118,101,99,52,32,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,32,61,32,116,101,120,116,117,114,101,40,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,46,114,103,98,32,42,32,101,120,112,111,115,117,114,101,44,32,49,46,48,41,32,43,32,99,111,108,111,114,32,42,32,49,46,49,59,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 23fd28181..5ef82cddf 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -57,22 +57,20 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); - const Nz::Vector3f origin(m_size.x / 2.f, m_size.y / -2.f, 0.f); - *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From a4934ae85520fc4c03ede597568925eda614903d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 19:16:20 +0200 Subject: [PATCH 208/235] Core/HardwareInfo: Fix indentation (Windows) Former-commit-id: 6c10c551860e30d80952e42d384e2d18bb9fda3c [formerly 70cffdb9c25b08ed64d6b47f9d324f04c7740a72] [formerly 3448fa94c62871de1ec9629779c9a614d9909499 [formerly 9475d9cca2e37fb4b0af52a6503e728bf979d26a]] Former-commit-id: 1d315648e6ec9e74be8733634b49a52c157c1ec9 [formerly 420fc7c77d0252bde216180a7eb08262405ab3e3] Former-commit-id: 9b96e2ae7cb58fa531566984ee6bec1a40771745 --- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 7ce5e10a1..62b86bf91 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -76,25 +76,25 @@ namespace Nz #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) int supported; asm volatile (" pushfl\n" - " pop %%eax\n" - " mov %%eax, %%ecx\n" - " xor $0x200000, %%eax\n" - " push %%eax\n" - " popfl\n" - " pushfl\n" - " pop %%eax\n" - " xor %%ecx, %%eax\n" - " mov %%eax, %0\n" - " push %%ecx\n" - " popfl" - : "=m" (supported) // output - : // input - : "eax", "ecx", "memory"); // clobbered register + " pop %%eax\n" + " mov %%eax, %%ecx\n" + " xor $0x200000, %%eax\n" + " push %%eax\n" + " popfl\n" + " pushfl\n" + " pop %%eax\n" + " xor %%ecx, %%eax\n" + " mov %%eax, %0\n" + " push %%ecx\n" + " popfl" + : "=m" (supported) // output + : // input + : "eax", "ecx", "memory"); // clobbered register return supported != 0; #else return false; #endif #endif -} + } } From 60ac889640fd7e37d886c53c37b6e59d5156820a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 20:53:27 +0200 Subject: [PATCH 209/235] Graphics/Sprite: Add Origin parameter Allows you to change center of translation/rotation/scale Former-commit-id: f3ce3d4f8350738f8ddca2e157282b70a982b5ef [formerly b3c9dff5ec52ee320e68c032817caef84862c059] [formerly 0dd589e277f5d625f2c52d9195e812d940e2a4e0 [formerly 06491fb509c1e8a49acb8628c82e60a8ca71db84]] Former-commit-id: 811657fd21f956a06906796be7986d8ddc37023c [formerly 7d6a08ef01b05140f6aed6f3f65b2ec5837fa28e] Former-commit-id: af0ee4137a64a0cd4986cfc29854aced0698bde0 --- include/Nazara/Graphics/Sprite.hpp | 3 +++ include/Nazara/Graphics/Sprite.inl | 33 +++++++++++++++++++++++++++++- src/Nazara/Graphics/Sprite.cpp | 14 ++++++++----- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index 3660bf872..3aa261d89 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -38,12 +38,14 @@ namespace Nz inline const Color& GetColor() const; inline const MaterialRef& GetMaterial() const; + inline const Vector3f& GetOrigin() const; inline const Vector2f& GetSize() const; inline const Rectf& GetTextureCoords() const; inline void SetColor(const Color& color); inline void SetDefaultMaterial(); inline void SetMaterial(MaterialRef material, bool resizeSprite = true); + inline void SetOrigin(const Vector3f& origin); inline void SetSize(const Vector2f& size); inline void SetSize(float sizeX, float sizeY); inline void SetTexture(TextureRef texture, bool resizeSprite = true); @@ -67,6 +69,7 @@ namespace Nz MaterialRef m_material; Rectf m_textureCoords; Vector2f m_size; + Vector3f m_origin; static SpriteLibrary::LibraryMap s_library; }; diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index f0e05c5a2..2cfc014a2 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -14,6 +14,7 @@ namespace Nz inline Sprite::Sprite() : m_color(Color::White), + m_origin(Nz::Vector3f::Zero()), m_textureCoords(0.f, 0.f, 1.f, 1.f), m_size(64.f, 64.f) { @@ -77,12 +78,23 @@ namespace Nz * \brief Gets the material of the sprite * \return Current material */ - inline const MaterialRef& Sprite::GetMaterial() const { return m_material; } + /*! + * \brief Gets the origin of the sprite + * + * \return Current material + * + * \see SetOrigin + */ + inline const Vector3f & Sprite::GetOrigin() const + { + return m_origin; + } + /*! * \brief Gets the size of the sprite * \return Current size @@ -146,6 +158,24 @@ namespace Nz } } + /*! + * \brief Sets the origin of the sprite + * + * The origin is the center of translation/rotation/scaling of the sprite. + * + * \param origin New origin for the sprite + * + * \see GetOrigin + */ + inline void Sprite::SetOrigin(const Vector3f& origin) + { + m_origin = origin; + + // On invalide la bounding box + InvalidateBoundingVolume(); + InvalidateVertices(); + } + /*! * \brief Sets the size of the sprite * @@ -277,3 +307,4 @@ namespace Nz } #include +#include "Sprite.hpp" diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 5ef82cddf..f4b2f0dab 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -39,7 +39,9 @@ namespace Nz void Sprite::MakeBoundingVolume() const { - m_boundingVolume.Set(Vector3f(0.f), m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); + + m_boundingVolume.Set(-origin, m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); } /*! @@ -57,20 +59,22 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); + Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); + *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 41ed0395d5c406bf43cc5ed892f7ce07d18f0dec Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 1 Sep 2016 13:02:46 +0200 Subject: [PATCH 210/235] Graphics: Clear instances in Clear method Former-commit-id: f6314967bf15544b530db2252aa5531d78554381 [formerly 47e880626a186e8b4cd59a2d0328cdb2667af86f] [formerly 319af73dbe6f3a5cbac3bdd7e2add637c6a16ea3 [formerly a1f223482cb27227c8255d5842a38b2506ae3496]] Former-commit-id: abae215139aadb2a1e6fd2b842db9ffafdeb326e [formerly 4e2c1dd62cf0d02982e786231b15774fb07589e0] Former-commit-id: 16bd3eb0a451653b05b813ed8921db2746c4aaa0 --- build/scripts/features/index_template.html | 140 +++++----- build/scripts/features/style.css | 240 +++++++++--------- src/Nazara/Graphics/DeferredGeometryPass.cpp | 7 - src/Nazara/Graphics/DeferredRenderQueue.cpp | 30 +++ src/Nazara/Graphics/ForwardRenderQueue.cpp | 56 ++++ .../Graphics/ForwardRenderTechnique.cpp | 13 +- 6 files changed, 278 insertions(+), 208 deletions(-) diff --git a/build/scripts/features/index_template.html b/build/scripts/features/index_template.html index 43bf5aea9..852811a4c 100644 --- a/build/scripts/features/index_template.html +++ b/build/scripts/features/index_template.html @@ -1,71 +1,71 @@ - - - - - - Avancement de Nazara - - -
- Nazara Engine - -
- - Retrouvez le moteur sur GitHub !
- Dépôt GitHub

- Venez vous renseigner sur les topics dédiés à Nazara présents sur plusieurs sites web :
- OpenClassrooms, Progdupeupl ou ZesteDeSavoir -

- ... ou pourquoi ne pas venir faire un tour sur le forum dédié au moteur ? - -
- -

Fonctionnalités de Nazara

- -
Dernière mise à jour : - %DATE% -
- -

Important:

-

Afin de faciliter la mise à jour, la page que vous voyez ici a été générée automatiquement par un script Lua, ce qui m'oblige néanmoins à encoder les fonctionnalités de chaque module dans un premier temps. - C'est un travail assez long (pour vous donner une idée, les données du noyau représentent un fichier de 200 lignes), et il n'est pas encore complet, c'est pourquoi des modules manquent sur cette page.
- Gardez donc à l'esprit que le moteur possède plus de fonctionnalités que ce qui est décrit actuellement sur cette page.

- -

Oh et bien sûr je ne suis pas concepteur de site web, c'est pourquoi cette page est moche (j'ai essayé de minimiser les dégâts).
- Si vous sentez en vous l'irrésistible envie d'améliorer cette page, sachez que votre aide serait grandement appréciée (vous pouvez me contacter via le lien de votre choix plus haut).

- -

Le pourcentage indiqué est calculé automatiquement en fonction des fonctionnalités, cela signifie qu'une fonctionnalité présente sera comptée à 100% à partir du moment où son implémentation de base est considérée fonctionnelle, cela n'est donc pas une assurance qu'aucun bug n'existe concernant cette fonctionnalité (cependant cela signifie que la fonctionnalité est utilisable).
- Et bien entendu, un module ou une fonctionnalité ayant atteint les 100% peut toujours évoluer par la suite.

- -
- - - - - - - - - - - %MODULELIST% - -
Sommaire
ModuleAvancement
- - %MODULEDESCRIPTION% -
- - - - - - - - - - %MODULELIST% - -
Sommaire
ModulePourcentage
-
- + + + + + + Avancement de Nazara + + +
+ Nazara Engine + +
+ + Retrouvez le moteur sur GitHub !
+ Dépôt GitHub

+ Venez vous renseigner sur les topics dédiés à Nazara présents sur plusieurs sites web :
+ OpenClassrooms, Progdupeupl ou ZesteDeSavoir +

+ ... ou pourquoi ne pas venir faire un tour sur le forum dédié au moteur ? + +
+ +

Fonctionnalités de Nazara

+ +
Dernière mise à jour : + %DATE% +
+ +

Important:

+

Afin de faciliter la mise à jour, la page que vous voyez ici a été générée automatiquement par un script Lua, ce qui m'oblige néanmoins à encoder les fonctionnalités de chaque module dans un premier temps. + C'est un travail assez long (pour vous donner une idée, les données du noyau représentent un fichier de 200 lignes), et il n'est pas encore complet, c'est pourquoi des modules manquent sur cette page.
+ Gardez donc à l'esprit que le moteur possède plus de fonctionnalités que ce qui est décrit actuellement sur cette page.

+ +

Oh et bien sûr je ne suis pas concepteur de site web, c'est pourquoi cette page est moche (j'ai essayé de minimiser les dégâts).
+ Si vous sentez en vous l'irrésistible envie d'améliorer cette page, sachez que votre aide serait grandement appréciée (vous pouvez me contacter via le lien de votre choix plus haut).

+ +

Le pourcentage indiqué est calculé automatiquement en fonction des fonctionnalités, cela signifie qu'une fonctionnalité présente sera comptée à 100% à partir du moment où son implémentation de base est considérée fonctionnelle, cela n'est donc pas une assurance qu'aucun bug n'existe concernant cette fonctionnalité (cependant cela signifie que la fonctionnalité est utilisable).
+ Et bien entendu, un module ou une fonctionnalité ayant atteint les 100% peut toujours évoluer par la suite.

+ +
+ + + + + + + + + + + %MODULELIST% + +
Sommaire
ModuleAvancement
+ + %MODULEDESCRIPTION% +
+ + + + + + + + + + %MODULELIST% + +
Sommaire
ModulePourcentage
+
+ \ No newline at end of file diff --git a/build/scripts/features/style.css b/build/scripts/features/style.css index ff83f706c..189b2a090 100644 --- a/build/scripts/features/style.css +++ b/build/scripts/features/style.css @@ -1,121 +1,121 @@ -/* Je ne suis pas développeur HTML/CSS, je dois y toucher une fois l'an, désolé pour les quelques atrocités que vous pourrez trouver ici */ - -body -{ - font-family: sans-serif; - text-align: center; - margin: 0; - background-color: #f1f1f1; -} - -#englob { - display: block; - margin-left: auto; - margin-right: auto; - background-color: white; - width: 50%; - min-width: 765px; - padding: 0 20px; -} - -hr { - height: 0; - border: 0; - border-top: 1px solid #eee; -} - -a -{ - color: #007ACC; -} - -a:hover -{ - color: lightblue; -} - -h1 -{ - display: inline; -} - -h2 -{ - display: inline; - text-decoration: underline; -} - -h4 -{ - text-decoration: underline; -} - -p { - text-align: justify; -} - -ol -{ - list-style-type: none; -} - -table -{ - border-collapse: collapse; - text-align: center; - display: inline-block; - border: white groove; - border-radius: 10px; - box-shadow: 0px 0px 10px lightblue; -} - -th -{ - text-shadow: 2px 2px 4px black; -} - -tr -{ - border: 1px solid white; -} - -tbody tr:hover -{ - text-shadow: 0px 0px 4px white; -} - -.description -{ - margin-left: 20px; -} - -.lastupdate -{ - font-size: x-large; - font-weight: bold; - color: #f1c40f; -} - -.modulename -{ - font-size: x-large; - font-weight: bold; - text-shadow: 2px 2px 10px #007ACC; -} - -.note -{ - margin-left: 20px; - color: #007ACC; -} - -.notedesc -{ - color: rgb(200, 200, 255); -} - -.portability -{ - margin-left: 20px; - color: red; +/* Je ne suis pas développeur HTML/CSS, je dois y toucher une fois l'an, désolé pour les quelques atrocités que vous pourrez trouver ici */ + +body +{ + font-family: sans-serif; + text-align: center; + margin: 0; + background-color: #f1f1f1; +} + +#englob { + display: block; + margin-left: auto; + margin-right: auto; + background-color: white; + width: 50%; + min-width: 765px; + padding: 0 20px; +} + +hr { + height: 0; + border: 0; + border-top: 1px solid #eee; +} + +a +{ + color: #007ACC; +} + +a:hover +{ + color: lightblue; +} + +h1 +{ + display: inline; +} + +h2 +{ + display: inline; + text-decoration: underline; +} + +h4 +{ + text-decoration: underline; +} + +p { + text-align: justify; +} + +ol +{ + list-style-type: none; +} + +table +{ + border-collapse: collapse; + text-align: center; + display: inline-block; + border: white groove; + border-radius: 10px; + box-shadow: 0px 0px 10px lightblue; +} + +th +{ + text-shadow: 2px 2px 4px black; +} + +tr +{ + border: 1px solid white; +} + +tbody tr:hover +{ + text-shadow: 0px 0px 4px white; +} + +.description +{ + margin-left: 20px; +} + +.lastupdate +{ + font-size: x-large; + font-weight: bold; + color: #f1c40f; +} + +.modulename +{ + font-size: x-large; + font-weight: bold; + text-shadow: 2px 2px 10px #007ACC; +} + +.note +{ + margin-left: 20px; + color: #007ACC; +} + +.notedesc +{ + color: rgb(200, 200, 255); +} + +.portability +{ + margin-left: 20px; + color: red; } \ No newline at end of file diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 1c4f8b8bb..dbdb95f5a 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -187,18 +187,11 @@ namespace Nz drawFunc(meshData.primitiveMode, 0, indexCount); } } - - instances.clear(); } } } - - // And we set it back data to zero - matEntry.enabled = false; } } - - pipelineEntry.maxInstanceCount = 0; } } } diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 7d214b217..41fb9d20b 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -278,6 +278,36 @@ namespace Nz Layer& layer = it->second; if (layer.clearCount++ >= 100) it = layers.erase(it); + else + { + for (auto& pipelinePair : layer.opaqueModels) + { + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.maxInstanceCount > 0) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + MeshInstanceContainer& meshInstances = matEntry.meshMap; + + for (auto& meshIt : meshInstances) + { + auto& meshEntry = meshIt.second; + + meshEntry.instances.clear(); + } + matEntry.enabled = false; + } + } + pipelineEntry.maxInstanceCount = 0; + } + } + } } } diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 882a6f61e..2de6b66e4 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -527,6 +527,62 @@ namespace Nz layers.erase(it++); else { + for (auto& pipelinePair : layer.basicSprites) + { + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.enabled) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + auto& overlayMap = matEntry.overlayMap; + for (auto& overlayIt : overlayMap) + { + const Texture* overlay = overlayIt.first; + auto& spriteChainVector = overlayIt.second.spriteChains; + + spriteChainVector.clear(); + } + + matEntry.enabled = false; + } + } + pipelineEntry.enabled = false; + } + } + + for (auto& pipelinePair : layer.opaqueModels) + { + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.maxInstanceCount > 0) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + MeshInstanceContainer& meshInstances = matEntry.meshMap; + + for (auto& meshIt : meshInstances) + { + auto& meshEntry = meshIt.second; + + meshEntry.instances.clear(); + } + matEntry.enabled = false; + } + } + pipelineEntry.maxInstanceCount = 0; + } + } + layer.otherDrawables.clear(); layer.transparentModels.clear(); layer.transparentModelData.clear(); diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 91507ee68..959ef2f03 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -386,17 +386,12 @@ namespace Nz vertexMapper.Unmap(); Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); - } while (spriteChain < spriteChainCount); - - spriteChainVector.clear(); + } + while (spriteChain < spriteChainCount); } } - - // We set it back to zero - matEntry.enabled = false; } } - pipelineEntry.enabled = false; } } } @@ -781,12 +776,8 @@ namespace Nz instances.clear(); } } - - matEntry.enabled = false; } } - - pipelineEntry.maxInstanceCount = 0; } } } From 9e3a7626fc5c86e09822806e84c5342d332867f7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 1 Sep 2016 21:07:08 +0200 Subject: [PATCH 211/235] Graphics/Sprite: Fix origin not being initialized/copied Former-commit-id: 790b49278d8cf7c1800f559cf0d29d65d0834b08 [formerly 93b247cc3433a5ac7c0f5a5ef48b0cf7a0c0f9dc] [formerly 9d6210ac2449aa5dc0d74d9a3cb256480e095008 [formerly 4ccda8249177b9ba5daa5406fd57f17b483cd81c]] Former-commit-id: 22dcc8245a3ec0774c1723f88682c585a43ff3c7 [formerly 94bbee0ec1e3fb904d83258da52b8f90634f4c8a] Former-commit-id: a8326b7bec2c16837b1340de8edd5c731ec837ec --- include/Nazara/Graphics/Sprite.inl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 2cfc014a2..410b42478 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -14,9 +14,9 @@ namespace Nz inline Sprite::Sprite() : m_color(Color::White), - m_origin(Nz::Vector3f::Zero()), m_textureCoords(0.f, 0.f, 1.f, 1.f), - m_size(64.f, 64.f) + m_size(64.f, 64.f), + m_origin(Nz::Vector3f::Zero()) { SetDefaultMaterial(); } @@ -26,11 +26,8 @@ namespace Nz * * \param material Reference to a material */ - inline Sprite::Sprite(MaterialRef material) : - m_color(Color::White), - m_textureCoords(0.f, 0.f, 1.f, 1.f), - m_size(64.f, 64.f) + Sprite() { SetMaterial(std::move(material), true); } @@ -42,9 +39,7 @@ namespace Nz */ inline Sprite::Sprite(Texture* texture) : - m_color(Color::White), - m_textureCoords(0.f, 0.f, 1.f, 1.f), - m_size(64.f, 64.f) + Sprite() { SetTexture(texture, true); } @@ -60,7 +55,8 @@ namespace Nz m_color(sprite.m_color), m_material(sprite.m_material), m_textureCoords(sprite.m_textureCoords), - m_size(sprite.m_size) + m_size(sprite.m_size), + m_origin(sprite.m_origin) { } @@ -270,6 +266,7 @@ namespace Nz m_color = sprite.m_color; m_material = sprite.m_material; + m_origin = sprite.m_origin; m_textureCoords = sprite.m_textureCoords; m_size = sprite.m_size; From 627444bea89cbe9778ac344b282b4a9bcc49f24c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 3 Sep 2016 21:13:00 +0200 Subject: [PATCH 212/235] Graphics/DeferredRenderQueue: Fix crash on layer removal Former-commit-id: 36ccd0e1d5b19b5b6fb47d485ef10e6f05a74bbb [formerly e1d228504afce70f6e73ccc2b825e2b048b03c5c] [formerly e2f9b47540640faa330e43fe1cf721d0ae66d170 [formerly 2efd87e99322061c14546ef0905d83e41de93b9b]] Former-commit-id: 572862971c69fe3e9d860df7edea12532534b597 [formerly 6e2f6c67b1cd1d40d9a183b66173093d55e09b1d] Former-commit-id: 21bff695f015134fb86ddb1a0b8a444223392df4 --- src/Nazara/Graphics/DeferredRenderQueue.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 41fb9d20b..b240edcd7 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -273,7 +273,7 @@ namespace Nz layers.clear(); else { - for (auto it = layers.begin(); it != layers.end(); ++it) + for (auto it = layers.begin(); it != layers.end();) { Layer& layer = it->second; if (layer.clearCount++ >= 100) @@ -307,6 +307,8 @@ namespace Nz pipelineEntry.maxInstanceCount = 0; } } + + ++it; } } } From 05528e029d173223d42fa503274559e2464c7b6b Mon Sep 17 00:00:00 2001 From: Ardakaniz Date: Sun, 4 Sep 2016 14:50:38 +0200 Subject: [PATCH 213/235] Utility/EventHandler: Fix OnMouseButtonReleased event Former-commit-id: 45fb49cbc3b4a2390ee80811047eb644cc511356 [formerly 998ad04604d18cce89046d3d0407d28710bb8b76] [formerly 5374b51a3e533ece806584d6c299a39954024506 [formerly f658b4d5fc1fce17ce67c5c2082111a6cae6f176]] Former-commit-id: 42808b9eb7c267c608707505edaf4507d10798ab [formerly 8a37a4b8430f9fd59e6cd10db5d82b11651236b8] Former-commit-id: 128b4f8aa6ab1a3b7842d3b6c84168d1cb06ec31 --- include/Nazara/Utility/EventHandler.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl index c066b6810..719ffddcb 100644 --- a/include/Nazara/Utility/EventHandler.inl +++ b/include/Nazara/Utility/EventHandler.inl @@ -43,7 +43,7 @@ namespace Nz break; case WindowEventType_MouseButtonReleased: - OnMouseButtonPressed(this, event.mouseButton); + OnMouseButtonReleased(this, event.mouseButton); break; case WindowEventType_MouseEntered: From 1ef0c04f20a10d8a3dcc1a281b954c6a182a83d9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 19:56:11 +0200 Subject: [PATCH 214/235] Audio: Fix some type warning Former-commit-id: cb3155ca088d24c4515a7e773454010f3e6df1e7 [formerly d9803b6bffbfc1c8d490dd9ae451a363faaaedfc] [formerly eef64e8fdcd1383970286e0756d31383afd0e756 [formerly 7431388ed48a2c516f305834f8f8fed0ad3e56b8]] Former-commit-id: fee589f9cfc45c9a3387e41026f372047886d381 [formerly 9742d88c55031414cba3b54403a61909a9f3c85e] Former-commit-id: f8f6b903238a7cad2946e75d497c22a5be9117c0 --- include/Nazara/Audio/Algorithm.hpp | 2 +- include/Nazara/Audio/Algorithm.inl | 6 +- include/Nazara/Audio/Music.hpp | 2 +- include/Nazara/Audio/SoundBuffer.hpp | 6 +- include/Nazara/Audio/SoundStream.hpp | 6 +- src/Nazara/Audio/Formats/sndfileLoader.cpp | 18 +++--- src/Nazara/Audio/Music.cpp | 46 +++----------- src/Nazara/Audio/Sound.cpp | 34 +--------- src/Nazara/Audio/SoundBuffer.cpp | 74 +++++----------------- 9 files changed, 47 insertions(+), 147 deletions(-) diff --git a/include/Nazara/Audio/Algorithm.hpp b/include/Nazara/Audio/Algorithm.hpp index ddb72a6b0..ea5bd09b6 100644 --- a/include/Nazara/Audio/Algorithm.hpp +++ b/include/Nazara/Audio/Algorithm.hpp @@ -11,7 +11,7 @@ namespace Nz { - template void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount); + template void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount); } #include diff --git a/include/Nazara/Audio/Algorithm.inl b/include/Nazara/Audio/Algorithm.inl index 1075a8b57..ce3c87369 100644 --- a/include/Nazara/Audio/Algorithm.inl +++ b/include/Nazara/Audio/Algorithm.inl @@ -19,16 +19,16 @@ namespace Nz * \remark The input buffer may be the same as the output one */ template - void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount) + void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount) { // To avoid overflow, we use, as an accumulator, a type which is large enough: (u)int 64 bits for integers, double for floatings typedef typename std::conditional::value, UInt64, Int64>::type BiggestInt; typedef typename std::conditional::value, BiggestInt, double>::type Biggest; - for (unsigned int i = 0; i < frameCount; ++i) + for (UInt64 i = 0; i < frameCount; ++i) { Biggest acc = Biggest(0); - for (unsigned int j = 0; j < channelCount; ++j) + for (UInt32 j = 0; j < channelCount; ++j) acc += input[i * channelCount + j]; output[i] = static_cast(acc / channelCount); diff --git a/include/Nazara/Audio/Music.hpp b/include/Nazara/Audio/Music.hpp index d08732fa7..f31882890 100644 --- a/include/Nazara/Audio/Music.hpp +++ b/include/Nazara/Audio/Music.hpp @@ -48,7 +48,7 @@ namespace Nz UInt32 GetDuration() const; AudioFormat GetFormat() const; UInt32 GetPlayingOffset() const; - UInt32 GetSampleCount() const; + UInt64 GetSampleCount() const; UInt32 GetSampleRate() const; SoundStatus GetStatus() const; diff --git a/include/Nazara/Audio/SoundBuffer.hpp b/include/Nazara/Audio/SoundBuffer.hpp index 2b02847b4..6b8e5c385 100644 --- a/include/Nazara/Audio/SoundBuffer.hpp +++ b/include/Nazara/Audio/SoundBuffer.hpp @@ -50,18 +50,18 @@ namespace Nz public: SoundBuffer() = default; - SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples); + SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples); SoundBuffer(const SoundBuffer&) = delete; SoundBuffer(SoundBuffer&&) = delete; ~SoundBuffer(); - bool Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples); + bool Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples); void Destroy(); UInt32 GetDuration() const; AudioFormat GetFormat() const; const Int16* GetSamples() const; - UInt32 GetSampleCount() const; + UInt64 GetSampleCount() const; UInt32 GetSampleRate() const; bool IsValid() const; diff --git a/include/Nazara/Audio/SoundStream.hpp b/include/Nazara/Audio/SoundStream.hpp index 4edc7b412..8fd93f412 100644 --- a/include/Nazara/Audio/SoundStream.hpp +++ b/include/Nazara/Audio/SoundStream.hpp @@ -21,11 +21,11 @@ namespace Nz virtual UInt32 GetDuration() const = 0; virtual AudioFormat GetFormat() const = 0; - virtual UInt32 GetSampleCount() const = 0; + virtual UInt64 GetSampleCount() const = 0; virtual UInt32 GetSampleRate() const = 0; - virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0; - virtual void Seek(UInt32 offset) = 0; + virtual UInt64 Read(void* buffer, UInt64 sampleCount) = 0; + virtual void Seek(UInt64 offset) = 0; }; } diff --git a/src/Nazara/Audio/Formats/sndfileLoader.cpp b/src/Nazara/Audio/Formats/sndfileLoader.cpp index 2aca17976..055e3b6a6 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.cpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.cpp @@ -97,7 +97,7 @@ namespace Nz return m_format; } - UInt32 GetSampleCount() const override + UInt64 GetSampleCount() const override { return m_sampleCount; } @@ -131,7 +131,7 @@ namespace Nz bool Open(Stream& stream, bool forceMono) { SF_INFO infos; - infos.format = 0; // Format inconnu + infos.format = 0; // Unknown format m_handle = sf_open_virtual(&callbacks, SFM_READ, &infos, &stream); if (!m_handle) @@ -154,7 +154,7 @@ namespace Nz return false; } - m_sampleCount = static_cast(infos.channels*infos.frames); + m_sampleCount = infos.channels*infos.frames; m_sampleRate = infos.samplerate; // Durée de la musique (s) = samples / channels*rate @@ -180,7 +180,7 @@ namespace Nz return true; } - unsigned int Read(void* buffer, unsigned int sampleCount) override + UInt64 Read(void* buffer, UInt64 sampleCount) override { // Si la musique a été demandée en mono, nous devons la convertir à la volée lors de la lecture if (m_mixToMono) @@ -190,13 +190,13 @@ namespace Nz sf_count_t readSampleCount = sf_read_short(m_handle, m_mixBuffer.data(), m_format * sampleCount); MixToMono(m_mixBuffer.data(), static_cast(buffer), m_format, sampleCount); - return static_cast(readSampleCount / m_format); + return readSampleCount / m_format; } else - return static_cast(sf_read_short(m_handle, static_cast(buffer), sampleCount)); + return sf_read_short(m_handle, static_cast(buffer), sampleCount); } - void Seek(UInt32 offset) override + void Seek(UInt64 offset) override { sf_seek(m_handle, offset*m_sampleRate / 1000, SEEK_SET); } @@ -208,8 +208,8 @@ namespace Nz SNDFILE* m_handle; bool m_mixToMono; UInt32 m_duration; - unsigned int m_sampleCount; - unsigned int m_sampleRate; + UInt32 m_sampleRate; + UInt64 m_sampleCount; }; bool IsSupported(const String& extension) diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index 9e38c7114..1f0df6ba5 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -166,17 +166,10 @@ namespace Nz * * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - UInt32 Music::GetPlayingOffset() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return 0; - } - #endif - + NazaraAssert(m_impl, "Music not created"); + // Prevent music thread from enqueing new buffers while we're getting the count Nz::LockGuard lock(m_impl->bufferLock); @@ -192,16 +185,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - - UInt32 Music::GetSampleCount() const + UInt64 Music::GetSampleCount() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Music not created"); return m_impl->stream->GetSampleCount(); } @@ -212,16 +198,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - UInt32 Music::GetSampleRate() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Music not created"); return m_impl->sampleRate; } @@ -233,16 +212,9 @@ namespace Nz * \remark If the music is not playing, Stopped is returned * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - SoundStatus Music::GetStatus() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return SoundStatus_Stopped; - } - #endif + NazaraAssert(m_impl, "Music not created"); SoundStatus status = GetInternalStatus(); @@ -425,8 +397,8 @@ namespace Nz bool Music::FillAndQueueBuffer(unsigned int buffer) { - unsigned int sampleCount = m_impl->chunkSamples.size(); - unsigned int sampleRead = 0; + std::size_t sampleCount = m_impl->chunkSamples.size(); + std::size_t sampleRead = 0; // Fill the buffer by reading from the stream for (;;) @@ -446,7 +418,7 @@ namespace Nz // Update the buffer (send it to OpenAL) and queue it if we got any data if (sampleRead > 0) { - alBufferData(buffer, m_impl->audioFormat, &m_impl->chunkSamples[0], sampleRead*sizeof(Int16), m_impl->sampleRate); + alBufferData(buffer, m_impl->audioFormat, &m_impl->chunkSamples[0], static_cast(sampleRead*sizeof(Int16)), static_cast(m_impl->sampleRate)); alSourceQueueBuffers(m_source, 1, &buffer); } diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index d2b71318b..3e2e27faa 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -27,7 +27,6 @@ namespace Nz * * \param soundBuffer Buffer to read sound from */ - Sound::Sound(const SoundBuffer* soundBuffer) { SetBuffer(soundBuffer); @@ -38,7 +37,6 @@ namespace Nz * * \param sound Sound to copy */ - Sound::Sound(const Sound& sound) : SoundEmitter(sound) { @@ -50,7 +48,6 @@ namespace Nz * * \see Stop */ - Sound::~Sound() { Stop(); @@ -61,7 +58,6 @@ namespace Nz * * \param loop Should sound loop */ - void Sound::EnableLooping(bool loop) { alSourcei(m_source, AL_LOOPING, loop); @@ -71,7 +67,6 @@ namespace Nz * \brief Gets the internal buffer * \return Internal buffer */ - const SoundBuffer* Sound::GetBuffer() const { return m_buffer; @@ -83,7 +78,6 @@ namespace Nz * * \remark Produces a NazaraError if there is no buffer */ - UInt32 Sound::GetDuration() const { NazaraAssert(m_buffer, "Invalid sound buffer"); @@ -95,7 +89,6 @@ namespace Nz * \brief Gets the current offset in the sound * \return Offset in milliseconds (works with entire seconds) */ - UInt32 Sound::GetPlayingOffset() const { ALint samples = 0; @@ -108,7 +101,6 @@ namespace Nz * \brief Gets the status of the music * \return Enumeration of type SoundStatus (Playing, Stopped, ...) */ - SoundStatus Sound::GetStatus() const { return GetInternalStatus(); @@ -118,7 +110,6 @@ namespace Nz * \brief Checks whether the sound is looping * \return true if it is the case */ - bool Sound::IsLooping() const { ALint loop; @@ -141,7 +132,6 @@ namespace Nz * \brief Checks whether the sound is playing * \return true if it is the case */ - bool Sound::IsPlaying() const { return GetStatus() == SoundStatus_Playing; @@ -156,7 +146,6 @@ namespace Nz * * \remark Produces a NazaraError if loading failed */ - bool Sound::LoadFromFile(const String& filePath, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -180,7 +169,6 @@ namespace Nz * * \remark Produces a NazaraError if loading failed */ - bool Sound::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -203,7 +191,6 @@ namespace Nz * * \remark Produces a NazaraError if loading failed */ - bool Sound::LoadFromStream(Stream& stream, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -220,7 +207,6 @@ namespace Nz /*! * \brief Pauses the sound */ - void Sound::Pause() { alSourcePause(m_source); @@ -231,16 +217,9 @@ namespace Nz * * \remark Produces a NazaraError if the sound is not playable with NAZARA_AUDIO_SAFE defined */ - void Sound::Play() { - #if NAZARA_AUDIO_SAFE - if (!IsPlayable()) - { - NazaraError("Invalid sound buffer"); - return; - } - #endif + NazaraAssert(IsPlayable(), "Music is not playable"); alSourcePlay(m_source); } @@ -252,16 +231,9 @@ namespace Nz * * \remark Produces a NazaraError if buffer is invalid with NAZARA_AUDIO_SAFE defined */ - void Sound::SetBuffer(const SoundBuffer* buffer) { - #if NAZARA_AUDIO_SAFE - if (buffer && !buffer->IsValid()) - { - NazaraError("Invalid sound buffer"); - return; - } - #endif + NazaraAssert(!buffer || buffer->IsValid(), "Invalid sound buffer"); if (m_buffer == buffer) return; @@ -281,7 +253,6 @@ namespace Nz * * \param offset Offset in the sound in milliseconds */ - void Sound::SetPlayingOffset(UInt32 offset) { alSourcei(m_source, AL_SAMPLE_OFFSET, static_cast(offset/1000.f * m_buffer->GetSampleRate())); @@ -290,7 +261,6 @@ namespace Nz /*! * \brief Stops the sound */ - void Sound::Stop() { alSourceStop(m_source); diff --git a/src/Nazara/Audio/SoundBuffer.cpp b/src/Nazara/Audio/SoundBuffer.cpp index b59e74e23..4b2b0410e 100644 --- a/src/Nazara/Audio/SoundBuffer.cpp +++ b/src/Nazara/Audio/SoundBuffer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,7 @@ namespace Nz AudioFormat format; UInt32 duration; std::unique_ptr samples; - UInt32 sampleCount; + UInt64 sampleCount; UInt32 sampleRate; }; @@ -57,8 +58,7 @@ namespace Nz * * \see Create */ - - SoundBuffer::SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) + SoundBuffer::SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples) { Create(format, sampleCount, sampleRate, samples); @@ -76,7 +76,6 @@ namespace Nz * * \see Destroy */ - SoundBuffer::~SoundBuffer() { OnSoundBufferRelease(this); @@ -96,8 +95,7 @@ namespace Nz * \remark Produces a NazaraError if creation went wrong with NAZARA_AUDIO_SAFE defined, * this could happen if parameters are invalid or creation of OpenAL buffers failed */ - - bool SoundBuffer::Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) + bool SoundBuffer::Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples) { Destroy(); @@ -132,19 +130,18 @@ namespace Nz ALuint buffer; alGenBuffers(1, &buffer); - if (alGetError() != AL_NO_ERROR) { NazaraError("Failed to create OpenAL buffer"); return false; } - alBufferData(buffer, OpenAL::AudioFormat[format], samples, sampleCount*sizeof(Int16), sampleRate); + CallOnExit clearBufferOnExit([buffer] () { alDeleteBuffers(1, &buffer); }); + + alBufferData(buffer, OpenAL::AudioFormat[format], samples, static_cast(sampleCount*sizeof(Int16)), static_cast(sampleRate)); if (alGetError() != AL_NO_ERROR) { - alDeleteBuffers(1, &buffer); - NazaraError("Failed to set OpenAL buffer"); return false; } @@ -158,6 +155,8 @@ namespace Nz m_impl->samples.reset(new Int16[sampleCount]); std::memcpy(&m_impl->samples[0], samples, sampleCount*sizeof(Int16)); + clearBufferOnExit.Reset(); + return true; } @@ -182,16 +181,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - UInt32 SoundBuffer::GetDuration() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->duration; } @@ -205,13 +197,7 @@ namespace Nz AudioFormat SoundBuffer::GetFormat() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return AudioFormat_Unknown; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->format; } @@ -222,16 +208,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - const Int16* SoundBuffer::GetSamples() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->samples.get(); } @@ -242,16 +221,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - - unsigned int SoundBuffer::GetSampleCount() const + UInt64 SoundBuffer::GetSampleCount() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->sampleCount; } @@ -262,16 +234,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - - unsigned int SoundBuffer::GetSampleRate() const + UInt32 SoundBuffer::GetSampleRate() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->sampleRate; } @@ -293,7 +258,6 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the sound buffer */ - bool SoundBuffer::LoadFromFile(const String& filePath, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromFile(this, filePath, params); @@ -307,7 +271,6 @@ namespace Nz * \param size Size of the memory * \param params Parameters for the sound buffer */ - bool SoundBuffer::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromMemory(this, data, size, params); @@ -320,7 +283,6 @@ namespace Nz * \param stream Stream to the sound buffer * \param params Parameters for the sound buffer */ - bool SoundBuffer::LoadFromStream(Stream& stream, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromStream(this, stream, params); @@ -332,7 +294,6 @@ namespace Nz * * \param format Format to check */ - bool SoundBuffer::IsFormatSupported(AudioFormat format) { return Audio::IsFormatSupported(format); @@ -344,7 +305,6 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - unsigned int SoundBuffer::GetOpenALBuffer() const { #ifdef NAZARA_DEBUG @@ -364,7 +324,6 @@ namespace Nz * * \remark Produces a NazaraError if sub-initialization failed */ - bool SoundBuffer::Initialize() { if (!SoundBufferLibrary::Initialize()) @@ -385,7 +344,6 @@ namespace Nz /*! * \brief Uninitializes the libraries and managers */ - void SoundBuffer::Uninitialize() { SoundBufferManager::Uninitialize(); From 2b27ba35c3760e94d56ec384ff9ffa9db9fffd9b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 19:58:22 +0200 Subject: [PATCH 215/235] Lua/LuaInstance: Improve code Former-commit-id: fa50a5a8610ac3f9c91392cf3eda8ea2ece2fadb [formerly 79dca34081cf9590ee906053bec751337a9a6dfd] [formerly c57fc5a5e10d531d14bcff891a9e9621db26a2b5 [formerly d3694fd32c07d74029120427321eb96815625fcd]] Former-commit-id: c3b064cf106b0ad7929b7b2267b1580ea41bcaf6 [formerly a309b75b7d85d22a9866b4c6bf0be39a6ce34ad6] Former-commit-id: 46ac5dd063eb4c05ac5fb7cc6fa414c02e2ed43d --- include/Nazara/Lua/LuaInstance.hpp | 12 +++++------ include/Nazara/Lua/LuaInstance.inl | 25 +++++++++++++++++++++++ src/Nazara/Lua/LuaInstance.cpp | 32 ++++-------------------------- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index e3bc517f8..c6d7c6385 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -92,16 +92,16 @@ namespace Nz LuaType GetField(const String& fieldName, int tableIndex = -1) const; LuaType GetGlobal(const char* name) const; LuaType GetGlobal(const String& name) const; - lua_State* GetInternalState() const; - String GetLastError() const; - UInt32 GetMemoryLimit() const; - UInt32 GetMemoryUsage() const; + inline lua_State* GetInternalState() const; + inline String GetLastError() const; + inline std::size_t GetMemoryLimit() const; + inline std::size_t GetMemoryUsage() const; LuaType GetMetatable(const char* tname) const; LuaType GetMetatable(const String& tname) const; bool GetMetatable(int index) const; unsigned int GetStackTop() const; LuaType GetTable(int index = -2) const; - UInt32 GetTimeLimit() const; + inline UInt32 GetTimeLimit() const; LuaType GetType(int index) const; const char* GetTypeName(LuaType type) const; @@ -144,7 +144,7 @@ namespace Nz void PushString(const char* str) const; void PushString(const char* str, std::size_t size) const; void PushString(const String& str) const; - void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0) const; + void PushTable(std::size_t sequenceElementCount = 0, std::size_t arrayElementCount = 0) const; void* PushUserdata(std::size_t size) const; void PushValue(int index) const; diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index f9f5e662f..e6a4b5482 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -25,6 +25,31 @@ namespace Nz instance.m_state = nullptr; } + inline lua_State* LuaInstance::GetInternalState() const + { + return m_state; + } + + inline String LuaInstance::GetLastError() const + { + return m_lastError; + } + + inline std::size_t LuaInstance::GetMemoryLimit() const + { + return m_memoryLimit; + } + + inline std::size_t LuaInstance::GetMemoryUsage() const + { + return m_memoryUsage; + } + + inline UInt32 LuaInstance::GetTimeLimit() const + { + return m_timeLimit; + } + inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept { m_clock = std::move(m_clock); diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index f31c6fe83..f73c4a207 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -464,26 +464,6 @@ namespace Nz return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer())); } - lua_State* LuaInstance::GetInternalState() const - { - return m_state; - } - - String LuaInstance::GetLastError() const - { - return m_lastError; - } - - UInt32 LuaInstance::GetMemoryLimit() const - { - return m_memoryLimit; - } - - UInt32 LuaInstance::GetMemoryUsage() const - { - return m_memoryUsage; - } - LuaType LuaInstance::GetMetatable(const char* tname) const { return FromLuaType(luaL_getmetatable(m_state, tname)); @@ -501,7 +481,7 @@ namespace Nz unsigned int LuaInstance::GetStackTop() const { - return lua_gettop(m_state); + return static_cast(lua_gettop(m_state)); } LuaType LuaInstance::GetTable(int index) const @@ -509,11 +489,6 @@ namespace Nz return FromLuaType(lua_gettable(m_state, index)); } - UInt32 LuaInstance::GetTimeLimit() const - { - return m_timeLimit; - } - LuaType LuaInstance::GetType(int index) const { return FromLuaType(lua_type(m_state, index)); @@ -690,9 +665,10 @@ namespace Nz lua_pushlstring(m_state, str.GetConstBuffer(), str.GetSize()); } - void LuaInstance::PushTable(unsigned int sequenceElementCount, unsigned int arrayElementCount) const + void LuaInstance::PushTable(std::size_t sequenceElementCount, std::size_t arrayElementCount) const { - lua_createtable(m_state, sequenceElementCount, arrayElementCount); + constexpr std::size_t maxInt = std::numeric_limits::max(); + lua_createtable(m_state, static_cast(std::min(sequenceElementCount, maxInt)), static_cast(std::min(arrayElementCount, maxInt))); } void* LuaInstance::PushUserdata(std::size_t size) const From 05053fdf5e189be9cc3bcd27ea1d21129c14c61e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 20:02:23 +0200 Subject: [PATCH 216/235] Sdk/GraphicsComponent: Allows to setup an offset to renderables Former-commit-id: 8803527725eb537ec2a85e64479ac9037b59da48 [formerly 8d2aca710c0fa942c6a5b89e0c6cba5722cf1601] [formerly e44866a9ffea3643893ffff5d9fe8418b00b961d [formerly 6efd8e148208de0d2817679321acca69f75617fc]] Former-commit-id: e79e25aca4df5fc5ee79b5963a35050d8c3cd79c [formerly 8e324bda1c9e43fb88aaf31e2d38b0ff587aa03f] Former-commit-id: 735155f96801d382e36f9be78c44afbcb35cb236 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 1 + SDK/include/NDK/Components/GraphicsComponent.inl | 13 ++++++++++++- SDK/src/NDK/Components/GraphicsComponent.cpp | 2 +- include/Nazara/Graphics/InstancedRenderable.hpp | 8 +++++--- include/Nazara/Graphics/Model.inl | 3 ++- src/Nazara/Graphics/Billboard.cpp | 2 +- src/Nazara/Graphics/InstancedRenderable.cpp | 2 +- src/Nazara/Graphics/Model.cpp | 2 +- src/Nazara/Graphics/SkeletalModel.cpp | 2 +- src/Nazara/Graphics/Sprite.cpp | 8 ++++---- src/Nazara/Graphics/TextSprite.cpp | 2 +- src/Nazara/Graphics/TileMap.cpp | 8 ++++---- 12 files changed, 34 insertions(+), 19 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index ec16ba593..b792cfd69 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -32,6 +32,7 @@ namespace Ndk inline 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); inline void Clear(); diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 01cd7a2e3..bd3e6dbfb 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -2,8 +2,10 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include +#include +#include #include -#include "GraphicsComponent.hpp" namespace Ndk { @@ -36,10 +38,13 @@ namespace Ndk { EnsureTransformMatrixUpdate(); + Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem(); + 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; } @@ -56,9 +61,15 @@ namespace Ndk */ 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)); diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index 759d3f24b..e06890c97 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -133,7 +133,7 @@ namespace Ndk Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem(); - m_transformMatrix = Nz::Matrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), m_entity->GetComponent().GetTransformMatrix()); + m_transformMatrix = m_entity->GetComponent().GetTransformMatrix(); m_transformMatrixUpdated = true; } diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index d854a41d6..8b44d7512 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -54,8 +54,8 @@ namespace Nz struct InstanceData { - InstanceData(const Matrix4f& referenceMatrix) : - transformMatrix(&referenceMatrix), + InstanceData(const Matrix4f& transformationMatrix) : + localMatrix(transformationMatrix), flags(0) { } @@ -67,6 +67,7 @@ namespace Nz data = std::move(instanceData.data); flags = instanceData.flags; renderOrder = instanceData.renderOrder; + localMatrix = instanceData.localMatrix; transformMatrix = instanceData.transformMatrix; volume = instanceData.volume; @@ -75,7 +76,8 @@ namespace Nz std::vector data; BoundingVolumef volume; - const Matrix4f* transformMatrix; + Matrix4f localMatrix; + mutable Matrix4f transformMatrix; UInt32 flags; int renderOrder; }; diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index 243611fb5..8e659e869 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -18,8 +18,9 @@ namespace Nz */ inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder) { - InstanceData instanceData(transformMatrix); + InstanceData instanceData(Nz::Matrix4f::Identity()); instanceData.renderOrder = renderOrder; + instanceData.transformMatrix = transformMatrix; return AddToRenderQueue(renderQueue, instanceData); } diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 17a2ad065..4aed923ae 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -30,7 +30,7 @@ namespace Nz if (!m_material) return; - Nz::Vector3f position = instanceData.transformMatrix->GetTranslation(); + Nz::Vector3f position = instanceData.transformMatrix.GetTranslation(); renderQueue->AddBillboards(instanceData.renderOrder, m_material, 1, &position, &m_size, &m_sinCos, &m_color); } diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index 03da17984..ef5f62b96 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -80,7 +80,7 @@ namespace Nz NazaraAssert(instanceData, "Invalid instance data"); NazaraUnused(instanceData); - instanceData->volume.Update(*instanceData->transformMatrix); + instanceData->volume.Update(instanceData->transformMatrix); } /*! diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index 2b9e03cc1..d382c77d9 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -82,7 +82,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = mesh->GetVertexBuffer(); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), *instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index 8621d1fce..b91ac0076 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -69,7 +69,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = SkinningManager::GetBuffer(mesh, &m_skeleton); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), *instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index f4b2f0dab..8b950bf2a 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -62,19 +62,19 @@ namespace Nz Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); + *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() - origin); + *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down() - origin); + *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); + *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 2f1d733b4..42dba4aaf 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -310,7 +310,7 @@ namespace Nz Vector3f localPos = localVertex->position.x*Vector3f::Right() + localVertex->position.y*Vector3f::Down(); localPos *= m_scale; - *pos++ = instanceData->transformMatrix->Transform(localPos); + *pos++ = instanceData->transformMatrix.Transform(localPos); *color++ = m_color * localVertex->color; *uv++ = localVertex->uv; diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index 2c6e26aa4..255685f43 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -71,19 +71,19 @@ namespace Nz Vector3f tileLeftCorner(x * m_tileSize.x, y * -m_tileSize.y, 0.f); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right()); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.y * Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner + m_tileSize.y * Vector3f::Down()); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right() + m_tileSize.y * Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right() + m_tileSize.y * Vector3f::Down()); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightBottom); } spriteCount += layer.tiles.size(); From bcb05f13f8f00f32fd2bdeb49c796bbf5d9d8175 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 20:39:34 +0200 Subject: [PATCH 217/235] Utility: First code cleaning pass Former-commit-id: 834097e149f393c278e47ff31c8c4d12b0628d2b [formerly 5eb47a1c307a874555e07106b0d484ecc0958345] [formerly fab49feb40dbc3bfdc959659ff74a6d3a2b59606 [formerly a2be53055f8fb8123035e145ea2edb0043d780e2]] Former-commit-id: d44f84cccad74434dc02a97a2a9b7a72dca49f5c [formerly d21b193e02096275d145af82ca4468f67ce1f74c] Former-commit-id: 618d73318ca6c9ad86b091312858b38024b3a5e0 --- include/Nazara/Utility/Animation.hpp | 29 +- .../Nazara/Utility/Formats/MD5AnimParser.hpp | 14 +- .../Nazara/Utility/Formats/MD5MeshParser.hpp | 6 +- include/Nazara/Utility/Formats/OBJParser.hpp | 34 +- include/Nazara/Utility/Formats/OBJParser.inl | 30 +- include/Nazara/Utility/Mesh.hpp | 30 +- include/Nazara/Utility/Sequence.hpp | 6 +- include/Nazara/Utility/Skeleton.hpp | 10 +- include/Nazara/Utility/SubMesh.hpp | 10 +- include/Nazara/Utility/VertexMapper.inl | 2 +- src/Nazara/Utility/Animation.cpp | 326 +++--------------- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 12 +- src/Nazara/Utility/Formats/MD5AnimParser.cpp | 52 +-- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 12 +- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 18 +- src/Nazara/Utility/Formats/MTLParser.cpp | 16 +- src/Nazara/Utility/Formats/OBJLoader.cpp | 22 +- src/Nazara/Utility/Formats/OBJParser.cpp | 28 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 14 +- src/Nazara/Utility/Mesh.cpp | 58 ++-- src/Nazara/Utility/Skeleton.cpp | 32 +- src/Nazara/Utility/SubMesh.cpp | 4 +- 22 files changed, 276 insertions(+), 489 deletions(-) diff --git a/include/Nazara/Utility/Animation.hpp b/include/Nazara/Utility/Animation.hpp index e196a0f77..2ab1f2baa 100644 --- a/include/Nazara/Utility/Animation.hpp +++ b/include/Nazara/Utility/Animation.hpp @@ -20,16 +20,15 @@ #include #include #include -#include namespace Nz { struct NAZARA_UTILITY_API AnimationParams : ResourceParameters { // La frame de fin à charger - unsigned int endFrame = std::numeric_limits::max(); + UInt32 endFrame = 0xFFFFFFFF; // La frame de début à charger - unsigned int startFrame = 0; + UInt32 startFrame = 0; bool IsValid() const; }; @@ -57,27 +56,27 @@ namespace Nz ~Animation(); bool AddSequence(const Sequence& sequence); - void AnimateSkeleton(Skeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const; + void AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const; - bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount); + bool CreateSkeletal(UInt32 frameCount, UInt32 jointCount); void Destroy(); void EnableLoopPointInterpolation(bool loopPointInterpolation); - unsigned int GetFrameCount() const; - unsigned int GetJointCount() const; + UInt32 GetFrameCount() const; + UInt32 GetJointCount() const; Sequence* GetSequence(const String& sequenceName); - Sequence* GetSequence(unsigned int index); + Sequence* GetSequence(UInt32 index); const Sequence* GetSequence(const String& sequenceName) const; - const Sequence* GetSequence(unsigned int index) const; - unsigned int GetSequenceCount() const; - int GetSequenceIndex(const String& sequenceName) const; - SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0); - const SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const; + const Sequence* GetSequence(UInt32 index) const; + UInt32 GetSequenceCount() const; + UInt32 GetSequenceIndex(const String& sequenceName) const; + SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0); + const SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0) const; AnimationType GetType() const; bool HasSequence(const String& sequenceName) const; - bool HasSequence(unsigned int index = 0) const; + bool HasSequence(UInt32 index = 0) const; bool IsLoopPointInterpolationEnabled() const; bool IsValid() const; @@ -87,7 +86,7 @@ namespace Nz bool LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams()); void RemoveSequence(const String& sequenceName); - void RemoveSequence(unsigned int index); + void RemoveSequence(UInt32 index); template static AnimationRef New(Args&&... args); diff --git a/include/Nazara/Utility/Formats/MD5AnimParser.hpp b/include/Nazara/Utility/Formats/MD5AnimParser.hpp index 558608142..3a9e2163d 100644 --- a/include/Nazara/Utility/Formats/MD5AnimParser.hpp +++ b/include/Nazara/Utility/Formats/MD5AnimParser.hpp @@ -34,12 +34,12 @@ namespace Nz struct Joint { + Int32 parent; Quaternionf bindOrient; String name; Vector3f bindPos; - int parent; - unsigned int flags; - unsigned int index; + UInt32 flags; + UInt32 index; }; MD5AnimParser(Stream& stream); @@ -47,12 +47,12 @@ namespace Nz Ternary Check(); - std::size_t GetAnimatedComponentCount() const; + UInt32 GetAnimatedComponentCount() const; const Frame* GetFrames() const; - std::size_t GetFrameCount() const; - std::size_t GetFrameRate() const; + UInt32 GetFrameCount() const; + UInt32 GetFrameRate() const; const Joint* GetJoints() const; - std::size_t GetJointCount() const; + UInt32 GetJointCount() const; bool Parse(); diff --git a/include/Nazara/Utility/Formats/MD5MeshParser.hpp b/include/Nazara/Utility/Formats/MD5MeshParser.hpp index cd2d19309..b515c1226 100644 --- a/include/Nazara/Utility/Formats/MD5MeshParser.hpp +++ b/include/Nazara/Utility/Formats/MD5MeshParser.hpp @@ -22,10 +22,10 @@ namespace Nz public: struct Joint { + Int32 parent; Quaternionf bindOrient; String name; Vector3f bindPos; - int parent; }; typedef Vector3ui Triangle; @@ -58,9 +58,9 @@ namespace Nz Ternary Check(); const Joint* GetJoints() const; - std::size_t GetJointCount() const; + UInt32 GetJointCount() const; const Mesh* GetMeshes() const; - std::size_t GetMeshCount() const; + UInt32 GetMeshCount() const; bool Parse(); diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 114f72635..6c0c35af4 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -31,43 +31,43 @@ namespace Nz inline String* GetMaterials(); inline const String* GetMaterials() const; - inline unsigned int GetMaterialCount() const; + inline UInt32 GetMaterialCount() const; inline Mesh* GetMeshes(); inline const Mesh* GetMeshes() const; - inline unsigned int GetMeshCount() const; + inline UInt32 GetMeshCount() const; inline const String& GetMtlLib() const; inline Vector3f* GetNormals(); inline const Vector3f* GetNormals() const; - inline unsigned int GetNormalCount() const; + inline UInt32 GetNormalCount() const; inline Vector4f* GetPositions(); inline const Vector4f* GetPositions() const; - inline unsigned int GetPositionCount() const; + inline UInt32 GetPositionCount() const; inline Vector3f* GetTexCoords(); inline const Vector3f* GetTexCoords() const; - inline unsigned int GetTexCoordCount() const; + inline UInt32 GetTexCoordCount() const; - bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); + bool Parse(Stream& stream, UInt32 reservedVertexCount = 100); bool Save(Stream& stream) const; - inline String* SetMaterialCount(std::size_t materialCount); - inline Mesh* SetMeshCount(std::size_t meshCount); + inline String* SetMaterialCount(UInt32 materialCount); + inline Mesh* SetMeshCount(UInt32 meshCount); inline void SetMtlLib(const String& mtlLib); - inline Vector3f* SetNormalCount(std::size_t normalCount); - inline Vector4f* SetPositionCount(std::size_t positionCount); - inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); + inline Vector3f* SetNormalCount(UInt32 normalCount); + inline Vector4f* SetPositionCount(UInt32 positionCount); + inline Vector3f* SetTexCoordCount(UInt32 texCoordCount); struct Face { - std::size_t firstVertex; - std::size_t vertexCount; + UInt32 firstVertex; + UInt32 vertexCount; }; struct FaceVertex { - std::size_t normal; - std::size_t position; - std::size_t texCoord; + UInt32 normal; + UInt32 position; + UInt32 texCoord; }; struct Mesh @@ -75,7 +75,7 @@ namespace Nz std::vector faces; std::vector vertices; String name; - std::size_t material; + UInt32 material; }; private: diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index b04506fdf..41e794f82 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -27,9 +27,9 @@ namespace Nz return m_materials.data(); } - inline unsigned int OBJParser::GetMaterialCount() const + inline UInt32 OBJParser::GetMaterialCount() const { - return m_materials.size(); + return static_cast(m_materials.size()); } inline OBJParser::Mesh* OBJParser::GetMeshes() @@ -42,9 +42,9 @@ namespace Nz return m_meshes.data(); } - inline unsigned int OBJParser::GetMeshCount() const + inline UInt32 OBJParser::GetMeshCount() const { - return m_meshes.size(); + return static_cast(m_meshes.size()); } inline const String& OBJParser::GetMtlLib() const @@ -62,9 +62,9 @@ namespace Nz return m_normals.data(); } - inline unsigned int OBJParser::GetNormalCount() const + inline UInt32 OBJParser::GetNormalCount() const { - return m_normals.size(); + return static_cast(m_normals.size()); } inline Vector4f* OBJParser::GetPositions() @@ -77,9 +77,9 @@ namespace Nz return m_positions.data(); } - inline unsigned int OBJParser::GetPositionCount() const + inline UInt32 OBJParser::GetPositionCount() const { - return m_positions.size(); + return static_cast(m_positions.size()); } inline Vector3f* OBJParser::GetTexCoords() @@ -92,18 +92,18 @@ namespace Nz return m_texCoords.data(); } - inline unsigned int OBJParser::GetTexCoordCount() const + inline UInt32 OBJParser::GetTexCoordCount() const { - return m_texCoords.size(); + return static_cast(m_texCoords.size()); } - inline String* OBJParser::SetMaterialCount(std::size_t materialCount) + inline String* OBJParser::SetMaterialCount(UInt32 materialCount) { m_materials.resize(materialCount); return m_materials.data(); } - inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount) + inline OBJParser::Mesh* OBJParser::SetMeshCount(UInt32 meshCount) { m_meshes.resize(meshCount); return m_meshes.data(); @@ -114,19 +114,19 @@ namespace Nz m_mtlLib = mtlLib; } - inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) + inline Vector3f* OBJParser::SetNormalCount(UInt32 normalCount) { m_normals.resize(normalCount); return m_normals.data(); } - inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount) + inline Vector4f* OBJParser::SetPositionCount(UInt32 positionCount) { m_positions.resize(positionCount); return m_positions.data(); } - inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount) + inline Vector3f* OBJParser::SetTexCoordCount(UInt32 texCoordCount) { m_texCoords.resize(texCoordCount); return m_texCoords.data(); diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 62a372384..60ccb98b1 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -84,7 +84,7 @@ namespace Nz SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams()); void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams()); - bool CreateSkeletal(unsigned int jointCount); + bool CreateSkeletal(UInt32 jointCount); bool CreateStatic(); void Destroy(); @@ -95,23 +95,23 @@ namespace Nz const Boxf& GetAABB() const; String GetAnimation() const; AnimationType GetAnimationType() const; - unsigned int GetJointCount() const; - ParameterList& GetMaterialData(unsigned int index); - const ParameterList& GetMaterialData(unsigned int index) const; - unsigned int GetMaterialCount() const; + UInt32 GetJointCount() const; + ParameterList& GetMaterialData(UInt32 index); + const ParameterList& GetMaterialData(UInt32 index) const; + UInt32 GetMaterialCount() const; Skeleton* GetSkeleton(); const Skeleton* GetSkeleton() const; SubMesh* GetSubMesh(const String& identifier); - SubMesh* GetSubMesh(unsigned int index); + SubMesh* GetSubMesh(UInt32 index); const SubMesh* GetSubMesh(const String& identifier) const; - const SubMesh* GetSubMesh(unsigned int index) const; - unsigned int GetSubMeshCount() const; - int GetSubMeshIndex(const String& identifier) const; - unsigned int GetTriangleCount() const; - unsigned int GetVertexCount() const; + const SubMesh* GetSubMesh(UInt32 index) const; + UInt32 GetSubMeshCount() const; + UInt32 GetSubMeshIndex(const String& identifier) const; + UInt32 GetTriangleCount() const; + UInt32 GetVertexCount() const; bool HasSubMesh(const String& identifier) const; - bool HasSubMesh(unsigned int index = 0) const; + bool HasSubMesh(UInt32 index = 0) const; void InvalidateAABB() const; @@ -125,14 +125,14 @@ namespace Nz void Recenter(); void RemoveSubMesh(const String& identifier); - void RemoveSubMesh(unsigned int index); + void RemoveSubMesh(UInt32 index); bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams()); bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams()); void SetAnimation(const String& animationPath); - void SetMaterialCount(unsigned int matCount); - void SetMaterialData(unsigned int matIndex, ParameterList data); + void SetMaterialCount(UInt32 matCount); + void SetMaterialData(UInt32 matIndex, ParameterList data); void Transform(const Matrix4f& matrix); diff --git a/include/Nazara/Utility/Sequence.hpp b/include/Nazara/Utility/Sequence.hpp index 1c6812eb7..b8549a4bf 100644 --- a/include/Nazara/Utility/Sequence.hpp +++ b/include/Nazara/Utility/Sequence.hpp @@ -16,9 +16,9 @@ namespace Nz struct Sequence { String name; - unsigned int firstFrame; - unsigned int frameCount; - unsigned int frameRate; + UInt32 firstFrame; + UInt32 frameCount; + UInt32 frameRate; }; struct SequenceJoint diff --git a/include/Nazara/Utility/Skeleton.hpp b/include/Nazara/Utility/Skeleton.hpp index fa217e6d4..8312f967f 100644 --- a/include/Nazara/Utility/Skeleton.hpp +++ b/include/Nazara/Utility/Skeleton.hpp @@ -37,21 +37,21 @@ namespace Nz Skeleton(const Skeleton& skeleton); ~Skeleton(); - bool Create(unsigned int jointCount); + bool Create(UInt32 jointCount); void Destroy(); const Boxf& GetAABB() const; Joint* GetJoint(const String& jointName); - Joint* GetJoint(unsigned int index); + Joint* GetJoint(UInt32 index); const Joint* GetJoint(const String& jointName) const; - const Joint* GetJoint(unsigned int index) const; + const Joint* GetJoint(UInt32 index) const; Joint* GetJoints(); const Joint* GetJoints() const; - unsigned int GetJointCount() const; + UInt32 GetJointCount() const; int GetJointIndex(const String& jointName) const; void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation); - void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount); + void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount); bool IsValid() const; diff --git a/include/Nazara/Utility/SubMesh.hpp b/include/Nazara/Utility/SubMesh.hpp index 6eee3a152..525930e0b 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -39,15 +39,15 @@ namespace Nz virtual const Boxf& GetAABB() const = 0; virtual AnimationType GetAnimationType() const = 0; virtual const IndexBuffer* GetIndexBuffer() const = 0; - unsigned int GetMaterialIndex() const; + UInt32 GetMaterialIndex() const; const Mesh* GetParent() const; PrimitiveMode GetPrimitiveMode() const; - unsigned int GetTriangleCount() const; - virtual unsigned int GetVertexCount() const = 0; + UInt32 GetTriangleCount() const; + virtual UInt32 GetVertexCount() const = 0; virtual bool IsAnimated() const = 0; - void SetMaterialIndex(unsigned int matIndex); + void SetMaterialIndex(UInt32 matIndex); void SetPrimitiveMode(PrimitiveMode mode); // Signals: @@ -56,7 +56,7 @@ namespace Nz protected: PrimitiveMode m_primitiveMode; const Mesh* m_parent; - unsigned int m_matIndex; + UInt32 m_matIndex; }; } diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index 7b36743eb..4a155bfbd 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -28,8 +28,8 @@ namespace Nz { NazaraError("Attribute 0x" + String::Number(component, 16) + " is not enabled"); return SparsePtr(); + } } } -} #include diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index 62591344b..a996f85a5 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -14,13 +14,13 @@ namespace Nz { struct AnimationImpl { - std::unordered_map sequenceMap; + std::unordered_map sequenceMap; std::vector sequences; std::vector sequenceJoints; // Uniquement pour les animations squelettiques AnimationType type; bool loopPointInterpolation = false; - unsigned int frameCount; - unsigned int jointCount; // Uniquement pour les animations squelettiques + UInt32 frameCount; + UInt32 jointCount; // Uniquement pour les animations squelettiques }; bool AnimationParams::IsValid() const @@ -43,40 +43,18 @@ namespace Nz bool Animation::AddSequence(const Sequence& sequence) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - - if (sequence.frameCount == 0) - { - NazaraError("Sequence frame count must be over zero"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(sequence.frameCount > 0, "Sequence frame count must be over zero"); if (m_impl->type == AnimationType_Skeletal) { - unsigned int endFrame = sequence.firstFrame + sequence.frameCount - 1; + UInt32 endFrame = sequence.firstFrame + sequence.frameCount - 1; if (endFrame >= m_impl->frameCount) { m_impl->frameCount = endFrame+1; m_impl->sequenceJoints.resize(m_impl->frameCount*m_impl->jointCount); } } - #if NAZARA_UTILITY_SAFE - else - { - unsigned int endFrame = sequence.firstFrame + sequence.frameCount - 1; - if (endFrame >= m_impl->frameCount) - { - NazaraError("Sequence end frame is over animation end frame"); - return false; - } - } - #endif if (!sequence.name.IsEmpty()) { @@ -84,12 +62,12 @@ namespace Nz auto it = m_impl->sequenceMap.find(sequence.name); if (it != m_impl->sequenceMap.end()) { - NazaraError("Sequence name \"" + sequence.name + "\" is already used"); + NazaraError("Sequence name \"" + sequence.name + "\" is already in use"); return false; } #endif - m_impl->sequenceMap[sequence.name] = m_impl->sequences.size(); + m_impl->sequenceMap[sequence.name] = static_cast(m_impl->sequences.size()); } m_impl->sequences.push_back(sequence); @@ -97,55 +75,16 @@ namespace Nz return true; } - void Animation::AnimateSkeleton(Skeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const + void Animation::AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); + NazaraAssert(targetSkeleton && targetSkeleton->IsValid(), "Invalid skeleton"); + NazaraAssert(targetSkeleton->GetJointCount() == m_impl->jointCount, "Skeleton joint does not match animation joint count"); + NazaraAssert(frameA < m_impl->frameCount, "FrameA is out of range"); + NazaraAssert(frameB < m_impl->frameCount, "FrameB is out of range"); - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return; - } - - if (!targetSkeleton || !targetSkeleton->IsValid()) - { - NazaraError("Target skeleton is invalid"); - return; - } - - if (targetSkeleton->GetJointCount() != m_impl->jointCount) - { - NazaraError("Target skeleton joint count must match animation joint count"); - return; - } - - if (frameA >= m_impl->frameCount) - { - NazaraError("Frame A is out of range (" + String::Number(frameA) + " >= " + String::Number(m_impl->frameCount) + ')'); - return; - } - - if (frameB >= m_impl->frameCount) - { - NazaraError("Frame B is out of range (" + String::Number(frameB) + " >= " + String::Number(m_impl->frameCount) + ')'); - return; - } - #endif - - #ifdef NAZARA_DEBUG - if (interpolation < 0.f || interpolation > 1.f) - { - NazaraError("Interpolation must be in range [0..1] (Got " + String::Number(interpolation) + ')'); - return; - } - #endif - - for (unsigned int i = 0; i < m_impl->jointCount; ++i) + for (UInt32 i = 0; i < m_impl->jointCount; ++i) { Joint* joint = targetSkeleton->GetJoint(i); @@ -158,17 +97,12 @@ namespace Nz } } - bool Animation::CreateSkeletal(unsigned int frameCount, unsigned int jointCount) + bool Animation::CreateSkeletal(UInt32 frameCount, UInt32 jointCount) { - Destroy(); + NazaraAssert(frameCount > 0, "Frame count must be over zero"); + NazaraAssert(jointCount > 0, "Frame count must be over zero"); - #if NAZARA_UTILITY_SAFE - if (frameCount == 0) - { - NazaraError("Frame count must be over zero"); - return false; - } - #endif + Destroy(); m_impl = new AnimationImpl; m_impl->frameCount = frameCount; @@ -192,255 +126,130 @@ namespace Nz void Animation::EnableLoopPointInterpolation(bool loopPointInterpolation) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } - #endif + NazaraAssert(m_impl, "Animation not created"); m_impl->loopPointInterpolation = loopPointInterpolation; } - unsigned int Animation::GetFrameCount() const + UInt32 Animation::GetFrameCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->frameCount; } - unsigned int Animation::GetJointCount() const + UInt32 Animation::GetJointCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return 0; - } - - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return 0; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->jointCount; } Sequence* Animation::GetSequence(const String& sequenceName) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(sequenceName); - - #if NAZARA_UTILITY_SAFE if (it == m_impl->sequenceMap.end()) { NazaraError("Sequence not found"); return nullptr; } - #endif return &m_impl->sequences[it->second]; } - Sequence* Animation::GetSequence(unsigned int index) + Sequence* Animation::GetSequence(UInt32 index) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (index >= m_impl->sequences.size()) - { - NazaraError("Sequence index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->sequences.size()) + ')'); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); return &m_impl->sequences[index]; } const Sequence* Animation::GetSequence(const String& sequenceName) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(sequenceName); - - #if NAZARA_UTILITY_SAFE if (it == m_impl->sequenceMap.end()) { NazaraError("Sequence not found"); return nullptr; } - #endif return &m_impl->sequences[it->second]; } - const Sequence* Animation::GetSequence(unsigned int index) const + const Sequence* Animation::GetSequence(UInt32 index) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (index >= m_impl->sequences.size()) - { - NazaraError("Sequence index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->sequences.size()) + ')'); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); return &m_impl->sequences[index]; } - unsigned int Animation::GetSequenceCount() const + UInt32 Animation::GetSequenceCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Animation not created"); - return m_impl->sequences.size(); + return static_cast(m_impl->sequences.size()); } - int Animation::GetSequenceIndex(const String& sequenceName) const + UInt32 Animation::GetSequenceIndex(const String& sequenceName) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return -1; - } - #endif + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(sequenceName); - - #if NAZARA_UTILITY_SAFE if (it == m_impl->sequenceMap.end()) { NazaraError("Sequence not found"); - return -1; + return 0xFFFFFFFF; } - #endif return it->second; } - SequenceJoint* Animation::GetSequenceJoints(unsigned int frameIndex) + SequenceJoint* Animation::GetSequenceJoints(UInt32 frameIndex) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); return &m_impl->sequenceJoints[frameIndex*m_impl->jointCount]; } - const SequenceJoint* Animation::GetSequenceJoints(unsigned int frameIndex) const + const SequenceJoint* Animation::GetSequenceJoints(UInt32 frameIndex) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); return &m_impl->sequenceJoints[frameIndex*m_impl->jointCount]; } AnimationType Animation::GetType() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return AnimationType_Static; // Ce qui est une valeur invalide pour Animation - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->type; } bool Animation::HasSequence(const String& sequenceName) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->sequenceMap.find(sequenceName) != m_impl->sequenceMap.end(); } - bool Animation::HasSequence(unsigned int index) const + bool Animation::HasSequence(UInt32 index) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return index >= m_impl->sequences.size(); } bool Animation::IsLoopPointInterpolationEnabled() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->loopPointInterpolation; } @@ -467,12 +276,7 @@ namespace Nz void Animation::RemoveSequence(const String& identifier) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(identifier); if (it == m_impl->sequenceMap.end()) @@ -481,32 +285,16 @@ namespace Nz return; } - int index = it->second; - #else - int index = m_impl->sequenceMap[identifier]; - #endif + auto sequenceIt = m_impl->sequences.begin(); + std::advance(sequenceIt, it->second); - auto it2 = m_impl->sequences.begin(); - std::advance(it2, index); - - m_impl->sequences.erase(it2); + m_impl->sequences.erase(sequenceIt); } - void Animation::RemoveSequence(unsigned int index) + void Animation::RemoveSequence(UInt32 index) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } - - if (index >= m_impl->sequences.size()) - { - NazaraError("Sequence index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->sequences.size()) + ')'); - return; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); auto it = m_impl->sequences.begin(); std::advance(it, index); diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index e61f6dda2..942b54f8e 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -37,10 +37,10 @@ namespace Nz } const MD5AnimParser::Frame* frames = parser.GetFrames(); - std::size_t frameCount = parser.GetFrameCount(); - std::size_t frameRate = parser.GetFrameRate(); + UInt32 frameCount = parser.GetFrameCount(); + UInt32 frameRate = parser.GetFrameRate(); const MD5AnimParser::Joint* joints = parser.GetJoints(); - std::size_t jointCount = parser.GetJointCount(); + UInt32 jointCount = parser.GetJointCount(); // À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation animation->CreateSkeletal(frameCount, jointCount); @@ -57,12 +57,12 @@ namespace Nz // Pour que le squelette soit correctement aligné, il faut appliquer un quaternion "de correction" aux joints à la base du squelette Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) * - Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); + Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); - for (std::size_t i = 0; i < jointCount; ++i) + for (UInt32 i = 0; i < jointCount; ++i) { int parent = joints[i].parent; - for (std::size_t j = 0; j < frameCount; ++j) + for (UInt32 j = 0; j < frameCount; ++j) { SequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i]; diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index 105944858..a1b02153b 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -48,9 +48,9 @@ namespace Nz return Ternary_False; } - std::size_t MD5AnimParser::GetAnimatedComponentCount() const + UInt32 MD5AnimParser::GetAnimatedComponentCount() const { - return m_animatedComponents.size(); + return static_cast(m_animatedComponents.size()); } const MD5AnimParser::Frame* MD5AnimParser::GetFrames() const @@ -58,12 +58,12 @@ namespace Nz return m_frames.data(); } - std::size_t MD5AnimParser::GetFrameCount() const + UInt32 MD5AnimParser::GetFrameCount() const { - return m_frames.size(); + return static_cast(m_frames.size()); } - std::size_t MD5AnimParser::GetFrameRate() const + UInt32 MD5AnimParser::GetFrameRate() const { return m_frameRate; } @@ -73,9 +73,9 @@ namespace Nz return m_joints.data(); } - std::size_t MD5AnimParser::GetJointCount() const + UInt32 MD5AnimParser::GetJointCount() const { - return m_joints.size(); + return static_cast(m_joints.size()); } bool MD5AnimParser::Parse() @@ -209,14 +209,14 @@ namespace Nz } } - unsigned int frameCount = m_frames.size(); + std::size_t frameCount = m_frames.size(); if (frameCount == 0) { NazaraError("Frame count is invalid or missing"); return false; } - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { NazaraError("Joint count is invalid or missing"); @@ -273,21 +273,21 @@ namespace Nz bool MD5AnimParser::ParseBaseframe() { - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); return false; } - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { if (!Advance()) return false; // Space is important for the buffer of \n if (std::sscanf(&m_currentLine[0], " ( %f %f %f ) ( %f %f %f )", &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, - &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 6) + &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 6) { UnrecognizedLine(true); return false; @@ -312,14 +312,14 @@ namespace Nz bool MD5AnimParser::ParseBounds() { - unsigned int frameCount = m_frames.size(); + std::size_t frameCount = m_frames.size(); if (frameCount == 0) { Error("Frame count is invalid or missing"); return false; } - for (unsigned int i = 0; i < frameCount; ++i) + for (std::size_t i = 0; i < frameCount; ++i) { if (!Advance()) return false; @@ -353,14 +353,14 @@ namespace Nz bool MD5AnimParser::ParseFrame() { - unsigned int animatedComponentsCount = m_animatedComponents.size(); + std::size_t animatedComponentsCount = m_animatedComponents.size(); if (animatedComponentsCount == 0) { Error("Animated components count is missing or invalid"); return false; } - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); @@ -369,14 +369,14 @@ namespace Nz String line; - unsigned int count = 0; + std::size_t count = 0; do { if (!Advance()) return false; - unsigned int index = 0; - unsigned int size = m_currentLine.GetSize(); + std::size_t index = 0; + std::size_t size = m_currentLine.GetSize(); do { float f; @@ -399,11 +399,11 @@ namespace Nz m_frames[m_frameIndex].joints.resize(jointCount); - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { Quaternionf jointOrient = m_joints[i].bindOrient; Vector3f jointPos = m_joints[i].bindPos; - unsigned int j = 0; + UInt32 j = 0; if (m_joints[i].flags & 1) // Px jointPos.x = m_animatedComponents[m_joints[i].index + j++]; @@ -447,19 +447,19 @@ namespace Nz bool MD5AnimParser::ParseHierarchy() { - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); return false; } - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { if (!Advance()) return false; - unsigned int pos = m_currentLine.Find(' '); + std::size_t pos = m_currentLine.Find(' '); if (pos == String::npos) { UnrecognizedLine(true); @@ -482,10 +482,10 @@ namespace Nz m_joints[i].name = name; m_joints[i].name.Trim('"'); - int parent = m_joints[i].parent; + Int32 parent = m_joints[i].parent; if (parent >= 0) { - if (static_cast(parent) >= jointCount) + if (static_cast(parent) >= jointCount) { Error("Joint's parent is out of bounds (" + String::Number(parent) + " >= " + String::Number(jointCount) + ')'); return false; diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index cd8a6813a..59988405a 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -53,15 +53,15 @@ namespace Nz const MD5MeshParser::Joint* joints = parser.GetJoints(); const MD5MeshParser::Mesh* meshes = parser.GetMeshes(); - std::size_t jointCount = parser.GetJointCount(); - std::size_t meshCount = parser.GetMeshCount(); + UInt32 jointCount = parser.GetJointCount(); + UInt32 meshCount = parser.GetMeshCount(); if (parameters.animated) { mesh->CreateSkeletal(jointCount); Skeleton* skeleton = mesh->GetSkeleton(); - for (std::size_t i = 0; i < jointCount; ++i) + for (UInt32 i = 0; i < jointCount; ++i) { Joint* joint = skeleton->GetJoint(i); @@ -82,7 +82,7 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (std::size_t i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; @@ -100,7 +100,7 @@ namespace Nz // Le format définit un set de triangles nous permettant de retrouver facilement les indices // Cependant les sommets des triangles ne sont pas spécifiés dans le même ordre que ceux du moteur // (On parle ici de winding) - unsigned int index = 0; + UInt32 index = 0; for (const MD5MeshParser::Triangle& triangle : md5Mesh.triangles) { // On les respécifie dans le bon ordre (inversion du winding) @@ -227,7 +227,7 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (std::size_t i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; std::size_t indexCount = md5Mesh.triangles.size()*3; diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index b4fd04a33..ce5264d01 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -58,9 +58,9 @@ namespace Nz return m_joints.data(); } - std::size_t MD5MeshParser::GetJointCount() const + UInt32 MD5MeshParser::GetJointCount() const { - return m_joints.size(); + return static_cast(m_joints.size()); } const MD5MeshParser::Mesh* MD5MeshParser::GetMeshes() const @@ -68,9 +68,9 @@ namespace Nz return m_meshes.data(); } - std::size_t MD5MeshParser::GetMeshCount() const + UInt32 MD5MeshParser::GetMeshCount() const { - return m_meshes.size(); + return static_cast(m_meshes.size()); } bool MD5MeshParser::Parse() @@ -211,19 +211,19 @@ namespace Nz bool MD5MeshParser::ParseJoints() { - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); return false; } - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { if (!Advance()) return false; - unsigned int pos = m_currentLine.Find(' '); + std::size_t pos = m_currentLine.Find(' '); if (pos == String::npos) { UnrecognizedLine(true); @@ -248,10 +248,10 @@ namespace Nz m_joints[i].name = name; m_joints[i].name.Trim('"'); - int parent = m_joints[i].parent; + Int32 parent = m_joints[i].parent; if (parent >= 0) { - if (static_cast(parent) >= jointCount) + if (static_cast(parent) >= jointCount) { Error("Joint's parent is out of bounds (" + String::Number(parent) + " >= " + String::Number(jointCount) + ')'); return false; diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 6685bcd04..b31ee24a9 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -160,7 +160,7 @@ namespace Nz } else if (keyword == "map_ka") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -172,7 +172,7 @@ namespace Nz } else if (keyword == "map_kd") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -184,7 +184,7 @@ namespace Nz } else if (keyword == "map_ks") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -196,7 +196,7 @@ namespace Nz } else if (keyword == "map_bump" || keyword == "bump") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -208,7 +208,7 @@ namespace Nz } else if (keyword == "map_d") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -220,7 +220,7 @@ namespace Nz } else if (keyword == "map_decal" || keyword == "decal") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -232,7 +232,7 @@ namespace Nz } else if (keyword == "map_disp" || keyword == "disp") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -244,7 +244,7 @@ namespace Nz } else if (keyword == "map_refl" || keyword == "refl") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 405c845ea..11029bada 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -40,7 +40,7 @@ namespace Nz return Ternary_Unknown; } - bool ParseMTL(Mesh* mesh, const String& filePath, const String* materials, const OBJParser::Mesh* meshes, unsigned int meshCount) + bool ParseMTL(Mesh* mesh, const String& filePath, const String* materials, const OBJParser::Mesh* meshes, UInt32 meshCount) { File file(filePath); if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) @@ -58,7 +58,7 @@ namespace Nz std::unordered_map materialCache; String baseDir = file.GetDirectory(); - for (unsigned int i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const String& matName = materials[meshes[i].material]; const MTLParser::Material* mtlMat = materialParser.GetMaterial(matName); @@ -154,21 +154,21 @@ namespace Nz const Vector3f* texCoords = parser.GetTexCoords(); const OBJParser::Mesh* meshes = parser.GetMeshes(); - unsigned int meshCount = parser.GetMeshCount(); + UInt32 meshCount = parser.GetMeshCount(); NazaraAssert(materials != nullptr && positions != nullptr && normals != nullptr && texCoords != nullptr && meshes != nullptr && meshCount > 0, "Invalid OBJParser output"); // Un conteneur temporaire pour contenir les indices de face avant triangulation - std::vector faceIndices(3); // Comme il y aura au moins trois sommets - for (unsigned int i = 0; i < meshCount; ++i) + std::vector faceIndices(3); // Comme il y aura au moins trois sommets + for (UInt32 i = 0; i < meshCount; ++i) { - unsigned int faceCount = meshes[i].faces.size(); + std::size_t faceCount = meshes[i].faces.size(); if (faceCount == 0) continue; - std::vector indices; + std::vector indices; indices.reserve(faceCount*3); // Pire cas si les faces sont des triangles // Afin d'utiliser OBJParser::FaceVertex comme clé dans un unordered_map, @@ -205,10 +205,10 @@ namespace Nz unsigned int vertexCount = 0; for (unsigned int j = 0; j < faceCount; ++j) { - unsigned int faceVertexCount = meshes[i].faces[j].vertexCount; + UInt32 faceVertexCount = meshes[i].faces[j].vertexCount; faceIndices.resize(faceVertexCount); - for (unsigned int k = 0; k < faceVertexCount; ++k) + for (UInt32 k = 0; k < faceVertexCount; ++k) { const OBJParser::FaceVertex& vertex = meshes[i].vertices[meshes[i].faces[j].firstVertex + k]; @@ -220,7 +220,7 @@ namespace Nz } // Triangulation - for (unsigned int k = 1; k < faceVertexCount-1; ++k) + for (UInt32 k = 1; k < faceVertexCount-1; ++k) { indices.push_back(faceIndices[0]); indices.push_back(faceIndices[k]); @@ -234,7 +234,7 @@ namespace Nz // Remplissage des indices IndexMapper indexMapper(indexBuffer, BufferAccess_WriteOnly); - for (unsigned int j = 0; j < indices.size(); ++j) + for (std::size_t j = 0; j < indices.size(); ++j) indexMapper.Set(j, indices[j]); indexMapper.Unmap(); // Pour laisser les autres tâches affecter l'index buffer diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index e2b63b467..a520d6be1 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -13,7 +13,7 @@ namespace Nz { - bool OBJParser::Parse(Nz::Stream& stream, std::size_t reservedVertexCount) + bool OBJParser::Parse(Nz::Stream& stream, UInt32 reservedVertexCount) { m_currentStream = &stream; @@ -50,8 +50,8 @@ namespace Nz using MatPair = std::pair; std::unordered_map> meshesByName; - std::size_t faceReserve = 0; - std::size_t vertexReserve = 0; + UInt32 faceReserve = 0; + UInt32 vertexReserve = 0; unsigned int matCount = 0; auto GetMaterial = [&] (const String& meshName, const String& matName) -> Mesh* { @@ -79,16 +79,16 @@ namespace Nz { case '#': //< Comment // Some softwares write comments to gives the number of vertex/faces an importer can expect - std::size_t data; - if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %zu", &data) == 1) + unsigned int data; + if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %u", &data) == 1) m_positions.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %u", &data) == 1) m_normals.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %u", &data) == 1) m_texCoords.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %u", &data) == 1) faceReserve = data; - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %u", &data) == 1) vertexReserve = data; break; @@ -118,8 +118,8 @@ namespace Nz currentMesh = GetMaterial(meshName, matName); Face face; - face.firstVertex = currentMesh->vertices.size(); - face.vertexCount = vertexCount; + face.firstVertex = static_cast(currentMesh->vertices.size()); + face.vertexCount = static_cast(vertexCount); currentMesh->vertices.resize(face.firstVertex + vertexCount, FaceVertex{0, 0, 0}); @@ -203,9 +203,9 @@ namespace Nz break; } - currentMesh->vertices[face.firstVertex + i].normal = static_cast(n); - currentMesh->vertices[face.firstVertex + i].position = static_cast(p); - currentMesh->vertices[face.firstVertex + i].texCoord = static_cast(t); + currentMesh->vertices[face.firstVertex + i].normal = static_cast(n); + currentMesh->vertices[face.firstVertex + i].position = static_cast(p); + currentMesh->vertices[face.firstVertex + i].texCoord = static_cast(t); pos += offset; } diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index a7a2cda0b..534eb1952 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -78,7 +78,7 @@ namespace Nz return false; } - std::size_t worstCacheVertexCount = mesh.GetVertexCount(); + UInt32 worstCacheVertexCount = mesh.GetVertexCount(); OBJParser objFormat; objFormat.SetNormalCount(worstCacheVertexCount); objFormat.SetPositionCount(worstCacheVertexCount); @@ -101,9 +101,9 @@ namespace Nz MTLParser mtlFormat; std::unordered_set registredMaterials; - std::size_t matCount = mesh.GetMaterialCount(); + UInt32 matCount = mesh.GetMaterialCount(); String* materialNames = objFormat.SetMaterialCount(matCount); - for (std::size_t i = 0; i < matCount; ++i) + for (UInt32 i = 0; i < matCount; ++i) { const ParameterList& matData = mesh.GetMaterialData(i); @@ -152,13 +152,13 @@ namespace Nz } // Meshes - std::size_t meshCount = mesh.GetSubMeshCount(); + UInt32 meshCount = mesh.GetSubMeshCount(); OBJParser::Mesh* meshes = objFormat.SetMeshCount(meshCount); - for (std::size_t i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const StaticMesh* staticMesh = static_cast(mesh.GetSubMesh(i)); - std::size_t triangleCount = staticMesh->GetTriangleCount(); + UInt32 triangleCount = staticMesh->GetTriangleCount(); meshes[i].faces.resize(triangleCount); meshes[i].material = staticMesh->GetMaterialIndex(); @@ -180,7 +180,7 @@ namespace Nz face.firstVertex = faceIndex * 3; face.vertexCount = 3; - for (std::size_t j = 0; j < 3; ++j) + for (unsigned int j = 0; j < 3; ++j) { OBJParser::FaceVertex& vertexIndices = meshes[i].vertices[face.firstVertex + j]; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 84559abda..363be074d 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -55,7 +55,7 @@ namespace Nz materialData.resize(1); // Un matériau par défaut } - std::unordered_map subMeshMap; + std::unordered_map subMeshMap; std::vector materialData; std::vector subMeshes; AnimationType animationType; @@ -63,7 +63,7 @@ namespace Nz Skeleton skeleton; // Uniquement pour les meshs squelettiques String animationPath; bool aabbUpdated = false; - unsigned int jointCount; // Uniquement pour les meshs squelettiques + UInt32 jointCount; // Uniquement pour les meshs squelettiques }; Mesh::~Mesh() @@ -92,7 +92,7 @@ namespace Nz NazaraAssert(subMesh, "Invalid submesh"); NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type"); - int index = m_impl->subMeshes.size(); + UInt32 index = m_impl->subMeshes.size(); m_impl->subMeshes.push_back(subMesh); m_impl->subMeshMap[identifier] = index; @@ -276,11 +276,11 @@ namespace Nz void Mesh::BuildSubMeshes(const PrimitiveList& list, const MeshParams& params) { - for (unsigned int i = 0; i < list.GetSize(); ++i) + for (UInt32 i = 0; i < list.GetSize(); ++i) BuildSubMesh(list.GetPrimitive(i), params); } - bool Mesh::CreateSkeletal(unsigned int jointCount) + bool Mesh::CreateSkeletal(UInt32 jointCount) { Destroy(); @@ -349,11 +349,11 @@ namespace Nz if (!m_impl->aabbUpdated) { - unsigned int subMeshCount = m_impl->subMeshes.size(); + UInt32 subMeshCount = m_impl->subMeshes.size(); if (subMeshCount > 0) { m_impl->aabb.Set(m_impl->subMeshes[0]->GetAABB()); - for (unsigned int i = 1; i < subMeshCount; ++i) + for (UInt32 i = 1; i < subMeshCount; ++i) m_impl->aabb.ExtendTo(m_impl->subMeshes[i]->GetAABB()); } else @@ -379,7 +379,7 @@ namespace Nz return m_impl->animationType; } - unsigned int Mesh::GetJointCount() const + UInt32 Mesh::GetJointCount() const { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(m_impl->animationType == AnimationType_Skeletal, "Mesh is not skeletal"); @@ -387,7 +387,7 @@ namespace Nz return m_impl->jointCount; } - ParameterList& Mesh::GetMaterialData(unsigned int index) + ParameterList& Mesh::GetMaterialData(UInt32 index) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->materialData.size(), "Material index out of range"); @@ -395,7 +395,7 @@ namespace Nz return m_impl->materialData[index]; } - const ParameterList& Mesh::GetMaterialData(unsigned int index) const + const ParameterList& Mesh::GetMaterialData(UInt32 index) const { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->materialData.size(), "Material index out of range"); @@ -403,7 +403,7 @@ namespace Nz return m_impl->materialData[index]; } - unsigned int Mesh::GetMaterialCount() const + UInt32 Mesh::GetMaterialCount() const { NazaraAssert(m_impl, "Mesh should be created first"); @@ -436,7 +436,7 @@ namespace Nz return m_impl->subMeshes[it->second]; } - SubMesh* Mesh::GetSubMesh(unsigned int index) + SubMesh* Mesh::GetSubMesh(UInt32 index) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); @@ -454,7 +454,7 @@ namespace Nz return m_impl->subMeshes[it->second]; } - const SubMesh* Mesh::GetSubMesh(unsigned int index) const + const SubMesh* Mesh::GetSubMesh(UInt32 index) const { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); @@ -462,14 +462,14 @@ namespace Nz return m_impl->subMeshes[index]; } - unsigned int Mesh::GetSubMeshCount() const + UInt32 Mesh::GetSubMeshCount() const { NazaraAssert(m_impl, "Mesh should be created first"); return m_impl->subMeshes.size(); } - int Mesh::GetSubMeshIndex(const String& identifier) const + UInt32 Mesh::GetSubMeshIndex(const String& identifier) const { NazaraAssert(m_impl, "Mesh should be created first"); @@ -479,22 +479,22 @@ namespace Nz return it->second; } - unsigned int Mesh::GetTriangleCount() const + UInt32 Mesh::GetTriangleCount() const { NazaraAssert(m_impl, "Mesh should be created first"); - unsigned int triangleCount = 0; + UInt32 triangleCount = 0; for (SubMesh* subMesh : m_impl->subMeshes) triangleCount += subMesh->GetTriangleCount(); return triangleCount; } - unsigned int Mesh::GetVertexCount() const + UInt32 Mesh::GetVertexCount() const { NazaraAssert(m_impl, "Mesh should be created first"); - unsigned int vertexCount = 0; + UInt32 vertexCount = 0; for (SubMesh* subMesh : m_impl->subMeshes) vertexCount += subMesh->GetVertexCount(); @@ -515,7 +515,7 @@ namespace Nz return m_impl->subMeshMap.find(identifier) != m_impl->subMeshMap.end(); } - bool Mesh::HasSubMesh(unsigned int index) const + bool Mesh::HasSubMesh(UInt32 index) const { NazaraAssert(m_impl, "Mesh should be created first"); @@ -564,8 +564,8 @@ namespace Nz BufferMapper mapper(staticMesh->GetVertexBuffer(), BufferAccess_ReadWrite); MeshVertex* vertices = static_cast(mapper.GetPointer()); - unsigned int vertexCount = staticMesh->GetVertexCount(); - for (unsigned int i = 0; i < vertexCount; ++i) + UInt32 vertexCount = staticMesh->GetVertexCount(); + for (UInt32 i = 0; i < vertexCount; ++i) { vertices->position -= center; vertices++; @@ -583,7 +583,7 @@ namespace Nz void Mesh::RemoveSubMesh(const String& identifier) { - unsigned int index = GetSubMeshIndex(identifier); + UInt32 index = GetSubMeshIndex(identifier); // On déplace l'itérateur du début d'une distance de x auto it2 = m_impl->subMeshes.begin(); @@ -593,7 +593,7 @@ namespace Nz InvalidateAABB(); } - void Mesh::RemoveSubMesh(unsigned int index) + void Mesh::RemoveSubMesh(UInt32 index) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); @@ -623,7 +623,7 @@ namespace Nz m_impl->animationPath = animationPath; } - void Mesh::SetMaterialData(unsigned int matIndex, ParameterList data) + void Mesh::SetMaterialData(UInt32 matIndex, ParameterList data) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(matIndex < m_impl->materialData.size(), "Material index out of range"); @@ -631,7 +631,7 @@ namespace Nz m_impl->materialData[matIndex] = std::move(data); } - void Mesh::SetMaterialCount(unsigned int matCount) + void Mesh::SetMaterialCount(UInt32 matCount) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(matCount > 0, "A mesh should have at least a material"); @@ -641,7 +641,7 @@ namespace Nz #ifdef NAZARA_DEBUG for (SubMesh* subMesh : m_impl->subMeshes) { - unsigned int matIndex = subMesh->GetMaterialIndex(); + UInt32 matIndex = subMesh->GetMaterialIndex(); if (matIndex >= matCount) { subMesh->SetMaterialIndex(0); // To prevent a crash @@ -665,8 +665,8 @@ namespace Nz Boxf aabb(vertices->position.x, vertices->position.y, vertices->position.z, 0.f, 0.f, 0.f); - unsigned int vertexCount = staticMesh->GetVertexCount(); - for (unsigned int i = 0; i < vertexCount; ++i) + UInt32 vertexCount = staticMesh->GetVertexCount(); + for (UInt32 i = 0; i < vertexCount; ++i) { vertices->position = matrix.Transform(vertices->position); aabb.ExtendTo(vertices->position); diff --git a/src/Nazara/Utility/Skeleton.cpp b/src/Nazara/Utility/Skeleton.cpp index ad5632b90..70f7adb07 100644 --- a/src/Nazara/Utility/Skeleton.cpp +++ b/src/Nazara/Utility/Skeleton.cpp @@ -10,7 +10,7 @@ namespace Nz { struct SkeletonImpl { - std::unordered_map jointMap; + std::unordered_map jointMap; std::vector joints; Boxf aabb; bool aabbUpdated = false; @@ -31,7 +31,7 @@ namespace Nz Destroy(); } - bool Skeleton::Create(unsigned int jointCount) + bool Skeleton::Create(UInt32 jointCount) { #if NAZARA_UTILITY_SAFE if (jointCount == 0) @@ -72,12 +72,12 @@ namespace Nz if (!m_impl->aabbUpdated) { - unsigned int jointCount = m_impl->joints.size(); + UInt32 jointCount = m_impl->joints.size(); if (jointCount > 0) { Vector3f pos = m_impl->joints[0].GetPosition(); m_impl->aabb.Set(pos.x, pos.y, pos.z, 0.f, 0.f, 0.f); - for (unsigned int i = 1; i < jointCount; ++i) + for (UInt32 i = 1; i < jointCount; ++i) m_impl->aabb.ExtendTo(m_impl->joints[i].GetPosition()); } else @@ -117,7 +117,7 @@ namespace Nz return &m_impl->joints[it->second]; } - Joint* Skeleton::GetJoint(unsigned int index) + Joint* Skeleton::GetJoint(UInt32 index) { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -164,7 +164,7 @@ namespace Nz return &m_impl->joints[it->second]; } - const Joint* Skeleton::GetJoint(unsigned int index) const + const Joint* Skeleton::GetJoint(UInt32 index) const { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -209,7 +209,7 @@ namespace Nz return &m_impl->joints[0]; } - unsigned int Skeleton::GetJointCount() const + UInt32 Skeleton::GetJointCount() const { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -278,13 +278,13 @@ namespace Nz Joint* jointsA = &skeletonA.m_impl->joints[0]; Joint* jointsB = &skeletonB.m_impl->joints[0]; - for (unsigned int i = 0; i < m_impl->joints.size(); ++i) + for (std::size_t i = 0; i < m_impl->joints.size(); ++i) m_impl->joints[i].Interpolate(jointsA[i], jointsB[i], interpolation, CoordSys_Local); InvalidateJoints(); } - void Skeleton::Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount) + void Skeleton::Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount) { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -314,9 +314,9 @@ namespace Nz const Joint* jointsA = &skeletonA.m_impl->joints[0]; const Joint* jointsB = &skeletonB.m_impl->joints[0]; - for (unsigned int i = 0; i < indiceCount; ++i) + for (UInt32 i = 0; i < indiceCount; ++i) { - unsigned int index = indices[i]; + UInt32 index = indices[i]; #if NAZARA_UTILITY_SAFE if (index >= m_impl->joints.size()) @@ -351,16 +351,16 @@ namespace Nz m_impl->jointMapUpdated = skeleton.m_impl->jointMapUpdated; m_impl->joints = skeleton.m_impl->joints; - // Code crade mais son optimisation demanderait de stocker jointCount*sizeof(unsigned int) en plus + // Code crade mais son optimisation demanderait de stocker jointCount*sizeof(UInt32) en plus // Ce qui, pour juste une copie qui ne se fera que rarement, ne vaut pas le coup // L'éternel trade-off mémoire/calculs .. - unsigned int jointCount = skeleton.m_impl->joints.size(); - for (unsigned int i = 0; i < jointCount; ++i) + std::size_t jointCount = skeleton.m_impl->joints.size(); + for (std::size_t i = 0; i < jointCount; ++i) { const Node* parent = skeleton.m_impl->joints[i].GetParent(); if (parent) { - for (unsigned int j = 0; j < i; ++j) // Le parent se trouve forcément avant nous + for (std::size_t j = 0; j < i; ++j) // Le parent se trouve forcément avant nous { if (parent == &skeleton.m_impl->joints[j]) // A-t-on trouvé le parent ? { @@ -406,7 +406,7 @@ namespace Nz #endif m_impl->jointMap.clear(); - for (unsigned int i = 0; i < m_impl->joints.size(); ++i) + for (std::size_t i = 0; i < m_impl->joints.size(); ++i) { String name = m_impl->joints[i].GetName(); if (!name.IsEmpty()) diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index 8b0589808..c8da223f0 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -196,7 +196,7 @@ namespace Nz return 0; } - unsigned int SubMesh::GetMaterialIndex() const + UInt32 SubMesh::GetMaterialIndex() const { return m_matIndex; } @@ -206,7 +206,7 @@ namespace Nz m_primitiveMode = mode; } - void SubMesh::SetMaterialIndex(unsigned int matIndex) + void SubMesh::SetMaterialIndex(UInt32 matIndex) { m_matIndex = matIndex; } From 842063b1cd3ef427f18a1fff56242257b092e082 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 20:40:02 +0200 Subject: [PATCH 218/235] Clean up some code Former-commit-id: 01788d37c2da84116c14d43ca318e5be4134d86f [formerly 5a4bd2b503f8ace2de3199e446123d2ebfebcc5e] [formerly e08e7b4831f4221b8a424d7a023e6e31081c2f63 [formerly 412302cba9aeeb89cb2d4b31a7b711c789ad8444]] Former-commit-id: 09c0406c65994e0f153eb472cc715839eef33ef4 [formerly fd5a153e97d8dc353b744367571b97396eec2cf8] Former-commit-id: ee4ef949183459a4067c5cbe2290c555c3753617 --- include/Nazara/Physics/Geom.hpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 +- src/Nazara/Physics/Geom.cpp | 21 +++++++-------------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/Nazara/Physics/Geom.hpp b/include/Nazara/Physics/Geom.hpp index 23a02c72b..e228c3d07 100644 --- a/include/Nazara/Physics/Geom.hpp +++ b/include/Nazara/Physics/Geom.hpp @@ -134,7 +134,7 @@ namespace Nz class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom { public: - CompoundGeom(PhysGeom** geoms, unsigned int geomCount); + CompoundGeom(PhysGeom** geoms, std::size_t geomCount); const std::vector& GetGeoms() const; GeomType GetType() const override; diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index cbcebb83b..0097227ef 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -56,7 +56,7 @@ namespace Nz std::array hostnameBuffer; std::array serviceBuffer; - int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); + int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); if (result == 0) { if (hostname) diff --git a/src/Nazara/Physics/Geom.cpp b/src/Nazara/Physics/Geom.cpp index e814b8618..48d6f0090 100644 --- a/src/Nazara/Physics/Geom.cpp +++ b/src/Nazara/Physics/Geom.cpp @@ -125,16 +125,7 @@ namespace Nz PhysGeomRef PhysGeom::Build(const PrimitiveList& list) { - unsigned int primitiveCount = list.GetSize(); - - #if NAZARA_PHYSICS_SAFE - if (primitiveCount == 0) - { - NazaraError("PrimitiveList must have at least one primitive"); - return nullptr; - } - #endif - + std::size_t primitiveCount = list.GetSize(); if (primitiveCount > 1) { std::vector geoms(primitiveCount); @@ -144,8 +135,10 @@ namespace Nz return CompoundGeom::New(&geoms[0], primitiveCount); } - else + else if (primitiveCount > 0) return CreateGeomFromPrimitive(list.GetPrimitive(0)); + else + return NullGeom::New(); } bool PhysGeom::Initialize() @@ -246,10 +239,10 @@ namespace Nz /******************************* CompoundGeom ********************************/ - CompoundGeom::CompoundGeom(PhysGeom** geoms, unsigned int geomCount) + CompoundGeom::CompoundGeom(PhysGeom** geoms, std::size_t geomCount) { m_geoms.reserve(geomCount); - for (unsigned int i = 0; i < geomCount; ++i) + for (std::size_t i = 0; i < geomCount; ++i) m_geoms.emplace_back(geoms[i]); } @@ -349,7 +342,7 @@ namespace Nz NewtonCollision* ConvexHullGeom::CreateHandle(PhysWorld* world) const { - return NewtonCreateConvexHull(world->GetHandle(), m_vertices.size(), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); + return NewtonCreateConvexHull(world->GetHandle(), static_cast(m_vertices.size()), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); } /******************************* CylinderGeom ********************************/ From ee1edc024be849464d18740dca1c9b0c8a01218a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 21:00:23 +0200 Subject: [PATCH 219/235] Utility/OBJSaver: Remove some warnings Former-commit-id: 15c52a8dfcecfe4cfdc27763b3e46c32ac79865f [formerly b0d9a1441ab178753382594b8915dca985787153] [formerly 568cc74817c0d41294ec2dc9afece9cbe9b04db1 [formerly 1b020021b8387298da6ff560a2f93d6ad58bf907]] Former-commit-id: 76f3f5869d13d66490d714fe8ba4dab5e1a2351d [formerly e173b22fb901b3c4597bb6b2054682138e209cc1] Former-commit-id: 11b5bc936031b44b3bea074572cc076ab95e7c7a --- include/Nazara/Core/Bitset.inl | 2 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index 21457d7c7..d29315afd 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -121,7 +121,7 @@ namespace Nz if (sizeof(T) <= sizeof(Block)) { m_bitCount = std::numeric_limits::digits; - m_blocks.push_back(value); + m_blocks.push_back(static_cast(value)); } else { diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 534eb1952..6ed15e717 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -35,12 +35,12 @@ namespace Nz { } - std::size_t GetCount() const + UInt32 GetCount() const { return m_count; } - std::size_t Insert(const T& data) + UInt32 Insert(const T& data) { auto it = m_cache.find(data); if (it == m_cache.end()) @@ -54,8 +54,8 @@ namespace Nz } private: - std::size_t m_count; - std::map m_cache; + UInt32 m_count; + std::map m_cache; T* m_buffer; }; @@ -172,7 +172,7 @@ namespace Nz SparsePtr positionPtr = vertexMapper.GetComponentPtr(VertexComponent_Position); SparsePtr texCoordsPtr = vertexMapper.GetComponentPtr(VertexComponent_TexCoord); - std::size_t faceIndex = 0; + UInt32 faceIndex = 0; TriangleIterator triangle(staticMesh); do { @@ -184,7 +184,7 @@ namespace Nz { OBJParser::FaceVertex& vertexIndices = meshes[i].vertices[face.firstVertex + j]; - std::size_t index = triangle[j]; + UInt32 index = triangle[j]; vertexIndices.normal = normalCache.Insert(normalPtr[index]); vertexIndices.position = positionCache.Insert(positionPtr[index]); vertexIndices.texCoord = texCoordsCache.Insert(texCoordsPtr[index]); From 347a0697286d5215d16b8effe36e5cf4c366066d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 6 Sep 2016 13:30:53 +0200 Subject: [PATCH 220/235] SDK/Binding: Fix compilation Former-commit-id: da400b9414ea935e49607d3194c5e2f7c535f153 [formerly a81c079e4c20658e692880babac04d920a5c8552] [formerly 990fea99e815d079cc6815c64398f2ee0ecccb79 [formerly 80c97dce52ed0f30859fb1a91b9dc0878e2a2a60]] Former-commit-id: 4716f641888376649728d40b485e7a0c8ef4b2e6 [formerly 823e2724ac7535f28551d12ea2a2d37de14debe9] Former-commit-id: d4d6419dcd17376909c3737ff9926433f560c763 --- SDK/src/NDK/LuaBinding_SDK.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 35c59ae68..1ccd16342 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -139,7 +139,7 @@ namespace Ndk #ifndef NDK_SERVER /*********************************** Ndk::GraphicsComponent **********************************/ - graphicsComponent.BindMethod("Attach", &GraphicsComponent::Attach, 0); + graphicsComponent.BindMethod("Attach", (void(Ndk::GraphicsComponent::*)(Nz::InstancedRenderableRef, int)) &GraphicsComponent::Attach, 0); #endif From 6f4542393b0047ba510a9207e418fd6e5605dcb9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 7 Sep 2016 13:04:58 +0200 Subject: [PATCH 221/235] Graphics/Sprite: Allows to set sprite corner color Former-commit-id: b9b49224a89e38b233b590d78fd58e702741190f [formerly a575b0a6a20f1e395c0d3722d0c718cf29ee3d10] [formerly 39ad76edf53946c635a2acdaf97e5112c4ecbce2 [formerly 3353bce80b26d16e82f580d7a7c86399f3cac387]] Former-commit-id: aa828d49caa667f82916c37f36cc44493c2b4b35 [formerly a0f30d565da18350446bc028f54dbcbe9d26bfb9] Former-commit-id: 56145df1ee427d56fd7a951278b99484e56400a8 --- include/Nazara/Graphics/Sprite.hpp | 3 ++ include/Nazara/Graphics/Sprite.inl | 59 +++++++++++++++++++++++++++--- src/Nazara/Graphics/Sprite.cpp | 9 ++--- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index 3aa261d89..13bcc289b 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -37,12 +37,14 @@ namespace Nz void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; inline const Color& GetColor() const; + inline const Color& GetCornerColor(RectCorner corner) const; inline const MaterialRef& GetMaterial() const; inline const Vector3f& GetOrigin() const; inline const Vector2f& GetSize() const; inline const Rectf& GetTextureCoords() const; inline void SetColor(const Color& color); + inline void SetCornerColor(RectCorner corner, const Color& color); inline void SetDefaultMaterial(); inline void SetMaterial(MaterialRef material, bool resizeSprite = true); inline void SetOrigin(const Vector3f& origin); @@ -65,6 +67,7 @@ namespace Nz static bool Initialize(); static void Uninitialize(); + std::array m_cornerColor; Color m_color; MaterialRef m_material; Rectf m_textureCoords; diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 410b42478..bc27bf67c 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -18,6 +18,9 @@ namespace Nz m_size(64.f, 64.f), m_origin(Nz::Vector3f::Zero()) { + for (Color& color : m_cornerColor) + color = Color::White; + SetDefaultMaterial(); } @@ -62,14 +65,35 @@ namespace Nz /*! * \brief Gets the color of the sprite + * + * This is the global color of the sprite, independent from corner colors + * * \return Current color + * + * \see GetCornerColor + * \see SetColor */ - inline const Color& Sprite::GetColor() const { return m_color; } + /*! + * \brief Gets the color setup on a corner of the sprite + * + * \return Current color + * + * \param corner Corner of the sprite to query + * + * \see SetCornerColor + */ + inline const Color& Sprite::GetCornerColor(RectCorner corner) const + { + NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + + return m_cornerColor[corner]; + } + /*! * \brief Gets the material of the sprite * \return Current material @@ -86,7 +110,7 @@ namespace Nz * * \see SetOrigin */ - inline const Vector3f & Sprite::GetOrigin() const + inline const Vector3f& Sprite::GetOrigin() const { return m_origin; } @@ -105,18 +129,21 @@ namespace Nz * \brief Gets the texture coordinates of the sprite * \return Current texture coordinates */ - inline const Rectf& Sprite::GetTextureCoords() const { return m_textureCoords; } /*! - * \brief Sets the color of the billboard + * \brief Sets the global color of the sprite * - * \param color Color for the billboard + * This is independent from the corner color of the sprite + * + * \param color Color for the sprite + * + * \see GetColor + * \see SetCornerColor */ - inline void Sprite::SetColor(const Color& color) { m_color = color; @@ -124,6 +151,26 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets a color for a corner of the sprite + * + * This is independent from the sprite global color, which gets multiplied by the corner color when rendering the sprite. + * + * \param corner Corner of the sprite to set + * \param color Color for the sprite + * + * \see GetCornerColor + * \see SetColor + */ + inline void Sprite::SetCornerColor(RectCorner corner, const Color& color) + { + NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + + m_cornerColor[corner] = color; + + InvalidateVertices(); + } + /*! * \brief Sets the default material of the sprite (just default material) */ diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 8b950bf2a..1b14ab6de 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -49,7 +49,6 @@ namespace Nz * * \param instanceData Data of the instance */ - void Sprite::UpdateData(InstanceData* instanceData) const { instanceData->data.resize(4 * sizeof(VertexStruct_XYZ_Color_UV)); @@ -61,19 +60,19 @@ namespace Nz Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftTop]; *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_RightTop]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftBottom]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_RightBottom]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 5eca42c9ad317dec7184e25784fab0db8c17b1cb Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 9 Sep 2016 23:17:36 +0200 Subject: [PATCH 222/235] Sdk/Entity: Fix component cleaning on destruction Former-commit-id: 052b0f181ed8590dec1a170f36d8e093d38a3e7e [formerly fa87f920de906200ad0475eec529f3e9adced46b] [formerly 76bab3bcfa54b29fa48a3d0092d52391120506fc [formerly 59f0bc8a11fdcd05625b8eff3b5618b1e40e6ccc]] Former-commit-id: 267047b5fa8bc5378d18883b97419bc1daa7d3ee [formerly 7f780ca86bedb16d30445f92dfd5d5152b1bca35] Former-commit-id: 255be652ba4f7efd2b7733235710d9bfa91eac80 --- SDK/src/NDK/Entity.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 815d0dc1b..a49a8f6aa 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -158,6 +158,9 @@ namespace Ndk UnregisterAllHandles(); + m_components.clear(); + m_componentBits.Reset(); + m_valid = false; } From 2be409a31373311b5648f0faa17366b1e407f49b Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:29:12 +0200 Subject: [PATCH 223/235] Test AppVeyor Former-commit-id: 3972342541ebe8df2b4743328da6a834c8897d89 [formerly 771e5645a6942b6f87277b4f111e32793ee9795c] [formerly fcf83c00557bd357cec57c648d7fbf7edc2682ee [formerly 3d932408744346f48df27beaf1505d810a6a261c]] Former-commit-id: 2a84b2c89c449a7a081e507c1ff0c568168e4c0a [formerly 2ba28757917ab6eff3ffb14902aacd8e544d6022] Former-commit-id: d1f91e7336592e38d38c6a4c6732a810c19b2cb7 --- appveyor.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..756c1e14b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +shallow_clone: true + +os: + - Visual Studio 2015 + +environment: + matrix: + - TOOLSET: vs2010 + - TOOLSET: vs2013 + - TOOLSET: vs2015 + +install: + - cd build && "./premake5.exe" %TOOLSET% && cd .. + +configuration: + - Debug + - Release + +build: + project: NazaraEngine/build/$(TOOLSET)/NazaraEngine.sln + +after_test: + - NazaraEngine\tests\Tests.exe From 4565585df30c04cbcc77b01302f382852d399e97 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:30:45 +0200 Subject: [PATCH 224/235] Try to fix build Former-commit-id: a7f8fcdbae1ba699a545e72c5cfcfed82a3e0e00 [formerly 90aa5772532dbb6b3c1dacdcab518193494b2719] [formerly 47a85e8bb012265923cfaca1004d26a64a03183a [formerly 7b1be8e6ca79d6b3e61e539e9d38c92d53319421]] Former-commit-id: 290e351fce56ff4400f4e27dc5c5ba2cf5284613 [formerly 1986aaff406c3338aa2ef50a79109a8dcebac580] Former-commit-id: 775070b6173675e8f9b9a20240103105df91e349 --- appveyor.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 756c1e14b..498270c14 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,6 @@ os: environment: matrix: - - TOOLSET: vs2010 - - TOOLSET: vs2013 - TOOLSET: vs2015 install: @@ -17,7 +15,4 @@ configuration: - Release build: - project: NazaraEngine/build/$(TOOLSET)/NazaraEngine.sln - -after_test: - - NazaraEngine\tests\Tests.exe + project: build/$(TOOLSET)/NazaraEngine.sln \ No newline at end of file From ba14c5671c6c3e47faa19b2b403329e8aa3b4b3a Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:35:58 +0200 Subject: [PATCH 225/235] Damnit Former-commit-id: 9f2e06199df0b887077d6ec9248ddff3364fcfd1 [formerly 255e4ee529adfd24437e5984b8ca4c897be44d7d] [formerly 640671f0434a35d00bfa1ecd40e9833b7cec8766 [formerly 9c982fe60d62f2dc24f0a516983a896ca2824ab3]] Former-commit-id: d395599476b37472fc6081e8b9e1db2a238a3164 [formerly 16e438d010a60b69404a5b5f6b4ef71d53da6fd1] Former-commit-id: edbe9b5ac8fb5e66d7f13d395b0cb3008593adda --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 498270c14..a705a4c8c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,5 @@ +version: '{branch}-rev{build}' +configuration: DebugDynamic, ReleaseDynamic shallow_clone: true os: From f0081c88174f6ed45afc1105aab1c8d718798795 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:36:34 +0200 Subject: [PATCH 226/235] I'm a moron Former-commit-id: c657fb51f06383769d53b11dd29ebe5d3b08d34b [formerly 5482d05d0e31b9ede0b135d4b5b884c75b125bcf] [formerly 7718539d36139bdec2e22cdc6b3ed68a6440de37 [formerly 8b343f4e3dc51bdf480b9d6be8e49132b29bf161]] Former-commit-id: 3cbad989c037da16dd4be92a64156f4b5dde892b [formerly c2f2a41e12c8022100478900725f083f95a680e2] Former-commit-id: 86c5f71ab9d0147d10f677bd31ad8272e6121fe6 --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a705a4c8c..39ff8f7a8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: '{branch}-rev{build}' -configuration: DebugDynamic, ReleaseDynamic + shallow_clone: true os: @@ -13,8 +13,8 @@ install: - cd build && "./premake5.exe" %TOOLSET% && cd .. configuration: - - Debug - - Release + - DebugDynamic + - ReleaseDynamic build: project: build/$(TOOLSET)/NazaraEngine.sln \ No newline at end of file From 81e819567bf5e37384639b7d3fe895f21a434a24 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 13 Sep 2016 18:22:40 +0200 Subject: [PATCH 227/235] SDK/Widgets: Add buttons (not clickable atm) Former-commit-id: b90e4ddc0fd7dd18efd480243639d4e7c76c719b [formerly 2ff8f6dc8bb21873734f6d7a3b4bba6fb6edf24d] [formerly 0268cc083e0a8c6285cf05eead7b1a375ae5466d [formerly a4bdefb8421a31c7c62c293f128253de0fa5c6da]] Former-commit-id: 8788b5116384b23544d620c28105516d8c2eb6a1 [formerly 785d6986573cd5483a37697b3f13651fa9ffa5b2] Former-commit-id: 2d424bb16eb5f01381b3a6b315bce258092542c1 --- SDK/include/NDK/BaseWidget.hpp | 4 +- SDK/include/NDK/BaseWidget.inl | 10 ++++- SDK/include/NDK/Widgets/ButtonWidget.hpp | 49 ++++++++++++++++++++++++ SDK/include/NDK/Widgets/ButtonWidget.inl | 13 +++++++ SDK/src/NDK/BaseWidget.cpp | 6 +-- SDK/src/NDK/Widgets/ButtonWidget.cpp | 47 +++++++++++++++++++++++ 6 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 SDK/include/NDK/Widgets/ButtonWidget.hpp create mode 100644 SDK/include/NDK/Widgets/ButtonWidget.inl create mode 100644 SDK/src/NDK/Widgets/ButtonWidget.cpp diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 58c00349e..46690ba64 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -33,6 +33,7 @@ namespace Ndk //virtual BaseWidget* Clone() const = 0; inline const Padding& GetPadding() const; + inline const Nz::Vector2f& GetContentSize() const; inline Nz::Vector2f GetSize() const; virtual void ResizeToContent() = 0; @@ -55,10 +56,9 @@ namespace Ndk protected: EntityHandle CreateEntity(); void DestroyEntity(Entity* entity); + virtual void Layout(); private: - void UpdateBackground(); - std::vector m_entities; std::vector m_children; EntityOwner m_backgroundEntity; diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 560d2b16e..a3cfc9763 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -27,6 +27,11 @@ namespace Ndk return m_padding; } + inline const Nz::Vector2f& BaseWidget::GetContentSize() const + { + return m_contentSize; + } + inline Nz::Vector2f BaseWidget::GetSize() const { return Nz::Vector2f(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); @@ -35,7 +40,8 @@ namespace Ndk inline void BaseWidget::SetContentSize(const Nz::Vector2f& size) { m_contentSize = size; - UpdateBackground(); + + Layout(); } inline void BaseWidget::SetPadding(float left, float top, float right, float bottom) @@ -45,6 +51,6 @@ namespace Ndk m_padding.bottom = bottom; m_padding.right = right; - UpdateBackground(); + Layout(); } } diff --git a/SDK/include/NDK/Widgets/ButtonWidget.hpp b/SDK/include/NDK/Widgets/ButtonWidget.hpp new file mode 100644 index 000000000..b70e9ca3d --- /dev/null +++ b/SDK/include/NDK/Widgets/ButtonWidget.hpp @@ -0,0 +1,49 @@ +// 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_WIDGETS_BUTTONWIDGET_HPP +#define NDK_WIDGETS_BUTTONWIDGET_HPP + +#include +#include +#include +#include +#include + +namespace Ndk +{ + class World; + + class NDK_API ButtonWidget : public BaseWidget + { + public: + ButtonWidget(const WorldHandle& world, BaseWidget* parent = nullptr); + ButtonWidget(const ButtonWidget&) = delete; + ButtonWidget(ButtonWidget&&) = default; + ~ButtonWidget() = default; + + //virtual ButtonWidget* Clone() const = 0; + + void ResizeToContent(); + + inline void UpdateText(const Nz::AbstractTextDrawer& drawer); + + ButtonWidget& operator=(const ButtonWidget&) = delete; + ButtonWidget& operator=(ButtonWidget&&) = default; + + private: + void Layout() override; + + EntityHandle m_textEntity; + EntityHandle m_gradientEntity; + Nz::SpriteRef m_gradientSprite; + Nz::TextSpriteRef m_textSprite; + }; +} + +#include + +#endif // NDK_WIDGETS_BUTTONWIDGET_HPP diff --git a/SDK/include/NDK/Widgets/ButtonWidget.inl b/SDK/include/NDK/Widgets/ButtonWidget.inl new file mode 100644 index 000000000..92d40719a --- /dev/null +++ b/SDK/include/NDK/Widgets/ButtonWidget.inl @@ -0,0 +1,13 @@ +// 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 + +namespace Ndk +{ + inline void ButtonWidget::UpdateText(const Nz::AbstractTextDrawer& drawer) + { + m_textSprite->Update(drawer); + } +} diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 774a36b25..368c18190 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -15,7 +15,7 @@ namespace Ndk delete child; } - inline void Ndk::BaseWidget::EnableBackground(bool enable) + inline void BaseWidget::EnableBackground(bool enable) { if (m_backgroundEntity.IsValid() == enable) return; @@ -30,7 +30,7 @@ namespace Ndk m_backgroundEntity->AddComponent().Attach(m_backgroundSprite, -1); m_backgroundEntity->AddComponent().SetParent(this); - UpdateBackground(); + BaseWidget::Layout(); // Only layout background } else { @@ -58,7 +58,7 @@ namespace Ndk m_entities.erase(it); } - void BaseWidget::UpdateBackground() + void BaseWidget::Layout() { if (m_backgroundEntity) { diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NDK/Widgets/ButtonWidget.cpp new file mode 100644 index 000000000..5afcb8ad8 --- /dev/null +++ b/SDK/src/NDK/Widgets/ButtonWidget.cpp @@ -0,0 +1,47 @@ +// 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 +#include +#include +#include + +namespace Ndk +{ + ButtonWidget::ButtonWidget(const WorldHandle& world, BaseWidget* parent) : + BaseWidget(world, parent) + { + m_gradientSprite = Nz::Sprite::New(); + m_gradientSprite->SetColor(Nz::Color(74, 74, 74)); + m_gradientSprite->SetCornerColor(Nz::RectCorner_LeftBottom, Nz::Color(180, 180, 180)); + m_gradientSprite->SetCornerColor(Nz::RectCorner_RightBottom, Nz::Color(180, 180, 180)); + m_gradientSprite->SetMaterial(Nz::Material::New("Basic2D")); + + m_gradientEntity = CreateEntity(); + m_gradientEntity->AddComponent().SetParent(this); + m_gradientEntity->AddComponent().Attach(m_gradientSprite); + m_gradientEntity->GetComponent().Attach(m_borderSprite, Nz::Matrix4f::Translate(Nz::Vector2f(-1.f, -1.f)), -1); + + m_textSprite = Nz::TextSprite::New(); + + m_textEntity = CreateEntity(); + m_textEntity->AddComponent().SetParent(this); + m_textEntity->AddComponent().Attach(m_textSprite, 1); + } + + void ButtonWidget::ResizeToContent() + { + SetContentSize(Nz::Vector2f(m_textSprite->GetBoundingVolume().obb.localBox.GetLengths())); + } + + void ButtonWidget::Layout() + { + const Nz::Vector2f& contentSize = GetContentSize(); + + m_gradientSprite->SetSize(contentSize); + + Nz::Boxf textBox = m_textEntity->GetComponent().GetBoundingVolume().aabb; + m_textEntity->GetComponent().SetPosition(contentSize.x / 2 - textBox.width / 2, contentSize.y / 2 - textBox.height / 2); + } +} From b94bc43c457394888e2d321042f859680627f5a9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 13 Sep 2016 19:51:46 +0200 Subject: [PATCH 228/235] Graphics/Sprite: Fix warning in Sprite.inl Former-commit-id: d98effab8708be30ad3005c3bca55d41dfad7374 [formerly 0b5277e1c02f1e72176b75050c3b079773dc236a] [formerly ea744cb5ec679e07b5f1899eb43c774d9f243512 [formerly d00d22f33e729a7da00a8419649aa8df99bf31ef]] Former-commit-id: fb3627a89717615b3e865f08a076cbeffba45cf6 [formerly d1f9986651979a37c581d94854843600780b7484] Former-commit-id: 1fc32e9067bb08f741ebf20ace85b43060353aa1 --- include/Nazara/Graphics/Sprite.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index bc27bf67c..35885a94a 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -89,7 +89,7 @@ namespace Nz */ inline const Color& Sprite::GetCornerColor(RectCorner corner) const { - NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + NazaraAssert(static_cast(corner) < m_cornerColor.size(), "Invalid corner"); return m_cornerColor[corner]; } @@ -164,7 +164,7 @@ namespace Nz */ inline void Sprite::SetCornerColor(RectCorner corner, const Color& color) { - NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + NazaraAssert(static_cast(corner) < m_cornerColor.size(), "Invalid corner"); m_cornerColor[corner] = color; From 220a7263b14b6c59123ea02d129df322b30eca2c Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 13 Sep 2016 19:55:39 +0200 Subject: [PATCH 229/235] Sdk/ButtonWidget: Fix compilation Former-commit-id: b45ba6c55c8942083b3bee3b742c300a1890eb0e [formerly f223376c239bab00acc4c560077c0bf691f8988d] [formerly e39b7c76edf6008b7a67c096714d1824705416c5 [formerly 9139170e026fc9c493f971ac55ac268249e32c77]] Former-commit-id: cf7e25cde5cc09839e0cd7364a0fff5fe77ed39b [formerly 7fd5a315ec88b6c0512505874970ee45f06c5f86] Former-commit-id: 3d85e1aad535da46085731400bfc153868972aea --- SDK/src/NDK/Widgets/ButtonWidget.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NDK/Widgets/ButtonWidget.cpp index 5afcb8ad8..0a941d070 100644 --- a/SDK/src/NDK/Widgets/ButtonWidget.cpp +++ b/SDK/src/NDK/Widgets/ButtonWidget.cpp @@ -21,7 +21,6 @@ namespace Ndk m_gradientEntity = CreateEntity(); m_gradientEntity->AddComponent().SetParent(this); m_gradientEntity->AddComponent().Attach(m_gradientSprite); - m_gradientEntity->GetComponent().Attach(m_borderSprite, Nz::Matrix4f::Translate(Nz::Vector2f(-1.f, -1.f)), -1); m_textSprite = Nz::TextSprite::New(); From 320ce3e1d5596abb5abe47ce7ecd7f623bc9f504 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 13 Sep 2016 20:25:50 +0200 Subject: [PATCH 230/235] Build: Exclude widgets from server Former-commit-id: 6413518ac424e52e8e38ebfeac097968bbb153b6 [formerly dab972657333b67cbc27b0c03c928289617db977] [formerly d90816f1d8a4643f089f1a14d3afb189a4f7d5ab [formerly 521bcf5d4fba8ff2866fb52b0cafaa38fd79c036]] Former-commit-id: 81a120be306c06ce0ae1e1e0506939f2a099e772 [formerly 7b61d9cdf0547c9a813059710e70aad0e4de41ba] Former-commit-id: 57ebe4da311643188488a370ec5d30f248854a04 --- build/scripts/tools/ndk_server.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index cebd158c6..f8550878f 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -33,6 +33,7 @@ TOOL.FilesExcluded = { "../SDK/**/Particle*Component.*", "../SDK/**/ParticleSystem.*", "../SDK/**/RenderSystem.*", + "../SDK/**/*Widget*.*", "../SDK/**/LuaBinding_Audio.*", "../SDK/**/LuaBinding_Graphics.*", "../SDK/**/LuaBinding_Renderer.*" From 9438f519bba0f2ffad357ef1f34fd5f239f50a81 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Sep 2016 13:16:37 +0200 Subject: [PATCH 231/235] Sdk/Widget: Add Canvas system, mouse movement event for widgets (buttons react to hovering) Former-commit-id: 1945290ec1bd8fb85f0271e71a3deac8fe29d1d3 [formerly 685f46c52586642355658b6dc97b01c62c8ceb18] [formerly 2d7b1bdc6ec1b08d82f5967bde41e07681b37bba [formerly 24f645b1a9ae22d4d9a3d45d40a09a92929f407a]] Former-commit-id: 0b8303a6701d2a0507433fb004a181ed1852e250 [formerly 81f107cd8a3b5adf3fb583e24d72fb11600be8d4] Former-commit-id: 1fe7c371f085ef008da5f4362924ebed8a2e968a --- SDK/include/NDK/BaseWidget.hpp | 20 ++++- SDK/include/NDK/BaseWidget.inl | 18 +++- SDK/include/NDK/Canvas.hpp | 61 ++++++++++++++ SDK/include/NDK/Canvas.inl | 22 +++++ SDK/include/NDK/Widgets/ButtonWidget.hpp | 6 +- SDK/include/NDK/Widgets/LabelWidget.hpp | 2 +- SDK/src/NDK/BaseWidget.cpp | 39 ++++++++- SDK/src/NDK/Canvas.cpp | 102 +++++++++++++++++++++++ SDK/src/NDK/Widgets/ButtonWidget.cpp | 24 +++++- SDK/src/NDK/Widgets/LabelWidget.cpp | 6 +- 10 files changed, 285 insertions(+), 15 deletions(-) create mode 100644 SDK/include/NDK/Canvas.hpp create mode 100644 SDK/include/NDK/Canvas.inl create mode 100644 SDK/src/NDK/Canvas.cpp diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 46690ba64..eb00d9ea4 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -16,12 +16,16 @@ namespace Ndk { + class Canvas; + class NDK_API BaseWidget : public Nz::Node { + friend Canvas; + public: struct Padding; - inline BaseWidget(WorldHandle world, BaseWidget* parent = nullptr); + BaseWidget(BaseWidget* parent); BaseWidget(const BaseWidget&) = delete; BaseWidget(BaseWidget&&) = default; virtual ~BaseWidget(); @@ -32,6 +36,7 @@ namespace Ndk //virtual BaseWidget* Clone() const = 0; + inline Canvas* GetCanvas(); inline const Padding& GetPadding() const; inline const Nz::Vector2f& GetContentSize() const; inline Nz::Vector2f GetSize() const; @@ -57,10 +62,21 @@ namespace Ndk EntityHandle CreateEntity(); void DestroyEntity(Entity* entity); virtual void Layout(); + void InvalidateNode() override; + + virtual void OnMouseEnter(); + virtual void OnMouseMoved(int x, int y, int deltaX, int deltaY); + virtual void OnMouseExit(); private: + inline BaseWidget(); + + inline void UpdateCanvasIndex(std::size_t index); + + std::size_t m_canvasIndex; std::vector m_entities; - std::vector m_children; + std::vector> m_children; + Canvas* m_canvas; EntityOwner m_backgroundEntity; Padding m_padding; WorldHandle m_world; diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index a3cfc9763..b5ab5b0f1 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -8,18 +8,23 @@ namespace Ndk { - inline BaseWidget::BaseWidget(WorldHandle world, BaseWidget* parent) : - m_world(std::move(world)), + inline BaseWidget::BaseWidget() : m_backgroundColor(Nz::Color(230, 230, 230, 255)), + m_canvas(nullptr), m_contentSize(50.f, 50.f), - m_widgetParent(parent) + m_widgetParent(nullptr) { SetPadding(5.f, 5.f, 5.f, 5.f); } inline void BaseWidget::AddChild(std::unique_ptr&& widget) { - m_children.push_back(widget.release()); + m_children.emplace_back(std::move(widget)); + } + + inline Canvas* BaseWidget::GetCanvas() + { + return m_canvas; } inline const BaseWidget::Padding& BaseWidget::GetPadding() const @@ -53,4 +58,9 @@ namespace Ndk Layout(); } + + inline void BaseWidget::UpdateCanvasIndex(std::size_t index) + { + m_canvasIndex = index; + } } diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp new file mode 100644 index 000000000..f307f3dd3 --- /dev/null +++ b/SDK/include/NDK/Canvas.hpp @@ -0,0 +1,61 @@ +// 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_CANVAS_HPP +#define NDK_CANVAS_HPP + +#include +#include +#include + +namespace Ndk +{ + class NDK_API Canvas : public BaseWidget + { + friend BaseWidget; + + public: + struct Padding; + + inline Canvas(WorldHandle world, Nz::EventHandler& eventHandler); + Canvas(const Canvas&) = delete; + Canvas(Canvas&&) = delete; + ~Canvas() = default; + + inline const WorldHandle& GetWorld() const; + + void ResizeToContent() override; + + Canvas& operator=(const Canvas&) = delete; + Canvas& operator=(Canvas&&) = delete; + + protected: + void Layout() override; + + void NotifyWidgetUpdate(std::size_t index); + std::size_t RegisterWidget(BaseWidget* widget); + void UnregisterWidget(std::size_t index); + + private: + void OnMouseMoved(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseMoveEvent& event); + + struct WidgetBox + { + BaseWidget* widget; + Nz::Boxf box; + }; + + NazaraSlot(Nz::EventHandler, OnMouseMoved, m_mouseMovedSlot); + + std::vector m_widgetBoxes; + BaseWidget* m_hoveredWidget; + WorldHandle m_world; + }; +} + +#include + +#endif // NDK_CANVAS_HPP diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl new file mode 100644 index 000000000..c976c911b --- /dev/null +++ b/SDK/include/NDK/Canvas.inl @@ -0,0 +1,22 @@ +// 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 + +namespace Ndk +{ + inline Canvas::Canvas(WorldHandle world, Nz::EventHandler& eventHandler) : + m_hoveredWidget(nullptr), + m_world(std::move(world)) + { + m_canvas = this; + + m_mouseMovedSlot.Connect(eventHandler.OnMouseMoved, this, &Canvas::OnMouseMoved); + } + + inline const WorldHandle& Canvas::GetWorld() const + { + return m_world; + } +} diff --git a/SDK/include/NDK/Widgets/ButtonWidget.hpp b/SDK/include/NDK/Widgets/ButtonWidget.hpp index b70e9ca3d..157304738 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.hpp +++ b/SDK/include/NDK/Widgets/ButtonWidget.hpp @@ -20,7 +20,7 @@ namespace Ndk class NDK_API ButtonWidget : public BaseWidget { public: - ButtonWidget(const WorldHandle& world, BaseWidget* parent = nullptr); + ButtonWidget(BaseWidget* parent = nullptr); ButtonWidget(const ButtonWidget&) = delete; ButtonWidget(ButtonWidget&&) = default; ~ButtonWidget() = default; @@ -37,6 +37,10 @@ namespace Ndk private: void Layout() override; + void OnMouseEnter() override; + void OnMouseMoved(int x, int y, int deltaX, int deltaY) override; + void OnMouseExit() override; + EntityHandle m_textEntity; EntityHandle m_gradientEntity; Nz::SpriteRef m_gradientSprite; diff --git a/SDK/include/NDK/Widgets/LabelWidget.hpp b/SDK/include/NDK/Widgets/LabelWidget.hpp index 6b9fe32fb..736cfd650 100644 --- a/SDK/include/NDK/Widgets/LabelWidget.hpp +++ b/SDK/include/NDK/Widgets/LabelWidget.hpp @@ -19,7 +19,7 @@ namespace Ndk class NDK_API LabelWidget : public BaseWidget { public: - LabelWidget(const WorldHandle& world, BaseWidget* parent = nullptr); + LabelWidget(BaseWidget* parent = nullptr); LabelWidget(const LabelWidget&) = delete; LabelWidget(LabelWidget&&) = default; ~LabelWidget() = default; diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 368c18190..e0c62aab2 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -3,16 +3,28 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include #include #include #include namespace Ndk { + BaseWidget::BaseWidget(BaseWidget* parent) : + BaseWidget() + { + NazaraAssert(parent, "Invalid parent"); + NazaraAssert(parent->GetCanvas(), "Parent has no canvas"); + + m_canvas = parent->GetCanvas(); + m_world = m_canvas->GetWorld(); + + m_canvasIndex = m_canvas->RegisterWidget(this); + } + BaseWidget::~BaseWidget() { - for (BaseWidget* child : m_children) - delete child; + m_canvas->UnregisterWidget(m_canvasIndex); } inline void BaseWidget::EnableBackground(bool enable) @@ -60,6 +72,9 @@ namespace Ndk void BaseWidget::Layout() { + if (m_canvas) + m_canvas->NotifyWidgetUpdate(m_canvasIndex); + if (m_backgroundEntity) { NodeComponent& node = m_backgroundEntity->GetComponent(); @@ -68,4 +83,24 @@ namespace Ndk m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); } } + + void BaseWidget::InvalidateNode() + { + Node::InvalidateNode(); + + if (m_canvas) + m_canvas->NotifyWidgetUpdate(m_canvasIndex); + } + + void BaseWidget::OnMouseEnter() + { + } + + void BaseWidget::OnMouseMoved(int x, int y, int deltaX, int deltaY) + { + } + + void BaseWidget::OnMouseExit() + { + } } \ No newline at end of file diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp new file mode 100644 index 000000000..79efc4cec --- /dev/null +++ b/SDK/src/NDK/Canvas.cpp @@ -0,0 +1,102 @@ +// 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 +#include +#include +#include +#include + +namespace Ndk +{ + void Ndk::Canvas::ResizeToContent() + { + } + + void Canvas::Layout() + { + if (m_backgroundEntity) + { + NodeComponent& node = m_backgroundEntity->GetComponent(); + node.SetPosition(-m_padding.left, -m_padding.top); + + m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom); + } + } + + void Canvas::NotifyWidgetUpdate(std::size_t index) + { + WidgetBox& entry = m_widgetBoxes[index]; + + Nz::Vector3f pos = entry.widget->GetPosition(); + Nz::Vector2f size = entry.widget->GetContentSize(); + + entry.box.Set(pos.x, pos.y, pos.z, size.x, size.y, 1.f); + } + + std::size_t Canvas::RegisterWidget(BaseWidget* widget) + { + WidgetBox box; + box.widget = widget; + + std::size_t index = m_widgetBoxes.size(); + m_widgetBoxes.emplace_back(box); + + NotifyWidgetUpdate(index); + return index; + } + + void Canvas::UnregisterWidget(std::size_t index) + { + if (m_widgetBoxes.size() > 1U) + { + WidgetBox& entry = m_widgetBoxes[index]; + WidgetBox& lastEntry = m_widgetBoxes.back(); + + entry = std::move(lastEntry); + entry.widget->UpdateCanvasIndex(index); + m_widgetBoxes.pop_back(); + } + } + + void Canvas::OnMouseMoved(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseMoveEvent& event) + { + const WidgetBox* bestEntry = nullptr; + float bestEntryArea = std::numeric_limits::infinity(); + + for (const WidgetBox& entry : m_widgetBoxes) + { + const Nz::Boxf& box = entry.box; + + if (box.Contains(Nz::Vector3f(event.x, event.y, 0.f))) + { + float area = box.width * box.height; + if (area < bestEntryArea) + { + bestEntry = &entry; + bestEntryArea = area; + } + } + } + + if (bestEntry) + { + if (m_hoveredWidget != bestEntry->widget) + { + if (m_hoveredWidget) + m_hoveredWidget->OnMouseExit(); + + m_hoveredWidget = bestEntry->widget; + m_hoveredWidget->OnMouseEnter(); + } + + bestEntry->widget->OnMouseMoved(event.x - bestEntry->box.x, event.y - bestEntry->box.y, event.deltaX, event.deltaY); + } + else if (m_hoveredWidget) + { + m_hoveredWidget->OnMouseExit(); + m_hoveredWidget = nullptr; + } + } +} \ No newline at end of file diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NDK/Widgets/ButtonWidget.cpp index 5afcb8ad8..db7fa53b4 100644 --- a/SDK/src/NDK/Widgets/ButtonWidget.cpp +++ b/SDK/src/NDK/Widgets/ButtonWidget.cpp @@ -9,8 +9,8 @@ namespace Ndk { - ButtonWidget::ButtonWidget(const WorldHandle& world, BaseWidget* parent) : - BaseWidget(world, parent) + ButtonWidget::ButtonWidget(BaseWidget* parent) : + BaseWidget(parent) { m_gradientSprite = Nz::Sprite::New(); m_gradientSprite->SetColor(Nz::Color(74, 74, 74)); @@ -21,13 +21,14 @@ namespace Ndk m_gradientEntity = CreateEntity(); m_gradientEntity->AddComponent().SetParent(this); m_gradientEntity->AddComponent().Attach(m_gradientSprite); - m_gradientEntity->GetComponent().Attach(m_borderSprite, Nz::Matrix4f::Translate(Nz::Vector2f(-1.f, -1.f)), -1); m_textSprite = Nz::TextSprite::New(); m_textEntity = CreateEntity(); m_textEntity->AddComponent().SetParent(this); m_textEntity->AddComponent().Attach(m_textSprite, 1); + + Layout(); } void ButtonWidget::ResizeToContent() @@ -37,6 +38,8 @@ namespace Ndk void ButtonWidget::Layout() { + BaseWidget::Layout(); + const Nz::Vector2f& contentSize = GetContentSize(); m_gradientSprite->SetSize(contentSize); @@ -44,4 +47,19 @@ namespace Ndk Nz::Boxf textBox = m_textEntity->GetComponent().GetBoundingVolume().aabb; m_textEntity->GetComponent().SetPosition(contentSize.x / 2 - textBox.width / 2, contentSize.y / 2 - textBox.height / 2); } + + void ButtonWidget::OnMouseEnter() + { + m_gradientSprite->SetColor(Nz::Color(128, 128, 128)); + } + + void ButtonWidget::OnMouseMoved(int x, int y, int deltaX, int deltaY) + { + NazaraDebug(Nz::String::Number(x) + ", " + Nz::String::Number(y)); + } + + void ButtonWidget::OnMouseExit() + { + m_gradientSprite->SetColor(Nz::Color(74, 74, 74)); + } } diff --git a/SDK/src/NDK/Widgets/LabelWidget.cpp b/SDK/src/NDK/Widgets/LabelWidget.cpp index ac2a87bf5..df9c0e1c7 100644 --- a/SDK/src/NDK/Widgets/LabelWidget.cpp +++ b/SDK/src/NDK/Widgets/LabelWidget.cpp @@ -9,14 +9,16 @@ namespace Ndk { - LabelWidget::LabelWidget(const WorldHandle& world, BaseWidget* parent) : - BaseWidget(world, parent) + LabelWidget::LabelWidget(BaseWidget* parent) : + BaseWidget(parent) { m_textSprite = Nz::TextSprite::New(); m_textEntity = CreateEntity(); m_textEntity->AddComponent().Attach(m_textSprite); m_textEntity->AddComponent().SetParent(this); + + Layout(); } void LabelWidget::ResizeToContent() From 9ea02e8b813a03de5ca8aaa8df05901972affd7c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 16 Sep 2016 16:55:55 +0200 Subject: [PATCH 232/235] Sdk/Widgets: Add OnMouseButtonPressed/OnMouseButtonRelease events Former-commit-id: 472d7dc96b23ae29eaa951acd9db1a7771252616 [formerly 48ebfb3f7bb87c895d9ed8208799ab9654d9a8d8] [formerly 7617433fe3c998e6bdde1e01f4b5b9ea7578640d [formerly 280df873dfc507940fdd7ddc0b282c3ba1c0a405]] Former-commit-id: 82ca7b74b4759b8a929e0110cdce3e1426d376da [formerly d8147aeca86e65d22182277f57b9ab47a5575793] Former-commit-id: 373c4a0f6655511f55355550d2f8d8af9e81eea0 --- SDK/include/NDK/BaseWidget.hpp | 3 +++ SDK/include/NDK/Canvas.hpp | 8 +++++- SDK/include/NDK/Canvas.inl | 3 +++ SDK/src/NDK/BaseWidget.cpp | 8 ++++++ SDK/src/NDK/Canvas.cpp | 49 +++++++++++++++++++++++++++++----- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index eb00d9ea4..38e593563 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace Ndk @@ -66,6 +67,8 @@ namespace Ndk virtual void OnMouseEnter(); virtual void OnMouseMoved(int x, int y, int deltaX, int deltaY); + virtual void OnMouseButtonPress(int x, int y, Nz::Mouse::Button button); + virtual void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button); virtual void OnMouseExit(); private: diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp index f307f3dd3..9bf8c8ddd 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NDK/Canvas.hpp @@ -40,7 +40,10 @@ namespace Ndk void UnregisterWidget(std::size_t index); private: + void OnMouseButtonPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseButtonEvent& event); + void OnMouseButtonRelease(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseButtonEvent& event); void OnMouseMoved(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseMoveEvent& event); + void OnMouseLeft(const Nz::EventHandler* eventHandler); struct WidgetBox { @@ -48,10 +51,13 @@ namespace Ndk Nz::Boxf box; }; + NazaraSlot(Nz::EventHandler, OnMouseButtonPressed, m_mouseButtonPressedSlot); + NazaraSlot(Nz::EventHandler, OnMouseButtonReleased, m_mouseButtonReleasedSlot); NazaraSlot(Nz::EventHandler, OnMouseMoved, m_mouseMovedSlot); + NazaraSlot(Nz::EventHandler, OnMouseLeft, m_mouseLeftSlot); std::vector m_widgetBoxes; - BaseWidget* m_hoveredWidget; + const WidgetBox* m_hoveredWidget; WorldHandle m_world; }; } diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index c976c911b..f9dcc5845 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -12,7 +12,10 @@ namespace Ndk { m_canvas = this; + m_mouseButtonPressedSlot.Connect(eventHandler.OnMouseButtonPressed, this, &Canvas::OnMouseButtonPressed); + m_mouseButtonReleasedSlot.Connect(eventHandler.OnMouseButtonReleased, this, &Canvas::OnMouseButtonRelease); m_mouseMovedSlot.Connect(eventHandler.OnMouseMoved, this, &Canvas::OnMouseMoved); + m_mouseLeftSlot.Connect(eventHandler.OnMouseLeft, this, &Canvas::OnMouseLeft); } inline const WorldHandle& Canvas::GetWorld() const diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index e0c62aab2..f72ace844 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -100,6 +100,14 @@ namespace Ndk { } + void BaseWidget::OnMouseButtonPress(int x, int y, Nz::Mouse::Button button) + { + } + + void BaseWidget::OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button) + { + } + void BaseWidget::OnMouseExit() { } diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index 79efc4cec..e8ee8c387 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -54,12 +54,37 @@ namespace Ndk WidgetBox& entry = m_widgetBoxes[index]; WidgetBox& lastEntry = m_widgetBoxes.back(); + if (m_hoveredWidget == &entry) + m_hoveredWidget = nullptr; + entry = std::move(lastEntry); entry.widget->UpdateCanvasIndex(index); m_widgetBoxes.pop_back(); } } + void Canvas::OnMouseButtonPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseButtonEvent& event) + { + if (m_hoveredWidget) + { + int x = static_cast(std::round(event.x - m_hoveredWidget->box.x)); + int y = static_cast(std::round(event.y - m_hoveredWidget->box.y)); + + m_hoveredWidget->widget->OnMouseButtonPress(x, y, event.button); + } + } + + void Canvas::OnMouseButtonRelease(const Nz::EventHandler * eventHandler, const Nz::WindowEvent::MouseButtonEvent & event) + { + if (m_hoveredWidget) + { + int x = static_cast(std::round(event.x - m_hoveredWidget->box.x)); + int y = static_cast(std::round(event.y - m_hoveredWidget->box.y)); + + m_hoveredWidget->widget->OnMouseButtonRelease(x, y, event.button); + } + } + void Canvas::OnMouseMoved(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseMoveEvent& event) { const WidgetBox* bestEntry = nullptr; @@ -82,20 +107,32 @@ namespace Ndk if (bestEntry) { - if (m_hoveredWidget != bestEntry->widget) + if (m_hoveredWidget != bestEntry) { if (m_hoveredWidget) - m_hoveredWidget->OnMouseExit(); + m_hoveredWidget->widget->OnMouseExit(); - m_hoveredWidget = bestEntry->widget; - m_hoveredWidget->OnMouseEnter(); + m_hoveredWidget = bestEntry; + m_hoveredWidget->widget->OnMouseEnter(); } - bestEntry->widget->OnMouseMoved(event.x - bestEntry->box.x, event.y - bestEntry->box.y, event.deltaX, event.deltaY); + int x = static_cast(std::round(event.x - m_hoveredWidget->box.x)); + int y = static_cast(std::round(event.y - m_hoveredWidget->box.y)); + + bestEntry->widget->OnMouseMoved(x, y, event.deltaX, event.deltaY); } else if (m_hoveredWidget) { - m_hoveredWidget->OnMouseExit(); + m_hoveredWidget->widget->OnMouseExit(); + m_hoveredWidget = nullptr; + } + } + + void Canvas::OnMouseLeft(const Nz::EventHandler* eventHandler) + { + if (m_hoveredWidget) + { + m_hoveredWidget->widget->OnMouseExit(); m_hoveredWidget = nullptr; } } From 7a111101e6d1cb6403da584178373757998feff0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 16 Sep 2016 16:56:10 +0200 Subject: [PATCH 233/235] Sdk/ButtonWidget: Make buttons clickable Former-commit-id: 999f91775de93746f964b5a8d9276208cd8a592b [formerly e135030f2cb801715242168c305950d8991f38f1] [formerly 9e88a4002c5293aa0f96585e23992e6b539961a4 [formerly ad29706e81fe2facde2a1e669ac0e0b558f0ae0a]] Former-commit-id: 32b8c7ebe3a5bccd02fa929471548b8872bdac16 [formerly 5d1450890b7dc43e967e3e1431f2ceb6c415b655] Former-commit-id: 21f53b1616bc5c367f7696c86781e5dad8455335 --- SDK/include/NDK/Widgets/ButtonWidget.hpp | 3 +++ SDK/src/NDK/Widgets/ButtonWidget.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/SDK/include/NDK/Widgets/ButtonWidget.hpp b/SDK/include/NDK/Widgets/ButtonWidget.hpp index 157304738..e2173d17e 100644 --- a/SDK/include/NDK/Widgets/ButtonWidget.hpp +++ b/SDK/include/NDK/Widgets/ButtonWidget.hpp @@ -34,11 +34,14 @@ namespace Ndk ButtonWidget& operator=(const ButtonWidget&) = delete; ButtonWidget& operator=(ButtonWidget&&) = default; + NazaraSignal(OnButtonTrigger, const ButtonWidget* /*button*/); + private: void Layout() override; void OnMouseEnter() override; void OnMouseMoved(int x, int y, int deltaX, int deltaY) override; + void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button) override; void OnMouseExit() override; EntityHandle m_textEntity; diff --git a/SDK/src/NDK/Widgets/ButtonWidget.cpp b/SDK/src/NDK/Widgets/ButtonWidget.cpp index db7fa53b4..d2005bb8b 100644 --- a/SDK/src/NDK/Widgets/ButtonWidget.cpp +++ b/SDK/src/NDK/Widgets/ButtonWidget.cpp @@ -48,6 +48,12 @@ namespace Ndk m_textEntity->GetComponent().SetPosition(contentSize.x / 2 - textBox.width / 2, contentSize.y / 2 - textBox.height / 2); } + void ButtonWidget::OnMouseButtonRelease(int /*x*/, int /*y*/, Nz::Mouse::Button button) + { + if (button == Nz::Mouse::Left) + OnButtonTrigger(this); + } + void ButtonWidget::OnMouseEnter() { m_gradientSprite->SetColor(Nz::Color(128, 128, 128)); From cf523f8dff9dfa54d633ec6f0fd3ce4fed982898 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 16 Sep 2016 17:26:41 +0200 Subject: [PATCH 234/235] Build: Exclude Canvas from SDKServer Former-commit-id: dd4a58fbed3f78e8409d6e4b64ce56ff8931196a [formerly 6e5e1187887403a27e6db10a7573f88bb420b66d] [formerly cd92e9bb999655ec61800c9c6dd82841001d55d9 [formerly 16a3cff53b7491731b8d8f4bdf5103b2e384a359]] Former-commit-id: 502c2ad8828b5a84232b622aedefbce9e7fa112d [formerly 081c0d9b4db201c03bf080b78f42539cab0bff06] Former-commit-id: 356d9849d351839c6d749b2d697f6a1c4b4cf123 --- build/scripts/tools/ndk_server.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index f8550878f..d20a90627 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -25,6 +25,7 @@ TOOL.Files = { -- Excludes client-only files TOOL.FilesExcluded = { "../SDK/**/CameraComponent.*", + "../SDK/**/Canvas.*", "../SDK/**/Console.*", "../SDK/**/GraphicsComponent.*", "../SDK/**/LightComponent.*",