Merge branch 'master' into vulkan
Former-commit-id: 783e31e1f02fea8f9cd5080dc5295eead00ba1ce [formerly 7bf4eb3cc900923a8b3483b45e73333954a9c143] [formerly bd47f3386b2ccaa49ab5a45d874ebcdd653df81f [formerly 60494c4bdb49e4c3cfbdd97f048ee9e5b7b3a81d]] Former-commit-id: eea148c75240307741b212eff37937ae325d323d [formerly df04c665b6bddd805665558928d8b16938c719fc] Former-commit-id: f69cd1b0f1762bb2c4a289e553207adbd622ac5a
This commit is contained in:
commit
9762acab62
|
|
@ -10,6 +10,9 @@ tests/*.dll
|
||||||
tests/*.so
|
tests/*.so
|
||||||
lib/*
|
lib/*
|
||||||
|
|
||||||
|
# Example generated files
|
||||||
|
examples/bin/HardwareInfo.txt
|
||||||
|
|
||||||
# Feature page
|
# Feature page
|
||||||
build/scripts/features/index.html
|
build/scripts/features/index.html
|
||||||
|
|
||||||
|
|
|
||||||
4
Doxyfile
4
Doxyfile
|
|
@ -776,7 +776,9 @@ WARN_LOGFILE =
|
||||||
# Note: If this tag is empty the current directory is searched.
|
# Note: If this tag is empty the current directory is searched.
|
||||||
|
|
||||||
INPUT = include \
|
INPUT = include \
|
||||||
src
|
src \
|
||||||
|
SDK/include \
|
||||||
|
SDK/src
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# 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
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,15 @@
|
||||||
|
|
||||||
namespace Ndk
|
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<unsigned int N>
|
template<unsigned int N>
|
||||||
ComponentId BuildComponentId(const char (&name)[N])
|
ComponentId BuildComponentId(const char (&name)[N])
|
||||||
{
|
{
|
||||||
|
|
@ -19,18 +27,38 @@ namespace Ndk
|
||||||
return componentId;
|
return componentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup NDK
|
||||||
|
* \brief Gets the component id of a component
|
||||||
|
* \return Identifier for the component
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
ComponentIndex GetComponentIndex()
|
ComponentIndex GetComponentIndex()
|
||||||
{
|
{
|
||||||
return ComponentType::componentIndex;
|
return ComponentType::componentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup NDK
|
||||||
|
* \brief Gets the system id of a system
|
||||||
|
* \return Identifier for the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename SystemType>
|
template<typename SystemType>
|
||||||
SystemIndex GetSystemIndex()
|
SystemIndex GetSystemIndex()
|
||||||
{
|
{
|
||||||
return SystemType::systemIndex;
|
return SystemType::systemIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup NDK
|
||||||
|
* \brief Initializes the a component
|
||||||
|
* \return Identifier for the component
|
||||||
|
*
|
||||||
|
* \param name Name to generate id from
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType, unsigned int N>
|
template<typename ComponentType, unsigned int N>
|
||||||
ComponentIndex InitializeComponent(const char (&name)[N])
|
ComponentIndex InitializeComponent(const char (&name)[N])
|
||||||
{
|
{
|
||||||
|
|
@ -38,6 +66,12 @@ namespace Ndk
|
||||||
return ComponentType::componentIndex;
|
return ComponentType::componentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup NDK
|
||||||
|
* \brief Initializes the a system
|
||||||
|
* \return Identifier for the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename SystemType>
|
template<typename SystemType>
|
||||||
SystemIndex InitializeSystem()
|
SystemIndex InitializeSystem()
|
||||||
{
|
{
|
||||||
|
|
@ -45,12 +79,26 @@ namespace Ndk
|
||||||
return SystemType::systemIndex;
|
return SystemType::systemIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether the parameter is a component
|
||||||
|
* \return true If it is the case
|
||||||
|
*
|
||||||
|
* \param component Component to check
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType, typename C>
|
template<typename ComponentType, typename C>
|
||||||
bool IsComponent(C& component)
|
bool IsComponent(C& component)
|
||||||
{
|
{
|
||||||
return component.GetIndex() == GetComponentIndex<ComponentType>();
|
return component.GetIndex() == GetComponentIndex<ComponentType>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether the parameter is a system
|
||||||
|
* \return true If it is the case
|
||||||
|
*
|
||||||
|
* \param system System to check
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename SystemType, typename S>
|
template<typename SystemType, typename S>
|
||||||
bool IsSystem(S& system)
|
bool IsSystem(S& system)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,35 @@
|
||||||
#define NDK_APPLICATION_HPP
|
#define NDK_APPLICATION_HPP
|
||||||
|
|
||||||
#include <NDK/Prerequesites.hpp>
|
#include <NDK/Prerequesites.hpp>
|
||||||
|
#include <NDK/EntityOwner.hpp>
|
||||||
#include <NDK/World.hpp>
|
#include <NDK/World.hpp>
|
||||||
#include <Nazara/Core/Clock.hpp>
|
#include <Nazara/Core/Clock.hpp>
|
||||||
#include <Nazara/Utility/Window.hpp>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
#include <NDK/Console.hpp>
|
||||||
|
#include <Nazara/Core/Log.hpp>
|
||||||
|
#include <Nazara/Lua/LuaInstance.hpp>
|
||||||
|
#include <Nazara/Graphics/TextSprite.hpp>
|
||||||
|
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||||
|
#include <Nazara/Utility/Window.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
class NDK_API Application
|
class NDK_API Application
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
struct ConsoleOverlay;
|
||||||
|
struct FPSCounterOverlay;
|
||||||
|
#endif
|
||||||
|
|
||||||
inline Application();
|
inline Application();
|
||||||
|
Application(int argc, char* argv[]);
|
||||||
Application(const Application&) = delete;
|
Application(const Application&) = delete;
|
||||||
Application(Application&&) = delete;
|
Application(Application&&) = delete;
|
||||||
inline ~Application();
|
inline ~Application();
|
||||||
|
|
@ -29,8 +46,27 @@ namespace Ndk
|
||||||
#endif
|
#endif
|
||||||
template<typename... Args> World& AddWorld(Args&&... args);
|
template<typename... Args> 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 const std::set<Nz::String>& GetOptions() const;
|
||||||
|
inline const std::map<Nz::String, Nz::String>& GetParameters() const;
|
||||||
|
|
||||||
inline float GetUpdateTime() 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;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Run();
|
bool Run();
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
|
|
@ -44,13 +80,63 @@ namespace Ndk
|
||||||
|
|
||||||
inline static Application* Instance();
|
inline static Application* Instance();
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
struct ConsoleOverlay
|
||||||
|
{
|
||||||
|
std::unique_ptr<Console> console;
|
||||||
|
Nz::LuaInstance lua;
|
||||||
|
|
||||||
|
NazaraSlot(Nz::EventHandler, OnEvent, eventSlot);
|
||||||
|
NazaraSlot(Nz::EventHandler, OnKeyPressed, keyPressedSlot);
|
||||||
|
NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, resizedSlot);
|
||||||
|
NazaraSlot(Nz::Log, OnLogWrite, logSlot);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FPSCounterOverlay
|
||||||
|
{
|
||||||
|
Nz::TextSpriteRef sprite;
|
||||||
|
EntityOwner entity;
|
||||||
|
float elapsedTime = 0.f;
|
||||||
|
unsigned int frameCount = 0;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
std::vector<std::unique_ptr<Nz::Window>> m_windows;
|
enum OverlayFlags
|
||||||
|
{
|
||||||
|
OverlayFlags_Console = 0x1,
|
||||||
|
OverlayFlags_FPSCounter = 0x2
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WindowInfo
|
||||||
|
{
|
||||||
|
inline WindowInfo(std::unique_ptr<Nz::Window>&& window);
|
||||||
|
|
||||||
|
Nz::RenderTarget* renderTarget;
|
||||||
|
std::unique_ptr<Nz::Window> window;
|
||||||
|
std::unique_ptr<ConsoleOverlay> console;
|
||||||
|
std::unique_ptr<FPSCounterOverlay> fpsCounter;
|
||||||
|
std::unique_ptr<World> overlayWorld;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetupConsole(WindowInfo& info);
|
||||||
|
void SetupFPSCounter(WindowInfo& info);
|
||||||
|
void SetupOverlay(WindowInfo& info);
|
||||||
|
|
||||||
|
template<typename T> void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/);
|
||||||
|
template<typename T> void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/);
|
||||||
|
|
||||||
|
std::vector<WindowInfo> m_windows;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::map<Nz::String, Nz::String> m_parameters;
|
||||||
|
std::set<Nz::String> m_options;
|
||||||
std::list<World> m_worlds;
|
std::list<World> m_worlds;
|
||||||
Nz::Clock m_updateClock;
|
Nz::Clock m_updateClock;
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
|
Nz::UInt32 m_overlayFlags;
|
||||||
bool m_exitOnClosedWindows;
|
bool m_exitOnClosedWindows;
|
||||||
#endif
|
#endif
|
||||||
bool m_shouldQuit;
|
bool m_shouldQuit;
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,23 @@
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Application.hpp>
|
||||||
#include <Nazara/Core/ErrorFlags.hpp>
|
#include <Nazara/Core/ErrorFlags.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <NDK/Sdk.hpp>
|
#include <NDK/Sdk.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs an Application object without passing command-line arguments
|
||||||
|
*
|
||||||
|
* This calls Sdk::Initialize()
|
||||||
|
*
|
||||||
|
* \remark Only one Application instance can exist at a time
|
||||||
|
*/
|
||||||
inline Application::Application() :
|
inline Application::Application() :
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
|
m_overlayFlags(0U),
|
||||||
m_exitOnClosedWindows(true),
|
m_exitOnClosedWindows(true),
|
||||||
#endif
|
#endif
|
||||||
m_shouldQuit(false),
|
m_shouldQuit(false),
|
||||||
|
|
@ -24,6 +33,11 @@ namespace Ndk
|
||||||
Sdk::Initialize();
|
Sdk::Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destructs the application object
|
||||||
|
*
|
||||||
|
* This destroy all worlds and windows and then calls Sdk::Uninitialize
|
||||||
|
*/
|
||||||
inline Application::~Application()
|
inline Application::~Application()
|
||||||
{
|
{
|
||||||
m_worlds.clear();
|
m_worlds.clear();
|
||||||
|
|
@ -31,24 +45,43 @@ namespace Ndk
|
||||||
m_windows.clear();
|
m_windows.clear();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Libération du SDK
|
// Free of SDK
|
||||||
Sdk::Uninitialize();
|
Sdk::Uninitialize();
|
||||||
|
|
||||||
// Libération automatique des modules
|
// Automatic free of modules
|
||||||
s_application = nullptr;
|
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
|
#ifndef NDK_SERVER
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
T& Application::AddWindow(Args&&... args)
|
T& Application::AddWindow(Args&&... args)
|
||||||
{
|
{
|
||||||
static_assert(std::is_base_of<Nz::Window, T>::value, "Type must inherit Window");
|
static_assert(std::is_base_of<Nz::Window, T>::value, "Type must inherit Window");
|
||||||
|
|
||||||
m_windows.emplace_back(new T(std::forward<Args>(args)...));
|
m_windows.emplace_back(std::make_unique<T>(std::forward<Args>(args)...));
|
||||||
return static_cast<T&>(*m_windows.back().get());
|
WindowInfo& info = m_windows.back();
|
||||||
|
|
||||||
|
T& window = static_cast<T&>(*info.window.get()); //< Warning: ugly
|
||||||
|
|
||||||
|
SetupWindow(info, &window, std::is_base_of<Nz::RenderTarget, T>());
|
||||||
|
|
||||||
|
return window;
|
||||||
}
|
}
|
||||||
#endif
|
#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<typename... Args>
|
template<typename... Args>
|
||||||
World& Application::AddWorld(Args&&... args)
|
World& Application::AddWorld(Args&&... args)
|
||||||
{
|
{
|
||||||
|
|
@ -56,11 +89,241 @@ namespace Ndk
|
||||||
return m_worlds.back();
|
return m_worlds.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enable/disable debug console
|
||||||
|
*
|
||||||
|
* \param enable Should the console overlay be enabled
|
||||||
|
*/
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (info.renderTarget)
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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))
|
||||||
|
{
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
if (m_overlayFlags == 0)
|
||||||
|
{
|
||||||
|
for (WindowInfo& info : m_windows)
|
||||||
|
SetupOverlay(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (WindowInfo& info : m_windows)
|
||||||
|
{
|
||||||
|
if (info.renderTarget)
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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
|
||||||
|
*/
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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
|
||||||
|
*/
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#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<Nz::String>& 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<Nz::String, Nz::String>& Application::GetParameters() const
|
||||||
|
{
|
||||||
|
return m_parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the update time of the application
|
||||||
|
* \return Update rate
|
||||||
|
*/
|
||||||
inline float Application::GetUpdateTime() const
|
inline float Application::GetUpdateTime() const
|
||||||
{
|
{
|
||||||
return m_updateTime;
|
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
|
||||||
|
*
|
||||||
|
* \remark This has nothing to do with the visibility state of the console
|
||||||
|
*
|
||||||
|
* \return True if the console overlay is enabled
|
||||||
|
*
|
||||||
|
* \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
|
||||||
|
* \return True if the FPS counter overlay is enabled
|
||||||
|
*
|
||||||
|
* \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
|
||||||
|
*
|
||||||
|
* \param exitOnClosedWindows Should exit be called when no more window is open
|
||||||
|
*/
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows)
|
inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows)
|
||||||
{
|
{
|
||||||
|
|
@ -68,13 +331,52 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Quits the application
|
||||||
|
*/
|
||||||
|
|
||||||
inline void Application::Quit()
|
inline void Application::Quit()
|
||||||
{
|
{
|
||||||
m_shouldQuit = true;
|
m_shouldQuit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the singleton instance of the application
|
||||||
|
* \return Singleton application
|
||||||
|
*/
|
||||||
|
|
||||||
inline Application* Application::Instance()
|
inline Application* Application::Instance()
|
||||||
{
|
{
|
||||||
return s_application;
|
return s_application;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
template<typename T>
|
||||||
|
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<typename T>
|
||||||
|
inline void Application::SetupWindow(WindowInfo&, T*, std::false_type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Application::WindowInfo::WindowInfo(std::unique_ptr<Nz::Window>&& window) :
|
||||||
|
window(std::move(window)),
|
||||||
|
renderTarget(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace Ndk
|
||||||
BaseComponent(BaseComponent&&) = default;
|
BaseComponent(BaseComponent&&) = default;
|
||||||
virtual ~BaseComponent();
|
virtual ~BaseComponent();
|
||||||
|
|
||||||
virtual BaseComponent* Clone() const = 0;
|
virtual std::unique_ptr<BaseComponent> Clone() const = 0;
|
||||||
|
|
||||||
ComponentIndex GetIndex() const;
|
ComponentIndex GetIndex() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,34 +7,60 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a BaseComponent object with an index
|
||||||
|
*
|
||||||
|
* \param index Index of the component
|
||||||
|
*/
|
||||||
|
|
||||||
inline BaseComponent::BaseComponent(ComponentIndex index) :
|
inline BaseComponent::BaseComponent(ComponentIndex index) :
|
||||||
m_componentIndex(index),
|
m_componentIndex(index),
|
||||||
m_entity(nullptr)
|
m_entity(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the index of the component
|
||||||
|
* \return Index of the component
|
||||||
|
*/
|
||||||
|
|
||||||
inline ComponentIndex BaseComponent::GetIndex() const
|
inline ComponentIndex BaseComponent::GetIndex() const
|
||||||
{
|
{
|
||||||
return m_componentIndex;
|
return m_componentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the maximal index of the components
|
||||||
|
* \return Index of the maximal component
|
||||||
|
*/
|
||||||
|
|
||||||
inline ComponentIndex BaseComponent::GetMaxComponentIndex()
|
inline ComponentIndex BaseComponent::GetMaxComponentIndex()
|
||||||
{
|
{
|
||||||
return static_cast<ComponentIndex>(s_entries.size());
|
return static_cast<ComponentIndex>(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)
|
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<ComponentIndex>(s_entries.size());
|
ComponentIndex index = static_cast<ComponentIndex>(s_entries.size());
|
||||||
s_entries.resize(index + 1);
|
s_entries.resize(index + 1);
|
||||||
|
|
||||||
// On récupère et on affecte
|
// We retrieve it and affect it
|
||||||
ComponentEntry& entry = s_entries.back();
|
ComponentEntry& entry = s_entries.back();
|
||||||
entry.factory = factoryFunc;
|
entry.factory = factoryFunc;
|
||||||
entry.id = id;
|
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");
|
NazaraAssert(s_idToIndex.find(id) == s_idToIndex.end(), "This id is already in use");
|
||||||
|
|
||||||
s_idToIndex[id] = index;
|
s_idToIndex[id] = index;
|
||||||
|
|
@ -42,6 +68,10 @@ namespace Ndk
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the entity on which the component operates
|
||||||
|
*/
|
||||||
|
|
||||||
inline void BaseComponent::SetEntity(Entity* entity)
|
inline void BaseComponent::SetEntity(Entity* entity)
|
||||||
{
|
{
|
||||||
if (m_entity != entity)
|
if (m_entity != entity)
|
||||||
|
|
@ -55,12 +85,21 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Initializes the BaseComponent
|
||||||
|
* \return true
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool BaseComponent::Initialize()
|
inline bool BaseComponent::Initialize()
|
||||||
{
|
{
|
||||||
// Rien à faire
|
// Nothing to do
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Uninitializes the BaseComponent
|
||||||
|
*/
|
||||||
|
|
||||||
inline void BaseComponent::Uninitialize()
|
inline void BaseComponent::Uninitialize()
|
||||||
{
|
{
|
||||||
s_entries.clear();
|
s_entries.clear();
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Ndk
|
||||||
|
|
||||||
inline void Enable(bool enable = true);
|
inline void Enable(bool enable = true);
|
||||||
|
|
||||||
virtual BaseSystem* Clone() const = 0;
|
virtual std::unique_ptr<BaseSystem> Clone() const = 0;
|
||||||
|
|
||||||
bool Filters(const Entity* entity) const;
|
bool Filters(const Entity* entity) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,12 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a BaseSystem object with an index
|
||||||
|
*
|
||||||
|
* \param systemId Index of the system
|
||||||
|
*/
|
||||||
|
|
||||||
inline BaseSystem::BaseSystem(SystemIndex systemId) :
|
inline BaseSystem::BaseSystem(SystemIndex systemId) :
|
||||||
m_updateEnabled(true),
|
m_updateEnabled(true),
|
||||||
m_systemIndex(systemId)
|
m_systemIndex(systemId)
|
||||||
|
|
@ -15,6 +21,12 @@ namespace Ndk
|
||||||
SetUpdateRate(30);
|
SetUpdateRate(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a BaseSystem object by copy semantic
|
||||||
|
*
|
||||||
|
* \param system System to copy
|
||||||
|
*/
|
||||||
|
|
||||||
inline BaseSystem::BaseSystem(const BaseSystem& system) :
|
inline BaseSystem::BaseSystem(const BaseSystem& system) :
|
||||||
m_excludedComponents(system.m_excludedComponents),
|
m_excludedComponents(system.m_excludedComponents),
|
||||||
m_requiredComponents(system.m_requiredComponents),
|
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)
|
inline void BaseSystem::Enable(bool enable)
|
||||||
{
|
{
|
||||||
m_updateEnabled = enable;
|
m_updateEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets every entities that system handle
|
||||||
|
* \return A constant reference to the list of entities
|
||||||
|
*/
|
||||||
|
|
||||||
inline const std::vector<EntityHandle>& BaseSystem::GetEntities() const
|
inline const std::vector<EntityHandle>& BaseSystem::GetEntities() const
|
||||||
{
|
{
|
||||||
return m_entities;
|
return m_entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the index of the system
|
||||||
|
* \return Index of the system
|
||||||
|
*/
|
||||||
|
|
||||||
inline SystemIndex BaseSystem::GetIndex() const
|
inline SystemIndex BaseSystem::GetIndex() const
|
||||||
{
|
{
|
||||||
return m_systemIndex;
|
return m_systemIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the rate of update for the system
|
||||||
|
* \return Update rate
|
||||||
|
*/
|
||||||
|
|
||||||
inline float BaseSystem::GetUpdateRate() const
|
inline float BaseSystem::GetUpdateRate() const
|
||||||
{
|
{
|
||||||
return (m_updateRate > 0.f) ? 1.f / m_updateRate : 0.f;
|
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
|
inline World& BaseSystem::GetWorld() const
|
||||||
{
|
{
|
||||||
return *m_world;
|
return *m_world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether or not the system is enabled
|
||||||
|
* \return true If it is the case
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool BaseSystem::IsEnabled() const
|
inline bool BaseSystem::IsEnabled() const
|
||||||
{
|
{
|
||||||
return m_updateEnabled;
|
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
|
inline bool BaseSystem::HasEntity(const Entity* entity) const
|
||||||
{
|
{
|
||||||
if (!entity)
|
if (!entity)
|
||||||
|
|
@ -63,12 +113,24 @@ namespace Ndk
|
||||||
return m_entityBits.UnboundedTest(entity->GetId());
|
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)
|
inline void BaseSystem::SetUpdateRate(float updatePerSecond)
|
||||||
{
|
{
|
||||||
m_updateCounter = 0.f;
|
m_updateCounter = 0.f;
|
||||||
m_updateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit
|
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)
|
inline void BaseSystem::Update(float elapsedTime)
|
||||||
{
|
{
|
||||||
if (!IsEnabled())
|
if (!IsEnabled())
|
||||||
|
|
@ -88,6 +150,10 @@ namespace Ndk
|
||||||
OnUpdate(elapsedTime);
|
OnUpdate(elapsedTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Excludes some component from the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
void BaseSystem::Excludes()
|
void BaseSystem::Excludes()
|
||||||
{
|
{
|
||||||
|
|
@ -96,6 +162,10 @@ namespace Ndk
|
||||||
ExcludesComponent(GetComponentIndex<ComponentType>());
|
ExcludesComponent(GetComponentIndex<ComponentType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Excludes some components from the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType1, typename ComponentType2, typename... Rest>
|
template<typename ComponentType1, typename ComponentType2, typename... Rest>
|
||||||
void BaseSystem::Excludes()
|
void BaseSystem::Excludes()
|
||||||
{
|
{
|
||||||
|
|
@ -103,16 +173,31 @@ namespace Ndk
|
||||||
Excludes<ComponentType2, Rest...>();
|
Excludes<ComponentType2, Rest...>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Excludes some component from the system by index
|
||||||
|
*
|
||||||
|
* \param index Index of the component
|
||||||
|
*/
|
||||||
|
|
||||||
inline void BaseSystem::ExcludesComponent(ComponentIndex index)
|
inline void BaseSystem::ExcludesComponent(ComponentIndex index)
|
||||||
{
|
{
|
||||||
m_excludedComponents.UnboundedSet(index);
|
m_excludedComponents.UnboundedSet(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the next index for the system
|
||||||
|
* \return Next unique index for the system
|
||||||
|
*/
|
||||||
|
|
||||||
inline SystemIndex BaseSystem::GetNextIndex()
|
inline SystemIndex BaseSystem::GetNextIndex()
|
||||||
{
|
{
|
||||||
return s_nextIndex++;
|
return s_nextIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Requires some component from the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
void BaseSystem::Requires()
|
void BaseSystem::Requires()
|
||||||
{
|
{
|
||||||
|
|
@ -121,6 +206,10 @@ namespace Ndk
|
||||||
RequiresComponent(GetComponentIndex<ComponentType>());
|
RequiresComponent(GetComponentIndex<ComponentType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Requires some components from the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType1, typename ComponentType2, typename... Rest>
|
template<typename ComponentType1, typename ComponentType2, typename... Rest>
|
||||||
void BaseSystem::Requires()
|
void BaseSystem::Requires()
|
||||||
{
|
{
|
||||||
|
|
@ -128,11 +217,21 @@ namespace Ndk
|
||||||
Requires<ComponentType2, Rest...>();
|
Requires<ComponentType2, Rest...>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Requires some component for the system by index
|
||||||
|
*
|
||||||
|
* \param index Index of the component
|
||||||
|
*/
|
||||||
|
|
||||||
inline void BaseSystem::RequiresComponent(ComponentIndex index)
|
inline void BaseSystem::RequiresComponent(ComponentIndex index)
|
||||||
{
|
{
|
||||||
m_requiredComponents.UnboundedSet(index);
|
m_requiredComponents.UnboundedSet(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Requires any component from the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
void BaseSystem::RequiresAny()
|
void BaseSystem::RequiresAny()
|
||||||
{
|
{
|
||||||
|
|
@ -141,6 +240,10 @@ namespace Ndk
|
||||||
RequiresAnyComponent(GetComponentIndex<ComponentType>());
|
RequiresAnyComponent(GetComponentIndex<ComponentType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Requires any components from the system
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType1, typename ComponentType2, typename... Rest>
|
template<typename ComponentType1, typename ComponentType2, typename... Rest>
|
||||||
void BaseSystem::RequiresAny()
|
void BaseSystem::RequiresAny()
|
||||||
{
|
{
|
||||||
|
|
@ -148,11 +251,25 @@ namespace Ndk
|
||||||
RequiresAny<ComponentType2, Rest...>();
|
RequiresAny<ComponentType2, Rest...>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Requires any component for the system by index
|
||||||
|
*
|
||||||
|
* \param index Index of the component
|
||||||
|
*/
|
||||||
|
|
||||||
inline void BaseSystem::RequiresAnyComponent(ComponentIndex index)
|
inline void BaseSystem::RequiresAnyComponent(ComponentIndex index)
|
||||||
{
|
{
|
||||||
m_requiredAnyComponents.UnboundedSet(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)
|
inline void BaseSystem::AddEntity(Entity* entity)
|
||||||
{
|
{
|
||||||
NazaraAssert(entity, "Invalid entity");
|
NazaraAssert(entity, "Invalid entity");
|
||||||
|
|
@ -165,6 +282,14 @@ namespace Ndk
|
||||||
OnEntityAdded(entity);
|
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)
|
inline void BaseSystem::RemoveEntity(Entity* entity)
|
||||||
{
|
{
|
||||||
NazaraAssert(entity, "Invalid entity");
|
NazaraAssert(entity, "Invalid entity");
|
||||||
|
|
@ -172,16 +297,25 @@ namespace Ndk
|
||||||
auto it = std::find(m_entities.begin(), m_entities.end(), *entity);
|
auto it = std::find(m_entities.begin(), m_entities.end(), *entity);
|
||||||
NazaraAssert(it != m_entities.end(), "Entity is not part of this system");
|
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());
|
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());
|
m_entityBits.Reset(entity->GetId());
|
||||||
entity->UnregisterSystem(m_systemIndex);
|
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)
|
inline void BaseSystem::ValidateEntity(Entity* entity, bool justAdded)
|
||||||
{
|
{
|
||||||
NazaraAssert(entity, "Invalid entity");
|
NazaraAssert(entity, "Invalid entity");
|
||||||
|
|
@ -190,11 +324,20 @@ namespace Ndk
|
||||||
OnEntityValidation(entity, justAdded);
|
OnEntityValidation(entity, justAdded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the world on which the system operates
|
||||||
|
*/
|
||||||
|
|
||||||
inline void BaseSystem::SetWorld(World* world) noexcept
|
inline void BaseSystem::SetWorld(World* world) noexcept
|
||||||
{
|
{
|
||||||
m_world = world;
|
m_world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Initializes the BaseSystem
|
||||||
|
* \return true
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool BaseSystem::Initialize()
|
inline bool BaseSystem::Initialize()
|
||||||
{
|
{
|
||||||
s_nextIndex = 0;
|
s_nextIndex = 0;
|
||||||
|
|
@ -202,6 +345,10 @@ namespace Ndk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Uninitializes the BaseSystem
|
||||||
|
*/
|
||||||
|
|
||||||
inline void BaseSystem::Uninitialize()
|
inline void BaseSystem::Uninitialize()
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Ndk
|
||||||
Component();
|
Component();
|
||||||
virtual ~Component();
|
virtual ~Component();
|
||||||
|
|
||||||
BaseComponent* Clone() const override;
|
std::unique_ptr<BaseComponent> Clone() const override;
|
||||||
|
|
||||||
static ComponentIndex RegisterComponent(ComponentId id);
|
static ComponentIndex RegisterComponent(ComponentId id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,18 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \ingroup NDK
|
||||||
|
* \class Ndk::Component<ComponentType>
|
||||||
|
* \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<Subtype>"
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a Component object by default
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
Component<ComponentType>::Component() :
|
Component<ComponentType>::Component() :
|
||||||
BaseComponent(GetComponentIndex<ComponentType>())
|
BaseComponent(GetComponentIndex<ComponentType>())
|
||||||
|
|
@ -16,19 +28,30 @@ namespace Ndk
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
Component<ComponentType>::~Component() = default;
|
Component<ComponentType>::~Component() = default;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Clones the component
|
||||||
|
* \return The clone newly created
|
||||||
|
*
|
||||||
|
* \remark The component to clone should be trivially copy constructible
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
BaseComponent* Component<ComponentType>::Clone() const
|
std::unique_ptr<BaseComponent> Component<ComponentType>::Clone() const
|
||||||
{
|
{
|
||||||
///FIXME: Pas encore supporté par GCC (4.9.2)
|
///FIXME: Pas encore supporté par GCC (4.9.2)
|
||||||
//static_assert(std::is_trivially_copy_constructible<ComponentType>::value, "ComponentType must be copy-constructible");
|
//static_assert(std::is_trivially_copy_constructible<ComponentType>::value, "ComponentType must be copy-constructible");
|
||||||
|
|
||||||
return new ComponentType(static_cast<const ComponentType&>(*this));
|
return std::make_unique<ComponentType>(static_cast<const ComponentType&>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Registers the component by assigning it an index
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
ComponentIndex Component<ComponentType>::RegisterComponent(ComponentId id)
|
ComponentIndex Component<ComponentType>::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*
|
auto factory = []() -> BaseComponent*
|
||||||
{
|
{
|
||||||
return nullptr; //< Temporary workaround to allow non-default-constructed components, will be updated for serialization
|
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);
|
return BaseComponent::RegisterComponent(id, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Registers the component by assigning it an index based on the name
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename ComponentType>
|
template<typename ComponentType>
|
||||||
template<unsigned int N>
|
template<unsigned int N>
|
||||||
ComponentIndex Component<ComponentType>::RegisterComponent(const char (&name)[N])
|
ComponentIndex Component<ComponentType>::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);
|
ComponentId id = BuildComponentId(name);
|
||||||
return RegisterComponent(id);
|
return RegisterComponent(id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs an CameraComponent object by default
|
||||||
|
*/
|
||||||
|
|
||||||
inline CameraComponent::CameraComponent() :
|
inline CameraComponent::CameraComponent() :
|
||||||
m_projectionType(Nz::ProjectionType_Perspective),
|
m_projectionType(Nz::ProjectionType_Perspective),
|
||||||
m_targetRegion(0.f, 0.f, 1.f, 1.f),
|
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) :
|
inline CameraComponent::CameraComponent(const CameraComponent& camera) :
|
||||||
Component(camera),
|
Component(camera),
|
||||||
AbstractViewer(camera),
|
AbstractViewer(camera),
|
||||||
|
|
@ -45,30 +55,51 @@ namespace Ndk
|
||||||
SetTarget(camera.m_target);
|
SetTarget(camera.m_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Ensures the frustum is up to date
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::EnsureFrustumUpdate() const
|
inline void CameraComponent::EnsureFrustumUpdate() const
|
||||||
{
|
{
|
||||||
if (!m_frustumUpdated)
|
if (!m_frustumUpdated)
|
||||||
UpdateFrustum();
|
UpdateFrustum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Ensures the projection matrix is up to date
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::EnsureProjectionMatrixUpdate() const
|
inline void CameraComponent::EnsureProjectionMatrixUpdate() const
|
||||||
{
|
{
|
||||||
if (!m_projectionMatrixUpdated)
|
if (!m_projectionMatrixUpdated)
|
||||||
UpdateProjectionMatrix();
|
UpdateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Ensures the view matrix is up to date
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::EnsureViewMatrixUpdate() const
|
inline void CameraComponent::EnsureViewMatrixUpdate() const
|
||||||
{
|
{
|
||||||
if (!m_viewMatrixUpdated)
|
if (!m_viewMatrixUpdated)
|
||||||
UpdateViewMatrix();
|
UpdateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Ensures the view port is up to date
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::EnsureViewportUpdate() const
|
inline void CameraComponent::EnsureViewportUpdate() const
|
||||||
{
|
{
|
||||||
if (!m_viewportUpdated)
|
if (!m_viewportUpdated)
|
||||||
UpdateViewport();
|
UpdateViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the aspect ratio of the camera
|
||||||
|
* \return Aspect ratio of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline float CameraComponent::GetAspectRatio() const
|
inline float CameraComponent::GetAspectRatio() const
|
||||||
{
|
{
|
||||||
EnsureViewportUpdate();
|
EnsureViewportUpdate();
|
||||||
|
|
@ -76,11 +107,21 @@ namespace Ndk
|
||||||
return m_aspectRatio;
|
return m_aspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the field of view of the camera
|
||||||
|
* \return Field of view of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline float CameraComponent::GetFOV() const
|
inline float CameraComponent::GetFOV() const
|
||||||
{
|
{
|
||||||
return m_fov;
|
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
|
inline const Nz::Frustumf& CameraComponent::GetFrustum() const
|
||||||
{
|
{
|
||||||
EnsureFrustumUpdate();
|
EnsureFrustumUpdate();
|
||||||
|
|
@ -88,11 +129,21 @@ namespace Ndk
|
||||||
return m_frustum;
|
return m_frustum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the layer of the camera
|
||||||
|
* \return Layer of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int CameraComponent::GetLayer() const
|
inline unsigned int CameraComponent::GetLayer() const
|
||||||
{
|
{
|
||||||
return m_layer;
|
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
|
inline const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const
|
||||||
{
|
{
|
||||||
EnsureProjectionMatrixUpdate();
|
EnsureProjectionMatrixUpdate();
|
||||||
|
|
@ -100,26 +151,51 @@ namespace Ndk
|
||||||
return m_projectionMatrix;
|
return m_projectionMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the projection type of the camera
|
||||||
|
* \return Projection type of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline Nz::ProjectionType CameraComponent::GetProjectionType() const
|
inline Nz::ProjectionType CameraComponent::GetProjectionType() const
|
||||||
{
|
{
|
||||||
return m_projectionType;
|
return m_projectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the size of the camera
|
||||||
|
* \return Size of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline const Nz::Vector2f & CameraComponent::GetSize() const
|
inline const Nz::Vector2f & CameraComponent::GetSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
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
|
inline const Nz::RenderTarget* CameraComponent::GetTarget() const
|
||||||
{
|
{
|
||||||
return m_target;
|
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
|
inline const Nz::Rectf& CameraComponent::GetTargetRegion() const
|
||||||
{
|
{
|
||||||
return m_targetRegion;
|
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
|
inline const Nz::Matrix4f& CameraComponent::GetViewMatrix() const
|
||||||
{
|
{
|
||||||
EnsureViewMatrixUpdate();
|
EnsureViewMatrixUpdate();
|
||||||
|
|
@ -127,6 +203,11 @@ namespace Ndk
|
||||||
return m_viewMatrix;
|
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
|
inline const Nz::Recti& CameraComponent::GetViewport() const
|
||||||
{
|
{
|
||||||
EnsureViewportUpdate();
|
EnsureViewportUpdate();
|
||||||
|
|
@ -134,16 +215,34 @@ namespace Ndk
|
||||||
return m_viewport;
|
return m_viewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the Z far distance of the camera
|
||||||
|
* \return Z far distance of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline float CameraComponent::GetZFar() const
|
inline float CameraComponent::GetZFar() const
|
||||||
{
|
{
|
||||||
return m_zFar;
|
return m_zFar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the Z near distance of the camera
|
||||||
|
* \return Z near distance of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline float CameraComponent::GetZNear() const
|
inline float CameraComponent::GetZNear() const
|
||||||
{
|
{
|
||||||
return m_zNear;
|
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)
|
inline void CameraComponent::SetFOV(float fov)
|
||||||
{
|
{
|
||||||
NazaraAssert(!Nz::NumberEquals(fov, 0.f), "FOV must be different from zero");
|
NazaraAssert(!Nz::NumberEquals(fov, 0.f), "FOV must be different from zero");
|
||||||
|
|
@ -152,6 +251,12 @@ namespace Ndk
|
||||||
InvalidateProjectionMatrix();
|
InvalidateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the projection type of the camera
|
||||||
|
*
|
||||||
|
* \param projectionType Projection type of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::SetProjectionType(Nz::ProjectionType projectionType)
|
inline void CameraComponent::SetProjectionType(Nz::ProjectionType projectionType)
|
||||||
{
|
{
|
||||||
m_projectionType = projectionType;
|
m_projectionType = projectionType;
|
||||||
|
|
@ -159,6 +264,12 @@ namespace Ndk
|
||||||
InvalidateProjectionMatrix();
|
InvalidateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the size of the camera
|
||||||
|
*
|
||||||
|
* \param size Size of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::SetSize(const Nz::Vector2f& size)
|
inline void CameraComponent::SetSize(const Nz::Vector2f& size)
|
||||||
{
|
{
|
||||||
m_size = size;
|
m_size = size;
|
||||||
|
|
@ -166,11 +277,24 @@ namespace Ndk
|
||||||
InvalidateProjectionMatrix();
|
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)
|
inline void CameraComponent::SetSize(float width, float height)
|
||||||
{
|
{
|
||||||
SetSize({width, 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)
|
inline void CameraComponent::SetTarget(const Nz::RenderTarget* renderTarget)
|
||||||
{
|
{
|
||||||
m_target = 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)
|
inline void CameraComponent::SetTargetRegion(const Nz::Rectf& region)
|
||||||
{
|
{
|
||||||
m_targetRegion = region;
|
m_targetRegion = region;
|
||||||
|
|
@ -193,17 +323,31 @@ namespace Ndk
|
||||||
InvalidateViewport();
|
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)
|
inline void CameraComponent::SetViewport(const Nz::Recti& viewport)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_target, "Component has no render target");
|
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
|
// 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 invWidth = 1.f / m_target->GetWidth();
|
||||||
float invHeight = 1.f/m_target->GetHeight();
|
float invHeight = 1.f / m_target->GetHeight();
|
||||||
|
|
||||||
SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
|
SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the Z far distance of the camera
|
||||||
|
*
|
||||||
|
* \param zFar Z far distance of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::SetZFar(float zFar)
|
inline void CameraComponent::SetZFar(float zFar)
|
||||||
{
|
{
|
||||||
m_zFar = zFar;
|
m_zFar = zFar;
|
||||||
|
|
@ -211,6 +355,14 @@ namespace Ndk
|
||||||
InvalidateProjectionMatrix();
|
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)
|
inline void CameraComponent::SetZNear(float zNear)
|
||||||
{
|
{
|
||||||
NazaraAssert(!Nz::NumberEquals(zNear, 0.f), "zNear cannot be zero");
|
NazaraAssert(!Nz::NumberEquals(zNear, 0.f), "zNear cannot be zero");
|
||||||
|
|
@ -219,23 +371,39 @@ namespace Ndk
|
||||||
InvalidateProjectionMatrix();
|
InvalidateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the frustum
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::InvalidateFrustum() const
|
inline void CameraComponent::InvalidateFrustum() const
|
||||||
{
|
{
|
||||||
m_frustumUpdated = false;
|
m_frustumUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the projection matrix
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::InvalidateProjectionMatrix() const
|
inline void CameraComponent::InvalidateProjectionMatrix() const
|
||||||
{
|
{
|
||||||
m_frustumUpdated = false;
|
m_frustumUpdated = false;
|
||||||
m_projectionMatrixUpdated = false;
|
m_projectionMatrixUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the view matrix
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::InvalidateViewMatrix() const
|
inline void CameraComponent::InvalidateViewMatrix() const
|
||||||
{
|
{
|
||||||
m_frustumUpdated = false;
|
m_frustumUpdated = false;
|
||||||
m_viewMatrixUpdated = false;
|
m_viewMatrixUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the view port
|
||||||
|
*/
|
||||||
|
|
||||||
inline void CameraComponent::InvalidateViewport() const
|
inline void CameraComponent::InvalidateViewport() const
|
||||||
{
|
{
|
||||||
m_frustumUpdated = false;
|
m_frustumUpdated = false;
|
||||||
|
|
|
||||||
|
|
@ -9,23 +9,47 @@
|
||||||
|
|
||||||
namespace Ndk
|
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) :
|
inline CollisionComponent::CollisionComponent(Nz::PhysGeomRef geom) :
|
||||||
m_geom(std::move(geom)),
|
m_geom(std::move(geom)),
|
||||||
m_bodyUpdated(false)
|
m_bodyUpdated(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a CollisionComponent object by copy semantic
|
||||||
|
*
|
||||||
|
* \param collision CollisionComponent to copy
|
||||||
|
*/
|
||||||
|
|
||||||
inline CollisionComponent::CollisionComponent(const CollisionComponent& collision) :
|
inline CollisionComponent::CollisionComponent(const CollisionComponent& collision) :
|
||||||
m_geom(collision.m_geom),
|
m_geom(collision.m_geom),
|
||||||
m_bodyUpdated(false)
|
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
|
inline const Nz::PhysGeomRef& CollisionComponent::GetGeom() const
|
||||||
{
|
{
|
||||||
return m_geom;
|
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)
|
inline CollisionComponent& CollisionComponent::operator=(Nz::PhysGeomRef geom)
|
||||||
{
|
{
|
||||||
SetGeom(geom);
|
SetGeom(geom);
|
||||||
|
|
@ -33,6 +57,11 @@ namespace Ndk
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the static body used by the entity
|
||||||
|
* \return A pointer to the entity
|
||||||
|
*/
|
||||||
|
|
||||||
inline Nz::PhysObject* CollisionComponent::GetStaticBody()
|
inline Nz::PhysObject* CollisionComponent::GetStaticBody()
|
||||||
{
|
{
|
||||||
return m_staticBody.get();
|
return m_staticBody.get();
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ namespace Ndk
|
||||||
inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
|
inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
|
||||||
|
|
||||||
inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
|
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();
|
inline void Clear();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,19 @@
|
||||||
// This file is part of the "Nazara Development Kit"
|
// This file is part of the "Nazara Development Kit"
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Components/GraphicsComponent.hpp>
|
||||||
|
#include <NDK/World.hpp>
|
||||||
|
#include <NDK/Systems/RenderSystem.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "GraphicsComponent.hpp"
|
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a GraphicsComponent object by copy semantic
|
||||||
|
*
|
||||||
|
* \param graphicsComponent GraphicsComponent to copy
|
||||||
|
*/
|
||||||
|
|
||||||
inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) :
|
inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) :
|
||||||
Component(graphicsComponent),
|
Component(graphicsComponent),
|
||||||
HandledObject(graphicsComponent),
|
HandledObject(graphicsComponent),
|
||||||
|
|
@ -20,14 +28,23 @@ namespace Ndk
|
||||||
Attach(r.renderable, r.data.renderOrder);
|
Attach(r.renderable, r.data.renderOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Adds the renderable elements to the render queue
|
||||||
|
*
|
||||||
|
* \param renderQueue Queue to be added
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const
|
inline void GraphicsComponent::AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const
|
||||||
{
|
{
|
||||||
EnsureTransformMatrixUpdate();
|
EnsureTransformMatrixUpdate();
|
||||||
|
|
||||||
|
Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem<Ndk::RenderSystem>();
|
||||||
|
|
||||||
for (const Renderable& object : m_renderables)
|
for (const Renderable& object : m_renderables)
|
||||||
{
|
{
|
||||||
if (!object.dataUpdated)
|
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.renderable->UpdateData(&object.data);
|
||||||
object.dataUpdated = true;
|
object.dataUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
@ -36,10 +53,23 @@ 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)
|
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);
|
m_renderables.emplace_back(m_transformMatrix);
|
||||||
Renderable& r = m_renderables.back();
|
Renderable& r = m_renderables.back();
|
||||||
|
r.data.localMatrix = localMatrix;
|
||||||
r.data.renderOrder = renderOrder;
|
r.data.renderOrder = renderOrder;
|
||||||
r.renderable = std::move(renderable);
|
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));
|
||||||
|
|
@ -48,6 +78,10 @@ namespace Ndk
|
||||||
InvalidateBoundingVolume();
|
InvalidateBoundingVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Clears every renderable elements
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::Clear()
|
inline void GraphicsComponent::Clear()
|
||||||
{
|
{
|
||||||
m_renderables.clear();
|
m_renderables.clear();
|
||||||
|
|
@ -55,6 +89,12 @@ namespace Ndk
|
||||||
InvalidateBoundingVolume();
|
InvalidateBoundingVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Detaches a renderable to the entity
|
||||||
|
*
|
||||||
|
* \param renderable Reference to a renderable element
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::Detach(const Nz::InstancedRenderable* renderable)
|
inline void GraphicsComponent::Detach(const Nz::InstancedRenderable* renderable)
|
||||||
{
|
{
|
||||||
for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it)
|
for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it)
|
||||||
|
|
@ -68,18 +108,34 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Ensures the bounding volume is up to date
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::EnsureBoundingVolumeUpdate() const
|
inline void GraphicsComponent::EnsureBoundingVolumeUpdate() const
|
||||||
{
|
{
|
||||||
if (!m_boundingVolumeUpdated)
|
if (!m_boundingVolumeUpdated)
|
||||||
UpdateBoundingVolume();
|
UpdateBoundingVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Ensures the transformation matrix is up to date
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::EnsureTransformMatrixUpdate() const
|
inline void GraphicsComponent::EnsureTransformMatrixUpdate() const
|
||||||
{
|
{
|
||||||
if (!m_transformMatrixUpdated)
|
if (!m_transformMatrixUpdated)
|
||||||
UpdateTransformMatrix();
|
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
|
inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const
|
||||||
{
|
{
|
||||||
NazaraAssert(renderables, "Invalid renderable list");
|
NazaraAssert(renderables, "Invalid renderable list");
|
||||||
|
|
@ -89,11 +145,21 @@ namespace Ndk
|
||||||
renderables->push_back(r.renderable);
|
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
|
inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const
|
||||||
{
|
{
|
||||||
return m_renderables.size();
|
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
|
inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const
|
||||||
{
|
{
|
||||||
EnsureBoundingVolumeUpdate();
|
EnsureBoundingVolumeUpdate();
|
||||||
|
|
@ -101,17 +167,29 @@ namespace Ndk
|
||||||
return m_boundingVolume;
|
return m_boundingVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the bounding volume
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::InvalidateBoundingVolume()
|
inline void GraphicsComponent::InvalidateBoundingVolume()
|
||||||
{
|
{
|
||||||
m_boundingVolumeUpdated = false;
|
m_boundingVolumeUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates every renderable elements
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::InvalidateRenderables()
|
inline void GraphicsComponent::InvalidateRenderables()
|
||||||
{
|
{
|
||||||
for (Renderable& r : m_renderables)
|
for (Renderable& r : m_renderables)
|
||||||
r.dataUpdated = false;
|
r.dataUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the transformation matrix
|
||||||
|
*/
|
||||||
|
|
||||||
inline void GraphicsComponent::InvalidateTransformMatrix()
|
inline void GraphicsComponent::InvalidateTransformMatrix()
|
||||||
{
|
{
|
||||||
m_boundingVolumeUpdated = false;
|
m_boundingVolumeUpdated = false;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs an LightComponent object with a light type
|
||||||
|
*/
|
||||||
|
|
||||||
inline LightComponent::LightComponent(Nz::LightType lightType) :
|
inline LightComponent::LightComponent(Nz::LightType lightType) :
|
||||||
Nz::Light(lightType)
|
Nz::Light(lightType)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,31 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs an ListenerComponent object by default
|
||||||
|
*/
|
||||||
|
|
||||||
inline ListenerComponent::ListenerComponent() :
|
inline ListenerComponent::ListenerComponent() :
|
||||||
m_isActive(true)
|
m_isActive(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether the listener is activated
|
||||||
|
* \param true If it is the case
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool ListenerComponent::IsActive() const
|
inline bool ListenerComponent::IsActive() const
|
||||||
{
|
{
|
||||||
return m_isActive;
|
return m_isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enables the listener
|
||||||
|
*
|
||||||
|
* \param active Should the listener be active
|
||||||
|
*/
|
||||||
|
|
||||||
inline void ListenerComponent::SetActive(bool active)
|
inline void ListenerComponent::SetActive(bool active)
|
||||||
{
|
{
|
||||||
m_isActive = active;
|
m_isActive = active;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,15 @@
|
||||||
|
|
||||||
namespace Ndk
|
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)
|
inline void NodeComponent::SetParent(Entity* entity, bool keepDerived)
|
||||||
{
|
{
|
||||||
if (entity)
|
if (entity)
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,42 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs an ParticleEmitterComponent object by default
|
||||||
|
*/
|
||||||
|
|
||||||
inline ParticleEmitterComponent::ParticleEmitterComponent() :
|
inline ParticleEmitterComponent::ParticleEmitterComponent() :
|
||||||
m_isActive(true)
|
m_isActive(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enables the emission of particles
|
||||||
|
*
|
||||||
|
* \param active Should the emitter be active
|
||||||
|
*/
|
||||||
|
|
||||||
inline void Ndk::ParticleEmitterComponent::Enable(bool active)
|
inline void Ndk::ParticleEmitterComponent::Enable(bool active)
|
||||||
{
|
{
|
||||||
m_isActive = 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
|
inline bool ParticleEmitterComponent::IsActive() const
|
||||||
{
|
{
|
||||||
return m_isActive;
|
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)
|
inline void Ndk::ParticleEmitterComponent::SetSetupFunc(SetupFunc func)
|
||||||
{
|
{
|
||||||
m_setupFunc = std::move(func);
|
m_setupFunc = std::move(func);
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,45 @@
|
||||||
|
|
||||||
namespace Ndk
|
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) :
|
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) :
|
||||||
ParticleGroup(maxParticleCount, 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) :
|
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration) :
|
||||||
ParticleGroup(maxParticleCount, std::move(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)
|
inline void ParticleGroupComponent::AddEmitter(Entity* emitter)
|
||||||
{
|
{
|
||||||
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
|
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
|
||||||
|
|
@ -27,6 +56,16 @@ namespace Ndk
|
||||||
ParticleGroup::AddEmitter(&emitterComponent);
|
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)
|
inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter)
|
||||||
{
|
{
|
||||||
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
|
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,27 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a PhysicsComponent object by copy semantic
|
||||||
|
*
|
||||||
|
* \param physics PhysicsComponent to copy
|
||||||
|
*/
|
||||||
|
|
||||||
inline PhysicsComponent::PhysicsComponent(const PhysicsComponent& physics)
|
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);
|
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)
|
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -19,6 +34,16 @@ namespace Ndk
|
||||||
m_object->AddForce(force, coordSys);
|
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)
|
inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -26,13 +51,30 @@ namespace Ndk
|
||||||
m_object->AddForce(force, point, coordSys);
|
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)
|
inline void PhysicsComponent::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
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)
|
inline void PhysicsComponent::EnableAutoSleep(bool autoSleep)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -40,6 +82,13 @@ namespace Ndk
|
||||||
m_object->EnableAutoSleep(autoSleep);
|
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
|
inline Nz::Boxf PhysicsComponent::GetAABB() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -47,6 +96,13 @@ namespace Ndk
|
||||||
return m_object->GetAABB();
|
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
|
inline Nz::Vector3f PhysicsComponent::GetAngularVelocity() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -54,6 +110,13 @@ namespace Ndk
|
||||||
return m_object->GetAngularVelocity();
|
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
|
inline float PhysicsComponent::GetGravityFactor() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -61,6 +124,13 @@ namespace Ndk
|
||||||
return m_object->GetGravityFactor();
|
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
|
inline float PhysicsComponent::GetMass() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -68,6 +138,15 @@ namespace Ndk
|
||||||
return m_object->GetMass();
|
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
|
inline Nz::Vector3f PhysicsComponent::GetMassCenter(Nz::CoordSys coordSys) const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -75,6 +154,13 @@ namespace Ndk
|
||||||
return m_object->GetMassCenter(coordSys);
|
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
|
inline const Nz::Matrix4f& PhysicsComponent::GetMatrix() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -82,6 +168,13 @@ namespace Ndk
|
||||||
return m_object->GetMatrix();
|
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
|
inline Nz::Vector3f PhysicsComponent::GetPosition() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -89,6 +182,13 @@ namespace Ndk
|
||||||
return m_object->GetPosition();
|
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
|
inline Nz::Quaternionf PhysicsComponent::GetRotation() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -96,6 +196,13 @@ namespace Ndk
|
||||||
return m_object->GetRotation();
|
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
|
inline Nz::Vector3f PhysicsComponent::GetVelocity() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -103,6 +210,13 @@ namespace Ndk
|
||||||
return m_object->GetVelocity();
|
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
|
inline bool PhysicsComponent::IsAutoSleepEnabled() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -110,6 +224,13 @@ namespace Ndk
|
||||||
return m_object->IsAutoSleepEnabled();
|
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
|
inline bool PhysicsComponent::IsSleeping() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -117,6 +238,14 @@ namespace Ndk
|
||||||
return m_object->IsSleeping();
|
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)
|
inline void PhysicsComponent::SetAngularVelocity(const Nz::Vector3f& angularVelocity)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -124,6 +253,14 @@ namespace Ndk
|
||||||
m_object->SetAngularVelocity(angularVelocity);
|
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)
|
inline void PhysicsComponent::SetGravityFactor(float gravityFactor)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -131,6 +268,15 @@ namespace Ndk
|
||||||
m_object->SetGravityFactor(gravityFactor);
|
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)
|
inline void PhysicsComponent::SetMass(float mass)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -139,6 +285,14 @@ namespace Ndk
|
||||||
m_object->SetMass(mass);
|
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)
|
inline void PhysicsComponent::SetMassCenter(const Nz::Vector3f& center)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -146,6 +300,14 @@ namespace Ndk
|
||||||
m_object->SetMassCenter(center);
|
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)
|
inline void PhysicsComponent::SetPosition(const Nz::Vector3f& position)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -153,6 +315,14 @@ namespace Ndk
|
||||||
m_object->SetPosition(position);
|
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)
|
inline void PhysicsComponent::SetRotation(const Nz::Quaternionf& rotation)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -160,6 +330,14 @@ namespace Ndk
|
||||||
m_object->SetRotation(rotation);
|
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)
|
inline void PhysicsComponent::SetVelocity(const Nz::Vector3f& velocity)
|
||||||
{
|
{
|
||||||
NazaraAssert(m_object, "Invalid physics object");
|
NazaraAssert(m_object, "Invalid physics object");
|
||||||
|
|
@ -167,6 +345,11 @@ namespace Ndk
|
||||||
m_object->SetVelocity(velocity);
|
m_object->SetVelocity(velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the underlying physics object
|
||||||
|
* \return A reference to the physics object
|
||||||
|
*/
|
||||||
|
|
||||||
inline Nz::PhysObject& PhysicsComponent::GetPhysObject()
|
inline Nz::PhysObject& PhysicsComponent::GetPhysObject()
|
||||||
{
|
{
|
||||||
return *m_object.get();
|
return *m_object.get();
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,30 @@
|
||||||
|
|
||||||
namespace Ndk
|
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) :
|
inline VelocityComponent::VelocityComponent(const Nz::Vector3f& velocity) :
|
||||||
linearVelocity(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)
|
inline VelocityComponent& VelocityComponent::operator=(const Nz::Vector3f& vel)
|
||||||
{
|
{
|
||||||
linearVelocity = vel;
|
linearVelocity = vel;
|
||||||
|
|
|
||||||
|
|
@ -7,41 +7,81 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Gets the character size
|
||||||
|
* \return Height of the character
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int Console::GetCharacterSize() const
|
inline unsigned int Console::GetCharacterSize() const
|
||||||
{
|
{
|
||||||
return m_characterSize;
|
return m_characterSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the entity representing the history of the console
|
||||||
|
* \return History of the console
|
||||||
|
*/
|
||||||
|
|
||||||
inline const EntityHandle& Console::GetHistory() const
|
inline const EntityHandle& Console::GetHistory() const
|
||||||
{
|
{
|
||||||
return m_history;
|
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
|
inline const EntityHandle& Console::GetHistoryBackground() const
|
||||||
{
|
{
|
||||||
return m_historyBackground;
|
return m_historyBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the entity representing the input of the console
|
||||||
|
* \return Input of the console
|
||||||
|
*/
|
||||||
|
|
||||||
inline const EntityHandle& Console::GetInput() const
|
inline const EntityHandle& Console::GetInput() const
|
||||||
{
|
{
|
||||||
return m_input;
|
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
|
inline const EntityHandle& Console::GetInputBackground() const
|
||||||
{
|
{
|
||||||
return m_inputBackground;
|
return m_inputBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the size of the console
|
||||||
|
* \return Size (Width, Height) of the console
|
||||||
|
*/
|
||||||
|
|
||||||
inline const Nz::Vector2f& Console::GetSize() const
|
inline const Nz::Vector2f& Console::GetSize() const
|
||||||
{
|
{
|
||||||
return m_size;
|
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
|
inline const Nz::FontRef& Console::GetTextFont() const
|
||||||
{
|
{
|
||||||
return m_defaultFont;
|
return m_defaultFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether the console is visible
|
||||||
|
* \return true If it is the case
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool Console::IsVisible() const
|
inline bool Console::IsVisible() const
|
||||||
{
|
{
|
||||||
return m_opened;
|
return m_opened;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ namespace Ndk
|
||||||
|
|
||||||
const EntityHandle& Clone() const;
|
const EntityHandle& Clone() const;
|
||||||
|
|
||||||
inline void Enable(bool enable);
|
inline void Enable(bool enable = true);
|
||||||
|
|
||||||
inline BaseComponent& GetComponent(ComponentIndex index);
|
inline BaseComponent& GetComponent(ComponentIndex index);
|
||||||
template<typename ComponentType> ComponentType& GetComponent();
|
template<typename ComponentType> ComponentType& GetComponent();
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,29 @@
|
||||||
|
|
||||||
namespace Ndk
|
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<typename ComponentType, typename... Args>
|
template<typename ComponentType, typename... Args>
|
||||||
ComponentType& Entity::AddComponent(Args&&... args)
|
ComponentType& Entity::AddComponent(Args&&... args)
|
||||||
{
|
{
|
||||||
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
|
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
|
||||||
|
|
||||||
// Allocation et affectation du component
|
// Affectation and return of the component
|
||||||
std::unique_ptr<ComponentType> ptr(new ComponentType(std::forward<Args>(args)...));
|
std::unique_ptr<ComponentType> ptr(new ComponentType(std::forward<Args>(args)...));
|
||||||
return static_cast<ComponentType&>(AddComponent(std::move(ptr)));
|
return static_cast<ComponentType&>(AddComponent(std::move(ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Enables the entity
|
||||||
|
*
|
||||||
|
* \param enable Should the entity be enabled
|
||||||
|
*/
|
||||||
|
|
||||||
inline void Entity::Enable(bool enable)
|
inline void Entity::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if (m_enabled != 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)
|
inline BaseComponent& Entity::GetComponent(ComponentIndex index)
|
||||||
{
|
{
|
||||||
///DOC: Le component doit être présent
|
|
||||||
NazaraAssert(HasComponent(index), "This component is not part of the entity");
|
NazaraAssert(HasComponent(index), "This component is not part of the entity");
|
||||||
|
|
||||||
BaseComponent* component = m_components[index].get();
|
BaseComponent* component = m_components[index].get();
|
||||||
|
|
@ -41,19 +62,33 @@ namespace Ndk
|
||||||
return *component;
|
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<typename ComponentType>
|
template<typename ComponentType>
|
||||||
ComponentType& Entity::GetComponent()
|
ComponentType& Entity::GetComponent()
|
||||||
{
|
{
|
||||||
///DOC: Le component doit être présent
|
|
||||||
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
|
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
|
||||||
|
|
||||||
ComponentIndex index = GetComponentIndex<ComponentType>();
|
ComponentIndex index = GetComponentIndex<ComponentType>();
|
||||||
return static_cast<ComponentType&>(GetComponent(index));
|
return static_cast<ComponentType&>(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
|
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");
|
NazaraAssert(HasComponent(index), "This component is not part of the entity");
|
||||||
|
|
||||||
BaseComponent* component = m_components[index].get();
|
BaseComponent* component = m_components[index].get();
|
||||||
|
|
@ -62,41 +97,79 @@ namespace Ndk
|
||||||
return *component;
|
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<typename ComponentType>
|
template<typename ComponentType>
|
||||||
const ComponentType& Entity::GetComponent() const
|
const ComponentType& Entity::GetComponent() const
|
||||||
{
|
{
|
||||||
///DOC: Le component doit être présent
|
|
||||||
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
|
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
|
||||||
|
|
||||||
ComponentIndex index = GetComponentIndex<ComponentType>();
|
ComponentIndex index = GetComponentIndex<ComponentType>();
|
||||||
return static_cast<ComponentType&>(GetComponent(index));
|
return static_cast<ComponentType&>(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
|
inline const Nz::Bitset<>& Entity::GetComponentBits() const
|
||||||
{
|
{
|
||||||
return m_componentBits;
|
return m_componentBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the identifier of the entity
|
||||||
|
* \return Identifier of the entity
|
||||||
|
*/
|
||||||
|
|
||||||
inline EntityId Entity::GetId() const
|
inline EntityId Entity::GetId() const
|
||||||
{
|
{
|
||||||
return m_id;
|
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
|
inline const Nz::Bitset<>& Entity::GetSystemBits() const
|
||||||
{
|
{
|
||||||
return m_systemBits;
|
return m_systemBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the world in which the entity is
|
||||||
|
* \return Pointer to the world
|
||||||
|
*/
|
||||||
|
|
||||||
inline World* Entity::GetWorld() const
|
inline World* Entity::GetWorld() const
|
||||||
{
|
{
|
||||||
return m_world;
|
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
|
inline bool Entity::HasComponent(ComponentIndex index) const
|
||||||
{
|
{
|
||||||
return m_componentBits.UnboundedTest(index);
|
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<typename ComponentType>
|
template<typename ComponentType>
|
||||||
bool Entity::HasComponent() const
|
bool Entity::HasComponent() const
|
||||||
{
|
{
|
||||||
|
|
@ -106,16 +179,54 @@ namespace Ndk
|
||||||
return HasComponent(index);
|
return HasComponent(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether or not the entity is enabled
|
||||||
|
* \return true If it is the case
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool Entity::IsEnabled() const
|
inline bool Entity::IsEnabled() const
|
||||||
{
|
{
|
||||||
return m_enabled;
|
return m_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether or not the entity is valid
|
||||||
|
* \return true If it is the case
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool Entity::IsValid() const
|
inline bool Entity::IsValid() const
|
||||||
{
|
{
|
||||||
return m_valid;
|
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<typename ComponentType>
|
template<typename ComponentType>
|
||||||
void Entity::RemoveComponent()
|
void Entity::RemoveComponent()
|
||||||
{
|
{
|
||||||
|
|
@ -125,19 +236,10 @@ namespace Ndk
|
||||||
RemoveComponent(index);
|
RemoveComponent(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Entity::RemoveAllComponents()
|
/*!
|
||||||
{
|
* \brief Gives a string representation
|
||||||
m_removedComponentBits = m_componentBits;
|
* \return A string representation of the object: "Entity(GetId())"
|
||||||
|
*/
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Entity::RemoveComponent(ComponentIndex index)
|
|
||||||
{
|
|
||||||
m_removedComponentBits.UnboundedSet(index);
|
|
||||||
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Nz::String Entity::ToString() const
|
inline Nz::String Entity::ToString() const
|
||||||
{
|
{
|
||||||
|
|
@ -145,16 +247,35 @@ namespace Ndk
|
||||||
return ss << "Entity(" << GetId() << ')';
|
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()
|
inline Nz::Bitset<>& Entity::GetRemovedComponentBits()
|
||||||
{
|
{
|
||||||
return m_removedComponentBits;
|
return m_removedComponentBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Registers a system for the entity
|
||||||
|
*
|
||||||
|
* \param index Index of the system
|
||||||
|
*/
|
||||||
|
|
||||||
inline void Entity::RegisterSystem(SystemIndex index)
|
inline void Entity::RegisterSystem(SystemIndex index)
|
||||||
{
|
{
|
||||||
m_systemBits.UnboundedSet(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
|
inline void Entity::SetWorld(World* world) noexcept
|
||||||
{
|
{
|
||||||
NazaraAssert(world, "An entity must be attached to a world at any time");
|
NazaraAssert(world, "An entity must be attached to a world at any time");
|
||||||
|
|
@ -162,6 +283,12 @@ namespace Ndk
|
||||||
m_world = world;
|
m_world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Unregisters a system for the entity
|
||||||
|
*
|
||||||
|
* \param index Index of the system
|
||||||
|
*/
|
||||||
|
|
||||||
inline void Entity::UnregisterSystem(SystemIndex index)
|
inline void Entity::UnregisterSystem(SystemIndex index)
|
||||||
{
|
{
|
||||||
m_systemBits.UnboundedReset(index);
|
m_systemBits.UnboundedReset(index);
|
||||||
|
|
@ -173,10 +300,16 @@ namespace std
|
||||||
template<>
|
template<>
|
||||||
struct hash<Ndk::EntityHandle>
|
struct hash<Ndk::EntityHandle>
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Specialisation of std to hash
|
||||||
|
* \return Result of the hash
|
||||||
|
*
|
||||||
|
* \param handle Entity to hash
|
||||||
|
*/
|
||||||
size_t operator()(const Ndk::EntityHandle& handle) const
|
size_t operator()(const Ndk::EntityHandle& handle) const
|
||||||
{
|
{
|
||||||
// Hasher le pointeur fonctionnerait jusqu'à ce que l'entité soit mise à jour et déplacée
|
// Hash the pointer will work until the entity is updated and moved
|
||||||
// pour cette raison, nous devons hasher l'ID de l'entité (qui reste constante)
|
// so, we have to hash the ID of the entity (which is constant)
|
||||||
Ndk::EntityId id = (handle.IsValid()) ? handle->GetId() : std::numeric_limits<Ndk::EntityId>::max();
|
Ndk::EntityId id = (handle.IsValid()) ? handle->GetId() : std::numeric_limits<Ndk::EntityId>::max();
|
||||||
|
|
||||||
return hash<Ndk::EntityId>()(id);
|
return hash<Ndk::EntityId>()(id);
|
||||||
|
|
|
||||||
|
|
@ -7,22 +7,54 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
inline void EntityList::Clear()
|
||||||
{
|
{
|
||||||
m_entities.clear();
|
m_entities.clear();
|
||||||
m_entityBits.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)
|
inline bool EntityList::Has(const Entity* entity)
|
||||||
{
|
{
|
||||||
return entity && entity->IsValid() && Has(entity->GetId());
|
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)
|
inline bool EntityList::Has(EntityId entity)
|
||||||
{
|
{
|
||||||
return m_entityBits.UnboundedTest(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)
|
inline void EntityList::Insert(Entity* entity)
|
||||||
{
|
{
|
||||||
if (!Has(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)
|
inline void EntityList::Remove(Entity* entity)
|
||||||
{
|
{
|
||||||
if (Has(entity))
|
if (Has(entity))
|
||||||
|
|
@ -40,7 +80,7 @@ namespace Ndk
|
||||||
NazaraAssert(it != m_entities.end(), "Entity should be part of the vector");
|
NazaraAssert(it != m_entities.end(), "Entity should be part of the vector");
|
||||||
|
|
||||||
std::swap(*it, m_entities.back());
|
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);
|
m_entityBits.UnboundedSet(entity->GetId(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,41 @@
|
||||||
|
|
||||||
namespace Ndk
|
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) :
|
inline EntityOwner::EntityOwner(Entity* entity) :
|
||||||
EntityOwner()
|
EntityOwner()
|
||||||
{
|
{
|
||||||
Reset(entity);
|
Reset(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destructs the object and calls Reset
|
||||||
|
*
|
||||||
|
* \see Reset
|
||||||
|
*/
|
||||||
|
|
||||||
inline EntityOwner::~EntityOwner()
|
inline EntityOwner::~EntityOwner()
|
||||||
{
|
{
|
||||||
Reset(nullptr);
|
Reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Resets the ownership of the entity, previous is killed
|
||||||
|
*
|
||||||
|
* \param entity Entity to own
|
||||||
|
*/
|
||||||
|
|
||||||
inline void EntityOwner::Reset(Entity* entity)
|
inline void EntityOwner::Reset(Entity* entity)
|
||||||
{
|
{
|
||||||
if (m_object)
|
if (m_object)
|
||||||
|
|
@ -27,12 +51,24 @@ namespace Ndk
|
||||||
EntityHandle::Reset(entity);
|
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)
|
inline void EntityOwner::Reset(EntityOwner&& handle)
|
||||||
{
|
{
|
||||||
Reset(handle.GetObject());
|
Reset(handle.GetObject());
|
||||||
handle.m_object = nullptr;
|
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)
|
inline EntityOwner& EntityOwner::operator=(Entity* entity)
|
||||||
{
|
{
|
||||||
Reset(entity);
|
Reset(entity);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Gets the internal binding for Lua
|
||||||
|
* \return A pointer to the binding
|
||||||
|
*/
|
||||||
|
|
||||||
inline LuaBinding* LuaAPI::GetBinding()
|
inline LuaBinding* LuaAPI::GetBinding()
|
||||||
{
|
{
|
||||||
return s_binding;
|
return s_binding;
|
||||||
|
|
@ -34,6 +39,15 @@ namespace Ndk
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param color Resulting color
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Color* color, TypeTag<Color>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Color* color, TypeTag<Color>)
|
||||||
{
|
{
|
||||||
instance.CheckType(index, Nz::LuaType_Table);
|
instance.CheckType(index, Nz::LuaType_Table);
|
||||||
|
|
@ -46,6 +60,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param angles Resulting euler angles
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesd* angles, TypeTag<EulerAnglesd>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesd* angles, TypeTag<EulerAnglesd>)
|
||||||
{
|
{
|
||||||
switch (instance.GetType(index))
|
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<EulerAnglesf>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesf* angles, TypeTag<EulerAnglesf>)
|
||||||
{
|
{
|
||||||
EulerAnglesd anglesDouble;
|
EulerAnglesd anglesDouble;
|
||||||
|
|
@ -75,6 +107,15 @@ namespace Nz
|
||||||
return ret;
|
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>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontRef* fontRef, TypeTag<FontRef>)
|
||||||
{
|
{
|
||||||
*fontRef = *static_cast<FontRef*>(instance.CheckUserdata(index, "Font"));
|
*fontRef = *static_cast<FontRef*>(instance.CheckUserdata(index, "Font"));
|
||||||
|
|
@ -82,6 +123,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param params Resulting parameters for a font
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag<FontParams>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag<FontParams>)
|
||||||
{
|
{
|
||||||
NazaraUnused(params);
|
NazaraUnused(params);
|
||||||
|
|
@ -93,6 +143,15 @@ namespace Nz
|
||||||
return 1;
|
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<MeshParams>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MeshParams* params, TypeTag<MeshParams>)
|
||||||
{
|
{
|
||||||
instance.CheckType(index, Nz::LuaType_Table);
|
instance.CheckType(index, Nz::LuaType_Table);
|
||||||
|
|
@ -106,6 +165,15 @@ namespace Nz
|
||||||
return 1;
|
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<Rectd>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectd* rect, TypeTag<Rectd>)
|
||||||
{
|
{
|
||||||
instance.CheckType(index, LuaType_Table);
|
instance.CheckType(index, LuaType_Table);
|
||||||
|
|
@ -118,6 +186,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param rect Resulting rectangle
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectf* rect, TypeTag<Rectf>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectf* rect, TypeTag<Rectf>)
|
||||||
{
|
{
|
||||||
Rectd rectDouble;
|
Rectd rectDouble;
|
||||||
|
|
@ -127,6 +204,15 @@ namespace Nz
|
||||||
return ret;
|
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<Rectui>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectui* rect, TypeTag<Rectui>)
|
||||||
{
|
{
|
||||||
Rectd rectDouble;
|
Rectd rectDouble;
|
||||||
|
|
@ -136,6 +222,15 @@ namespace Nz
|
||||||
return ret;
|
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<Quaterniond>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag<Quaterniond>)
|
||||||
{
|
{
|
||||||
switch (instance.GetType(index))
|
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<Quaternionf>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaternionf* quat, TypeTag<Quaternionf>)
|
||||||
{
|
{
|
||||||
Quaterniond quatDouble;
|
Quaterniond quatDouble;
|
||||||
|
|
@ -165,6 +269,15 @@ namespace Nz
|
||||||
return ret;
|
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<IpAddress>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, IpAddress* address, TypeTag<IpAddress>)
|
||||||
{
|
{
|
||||||
switch (instance.GetType(index))
|
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<Vector2d>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2d* vec, TypeTag<Vector2d>)
|
||||||
{
|
{
|
||||||
switch (instance.GetType(index))
|
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<Vector2f>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2f* vec, TypeTag<Vector2f>)
|
||||||
{
|
{
|
||||||
Vector2d vecDouble;
|
Vector2d vecDouble;
|
||||||
|
|
@ -209,6 +340,15 @@ namespace Nz
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param vec Resulting vector2D
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2ui* vec, TypeTag<Vector2ui>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2ui* vec, TypeTag<Vector2ui>)
|
||||||
{
|
{
|
||||||
Vector2d vecDouble;
|
Vector2d vecDouble;
|
||||||
|
|
@ -218,6 +358,15 @@ namespace Nz
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param vec Resulting vector3D
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3d* vec, TypeTag<Vector3d>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3d* vec, TypeTag<Vector3d>)
|
||||||
{
|
{
|
||||||
switch (instance.GetType(index))
|
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<Vector3f>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3f* vec, TypeTag<Vector3f>)
|
||||||
{
|
{
|
||||||
Vector3d vecDouble;
|
Vector3d vecDouble;
|
||||||
|
|
@ -248,6 +406,15 @@ namespace Nz
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param vec Resulting vector3D
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3ui* vec, TypeTag<Vector3ui>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3ui* vec, TypeTag<Vector3ui>)
|
||||||
{
|
{
|
||||||
Vector3d vecDouble;
|
Vector3d vecDouble;
|
||||||
|
|
@ -257,6 +424,15 @@ namespace Nz
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param handle Resulting entity
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::EntityHandle* handle, TypeTag<Ndk::EntityHandle>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::EntityHandle* handle, TypeTag<Ndk::EntityHandle>)
|
||||||
{
|
{
|
||||||
*handle = *static_cast<Ndk::EntityHandle*>(instance.CheckUserdata(index, "Entity"));
|
*handle = *static_cast<Ndk::EntityHandle*>(instance.CheckUserdata(index, "Entity"));
|
||||||
|
|
@ -264,6 +440,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param handle Resulting world
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::WorldHandle* handle, TypeTag<Ndk::WorldHandle>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::WorldHandle* handle, TypeTag<Ndk::WorldHandle>)
|
||||||
{
|
{
|
||||||
*handle = *static_cast<Ndk::WorldHandle*>(instance.CheckUserdata(index, "World"));
|
*handle = *static_cast<Ndk::WorldHandle*>(instance.CheckUserdata(index, "World"));
|
||||||
|
|
@ -272,6 +457,16 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param renderable Resulting reference to a instanced renderable
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, InstancedRenderableRef* renderable, TypeTag<InstancedRenderableRef>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, InstancedRenderableRef* renderable, TypeTag<InstancedRenderableRef>)
|
||||||
{
|
{
|
||||||
if (instance.IsOfType(index, "InstancedRenderable"))
|
if (instance.IsOfType(index, "InstancedRenderable"))
|
||||||
|
|
@ -281,6 +476,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param params Resulting parameters for a material
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MaterialParams* params, TypeTag<MaterialParams>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MaterialParams* params, TypeTag<MaterialParams>)
|
||||||
{
|
{
|
||||||
instance.CheckType(index, Nz::LuaType_Table);
|
instance.CheckType(index, Nz::LuaType_Table);
|
||||||
|
|
@ -295,6 +499,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param params Resulting parameters for a model
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ModelParameters* params, TypeTag<ModelParameters>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ModelParameters* params, TypeTag<ModelParameters>)
|
||||||
{
|
{
|
||||||
instance.CheckType(index, Nz::LuaType_Table);
|
instance.CheckType(index, Nz::LuaType_Table);
|
||||||
|
|
@ -307,6 +520,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param params Resulting parameters for a music
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MusicParams* params, TypeTag<MusicParams>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MusicParams* params, TypeTag<MusicParams>)
|
||||||
{
|
{
|
||||||
instance.CheckType(index, Nz::LuaType_Table);
|
instance.CheckType(index, Nz::LuaType_Table);
|
||||||
|
|
@ -316,6 +538,15 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Queries arguments for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param index Index type
|
||||||
|
* \param params Resulting parameters for a sound buffer
|
||||||
|
*/
|
||||||
|
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SoundBufferParams* params, TypeTag<SoundBufferParams>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SoundBufferParams* params, TypeTag<SoundBufferParams>)
|
||||||
{
|
{
|
||||||
instance.CheckType(index, Nz::LuaType_Table);
|
instance.CheckType(index, Nz::LuaType_Table);
|
||||||
|
|
@ -324,9 +555,16 @@ namespace Nz
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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<EulerAnglesd>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesd&& val, TypeTag<EulerAnglesd>)
|
||||||
{
|
{
|
||||||
|
|
@ -334,18 +572,42 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting euler angles
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesf&& val, TypeTag<EulerAnglesf>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesf&& val, TypeTag<EulerAnglesf>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<EulerAnglesd>("EulerAngles", val);
|
instance.PushInstance<EulerAnglesd>("EulerAngles", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting reference to a font
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, FontRef&& val, TypeTag<FontRef>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, FontRef&& val, TypeTag<FontRef>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<FontRef>("Font", val);
|
instance.PushInstance<FontRef>("Font", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting size information for a font
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo&& val, TypeTag<Font::SizeInfo>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo&& val, TypeTag<Font::SizeInfo>)
|
||||||
{
|
{
|
||||||
instance.PushTable();
|
instance.PushTable();
|
||||||
|
|
@ -357,114 +619,266 @@ namespace Nz
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting quaternion
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond&& val, TypeTag<Quaterniond>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond&& val, TypeTag<Quaterniond>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Quaterniond>("Quaternion", val);
|
instance.PushInstance<Quaterniond>("Quaternion", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting quaternion
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Quaternionf&& val, TypeTag<Quaternionf>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Quaternionf&& val, TypeTag<Quaternionf>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Quaterniond>("Quaternion", val);
|
instance.PushInstance<Quaterniond>("Quaternion", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting IP address
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress&& val, TypeTag<IpAddress>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress&& val, TypeTag<IpAddress>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<IpAddress>("IpAddress", val);
|
instance.PushInstance<IpAddress>("IpAddress", val);
|
||||||
return 1;
|
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<Rectf>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Rectd&& val, TypeTag<Rectf>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Rectd>("Rect", val);
|
instance.PushInstance<Rectd>("Rect", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting rectangle
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Rectf&& val, TypeTag<Rectf>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Rectf&& val, TypeTag<Rectf>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Rectd>("Rect", val);
|
instance.PushInstance<Rectd>("Rect", val);
|
||||||
return 1;
|
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<Rectui>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Rectui&& val, TypeTag<Rectui>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Rectd>("Rect", val);
|
instance.PushInstance<Rectd>("Rect", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting vector2D
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d&& val, TypeTag<Vector2d>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d&& val, TypeTag<Vector2d>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Vector2d>("Vector2", val);
|
instance.PushInstance<Vector2d>("Vector2", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting vector2D
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2f&& val, TypeTag<Vector2f>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2f&& val, TypeTag<Vector2f>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Vector2d>("Vector2", val);
|
instance.PushInstance<Vector2d>("Vector2", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting vector2D
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2ui&& val, TypeTag<Vector2ui>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Vector2ui&& val, TypeTag<Vector2ui>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Vector2d>("Vector2", val);
|
instance.PushInstance<Vector2d>("Vector2", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting vector3D
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d&& val, TypeTag<Vector3d>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d&& val, TypeTag<Vector3d>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Vector3d>("Vector3", val);
|
instance.PushInstance<Vector3d>("Vector3", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting vector3D
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f&& val, TypeTag<Vector3f>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f&& val, TypeTag<Vector3f>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Vector3d>("Vector3", val);
|
instance.PushInstance<Vector3d>("Vector3", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting vector3D
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui&& val, TypeTag<Vector3ui>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui&& val, TypeTag<Vector3ui>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Vector3d>("Vector3", val);
|
instance.PushInstance<Vector3d>("Vector3", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param ptr Resulting entity
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Entity* ptr, TypeTag<Ndk::Entity*>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Entity* ptr, TypeTag<Ndk::Entity*>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::EntityHandle>("Entity", ptr);
|
instance.PushInstance<Ndk::EntityHandle>("Entity", ptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param ptr Resulting application
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Application* ptr, TypeTag<Ndk::Application*>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Application* ptr, TypeTag<Ndk::Application*>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::Application*>("Application", ptr);
|
instance.PushInstance<Ndk::Application*>("Application", ptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param handle Resulting entity
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::EntityHandle&& handle, TypeTag<Ndk::EntityHandle>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::EntityHandle&& handle, TypeTag<Ndk::EntityHandle>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::EntityHandle>("Entity", handle);
|
instance.PushInstance<Ndk::EntityHandle>("Entity", handle);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param handle Resulting node component
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::NodeComponentHandle&& handle, TypeTag<Ndk::NodeComponentHandle>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::NodeComponentHandle&& handle, TypeTag<Ndk::NodeComponentHandle>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::NodeComponentHandle>("NodeComponent", handle);
|
instance.PushInstance<Ndk::NodeComponentHandle>("NodeComponent", handle);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param handle Resulting velocity component
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::VelocityComponentHandle&& handle, TypeTag<Ndk::VelocityComponentHandle>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::VelocityComponentHandle&& handle, TypeTag<Ndk::VelocityComponentHandle>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::VelocityComponentHandle>("VelocityComponent", handle);
|
instance.PushInstance<Ndk::VelocityComponentHandle>("VelocityComponent", handle);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param ptr Resulting world
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::World* ptr, TypeTag<Ndk::World*>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::World* ptr, TypeTag<Ndk::World*>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::WorldHandle>("World", ptr);
|
instance.PushInstance<Ndk::WorldHandle>("World", ptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param ptr Resulting world
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::WorldHandle&& handle, TypeTag<Ndk::WorldHandle>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::WorldHandle&& handle, TypeTag<Ndk::WorldHandle>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::WorldHandle>("World", handle);
|
instance.PushInstance<Ndk::WorldHandle>("World", handle);
|
||||||
|
|
@ -472,22 +886,49 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#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<Ndk::ConsoleHandle>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::ConsoleHandle&& handle, TypeTag<Ndk::ConsoleHandle>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::ConsoleHandle>("Console", handle);
|
instance.PushInstance<Ndk::ConsoleHandle>("Console", handle);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param handle Resulting graphics component
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle&& handle, TypeTag<Ndk::GraphicsComponentHandle>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle&& handle, TypeTag<Ndk::GraphicsComponentHandle>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<Ndk::GraphicsComponentHandle>("GraphicsComponent", handle);
|
instance.PushInstance<Ndk::GraphicsComponentHandle>("GraphicsComponent", handle);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Replies by value for Lua
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance to interact with
|
||||||
|
* \param val Resulting sound buffer
|
||||||
|
*/
|
||||||
|
|
||||||
inline int LuaImplReplyVal(const LuaInstance& instance, const SoundBuffer* val, TypeTag<const SoundBuffer*>)
|
inline int LuaImplReplyVal(const LuaInstance& instance, const SoundBuffer* val, TypeTag<const SoundBuffer*>)
|
||||||
{
|
{
|
||||||
instance.PushInstance<SoundBufferConstRef>("SoundBuffer", val);
|
instance.PushInstance<SoundBufferConstRef>("SoundBuffer", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,14 @@
|
||||||
|
|
||||||
namespace Ndk
|
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<typename T>
|
template<typename T>
|
||||||
void LuaBinding::BindComponent(const Nz::String& name)
|
void LuaBinding::BindComponent(const Nz::String& name)
|
||||||
{
|
{
|
||||||
|
|
@ -24,6 +32,16 @@ namespace Ndk
|
||||||
m_componentBindingByName[name] = T::componentIndex;
|
m_componentBindingByName[name] = T::componentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Adds a component to an entity
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance that will interact with the component
|
||||||
|
* \param handle Entity which component will be added to
|
||||||
|
*
|
||||||
|
* \remark T must be a subtype of BaseComponent
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle)
|
||||||
{
|
{
|
||||||
|
|
@ -34,6 +52,16 @@ namespace Ndk
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Pushes a component
|
||||||
|
* \return 1 in case of success
|
||||||
|
*
|
||||||
|
* \param instance Lua instance that will interact with the component
|
||||||
|
* \param component Component that will be pushed
|
||||||
|
*
|
||||||
|
* \remark T must be a subtype of BaseComponent
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
|
||||||
// Version du SDK
|
// Version of SDK
|
||||||
#define NDK_VERSION_MAJOR 0
|
#define NDK_VERSION_MAJOR 0
|
||||||
#define NDK_VERSION_MINOR 1
|
#define NDK_VERSION_MINOR 1
|
||||||
|
|
||||||
// Importation/Exportation de l'API
|
// Importation/Exportation of the API
|
||||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||||
#if !defined(NDK_STATIC)
|
#if !defined(NDK_STATIC)
|
||||||
#ifdef NDK_BUILD
|
#ifdef NDK_BUILD
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
#define NDK_API
|
#define NDK_API
|
||||||
#endif
|
#endif
|
||||||
#else
|
#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
|
#error This operating system is not fully supported by the Nazara Development Kit
|
||||||
|
|
||||||
#define NDK_API
|
#define NDK_API
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Checks whether the module is initialized
|
||||||
|
* \return true if module is initialized
|
||||||
|
*/
|
||||||
|
|
||||||
inline bool Sdk::IsInitialized()
|
inline bool Sdk::IsInitialized()
|
||||||
{
|
{
|
||||||
return s_referenceCounter != 0;
|
return s_referenceCounter != 0;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,21 @@
|
||||||
|
|
||||||
namespace Ndk
|
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<State> originalState) :
|
inline StateMachine::StateMachine(std::shared_ptr<State> originalState) :
|
||||||
m_currentState(std::move(originalState))
|
m_currentState(std::move(originalState))
|
||||||
{
|
{
|
||||||
|
|
@ -15,22 +30,45 @@ namespace Ndk
|
||||||
m_currentState->Enter(*this);
|
m_currentState->Enter(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destructs the object
|
||||||
|
*
|
||||||
|
* \remark Calls "Leave" on the state
|
||||||
|
*/
|
||||||
|
|
||||||
inline StateMachine::~StateMachine()
|
inline StateMachine::~StateMachine()
|
||||||
{
|
{
|
||||||
m_currentState->Leave(*this);
|
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> state)
|
inline void StateMachine::ChangeState(std::shared_ptr<State> state)
|
||||||
{
|
{
|
||||||
m_nextState = std::move(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<State>& StateMachine::GetCurrentState() const
|
inline const std::shared_ptr<State>& StateMachine::GetCurrentState() const
|
||||||
{
|
{
|
||||||
return m_currentState;
|
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)
|
inline bool StateMachine::Update(float elapsedTime)
|
||||||
{
|
{
|
||||||
if (m_nextState)
|
if (m_nextState)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
template<typename ComponentType>
|
template<typename SystemType>
|
||||||
class System : public BaseSystem
|
class System : public BaseSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Ndk
|
||||||
System(System&&) = default;
|
System(System&&) = default;
|
||||||
virtual ~System();
|
virtual ~System();
|
||||||
|
|
||||||
BaseSystem* Clone() const override;
|
std::unique_ptr<BaseSystem> Clone() const override;
|
||||||
|
|
||||||
System& operator=(const System&) = delete;
|
System& operator=(const System&) = delete;
|
||||||
System& operator=(System&&) = default;
|
System& operator=(System&&) = default;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,18 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \ingroup NDK
|
||||||
|
* \class Ndk::System<SystemType>
|
||||||
|
* \brief NDK class that represents a system which interacts on a world
|
||||||
|
*
|
||||||
|
* \remark This class is meant to be derived as CRTP: "System<Subtype>"
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a System object by default
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename SystemType>
|
template<typename SystemType>
|
||||||
System<SystemType>::System() :
|
System<SystemType>::System() :
|
||||||
BaseSystem(GetSystemIndex<SystemType>())
|
BaseSystem(GetSystemIndex<SystemType>())
|
||||||
|
|
@ -16,15 +28,26 @@ namespace Ndk
|
||||||
template<typename SystemType>
|
template<typename SystemType>
|
||||||
System<SystemType>::~System() = default;
|
System<SystemType>::~System() = default;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Clones the system
|
||||||
|
* \return The clone newly created
|
||||||
|
*
|
||||||
|
* \remark The system to clone should be trivially copy constructible
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename SystemType>
|
template<typename SystemType>
|
||||||
BaseSystem* System<SystemType>::Clone() const
|
std::unique_ptr<BaseSystem> System<SystemType>::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<SystemType>::value, "SystemType should be copy-constructible");
|
//static_assert(std::is_trivially_copy_constructible<SystemType>::value, "SystemType should be copy-constructible");
|
||||||
|
|
||||||
return new SystemType(static_cast<const SystemType&>(*this));
|
return std::make_unique<SystemType>(static_cast<const SystemType&>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Registers the system by assigning it an index
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename SystemType>
|
template<typename SystemType>
|
||||||
SystemIndex System<SystemType>::RegisterSystem()
|
SystemIndex System<SystemType>::RegisterSystem()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,21 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Gets the physical world
|
||||||
|
* \return A reference to the physical world
|
||||||
|
*/
|
||||||
|
|
||||||
inline Nz::PhysWorld& PhysicsSystem::GetWorld()
|
inline Nz::PhysWorld& PhysicsSystem::GetWorld()
|
||||||
{
|
{
|
||||||
return m_world;
|
return m_world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the physical world
|
||||||
|
* \return A constant reference to the physical world
|
||||||
|
*/
|
||||||
|
|
||||||
inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const
|
inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const
|
||||||
{
|
{
|
||||||
return m_world;
|
return m_world;
|
||||||
|
|
|
||||||
|
|
@ -4,58 +4,119 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a RenderSystem object by copy semantic
|
||||||
|
*
|
||||||
|
* \param renderSystem RenderSystem to copy
|
||||||
|
*/
|
||||||
|
|
||||||
inline RenderSystem::RenderSystem(const RenderSystem& renderSystem) :
|
inline RenderSystem::RenderSystem(const RenderSystem& renderSystem) :
|
||||||
System(renderSystem)
|
System(renderSystem)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Changes the render technique used for the system
|
||||||
|
* \return A reference to the render technique type
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T& RenderSystem::ChangeRenderTechnique()
|
inline T& RenderSystem::ChangeRenderTechnique()
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_base_of<Nz::AbstractRenderTechnique, T>::value, "RenderTechnique is not a subtype of AbstractRenderTechnique");
|
||||||
return static_cast<T&>(ChangeRenderTechnique(std::make_unique<T>()));
|
return static_cast<T&>(ChangeRenderTechnique(std::make_unique<T>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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<Nz::AbstractRenderTechnique>&& renderTechnique)
|
inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique)
|
||||||
{
|
{
|
||||||
m_renderTechnique = std::move(renderTechnique);
|
m_renderTechnique = std::move(renderTechnique);
|
||||||
return *m_renderTechnique.get();
|
return *m_renderTechnique.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets the background used for rendering
|
||||||
|
* \return A reference to the background
|
||||||
|
*/
|
||||||
|
|
||||||
inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const
|
inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const
|
||||||
{
|
{
|
||||||
return m_background;
|
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
|
inline const Nz::Matrix4f& RenderSystem::GetCoordinateSystemMatrix() const
|
||||||
{
|
{
|
||||||
return m_coordinateSystemMatrix;
|
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
|
inline Nz::Vector3f RenderSystem::GetGlobalForward() const
|
||||||
{
|
{
|
||||||
return Nz::Vector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33);
|
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
|
inline Nz::Vector3f RenderSystem::GetGlobalRight() const
|
||||||
{
|
{
|
||||||
return Nz::Vector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31);
|
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
|
inline Nz::Vector3f RenderSystem::GetGlobalUp() const
|
||||||
{
|
{
|
||||||
return Nz::Vector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32);
|
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
|
inline Nz::AbstractRenderTechnique& RenderSystem::GetRenderTechnique() const
|
||||||
{
|
{
|
||||||
return *m_renderTechnique.get();
|
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)
|
inline void RenderSystem::SetDefaultBackground(Nz::BackgroundRef background)
|
||||||
{
|
{
|
||||||
m_background = std::move(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)
|
inline void RenderSystem::SetGlobalForward(const Nz::Vector3f& direction)
|
||||||
{
|
{
|
||||||
m_coordinateSystemMatrix.m13 = -direction.x;
|
m_coordinateSystemMatrix.m13 = -direction.x;
|
||||||
|
|
@ -65,6 +126,12 @@ namespace Ndk
|
||||||
InvalidateCoordinateSystem();
|
InvalidateCoordinateSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the "right" global direction
|
||||||
|
*
|
||||||
|
* \param direction The new right direction
|
||||||
|
*/
|
||||||
|
|
||||||
inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction)
|
inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction)
|
||||||
{
|
{
|
||||||
m_coordinateSystemMatrix.m11 = direction.x;
|
m_coordinateSystemMatrix.m11 = direction.x;
|
||||||
|
|
@ -74,6 +141,12 @@ namespace Ndk
|
||||||
InvalidateCoordinateSystem();
|
InvalidateCoordinateSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the "up" global direction
|
||||||
|
*
|
||||||
|
* \param direction The new up direction
|
||||||
|
*/
|
||||||
|
|
||||||
inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction)
|
inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction)
|
||||||
{
|
{
|
||||||
m_coordinateSystemMatrix.m12 = direction.x;
|
m_coordinateSystemMatrix.m12 = direction.x;
|
||||||
|
|
@ -83,6 +156,10 @@ namespace Ndk
|
||||||
InvalidateCoordinateSystem();
|
InvalidateCoordinateSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the matrix of coordinates for the system
|
||||||
|
*/
|
||||||
|
|
||||||
inline void RenderSystem::InvalidateCoordinateSystem()
|
inline void RenderSystem::InvalidateCoordinateSystem()
|
||||||
{
|
{
|
||||||
m_coordinateSystemInvalidated = true;
|
m_coordinateSystemInvalidated = true;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ namespace Ndk
|
||||||
inline EntityList CreateEntities(unsigned int count);
|
inline EntityList CreateEntities(unsigned int count);
|
||||||
|
|
||||||
void Clear() noexcept;
|
void Clear() noexcept;
|
||||||
|
|
||||||
const EntityHandle& CloneEntity(EntityId id);
|
const EntityHandle& CloneEntity(EntityId id);
|
||||||
|
|
||||||
const EntityHandle& GetEntity(EntityId id);
|
const EntityHandle& GetEntity(EntityId id);
|
||||||
|
|
|
||||||
|
|
@ -7,47 +7,80 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a World object
|
||||||
|
*
|
||||||
|
* \param addDefaultSystems Should default provided systems be used
|
||||||
|
*/
|
||||||
|
|
||||||
inline World::World(bool addDefaultSystems)
|
inline World::World(bool addDefaultSystems)
|
||||||
{
|
{
|
||||||
if (addDefaultSystems)
|
if (addDefaultSystems)
|
||||||
AddDefaultSystems();
|
AddDefaultSystems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a World object by move semantic
|
||||||
|
*
|
||||||
|
* \param world World to move into this
|
||||||
|
*/
|
||||||
|
|
||||||
inline World::World(World&& world) noexcept :
|
inline World::World(World&& world) noexcept :
|
||||||
HandledObject(std::move(world))
|
HandledObject(std::move(world))
|
||||||
{
|
{
|
||||||
operator=(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<BaseSystem>&& system)
|
inline BaseSystem& World::AddSystem(std::unique_ptr<BaseSystem>&& system)
|
||||||
{
|
{
|
||||||
NazaraAssert(system, "System must be valid");
|
NazaraAssert(system, "System must be valid");
|
||||||
|
|
||||||
SystemIndex index = system->GetIndex();
|
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())
|
if (index >= m_systems.size())
|
||||||
m_systems.resize(index + 1);
|
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] = std::move(system);
|
||||||
m_systems[index]->SetWorld(this);
|
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();
|
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<typename SystemType, typename... Args>
|
template<typename SystemType, typename... Args>
|
||||||
SystemType& World::AddSystem(Args&&... args)
|
SystemType& World::AddSystem(Args&&... args)
|
||||||
{
|
{
|
||||||
static_assert(std::is_base_of<BaseSystem, SystemType>::value, "SystemType is not a component");
|
static_assert(std::is_base_of<BaseSystem, SystemType>::value, "SystemType is not a component");
|
||||||
|
|
||||||
// Allocation et affectation du component
|
// Allocation and affectation of the system
|
||||||
std::unique_ptr<SystemType> ptr(new SystemType(std::forward<Args>(args)...));
|
std::unique_ptr<SystemType> ptr(new SystemType(std::forward<Args>(args)...));
|
||||||
return static_cast<SystemType&>(AddSystem(std::move(ptr)));
|
return static_cast<SystemType&>(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)
|
inline World::EntityList World::CreateEntities(unsigned int count)
|
||||||
{
|
{
|
||||||
EntityList list;
|
EntityList list;
|
||||||
|
|
@ -59,14 +92,27 @@ namespace Ndk
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Gets every entities in the world
|
||||||
|
* \return A constant reference to the entities
|
||||||
|
*/
|
||||||
|
|
||||||
inline const World::EntityList& World::GetEntities()
|
inline const World::EntityList& World::GetEntities()
|
||||||
{
|
{
|
||||||
return m_aliveEntities;
|
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)
|
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");
|
NazaraAssert(HasSystem(index), "This system is not part of the world");
|
||||||
|
|
||||||
BaseSystem* system = m_systems[index].get();
|
BaseSystem* system = m_systems[index].get();
|
||||||
|
|
@ -75,21 +121,39 @@ namespace Ndk
|
||||||
return *system;
|
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<typename SystemType>
|
template<typename SystemType>
|
||||||
SystemType& World::GetSystem()
|
SystemType& World::GetSystem()
|
||||||
{
|
{
|
||||||
///DOC: Le système doit être présent
|
|
||||||
static_assert(std::is_base_of<BaseSystem, SystemType>::value, "SystemType is not a system");
|
static_assert(std::is_base_of<BaseSystem, SystemType>::value, "SystemType is not a system");
|
||||||
|
|
||||||
SystemIndex index = GetSystemIndex<SystemType>();
|
SystemIndex index = GetSystemIndex<SystemType>();
|
||||||
return static_cast<SystemType&>(GetSystem(index));
|
return static_cast<SystemType&>(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
|
inline bool World::HasSystem(SystemIndex index) const
|
||||||
{
|
{
|
||||||
return index < m_systems.size() && m_systems[index];
|
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<typename SystemType>
|
template<typename SystemType>
|
||||||
bool World::HasSystem() const
|
bool World::HasSystem() const
|
||||||
{
|
{
|
||||||
|
|
@ -99,34 +163,69 @@ namespace Ndk
|
||||||
return HasSystem(index);
|
return HasSystem(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Kills a set of entities
|
||||||
|
*
|
||||||
|
* \param list Set of entities to kill
|
||||||
|
*/
|
||||||
|
|
||||||
inline void World::KillEntities(const EntityList& list)
|
inline void World::KillEntities(const EntityList& list)
|
||||||
{
|
{
|
||||||
for (const EntityHandle& entity : list)
|
for (const EntityHandle& entity : list)
|
||||||
KillEntity(entity);
|
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
|
inline bool World::IsEntityValid(const Entity* entity) const
|
||||||
{
|
{
|
||||||
return entity && entity->GetWorld() == this && IsEntityIdValid(entity->GetId());
|
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
|
inline bool World::IsEntityIdValid(EntityId id) const
|
||||||
{
|
{
|
||||||
return id < m_entities.size() && m_entities[id].entity.IsValid();
|
return id < m_entities.size() && m_entities[id].entity.IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Removes each system from the world
|
||||||
|
*/
|
||||||
|
|
||||||
inline void World::RemoveAllSystems()
|
inline void World::RemoveAllSystems()
|
||||||
{
|
{
|
||||||
m_systems.clear();
|
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)
|
inline void World::RemoveSystem(SystemIndex index)
|
||||||
{
|
{
|
||||||
///DOC: N'a aucun effet si le système n'est pas présent
|
|
||||||
if (HasSystem(index))
|
if (HasSystem(index))
|
||||||
m_systems[index].reset();
|
m_systems[index].reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Removes a system from the world by type
|
||||||
|
*/
|
||||||
|
|
||||||
template<typename SystemType>
|
template<typename SystemType>
|
||||||
void World::RemoveSystem()
|
void World::RemoveSystem()
|
||||||
{
|
{
|
||||||
|
|
@ -136,6 +235,12 @@ namespace Ndk
|
||||||
RemoveSystem(index);
|
RemoveSystem(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Updates the world
|
||||||
|
*
|
||||||
|
* \param elapsedTime Delta time used for the update
|
||||||
|
*/
|
||||||
|
|
||||||
inline void World::Update(float elapsedTime)
|
inline void World::Update(float elapsedTime)
|
||||||
{
|
{
|
||||||
Update(); //< Update entities
|
Update(); //< Update entities
|
||||||
|
|
@ -148,17 +253,32 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates each entity in the world
|
||||||
|
*/
|
||||||
|
|
||||||
inline void World::Invalidate()
|
inline void World::Invalidate()
|
||||||
{
|
{
|
||||||
m_dirtyEntities.Resize(m_entities.size(), false);
|
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)
|
inline void World::Invalidate(EntityId id)
|
||||||
{
|
{
|
||||||
m_dirtyEntities.UnboundedSet(id, true);
|
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
|
inline World& World::operator=(World&& world) noexcept
|
||||||
{
|
{
|
||||||
m_aliveEntities = std::move(world.m_aliveEntities);
|
m_aliveEntities = std::move(world.m_aliveEntities);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,79 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
#include <NDK/Application.hpp>
|
#include <NDK/Application.hpp>
|
||||||
|
#include <Nazara/Core/Log.hpp>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
#include <NDK/Components/CameraComponent.hpp>
|
||||||
|
#include <NDK/Components/GraphicsComponent.hpp>
|
||||||
|
#include <NDK/Components/NodeComponent.hpp>
|
||||||
|
#include <NDK/Systems/RenderSystem.hpp>
|
||||||
|
#include <NDK/LuaAPI.hpp>
|
||||||
|
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Ndk
|
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 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 + '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
if (HasOption("console"))
|
||||||
|
EnableConsole(true);
|
||||||
|
|
||||||
|
if (HasOption("fpscounter"))
|
||||||
|
EnableFPSCounter(true);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Runs the application by updating worlds, taking care about windows, ...
|
||||||
|
*/
|
||||||
bool Application::Run()
|
bool Application::Run()
|
||||||
{
|
{
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
|
|
@ -14,7 +84,9 @@ namespace Ndk
|
||||||
auto it = m_windows.begin();
|
auto it = m_windows.begin();
|
||||||
while (it != m_windows.end())
|
while (it != m_windows.end())
|
||||||
{
|
{
|
||||||
Nz::Window& window = **it;
|
Nz::Window& window = *it->window;
|
||||||
|
|
||||||
|
window.ProcessEvents();
|
||||||
|
|
||||||
if (!window.IsOpen(true))
|
if (!window.IsOpen(true))
|
||||||
{
|
{
|
||||||
|
|
@ -42,8 +114,140 @@ namespace Ndk
|
||||||
for (World& world : m_worlds)
|
for (World& world : m_worlds)
|
||||||
world.Update(m_updateTime);
|
world.Update(m_updateTime);
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
for (WindowInfo& info : m_windows)
|
||||||
|
{
|
||||||
|
if (!info.overlayWorld)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDK_SERVER
|
||||||
|
void Application::SetupConsole(WindowInfo& info)
|
||||||
|
{
|
||||||
|
std::unique_ptr<ConsoleOverlay> overlay = std::make_unique<ConsoleOverlay>();
|
||||||
|
|
||||||
|
Nz::Vector2ui windowDimensions;
|
||||||
|
if (info.window->IsValid())
|
||||||
|
windowDimensions.Set(info.window->GetWidth(), info.window->GetHeight() / 4);
|
||||||
|
else
|
||||||
|
windowDimensions.MakeZero();
|
||||||
|
|
||||||
|
overlay->console = std::make_unique<Console>(*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)
|
||||||
|
{
|
||||||
|
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(info.renderTarget->OnRenderTargetSizeChange, [&consoleRef] (const Nz::RenderTarget* renderTarget)
|
||||||
|
{
|
||||||
|
consoleRef.SetSize({float(renderTarget->GetWidth()), renderTarget->GetHeight() / 4.f});
|
||||||
|
});
|
||||||
|
|
||||||
|
info.console = std::move(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::SetupFPSCounter(WindowInfo& info)
|
||||||
|
{
|
||||||
|
std::unique_ptr<FPSCounterOverlay> fpsCounter = std::make_unique<FPSCounterOverlay>();
|
||||||
|
fpsCounter->sprite = Nz::TextSprite::New();
|
||||||
|
|
||||||
|
fpsCounter->entity = info.overlayWorld->CreateEntity();
|
||||||
|
fpsCounter->entity->AddComponent<NodeComponent>();
|
||||||
|
fpsCounter->entity->AddComponent<GraphicsComponent>().Attach(fpsCounter->sprite);
|
||||||
|
|
||||||
|
info.fpsCounter = std::move(fpsCounter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::SetupOverlay(WindowInfo& info)
|
||||||
|
{
|
||||||
|
info.overlayWorld = std::make_unique<World>(false); //< No default system
|
||||||
|
|
||||||
|
RenderSystem& renderSystem = info.overlayWorld->AddSystem<RenderSystem>();
|
||||||
|
renderSystem.ChangeRenderTechnique<Nz::ForwardRenderTechnique>();
|
||||||
|
renderSystem.SetDefaultBackground(nullptr);
|
||||||
|
renderSystem.SetGlobalUp(Nz::Vector3f::Down());
|
||||||
|
|
||||||
|
EntityHandle viewer = info.overlayWorld->CreateEntity();
|
||||||
|
CameraComponent& camComponent = viewer->AddComponent<CameraComponent>();
|
||||||
|
viewer->AddComponent<NodeComponent>();
|
||||||
|
|
||||||
|
camComponent.SetProjectionType(Nz::ProjectionType_Orthogonal);
|
||||||
|
camComponent.SetTarget(info.renderTarget);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Application* Application::s_application = nullptr;
|
Application* Application::s_application = nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -6,22 +6,50 @@
|
||||||
|
|
||||||
namespace Ndk
|
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;
|
BaseComponent::~BaseComponent() = default;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is attached to an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void BaseComponent::OnAttached()
|
void BaseComponent::OnAttached()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is attached to this component
|
||||||
|
*
|
||||||
|
* \param component Component being attached
|
||||||
|
*/
|
||||||
|
|
||||||
void BaseComponent::OnComponentAttached(BaseComponent& component)
|
void BaseComponent::OnComponentAttached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
NazaraUnused(component);
|
NazaraUnused(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is detached from this component
|
||||||
|
*
|
||||||
|
* \param component Component being detached
|
||||||
|
*/
|
||||||
|
|
||||||
void BaseComponent::OnComponentDetached(BaseComponent& component)
|
void BaseComponent::OnComponentDetached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
NazaraUnused(component);
|
NazaraUnused(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is detached from an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void BaseComponent::OnDetached()
|
void BaseComponent::OnDetached()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,31 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
BaseSystem::~BaseSystem()
|
||||||
{
|
{
|
||||||
for (const EntityHandle& entity : m_entities)
|
for (const EntityHandle& entity : m_entities)
|
||||||
entity->UnregisterSystem(m_systemIndex);
|
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
|
bool BaseSystem::Filters(const Entity* entity) const
|
||||||
{
|
{
|
||||||
if (!entity)
|
if (!entity)
|
||||||
|
|
@ -21,13 +40,13 @@ namespace Ndk
|
||||||
|
|
||||||
m_filterResult.PerformsAND(m_requiredComponents, components);
|
m_filterResult.PerformsAND(m_requiredComponents, components);
|
||||||
if (m_filterResult != m_requiredComponents)
|
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);
|
m_filterResult.PerformsAND(m_excludedComponents, components);
|
||||||
if (m_filterResult.TestAny())
|
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.TestAny())
|
||||||
{
|
{
|
||||||
if (!m_requiredAnyComponents.Intersects(components))
|
if (!m_requiredAnyComponents.Intersects(components))
|
||||||
|
|
@ -37,16 +56,35 @@ namespace Ndk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when entity is added to the system
|
||||||
|
*
|
||||||
|
* \param Pointer to the entity
|
||||||
|
*/
|
||||||
|
|
||||||
void BaseSystem::OnEntityAdded(Entity* entity)
|
void BaseSystem::OnEntityAdded(Entity* entity)
|
||||||
{
|
{
|
||||||
NazaraUnused(entity);
|
NazaraUnused(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when entity is removed to the system
|
||||||
|
*
|
||||||
|
* \param Pointer to the entity
|
||||||
|
*/
|
||||||
|
|
||||||
void BaseSystem::OnEntityRemoved(Entity* entity)
|
void BaseSystem::OnEntityRemoved(Entity* entity)
|
||||||
{
|
{
|
||||||
NazaraUnused(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)
|
void BaseSystem::OnEntityValidation(Entity* entity, bool justAdded)
|
||||||
{
|
{
|
||||||
NazaraUnused(entity);
|
NazaraUnused(entity);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,18 @@
|
||||||
|
|
||||||
namespace Ndk
|
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
|
void CameraComponent::ApplyView() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_target, "CameraComponent has no target");
|
NazaraAssert(m_target, "CameraComponent has no target");
|
||||||
|
|
@ -23,6 +35,12 @@ namespace Ndk
|
||||||
Nz::Renderer::SetViewport(m_viewport);
|
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
|
Nz::Vector3f CameraComponent::GetEyePosition() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
||||||
|
|
@ -30,6 +48,12 @@ namespace Ndk
|
||||||
return m_entity->GetComponent<NodeComponent>().GetPosition();
|
return m_entity->GetComponent<NodeComponent>().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
|
Nz::Vector3f CameraComponent::GetForward() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
||||||
|
|
@ -37,6 +61,12 @@ namespace Ndk
|
||||||
return m_entity->GetComponent<NodeComponent>().GetForward();
|
return m_entity->GetComponent<NodeComponent>().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)
|
void CameraComponent::SetLayer(unsigned int layer)
|
||||||
{
|
{
|
||||||
m_layer = layer;
|
m_layer = layer;
|
||||||
|
|
@ -44,6 +74,10 @@ namespace Ndk
|
||||||
m_entity->Invalidate(); // Invalidate the entity to make it passes through RenderSystem validation
|
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()
|
void CameraComponent::OnAttached()
|
||||||
{
|
{
|
||||||
if (m_entity->HasComponent<NodeComponent>())
|
if (m_entity->HasComponent<NodeComponent>())
|
||||||
|
|
@ -52,6 +86,12 @@ namespace Ndk
|
||||||
InvalidateViewMatrix();
|
InvalidateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is attached to this component
|
||||||
|
*
|
||||||
|
* \param component Component being attached
|
||||||
|
*/
|
||||||
|
|
||||||
void CameraComponent::OnComponentAttached(BaseComponent& component)
|
void CameraComponent::OnComponentAttached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<NodeComponent>(component))
|
if (IsComponent<NodeComponent>(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)
|
void CameraComponent::OnComponentDetached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<NodeComponent>(component))
|
if (IsComponent<NodeComponent>(component))
|
||||||
|
|
@ -73,6 +119,10 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is detached from an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void CameraComponent::OnDetached()
|
void CameraComponent::OnDetached()
|
||||||
{
|
{
|
||||||
m_nodeInvalidationSlot.Disconnect();
|
m_nodeInvalidationSlot.Disconnect();
|
||||||
|
|
@ -80,6 +130,12 @@ namespace Ndk
|
||||||
InvalidateViewMatrix();
|
InvalidateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when the node is invalidated
|
||||||
|
*
|
||||||
|
* \param node Pointer to the node
|
||||||
|
*/
|
||||||
|
|
||||||
void CameraComponent::OnNodeInvalidated(const Nz::Node* node)
|
void CameraComponent::OnNodeInvalidated(const Nz::Node* node)
|
||||||
{
|
{
|
||||||
NazaraUnused(node);
|
NazaraUnused(node);
|
||||||
|
|
@ -88,6 +144,12 @@ namespace Ndk
|
||||||
InvalidateViewMatrix();
|
InvalidateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when the render target is released
|
||||||
|
*
|
||||||
|
* \param renderTarget Pointer to the RenderTarget
|
||||||
|
*/
|
||||||
|
|
||||||
void CameraComponent::OnRenderTargetRelease(const Nz::RenderTarget* renderTarget)
|
void CameraComponent::OnRenderTargetRelease(const Nz::RenderTarget* renderTarget)
|
||||||
{
|
{
|
||||||
if (renderTarget == m_target)
|
if (renderTarget == m_target)
|
||||||
|
|
@ -96,6 +158,12 @@ namespace Ndk
|
||||||
NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget));
|
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)
|
void CameraComponent::OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget)
|
||||||
{
|
{
|
||||||
if (renderTarget == m_target)
|
if (renderTarget == m_target)
|
||||||
|
|
@ -104,6 +172,10 @@ namespace Ndk
|
||||||
NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget));
|
NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Updates the frustum of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
void CameraComponent::UpdateFrustum() const
|
void CameraComponent::UpdateFrustum() const
|
||||||
{
|
{
|
||||||
EnsureProjectionMatrixUpdate();
|
EnsureProjectionMatrixUpdate();
|
||||||
|
|
@ -114,6 +186,10 @@ namespace Ndk
|
||||||
m_frustumUpdated = true;
|
m_frustumUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Updates the project matrix of the camera
|
||||||
|
*/
|
||||||
|
|
||||||
void CameraComponent::UpdateProjectionMatrix() const
|
void CameraComponent::UpdateProjectionMatrix() const
|
||||||
{
|
{
|
||||||
switch (m_projectionType)
|
switch (m_projectionType)
|
||||||
|
|
@ -139,6 +215,12 @@ namespace Ndk
|
||||||
m_projectionMatrixUpdated = true;
|
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
|
void CameraComponent::UpdateViewMatrix() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "CameraComponent requires NodeComponent");
|
||||||
|
|
@ -150,6 +232,12 @@ namespace Ndk
|
||||||
m_viewMatrixUpdated = true;
|
m_viewMatrixUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Updates the view port of the camera
|
||||||
|
*
|
||||||
|
* \remark Produces a NazaraAssert if entity has no target
|
||||||
|
*/
|
||||||
|
|
||||||
void CameraComponent::UpdateViewport() const
|
void CameraComponent::UpdateViewport() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_target, "CameraComponent has no target");
|
NazaraAssert(m_target, "CameraComponent has no target");
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,27 @@
|
||||||
|
|
||||||
namespace Ndk
|
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)
|
void CollisionComponent::SetGeom(Nz::PhysGeomRef geom)
|
||||||
{
|
{
|
||||||
m_geom = std::move(geom);
|
m_geom = std::move(geom);
|
||||||
|
|
||||||
if (m_entity->HasComponent<PhysicsComponent>())
|
if (m_entity->HasComponent<PhysicsComponent>())
|
||||||
{
|
{
|
||||||
// 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<PhysicsComponent>();
|
PhysicsComponent& physComponent = m_entity->GetComponent<PhysicsComponent>();
|
||||||
physComponent.GetPhysObject().SetGeom(m_geom);
|
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()
|
void CollisionComponent::InitializeStaticBody()
|
||||||
{
|
{
|
||||||
NazaraAssert(m_entity, "Invalid entity");
|
NazaraAssert(m_entity, "Invalid entity");
|
||||||
|
|
@ -41,24 +62,44 @@ namespace Ndk
|
||||||
m_staticBody->EnableAutoSleep(false);
|
m_staticBody->EnableAutoSleep(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is attached to an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void CollisionComponent::OnAttached()
|
void CollisionComponent::OnAttached()
|
||||||
{
|
{
|
||||||
if (!m_entity->HasComponent<PhysicsComponent>())
|
if (!m_entity->HasComponent<PhysicsComponent>())
|
||||||
InitializeStaticBody();
|
InitializeStaticBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is attached to this component
|
||||||
|
*
|
||||||
|
* \param component Component being attached
|
||||||
|
*/
|
||||||
|
|
||||||
void CollisionComponent::OnComponentAttached(BaseComponent& component)
|
void CollisionComponent::OnComponentAttached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<PhysicsComponent>(component))
|
if (IsComponent<PhysicsComponent>(component))
|
||||||
m_staticBody.reset();
|
m_staticBody.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is detached from this component
|
||||||
|
*
|
||||||
|
* \param component Component being detached
|
||||||
|
*/
|
||||||
|
|
||||||
void CollisionComponent::OnComponentDetached(BaseComponent& component)
|
void CollisionComponent::OnComponentDetached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<PhysicsComponent>(component))
|
if (IsComponent<PhysicsComponent>(component))
|
||||||
InitializeStaticBody();
|
InitializeStaticBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is detached from an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void CollisionComponent::OnDetached()
|
void CollisionComponent::OnDetached()
|
||||||
{
|
{
|
||||||
m_staticBody.reset();
|
m_staticBody.reset();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,23 @@
|
||||||
|
|
||||||
namespace Ndk
|
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");
|
NazaraAssert(index < m_renderables.size(), "Invalid renderable index");
|
||||||
NazaraUnused(renderable);
|
NazaraUnused(renderable);
|
||||||
|
|
@ -19,6 +35,10 @@ namespace Ndk
|
||||||
r.renderable->InvalidateData(&r.data, flags);
|
r.renderable->InvalidateData(&r.data, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is attached to an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void GraphicsComponent::OnAttached()
|
void GraphicsComponent::OnAttached()
|
||||||
{
|
{
|
||||||
if (m_entity->HasComponent<NodeComponent>())
|
if (m_entity->HasComponent<NodeComponent>())
|
||||||
|
|
@ -27,6 +47,12 @@ namespace Ndk
|
||||||
InvalidateTransformMatrix();
|
InvalidateTransformMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is attached to this component
|
||||||
|
*
|
||||||
|
* \param component Component being attached
|
||||||
|
*/
|
||||||
|
|
||||||
void GraphicsComponent::OnComponentAttached(BaseComponent& component)
|
void GraphicsComponent::OnComponentAttached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<NodeComponent>(component))
|
if (IsComponent<NodeComponent>(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)
|
void GraphicsComponent::OnComponentDetached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<NodeComponent>(component))
|
if (IsComponent<NodeComponent>(component))
|
||||||
|
|
@ -48,6 +80,10 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is detached from an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void GraphicsComponent::OnDetached()
|
void GraphicsComponent::OnDetached()
|
||||||
{
|
{
|
||||||
m_nodeInvalidationSlot.Disconnect();
|
m_nodeInvalidationSlot.Disconnect();
|
||||||
|
|
@ -55,6 +91,12 @@ namespace Ndk
|
||||||
InvalidateTransformMatrix();
|
InvalidateTransformMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when the node is invalidated
|
||||||
|
*
|
||||||
|
* \param node Pointer to the node
|
||||||
|
*/
|
||||||
|
|
||||||
void GraphicsComponent::OnNodeInvalidated(const Nz::Node* node)
|
void GraphicsComponent::OnNodeInvalidated(const Nz::Node* node)
|
||||||
{
|
{
|
||||||
NazaraUnused(node);
|
NazaraUnused(node);
|
||||||
|
|
@ -63,6 +105,10 @@ namespace Ndk
|
||||||
InvalidateTransformMatrix();
|
InvalidateTransformMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Updates the bounding volume
|
||||||
|
*/
|
||||||
|
|
||||||
void GraphicsComponent::UpdateBoundingVolume() const
|
void GraphicsComponent::UpdateBoundingVolume() const
|
||||||
{
|
{
|
||||||
EnsureTransformMatrixUpdate();
|
EnsureTransformMatrixUpdate();
|
||||||
|
|
@ -75,13 +121,19 @@ namespace Ndk
|
||||||
m_boundingVolumeUpdated = true;
|
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
|
void GraphicsComponent::UpdateTransformMatrix() const
|
||||||
{
|
{
|
||||||
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "GraphicsComponent requires NodeComponent");
|
NazaraAssert(m_entity && m_entity->HasComponent<NodeComponent>(), "GraphicsComponent requires NodeComponent");
|
||||||
|
|
||||||
Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem<Ndk::RenderSystem>();
|
Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem<Ndk::RenderSystem>();
|
||||||
|
|
||||||
m_transformMatrix = Nz::Matrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), m_entity->GetComponent<NodeComponent>().GetTransformMatrix());
|
m_transformMatrix = m_entity->GetComponent<NodeComponent>().GetTransformMatrix();
|
||||||
m_transformMatrixUpdated = true;
|
m_transformMatrixUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,19 @@
|
||||||
|
|
||||||
namespace Ndk
|
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
|
void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const
|
||||||
{
|
{
|
||||||
if (m_isActive && m_setupFunc)
|
if (m_isActive && m_setupFunc)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,18 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
void PhysicsComponent::OnAttached()
|
||||||
{
|
{
|
||||||
World* entityWorld = m_entity->GetWorld();
|
World* entityWorld = m_entity->GetWorld();
|
||||||
|
|
@ -33,6 +45,14 @@ namespace Ndk
|
||||||
m_object->SetMass(1.f);
|
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)
|
void PhysicsComponent::OnComponentAttached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<CollisionComponent>(component))
|
if (IsComponent<CollisionComponent>(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)
|
void PhysicsComponent::OnComponentDetached(BaseComponent& component)
|
||||||
{
|
{
|
||||||
if (IsComponent<CollisionComponent>(component))
|
if (IsComponent<CollisionComponent>(component))
|
||||||
|
|
@ -51,6 +79,10 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when component is detached from an entity
|
||||||
|
*/
|
||||||
|
|
||||||
void PhysicsComponent::OnDetached()
|
void PhysicsComponent::OnDetached()
|
||||||
{
|
{
|
||||||
m_object.reset();
|
m_object.reset();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,20 @@ namespace Ndk
|
||||||
constexpr std::size_t s_inputPrefixSize = Nz::CountOf(s_inputPrefix) - 1;
|
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) :
|
Console::Console(World& world, const Nz::Vector2f& size, Nz::LuaInstance& instance) :
|
||||||
m_historyPosition(0),
|
m_historyPosition(0),
|
||||||
m_defaultFont(Nz::Font::GetDefault()),
|
m_defaultFont(Nz::Font::GetDefault()),
|
||||||
|
|
@ -86,18 +100,35 @@ namespace Ndk
|
||||||
Layout();
|
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)
|
void Console::AddLine(const Nz::String& text, const Nz::Color& color)
|
||||||
{
|
{
|
||||||
AddLineInternal(text, color);
|
AddLineInternal(text, color);
|
||||||
RefreshHistory();
|
RefreshHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Clears the console
|
||||||
|
*/
|
||||||
|
|
||||||
void Console::Clear()
|
void Console::Clear()
|
||||||
{
|
{
|
||||||
m_historyLines.clear();
|
m_historyLines.clear();
|
||||||
RefreshHistory();
|
RefreshHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sends a character to the console
|
||||||
|
*
|
||||||
|
* \param character Character that will be added to the console
|
||||||
|
*/
|
||||||
|
|
||||||
void Console::SendCharacter(char32_t character)
|
void Console::SendCharacter(char32_t character)
|
||||||
{
|
{
|
||||||
switch (character)
|
switch (character)
|
||||||
|
|
@ -131,6 +162,12 @@ namespace Ndk
|
||||||
m_inputTextSprite->Update(m_inputDrawer);
|
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)
|
void Console::SendEvent(Nz::WindowEvent event)
|
||||||
{
|
{
|
||||||
switch (event.type)
|
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)
|
void Console::SetCharacterSize(unsigned int size)
|
||||||
{
|
{
|
||||||
m_characterSize = size;
|
m_characterSize = size;
|
||||||
|
|
@ -182,6 +225,12 @@ namespace Ndk
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets the console size
|
||||||
|
*
|
||||||
|
* \param size (Width, Height) of the console
|
||||||
|
*/
|
||||||
|
|
||||||
void Console::SetSize(const Nz::Vector2f& size)
|
void Console::SetSize(const Nz::Vector2f& size)
|
||||||
{
|
{
|
||||||
m_size = size;
|
m_size = size;
|
||||||
|
|
@ -189,6 +238,14 @@ namespace Ndk
|
||||||
Layout();
|
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)
|
void Console::SetTextFont(Nz::FontRef font)
|
||||||
{
|
{
|
||||||
NazaraAssert(font && font->IsValid(), "Invalid font");
|
NazaraAssert(font && font->IsValid(), "Invalid font");
|
||||||
|
|
@ -200,6 +257,12 @@ namespace Ndk
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Shows the console
|
||||||
|
*
|
||||||
|
* \param show Should the console be showed
|
||||||
|
*/
|
||||||
|
|
||||||
void Console::Show(bool show)
|
void Console::Show(bool show)
|
||||||
{
|
{
|
||||||
if (m_opened != 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)
|
void Console::AddLineInternal(const Nz::String& text, const Nz::Color& color)
|
||||||
{
|
{
|
||||||
m_historyLines.emplace_back(Line{color, text});
|
m_historyLines.emplace_back(Line{color, text});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Performs this action when an input is added to the console
|
||||||
|
*/
|
||||||
|
|
||||||
void Console::ExecuteInput()
|
void Console::ExecuteInput()
|
||||||
{
|
{
|
||||||
Nz::String input = m_inputDrawer.GetText();
|
Nz::String input = m_inputDrawer.GetText();
|
||||||
|
|
@ -237,6 +311,10 @@ namespace Ndk
|
||||||
RefreshHistory();
|
RefreshHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Places the console according to its layout
|
||||||
|
*/
|
||||||
|
|
||||||
void Console::Layout()
|
void Console::Layout()
|
||||||
{
|
{
|
||||||
unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight;
|
unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight;
|
||||||
|
|
@ -258,6 +336,10 @@ namespace Ndk
|
||||||
m_inputBackgroundSprite->SetSize(m_size.x, m_size.y - historyHeight);
|
m_inputBackgroundSprite->SetSize(m_size.x, m_size.y - historyHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Refreshes the history of the console
|
||||||
|
*/
|
||||||
|
|
||||||
void Console::RefreshHistory()
|
void Console::RefreshHistory()
|
||||||
{
|
{
|
||||||
m_historyDrawer.Clear();
|
m_historyDrawer.Clear();
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,18 @@
|
||||||
|
|
||||||
namespace Ndk
|
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) :
|
Entity::Entity(Entity&& entity) :
|
||||||
HandledObject(std::move(entity)),
|
HandledObject(std::move(entity)),
|
||||||
m_components(std::move(entity.m_components)),
|
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) :
|
Entity::Entity(World* world, EntityId id) :
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_world(world)
|
m_world(world)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destructs the object and calls Destroy
|
||||||
|
*
|
||||||
|
* \see Destroy
|
||||||
|
*/
|
||||||
|
|
||||||
Entity::~Entity()
|
Entity::~Entity()
|
||||||
{
|
{
|
||||||
Destroy();
|
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<BaseComponent>&& componentPtr)
|
BaseComponent& Entity::AddComponent(std::unique_ptr<BaseComponent>&& componentPtr)
|
||||||
{
|
{
|
||||||
NazaraAssert(componentPtr, "Component must be valid");
|
NazaraAssert(componentPtr, "Component must be valid");
|
||||||
|
|
||||||
ComponentIndex index = componentPtr->GetIndex();
|
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())
|
if (index >= m_components.size())
|
||||||
m_components.resize(index + 1);
|
m_components.resize(index + 1);
|
||||||
|
|
||||||
// Affectation et retour du component
|
// Affectation and return of the component
|
||||||
m_components[index] = std::move(componentPtr);
|
m_components[index] = std::move(componentPtr);
|
||||||
m_componentBits.UnboundedSet(index);
|
m_componentBits.UnboundedSet(index);
|
||||||
m_removedComponentBits.UnboundedReset(index);
|
m_removedComponentBits.UnboundedReset(index);
|
||||||
|
|
||||||
Invalidate();
|
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();
|
BaseComponent& component = *m_components[index].get();
|
||||||
component.SetEntity(this);
|
component.SetEntity(this);
|
||||||
|
|
||||||
|
|
@ -61,34 +95,57 @@ namespace Ndk
|
||||||
return component;
|
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
|
const EntityHandle& Entity::Clone() const
|
||||||
{
|
{
|
||||||
///DOC: The clone is enabled by default, even if the original entity is disabled
|
|
||||||
NazaraAssert(IsValid(), "Invalid entity");
|
NazaraAssert(IsValid(), "Invalid entity");
|
||||||
|
|
||||||
return m_world->CloneEntity(m_id);
|
return m_world->CloneEntity(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Kills the entity
|
||||||
|
*/
|
||||||
|
|
||||||
void Entity::Kill()
|
void Entity::Kill()
|
||||||
{
|
{
|
||||||
m_world->KillEntity(this);
|
m_world->KillEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Invalidates the entity
|
||||||
|
*/
|
||||||
|
|
||||||
void Entity::Invalidate()
|
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);
|
m_world->Invalidate(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Creates the entity
|
||||||
|
*/
|
||||||
|
|
||||||
void Entity::Create()
|
void Entity::Create()
|
||||||
{
|
{
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
m_valid = true;
|
m_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destroys the entity
|
||||||
|
*/
|
||||||
|
|
||||||
void Entity::Destroy()
|
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))
|
for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index))
|
||||||
{
|
{
|
||||||
if (m_world->HasSystem(index))
|
if (m_world->HasSystem(index))
|
||||||
|
|
@ -101,15 +158,25 @@ namespace Ndk
|
||||||
|
|
||||||
UnregisterAllHandles();
|
UnregisterAllHandles();
|
||||||
|
|
||||||
|
m_components.clear();
|
||||||
|
m_componentBits.Reset();
|
||||||
|
|
||||||
m_valid = false;
|
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)
|
void Entity::DestroyComponent(ComponentIndex index)
|
||||||
{
|
{
|
||||||
///DOC: N'a aucun effet si le component n'est pas présent
|
|
||||||
if (HasComponent(index))
|
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();
|
BaseComponent& component = *m_components[index].get();
|
||||||
for (std::size_t 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))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,29 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
bool LuaAPI::Initialize()
|
||||||
{
|
{
|
||||||
s_binding = new LuaBinding;
|
s_binding = new LuaBinding;
|
||||||
return true;
|
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)
|
void LuaAPI::RegisterClasses(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
if (!s_binding && !Initialize())
|
if (!s_binding && !Initialize())
|
||||||
|
|
@ -22,6 +39,10 @@ namespace Ndk
|
||||||
s_binding->RegisterClasses(instance);
|
s_binding->RegisterClasses(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Uninitializes the LuaAPI module
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaAPI::Uninitialize()
|
void LuaAPI::Uninitialize()
|
||||||
{
|
{
|
||||||
delete s_binding;
|
delete s_binding;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,16 @@
|
||||||
|
|
||||||
namespace Ndk
|
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() :
|
LuaBinding::LuaBinding() :
|
||||||
// Core
|
// Core
|
||||||
clockClass("Clock"),
|
clockClass("Clock"),
|
||||||
|
|
@ -65,6 +75,12 @@ namespace Ndk
|
||||||
#endif
|
#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)
|
void LuaBinding::RegisterClasses(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
RegisterCore(instance);
|
RegisterCore(instance);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds Audio module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindAudio()
|
void LuaBinding::BindAudio()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::Music **********************************/
|
/*********************************** Nz::Music **********************************/
|
||||||
|
|
@ -164,6 +168,12 @@ namespace Ndk
|
||||||
soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop);
|
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)
|
void LuaBinding::RegisterAudio(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
musicClass.Register(instance);
|
musicClass.Register(instance);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds Core module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindCore()
|
void LuaBinding::BindCore()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::Clock **********************************/
|
/*********************************** 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)
|
void LuaBinding::RegisterCore(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
// Classes
|
// Classes
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds Graphics module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindGraphics()
|
void LuaBinding::BindGraphics()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::InstancedRenderable ***********************************/
|
/*********************************** Nz::InstancedRenderable ***********************************/
|
||||||
|
|
@ -40,6 +44,12 @@ namespace Ndk
|
||||||
modelClass.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount);
|
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)
|
void LuaBinding::RegisterGraphics(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
instancedRenderable.Register(instance);
|
instancedRenderable.Register(instance);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds Math module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindMath()
|
void LuaBinding::BindMath()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::EulerAngles **********************************/
|
/*********************************** 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)
|
void LuaBinding::RegisterMath(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
eulerAnglesClass.Register(instance);
|
eulerAnglesClass.Register(instance);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds Network module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindNetwork()
|
void LuaBinding::BindNetwork()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::AbstractSocket **********************************/
|
/*********************************** 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)
|
void LuaBinding::RegisterNetwork(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
// Classes
|
// Classes
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,20 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds Renderer module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindRenderer()
|
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)
|
void LuaBinding::RegisterRenderer(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,24 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds SDK module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindSDK()
|
void LuaBinding::BindSDK()
|
||||||
{
|
{
|
||||||
/*********************************** Ndk::Application **********************************/
|
/*********************************** Ndk::Application **********************************/
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
//application.SetMethod("AddWindow", &Application::AddWindow);
|
//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
|
#endif
|
||||||
|
|
||||||
application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application) -> int
|
application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application) -> int
|
||||||
{
|
{
|
||||||
instance.Push(application->AddWorld().CreateHandle());
|
instance.Push(application->AddWorld().CreateHandle());
|
||||||
|
|
@ -53,7 +64,7 @@ namespace Ndk
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*********************************** Ndk::Entity **********************************/
|
/*********************************** Ndk::Entity **********************************/
|
||||||
entityClass.BindMethod("Enable", &Entity::Enable);
|
entityClass.BindMethod("Enable", &Entity::Enable, true);
|
||||||
entityClass.BindMethod("GetId", &Entity::GetId);
|
entityClass.BindMethod("GetId", &Entity::GetId);
|
||||||
entityClass.BindMethod("GetWorld", &Entity::GetWorld);
|
entityClass.BindMethod("GetWorld", &Entity::GetWorld);
|
||||||
entityClass.BindMethod("Kill", &Entity::Kill);
|
entityClass.BindMethod("Kill", &Entity::Kill);
|
||||||
|
|
@ -128,7 +139,7 @@ namespace Ndk
|
||||||
|
|
||||||
#ifndef NDK_SERVER
|
#ifndef NDK_SERVER
|
||||||
/*********************************** Ndk::GraphicsComponent **********************************/
|
/*********************************** Ndk::GraphicsComponent **********************************/
|
||||||
graphicsComponent.BindMethod("Attach", &GraphicsComponent::Attach, 0);
|
graphicsComponent.BindMethod("Attach", (void(Ndk::GraphicsComponent::*)(Nz::InstancedRenderableRef, int)) &GraphicsComponent::Attach, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -143,6 +154,12 @@ namespace Ndk
|
||||||
#endif
|
#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)
|
void LuaBinding::RegisterSDK(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
// Classes
|
// Classes
|
||||||
|
|
@ -173,6 +190,14 @@ namespace Ndk
|
||||||
instance.SetGlobal("ComponentType");
|
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)
|
LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex)
|
||||||
{
|
{
|
||||||
switch (instance.GetType(argIndex))
|
switch (instance.GetType(argIndex))
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Binds Utility module to Lua
|
||||||
|
*/
|
||||||
|
|
||||||
void LuaBinding::BindUtility()
|
void LuaBinding::BindUtility()
|
||||||
{
|
{
|
||||||
/*********************************** Nz::AbstractImage **********************************/
|
/*********************************** 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)
|
void LuaBinding::RegisterUtility(Nz::LuaInstance& instance)
|
||||||
{
|
{
|
||||||
abstractImage.Register(instance);
|
abstractImage.Register(instance);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,19 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
bool Sdk::Initialize()
|
||||||
{
|
{
|
||||||
if (s_referenceCounter++ > 0)
|
if (s_referenceCounter++ > 0)
|
||||||
|
|
@ -104,6 +117,12 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Uninitializes the Sdk module
|
||||||
|
*
|
||||||
|
* \remark Produces a NazaraNotice
|
||||||
|
*/
|
||||||
|
|
||||||
void Sdk::Uninitialize()
|
void Sdk::Uninitialize()
|
||||||
{
|
{
|
||||||
if (s_referenceCounter != 1)
|
if (s_referenceCounter != 1)
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,11 @@
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
/*!
|
||||||
|
* \ingroup NDK
|
||||||
|
* \class Ndk::State
|
||||||
|
* \brief NDK class that represents a state of your application
|
||||||
|
*/
|
||||||
|
|
||||||
State::~State() = default;
|
State::~State() = default;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,29 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
ListenerSystem::ListenerSystem()
|
||||||
{
|
{
|
||||||
Requires<ListenerComponent, NodeComponent>();
|
Requires<ListenerComponent, NodeComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when system is updated
|
||||||
|
*
|
||||||
|
* \param elapsedTime Delta time used for the update
|
||||||
|
*/
|
||||||
|
|
||||||
void ListenerSystem::OnUpdate(float elapsedTime)
|
void ListenerSystem::OnUpdate(float elapsedTime)
|
||||||
{
|
{
|
||||||
NazaraUnused(elapsedTime);
|
NazaraUnused(elapsedTime);
|
||||||
|
|
@ -23,18 +41,18 @@ namespace Ndk
|
||||||
|
|
||||||
for (const Ndk::EntityHandle& entity : GetEntities())
|
for (const Ndk::EntityHandle& entity : GetEntities())
|
||||||
{
|
{
|
||||||
// Le listener est-il actif ?
|
// Is the listener actif ?
|
||||||
const ListenerComponent& listener = entity->GetComponent<ListenerComponent>();
|
const ListenerComponent& listener = entity->GetComponent<ListenerComponent>();
|
||||||
if (!listener.IsActive())
|
if (!listener.IsActive())
|
||||||
continue;
|
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<NodeComponent>();
|
const NodeComponent& node = entity->GetComponent<NodeComponent>();
|
||||||
Nz::Audio::SetListenerPosition(node.GetPosition(Nz::CoordSys_Global));
|
Nz::Audio::SetListenerPosition(node.GetPosition(Nz::CoordSys_Global));
|
||||||
Nz::Audio::SetListenerRotation(node.GetRotation(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
|
// We verify the presence of a component of velocity
|
||||||
// (La vitesse du listener Audio ne le fait pas se déplacer, mais affecte par exemple l'effet Doppler)
|
// (The listener'speed does not move it, but disturbs the sound like Doppler effect)
|
||||||
if (entity->HasComponent<VelocityComponent>())
|
if (entity->HasComponent<VelocityComponent>())
|
||||||
{
|
{
|
||||||
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
|
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,29 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
ParticleSystem::ParticleSystem()
|
||||||
{
|
{
|
||||||
Requires<ParticleGroupComponent>();
|
Requires<ParticleGroupComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when system is updated
|
||||||
|
*
|
||||||
|
* \param elapsedTime Delta time used for the update
|
||||||
|
*/
|
||||||
|
|
||||||
void ParticleSystem::OnUpdate(float elapsedTime)
|
void ParticleSystem::OnUpdate(float elapsedTime)
|
||||||
{
|
{
|
||||||
for (const Ndk::EntityHandle& entity : GetEntities())
|
for (const Ndk::EntityHandle& entity : GetEntities())
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,50 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
PhysicsSystem::PhysicsSystem()
|
||||||
{
|
{
|
||||||
Requires<NodeComponent>();
|
Requires<NodeComponent>();
|
||||||
RequiresAny<CollisionComponent, PhysicsComponent>();
|
RequiresAny<CollisionComponent, PhysicsComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a PhysicsSystem object by copy semantic
|
||||||
|
*
|
||||||
|
* \param system PhysicsSystem to copy
|
||||||
|
*/
|
||||||
|
|
||||||
PhysicsSystem::PhysicsSystem(const PhysicsSystem& system) :
|
PhysicsSystem::PhysicsSystem(const PhysicsSystem& system) :
|
||||||
System(system),
|
System(system),
|
||||||
m_world()
|
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)
|
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)
|
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<PhysicsComponent>()) ? m_staticObjects : m_dynamicObjects;
|
auto& entities = (entity->HasComponent<PhysicsComponent>()) ? m_staticObjects : m_dynamicObjects;
|
||||||
entities.Remove(entity);
|
entities.Remove(entity);
|
||||||
}
|
}
|
||||||
|
|
@ -36,6 +62,12 @@ namespace Ndk
|
||||||
entities.Insert(entity);
|
entities.Insert(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when system is updated
|
||||||
|
*
|
||||||
|
* \param elapsedTime Delta time used for the update
|
||||||
|
*/
|
||||||
|
|
||||||
void PhysicsSystem::OnUpdate(float elapsedTime)
|
void PhysicsSystem::OnUpdate(float elapsedTime)
|
||||||
{
|
{
|
||||||
m_world.Step(elapsedTime);
|
m_world.Step(elapsedTime);
|
||||||
|
|
@ -63,8 +95,8 @@ namespace Ndk
|
||||||
Nz::Quaternionf newRotation = node.GetRotation(Nz::CoordSys_Global);
|
Nz::Quaternionf newRotation = node.GetRotation(Nz::CoordSys_Global);
|
||||||
Nz::Vector3f newPosition = node.GetPosition(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
|
// To move static objects and ensure their collisions, we have to specify them a velocity
|
||||||
// (note importante: le moteur physique n'applique pas la vitesse sur les objets statiques)
|
// (/!\: the physical motor does not apply the speed on static objects)
|
||||||
if (newPosition != oldPosition)
|
if (newPosition != oldPosition)
|
||||||
{
|
{
|
||||||
physObj->SetPosition(newPosition);
|
physObj->SetPosition(newPosition);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,21 @@
|
||||||
|
|
||||||
namespace Ndk
|
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() :
|
RenderSystem::RenderSystem() :
|
||||||
m_coordinateSystemMatrix(Nz::Matrix4f::Identity()),
|
m_coordinateSystemMatrix(Nz::Matrix4f::Identity()),
|
||||||
m_coordinateSystemInvalidated(true)
|
m_coordinateSystemInvalidated(true)
|
||||||
|
|
@ -23,6 +38,12 @@ namespace Ndk
|
||||||
SetUpdateRate(0.f);
|
SetUpdateRate(0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when an entity is removed
|
||||||
|
*
|
||||||
|
* \param entity Pointer to the entity
|
||||||
|
*/
|
||||||
|
|
||||||
void RenderSystem::OnEntityRemoved(Entity* entity)
|
void RenderSystem::OnEntityRemoved(Entity* entity)
|
||||||
{
|
{
|
||||||
m_cameras.Remove(entity);
|
m_cameras.Remove(entity);
|
||||||
|
|
@ -33,6 +54,13 @@ namespace Ndk
|
||||||
m_pointSpotLights.Remove(entity);
|
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)
|
void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded)
|
||||||
{
|
{
|
||||||
NazaraUnused(justAdded);
|
NazaraUnused(justAdded);
|
||||||
|
|
@ -82,6 +110,12 @@ namespace Ndk
|
||||||
m_particleGroups.Remove(entity);
|
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)
|
void RenderSystem::OnUpdate(float elapsedTime)
|
||||||
{
|
{
|
||||||
NazaraUnused(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)
|
void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer)
|
||||||
{
|
{
|
||||||
if (!m_shadowRT.IsValid())
|
if (!m_shadowRT.IsValid())
|
||||||
|
|
@ -191,6 +231,10 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Updates the point spot shadow maps
|
||||||
|
*/
|
||||||
|
|
||||||
void RenderSystem::UpdatePointSpotShadowMaps()
|
void RenderSystem::UpdatePointSpotShadowMaps()
|
||||||
{
|
{
|
||||||
if (!m_shadowRT.IsValid())
|
if (!m_shadowRT.IsValid())
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,31 @@
|
||||||
|
|
||||||
namespace Ndk
|
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()
|
VelocitySystem::VelocitySystem()
|
||||||
{
|
{
|
||||||
Requires<NodeComponent, VelocityComponent>();
|
Requires<NodeComponent, VelocityComponent>();
|
||||||
Excludes<PhysicsComponent>();
|
Excludes<PhysicsComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation to perform when system is updated
|
||||||
|
*
|
||||||
|
* \param elapsedTime Delta time used for the update
|
||||||
|
*/
|
||||||
|
|
||||||
void VelocitySystem::OnUpdate(float elapsedTime)
|
void VelocitySystem::OnUpdate(float elapsedTime)
|
||||||
{
|
{
|
||||||
for (const Ndk::EntityHandle& entity : GetEntities())
|
for (const Ndk::EntityHandle& entity : GetEntities())
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,28 @@
|
||||||
|
|
||||||
namespace Ndk
|
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
|
World::~World() noexcept
|
||||||
{
|
{
|
||||||
// La destruction doit se faire dans un ordre précis
|
// The destruct must be done in an ordered way
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Adds default systems to the world
|
||||||
|
*/
|
||||||
|
|
||||||
void World::AddDefaultSystems()
|
void World::AddDefaultSystems()
|
||||||
{
|
{
|
||||||
AddSystem<PhysicsSystem>();
|
AddSystem<PhysicsSystem>();
|
||||||
|
|
@ -34,40 +50,49 @@ namespace Ndk
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Creates an entity in the world
|
||||||
|
* \return The entity created
|
||||||
|
*/
|
||||||
|
|
||||||
const EntityHandle& World::CreateEntity()
|
const EntityHandle& World::CreateEntity()
|
||||||
{
|
{
|
||||||
EntityId id;
|
EntityId id;
|
||||||
if (!m_freeIdList.empty())
|
if (!m_freeIdList.empty())
|
||||||
{
|
{
|
||||||
// On récupère un identifiant
|
// We get an identifier
|
||||||
id = m_freeIdList.back();
|
id = m_freeIdList.back();
|
||||||
m_freeIdList.pop_back();
|
m_freeIdList.pop_back();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// On alloue une nouvelle entité
|
// We allocate a new entity
|
||||||
id = m_entities.size();
|
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));
|
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& entity = m_entities[id].entity;
|
||||||
entity.Create();
|
entity.Create();
|
||||||
|
|
||||||
m_aliveEntities.emplace_back(&entity);
|
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();
|
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
|
void World::Clear() noexcept
|
||||||
{
|
{
|
||||||
///DOC: Tous les handles sont correctement invalidés, les entités sont immédiatement invalidées
|
// First, destruction of entities, then handles
|
||||||
|
// This is made to avoid that handle warn uselessly entities before their destruction
|
||||||
// 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
|
|
||||||
m_entities.clear();
|
m_entities.clear();
|
||||||
|
|
||||||
m_aliveEntities.clear();
|
m_aliveEntities.clear();
|
||||||
|
|
@ -75,6 +100,15 @@ namespace Ndk
|
||||||
m_killedEntities.Clear();
|
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)
|
const EntityHandle& World::CloneEntity(EntityId id)
|
||||||
{
|
{
|
||||||
EntityHandle original = GetEntity(id);
|
EntityHandle original = GetEntity(id);
|
||||||
|
|
@ -96,14 +130,29 @@ namespace Ndk
|
||||||
return GetEntity(clone->GetId());
|
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)
|
void World::KillEntity(Entity* entity)
|
||||||
{
|
{
|
||||||
///DOC: Ignoré si l'entité est invalide
|
|
||||||
|
|
||||||
if (IsEntityValid(entity))
|
if (IsEntityValid(entity))
|
||||||
m_killedEntities.UnboundedSet(entity->GetId(), true);
|
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)
|
const EntityHandle& World::GetEntity(EntityId id)
|
||||||
{
|
{
|
||||||
if (IsEntityIdValid(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()
|
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))
|
for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i))
|
||||||
{
|
{
|
||||||
EntityBlock& block = m_entities[i];
|
EntityBlock& block = m_entities[i];
|
||||||
|
|
@ -125,32 +180,32 @@ namespace Ndk
|
||||||
|
|
||||||
NazaraAssert(entity.IsValid(), "Entity must be valid");
|
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());
|
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();
|
entity.Destroy();
|
||||||
|
|
||||||
// Nous allons sortir le handle de la liste des entités vivantes
|
// We take out the handle from the list of alive entities
|
||||||
// en swappant le handle avec le dernier handle, avant de pop
|
// With the idiom swap and pop
|
||||||
|
|
||||||
NazaraAssert(block.aliveIndex < m_aliveEntities.size(), "Alive index out of range");
|
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& lastHandle = m_aliveEntities.back();
|
||||||
EntityHandle& myHandle = m_aliveEntities[block.aliveIndex];
|
EntityHandle& myHandle = m_aliveEntities[block.aliveIndex];
|
||||||
|
|
||||||
myHandle = std::move(lastHandle);
|
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_entities[myHandle->GetId()].aliveIndex = block.aliveIndex;
|
||||||
}
|
}
|
||||||
m_aliveEntities.pop_back();
|
m_aliveEntities.pop_back();
|
||||||
}
|
}
|
||||||
m_killedEntities.Reset();
|
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))
|
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");
|
NazaraAssert(i < m_entities.size(), "Entity index out of range");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
version: '{branch}-rev{build}'
|
||||||
|
|
||||||
|
shallow_clone: true
|
||||||
|
|
||||||
|
os:
|
||||||
|
- Visual Studio 2015
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- TOOLSET: vs2015
|
||||||
|
|
||||||
|
install:
|
||||||
|
- cd build && "./premake5.exe" %TOOLSET% && cd ..
|
||||||
|
|
||||||
|
configuration:
|
||||||
|
- DebugDynamic
|
||||||
|
- ReleaseDynamic
|
||||||
|
|
||||||
|
build:
|
||||||
|
project: build/$(TOOLSET)/NazaraEngine.sln
|
||||||
|
|
@ -314,7 +314,7 @@ function NazaraBuild:Execute()
|
||||||
|
|
||||||
configuration({"codeblocks or codelite or gmake", "x64"})
|
configuration({"codeblocks or codelite or gmake", "x64"})
|
||||||
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
|
libdirs("../extlibs/lib/" .. makeLibDir .. "/x64")
|
||||||
libdirs("../lib/" .. makeLibDir .. "/x86")
|
libdirs("../lib/" .. makeLibDir .. "/x64")
|
||||||
if (toolTable.Kind == "library") then
|
if (toolTable.Kind == "library") then
|
||||||
targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64")
|
targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64")
|
||||||
elseif (toolTable.Kind == "plugin") then
|
elseif (toolTable.Kind == "plugin") then
|
||||||
|
|
@ -1084,4 +1084,4 @@ function NazaraBuild:SetupModuleTable(infoTable)
|
||||||
table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64")
|
table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64")
|
||||||
end
|
end
|
||||||
|
|
||||||
NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable
|
NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,10 @@ TOOL.Includes = {
|
||||||
|
|
||||||
TOOL.Files = {
|
TOOL.Files = {
|
||||||
"../tests/main.cpp",
|
"../tests/main.cpp",
|
||||||
"../tests/Engine/**.cpp"
|
"../tests/Engine/**.cpp",
|
||||||
|
"../tests/SDK/**.cpp"
|
||||||
}
|
}
|
||||||
|
|
||||||
TOOL.Libraries = {
|
TOOL.Libraries = {
|
||||||
"NazaraCore",
|
"NazaraSDK"
|
||||||
"NazaraAudio",
|
|
||||||
"NazaraLua",
|
|
||||||
"NazaraGraphics",
|
|
||||||
"NazaraRenderer",
|
|
||||||
"NazaraNetwork",
|
|
||||||
"NazaraNoise",
|
|
||||||
"NazaraPhysics",
|
|
||||||
"NazaraUtility"
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -256,78 +256,22 @@ int main()
|
||||||
// On lie la caméra à la fenêtre
|
// On lie la caméra à la fenêtre
|
||||||
cameraComp.SetTarget(&window);
|
cameraComp.SetTarget(&window);
|
||||||
|
|
||||||
// Et on créé deux horloges pour gérer le temps
|
// Et on créé une horloge pour gérer le temps
|
||||||
Nz::Clock secondClock, updateClock;
|
Nz::Clock updateClock;
|
||||||
Nz::UInt64 updateAccumulator = 0;
|
Nz::UInt64 updateAccumulator = 0;
|
||||||
|
|
||||||
// Ainsi qu'un compteur de FPS improvisé
|
|
||||||
unsigned int fps = 0;
|
|
||||||
|
|
||||||
// Quelques variables de plus pour notre caméra
|
// Quelques variables de plus pour notre caméra
|
||||||
bool smoothMovement = true;
|
bool smoothMovement = true;
|
||||||
Nz::Vector3f targetPos = cameraNode.GetPosition();
|
Nz::Vector3f targetPos = cameraNode.GetPosition();
|
||||||
|
|
||||||
// Pour ajouter une console à notre application, nous avons besoin d'un monde 2D pour gérer ces rendus
|
window.EnableEventPolling(true); // Déprécié
|
||||||
Ndk::WorldHandle world2D = application.AddWorld().CreateHandle();
|
|
||||||
world2D->GetSystem<Ndk::RenderSystem>().SetDefaultBackground(nullptr);
|
|
||||||
world2D->GetSystem<Ndk::RenderSystem>().SetGlobalUp(Nz::Vector3f::Down());
|
|
||||||
|
|
||||||
// Nous ajoutons une caméra comme précédement
|
application.EnableConsole(true);
|
||||||
Ndk::EntityHandle viewEntity = world2D->CreateEntity();
|
application.EnableFPSCounter(true);
|
||||||
viewEntity->AddComponent<Ndk::NodeComponent>();
|
|
||||||
|
|
||||||
// À la différence que celui-ci effectuera une projection orthogonale
|
Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay();
|
||||||
Ndk::CameraComponent& viewer = viewEntity->AddComponent<Ndk::CameraComponent>();
|
consoleOverlay.lua.PushGlobal("Spaceship", spaceship->CreateHandle());
|
||||||
viewer.SetTarget(&window);
|
consoleOverlay.lua.PushGlobal("World", world->CreateHandle());
|
||||||
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)
|
// Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde)
|
||||||
while (application.Run())
|
while (application.Run())
|
||||||
|
|
@ -340,8 +284,12 @@ int main()
|
||||||
{
|
{
|
||||||
case Nz::WindowEventType_MouseMoved: // La souris a bougé
|
case Nz::WindowEventType_MouseMoved: // La souris a bougé
|
||||||
{
|
{
|
||||||
if (console.IsVisible())
|
if (application.IsConsoleEnabled())
|
||||||
break;
|
{
|
||||||
|
Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay();
|
||||||
|
if (consoleOverlay.console->IsVisible())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Gestion de la caméra free-fly (Rotation)
|
// Gestion de la caméra free-fly (Rotation)
|
||||||
float sensitivity = 0.3f; // Sensibilité de la souris
|
float sensitivity = 0.3f; // Sensibilité de la souris
|
||||||
|
|
@ -366,9 +314,6 @@ int main()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Nz::WindowEventType_KeyPressed: // Une touche a été pressée !
|
case Nz::WindowEventType_KeyPressed: // Une touche a été pressée !
|
||||||
if (console.IsVisible())
|
|
||||||
console.SendEvent(event);
|
|
||||||
|
|
||||||
if (event.key.code == Nz::Keyboard::Key::Escape)
|
if (event.key.code == Nz::Keyboard::Key::Escape)
|
||||||
window.Close();
|
window.Close();
|
||||||
else if (event.key.code == Nz::Keyboard::F1)
|
else if (event.key.code == Nz::Keyboard::F1)
|
||||||
|
|
@ -381,19 +326,6 @@ int main()
|
||||||
else
|
else
|
||||||
smoothMovement = true;
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -417,7 +349,16 @@ int main()
|
||||||
// Vitesse de déplacement de la caméra
|
// Vitesse de déplacement de la caméra
|
||||||
float cameraSpeed = 3.f * elapsedTime; // Trois mètres par seconde
|
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
|
// Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux
|
||||||
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space))
|
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space))
|
||||||
|
|
@ -458,28 +399,6 @@ int main()
|
||||||
// Après avoir dessiné sur la fenêtre, il faut s'assurer qu'elle affiche cela
|
// 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)
|
// Cet appel ne fait rien d'autre qu'échanger les buffers de rendu (Double Buffering)
|
||||||
window.Display();
|
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;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ int main()
|
||||||
|
|
||||||
std::cout << oss.str() << std::endl;
|
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))
|
if (reportFile.Open(Nz::OpenMode_Text | Nz::OpenMode_Truncate | Nz::OpenMode_WriteOnly))
|
||||||
{
|
{
|
||||||
reportFile.Write(oss.str()); // Conversion implicite en Nz::String
|
reportFile.Write(oss.str()); // Conversion implicite en Nz::String
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,14 @@
|
||||||
#include <Nazara/Utility.hpp>
|
#include <Nazara/Utility.hpp>
|
||||||
#include <NDK/Application.hpp>
|
#include <NDK/Application.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
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
|
// 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
|
// 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;
|
Ndk::Application application(argc, argv);
|
||||||
|
|
||||||
// Do what you want here
|
// Do what you want here
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -9,16 +9,17 @@
|
||||||
#include <NDK/World.hpp>
|
#include <NDK/World.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main()
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Ndk::Application application;
|
Ndk::Application application(argc, argv);
|
||||||
|
|
||||||
Nz::RenderWindow& mainWindow = application.AddWindow<Nz::RenderWindow>();
|
Nz::RenderWindow& mainWindow = application.AddWindow<Nz::RenderWindow>();
|
||||||
mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test");
|
mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test");
|
||||||
|
|
||||||
|
|
||||||
Ndk::World& world = application.AddWorld();
|
Ndk::World& world = application.AddWorld();
|
||||||
world.GetSystem<Ndk::RenderSystem>().SetGlobalUp(Nz::Vector3f::Down());
|
world.GetSystem<Ndk::RenderSystem>().SetGlobalUp(Nz::Vector3f::Down());
|
||||||
world.GetSystem<Ndk::RenderSystem>().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(192, 100, 100)));
|
world.GetSystem<Ndk::RenderSystem>().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(117, 122, 214)));
|
||||||
|
|
||||||
|
|
||||||
Ndk::EntityHandle viewEntity = world.CreateEntity();
|
Ndk::EntityHandle viewEntity = world.CreateEntity();
|
||||||
|
|
@ -43,13 +44,6 @@ int main()
|
||||||
|
|
||||||
while (application.Run())
|
while (application.Run())
|
||||||
{
|
{
|
||||||
Nz::WindowEvent event;
|
|
||||||
while (mainWindow.PollEvent(&event))
|
|
||||||
{
|
|
||||||
if (event.type == Nz::WindowEventType_Quit)
|
|
||||||
application.Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
mainWindow.Display();
|
mainWindow.Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
template<typename T> void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount);
|
template<typename T> void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Audio/Algorithm.inl>
|
#include <Nazara/Audio/Algorithm.inl>
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,16 @@ namespace Nz
|
||||||
* \remark The input buffer may be the same as the output one
|
* \remark The input buffer may be the same as the output one
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
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
|
// 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<std::is_unsigned<T>::value, UInt64, Int64>::type BiggestInt;
|
typedef typename std::conditional<std::is_unsigned<T>::value, UInt64, Int64>::type BiggestInt;
|
||||||
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
typedef typename std::conditional<std::is_integral<T>::value, BiggestInt, double>::type Biggest;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < frameCount; ++i)
|
for (UInt64 i = 0; i < frameCount; ++i)
|
||||||
{
|
{
|
||||||
Biggest acc = Biggest(0);
|
Biggest acc = Biggest(0);
|
||||||
for (unsigned int j = 0; j < channelCount; ++j)
|
for (UInt32 j = 0; j < channelCount; ++j)
|
||||||
acc += input[i * channelCount + j];
|
acc += input[i * channelCount + j];
|
||||||
|
|
||||||
output[i] = static_cast<T>(acc / channelCount);
|
output[i] = static_cast<T>(acc / channelCount);
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Nz
|
||||||
UInt32 GetDuration() const;
|
UInt32 GetDuration() const;
|
||||||
AudioFormat GetFormat() const;
|
AudioFormat GetFormat() const;
|
||||||
UInt32 GetPlayingOffset() const;
|
UInt32 GetPlayingOffset() const;
|
||||||
UInt32 GetSampleCount() const;
|
UInt64 GetSampleCount() const;
|
||||||
UInt32 GetSampleRate() const;
|
UInt32 GetSampleRate() const;
|
||||||
SoundStatus GetStatus() const;
|
SoundStatus GetStatus() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,18 +50,18 @@ namespace Nz
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundBuffer() = default;
|
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(const SoundBuffer&) = delete;
|
||||||
SoundBuffer(SoundBuffer&&) = delete;
|
SoundBuffer(SoundBuffer&&) = delete;
|
||||||
~SoundBuffer();
|
~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();
|
void Destroy();
|
||||||
|
|
||||||
UInt32 GetDuration() const;
|
UInt32 GetDuration() const;
|
||||||
AudioFormat GetFormat() const;
|
AudioFormat GetFormat() const;
|
||||||
const Int16* GetSamples() const;
|
const Int16* GetSamples() const;
|
||||||
UInt32 GetSampleCount() const;
|
UInt64 GetSampleCount() const;
|
||||||
UInt32 GetSampleRate() const;
|
UInt32 GetSampleRate() const;
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ namespace Nz
|
||||||
|
|
||||||
virtual UInt32 GetDuration() const = 0;
|
virtual UInt32 GetDuration() const = 0;
|
||||||
virtual AudioFormat GetFormat() const = 0;
|
virtual AudioFormat GetFormat() const = 0;
|
||||||
virtual UInt32 GetSampleCount() const = 0;
|
virtual UInt64 GetSampleCount() const = 0;
|
||||||
virtual UInt32 GetSampleRate() const = 0;
|
virtual UInt32 GetSampleRate() const = 0;
|
||||||
|
|
||||||
virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0;
|
virtual UInt64 Read(void* buffer, UInt64 sampleCount) = 0;
|
||||||
virtual void Seek(UInt32 offset) = 0;
|
virtual void Seek(UInt64 offset) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ namespace Nz
|
||||||
if (sizeof(T) <= sizeof(Block))
|
if (sizeof(T) <= sizeof(Block))
|
||||||
{
|
{
|
||||||
m_bitCount = std::numeric_limits<T>::digits;
|
m_bitCount = std::numeric_limits<T>::digits;
|
||||||
m_blocks.push_back(value);
|
m_blocks.push_back(static_cast<Block>(value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ namespace Nz
|
||||||
|
|
||||||
struct InstanceData
|
struct InstanceData
|
||||||
{
|
{
|
||||||
InstanceData(const Matrix4f& referenceMatrix) :
|
InstanceData(const Matrix4f& transformationMatrix) :
|
||||||
transformMatrix(&referenceMatrix),
|
localMatrix(transformationMatrix),
|
||||||
flags(0)
|
flags(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +67,7 @@ namespace Nz
|
||||||
data = std::move(instanceData.data);
|
data = std::move(instanceData.data);
|
||||||
flags = instanceData.flags;
|
flags = instanceData.flags;
|
||||||
renderOrder = instanceData.renderOrder;
|
renderOrder = instanceData.renderOrder;
|
||||||
|
localMatrix = instanceData.localMatrix;
|
||||||
transformMatrix = instanceData.transformMatrix;
|
transformMatrix = instanceData.transformMatrix;
|
||||||
volume = instanceData.volume;
|
volume = instanceData.volume;
|
||||||
|
|
||||||
|
|
@ -75,7 +76,8 @@ namespace Nz
|
||||||
|
|
||||||
std::vector<UInt8> data;
|
std::vector<UInt8> data;
|
||||||
BoundingVolumef volume;
|
BoundingVolumef volume;
|
||||||
const Matrix4f* transformMatrix;
|
Matrix4f localMatrix;
|
||||||
|
mutable Matrix4f transformMatrix;
|
||||||
UInt32 flags;
|
UInt32 flags;
|
||||||
int renderOrder;
|
int renderOrder;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ namespace Nz
|
||||||
MaterialPipelineRef MaterialPipeline::New(Args&&... args)
|
MaterialPipelineRef MaterialPipeline::New(Args&&... args)
|
||||||
{
|
{
|
||||||
std::unique_ptr<MaterialPipeline> object(new MaterialPipeline(std::forward<Args>(args)...));
|
std::unique_ptr<MaterialPipeline> object(new MaterialPipeline(std::forward<Args>(args)...));
|
||||||
|
object->SetPersistent(false);
|
||||||
return object.release();
|
return object.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,9 @@ namespace Nz
|
||||||
*/
|
*/
|
||||||
inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder)
|
inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder)
|
||||||
{
|
{
|
||||||
InstanceData instanceData(transformMatrix);
|
InstanceData instanceData(Nz::Matrix4f::Identity());
|
||||||
instanceData.renderOrder = renderOrder;
|
instanceData.renderOrder = renderOrder;
|
||||||
|
instanceData.transformMatrix = transformMatrix;
|
||||||
return AddToRenderQueue(renderQueue, instanceData);
|
return AddToRenderQueue(renderQueue, instanceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,17 @@ namespace Nz
|
||||||
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
||||||
|
|
||||||
inline const Color& GetColor() const;
|
inline const Color& GetColor() const;
|
||||||
|
inline const Color& GetCornerColor(RectCorner corner) const;
|
||||||
inline const MaterialRef& GetMaterial() const;
|
inline const MaterialRef& GetMaterial() const;
|
||||||
|
inline const Vector3f& GetOrigin() const;
|
||||||
inline const Vector2f& GetSize() const;
|
inline const Vector2f& GetSize() const;
|
||||||
inline const Rectf& GetTextureCoords() const;
|
inline const Rectf& GetTextureCoords() const;
|
||||||
|
|
||||||
inline void SetColor(const Color& color);
|
inline void SetColor(const Color& color);
|
||||||
|
inline void SetCornerColor(RectCorner corner, const Color& color);
|
||||||
inline void SetDefaultMaterial();
|
inline void SetDefaultMaterial();
|
||||||
inline void SetMaterial(MaterialRef material, bool resizeSprite = true);
|
inline void SetMaterial(MaterialRef material, bool resizeSprite = true);
|
||||||
|
inline void SetOrigin(const Vector3f& origin);
|
||||||
inline void SetSize(const Vector2f& size);
|
inline void SetSize(const Vector2f& size);
|
||||||
inline void SetSize(float sizeX, float sizeY);
|
inline void SetSize(float sizeX, float sizeY);
|
||||||
inline void SetTexture(TextureRef texture, bool resizeSprite = true);
|
inline void SetTexture(TextureRef texture, bool resizeSprite = true);
|
||||||
|
|
@ -63,10 +67,12 @@ namespace Nz
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
static void Uninitialize();
|
static void Uninitialize();
|
||||||
|
|
||||||
|
std::array<Color, 4> m_cornerColor;
|
||||||
Color m_color;
|
Color m_color;
|
||||||
MaterialRef m_material;
|
MaterialRef m_material;
|
||||||
Rectf m_textureCoords;
|
Rectf m_textureCoords;
|
||||||
Vector2f m_size;
|
Vector2f m_size;
|
||||||
|
Vector3f m_origin;
|
||||||
|
|
||||||
static SpriteLibrary::LibraryMap s_library;
|
static SpriteLibrary::LibraryMap s_library;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,12 @@ namespace Nz
|
||||||
inline Sprite::Sprite() :
|
inline Sprite::Sprite() :
|
||||||
m_color(Color::White),
|
m_color(Color::White),
|
||||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
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())
|
||||||
{
|
{
|
||||||
|
for (Color& color : m_cornerColor)
|
||||||
|
color = Color::White;
|
||||||
|
|
||||||
SetDefaultMaterial();
|
SetDefaultMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,11 +29,8 @@ namespace Nz
|
||||||
*
|
*
|
||||||
* \param material Reference to a material
|
* \param material Reference to a material
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline Sprite::Sprite(MaterialRef material) :
|
inline Sprite::Sprite(MaterialRef material) :
|
||||||
m_color(Color::White),
|
Sprite()
|
||||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
|
||||||
m_size(64.f, 64.f)
|
|
||||||
{
|
{
|
||||||
SetMaterial(std::move(material), true);
|
SetMaterial(std::move(material), true);
|
||||||
}
|
}
|
||||||
|
|
@ -41,9 +42,7 @@ namespace Nz
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline Sprite::Sprite(Texture* texture) :
|
inline Sprite::Sprite(Texture* texture) :
|
||||||
m_color(Color::White),
|
Sprite()
|
||||||
m_textureCoords(0.f, 0.f, 1.f, 1.f),
|
|
||||||
m_size(64.f, 64.f)
|
|
||||||
{
|
{
|
||||||
SetTexture(texture, true);
|
SetTexture(texture, true);
|
||||||
}
|
}
|
||||||
|
|
@ -59,30 +58,63 @@ namespace Nz
|
||||||
m_color(sprite.m_color),
|
m_color(sprite.m_color),
|
||||||
m_material(sprite.m_material),
|
m_material(sprite.m_material),
|
||||||
m_textureCoords(sprite.m_textureCoords),
|
m_textureCoords(sprite.m_textureCoords),
|
||||||
m_size(sprite.m_size)
|
m_size(sprite.m_size),
|
||||||
|
m_origin(sprite.m_origin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the color of the sprite
|
* \brief Gets the color of the sprite
|
||||||
|
*
|
||||||
|
* This is the global color of the sprite, independent from corner colors
|
||||||
|
*
|
||||||
* \return Current color
|
* \return Current color
|
||||||
|
*
|
||||||
|
* \see GetCornerColor
|
||||||
|
* \see SetColor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline const Color& Sprite::GetColor() const
|
inline const Color& Sprite::GetColor() const
|
||||||
{
|
{
|
||||||
return m_color;
|
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(static_cast<std::size_t>(corner) < m_cornerColor.size(), "Invalid corner");
|
||||||
|
|
||||||
|
return m_cornerColor[corner];
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the material of the sprite
|
* \brief Gets the material of the sprite
|
||||||
* \return Current material
|
* \return Current material
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline const MaterialRef& Sprite::GetMaterial() const
|
inline const MaterialRef& Sprite::GetMaterial() const
|
||||||
{
|
{
|
||||||
return m_material;
|
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
|
* \brief Gets the size of the sprite
|
||||||
* \return Current size
|
* \return Current size
|
||||||
|
|
@ -97,18 +129,21 @@ namespace Nz
|
||||||
* \brief Gets the texture coordinates of the sprite
|
* \brief Gets the texture coordinates of the sprite
|
||||||
* \return Current texture coordinates
|
* \return Current texture coordinates
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline const Rectf& Sprite::GetTextureCoords() const
|
inline const Rectf& Sprite::GetTextureCoords() const
|
||||||
{
|
{
|
||||||
return m_textureCoords;
|
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)
|
inline void Sprite::SetColor(const Color& color)
|
||||||
{
|
{
|
||||||
m_color = color;
|
m_color = color;
|
||||||
|
|
@ -116,6 +151,26 @@ namespace Nz
|
||||||
InvalidateVertices();
|
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(static_cast<std::size_t>(corner) < m_cornerColor.size(), "Invalid corner");
|
||||||
|
|
||||||
|
m_cornerColor[corner] = color;
|
||||||
|
|
||||||
|
InvalidateVertices();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Sets the default material of the sprite (just default material)
|
* \brief Sets the default material of the sprite (just default material)
|
||||||
*/
|
*/
|
||||||
|
|
@ -146,6 +201,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
|
* \brief Sets the size of the sprite
|
||||||
*
|
*
|
||||||
|
|
@ -240,6 +313,7 @@ namespace Nz
|
||||||
|
|
||||||
m_color = sprite.m_color;
|
m_color = sprite.m_color;
|
||||||
m_material = sprite.m_material;
|
m_material = sprite.m_material;
|
||||||
|
m_origin = sprite.m_origin;
|
||||||
m_textureCoords = sprite.m_textureCoords;
|
m_textureCoords = sprite.m_textureCoords;
|
||||||
m_size = sprite.m_size;
|
m_size = sprite.m_size;
|
||||||
|
|
||||||
|
|
@ -277,3 +351,4 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Renderer/DebugOff.hpp>
|
#include <Nazara/Renderer/DebugOff.hpp>
|
||||||
|
#include "Sprite.hpp"
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
LuaInstance();
|
LuaInstance();
|
||||||
LuaInstance(const LuaInstance&) = delete;
|
LuaInstance(const LuaInstance&) = delete;
|
||||||
LuaInstance(LuaInstance&&) = delete; ///TODO
|
inline LuaInstance(LuaInstance&& instance) noexcept;
|
||||||
~LuaInstance();
|
~LuaInstance();
|
||||||
|
|
||||||
void ArgCheck(bool condition, unsigned int argNum, const char* error);
|
void ArgCheck(bool condition, unsigned int argNum, const char* error);
|
||||||
|
|
@ -92,16 +92,16 @@ namespace Nz
|
||||||
LuaType GetField(const String& fieldName, int tableIndex = -1) const;
|
LuaType GetField(const String& fieldName, int tableIndex = -1) const;
|
||||||
LuaType GetGlobal(const char* name) const;
|
LuaType GetGlobal(const char* name) const;
|
||||||
LuaType GetGlobal(const String& name) const;
|
LuaType GetGlobal(const String& name) const;
|
||||||
lua_State* GetInternalState() const;
|
inline lua_State* GetInternalState() const;
|
||||||
String GetLastError() const;
|
inline String GetLastError() const;
|
||||||
UInt32 GetMemoryLimit() const;
|
inline std::size_t GetMemoryLimit() const;
|
||||||
UInt32 GetMemoryUsage() const;
|
inline std::size_t GetMemoryUsage() const;
|
||||||
LuaType GetMetatable(const char* tname) const;
|
LuaType GetMetatable(const char* tname) const;
|
||||||
LuaType GetMetatable(const String& tname) const;
|
LuaType GetMetatable(const String& tname) const;
|
||||||
bool GetMetatable(int index) const;
|
bool GetMetatable(int index) const;
|
||||||
unsigned int GetStackTop() const;
|
unsigned int GetStackTop() const;
|
||||||
LuaType GetTable(int index = -2) const;
|
LuaType GetTable(int index = -2) const;
|
||||||
UInt32 GetTimeLimit() const;
|
inline UInt32 GetTimeLimit() const;
|
||||||
LuaType GetType(int index) const;
|
LuaType GetType(int index) const;
|
||||||
const char* GetTypeName(LuaType type) const;
|
const char* GetTypeName(LuaType type) const;
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ namespace Nz
|
||||||
void PushString(const char* str) const;
|
void PushString(const char* str) const;
|
||||||
void PushString(const char* str, std::size_t size) const;
|
void PushString(const char* str, std::size_t size) const;
|
||||||
void PushString(const String& str) 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* PushUserdata(std::size_t size) const;
|
||||||
void PushValue(int index) const;
|
void PushValue(int index) const;
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ namespace Nz
|
||||||
void* ToUserdata(int index, const String& tname) const;
|
void* ToUserdata(int index, const String& tname) const;
|
||||||
|
|
||||||
LuaInstance& operator=(const LuaInstance&) = delete;
|
LuaInstance& operator=(const LuaInstance&) = delete;
|
||||||
LuaInstance& operator=(LuaInstance&&) = delete; ///TODO
|
inline LuaInstance& operator=(LuaInstance&& instance) noexcept;
|
||||||
|
|
||||||
static int GetIndexOfUpValue(int upValue);
|
static int GetIndexOfUpValue(int upValue);
|
||||||
static LuaInstance* GetInstance(lua_State* state);
|
static LuaInstance* GetInstance(lua_State* state);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,58 @@
|
||||||
|
|
||||||
namespace Nz
|
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 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);
|
||||||
|
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
|
// Functions args
|
||||||
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag<bool>)
|
inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag<bool>)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -45,20 +45,21 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
// 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)
|
typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2(T number)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed");
|
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
|
// Masking and shifting bits to the right (to bring it back to 32 bits)
|
||||||
// ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting
|
|
||||||
|
// 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))
|
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<UInt32>::max()) << i*8;
|
T mask = T(std::numeric_limits<UInt32>::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<UInt32>(val);
|
unsigned int log2 = IntegralLog2<UInt32>(val);
|
||||||
if (log2)
|
if (log2)
|
||||||
return log2 + i*8;
|
return log2 + i*8;
|
||||||
|
|
@ -75,20 +76,20 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
// 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)
|
typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2Pot(T number)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed");
|
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
|
// The algorithm for logarithm in base 2 only works with numbers greather than 32 bits
|
||||||
// ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting
|
// This code subdivides the biggest number into 32 bits ones
|
||||||
for (int i = sizeof(T)-sizeof(UInt32); i >= 0; i -= sizeof(UInt32))
|
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<UInt32>::max()) << i*8;
|
T mask = T(std::numeric_limits<UInt32>::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<UInt32>(val);
|
unsigned int log2 = IntegralLog2Pot<UInt32>(val);
|
||||||
if (log2 || val == 1)
|
if (log2 || val == 1)
|
||||||
return log2 + i*8;
|
return log2 + i*8;
|
||||||
|
|
@ -99,7 +100,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup math
|
* \ingroup math
|
||||||
* \brief Approaches the objective, beginning with value and with increment
|
* \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
|
* \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
|
* \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
|
* \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
|
* \brief Gets number of bits set in the number
|
||||||
* \return The number of bits set to 1
|
* \return The number of bits set to 1
|
||||||
*
|
*
|
||||||
|
|
@ -160,7 +161,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup math
|
* \ingroup math
|
||||||
* \brief Converts degree to radian
|
* \brief Converts degree to radian
|
||||||
* \return The representation in radian of the angle in degree (0..2*pi)
|
* \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
|
* \brief Gets the unit from degree and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||||
* \return Express the degrees
|
* \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
|
* \brief Gets the unit from radian and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||||
* \return Express the radians
|
* \return Express the radians
|
||||||
*
|
*
|
||||||
|
|
@ -210,7 +211,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup math
|
* \ingroup math
|
||||||
* \brief Gets the nearest power of two for the number
|
* \brief Gets the nearest power of two for the number
|
||||||
* \return First power of two containing 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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits + 1 for the dot
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits + 1 for the dot
|
* \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
|
* \brief Gets the number of digits to represent the number in base 10
|
||||||
* \return Number of digits + 1 for the dot
|
* \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
|
* \brief Gets the log in base 2 of integral number
|
||||||
* \return Log of the number (floor)
|
* \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 !
|
* \brief Gets the log in base 2 of integral number, only works for power of two !
|
||||||
* \return Log of the number
|
* \return Log of the number
|
||||||
*
|
*
|
||||||
|
|
@ -426,7 +427,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup math
|
* \ingroup math
|
||||||
* \brief Gets the power of integrals
|
* \brief Gets the power of integrals
|
||||||
* \return base^exponent for integral
|
* \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
|
* \brief Interpolates the value to other one with a factor of interpolation
|
||||||
* \return A new value which is the interpolation of two values
|
* \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
|
* \brief Multiplies X and Y, then add Z
|
||||||
* \return The result of X * Y + Z
|
* \return The result of X * Y + Z
|
||||||
*
|
*
|
||||||
|
|
@ -508,7 +509,7 @@ namespace Nz
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup math
|
* \ingroup math
|
||||||
* \brief Normalizes the angle
|
* \brief Normalizes the angle
|
||||||
* \return Normalized value between 0..2*(pi if radian or 180 if degrees)
|
* \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
|
* \brief Checks whether two numbers are equal
|
||||||
* \return true if they are equal within a certain epsilon
|
* \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
|
* \brief Checks whether two numbers are equal
|
||||||
* \return true if they are equal within the max difference
|
* \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
|
* \brief Converts the number to String
|
||||||
* \return String representation of the number
|
* \return String representation of the number
|
||||||
*
|
*
|
||||||
|
|
@ -623,7 +624,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup math
|
* \ingroup math
|
||||||
* \brief Converts radian to degree
|
* \brief Converts radian to degree
|
||||||
* \return The representation in degree of the angle in radian (0..360)
|
* \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
|
* \brief Converts the string to number
|
||||||
* \return Number which is represented by the string
|
* \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
|
* \brief Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||||
* \return Express in degrees
|
* \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
|
* \brief Gets the radian from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN
|
||||||
* \return Express in radians
|
* \return Express in radians
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ namespace Nz
|
||||||
class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom
|
class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CompoundGeom(PhysGeom** geoms, unsigned int geomCount);
|
CompoundGeom(PhysGeom** geoms, std::size_t geomCount);
|
||||||
|
|
||||||
const std::vector<PhysGeomRef>& GetGeoms() const;
|
const std::vector<PhysGeomRef>& GetGeoms() const;
|
||||||
GeomType GetType() const override;
|
GeomType GetType() const override;
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,15 @@
|
||||||
#include <Nazara/Utility/Config.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
#include <Nazara/Utility/Sequence.hpp>
|
#include <Nazara/Utility/Sequence.hpp>
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
struct NAZARA_UTILITY_API AnimationParams : ResourceParameters
|
struct NAZARA_UTILITY_API AnimationParams : ResourceParameters
|
||||||
{
|
{
|
||||||
// La frame de fin à charger
|
// La frame de fin à charger
|
||||||
unsigned int endFrame = std::numeric_limits<unsigned int>::max();
|
UInt32 endFrame = 0xFFFFFFFF;
|
||||||
// La frame de début à charger
|
// La frame de début à charger
|
||||||
unsigned int startFrame = 0;
|
UInt32 startFrame = 0;
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
};
|
};
|
||||||
|
|
@ -57,27 +56,27 @@ namespace Nz
|
||||||
~Animation();
|
~Animation();
|
||||||
|
|
||||||
bool AddSequence(const Sequence& sequence);
|
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 Destroy();
|
||||||
|
|
||||||
void EnableLoopPointInterpolation(bool loopPointInterpolation);
|
void EnableLoopPointInterpolation(bool loopPointInterpolation);
|
||||||
|
|
||||||
unsigned int GetFrameCount() const;
|
UInt32 GetFrameCount() const;
|
||||||
unsigned int GetJointCount() const;
|
UInt32 GetJointCount() const;
|
||||||
Sequence* GetSequence(const String& sequenceName);
|
Sequence* GetSequence(const String& sequenceName);
|
||||||
Sequence* GetSequence(unsigned int index);
|
Sequence* GetSequence(UInt32 index);
|
||||||
const Sequence* GetSequence(const String& sequenceName) const;
|
const Sequence* GetSequence(const String& sequenceName) const;
|
||||||
const Sequence* GetSequence(unsigned int index) const;
|
const Sequence* GetSequence(UInt32 index) const;
|
||||||
unsigned int GetSequenceCount() const;
|
UInt32 GetSequenceCount() const;
|
||||||
int GetSequenceIndex(const String& sequenceName) const;
|
UInt32 GetSequenceIndex(const String& sequenceName) const;
|
||||||
SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0);
|
SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0);
|
||||||
const SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const;
|
const SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0) const;
|
||||||
AnimationType GetType() const;
|
AnimationType GetType() const;
|
||||||
|
|
||||||
bool HasSequence(const String& sequenceName) const;
|
bool HasSequence(const String& sequenceName) const;
|
||||||
bool HasSequence(unsigned int index = 0) const;
|
bool HasSequence(UInt32 index = 0) const;
|
||||||
|
|
||||||
bool IsLoopPointInterpolationEnabled() const;
|
bool IsLoopPointInterpolationEnabled() const;
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
@ -87,7 +86,7 @@ namespace Nz
|
||||||
bool LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams());
|
bool LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams());
|
||||||
|
|
||||||
void RemoveSequence(const String& sequenceName);
|
void RemoveSequence(const String& sequenceName);
|
||||||
void RemoveSequence(unsigned int index);
|
void RemoveSequence(UInt32 index);
|
||||||
|
|
||||||
template<typename... Args> static AnimationRef New(Args&&... args);
|
template<typename... Args> static AnimationRef New(Args&&... args);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// 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 <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/Signal.hpp>
|
||||||
|
#include <Nazara/Utility/Config.hpp>
|
||||||
|
#include <Nazara/Utility/Event.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
class EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EventHandler() = default;
|
||||||
|
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*/);
|
||||||
|
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 <Nazara/Utility/EventHandler.inl>
|
||||||
|
|
||||||
|
#endif // NAZARA_EVENTHANDLER_HPP
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
// 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 <Nazara/Utility/EventHandler.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
inline EventHandler::EventHandler(const EventHandler&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void EventHandler::Dispatch(const WindowEvent& event)
|
||||||
|
{
|
||||||
|
OnEvent(this, 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:
|
||||||
|
OnMouseButtonReleased(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 <Nazara/Utility/DebugOff.hpp>
|
||||||
|
|
@ -34,12 +34,12 @@ namespace Nz
|
||||||
|
|
||||||
struct Joint
|
struct Joint
|
||||||
{
|
{
|
||||||
|
Int32 parent;
|
||||||
Quaternionf bindOrient;
|
Quaternionf bindOrient;
|
||||||
String name;
|
String name;
|
||||||
Vector3f bindPos;
|
Vector3f bindPos;
|
||||||
int parent;
|
UInt32 flags;
|
||||||
unsigned int flags;
|
UInt32 index;
|
||||||
unsigned int index;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MD5AnimParser(Stream& stream);
|
MD5AnimParser(Stream& stream);
|
||||||
|
|
@ -47,12 +47,12 @@ namespace Nz
|
||||||
|
|
||||||
Ternary Check();
|
Ternary Check();
|
||||||
|
|
||||||
std::size_t GetAnimatedComponentCount() const;
|
UInt32 GetAnimatedComponentCount() const;
|
||||||
const Frame* GetFrames() const;
|
const Frame* GetFrames() const;
|
||||||
std::size_t GetFrameCount() const;
|
UInt32 GetFrameCount() const;
|
||||||
std::size_t GetFrameRate() const;
|
UInt32 GetFrameRate() const;
|
||||||
const Joint* GetJoints() const;
|
const Joint* GetJoints() const;
|
||||||
std::size_t GetJointCount() const;
|
UInt32 GetJointCount() const;
|
||||||
|
|
||||||
bool Parse();
|
bool Parse();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
struct Joint
|
struct Joint
|
||||||
{
|
{
|
||||||
|
Int32 parent;
|
||||||
Quaternionf bindOrient;
|
Quaternionf bindOrient;
|
||||||
String name;
|
String name;
|
||||||
Vector3f bindPos;
|
Vector3f bindPos;
|
||||||
int parent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Vector3ui Triangle;
|
typedef Vector3ui Triangle;
|
||||||
|
|
@ -58,9 +58,9 @@ namespace Nz
|
||||||
Ternary Check();
|
Ternary Check();
|
||||||
|
|
||||||
const Joint* GetJoints() const;
|
const Joint* GetJoints() const;
|
||||||
std::size_t GetJointCount() const;
|
UInt32 GetJointCount() const;
|
||||||
const Mesh* GetMeshes() const;
|
const Mesh* GetMeshes() const;
|
||||||
std::size_t GetMeshCount() const;
|
UInt32 GetMeshCount() const;
|
||||||
|
|
||||||
bool Parse();
|
bool Parse();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,43 +31,43 @@ namespace Nz
|
||||||
|
|
||||||
inline String* GetMaterials();
|
inline String* GetMaterials();
|
||||||
inline const String* GetMaterials() const;
|
inline const String* GetMaterials() const;
|
||||||
inline unsigned int GetMaterialCount() const;
|
inline UInt32 GetMaterialCount() const;
|
||||||
inline Mesh* GetMeshes();
|
inline Mesh* GetMeshes();
|
||||||
inline const Mesh* GetMeshes() const;
|
inline const Mesh* GetMeshes() const;
|
||||||
inline unsigned int GetMeshCount() const;
|
inline UInt32 GetMeshCount() const;
|
||||||
inline const String& GetMtlLib() const;
|
inline const String& GetMtlLib() const;
|
||||||
inline Vector3f* GetNormals();
|
inline Vector3f* GetNormals();
|
||||||
inline const Vector3f* GetNormals() const;
|
inline const Vector3f* GetNormals() const;
|
||||||
inline unsigned int GetNormalCount() const;
|
inline UInt32 GetNormalCount() const;
|
||||||
inline Vector4f* GetPositions();
|
inline Vector4f* GetPositions();
|
||||||
inline const Vector4f* GetPositions() const;
|
inline const Vector4f* GetPositions() const;
|
||||||
inline unsigned int GetPositionCount() const;
|
inline UInt32 GetPositionCount() const;
|
||||||
inline Vector3f* GetTexCoords();
|
inline Vector3f* GetTexCoords();
|
||||||
inline const Vector3f* GetTexCoords() const;
|
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;
|
bool Save(Stream& stream) const;
|
||||||
|
|
||||||
inline String* SetMaterialCount(std::size_t materialCount);
|
inline String* SetMaterialCount(UInt32 materialCount);
|
||||||
inline Mesh* SetMeshCount(std::size_t meshCount);
|
inline Mesh* SetMeshCount(UInt32 meshCount);
|
||||||
inline void SetMtlLib(const String& mtlLib);
|
inline void SetMtlLib(const String& mtlLib);
|
||||||
inline Vector3f* SetNormalCount(std::size_t normalCount);
|
inline Vector3f* SetNormalCount(UInt32 normalCount);
|
||||||
inline Vector4f* SetPositionCount(std::size_t positionCount);
|
inline Vector4f* SetPositionCount(UInt32 positionCount);
|
||||||
inline Vector3f* SetTexCoordCount(std::size_t texCoordCount);
|
inline Vector3f* SetTexCoordCount(UInt32 texCoordCount);
|
||||||
|
|
||||||
struct Face
|
struct Face
|
||||||
{
|
{
|
||||||
std::size_t firstVertex;
|
UInt32 firstVertex;
|
||||||
std::size_t vertexCount;
|
UInt32 vertexCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FaceVertex
|
struct FaceVertex
|
||||||
{
|
{
|
||||||
std::size_t normal;
|
UInt32 normal;
|
||||||
std::size_t position;
|
UInt32 position;
|
||||||
std::size_t texCoord;
|
UInt32 texCoord;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Mesh
|
struct Mesh
|
||||||
|
|
@ -75,7 +75,7 @@ namespace Nz
|
||||||
std::vector<Face> faces;
|
std::vector<Face> faces;
|
||||||
std::vector<FaceVertex> vertices;
|
std::vector<FaceVertex> vertices;
|
||||||
String name;
|
String name;
|
||||||
std::size_t material;
|
UInt32 material;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ namespace Nz
|
||||||
return m_materials.data();
|
return m_materials.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int OBJParser::GetMaterialCount() const
|
inline UInt32 OBJParser::GetMaterialCount() const
|
||||||
{
|
{
|
||||||
return m_materials.size();
|
return static_cast<UInt32>(m_materials.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline OBJParser::Mesh* OBJParser::GetMeshes()
|
inline OBJParser::Mesh* OBJParser::GetMeshes()
|
||||||
|
|
@ -42,9 +42,9 @@ namespace Nz
|
||||||
return m_meshes.data();
|
return m_meshes.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int OBJParser::GetMeshCount() const
|
inline UInt32 OBJParser::GetMeshCount() const
|
||||||
{
|
{
|
||||||
return m_meshes.size();
|
return static_cast<UInt32>(m_meshes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const String& OBJParser::GetMtlLib() const
|
inline const String& OBJParser::GetMtlLib() const
|
||||||
|
|
@ -62,9 +62,9 @@ namespace Nz
|
||||||
return m_normals.data();
|
return m_normals.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int OBJParser::GetNormalCount() const
|
inline UInt32 OBJParser::GetNormalCount() const
|
||||||
{
|
{
|
||||||
return m_normals.size();
|
return static_cast<UInt32>(m_normals.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector4f* OBJParser::GetPositions()
|
inline Vector4f* OBJParser::GetPositions()
|
||||||
|
|
@ -77,9 +77,9 @@ namespace Nz
|
||||||
return m_positions.data();
|
return m_positions.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int OBJParser::GetPositionCount() const
|
inline UInt32 OBJParser::GetPositionCount() const
|
||||||
{
|
{
|
||||||
return m_positions.size();
|
return static_cast<UInt32>(m_positions.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector3f* OBJParser::GetTexCoords()
|
inline Vector3f* OBJParser::GetTexCoords()
|
||||||
|
|
@ -92,18 +92,18 @@ namespace Nz
|
||||||
return m_texCoords.data();
|
return m_texCoords.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int OBJParser::GetTexCoordCount() const
|
inline UInt32 OBJParser::GetTexCoordCount() const
|
||||||
{
|
{
|
||||||
return m_texCoords.size();
|
return static_cast<UInt32>(m_texCoords.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline String* OBJParser::SetMaterialCount(std::size_t materialCount)
|
inline String* OBJParser::SetMaterialCount(UInt32 materialCount)
|
||||||
{
|
{
|
||||||
m_materials.resize(materialCount);
|
m_materials.resize(materialCount);
|
||||||
return m_materials.data();
|
return m_materials.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount)
|
inline OBJParser::Mesh* OBJParser::SetMeshCount(UInt32 meshCount)
|
||||||
{
|
{
|
||||||
m_meshes.resize(meshCount);
|
m_meshes.resize(meshCount);
|
||||||
return m_meshes.data();
|
return m_meshes.data();
|
||||||
|
|
@ -114,19 +114,19 @@ namespace Nz
|
||||||
m_mtlLib = mtlLib;
|
m_mtlLib = mtlLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount)
|
inline Vector3f* OBJParser::SetNormalCount(UInt32 normalCount)
|
||||||
{
|
{
|
||||||
m_normals.resize(normalCount);
|
m_normals.resize(normalCount);
|
||||||
return m_normals.data();
|
return m_normals.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount)
|
inline Vector4f* OBJParser::SetPositionCount(UInt32 positionCount)
|
||||||
{
|
{
|
||||||
m_positions.resize(positionCount);
|
m_positions.resize(positionCount);
|
||||||
return m_positions.data();
|
return m_positions.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount)
|
inline Vector3f* OBJParser::SetTexCoordCount(UInt32 texCoordCount)
|
||||||
{
|
{
|
||||||
m_texCoords.resize(texCoordCount);
|
m_texCoords.resize(texCoordCount);
|
||||||
return m_texCoords.data();
|
return m_texCoords.data();
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Nz
|
||||||
SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams());
|
SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams());
|
||||||
void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams());
|
void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams());
|
||||||
|
|
||||||
bool CreateSkeletal(unsigned int jointCount);
|
bool CreateSkeletal(UInt32 jointCount);
|
||||||
bool CreateStatic();
|
bool CreateStatic();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
|
|
@ -95,23 +95,23 @@ namespace Nz
|
||||||
const Boxf& GetAABB() const;
|
const Boxf& GetAABB() const;
|
||||||
String GetAnimation() const;
|
String GetAnimation() const;
|
||||||
AnimationType GetAnimationType() const;
|
AnimationType GetAnimationType() const;
|
||||||
unsigned int GetJointCount() const;
|
UInt32 GetJointCount() const;
|
||||||
ParameterList& GetMaterialData(unsigned int index);
|
ParameterList& GetMaterialData(UInt32 index);
|
||||||
const ParameterList& GetMaterialData(unsigned int index) const;
|
const ParameterList& GetMaterialData(UInt32 index) const;
|
||||||
unsigned int GetMaterialCount() const;
|
UInt32 GetMaterialCount() const;
|
||||||
Skeleton* GetSkeleton();
|
Skeleton* GetSkeleton();
|
||||||
const Skeleton* GetSkeleton() const;
|
const Skeleton* GetSkeleton() const;
|
||||||
SubMesh* GetSubMesh(const String& identifier);
|
SubMesh* GetSubMesh(const String& identifier);
|
||||||
SubMesh* GetSubMesh(unsigned int index);
|
SubMesh* GetSubMesh(UInt32 index);
|
||||||
const SubMesh* GetSubMesh(const String& identifier) const;
|
const SubMesh* GetSubMesh(const String& identifier) const;
|
||||||
const SubMesh* GetSubMesh(unsigned int index) const;
|
const SubMesh* GetSubMesh(UInt32 index) const;
|
||||||
unsigned int GetSubMeshCount() const;
|
UInt32 GetSubMeshCount() const;
|
||||||
int GetSubMeshIndex(const String& identifier) const;
|
UInt32 GetSubMeshIndex(const String& identifier) const;
|
||||||
unsigned int GetTriangleCount() const;
|
UInt32 GetTriangleCount() const;
|
||||||
unsigned int GetVertexCount() const;
|
UInt32 GetVertexCount() const;
|
||||||
|
|
||||||
bool HasSubMesh(const String& identifier) const;
|
bool HasSubMesh(const String& identifier) const;
|
||||||
bool HasSubMesh(unsigned int index = 0) const;
|
bool HasSubMesh(UInt32 index = 0) const;
|
||||||
|
|
||||||
void InvalidateAABB() const;
|
void InvalidateAABB() const;
|
||||||
|
|
||||||
|
|
@ -125,14 +125,14 @@ namespace Nz
|
||||||
void Recenter();
|
void Recenter();
|
||||||
|
|
||||||
void RemoveSubMesh(const String& identifier);
|
void RemoveSubMesh(const String& identifier);
|
||||||
void RemoveSubMesh(unsigned int index);
|
void RemoveSubMesh(UInt32 index);
|
||||||
|
|
||||||
bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams());
|
bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams());
|
||||||
bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams());
|
bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams());
|
||||||
|
|
||||||
void SetAnimation(const String& animationPath);
|
void SetAnimation(const String& animationPath);
|
||||||
void SetMaterialCount(unsigned int matCount);
|
void SetMaterialCount(UInt32 matCount);
|
||||||
void SetMaterialData(unsigned int matIndex, ParameterList data);
|
void SetMaterialData(UInt32 matIndex, ParameterList data);
|
||||||
|
|
||||||
void Transform(const Matrix4f& matrix);
|
void Transform(const Matrix4f& matrix);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ namespace Nz
|
||||||
struct Sequence
|
struct Sequence
|
||||||
{
|
{
|
||||||
String name;
|
String name;
|
||||||
unsigned int firstFrame;
|
UInt32 firstFrame;
|
||||||
unsigned int frameCount;
|
UInt32 frameCount;
|
||||||
unsigned int frameRate;
|
UInt32 frameRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SequenceJoint
|
struct SequenceJoint
|
||||||
|
|
|
||||||
|
|
@ -37,21 +37,21 @@ namespace Nz
|
||||||
Skeleton(const Skeleton& skeleton);
|
Skeleton(const Skeleton& skeleton);
|
||||||
~Skeleton();
|
~Skeleton();
|
||||||
|
|
||||||
bool Create(unsigned int jointCount);
|
bool Create(UInt32 jointCount);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
const Boxf& GetAABB() const;
|
const Boxf& GetAABB() const;
|
||||||
Joint* GetJoint(const String& jointName);
|
Joint* GetJoint(const String& jointName);
|
||||||
Joint* GetJoint(unsigned int index);
|
Joint* GetJoint(UInt32 index);
|
||||||
const Joint* GetJoint(const String& jointName) const;
|
const Joint* GetJoint(const String& jointName) const;
|
||||||
const Joint* GetJoint(unsigned int index) const;
|
const Joint* GetJoint(UInt32 index) const;
|
||||||
Joint* GetJoints();
|
Joint* GetJoints();
|
||||||
const Joint* GetJoints() const;
|
const Joint* GetJoints() const;
|
||||||
unsigned int GetJointCount() const;
|
UInt32 GetJointCount() const;
|
||||||
int GetJointIndex(const String& jointName) 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);
|
||||||
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;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,15 +39,15 @@ namespace Nz
|
||||||
virtual const Boxf& GetAABB() const = 0;
|
virtual const Boxf& GetAABB() const = 0;
|
||||||
virtual AnimationType GetAnimationType() const = 0;
|
virtual AnimationType GetAnimationType() const = 0;
|
||||||
virtual const IndexBuffer* GetIndexBuffer() const = 0;
|
virtual const IndexBuffer* GetIndexBuffer() const = 0;
|
||||||
unsigned int GetMaterialIndex() const;
|
UInt32 GetMaterialIndex() const;
|
||||||
const Mesh* GetParent() const;
|
const Mesh* GetParent() const;
|
||||||
PrimitiveMode GetPrimitiveMode() const;
|
PrimitiveMode GetPrimitiveMode() const;
|
||||||
unsigned int GetTriangleCount() const;
|
UInt32 GetTriangleCount() const;
|
||||||
virtual unsigned int GetVertexCount() const = 0;
|
virtual UInt32 GetVertexCount() const = 0;
|
||||||
|
|
||||||
virtual bool IsAnimated() const = 0;
|
virtual bool IsAnimated() const = 0;
|
||||||
|
|
||||||
void SetMaterialIndex(unsigned int matIndex);
|
void SetMaterialIndex(UInt32 matIndex);
|
||||||
void SetPrimitiveMode(PrimitiveMode mode);
|
void SetPrimitiveMode(PrimitiveMode mode);
|
||||||
|
|
||||||
// Signals:
|
// Signals:
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Nz
|
||||||
protected:
|
protected:
|
||||||
PrimitiveMode m_primitiveMode;
|
PrimitiveMode m_primitiveMode;
|
||||||
const Mesh* m_parent;
|
const Mesh* m_parent;
|
||||||
unsigned int m_matIndex;
|
UInt32 m_matIndex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraError("Attribute 0x" + String::Number(component, 16) + " is not enabled");
|
NazaraError("Attribute 0x" + String::Number(component, 16) + " is not enabled");
|
||||||
return SparsePtr<T>();
|
return SparsePtr<T>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#include <Nazara/Utility/DebugOff.hpp>
|
#include <Nazara/Utility/DebugOff.hpp>
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue