From 9a11c39fa7417406177eda1a604640300221f851 Mon Sep 17 00:00:00 2001 From: Tao Schreiner Date: Wed, 27 Apr 2016 03:00:35 +0200 Subject: [PATCH 001/383] Cleaner looking features page Former-commit-id: 85ab37bc15b1bf4d64261304b4989c8d7ccab9de --- build/scripts/features/index_template.html | 144 +++++++------ build/scripts/features/style.css | 227 +++++++++++---------- 2 files changed, 190 insertions(+), 181 deletions(-) diff --git a/build/scripts/features/index_template.html b/build/scripts/features/index_template.html index d06aeb4d9..852811a4c 100644 --- a/build/scripts/features/index_template.html +++ b/build/scripts/features/index_template.html @@ -1,75 +1,71 @@ - - - - - - Avancement de Nazara - - -

- Nazara Engine -
-
- Retrouvez le moteur sur GitHub ! -
- Dépôt Github

- Ou venez vous renseigner sur les topics dédiés à Nazara présents sur plusieurs site webs: -
- OpenClassrooms ou Progdupeupl ou ZesteDeSavoir -
-
- ... ou pourquoi ne pas venir faire un tour sur le forum dédié au moteur ? -

-
-

Fonctionnalités de Nazara

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

Important:


- Afin de faciliter la mise à jour, la page que vous voyez ici a été généré automatiquement par un script Lua, ce qui m'oblige néanmoins à encoder les fonctionnalités de chaque module dans un premier temps.
- C'est un travail assez long (pour vous donner une idée, les données du noyau représentent un fichier de 200 lignes), et il n'est pas encore complet, c'est pourquoi des modules manquent sur cette page.
- Gardez donc à l'esprit que le moteur possède plus de fonctionnalités que ce qui est décrit actuellement sur cette page.
-
- Oh et bien sûr je ne suis pas concepteur de site web, c'est pourquoi cette page est moche (j'ai essayé de minimiser les dégats).
- Si vous sentez en vous l'irrésistible envie d'améliorer cette page, sachez que votre aide sera grandement appréciée (vous pouvez me contacter via le lien de votre choix plus haut). -
-
- Le pourcentage indiqué est calculé automatiquement en fonction des fonctionnalités,
cela signifie qu'une fonctionnalité présente sera comptée à 100% à partir du moment où son implémentation de base est considérée fonctionnelle,
cela n'est donc pas une assurance qu'aucun bug n'existe concernant cette fonctionnalité (cependant cela signifie que la fonctionnalité est utilisable).
- Et bien entendu, un module ou une fonctionnalité ayant atteint les 100% peut toujours évoluer par la suite. -
-
- - - - - - - - - - %MODULELIST% - -
Sommaire
ModuleAvancement
-
- %MODULEDESCRIPTION% -
-
- - - - - - - - - - %MODULELIST% - -
Sommaire
ModulePourcentage
-
- + + + + + + Avancement de Nazara + + +
+ Nazara Engine + +
+ + Retrouvez le moteur sur GitHub !
+ Dépôt GitHub

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

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

Fonctionnalités de Nazara

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

Important:

+

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

+ +

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

+ +

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

+ +
+ + + + + + + + + + + %MODULELIST% + +
Sommaire
ModuleAvancement
+ + %MODULEDESCRIPTION% +
+ + + + + + + + + + %MODULELIST% + +
Sommaire
ModulePourcentage
+
+ \ No newline at end of file diff --git a/build/scripts/features/style.css b/build/scripts/features/style.css index 8a3399bad..189b2a090 100644 --- a/build/scripts/features/style.css +++ b/build/scripts/features/style.css @@ -1,108 +1,121 @@ -/* Je ne suis pas développeur HTML/CSS, je dois y toucher une fois l'an, désolé pour les quelques atrocités que vous pourrez trouver ici */ - -body -{ - background-color: black; - color: white; -} - -a -{ - color: #007ACC; -} - -a:hover -{ - color: lightblue; -} - -h1 -{ - display: inline; -} - -h2 -{ - display: inline; - text-decoration: underline; -} - -h4 -{ - text-decoration: underline; -} - -ol -{ - list-style-type: none; -} - -table -{ - border-collapse: collapse; - text-align: center; - display: inline-block; - border: white groove; - border-radius: 10px; - box-shadow: 0px 0px 10px lightblue; -} - -th -{ - text-shadow: 2px 2px 4px black; -} - -tr -{ - border: 1px solid white; -} - -tbody tr:hover -{ - text-shadow: 0px 0px 4px white; -} - -.centre -{ - text-align: center; -} - -.description -{ - margin-left: 20px; -} - -.lastupdate -{ - font-size: x-large; - font-weight: bold; - color: yellow; -} - -.module -{ -} - -.modulename -{ - font-size: x-large; - font-weight: bold; - text-shadow: 2px 2px 10px #007ACC; -} - -.note -{ - margin-left: 20px; - color: #007ACC; -} - -.notedesc -{ - color: rgb(200, 200, 255); -} - -.portability -{ - margin-left: 20px; - color: red; +/* Je ne suis pas développeur HTML/CSS, je dois y toucher une fois l'an, désolé pour les quelques atrocités que vous pourrez trouver ici */ + +body +{ + font-family: sans-serif; + text-align: center; + margin: 0; + background-color: #f1f1f1; +} + +#englob { + display: block; + margin-left: auto; + margin-right: auto; + background-color: white; + width: 50%; + min-width: 765px; + padding: 0 20px; +} + +hr { + height: 0; + border: 0; + border-top: 1px solid #eee; +} + +a +{ + color: #007ACC; +} + +a:hover +{ + color: lightblue; +} + +h1 +{ + display: inline; +} + +h2 +{ + display: inline; + text-decoration: underline; +} + +h4 +{ + text-decoration: underline; +} + +p { + text-align: justify; +} + +ol +{ + list-style-type: none; +} + +table +{ + border-collapse: collapse; + text-align: center; + display: inline-block; + border: white groove; + border-radius: 10px; + box-shadow: 0px 0px 10px lightblue; +} + +th +{ + text-shadow: 2px 2px 4px black; +} + +tr +{ + border: 1px solid white; +} + +tbody tr:hover +{ + text-shadow: 0px 0px 4px white; +} + +.description +{ + margin-left: 20px; +} + +.lastupdate +{ + font-size: x-large; + font-weight: bold; + color: #f1c40f; +} + +.modulename +{ + font-size: x-large; + font-weight: bold; + text-shadow: 2px 2px 10px #007ACC; +} + +.note +{ + margin-left: 20px; + color: #007ACC; +} + +.notedesc +{ + color: rgb(200, 200, 255); +} + +.portability +{ + margin-left: 20px; + color: red; } \ No newline at end of file From 6d824109f318847ea8c6d1ccac94a913cabea98c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Apr 2016 12:44:34 +0200 Subject: [PATCH 002/383] Core/ParameterList: Add support for color values and updated documentation Former-commit-id: 4cd9faf2fe035b946afa1ba15243bdcf3255716a --- include/Nazara/Core/Enums.hpp | 1 + include/Nazara/Core/ParameterList.hpp | 8 +- src/Nazara/Core/ParameterList.cpp | 320 ++++++++++++++++---------- 3 files changed, 209 insertions(+), 120 deletions(-) diff --git a/include/Nazara/Core/Enums.hpp b/include/Nazara/Core/Enums.hpp index 02039811b..7a5c161ab 100644 --- a/include/Nazara/Core/Enums.hpp +++ b/include/Nazara/Core/Enums.hpp @@ -93,6 +93,7 @@ namespace Nz enum ParameterType { ParameterType_Boolean, + ParameterType_Color, ParameterType_Float, ParameterType_Integer, ParameterType_None, diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index 2475185d7..119d05cca 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -8,6 +8,7 @@ #define NAZARA_PARAMETERLIST_HPP #include +#include #include #include #include @@ -27,6 +28,7 @@ namespace Nz void Clear(); bool GetBooleanParameter(const String& name, bool* value) const; + bool GetColorParameter(const String& name, Color* value) const; bool GetFloatParameter(const String& name, float* value) const; bool GetIntegerParameter(const String& name, int* value) const; bool GetParameterType(const String& name, ParameterType* type) const; @@ -39,13 +41,14 @@ namespace Nz void RemoveParameter(const String& name); void SetParameter(const String& name); + void SetParameter(const String& name, const Color& value); void SetParameter(const String& name, const String& value); void SetParameter(const String& name, const char* value); - void SetParameter(const String& name, void* value); - void SetParameter(const String& name, void* value, Destructor destructor); void SetParameter(const String& name, bool value); void SetParameter(const String& name, float value); void SetParameter(const String& name, int value); + void SetParameter(const String& name, void* value); + void SetParameter(const String& name, void* value, Destructor destructor); ParameterList& operator=(const ParameterList& list); ParameterList& operator=(ParameterList&&) = default; @@ -79,6 +82,7 @@ namespace Nz float floatVal; int intVal; void* ptrVal; + Color colorVal; String stringVal; UserdataValue* userdataVal; }; diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index f9a24d4cc..91426a0b7 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -22,7 +22,6 @@ namespace Nz /*! * \brief Constructs a ParameterList object by copy */ - ParameterList::ParameterList(const ParameterList& list) { operator=(list); @@ -31,16 +30,14 @@ namespace Nz /*! * \brief Destructs the object and clears */ - ParameterList::~ParameterList() { Clear(); } /*! - * \brief Clears the list of parameters + * \brief Clears all the parameters */ - void ParameterList::Clear() { for (auto it = m_parameters.begin(); it != m_parameters.end(); ++it) @@ -50,17 +47,18 @@ namespace Nz } /*! - * \brief Gets a boolean parameter by name - * \return true if success + * \brief Gets a parameter as a boolean + * \return true if the parameter could be represented as a boolean * - * \param name Name of the variable - * \param value Value to set + * \param name Name of the parameter + * \param value Pointer to a boolean to hold the retrieved value * - * \remark Produces a NazaraAssert if pointer is invalid - * \remark Produces a silent NazaraError if name is not a variable - * \remark Produces a silent NazaraError if value could not be convertible + * \remark value must be a valid pointer + * \remark In case of failure, the variable pointed by value keep its value + * \remark If the parameter is not a boolean, a conversion will be performed, compatibles types are: + Integer: 0 is interpreted as false, any other value is interpreted as true + String: Conversion obeys the rule as described by String::ToBool */ - bool ParameterList::GetBooleanParameter(const String& name, bool* value) const { NazaraAssert(value, "Invalid pointer"); @@ -85,17 +83,17 @@ namespace Nz return true; case ParameterType_String: + { + bool converted; + if (it->second.value.stringVal.ToBool(&converted, String::CaseInsensitive)) { - bool converted; - if (it->second.value.stringVal.ToBool(&converted, String::CaseInsensitive)) - { - *value = converted; - return true; - } - - break; + *value = converted; + return true; } + break; + } + case ParameterType_Float: case ParameterType_None: case ParameterType_Pointer: @@ -108,17 +106,62 @@ namespace Nz } /*! - * \brief Gets a float parameter by name - * \return true if success + * \brief Gets a parameter as a color + * \return true if the parameter could be represented as a color * - * \param name Name of the variable - * \param value Value to set + * \param name Name of the parameter + * \param value Pointer to a color to hold the retrieved value * - * \remark Produces a NazaraAssert if pointer is invalid - * \remark Produces a silent NazaraError if name is not a variable - * \remark Produces a silent NazaraError if value could not be convertible + * \remark value must be a valid pointer + * \remark In case of failure, the variable pointed by value keep its value + * \remark If the parameter is not a color, the function fails */ + bool ParameterList::GetColorParameter(const String& name, Color* value) const + { + NazaraAssert(value, "Invalid pointer"); + ErrorFlags flags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled); + + auto it = m_parameters.find(name); + if (it == m_parameters.end()) + { + NazaraError("Parameter \"" + name + "\" is not present"); + return false; + } + + switch (it->second.type) + { + case ParameterType_Color: + *value = it->second.value.colorVal; + return true; + + case ParameterType_Boolean: + case ParameterType_Integer: + case ParameterType_String: + case ParameterType_Float: + case ParameterType_None: + case ParameterType_Pointer: + case ParameterType_Userdata: + break; + } + + NazaraError("Parameter value is not representable as a color"); + return false; + } + + /*! + * \brief Gets a parameter as a float + * \return true if the parameter could be represented as a float + * + * \param name Name of the parameter + * \param value Pointer to a float to hold the retrieved value + * + * \remark value must be a valid pointer + * \remark In case of failure, the variable pointed by value keep its value + * \remark If the parameter is not a float, a conversion will be performed, compatibles types are: + Integer: The integer value is converted to its float representation + String: Conversion obeys the rule as described by String::ToDouble + */ bool ParameterList::GetFloatParameter(const String& name, float* value) const { NazaraAssert(value, "Invalid pointer"); @@ -164,19 +207,21 @@ namespace Nz NazaraError("Parameter value is not representable as a float"); return false; } - + /*! - * \brief Gets a integer parameter by name - * \return true if success + * \brief Gets a parameter as an integer + * \return true if the parameter could be represented as an integer * - * \param name Name of the variable - * \param value Value to set + * \param name Name of the parameter + * \param value Pointer to an integer to hold the retrieved value * - * \remark Produces a NazaraAssert if pointer is invalid - * \remark Produces a silent NazaraError if name is not a variable - * \remark Produces a silent NazaraError if value could not be convertible + * \remark value must be a valid pointer + * \remark In case of failure, the variable pointed by value keep its value + * \remark If the parameter is not a float, a conversion will be performed, compatibles types are: + Boolean: The boolean is represented as 1 if true and 0 if false + Float: The floating-point value is truncated and converted to a integer + String: Conversion obeys the rule as described by String::ToInteger but fails if the value could not be represented as a int */ - bool ParameterList::GetIntegerParameter(const String& name, int* value) const { NazaraAssert(value, "Invalid pointer"); @@ -229,15 +274,14 @@ namespace Nz } /*! - * \brief Gets a parameter type by name - * \return true if the parameter is present + * \brief Gets a parameter type + * \return true if the parameter is present, its type being written to type * * \param name Name of the variable - * \param type Pointer to a variable to hold result + * \param type Pointer to a variable to hold the result * - * \remark Produces a NazaraAssert if type is invalid + * \remark type must be a valid pointer to a ParameterType variable */ - bool ParameterList::GetParameterType(const String& name, ParameterType* type) const { NazaraAssert(type, "Invalid pointer"); @@ -252,17 +296,17 @@ namespace Nz } /*! - * \brief Gets a pointer parameter by name - * \return true if success + * \brief Gets a parameter as a pointer + * \return true if the parameter could be represented as a pointer * - * \param name Name of the variable - * \param value Value to set + * \param name Name of the parameter + * \param value Pointer to a pointer to hold the retrieved value * - * \remark Produces a NazaraAssert if pointer is invalid - * \remark Produces a silent NazaraError if name is not a variable - * \remark Produces a silent NazaraError if value could not be convertible + * \remark value must be a valid pointer + * \remark In case of failure, the variable pointed by value keep its value + * \remark If the parameter is not a pointer, a conversion will be performed, compatibles types are: + Userdata: The pointer part of the userdata is returned */ - bool ParameterList::GetPointerParameter(const String& name, void** value) const { NazaraAssert(value, "Invalid pointer"); @@ -299,17 +343,23 @@ namespace Nz } /*! - * \brief Gets a string parameter by name - * \return true if success + * \brief Gets a parameter as a string + * \return true if the parameter could be represented as a string * - * \param name Name of the variable - * \param value Value to set + * \param name Name of the parameter + * \param value Pointer to a pointer to hold the retrieved value * - * \remark Produces a NazaraAssert if pointer is invalid - * \remark Produces a silent NazaraError if name is not a variable - * \remark Produces a silent NazaraError if value could not be convertible + * \remark value must be a valid pointer + * \remark In case of failure, the variable pointed by value keep its value + * \remark If the parameter is not a string, a conversion will be performed, all types are compatibles: + Boolean: Conversion obeys the rules of String::Boolean + Color: Conversion obeys the rules of Color::ToString + Float: Conversion obeys the rules of String::Number + Integer: Conversion obeys the rules of String::Number + None: An empty string is returned + Pointer: Conversion obeys the rules of String::Pointer + Userdata: Conversion obeys the rules of String::Pointer */ - bool ParameterList::GetStringParameter(const String& name, String* value) const { NazaraAssert(value, "Invalid pointer"); @@ -329,6 +379,10 @@ namespace Nz *value = String::Boolean(it->second.value.boolVal); return true; + case ParameterType_Color: + *value = it->second.value.colorVal.ToString(); + return true; + case ParameterType_Float: *value = String::Number(it->second.value.floatVal); return true; @@ -357,19 +411,20 @@ namespace Nz NazaraInternalError("Parameter value is not valid"); return false; } - + /*! - * \brief Gets a user parameter by name - * \return true if success + * \brief Gets a parameter as an userdata + * \return true if the parameter could be represented as a userdata * - * \param name Name of the variable - * \param value Value to set + * \param name Name of the parameter + * \param value Pointer to a pointer to hold the retrieved value * - * \remark Produces a NazaraAssert if pointer is invalid - * \remark Produces a silent NazaraError if name is not a variable - * \remark Produces a silent NazaraError if value could not be convertible + * \remark value must be a valid pointer + * \remark In case of failure, the variable pointed by value keep its value + * \remark If the parameter is not an userdata, the function fails + * + * \see GetPointerParameter */ - bool ParameterList::GetUserdataParameter(const String& name, void** value) const { NazaraAssert(value, "Invalid pointer"); @@ -396,25 +451,24 @@ namespace Nz } /*! - * \brief Checks whether the parameter list has a parameter with that name + * \brief Checks whether the parameter list contains a parameter named `name` * \return true if found * * \param name Name of the parameter */ - bool ParameterList::HasParameter(const String& name) const { return m_parameters.find(name) != m_parameters.end(); } /*! - * \brief Removes the parameter with that name + * \brief Removes the parameter named `name` * - * Removes the parameter with that name, if not found, nothing is done + * Search for a parameter named `name` and remove it from the parameter list, freeing up its memory + * Nothing is done if the parameter is not present in the parameter list * * \param name Name of the parameter */ - void ParameterList::RemoveParameter(const String& name) { auto it = m_parameters.find(name); @@ -426,11 +480,12 @@ namespace Nz } /*! - * \brief Sets the parameter with the name to ParameterType_None + * \brief Sets a null parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter */ - void ParameterList::SetParameter(const String& name) { Parameter& parameter = CreateValue(name); @@ -438,12 +493,29 @@ namespace Nz } /*! - * \brief Sets the parameter with the name to the value + * \brief Sets a color parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter - * \param value Value of the parameter + * \param value The color value */ + void ParameterList::SetParameter(const String& name, const Color& value) + { + Parameter& parameter = CreateValue(name); + parameter.type = ParameterType_Color; + PlacementNew(¶meter.value.colorVal, value); + } + + /*! + * \brief Sets a string parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call + * + * \param name Name of the parameter + * \param value The string value + */ void ParameterList::SetParameter(const String& name, const String& value) { Parameter& parameter = CreateValue(name); @@ -453,12 +525,13 @@ namespace Nz } /*! - * \brief Sets the parameter with the name to the value + * \brief Sets a string parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter - * \param value Value of the parameter + * \param value The string value */ - void ParameterList::SetParameter(const String& name, const char* value) { Parameter& parameter = CreateValue(name); @@ -468,41 +541,13 @@ namespace Nz } /*! - * \brief Sets the parameter with the name to the value + * \brief Sets a boolean parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter - * \param value Value of the parameter + * \param value The boolean value */ - - void ParameterList::SetParameter(const String& name, void* value) - { - Parameter& parameter = CreateValue(name); - parameter.type = ParameterType_Pointer; - parameter.value.ptrVal = value; - } - - /*! - * \brief Sets the parameter with the name to the value - * - * \param name Name of the parameter - * \param value Value of the parameter - * \param destructor Destructor for dynamic variable - */ - - void ParameterList::SetParameter(const String& name, void* value, Destructor destructor) - { - Parameter& parameter = CreateValue(name); - parameter.type = ParameterType_Userdata; - parameter.value.userdataVal = new Parameter::UserdataValue(destructor, value); - } - - /*! - * \brief Sets the parameter with the name to the value - * - * \param name Name of the parameter - * \param value Value of the parameter - */ - void ParameterList::SetParameter(const String& name, bool value) { Parameter& parameter = CreateValue(name); @@ -511,12 +556,13 @@ namespace Nz } /*! - * \brief Sets the parameter with the name to the value + * \brief Sets a float parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter - * \param value Value of the parameter + * \param value The float value */ - void ParameterList::SetParameter(const String& name, float value) { Parameter& parameter = CreateValue(name); @@ -525,26 +571,63 @@ namespace Nz } /*! - * \brief Sets the parameter with the name to the value + * \brief Sets an integer parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter - * \param value Value of the parameter + * \param value The integer value */ - void ParameterList::SetParameter(const String& name, int value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Integer; parameter.value.intVal = value; } + + /*! + * \brief Sets a pointer parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call + * + * \param name Name of the parameter + * \param value The pointer value + * + * \remark This sets a raw pointer, this class takes no responsibility toward it, + if you wish to destroy the pointed variable along with the parameter list, you should set a userdata + */ + void ParameterList::SetParameter(const String& name, void* value) + { + Parameter& parameter = CreateValue(name); + parameter.type = ParameterType_Pointer; + parameter.value.ptrVal = value; + } /*! - * \brief Assigns the content of the other parameter list to this + * \brief Sets a userdata parameter named `name` + * + * If a parameter already exists with that name, it is destroyed and replaced by this call + * + * \param name Name of the parameter + * \param value The pointer value + * \param destructor The destructor function to be called upon parameter suppression + * + * \remark The destructor is called once when all copies of the userdata are destroyed, which means + you can safely copy the parameter list around. + */ + void ParameterList::SetParameter(const String& name, void* value, Destructor destructor) + { + Parameter& parameter = CreateValue(name); + parameter.type = ParameterType_Userdata; + parameter.value.userdataVal = new Parameter::UserdataValue(destructor, value); + } + + /*! + * \brief Copies the content of the other parameter list to this * \return A reference to this * * \param list List to assign */ - ParameterList& ParameterList::operator=(const ParameterList& list) { Clear(); @@ -627,6 +710,7 @@ namespace Nz } case ParameterType_Boolean: + case ParameterType_Color: case ParameterType_Float: case ParameterType_Integer: case ParameterType_None: From 9e3b99bb5ab0de6d8b992f8730d10b117df3fac4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Apr 2016 18:44:33 +0200 Subject: [PATCH 003/383] Make mesh able to carry material informations - Move OBJ Loader to Utility module, where it belongs - Change Mesh material informations from a path to a parameterlist - Improve Mesh code Former-commit-id: 3c18901133fa5ac8281269822f6e2650ddcefd2d --- include/Nazara/Graphics/Material.hpp | 3 + include/Nazara/Renderer/Enums.hpp | 101 ---- include/Nazara/Renderer/RenderStates.hpp | 2 +- include/Nazara/Renderer/TextureSampler.hpp | 2 +- include/Nazara/Utility/Enums.hpp | 101 ++++ include/Nazara/Utility/MaterialData.hpp | 65 +++ include/Nazara/Utility/Mesh.hpp | 5 +- src/Nazara/Graphics/Formats/MeshLoader.cpp | 63 ++- src/Nazara/Graphics/Graphics.cpp | 5 - src/Nazara/Graphics/Material.cpp | 161 ++++++ src/Nazara/Utility/Formats/MD2Loader.cpp | 7 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 11 +- .../Formats/OBJLoader.cpp | 117 ++-- .../Formats/OBJLoader.hpp | 0 src/Nazara/Utility/Mesh.cpp | 510 +++--------------- src/Nazara/Utility/Utility.cpp | 7 +- 16 files changed, 523 insertions(+), 637 deletions(-) create mode 100644 include/Nazara/Utility/MaterialData.hpp rename src/Nazara/{Graphics => Utility}/Formats/OBJLoader.cpp (67%) rename src/Nazara/{Graphics => Utility}/Formats/OBJLoader.hpp (100%) diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index a2d30b643..397253022 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace Nz { @@ -62,6 +63,8 @@ namespace Nz const Shader* Apply(UInt32 shaderFlags = 0, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const; + void BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams = MaterialParams()); + void Enable(RendererParameter renderParameter, bool enable); void EnableAlphaTest(bool alphaTest); void EnableDepthSorting(bool depthSorting); diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 30e0b5616..2d0e6d3a7 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -19,40 +19,6 @@ namespace Nz AttachmentPoint_Max = AttachmentPoint_Stencil }; - enum BlendFunc - { - BlendFunc_DestAlpha, - BlendFunc_DestColor, - BlendFunc_SrcAlpha, - BlendFunc_SrcColor, - BlendFunc_InvDestAlpha, - BlendFunc_InvDestColor, - BlendFunc_InvSrcAlpha, - BlendFunc_InvSrcColor, - BlendFunc_One, - BlendFunc_Zero, - - BlendFunc_Max = BlendFunc_Zero - }; - - enum FaceFilling - { - FaceFilling_Fill, - FaceFilling_Line, - FaceFilling_Point, - - FaceFilling_Max = FaceFilling_Point - }; - - enum FaceSide - { - FaceSide_Back, - FaceSide_Front, - FaceSide_FrontAndBack, - - FaceSide_Max = FaceSide_FrontAndBack - }; - enum GpuQueryCondition { GpuQueryCondition_Region_NoWait, @@ -124,59 +90,6 @@ namespace Nz RendererBuffer_Max = RendererBuffer_Stencil*2-1 }; - enum RendererComparison - { - RendererComparison_Always, - RendererComparison_Equal, - RendererComparison_Greater, - RendererComparison_GreaterOrEqual, - RendererComparison_Less, - RendererComparison_LessOrEqual, - RendererComparison_Never, - RendererComparison_NotEqual, - - RendererComparison_Max = RendererComparison_NotEqual - }; - - enum RendererParameter - { - RendererParameter_Blend, - RendererParameter_ColorWrite, - RendererParameter_DepthBuffer, - RendererParameter_DepthWrite, - RendererParameter_FaceCulling, - RendererParameter_ScissorTest, - RendererParameter_StencilTest, - - RendererParameter_Max = RendererParameter_StencilTest - }; - - enum SamplerFilter - { - SamplerFilter_Unknown = -1, - - SamplerFilter_Bilinear, - SamplerFilter_Nearest, - SamplerFilter_Trilinear, - - SamplerFilter_Default, - - SamplerFilter_Max = SamplerFilter_Default - }; - - enum SamplerWrap - { - SamplerWrap_Unknown = -1, - - SamplerWrap_Clamp, - SamplerWrap_MirroredRepeat, - SamplerWrap_Repeat, - - SamplerWrap_Default, - - SamplerWrap_Max = SamplerWrap_Repeat - }; - enum ShaderUniform { ShaderUniform_InvProjMatrix, @@ -205,20 +118,6 @@ namespace Nz ShaderStageType_Max = ShaderStageType_Vertex }; - - enum StencilOperation - { - StencilOperation_Decrement, - StencilOperation_DecrementNoClamp, - StencilOperation_Increment, - StencilOperation_IncrementNoClamp, - StencilOperation_Invert, - StencilOperation_Keep, - StencilOperation_Replace, - StencilOperation_Zero, - - StencilOperation_Max = StencilOperation_Zero - }; } #endif // NAZARA_ENUMS_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index 9e9d455f4..4040bec55 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_RENDERSTATES_HPP #define NAZARA_RENDERSTATES_HPP -#include +#include namespace Nz { diff --git a/include/Nazara/Renderer/TextureSampler.hpp b/include/Nazara/Renderer/TextureSampler.hpp index a461f57b2..21675e6c9 100644 --- a/include/Nazara/Renderer/TextureSampler.hpp +++ b/include/Nazara/Renderer/TextureSampler.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Nz { diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 096aa5fb6..143390906 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -17,6 +17,22 @@ namespace Nz AnimationType_Max = AnimationType_Static }; + enum BlendFunc + { + BlendFunc_DestAlpha, + BlendFunc_DestColor, + BlendFunc_SrcAlpha, + BlendFunc_SrcColor, + BlendFunc_InvDestAlpha, + BlendFunc_InvDestColor, + BlendFunc_InvSrcAlpha, + BlendFunc_InvSrcColor, + BlendFunc_One, + BlendFunc_Zero, + + BlendFunc_Max = BlendFunc_Zero + }; + enum BufferAccess { BufferAccess_DiscardAndWrite, @@ -87,6 +103,24 @@ namespace Nz DataStorage_Max = DataStorage_Software*2-1 }; + enum FaceFilling + { + FaceFilling_Fill, + FaceFilling_Line, + FaceFilling_Point, + + FaceFilling_Max = FaceFilling_Point + }; + + enum FaceSide + { + FaceSide_Back, + FaceSide_Front, + FaceSide_FrontAndBack, + + FaceSide_Max = FaceSide_FrontAndBack + }; + enum ImageType { ImageType_1D, @@ -211,6 +245,73 @@ namespace Nz PrimitiveMode_Max = PrimitiveMode_TriangleFan }; + enum RendererComparison + { + RendererComparison_Always, + RendererComparison_Equal, + RendererComparison_Greater, + RendererComparison_GreaterOrEqual, + RendererComparison_Less, + RendererComparison_LessOrEqual, + RendererComparison_Never, + RendererComparison_NotEqual, + + RendererComparison_Max = RendererComparison_NotEqual + }; + + enum RendererParameter + { + RendererParameter_Blend, + RendererParameter_ColorWrite, + RendererParameter_DepthBuffer, + RendererParameter_DepthWrite, + RendererParameter_FaceCulling, + RendererParameter_ScissorTest, + RendererParameter_StencilTest, + + RendererParameter_Max = RendererParameter_StencilTest + }; + + enum SamplerFilter + { + SamplerFilter_Unknown = -1, + + SamplerFilter_Bilinear, + SamplerFilter_Nearest, + SamplerFilter_Trilinear, + + SamplerFilter_Default, + + SamplerFilter_Max = SamplerFilter_Default + }; + + enum SamplerWrap + { + SamplerWrap_Unknown = -1, + + SamplerWrap_Clamp, + SamplerWrap_MirroredRepeat, + SamplerWrap_Repeat, + + SamplerWrap_Default, + + SamplerWrap_Max = SamplerWrap_Repeat + }; + + enum StencilOperation + { + StencilOperation_Decrement, + StencilOperation_DecrementNoClamp, + StencilOperation_Increment, + StencilOperation_IncrementNoClamp, + StencilOperation_Invert, + StencilOperation_Keep, + StencilOperation_Replace, + StencilOperation_Zero, + + StencilOperation_Max = StencilOperation_Zero + }; + enum TextAlign { TextAlign_Left, diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp new file mode 100644 index 000000000..0f69c9846 --- /dev/null +++ b/include/Nazara/Utility/MaterialData.hpp @@ -0,0 +1,65 @@ +// 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_MATERIALDATA_HPP +#define NAZARA_MATERIALDATA_HPP + +namespace Nz +{ + struct MaterialData + { + static constexpr const char* AlphaTest = "MatAlphaTest"; + static constexpr const char* AlphaTexturePath = "MatAlphaTexturePath"; + static constexpr const char* AlphaThreshold = "MatAlphaThreshold"; + static constexpr const char* AmbientColor = "MatAmbientColor"; + static constexpr const char* BackFaceStencilCompare = "MatBackFaceStencilCompare"; + static constexpr const char* BackFaceStencilFail = "MatBackFaceStencilFail"; + static constexpr const char* BackFaceStencilMask = "MatBackFaceStencilMask"; + static constexpr const char* BackFaceStencilPass = "MatBackFaceStencilPass"; + static constexpr const char* BackFaceStencilReference = "MatBackFaceStencilReference"; + static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail"; + static constexpr const char* Blending = "MatBlending"; + static constexpr const char* CustomDefined = "MatCustomDefined"; + static constexpr const char* ColorWrite = "MatColorWrite"; + static constexpr const char* DepthBuffer = "MatDepthBuffer"; + static constexpr const char* DepthFunc = "MatDepthfunc"; + static constexpr const char* DepthSorting = "MatDepthSorting"; + static constexpr const char* DepthWrite = "MatDepthWrite"; + static constexpr const char* DiffuseAnisotropyLevel = "MatDiffuseAnisotropyLevel"; + static constexpr const char* DiffuseColor = "MatDiffuseColor"; + static constexpr const char* DiffuseFilter = "MatDiffuseFilter"; + static constexpr const char* DiffuseTexturePath = "MatDiffuseTexturePath"; + static constexpr const char* DiffuseWrap = "MatDiffuseWrap"; + static constexpr const char* DstBlend = "MatDstBlend"; + static constexpr const char* EmissiveTexturePath = "MatEmissiveTexturePath"; + static constexpr const char* FaceCulling = "MatFaceCulling"; + static constexpr const char* FaceFilling = "MatFaceFilling"; + static constexpr const char* FilePath = "MatFilePath"; + static constexpr const char* HeightTexturePath = "MatHeightTexturePath"; + static constexpr const char* Lighting = "MatLighting"; + static constexpr const char* LineWidth = "MatLineWidth"; + static constexpr const char* NormalTexturePath = "MatNormalTexturePath"; + static constexpr const char* PointSize = "MatPointSize"; + static constexpr const char* ScissorTest = "MatScissorTest"; + static constexpr const char* Shininess = "MatShininess"; + static constexpr const char* SpecularAnisotropyLevel = "MatSpecularAnisotropyLevel"; + static constexpr const char* SpecularColor = "MatSpecularColor"; + static constexpr const char* SpecularFilter = "MatSpecularFilter"; + static constexpr const char* SpecularTexturePath = "MatSpecularTexturePath"; + static constexpr const char* SpecularWrap = "MatSpecularWrap"; + static constexpr const char* SrcBlend = "MatSrcBlend"; + static constexpr const char* StencilCompare = "MatStencilCompare"; + static constexpr const char* StencilFail = "MatStencilFail"; + static constexpr const char* StencilMask = "MatStencilMask"; + static constexpr const char* StencilPass = "MatStencilPass"; + static constexpr const char* StencilReference = "MatStencilReference"; + static constexpr const char* StencilTest = "MatStencilTest"; + static constexpr const char* StencilZFail = "MatStencilZFail"; + static constexpr const char* Transform = "MatTransform"; + }; +} + +#endif // NAZARA_MATERIALDATA_HPP diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 433f50ab5..ff11b5d4d 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -93,7 +93,8 @@ namespace Nz String GetAnimation() const; AnimationType GetAnimationType() const; unsigned int GetJointCount() const; - String GetMaterial(unsigned int index) const; + ParameterList& GetMaterialData(unsigned int index); + const ParameterList& GetMaterialData(unsigned int index) const; unsigned int GetMaterialCount() const; Skeleton* GetSkeleton(); const Skeleton* GetSkeleton() const; @@ -124,8 +125,8 @@ namespace Nz void RemoveSubMesh(unsigned int index); void SetAnimation(const String& animationPath); - void SetMaterial(unsigned int matIndex, const String& materialPath); void SetMaterialCount(unsigned int matCount); + void SetMaterialData(unsigned int matIndex, ParameterList data); void Transform(const Matrix4f& matrix); diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index b915c6f2e..ffd2b423e 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -3,9 +3,11 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include +#include #include #include #include @@ -14,6 +16,33 @@ namespace Nz { namespace { + void LoadMaterials(Model* model, const ModelParameters& parameters) + { + unsigned int matCount = model->GetMaterialCount(); + + for (unsigned int i = 0; i < matCount; ++i) + { + const ParameterList& matData = model->GetMesh()->GetMaterialData(i); + + String filePath; + if (matData.GetStringParameter(MaterialData::FilePath, &filePath)) + { + MaterialRef material = Material::New(); + if (material->LoadFromFile(filePath, parameters.material)) + model->SetMaterial(i, std::move(material)); + else + NazaraWarning("Failed to load material from file " + String::Number(i)); + } + else if (matData.HasParameter(MaterialData::CustomDefined)) + { + MaterialRef material = Material::New(); + material->BuildFromParameters(matData, parameters.material); + + model->SetMaterial(i, std::move(material)); + } + } + } + Ternary CheckStatic(Stream& stream, const ModelParameters& parameters) { NazaraUnused(stream); @@ -46,22 +75,7 @@ namespace Nz model->SetMesh(mesh); if (parameters.loadMaterials) - { - unsigned int matCount = model->GetMaterialCount(); - - for (unsigned int i = 0; i < matCount; ++i) - { - String mat = mesh->GetMaterial(i); - if (!mat.IsEmpty()) - { - MaterialRef material = Material::New(); - if (material->LoadFromFile(mat, parameters.material)) - model->SetMaterial(i, material); - else - NazaraWarning("Failed to load material #" + String::Number(i)); - } - } - } + LoadMaterials(model, parameters); return true; } @@ -98,22 +112,7 @@ namespace Nz model->SetMesh(mesh); if (parameters.loadMaterials) - { - unsigned int matCount = model->GetMaterialCount(); - - for (unsigned int i = 0; i < matCount; ++i) - { - String mat = mesh->GetMaterial(i); - if (!mat.IsEmpty()) - { - MaterialRef material = Material::New(); - if (material->LoadFromFile(mat, parameters.material)) - model->SetMaterial(i, material); - else - NazaraWarning("Failed to load material #" + String::Number(i)); - } - } - } + LoadMaterials(model, parameters); return true; } diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index a96f2f4e7..03c343ed3 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -96,9 +95,6 @@ namespace Nz return false; } - // Loaders - Loaders::RegisterOBJ(); - // Loaders génériques Loaders::RegisterMesh(); Loaders::RegisterTexture(); @@ -176,7 +172,6 @@ namespace Nz // Loaders Loaders::UnregisterMesh(); - Loaders::UnregisterOBJ(); Loaders::UnregisterTexture(); DeferredRenderTechnique::Uninitialize(); diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 0a4755c03..c646d940b 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -7,6 +7,7 @@ #endif #include +#include #include #include #include @@ -139,6 +140,166 @@ namespace Nz return instance.shader; } + void Material::BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams) + { + Color color; + bool isEnabled; + float fValue; + int iValue; + String path; + + ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled, true); + + + if (matData.GetFloatParameter(MaterialData::AlphaThreshold, &fValue)) + SetAlphaThreshold(fValue); + + if (matData.GetBooleanParameter(MaterialData::AlphaTest, &isEnabled)) + EnableAlphaTest(isEnabled); + + if (matData.GetColorParameter(MaterialData::AmbientColor, &color)) + SetAmbientColor(color); + + if (matData.GetIntegerParameter(MaterialData::DepthFunc, &iValue)) + SetDepthFunc(static_cast(iValue)); + + if (matData.GetBooleanParameter(MaterialData::DepthSorting, &isEnabled)) + EnableDepthSorting(isEnabled); + + if (matData.GetColorParameter(MaterialData::DiffuseColor, &color)) + SetDiffuseColor(color); + + if (matData.GetIntegerParameter(MaterialData::DstBlend, &iValue)) + SetDstBlend(static_cast(iValue)); + + if (matData.GetIntegerParameter(MaterialData::FaceCulling, &iValue)) + SetFaceCulling(static_cast(iValue)); + + if (matData.GetIntegerParameter(MaterialData::FaceFilling, &iValue)) + SetFaceFilling(static_cast(iValue)); + + if (matData.GetBooleanParameter(MaterialData::Lighting, &isEnabled)) + EnableLighting(isEnabled); + + if (matData.GetFloatParameter(MaterialData::LineWidth, &fValue)) + m_states.lineWidth = fValue; + + if (matData.GetFloatParameter(MaterialData::PointSize, &fValue)) + m_states.pointSize = fValue; + + if (matData.GetColorParameter(MaterialData::SpecularColor, &color)) + SetSpecularColor(color); + + if (matData.GetFloatParameter(MaterialData::Shininess, &fValue)) + SetShininess(fValue); + + if (matData.GetIntegerParameter(MaterialData::SrcBlend, &iValue)) + SetSrcBlend(static_cast(iValue)); + + if (matData.GetBooleanParameter(MaterialData::Transform, &isEnabled)) + EnableTransform(isEnabled); + + // RendererParameter + if (matData.GetBooleanParameter(MaterialData::Blending, &isEnabled)) + Enable(RendererParameter_Blend, isEnabled); + + if (matData.GetBooleanParameter(MaterialData::ColorWrite, &isEnabled)) + Enable(RendererParameter_ColorWrite, isEnabled); + + if (matData.GetBooleanParameter(MaterialData::DepthBuffer, &isEnabled)) + Enable(RendererParameter_DepthBuffer, isEnabled); + + if (matData.GetBooleanParameter(MaterialData::DepthWrite, &isEnabled)) + Enable(RendererParameter_DepthWrite, isEnabled); + + if (matData.GetBooleanParameter(MaterialData::FaceCulling, &isEnabled)) + Enable(RendererParameter_FaceCulling, isEnabled); + + if (matData.GetBooleanParameter(MaterialData::ScissorTest, &isEnabled)) + Enable(RendererParameter_ScissorTest, isEnabled); + + if (matData.GetBooleanParameter(MaterialData::StencilTest, &isEnabled)) + Enable(RendererParameter_StencilTest, isEnabled); + + // Samplers + if (matData.GetIntegerParameter(MaterialData::DiffuseAnisotropyLevel, &iValue)) + m_diffuseSampler.SetAnisotropyLevel(static_cast(iValue)); + + if (matData.GetIntegerParameter(MaterialData::DiffuseFilter, &iValue)) + m_diffuseSampler.SetFilterMode(static_cast(iValue)); + + if (matData.GetIntegerParameter(MaterialData::DiffuseWrap, &iValue)) + m_diffuseSampler.SetWrapMode(static_cast(iValue)); + + if (matData.GetIntegerParameter(MaterialData::SpecularAnisotropyLevel, &iValue)) + m_specularSampler.SetAnisotropyLevel(static_cast(iValue)); + + if (matData.GetIntegerParameter(MaterialData::SpecularFilter, &iValue)) + m_specularSampler.SetFilterMode(static_cast(iValue)); + + if (matData.GetIntegerParameter(MaterialData::SpecularWrap, &iValue)) + m_specularSampler.SetWrapMode(static_cast(iValue)); + + // Stencil + if (matData.GetIntegerParameter(MaterialData::StencilCompare, &iValue)) + m_states.frontFace.stencilCompare = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::StencilFail, &iValue)) + m_states.frontFace.stencilFail = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::StencilPass, &iValue)) + m_states.frontFace.stencilPass = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::StencilZFail, &iValue)) + m_states.frontFace.stencilZFail = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::StencilMask, &iValue)) + m_states.frontFace.stencilMask = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::StencilReference, &iValue)) + m_states.frontFace.stencilReference = static_cast(iValue); + + // Stencil (back) + if (matData.GetIntegerParameter(MaterialData::BackFaceStencilCompare, &iValue)) + m_states.backFace.stencilCompare = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::BackFaceStencilFail, &iValue)) + m_states.backFace.stencilFail = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::BackFaceStencilPass, &iValue)) + m_states.backFace.stencilPass = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::BackFaceStencilZFail, &iValue)) + m_states.backFace.stencilZFail = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::BackFaceStencilMask, &iValue)) + m_states.backFace.stencilMask = static_cast(iValue); + + if (matData.GetIntegerParameter(MaterialData::BackFaceStencilReference, &iValue)) + m_states.backFace.stencilReference = static_cast(iValue); + + // Textures + if (matParams.loadAlphaMap && matData.GetStringParameter(MaterialData::AlphaTexturePath, &path)) + SetAlphaMap(path); + + if (matParams.loadDiffuseMap && matData.GetStringParameter(MaterialData::DiffuseTexturePath, &path)) + SetDiffuseMap(path); + + if (matParams.loadEmissiveMap && matData.GetStringParameter(MaterialData::EmissiveTexturePath, &path)) + SetEmissiveMap(path); + + if (matParams.loadHeightMap && matData.GetStringParameter(MaterialData::HeightTexturePath, &path)) + SetHeightMap(path); + + if (matParams.loadNormalMap && matData.GetStringParameter(MaterialData::NormalTexturePath, &path)) + SetNormalMap(path); + + if (matParams.loadSpecularMap && matData.GetStringParameter(MaterialData::SpecularTexturePath, &path)) + SetSpecularMap(path); + + SetShader(matParams.shaderName); + } + void Material::Enable(RendererParameter renderParameter, bool enable) { #ifdef NAZARA_DEBUG diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index 184adfe17..eef4ac63d 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -99,7 +100,11 @@ namespace Nz for (unsigned int i = 0; i < header.num_skins; ++i) { stream.Read(skin, 68*sizeof(char)); - mesh->SetMaterial(i, baseDir + skin); + + ParameterList matData; + matData.SetParameter(MaterialData::FilePath, baseDir + skin); + + mesh->SetMaterialData(i, std::move(matData)); } } } diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 629452161..9f7b6151c 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -189,7 +190,10 @@ namespace Nz vertexMapper.Unmap(); // Material - mesh->SetMaterial(i, baseDir + md5Mesh.shader); + ParameterList matData; + matData.SetParameter(MaterialData::FilePath, baseDir + md5Mesh.shader); + + mesh->SetMaterialData(i, std::move(matData)); // Submesh SkeletalMeshRef subMesh = SkeletalMesh::New(mesh); @@ -285,7 +289,10 @@ namespace Nz mesh->AddSubMesh(subMesh); // Material - mesh->SetMaterial(i, baseDir + md5Mesh.shader); + ParameterList matData; + matData.SetParameter(MaterialData::FilePath, baseDir + md5Mesh.shader); + + mesh->SetMaterialData(i, std::move(matData)); } if (parameters.center) diff --git a/src/Nazara/Graphics/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp similarity index 67% rename from src/Nazara/Graphics/Formats/OBJLoader.cpp rename to src/Nazara/Utility/Formats/OBJLoader.cpp index 09ad743d7..75b5ba22f 100644 --- a/src/Nazara/Graphics/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -1,14 +1,13 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Graphics module" +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include -#include #include #include +#include #include #include #include @@ -17,7 +16,7 @@ #include #include #include -#include +#include ///TODO: N'avoir qu'un seul VertexBuffer communs à tous les meshes @@ -30,7 +29,7 @@ namespace Nz return (extension == "obj"); } - Ternary Check(Stream& stream, const ModelParameters& parameters) + Ternary Check(Stream& stream, const MeshParams& parameters) { NazaraUnused(stream); @@ -41,7 +40,7 @@ namespace Nz return Ternary_Unknown; } - bool LoadMaterials(Model* model, const String& filePath, const MaterialParams& parameters, const String* materials, const OBJParser::Mesh* meshes, unsigned int meshCount) + bool ParseMTL(Mesh* mesh, const String& filePath, const String* materials, const OBJParser::Mesh* meshes, unsigned int meshCount) { File file(filePath); if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) @@ -57,7 +56,7 @@ namespace Nz return false; } - std::unordered_map materialCache; + std::unordered_map materialCache; String baseDir = file.GetDirectory(); for (unsigned int i = 0; i < meshCount; ++i) { @@ -72,8 +71,9 @@ namespace Nz auto it = materialCache.find(matName); if (it == materialCache.end()) { - MaterialRef material = Material::New(); - material->SetShader(parameters.shaderName); + ParameterList data; + + data.SetParameter(MaterialData::CustomDefined); UInt8 alphaValue = static_cast(mtlMat->alpha*255.f); @@ -84,54 +84,40 @@ namespace Nz diffuseColor.a = alphaValue; specularColor.a = alphaValue; - material->SetAmbientColor(ambientColor); - material->SetDiffuseColor(diffuseColor); - material->SetSpecularColor(specularColor); - material->SetShininess(mtlMat->shininess); + data.SetParameter(MaterialData::AmbientColor, ambientColor); + data.SetParameter(MaterialData::DiffuseColor, diffuseColor); + data.SetParameter(MaterialData::Shininess, mtlMat->shininess); + data.SetParameter(MaterialData::SpecularColor, specularColor); - bool isTranslucent = (alphaValue != 255); + if (!mtlMat->alphaMap.IsEmpty()) + data.SetParameter(MaterialData::AlphaTexturePath, baseDir + mtlMat->alphaMap); - if (parameters.loadAlphaMap && !mtlMat->alphaMap.IsEmpty()) + if (!mtlMat->diffuseMap.IsEmpty()) + data.SetParameter(MaterialData::DiffuseTexturePath, baseDir + mtlMat->diffuseMap); + + if (!mtlMat->specularMap.IsEmpty()) + data.SetParameter(MaterialData::SpecularTexturePath, baseDir + mtlMat->specularMap); + + // If we either have an alpha value or an alpha map, let's configure the material for transparency + if (alphaValue != 255 || !mtlMat->alphaMap.IsEmpty()) { - if (material->SetAlphaMap(baseDir + mtlMat->alphaMap)) - isTranslucent = true; // Une alpha map indique de la transparence - else - NazaraWarning("Failed to load alpha map (" + mtlMat->alphaMap + ')'); + // Some default settings + data.SetParameter(MaterialData::Blending, true); + data.SetParameter(MaterialData::DepthWrite, true); + data.SetParameter(MaterialData::DstBlend, static_cast(BlendFunc_InvSrcAlpha)); + data.SetParameter(MaterialData::SrcBlend, static_cast(BlendFunc_SrcAlpha)); } - if (parameters.loadDiffuseMap && !mtlMat->diffuseMap.IsEmpty()) - { - if (!material->SetDiffuseMap(baseDir + mtlMat->diffuseMap)) - NazaraWarning("Failed to load diffuse map (" + mtlMat->diffuseMap + ')'); - } - - if (parameters.loadSpecularMap && !mtlMat->specularMap.IsEmpty()) - { - if (!material->SetSpecularMap(baseDir + mtlMat->specularMap)) - NazaraWarning("Failed to load specular map (" + mtlMat->specularMap + ')'); - } - - // Si nous avons une alpha map ou des couleurs transparentes, - // nous devons configurer le matériau pour accepter la transparence au mieux - if (isTranslucent) - { - // On paramètre le matériau pour accepter la transparence au mieux - material->Enable(RendererParameter_Blend, true); - material->Enable(RendererParameter_DepthWrite, false); - material->SetDstBlend(BlendFunc_InvSrcAlpha); - material->SetSrcBlend(BlendFunc_SrcAlpha); - } - - it = materialCache.emplace(matName, std::move(material)).first; + it = materialCache.emplace(matName, std::move(data)).first; } - model->SetMaterial(meshes[i].material, it->second); + mesh->SetMaterialData(meshes[i].material, it->second); } return true; } - bool Load(Model* model, Stream& stream, const ModelParameters& parameters) + bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) { int reservedVertexCount; if (!parameters.custom.GetIntegerParameter("NativeOBJLoader_VertexCount", &reservedVertexCount)) @@ -144,12 +130,7 @@ namespace Nz return false; } - MeshRef mesh = Mesh::New(); - if (!mesh->CreateStatic()) // Ne devrait jamais échouer - { - NazaraInternalError("Failed to create mesh"); - return false; - } + mesh->CreateStatic(); const String* materials = parser.GetMaterials(); const Vector4f* positions = parser.GetPositions(); @@ -160,8 +141,8 @@ namespace Nz unsigned int meshCount = parser.GetMeshCount(); NazaraAssert(materials != nullptr && positions != nullptr && normals != nullptr && - texCoords != nullptr && meshes != nullptr && meshCount > 0, - "Invalid OBJParser output"); + texCoords != nullptr && meshes != nullptr && meshCount > 0, + "Invalid OBJParser output"); // Un conteneur temporaire pour contenir les indices de face avant triangulation std::vector faceIndices(3); // Comme il y aura au moins trois sommets @@ -197,8 +178,8 @@ namespace Nz bool operator()(const OBJParser::FaceVertex& lhs, const OBJParser::FaceVertex& rhs) const { return lhs.normal == rhs.normal && - lhs.position == rhs.position && - lhs.texCoord == rhs.texCoord; + lhs.position == rhs.position && + lhs.texCoord == rhs.texCoord; } }; @@ -230,8 +211,8 @@ namespace Nz } // Création des buffers - IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits::max(), indices.size(), parameters.mesh.storage, BufferUsage_Static); - VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.mesh.storage, BufferUsage_Static); + IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits::max(), indices.size(), parameters.storage, BufferUsage_Static); + VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage, BufferUsage_Static); // Remplissage des indices IndexMapper indexMapper(indexBuffer, BufferAccess_WriteOnly); @@ -254,7 +235,7 @@ namespace Nz const Vector4f& vec = positions[vertexIndices.position]; vertex.position.Set(vec.x, vec.y, vec.z); - vertex.position *= parameters.mesh.scale/vec.w; + vertex.position *= parameters.scale/vec.w; if (vertexIndices.normal >= 0) vertex.normal = normals[vertexIndices.normal]; @@ -264,7 +245,7 @@ namespace Nz if (vertexIndices.texCoord >= 0) { const Vector3f& uvw = texCoords[vertexIndices.texCoord]; - vertex.uv.Set(uvw.x, (parameters.mesh.flipUVs) ? 1.f - uvw.y : uvw.y); // Inversion des UVs si demandé + vertex.uv.Set(uvw.x, (parameters.flipUVs) ? 1.f - uvw.y : uvw.y); // Inversion des UVs si demandé } else hasTexCoords = false; @@ -279,7 +260,7 @@ namespace Nz continue; } - if (parameters.mesh.optimizeIndexBuffers) + if (parameters.optimizeIndexBuffers) indexBuffer->Optimize(); subMesh->GenerateAABB(); @@ -299,17 +280,15 @@ namespace Nz } mesh->SetMaterialCount(parser.GetMaterialCount()); - if (parameters.mesh.center) + if (parameters.center) mesh->Recenter(); - model->SetMesh(mesh); - // On charge les matériaux si demandé String mtlLib = parser.GetMtlLib(); - if (parameters.loadMaterials && !mtlLib.IsEmpty()) + if (!mtlLib.IsEmpty()) { ErrorFlags flags(ErrorFlag_ThrowExceptionDisabled); - LoadMaterials(model, stream.GetDirectory() + mtlLib, parameters.material, materials, meshes, meshCount); + ParseMTL(mesh, stream.GetDirectory() + mtlLib, materials, meshes, meshCount); } return true; @@ -320,12 +299,12 @@ namespace Nz { void RegisterOBJ() { - ModelLoader::RegisterLoader(IsSupported, Check, Load); + MeshLoader::RegisterLoader(IsSupported, Check, Load); } void UnregisterOBJ() { - ModelLoader::UnregisterLoader(IsSupported, Check, Load); + MeshLoader::UnregisterLoader(IsSupported, Check, Load); } } } diff --git a/src/Nazara/Graphics/Formats/OBJLoader.hpp b/src/Nazara/Utility/Formats/OBJLoader.hpp similarity index 100% rename from src/Nazara/Graphics/Formats/OBJLoader.hpp rename to src/Nazara/Utility/Formats/OBJLoader.hpp diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 82c903cae..fca38e415 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -52,11 +52,11 @@ namespace Nz { MeshImpl() { - materials.resize(1); // Un matériau par défaut + materialData.resize(1); // Un matériau par défaut } std::unordered_map subMeshMap; - std::vector materials; + std::vector materialData; std::vector subMeshes; AnimationType animationType; Boxf aabb; @@ -75,93 +75,36 @@ namespace Nz void Mesh::AddSubMesh(SubMesh* subMesh) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(subMesh, "Invalid submesh"); + NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type"); - if (!subMesh) - { - NazaraError("Invalid submesh"); - return; - } - - if (subMesh->GetAnimationType() != m_impl->animationType) - { - NazaraError("Submesh animation type must match mesh animation type"); - return; - } - #endif - - m_impl->aabbUpdated = false; // On invalide l'AABB m_impl->subMeshes.push_back(subMesh); + + InvalidateAABB(); } void Mesh::AddSubMesh(const String& identifier, SubMesh* subMesh) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - - if (identifier.IsEmpty()) - { - NazaraError("Identifier is empty"); - return; - } - - auto it = m_impl->subMeshMap.find(identifier); - if (it != m_impl->subMeshMap.end()) - { - NazaraError("SubMesh identifier \"" + identifier + "\" is already used"); - return; - } - - if (!subMesh) - { - NazaraError("Invalid submesh"); - return; - } - - if (m_impl->animationType != subMesh->GetAnimationType()) - { - NazaraError("Submesh animation type must match mesh animation type"); - return; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(!identifier.IsEmpty(), "Identifier is empty"); + NazaraAssert(m_impl->subMeshMap.find(identifier) == m_impl->subMeshMap.end(), "SubMesh identifier \"" + identifier + "\" is already in use"); + NazaraAssert(subMesh, "Invalid submesh"); + NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type"); int index = m_impl->subMeshes.size(); - m_impl->aabbUpdated = false; // On invalide l'AABB m_impl->subMeshes.push_back(subMesh); m_impl->subMeshMap[identifier] = index; + + InvalidateAABB(); } SubMesh* Mesh::BuildSubMesh(const Primitive& primitive, const MeshParams& params) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return nullptr; - } - - if (m_impl->animationType != AnimationType_Static) - { - NazaraError("Mesh must be static"); - return nullptr; - } - - if (!params.IsValid()) - { - NazaraError("Parameters must be valid"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(m_impl->animationType == AnimationType_Static, "Submesh building only works for static meshes"); + NazaraAssert(params.IsValid(), "Invalid parameters"); Boxf aabb; IndexBufferRef indexBuffer; @@ -333,17 +276,7 @@ namespace Nz void Mesh::BuildSubMeshes(const PrimitiveList& list, const MeshParams& params) { - unsigned int primitiveCount = list.GetSize(); - - #if NAZARA_UTILITY_SAFE - if (primitiveCount == 0) - { - NazaraError("PrimitiveList must have at least one primitive"); - return; - } - #endif - - for (unsigned int i = 0; i < primitiveCount; ++i) + for (unsigned int i = 0; i < list.GetSize(); ++i) BuildSubMesh(list.GetPrimitive(i), params); } @@ -351,18 +284,17 @@ namespace Nz { Destroy(); - m_impl = new MeshImpl; - m_impl->animationType = AnimationType_Skeletal; - m_impl->jointCount = jointCount; - if (!m_impl->skeleton.Create(jointCount)) + std::unique_ptr impl(new MeshImpl); + impl->animationType = AnimationType_Skeletal; + impl->jointCount = jointCount; + if (!impl->skeleton.Create(jointCount)) { - delete m_impl; - m_impl = nullptr; - NazaraError("Failed to create skeleton"); return false; } + m_impl = impl.release(); + return true; } @@ -389,13 +321,7 @@ namespace Nz void Mesh::GenerateNormals() { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); for (SubMesh* subMesh : m_impl->subMeshes) subMesh->GenerateNormals(); @@ -403,13 +329,7 @@ namespace Nz void Mesh::GenerateNormalsAndTangents() { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); for (SubMesh* subMesh : m_impl->subMeshes) subMesh->GenerateNormalsAndTangents(); @@ -417,13 +337,7 @@ namespace Nz void Mesh::GenerateTangents() { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); for (SubMesh* subMesh : m_impl->subMeshes) subMesh->GenerateTangents(); @@ -431,15 +345,7 @@ namespace Nz const Boxf& Mesh::GetAABB() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - - static Boxf dummy; - return dummy; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); if (!m_impl->aabbUpdated) { @@ -461,248 +367,121 @@ namespace Nz String Mesh::GetAnimation() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return String(); - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); return m_impl->animationPath; } AnimationType Mesh::GetAnimationType() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return AnimationType_Static; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); return m_impl->animationType; } unsigned int Mesh::GetJointCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return 0; - } - - if (m_impl->animationType != AnimationType_Skeletal) - { - NazaraError("Mesh's animation type is not skeletal"); - return 0; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(m_impl->animationType == AnimationType_Skeletal, "Mesh is not skeletal"); return m_impl->jointCount; } - String Mesh::GetMaterial(unsigned int index) const + ParameterList& Mesh::GetMaterialData(unsigned int index) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return String(); - } + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(index < m_impl->materialData.size(), "Material index out of range"); - if (index >= m_impl->materials.size()) - { - NazaraError("Material index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->materials.size()) + ')'); - return String(); - } - #endif + return m_impl->materialData[index]; + } - return m_impl->materials[index]; + const ParameterList& Mesh::GetMaterialData(unsigned int index) const + { + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(index < m_impl->materialData.size(), "Material index out of range"); + + return m_impl->materialData[index]; } unsigned int Mesh::GetMaterialCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); - return m_impl->materials.size(); + return m_impl->materialData.size(); } Skeleton* Mesh::GetSkeleton() { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (m_impl->animationType != AnimationType_Skeletal) - { - NazaraError("Mesh's animation type is not skeletal"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(m_impl->animationType == AnimationType_Skeletal, "Mesh is not skeletal"); return &m_impl->skeleton; } const Skeleton* Mesh::GetSkeleton() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (m_impl->animationType != AnimationType_Skeletal) - { - NazaraError("Mesh's animation type is not skeletal"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(m_impl->animationType == AnimationType_Skeletal, "Mesh is not skeletal"); return &m_impl->skeleton; } SubMesh* Mesh::GetSubMesh(const String& identifier) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); auto it = m_impl->subMeshMap.find(identifier); - - #if NAZARA_UTILITY_SAFE - if (it == m_impl->subMeshMap.end()) - { - NazaraError("SubMesh not found"); - return nullptr; - } - #endif + NazaraAssert(it != m_impl->subMeshMap.end(), "SubMesh " + identifier + " not found"); return m_impl->subMeshes[it->second]; } SubMesh* Mesh::GetSubMesh(unsigned int index) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return nullptr; - } - - if (index >= m_impl->subMeshes.size()) - { - NazaraError("SubMesh index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->subMeshes.size()) + ')'); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); return m_impl->subMeshes[index]; } const SubMesh* Mesh::GetSubMesh(const String& identifier) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); auto it = m_impl->subMeshMap.find(identifier); - - #if NAZARA_UTILITY_SAFE - if (it == m_impl->subMeshMap.end()) - { - NazaraError("SubMesh not found"); - return nullptr; - } - #endif + NazaraAssert(it != m_impl->subMeshMap.end(), "SubMesh " + identifier + " not found"); return m_impl->subMeshes[it->second]; } const SubMesh* Mesh::GetSubMesh(unsigned int index) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return nullptr; - } - - if (index >= m_impl->subMeshes.size()) - { - NazaraError("SubMesh index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->subMeshes.size()) + ')'); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); return m_impl->subMeshes[index]; } unsigned int Mesh::GetSubMeshCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); return m_impl->subMeshes.size(); } int Mesh::GetSubMeshIndex(const String& identifier) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return -1; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); auto it = m_impl->subMeshMap.find(identifier); - - #if NAZARA_UTILITY_SAFE - if (it == m_impl->subMeshMap.end()) - { - NazaraError("SubMesh not found"); - return -1; - } - #endif + NazaraAssert(it != m_impl->subMeshMap.end(), "SubMesh " + identifier + " not found"); return it->second; } unsigned int Mesh::GetTriangleCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); unsigned int triangleCount = 0; for (SubMesh* subMesh : m_impl->subMeshes) @@ -713,13 +492,7 @@ namespace Nz unsigned int Mesh::GetVertexCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); unsigned int vertexCount = 0; for (SubMesh* subMesh : m_impl->subMeshes) @@ -730,52 +503,28 @@ namespace Nz void Mesh::InvalidateAABB() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); m_impl->aabbUpdated = false; } bool Mesh::HasSubMesh(const String& identifier) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); return m_impl->subMeshMap.find(identifier) != m_impl->subMeshMap.end(); } bool Mesh::HasSubMesh(unsigned int index) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); return index < m_impl->subMeshes.size(); } bool Mesh::IsAnimable() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); return m_impl->animationType != AnimationType_Static; } @@ -802,21 +551,10 @@ namespace Nz void Mesh::Recenter() { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(m_impl->animationType == AnimationType_Static, "Mesh is not static"); - if (m_impl->animationType != AnimationType_Static) - { - NazaraError("Mesh must be static"); - return; - } - #endif - - // Le centre de notre mesh est le centre de l'AABB *globale* + // The center of our mesh is the center of our *global* AABB Vector3f center = GetAABB().GetCenter(); for (SubMesh* subMesh : m_impl->subMeshes) @@ -833,119 +571,62 @@ namespace Nz vertices++; } - // l'AABB ne change pas de dimensions mais seulement de position, appliquons-lui le même procédé + // Our AABB doesn't change shape, only position Boxf aabb = staticMesh->GetAABB(); aabb.Translate(-center); staticMesh->SetAABB(aabb); } - // Il ne faut pas oublier d'invalider notre AABB - m_impl->aabbUpdated = false; + InvalidateAABB(); } void Mesh::RemoveSubMesh(const String& identifier) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - - auto it = m_impl->subMeshMap.find(identifier); - if (it == m_impl->subMeshMap.end()) - { - NazaraError("SubMesh not found"); - return; - } - - unsigned int index = it->second; - #else - unsigned int index = m_impl->subMeshMap[identifier]; - #endif + unsigned int index = GetSubMeshIndex(identifier); // On déplace l'itérateur du début d'une distance de x auto it2 = m_impl->subMeshes.begin(); std::advance(it2, index); m_impl->subMeshes.erase(it2); - m_impl->aabbUpdated = false; // On invalide l'AABB + InvalidateAABB(); } void Mesh::RemoveSubMesh(unsigned int index) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - - if (index >= m_impl->subMeshes.size()) - { - NazaraError("SubMesh index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->subMeshes.size()) + ')'); - return; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); // On déplace l'itérateur du début de x auto it = m_impl->subMeshes.begin(); std::advance(it, index); m_impl->subMeshes.erase(it); - m_impl->aabbUpdated = false; // On invalide l'AABB + InvalidateAABB(); } void Mesh::SetAnimation(const String& animationPath) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - #endif + NazaraAssert(m_impl, "Mesh should be created first"); m_impl->animationPath = animationPath; } - void Mesh::SetMaterial(unsigned int matIndex, const String& materialPath) + void Mesh::SetMaterialData(unsigned int matIndex, ParameterList data) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(matIndex < m_impl->materialData.size(), "Material index out of range"); - if (matIndex >= m_impl->materials.size()) - { - NazaraError("Material index out of range (" + String::Number(matIndex) + " >= " + String::Number(m_impl->materials.size()) + ')'); - return; - } - #endif - - m_impl->materials[matIndex] = materialPath; + m_impl->materialData[matIndex] = std::move(data); } void Mesh::SetMaterialCount(unsigned int matCount) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(matCount > 0, "A mesh should have at least a material"); - if (matCount == 0) - { - NazaraError("A mesh should have at least a material"); - return; - } - #endif - - m_impl->materials.resize(matCount); + m_impl->materialData.resize(matCount); #ifdef NAZARA_DEBUG for (SubMesh* subMesh : m_impl->subMeshes) @@ -953,7 +634,7 @@ namespace Nz unsigned int matIndex = subMesh->GetMaterialIndex(); if (matIndex >= matCount) { - subMesh->SetMaterialIndex(0); // Pour empêcher un crash + subMesh->SetMaterialIndex(0); // To prevent a crash NazaraWarning("SubMesh " + String::Pointer(subMesh) + " material index is over mesh new material count (" + String::Number(matIndex) + " >= " + String::Number(matCount) + "), setting it to first material"); } } @@ -962,22 +643,8 @@ namespace Nz void Mesh::Transform(const Matrix4f& matrix) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Mesh not created"); - return; - } - - if (m_impl->animationType != AnimationType_Static) - { - NazaraError("Mesh must be static"); - return; - } - #endif - - if (matrix.IsIdentity()) - return; + NazaraAssert(m_impl, "Mesh should be created first"); + NazaraAssert(m_impl->animationType == AnimationType_Static, "Mesh is not static"); for (SubMesh* subMesh : m_impl->subMeshes) { @@ -1000,8 +667,7 @@ namespace Nz staticMesh->SetAABB(aabb); } - // Il ne faut pas oublier d'invalider notre AABB - m_impl->aabbUpdated = false; + InvalidateAABB(); } bool Mesh::Initialize() diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 75084b8c0..78553ce54 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -114,7 +115,7 @@ namespace Nz Loaders::RegisterFreeType(); // Image - Loaders::RegisterDDSLoader(); // Generic loader (STB) + Loaders::RegisterDDSLoader(); // DDS Loader (DirectX format) Loaders::RegisterSTBLoader(); // Generic loader (STB) Loaders::RegisterSTBSaver(); // Generic saver (STB) @@ -122,6 +123,9 @@ namespace Nz // Animation Loaders::RegisterMD5Anim(); // Loader de fichiers .md5anim (v10) + // Mesh (text) + Loaders::RegisterOBJ(); + // Mesh Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8) Loaders::RegisterMD5Mesh(); // Loader de fichiers .md5mesh (v10) @@ -158,6 +162,7 @@ namespace Nz Loaders::UnregisterMD2(); Loaders::UnregisterMD5Anim(); Loaders::UnregisterMD5Mesh(); + Loaders::UnregisterOBJ(); Loaders::UnregisterPCX(); Loaders::UnregisterSTBLoader(); Loaders::UnregisterSTBSaver(); From f44abfb87cde5adbdd384ebb3b62c3adee5cd621 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 1 May 2016 19:23:31 +0200 Subject: [PATCH 004/383] Plugins/Assimp: Add material loading Former-commit-id: 21cd74156915f9592ce47ee832d3373751a0ebfe --- plugins/Assimp/Plugin.cpp | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 0e754ea70..395ca6305 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -27,6 +27,7 @@ SOFTWARE. #include #include #include +#include #include #include #include @@ -165,6 +166,9 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) { mesh->CreateStatic(); + // aiMaterial index in scene => Material index and data in Mesh + std::unordered_map> materials; + for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { aiMesh* iMesh = scene->mMeshes[i]; @@ -222,8 +226,86 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) subMesh->GenerateAABB(); subMesh->SetMaterialIndex(iMesh->mMaterialIndex); + auto matIt = materials.find(iMesh->mMaterialIndex); + if (matIt == materials.end()) + { + ParameterList matData; + aiMaterial* aiMat = scene->mMaterials[iMesh->mMaterialIndex]; + + auto ConvertColor = [&] (const char* aiKey, unsigned int aiType, unsigned int aiIndex, const char* colorKey) + { + aiColor4D color; + if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS) + { + matData.SetParameter(MaterialData::CustomDefined); + + matData.SetParameter(colorKey, Color(static_cast(color.r * 255), static_cast(color.g * 255), static_cast(color.b * 255), static_cast(color.a * 255))); + } + }; + + auto ConvertTexture = [&] (aiTextureType aiType, const char* textureKey, const char* wrapKey = nullptr) + { + aiString path; + aiTextureMapMode mapMode; + if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode, nullptr) == aiReturn_SUCCESS) + { + matData.SetParameter(MaterialData::CustomDefined); + matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length)); + + if (wrapKey) + { + SamplerWrap wrap = SamplerWrap_Default; + switch (mapMode) + { + case aiTextureMapMode_Clamp: + case aiTextureMapMode_Decal: + wrap = SamplerWrap_Clamp; + break; + + case aiTextureMapMode_Mirror: + wrap = SamplerWrap_MirroredRepeat; + break; + + case aiTextureMapMode_Wrap: + wrap = SamplerWrap_Repeat; + break; + + default: + NazaraWarning("Assimp texture map mode 0x" + String::Number(mapMode, 16) + " not handled"); + break; + } + + matData.SetParameter(wrapKey, static_cast(wrap)); + } + } + }; + + ConvertColor(AI_MATKEY_COLOR_AMBIENT, MaterialData::AmbientColor); + ConvertColor(AI_MATKEY_COLOR_DIFFUSE, MaterialData::DiffuseColor); + ConvertColor(AI_MATKEY_COLOR_SPECULAR, MaterialData::SpecularColor); + + ConvertTexture(aiTextureType_DIFFUSE, MaterialData::DiffuseTexturePath, MaterialData::DiffuseWrap); + ConvertTexture(aiTextureType_EMISSIVE, MaterialData::EmissiveTexturePath); + ConvertTexture(aiTextureType_HEIGHT, MaterialData::HeightTexturePath); + ConvertTexture(aiTextureType_NORMALS, MaterialData::NormalTexturePath); + ConvertTexture(aiTextureType_OPACITY, MaterialData::AlphaTexturePath); + ConvertTexture(aiTextureType_SPECULAR, MaterialData::SpecularTexturePath, MaterialData::SpecularWrap); + + int iValue; + if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue)) + matData.SetParameter(MaterialData::FaceCulling, !iValue); + + matIt = materials.insert(std::make_pair(iMesh->mMaterialIndex, std::make_pair(materials.size(), std::move(matData)))).first; + } + + subMesh->SetMaterialIndex(matIt->first); + mesh->AddSubMesh(subMesh); } + + mesh->SetMaterialCount(std::max(materials.size(), 1)); + for (const auto& pair : materials) + mesh->SetMaterialData(pair.second.first, pair.second.second); } if (parameters.center) From 6c9a48d80eb2cb8e9f8e902ceb7c69c2511b308e Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 3 May 2016 12:42:52 +0200 Subject: [PATCH 005/383] Utility/Formats: Fix MD5 loading Former-commit-id: 05a4ee3745a6f5444a19c15f713fdd21d51a7804 --- src/Nazara/Core/String.cpp | 10 ++++++---- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 2 +- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index b94715457..a57d89861 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -4240,7 +4240,7 @@ namespace Nz utf8::unchecked::iterator it(m_sharedString->string.get()); do { - if ((Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) + if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) break; } while (*++it); @@ -4255,7 +4255,7 @@ namespace Nz utf8::unchecked::iterator it(&m_sharedString->string[m_sharedString->size]); while ((it--).base() != m_sharedString->string.get()) { - if ((Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) + if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) break; } @@ -4271,7 +4271,8 @@ namespace Nz { for (; startPos < m_sharedString->size; ++startPos) { - if ((Unicode::GetCategory(m_sharedString->string[startPos]) & Unicode::Category_Separator) == 0) + char c = m_sharedString->string[startPos]; + if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0) break; } } @@ -4281,7 +4282,8 @@ namespace Nz { for (; endPos > 0; --endPos) { - if ((Unicode::GetCategory(m_sharedString->string[endPos]) & Unicode::Category_Separator) == 0) + char c = m_sharedString->string[endPos]; + if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0) break; } } diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 9f7b6151c..cda183313 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -42,7 +42,7 @@ namespace Nz // Pour que le squelette soit correctement aligné, il faut appliquer un quaternion "de correction" aux joints à la base du squelette Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) * - Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); + Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); String baseDir = stream.GetDirectory(); diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index d8dfcb304..56e384bf0 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -194,6 +194,7 @@ namespace Nz m_currentLine = m_stream.ReadLine(); m_currentLine = m_currentLine.SubStringTo("//"); // On ignore les commentaires m_currentLine.Simplify(); // Pour un traitement plus simple + m_currentLine.Trim(); } while (m_currentLine.IsEmpty()); } From 176b1e904271c929839273fb5411205c73200c60 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 3 May 2016 22:44:01 +0200 Subject: [PATCH 006/383] Sdk/Binding: Fix querying argument of type IpAddress Former-commit-id: f080b4b9463aa0a7f0f881105c3b2c15f50e788e --- SDK/include/NDK/LuaAPI.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index 903e76c05..cbd4e7c4a 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -170,7 +170,7 @@ namespace Nz return 1; default: - *address = *(*static_cast(instance.CheckUserdata(index, "IpAddress"))); + *address = *static_cast(instance.CheckUserdata(index, "IpAddress")); return 1; } } From 371922ec11a458007bca75f352d3ed4ac98f33e3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 3 May 2016 23:04:56 +0200 Subject: [PATCH 007/383] Build: Rename .bat scripts Former-commit-id: 9124b087eb795f1b52e1f3702130c63b6176f667 --- build/{Build CodeBlocks (complete).bat => Build_CodeBlocks.bat} | 0 ...cks (complete, united).bat => Build_CodeBlocks_OneLibrary.bat} | 0 build/{Build CodeLite (complete).bat => Build_CodeLite.bat} | 0 ...eLite (complete, united).bat => Build_CodeLite_OneLibrary.bat} | 0 .../{Build Visual Studio 2015 (complete).bat => Build_VS2015.bat} | 0 ...io 2015 (complete, united).bat => Build_VS2015_OneLibrary.bat} | 0 build/{Encode Resources.bat => EncodeResources.bat} | 0 build/{Generate Headers.bat => Generate_GlobalIncludes.bat} | 0 build/{Parse Unicode.bat => Generate_UnicodeData.bat} | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename build/{Build CodeBlocks (complete).bat => Build_CodeBlocks.bat} (100%) rename build/{Build CodeBlocks (complete, united).bat => Build_CodeBlocks_OneLibrary.bat} (100%) rename build/{Build CodeLite (complete).bat => Build_CodeLite.bat} (100%) rename build/{Build CodeLite (complete, united).bat => Build_CodeLite_OneLibrary.bat} (100%) rename build/{Build Visual Studio 2015 (complete).bat => Build_VS2015.bat} (100%) rename build/{Build Visual Studio 2015 (complete, united).bat => Build_VS2015_OneLibrary.bat} (100%) rename build/{Encode Resources.bat => EncodeResources.bat} (100%) rename build/{Generate Headers.bat => Generate_GlobalIncludes.bat} (100%) rename build/{Parse Unicode.bat => Generate_UnicodeData.bat} (100%) diff --git a/build/Build CodeBlocks (complete).bat b/build/Build_CodeBlocks.bat similarity index 100% rename from build/Build CodeBlocks (complete).bat rename to build/Build_CodeBlocks.bat diff --git a/build/Build CodeBlocks (complete, united).bat b/build/Build_CodeBlocks_OneLibrary.bat similarity index 100% rename from build/Build CodeBlocks (complete, united).bat rename to build/Build_CodeBlocks_OneLibrary.bat diff --git a/build/Build CodeLite (complete).bat b/build/Build_CodeLite.bat similarity index 100% rename from build/Build CodeLite (complete).bat rename to build/Build_CodeLite.bat diff --git a/build/Build CodeLite (complete, united).bat b/build/Build_CodeLite_OneLibrary.bat similarity index 100% rename from build/Build CodeLite (complete, united).bat rename to build/Build_CodeLite_OneLibrary.bat diff --git a/build/Build Visual Studio 2015 (complete).bat b/build/Build_VS2015.bat similarity index 100% rename from build/Build Visual Studio 2015 (complete).bat rename to build/Build_VS2015.bat diff --git a/build/Build Visual Studio 2015 (complete, united).bat b/build/Build_VS2015_OneLibrary.bat similarity index 100% rename from build/Build Visual Studio 2015 (complete, united).bat rename to build/Build_VS2015_OneLibrary.bat diff --git a/build/Encode Resources.bat b/build/EncodeResources.bat similarity index 100% rename from build/Encode Resources.bat rename to build/EncodeResources.bat diff --git a/build/Generate Headers.bat b/build/Generate_GlobalIncludes.bat similarity index 100% rename from build/Generate Headers.bat rename to build/Generate_GlobalIncludes.bat diff --git a/build/Parse Unicode.bat b/build/Generate_UnicodeData.bat similarity index 100% rename from build/Parse Unicode.bat rename to build/Generate_UnicodeData.bat From 08926cf53019fb833342fb9d859cfdcfb834df89 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 3 May 2016 23:15:22 +0200 Subject: [PATCH 008/383] Core/Posix: Add absolutly not tested File::SetSize implementation At least the engine should compile again on posix Former-commit-id: c2ccdb9ad939b20e288b211aee678917934f1757 --- src/Nazara/Core/Posix/FileImpl.cpp | 5 +++++ src/Nazara/Core/Posix/FileImpl.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Nazara/Core/Posix/FileImpl.cpp b/src/Nazara/Core/Posix/FileImpl.cpp index 31c1ace73..f6e8b3bcc 100644 --- a/src/Nazara/Core/Posix/FileImpl.cpp +++ b/src/Nazara/Core/Posix/FileImpl.cpp @@ -118,6 +118,11 @@ namespace Nz return lseek64(m_fileDescriptor, offset, moveMethod) != -1; } + bool FileImpl::SetSize(UInt64 size) + { + return ftruncate64(m_fileDescriptor, size) != 0; + } + std::size_t FileImpl::Write(const void* buffer, std::size_t size) { lockf64(m_fileDescriptor, F_LOCK, size); diff --git a/src/Nazara/Core/Posix/FileImpl.hpp b/src/Nazara/Core/Posix/FileImpl.hpp index 844bebd29..4981a832e 100644 --- a/src/Nazara/Core/Posix/FileImpl.hpp +++ b/src/Nazara/Core/Posix/FileImpl.hpp @@ -39,6 +39,7 @@ namespace Nz bool Open(const String& filePath, UInt32 mode); std::size_t Read(void* buffer, std::size_t size); bool SetCursorPos(CursorPosition pos, Int64 offset); + bool SetSize(UInt64 size); std::size_t Write(const void* buffer, std::size_t size); FileImpl& operator=(const FileImpl&) = delete; From 5e5a83f825b13a3b4143e4d885cadfda921da576 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 3 May 2016 23:18:08 +0200 Subject: [PATCH 009/383] Utility: Fix some warnings Former-commit-id: e7645dc5a618d06f0c99bd54bf44756d68288959 --- src/Nazara/Utility/Formats/DDSLoader.cpp | 4 ++-- src/Nazara/Utility/SubMesh.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index 15ed11f95..baa2657b3 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -65,7 +65,7 @@ namespace Nz headerDX10.resourceDimension = D3D10_RESOURCE_DIMENSION_UNKNOWN; } - if (header.flags & DDSD_WIDTH == 0) + if ((header.flags & DDSD_WIDTH) == 0) NazaraWarning("Ill-formed DDS file, doesn't have a width flag"); unsigned int width = std::max(header.width, 1U); @@ -141,7 +141,7 @@ namespace Nz { if (header.ddsCaps[1] & DDSCAPS2_CUBEMAP) { - if (header.ddsCaps[1] & DDSCAPS2_CUBEMAP_ALLFACES != DDSCAPS2_CUBEMAP_ALLFACES) + if ((header.ddsCaps[1] & DDSCAPS2_CUBEMAP_ALLFACES) != DDSCAPS2_CUBEMAP_ALLFACES) { NazaraError("Partial cubemap are not yet supported, sorry"); return false; diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index ffe5a05f1..8b0589808 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -209,5 +209,5 @@ namespace Nz void SubMesh::SetMaterialIndex(unsigned int matIndex) { m_matIndex = matIndex; -} + } } From 51549f8526895a2463098526ca1b1e7f1fd8f0d9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 May 2016 20:40:25 +0200 Subject: [PATCH 010/383] Sdk/Binding: Add component access by name Former-commit-id: dd2e5d76254e8ce5e60db62e606c8129d784f528 --- SDK/include/NDK/LuaBinding.hpp | 15 +++--- SDK/include/NDK/LuaBinding.inl | 1 + SDK/src/NDK/LuaBinding_SDK.cpp | 92 ++++++++++++++++++++-------------- 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/SDK/include/NDK/LuaBinding.hpp b/SDK/include/NDK/LuaBinding.hpp index 265e9e452..0c1dea15e 100644 --- a/SDK/include/NDK/LuaBinding.hpp +++ b/SDK/include/NDK/LuaBinding.hpp @@ -83,12 +83,6 @@ namespace Ndk Nz::LuaClass nodeClass; // SDK - Nz::LuaClass application; - Nz::LuaClass entityClass; - Nz::LuaClass nodeComponent; - Nz::LuaClass velocityComponent; - Nz::LuaClass worldClass; - using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&); using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&); @@ -100,7 +94,16 @@ namespace Ndk Nz::String name; }; + ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 1); + + Nz::LuaClass application; + Nz::LuaClass entityClass; + Nz::LuaClass nodeComponent; + Nz::LuaClass velocityComponent; + Nz::LuaClass worldClass; + std::vector m_componentBinding; + std::unordered_map m_componentBindingByName; #ifndef NDK_SERVER // Audio diff --git a/SDK/include/NDK/LuaBinding.inl b/SDK/include/NDK/LuaBinding.inl index 5ca290398..64e3eb453 100644 --- a/SDK/include/NDK/LuaBinding.inl +++ b/SDK/include/NDK/LuaBinding.inl @@ -21,6 +21,7 @@ namespace Ndk m_componentBinding.resize(T::componentIndex + 1); m_componentBinding[T::componentIndex] = std::move(binding); + m_componentBindingByName[name] = T::componentIndex; } template diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 289e316a3..b371e76e3 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -59,56 +59,29 @@ namespace Ndk entityClass.BindMethod("Kill", &Entity::Kill); entityClass.BindMethod("IsEnabled", &Entity::IsEnabled); entityClass.BindMethod("IsValid", &Entity::IsValid); - entityClass.BindMethod("RemoveComponent", (void(Entity::*)(ComponentIndex)) &Entity::RemoveComponent); entityClass.BindMethod("RemoveAllComponents", &Entity::RemoveAllComponents); entityClass.BindMethod("__tostring", &EntityHandle::ToString); - entityClass.BindMethod("AddComponent", [this] (Nz::LuaInstance& lua, EntityHandle& handle) -> int + entityClass.BindMethod("AddComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle) -> int { - int index = 1; - ComponentIndex componentIndex = lua.Check(&index); + ComponentBinding* binding = QueryComponentIndex(instance); - if (componentIndex > m_componentBinding.size()) - { - lua.Error("Invalid component index"); - return 0; - } - - ComponentBinding& binding = m_componentBinding[componentIndex]; - if (binding.name.IsEmpty()) - { - lua.Error("This component is not available to the LuaAPI"); - return 0; - } - - return binding.adder(lua, handle); + return binding->adder(instance, handle); }); - entityClass.BindMethod("GetComponent", [this] (Nz::LuaInstance& lua, EntityHandle& handle) -> int + entityClass.BindMethod("GetComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle) -> int { - int index = 1; - ComponentIndex componentIndex = lua.Check(&index); + ComponentBinding* binding = QueryComponentIndex(instance); - if (!handle->HasComponent(componentIndex)) - { - lua.PushNil(); - return 1; - } + return binding->getter(instance, handle->GetComponent(binding->index)); + }); - if (componentIndex > m_componentBinding.size()) - { - lua.Error("Invalid component index"); - return 0; - } + entityClass.BindMethod("RemoveComponent", [this] (Nz::LuaInstance& instance, EntityHandle& handle) -> int + { + ComponentBinding* binding = QueryComponentIndex(instance); - ComponentBinding& binding = m_componentBinding[componentIndex]; - if (binding.name.IsEmpty()) - { - lua.Error("This component is not available to the LuaAPI"); - return 0; - } - - return binding.getter(lua, handle->GetComponent(componentIndex)); + handle->RemoveComponent(binding->index); + return 0; }); /*********************************** Ndk::NodeComponent **********************************/ @@ -199,4 +172,45 @@ namespace Ndk } instance.SetGlobal("ComponentType"); } + + LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex) + { + switch (instance.GetType(argIndex)) + { + case Nz::LuaType_Number: + { + ComponentIndex componentIndex = instance.Check(&argIndex); + if (componentIndex > m_componentBinding.size()) + { + instance.Error("Invalid component index"); + return nullptr; + } + + ComponentBinding& binding = m_componentBinding[componentIndex]; + if (binding.name.IsEmpty()) + { + instance.Error("Invalid component index"); + return nullptr; + } + + return &binding; + } + + case Nz::LuaType_String: + { + const char* key = instance.CheckString(argIndex); + auto it = m_componentBindingByName.find(key); + if (it == m_componentBindingByName.end()) + { + instance.Error("Invalid component name"); + return nullptr; + } + + return &m_componentBinding[it->second]; + } + } + + instance.Error("Invalid component index at #" + Nz::String::Number(argIndex)); + return nullptr; + } } From f7b0496d626798074cf9af27ad446a7c875ff87d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 May 2016 21:27:36 +0200 Subject: [PATCH 011/383] UnitTests: Fix errors Former-commit-id: 7d338bd57e8a083e63c5f6387ff37c81109903ed --- include/Nazara/Core.hpp | 2 +- include/Nazara/Core/Algorithm.hpp | 2 +- include/Nazara/Core/Algorithm.inl | 13 ++----- include/Nazara/Core/ByteStream.hpp | 2 +- ...alization.hpp => SerializationContext.hpp} | 8 ++++- include/Nazara/Core/SerializationContext.inl | 24 +++++++++++++ include/Nazara/Core/String.hpp | 2 +- src/Nazara/Core/File.cpp | 32 ++++++++--------- src/Nazara/Core/SerializationContext.cpp | 35 +++++++++++++++++++ src/Nazara/Utility/Formats/DDSConstants.hpp | 2 +- tests/Engine/Core/Bitset.cpp | 2 +- tests/Engine/Core/File.cpp | 6 ++-- tests/Engine/Core/Serialization.cpp | 3 +- 13 files changed, 96 insertions(+), 37 deletions(-) rename include/Nazara/Core/{Serialization.hpp => SerializationContext.hpp} (79%) create mode 100644 include/Nazara/Core/SerializationContext.inl create mode 100644 src/Nazara/Core/SerializationContext.cpp diff --git a/include/Nazara/Core.hpp b/include/Nazara/Core.hpp index a9a93d45c..f2be4f231 100644 --- a/include/Nazara/Core.hpp +++ b/include/Nazara/Core.hpp @@ -73,7 +73,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index 5f8b8aa7f..f031854c5 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index c45147d79..821a9069f 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -209,14 +209,8 @@ namespace Nz template std::enable_if_t::value, bool> Serialize(SerializationContext& context, T value) { - // Flush bits if a writing is in progress - if (context.currentBitPos != 8) - { - context.currentBitPos = 8; - - if (!Serialize(context, context.currentByte)) - NazaraWarning("Failed to flush bits"); - } + // Flush bits in case a writing is in progress + context.FlushBits(); if (context.endianness != Endianness_Unknown && context.endianness != GetPlatformEndianness()) SwapBytes(&value, sizeof(T)); @@ -269,8 +263,7 @@ namespace Nz { NazaraAssert(value, "Invalid data pointer"); - // Reset bit position - context.currentBitPos = 8; + context.ResetBitPosition(); if (context.stream->Read(value, sizeof(T)) == sizeof(T)) { diff --git a/include/Nazara/Core/ByteStream.hpp b/include/Nazara/Core/ByteStream.hpp index e26382cf4..fe1516b06 100644 --- a/include/Nazara/Core/ByteStream.hpp +++ b/include/Nazara/Core/ByteStream.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/include/Nazara/Core/Serialization.hpp b/include/Nazara/Core/SerializationContext.hpp similarity index 79% rename from include/Nazara/Core/Serialization.hpp rename to include/Nazara/Core/SerializationContext.hpp index 47339b0a2..64c558a7b 100644 --- a/include/Nazara/Core/Serialization.hpp +++ b/include/Nazara/Core/SerializationContext.hpp @@ -8,6 +8,7 @@ #define NAZARA_SERIALIZATION_HPP #include +#include #include #include #include @@ -17,13 +18,18 @@ namespace Nz { class Stream; - struct SerializationContext + struct NAZARA_CORE_API SerializationContext { Stream* stream; Endianness endianness = Endianness_BigEndian; //< Default to Big Endian encoding UInt8 currentBitPos = 8; //< 8 means no bit is currently wrote UInt8 currentByte; //< Undefined value, will be initialized at the first bit write + + void FlushBits(); + inline void ResetBitPosition(); }; } +#include + #endif // NAZARA_SERIALIZATION_HPP diff --git a/include/Nazara/Core/SerializationContext.inl b/include/Nazara/Core/SerializationContext.inl new file mode 100644 index 000000000..47f56e5c2 --- /dev/null +++ b/include/Nazara/Core/SerializationContext.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \brief Reset the current bit cursor + + * \remark This function only reset the cursor position, it doesn't do any writing + if you wish to write all bits and reset bit position, call FlushBits + + \see FlushBits + */ + inline void SerializationContext::ResetBitPosition() + { + currentBitPos = 8; + } +} + +#include diff --git a/include/Nazara/Core/String.hpp b/include/Nazara/Core/String.hpp index 70673ae8a..765ef8b85 100644 --- a/include/Nazara/Core/String.hpp +++ b/include/Nazara/Core/String.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 8505e42f9..97504b0ee 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -454,24 +454,24 @@ namespace Nz return true; } - /*! - * \brief Sets the size of the file - * \return true if the file size has correctly changed - * - * \param size The size the file should have after this call - * - * \remark The cursor position is not affected by this call - * \remark The file must be open in write mode - */ - bool File::SetSize(UInt64 size) - { - NazaraLock(m_mutex) + /*! + * \brief Sets the size of the file + * \return true if the file size has correctly changed + * + * \param size The size the file should have after this call + * + * \remark The cursor position is not affected by this call + * \remark The file must be open in write mode + */ + bool File::SetSize(UInt64 size) + { + NazaraLock(m_mutex) - NazaraAssert(IsOpen(), "File is not open"); - NazaraAssert(IsWritable(), "File is not writable"); + NazaraAssert(IsOpen(), "File is not open"); + NazaraAssert(IsWritable(), "File is not writable"); - return m_impl->SetSize(size); - } + return m_impl->SetSize(size); + } /*! * \brief Sets the file path diff --git a/src/Nazara/Core/SerializationContext.cpp b/src/Nazara/Core/SerializationContext.cpp new file mode 100644 index 000000000..734b3b23d --- /dev/null +++ b/src/Nazara/Core/SerializationContext.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + + /*! + * \ingroup core + * \class Nz::SerializationContext + * \brief Structure containing a serialization/unserialization context states + */ + + /*! + * Write bits to the stream (if any) and reset the current bit cursor + + * \see ResetBitPosition + */ + void SerializationContext::FlushBits() + { + if (currentBitPos != 8) + { + ResetBitPosition(); + + // Serialize will reset the bit position + if (!Serialize(*this, currentByte)) + NazaraWarning("Failed to flush bits"); + } + } +} diff --git a/src/Nazara/Utility/Formats/DDSConstants.hpp b/src/Nazara/Utility/Formats/DDSConstants.hpp index 47a1766a4..4839df800 100644 --- a/src/Nazara/Utility/Formats/DDSConstants.hpp +++ b/src/Nazara/Utility/Formats/DDSConstants.hpp @@ -8,7 +8,7 @@ #define NAZARA_LOADERS_DDS_CONSTANTS_HPP #include -#include +#include #include namespace Nz diff --git a/tests/Engine/Core/Bitset.cpp b/tests/Engine/Core/Bitset.cpp index 76c35c886..cb870f7a4 100644 --- a/tests/Engine/Core/Bitset.cpp +++ b/tests/Engine/Core/Bitset.cpp @@ -7,7 +7,7 @@ SCENARIO("Bitset", "[CORE][BITSET]") { GIVEN("Allocate and constructor") { - Nz::Bitset<> bitset(3); + Nz::Bitset<> bitset(3, false); THEN("Capacity is 3 and size is 3") { diff --git a/tests/Engine/Core/File.cpp b/tests/Engine/Core/File.cpp index 2a87c8495..2ddbfebbf 100644 --- a/tests/Engine/Core/File.cpp +++ b/tests/Engine/Core/File.cpp @@ -78,9 +78,9 @@ SCENARIO("File", "[CORE][FILE]") THEN("The relative positioning should disappear") { - Nz::String containingNoMoreDot = "/resources/Spaceship/spaceship.mtl"; - REQUIRE(Nz::File::AbsolutePath(containingDot) == containingNoMoreDot); - REQUIRE(Nz::File::AbsolutePath(containingDoubleDot) == containingNoMoreDot); + Nz::String containingNoMoreDot = Nz::File::NormalizePath("/resources/Spaceship/spaceship.mtl"); + REQUIRE(Nz::File::AbsolutePath(containingDot).EndsWith(containingNoMoreDot)); + REQUIRE(Nz::File::AbsolutePath(containingDoubleDot).EndsWith(containingNoMoreDot)); } } } diff --git a/tests/Engine/Core/Serialization.cpp b/tests/Engine/Core/Serialization.cpp index a4d8ff75e..cc556dec8 100644 --- a/tests/Engine/Core/Serialization.cpp +++ b/tests/Engine/Core/Serialization.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -35,6 +35,7 @@ SCENARIO("Serialization", "[CORE][SERIALIZATION]") { context.stream->SetCursorPos(0); REQUIRE(Serialize(context, true)); + context.FlushBits(); //< Don't forget to flush bits (it is NOT done by the stream) context.stream->SetCursorPos(0); bool value = false; REQUIRE(Unserialize(context, &value)); From acdabbc432ada328de4056825fcd07932955e51f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 May 2016 21:50:44 +0200 Subject: [PATCH 012/383] Examples: Fix MeshInfos since material update Former-commit-id: fc8768a889c59e761983e20d9633dd0dee720a6a --- examples/MeshInfos/main.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/MeshInfos/main.cpp b/examples/MeshInfos/main.cpp index ba55d2686..73864abaa 100644 --- a/examples/MeshInfos/main.cpp +++ b/examples/MeshInfos/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,7 @@ int main() for (;;) { - Nz::Directory resourceDirectory("resources/"); + Nz::Directory resourceDirectory("resources"); if (!resourceDirectory.Open()) { std::cerr << "Failed to open resource directory" << std::endl; @@ -68,7 +69,7 @@ int main() break; Nz::Mesh mesh; - if (!mesh.LoadFromFile("resources/" + models[iChoice-1])) + if (!mesh.LoadFromFile(resourceDirectory.GetPath() + '/' + models[iChoice-1])) { std::cout << "Failed to load mesh" << std::endl; std::getchar(); @@ -168,8 +169,18 @@ int main() { for (unsigned int i = 0; i < materialCount; ++i) { - std::cout << "\t" << (i+1) << ": " << mesh.GetMaterial(i) << std::endl; - std::cin.ignore(std::numeric_limits::max(), '\n'); + const Nz::ParameterList& matData = mesh.GetMaterialData(i); + + Nz::String data; + if (!matData.GetStringParameter(Nz::MaterialData::FilePath, &data)) + { + if (matData.HasParameter(Nz::MaterialData::CustomDefined)) + data = ""; + else + data = ""; + } + + std::cout << "\t" << (i+1) << ": " << data << std::endl; } } From 7e037e4d6fcf2059b13c9e4e24de72f22bba5b6b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 May 2016 23:36:34 +0200 Subject: [PATCH 013/383] Build: Add an option to copy the built library to the example directory Former-commit-id: e9b2df26e19917355e3bbc486892f2aeead2ae0e --- .gitignore | 2 ++ build/scripts/common.lua | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index d671b209b..258594792 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Nazara build examples/bin/*.exe examples/bin/*.pdb +examples/bin/*.dll +examples/bin/*.so tests/*.exe tests/*.pdb lib/* diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 266b50f85..405b66b60 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -298,6 +298,14 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end + -- Copy the module binaries to the example folder + if (toolTable.CopyTargetToExampleDir) then + if (os.is("windows")) then + configuration({}) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) + end + end + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") From 190462fd314eff6fefd70f0ff41d084f2f2bd49e Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 May 2016 23:36:53 +0200 Subject: [PATCH 014/383] Build/Tool: Make Assimp plugin copy its library file to the example directory Former-commit-id: eaf807d1f7f5148413dd7ab8729cdf52113ba5d8 --- build/scripts/tools/assimp.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index 0eecbcd54..3a1ca093b 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -3,6 +3,8 @@ TOOL.Name = "Assimp" TOOL.Directory = "../SDK/lib" TOOL.Kind = "Plugin" +TOOL.CopyTargetToExampleDir = true + TOOL.Includes = { "../include", "../plugins/Assimp" From e34c94343f550b59835116c1c51e1018b9fb6b38 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 6 May 2016 19:15:15 +0200 Subject: [PATCH 015/383] Core/Bitset: Fix value constructor Former-commit-id: 44cfe386a985a4b449527a9fab3d5da49e30117c --- include/Nazara/Core/Bitset.hpp | 2 +- include/Nazara/Core/Bitset.inl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index a371212ab..3b440278c 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -31,7 +31,7 @@ namespace Nz Bitset(const char* bits, unsigned int bitCount); Bitset(const Bitset& bitset) = default; explicit Bitset(const String& bits); - template explicit Bitset(T value); + template Bitset(T value); Bitset(Bitset&& bitset) noexcept = default; ~Bitset() noexcept = default; diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index d689ff18a..efea1d2db 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -120,14 +120,14 @@ namespace Nz { if (sizeof(T) <= sizeof(Block)) { - m_bitCount = CountBits(value); + m_bitCount = std::numeric_limits::digits; m_blocks.push_back(value); } else { // Note: I was kinda tired when I wrote this, there's probably a much easier method than checking bits to write bits unsigned int bitPos = 0; - for (T bit = 1; bit < std::numeric_limits::digits; bit <<= 1) + for (T bit = 1; bit < std::numeric_limits::max(); bit <<= 1) { if (value & bit) UnboundedSet(bitPos, true); @@ -838,7 +838,7 @@ namespace Nz Block block = m_blocks[i]; - // Compute the position of LSB in the block (and adjustement of the position) + // Compute the position of LSB in the block (and adjustment of the position) return IntegralLog2Pot(block & -block) + i*bitsPerBlock; } From cc5d719a646f79a9864ec2d8e858b51492f276f0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 6 May 2016 20:29:45 +0200 Subject: [PATCH 016/383] Vulkan/Device: Make Device a handled object Former-commit-id: c21479718e2de1ade137635a2f7ac40ef6f060cd --- include/Nazara/Vulkan/VkDevice.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 06247ab19..084aaa2f0 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKAN_VKDEVICE_HPP #include +#include #include #include #include @@ -17,9 +18,12 @@ namespace Nz { namespace Vk { + class Device; class Instance; - class NAZARA_VULKAN_API Device + using DeviceHandle = ObjectHandle; + + class NAZARA_VULKAN_API Device : public HandledObject { public: inline Device(Instance& instance); From 7db8507874e96a1efebab29141eaf7709dcc2bbd Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 9 May 2016 09:03:11 +0200 Subject: [PATCH 017/383] Core/ObjectHandle: Add noexcept move constructor/assignment Former-commit-id: 930de41518be74fff072e061f735afceb218138c --- SDK/include/NDK/EntityOwner.hpp | 4 ++-- SDK/include/NDK/EntityOwner.inl | 12 ----------- include/Nazara/Core/HandledObject.hpp | 3 ++- include/Nazara/Core/HandledObject.inl | 16 +++++++++++--- include/Nazara/Core/ObjectHandle.hpp | 3 +++ include/Nazara/Core/ObjectHandle.inl | 30 ++++++++++++++++++++++++++- 6 files changed, 49 insertions(+), 19 deletions(-) diff --git a/SDK/include/NDK/EntityOwner.hpp b/SDK/include/NDK/EntityOwner.hpp index c7cab901f..d0a4a4f59 100644 --- a/SDK/include/NDK/EntityOwner.hpp +++ b/SDK/include/NDK/EntityOwner.hpp @@ -17,7 +17,7 @@ namespace Ndk EntityOwner() = default; explicit EntityOwner(Entity* entity); EntityOwner(const EntityOwner& handle) = delete; - EntityOwner(EntityOwner&& handle); + EntityOwner(EntityOwner&& handle) noexcept = default; ~EntityOwner(); void Reset(Entity* entity = nullptr); @@ -25,7 +25,7 @@ namespace Ndk EntityOwner& operator=(Entity* entity); EntityOwner& operator=(const EntityOwner& handle) = delete; - EntityOwner& operator=(EntityOwner&& handle); + EntityOwner& operator=(EntityOwner&& handle) noexcept = default; }; } diff --git a/SDK/include/NDK/EntityOwner.inl b/SDK/include/NDK/EntityOwner.inl index 607f3229d..6efc2b30e 100644 --- a/SDK/include/NDK/EntityOwner.inl +++ b/SDK/include/NDK/EntityOwner.inl @@ -14,11 +14,6 @@ namespace Ndk Reset(entity); } - inline EntityOwner::EntityOwner(EntityOwner&& handle) : - EntityHandle(std::move(handle)) - { - } - inline EntityOwner::~EntityOwner() { Reset(nullptr); @@ -44,13 +39,6 @@ namespace Ndk return *this; } - - inline EntityOwner& EntityOwner::operator=(EntityOwner&& handle) - { - Reset(std::move(handle)); - - return *this; - } } namespace std diff --git a/include/Nazara/Core/HandledObject.hpp b/include/Nazara/Core/HandledObject.hpp index f1e096748..eeb9c4bfa 100644 --- a/include/Nazara/Core/HandledObject.hpp +++ b/include/Nazara/Core/HandledObject.hpp @@ -36,7 +36,8 @@ namespace Nz private: void RegisterHandle(ObjectHandle* handle); - void UnregisterHandle(ObjectHandle* handle); + void UnregisterHandle(ObjectHandle* handle) noexcept; + void UpdateHandle(ObjectHandle* oldHandle, ObjectHandle* newHandle) noexcept; std::vector*> m_handles; }; diff --git a/include/Nazara/Core/HandledObject.inl b/include/Nazara/Core/HandledObject.inl index 53a5065f4..738a5f7a5 100644 --- a/include/Nazara/Core/HandledObject.inl +++ b/include/Nazara/Core/HandledObject.inl @@ -71,14 +71,24 @@ namespace Nz } template - void HandledObject::UnregisterHandle(ObjectHandle* handle) + void HandledObject::UnregisterHandle(ObjectHandle* handle) noexcept { ///DOC: Un handle ne doit être libéré qu'une fois, et doit faire partie de la liste, sous peine de crash auto it = std::find(m_handles.begin(), m_handles.end(), handle); - NazaraAssert(it != m_handles.end(), "Handle not registred"); + NazaraAssert(it != m_handles.end(), "Handle not registered"); - // On échange cet élément avec le dernier, et on diminue la taille du vector de 1 + // Swap and pop idiom, more efficient than vector::erase std::swap(*it, m_handles.back()); m_handles.pop_back(); } + + template + void HandledObject::UpdateHandle(ObjectHandle* oldHandle, ObjectHandle* newHandle) noexcept + { + auto it = std::find(m_handles.begin(), m_handles.end(), oldHandle); + NazaraAssert(it != m_handles.end(), "Handle not registered"); + + // Simply update the handle + *it = newHandle; + } } diff --git a/include/Nazara/Core/ObjectHandle.hpp b/include/Nazara/Core/ObjectHandle.hpp index d7a53e281..b3cc080dd 100644 --- a/include/Nazara/Core/ObjectHandle.hpp +++ b/include/Nazara/Core/ObjectHandle.hpp @@ -23,6 +23,7 @@ namespace Nz ObjectHandle(); explicit ObjectHandle(T* object); ObjectHandle(const ObjectHandle& handle); + ObjectHandle(ObjectHandle&& handle) noexcept; ~ObjectHandle(); T* GetObject() const; @@ -31,6 +32,7 @@ namespace Nz void Reset(T* object = nullptr); void Reset(const ObjectHandle& handle); + void Reset(ObjectHandle&& handle) noexcept; ObjectHandle& Swap(ObjectHandle& handle); @@ -42,6 +44,7 @@ namespace Nz ObjectHandle& operator=(T* object); ObjectHandle& operator=(const ObjectHandle& handle); + ObjectHandle& operator=(ObjectHandle&& handle) noexcept; static const ObjectHandle InvalidHandle; diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index 752cb96c0..ef89828e3 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -24,11 +24,18 @@ namespace Nz template ObjectHandle::ObjectHandle(const ObjectHandle& handle) : - ObjectHandle() + ObjectHandle() { Reset(handle); } + template + ObjectHandle::ObjectHandle(ObjectHandle&& handle) noexcept : + ObjectHandle() + { + Reset(std::move(handle)); + } + template ObjectHandle::~ObjectHandle() { @@ -66,6 +73,19 @@ namespace Nz Reset(handle.GetObject()); } + template + void ObjectHandle::Reset(ObjectHandle&& handle) noexcept + { + if (m_object) + m_object->UnregisterHandle(this); + + if (T* object = handle.GetObject()) + { + object->UpdateHandle(&handle, this); + handle.m_object = nullptr; + } + } + template ObjectHandle& ObjectHandle::Swap(ObjectHandle& handle) { @@ -138,6 +158,14 @@ namespace Nz return *this; } + template + ObjectHandle& ObjectHandle::operator=(ObjectHandle&& handle) noexcept + { + Reset(std::move(handle)); + + return *this; + } + template void ObjectHandle::OnObjectDestroyed() { From 34bc2301a0df87ab21b2a2c9ed5efa121f208faf Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 9 May 2016 18:10:46 +0200 Subject: [PATCH 018/383] Core/Bitset: Fix infinite loop Former-commit-id: 366ad4248a72e3e06637163b44a9a5cedbbaf195 --- include/Nazara/Core/Bitset.inl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index efea1d2db..568d4a815 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -126,13 +126,10 @@ namespace Nz else { // Note: I was kinda tired when I wrote this, there's probably a much easier method than checking bits to write bits - unsigned int bitPos = 0; - for (T bit = 1; bit < std::numeric_limits::max(); bit <<= 1) + for (unsigned int bitPos = 0; bitPos < std::numeric_limits::digits; bitPos++) { - if (value & bit) + if (value & (T(1U) << bitPos)) UnboundedSet(bitPos, true); - - bitPos++; } } } From e8a4be2039c577fd28002c50c7c564e8f642ad1e Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 9 May 2016 18:10:58 +0200 Subject: [PATCH 019/383] Core/ObjectHandle: Fix movement Former-commit-id: 8fd32af2b58e8f0d2146232c23a8405e3e012349 --- include/Nazara/Core/ObjectHandle.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index ef89828e3..cfcd6bc0d 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -81,8 +81,9 @@ namespace Nz if (T* object = handle.GetObject()) { - object->UpdateHandle(&handle, this); + m_object = handle.m_object; handle.m_object = nullptr; + object->UpdateHandle(&handle, this); } } From f941a751b5c4b1114ca8c1f2ca6f7d2d01932d0d Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 9 May 2016 18:11:11 +0200 Subject: [PATCH 020/383] Core: Update global include Former-commit-id: 40702153f3a811a8d01155094257c0a7e1d34918 --- include/Nazara/Core.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core.hpp b/include/Nazara/Core.hpp index f2be4f231..5f3c85c4c 100644 --- a/include/Nazara/Core.hpp +++ b/include/Nazara/Core.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 03 Feb 2016 at 00:06:56 +// This file was automatically generated on 09 May 2016 at 17:07:09 /* Nazara Engine - Core module @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +74,8 @@ #include #include #include +#include +#include #include #include #include From 16c229bc90671183f39aee49e40314b91c074374 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 9 May 2016 19:38:30 +0200 Subject: [PATCH 021/383] Sdk/LuaBinding: Make LuaClass members public Former-commit-id: 31867b0b6233641952e71638b90c49c7702a26e8 --- SDK/include/NDK/LuaBinding.hpp | 79 +++++++++++++++++----------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/SDK/include/NDK/LuaBinding.hpp b/SDK/include/NDK/LuaBinding.hpp index 0c1dea15e..cb4fc24e5 100644 --- a/SDK/include/NDK/LuaBinding.hpp +++ b/SDK/include/NDK/LuaBinding.hpp @@ -37,29 +37,6 @@ namespace Ndk void RegisterClasses(Nz::LuaInstance& instance); - private: - void BindCore(); - void BindMath(); - void BindNetwork(); - void BindSDK(); - void BindUtility(); - - void RegisterCore(Nz::LuaInstance& instance); - void RegisterMath(Nz::LuaInstance& instance); - void RegisterNetwork(Nz::LuaInstance& instance); - void RegisterSDK(Nz::LuaInstance& instance); - void RegisterUtility(Nz::LuaInstance& instance); - - #ifndef NDK_SERVER - void BindAudio(); - void BindGraphics(); - void BindRenderer(); - - void RegisterAudio(Nz::LuaInstance& instance); - void RegisterGraphics(Nz::LuaInstance& instance); - void RegisterRenderer(Nz::LuaInstance& instance); - #endif - // Core Nz::LuaClass clockClass; Nz::LuaClass directoryClass; @@ -83,28 +60,12 @@ namespace Ndk Nz::LuaClass nodeClass; // SDK - using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&); - using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&); - - struct ComponentBinding - { - AddComponentFunc adder; - ComponentIndex index; - GetComponentFunc getter; - Nz::String name; - }; - - ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 1); - Nz::LuaClass application; Nz::LuaClass entityClass; Nz::LuaClass nodeComponent; Nz::LuaClass velocityComponent; Nz::LuaClass worldClass; - std::vector m_componentBinding; - std::unordered_map m_componentBindingByName; - #ifndef NDK_SERVER // Audio Nz::LuaClass musicClass; @@ -120,6 +81,46 @@ namespace Ndk Nz::LuaClass consoleClass; Nz::LuaClass graphicsComponent; #endif + + private: + void BindCore(); + void BindMath(); + void BindNetwork(); + void BindSDK(); + void BindUtility(); + + void RegisterCore(Nz::LuaInstance& instance); + void RegisterMath(Nz::LuaInstance& instance); + void RegisterNetwork(Nz::LuaInstance& instance); + void RegisterSDK(Nz::LuaInstance& instance); + void RegisterUtility(Nz::LuaInstance& instance); + + #ifndef NDK_SERVER + void BindAudio(); + void BindGraphics(); + void BindRenderer(); + + void RegisterAudio(Nz::LuaInstance& instance); + void RegisterGraphics(Nz::LuaInstance& instance); + void RegisterRenderer(Nz::LuaInstance& instance); + #endif + + + using AddComponentFunc = int(*)(Nz::LuaInstance&, EntityHandle&); + using GetComponentFunc = int(*)(Nz::LuaInstance&, BaseComponent&); + + struct ComponentBinding + { + AddComponentFunc adder; + ComponentIndex index; + GetComponentFunc getter; + Nz::String name; + }; + + ComponentBinding* QueryComponentIndex(Nz::LuaInstance& lua, int argIndex = 1); + + std::vector m_componentBinding; + std::unordered_map m_componentBindingByName; }; template From 0bd8904878100b370892c82c022323c5fd61554b Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 11 May 2016 12:27:18 +0200 Subject: [PATCH 022/383] Utility/*TextDrawer: Fix bounds starting at a negative position Former-commit-id: 4954d0f3d1b10d4b7512c7b57936bc73c7ea69ae --- include/Nazara/Graphics/TextSprite.hpp | 2 +- include/Nazara/Utility/AbstractTextDrawer.hpp | 2 +- include/Nazara/Utility/SimpleTextDrawer.hpp | 4 ++-- src/Nazara/Utility/SimpleTextDrawer.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Graphics/TextSprite.hpp b/include/Nazara/Graphics/TextSprite.hpp index db99077e2..8e0afa93e 100644 --- a/include/Nazara/Graphics/TextSprite.hpp +++ b/include/Nazara/Graphics/TextSprite.hpp @@ -77,7 +77,7 @@ namespace Nz mutable std::vector m_localVertices; Color m_color; MaterialRef m_material; - Rectui m_localBounds; + Recti m_localBounds; mutable bool m_verticesUpdated; float m_scale; diff --git a/include/Nazara/Utility/AbstractTextDrawer.hpp b/include/Nazara/Utility/AbstractTextDrawer.hpp index 20aac4db3..ffd704f6a 100644 --- a/include/Nazara/Utility/AbstractTextDrawer.hpp +++ b/include/Nazara/Utility/AbstractTextDrawer.hpp @@ -26,7 +26,7 @@ namespace Nz AbstractTextDrawer() = default; virtual ~AbstractTextDrawer(); - virtual const Rectui& GetBounds() const = 0; + virtual const Recti& GetBounds() const = 0; virtual Font* GetFont(unsigned int index) const = 0; virtual unsigned int GetFontCount() const = 0; virtual const Glyph& GetGlyph(unsigned int index) const = 0; diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 3f87bf3bb..f5532ca8f 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -28,7 +28,7 @@ namespace Nz void Clear(); - const Rectui& GetBounds() const override; + const Recti& GetBounds() const override; unsigned int GetCharacterSize() const; const Color& GetColor() const; Font* GetFont() const; @@ -71,7 +71,7 @@ namespace Nz Color m_color; FontRef m_font; mutable Rectf m_workingBounds; - mutable Rectui m_bounds; + mutable Recti m_bounds; String m_text; mutable UInt32 m_previousCharacter; UInt32 m_style; diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index cc2130c05..ae2dc8762 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -49,7 +49,7 @@ namespace Nz ClearGlyphs(); } - const Rectui& SimpleTextDrawer::GetBounds() const + const Recti& SimpleTextDrawer::GetBounds() const { if (!m_glyphUpdated) UpdateGlyphs(); From 24e23be7ea51b9b129a7deee0c3e5bf357539af0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 13 May 2016 12:47:43 +0200 Subject: [PATCH 023/383] Graphics/Material: Add Basic2D and Translucent2D materials Former-commit-id: 4c5d24d76d22894985e591036589ebba95f320d9 --- src/Nazara/Graphics/Material.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index c646d940b..9a95c656b 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -911,12 +911,29 @@ namespace Nz UberShaderLibrary::Register("PhongLighting", uberShader); } - // Une fois les shaders de base enregistrés, on peut créer le matériau par défaut - s_defaultMaterial = Material::New(); + // Once the base shaders are registered, we can now set some default materials + s_defaultMaterial = New(); s_defaultMaterial->Enable(RendererParameter_FaceCulling, false); s_defaultMaterial->SetFaceFilling(FaceFilling_Line); MaterialLibrary::Register("Default", s_defaultMaterial); + MaterialRef mat; + + mat = New(); + mat->Enable(RendererParameter_DepthWrite, false); + mat->Enable(RendererParameter_FaceCulling, false); + mat->EnableLighting(false); + MaterialLibrary::Register("Basic2D", std::move(mat)); + + mat = New(); + mat->Enable(RendererParameter_Blend, true); + mat->Enable(RendererParameter_DepthWrite, false); + mat->Enable(RendererParameter_FaceCulling, false); + mat->EnableLighting(false); + mat->SetDstBlend(BlendFunc_InvSrcAlpha); + mat->SetSrcBlend(BlendFunc_SrcAlpha); + MaterialLibrary::Register("Translucent2D", std::move(mat)); + return true; } From 9f6a311c076df74eb7eb2d2850fb29f8f636c1d7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 13 May 2016 12:47:53 +0200 Subject: [PATCH 024/383] Core/Color: Add IsOpaque method Former-commit-id: 4e9dd99525a550af90a1de1a8c86e3120e33a5de --- include/Nazara/Core/Color.hpp | 2 ++ include/Nazara/Core/Color.inl | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/Nazara/Core/Color.hpp b/include/Nazara/Core/Color.hpp index 91a8cc43d..5fef4f854 100644 --- a/include/Nazara/Core/Color.hpp +++ b/include/Nazara/Core/Color.hpp @@ -25,6 +25,8 @@ namespace Nz inline Color(const Color& color) = default; inline ~Color() = default; + inline bool IsOpaque() const; + inline String ToString() const; inline Color operator+(const Color& angles) const; diff --git a/include/Nazara/Core/Color.inl b/include/Nazara/Core/Color.inl index 4ac3a2246..5d71393df 100644 --- a/include/Nazara/Core/Color.inl +++ b/include/Nazara/Core/Color.inl @@ -72,6 +72,15 @@ namespace Nz { } + /*! + * \brief Return true is the color has no degree of transparency + * \return true if the color has an alpha value of 255 + */ + inline bool Color::IsOpaque() const + { + return a == 255; + } + /*! * \brief Converts this to string * \return String representation of the object "Color(r, g, b[, a])" From 1715ca19b5eff821488f34ba6ca16c17daf9a558 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 13 May 2016 13:02:42 +0200 Subject: [PATCH 025/383] Sdk/CameraComponent: Clean include Former-commit-id: d0856ba86be59ed82c9b044b270f6369ed1f57be --- SDK/include/NDK/Components/CameraComponent.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index 7ff31d623..d3bb9177e 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -2,9 +2,9 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include -#include "CameraComponent.hpp" namespace Ndk { From a8fa5e1d124ff0e4cb84df74c8e6a76cc3e3961e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 May 2016 14:46:15 +0200 Subject: [PATCH 026/383] Vulkan: Use a generic class helper for all device objects This greatly reduce the amount of code required for wrappers around Vulkan Objects Former-commit-id: 885d0b39197ba41fd856c45571dbf06d8ae27d8c --- include/Nazara/Vulkan/VkDeviceObject.hpp | 49 +++++++++++++++++ include/Nazara/Vulkan/VkDeviceObject.inl | 67 ++++++++++++++++++++++++ include/Nazara/Vulkan/VkSemaphore.hpp | 23 +++----- include/Nazara/Vulkan/VkSemaphore.inl | 42 ++------------- include/Nazara/Vulkan/VkSwapchain.hpp | 22 ++------ include/Nazara/Vulkan/VkSwapchain.inl | 42 +-------------- 6 files changed, 133 insertions(+), 112 deletions(-) create mode 100644 include/Nazara/Vulkan/VkDeviceObject.hpp create mode 100644 include/Nazara/Vulkan/VkDeviceObject.inl diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp new file mode 100644 index 000000000..efad29c30 --- /dev/null +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKAN_VKDEVICEOBJECT_HPP +#define NAZARA_VULKAN_VKDEVICEOBJECT_HPP + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + class DeviceObject + { + public: + inline DeviceObject(Device& instance); + DeviceObject(const DeviceObject&) = delete; + DeviceObject(DeviceObject&&) = delete; + inline ~DeviceObject(); + + inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + inline void Destroy(); + + inline VkResult GetLastErrorCode() const; + + DeviceObject& operator=(const DeviceObject&) = delete; + DeviceObject& operator=(DeviceObject&&) = delete; + + inline operator VkType(); + + protected: + Device& m_device; + VkAllocationCallbacks m_allocator; + VkType m_handle; + VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl new file mode 100644 index 000000000..7aa313ca9 --- /dev/null +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -0,0 +1,67 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + inline DeviceObject::DeviceObject(Device& device) : + m_device(device), + m_handle(VK_NULL_HANDLE) + { + } + + template + inline DeviceObject::~DeviceObject() + { + Destroy(); + } + + template + inline bool DeviceObject::Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + { + m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to create Vulkan object"); + return false; + } + + // Store the allocator to access them when needed + if (allocator) + m_allocator = *allocator; + else + m_allocator.pfnAllocation = nullptr; + + return true; + } + + template + inline void DeviceObject::Destroy() + { + if (m_handle != VK_NULL_HANDLE) + C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + } + + template + inline VkResult DeviceObject::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + template + inline DeviceObject::operator VkType() + { + return m_handle; + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp index 0cf871d5d..b7983ee0b 100644 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ b/include/Nazara/Vulkan/VkSemaphore.hpp @@ -9,39 +9,32 @@ #include #include -#include +#include #include namespace Nz { namespace Vk { - class Device; - - class NAZARA_VULKAN_API Semaphore + class Semaphore : public DeviceObject { + friend DeviceObject; + public: inline Semaphore(Device& instance); Semaphore(const Semaphore&) = delete; Semaphore(Semaphore&&) = delete; - inline ~Semaphore(); + ~Semaphore() = default; - inline bool Create(const VkSemaphoreCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + using DeviceObject::Create; inline bool Create(VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - inline VkResult GetLastErrorCode() const; Semaphore& operator=(const Semaphore&) = delete; Semaphore& operator=(Semaphore&&) = delete; - inline operator VkSemaphore(); - private: - Device& m_device; - VkAllocationCallbacks m_allocator; - VkSemaphore m_semaphore; - VkResult m_lastErrorCode; + static VkResult CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); + static void DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkSemaphore.inl b/include/Nazara/Vulkan/VkSemaphore.inl index 0fb61c426..fd2bf3427 100644 --- a/include/Nazara/Vulkan/VkSemaphore.inl +++ b/include/Nazara/Vulkan/VkSemaphore.inl @@ -3,8 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include -#include #include namespace Nz @@ -12,34 +10,10 @@ namespace Nz namespace Vk { inline Semaphore::Semaphore(Device& device) : - m_device(device), - m_semaphore(VK_NULL_HANDLE) + DeviceObject(device) { } - inline Semaphore::~Semaphore() - { - Destroy(); - } - - inline bool Semaphore::Create(const VkSemaphoreCreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_device.vkCreateSemaphore(m_device, &createInfo, allocator, &m_semaphore); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan semaphore"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - inline bool Semaphore::Create(VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) { VkSemaphoreCreateInfo createInfo = @@ -52,20 +26,14 @@ namespace Nz return Create(createInfo, allocator); } - inline void Semaphore::Destroy() + VkResult Semaphore::CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) { - if (m_semaphore != VK_NULL_HANDLE) - m_device.vkDestroySemaphore(m_device, m_semaphore, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + return device.vkCreateSemaphore(device, createInfo, allocator, handle); } - inline VkResult Semaphore::GetLastErrorCode() const + void Semaphore::DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) { - return m_lastErrorCode; - } - - inline Semaphore::operator VkSemaphore() - { - return m_semaphore; + return device.vkDestroySemaphore(device, handle, allocator); } } } diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index a0f23f8ac..71ab1a853 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -9,40 +9,24 @@ #include #include -#include -#include +#include namespace Nz { namespace Vk { - class Device; - - class NAZARA_VULKAN_API Swapchain + class Swapchain : public DeviceObject { public: inline Swapchain(Device& instance); Swapchain(const Swapchain&) = delete; Swapchain(Swapchain&&) = delete; - inline ~Swapchain(); - - bool Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); + ~Swapchain() = default; inline bool IsSupported() const; - inline VkResult GetLastErrorCode() const; - Swapchain& operator=(const Swapchain&) = delete; Swapchain& operator=(Swapchain&&) = delete; - - inline operator VkSwapchainKHR(); - - private: - Device& m_device; - VkAllocationCallbacks m_allocator; - VkSwapchainKHR m_swapchain; - VkResult m_lastErrorCode; }; } } diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index 7ed08b902..8c05c0284 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -12,55 +12,15 @@ namespace Nz namespace Vk { inline Swapchain::Swapchain(Device& device) : - m_device(device), - m_swapchain(VK_NULL_HANDLE) + DeviceObject(device) { } - inline Swapchain::~Swapchain() - { - Destroy(); - } - - inline bool Swapchain::Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_device.vkCreateSwapchainKHR(m_device, &createInfo, allocator, &m_swapchain); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan swapchain"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - - inline void Swapchain::Destroy() - { - if (m_swapchain != VK_NULL_HANDLE) - m_device.vkDestroySwapchainKHR(m_device, m_swapchain, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - inline VkResult Swapchain::GetLastErrorCode() const - { - return m_lastErrorCode; - } - inline bool Swapchain::IsSupported() const { if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) return false; } - - inline Swapchain::operator VkSwapchainKHR() - { - return m_swapchain; - } } } From 499690181621c456a43ca61565783bd6a002964b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 May 2016 15:28:29 +0200 Subject: [PATCH 027/383] Vulkan: Remove redundant headers Former-commit-id: b3bd76e96cd3c1516123b08f45bd5ff706837717 --- include/Nazara/Vulkan/VkDeviceObject.hpp | 1 - include/Nazara/Vulkan/VkSemaphore.hpp | 2 -- include/Nazara/Vulkan/VkSwapchain.hpp | 1 - 3 files changed, 4 deletions(-) diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index efad29c30..d84812a3d 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -8,7 +8,6 @@ #define NAZARA_VULKAN_VKDEVICEOBJECT_HPP #include -#include #include #include diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp index b7983ee0b..e1df38bc2 100644 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ b/include/Nazara/Vulkan/VkSemaphore.hpp @@ -8,9 +8,7 @@ #define NAZARA_VULKAN_VKSEMAPHORE_HPP #include -#include #include -#include namespace Nz { diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index 71ab1a853..7feb6518f 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -8,7 +8,6 @@ #define NAZARA_VULKAN_VKSWAPCHAIN_HPP #include -#include #include namespace Nz From 1346c3e2c03fb4ae03da60bf6818b0dc790d4040 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 May 2016 15:41:26 +0200 Subject: [PATCH 028/383] Vulkan/Swapchain: Fix compilation Former-commit-id: 22679aa8e212c63360903f3094a60441323b488a --- include/Nazara/Vulkan/VkSwapchain.hpp | 6 ++++++ include/Nazara/Vulkan/VkSwapchain.inl | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index 7feb6518f..dbef41394 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -16,6 +16,8 @@ namespace Nz { class Swapchain : public DeviceObject { + friend DeviceObject; + public: inline Swapchain(Device& instance); Swapchain(const Swapchain&) = delete; @@ -26,6 +28,10 @@ namespace Nz Swapchain& operator=(const Swapchain&) = delete; Swapchain& operator=(Swapchain&&) = delete; + + private: + static VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); + static void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index 8c05c0284..e05dfefd3 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -21,6 +21,16 @@ namespace Nz if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) return false; } + + VkResult Swapchain::CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) + { + return device.vkCreateSwapchainKHR(device, createInfo, allocator, handle); + } + + void Swapchain::DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroySwapchainKHR(device, handle, allocator); + } } } From 68e3fd8db31a7f3fc6cfad55723711b82de3a818 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 May 2016 21:28:59 +0200 Subject: [PATCH 029/383] Vulkan: Allow Device Objects to be move-constructed Former-commit-id: c7fb30b30d2242e19d531a6860b856660b6b0c01 --- include/Nazara/Vulkan/VkDeviceObject.hpp | 2 +- include/Nazara/Vulkan/VkDeviceObject.inl | 10 ++++++++++ include/Nazara/Vulkan/VkSemaphore.hpp | 2 +- include/Nazara/Vulkan/VkSurface.hpp | 2 +- include/Nazara/Vulkan/VkSurface.inl | 9 +++++++++ include/Nazara/Vulkan/VkSwapchain.hpp | 2 +- 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index d84812a3d..999762098 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -21,7 +21,7 @@ namespace Nz public: inline DeviceObject(Device& instance); DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&&) = delete; + DeviceObject(DeviceObject&&); inline ~DeviceObject(); inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl index 7aa313ca9..58645983e 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -18,6 +18,16 @@ namespace Nz { } + template + inline DeviceObject::DeviceObject(DeviceObject&& object) : + m_device(object.m_device), + m_allocator(object.m_allocator), + m_handle(object.m_handle), + m_lastErrorCode(object.m_lastErrorCode) + { + object.m_handle = VK_NULL_HANDLE; + } + template inline DeviceObject::~DeviceObject() { diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp index e1df38bc2..138d726be 100644 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ b/include/Nazara/Vulkan/VkSemaphore.hpp @@ -21,7 +21,7 @@ namespace Nz public: inline Semaphore(Device& instance); Semaphore(const Semaphore&) = delete; - Semaphore(Semaphore&&) = delete; + Semaphore(Semaphore&&) = default; ~Semaphore() = default; using DeviceObject::Create; diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp index 84f8459a2..a27f3d357 100644 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ b/include/Nazara/Vulkan/VkSurface.hpp @@ -23,7 +23,7 @@ namespace Nz public: inline Surface(Instance& instance); Surface(const Surface&) = delete; - Surface(Surface&&) = delete; + Surface(Surface&& surface); inline ~Surface(); #ifdef VK_USE_PLATFORM_ANDROID_KHR diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl index d045a1f06..e7b0efe64 100644 --- a/include/Nazara/Vulkan/VkSurface.inl +++ b/include/Nazara/Vulkan/VkSurface.inl @@ -17,6 +17,15 @@ namespace Nz { } + inline Surface::Surface(Surface&& surface) : + m_instance(surface.m_instance), + m_allocator(surface.m_allocator), + m_surface(surface.m_surface), + m_lastErrorCode(surface.m_lastErrorCode) + { + surface.m_surface = VK_NULL_HANDLE; + } + inline Surface::~Surface() { Destroy(); diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index dbef41394..ea47970d5 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -21,7 +21,7 @@ namespace Nz public: inline Swapchain(Device& instance); Swapchain(const Swapchain&) = delete; - Swapchain(Swapchain&&) = delete; + Swapchain(Swapchain&&) = default; ~Swapchain() = default; inline bool IsSupported() const; From efc42b58cfe631b77276f9de9643779352d431ed Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 May 2016 00:08:05 +0200 Subject: [PATCH 030/383] Vulkan: Add support for CommandPool and CommandBuffer Former-commit-id: 85b1935a402b007a53ffbc080374a5028b6eaebc --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 50 +++++++++++++++++++++ include/Nazara/Vulkan/VkCommandBuffer.inl | 51 ++++++++++++++++++++++ include/Nazara/Vulkan/VkCommandPool.hpp | 53 +++++++++++++++++++++++ include/Nazara/Vulkan/VkCommandPool.inl | 53 +++++++++++++++++++++++ include/Nazara/Vulkan/VkDeviceObject.hpp | 2 + include/Nazara/Vulkan/VkDeviceObject.inl | 12 +++++ include/Nazara/Vulkan/VkSurface.hpp | 2 +- src/Nazara/Vulkan/VkCommandPool.cpp | 53 +++++++++++++++++++++++ 8 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 include/Nazara/Vulkan/VkCommandBuffer.hpp create mode 100644 include/Nazara/Vulkan/VkCommandBuffer.inl create mode 100644 include/Nazara/Vulkan/VkCommandPool.hpp create mode 100644 include/Nazara/Vulkan/VkCommandPool.inl create mode 100644 src/Nazara/Vulkan/VkCommandPool.cpp diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp new file mode 100644 index 000000000..0399d4cf7 --- /dev/null +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -0,0 +1,50 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKAN_VKCOMMANDBUFFER_HPP +#define NAZARA_VULKAN_VKCOMMANDBUFFER_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class NAZARA_VULKAN_API CommandBuffer + { + friend CommandPool; + + public: + CommandBuffer(const CommandBuffer&) = delete; + CommandBuffer(CommandBuffer&& commandBuffer); + inline ~CommandBuffer(); + + inline void Free(); + + inline VkResult GetLastErrorCode() const; + + CommandBuffer& operator=(const CommandBuffer&) = delete; + CommandBuffer& operator=(CommandBuffer&&) = delete; + + inline operator VkCommandBuffer(); + + private: + inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); + + CommandPoolHandle m_pool; + VkAllocationCallbacks m_allocator; + VkCommandBuffer m_handle; + VkResult m_lastErrorCode; + + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKCOMMANDBUFFER_HPP diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl new file mode 100644 index 000000000..ff4eaede4 --- /dev/null +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -0,0 +1,51 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline CommandBuffer::CommandBuffer(CommandPool& pool, VkCommandBuffer handle) : + m_pool(&pool), + m_handle(handle) + { + } + + inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) : + m_pool(std::move(commandBuffer.m_pool)), + m_allocator(commandBuffer.m_allocator), + m_handle(commandBuffer.m_handle), + m_lastErrorCode(commandBuffer.m_lastErrorCode) + { + commandBuffer.m_handle = VK_NULL_HANDLE; + } + + inline CommandBuffer::~CommandBuffer() + { + Free(); + } + + inline void CommandBuffer::Free() + { + m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); + } + + inline VkResult CommandBuffer::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline CommandBuffer::operator VkCommandBuffer() + { + return m_handle; + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkCommandPool.hpp b/include/Nazara/Vulkan/VkCommandPool.hpp new file mode 100644 index 000000000..8b99513e3 --- /dev/null +++ b/include/Nazara/Vulkan/VkCommandPool.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKAN_VKCOMMANDPOOL_HPP +#define NAZARA_VULKAN_VKCOMMANDPOOL_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class CommandBuffer; + class CommandPool; + + using CommandPoolHandle = ObjectHandle; + + class CommandPool : public DeviceObject, public HandledObject + { + friend DeviceObject; + + public: + inline CommandPool(Device& instance); + CommandPool(const CommandPool&) = delete; + CommandPool(CommandPool&&) = default; + ~CommandPool() = default; + + CommandBuffer AllocateCommandBuffer(VkCommandBufferLevel level); + std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); + + using DeviceObject::Create; + inline bool Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + inline bool Reset(VkCommandPoolResetFlags flags); + + CommandPool& operator=(const CommandPool&) = delete; + CommandPool& operator=(CommandPool&&) = delete; + + private: + static VkResult CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); + static void DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKCOMMANDPOOL_HPP diff --git a/include/Nazara/Vulkan/VkCommandPool.inl b/include/Nazara/Vulkan/VkCommandPool.inl new file mode 100644 index 000000000..f7aef6978 --- /dev/null +++ b/include/Nazara/Vulkan/VkCommandPool.inl @@ -0,0 +1,53 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline CommandPool::CommandPool(Device& device) : + DeviceObject(device) + { + } + + inline bool CommandPool::Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkCommandPoolCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, + nullptr, + flags, + queueFamilyIndex + }; + + return Create(createInfo, allocator); + } + + inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) + { + m_lastErrorCode = m_device.vkResetCommandPool(m_device, m_handle, flags); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + VkResult CommandPool::CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) + { + return device.vkCreateCommandPool(device, createInfo, allocator, handle); + } + + void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyCommandPool(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index 999762098..dd9da38c9 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -27,6 +27,8 @@ namespace Nz inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); + inline Device& GetDevice(); + inline const Device& GetDevice() const; inline VkResult GetLastErrorCode() const; DeviceObject& operator=(const DeviceObject&) = delete; diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl index 58645983e..a3136156c 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -60,6 +60,18 @@ namespace Nz C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); } + template + inline Device& DeviceObject::GetDevice() + { + return m_device; + } + + template + inline const Device& DeviceObject::GetDevice() const + { + return m_device; + } + template inline VkResult DeviceObject::GetLastErrorCode() const { diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp index a27f3d357..7b7fbcdfd 100644 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ b/include/Nazara/Vulkan/VkSurface.hpp @@ -18,7 +18,7 @@ namespace Nz { class Instance; - class NAZARA_VULKAN_API Surface + class Surface { public: inline Surface(Instance& instance); diff --git a/src/Nazara/Vulkan/VkCommandPool.cpp b/src/Nazara/Vulkan/VkCommandPool.cpp new file mode 100644 index 000000000..3ee53ab6f --- /dev/null +++ b/src/Nazara/Vulkan/VkCommandPool.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + CommandBuffer CommandPool::AllocateCommandBuffer(VkCommandBufferLevel level) + { + VkCommandBufferAllocateInfo createInfo = + { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, + nullptr, + m_handle, + level, + 1U + }; + + VkCommandBuffer handle = VK_NULL_HANDLE; + m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, &handle); + + return CommandBuffer(*this, handle); + } + + std::vector CommandPool::AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level) + { + VkCommandBufferAllocateInfo createInfo = + { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, + nullptr, + m_handle, + level, + 1U + }; + + std::vector handles(commandBufferCount, VK_NULL_HANDLE); + m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, handles.data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return std::vector(); + + std::vector commandBuffers; + for (UInt32 i = 0; i < commandBufferCount; ++i) + commandBuffers.emplace_back(CommandBuffer(*this, handles[i])); + + return commandBuffers; + } + } +} From e7f21b7a3dfa8ad9afc516ad6a2ddcf91517fa53 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 May 2016 00:11:26 +0200 Subject: [PATCH 031/383] Vulkan: Update global header Former-commit-id: 3d67bedb8835c68706dd681e12074553b4947a0c --- include/Nazara/Vulkan.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan.hpp b/include/Nazara/Vulkan.hpp index a935674e9..a3e363272 100644 --- a/include/Nazara/Vulkan.hpp +++ b/include/Nazara/Vulkan.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 24 Apr 2016 at 02:26:55 +// This file was automatically generated on 15 May 2016 at 00:11:13 /* Nazara Engine - Vulkan @@ -30,9 +30,15 @@ #define NAZARA_GLOBAL_VULKAN_HPP #include +#include +#include #include +#include #include #include +#include +#include +#include #include #endif // NAZARA_GLOBAL_VULKAN_HPP From c0b5ac25294a654e8273aceb5341c76ab9fe385d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 May 2016 00:38:19 +0200 Subject: [PATCH 032/383] Build: Make every lib copy its binaries (and dependency bins) to the example/bin folder Former-commit-id: 02571367a0af738197066d4a17446e203b389d31 --- build/scripts/common.lua | 25 ++++++++++++++++++++++++- build/scripts/modules/audio.lua | 4 ++++ build/scripts/tools/ndk.lua | 2 ++ build/scripts/tools/ndk_server.lua | 2 ++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 405b66b60..a0957966d 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -188,6 +188,29 @@ function NazaraBuild:Execute() libdirs("../lib/" .. makeLibDir .. "/x64") targetdir("../lib/" .. makeLibDir .. "/x64") + -- Copy the module binaries to the example folder + if (os.is("windows")) then + configuration({}) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) + + for k,v in pairs(table.join(moduleTable.Libraries, moduleTable.DynLib)) do + local paths = {} + table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) + table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) + table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) + table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) + + for k,v in pairs(paths) do + local config = v[1] + local path = v[2] + if (os.isfile(path)) then + configuration(config) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. path .. [[")}" "..\..\..\examples\bin\" /E /Y]]}) + end + end + end + end + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") @@ -851,7 +874,7 @@ function NazaraBuild:SetupInfoTable(infoTable) infoTable.ConfigurationLibraries.DebugDynamic = {} infoTable.ConfigurationLibraries.ReleaseDynamic = {} - local infos = {"Defines", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"} + local infos = {"Defines", "DynLib", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"} for k,v in ipairs(infos) do infoTable[v] = {} infoTable["Os" .. v] = {} diff --git a/build/scripts/modules/audio.lua b/build/scripts/modules/audio.lua index f03e493a9..4fcb1bf5a 100644 --- a/build/scripts/modules/audio.lua +++ b/build/scripts/modules/audio.lua @@ -14,6 +14,10 @@ MODULE.OsFiles.Windows = { "../src/Nazara/Audio/Win32/**.cpp" } +MODULE.OsDynLib.Windows = { + "soft_oal" +} + MODULE.OsFiles.Posix = { "../src/Nazara/Audio/Posix/**.hpp", "../src/Nazara/Audio/Posix/**.cpp" diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 78ff544de..5a1084f48 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -1,5 +1,7 @@ TOOL.Name = "SDK" +TOOL.CopyTargetToExampleDir = true + TOOL.Directory = "../SDK/lib" TOOL.Kind = "Library" diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index c9c443e57..978d620be 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -1,5 +1,7 @@ TOOL.Name = "SDKServer" +TOOL.CopyTargetToExampleDir = true + TOOL.Directory = "../SDK/lib" TOOL.Kind = "Library" From c31f70af55dd013b0db7f8b17bf1231af0e482ad Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 16 May 2016 20:02:59 +0200 Subject: [PATCH 033/383] Build: Copy all dependency modules to the example directory Former-commit-id: 13e9d585df15ecc727c140b30dbd5e83e3997b5f --- build/scripts/common.lua | 53 +++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index a0957966d..ec95c2641 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -190,25 +190,7 @@ function NazaraBuild:Execute() -- Copy the module binaries to the example folder if (os.is("windows")) then - configuration({}) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) - - for k,v in pairs(table.join(moduleTable.Libraries, moduleTable.DynLib)) do - local paths = {} - table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) - table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) - table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) - table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) - - for k,v in pairs(paths) do - local config = v[1] - local path = v[2] - if (os.isfile(path)) then - configuration(config) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. path .. [[")}" "..\..\..\examples\bin\" /E /Y]]}) - end - end - end + self:MakeCopyAfterBuild(moduleTable) end configuration({"vs*", "x32"}) @@ -323,10 +305,7 @@ function NazaraBuild:Execute() -- Copy the module binaries to the example folder if (toolTable.CopyTargetToExampleDir) then - if (os.is("windows")) then - configuration({}) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) - end + self:MakeCopyAfterBuild(toolTable) end configuration({"vs*", "x32"}) @@ -867,6 +846,34 @@ function NazaraBuild:Process(infoTable) end end +function NazaraBuild:MakeCopyAfterBuild(infoTable) + if (os.is("windows")) then + configuration({}) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) + + for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do + local paths = {} + table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) + table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) + table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) + table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) + + for k,v in pairs(paths) do + local config = v[1] + local path = v[2] + if (os.isfile(path)) then + if (infoTable.Kind == "plugin") then + path = "../../" .. path + end + + configuration(config) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. path .. [[")}" "..\..\..\examples\bin\" /E /Y]]}) + end + end + end + end +end + function NazaraBuild:SetupInfoTable(infoTable) infoTable.ConfigurationLibraries = {} infoTable.ConfigurationLibraries.DebugStatic = {} From 1ebe1a80911a66f5b64b3c0f3716ed9e076f9883 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 May 2016 14:23:45 +0200 Subject: [PATCH 034/383] Utility: Rework PixelFormat (WIP) Former-commit-id: 1ab609e753783d9767ba23fd4cab9390453bf729 --- include/Nazara/Utility/Enums.hpp | 34 +- include/Nazara/Utility/PixelFormat.hpp | 64 +-- include/Nazara/Utility/PixelFormat.inl | 642 ++++++----------------- src/Nazara/Renderer/RenderBuffer.cpp | 2 +- src/Nazara/Renderer/RenderTexture.cpp | 27 +- src/Nazara/Renderer/Texture.cpp | 6 +- src/Nazara/Utility/Formats/DDSLoader.cpp | 2 +- src/Nazara/Utility/Image.cpp | 8 +- src/Nazara/Utility/PixelFormat.cpp | 82 ++- 9 files changed, 306 insertions(+), 561 deletions(-) diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 143390906..3f32945c2 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -142,6 +142,17 @@ namespace Nz NodeType_Max = NodeType_Skeletal }; + enum PixelFormatContent + { + PixelFormatContent_Undefined = -1, + + PixelFormatContent_ColorRGBA, + PixelFormatContent_DepthStencil, + PixelFormatContent_Stencil, + + PixelFormatContent_Max = PixelFormatContent_Stencil + }; + enum PixelFormatType { PixelFormatType_Undefined = -1, @@ -204,27 +215,16 @@ namespace Nz enum PixelFormatSubType { - PixelFormatSubType_Double, // F64 - PixelFormatSubType_Float, // F32 - PixelFormatSubType_Half, // F16 - PixelFormatSubType_Int, // I32 - PixelFormatSubType_Unsigned, // U32 + PixelFormatSubType_Compressed, // Opaque + PixelFormatSubType_Double, // F64 + PixelFormatSubType_Float, // F32 + PixelFormatSubType_Half, // F16 + PixelFormatSubType_Int, // Signed integer + PixelFormatSubType_Unsigned, // Unsigned integer PixelFormatSubType_Max = PixelFormatSubType_Unsigned }; - enum PixelFormatTypeType - { - PixelFormatTypeType_Undefined = -1, - - PixelFormatTypeType_Color, - PixelFormatTypeType_Depth, - PixelFormatTypeType_DepthStencil, - PixelFormatTypeType_Stencil, - - PixelFormatTypeType_Max = PixelFormatTypeType_Stencil - }; - enum PixelFlipping { PixelFlipping_Horizontally, diff --git a/include/Nazara/Utility/PixelFormat.hpp b/include/Nazara/Utility/PixelFormat.hpp index 6844162d5..92eecb7f4 100644 --- a/include/Nazara/Utility/PixelFormat.hpp +++ b/include/Nazara/Utility/PixelFormat.hpp @@ -23,33 +23,36 @@ namespace Nz { struct PixelFormatInfo { - PixelFormatInfo() : - bitsPerPixel(0) - { - } + inline PixelFormatInfo(); + inline PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType); + inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType); + inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType); + inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0); - PixelFormatInfo(UInt8 bpp, PixelFormatSubType subType) : - bitsPerPixel(bpp), - redType(subType), - greenType(subType), - blueType(subType), - alphaType(subType) - { - } + inline void Clear(); - // Warning: Bit Endian + inline bool IsCompressed() const; + inline bool IsValid() const; + + inline void RecomputeBitsPerPixel(); + + inline bool Validate() const; + + // Warning: Masks bit order is reversed Bitset<> redMask; Bitset<> greenMask; Bitset<> blueMask; Bitset<> alphaMask; + PixelFormatContent content; PixelFormatSubType redType; PixelFormatSubType greenType; PixelFormatSubType blueType; PixelFormatSubType alphaType; + String name; UInt8 bitsPerPixel; }; - class PixelFormat + class NAZARA_UTILITY_API PixelFormat { friend class Utility; @@ -59,34 +62,35 @@ namespace Nz static inline std::size_t ComputeSize(PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth); - static bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst); - static bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst); + static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst); + static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst); - static bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst); + static inline bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst); - static UInt8 GetBitsPerPixel(PixelFormatType format); - static UInt8 GetBytesPerPixel(PixelFormatType format); - static PixelFormatTypeType GetType(PixelFormatType format); + static inline UInt8 GetBitsPerPixel(PixelFormatType format); + static inline PixelFormatContent GetContent(PixelFormatType format); + static inline UInt8 GetBytesPerPixel(PixelFormatType format); + static inline const PixelFormatInfo& GetInfo(PixelFormatType format); + static inline const String& GetName(PixelFormatType format); - static bool HasAlpha(PixelFormatType format); + static inline bool HasAlpha(PixelFormatType format); static PixelFormatType IdentifyFormat(const PixelFormatInfo& info); - static bool IsCompressed(PixelFormatType format); - static bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat); - static bool IsValid(PixelFormatType format); + static inline bool IsCompressed(PixelFormatType format); + static inline bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat); + static inline bool IsValid(PixelFormatType format); - static void SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func); - static void SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func); - - static String ToString(PixelFormatType format); + static inline void SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func); + static inline void SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func); private: static bool Initialize(); static void Uninitialize(); - static NAZARA_UTILITY_API ConvertFunction s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1]; - static NAZARA_UTILITY_API std::map s_flipFunctions[PixelFlipping_Max+1]; + static PixelFormatInfo s_pixelFormatInfos[PixelFormatType_Max + 1]; + static ConvertFunction s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1]; + static std::map s_flipFunctions[PixelFlipping_Max+1]; }; } diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index 2d09273b9..7b05ec8fb 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -2,13 +2,151 @@ // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include +#include #include #include namespace Nz { + inline PixelFormatInfo::PixelFormatInfo() : + bitsPerPixel(0), + content(PixelFormatContent_Undefined) + { + } + + inline PixelFormatInfo::PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : + bitsPerPixel(bpp), + content(formatContent), + redType(subType), + greenType(subType), + blueType(subType), + alphaType(subType) + { + } + + inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : + bitsPerPixel(bpp), + content(formatContent), + redType(subType), + greenType(subType), + blueType(subType), + alphaType(subType), + name(formatName) + { + } + + inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) : + redMask(rMask), + greenMask(gMask), + blueMask(bMask), + alphaMask(aMask), + content(formatContent), + redType(subType), + greenType(subType), + blueType(subType), + alphaType(subType), + name(formatName) + { + RecomputeBitsPerPixel(); + } + + inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) : + redMask(rMask), + greenMask(gMask), + blueMask(bMask), + alphaMask(aMask), + content(formatContent), + redType(rType), + greenType(gType), + blueType(bType), + alphaType(aType), + name(formatName) + { + if (bpp == 0) + RecomputeBitsPerPixel(); + } + + inline void PixelFormatInfo::Clear() + { + bitsPerPixel = 0; + alphaMask.Clear(); + blueMask.Clear(); + greenMask.Clear(); + redMask.Clear(); + name.Clear(); + } + + inline bool PixelFormatInfo::IsCompressed() const + { + return redType == PixelFormatSubType_Compressed || + greenType == PixelFormatSubType_Compressed || + blueType == PixelFormatSubType_Compressed || + alphaType == PixelFormatSubType_Compressed; + } + + inline bool PixelFormatInfo::IsValid() const + { + return bitsPerPixel != 0; + } + + inline void PixelFormatInfo::RecomputeBitsPerPixel() + { + Bitset<> counter; + counter |= redMask; + counter |= greenMask; + counter |= blueMask; + counter |= alphaMask; + + bitsPerPixel = counter.Count(); + } + + inline bool PixelFormatInfo::Validate() const + { + if (!IsValid()) + return false; + + if (content <= PixelFormatContent_Undefined || content > PixelFormatContent_Max) + return false; + + std::array*, 4> masks = {&redMask, &greenMask, &blueMask, &alphaMask}; + std::array types = {redType, greenType, blueType, alphaType}; + + for (unsigned int i = 0; i < 4; ++i) + { + unsigned int usedBits = masks[i]->Count(); + if (usedBits == 0) + continue; + + if (usedBits > bitsPerPixel) + return false; + + switch (types[i]) + { + case PixelFormatSubType_Half: + if (usedBits != 16) + return false; + + break; + + case PixelFormatSubType_Float: + if (usedBits != 32) + return false; + + break; + + default: + break; + } + } + + return true; + } + + + inline std::size_t PixelFormat::ComputeSize(PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth) { if (IsCompressed(format)) @@ -54,13 +192,13 @@ namespace Nz ConvertFunction func = s_convertFunctions[srcFormat][dstFormat]; if (!func) { - NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " is not supported"); + NazaraError("Pixel format conversion from " + GetName(srcFormat) + " to " + GetName(dstFormat) + " is not supported"); return false; } if (!func(reinterpret_cast(src), reinterpret_cast(src) + GetBytesPerPixel(srcFormat), reinterpret_cast(dst))) { - NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " failed"); + NazaraError("Pixel format conversion from " + GetName(srcFormat) + " to " + GetName(dstFormat) + " failed"); return false; } @@ -78,13 +216,13 @@ namespace Nz ConvertFunction func = s_convertFunctions[srcFormat][dstFormat]; if (!func) { - NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " is not supported"); + NazaraError("Pixel format conversion from " + GetName(srcFormat) + " to " + GetName(dstFormat) + " is not supported"); return false; } if (!func(reinterpret_cast(start), reinterpret_cast(end), reinterpret_cast(dst))) { - NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " failed"); + NazaraError("Pixel format conversion from " + GetName(srcFormat) + " to " + GetName(dstFormat) + " failed"); return false; } @@ -189,126 +327,7 @@ namespace Nz inline UInt8 PixelFormat::GetBitsPerPixel(PixelFormatType format) { - switch (format) - { - case PixelFormatType_A8: - return 8; - - case PixelFormatType_BGR8: - return 24; - - case PixelFormatType_BGRA8: - return 32; - - case PixelFormatType_DXT1: - return 8; - - case PixelFormatType_DXT3: - return 16; - - case PixelFormatType_DXT5: - return 16; - - case PixelFormatType_L8: - return 8; - - case PixelFormatType_LA8: - return 16; - - case PixelFormatType_R8: - case PixelFormatType_R8I: - case PixelFormatType_R8UI: - return 8; - - case PixelFormatType_R16: - case PixelFormatType_R16F: - case PixelFormatType_R16I: - case PixelFormatType_R16UI: - return 16; - - case PixelFormatType_R32F: - case PixelFormatType_R32I: - case PixelFormatType_R32UI: - return 32; - - case PixelFormatType_RG8: - case PixelFormatType_RG8I: - case PixelFormatType_RG8UI: - return 16; - - case PixelFormatType_RG16: - case PixelFormatType_RG16F: - case PixelFormatType_RG16I: - case PixelFormatType_RG16UI: - return 32; - - case PixelFormatType_RG32F: - case PixelFormatType_RG32I: - case PixelFormatType_RG32UI: - return 64; - - case PixelFormatType_RGB16F: - case PixelFormatType_RGB16I: - case PixelFormatType_RGB16UI: - return 48; - - case PixelFormatType_RGB32F: - case PixelFormatType_RGB32I: - case PixelFormatType_RGB32UI: - return 96; - - case PixelFormatType_RGBA16F: - case PixelFormatType_RGBA16I: - case PixelFormatType_RGBA16UI: - return 64; - - case PixelFormatType_RGBA32F: - case PixelFormatType_RGBA32I: - case PixelFormatType_RGBA32UI: - return 128; - - case PixelFormatType_RGBA4: - return 16; - - case PixelFormatType_RGB5A1: - return 16; - - case PixelFormatType_RGB8: - return 24; - - case PixelFormatType_RGBA8: - return 32; - - case PixelFormatType_Depth16: - return 16; - - case PixelFormatType_Depth24: - return 24; - - case PixelFormatType_Depth24Stencil8: - return 32; - - case PixelFormatType_Depth32: - return 32; - - case PixelFormatType_Stencil1: - return 1; - - case PixelFormatType_Stencil4: - return 2; - - case PixelFormatType_Stencil8: - return 8; - - case PixelFormatType_Stencil16: - return 16; - - case PixelFormatType_Undefined: - break; - } - - NazaraError("Invalid pixel format"); - return 0; + return s_pixelFormatInfos[format].bitsPerPixel; } inline UInt8 PixelFormat::GetBytesPerPixel(PixelFormatType format) @@ -316,212 +335,29 @@ namespace Nz return GetBitsPerPixel(format)/8; } - inline PixelFormatTypeType PixelFormat::GetType(PixelFormatType format) + inline PixelFormatContent PixelFormat::GetContent(PixelFormatType format) { - switch (format) - { - case PixelFormatType_A8: - case PixelFormatType_BGR8: - case PixelFormatType_BGRA8: - case PixelFormatType_DXT1: - case PixelFormatType_DXT3: - case PixelFormatType_DXT5: - case PixelFormatType_L8: - case PixelFormatType_LA8: - case PixelFormatType_R8: - case PixelFormatType_R8I: - case PixelFormatType_R8UI: - case PixelFormatType_R16: - case PixelFormatType_R16F: - case PixelFormatType_R16I: - case PixelFormatType_R16UI: - case PixelFormatType_R32F: - case PixelFormatType_R32I: - case PixelFormatType_R32UI: - case PixelFormatType_RG8: - case PixelFormatType_RG8I: - case PixelFormatType_RG8UI: - case PixelFormatType_RG16: - case PixelFormatType_RG16F: - case PixelFormatType_RG16I: - case PixelFormatType_RG16UI: - case PixelFormatType_RG32F: - case PixelFormatType_RG32I: - case PixelFormatType_RG32UI: - case PixelFormatType_RGB5A1: - case PixelFormatType_RGB8: - case PixelFormatType_RGB16F: - case PixelFormatType_RGB16I: - case PixelFormatType_RGB16UI: - case PixelFormatType_RGB32F: - case PixelFormatType_RGB32I: - case PixelFormatType_RGB32UI: - case PixelFormatType_RGBA4: - case PixelFormatType_RGBA8: - case PixelFormatType_RGBA16F: - case PixelFormatType_RGBA16I: - case PixelFormatType_RGBA16UI: - case PixelFormatType_RGBA32F: - case PixelFormatType_RGBA32I: - case PixelFormatType_RGBA32UI: - return PixelFormatTypeType_Color; + return s_pixelFormatInfos[format].content; + } - case PixelFormatType_Depth16: - case PixelFormatType_Depth24: - case PixelFormatType_Depth32: - return PixelFormatTypeType_Depth; + inline const PixelFormatInfo& PixelFormat::GetInfo(PixelFormatType format) + { + return s_pixelFormatInfos[format]; + } - case PixelFormatType_Depth24Stencil8: - return PixelFormatTypeType_DepthStencil; - - case PixelFormatType_Stencil1: - case PixelFormatType_Stencil4: - case PixelFormatType_Stencil8: - case PixelFormatType_Stencil16: - return PixelFormatTypeType_Stencil; - - case PixelFormatType_Undefined: - break; - } - - NazaraError("Invalid pixel format"); - return PixelFormatTypeType_Undefined; + inline const String& PixelFormat::GetName(PixelFormatType format) + { + return s_pixelFormatInfos[format].name; } inline bool PixelFormat::HasAlpha(PixelFormatType format) { - switch (format) - { - case PixelFormatType_A8: - case PixelFormatType_BGRA8: - case PixelFormatType_DXT3: - case PixelFormatType_DXT5: - case PixelFormatType_LA8: - case PixelFormatType_RGB5A1: - case PixelFormatType_RGBA16F: - case PixelFormatType_RGBA16I: - case PixelFormatType_RGBA16UI: - case PixelFormatType_RGBA32F: - case PixelFormatType_RGBA32I: - case PixelFormatType_RGBA32UI: - case PixelFormatType_RGBA4: - case PixelFormatType_RGBA8: - return true; - - case PixelFormatType_BGR8: - case PixelFormatType_DXT1: - case PixelFormatType_L8: - case PixelFormatType_R8: - case PixelFormatType_R8I: - case PixelFormatType_R8UI: - case PixelFormatType_R16: - case PixelFormatType_R16F: - case PixelFormatType_R16I: - case PixelFormatType_R16UI: - case PixelFormatType_R32F: - case PixelFormatType_R32I: - case PixelFormatType_R32UI: - case PixelFormatType_RG8: - case PixelFormatType_RG8I: - case PixelFormatType_RG8UI: - case PixelFormatType_RG16: - case PixelFormatType_RG16F: - case PixelFormatType_RG16I: - case PixelFormatType_RG16UI: - case PixelFormatType_RG32F: - case PixelFormatType_RG32I: - case PixelFormatType_RG32UI: - case PixelFormatType_RGB8: - case PixelFormatType_RGB16F: - case PixelFormatType_RGB16I: - case PixelFormatType_RGB16UI: - case PixelFormatType_RGB32F: - case PixelFormatType_RGB32I: - case PixelFormatType_RGB32UI: - case PixelFormatType_Depth16: - case PixelFormatType_Depth24: - case PixelFormatType_Depth24Stencil8: - case PixelFormatType_Depth32: - case PixelFormatType_Stencil1: - case PixelFormatType_Stencil4: - case PixelFormatType_Stencil8: - case PixelFormatType_Stencil16: - return false; - - case PixelFormatType_Undefined: - break; - } - - NazaraError("Invalid pixel format"); - return false; + return s_pixelFormatInfos[format].alphaMask.TestAny(); } inline bool PixelFormat::IsCompressed(PixelFormatType format) { - switch (format) - { - case PixelFormatType_DXT1: - case PixelFormatType_DXT3: - case PixelFormatType_DXT5: - return true; - - case PixelFormatType_A8: - case PixelFormatType_BGR8: - case PixelFormatType_BGRA8: - case PixelFormatType_L8: - case PixelFormatType_LA8: - case PixelFormatType_R8: - case PixelFormatType_R8I: - case PixelFormatType_R8UI: - case PixelFormatType_R16: - case PixelFormatType_R16F: - case PixelFormatType_R16I: - case PixelFormatType_R16UI: - case PixelFormatType_R32F: - case PixelFormatType_R32I: - case PixelFormatType_R32UI: - case PixelFormatType_RG8: - case PixelFormatType_RG8I: - case PixelFormatType_RG8UI: - case PixelFormatType_RG16: - case PixelFormatType_RG16F: - case PixelFormatType_RG16I: - case PixelFormatType_RG16UI: - case PixelFormatType_RG32F: - case PixelFormatType_RG32I: - case PixelFormatType_RG32UI: - case PixelFormatType_RGB5A1: - case PixelFormatType_RGB8: - case PixelFormatType_RGB16F: - case PixelFormatType_RGB16I: - case PixelFormatType_RGB16UI: - case PixelFormatType_RGB32F: - case PixelFormatType_RGB32I: - case PixelFormatType_RGB32UI: - case PixelFormatType_RGBA4: - case PixelFormatType_RGBA8: - case PixelFormatType_RGBA16F: - case PixelFormatType_RGBA16I: - case PixelFormatType_RGBA16UI: - case PixelFormatType_RGBA32F: - case PixelFormatType_RGBA32I: - case PixelFormatType_RGBA32UI: - case PixelFormatType_Depth16: - case PixelFormatType_Depth24: - case PixelFormatType_Depth24Stencil8: - case PixelFormatType_Depth32: - case PixelFormatType_Stencil1: - case PixelFormatType_Stencil4: - case PixelFormatType_Stencil8: - case PixelFormatType_Stencil16: - return false; - - case PixelFormatType_Undefined: - break; - } - - NazaraError("Invalid pixel format"); - return false; + return s_pixelFormatInfos[format].IsCompressed(); } inline bool PixelFormat::IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat) @@ -546,174 +382,6 @@ namespace Nz { s_flipFunctions[flipping][format] = func; } - - inline String PixelFormat::ToString(PixelFormatType format) - { - switch (format) - { - case PixelFormatType_A8: - return "A8"; - - case PixelFormatType_BGR8: - return "BGR8"; - - case PixelFormatType_BGRA8: - return "BGRA8"; - - case PixelFormatType_DXT1: - return "DXT1"; - - case PixelFormatType_DXT3: - return "DXT3"; - - case PixelFormatType_DXT5: - return "DXT5"; - - case PixelFormatType_L8: - return "L8"; - - case PixelFormatType_LA8: - return "LA8"; - - case PixelFormatType_R8: - return "R8"; - - case PixelFormatType_R8I: - return "R8I"; - - case PixelFormatType_R8UI: - return "R8UI"; - - case PixelFormatType_R16: - return "R16"; - - case PixelFormatType_R16F: - return "R16F"; - - case PixelFormatType_R16I: - return "R16I"; - - case PixelFormatType_R16UI: - return "R16UI"; - - case PixelFormatType_R32F: - return "R32F"; - - case PixelFormatType_R32I: - return "R32I"; - - case PixelFormatType_R32UI: - return "R32UI"; - - case PixelFormatType_RG8: - return "RG8"; - - case PixelFormatType_RG8I: - return "RG8I"; - - case PixelFormatType_RG8UI: - return "RG8UI"; - - case PixelFormatType_RG16: - return "RG16"; - - case PixelFormatType_RG16F: - return "RG16F"; - - case PixelFormatType_RG16I: - return "RG16I"; - - case PixelFormatType_RG16UI: - return "RG16UI"; - - case PixelFormatType_RG32F: - return "RG32F"; - - case PixelFormatType_RG32I: - return "RG32I"; - - case PixelFormatType_RG32UI: - return "RG32UI"; - - case PixelFormatType_RGB5A1: - return "RGB5A1"; - - case PixelFormatType_RGB8: - return "RGB8"; - - case PixelFormatType_RGB16F: - return "RGB16F"; - - case PixelFormatType_RGB16I: - return "RGB16I"; - - case PixelFormatType_RGB16UI: - return "RGB16UI"; - - case PixelFormatType_RGB32F: - return "RGB32F"; - - case PixelFormatType_RGB32I: - return "RGB32I"; - - case PixelFormatType_RGB32UI: - return "RGB32UI"; - - case PixelFormatType_RGBA4: - return "RGBA4"; - - case PixelFormatType_RGBA8: - return "RGBA8"; - - case PixelFormatType_RGBA16F: - return "RGBA16F"; - - case PixelFormatType_RGBA16I: - return "RGBA16I"; - - case PixelFormatType_RGBA16UI: - return "RGBA16UI"; - - case PixelFormatType_RGBA32F: - return "RGBA32F"; - - case PixelFormatType_RGBA32I: - return "RGBA32I"; - - case PixelFormatType_RGBA32UI: - return "RGBA32UI"; - - case PixelFormatType_Depth16: - return "Depth16"; - - case PixelFormatType_Depth24: - return "Depth24"; - - case PixelFormatType_Depth24Stencil8: - return "Depth24Stencil8"; - - case PixelFormatType_Depth32: - return "Depth32"; - - case PixelFormatType_Stencil1: - return "Stencil1"; - - case PixelFormatType_Stencil4: - return "Stencil4"; - - case PixelFormatType_Stencil8: - return "Stencil8"; - - case PixelFormatType_Stencil16: - return "Stencil16"; - - case PixelFormatType_Undefined: - return "Undefined"; - } - - NazaraError("Invalid pixel format"); - return "Invalid format"; - } } #include diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp index b1316f4c3..b6b182ab8 100644 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -44,7 +44,7 @@ namespace Nz OpenGL::Format openglFormat; if (!OpenGL::TranslateFormat(format, &openglFormat, OpenGL::FormatType_RenderBuffer)) { - NazaraError("Failed to translate pixel format \"" + PixelFormat::ToString(format) + "\" into OpenGL format"); + NazaraError("Failed to translate pixel format \"" + PixelFormat::GetName(format) + "\" into OpenGL format"); return false; } diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 37b45c46a..0ae0d97bf 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -44,12 +44,23 @@ namespace Nz 2 // AttachmentPoint_Stencil }; - AttachmentPoint formatTypeToAttachment[PixelFormatTypeType_Max+1] = + AttachmentPoint FormatTypeToAttachment(PixelFormatType format) { - AttachmentPoint_Color, // PixelFormatTypeType_Color - AttachmentPoint_Depth, // PixelFormatTypeType_Depth - AttachmentPoint_DepthStencil, // PixelFormatTypeType_DepthStencil - AttachmentPoint_Stencil // PixelFormatTypeType_Stencil + const PixelFormatInfo& info = PixelFormat::GetInfo(format); + switch (info.content) + { + case PixelFormatContent_ColorRGBA: + return AttachmentPoint_Color; + + case PixelFormatContent_DepthStencil: + return (!info.greenMask.TestAny()) ? AttachmentPoint_Depth : AttachmentPoint_DepthStencil; + + case PixelFormatContent_Stencil: + return AttachmentPoint_Stencil; + } + + NazaraInternalError("Unexpected pixel format content: 0x" + String::Number(info.content, 16)); + return AttachmentPoint_Max; }; GLuint lockedPrevious = 0; @@ -118,9 +129,9 @@ namespace Nz } } - AttachmentPoint targetAttachmentPoint = formatTypeToAttachment[PixelFormat::GetType(buffer->GetFormat())]; + AttachmentPoint targetAttachmentPoint = FormatTypeToAttachment(buffer->GetFormat()); if (targetAttachmentPoint != attachmentPoint && targetAttachmentPoint != AttachmentPoint_DepthStencil && - attachmentPoint != AttachmentPoint_Depth && attachmentPoint != AttachmentPoint_Stencil) + attachmentPoint != AttachmentPoint_Depth && attachmentPoint != AttachmentPoint_Stencil) { NazaraError("Pixel format type does not match attachment point type"); return false; @@ -230,7 +241,7 @@ namespace Nz return false; } - AttachmentPoint targetAttachmentPoint = formatTypeToAttachment[PixelFormat::GetType(texture->GetFormat())]; + AttachmentPoint targetAttachmentPoint = FormatTypeToAttachment(texture->GetFormat()); if (targetAttachmentPoint != attachmentPoint && targetAttachmentPoint != AttachmentPoint_DepthStencil && attachmentPoint != AttachmentPoint_Depth && attachmentPoint != AttachmentPoint_Stencil) { diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index e4382cfc5..835dce85e 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -521,7 +521,7 @@ namespace Nz { ///TODO: Sélectionner le format le plus adapté selon les composantes présentes dans le premier format PixelFormatType newFormat = (PixelFormat::HasAlpha(format)) ? PixelFormatType_BGRA8 : PixelFormatType_BGR8; - NazaraWarning("Format " + PixelFormat::ToString(format) + " not supported, trying to convert it to " + PixelFormat::ToString(newFormat) + "..."); + NazaraWarning("Format " + PixelFormat::GetName(format) + " not supported, trying to convert it to " + PixelFormat::GetName(newFormat) + "..."); if (PixelFormat::IsConversionSupported(format, newFormat)) { @@ -1197,7 +1197,7 @@ namespace Nz OpenGL::Format openGLFormat; if (!OpenGL::TranslateFormat(m_impl->format, &openGLFormat, OpenGL::FormatType_Texture)) { - NazaraError("Format " + PixelFormat::ToString(m_impl->format) + " not supported by OpenGL"); + NazaraError("Format " + PixelFormat::GetName(m_impl->format) + " not supported by OpenGL"); return false; } @@ -1306,7 +1306,7 @@ namespace Nz glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, openGLFormat.swizzle[3]); } - if (!proxy && PixelFormat::GetType(m_impl->format) == PixelFormatTypeType_Depth) + if (!proxy && PixelFormat::GetContent(m_impl->format) == PixelFormatContent_DepthStencil) { glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index baa2657b3..fe775d97a 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -169,7 +169,7 @@ namespace Nz { if (header.format.flags & (DDPF_RGB | DDPF_ALPHA | DDPF_ALPHAPIXELS | DDPF_LUMINANCE)) { - PixelFormatInfo info(header.format.bpp, PixelFormatSubType_Unsigned); + PixelFormatInfo info(PixelFormatContent_ColorRGBA, header.format.bpp, PixelFormatSubType_Unsigned); if (header.format.flags & DDPF_RGB) { diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 6d05b493c..c8f3e49f1 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -89,7 +89,7 @@ namespace Nz if (!PixelFormat::IsConversionSupported(m_sharedImage->format, newFormat)) { - NazaraError("Conversion from " + PixelFormat::ToString(m_sharedImage->format) + " to " + PixelFormat::ToString(newFormat) + " is not supported"); + NazaraError("Conversion from " + PixelFormat::GetName(m_sharedImage->format) + " to " + PixelFormat::GetName(newFormat) + " is not supported"); return false; } #endif @@ -327,7 +327,7 @@ namespace Nz std::unique_ptr colorBuffer(new UInt8[bpp]); if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) { - NazaraError("Failed to convert RGBA8 to " + PixelFormat::ToString(m_sharedImage->format)); + NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format)); return false; } @@ -405,7 +405,7 @@ namespace Nz std::unique_ptr colorBuffer(new UInt8[bpp]); if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) { - NazaraError("Failed to convert RGBA8 to " + PixelFormat::ToString(m_sharedImage->format)); + NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format)); return false; } @@ -477,7 +477,7 @@ namespace Nz std::unique_ptr colorBuffer(new UInt8[bpp]); if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) { - NazaraError("Failed to convert RGBA8 to " + PixelFormat::ToString(m_sharedImage->format)); + NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format)); return false; } diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index 8c571d62e..a9b740b8f 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -48,7 +48,7 @@ namespace Nz NazaraUnused(dst); NazaraUnused(end); - NazaraInternalError("Conversion from " + PixelFormat::ToString(from) + " to " + PixelFormat::ToString(to) + " is not supported"); + NazaraInternalError("Conversion from " + PixelFormat::GetName(from) + " to " + PixelFormat::GetName(to) + " is not supported"); return nullptr; } @@ -1270,15 +1270,13 @@ namespace Nz PixelFormatType PixelFormat::IdentifyFormat(const PixelFormatInfo& info) { - switch (info.bitsPerPixel) + for (unsigned int i = 0; i <= PixelFormatType_Max; ++i) { - case 32: - if (info.redMask == Bitset<>(0xFF000000) && - info.greenMask == Bitset<>(0x00FF0000) && - info.blueMask == Bitset<>(0x0000FF00) && - info.alphaMask == Bitset<>(0x000000FF)) - return PixelFormatType_RGBA8; - break; + PixelFormatInfo& info2 = s_pixelFormatInfos[i]; + if (info.bitsPerPixel == info2.bitsPerPixel && info.content == info2.content && + info.redMask == info2.redMask && info.greenMask == info2.greenMask && info.blueMask == info2.blueMask && info.alphaMask == info2.alphaMask && + info.redType == info2.redType && info.greenType == info2.greenType && info.blueType == info2.blueType && info.alphaType == info2.alphaType) + return static_cast(i); } return PixelFormatType_Undefined; @@ -1286,7 +1284,67 @@ namespace Nz bool PixelFormat::Initialize() { - // Réinitialisation + // Setup informations about every pixel format + s_pixelFormatInfos[PixelFormatType_A8] = PixelFormatInfo("A8", PixelFormatContent_ColorRGBA, 0, 0, 0, 0xFF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_BGR8] = PixelFormatInfo("BGR8", PixelFormatContent_ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_BGRA8] = PixelFormatInfo("BGRA8", PixelFormatContent_ColorRGBA, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_DXT1] = PixelFormatInfo("DXT1", PixelFormatContent_ColorRGBA, 8, PixelFormatSubType_Compressed); + s_pixelFormatInfos[PixelFormatType_DXT3] = PixelFormatInfo("DXT3", PixelFormatContent_ColorRGBA, 16, PixelFormatSubType_Compressed); + s_pixelFormatInfos[PixelFormatType_DXT5] = PixelFormatInfo("DXT5", PixelFormatContent_ColorRGBA, 16, PixelFormatSubType_Compressed); + s_pixelFormatInfos[PixelFormatType_L8] = PixelFormatInfo("L8", PixelFormatContent_ColorRGBA, 0xFF, 0xFF, 0xFF, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_LA8] = PixelFormatInfo("LA8", PixelFormatContent_ColorRGBA, 0xFF00, 0xFF00, 0xFF00, 0x00FF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_R8] = PixelFormatInfo("R8", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_R8I] = PixelFormatInfo("R8I", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_R8UI] = PixelFormatInfo("R8UI", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_R16] = PixelFormatInfo("R16", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_R16F] = PixelFormatInfo("R16F", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormatType_R16I] = PixelFormatInfo("R16I", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_R16UI] = PixelFormatInfo("R16UI", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_R32F] = PixelFormatInfo("R32F", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormatType_R32I] = PixelFormatInfo("R32I", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_R32UI] = PixelFormatInfo("R32UI", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RG8] = PixelFormatInfo("RG8", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RG8I] = PixelFormatInfo("RG8I", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RG8UI] = PixelFormatInfo("RG8UI", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RG16] = PixelFormatInfo("RG16", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RG16F] = PixelFormatInfo("RG16F", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormatType_RG16I] = PixelFormatInfo("RG16I", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RG16UI] = PixelFormatInfo("RG16UI", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RG32F] = PixelFormatInfo("RG32F", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormatType_RG32I] = PixelFormatInfo("RG32I", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RG32UI] = PixelFormatInfo("RG32UI", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGB8] = PixelFormatInfo("RGB8", PixelFormatContent_ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGB16F] = PixelFormatInfo("RGB16F", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormatType_RGB16I] = PixelFormatInfo("RGB16I", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RGB16UI] = PixelFormatInfo("RGB16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGB32F] = PixelFormatInfo("RGB32F", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormatType_RGB32I] = PixelFormatInfo("RGB32I", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RGB32UI] = PixelFormatInfo("RGB32UI", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGBA4] = PixelFormatInfo("RGBA4", PixelFormatContent_ColorRGBA, 0xF000, 0x0F00, 0x00F0, 0x000F, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGB5A1] = PixelFormatInfo("RGB5A1", PixelFormatContent_ColorRGBA, 0xF800, 0x07C0, 0x003E, 0x0001, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGBA8] = PixelFormatInfo("RGBA8", PixelFormatContent_ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGBA16F] = PixelFormatInfo("RGBA16F", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormatType_RGBA16I] = PixelFormatInfo("RGBA16I", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RGBA16UI] = PixelFormatInfo("RGBA16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGBA32F] = PixelFormatInfo("RGBA32F", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormatType_RGBA32I] = PixelFormatInfo("RGBA32I", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RGBA32UI] = PixelFormatInfo("RGBA32UI", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Depth16] = PixelFormatInfo("Depth16", PixelFormatContent_DepthStencil, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Depth24] = PixelFormatInfo("Depth24", PixelFormatContent_DepthStencil, 0xFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Depth24Stencil8] = PixelFormatInfo("Depth24Stencil8", PixelFormatContent_DepthStencil, 0xFFFFFF00, 0x000000FF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Depth32] = PixelFormatInfo("Depth32", PixelFormatContent_DepthStencil, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Stencil1] = PixelFormatInfo("Stencil1", PixelFormatContent_Stencil, 0x1, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Stencil4] = PixelFormatInfo("Stencil4", PixelFormatContent_Stencil, 0xF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Stencil8] = PixelFormatInfo("Stencil8", PixelFormatContent_Stencil, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_Stencil16] = PixelFormatInfo("Stencil16", PixelFormatContent_Stencil, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + + for (unsigned int i = 0; i <= PixelFormatType_Max; ++i) + { + if (!s_pixelFormatInfos[i].Validate()) + NazaraWarning("Pixel format 0x" + String::Number(i, 16) + " (" + GetName(static_cast(i)) + ") failed validation tests"); + } + + // Reset functions std::memset(s_convertFunctions, 0, (PixelFormatType_Max+1)*(PixelFormatType_Max+1)*sizeof(PixelFormat::ConvertFunction)); /***********************************A8************************************/ @@ -1511,12 +1569,16 @@ namespace Nz void PixelFormat::Uninitialize() { + for (unsigned int i = 0; i <= PixelFormatType_Max; ++i) + s_pixelFormatInfos[i].Clear(); + std::memset(s_convertFunctions, 0, (PixelFormatType_Max+1)*(PixelFormatType_Max+1)*sizeof(PixelFormat::ConvertFunction)); for (unsigned int i = 0; i <= PixelFlipping_Max; ++i) s_flipFunctions[i].clear(); } + PixelFormatInfo PixelFormat::s_pixelFormatInfos[PixelFormatType_Max + 1]; PixelFormat::ConvertFunction PixelFormat::s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1]; std::map PixelFormat::s_flipFunctions[PixelFlipping_Max+1]; } From 43895d29af9eb8dd8c707e65ae4847b78a495232 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 May 2016 17:08:14 +0200 Subject: [PATCH 035/383] Core/Algorithm: Add ReverseBits function Former-commit-id: fa37fcf64cfe6786b9906aa7a8b410e19a3079d1 --- include/Nazara/Core/Algorithm.hpp | 1 + include/Nazara/Core/Algorithm.inl | 19 +++++++++++++++++ src/Nazara/Core/AlgorithmCore.cpp | 34 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/Nazara/Core/AlgorithmCore.cpp diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index f031854c5..b8a3206af 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -26,6 +26,7 @@ namespace Nz template constexpr std::size_t CountOf(T(&name)[N]) noexcept; template std::size_t CountOf(const T& c); template void HashCombine(std::size_t& seed, const T& v); + template T ReverseBits(T integer); template struct PointedType diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 821a9069f..72b5ee27a 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -28,6 +28,8 @@ namespace Nz { return (object .* std::forward(fn))(std::get(std::forward(t))...); } + + NAZARA_CORE_API extern const UInt8 BitReverseTable256[256]; } /*! @@ -164,6 +166,23 @@ namespace Nz seed = static_cast(b * kMul); } + /*! + * \ingroup core + * \brief Reverse the bit order of the integer + * \return integer with reversed bits + * + * \param integer Integer whose bits are to be reversed + */ + template + T ReverseBits(T integer) + { + T reversed = 0; + for (std::size_t i = 0; i < sizeof(T); ++i) + reversed |= T(Detail::BitReverseTable256[(integer >> i * 8) & 0xFF]) << sizeof(T) * 8 - (i + 1) * 8; + + return reversed; + } + template struct PointedType {typedef T type;}; template struct PointedType {typedef T type;}; template struct PointedType {typedef T type;}; diff --git a/src/Nazara/Core/AlgorithmCore.cpp b/src/Nazara/Core/AlgorithmCore.cpp new file mode 100644 index 000000000..1a9d8a171 --- /dev/null +++ b/src/Nazara/Core/AlgorithmCore.cpp @@ -0,0 +1,34 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Detail + { + const UInt8 BitReverseTable256[256] = + { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; + } +} + +#include From 549f37efb8e0ca7e539f5c9804dcff6572c26199 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 May 2016 17:08:45 +0200 Subject: [PATCH 036/383] Core/Bitset: Fix OR/XOR with two bitset of similar size Former-commit-id: df5c15cb0c1c4984c7bc142886843f8977379ec2 --- include/Nazara/Core/Bitset.inl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index 568d4a815..f7256bdbb 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -329,8 +329,8 @@ namespace Nz template void Bitset::PerformsOR(const Bitset& a, const Bitset& b) { - const Bitset& greater = (a.GetBlockCount() > b.GetBlockCount()) ? a : b; - const Bitset& lesser = (a.GetBlockCount() > b.GetBlockCount()) ? b : a; + const Bitset& greater = (a.GetSize() > b.GetSize()) ? a : b; + const Bitset& lesser = (a.GetSize() > b.GetSize()) ? b : a; unsigned int maxBlockCount = greater.GetBlockCount(); unsigned int minBlockCount = lesser.GetBlockCount(); @@ -358,8 +358,8 @@ namespace Nz template void Bitset::PerformsXOR(const Bitset& a, const Bitset& b) { - const Bitset& greater = (a.GetBlockCount() > b.GetBlockCount()) ? a : b; - const Bitset& lesser = (a.GetBlockCount() > b.GetBlockCount()) ? b : a; + const Bitset& greater = (a.GetSize() > b.GetSize()) ? a : b; + const Bitset& lesser = (a.GetSize() > b.GetSize()) ? b : a; unsigned int maxBlockCount = greater.GetBlockCount(); unsigned int minBlockCount = lesser.GetBlockCount(); From 7ae35a0f804c89f921870f283bc70c4d31c9c2c8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 May 2016 17:09:08 +0200 Subject: [PATCH 037/383] Utility/DDSLoader: Fix bit reversing for exotic format Former-commit-id: be5a619259410e212fb3124d02d291431c5a0859 --- src/Nazara/Utility/Formats/DDSLoader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index fe775d97a..d9783115b 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -173,16 +173,16 @@ namespace Nz if (header.format.flags & DDPF_RGB) { - // DDS Masks are in little endian - info.redMask = SwapBytes(header.format.redMask); - info.greenMask = SwapBytes(header.format.greenMask); - info.blueMask = SwapBytes(header.format.blueMask); + // Reverse bits for our masks + info.redMask = ReverseBits(header.format.redMask); + info.greenMask = ReverseBits(header.format.greenMask); + info.blueMask = ReverseBits(header.format.blueMask); } else if (header.format.flags & DDPF_LUMINANCE) - info.redMask = SwapBytes(header.format.redMask); + info.redMask = ReverseBits(header.format.redMask); if (header.format.flags & (DDPF_ALPHA | DDPF_ALPHAPIXELS)) - info.alphaMask = SwapBytes(header.format.alphaMask); + info.alphaMask = ReverseBits(header.format.alphaMask); *format = PixelFormat::IdentifyFormat(info); if (!PixelFormat::IsValid(*format)) From dff823fe1d22a1feaf4f553a0dc2a79281fdeae9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 May 2016 18:11:05 +0200 Subject: [PATCH 038/383] Sdk/LuaAPI: Fix handles retrieval Former-commit-id: e7aca6dff50c97630e86e90148a9778186e21707 --- SDK/include/NDK/LuaAPI.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index cbd4e7c4a..ae2da917c 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -255,14 +255,14 @@ namespace Nz inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::EntityHandle* handle, TypeTag) { - *handle = std::move(*static_cast(instance.CheckUserdata(index, "Entity"))); + *handle = *static_cast(instance.CheckUserdata(index, "Entity")); return 1; } inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::WorldHandle* handle, TypeTag) { - *handle = std::move(*static_cast(instance.CheckUserdata(index, "World"))); + *handle = *static_cast(instance.CheckUserdata(index, "World")); return 1; } From 9036eb48047b2e33243e2cc67cf0ca4cda08056e Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 May 2016 20:14:06 +0200 Subject: [PATCH 039/383] Graphics/Light: Fix compilation Former-commit-id: 39de337102ae862b74d5fe8fae9fdb7e19e32e06 --- include/Nazara/Graphics/Light.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index 266f7939a..e877852cb 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -178,7 +178,7 @@ namespace Nz inline void Light::SetShadowMapFormat(PixelFormatType shadowFormat) { - NazaraAssert(PixelFormat::GetType(shadowFormat) == PixelFormatTypeType_Depth, "Shadow format type is not a depth format"); + NazaraAssert(PixelFormat::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format"); m_shadowMapFormat = shadowFormat; From 16de05a3b96a2dbfa137f8da6b2fe2c56207126b Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 May 2016 20:22:30 +0200 Subject: [PATCH 040/383] Plugins/Assimp: Fix UV parameters Former-commit-id: e5096eb02ae91ad84e0b4a6729f181c09f113367 --- plugins/Assimp/Plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 395ca6305..1c998e91c 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -104,7 +104,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) | aiProcess_OptimizeGraph | aiProcess_FlipWindingOrder | aiProcess_Debone; - if (!parameters.flipUVs) + if (parameters.flipUVs) postProcess |= aiProcess_FlipUVs; if (parameters.optimizeIndexBuffers) From c0bfaa12b08b6a3509a2cc2551292dd17c4f75cb Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 May 2016 00:44:58 +0200 Subject: [PATCH 041/383] Plugins/Assimp: Fix stack corruption Former-commit-id: 8dc0f64ecb15f4f810c40b0a6c9be519d049ad62 --- plugins/Assimp/Plugin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 1c998e91c..68c443b29 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -206,8 +206,8 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) { aiVector3D position = iMesh->mVertices[j]; aiVector3D normal = iMesh->mNormals[j]; - aiVector3D tangent = iMesh->mTangents[j]; - aiVector3D uv = iMesh->mTextureCoords[0][j]; + aiVector3D tangent = (iMesh->HasTangentsAndBitangents()) ? iMesh->mTangents[j] : aiVector3D(0.f, 1.f, 0.f); + aiVector3D uv = (iMesh->HasTextureCoords(0)) ? iMesh->mTextureCoords[0][j] : aiVector3D(0.f); vertex->position = parameters.scale * Vector3f(position.x, position.y, position.z); vertex->normal.Set(normal.x, normal.y, normal.z); @@ -246,8 +246,8 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) auto ConvertTexture = [&] (aiTextureType aiType, const char* textureKey, const char* wrapKey = nullptr) { aiString path; - aiTextureMapMode mapMode; - if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode, nullptr) == aiReturn_SUCCESS) + aiTextureMapMode mapMode[3]; + if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS) { matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length)); @@ -255,7 +255,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) if (wrapKey) { SamplerWrap wrap = SamplerWrap_Default; - switch (mapMode) + switch (mapMode[0]) { case aiTextureMapMode_Clamp: case aiTextureMapMode_Decal: @@ -271,7 +271,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) break; default: - NazaraWarning("Assimp texture map mode 0x" + String::Number(mapMode, 16) + " not handled"); + NazaraWarning("Assimp texture map mode 0x" + String::Number(mapMode[0], 16) + " not handled"); break; } From be76deed06b12e1ec0efbdce0dca8b317a405abe Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 May 2016 21:31:49 +0200 Subject: [PATCH 042/383] Vulkan/Instance: Fix support of VK_KHR_surface Former-commit-id: 8d055017ac65d53da26fa61e645f527290472199 --- src/Nazara/Vulkan/VkInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Vulkan/VkInstance.cpp b/src/Nazara/Vulkan/VkInstance.cpp index e66189b7c..35378a699 100644 --- a/src/Nazara/Vulkan/VkInstance.cpp +++ b/src/Nazara/Vulkan/VkInstance.cpp @@ -65,7 +65,7 @@ namespace Nz } // VK_KHR_surface - if (IsExtensionLoaded("VK_KHR_display")) + if (IsExtensionLoaded("VK_KHR_surface")) { NAZARA_VULKAN_LOAD_INSTANCE(vkDestroySurfaceKHR); NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); From e536f1c9629eec4841e55390404f7dbec879b07d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 May 2016 21:32:41 +0200 Subject: [PATCH 043/383] Vulkan/Surface: Add a few wrapper methods Former-commit-id: 7c299cdd3964279dd6dafb25acc762d753c17ab0 --- include/Nazara/Vulkan/VkSurface.hpp | 5 ++ include/Nazara/Vulkan/VkSurface.inl | 73 +++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp index 7b7fbcdfd..03a57d2fe 100644 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ b/include/Nazara/Vulkan/VkSurface.hpp @@ -64,6 +64,11 @@ namespace Nz inline void Destroy(); + bool GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities); + bool GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats); + bool GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes); + bool GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported); + inline bool IsSupported() const; inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl index e7b0efe64..b6cb3a28f 100644 --- a/include/Nazara/Vulkan/VkSurface.inl +++ b/include/Nazara/Vulkan/VkSurface.inl @@ -173,6 +173,79 @@ namespace Nz return m_lastErrorCode; } + inline bool Surface::GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) + { + m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surface, surfaceCapabilities); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query surface capabilities"); + return false; + } + + return true; + } + + inline bool Surface::GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) + { + // First, query format count + UInt32 surfaceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t + m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, nullptr); + if (m_lastErrorCode != VkResult::VK_SUCCESS || surfaceCount == 0) + { + NazaraError("Failed to query format count"); + return false; + } + + // Now we can get the list of the available physical device + surfaceFormats->resize(surfaceCount); + m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, surfaceFormats->data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query formats"); + return false; + } + + return true; + } + + inline bool Surface::GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) + { + // First, query present modes count + UInt32 presentModeCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t + m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, nullptr); + if (m_lastErrorCode != VkResult::VK_SUCCESS || presentModeCount == 0) + { + NazaraError("Failed to query present mode count"); + return false; + } + + // Now we can get the list of the available physical device + presentModes->resize(presentModeCount); + m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, presentModes->data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query present modes"); + return false; + } + + return true; + } + + inline bool Surface::GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) + { + VkBool32 presentationSupported = VK_FALSE; + m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, m_surface, &presentationSupported); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query surface capabilities"); + return false; + } + + *supported = (presentationSupported == VK_TRUE); + + return true; + } + inline bool Surface::IsSupported() const { if (!m_instance.IsExtensionLoaded("VK_KHR_surface")) From 358f0ea87bc6aa2cba5622018b4f659392af934f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 09:03:49 +0200 Subject: [PATCH 044/383] Vulkan/CommandPool: Fix linking error Former-commit-id: 89988bc96174b5531a7ed1478cf8486ef6c50289 --- include/Nazara/Vulkan/VkCommandPool.hpp | 6 +++--- include/Nazara/Vulkan/VkCommandPool.inl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandPool.hpp b/include/Nazara/Vulkan/VkCommandPool.hpp index 8b99513e3..b51061bb2 100644 --- a/include/Nazara/Vulkan/VkCommandPool.hpp +++ b/include/Nazara/Vulkan/VkCommandPool.hpp @@ -20,7 +20,7 @@ namespace Nz using CommandPoolHandle = ObjectHandle; - class CommandPool : public DeviceObject, public HandledObject + class NAZARA_VULKAN_API CommandPool : public DeviceObject, public HandledObject { friend DeviceObject; @@ -42,8 +42,8 @@ namespace Nz CommandPool& operator=(CommandPool&&) = delete; private: - static VkResult CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); - static void DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); + static inline void DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkCommandPool.inl b/include/Nazara/Vulkan/VkCommandPool.inl index f7aef6978..61cfeaa43 100644 --- a/include/Nazara/Vulkan/VkCommandPool.inl +++ b/include/Nazara/Vulkan/VkCommandPool.inl @@ -38,12 +38,12 @@ namespace Nz return true; } - VkResult CommandPool::CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) + inline VkResult CommandPool::CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) { return device.vkCreateCommandPool(device, createInfo, allocator, handle); } - void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) + inline void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) { return device.vkDestroyCommandPool(device, handle, allocator); } From aa654b5caf8e2d13e03376ea484b6fff4de58aab Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 09:04:01 +0200 Subject: [PATCH 045/383] Vulkan/CommandBuffer: Fix crash when moving Former-commit-id: fbb9c69e709109ca9f06def3bf8b35e112ee294c --- include/Nazara/Vulkan/VkCommandBuffer.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index ff4eaede4..7e48901c2 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -33,7 +33,8 @@ namespace Nz inline void CommandBuffer::Free() { - m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); + if (m_handle) + m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); } inline VkResult CommandBuffer::GetLastErrorCode() const From 42fba6eee4deff7f52ae07a07cd735c345fb793c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 09:04:29 +0200 Subject: [PATCH 046/383] Vulkan/Device: Improve and rename GetDeviceQueue method Former-commit-id: 7887f86989e9f19f315275bcb944147bca306afd --- include/Nazara/Vulkan/VkDevice.hpp | 2 +- include/Nazara/Vulkan/VkDevice.inl | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 084aaa2f0..8f915e965 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -34,7 +34,7 @@ namespace Nz bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); - inline void GetDeviceQueue(UInt32 queueFamilyIndex, UInt32 queueIndex, VkQueue* queue); + inline VkQueue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index e837f67f6..471107c84 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -31,9 +31,12 @@ namespace Nz } } - inline void Device::GetDeviceQueue(UInt32 queueFamilyIndex, UInt32 queueIndex, VkQueue* queue) + inline VkQueue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { - return vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, queue); + VkQueue queue; + vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); + + return queue; } inline Instance& Device::GetInstance() From 602c39e8baf0309deee47b8ced5470a4e1478d0e Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 09:07:31 +0200 Subject: [PATCH 047/383] Vulkan/Swapchain: Wrap images creation/getters Former-commit-id: 50e5890c7aeb16408a460e6734301c6393c435e5 --- include/Nazara/Vulkan/VkSwapchain.hpp | 10 +++++ include/Nazara/Vulkan/VkSwapchain.inl | 53 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index ea47970d5..374ad88e6 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -24,6 +24,14 @@ namespace Nz Swapchain(Swapchain&&) = default; ~Swapchain() = default; + inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex); + + inline bool Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); + + inline VkImage GetImage(UInt32 index) const; + inline const std::vector& GetImages() const; + inline UInt32 GetImageCount() const; + inline bool IsSupported() const; Swapchain& operator=(const Swapchain&) = delete; @@ -32,6 +40,8 @@ namespace Nz private: static VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); static void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); + + std::vector m_images; }; } } diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index e05dfefd3..8865012e4 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -16,6 +16,59 @@ namespace Nz { } + inline bool Swapchain::AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) + { + m_lastErrorCode = m_device.vkAcquireNextImageKHR(m_device, m_handle, timeout, semaphore, fence, imageIndex); + switch (m_lastErrorCode) + { + case VkResult::VK_SUBOPTIMAL_KHR: + case VkResult::VK_SUCCESS: + return true; + + default: + return false; + } + } + + inline bool Swapchain::Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) + { + if (!DeviceObject::Create(createInfo, allocator)) + return false; + + UInt32 imageCount = 0; + m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, nullptr); + if (m_lastErrorCode != VkResult::VK_SUCCESS || imageCount == 0) + { + NazaraError("Failed to query swapchain image count"); + return false; + } + + m_images.resize(imageCount); + m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, m_images.data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query swapchain images"); + return false; + } + + return true; + } + + inline VkImage Swapchain::GetImage(UInt32 index) const + { + return m_images[index]; + } + + inline const std::vector& Swapchain::GetImages() const + { + return m_images; + } + + inline UInt32 Swapchain::GetImageCount() const + { + return m_images.size(); + } + inline bool Swapchain::IsSupported() const { if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) From ecd4a7e4bb247231dbf761f950b98bc62cf78f7b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 18:33:47 +0200 Subject: [PATCH 048/383] Vulkan: Wrap vulkan queues Former-commit-id: 50a37b90b8f95d3842442e41357c117099d2afda --- include/Nazara/Vulkan/VkDevice.hpp | 3 +- include/Nazara/Vulkan/VkDevice.inl | 5 +- include/Nazara/Vulkan/VkQueue.hpp | 52 +++++++++++++++ include/Nazara/Vulkan/VkQueue.inl | 102 +++++++++++++++++++++++++++++ 4 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 include/Nazara/Vulkan/VkQueue.hpp create mode 100644 include/Nazara/Vulkan/VkQueue.inl diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 8f915e965..1b9d3a470 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -19,6 +19,7 @@ namespace Nz namespace Vk { class Device; + class Queue; class Instance; using DeviceHandle = ObjectHandle; @@ -34,7 +35,7 @@ namespace Nz bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); - inline VkQueue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); + inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index 471107c84..77dc1e254 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -31,12 +32,12 @@ namespace Nz } } - inline VkQueue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) + inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { VkQueue queue; vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - return queue; + return Queue(*this, queue); } inline Instance& Device::GetInstance() diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp new file mode 100644 index 000000000..35c8d16e0 --- /dev/null +++ b/include/Nazara/Vulkan/VkQueue.hpp @@ -0,0 +1,52 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKAN_VKQUEUE_HPP +#define NAZARA_VULKAN_VKQUEUE_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class Queue + { + public: + inline Queue(Device& device, VkQueue queue); + inline Queue(const Queue& queue); + inline Queue(Queue&& queue); + inline ~Queue() = default; + + inline Device& GetDevice(); + inline VkResult GetLastErrorCode() const; + + inline bool Present(const VkPresentInfoKHR& presentInfo); + inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); + + inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE); + inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE); + + inline bool WaitIdle(); + + Queue& operator=(const Queue& queue) = delete; + Queue& operator=(Queue&&) = delete; + + inline operator VkQueue(); + + protected: + Device& m_device; + VkQueue m_handle; + VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKQUEUE_HPP diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl new file mode 100644 index 000000000..a47918da3 --- /dev/null +++ b/include/Nazara/Vulkan/VkQueue.inl @@ -0,0 +1,102 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline Queue::Queue(Device& device, VkQueue queue) : + m_device(device), + m_handle(queue), + m_lastErrorCode(VkResult::VK_SUCCESS) + { + } + + inline Queue::Queue(const Queue& queue) : + m_device(queue.m_device), + m_handle(queue.m_handle), + m_lastErrorCode(queue.m_lastErrorCode) + { + } + + inline Queue::Queue(Queue&& queue) : + m_device(queue.m_device), + m_handle(queue.m_handle), + m_lastErrorCode(queue.m_lastErrorCode) + { + } + + inline Device& Queue::GetDevice() + { + return m_device; + } + + inline VkResult Queue::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) + { + m_lastErrorCode = m_device.vkQueuePresentKHR(m_handle, &presentInfo); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) + { + VkPresentInfoKHR presentInfo = + { + VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, + nullptr, + (waitSemaphore) ? 1U : 0U, + &waitSemaphore, + 1U, + &swapchain, + &imageIndex, + nullptr + }; + + return Present(presentInfo); + } + + inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) + { + return Submit(1, &submit, fence); + } + + inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) + { + m_lastErrorCode = m_device.vkQueueSubmit(m_handle, submitCount, submits, fence); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline bool Queue::WaitIdle() + { + m_lastErrorCode = m_device.vkQueueWaitIdle(m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline Queue::operator VkQueue() + { + return m_handle; + } + + } +} + +#include From 9c08208de3c998cc864117fcec08cafcedcbcc5a Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 May 2016 18:34:03 +0200 Subject: [PATCH 049/383] Vulkan/CommandBuffer: Add Begin/End overloads Former-commit-id: c2681cf86c04cfba835204e87b386f3527f689c4 --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 10 ++- include/Nazara/Vulkan/VkCommandBuffer.inl | 98 +++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 0399d4cf7..2dea341dd 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -23,7 +23,15 @@ namespace Nz CommandBuffer(const CommandBuffer&) = delete; CommandBuffer(CommandBuffer&& commandBuffer); inline ~CommandBuffer(); - + + inline bool Begin(const VkCommandBufferBeginInfo& info); + inline bool Begin(VkCommandBufferUsageFlags flags); + inline bool Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo); + inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); + inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); + + inline bool End(); + inline void Free(); inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index 7e48901c2..d9944e33b 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -31,6 +31,104 @@ namespace Nz Free(); } + inline bool CommandBuffer::Begin(const VkCommandBufferBeginInfo& info) + { + m_lastErrorCode = m_pool->GetDevice().vkBeginCommandBuffer(m_handle, &info); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to begin command buffer"); + return false; + } + + return true; + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags) + { + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + nullptr + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo) + { + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + &inheritanceInfo + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) + { + NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); + + VkCommandBufferInheritanceInfo inheritanceInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, + nullptr, + renderPass, + subpass, + framebuffer, + (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + queryFlags, + pipelineStatistics + }; + + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + &inheritanceInfo + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) + { + NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); + + VkCommandBufferInheritanceInfo inheritanceInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, + nullptr, + VK_NULL_HANDLE, + 0, + VK_NULL_HANDLE, + (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + queryFlags, + pipelineStatistics + }; + + VkCommandBufferBeginInfo beginInfo = { + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, + nullptr, + flags, + &inheritanceInfo + }; + + return Begin(beginInfo); + } + + inline bool CommandBuffer::End() + { + m_lastErrorCode = m_pool->GetDevice().vkEndCommandBuffer(m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to end command buffer"); + return false; + } + + return true; + } + inline void CommandBuffer::Free() { if (m_handle) From 3e78dd40adab0ab59df01a511958569711560a5a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 25 May 2016 13:52:10 +0200 Subject: [PATCH 050/383] Fix some GCC warnings Former-commit-id: b3292fcfd4d029793cb70f97ab608aeb7d0579ef --- .../NDK/Components/CameraComponent.inl | 4 +- .../NDK/Components/GraphicsComponent.inl | 3 +- SDK/include/NDK/LuaAPI.inl | 4 ++ SDK/src/NDK/Console.cpp | 5 +++ SDK/src/NDK/LuaBinding.cpp | 4 +- SDK/src/NDK/LuaBinding_Audio.cpp | 18 +++++---- SDK/src/NDK/LuaBinding_Math.cpp | 38 ++++++++++++++++++- include/Nazara/Core/Algorithm.inl | 4 +- include/Nazara/Core/HandledObject.inl | 3 +- include/Nazara/Graphics/Light.inl | 2 +- include/Nazara/Lua/LuaClass.inl | 10 +++-- include/Nazara/Network/IpAddress.inl | 8 ++-- include/Nazara/Network/TcpClient.hpp | 2 +- include/Nazara/Utility/PixelFormat.inl | 28 +++++++------- src/Nazara/Core/File.cpp | 6 +-- src/Nazara/Core/ParameterList.cpp | 13 +++++-- src/Nazara/Graphics/ForwardRenderQueue.cpp | 6 +-- src/Nazara/Renderer/RenderTexture.cpp | 5 ++- src/Nazara/Utility/AlgorithmUtility.cpp | 4 +- 19 files changed, 113 insertions(+), 54 deletions(-) diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index d3bb9177e..d91c357eb 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -11,8 +11,8 @@ namespace Ndk inline CameraComponent::CameraComponent() : m_projectionType(Nz::ProjectionType_Perspective), m_targetRegion(0.f, 0.f, 1.f, 1.f), - m_size(0.f), m_target(nullptr), + m_size(0.f), m_frustumUpdated(false), m_projectionMatrixUpdated(false), m_viewMatrixUpdated(false), @@ -30,8 +30,8 @@ namespace Ndk AbstractViewer(camera), m_projectionType(camera.m_projectionType), m_targetRegion(camera.m_targetRegion), - m_size(camera.m_size), m_target(nullptr), + m_size(camera.m_size), m_frustumUpdated(false), m_projectionMatrixUpdated(false), m_viewMatrixUpdated(false), diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 205eb9462..c330da5eb 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -8,6 +8,7 @@ namespace Ndk { inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) : Component(graphicsComponent), + HandledObject(graphicsComponent), m_boundingVolume(graphicsComponent.m_boundingVolume), m_transformMatrix(graphicsComponent.m_transformMatrix), m_boundingVolumeUpdated(graphicsComponent.m_boundingVolumeUpdated), @@ -41,7 +42,7 @@ namespace Ndk r.data.renderOrder = renderOrder; r.renderable = std::move(renderable); r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1)); - + InvalidateBoundingVolume(); } diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index ae2da917c..a42479cae 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -84,8 +84,12 @@ namespace Nz inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag) { + NazaraUnused(params); + instance.CheckType(index, Nz::LuaType_Table); + // Structure is empty for now + return 1; } diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 24a5d8df2..48ad10196 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -145,6 +145,7 @@ namespace Ndk { case Nz::Keyboard::Down: case Nz::Keyboard::Up: + { if (event.key.code == Nz::Keyboard::Up) m_historyPosition = std::min(m_commandHistory.size(), m_historyPosition + 1); else @@ -159,6 +160,10 @@ namespace Ndk m_inputDrawer.SetText(s_inputPrefix + text); m_inputTextSprite->Update(m_inputDrawer); break; + } + + default: + break; } break; } diff --git a/SDK/src/NDK/LuaBinding.cpp b/SDK/src/NDK/LuaBinding.cpp index 33c70dbe1..6acc05a46 100644 --- a/SDK/src/NDK/LuaBinding.cpp +++ b/SDK/src/NDK/LuaBinding.cpp @@ -29,8 +29,8 @@ namespace Ndk // SDK application("Application"), - nodeComponent("NodeComponent"), entityClass("Entity"), + nodeComponent("NodeComponent"), velocityComponent("VelocityComponent"), worldClass("World") @@ -39,9 +39,9 @@ namespace Ndk // Audio musicClass("Music"), + soundClass("Sound"), soundBuffer("SoundBuffer"), soundEmitter("SoundEmitter"), - soundClass("Sound"), // Graphics instancedRenderable("InstancedRenderable"), diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index d75c8215e..89452d720 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -76,6 +76,8 @@ namespace Ndk /*********************************** Nz::SoundBuffer **********************************/ soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance) { + NazaraUnused(lua); + Nz::PlacementNew(instance, Nz::SoundBuffer::New()); return true; }); @@ -115,16 +117,16 @@ namespace Ndk return 1; }); - soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& soundBuffer) -> int + soundBuffer.BindMethod("__tostring", [] (Nz::LuaInstance& lua, Nz::SoundBufferRef& instance) -> int { Nz::StringStream stream("SoundBuffer("); - if (soundBuffer->IsValid()) + if (instance->IsValid()) { - Nz::String filePath = soundBuffer->GetFilePath(); + Nz::String filePath = instance->GetFilePath(); if (!filePath.IsEmpty()) stream << "File: " << filePath << ", "; - - stream << "Duration: " << soundBuffer->GetDuration() / 1000.f << "s"; + + stream << "Duration: " << instance->GetDuration() / 1000.f << "s"; } stream << ')'; @@ -148,17 +150,17 @@ namespace Ndk soundEmitter.BindMethod("IsLooping", &Nz::SoundEmitter::IsLooping); soundEmitter.BindMethod("IsSpatialized", &Nz::SoundEmitter::IsSpatialized); - + soundEmitter.BindMethod("Pause", &Nz::SoundEmitter::Pause); soundEmitter.BindMethod("Play", &Nz::SoundEmitter::Play); - + soundEmitter.BindMethod("SetAttenuation", &Nz::SoundEmitter::SetAttenuation); soundEmitter.BindMethod("SetMinDistance", &Nz::SoundEmitter::SetMinDistance); soundEmitter.BindMethod("SetPitch", &Nz::SoundEmitter::SetPitch); soundEmitter.BindMethod("SetPosition", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetPosition); soundEmitter.BindMethod("SetVelocity", (void(Nz::SoundEmitter::*)(const Nz::Vector3f&)) &Nz::SoundEmitter::SetVelocity); soundEmitter.BindMethod("SetVolume", &Nz::SoundEmitter::SetVolume); - + soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop); } diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index cf5454450..7db9ae9e2 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -238,9 +238,15 @@ namespace Ndk case 'h': lua.Push(instance.height); return true; + + default: + break; } break; } + + default: + break; } return false; @@ -290,6 +296,9 @@ namespace Ndk } break; } + + default: + break; } return false; @@ -313,7 +322,7 @@ namespace Ndk Nz::PlacementNew(quaternion, *static_cast(lua.ToUserdata(1))); else break; - + return true; } @@ -389,6 +398,9 @@ namespace Ndk case 'z': instance.z = value; return true; + + default: + break; } return false; @@ -455,9 +467,15 @@ namespace Ndk case 'y': lua.Push(instance.y); return true; + + default: + break; } break; } + + default: + break; } return false; @@ -496,9 +514,15 @@ namespace Ndk case 'y': instance.y = value; return true; + + default: + break; } break; } + + default: + break; } return false; @@ -582,9 +606,15 @@ namespace Ndk case 'z': lua.Push(instance.z); return true; + + default: + break; } break; } + + default: + break; } return false; @@ -627,9 +657,15 @@ namespace Ndk case 'z': instance.z = value; return true; + + default: + break; } break; } + + default: + break; } return false; diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 72b5ee27a..048fae8e9 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -78,7 +78,7 @@ namespace Nz * \param v Object to hash * * \remark a HashAppend specialization for type T is required - * + * * \see ComputeHash */ template @@ -178,7 +178,7 @@ namespace Nz { T reversed = 0; for (std::size_t i = 0; i < sizeof(T); ++i) - reversed |= T(Detail::BitReverseTable256[(integer >> i * 8) & 0xFF]) << sizeof(T) * 8 - (i + 1) * 8; + reversed |= T(Detail::BitReverseTable256[(integer >> i * 8) & 0xFF]) << (sizeof(T) * 8 - (i + 1) * 8); return reversed; } diff --git a/include/Nazara/Core/HandledObject.inl b/include/Nazara/Core/HandledObject.inl index 738a5f7a5..da435302e 100644 --- a/include/Nazara/Core/HandledObject.inl +++ b/include/Nazara/Core/HandledObject.inl @@ -13,6 +13,7 @@ namespace Nz template HandledObject::HandledObject(const HandledObject& object) { + NazaraUnused(object); // Don't copy anything, we're a copy of the object, we have no handle right now } @@ -40,7 +41,7 @@ namespace Nz HandledObject& HandledObject::operator=(const HandledObject& object) { // Nothing to do - return *this; + return *this; } template diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index e877852cb..edff48a66 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -9,9 +9,9 @@ namespace Nz { inline Light::Light(const Light& light) : Renderable(light), + m_color(light.m_color), m_type(light.m_type), m_shadowMapFormat(light.m_shadowMapFormat), - m_color(light.m_color), m_shadowMapSize(light.m_shadowMapSize), m_shadowCastingEnabled(light.m_shadowCastingEnabled), m_shadowMapUpdated(false), diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index 710b50416..89487b653 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -21,6 +21,8 @@ namespace Nz { SetConstructor([] (Nz::LuaInstance& lua, T* instance) { + NazaraUnused(lua); + PlacementNew(instance); return true; }); @@ -132,9 +134,9 @@ namespace Nz lua.SetField(pair.first); // Method name } - m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& lua) + m_info->instanceGetters[m_info->name] = [info = m_info] (LuaInstance& instance) { - return static_cast(lua.CheckUserdata(1, info->name)); + return static_cast(instance.CheckUserdata(1, info->name)); }; } lua.Pop(); // On pop la metatable @@ -391,11 +393,11 @@ namespace Nz if (!lua.IsValid(-1)) { - for (const ParentFunc& getter : info->parentGetters) + for (const ParentFunc& parentGetter : info->parentGetters) { lua.Pop(); //< Pop the last nil value - getter(lua, instance); + parentGetter(lua, instance); if (lua.IsValid(-1)) return; } diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index c11c1879a..3184bd34d 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -224,7 +224,7 @@ namespace std // This is SDBM adapted for IP addresses, tested to generate the least collisions possible // (It doesn't mean it cannot be improved though) - std::size_t hash = 0; + std::size_t h = 0; switch (ip.GetProtocol()) { case Nz::NetProtocol_Any: @@ -233,20 +233,20 @@ namespace std case Nz::NetProtocol_IPv4: { - hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash; + h = ip.ToUInt32() + (h << 6) + (h << 16) - h; break; } case Nz::NetProtocol_IPv6: { Nz::IpAddress::IPv6 v6 = ip.ToIPv6(); for (std::size_t i = 0; i < v6.size(); i++) - hash = v6[i] + (hash << 6) + (hash << 16) - hash; + h = v6[i] + (h << 6) + (h << 16) - h; break; } } - return ip.GetPort() + (hash << 6) + (hash << 16) - hash; + return ip.GetPort() + (h << 6) + (h << 16) - h; } }; } diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index fda4671f9..0fcedcf39 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -79,8 +79,8 @@ namespace Nz PendingPacket m_pendingPacket; UInt64 m_keepAliveInterval; UInt64 m_keepAliveTime; - bool m_isLowDelayEnabled; bool m_isKeepAliveEnabled; + bool m_isLowDelayEnabled; }; } diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index 7b05ec8fb..e30701d3d 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -12,29 +12,29 @@ namespace Nz { inline PixelFormatInfo::PixelFormatInfo() : - bitsPerPixel(0), - content(PixelFormatContent_Undefined) + content(PixelFormatContent_Undefined), + bitsPerPixel(0) { } inline PixelFormatInfo::PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : - bitsPerPixel(bpp), - content(formatContent), - redType(subType), - greenType(subType), - blueType(subType), - alphaType(subType) - { - } - - inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : - bitsPerPixel(bpp), content(formatContent), redType(subType), greenType(subType), blueType(subType), alphaType(subType), - name(formatName) + bitsPerPixel(bpp) + { + } + + inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : + content(formatContent), + redType(subType), + greenType(subType), + blueType(subType), + alphaType(subType), + name(formatName), + bitsPerPixel(bpp) { } diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 97504b0ee..39e873373 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -385,7 +385,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param pos Position of the cursor @@ -404,7 +404,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param offset Offset according to the cursor begin position @@ -906,5 +906,5 @@ namespace Nz } return true; - }; + } } diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 91426a0b7..371e91b77 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -94,6 +94,7 @@ namespace Nz break; } + case ParameterType_Color: case ParameterType_Float: case ParameterType_None: case ParameterType_Pointer: @@ -198,6 +199,7 @@ namespace Nz } case ParameterType_Boolean: + case ParameterType_Color: case ParameterType_None: case ParameterType_Pointer: case ParameterType_Userdata: @@ -207,7 +209,7 @@ namespace Nz NazaraError("Parameter value is not representable as a float"); return false; } - + /*! * \brief Gets a parameter as an integer * \return true if the parameter could be represented as an integer @@ -263,6 +265,7 @@ namespace Nz break; } + case ParameterType_Color: case ParameterType_None: case ParameterType_Pointer: case ParameterType_Userdata: @@ -331,6 +334,7 @@ namespace Nz return true; case ParameterType_Boolean: + case ParameterType_Color: case ParameterType_Float: case ParameterType_Integer: case ParameterType_None: @@ -411,7 +415,7 @@ namespace Nz NazaraInternalError("Parameter value is not valid"); return false; } - + /*! * \brief Gets a parameter as an userdata * \return true if the parameter could be represented as a userdata @@ -584,7 +588,7 @@ namespace Nz parameter.type = ParameterType_Integer; parameter.value.intVal = value; } - + /*! * \brief Sets a pointer parameter named `name` * @@ -593,7 +597,7 @@ namespace Nz * \param name Name of the parameter * \param value The pointer value * - * \remark This sets a raw pointer, this class takes no responsibility toward it, + * \remark This sets a raw pointer, this class takes no responsibility toward it, if you wish to destroy the pointed variable along with the parameter list, you should set a userdata */ void ParameterList::SetParameter(const String& name, void* value) @@ -639,6 +643,7 @@ namespace Nz switch (it->second.type) { case ParameterType_Boolean: + case ParameterType_Color: case ParameterType_Float: case ParameterType_Integer: case ParameterType_Pointer: diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 683230706..9f0f5d04d 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -524,9 +524,9 @@ namespace Nz Vector3f viewerPos = viewer->GetEyePosition(); Vector3f viewerNormal = viewer->GetForward(); - for (auto& pair : layers) + for (auto& layerPair : layers) { - Layer& layer = pair.second; + Layer& layer = layerPair.second; std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2) { @@ -562,7 +562,7 @@ namespace Nz auto it = layers.find(i); if (it == layers.end()) it = layers.insert(std::make_pair(i, Layer())).first; - + Layer& layer = it->second; layer.clearCount = 0; diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index 0ae0d97bf..c6e78df86 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -57,11 +57,14 @@ namespace Nz case PixelFormatContent_Stencil: return AttachmentPoint_Stencil; + + case PixelFormatContent_Undefined: + break; } NazaraInternalError("Unexpected pixel format content: 0x" + String::Number(info.content, 16)); return AttachmentPoint_Max; - }; + } GLuint lockedPrevious = 0; UInt8 lockedLevel = 0; diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index b23542993..7f4dbaf44 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -105,9 +105,9 @@ namespace Nz for (unsigned int i = 0; i < recursionLevel; ++i) { std::size_t triangleCount = triangles.size(); - for (std::size_t i = 0; i < triangleCount; ++i) + for (std::size_t j = 0; j < triangleCount; ++j) { - Vector3ui& triangle = triangles[i]; + Vector3ui& triangle = triangles[j]; unsigned int a = GetMiddleVertex(triangle.x, triangle.y); unsigned int b = GetMiddleVertex(triangle.y, triangle.z); From 37ee0347022322454836a8d09a4cb8afa92fe77b Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 07:41:32 +0200 Subject: [PATCH 051/383] Graphics/DepthRenderTechnique: Fix typo in include name Former-commit-id: f304f7bf1f0ecc2d58ce68d3b3a64802958bf2c7 --- include/Nazara/Graphics/DepthRenderTechnique.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Graphics/DepthRenderTechnique.hpp b/include/Nazara/Graphics/DepthRenderTechnique.hpp index ac75f7e52..42b7f6e0a 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.hpp +++ b/include/Nazara/Graphics/DepthRenderTechnique.hpp @@ -74,6 +74,6 @@ namespace Nz } -#include +#include #endif // NAZARA_DEPTHRENDERTECHNIQUE_HPP From 044882bb31132ce7e212884cea3be37a9d9bbf41 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 08:48:22 +0200 Subject: [PATCH 052/383] Build: Improve build - Help linux default to 64bits build in case of 64bits OS - Fix linux linking with tools Former-commit-id: 31ea427401fd4fb12b453e8517b2cb4f24ded094 --- build/scripts/common.lua | 60 +++++++++++++++++++++++------------ examples/FirstScene/build.lua | 4 --- examples/Tut01/build.lua | 4 --- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index ec95c2641..15bf69849 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -5,12 +5,19 @@ function NazaraBuild:Execute() return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien end + local platformData + if (os.is64bit()) then + platformData = {"x64", "x86"} + else + platformData = {"x64", "x86"} + end + if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" if (#self.OrderedExtLibs > 0) then workspace("NazaraExtlibs") - platforms({"x32", "x64"}) + platforms(platformData) -- Configuration générale configurations({ @@ -23,13 +30,13 @@ function NazaraBuild:Execute() location(_ACTION) kind("StaticLib") - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") targetdir("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -40,7 +47,7 @@ function NazaraBuild:Execute() configuration("vs*") buildoptions("/MP") - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") targetdir("../extlibs/lib/msvc/x86") @@ -48,7 +55,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x64") targetdir("../extlibs/lib/msvc/x64") - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../extlibs/lib/xcode/x86") targetdir("../extlibs/lib/xcode/x86") @@ -102,7 +109,7 @@ function NazaraBuild:Execute() end workspace("NazaraEngine") - platforms({"x32", "x64"}) + platforms(platformData) -- Configuration générale configurations({ @@ -171,14 +178,14 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") targetdir("../lib/" .. makeLibDir .. "/x86") @@ -193,7 +200,7 @@ function NazaraBuild:Execute() self:MakeCopyAfterBuild(moduleTable) end - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") targetdir("../lib/msvc/x86") @@ -203,7 +210,7 @@ function NazaraBuild:Execute() libdirs("../lib/msvc/x64") targetdir("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") targetdir("../lib/xcode/x86") @@ -278,20 +285,20 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then targetdir("../lib/" .. makeLibDir .. "/x86") elseif (toolTable.Kind == "plugin") then - targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x32") + targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x86") end configuration({"codeblocks or codelite or gmake", "x64"}) @@ -308,7 +315,7 @@ function NazaraBuild:Execute() self:MakeCopyAfterBuild(toolTable) end - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") if (toolTable.Kind == "library") then @@ -326,7 +333,7 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x64") end - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") if (toolTable.Kind == "library") then @@ -406,26 +413,26 @@ function NazaraBuild:Execute() includedirs(exampleTable.Includes) links(exampleTable.Libraries) - configuration("x32") + configuration("x86") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) + configuration({"codeblocks or codelite or gmake", "x86"}) libdirs("../lib/" .. makeLibDir .. "/x86") configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../lib/" .. makeLibDir .. "/x64") - configuration({"vs*", "x32"}) + configuration({"vs*", "x86"}) libdirs("../lib/msvc/x86") configuration({"vs*", "x64"}) libdirs("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x32"}) + configuration({"xcode3 or xcode4", "x86"}) libdirs("../lib/xcode/x86") configuration({"xcode3 or xcode4", "x64"}) @@ -801,6 +808,17 @@ function NazaraBuild:Process(infoTable) for k,v in ipairs(toolTable.Includes) do table.insert(infoTable.Includes, v) end + + -- And libraries + for k, v in pairs(toolTable.Libraries) do + table.insert(infoTable.Libraries, v) + end + + for config, libs in pairs(toolTable.ConfigurationLibraries) do + for k,v in pairs(libs) do + table.insert(infoTable.ConfigurationLibraries[config], v) + end + end table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") @@ -853,8 +871,8 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do local paths = {} - table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) - table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) + table.insert(paths, {"x86", "../extlibs/lib/common/x86/" .. v .. ".dll"}) + table.insert(paths, {"x86", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) diff --git a/examples/FirstScene/build.lua b/examples/FirstScene/build.lua index bdcdf8bca..14bf8a42f 100644 --- a/examples/FirstScene/build.lua +++ b/examples/FirstScene/build.lua @@ -7,9 +7,5 @@ EXAMPLE.Files = { } EXAMPLE.Libraries = { - "NazaraCore", - "NazaraGraphics", - "NazaraRenderer", - "NazaraUtility", "NazaraSDK" } diff --git a/examples/Tut01/build.lua b/examples/Tut01/build.lua index 03b4457ab..c12dc35b5 100644 --- a/examples/Tut01/build.lua +++ b/examples/Tut01/build.lua @@ -7,9 +7,5 @@ EXAMPLE.Files = { } EXAMPLE.Libraries = { - "NazaraCore", - "NazaraGraphics", - "NazaraRenderer", - "NazaraUtility", "NazaraSDK" } From ea920d2e6481ad1be72f9f999ba8cfb978eccbd2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 08:50:49 +0200 Subject: [PATCH 053/383] Build: Fix linking for audio and utility system for POSIX Former-commit-id: 3eee15c4df5795b05a36fad43b5ae2a93de9152a --- build/scripts/modules/audio.lua | 17 ++++++++++++----- build/scripts/modules/utility.lua | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/build/scripts/modules/audio.lua b/build/scripts/modules/audio.lua index 4fcb1bf5a..27e49a08c 100644 --- a/build/scripts/modules/audio.lua +++ b/build/scripts/modules/audio.lua @@ -5,19 +5,26 @@ MODULE.Defines = { } MODULE.Libraries = { - "NazaraCore", + "NazaraCore" +} + +MODULE.OsLibraries.Windows = { "sndfile-1" } +MODULE.OsLibraries.Posix = { + "sndfile" +} + +MODULE.OsDynLib.Windows = { + "soft_oal" +} + MODULE.OsFiles.Windows = { "../src/Nazara/Audio/Win32/**.hpp", "../src/Nazara/Audio/Win32/**.cpp" } -MODULE.OsDynLib.Windows = { - "soft_oal" -} - MODULE.OsFiles.Posix = { "../src/Nazara/Audio/Posix/**.hpp", "../src/Nazara/Audio/Posix/**.cpp" diff --git a/build/scripts/modules/utility.lua b/build/scripts/modules/utility.lua index 1fafbd1a4..c1bc186c0 100644 --- a/build/scripts/modules/utility.lua +++ b/build/scripts/modules/utility.lua @@ -1,7 +1,6 @@ MODULE.Name = "Utility" MODULE.Libraries = { - "freetype-s", "NazaraCore", "stb_image" } @@ -17,10 +16,12 @@ MODULE.OsFiles.Posix = { } MODULE.OsLibraries.Windows = { + "freetype-s", "gdi32" } MODULE.OsLibraries.Posix = { + "freetype", "X11", "xcb", "xcb-cursor", From 8336c0552206b36f9f31812f01c555306391144d Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 13:36:52 +0200 Subject: [PATCH 054/383] Documentation for module: Audio Former-commit-id: acb9e00a7af8bf1c36f42b45fe7e7df99e03c0f9 --- include/Nazara/Audio/Algorithm.inl | 16 +- include/Nazara/Audio/Config.hpp | 15 +- include/Nazara/Audio/ConfigCheck.hpp | 4 +- include/Nazara/Audio/DebugOff.hpp | 2 +- include/Nazara/Audio/Enums.hpp | 2 +- include/Nazara/Audio/OpenAL.hpp | 10 +- include/Nazara/Audio/SoundBuffer.inl | 7 + include/Nazara/Audio/SoundEmitter.hpp | 2 +- src/Nazara/Audio/Audio.cpp | 176 ++++++++++++++++-- src/Nazara/Audio/Music.cpp | 172 +++++++++++++++-- src/Nazara/Audio/OpenAL.cpp | 125 +++++++++++-- src/Nazara/Audio/Sound.cpp | 130 ++++++++++++- src/Nazara/Audio/SoundBuffer.cpp | 144 +++++++++++++- src/Nazara/Audio/SoundEmitter.cpp | 123 +++++++++++- src/Nazara/Audio/SoundStream.cpp | 8 + tests/Engine/Audio/AlgorithmAudio.cpp | 19 ++ tests/Engine/Audio/Music.cpp | 49 +++++ tests/Engine/Audio/Sound.cpp | 44 +++++ tests/Engine/Audio/SoundBuffer.cpp | 21 +++ tests/Engine/Audio/SoundEmitter.cpp | 41 ++++ .../Engine/Audio/Cat.flac.REMOVED.git-id | 1 + .../Audio/The_Brabanconne.ogg.REMOVED.git-id | 1 + tests/resources/Engine/Audio/copyrights.txt | 54 ++++++ 23 files changed, 1110 insertions(+), 56 deletions(-) create mode 100644 tests/Engine/Audio/AlgorithmAudio.cpp create mode 100644 tests/Engine/Audio/Music.cpp create mode 100644 tests/Engine/Audio/Sound.cpp create mode 100644 tests/Engine/Audio/SoundBuffer.cpp create mode 100644 tests/Engine/Audio/SoundEmitter.cpp create mode 100644 tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id create mode 100644 tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id create mode 100644 tests/resources/Engine/Audio/copyrights.txt diff --git a/include/Nazara/Audio/Algorithm.inl b/include/Nazara/Audio/Algorithm.inl index ec89cdca9..1075a8b57 100644 --- a/include/Nazara/Audio/Algorithm.inl +++ b/include/Nazara/Audio/Algorithm.inl @@ -7,11 +7,21 @@ namespace Nz { + /*! + * \ingroup audio + * \brief Mixes channels in mono + * + * \param input Input buffer with multiples channels + * \param output Output butter for mono + * \param channelCount Number of channels + * \param frameCount Number of frames + * + * \remark The input buffer may be the same as the output one + */ template void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount) { - ///DOC: Le buffer d'entrée peut être le même que le buffer de sortie - // Pour éviter l'overflow, on utilise comme accumulateur un type assez grand, (u)int 64 bits pour les entiers, double pour les flottants + // To avoid overflow, we use, as an accumulator, a type which is large enough: (u)int 64 bits for integers, double for floatings typedef typename std::conditional::value, UInt64, Int64>::type BiggestInt; typedef typename std::conditional::value, BiggestInt, double>::type Biggest; @@ -19,7 +29,7 @@ namespace Nz { Biggest acc = Biggest(0); for (unsigned int j = 0; j < channelCount; ++j) - acc += input[i*channelCount + j]; + acc += input[i * channelCount + j]; output[i] = static_cast(acc / channelCount); } diff --git a/include/Nazara/Audio/Config.hpp b/include/Nazara/Audio/Config.hpp index e11bda468..8e2068069 100644 --- a/include/Nazara/Audio/Config.hpp +++ b/include/Nazara/Audio/Config.hpp @@ -27,18 +27,23 @@ #ifndef NAZARA_CONFIG_AUDIO_HPP #define NAZARA_CONFIG_AUDIO_HPP -/// Modifier la configuration d'un module nécessite une recompilation quasi-intégrale de celui-ci et de ceux en héritant +/*! +* \defgroup audio (NazaraAudio) Audio module +* Audio/System module including classes to handle music, sound, etc... +*/ -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +/// Each modification of a parameter needs a recompilation of the module + +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) #define NAZARA_AUDIO_MANAGE_MEMORY 0 -// Active les tests de sécurité supplémentaires (Teste notamment les arguments des fonctions, conseillé pour le développement) +// Activate the security tests based on the code (Advised for development) #define NAZARA_AUDIO_SAFE 1 -// Le nombre de buffers utilisés lors du streaming d'objets audio (Au moins deux) +// The number of buffers used for audio streaming (At least two) #define NAZARA_AUDIO_STREAMED_BUFFER_COUNT 2 -/// Vérification des valeurs et types de certaines constantes +/// Checking the values and types of certain constants #include #if !defined(NAZARA_STATIC) diff --git a/include/Nazara/Audio/ConfigCheck.hpp b/include/Nazara/Audio/ConfigCheck.hpp index 9ed35c1a4..70d0c6fe5 100644 --- a/include/Nazara/Audio/ConfigCheck.hpp +++ b/include/Nazara/Audio/ConfigCheck.hpp @@ -7,12 +7,12 @@ #ifndef NAZARA_CONFIG_CHECK_AUDIO_HPP #define NAZARA_CONFIG_CHECK_AUDIO_HPP -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp +/// This file is used to check the constant values defined in Config.hpp #include #define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) -// On force la valeur de MANAGE_MEMORY en mode debug +// We force the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_AUDIO_MANAGE_MEMORY #undef NAZARA_AUDIO_MANAGE_MEMORY #define NAZARA_AUDIO_MANAGE_MEMORY 0 diff --git a/include/Nazara/Audio/DebugOff.hpp b/include/Nazara/Audio/DebugOff.hpp index 254d7701d..e5149d5b5 100644 --- a/include/Nazara/Audio/DebugOff.hpp +++ b/include/Nazara/Audio/DebugOff.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +// We assume that Debug.hpp has already been included, same thing for Config.hpp #if NAZARA_AUDIO_MANAGE_MEMORY #undef delete #undef new diff --git a/include/Nazara/Audio/Enums.hpp b/include/Nazara/Audio/Enums.hpp index b8d3e3ec6..20866e5e9 100644 --- a/include/Nazara/Audio/Enums.hpp +++ b/include/Nazara/Audio/Enums.hpp @@ -13,7 +13,7 @@ namespace Nz { AudioFormat_Unknown = -1, - // La valeur entière est le nombre de canaux possédés par ce format + // The integer value is the number of channels used by the format AudioFormat_Mono = 1, AudioFormat_Stereo = 2, AudioFormat_Quad = 4, diff --git a/include/Nazara/Audio/OpenAL.hpp b/include/Nazara/Audio/OpenAL.hpp index eab95e6d0..aa80f406e 100644 --- a/include/Nazara/Audio/OpenAL.hpp +++ b/include/Nazara/Audio/OpenAL.hpp @@ -15,18 +15,18 @@ #include #include -// Inclusion des headers OpenAL +// Inclusion of OpenAL headers -// Étant donné que les headers OpenAL ne nous permettent pas de n'avoir que les signatures sans les pointeurs de fonctions -// Et que je ne souhaite pas les modifier, je suis contraint de les placer dans un espace de nom différent pour ensuite -// remettre dans l'espace global les choses intéressantes (les typedef notamment) +// OpenAL headers does not allow us to only get the signatures without the pointers to the functions +// And I do no want to modify them, I'm obliged to put them in a different namespace +// to put only interesting things back in the global namespace (specially typedef) namespace OpenALDetail { #include #include } -// Si quelqu'un a une meilleure idée ... +// If someone has a better idea ... using OpenALDetail::ALboolean; using OpenALDetail::ALbyte; using OpenALDetail::ALchar; diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index 9c5d1198b..a4c42be69 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -7,6 +7,13 @@ namespace Nz { + /*! + * \brief Creates a new sound buffer from the arguments + * \return A reference to the newly created sound buffer + * + * \param args Arguments for the sound buffer + */ + template SoundBufferRef SoundBuffer::New(Args&&... args) { diff --git a/include/Nazara/Audio/SoundEmitter.hpp b/include/Nazara/Audio/SoundEmitter.hpp index d56cd1bca..9a68d88cc 100644 --- a/include/Nazara/Audio/SoundEmitter.hpp +++ b/include/Nazara/Audio/SoundEmitter.hpp @@ -12,7 +12,7 @@ #include #include -///TODO: Faire hériter SoundEmitter de Node +///TODO: Inherit SoundEmitter from Node namespace Nz { diff --git a/src/Nazara/Audio/Audio.cpp b/src/Nazara/Audio/Audio.cpp index c0e785865..6eaa86c39 100644 --- a/src/Nazara/Audio/Audio.cpp +++ b/src/Nazara/Audio/Audio.cpp @@ -16,6 +16,21 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::Audio + * \brief Audio class that represents the module initializer of Audio + */ + + /*! + * \brief Gets the format of the audio + * \return AudioFormat Enumeration type for the format + * + * \param channelCount Number of channels + * + * \remark Produces a NazaraError if the number of channels is erroneous (3 or 5) and AudioFormat_Unknown is returned + */ + AudioFormat Audio::GetAudioFormat(unsigned int channelCount) { switch (channelCount) @@ -34,19 +49,36 @@ namespace Nz } } + /*! + * \brief Gets the factor of the doppler effect + * \return Global factor of the doppler effect + */ + float Audio::GetDopplerFactor() { return alGetFloat(AL_DOPPLER_FACTOR); } + /*! + * \brief Gets the global volume + * \return Float between [0, inf) with 100.f being the default + */ + float Audio::GetGlobalVolume() { ALfloat gain = 0.f; alGetListenerf(AL_GAIN, &gain); - return gain*100.f; + return gain * 100.f; } + /*! + * \brief Gets the direction of the listener + * \return Direction of the listener, in front of the listener + * + * \see GetListenerRotation + */ + Vector3f Audio::GetListenerDirection() { ALfloat orientation[6]; @@ -55,6 +87,13 @@ namespace Nz return Vector3f(orientation[0], orientation[1], orientation[2]); } + /*! + * \brief Gets the position of the listener + * \return Position of the listener + * + * \see GetListenerVelocity + */ + Vector3f Audio::GetListenerPosition() { Vector3f position; @@ -63,6 +102,11 @@ namespace Nz return position; } + /*! + * \brief Gets the rotation of the listener + * \return Rotation of the listener + */ + Quaternionf Audio::GetListenerRotation() { ALfloat orientation[6]; @@ -73,6 +117,13 @@ namespace Nz return Quaternionf::RotationBetween(Vector3f::Forward(), forward); } + /*! + * \brief Gets the velocity of the listener + * \return Velocity of the listener + * + * \see GetListenerPosition + */ + Vector3f Audio::GetListenerVelocity() { Vector3f velocity; @@ -81,20 +132,33 @@ namespace Nz return velocity; } + /*! + * \brief Gets the speed of sound + * \return Speed of sound + */ + float Audio::GetSpeedOfSound() { return alGetFloat(AL_SPEED_OF_SOUND); } + /*! + * \brief Initializes the Audio module + * \return true if initialization is successful + * + * \remark Produces a NazaraError if initialization of modules Core, OpenAL or SoundBuffer failed + * \remark Produces a NazaraNotice + */ + bool Audio::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; - return true; // Déjà initialisé + return true; // Already initialized } - // Initialisation des dépendances + // Initialisation of dependencies if (!Core::Initialize()) { NazaraError("Failed to initialize core module"); @@ -103,10 +167,10 @@ namespace Nz s_moduleReferenceCounter++; - // Initialisation du module + // Initialisation of the module CallOnExit onExit(Audio::Uninitialize); - // Initialisation d'OpenAL + // Initialisation of OpenAL if (!OpenAL::Initialize()) { NazaraError("Failed to initialize OpenAL"); @@ -119,7 +183,7 @@ namespace Nz return false; } - // Définition de l'orientation par défaut + // Definition of the orientation by default SetListenerDirection(Vector3f::Forward()); // Loaders @@ -131,6 +195,13 @@ namespace Nz return true; } + /*! + * \brief Checks whether the format is supported by the engine + * \return true if it is the case + * + * \param format Format to check + */ + bool Audio::IsFormatSupported(AudioFormat format) { if (format == AudioFormat_Unknown) @@ -139,21 +210,46 @@ namespace Nz return OpenAL::AudioFormat[format] != 0; } + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + bool Audio::IsInitialized() { return s_moduleReferenceCounter != 0; } + /*! + * \brief Sets the factor of the doppler effect + * + * \param dopplerFactor Global factor of the doppler effect + */ + void Audio::SetDopplerFactor(float dopplerFactor) { alDopplerFactor(dopplerFactor); } + /*! + * \brief Sets the global volume + * + * \param volume Float between [0, inf) with 100.f being the default + */ + void Audio::SetGlobalVolume(float volume) { - alListenerf(AL_GAIN, volume*0.01f); + alListenerf(AL_GAIN, volume * 0.01f); } + /*! + * \brief Sets the direction of the listener + * + * \param direction Direction of the listener, in front of the listener + * + * \see SetListenerDirection, SetListenerRotation + */ + void Audio::SetListenerDirection(const Vector3f& direction) { Vector3f up = Vector3f::Up(); @@ -167,6 +263,14 @@ namespace Nz alListenerfv(AL_ORIENTATION, orientation); } + /*! + * \brief Sets the direction of the listener + * + * \param (dirX, dirY, dirZ) Direction of the listener, in front of the listener + * + * \see SetListenerDirection, SetListenerRotation + */ + void Audio::SetListenerDirection(float dirX, float dirY, float dirZ) { Vector3f up = Vector3f::Up(); @@ -180,16 +284,38 @@ namespace Nz alListenerfv(AL_ORIENTATION, orientation); } + /*! + * \brief Sets the position of the listener + * + * \param position Position of the listener + * + * \see SetListenerVelocity + */ + void Audio::SetListenerPosition(const Vector3f& position) { alListenerfv(AL_POSITION, position); } + /*! + * \brief Sets the position of the listener + * + * \param (x, y, z) Position of the listener + * + * \see SetListenerVelocity + */ + void Audio::SetListenerPosition(float x, float y, float z) { alListener3f(AL_POSITION, x, y, z); } + /*! + * \brief Sets the rotation of the listener + * + * \param rotation Rotation of the listener + */ + void Audio::SetListenerRotation(const Quaternionf& rotation) { Vector3f forward = rotation * Vector3f::Forward(); @@ -204,33 +330,61 @@ namespace Nz alListenerfv(AL_ORIENTATION, orientation); } + /*! + * \brief Sets the velocity of the listener + * + * \param velocity Velocity of the listener + * + * \see SetListenerPosition + */ + void Audio::SetListenerVelocity(const Vector3f& velocity) { alListenerfv(AL_VELOCITY, velocity); } + /*! + * \brief Sets the velocity of the listener + * + * \param (velX, velY, velZ) Velocity of the listener + * + * \see SetListenerPosition + */ + void Audio::SetListenerVelocity(float velX, float velY, float velZ) { alListener3f(AL_VELOCITY, velX, velY, velZ); } + /*! + * \brief Sets the speed of sound + * + * \param speed Speed of sound + */ + void Audio::SetSpeedOfSound(float speed) { alSpeedOfSound(speed); } + /*! + * \brief Uninitializes the Audio module + * + * \remark Produces a NazaraNotice + */ + void Audio::Uninitialize() { if (s_moduleReferenceCounter != 1) { - // Le module est soit encore utilisé, soit pas initialisé + // The module is still in use, or can not be uninitialized if (s_moduleReferenceCounter > 1) s_moduleReferenceCounter--; return; } - // Libération du module + // Free of module s_moduleReferenceCounter = 0; // Loaders @@ -241,7 +395,7 @@ namespace Nz NazaraNotice("Uninitialized: Audio module"); - // Libération des dépendances + // Free of dependencies Core::Uninitialize(); } diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index bbcb7d813..9e38c7114 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -14,6 +14,19 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::Music + * \brief Audio class that represents a music + * + * \remark Module Audio needs to be initialized to use this class + */ + + /*! + * \brief Checks whether the parameters for the loading of the music are correct + * \return true If parameters are valid + */ + bool MusicParams::IsValid() const { return true; @@ -32,11 +45,26 @@ namespace Nz unsigned int sampleRate; }; + /*! + * \brief Destructs the object and calls Destroy + * + * \see Destroy + */ + Music::~Music() { Destroy(); } + /*! + * \brief Creates a music with a sound stream + * \return true if creation was succesful + * + * \param soundStream Sound stream which is the source for the music + * + * \remark Produces a NazaraError if soundStream is invalid with NAZARA_AUDIO_SAFE defined + */ + bool Music::Create(SoundStream* soundStream) { NazaraAssert(soundStream, "Invalid stream"); @@ -48,7 +76,7 @@ namespace Nz m_impl = new MusicImpl; m_impl->sampleRate = soundStream->GetSampleRate(); m_impl->audioFormat = OpenAL::AudioFormat[format]; - m_impl->chunkSamples.resize(format * m_impl->sampleRate); // Une seconde de samples + m_impl->chunkSamples.resize(format * m_impl->sampleRate); // One second of samples m_impl->stream.reset(soundStream); SetPlayingOffset(0); @@ -56,6 +84,10 @@ namespace Nz return true; } + /*! + * \brief Destroys the current music and frees resources + */ + void Music::Destroy() { if (m_impl) @@ -67,6 +99,14 @@ namespace Nz } } + /*! + * \brief Enables the looping of the music + * + * \param loop Should music loop + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::EnableLooping(bool loop) { #if NAZARA_AUDIO_SAFE @@ -80,6 +120,13 @@ namespace Nz m_impl->loop = loop; } + /*! + * \brief Gets the duration of the music + * \return Duration of the music in milliseconds + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetDuration() const { #if NAZARA_AUDIO_SAFE @@ -93,6 +140,13 @@ namespace Nz return m_impl->stream->GetDuration(); } + /*! + * \brief Gets the format of the music + * \return Enumeration of type AudioFormat (mono, stereo, ...) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + AudioFormat Music::GetFormat() const { #if NAZARA_AUDIO_SAFE @@ -106,6 +160,13 @@ namespace Nz return m_impl->stream->GetFormat(); } + /*! + * \brief Gets the current offset in the music + * \return Offset in milliseconds (works with entire seconds) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetPlayingOffset() const { #if NAZARA_AUDIO_SAFE @@ -125,6 +186,13 @@ namespace Nz return static_cast((1000ULL * (samples + (m_impl->processedSamples / m_impl->stream->GetFormat()))) / m_impl->sampleRate); } + /*! + * \brief Gets the number of samples in the music + * \return Count of samples (number of seconds * sample rate * channel count) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetSampleCount() const { #if NAZARA_AUDIO_SAFE @@ -138,6 +206,13 @@ namespace Nz return m_impl->stream->GetSampleCount(); } + /*! + * \brief Gets the rates of sample in the music + * \return Rate of sample in Hertz (Hz) + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + UInt32 Music::GetSampleRate() const { #if NAZARA_AUDIO_SAFE @@ -151,6 +226,14 @@ namespace Nz return m_impl->sampleRate; } + /*! + * \brief Gets the status of the music + * \return Enumeration of type SoundStatus (Playing, Stopped, ...) + * + * \remark If the music is not playing, Stopped is returned + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + SoundStatus Music::GetStatus() const { #if NAZARA_AUDIO_SAFE @@ -163,13 +246,20 @@ namespace Nz SoundStatus status = GetInternalStatus(); - // Pour compenser les éventuels retards (ou le laps de temps entre Play() et la mise en route du thread) + // To compensate any delays (or the timelaps between Play() and the thread startup) if (m_impl->streaming && status == SoundStatus_Stopped) status = SoundStatus_Playing; return status; } + /*! + * \brief Checks whether the music is looping + * \return true if it is the case + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + bool Music::IsLooping() const { #if NAZARA_AUDIO_SAFE @@ -183,26 +273,61 @@ namespace Nz return m_impl->loop; } + /*! + * \brief Loads the music from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the music + */ + bool Music::OpenFromFile(const String& filePath, const MusicParams& params) { return MusicLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the music from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the music + */ + bool Music::OpenFromMemory(const void* data, std::size_t size, const MusicParams& params) { return MusicLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the music from stream + * \return true if loading is successful + * + * \param stream Stream to the music + * \param params Parameters for the music + */ + bool Music::OpenFromStream(Stream& stream, const MusicParams& params) { return MusicLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Pauses the music + */ + void Music::Pause() { alSourcePause(m_source); } + /*! + * \brief Plays the music + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::Play() { #if NAZARA_AUDIO_SAFE @@ -238,6 +363,14 @@ namespace Nz } } + /*! + * \brief Sets the playing offset for the music + * + * \param offset Offset in the music in milliseconds + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::SetPlayingOffset(UInt32 offset) { #if NAZARA_AUDIO_SAFE @@ -260,6 +393,12 @@ namespace Nz Play(); } + /*! + * \brief Stops the music + * + * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined + */ + void Music::Stop() { #if NAZARA_AUDIO_SAFE @@ -277,6 +416,13 @@ namespace Nz } } + /*! + * \brief Fills the buffer and queues it up + * \return true if operation was successful + * + * \param buffer Index of the buffer + */ + bool Music::FillAndQueueBuffer(unsigned int buffer) { unsigned int sampleCount = m_impl->chunkSamples.size(); @@ -304,27 +450,31 @@ namespace Nz alSourceQueueBuffers(m_source, 1, &buffer); } - return sampleRead != sampleCount; // Fin du stream (N'arrive pas en cas de loop) + return sampleRead != sampleCount; // End of stream (Does not happen when looping) } + /*! + * \brief Thread function for the music + */ + void Music::MusicThread() { - // Allocation des buffers de streaming + // Allocation of streaming buffers ALuint buffers[NAZARA_AUDIO_STREAMED_BUFFER_COUNT]; alGenBuffers(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, buffers); for (unsigned int i = 0; i < NAZARA_AUDIO_STREAMED_BUFFER_COUNT; ++i) { if (FillAndQueueBuffer(buffers[i])) - break; // Nous avons atteint la fin du stream, inutile de rajouter des buffers + break; // We have reached the end of the stream, there is no use to add new buffers } alSourcePlay(m_source); - // Boucle de lecture (remplissage de nouveaux buffers au fur et à mesure) + // Reading loop (Filling new buffers as playing) while (m_impl->streaming) { - // La lecture s'est arrêtée, nous avons atteint la fin du stream + // The reading has stopped, we have reached the end of the stream SoundStatus status = GetInternalStatus(); if (status == SoundStatus_Stopped) { @@ -334,7 +484,7 @@ namespace Nz Nz::LockGuard lock(m_impl->bufferLock); - // On traite les buffers lus + // We treat read buffers ALint processedCount = 0; alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &processedCount); while (processedCount--) @@ -355,14 +505,14 @@ namespace Nz lock.Unlock(); - // On retourne dormir un peu + // We go back to sleep Thread::Sleep(50); } - // Arrêt de la lecture du son (dans le cas où ça ne serait pas déjà fait) + // Stop playing of the sound (in the case where it has not been already done) alSourceStop(m_source); - // On supprime les buffers du stream + // We delete buffers from the stream ALint queuedBufferCount; alGetSourcei(m_source, AL_BUFFERS_QUEUED, &queuedBufferCount); diff --git a/src/Nazara/Audio/OpenAL.cpp b/src/Nazara/Audio/OpenAL.cpp index f527b682d..489855022 100644 --- a/src/Nazara/Audio/OpenAL.cpp +++ b/src/Nazara/Audio/OpenAL.cpp @@ -23,6 +23,14 @@ namespace Nz ALCcontext* s_context = nullptr; unsigned int s_version; + /*! + * \brief Parses the devices + * \return Number of devices + * + * \param deviceString String for the device (input / output) + * \param devices List of names of the devices + */ + std::size_t ParseDevices(const char* deviceString, std::vector& devices) { if (!deviceString) @@ -41,35 +49,77 @@ namespace Nz } } + /*! + * \ingroup audio + * \class Nz::OpenAL + * \brief Audio class that represents the link with OpenAL + * + * \remark This class is meant to be used by Module Audio + */ + + /*! + * \brief Gets the entry for the function name + * \return Pointer to the function + * + * \param entryPoint Name of the entry + * + * \remark This does not produces a NazaraError if entry does not exist + */ + OpenALFunc OpenAL::GetEntry(const String& entryPoint) { return LoadEntry(entryPoint.GetConstBuffer(), false); } + /*! + * \brief Gets the name of the renderer + * \return Name of the renderer + */ + String OpenAL::GetRendererName() { return s_rendererName; } + /*! + * \brief Gets the name of the vendor + * \return Name of the vendor + */ + String OpenAL::GetVendorName() { return s_vendorName; } + /*! + * \brief Gets the version of OpenAL + * \return Version of OpenAL + */ + unsigned int OpenAL::GetVersion() { return s_version; } + /*! + * \brief Initializes the module OpenAL + * \return true if initialization is successful + * + * \param openDevice True to get information from the device + * + * \remark Produces a NazaraError if one of the entry failed + * \remark Produces a NazaraError if opening device failed with openDevice parameter set to true + */ + bool OpenAL::Initialize(bool openDevice) { - if (s_library.IsLoaded()) + if (IsInitialized()) return true; #if defined(NAZARA_PLATFORM_WINDOWS) - ///FIXME: Est-ce qu'OpenAL Soft est une meilleure implémentation que Creative ? - /// Si on pouvait se résigner à utiliser OpenAL Soft tout le temps, cela nous permettrait d'utiliser les extensions sonores - /// et de donner plus de possibilités techniques au niveau de l'audio. + ///FIXME: Is OpenAL Soft a better implementation than Creative ? + /// If we could use OpenAL Soft everytime, this would allow us to use sonorous extensions + /// and give us more technical possibilities with audio const char* libs[] = { "soft_oal.dll", "wrap_oal.dll", @@ -217,11 +267,23 @@ namespace Nz return true; } + /*! + * \brief Checks whether the module is initialized + * \return true if it is the case + */ + bool OpenAL::IsInitialized() { return s_library.IsLoaded(); } + /*! + * \brief Queries the input devices + * \return Number of devices + * + * \param devices List of names of the input devices + */ + std::size_t OpenAL::QueryInputDevices(std::vector& devices) { const char* deviceString = reinterpret_cast(alcGetString(nullptr, ALC_CAPTURE_DEVICE_SPECIFIER)); @@ -231,6 +293,13 @@ namespace Nz return ParseDevices(deviceString, devices); } + /*! + * \brief Queries the output devices + * \return Number of devices + * + * \param devices List of names of the output devices + */ + std::size_t OpenAL::QueryOutputDevices(std::vector& devices) { const char* deviceString = reinterpret_cast(alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER)); @@ -240,6 +309,13 @@ namespace Nz return ParseDevices(deviceString, devices); } + /*! + * \brief Sets the active device + * \return true if device is successfully opened + * + * \param deviceName Name of the device + */ + bool OpenAL::SetDevice(const String& deviceName) { s_deviceName = deviceName; @@ -253,6 +329,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the module + */ + void OpenAL::Uninitialize() { CloseDevice(); @@ -262,8 +342,14 @@ namespace Nz s_library.Unload(); } - ///ATTENTION: La valeur entière est le nombre de canaux possédés par ce format - ALenum OpenAL::AudioFormat[AudioFormat_Max+1] = {0}; // Valeur ajoutées au chargement d'OpenAL + ///WARNING: The integer value is the number of canals owned by the format + ALenum OpenAL::AudioFormat[AudioFormat_Max+1] = {0}; // Added values with loading of OpenAL + + /*! + * \brief Closes the device + * + * \remark Produces a NazaraWarning if you try to close an active device + */ void OpenAL::CloseDevice() { @@ -277,24 +363,31 @@ namespace Nz } if (!alcCloseDevice(s_device)) - // Nous n'avons pas pu fermer le device, ce qui signifie qu'il est en cours d'utilisation + // We could not close the close, this means that it's still in use NazaraWarning("Failed to close device"); s_device = nullptr; } } + /*! + * \brief Opens the device + * \return true if open is successful + * + * \remark Produces a NazaraError if it could not create the context + */ + bool OpenAL::OpenDevice() { - // Initialisation du module - s_device = alcOpenDevice(s_deviceName.IsEmpty() ? nullptr : s_deviceName.GetConstBuffer()); // On choisit le device par défaut + // Initialisation of the module + s_device = alcOpenDevice(s_deviceName.IsEmpty() ? nullptr : s_deviceName.GetConstBuffer()); // We choose the default device if (!s_device) { NazaraError("Failed to open default device"); return false; } - // Un seul contexte nous suffira + // One context is enough s_context = alcCreateContext(s_device, nullptr); if (!s_context) { @@ -341,7 +434,7 @@ namespace Nz s_version = 0; } - // On complète le tableau de formats + // We complete the formats table AudioFormat[AudioFormat_Mono] = AL_FORMAT_MONO16; AudioFormat[AudioFormat_Stereo] = AL_FORMAT_STEREO16; @@ -359,6 +452,16 @@ namespace Nz return true; } + /*! + * \brief Loads the entry for the function name + * \return Pointer to the function + * + * \param name Name of the entry + * \param throwException Should throw exception if failed ? + * + * \remark Produces a std::runtime_error if entry does not exist and throwException is set to true + */ + OpenALFunc OpenAL::LoadEntry(const char* name, bool throwException) { OpenALFunc entry = reinterpret_cast(s_library.GetSymbol(name)); diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index 7198a01d6..d2b71318b 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -14,32 +14,76 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::Sound + * \brief Audio class that represents a sound + * + * \remark Module Audio needs to be initialized to use this class + */ + + /*! + * \brief Constructs a Sound object + * + * \param soundBuffer Buffer to read sound from + */ + Sound::Sound(const SoundBuffer* soundBuffer) { SetBuffer(soundBuffer); } + /*! + * \brief Constructs a Sound object which is a copy of another + * + * \param sound Sound to copy + */ + Sound::Sound(const Sound& sound) : SoundEmitter(sound) { SetBuffer(sound.m_buffer); } + /*! + * \brief Destructs the object and calls Stop + * + * \see Stop + */ + Sound::~Sound() { Stop(); } + /*! + * \brief Enables the looping of the music + * + * \param loop Should sound loop + */ + void Sound::EnableLooping(bool loop) { alSourcei(m_source, AL_LOOPING, loop); } + /*! + * \brief Gets the internal buffer + * \return Internal buffer + */ + const SoundBuffer* Sound::GetBuffer() const { return m_buffer; } + /*! + * \brief Gets the duration of the sound + * \return Duration of the music in milliseconds + * + * \remark Produces a NazaraError if there is no buffer + */ + UInt32 Sound::GetDuration() const { NazaraAssert(m_buffer, "Invalid sound buffer"); @@ -47,6 +91,11 @@ namespace Nz return m_buffer->GetDuration(); } + /*! + * \brief Gets the current offset in the sound + * \return Offset in milliseconds (works with entire seconds) + */ + UInt32 Sound::GetPlayingOffset() const { ALint samples = 0; @@ -55,11 +104,21 @@ namespace Nz return static_cast(1000ULL * samples / m_buffer->GetSampleRate()); } + /*! + * \brief Gets the status of the music + * \return Enumeration of type SoundStatus (Playing, Stopped, ...) + */ + SoundStatus Sound::GetStatus() const { return GetInternalStatus(); } + /*! + * \brief Checks whether the sound is looping + * \return true if it is the case + */ + bool Sound::IsLooping() const { ALint loop; @@ -68,16 +127,36 @@ namespace Nz return loop != AL_FALSE; } + /*! + * \brief Checks whether the sound is playable + * \return true if it is the case + */ + bool Sound::IsPlayable() const { return m_buffer != nullptr; } + /*! + * \brief Checks whether the sound is playing + * \return true if it is the case + */ + bool Sound::IsPlaying() const { return GetStatus() == SoundStatus_Playing; } + /*! + * \brief Loads the sound from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the sound + * + * \remark Produces a NazaraError if loading failed + */ + bool Sound::LoadFromFile(const String& filePath, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -91,6 +170,17 @@ namespace Nz return true; } + /*! + * \brief Loads the sound from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the sound + * + * \remark Produces a NazaraError if loading failed + */ + bool Sound::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -104,6 +194,16 @@ namespace Nz return true; } + /*! + * \brief Loads the sound from stream + * \return true if loading is successful + * + * \param stream Stream to the sound + * \param params Parameters for the sound + * + * \remark Produces a NazaraError if loading failed + */ + bool Sound::LoadFromStream(Stream& stream, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -117,15 +217,25 @@ namespace Nz return true; } + /*! + * \brief Pauses the sound + */ + void Sound::Pause() { alSourcePause(m_source); } + /*! + * \brief Plays the music + * + * \remark Produces a NazaraError if the sound is not playable with NAZARA_AUDIO_SAFE defined + */ + void Sound::Play() { #if NAZARA_AUDIO_SAFE - if (!m_buffer) + if (!IsPlayable()) { NazaraError("Invalid sound buffer"); return; @@ -135,6 +245,14 @@ namespace Nz alSourcePlay(m_source); } + /*! + * \brief Sets the internal buffer + * + * \param buffer Internal buffer + * + * \remark Produces a NazaraError if buffer is invalid with NAZARA_AUDIO_SAFE defined + */ + void Sound::SetBuffer(const SoundBuffer* buffer) { #if NAZARA_AUDIO_SAFE @@ -158,11 +276,21 @@ namespace Nz alSourcei(m_source, AL_BUFFER, AL_NONE); } + /*! + * \brief Sets the playing offset for the sound + * + * \param offset Offset in the sound in milliseconds + */ + void Sound::SetPlayingOffset(UInt32 offset) { alSourcei(m_source, AL_SAMPLE_OFFSET, static_cast(offset/1000.f * m_buffer->GetSampleRate())); } + /*! + * \brief Stops the sound + */ + void Sound::Stop() { alSourceStop(m_source); diff --git a/src/Nazara/Audio/SoundBuffer.cpp b/src/Nazara/Audio/SoundBuffer.cpp index c01878383..b59e74e23 100644 --- a/src/Nazara/Audio/SoundBuffer.cpp +++ b/src/Nazara/Audio/SoundBuffer.cpp @@ -12,10 +12,23 @@ #include #include -///FIXME: Adapter la création +///FIXME: Adapt the creation namespace Nz { + /*! + * \ingroup audio + * \class Nz::SoundBuffer + * \brief Audio class that represents a buffer for sound + * + * \remark Module Audio needs to be initialized to use this class + */ + + /*! + * \brief Checks whether the parameters for the buffer' sound are correct + * \return true If parameters are valid + */ + bool SoundBufferParams::IsValid() const { return true; @@ -31,6 +44,20 @@ namespace Nz UInt32 sampleRate; }; + /*! + * \brief Constructs a SoundBuffer object + * + * \param format Format for the audio + * \param sampleCount Number of samples + * \param sampleRate Rate of samples + * \param samples Samples raw data + * + * \remark Produces a NazaraError if creation went wrong with NAZARA_AUDIO_SAFE defined + * \remark Produces a std::runtime_error if creation went wrong with NAZARA_AUDIO_SAFE defined + * + * \see Create + */ + SoundBuffer::SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) { Create(format, sampleCount, sampleRate, samples); @@ -44,6 +71,12 @@ namespace Nz #endif } + /*! + * \brief Destructs the object and calls Destroy + * + * \see Destroy + */ + SoundBuffer::~SoundBuffer() { OnSoundBufferRelease(this); @@ -51,6 +84,19 @@ namespace Nz Destroy(); } + /*! + * \brief Creates the SoundBuffer object + * \return true if creation is successful + * + * \param format Format for the audio + * \param sampleCount Number of samples + * \param sampleRate Rate of samples + * \param samples Samples raw data + * + * \remark Produces a NazaraError if creation went wrong with NAZARA_AUDIO_SAFE defined, + * this could happen if parameters are invalid or creation of OpenAL buffers failed + */ + bool SoundBuffer::Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) { Destroy(); @@ -81,7 +127,7 @@ namespace Nz } #endif - // On vide le stack d'erreurs + // We empty the error stack while (alGetError() != AL_NO_ERROR); ALuint buffer; @@ -115,6 +161,10 @@ namespace Nz return true; } + /*! + * \brief Destroys the current sound buffer and frees resources + */ + void SoundBuffer::Destroy() { if (m_impl) @@ -126,6 +176,13 @@ namespace Nz } } + /*! + * \brief Gets the duration of the sound buffer + * \return Duration of the sound buffer in milliseconds + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + UInt32 SoundBuffer::GetDuration() const { #if NAZARA_AUDIO_SAFE @@ -139,6 +196,13 @@ namespace Nz return m_impl->duration; } + /*! + * \brief Gets the format of the sound buffer + * \return Enumeration of type AudioFormat (mono, stereo, ...) + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + AudioFormat SoundBuffer::GetFormat() const { #if NAZARA_AUDIO_SAFE @@ -152,6 +216,13 @@ namespace Nz return m_impl->format; } + /*! + * \brief Gets the internal raw samples + * \return Pointer to raw data + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + const Int16* SoundBuffer::GetSamples() const { #if NAZARA_AUDIO_SAFE @@ -165,6 +236,13 @@ namespace Nz return m_impl->samples.get(); } + /*! + * \brief Gets the number of samples in the sound buffer + * \return Count of samples (number of seconds * sample rate * channel count) + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + unsigned int SoundBuffer::GetSampleCount() const { #if NAZARA_AUDIO_SAFE @@ -178,6 +256,13 @@ namespace Nz return m_impl->sampleCount; } + /*! + * \brief Gets the rates of sample in the sound buffer + * \return Rate of sample in Hertz (Hz) + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + unsigned int SoundBuffer::GetSampleRate() const { #if NAZARA_AUDIO_SAFE @@ -191,31 +276,75 @@ namespace Nz return m_impl->sampleRate; } + /*! + * \brief Checks whether the sound buffer is valid + * \return true if it is the case + */ + bool SoundBuffer::IsValid() const { return m_impl != nullptr; } + /*! + * \brief Loads the sound buffer from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the sound buffer + */ + bool SoundBuffer::LoadFromFile(const String& filePath, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the sound buffer from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the sound buffer + */ + bool SoundBuffer::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the sound buffer from stream + * \return true if loading is successful + * + * \param stream Stream to the sound buffer + * \param params Parameters for the sound buffer + */ + bool SoundBuffer::LoadFromStream(Stream& stream, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Checks whether the format is supported by the engine + * \return true if it is the case + * + * \param format Format to check + */ + bool SoundBuffer::IsFormatSupported(AudioFormat format) { return Audio::IsFormatSupported(format); } + /*! + * \brief Gets the internal OpenAL buffer + * \return The index of the OpenAL buffer + * + * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined + */ + unsigned int SoundBuffer::GetOpenALBuffer() const { #ifdef NAZARA_DEBUG @@ -229,6 +358,13 @@ namespace Nz return m_impl->buffer; } + /*! + * \brief Initializes the libraries and managers + * \return true if initialization is successful + * + * \remark Produces a NazaraError if sub-initialization failed + */ + bool SoundBuffer::Initialize() { if (!SoundBufferLibrary::Initialize()) @@ -246,6 +382,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the libraries and managers + */ + void SoundBuffer::Uninitialize() { SoundBufferManager::Uninitialize(); diff --git a/src/Nazara/Audio/SoundEmitter.cpp b/src/Nazara/Audio/SoundEmitter.cpp index cbee8a8f9..840c4f47d 100644 --- a/src/Nazara/Audio/SoundEmitter.cpp +++ b/src/Nazara/Audio/SoundEmitter.cpp @@ -11,11 +11,32 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::SoundEmitter + * \brief Audio class that represents a sound source, that emits sound + * + * \remark Module Audio needs to be initialized to use this class + * \remark This class is abstract + */ + + /*! + * \brief Constructs a SoundEmitter object + */ + SoundEmitter::SoundEmitter() { alGenSources(1, &m_source); } + /*! + * \brief Constructs a SoundEmitter object which is a copy of another + * + * \param emitter SoundEmitter to copy + * + * \remark Position and velocity are not copied + */ + SoundEmitter::SoundEmitter(const SoundEmitter& emitter) { alGenSources(1, &m_source); @@ -23,20 +44,35 @@ namespace Nz SetAttenuation(emitter.GetAttenuation()); SetMinDistance(emitter.GetMinDistance()); SetPitch(emitter.GetPitch()); - // Pas de copie de position ou de vitesse + // No copy for position or velocity SetVolume(emitter.GetVolume()); } + /*! + * \brief Destructs the object + */ + SoundEmitter::~SoundEmitter() { alDeleteSources(1, &m_source); } + /*! + * \brief Enables spatialization + * + * \param spatialization True if spatialization is enabled + */ + void SoundEmitter::EnableSpatialization(bool spatialization) { alSourcei(m_source, AL_SOURCE_RELATIVE, !spatialization); } + /*! + * \brief Gets the attenuation + * \return Amount that your sound will drop off as by the inverse square law + */ + float SoundEmitter::GetAttenuation() const { ALfloat attenuation; @@ -45,6 +81,11 @@ namespace Nz return attenuation; } + /*! + * \brief Gets the minimum distance to hear + * \return Distance to begin to hear + */ + float SoundEmitter::GetMinDistance() const { ALfloat distance; @@ -53,6 +94,11 @@ namespace Nz return distance; } + /*! + * \brief Gets the pitch + * \return Pitch of the sound + */ + float SoundEmitter::GetPitch() const { ALfloat pitch; @@ -61,6 +107,11 @@ namespace Nz return pitch; } + /*! + * \brief Gets the position of the emitter + * \return Position of the sound + */ + Vector3f SoundEmitter::GetPosition() const { Vector3f position; @@ -69,6 +120,11 @@ namespace Nz return position; } + /*! + * \brief Gets the velocity of the emitter + * \return Velocity of the sound + */ + Vector3f SoundEmitter::GetVelocity() const { Vector3f velocity; @@ -77,6 +133,11 @@ namespace Nz return velocity; } + /*! + * \brief Gets the volume of the emitter + * \param volume Float between [0, inf) with 100.f being the default + */ + float SoundEmitter::GetVolume() const { ALfloat gain; @@ -85,6 +146,11 @@ namespace Nz return gain * 100.f; } + /*! + * \brief Checks whether the sound emitter has spatialization enabled + * \return true if it the case + */ + bool SoundEmitter::IsSpatialized() const { ALint relative; @@ -93,46 +159,99 @@ namespace Nz return relative == AL_FALSE; } + /*! + * \brief Sets the attenuation + * + * \param attenuation Amount that your sound will drop off as by the inverse square law + */ + void SoundEmitter::SetAttenuation(float attenuation) { alSourcef(m_source, AL_ROLLOFF_FACTOR, attenuation); } + /*! + * \brief Sets the minimum distance to hear + * + * \param minDistance to begin to hear + */ + void SoundEmitter::SetMinDistance(float minDistance) { alSourcef(m_source, AL_REFERENCE_DISTANCE, minDistance); } + /*! + * \brief Sets the pitch + * + * \param pitch of the sound + */ + void SoundEmitter::SetPitch(float pitch) { alSourcef(m_source, AL_PITCH, pitch); } + /*! + * \brief Sets the position of the emitter + * + * \param position Position of the sound + */ + void SoundEmitter::SetPosition(const Vector3f& position) { alSourcefv(m_source, AL_POSITION, position); } + /*! + * \brief Sets the position of the emitter + * + * \param position Position of the sound with (x, y, z) + */ + void SoundEmitter::SetPosition(float x, float y, float z) { alSource3f(m_source, AL_POSITION, x, y, z); } + /*! + * \brief Sets the velocity of the emitter + * + * \param velocity Velocity of the sound + */ + void SoundEmitter::SetVelocity(const Vector3f& velocity) { alSourcefv(m_source, AL_VELOCITY, velocity); } + /*! + * \brief Sets the velocity of the emitter + * + * \param velocity Velocity with (velX, velY, velZ) + */ + void SoundEmitter::SetVelocity(float velX, float velY, float velZ) { alSource3f(m_source, AL_VELOCITY, velX, velY, velZ); } + /*! + * \brief Sets the volume of the emitter + * + * \param volume Float between [0, inf) with 100.f being the default + */ + void SoundEmitter::SetVolume(float volume) { - alSourcef(m_source, AL_GAIN, volume*0.01f); + alSourcef(m_source, AL_GAIN, volume * 0.01f); } + /*! + * \brief Gets the status of the sound emitter + * \return Enumeration of type SoundStatus (Playing, Stopped, ...) + */ + SoundStatus SoundEmitter::GetInternalStatus() const { ALint state; diff --git a/src/Nazara/Audio/SoundStream.cpp b/src/Nazara/Audio/SoundStream.cpp index c243e875f..88bc0069b 100644 --- a/src/Nazara/Audio/SoundStream.cpp +++ b/src/Nazara/Audio/SoundStream.cpp @@ -6,5 +6,13 @@ namespace Nz { + /*! + * \ingroup audio + * \class Nz::SoundStream + * \brief Audio class that represents a sound stream + * + * \remark This class is abstract + */ + SoundStream::~SoundStream() = default; } diff --git a/tests/Engine/Audio/AlgorithmAudio.cpp b/tests/Engine/Audio/AlgorithmAudio.cpp new file mode 100644 index 000000000..dfcfeee56 --- /dev/null +++ b/tests/Engine/Audio/AlgorithmAudio.cpp @@ -0,0 +1,19 @@ +#include +#include + +#include + +TEST_CASE("MixToMono", "[AUDIO][ALGORITHM]") +{ + SECTION("Mix two channels together") + { + std::array input{ 1, 3, 5, 3 }; + std::array output{ 0, 0 }; + + // Two channels and two frames ! + Nz::MixToMono(input.data(), output.data(), 2, 2); + + std::array theoric{ 2, 4 }; // It's the mean of the two channels + REQUIRE(output == theoric); + } +} diff --git a/tests/Engine/Audio/Music.cpp b/tests/Engine/Audio/Music.cpp new file mode 100644 index 000000000..404c57c5f --- /dev/null +++ b/tests/Engine/Audio/Music.cpp @@ -0,0 +1,49 @@ +#include +#include + +#include +#include + +SCENARIO("Music", "[AUDIO][MUSIC]") +{ + GIVEN("A music") + { + Nz::Music music; + + WHEN("We load our music") + { + REQUIRE(music.OpenFromFile("resources/Engine/Audio/The_Brabanconne.ogg")); + + THEN("We can ask the informations of the file") + { + REQUIRE(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms + REQUIRE(music.GetDuration() >= 63000); + REQUIRE(music.GetFormat() == Nz::AudioFormat_Stereo); + REQUIRE(music.GetPlayingOffset() == 0); + REQUIRE(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo) + REQUIRE(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo) + REQUIRE(music.GetSampleRate() == 44100 /* Hz */); + REQUIRE(music.GetStatus() == Nz::SoundStatus_Stopped); + REQUIRE(music.IsLooping() == false); + } + + THEN("We can play it and get the time offset") + { + Nz::Audio::SetGlobalVolume(0.f); + + music.Play(); + Nz::Thread::Sleep(1000); + REQUIRE(music.GetPlayingOffset() >= 950); + Nz::Thread::Sleep(200); + REQUIRE(music.GetPlayingOffset() <= 1300); + music.Pause(); + REQUIRE(music.GetStatus() == Nz::SoundStatus_Paused); + + music.SetPlayingOffset(3500); + REQUIRE(music.GetPlayingOffset() >= 3500); + + Nz::Audio::SetGlobalVolume(100.f); + } + } + } +} diff --git a/tests/Engine/Audio/Sound.cpp b/tests/Engine/Audio/Sound.cpp new file mode 100644 index 000000000..684138ccd --- /dev/null +++ b/tests/Engine/Audio/Sound.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include +#include + +SCENARIO("Sound", "[AUDIO][SOUND]") +{ + GIVEN("A sound") + { + Nz::Sound sound; + + WHEN("We load our sound") + { + REQUIRE(sound.LoadFromFile("resources/Engine/Audio/Cat.flac")); + + THEN("We can ask the informations of the file") + { + REQUIRE(sound.GetDuration() <= 8500); // 8s = 8000ms + REQUIRE(sound.GetDuration() >= 8000); + REQUIRE(sound.GetStatus() == Nz::SoundStatus_Stopped); + REQUIRE(sound.IsLooping() == false); + } + + THEN("We can play it and get the time offset") + { + Nz::Audio::SetGlobalVolume(0.f); + + sound.Play(); + Nz::Thread::Sleep(1000); + REQUIRE(sound.GetPlayingOffset() >= 950); + Nz::Thread::Sleep(200); + REQUIRE(sound.GetPlayingOffset() <= 1300); + sound.Pause(); + REQUIRE(sound.GetStatus() == Nz::SoundStatus_Paused); + + sound.SetPlayingOffset(3500); + REQUIRE(sound.GetPlayingOffset() >= 3500); + + Nz::Audio::SetGlobalVolume(100.f); + } + } + } +} diff --git a/tests/Engine/Audio/SoundBuffer.cpp b/tests/Engine/Audio/SoundBuffer.cpp new file mode 100644 index 000000000..ed5f2f6c6 --- /dev/null +++ b/tests/Engine/Audio/SoundBuffer.cpp @@ -0,0 +1,21 @@ +#include +#include + +SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]") +{ + GIVEN("A sound buffer") + { + Nz::SoundBuffer soundBuffer; + + WHEN("We load our sound") + { + REQUIRE(soundBuffer.LoadFromFile("resources/Engine/Audio/Cat.flac")); + + THEN("We can ask the informations of the file") + { + REQUIRE(soundBuffer.GetDuration() <= 8500); // 8s = 8000ms + REQUIRE(soundBuffer.GetDuration() >= 8000); + } + } + } +} diff --git a/tests/Engine/Audio/SoundEmitter.cpp b/tests/Engine/Audio/SoundEmitter.cpp new file mode 100644 index 000000000..baac41eb3 --- /dev/null +++ b/tests/Engine/Audio/SoundEmitter.cpp @@ -0,0 +1,41 @@ +#include +#include + +#include + +SCENARIO("SoundEmitter", "[AUDIO][SOUNDEMITTER]") +{ + GIVEN("A sound emitter") + { + Nz::Sound sound; + + WHEN("We load our sound") + { + REQUIRE(sound.LoadFromFile("resources/Engine/Audio/Cat.flac")); + + THEN("We can ask information about position and velocity") + { + sound.EnableSpatialization(true); + sound.SetPosition(Nz::Vector3f::Zero()); + sound.SetVelocity(Nz::Vector3f::UnitX()); + + REQUIRE(sound.IsSpatialized()); + REQUIRE(sound.GetPosition() == Nz::Vector3f::Zero()); + REQUIRE(sound.GetVelocity() == Nz::Vector3f::UnitX()); + } + + THEN("We can ask information about attenuation, pitch, ...") + { + sound.SetAttenuation(0.4f); + sound.SetMinDistance(40.f); + sound.SetPitch(0.8f); + sound.SetVolume(50.f); + + REQUIRE(Approx(sound.GetAttenuation()) == 0.4f); + REQUIRE(Approx(sound.GetMinDistance()) == 40.f); + REQUIRE(Approx(sound.GetPitch()) == 0.8f); + REQUIRE(Approx(sound.GetVolume()) == 50.f); + } + } + } +} diff --git a/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id b/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id new file mode 100644 index 000000000..a686bc57d --- /dev/null +++ b/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id @@ -0,0 +1 @@ +6993cbcca9ac596667135cb0f30bea4841178d3b \ No newline at end of file diff --git a/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id b/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id new file mode 100644 index 000000000..bfd8dbd70 --- /dev/null +++ b/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id @@ -0,0 +1 @@ +94b2c47c9143adbac0fb7e81df5cc87f969f7150 \ No newline at end of file diff --git a/tests/resources/Engine/Audio/copyrights.txt b/tests/resources/Engine/Audio/copyrights.txt new file mode 100644 index 000000000..7b01b7090 --- /dev/null +++ b/tests/resources/Engine/Audio/copyrights.txt @@ -0,0 +1,54 @@ +The_Brabanconne.ogg + +https://en.wikipedia.org/wiki/File:The_Brabanconne.ogg + +Original file: +The_Brabanconne.ogg ‎(Ogg Vorbis sound file, length 1 min 3 s, 378 kbps) + +Summary: + +Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3. +Date: 19 October 2004 +Source: http://www.navyband.navy.mil/anthems/national_anthems.htm +Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald + +Licencing: + +This file is a work of a sailor or employee of the U.S. Navy, taken or made as part of that person's official duties. As a work of the U.S. federal government, the image is in the public domain. +This file has been identified as being free of known restrictions under copyright law, including all related and neighboring rights. + +------------------------------------------------------------------------------------------------- + +Cat.flac: + +http://www.freesound.org/people/EARR/sounds/148013/ + +Original file: +148013__earr__angry-cat.flac (Flac sound file, length 8 s, 96000 Hz, 24 bit depth) + +Author: + +EARR + +Description: + +Slightly angry cat. She is a beautiful Siamese cat called Agostina. She is angry for the recording because i pressed his tail. + +Information about the recording and equipment: + +-Location: Living room. +-Type of acoustic environment: Small, diffuse, moderately reflective. +-Distance from sound source to microphones: Approx a few centimeters. +-Miking technique: Jecklin disk. + +-Microphones: 2 Brüel & Kjaer type 4190 capsules with type 2669L head amplifier. +-Microphone preamps: Modified Brüel & Kjaer type 5935L. +-ADC: Echo Audiofire 4. (line inputs 3 & 4). +-Recorder: Echo Audiofire 4 and Dell D630C running Samplitude 10. + +Eq: Compensation only for the response of the microphones (In this case for flat response at 60º. See Brüel & Kjaer type 4190 datasheet). +No reverb, no compression, no fx. + +Licencing: + +Creative commons From a8439756d819687cb11ce8ffd3fce625b36c2c36 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 13:50:52 +0200 Subject: [PATCH 055/383] Examples: Add empty project for testing purposes Former-commit-id: aacd1ad6385b7d3a190343473b822160eeadc5f9 --- examples/Tut00/build.lua | 20 ++++++++++++++++++++ examples/Tut00/main.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 examples/Tut00/build.lua create mode 100644 examples/Tut00/main.cpp diff --git a/examples/Tut00/build.lua b/examples/Tut00/build.lua new file mode 100644 index 000000000..d0c499df6 --- /dev/null +++ b/examples/Tut00/build.lua @@ -0,0 +1,20 @@ +EXAMPLE.Name = "Tut00_EmptyProject" + +EXAMPLE.Console = true + +EXAMPLE.Files = { + "main.cpp" +} + +EXAMPLE.Libraries = { + "NazaraAudio", + "NazaraCore", + "NazaraGraphics", + "NazaraLua", + "NazaraNetwork", + "NazaraNoise", + "NazaraPhysics", + "NazaraRenderer", + "NazaraUtility", + "NazaraSDK" +} diff --git a/examples/Tut00/main.cpp b/examples/Tut00/main.cpp new file mode 100644 index 000000000..472db3148 --- /dev/null +++ b/examples/Tut00/main.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + // This "example" has only one purpose: Giving an empty project for you to test whatever you want + // If you wish to have multiple test projects, you only have to copy/paste this directory and change the name in the build.lua + Ndk::Application app; + + // Do what you want here + + return EXIT_SUCCESS; +} \ No newline at end of file From 9a2a19a834991654f6064c78d8b2790f924b1401 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 30 May 2016 13:52:08 +0200 Subject: [PATCH 056/383] Build: Fix default platform on 32bits os Former-commit-id: a068dac229fce61efa32634ff616309c91a66079 --- build/scripts/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 15bf69849..822067ea2 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -9,7 +9,7 @@ function NazaraBuild:Execute() if (os.is64bit()) then platformData = {"x64", "x86"} else - platformData = {"x64", "x86"} + platformData = {"x86", "x64"} end if (self.Actions[_ACTION] == nil) then From 6400ba2e28a03e15d626eda3627836b91bfd4154 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:09:51 +0200 Subject: [PATCH 058/383] Fix documentation for module: Core Former-commit-id: a79bf956a2759c6056e4e4e2193b8b192c5727c5 --- include/Nazara/Core/Algorithm.inl | 2 +- include/Nazara/Core/ConfigCheck.hpp | 2 +- include/Nazara/Core/HandledObject.inl | 67 ++++++- include/Nazara/Core/ObjectHandle.inl | 265 +++++++++++++++++++++++-- include/Nazara/Core/ParameterList.hpp | 6 +- include/Nazara/Core/ResourceLoader.inl | 2 +- src/Nazara/Core/Core.cpp | 2 +- src/Nazara/Core/File.cpp | 6 +- src/Nazara/Core/ParameterList.cpp | 62 ++++++ tests/Engine/Core/ByteArray.cpp | 20 ++ tests/Engine/Core/File.cpp | 12 +- 11 files changed, 421 insertions(+), 25 deletions(-) diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 048fae8e9..6997f8d1e 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -78,7 +78,7 @@ namespace Nz * \param v Object to hash * * \remark a HashAppend specialization for type T is required - * + * * \see ComputeHash */ template diff --git a/include/Nazara/Core/ConfigCheck.hpp b/include/Nazara/Core/ConfigCheck.hpp index 8329f4ff0..aa1ac5cfa 100644 --- a/include/Nazara/Core/ConfigCheck.hpp +++ b/include/Nazara/Core/ConfigCheck.hpp @@ -12,7 +12,7 @@ #include #define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) -// We fore the value of MANAGE_MEMORY in debug +// We force the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_CORE_MANAGE_MEMORY #undef NAZARA_CORE_MANAGE_MEMORY #define NAZARA_CORE_MANAGE_MEMORY 0 diff --git a/include/Nazara/Core/HandledObject.inl b/include/Nazara/Core/HandledObject.inl index da435302e..6b4d64c45 100644 --- a/include/Nazara/Core/HandledObject.inl +++ b/include/Nazara/Core/HandledObject.inl @@ -10,6 +10,17 @@ namespace Nz { + /*! + * \ingroup core + * \class Nz::HandledObject + * \brief Core class that represents a handled object + */ + + /*! + * \brief Constructs a HandledObject object by assignation + * + * \param object HandledObject to assign into this + */ template HandledObject::HandledObject(const HandledObject& object) { @@ -17,6 +28,11 @@ namespace Nz // Don't copy anything, we're a copy of the object, we have no handle right now } + /*! + * \brief Constructs a HandledObject object by move semantic + * + * \param object HandledObject to move into this + */ template HandledObject::HandledObject(HandledObject&& object) : m_handles(std::move(object.m_handles)) @@ -25,25 +41,46 @@ namespace Nz handle->OnObjectMoved(static_cast(this)); } + /*! + * \brief Destructs the object and calls UnregisterAllHandles + * + * \see UnregisterAllHandles + */ template HandledObject::~HandledObject() { UnregisterAllHandles(); } + /*! + * \brief Creates a ObjectHandle for this + * \return ObjectHandle to this + */ template ObjectHandle HandledObject::CreateHandle() { return ObjectHandle(static_cast(this)); } + /*! + * \brief Sets the reference of the HandledObject with the handle from another + * \return A reference to this + * + * \param object The other HandledObject + */ template HandledObject& HandledObject::operator=(const HandledObject& object) { // Nothing to do - return *this; + return *this; } + /*! + * \brief Moves the HandledObject into this + * \return A reference to this + * + * \param object HandledObject to move in this + */ template HandledObject& HandledObject::operator=(HandledObject&& object) { @@ -54,13 +91,22 @@ namespace Nz return *this; } + /*! + * \brief Registers a handle + * + * \param handle Handle to register + * + * \remark One handle can only be registered once, errors can occur if it's more than once + */ template void HandledObject::RegisterHandle(ObjectHandle* handle) { - ///DOC: Un handle ne doit être enregistré qu'une fois, des erreurs se produisent s'il l'est plus d'une fois m_handles.push_back(handle); } + /*! + * \brief Unregisters all handles + */ template void HandledObject::UnregisterAllHandles() { @@ -71,10 +117,17 @@ namespace Nz m_handles.clear(); } + /*! + * \brief Unregisters a handle + * + * \param handle Handle to unregister + * + * \remark One handle can only be unregistered once, crash can occur if it's more than once + * \remark Produces a NazaraAssert if handle not registered + */ template void HandledObject::UnregisterHandle(ObjectHandle* handle) noexcept { - ///DOC: Un handle ne doit être libéré qu'une fois, et doit faire partie de la liste, sous peine de crash auto it = std::find(m_handles.begin(), m_handles.end(), handle); NazaraAssert(it != m_handles.end(), "Handle not registered"); @@ -83,6 +136,14 @@ namespace Nz m_handles.pop_back(); } + /*! + * \brief Updates one handle with another + * + * \param oldHandle Old handle to replace + * \param newHandle New handle to take place + * + * \remark Produces a NazaraAssert if handle not registered + */ template void HandledObject::UpdateHandle(ObjectHandle* oldHandle, ObjectHandle* newHandle) noexcept { diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index cfcd6bc0d..ee6e26268 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -9,12 +9,26 @@ namespace Nz { + /*! + * \ingroup core + * \class Nz::ObjectHandle + * \brief Core class that represents a object handle + */ + + /*! + * \brief Constructs a ObjectHandle object by default + */ template ObjectHandle::ObjectHandle() : m_object(nullptr) { } + /*! + * \brief Constructs a ObjectHandle object with a pointer to an object + * + * \param object Pointer to handle like an object (can be nullptr) + */ template ObjectHandle::ObjectHandle(T* object) : ObjectHandle() @@ -22,59 +36,97 @@ namespace Nz Reset(object); } + /*! + * \brief Constructs a ObjectHandle object by assignation + * + * \param handle ObjectHandle to assign into this + */ template - ObjectHandle::ObjectHandle(const ObjectHandle& handle) : + ObjectHandle::ObjectHandle(const ObjectHandle& handle) : ObjectHandle() { Reset(handle); } + /*! + * \brief Constructs a ObjectHandle object by move semantic + * + * \param handle ObjectHandle to move into this + */ template - ObjectHandle::ObjectHandle(ObjectHandle&& handle) noexcept : + ObjectHandle::ObjectHandle(ObjectHandle&& handle) noexcept : ObjectHandle() { Reset(std::move(handle)); } + /*! + * \brief Destructs the object and calls reset with nullptr + * + * \see Reset + */ template ObjectHandle::~ObjectHandle() { Reset(nullptr); } + /*! + * \brief Gets the underlying object + * \return Underlying object + */ template T* ObjectHandle::GetObject() const { return m_object; } + /*! + * \brief Checks whether the object is valid + * \return true if object is not nullptr + */ template bool ObjectHandle::IsValid() const { return m_object != nullptr; } + /*! + * \brief Resets the content of the ObjectHandle with another object + * + * \param object Object to handle + */ template void ObjectHandle::Reset(T* object) { - // Si nous avions déjà une entité, nous devons l'informer que nous ne pointons plus sur elle + // If we already have an entity, we must alert it that we are not pointing to it anymore if (m_object) m_object->UnregisterHandle(this); m_object = object; if (m_object) - // On informe la nouvelle entité que nous pointons sur elle + // We alert the new entity that we are pointing to it m_object->RegisterHandle(this); } + /*! + * \brief Resets the content of this with another object + * + * \param handle New object to handle + */ template - void ObjectHandle::Reset(const ObjectHandle& handle) + void ObjectHandle::Reset(const ObjectHandle& handle) { Reset(handle.GetObject()); } + /*! + * \brief Resets the content of this with another object by move semantic + * + * \param handle New object to handle to move into this + */ template - void ObjectHandle::Reset(ObjectHandle&& handle) noexcept + void ObjectHandle::Reset(ObjectHandle&& handle) noexcept { if (m_object) m_object->UnregisterHandle(this); @@ -87,12 +139,18 @@ namespace Nz } } + /*! + * \brief Swaps the content of the two ObjectHandle + * \return A reference to this + * + * \param handle ObjectHandle to swap + */ template - ObjectHandle& ObjectHandle::Swap(ObjectHandle& handle) + ObjectHandle& ObjectHandle::Swap(ObjectHandle& handle) { - // Comme nous inversons les handles, nous devons prévenir les entités - // La version par défaut de swap (à base de move) aurait fonctionné, - // mais en enregistrant les handles une fois de plus que nécessaire (à cause de la copie temporaire). + // As we swap the two handles, we must alert the entities + // The default version with swap (move) would be working, + // but will register handles one more time (due to temporary copy). if (m_object) { m_object->UnregisterHandle(this); @@ -105,11 +163,15 @@ namespace Nz handle.m_object->RegisterHandle(this); } - // On effectue l'échange + // We do the swap std::swap(m_object, handle.m_object); return *this; } + /*! + * \brief Gives a string representation + * \return A string representation of the object "ObjectHandle(object representation) or Null" + */ template Nz::String ObjectHandle::ToString() const { @@ -125,24 +187,44 @@ namespace Nz return ss; } + /*! + * \brief Converts the ObjectHandle to bool + * \return true if reference is not nullptr + * + * \see IsValid + */ template ObjectHandle::operator bool() const { return IsValid(); } + /*! + * \brief Dereferences the ObjectHandle + * \return Underlying pointer + */ template ObjectHandle::operator T*() const { return m_object; } + /*! + * \brief Dereferences the ObjectHandle + * \return Underlying pointer + */ template T* ObjectHandle::operator->() const { return m_object; } + /*! + * \brief Assigns the entity into this + * \return A reference to this + * + * \param entity Pointer to handle like an object (can be nullptr) + */ template ObjectHandle& ObjectHandle::operator=(T* entity) { @@ -151,22 +233,37 @@ namespace Nz return *this; } + /*! + * \brief Sets the handle of the ObjectHandle with the handle from another + * \return A reference to this + * + * \param handle The other ObjectHandle + */ template - ObjectHandle& ObjectHandle::operator=(const ObjectHandle& handle) + ObjectHandle& ObjectHandle::operator=(const ObjectHandle& handle) { Reset(handle); return *this; } + /*! + * \brief Moves the ObjectHandle into this + * \return A reference to this + * + * \param handle ObjectHandle to move in this + */ template - ObjectHandle& ObjectHandle::operator=(ObjectHandle&& handle) noexcept + ObjectHandle& ObjectHandle::operator=(ObjectHandle&& handle) noexcept { Reset(std::move(handle)); return *this; } + /*! + * \brief Action to do on object destruction + */ template void ObjectHandle::OnObjectDestroyed() { @@ -174,6 +271,9 @@ namespace Nz m_object = nullptr; } + /*! + * \brief Action to do on object move + */ template void ObjectHandle::OnObjectMoved(T* newObject) { @@ -181,114 +281,247 @@ namespace Nz m_object = newObject; } + /*! + * \brief Output operator + * \return The stream + * + * \param out The stream + * \param handle The ObjectHandle to output + */ template std::ostream& operator<<(std::ostream& out, const ObjectHandle& handle) { return handle.ToString(); } + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator==(const ObjectHandle& lhs, const ObjectHandle& rhs) { return lhs.GetObject() == rhs.GetObject(); } + /*! + * \brief Checks whether the object is equal to the second object handle + * \return true if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator==(const T& lhs, const ObjectHandle& rhs) { return &lhs == rhs.GetObject(); } + /*! + * \brief Checks whether the object handle is equal to the second object + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second Object to compare in right hand side + */ template bool operator==(const ObjectHandle& lhs, const T& rhs) { return lhs.GetObject() == &rhs; } + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return false if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator!=(const ObjectHandle& lhs, const ObjectHandle& rhs) { return !(lhs == rhs); } + /*! + * \brief Checks whether the object is equal to the second object handle + * \return false if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator!=(const T& lhs, const ObjectHandle& rhs) { return !(lhs == rhs); } + /*! + * \brief Checks whether the object handle is equal to the second object + * \return false if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second Object to compare in right hand side + */ template bool operator!=(const ObjectHandle& lhs, const T& rhs) { return !(lhs == rhs); } + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<(const ObjectHandle& lhs, const ObjectHandle& rhs) { return lhs.m_object < rhs.m_object; } + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<(const T& lhs, const ObjectHandle& rhs) { return &lhs < rhs.m_object; } + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<(const ObjectHandle& lhs, const T& rhs) { return lhs.m_object < &rhs; } + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<=(const ObjectHandle& lhs, const ObjectHandle& rhs) { return !(lhs > rhs); } + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<=(const T& lhs, const ObjectHandle& rhs) { return !(lhs > rhs); } + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator<=(const ObjectHandle& lhs, const T& rhs) { return !(lhs > rhs); } + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>(const ObjectHandle& lhs, const ObjectHandle& rhs) { return rhs < lhs; } + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>(const T& lhs, const ObjectHandle& rhs) { return rhs < lhs; } + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>(const ObjectHandle& lhs, const T& rhs) { return rhs < lhs; } + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>=(const ObjectHandle& lhs, const ObjectHandle& rhs) { return !(lhs < rhs); } + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>=(const T& lhs, const ObjectHandle& rhs) { return !(lhs < rhs); } + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectHandle to compare in left hand side + * \param second ObjectHandle to compare in right hand side + */ template bool operator>=(const ObjectHandle& lhs, const T& rhs) { @@ -301,6 +534,12 @@ namespace Nz namespace std { + /*! + * \brief Swaps two ObjectHandle, specialisation of std + * + * \param lhs First object handle + * \param rhs Second object handle + */ template void swap(Nz::ObjectHandle& lhs, Nz::ObjectHandle& rhs) { diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index 119d05cca..751746aea 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -50,6 +50,8 @@ namespace Nz void SetParameter(const String& name, void* value); void SetParameter(const String& name, void* value, Destructor destructor); + String ToString() const; + ParameterList& operator=(const ParameterList& list); ParameterList& operator=(ParameterList&&) = default; @@ -73,7 +75,7 @@ namespace Nz ParameterType type; union Value { - // On définit un constructeur/destructeur vide, permettant de mettre des classes dans l'union + // We define an empty constructor/destructor, to be able to put classes in the union Value() {} Value(const Value&) {} // Placeholder ~Value() {} @@ -98,4 +100,6 @@ namespace Nz }; } +std::ostream& operator<<(std::ostream& out, const Nz::ParameterList& parameterList); + #endif // NAZARA_PARAMETERLIST_HPP diff --git a/include/Nazara/Core/ResourceLoader.inl b/include/Nazara/Core/ResourceLoader.inl index af0a8a7f0..74e59067d 100644 --- a/include/Nazara/Core/ResourceLoader.inl +++ b/include/Nazara/Core/ResourceLoader.inl @@ -66,7 +66,7 @@ namespace Nz return false; } - File file(path); // Ouvert seulement en cas de besoin + File file(path); // Open only if needed bool found = false; for (Loader& loader : Type::s_loaders) diff --git a/src/Nazara/Core/Core.cpp b/src/Nazara/Core/Core.cpp index 1ccb35212..026e4a247 100644 --- a/src/Nazara/Core/Core.cpp +++ b/src/Nazara/Core/Core.cpp @@ -28,7 +28,7 @@ namespace Nz bool Core::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; return true; // Already initialized diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 39e873373..97504b0ee 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -385,7 +385,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param pos Position of the cursor @@ -404,7 +404,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param offset Offset according to the cursor begin position @@ -906,5 +906,5 @@ namespace Nz } return true; - } + }; } diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 371e91b77..abe93c640 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -607,6 +607,54 @@ namespace Nz parameter.value.ptrVal = value; } + /*! + * \brief Gives a string representation + * \return A string representation of the object: "ParameterList(Name: Type(value), ...)" + */ + String ParameterList::ToString() const + { + StringStream ss; + + ss << "ParameterList("; + for (auto it = m_parameters.cbegin(); it != m_parameters.cend();) + { + ss << it->first << ": "; + switch (it->second.type) + { + case ParameterType_Boolean: + ss << "Boolean(" << String::Boolean(it->second.value.boolVal) << ")"; + break; + case ParameterType_Color: + ss << "Color(" << it->second.value.colorVal.ToString() << ")"; + break; + case ParameterType_Float: + ss << "Float(" << it->second.value.floatVal << ")"; + break; + case ParameterType_Integer: + ss << "Integer(" << it->second.value.intVal << ")"; + break; + case ParameterType_String: + ss << "String(" << it->second.value.stringVal << ")"; + break; + case ParameterType_Pointer: + ss << "Pointer(" << String::Pointer(it->second.value.ptrVal) << ")"; + break; + case ParameterType_Userdata: + ss << "Userdata(" << String::Pointer(it->second.value.userdataVal->ptr) << ")"; + break; + case ParameterType_None: + ss << "None"; + break; + } + + if (++it != m_parameters.cend()) + ss << ", "; + } + ss << ")"; + + return ss; + } + /*! * \brief Sets a userdata parameter named `name` * @@ -724,3 +772,17 @@ namespace Nz } } } + +/*! +* \brief Output operator +* \return The stream +* +* \param out The stream +* \param parameterList The ParameterList to output +*/ + +std::ostream& operator<<(std::ostream& out, const Nz::ParameterList& parameterList) +{ + out << parameterList.ToString(); + return out; +} diff --git a/tests/Engine/Core/ByteArray.cpp b/tests/Engine/Core/ByteArray.cpp index 476643d5e..d085585a5 100644 --- a/tests/Engine/Core/ByteArray.cpp +++ b/tests/Engine/Core/ByteArray.cpp @@ -213,4 +213,24 @@ SCENARIO("ByteArray", "[CORE][BYTEARRAY]") } } } + + GIVEN("A default byte array") + { + Nz::ByteArray defaultByteArray; + + WHEN("We resize") + { + Nz::UInt64 oldSize = defaultByteArray.GetSize(); + REQUIRE(oldSize == 0); + defaultByteArray.Resize(10); + + THEN("Capacity has increased") + { + REQUIRE(defaultByteArray[oldSize] == 0); + + REQUIRE(defaultByteArray.GetCapacity() >= 10); + REQUIRE(defaultByteArray.GetSize() == 10); + } + } + } } diff --git a/tests/Engine/Core/File.cpp b/tests/Engine/Core/File.cpp index 2ddbfebbf..1163a8aad 100644 --- a/tests/Engine/Core/File.cpp +++ b/tests/Engine/Core/File.cpp @@ -32,12 +32,22 @@ SCENARIO("File", "[CORE][FILE]") REQUIRE(Nz::String(message) == "Test String"); } + AND_THEN("We can get its size") + { + REQUIRE(file.GetSize() == 33U); + } + AND_THEN("We close it") { file.Close(); - REQUIRE(file.GetSize() == 33U); CHECK(!file.IsOpen()); } + + AND_THEN("Change its size") + { + file.SetSize(50U); + REQUIRE(file.GetSize() == 50U); + } } WHEN("We delete this file") From 96b958d655520d1a626f01575f40b0d1051f77b7 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:21:36 +0200 Subject: [PATCH 059/383] Documentation for module: Graphics Former-commit-id: 5e3ee3c61779fbdd1a083117f537a45e1bad820b --- include/Nazara/Graphics/Billboard.inl | 101 +++- include/Nazara/Graphics/ColorBackground.inl | 7 + include/Nazara/Graphics/Config.hpp | 19 +- include/Nazara/Graphics/ConfigCheck.hpp | 4 +- include/Nazara/Graphics/DebugOff.hpp | 2 +- include/Nazara/Graphics/DeferredBloomPass.hpp | 2 +- include/Nazara/Graphics/DeferredDOFPass.hpp | 2 +- include/Nazara/Graphics/DeferredFXAAPass.hpp | 2 +- include/Nazara/Graphics/DeferredFinalPass.hpp | 2 +- include/Nazara/Graphics/DeferredFogPass.hpp | 2 +- .../Nazara/Graphics/DeferredForwardPass.hpp | 2 +- .../Nazara/Graphics/DeferredGeometryPass.hpp | 2 +- .../Graphics/DeferredPhongLightingPass.hpp | 2 +- .../Nazara/Graphics/DeferredRenderPass.hpp | 2 +- .../Graphics/DeferredRenderTechnique.hpp | 2 +- include/Nazara/Graphics/DepthRenderQueue.inl | 8 + include/Nazara/Graphics/Enums.hpp | 4 +- .../Nazara/Graphics/ForwardRenderQueue.hpp | 1 + .../Graphics/ForwardRenderTechnique.hpp | 10 +- .../Graphics/ForwardRenderTechnique.inl | 58 ++ .../Nazara/Graphics/InstancedRenderable.inl | 31 ++ include/Nazara/Graphics/Light.inl | 174 ++++++ include/Nazara/Graphics/Material.hpp | 6 +- include/Nazara/Graphics/Material.inl | 509 ++++++++++++++++++ include/Nazara/Graphics/Model.hpp | 2 - include/Nazara/Graphics/Model.inl | 7 + .../Nazara/Graphics/ParticleDeclaration.hpp | 10 +- include/Nazara/Graphics/ParticleMapper.inl | 28 +- include/Nazara/Graphics/Renderable.inl | 14 + include/Nazara/Graphics/SkyboxBackground.inl | 56 ++ include/Nazara/Graphics/Sprite.inl | 120 ++++- include/Nazara/Graphics/TextSprite.inl | 84 ++- include/Nazara/Graphics/TextureBackground.inl | 18 + include/Nazara/Math/Frustum.inl | 4 +- include/Nazara/Math/Sphere.inl | 2 +- src/Nazara/Graphics/AbstractBackground.cpp | 8 + src/Nazara/Graphics/AbstractRenderQueue.cpp | 32 ++ .../Graphics/AbstractRenderTechnique.cpp | 30 ++ src/Nazara/Graphics/AbstractViewer.cpp | 8 + src/Nazara/Graphics/Billboard.cpp | 19 +- src/Nazara/Graphics/ColorBackground.cpp | 39 ++ src/Nazara/Graphics/DeferredBloomPass.cpp | 85 ++- src/Nazara/Graphics/DeferredDOFPass.cpp | 34 +- src/Nazara/Graphics/DeferredFXAAPass.cpp | 21 +- src/Nazara/Graphics/DeferredFinalPass.cpp | 21 +- src/Nazara/Graphics/DeferredFogPass.cpp | 26 +- src/Nazara/Graphics/DeferredForwardPass.cpp | 23 +- src/Nazara/Graphics/DeferredGeometryPass.cpp | 73 ++- .../Graphics/DeferredPhongLightingPass.cpp | 44 +- src/Nazara/Graphics/DeferredRenderPass.cpp | 34 ++ src/Nazara/Graphics/DeferredRenderQueue.cpp | 205 ++++++- .../Graphics/DeferredRenderTechnique.cpp | 166 +++++- src/Nazara/Graphics/DepthRenderQueue.cpp | 183 +++++++ src/Nazara/Graphics/DepthRenderTechnique.cpp | 136 ++++- src/Nazara/Graphics/Drawable.cpp | 8 + src/Nazara/Graphics/ForwardRenderQueue.cpp | 479 ++++++++++------ .../Graphics/ForwardRenderTechnique.cpp | 291 +++++++--- src/Nazara/Graphics/Graphics.cpp | 53 +- .../Graphics/GuillotineTextureAtlas.cpp | 28 +- src/Nazara/Graphics/InstancedRenderable.cpp | 54 ++ src/Nazara/Graphics/Light.cpp | 77 ++- src/Nazara/Graphics/Material.cpp | 64 ++- src/Nazara/Graphics/Model.cpp | 219 +++++++- src/Nazara/Graphics/ParticleController.cpp | 31 ++ src/Nazara/Graphics/ParticleDeclaration.cpp | 108 +++- src/Nazara/Graphics/ParticleEmitter.cpp | 72 ++- src/Nazara/Graphics/ParticleGenerator.cpp | 31 ++ src/Nazara/Graphics/ParticleMapper.cpp | 13 + src/Nazara/Graphics/ParticleRenderer.cpp | 29 + src/Nazara/Graphics/ParticleSystem.cpp | 244 ++++++++- src/Nazara/Graphics/RenderTechniques.cpp | 80 ++- src/Nazara/Graphics/Renderable.cpp | 27 + src/Nazara/Graphics/SkeletalModel.cpp | 167 +++++- src/Nazara/Graphics/SkinningManager.cpp | 69 ++- src/Nazara/Graphics/SkyboxBackground.cpp | 36 +- src/Nazara/Graphics/Sprite.cpp | 34 ++ src/Nazara/Graphics/TextSprite.cpp | 85 ++- src/Nazara/Graphics/TextureBackground.cpp | 28 + tests/Engine/Graphics/Billboard.cpp | 34 ++ tests/Engine/Graphics/ColorBackground.cpp | 20 + .../Graphics/DeferredRenderTechnique.cpp | 29 + tests/Engine/Graphics/Light.cpp | 31 ++ tests/Engine/Graphics/Model.cpp | 24 + tests/Engine/Graphics/ParticleDeclaration.cpp | 29 + tests/Engine/Graphics/ParticleSystem.cpp | 103 ++++ tests/Engine/Graphics/RenderTechniques.cpp | 47 ++ tests/Engine/Graphics/SkeletalModel.cpp | 26 + tests/Engine/Graphics/SkyboxBackground.cpp | 25 + tests/Engine/Graphics/TextureBackground.cpp | 20 + tests/Engine/Math/Sphere.cpp | 12 +- tests/main.cpp | 16 +- .../Engine/Graphics/Bob lamp/Readme.txt | 24 + .../resources/Engine/Graphics/copyrights.txt | 82 +++ .../Engine/Graphics/dragon_recon/README | 27 + 94 files changed, 4858 insertions(+), 504 deletions(-) create mode 100644 tests/Engine/Graphics/Billboard.cpp create mode 100644 tests/Engine/Graphics/ColorBackground.cpp create mode 100644 tests/Engine/Graphics/DeferredRenderTechnique.cpp create mode 100644 tests/Engine/Graphics/Light.cpp create mode 100644 tests/Engine/Graphics/Model.cpp create mode 100644 tests/Engine/Graphics/ParticleDeclaration.cpp create mode 100644 tests/Engine/Graphics/ParticleSystem.cpp create mode 100644 tests/Engine/Graphics/RenderTechniques.cpp create mode 100644 tests/Engine/Graphics/SkeletalModel.cpp create mode 100644 tests/Engine/Graphics/SkyboxBackground.cpp create mode 100644 tests/Engine/Graphics/TextureBackground.cpp create mode 100644 tests/resources/Engine/Graphics/Bob lamp/Readme.txt create mode 100644 tests/resources/Engine/Graphics/copyrights.txt create mode 100644 tests/resources/Engine/Graphics/dragon_recon/README diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index c9760d0d1..6c4a1e0a9 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a Billboard object by default + */ + inline Billboard::Billboard() { SetColor(Color::White); @@ -15,6 +19,12 @@ namespace Nz SetSize(64.f, 64.f); } + /*! + * \brief Constructs a Billboard object with a reference to a material + * + * \param material Reference to a material + */ + inline Billboard::Billboard(MaterialRef material) { SetColor(Color::White); @@ -23,6 +33,12 @@ namespace Nz SetSize(64.f, 64.f); } + /*! + * \brief Constructs a Billboard object with a pointer to a texture + * + * \param texture Pointer to a texture + */ + inline Billboard::Billboard(Texture* texture) { SetColor(Color::White); @@ -31,6 +47,12 @@ namespace Nz SetTexture(texture, true); } + /*! + * \brief Constructs a Billboard object by assignation + * + * \param billboard Billboard to copy into this + */ + inline Billboard::Billboard(const Billboard& billboard) : InstancedRenderable(billboard), m_color(billboard.m_color), @@ -41,31 +63,61 @@ namespace Nz { } + /*! + * \brief Gets the color of the billboard + * \return Current color + */ + inline const Color& Billboard::GetColor() const { return m_color; } + /*! + * \brief Gets the material of the billboard + * \return Current material + */ + inline const MaterialRef& Billboard::GetMaterial() const { return m_material; } + /*! + * \brief Gets the rotation of the billboard + * \return Current rotation + */ + inline float Billboard::GetRotation() const { return m_rotation; } + /*! + * \brief Gets the size of the billboard + * \return Current size + */ + inline const Vector2f& Billboard::GetSize() const { return m_size; } + /*! + * \brief Sets the color of the billboard + * + * \param color Color for the billboard + */ + inline void Billboard::SetColor(const Color& color) { m_color = color; } + /*! + * \brief Sets the default material of the billboard (just default material) + */ + inline void Billboard::SetDefaultMaterial() { MaterialRef material = Material::New(); @@ -75,6 +127,13 @@ namespace Nz SetMaterial(std::move(material)); } + /*! + * \brief Sets the material of the billboard + * + * \param material Material for the billboard + * \param resizeBillboard Should billboard be resized to the material size (diffuse map) + */ + inline void Billboard::SetMaterial(MaterialRef material, bool resizeBillboard) { m_material = std::move(material); @@ -86,25 +145,51 @@ namespace Nz } } + /*! + * \brief Sets the rotation of the billboard + * + * \param rotation Rotation for the billboard + */ + inline void Billboard::SetRotation(float rotation) { m_rotation = rotation; m_sinCos.Set(std::sin(m_rotation), std::cos(m_rotation)); } + /*! + * \brief Sets the size of the billboard + * + * \param size Size for the billboard + */ + inline void Billboard::SetSize(const Vector2f& size) { m_size = size; - // On invalide la bounding box + // We invalidate the bounding volume InvalidateBoundingVolume(); } + /*! + * \brief Sets the size of the billboard + * + * \param sizeX Size in X for the billboard + * \param sizeY Size in Y for the billboard + */ + inline void Billboard::SetSize(float sizeX, float sizeY) { SetSize(Vector2f(sizeX, sizeY)); } + /*! + * \brief Sets the texture of the billboard + * + * \param texture Texture for the billboard + * \param resizeBillboard Should billboard be resized to the texture size + */ + inline void Billboard::SetTexture(TextureRef texture, bool resizeBillboard) { if (!m_material) @@ -118,6 +203,13 @@ namespace Nz m_material->SetDiffuseMap(std::move(texture)); } + /*! + * \brief Sets the current billboard with the content of the other one + * \return A reference to this + * + * \param billboard The other Billboard + */ + inline Billboard& Billboard::operator=(const Billboard& billboard) { InstancedRenderable::operator=(billboard); @@ -131,6 +223,13 @@ namespace Nz return *this; } + /*! + * \brief Creates a new billboard from the arguments + * \return A reference to the newly created billboard + * + * \param args Arguments for the billboard + */ + template BillboardRef Billboard::New(Args&&... args) { diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 21b67d92c..67b1f2558 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -7,6 +7,13 @@ namespace Nz { + /*! + * \brief Creates a new color background from the arguments + * \return A reference to the newly created color background + * + * \param args Arguments for the color background + */ + template ColorBackgroundRef ColorBackground::New(Args&&... args) { diff --git a/include/Nazara/Graphics/Config.hpp b/include/Nazara/Graphics/Config.hpp index 77f1669c4..e47c8d3a5 100644 --- a/include/Nazara/Graphics/Config.hpp +++ b/include/Nazara/Graphics/Config.hpp @@ -27,23 +27,28 @@ #ifndef NAZARA_CONFIG_GRAPHICS_HPP #define NAZARA_CONFIG_GRAPHICS_HPP -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci +/*! +* \defgroup graphics (NazaraGraphics) Graphics module +* Graphics/System module including classes to handle graphical elements... +*/ -// À partir de combien d'instances d'un même mesh/matériau l'instancing doit-il être utilisé ? +/// Each modification of a paramater of the module needs a recompilation of the unit + +// How much instances are need of a same mesh/material to enable instancing ? #define NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT 10 -// Utilise un manager de mémoire pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) #define NAZARA_GRAPHICS_MANAGE_MEMORY 0 -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) +// Activate the security tests based on the code (Advised for development) #define NAZARA_GRAPHICS_SAFE 1 -/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code +/// Each modification of a parameter following implies a modification (often minor) of the code -// Le nombre maximum de lumières qu'un shader standard supportera +// The maximum number of lights in a standard shader #define NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS 3 -/// Vérification des valeurs et types de certaines constantes +/// Checking the values and types of certain constants #include #if defined(NAZARA_STATIC) diff --git a/include/Nazara/Graphics/ConfigCheck.hpp b/include/Nazara/Graphics/ConfigCheck.hpp index e93c8e0ec..c2bbda886 100644 --- a/include/Nazara/Graphics/ConfigCheck.hpp +++ b/include/Nazara/Graphics/ConfigCheck.hpp @@ -7,12 +7,12 @@ #ifndef NAZARA_CONFIG_CHECK_GRAPHICS_HPP #define NAZARA_CONFIG_CHECK_GRAPHICS_HPP -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp +/// This file is used to check the constant values defined in Config.hpp #include #define NazaraCheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) -// On force la valeur de MANAGE_MEMORY en mode debug +// We fore the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_GRAPHICS_MANAGE_MEMORY #undef NAZARA_GRAPHICS_MANAGE_MEMORY #define NAZARA_GRAPHICS_MANAGE_MEMORY 0 diff --git a/include/Nazara/Graphics/DebugOff.hpp b/include/Nazara/Graphics/DebugOff.hpp index 38a452aab..c90640fc0 100644 --- a/include/Nazara/Graphics/DebugOff.hpp +++ b/include/Nazara/Graphics/DebugOff.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +// We suppose that Debug.hpp is already included, same goes for Config.hpp #if NAZARA_GRAPHICS_MANAGE_MEMORY #undef delete #undef new diff --git a/include/Nazara/Graphics/DeferredBloomPass.hpp b/include/Nazara/Graphics/DeferredBloomPass.hpp index 603998d84..5c45a2277 100644 --- a/include/Nazara/Graphics/DeferredBloomPass.hpp +++ b/include/Nazara/Graphics/DeferredBloomPass.hpp @@ -29,7 +29,7 @@ namespace Nz float GetBrightThreshold() const; Texture* GetTexture(unsigned int i) const; - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; bool Resize(const Vector2ui& dimensions); void SetBlurPassCount(unsigned int passCount); diff --git a/include/Nazara/Graphics/DeferredDOFPass.hpp b/include/Nazara/Graphics/DeferredDOFPass.hpp index 4da8824c7..c3d6e4c0f 100644 --- a/include/Nazara/Graphics/DeferredDOFPass.hpp +++ b/include/Nazara/Graphics/DeferredDOFPass.hpp @@ -23,7 +23,7 @@ namespace Nz DeferredDOFPass(); virtual ~DeferredDOFPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; bool Resize(const Vector2ui& dimensions); protected: diff --git a/include/Nazara/Graphics/DeferredFXAAPass.hpp b/include/Nazara/Graphics/DeferredFXAAPass.hpp index 34fc46867..1c74ffb1c 100644 --- a/include/Nazara/Graphics/DeferredFXAAPass.hpp +++ b/include/Nazara/Graphics/DeferredFXAAPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFXAAPass(); virtual ~DeferredFXAAPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredFinalPass.hpp b/include/Nazara/Graphics/DeferredFinalPass.hpp index c800d44d1..f6b633925 100644 --- a/include/Nazara/Graphics/DeferredFinalPass.hpp +++ b/include/Nazara/Graphics/DeferredFinalPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFinalPass(); virtual ~DeferredFinalPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredFogPass.hpp b/include/Nazara/Graphics/DeferredFogPass.hpp index 37466305b..babccb0bf 100644 --- a/include/Nazara/Graphics/DeferredFogPass.hpp +++ b/include/Nazara/Graphics/DeferredFogPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredFogPass(); virtual ~DeferredFogPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: RenderStates m_states; diff --git a/include/Nazara/Graphics/DeferredForwardPass.hpp b/include/Nazara/Graphics/DeferredForwardPass.hpp index 0b1d8aa0a..cd5341d85 100644 --- a/include/Nazara/Graphics/DeferredForwardPass.hpp +++ b/include/Nazara/Graphics/DeferredForwardPass.hpp @@ -21,7 +21,7 @@ namespace Nz virtual ~DeferredForwardPass(); void Initialize(DeferredRenderTechnique* technique); - bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const; + bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const; protected: const ForwardRenderTechnique* m_forwardTechnique; diff --git a/include/Nazara/Graphics/DeferredGeometryPass.hpp b/include/Nazara/Graphics/DeferredGeometryPass.hpp index 652060b3d..15437f0d8 100644 --- a/include/Nazara/Graphics/DeferredGeometryPass.hpp +++ b/include/Nazara/Graphics/DeferredGeometryPass.hpp @@ -21,7 +21,7 @@ namespace Nz DeferredGeometryPass(); virtual ~DeferredGeometryPass(); - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; bool Resize(const Vector2ui& dimensions); protected: diff --git a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp index 40b480217..68eb96264 100644 --- a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp +++ b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp @@ -28,7 +28,7 @@ namespace Nz bool IsLightMeshesDrawingEnabled() const; - bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const; + bool Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const; protected: LightUniforms m_directionalLightUniforms; diff --git a/include/Nazara/Graphics/DeferredRenderPass.hpp b/include/Nazara/Graphics/DeferredRenderPass.hpp index d9ad69919..34a4020a6 100644 --- a/include/Nazara/Graphics/DeferredRenderPass.hpp +++ b/include/Nazara/Graphics/DeferredRenderPass.hpp @@ -38,7 +38,7 @@ namespace Nz bool IsEnabled() const; - virtual bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const = 0; + virtual bool Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const = 0; virtual bool Resize(const Vector2ui& GBufferSize); DeferredRenderPass& operator=(const DeferredRenderPass&) = delete; diff --git a/include/Nazara/Graphics/DeferredRenderTechnique.hpp b/include/Nazara/Graphics/DeferredRenderTechnique.hpp index 99d1fc813..e9e357184 100644 --- a/include/Nazara/Graphics/DeferredRenderTechnique.hpp +++ b/include/Nazara/Graphics/DeferredRenderTechnique.hpp @@ -67,7 +67,7 @@ namespace Nz }; std::map>, RenderPassComparator> m_passes; - ForwardRenderTechnique m_forwardTechnique; // Doit être initialisé avant la RenderQueue + ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue DeferredRenderQueue m_renderQueue; mutable RenderBufferRef m_depthStencilBuffer; mutable RenderTexture m_GBufferRTT; diff --git a/include/Nazara/Graphics/DepthRenderQueue.inl b/include/Nazara/Graphics/DepthRenderQueue.inl index 7d6c9221f..a8a8da45e 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.inl +++ b/include/Nazara/Graphics/DepthRenderQueue.inl @@ -6,6 +6,14 @@ namespace Nz { + + /*! + * \brief Checks whether the material is suitable to fit in the render queue + * \return true If it is the case + * + * \param material Material to verify + */ + bool DepthRenderQueue::IsMaterialSuitable(const Material* material) const { NazaraAssert(material, "Invalid material"); diff --git a/include/Nazara/Graphics/Enums.hpp b/include/Nazara/Graphics/Enums.hpp index 6703f88a0..d378058f7 100644 --- a/include/Nazara/Graphics/Enums.hpp +++ b/include/Nazara/Graphics/Enums.hpp @@ -128,7 +128,7 @@ namespace Nz SceneNodeType_Max = SceneNodeType_User }; - // Ces paramètres sont indépendants du matériau: ils peuvent être demandés à tout moment + // These parameters are independant of the material: they can not be asked for the moment enum ShaderFlags { ShaderFlags_None = 0, @@ -139,7 +139,7 @@ namespace Nz ShaderFlags_TextureOverlay = 0x08, ShaderFlags_VertexColor = 0x10, - ShaderFlags_Max = ShaderFlags_VertexColor*2-1 + ShaderFlags_Max = ShaderFlags_VertexColor * 2 - 1 }; } diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index 9a17f5d2f..c358e331c 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -159,6 +159,7 @@ namespace Nz std::map layers; private: + BillboardData* GetBillboardData(int renderOrder, const Material* material, unsigned int count); Layer& GetLayer(int i); ///TODO: Inline void OnIndexBufferInvalidation(const IndexBuffer* indexBuffer); diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index 447818958..21b3a0899 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -31,7 +31,7 @@ namespace Nz AbstractRenderQueue* GetRenderQueue() override; RenderTechniqueType GetType() const override; - void SetMaxLightPassPerObject(unsigned int passCount); + void SetMaxLightPassPerObject(unsigned int maxLightPassPerObject); static bool Initialize(); static void Uninitialize(); @@ -70,11 +70,11 @@ namespace Nz LightUniforms lightUniforms; bool hasLightUniforms; - /// Moins coûteux en mémoire que de stocker un LightUniforms par index de lumière, - /// à voir si ça fonctionne chez tout le monde - int lightOffset; // "Distance" entre Lights[0].type et Lights[1].type + /// Less costly in memory than storing a LightUniforms by index of light, + /// this may not work everywhere + int lightOffset; // "Distance" between Lights[0].type and Lights[1].type - // Autre uniformes + // Other uniforms int eyePosition; int sceneAmbient; int textureOverlay; diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index bf9e5674c..6490513f8 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -6,6 +6,16 @@ namespace Nz { + /*! + * \brief Sens the uniforms for light + * + * \param shader Shader to send uniforms to + * \param uniforms Uniforms to send + * \param index Index of the light + * \param uniformOffset Offset for the uniform + * \param availableTextureUnit Unit texture available + */ + inline void ForwardRenderTechnique::SendLightUniforms(const Shader* shader, const LightUniforms& uniforms, unsigned int index, unsigned int uniformOffset, UInt8 availableTextureUnit) const { // If anyone got a better idea.. @@ -104,6 +114,14 @@ namespace Nz } } + /*! + * \brief Computes the score for directional light + * \return 0.f + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline float ForwardRenderTechnique::ComputeDirectionalLightScore(const Spheref& object, const AbstractRenderQueue::DirectionalLight& light) { NazaraUnused(object); @@ -113,18 +131,42 @@ namespace Nz return 0.f; } + /*! + * \brief Computes the score for point light + * \return Distance to the light + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline float ForwardRenderTechnique::ComputePointLightScore(const Spheref& object, const AbstractRenderQueue::PointLight& light) { ///TODO: Compute a score depending on the light luminosity return object.SquaredDistance(light.position); } + /*! + * \brief Computes the score for spot light + * \return Distance to the light + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline float ForwardRenderTechnique::ComputeSpotLightScore(const Spheref& object, const AbstractRenderQueue::SpotLight& light) { ///TODO: Compute a score depending on the light luminosity and spot direction return object.SquaredDistance(light.position); } + /*! + * \brief Checks whether the directional light is suitable for the computations + * \return true if light is enoughly close + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline bool ForwardRenderTechnique::IsDirectionalLightSuitable(const Spheref& object, const AbstractRenderQueue::DirectionalLight& light) { NazaraUnused(object); @@ -134,12 +176,28 @@ namespace Nz return true; } + /*! + * \brief Checks whether the point light is suitable for the computations + * \return true if light is enoughly close + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline bool ForwardRenderTechnique::IsPointLightSuitable(const Spheref& object, const AbstractRenderQueue::PointLight& light) { // If the object is too far away from this point light, there is not way it could light it return object.SquaredDistance(light.position) <= light.radius * light.radius; } + /*! + * \brief Checks whether the spot light is suitable for the computations + * \return true if light is enoughly close + * + * \param object Sphere symbolising the object + * \param light Light to compute + */ + inline bool ForwardRenderTechnique::IsSpotLightSuitable(const Spheref& object, const AbstractRenderQueue::SpotLight& light) { ///TODO: Exclude spot lights based on their direction and outer angle? diff --git a/include/Nazara/Graphics/InstancedRenderable.inl b/include/Nazara/Graphics/InstancedRenderable.inl index 0cc97f101..7f2537fbf 100644 --- a/include/Nazara/Graphics/InstancedRenderable.inl +++ b/include/Nazara/Graphics/InstancedRenderable.inl @@ -4,6 +4,12 @@ namespace Nz { + /*! + * \brief Constructs a InstancedRenderable object by assignation + * + * \param renderable InstancedRenderable to copy into this + */ + inline InstancedRenderable::InstancedRenderable(const InstancedRenderable& renderable) : RefCounted(), m_boundingVolume(renderable.m_boundingVolume), @@ -11,22 +17,43 @@ namespace Nz { } + /*! + * \brief Ensures that the bounding volume is up to date + */ + inline void InstancedRenderable::EnsureBoundingVolumeUpdated() const { if (!m_boundingVolumeUpdated) UpdateBoundingVolume(); } + /*! + * \brief Invalidates the bounding volume + */ + inline void InstancedRenderable::InvalidateBoundingVolume() { m_boundingVolumeUpdated = false; } + /*! + * \brief Invalidates the instance data based on flags + * + * \param flags Flags to invalidate + */ + inline void InstancedRenderable::InvalidateInstanceData(UInt32 flags) { OnInstancedRenderableInvalidateData(this, flags); } + /*! + * \brief Sets the current instanced renderable with the content of the other one + * \return A reference to this + * + * \param renderable The other InstancedRenderable + */ + inline InstancedRenderable& InstancedRenderable::operator=(const InstancedRenderable& renderable) { m_boundingVolume = renderable.m_boundingVolume; @@ -35,6 +62,10 @@ namespace Nz return *this; } + /*! + * \brief Updates the bounding volume + */ + inline void InstancedRenderable::UpdateBoundingVolume() const { MakeBoundingVolume(); diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index edff48a66..2852834b7 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a Light object by default + */ + inline Light::Light(const Light& light) : Renderable(light), m_color(light.m_color), @@ -28,6 +32,12 @@ namespace Nz { } + /*! + * \brief Enables shadow casting + * + * \param castShadows Should shadows be cast + */ + inline void Light::EnableShadowCasting(bool castShadows) { if (m_shadowCastingEnabled != castShadows) @@ -37,72 +47,141 @@ namespace Nz } } + /*! + * \brief Ensures that the shadow map is up to date + */ + inline void Light::EnsureShadowMapUpdate() const { if (!m_shadowMapUpdated) UpdateShadowMap(); } + /*! + * \brief Gets the ambient factor + * \return Current ambient factor + */ + inline float Light::GetAmbientFactor() const { return m_ambientFactor; } + /*! + * \brief Gets the light attenuation (in 1 / R^2) + * \return Attenuation + */ + inline float Light::GetAttenuation() const { return m_attenuation; } + /*! + * \brief Gets the color of the light + * \return Light color + */ + inline Color Light::GetColor() const { return m_color; } + /*! + * \brief Gets the diffuse factor + * \return Current diffuse factor + */ + inline float Light::GetDiffuseFactor() const { return m_diffuseFactor; } + /*! + * \brief Gets the inner angle in spot light + * \return Inner angle + */ + inline float Light::GetInnerAngle() const { return m_innerAngle; } + /*! + * \brief Gets the cosine inner angle in spot light + * \return Cosine inner angle + */ + inline float Light::GetInnerAngleCosine() const { return m_innerAngleCosine; } + /*! + * \brief Gets the inverse of the radius + * \return Inverse of the radius + */ + inline float Light::GetInvRadius() const { return m_invRadius; } + /*! + * \brief Gets the type of the light + * \return Light type + */ + inline LightType Light::GetLightType() const { return m_type; } + /*! + * \brief Gets the outer angle in spot light + * \return Outer angle + */ + inline float Light::GetOuterAngle() const { return m_outerAngle; } + /*! + * \brief Gets the cosine outer angle in spot light + * \return Cosine outer angle + */ + inline float Light::GetOuterAngleCosine() const { return m_outerAngleCosine; } + /*! + * \brief Gets the tangent outer angle in spot light + * \return Tangent outer angle + */ + inline float Light::GetOuterAngleTangent() const { return m_outerAngleTangent; } + /*! + * \brief Gets the radius of the light + * \return Light radius + */ + inline float Light::GetRadius() const { return m_radius; } + /*! + * \brief Gets the shadow map + * \return Reference to the shadow map texture + */ + inline TextureRef Light::GetShadowMap() const { EnsureShadowMapUpdate(); @@ -110,47 +189,97 @@ namespace Nz return m_shadowMap; } + /*! + * \brief Gets the format of the shadow map + * \return Shadow map format + */ + inline PixelFormatType Light::GetShadowMapFormat() const { return m_shadowMapFormat; } + /*! + * \brief Gets the size of the shadow map + * \return Shadow map size + */ + inline const Vector2ui& Light::GetShadowMapSize() const { return m_shadowMapSize; } + /*! + * \brief Checks whether the shadow casting is enabled + * \return true If it is the case + */ + inline bool Light::IsShadowCastingEnabled() const { return m_shadowCastingEnabled; } + /*! + * \brief Sets the ambient factor + * + * \param factor Ambient factor + */ + inline void Light::SetAmbientFactor(float factor) { m_ambientFactor = factor; } + /*! + * \brief Sets the light attenuation (in 1 / R^2) + * + * \param attenuation Light attenuation + */ + inline void Light::SetAttenuation(float attenuation) { m_attenuation = attenuation; } + /*! + * \brief Sets the color of the light + * + * \param color Light color + */ + inline void Light::SetColor(const Color& color) { m_color = color; } + /*! + * \brief Sets the diffuse factor + * + * \param factor Diffuse factor + */ + inline void Light::SetDiffuseFactor(float factor) { m_diffuseFactor = factor; } + /*! + * \brief Sets the inner angle in spot light + * \return innerAngle Inner angle + */ + inline void Light::SetInnerAngle(float innerAngle) { m_innerAngle = innerAngle; m_innerAngleCosine = std::cos(DegreeToRadian(m_innerAngle)); } + /*! + * \brief Sets the type of light + * + * \param type Light type + */ + inline void Light::SetLightType(LightType type) { m_type = type; @@ -158,6 +287,13 @@ namespace Nz InvalidateShadowMap(); } + /*! + * \brief Sets the outer angle in spot light + * \return outerAngle Outer angle + * + * \remark Invalidates the bounding volume + */ + inline void Light::SetOuterAngle(float outerAngle) { m_outerAngle = outerAngle; @@ -167,6 +303,13 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Sets the radius of the light + * \return radius Light radius + * + * \remark Invalidates the bounding volume + */ + inline void Light::SetRadius(float radius) { m_radius = radius; @@ -176,6 +319,15 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Sets the shadow map format + * + * \param shadowFormat Shadow map format + * + * \remark Invalidates the shadow map + * \remark Produces a NazaraAssert if format is not a depth type + */ + inline void Light::SetShadowMapFormat(PixelFormatType shadowFormat) { NazaraAssert(PixelFormat::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format"); @@ -185,6 +337,15 @@ namespace Nz InvalidateShadowMap(); } + /*! + * \brief Sets the size of the shadow map + * + * \param size Shadow map size + * + * \remark Invalidates the shadow map + * \remark Produces a NazaraAssert if size is zero + */ + inline void Light::SetShadowMapSize(const Vector2ui& size) { NazaraAssert(size.x > 0 && size.y > 0, "Shadow map size must have a positive size"); @@ -194,6 +355,15 @@ namespace Nz InvalidateShadowMap(); } + /*! + * \brief Sets the current light with the content of the other one + * \return A reference to this + * + * \param light The other Light + * + * \remark Invalidates the shadow map + */ + inline Light& Light::operator=(const Light& light) { Renderable::operator=(light); @@ -218,6 +388,10 @@ namespace Nz return *this; } + /*! + * \brief Invalidates the shadow map + */ + inline void Light::InvalidateShadowMap() { m_shadowMapUpdated = false; diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 4a110c64f..85c4d315c 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -151,7 +151,7 @@ namespace Nz inline Material& operator=(const Material& material); - static MaterialRef GetDefault(); + inline static MaterialRef GetDefault(); template static MaterialRef New(Args&&... args); // Signals: @@ -163,7 +163,7 @@ namespace Nz { const Shader* shader; UberShaderInstance* uberInstance = nullptr; - int uniforms[MaterialUniform_Max+1]; + int uniforms[MaterialUniform_Max + 1]; }; void Copy(const Material& material); @@ -187,7 +187,7 @@ namespace Nz TextureRef m_normalMap; TextureRef m_specularMap; UberShaderConstRef m_uberShader; - mutable ShaderInstance m_shaders[ShaderFlags_Max+1]; + mutable ShaderInstance m_shaders[ShaderFlags_Max + 1]; bool m_alphaTestEnabled; bool m_depthSortingEnabled; bool m_lightingEnabled; diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index c8559e11f..cdb9e0d5f 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -7,11 +7,21 @@ namespace Nz { + /*! + * \brief Constructs a Material object by default + */ + inline Material::Material() { Reset(); } + /*! + * \brief Constructs a Material object by assignation + * + * \param material Material to copy into this + */ + inline Material::Material(const Material& material) : RefCounted(), Resource(material) @@ -19,11 +29,26 @@ namespace Nz Copy(material); } + /*! + * \brief Destructs the object and calls OnMaterialRelease + * + * \see OnMaterialRelease + */ + inline Material::~Material() { OnMaterialRelease(this); } + /*! + * \brief Enables a renderer parameter + * + * \param renderParameter Parameter for the rendering + * \param enable Should the parameter be enabled + * + * \remark Produces a NazaraAssert if enumeration is invalid + */ + inline void Material::Enable(RendererParameter renderParameter, bool enable) { NazaraAssert(renderParameter <= RendererParameter_Max, "Renderer parameter out of enum"); @@ -31,6 +56,14 @@ namespace Nz m_states.parameters[renderParameter] = enable; } + /*! + * \brief Enables the alpha test + * + * \param alphaTest Should the parameter be enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableAlphaTest(bool alphaTest) { m_alphaTestEnabled = alphaTest; @@ -38,12 +71,26 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Enables the depth sorting + * + * \param depthSorting Should the parameter be enabled + */ + inline void Material::EnableDepthSorting(bool depthSorting) { // Has no influence on shaders m_depthSortingEnabled = depthSorting; } + /*! + * \brief Enables the lighting + * + * \param lighting Should the parameter be enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableLighting(bool lighting) { m_lightingEnabled = lighting; @@ -51,12 +98,26 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Enables the shadow casting + * + * \param castShadows Should shadow casting be enabled + */ + inline void Material::EnableShadowCasting(bool castShadows) { // Has no influence on shaders m_shadowCastingEnabled = castShadows; } + /*! + * \brief Enables the shadow on receiving object + * + * \param receiveShadow Should receiving object have shadows enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableShadowReceive(bool receiveShadows) { m_shadowReceiveEnabled = receiveShadows; @@ -64,6 +125,14 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Enables the transformation + * + * \param transform Should the parameter be enabled + * + * \remark Invalidates the shaders + */ + inline void Material::EnableTransform(bool transform) { m_transformEnabled = transform; @@ -71,91 +140,183 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Gets the alpha map + * \return Constant reference to the current texture + */ + inline const TextureRef& Material::GetAlphaMap() const { return m_alphaMap; } + /*! + * \brief Gets the alpha threshold + * \return The threshold value for the alpha + */ + inline float Material::GetAlphaThreshold() const { return m_alphaThreshold; } + /*! + * \brief Gets the ambient color + * \return Ambient color + */ + inline Color Material::GetAmbientColor() const { return m_ambientColor; } + /*! + * \brief Gets the function to compare depth + * \return Function comparing the depth of two materials + */ + inline RendererComparison Material::GetDepthFunc() const { return m_states.depthFunc; } + /*! + * \brief Gets the depth material + * \return Constant reference to the depth material + */ + inline const MaterialRef& Material::GetDepthMaterial() const { return m_depthMaterial; } + /*! + * \brief Gets the diffuse color + * \return Diffuse color + */ + inline Color Material::GetDiffuseColor() const { return m_diffuseColor; } + /*! + * \brief Gets the diffuse sampler + * \return Reference to the current texture sampler for the diffuse + */ + inline TextureSampler& Material::GetDiffuseSampler() { return m_diffuseSampler; } + /*! + * \brief Gets the diffuse sampler + * \return Constant reference to the current texture sampler for the diffuse + */ + inline const TextureSampler& Material::GetDiffuseSampler() const { return m_diffuseSampler; } + /*! + * \brief Gets the diffuse map + * \return Constant reference to the texture + */ + const TextureRef& Material::GetDiffuseMap() const { return m_diffuseMap; } + /*! + * \brief Gets the dst in blend + * \return Function for dst blending + */ + inline BlendFunc Material::GetDstBlend() const { return m_states.dstBlend; } + /*! + * \brief Gets the emissive map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetEmissiveMap() const { return m_emissiveMap; } + /*! + * \brief Gets the face culling + * \return Current face culling side + */ + inline FaceSide Material::GetFaceCulling() const { return m_states.faceCulling; } + /*! + * \brief Gets the face filling + * \return Current face filling + */ + inline FaceFilling Material::GetFaceFilling() const { return m_states.faceFilling; } + /*! + * \brief Gets the height map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetHeightMap() const { return m_heightMap; } + /*! + * \brief Gets the normal map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetNormalMap() const { return m_normalMap; } + /*! + * \brief Gets the render states + * \return Constant reference to the render states + */ + inline const RenderStates& Material::GetRenderStates() const { return m_states; } + /*! + * \brief Gets the shader of this material + * \return Constant pointer to the ubershader used + */ + inline const UberShader* Material::GetShader() const { return m_uberShader; } + /*! + * \brief Gets the shader instance based on the flag + * \return Constant pointer to the ubershader instance + * + * \param flags Flag of the shader + */ + inline const UberShaderInstance* Material::GetShaderInstance(UInt32 flags) const { const ShaderInstance& instance = m_shaders[flags]; @@ -165,81 +326,165 @@ namespace Nz return instance.uberInstance; } + /*! + * \brief Gets the shininess + * \return Current shininess + */ + inline float Material::GetShininess() const { return m_shininess; } + /*! + * \brief Gets the specular color + * \return Specular color + */ + inline Color Material::GetSpecularColor() const { return m_specularColor; } + /*! + * \brief Gets the specular map + * \return Constant reference to the texture + */ + inline const TextureRef& Material::GetSpecularMap() const { return m_specularMap; } + /*! + * \brief Gets the specular sampler + * \return Reference to the current texture sampler for the specular + */ + inline TextureSampler& Material::GetSpecularSampler() { return m_specularSampler; } + /*! + * \brief Gets the specular sampler + * \return Constant reference to the current texture sampler for the specular + */ + inline const TextureSampler& Material::GetSpecularSampler() const { return m_specularSampler; } + /*! + * \brief Gets the src in blend + * \return Function for src blending + */ + inline BlendFunc Material::GetSrcBlend() const { return m_states.srcBlend; } + /*! + * \brief Checks whether this material has an alpha map + * \return true If it is the case + */ + inline bool Material::HasAlphaMap() const { return m_alphaMap.IsValid(); } + /*! + * \brief Checks whether this material has a depth material + * \return true If it is the case + */ + inline bool Material::HasDepthMaterial() const { return m_depthMaterial.IsValid(); } + /*! + * \brief Checks whether this material has a diffuse map + * \return true If it is the case + */ + inline bool Material::HasDiffuseMap() const { return m_diffuseMap.IsValid(); } + /*! + * \brief Checks whether this material has a emissive map + * \return true If it is the case + */ + inline bool Material::HasEmissiveMap() const { return m_emissiveMap.IsValid(); } + /*! + * \brief Checks whether this material has a height map + * \return true If it is the case + */ + inline bool Material::HasHeightMap() const { return m_heightMap.IsValid(); } + /*! + * \brief Checks whether this material has a normal map + * \return true If it is the case + */ + inline bool Material::HasNormalMap() const { return m_normalMap.IsValid(); } + /*! + * \brief Checks whether this material has a specular map + * \return true If it is the case + */ + inline bool Material::HasSpecularMap() const { return m_specularMap.IsValid(); } + /*! + * \brief Checks whether this material has alpha test enabled + * \return true If it is the case + */ + inline bool Material::IsAlphaTestEnabled() const { return m_alphaTestEnabled; } + /*! + * \brief Checks whether this material has depth sorting enabled + * \return true If it is the case + */ + inline bool Material::IsDepthSortingEnabled() const { return m_depthSortingEnabled; } + /*! + * \brief Checks whether this material has the render parameter enabled + * \return true If it is the case + * + * \param parameter Parameter for the rendering + * + * \remark Produces a NazaraAssert if enumeration is invalid + */ + inline bool Material::IsEnabled(RendererParameter parameter) const { NazaraAssert(parameter <= RendererParameter_Max, "Renderer parameter out of enum"); @@ -247,41 +492,93 @@ namespace Nz return m_states.parameters[parameter]; } + /*! + * \brief Checks whether this material has lightning enabled + * \return true If it is the case + */ + inline bool Material::IsLightingEnabled() const { return m_lightingEnabled; } + /*! + * \brief Checks whether this material cast shadow + * \return true If it is the case + */ + inline bool Material::IsShadowCastingEnabled() const { return m_shadowCastingEnabled; } + /*! + * \brief Checks whether this material receive shadow + * \return true If it is the case + */ + inline bool Material::IsShadowReceiveEnabled() const { return m_shadowReceiveEnabled; } + /*! + * \brief Checks whether this material has transformation enabled + * \return true If it is the case + */ + inline bool Material::IsTransformEnabled() const { return m_transformEnabled; } + /*! + * \brief Loads the material from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the material + */ + inline bool Material::LoadFromFile(const String& filePath, const MaterialParams& params) { return MaterialLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the material from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the material + */ + inline bool Material::LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params) { return MaterialLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the material from stream + * \return true if loading is successful + * + * \param stream Stream to the material + * \param params Parameters for the material + */ + inline bool Material::LoadFromStream(Stream& stream, const MaterialParams& params) { return MaterialLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Sets the alpha map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetAlphaMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -296,6 +593,15 @@ namespace Nz return true; } + /*! + * \brief Sets the alpha map with a reference to a texture + * \return true If successful + * + * \param alphaMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetAlphaMap(TextureRef alphaMap) { m_alphaMap = std::move(alphaMap); @@ -303,31 +609,69 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the alpha threshold + * + * \param alphaThreshold Threshold for the alpha + */ + inline void Material::SetAlphaThreshold(float alphaThreshold) { m_alphaThreshold = alphaThreshold; } + /*! + * \brief Sets the color for ambient + * + * \param ambient Color for ambient + */ + inline void Material::SetAmbientColor(const Color& ambient) { m_ambientColor = ambient; } + /*! + * \brief Sets the depth functor + * + * \param depthFunc + */ + inline void Material::SetDepthFunc(RendererComparison depthFunc) { m_states.depthFunc = depthFunc; } + /*! + * \brief Sets the depth material + * \return true If successful + * + * \param depthMaterial Material for depth + */ + inline void Material::SetDepthMaterial(MaterialRef depthMaterial) { m_depthMaterial = std::move(depthMaterial); } + /*! + * \brief Sets the color for diffuse + * + * \param diffuse Color for diffuse + */ + inline void Material::SetDiffuseColor(const Color& diffuse) { m_diffuseColor = diffuse; } + /*! + * \brief Sets the diffuse map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetDiffuseMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -342,6 +686,15 @@ namespace Nz return true; } + /*! + * \brief Sets the diffuse map with a reference to a texture + * \return true If successful + * + * \param diffuseMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetDiffuseMap(TextureRef diffuseMap) { m_diffuseMap = std::move(diffuseMap); @@ -349,16 +702,35 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the diffuse sampler + * + * \param sampler Diffuse sample + */ + inline void Material::SetDiffuseSampler(const TextureSampler& sampler) { m_diffuseSampler = sampler; } + /*! + * \brief Sets the dst in blend + * + * \param func Function for dst blending + */ + inline void Material::SetDstBlend(BlendFunc func) { m_states.dstBlend = func; } + /*! + * \brief Sets the emissive map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetEmissiveMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -373,6 +745,15 @@ namespace Nz return true; } + /*! + * \brief Sets the emissive map with a reference to a texture + * \return true If successful + * + * \param emissiveMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetEmissiveMap(TextureRef emissiveMap) { m_emissiveMap = std::move(emissiveMap); @@ -380,16 +761,35 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the face culling + * + * \param faceSide Face to cull + */ + inline void Material::SetFaceCulling(FaceSide faceSide) { m_states.faceCulling = faceSide; } + /*! + * \brief Sets the face filling + * + * \param filling Face to fill + */ + inline void Material::SetFaceFilling(FaceFilling filling) { m_states.faceFilling = filling; } + /*! + * \brief Sets the height map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetHeightMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -404,6 +804,15 @@ namespace Nz return true; } + /*! + * \brief Sets the height map with a reference to a texture + * \return true If successful + * + * \param heightMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetHeightMap(TextureRef heightMap) { m_heightMap = std::move(heightMap); @@ -411,6 +820,13 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the normal map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetNormalMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -425,6 +841,15 @@ namespace Nz return true; } + /*! + * \brief Sets the normal map with a reference to a texture + * \return true If successful + * + * \param normalMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetNormalMap(TextureRef normalMap) { m_normalMap = std::move(normalMap); @@ -432,11 +857,25 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the render states + * + * \param states States for the rendering + */ + inline void Material::SetRenderStates(const RenderStates& states) { m_states = states; } + /*! + * \brief Sets the shader with a constant reference to a ubershader + * + * \param uberShader Uber shader to apply + * + * \remark Invalidates the shaders + */ + inline void Material::SetShader(UberShaderConstRef uberShader) { m_uberShader = std::move(uberShader); @@ -444,6 +883,13 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the shader by name + * \return true If successful + * + * \param uberShaderName Named shader + */ + inline bool Material::SetShader(const String& uberShaderName) { UberShaderConstRef uberShader = UberShaderLibrary::Get(uberShaderName); @@ -454,16 +900,35 @@ namespace Nz return true; } + /*! + * \brief Sets the shininess of the material + * + * \param shininess Value of the shininess + */ + inline void Material::SetShininess(float shininess) { m_shininess = shininess; } + /*! + * \brief Sets the color for specular + * + * \param specular Color + */ + inline void Material::SetSpecularColor(const Color& specular) { m_specularColor = specular; } + /*! + * \brief Sets the specular map by name + * \return true If successful + * + * \param textureName Named texture + */ + inline bool Material::SetSpecularMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -478,6 +943,15 @@ namespace Nz return true; } + /*! + * \brief Sets the specular map with a reference to a texture + * \return true If successful + * + * \param specularMap Texture + * + * \remark Invalidates the shaders + */ + inline void Material::SetSpecularMap(TextureRef specularMap) { m_specularMap = std::move(specularMap); @@ -485,16 +959,35 @@ namespace Nz InvalidateShaders(); } + /*! + * \brief Sets the specular sampler + * + * \param sampler Specular sample + */ + inline void Material::SetSpecularSampler(const TextureSampler& sampler) { m_specularSampler = sampler; } + /*! + * \brief Sets the src in blend + * + * \param func Function for src blending + */ + inline void Material::SetSrcBlend(BlendFunc func) { m_states.srcBlend = func; } + /*! + * \brief Sets the current material with the content of the other one + * \return A reference to this + * + * \param material The other Material + */ + inline Material& Material::operator=(const Material& material) { Resource::operator=(material); @@ -503,17 +996,33 @@ namespace Nz return *this; } + /*! + * \brief Gets the default material + * \return Reference to the default material + */ + inline MaterialRef Material::GetDefault() { return s_defaultMaterial; } + /*! + * \brief Invalidates the shaders + */ + inline void Material::InvalidateShaders() { for (ShaderInstance& instance : m_shaders) instance.uberInstance = nullptr; } + /*! + * \brief Creates a new material from the arguments + * \return A reference to the newly created material + * + * \param args Arguments for the material + */ + template MaterialRef Material::New(Args&&... args) { diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index b4564d1b8..f119072c8 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -68,8 +68,6 @@ namespace Nz bool SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material); void SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material); virtual void SetMesh(Mesh* mesh); - bool SetSequence(const String& sequenceName); - void SetSequence(unsigned int sequenceIndex); void SetSkin(unsigned int skin); void SetSkinCount(unsigned int skinCount); diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index ea30ebd72..a2b4c3967 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -7,6 +7,13 @@ namespace Nz { + /*! + * \brief Creates a new Model from the arguments + * \return A reference to the newly created model + * + * \param args Arguments for the model + */ + template ModelRef Model::New(Args&&... args) { diff --git a/include/Nazara/Graphics/ParticleDeclaration.hpp b/include/Nazara/Graphics/ParticleDeclaration.hpp index 4fd8b6c33..0edfba85f 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.hpp +++ b/include/Nazara/Graphics/ParticleDeclaration.hpp @@ -62,16 +62,16 @@ namespace Nz /* ** -Lynix: - ** Il serait aussi possible de préciser le stride de façon indépendante, ce que je ne permets pas - ** pour décomplexifier l'interface en enlevant quelque chose que je juge inutile. - ** Si vous pensez que ça peut être utile, n'hésitez pas à me le faire savoir ! + ** It would be also possible to precise the stride by an independant way, what I don't allow + ** to decomplexify the interface of something I consider useless. + ** If you think that could be useful, don't hesitate to make me aware ! */ }; - Component m_components[ParticleComponent_Max+1]; + Component m_components[ParticleComponent_Max + 1]; unsigned int m_stride; - static ParticleDeclaration s_declarations[ParticleLayout_Max+1]; + static ParticleDeclaration s_declarations[ParticleLayout_Max + 1]; static ParticleDeclarationLibrary::LibraryMap s_library; }; } diff --git a/include/Nazara/Graphics/ParticleMapper.inl b/include/Nazara/Graphics/ParticleMapper.inl index a28315312..63c9c49ba 100644 --- a/include/Nazara/Graphics/ParticleMapper.inl +++ b/include/Nazara/Graphics/ParticleMapper.inl @@ -7,10 +7,20 @@ namespace Nz { + /*! + * \brief Gets a pointer to iterate through same components + * \return SparsePtr pointing to same components + * + * \param component Component to get in the declaration + * + * \remark The same components are not continguous but separated by sizeof(ParticleSize) + * \remark Produces a NazaraError if component is disabled + */ + template SparsePtr ParticleMapper::GetComponentPtr(ParticleComponent component) { - // Ensuite le composant qui nous intéresse + // Then the component that are interesting bool enabled; ComponentType type; unsigned int offset; @@ -18,7 +28,7 @@ namespace Nz if (enabled) { - ///TODO: Vérifier le rapport entre le type de l'attribut et le type template ? + ///TODO: Check the ratio between the type of the attribute and the template type ? return SparsePtr(m_ptr + offset, m_declaration->GetStride()); } else @@ -28,10 +38,20 @@ namespace Nz } } + /*! + * \brief Gets a pointer to iterate through same components + * \return SparsePtr pointing to same components + * + * \param component Component to get in the declaration + * + * \remark The same components are not continguous but separated by sizeof(ParticleSize) + * \remark Produces a NazaraError if component is disabled + */ + template SparsePtr ParticleMapper::GetComponentPtr(ParticleComponent component) const { - // Ensuite le composant qui nous intéresse + // Then the component that are interesting bool enabled; ComponentType type; unsigned int offset; @@ -39,7 +59,7 @@ namespace Nz if (enabled) { - ///TODO: Vérifier le rapport entre le type de l'attribut et le type template ? + ///TODO: Check the ratio between the type of the attribute and the template type ? return SparsePtr(m_ptr + offset, m_declaration->GetStride()); } else diff --git a/include/Nazara/Graphics/Renderable.inl b/include/Nazara/Graphics/Renderable.inl index ed445ec96..9a69329a5 100644 --- a/include/Nazara/Graphics/Renderable.inl +++ b/include/Nazara/Graphics/Renderable.inl @@ -4,17 +4,31 @@ namespace Nz { + /*! + * \brief Ensures that the bounding volume is up to date + */ + inline void Renderable::EnsureBoundingVolumeUpdated() const { if (!m_boundingVolumeUpdated) UpdateBoundingVolume(); } + /*! + * \brief Invalidates the bounding volume + */ + inline void Renderable::InvalidateBoundingVolume() { m_boundingVolumeUpdated = false; } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + */ + inline void Renderable::UpdateBoundingVolume() const { MakeBoundingVolume(); diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 8edb694c9..6171f1e28 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -7,31 +7,62 @@ namespace Nz { + /*! + * \brief Gets the movement offset + * \return Offset of the movement + */ + inline const Vector3f& Nz::SkyboxBackground::GetMovementOffset() const { return m_movementOffset; } + /*! + * \brief Gets the movement scale + * \return Scale of the movement + */ + inline float SkyboxBackground::GetMovementScale() const { return m_movementScale; } + /*! + * \brief Gets the texture of the background + * \return Texture of the background + */ + inline const TextureRef& SkyboxBackground::GetTexture() const { return m_texture; } + /*! + * \brief Gets the texture sampler of the background + * \return A reference to the texture sampler of the background + */ + inline TextureSampler& SkyboxBackground::GetTextureSampler() { return m_sampler; } + /*! + * \brief Gets the texture sampler of the background + * \return A constant reference to the texture sampler of the background + */ + inline const TextureSampler& SkyboxBackground::GetTextureSampler() const { return m_sampler; } + /*! + * \brief Sets the movement offset + * + * \param offset Offset of the movement + */ + inline void SkyboxBackground::SetMovementOffset(const Vector3f& offset) { NazaraAssert(std::isfinite(offset.x) && std::isfinite(offset.y) && std::isfinite(offset.z), "Offset must be a finite vector"); @@ -39,6 +70,12 @@ namespace Nz m_movementOffset = offset; } + /*! + * \brief Sets the movement scale + * + * \param scale Scale of the movement + */ + inline void SkyboxBackground::SetMovementScale(float scale) { NazaraAssert(std::isfinite(scale), "Scale must be a finite value"); @@ -46,6 +83,12 @@ namespace Nz m_movementScale = scale; } + /*! + * \brief Sets the texture of the background + * + * \param cubemapTexture Texture of the background + */ + inline void SkyboxBackground::SetTexture(TextureRef cubemapTexture) { NazaraAssert(!cubemapTexture || cubemapTexture->IsValid(), "Invalid texture"); @@ -54,11 +97,24 @@ namespace Nz m_texture = std::move(cubemapTexture); } + /*! + * \brief Sets the texture sampler of the background + * + * \param sampler Texture sampler of the background + */ + void SkyboxBackground::SetTextureSampler(const TextureSampler& sampler) { m_sampler = sampler; } + /*! + * \brief Creates a new skybox background from the arguments + * \return A reference to the newly created skybox background + * + * \param args Arguments for the skybox background + */ + template SkyboxBackgroundRef SkyboxBackground::New(Args&&... args) { diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 8969cddf0..840a930e6 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -8,6 +8,10 @@ namespace Nz { + /*! + * \brief Constructs a Sprite object by default + */ + inline Sprite::Sprite() : m_color(Color::White), m_textureCoords(0.f, 0.f, 1.f, 1.f), @@ -16,6 +20,12 @@ namespace Nz SetDefaultMaterial(); } + /*! + * \brief Constructs a Sprite object with a reference to a material + * + * \param material Reference to a material + */ + inline Sprite::Sprite(MaterialRef material) : m_color(Color::White), m_textureCoords(0.f, 0.f, 1.f, 1.f), @@ -24,6 +34,12 @@ namespace Nz SetMaterial(std::move(material), true); } + /*! + * \brief Constructs a Sprite object with a pointer to a texture + * + * \param texture Pointer to a texture + */ + inline Sprite::Sprite(Texture* texture) : m_color(Color::White), m_textureCoords(0.f, 0.f, 1.f, 1.f), @@ -32,6 +48,12 @@ namespace Nz SetTexture(texture, true); } + /*! + * \brief Constructs a Sprite object by assignation + * + * \param sprite Sprite to copy into this + */ + inline Sprite::Sprite(const Sprite& sprite) : InstancedRenderable(sprite), m_color(sprite.m_color), @@ -41,26 +63,52 @@ namespace Nz { } + /*! + * \brief Gets the color of the sprite + * \return Current color + */ + inline const Color& Sprite::GetColor() const { return m_color; } + /*! + * \brief Gets the material of the sprite + * \return Current material + */ + inline const MaterialRef& Sprite::GetMaterial() const { return m_material; } + /*! + * \brief Gets the size of the sprite + * \return Current size + */ + inline const Vector2f& Sprite::GetSize() const { return m_size; } + /*! + * \brief Gets the texture coordinates of the sprite + * \return Current texture coordinates + */ + inline const Rectf& Sprite::GetTextureCoords() const { return m_textureCoords; } + /*! + * \brief Sets the color of the billboard + * + * \param color Color for the billboard + */ + inline void Sprite::SetColor(const Color& color) { m_color = color; @@ -68,6 +116,10 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets the default material of the sprite (just default material) + */ + inline void Sprite::SetDefaultMaterial() { MaterialRef material = Material::New(); @@ -77,6 +129,13 @@ namespace Nz SetMaterial(std::move(material)); } + /*! + * \brief Sets the material of the sprite + * + * \param material Material for the sprite + * \param resizeSprite Should sprite be resized to the material size (diffuse map) + */ + inline void Sprite::SetMaterial(MaterialRef material, bool resizeSprite) { m_material = std::move(material); @@ -88,6 +147,12 @@ namespace Nz } } + /*! + * \brief Sets the size of the sprite + * + * \param size Size for the sprite + */ + inline void Sprite::SetSize(const Vector2f& size) { m_size = size; @@ -97,11 +162,25 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets the size of the sprite + * + * \param sizeX Size in X for the sprite + * \param sizeY Size in Y for the sprite + */ + inline void Sprite::SetSize(float sizeX, float sizeY) { SetSize(Vector2f(sizeX, sizeY)); } + /*! + * \brief Sets the texture of the sprite + * + * \param texture Texture for the sprite + * \param resizeSprite Should sprite be resized to the texture size + */ + inline void Sprite::SetTexture(TextureRef texture, bool resizeSprite) { if (!m_material) @@ -115,12 +194,27 @@ namespace Nz m_material->SetDiffuseMap(std::move(texture)); } + /*! + * \brief Sets the texture coordinates of the sprite + * + * \param coords Texture coordinates + */ + inline void Sprite::SetTextureCoords(const Rectf& coords) { m_textureCoords = coords; InvalidateVertices(); } + /*! + * \brief Sets the texture rectangle of the sprite + * + * \param rect Rectangles symbolizing the size of the texture + * + * \remark Produces a NazaraAssert if material is invalid + * \remark Produces a NazaraAssert if material has no diffuse map + */ + inline void Sprite::SetTextureRect(const Rectui& rect) { NazaraAssert(m_material, "Sprite has no material"); @@ -128,12 +222,19 @@ namespace Nz Texture* diffuseMap = m_material->GetDiffuseMap(); - float invWidth = 1.f/diffuseMap->GetWidth(); - float invHeight = 1.f/diffuseMap->GetHeight(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); - SetTextureCoords(Rectf(invWidth*rect.x, invHeight*rect.y, invWidth*rect.width, invHeight*rect.height)); + SetTextureCoords(Rectf(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height)); } + /*! + * \brief Sets the current sprite with the content of the other one + * \return A reference to this + * + * \param sprite The other Sprite + */ + inline Sprite& Sprite::operator=(const Sprite& sprite) { InstancedRenderable::operator=(sprite); @@ -143,18 +244,29 @@ namespace Nz m_textureCoords = sprite.m_textureCoords; m_size = sprite.m_size; - // On ne copie pas les sommets finaux car il est très probable que nos paramètres soient modifiés et qu'ils doivent être régénérés de toute façon + // We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated InvalidateBoundingVolume(); InvalidateVertices(); return *this; } + /*! + * \brief Invalidates the vertices + */ + inline void Sprite::InvalidateVertices() { InvalidateInstanceData(0); } + /*! + * \brief Creates a new sprite from the arguments + * \return A reference to the newly created sprite + * + * \param args Arguments for the sprite + */ + template SpriteRef Sprite::New(Args&&... args) { diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index 312658557..baeeb50db 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a TextSprite object by default + */ + inline TextSprite::TextSprite() : m_color(Color::White), m_scale(1.f) @@ -14,12 +18,24 @@ namespace Nz SetDefaultMaterial(); } + /*! + * \brief Constructs a TextSprite object with a drawer + * + * \param drawer Drawer used to compose text on the sprite + */ + inline TextSprite::TextSprite(const AbstractTextDrawer& drawer) : TextSprite() { Update(drawer); } + /*! + * \brief Constructs a TextSprite object by assignation + * + * \param sprite TextSprite to copy into this + */ + inline TextSprite::TextSprite(const TextSprite& sprite) : InstancedRenderable(sprite), m_renderInfos(sprite.m_renderInfos), @@ -40,6 +56,10 @@ namespace Nz } } + /*! + * \brief Clears the data + */ + inline void TextSprite::Clear() { m_atlases.clear(); @@ -48,21 +68,42 @@ namespace Nz m_renderInfos.clear(); } + /*! + * \brief Gets the color of the text sprite + * \return Current color + */ + inline const Color& TextSprite::GetColor() const { return m_color; } + /*! + * \brief Gets the material of the text sprite + * \return Current material + */ + inline const MaterialRef& TextSprite::GetMaterial() const { return m_material; } + /*! + * \brief Gets the current scale of the text sprite + * \return Current scale + */ + inline float TextSprite::GetScale() const { return m_scale; } + /*! + * \brief Sets the color of the text sprite + * + * \param color Color for the text sprite + */ + inline void TextSprite::SetColor(const Color& color) { m_color = color; @@ -70,6 +111,11 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets the default material of the text sprite (just default material) + */ + + inline void TextSprite::SetDefaultMaterial() { MaterialRef material = Material::New(); @@ -83,11 +129,23 @@ namespace Nz SetMaterial(material); } + /*! + * \brief Sets the material of the text sprite + * + * \param material Material for the text sprite + */ + inline void TextSprite::SetMaterial(MaterialRef material) { m_material = std::move(material); } + /*! + * \brief Sets the current scale of the text sprite + * + * \param scale Scale of the text sprite + */ + inline void TextSprite::SetScale(float scale) { m_scale = scale; @@ -95,10 +153,12 @@ namespace Nz InvalidateVertices(); } - inline void TextSprite::InvalidateVertices() - { - InvalidateInstanceData(0); - } + /*! + * \brief Sets the current text sprite with the content of the other one + * \return A reference to this + * + * \param text sprite The other TextSprite + */ inline TextSprite& TextSprite::operator=(const TextSprite& text) { @@ -130,6 +190,22 @@ namespace Nz return *this; } + /*! + * \brief Invalidates the vertices + */ + + inline void TextSprite::InvalidateVertices() + { + InvalidateInstanceData(0); + } + + /*! + * \brief Creates a new text sprite from the arguments + * \return A reference to the newly created text sprite + * + * \param args Arguments for the text sprite + */ + template TextSpriteRef TextSprite::New(Args&&... args) { diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index c40ad3d2d..31067f36c 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -7,11 +7,22 @@ namespace Nz { + /*! + * \brief Gets the texture of the background + * \return Texture of the background + */ + inline const TextureRef& TextureBackground::GetTexture() const { return m_texture; } + /*! + * \brief Sets the texture of the background + * + * \param texture Texture of the background + */ + inline void TextureBackground::SetTexture(TextureRef texture) { NazaraAssert(!texture || texture->IsValid(), "Invalid texture"); @@ -19,6 +30,13 @@ namespace Nz m_texture = std::move(texture); } + /*! + * \brief Creates a new texture background from the arguments + * \return A reference to the newly created texture background + * + * \param args Arguments for the texture background + */ + template TextureBackgroundRef TextureBackground::New(Args&&... args) { diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index b9f56c1e1..71f385cac 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -491,8 +491,8 @@ namespace Nz * * \remark If volume is infinite, IntersectionSide_Intersecting is returned * \remark If volume is null, IntersectionSide_Outside is returned - * \remark If enumeration of the volume is not defined in Extend, a NazaraError is thrown and false is returned - * \remark If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and false is returned. This should not never happen for a user of the library + * \remark If enumeration of the volume is not defined in Extend, a NazaraError is thrown and IntersectionSide_Outside is returned + * \remark If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and IntersectionSide_Outside is returned. This should not never happen for a user of the library */ template diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index b87bd51a7..0a8d1adae 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -485,7 +485,7 @@ namespace Nz template T Sphere::SquaredDistance(const Vector3& point) const { - return Vector3f::Distance(point, GetPosition()) - radius * radius; + return Vector3f::SquaredDistance(point, GetPosition() + (point - GetPosition()).Normalize() * radius); } /*! diff --git a/src/Nazara/Graphics/AbstractBackground.cpp b/src/Nazara/Graphics/AbstractBackground.cpp index 628819edd..28d0f0d4f 100644 --- a/src/Nazara/Graphics/AbstractBackground.cpp +++ b/src/Nazara/Graphics/AbstractBackground.cpp @@ -7,6 +7,14 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractBackground + * \brief Graphics class that represents the background for our scene + * + * \remark This class is abstract + */ + AbstractBackground::~AbstractBackground() = default; BackgroundLibrary::LibraryMap AbstractBackground::s_library; diff --git a/src/Nazara/Graphics/AbstractRenderQueue.cpp b/src/Nazara/Graphics/AbstractRenderQueue.cpp index d00816f85..1346e37ff 100644 --- a/src/Nazara/Graphics/AbstractRenderQueue.cpp +++ b/src/Nazara/Graphics/AbstractRenderQueue.cpp @@ -7,23 +7,55 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractRenderQueue + * \brief Graphics class that represents the rendering queue for our scene + * + * \remark This class is abstract + */ + AbstractRenderQueue::~AbstractRenderQueue() = default; + /*! + * \brief Adds a directional light to the rendering queue + * + * \param light Directional light + */ + void AbstractRenderQueue::AddDirectionalLight(const DirectionalLight& light) { directionalLights.push_back(light); } + /*! + * \brief Adds a point light to the rendering queue + * + * \param light Point light + */ + void AbstractRenderQueue::AddPointLight(const PointLight& light) { pointLights.push_back(light); } + /*! + * \brief Adds a spot light to the rendering queue + * + * \param light Spot light + */ + void AbstractRenderQueue::AddSpotLight(const SpotLight& light) { spotLights.push_back(light); } + /*! + * \brief Clears the rendering queue + * + * \param fully Should everything be cleared ? + */ + void AbstractRenderQueue::Clear(bool fully) { NazaraUnused(fully); diff --git a/src/Nazara/Graphics/AbstractRenderTechnique.cpp b/src/Nazara/Graphics/AbstractRenderTechnique.cpp index 11d894a00..9872178cf 100644 --- a/src/Nazara/Graphics/AbstractRenderTechnique.cpp +++ b/src/Nazara/Graphics/AbstractRenderTechnique.cpp @@ -10,6 +10,18 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractRenderTechnique + * \brief Graphics class that represents the rendering technique for our scene + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a AbstractRenderTechnique object + */ + AbstractRenderTechnique::AbstractRenderTechnique() : m_instancingEnabled(true) { @@ -17,16 +29,34 @@ namespace Nz AbstractRenderTechnique::~AbstractRenderTechnique() = default; + /*! + * \brief Enables the instancing + * + * \param instancing Should instancing be enabled + * + * \remark This may improve performances + */ + void AbstractRenderTechnique::EnableInstancing(bool instancing) { m_instancingEnabled = instancing; } + /*! + * \brief Gets the name of the actual technique + * \return Name of the technique being used + */ + String AbstractRenderTechnique::GetName() const { return RenderTechniques::ToString(GetType()); } + /*! + * \brief Checks whether the instancing is enabled + * \return true If it is the case + */ + bool AbstractRenderTechnique::IsInstancingEnabled() const { return m_instancingEnabled; diff --git a/src/Nazara/Graphics/AbstractViewer.cpp b/src/Nazara/Graphics/AbstractViewer.cpp index cc9a4b96a..bd8752bc7 100644 --- a/src/Nazara/Graphics/AbstractViewer.cpp +++ b/src/Nazara/Graphics/AbstractViewer.cpp @@ -7,5 +7,13 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::AbstractViewer + * \brief Graphics class that represents the viewer for our scene + * + * \remark This class is abstract + */ + AbstractViewer::~AbstractViewer() = default; } diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 3e5173c89..6f47e9847 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -12,6 +12,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Billboard + * \brief Graphics class that represents a billboard, a 2D surface which simulates a 3D object + */ + + /*! + * \brief Adds this billboard to the render queue + * + * \param renderQueue Queue to be added + * \param instanceData Data used for instance + */ + void Billboard::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_material) @@ -20,11 +33,15 @@ namespace Nz renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix.GetTranslation(), m_size, m_sinCos, m_color); } + /* + * \brief Makes the bounding volume of this billboard + */ + void Billboard::MakeBoundingVolume() const { constexpr float sqrt2 = float(M_SQRT2); - m_boundingVolume.Set(Vector3f(0.f), sqrt2*m_size.x*Vector3f::Right() + sqrt2*m_size.y*Vector3f::Down()); + m_boundingVolume.Set(Vector3f(0.f), sqrt2 * m_size.x * Vector3f::Right() + sqrt2 * m_size.y * Vector3f::Down()); } BillboardLibrary::LibraryMap Billboard::s_library; diff --git a/src/Nazara/Graphics/ColorBackground.cpp b/src/Nazara/Graphics/ColorBackground.cpp index 76f717858..33c282390 100644 --- a/src/Nazara/Graphics/ColorBackground.cpp +++ b/src/Nazara/Graphics/ColorBackground.cpp @@ -11,6 +11,11 @@ namespace Nz { namespace { + /*! + * \brief Defines render states + * \return RenderStates for the color background + */ + RenderStates BuildRenderStates() { RenderStates states; @@ -24,6 +29,18 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::ColorBackground + * \brief Graphics class that represents a background with uniform color + */ + + /*! + * \brief Constructs a ColorBackground object with a color + * + * \param color Uniform color (by default Black) + */ + ColorBackground::ColorBackground(const Color& color) : m_color(color) { @@ -38,6 +55,12 @@ namespace Nz m_vertexDepthUniform = shader->GetUniformLocation("VertexDepth"); } + /*! + * \brief Draws this relatively to the viewer + * + * \param viewer Viewer for the background + */ + void ColorBackground::Draw(const AbstractViewer* viewer) const { NazaraUnused(viewer); @@ -55,16 +78,32 @@ namespace Nz Renderer::DrawFullscreenQuad(); } + /*! + * \brief Gets the background type + * \return Type of background + */ + BackgroundType ColorBackground::GetBackgroundType() const { return BackgroundType_Color; } + /*! + * \brief Gets the color of the background + * \return Background color + */ + Color ColorBackground::GetColor() const { return m_color; } + /*! + * \brief Sets the color of the background + * + * \param color Background color + */ + void ColorBackground::SetColor(const Color& color) { m_color = color; diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index 0fc80e750..c902c7615 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -9,6 +9,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredBloomPass + * \brief Graphics class that represents the pass for bloom in deferred rendering + */ + + /*! + * \brief Constructs a DeferredBloomPass object by default + */ + DeferredBloomPass::DeferredBloomPass() : m_uniformUpdated(false), m_brightLuminance(0.8f), @@ -32,26 +42,55 @@ namespace Nz DeferredBloomPass::~DeferredBloomPass() = default; + /*! + * \brief Gets the number of pass for blur + * \return Number of pass for blur + */ + unsigned int DeferredBloomPass::GetBlurPassCount() const { return m_blurPassCount; } + /*! + * \brief Gets the coefficiant for luminosity + * \return Luminosity of bright elements + */ + float DeferredBloomPass::GetBrightLuminance() const { return m_brightLuminance; } + /*! + * \brief Gets the coefficiant for the middle grey + * \return Luminosity of grey elements + */ + float DeferredBloomPass::GetBrightMiddleGrey() const { return m_brightMiddleGrey; } + /*! + * \brief Gets the coefficiant for things to be bright + * \return Threshold for bright elements + */ + float DeferredBloomPass::GetBrightThreshold() const { return m_brightThreshold; } + /*! + * \brief Gets the ith texture + * \return Texture computed + * + * \param i Index of the texture + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if index is invalid + */ + Texture* DeferredBloomPass::GetTexture(unsigned int i) const { #if NAZARA_GRAPHICS_SAFE @@ -65,7 +104,16 @@ namespace Nz return m_bloomTextures[i]; } - bool DeferredBloomPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredBloomPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraUnused(sceneData); @@ -91,7 +139,7 @@ namespace Nz Renderer::DrawFullscreenQuad(); Renderer::SetTarget(&m_bloomRTT); - Renderer::SetViewport(Recti(0, 0, m_dimensions.x/8, m_dimensions.y/8)); + Renderer::SetViewport(Recti(0, 0, m_dimensions.x / 8, m_dimensions.y / 8)); Renderer::SetShader(m_gaussianBlurShader); @@ -124,6 +172,13 @@ namespace Nz return true; } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredBloomPass::Resize(const Vector2ui& dimensions) { DeferredRenderPass::Resize(dimensions); @@ -131,7 +186,7 @@ namespace Nz m_bloomRTT.Create(true); for (unsigned int i = 0; i < 2; ++i) { - m_bloomTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x/8, dimensions.y/8); + m_bloomTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x / 8, dimensions.y / 8); m_bloomRTT.AttachTexture(AttachmentPoint_Color, i, m_bloomTextures[i]); } m_bloomRTT.Unlock(); @@ -145,23 +200,47 @@ namespace Nz return true; } + /*! + * \brief Sets the number of pass for blur + * + * \param passCount Number of pass for blur + */ + void DeferredBloomPass::SetBlurPassCount(unsigned int passCount) { m_blurPassCount = passCount; // N'est pas une uniforme } + /*! + * \brief Sets the coefficiant for luminosity + * + * \param luminance Luminosity of bright elements + */ + void DeferredBloomPass::SetBrightLuminance(float luminance) { m_brightLuminance = luminance; m_uniformUpdated = false; } + /*! + * \brief Sets the coefficiant for the middle grey + * + * \param middleGrey Luminosity of grey elements + */ + void DeferredBloomPass::SetBrightMiddleGrey(float middleGrey) { m_brightMiddleGrey = middleGrey; m_uniformUpdated = false; } + /*! + * \brief Sets the coefficiant for things to be bright + * + * \param threshold Threshold for bright elements + */ + void DeferredBloomPass::SetBrightThreshold(float threshold) { m_brightThreshold = threshold; diff --git a/src/Nazara/Graphics/DeferredDOFPass.cpp b/src/Nazara/Graphics/DeferredDOFPass.cpp index f29529749..63df2c400 100644 --- a/src/Nazara/Graphics/DeferredDOFPass.cpp +++ b/src/Nazara/Graphics/DeferredDOFPass.cpp @@ -13,6 +13,10 @@ namespace Nz { namespace { + /*! + * \brief Builds the shader for the depth of field + * \return Reference to the shader newly created + */ // http://digitalerr0r.wordpress.com/2009/05/16/xna-shader-programming-tutorial-20-depth-of-field/ ShaderRef BuildDepthOfFieldShader() { @@ -92,6 +96,16 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::DeferredDOFPass + * \brief Graphics class that represents the pass for depth of field in deferred rendering + */ + + /*! + * \brief Constructs a DeferredDOFPass object by default + */ + DeferredDOFPass::DeferredDOFPass() { m_dofShader = BuildDepthOfFieldShader(); @@ -118,7 +132,16 @@ namespace Nz DeferredDOFPass::~DeferredDOFPass() = default; - bool DeferredDOFPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredDOFPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraUnused(sceneData); @@ -162,6 +185,13 @@ namespace Nz return true; } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredDOFPass::Resize(const Vector2ui& dimensions) { DeferredRenderPass::Resize(dimensions); @@ -181,5 +211,5 @@ namespace Nz } return true; -} + } } diff --git a/src/Nazara/Graphics/DeferredFXAAPass.cpp b/src/Nazara/Graphics/DeferredFXAAPass.cpp index 3a300392a..3f1e9395a 100644 --- a/src/Nazara/Graphics/DeferredFXAAPass.cpp +++ b/src/Nazara/Graphics/DeferredFXAAPass.cpp @@ -10,6 +10,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredFXAAPass + * \brief Graphics class that represents the pass for FXAA in deferred rendering + */ + + /*! + * \brief Constructs a DeferredFXAAPass object by default + */ + DeferredFXAAPass::DeferredFXAAPass() { m_fxaaShader = ShaderLibrary::Get("DeferredFXAA"); @@ -23,7 +33,16 @@ namespace Nz DeferredFXAAPass::~DeferredFXAAPass() = default; - bool DeferredFXAAPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredFXAAPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraUnused(sceneData); diff --git a/src/Nazara/Graphics/DeferredFinalPass.cpp b/src/Nazara/Graphics/DeferredFinalPass.cpp index 6ca1e72c4..091c95af6 100644 --- a/src/Nazara/Graphics/DeferredFinalPass.cpp +++ b/src/Nazara/Graphics/DeferredFinalPass.cpp @@ -10,6 +10,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredFinalPass + * \brief Graphics class that represents the final pass in deferred rendering + */ + + /*! + * \brief Constructs a DeferredFinalPass object by default + */ + DeferredFinalPass::DeferredFinalPass() { m_pointSampler.SetAnisotropyLevel(1); @@ -34,7 +44,16 @@ namespace Nz DeferredFinalPass::~DeferredFinalPass() = default; - bool DeferredFinalPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredFinalPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); diff --git a/src/Nazara/Graphics/DeferredFogPass.cpp b/src/Nazara/Graphics/DeferredFogPass.cpp index af00a7c1d..f64521daf 100644 --- a/src/Nazara/Graphics/DeferredFogPass.cpp +++ b/src/Nazara/Graphics/DeferredFogPass.cpp @@ -13,6 +13,11 @@ namespace Nz { namespace { + /*! + * \brief Builds the shader for the fog + * \return Reference to the shader newly created + */ + ShaderRef BuildFogShader() { /*const UInt8 fragmentSource[] = { @@ -117,6 +122,16 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::DeferredFogPass + * \brief Graphics class that represents the pass for fog in deferred rendering + */ + + /*! + * \brief Constructs a DeferredFogPass object by default + */ + DeferredFogPass::DeferredFogPass() { m_pointSampler.SetAnisotropyLevel(1); @@ -131,7 +146,16 @@ namespace Nz DeferredFogPass::~DeferredFogPass() = default; - bool DeferredFogPass::Process( const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredFogPass::Process( const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); diff --git a/src/Nazara/Graphics/DeferredForwardPass.cpp b/src/Nazara/Graphics/DeferredForwardPass.cpp index 35daabae8..ed7ad45d1 100644 --- a/src/Nazara/Graphics/DeferredForwardPass.cpp +++ b/src/Nazara/Graphics/DeferredForwardPass.cpp @@ -13,9 +13,21 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredForwardPass + * \brief Graphics class that represents the forward pass in deferred rendering + */ + DeferredForwardPass::DeferredForwardPass() = default; DeferredForwardPass::~DeferredForwardPass() = default; + /*! + * \brief Initializes the deferred forward pass which needs the forward technique + * + * \param technique Rendering technique + */ + void DeferredForwardPass::Initialize(DeferredRenderTechnique* technique) { DeferredRenderPass::Initialize(technique); @@ -23,7 +35,16 @@ namespace Nz m_forwardTechnique = technique->GetForwardTechnique(); } - bool DeferredForwardPass::Process(const SceneData& sceneData, unsigned int workTexture, unsigned sceneTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredForwardPass::Process(const SceneData& sceneData, unsigned int workTexture, unsigned int sceneTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); NazaraUnused(workTexture); diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 2ae39ed9b..08b111a70 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -18,6 +18,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredGeometryPass + * \brief Graphics class that represents the pass for geometries in deferred rendering + */ + + /*! + * \brief Constructs a DeferredGeometryPass object by default + */ + DeferredGeometryPass::DeferredGeometryPass() { m_clearShader = ShaderLibrary::Get("DeferredGBufferClear"); @@ -31,7 +41,16 @@ namespace Nz DeferredGeometryPass::~DeferredGeometryPass() = default; - bool DeferredGeometryPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const + /*! + * \brief Processes the work on the data while working with textures + * \return false + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + + bool DeferredGeometryPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); NazaraUnused(firstWorkTexture); @@ -72,22 +91,22 @@ namespace Nz bool useInstancing = instancingEnabled && matEntry.instancingEnabled; - // On commence par récupérer le programme du matériau + // We begin by getting the program for materials UInt32 flags = ShaderFlags_Deferred; if (useInstancing) flags |= ShaderFlags_Instancing; const Shader* shader = material->Apply(flags); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // The uniforms are conserved in our program, there's no point to send them back if they don't change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambient color for the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; @@ -105,7 +124,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before rendering loop Renderer::DrawCall drawFunc; Renderer::DrawCallInstanced instancedDrawFunc; unsigned int indexCount; @@ -128,33 +147,33 @@ namespace Nz if (useInstancing) { - // On récupère le buffer d'instancing du Renderer et on le configure pour fonctionner avec des matrices + // We get the buffer for instance of Renderer and we configure it to work with matrices VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); const Matrix4f* instanceMatrices = &instances[0]; unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Le nombre de matrices que peut contenir le buffer + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer while (instanceCount > 0) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to show this time (Depending on the instance buffer size) unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); instanceCount -= renderedInstanceCount; - // On remplit l'instancing buffer avec nos matrices world + // We fill the instancing buffer with our world matrices instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); instanceMatrices += renderedInstanceCount; - // Et on affiche + // And we show instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); } } else { - // Sans instancing, on doit effectuer un draw call pour chaque instance - // Cela reste néanmoins plus rapide que l'instancing en dessous d'un certain nombre d'instances - // À cause du temps de modification du buffer d'instancing + // Without instancing, we must do one draw call for each instance + // This may be faster than instancing under a threshold + // Due to the time to modify the instancing buffer for (const Matrix4f& matrix : instances) { Renderer::SetMatrix(MatrixType_World, matrix); @@ -167,16 +186,23 @@ namespace Nz } } - // Et on remet à zéro les données + // Abd we set it back data to zero matEntry.enabled = false; matEntry.instancingEnabled = false; } } } - return false; // On ne fait que remplir le G-Buffer, les work texture ne sont pas affectées + return false; // We only fill the G-Buffer, the work texture are unchanged } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredGeometryPass::Resize(const Vector2ui& dimensions) { DeferredRenderPass::Resize(dimensions); @@ -241,6 +267,13 @@ namespace Nz } } + /*! + * \brief Gets the uniforms of a shader + * \return Uniforms of the shader + * + * \param shader Shader to get uniforms from + */ + const DeferredGeometryPass::ShaderUniforms* DeferredGeometryPass::GetShaderUniforms(const Shader* shader) const { auto it = m_shaderUniforms.find(shader); @@ -260,6 +293,12 @@ namespace Nz return &it->second; } + /*! + * \brief Handle the invalidation of a shader + * + * \param shader Shader being invalidated + */ + void DeferredGeometryPass::OnShaderInvalidated(const Shader* shader) const { m_shaderUniforms.erase(shader); diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index c340d89a2..efcc88e75 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -13,6 +13,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredPhongLightingPass + * \brief Graphics class that represents the pass for phong lighting in deferred rendering + */ + + /*! + * \brief Constructs a DeferredPhongLightingPass object by default + */ + DeferredPhongLightingPass::DeferredPhongLightingPass() : m_lightMeshesDrawing(false) { @@ -21,7 +31,7 @@ namespace Nz m_directionalLightShaderSceneAmbientLocation = m_directionalLightShader->GetUniformLocation("SceneAmbient"); m_directionalLightUniforms.ubo = false; - m_directionalLightUniforms.locations.type = -1; // Type déjà connu + m_directionalLightUniforms.locations.type = -1; // Type already known m_directionalLightUniforms.locations.color = m_directionalLightShader->GetUniformLocation("LightColor"); m_directionalLightUniforms.locations.factors = m_directionalLightShader->GetUniformLocation("LightFactors"); m_directionalLightUniforms.locations.parameters1 = m_directionalLightShader->GetUniformLocation("LightDirection"); @@ -56,16 +66,36 @@ namespace Nz DeferredPhongLightingPass::~DeferredPhongLightingPass() = default; + /*! + * \brief Enables the drawing of meshes with light + * + * \param enable Should meshes with light parameter be drawed + */ + void DeferredPhongLightingPass::EnableLightMeshesDrawing(bool enable) { m_lightMeshesDrawing = enable; } + /*! + * \brief Checks whether the drawing of meshes with light is enabled + * \return true If it is the case + */ + bool DeferredPhongLightingPass::IsLightMeshesDrawingEnabled() const { return m_lightMeshesDrawing; } + /*! + * \brief Processes the work on the data while working with textures + * \return true + * + * \param sceneData Data for the scene + * \param firstWorkTexture Index of the first texture to work with + * \param firstWorkTexture Index of the second texture to work with + */ + bool DeferredPhongLightingPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -151,12 +181,12 @@ namespace Nz m_pointSpotLightShader->SendVector(m_pointSpotLightUniforms.locations.parameters1, Vector4f(light.position, light.attenuation)); m_pointSpotLightShader->SendVector(m_pointSpotLightUniforms.locations.parameters2, Vector4f(0.f, 0.f, 0.f, light.invRadius)); - lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // Pour corriger les imperfections liées à la sphère + lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // To correct imperfections due to the sphere lightMatrix.SetTranslation(light.position); Renderer::SetMatrix(MatrixType_World, lightMatrix); - // Rendu de la sphère dans le stencil buffer + // Sphere rendering in the stencil buffer Renderer::Enable(RendererParameter_ColorWrite, false); Renderer::Enable(RendererParameter_DepthBuffer, true); Renderer::Enable(RendererParameter_FaceCulling, false); @@ -166,7 +196,7 @@ namespace Nz Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, indexBuffer->GetIndexCount()); - // Rendu de la sphère comme zone d'effet + // Sphere rendering as effect zone Renderer::Enable(RendererParameter_ColorWrite, true); Renderer::Enable(RendererParameter_DepthBuffer, false); Renderer::Enable(RendererParameter_FaceCulling, true); @@ -192,7 +222,7 @@ namespace Nz Renderer::SetShader(shader); for (const auto& light : m_renderQueue->pointLights) { - lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // Pour corriger les imperfections liées à la sphère + lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // To correct imperfections due to the sphere lightMatrix.SetTranslation(light.position); Renderer::SetMatrix(MatrixType_World, lightMatrix); @@ -230,7 +260,7 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, lightMatrix); - // Rendu de la sphère dans le stencil buffer + // Sphere rendering in the stencil buffer Renderer::Enable(RendererParameter_ColorWrite, false); Renderer::Enable(RendererParameter_DepthBuffer, true); Renderer::Enable(RendererParameter_FaceCulling, false); @@ -240,7 +270,7 @@ namespace Nz Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, indexBuffer->GetIndexCount()); - // Rendu de la sphère comme zone d'effet + // Sphere rendering as effect zone Renderer::Enable(RendererParameter_ColorWrite, true); Renderer::Enable(RendererParameter_DepthBuffer, false); Renderer::Enable(RendererParameter_FaceCulling, true); diff --git a/src/Nazara/Graphics/DeferredRenderPass.cpp b/src/Nazara/Graphics/DeferredRenderPass.cpp index 8d688c871..da40c01da 100644 --- a/src/Nazara/Graphics/DeferredRenderPass.cpp +++ b/src/Nazara/Graphics/DeferredRenderPass.cpp @@ -9,6 +9,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredRenderPass + * \brief Graphics class that represents the pass for rendering in deferred rendering + */ + + /*! + * \brief Constructs a DeferredRenderPass object by default + */ + DeferredRenderPass::DeferredRenderPass() : m_enabled(true) { @@ -16,11 +26,23 @@ namespace Nz DeferredRenderPass::~DeferredRenderPass() = default; + /*! + * \brief Enables the deferred rendering + * + * \param enable Should deferred rendering be activated + */ + void DeferredRenderPass::Enable(bool enable) { m_enabled = enable; } + /*! + * \brief Initializes the deferred forward pass which needs the deferred technique + * + * \param technique Rendering technique + */ + void DeferredRenderPass::Initialize(DeferredRenderTechnique* technique) { m_deferredTechnique = technique; @@ -37,11 +59,23 @@ namespace Nz m_workTextures[i] = technique->GetWorkTexture(i); } + /*! + * \brief Checks whether the deferred rendering is enabled + * \return true If it the case + */ + bool DeferredRenderPass::IsEnabled() const { return m_enabled; } + /*! + * \brief Resizes the texture sizes + * \return true If successful + * + * \param dimensions Dimensions for the compute texture + */ + bool DeferredRenderPass::Resize(const Vector2ui& dimensions) { m_dimensions = dimensions; diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 5bd0931e3..738e7b799 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -8,69 +8,207 @@ #include #include -///TODO: Rendre les billboards via Deferred Shading si possible +///TODO: Render billboards using Deferred Shading if possible namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DeferredRenderQueue + * \brief Graphics class that represents the rendering queue for deferred rendering + */ + + /*! + * \brief Constructs a DeferredRenderQueue object with the rendering queue of forward rendering + * + * \param forwardQueue Queue of data to render + */ + DeferredRenderQueue::DeferredRenderQueue(ForwardRenderQueue* forwardQueue) : m_forwardQueue(forwardQueue) { } + /*! + * \brief Adds billboard to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + * \param position Position of the billboard + * \param size Sizes of the billboard + * \param sinCos Rotation of the billboard + * \param color Color of the billboard + */ + void DeferredRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) { m_forwardQueue->AddBillboard(renderOrder, material, position, size, sinCos, color); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + */ + void DeferredRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { m_forwardQueue->AddBillboards(renderOrder, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds drawable to the queue + * + * \param renderOrder Order of rendering + * \param drawable Drawable user defined + * + * \remark Produces a NazaraError if drawable is invalid + */ + void DeferredRenderQueue::AddDrawable(int renderOrder, const Drawable* drawable) { m_forwardQueue->AddDrawable(renderOrder, drawable); } + /*! + * \brief Adds mesh to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the mesh + * \param meshData Data of the mesh + * \param meshAABB Box of the mesh + * \param transformMatrix Matrix of the mesh + */ + void DeferredRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { if (material->IsEnabled(RendererParameter_Blend)) - // Un matériau transparent ? J'aime pas, va voir dans la forward queue si j'y suis + // One transparent material ? I don't like it, go see if I'm in the forward queue m_forwardQueue->AddMesh(renderOrder, material, meshData, meshAABB, transformMatrix); else { @@ -103,21 +241,37 @@ namespace Nz it2 = meshMap.insert(std::make_pair(meshData, std::move(instanceEntry))).first; } - // On ajoute la matrice à la liste des instances de cet objet + // We add matrices to the list of instances of this object std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - // Avons-nous suffisamment d'instances pour que le coût d'utilisation de l'instancing soit payé ? + // Do we have enough instances to perform instancing ? if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Apparemment oui, activons l'instancing avec ce matériau + entry.instancingEnabled = true; // Thus we can activate it } } + /*! + * \brief Adds sprites to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the sprites + * \param vertices Buffer of data for the sprites + * \param spriteCount Number of sprites + * \param overlay Texture of the sprites + */ + void DeferredRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { m_forwardQueue->AddSprites(renderOrder, material, vertices, spriteCount, overlay); } + /*! + * \brief Clears the queue + * + * \param fully Should everything be cleared or we can keep layers + */ + void DeferredRenderQueue::Clear(bool fully) { AbstractRenderQueue::Clear(fully); @@ -137,6 +291,13 @@ namespace Nz m_forwardQueue->Clear(fully); } + /*! + * \brief Gets the ith layer + * \return Reference to the ith layer for the queue + * + * \param i Index of the layer + */ + DeferredRenderQueue::Layer& DeferredRenderQueue::GetLayer(unsigned int i) { auto it = layers.find(i); @@ -149,6 +310,12 @@ namespace Nz return layer; } + /*! + * \brief Handle the invalidation of an index buffer + * + * \param indexBuffer Index buffer being invalidated + */ + void DeferredRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer) { for (auto& pair : layers) @@ -170,6 +337,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a material + * + * \param material Material being invalidated + */ + void DeferredRenderQueue::OnMaterialInvalidation(const Material* material) { for (auto& pair : layers) @@ -180,6 +353,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a vertex buffer + * + * \param vertexBuffer Vertex buffer being invalidated + */ + void DeferredRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer) { for (auto& pair : layers) @@ -201,6 +380,14 @@ namespace Nz } } + /*! + * \brief Functor to compare two batched model with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool DeferredRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const { const UberShader* uberShader1 = mat1->GetShader(); @@ -221,6 +408,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two mesh data + * \return true If first mesh is "smaller" than the second one + * + * \param data1 First mesh to compare + * \param data2 Second mesh to compare + */ + bool DeferredRenderQueue::MeshDataComparator::operator()(const MeshData& data1, const MeshData& data2) const { const Buffer* buffer1; diff --git a/src/Nazara/Graphics/DeferredRenderTechnique.cpp b/src/Nazara/Graphics/DeferredRenderTechnique.cpp index 88335d92b..585091406 100644 --- a/src/Nazara/Graphics/DeferredRenderTechnique.cpp +++ b/src/Nazara/Graphics/DeferredRenderTechnique.cpp @@ -77,7 +77,18 @@ namespace Nz 3, // RenderPassType_SSAO }; - static_assert(sizeof(RenderPassPriority)/sizeof(unsigned int) == RenderPassType_Max+1, "Render pass priority array is incomplete"); + static_assert(sizeof(RenderPassPriority) / sizeof(unsigned int) == RenderPassType_Max + 1, "Render pass priority array is incomplete"); + + /*! + * \brief Registers the deferred shader + * \return Reference to the newly created shader + * + * \param name Name of the shader + * \param fragmentSource Raw data to fragment shader + * \param fragmentSourceLength Size of the fragment source + * \param vertexStage Stage of the shader + * \param err Pointer to string to contain error message + */ inline ShaderRef RegisterDeferredShader(const String& name, const UInt8* fragmentSource, unsigned int fragmentSourceLength, const ShaderStage& vertexStage, String* err) { @@ -109,6 +120,18 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::DeferredRenderTechnique + * \brief Graphics class that represents the technique used in deferred rendering + */ + + /*! + * \brief Constructs a DeferredRenderTechnique object by default + * + * \remark Produces a NazaraError if one pass could not be created + */ + DeferredRenderTechnique::DeferredRenderTechnique() : m_renderQueue(static_cast(m_forwardTechnique.GetRenderQueue())), m_GBufferSize(0U) @@ -204,11 +227,27 @@ namespace Nz DeferredRenderTechnique::~DeferredRenderTechnique() = default; + /*! + * \brief Clears the data + * + * \param sceneData Data of the scene + */ + void DeferredRenderTechnique::Clear(const SceneData& sceneData) const { NazaraUnused(sceneData); } + /*! + * \brief Draws the data of the scene + * \return true If successful + * + * \param sceneData Data of the scene + * + * \remark Produces a NazaraAssert if viewer of the scene is invalid + * \remark Produces a NazaraError if updating viewport dimensions failed + */ + bool DeferredRenderTechnique::Draw(const SceneData& sceneData) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -242,6 +281,14 @@ namespace Nz return true; } + /*! + * \brief Enables a pass + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + * \param enable Should the pass be enabled + */ + void DeferredRenderTechnique::EnablePass(RenderPassType renderPass, int position, bool enable) { auto it = m_passes.find(renderPass); @@ -253,11 +300,25 @@ namespace Nz } } + /*! + * \brief Gets the stencil buffer + * \return Pointer to the rendering buffer + */ + RenderBuffer* DeferredRenderTechnique::GetDepthStencilBuffer() const { return m_depthStencilBuffer; } + /*! + * \brief Gets the G-buffer + * \return Pointer to the ith texture + * + * \param i Index of the G-buffer + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if index is invalid + */ + Texture* DeferredRenderTechnique::GetGBuffer(unsigned int i) const { #if NAZARA_GRAPHICS_SAFE @@ -271,16 +332,34 @@ namespace Nz return m_GBuffer[i]; } + /*! + * \brief Gets the rendering texture of the G-buffer + * \return Pointer to the rendering buffer + */ + RenderTexture* DeferredRenderTechnique::GetGBufferRTT() const { return &m_GBufferRTT; } + /*! + * \brief Gets the forward technique + * \return Constant pointer to the forward technique + */ + const ForwardRenderTechnique* DeferredRenderTechnique::GetForwardTechnique() const { return &m_forwardTechnique; } + /*! + * \brief Gets the pass + * \return Pointer to the deferred render pass + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + */ + DeferredRenderPass* DeferredRenderTechnique::GetPass(RenderPassType renderPass, int position) { auto it = m_passes.find(renderPass); @@ -294,21 +373,45 @@ namespace Nz return nullptr; } + /*! + * \brief Gets the render queue + * \return Pointer to the render queue + */ + AbstractRenderQueue* DeferredRenderTechnique::GetRenderQueue() { return &m_renderQueue; } + /*! + * \brief Gets the type of the current technique + * \return Type of the render technique + */ + RenderTechniqueType DeferredRenderTechnique::GetType() const { return RenderTechniqueType_DeferredShading; } + /*! + * \brief Gets the render texture used to work + * \return Pointer to the rendering texture + */ + RenderTexture* DeferredRenderTechnique::GetWorkRTT() const { return &m_workRTT; } + /*! + * \brief Gets the ith texture to work + * \return Pointer to the texture + * + * \param i Index of the texture used to work + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if index is invalid + */ + Texture* DeferredRenderTechnique::GetWorkTexture(unsigned int i) const { #if NAZARA_GRAPHICS_SAFE @@ -322,6 +425,14 @@ namespace Nz return m_workTextures[i]; } + /*! + * \brief Checks whether the pass is enable + * \return true If it is the case + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + */ + bool DeferredRenderTechnique::IsPassEnabled(RenderPassType renderPass, int position) { auto it = m_passes.find(renderPass); @@ -335,9 +446,17 @@ namespace Nz return false; } + /*! + * \brief Resets the pass + * \return Pointer to the new deferred render pass + * + * \param renderPass Enumeration for the pass + * \param position Position of the pass + */ + DeferredRenderPass* DeferredRenderTechnique::ResetPass(RenderPassType renderPass, int position) { - std::unique_ptr smartPtr; // Nous évite un leak en cas d'exception + std::unique_ptr smartPtr; // We avoid to leak in case of exception switch (renderPass) { @@ -386,6 +505,14 @@ namespace Nz return smartPtr.release(); } + /*! + * \brief Sets the pass + * + * \param relativeTo Enumeration for the pass + * \param position Position of the pass + * \param pass Render pass to set + */ + void DeferredRenderTechnique::SetPass(RenderPassType relativeTo, int position, DeferredRenderPass* pass) { if (pass) @@ -400,12 +527,26 @@ namespace Nz m_passes[relativeTo].erase(position); } + /*! + * \brief Checks whether the technique is supported + * \return true if it is the case + */ + bool DeferredRenderTechnique::IsSupported() { - // Depuis qu'OpenGL 3.3 est la version minimale, le Renderer supporte ce qu'il faut, mais par acquis de conscience... + // Since OpenGL 3.3 is the minimal version, the Renderer supports what it needs, but we are never sure... return Renderer::GetMaxColorAttachments() >= 4 && Renderer::GetMaxRenderTargets() >= 4; } + /*! + * \brief Resizes the texture sizes used for the render technique + * \return true If successful + * + * \param dimensions Dimensions for the render technique + * + * \param Produces a NazaraError if one pass could not be resized + */ + bool DeferredRenderTechnique::Resize(const Vector2ui& dimensions) const { try @@ -427,6 +568,13 @@ namespace Nz } } + /*! + * \brief Initializes the deferred render technique + * \return true If successful + * + * \remark Produces a NazaraError if one shader creation failed + */ + bool DeferredRenderTechnique::Initialize() { const char vertexSource_Basic[] = @@ -560,6 +708,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the deferred render technique + */ + void DeferredRenderTechnique::Uninitialize() { ShaderLibrary::Unregister("DeferredGBufferClear"); @@ -571,6 +723,14 @@ namespace Nz ShaderLibrary::Unregister("DeferredGaussianBlur"); } + /*! + * \brief Functor to compare two render pass + * \return true If first render pass is "smaller" than the second one + * + * \param pass1 First render pass to compare + * \param pass2 Second render pass to compare + */ + bool DeferredRenderTechnique::RenderPassComparator::operator()(RenderPassType pass1, RenderPassType pass2) const { return RenderPassPriority[pass1] < RenderPassPriority[pass2]; diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index e6fc71ae0..dc31d2a45 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -9,6 +9,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::DepthRenderQueue + * \brief Graphics class that represents the rendering queue for depth rendering + */ + + /*! + * \brief Constructs a DepthRenderTechnique object by default + */ + DepthRenderQueue::DepthRenderQueue() { // Material @@ -18,6 +28,19 @@ namespace Nz //m_baseMaterial->SetFaceCulling(FaceSide_Front); } + /*! + * \brief Adds billboard to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + * \param position Position of the billboard + * \param size Sizes of the billboard + * \param sinCos Rotation of the billboard + * \param color Color of the billboard + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) { NazaraAssert(material, "Invalid material"); @@ -34,6 +57,20 @@ namespace Nz ForwardRenderQueue::AddBillboard(0, material, position, size, sinCos, color); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -50,6 +87,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -66,6 +117,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -82,6 +147,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -98,6 +177,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -114,6 +207,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -130,6 +237,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, sinCosPtr, alphaPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); @@ -146,6 +267,20 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, colorPtr); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); @@ -162,12 +297,32 @@ namespace Nz ForwardRenderQueue::AddBillboards(0, material, count, positionPtr, sizePtr, anglePtr, alphaPtr); } + /*! + * \brief Adds a direcitonal light to the queue + * + * \param light Light to add + * + * \remark Produces a NazaraAssert + */ + void DepthRenderQueue::AddDirectionalLight(const DirectionalLight& light) { NazaraAssert(false, "Depth render queue doesn't handle lights"); NazaraUnused(light); } + /*! + * \brief Adds mesh to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the mesh + * \param meshData Data of the mesh + * \param meshAABB Box of the mesh + * \param transformMatrix Matrix of the mesh + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { NazaraAssert(material, "Invalid material"); @@ -185,18 +340,46 @@ namespace Nz ForwardRenderQueue::AddMesh(0, material, meshData, meshAABB, transformMatrix); } + /*! + * \brief Adds a point light to the queue + * + * \param light Light to add + * + * \remark Produces a NazaraAssert + */ + void DepthRenderQueue::AddPointLight(const PointLight& light) { NazaraAssert(false, "Depth render queue doesn't handle lights"); NazaraUnused(light); } + /*! + * \brief Adds a spot light to the queue + * + * \param light Light to add + * + * \remark Produces a NazaraAssert + */ + void DepthRenderQueue::AddSpotLight(const SpotLight& light) { NazaraAssert(false, "Depth render queue doesn't handle lights"); NazaraUnused(light); } + /*! + * \brief Adds sprites to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the sprites + * \param vertices Buffer of data for the sprites + * \param spriteCount Number of sprites + * \param overlay Texture of the sprites + * + * \remark Produces a NazaraAssert if material is invalid + */ + void DepthRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { NazaraAssert(material, "Invalid material"); diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 46e7fb043..233eb9c72 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -37,6 +37,16 @@ namespace Nz unsigned int s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB } + /*! + * \ingroup graphics + * \class Nz::DepthRenderTechnique + * \brief Graphics class that represents the technique used in depth rendering + */ + + /*! + * \brief Constructs a DepthRenderTechnique object by default + */ + DepthRenderTechnique::DepthRenderTechnique() : m_vertexBuffer(BufferType_Vertex) { @@ -48,6 +58,12 @@ namespace Nz m_spriteBuffer.Reset(VertexDeclaration::Get(VertexLayout_XYZ_Color_UV), &m_vertexBuffer); } + /*! + * \brief Clears the data + * + * \param sceneData Data of the scene + */ + void DepthRenderTechnique::Clear(const SceneData& sceneData) const { Renderer::Enable(RendererParameter_DepthBuffer, true); @@ -59,6 +75,13 @@ namespace Nz // sceneData.background->Draw(sceneData.viewer); } + /*! + * \brief Draws the data of the scene + * \return true If successful + * + * \param sceneData Data of the scene + */ + bool DepthRenderTechnique::Draw(const SceneData& sceneData) const { for (auto& pair : m_renderQueue.layers) @@ -81,16 +104,33 @@ namespace Nz return true; } + /*! + * \brief Gets the render queue + * \return Pointer to the render queue + */ + AbstractRenderQueue* DepthRenderTechnique::GetRenderQueue() { return &m_renderQueue; } + /*! + * \brief Gets the type of the current technique + * \return Type of the render technique + */ + RenderTechniqueType DepthRenderTechnique::GetType() const { return RenderTechniqueType_Depth; } + /*! + * \brief Initializes the depth render technique + * \return true If successful + * + * \remark Produces a NazaraError if one shader creation failed + */ + bool DepthRenderTechnique::Initialize() { try @@ -149,12 +189,23 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the depth render technique + */ + void DepthRenderTechnique::Uninitialize() { s_quadIndexBuffer.Reset(); s_quadVertexBuffer.Reset(); } + /*! + * \brief Draws basic sprites + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + */ + void DepthRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; @@ -180,7 +231,7 @@ namespace Nz unsigned int spriteChainCount = spriteChainVector.size(); if (spriteChainCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt32 flags = 0; if (overlay) flags |= ShaderFlags_TextureOverlay; @@ -195,26 +246,26 @@ namespace Nz Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); } - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); // Overlay shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); lastShader = shader; } - unsigned int spriteChain = 0; // Quelle chaîne de sprite traitons-nous - unsigned int spriteChainOffset = 0; // À quel offset dans la dernière chaîne nous sommes-nous arrêtés + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain do { - // On ouvre le buffer en écriture + // We open the buffer in writing mode BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(vertexMapper.GetPointer()); @@ -232,7 +283,7 @@ namespace Nz spriteCount += count; spriteChainOffset += count; - // Avons-nous traité la chaîne entière ? + // Have we treated the entire chain ? if (spriteChainOffset == currentChain.spriteCount) { spriteChain++; @@ -257,6 +308,13 @@ namespace Nz } } + /*! + * \brief Draws billboards + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + */ + void DepthRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; @@ -278,16 +336,16 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); lastShader = shader; @@ -325,16 +383,16 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); lastShader = shader; @@ -396,6 +454,13 @@ namespace Nz } } + /*! + * \brief Draws opaques models + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + */ + void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; @@ -415,14 +480,14 @@ namespace Nz bool instancing = m_instancingEnabled && matEntry.instancingEnabled; - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); lastShader = shader; } @@ -441,7 +506,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before rendering loop Renderer::DrawCall drawFunc; Renderer::DrawCallInstanced instancedDrawFunc; unsigned int indexCount; @@ -464,33 +529,33 @@ namespace Nz if (instancing) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); const Matrix4f* instanceMatrices = &instances[0]; unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Le nombre maximum d'instances en une fois + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The maximum number of instances in one batch while (instanceCount > 0) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); instanceCount -= renderedInstanceCount; - // On remplit l'instancing buffer avec nos matrices world + // We fill the instancing buffer with our world matrices instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); instanceMatrices += renderedInstanceCount; - // Et on affiche + // And we draw instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); } } else { - // Sans instancing, on doit effectuer un draw call pour chaque instance - // Cela reste néanmoins plus rapide que l'instancing en dessous d'un certain nombre d'instances - // À cause du temps de modification du buffer d'instancing + // Without instancing, we must do a draw call for each instance + // This may be faster than instancing under a certain number + // Due to the time to modify the instancing buffer for (const Matrix4f& matrix : instances) { Renderer::SetMatrix(MatrixType_World, matrix); @@ -502,13 +567,20 @@ namespace Nz } } - // Et on remet à zéro les données + // And we set the data back to zero matEntry.enabled = false; matEntry.instancingEnabled = false; } } } + /*! + * \brief Gets the shader uniforms + * \return Uniforms of the shader + * + * \param shader Shader to get uniforms from + */ + const DepthRenderTechnique::ShaderUniforms* DepthRenderTechnique::GetShaderUniforms(const Shader* shader) const { auto it = m_shaderUniforms.find(shader); @@ -527,6 +599,12 @@ namespace Nz return &it->second; } + /*! + * \brief Handle the invalidation of a shader + * + * \param shader Shader being invalidated + */ + void DepthRenderTechnique::OnShaderInvalidated(const Shader* shader) const { m_shaderUniforms.erase(shader); diff --git a/src/Nazara/Graphics/Drawable.cpp b/src/Nazara/Graphics/Drawable.cpp index baac1defb..7db121225 100644 --- a/src/Nazara/Graphics/Drawable.cpp +++ b/src/Nazara/Graphics/Drawable.cpp @@ -7,5 +7,13 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Drawable + * \brief Graphics class that represents something drawable for our scene + * + * \remark This class is abstract + */ + Drawable::~Drawable() = default; } diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 9f0f5d04d..0f182a185 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -7,10 +7,29 @@ #include #include -///TODO: Remplacer les sinus/cosinus par une lookup table (va booster les perfs d'un bon x10) +///TODO: Replace sinus/cosinus by a lookup table (which will lead to a speed up about 10x) namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ForwardRenderQueue + * \brief Graphics class that represents the rendering queue for forward rendering + */ + + /*! + * \brief Adds billboard to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + * \param position Position of the billboard + * \param size Sizes of the billboard + * \param sinCos Rotation of the billboard + * \param color Color of the billboard + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) { NazaraAssert(material, "Invalid material"); @@ -32,37 +51,33 @@ namespace Nz billboardVector.push_back(BillboardData{color, position, size, sinCos}); } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seont remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -73,39 +88,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -116,37 +127,33 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -161,39 +168,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Sizes of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -208,37 +211,33 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -249,39 +248,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param sinCosPtr Rotation of the billboards if null, Vector2f(0.f, 1.f) is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White Vector2f defaultSinCos(0.f, 1.f); // sin(0) = 0, cos(0) = 1 if (!sinCosPtr) - sinCosPtr.Reset(&defaultSinCos, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + sinCosPtr.Reset(&defaultSinCos, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { billboardData->center = *positionPtr++; @@ -292,37 +287,33 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param colorPtr Color of the billboards if null, Color::White is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et colorPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile if (!colorPtr) - colorPtr.Reset(&Color::White, 0); // Pareil + colorPtr.Reset(&Color::White, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -337,39 +328,35 @@ namespace Nz } } + /*! + * \brief Adds multiple billboards to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the billboards + * \param count Number of billboards + * \param positionPtr Position of the billboards + * \param sizePtr Size of the billboards + * \param anglePtr Rotation of the billboards if null, 0.f is used + * \param alphaPtr Alpha parameters of the billboards if null, 1.f is used + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr alphaPtr) { NazaraAssert(material, "Invalid material"); - ///DOC: sinCosPtr et alphaPtr peuvent être nuls, ils seront remplacés respectivement par Vector2f(0.f, 1.f) et Color::White float defaultRotation = 0.f; if (!anglePtr) - anglePtr.Reset(&defaultRotation, 0); // L'astuce ici est de mettre le stride sur zéro, rendant le pointeur immobile + anglePtr.Reset(&defaultRotation, 0); // The trick here is to put the stride to zero, which leads the pointer to be immobile float defaultAlpha = 1.f; if (!alphaPtr) - alphaPtr.Reset(&defaultAlpha, 0); // Pareil + alphaPtr.Reset(&defaultAlpha, 0); // Same - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - unsigned int prevSize = billboardVector.size(); - billboardVector.resize(prevSize + count); - - BillboardData* billboardData = &billboardVector[prevSize]; + BillboardData* billboardData = GetBillboardData(renderOrder, material, count); for (unsigned int i = 0; i < count; ++i) { float sin = std::sin(ToRadians(*anglePtr)); @@ -384,6 +371,15 @@ namespace Nz } } + /*! + * \brief Adds drawable to the queue + * + * \param renderOrder Order of rendering + * \param drawable Drawable user defined + * + * \remark Produces a NazaraError if drawable is invalid + */ + void ForwardRenderQueue::AddDrawable(int renderOrder, const Drawable* drawable) { #if NAZARA_GRAPHICS_SAFE @@ -399,15 +395,29 @@ namespace Nz otherDrawables.push_back(drawable); } + /*! + * \brief Adds mesh to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the mesh + * \param meshData Data of the mesh + * \param meshAABB Box of the mesh + * \param transformMatrix Matrix of the mesh + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { + NazaraAssert(material, "Invalid material"); + if (material->IsEnabled(RendererParameter_Blend)) { Layer& currentLayer = GetLayer(renderOrder); auto& transparentModels = currentLayer.transparentModels; auto& transparentModelData = currentLayer.transparentModelData; - // Le matériau est transparent, nous devons rendre ce mesh d'une autre façon (après le rendu des objets opaques et en les triant) + // The material is transparent, we must draw this mesh using another way (after the rendering of opages objects while sorting them) unsigned int index = transparentModelData.size(); transparentModelData.resize(index+1); @@ -455,14 +465,28 @@ namespace Nz std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - // Avons-nous suffisamment d'instances pour que le coût d'utilisation de l'instancing soit payé ? + // Do we have enough instances to perform instancing ? if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Apparemment oui, activons l'instancing avec ce matériau + entry.instancingEnabled = true; // Thus we can activate it } } + /*! + * \brief Adds sprites to the queue + * + * \param renderOrder Order of rendering + * \param material Material of the sprites + * \param vertices Buffer of data for the sprites + * \param spriteCount Number of sprites + * \param overlay Texture of the sprites + * + * \remark Produces a NazaraAssert if material is invalid + */ + void ForwardRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { + NazaraAssert(material, "Invalid material"); + Layer& currentLayer = GetLayer(renderOrder); auto& basicSprites = currentLayer.basicSprites; @@ -494,6 +518,12 @@ namespace Nz spriteVector.push_back(SpriteChain_XYZ_Color_UV({vertices, spriteCount})); } + /*! + * \brief Clears the queue + * + * \param fully Should everything be cleared or we can keep layers + */ + void ForwardRenderQueue::Clear(bool fully) { AbstractRenderQueue::Clear(fully); @@ -518,15 +548,21 @@ namespace Nz } } + /*! + * \brief Sorts the object according to the viewer position, furthest to nearest + * + * \param viewer Viewer of the scene + */ + void ForwardRenderQueue::Sort(const AbstractViewer* viewer) { Planef nearPlane = viewer->GetFrustum().GetPlane(FrustumPlane_Near); Vector3f viewerPos = viewer->GetEyePosition(); Vector3f viewerNormal = viewer->GetForward(); - for (auto& layerPair : layers) + for (auto& pair : layers) { - Layer& layer = layerPair.second; + Layer& layer = pair.second; std::sort(layer.transparentModels.begin(), layer.transparentModels.end(), [&layer, &nearPlane, &viewerNormal] (unsigned int index1, unsigned int index2) { @@ -557,18 +593,61 @@ namespace Nz } } + /*! + * \brief Gets the billboard data + * \return Pointer to the data of the billboards + * + * \param renderOrder Order of rendering + * \param material Material of the billboard + */ + + ForwardRenderQueue::BillboardData* ForwardRenderQueue::GetBillboardData(int renderOrder, const Material* material, unsigned int count) + { + auto& billboards = GetLayer(renderOrder).billboards; + + auto it = billboards.find(material); + if (it == billboards.end()) + { + BatchedBillboardEntry entry; + entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); + + it = billboards.insert(std::make_pair(material, std::move(entry))).first; + } + + BatchedBillboardEntry& entry = it->second; + + auto& billboardVector = entry.billboards; + unsigned int prevSize = billboardVector.size(); + billboardVector.resize(prevSize + count); + + return &billboardVector[prevSize]; + } + + /*! + * \brief Gets the ith layer + * \return Reference to the ith layer for the queue + * + * \param i Index of the layer + */ + ForwardRenderQueue::Layer& ForwardRenderQueue::GetLayer(int i) { auto it = layers.find(i); if (it == layers.end()) it = layers.insert(std::make_pair(i, Layer())).first; - + Layer& layer = it->second; layer.clearCount = 0; return layer; } + /*! + * \brief Handle the invalidation of an index buffer + * + * \param indexBuffer Index buffer being invalidated + */ + void ForwardRenderQueue::OnIndexBufferInvalidation(const IndexBuffer* indexBuffer) { for (auto& pair : layers) @@ -590,6 +669,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a material + * + * \param material Material being invalidated + */ + void ForwardRenderQueue::OnMaterialInvalidation(const Material* material) { for (auto& pair : layers) @@ -602,6 +687,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a texture + * + * \param texture Texture being invalidated + */ + void ForwardRenderQueue::OnTextureInvalidation(const Texture* texture) { for (auto& pair : layers) @@ -615,6 +706,12 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a vertex buffer + * + * \param vertexBuffer Vertex buffer being invalidated + */ + void ForwardRenderQueue::OnVertexBufferInvalidation(const VertexBuffer* vertexBuffer) { for (auto& pair : layers) @@ -635,6 +732,14 @@ namespace Nz } } + /*! + * \brief Functor to compare two batched billboard with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool ForwardRenderQueue::BatchedBillboardComparator::operator()(const Material* mat1, const Material* mat2) const { const UberShader* uberShader1 = mat1->GetShader(); @@ -655,6 +760,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two batched model with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool ForwardRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const { const UberShader* uberShader1 = mat1->GetShader(); @@ -675,6 +788,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two batched sprites with material + * \return true If first material is "smaller" than the second one + * + * \param mat1 First material to compare + * \param mat2 Second material to compare + */ + bool ForwardRenderQueue::BatchedSpriteMaterialComparator::operator()(const Material* mat1, const Material* mat2) { const UberShader* uberShader1 = mat1->GetShader(); @@ -695,6 +816,14 @@ namespace Nz return mat1 < mat2; } + /*! + * \brief Functor to compare two mesh data + * \return true If first mesh is "smaller" than the second one + * + * \param data1 First mesh to compare + * \param data2 Second mesh to compare + */ + bool ForwardRenderQueue::MeshDataComparator::operator()(const MeshData& data1, const MeshData& data2) const { const Buffer* buffer1; diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 2ec95aee7..482852347 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -33,10 +33,20 @@ namespace Nz Vector2f uv; }; - unsigned int s_maxQuads = std::numeric_limits::max()/6; - unsigned int s_vertexBufferSize = 4*1024*1024; // 4 MiB + unsigned int s_maxQuads = std::numeric_limits::max() / 6; + unsigned int s_vertexBufferSize = 4 * 1024 * 1024; // 4 MiB } + /*! + * \ingroup graphics + * \class Nz::ForwardRenderTechnique + * \brief Graphics class that represents the technique used in forward rendering + */ + + /*! + * \brief Constructs a ForwardRenderTechnique object by default + */ + ForwardRenderTechnique::ForwardRenderTechnique() : m_vertexBuffer(BufferType_Vertex), m_maxLightPassPerObject(3) @@ -49,6 +59,12 @@ namespace Nz m_spriteBuffer.Reset(VertexDeclaration::Get(VertexLayout_XYZ_Color_UV), &m_vertexBuffer); } + /*! + * \brief Clears the data + * + * \param sceneData Data of the scene + */ + void ForwardRenderTechnique::Clear(const SceneData& sceneData) const { Renderer::Enable(RendererParameter_DepthBuffer, true); @@ -59,6 +75,15 @@ namespace Nz sceneData.background->Draw(sceneData.viewer); } + /*! + * \brief Draws the data of the scene + * \return true If successful + * + * \param sceneData Data of the scene + * + * \remark Produces a NazaraAssert if viewer of the scene is invalid + */ + bool ForwardRenderTechnique::Draw(const SceneData& sceneData) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -88,55 +113,83 @@ namespace Nz return true; } + /*! + * \brief Gets the maximum number of lights available per pass per object + * \return Maximum number of light simulatenously per object + */ + unsigned int ForwardRenderTechnique::GetMaxLightPassPerObject() const { return m_maxLightPassPerObject; } + /*! + * \brief Gets the render queue + * \return Pointer to the render queue + */ + AbstractRenderQueue* ForwardRenderTechnique::GetRenderQueue() { return &m_renderQueue; } + /*! + * \brief Gets the type of the current technique + * \return Type of the render technique + */ + RenderTechniqueType ForwardRenderTechnique::GetType() const { return RenderTechniqueType_BasicForward; } - void ForwardRenderTechnique::SetMaxLightPassPerObject(unsigned int passCount) + /*! + * \brief Sets the maximum number of lights available per pass per object + * + * \param passCount Maximum number of light simulatenously per object + */ + + void ForwardRenderTechnique::SetMaxLightPassPerObject(unsigned int maxLightPassPerObject) { - m_maxLightPassPerObject = passCount; + m_maxLightPassPerObject = maxLightPassPerObject; } + /*! + * \brief Initializes the forward render technique + * \return true If successful + * + * \remark Produces a NazaraError if one shader creation failed + */ + bool ForwardRenderTechnique::Initialize() { try { ErrorFlags flags(ErrorFlag_ThrowException, true); - s_quadIndexBuffer.Reset(false, s_maxQuads*6, DataStorage_Hardware, BufferUsage_Static); + s_quadIndexBuffer.Reset(false, s_maxQuads * 6, DataStorage_Hardware, BufferUsage_Static); BufferMapper mapper(s_quadIndexBuffer, BufferAccess_WriteOnly); UInt16* indices = static_cast(mapper.GetPointer()); for (unsigned int i = 0; i < s_maxQuads; ++i) { - *indices++ = i*4 + 0; - *indices++ = i*4 + 2; - *indices++ = i*4 + 1; + *indices++ = i * 4 + 0; + *indices++ = i * 4 + 2; + *indices++ = i * 4 + 1; - *indices++ = i*4 + 2; - *indices++ = i*4 + 3; - *indices++ = i*4 + 1; + *indices++ = i * 4 + 2; + *indices++ = i * 4 + 3; + *indices++ = i * 4 + 1; } - mapper.Unmap(); // Inutile de garder le buffer ouvert plus longtemps + mapper.Unmap(); // No point to keep the buffer open any longer - // Quad buffer (utilisé pour l'instancing de billboard et de sprites) - //Note: Les UV sont calculés dans le shader + // Quad buffer (used for instancing of billboards and sprites) + //Note: UV are computed in the shader s_quadVertexBuffer.Reset(VertexDeclaration::Get(VertexLayout_XY), 4, DataStorage_Hardware, BufferUsage_Static); - float vertices[2*4] = { + float vertices[2 * 4] = { -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, @@ -145,14 +198,14 @@ namespace Nz s_quadVertexBuffer.FillRaw(vertices, 0, sizeof(vertices)); - // Déclaration lors du rendu des billboards par sommet + // Declaration used when rendering the vertex billboards s_billboardVertexDeclaration.EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(BillboardPoint, color)); s_billboardVertexDeclaration.EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(BillboardPoint, position)); s_billboardVertexDeclaration.EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(BillboardPoint, uv)); - s_billboardVertexDeclaration.EnableComponent(VertexComponent_Userdata0, ComponentType_Float4, NazaraOffsetOf(BillboardPoint, size)); // Englobe sincos + s_billboardVertexDeclaration.EnableComponent(VertexComponent_Userdata0, ComponentType_Float4, NazaraOffsetOf(BillboardPoint, size)); // Includes sincos - // Declaration utilisée lors du rendu des billboards par instancing - // L'avantage ici est la copie directe (std::memcpy) des données de la RenderQueue vers le buffer GPU + // Declaration used when rendering the billboards with intancing + // The main advantage is the direct copy (std::memcpy) of data in the RenderQueue to the GPU buffer s_billboardInstanceDeclaration.EnableComponent(VertexComponent_InstanceData0, ComponentType_Float3, NazaraOffsetOf(ForwardRenderQueue::BillboardData, center)); s_billboardInstanceDeclaration.EnableComponent(VertexComponent_InstanceData1, ComponentType_Float4, NazaraOffsetOf(ForwardRenderQueue::BillboardData, size)); // Englobe sincos s_billboardInstanceDeclaration.EnableComponent(VertexComponent_InstanceData2, ComponentType_Color, NazaraOffsetOf(ForwardRenderQueue::BillboardData, color)); @@ -169,12 +222,23 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the forward render technique + */ + void ForwardRenderTechnique::Uninitialize() { s_quadIndexBuffer.Reset(); s_quadVertexBuffer.Reset(); } + /*! + * \brief Chooses the nearest lights for one object + * + * \param object Sphere symbolising the object + * \param includeDirectionalLights Should directional lights be included in the computation + */ + void ForwardRenderTechnique::ChooseLights(const Spheref& object, bool includeDirectionalLights) const { m_lights.clear(); @@ -213,6 +277,15 @@ namespace Nz }); } + /*! + * \brief Draws basic sprites + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -240,7 +313,7 @@ namespace Nz unsigned int spriteChainCount = spriteChainVector.size(); if (spriteChainCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt32 flags = ShaderFlags_VertexColor; if (overlay) flags |= ShaderFlags_TextureOverlay; @@ -255,46 +328,46 @@ namespace Nz Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); } - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); // Overlay shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } - unsigned int spriteChain = 0; // Quelle chaîne de sprite traitons-nous - unsigned int spriteChainOffset = 0; // À quel offset dans la dernière chaîne nous sommes-nous arrêtés + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain do { - // On ouvre le buffer en écriture + // We open the buffer in writing mode BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); unsigned int spriteCount = 0; - unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount()/4); + unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); do { ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); - std::memcpy(vertices, currentChain.vertices + spriteChainOffset*4, 4*count*sizeof(VertexStruct_XYZ_Color_UV)); - vertices += count*4; + std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); + vertices += count * 4; spriteCount += count; spriteChainOffset += count; - // Avons-nous traité la chaîne entière ? + // Have we treated the entire chain ? if (spriteChainOffset == currentChain.spriteCount) { spriteChain++; @@ -305,7 +378,7 @@ namespace Nz vertexMapper.Unmap(); - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount*6); + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); } while (spriteChain < spriteChainCount); @@ -313,12 +386,21 @@ namespace Nz } } - // On remet à zéro + // We set it back to zero matEntry.enabled = false; } } } + /*! + * \brief Draws billboards + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -342,18 +424,18 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; @@ -391,32 +473,32 @@ namespace Nz unsigned int billboardCount = billboardVector.size(); if (billboardCount > 0) { - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount()/4); + unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); do { unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); billboardCount -= renderedBillboardCount; - BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount*4); + BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); for (unsigned int i = 0; i < renderedBillboardCount; ++i) @@ -454,7 +536,7 @@ namespace Nz vertexMapper.Unmap(); - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount*6); + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); } while (billboardCount > 0); @@ -464,6 +546,15 @@ namespace Nz } } + /*! + * \brief Draws opaques models + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -483,25 +574,25 @@ namespace Nz { const Material* material = matIt.first; - // Nous utilisons de l'instancing que lorsqu'aucune lumière (autre que directionnelle) n'est active - // Ceci car l'instancing n'est pas compatible avec la recherche des lumières les plus proches - // (Le deferred shading n'a pas ce problème) + // We only use instancing when no light (other than directional) is active + // This is because instancing is not compatible with the search of nearest lights + // Deferred shading does not have this problem bool noPointSpotLight = m_renderQueue.pointLights.empty() && m_renderQueue.spotLights.empty(); bool instancing = m_instancingEnabled && (!material->IsLightingEnabled() || noPointSpotLight) && matEntry.instancingEnabled; - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; @@ -521,7 +612,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before rendering loop Renderer::DrawCall drawFunc; Renderer::DrawCallInstanced instancedDrawFunc; unsigned int indexCount; @@ -544,17 +635,17 @@ namespace Nz if (instancing) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - // Avec l'instancing, impossible de sélectionner les lumières pour chaque objet - // Du coup, il n'est activé que pour les lumières directionnelles + // With instancing, impossible to select the lights for each object + // So, it's only activated for directional lights unsigned int lightCount = m_renderQueue.directionalLights.size(); unsigned int lightIndex = 0; RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; for (unsigned int pass = 0; pass < passCount; ++pass) { if (shaderUniforms->hasLightUniforms) @@ -564,10 +655,10 @@ namespace Nz if (pass == 1) { - // Pour additionner le résultat des calculs de lumière - // Aucune chance d'interférer avec les paramètres du matériau car nous ne rendons que les objets opaques - // (Autrement dit, sans blending) - // Quant à la fonction de profondeur, elle ne doit être appliquée que la première fois + // To add the result of light computations + // We won't interfeer with materials parameters because we only render opaques objects + // (A.K.A., without blending) + // About the depth function, it must be applied only the first time Renderer::Enable(RendererParameter_Blend, true); Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); Renderer::SetDepthFunc(RendererComparison_Equal); @@ -575,32 +666,32 @@ namespace Nz // Sends the uniforms for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); + SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); - // Et on passe à l'affichage + // And we give them to draw drawFunc(meshData.primitiveMode, 0, indexCount); } const Matrix4f* instanceMatrices = &instances[0]; unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Le nombre maximum d'instances en une fois + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch while (instanceCount > 0) { - // On calcule le nombre d'instances que l'on pourra afficher cette fois-ci (Selon la taille du buffer d'instancing) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); instanceCount -= renderedInstanceCount; - // On remplit l'instancing buffer avec nos matrices world + // We fill the instancing buffer with our world matrices instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); instanceMatrices += renderedInstanceCount; - // Et on affiche + // And we draw instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); } } - // On n'oublie pas de désactiver le blending pour ne pas interférer sur le reste du rendu + // We don't forget to disable the blending to avoid to interfeer with the rest of the rendering Renderer::Enable(RendererParameter_Blend, false); Renderer::SetDepthFunc(oldDepthFunc); } @@ -617,19 +708,19 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, matrix); unsigned int lightIndex = 0; - RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // Dans le cas où nous aurions à le changer + RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount-1)/NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; for (unsigned int pass = 0; pass < passCount; ++pass) { lightCount -= std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); if (pass == 1) { - // Pour additionner le résultat des calculs de lumière - // Aucune chance d'interférer avec les paramètres du matériau car nous ne rendons que les objets opaques - // (Autrement dit, sans blending) - // Quant à la fonction de profondeur, elle ne doit être appliquée que la première fois + // To add the result of light computations + // We won't interfeer with materials parameters because we only render opaques objects + // (A.K.A., without blending) + // About the depth function, it must be applied only the first time Renderer::Enable(RendererParameter_Blend, true); Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); Renderer::SetDepthFunc(RendererComparison_Equal); @@ -639,7 +730,7 @@ namespace Nz for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); - // Et on passe à l'affichage + // And we draw drawFunc(meshData.primitiveMode, 0, indexCount); } @@ -649,9 +740,9 @@ namespace Nz } else { - // Sans instancing, on doit effectuer un draw call pour chaque instance - // Cela reste néanmoins plus rapide que l'instancing en dessous d'un certain nombre d'instances - // À cause du temps de modification du buffer d'instancing + // Without instancing, we must do a draw call for each instance + // This may be faster than instancing under a certain number + // Due to the time to modify the instancing buffer for (const Matrix4f& matrix : instances) { Renderer::SetMatrix(MatrixType_World, matrix); @@ -664,13 +755,22 @@ namespace Nz } } - // Et on remet à zéro les données + // And we set the data back to zero matEntry.enabled = false; matEntry.instancingEnabled = false; } } } + /*! + * \brief Draws transparent models + * + * \param sceneData Data of the scene + * \param layer Layer of the rendering + * + * \remark Produces a NazaraAssert is viewer is invalid + */ + void ForwardRenderTechnique::DrawTransparentModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { NazaraAssert(sceneData.viewer, "Invalid viewer"); @@ -683,25 +783,25 @@ namespace Nz { const ForwardRenderQueue::TransparentModelData& modelData = layer.transparentModelData[index]; - // Matériau + // Material const Material* material = modelData.material; - // On commence par appliquer du matériau (et récupérer le shader ainsi activé) + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; const Shader* shader = material->Apply(0, 0, &freeTextureUnit); - // Les uniformes sont conservées au sein d'un programme, inutile de les renvoyer tant qu'il ne change pas + // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) { - // Index des uniformes dans le shader + // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); - // Couleur ambiante de la scène + // Ambiant color of the scene shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position de la caméra + // Position of the camera shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // On envoie les lumières directionnelles s'il y a (Les mêmes pour tous) + // We send the directional lights if there is one (same for all) if (shaderUniforms->hasLightUniforms) { lightCount = std::min(m_renderQueue.directionalLights.size(), static_cast(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS)); @@ -720,7 +820,7 @@ namespace Nz const IndexBuffer* indexBuffer = meshData.indexBuffer; const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // Gestion du draw call avant la boucle de rendu + // Handle draw call before the rendering loop Renderer::DrawCall drawFunc; unsigned int indexCount; @@ -754,6 +854,13 @@ namespace Nz } } + /*! + * \brief Gets the shader uniforms + * \return Uniforms of the shader + * + * \param shader Shader to get uniforms from + */ + const ForwardRenderTechnique::ShaderUniforms* ForwardRenderTechnique::GetShaderUniforms(const Shader* shader) const { auto it = m_shaderUniforms.find(shader); @@ -795,6 +902,12 @@ namespace Nz return &it->second; } + /*! + * \brief Handle the invalidation of a shader + * + * \param shader Shader being invalidated + */ + void ForwardRenderTechnique::OnShaderInvalidated(const Shader* shader) const { m_shaderUniforms.erase(shader); diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index b501682bc..c9cc652a8 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -28,15 +28,29 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Graphics + * \brief Graphics class that represents the module initializer of Graphics + */ + + /*! + * \brief Initializes the Graphics module + * \return true if initialization is successful + * + * \remark Produces a NazaraNotice + * \remark Produces a NazaraError if one submodule failed + */ + bool Graphics::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; - return true; // Déjà initialisé + return true; // Already initialized } - // Initialisation des dépendances + // Initialisation of dependances if (!Renderer::Initialize()) { NazaraError("Failed to initialize Renderer module"); @@ -45,7 +59,7 @@ namespace Nz s_moduleReferenceCounter++; - // Initialisation du module + // Initialisation of the module CallOnExit onExit(Graphics::Uninitialize); if (!Material::Initialize()) @@ -96,7 +110,7 @@ namespace Nz return false; } - // Loaders génériques + // Generic loaders Loaders::RegisterMesh(); Loaders::RegisterTexture(); @@ -133,43 +147,54 @@ namespace Nz return true; } + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + bool Graphics::IsInitialized() { return s_moduleReferenceCounter != 0; } + /*! + * \brief Uninitializes the Core module + * + * \remark Produces a NazaraNotice + */ + void Graphics::Uninitialize() { if (s_moduleReferenceCounter != 1) { - // Le module est soit encore utilisé, soit pas initialisé + // The module is still in use, or can not be uninitialized if (s_moduleReferenceCounter > 1) s_moduleReferenceCounter--; return; } - // Libération du module + // Free of module s_moduleReferenceCounter = 0; - // Libération de l'atlas s'il vient de nous + // Free of atlas if it is ours std::shared_ptr defaultAtlas = Font::GetDefaultAtlas(); if (defaultAtlas && defaultAtlas->GetStorage() & DataStorage_Hardware) { Font::SetDefaultAtlas(nullptr); - // La police par défaut peut faire vivre un atlas hardware après la libération du module (ce qui va être problématique) - // du coup, si la police par défaut utilise un atlas hardware, on lui enlève. - // Je n'aime pas cette solution mais je n'en ai pas de meilleure sous la main pour l'instant + // The default police can make live one hardware atlas after the free of a module (which could be problematic) + // So, if the default police use a hardware atlas, we stole it. + // I don't like this solution, but I don't have any better if (!defaultAtlas.unique()) { - // Encore au moins une police utilise l'atlas + // Still at least one police use the atlas Font* defaultFont = Font::GetDefault(); defaultFont->SetAtlas(nullptr); if (!defaultAtlas.unique()) { - // Toujours pas seuls propriétaires ? Ah ben zut. + // Still not the only one to own it ? Then crap. NazaraWarning("Default font atlas uses hardware storage and is still used"); } } @@ -195,7 +220,7 @@ namespace Nz NazaraNotice("Uninitialized: Graphics module"); - // Libération des dépendances + // Free of dependances Renderer::Uninitialize(); } diff --git a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp index c8034d7b9..7c2122281 100644 --- a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp +++ b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp @@ -9,11 +9,32 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::GuillotineTextureAtlas + * \brief Graphics class that represents an atlas texture for guillotine + */ + + /*! + * \brief Gets the underlying data storage + * \return Value of the enumeration of the underlying data storage + */ + UInt32 GuillotineTextureAtlas::GetStorage() const { return DataStorage_Hardware; } + /*! + * \brief Resizes the image + * \return Updated texture + * + * \param oldImage Old image to resize + * \param size New image size + * + * \remark Produces a NazaraError if resize failed + */ + AbstractImage* GuillotineTextureAtlas::ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const { std::unique_ptr newTexture(new Texture); @@ -23,8 +44,8 @@ namespace Nz { Texture* oldTexture = static_cast(oldImage); - // Copie des anciennes données - ///TODO: Copie de texture à texture + // Copy of old data + ///TODO: Copy from texture to texture Image image; if (!oldTexture->Download(&image)) { @@ -43,8 +64,7 @@ namespace Nz } else { - // Si on arrive ici c'est que la taille demandée est trop grande pour la carte graphique - // ou que nous manquons de mémoire + // If we are here, it is that the size is too big for the graphic card or we don't have enough return nullptr; } } diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index 780f11a67..ef5f62b96 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -7,16 +7,43 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::InstancedRenderable + * \brief Graphics class that represents an instancer renderable + * + * \remark This class is abstract + */ + + /*! + * \brief Destructs the object and calls OnInstancedRenderableRelease + * + * \see OnInstancedRenderableRelease + */ + InstancedRenderable::~InstancedRenderable() { OnInstancedRenderableRelease(this); } + /*! + * \brief Culls the instanced if not in the frustum + * \return true If instanced is in the frustum + * + * \param frustum Symbolizing the field of view + * \param transformMatrix Matrix transformation for our object + */ + bool InstancedRenderable::Cull(const Frustumf& frustum, const InstanceData& instanceData) const { return frustum.Contains(instanceData.volume); } + /*! + * \brief Gets the bounding volume + * \return Bounding volume of the instanced + */ + const BoundingVolumef& InstancedRenderable::GetBoundingVolume() const { EnsureBoundingVolumeUpdated(); @@ -24,11 +51,30 @@ namespace Nz return m_boundingVolume; } + /*! + * \brief Invalidates data for instanced + * + * \param instanceData Pointer to data of instances + * \param flags Flags for the instances + * + * \remark Produces a NazaraAssert if instanceData is invalid + */ + void InstancedRenderable::InvalidateData(InstanceData* instanceData, UInt32 flags) const { + NazaraAssert(instanceData, "Invalid instance data"); + instanceData->flags |= flags; } + /*! + * \brief Updates the bounding volume + * + * \param instanceData Pointer to data of instances + * + * \remark Produces a NazaraAssert if instanceData is invalid + */ + void InstancedRenderable::UpdateBoundingVolume(InstanceData* instanceData) const { NazaraAssert(instanceData, "Invalid instance data"); @@ -37,6 +83,14 @@ namespace Nz instanceData->volume.Update(instanceData->transformMatrix); } + /*! + * \brief Updates the instance data + * + * \param instanceData Pointer to data of instances + * + * \remark Produces a NazaraAssert if instanceData is invalid + */ + void InstancedRenderable::UpdateData(InstanceData* instanceData) const { NazaraAssert(instanceData, "Invalid instance data"); diff --git a/src/Nazara/Graphics/Light.cpp b/src/Nazara/Graphics/Light.cpp index 14e33100b..275d78a79 100644 --- a/src/Nazara/Graphics/Light.cpp +++ b/src/Nazara/Graphics/Light.cpp @@ -13,11 +13,23 @@ #include #include -///TODO: Utilisation des UBOs +///TODO: Use of UBOs ///TODO: Scale ? namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Light + * \brief Graphics class that represents a light + */ + + /*! + * \brief Constructs a Light object with a type + * + * \param type Type of the light + */ + Light::Light(LightType type) : m_type(type), m_shadowMapFormat(PixelFormatType_Depth16), @@ -34,6 +46,15 @@ namespace Nz SetRadius(5.f); } + /*! + * \brief Adds this light to the render queue + * + * \param renderQueue Queue to be added + * \param transformMatrix Matrix transformation for this light + * + * \remark Produces a NazaraError if type is invalid + */ + void Light::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const { static Matrix4f biasMatrix(0.5f, 0.f, 0.f, 0.f, @@ -100,16 +121,36 @@ namespace Nz } } + /*! + * \brief Clones this light + * \return Pointer to newly allocated Light + */ + Light* Light::Clone() const { return new Light(*this); } + /*! + * \brief Creates a default light + * \return Pointer to newly allocated light + */ + Light* Light::Create() const { return new Light; } + /*! + * \brief Culls the light if not in the frustum + * \return true If light is in the frustum + * + * \param frustum Symbolizing the field of view + * \param transformMatrix Matrix transformation for our object + * + * \remark Produces a NazaraError if type is invalid + */ + bool Light::Cull(const Frustumf& frustum, const Matrix4f& transformMatrix) const { switch (m_type) @@ -128,6 +169,14 @@ namespace Nz return false; } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + * + * \remark Produces a NazaraError if type is invalid + */ + void Light::UpdateBoundingVolume(const Matrix4f& transformMatrix) { switch (m_type) @@ -149,6 +198,12 @@ namespace Nz } } + /* + * \brief Makes the bounding volume of this light + * + * \remark Produces a NazaraError if type is invalid + */ + void Light::MakeBoundingVolume() const { switch (m_type) @@ -166,19 +221,19 @@ namespace Nz case LightType_Spot: { - // On forme une boite sur l'origine + // We make a box center in the origin Boxf box(Vector3f::Zero()); - // On calcule le reste des points - Vector3f base(Vector3f::Forward()*m_radius); + // We compute the other points + Vector3f base(Vector3f::Forward() * m_radius); - // Il nous faut maintenant le rayon du cercle projeté à cette distance - // Tangente = Opposé/Adjaçent <=> Opposé = Adjaçent*Tangente + // Now we need the radius of the projected circle depending on the distance + // Tangent = Opposite/Adjacent <=> Opposite = Adjacent * Tangent float radius = m_radius * m_outerAngleTangent; - Vector3f lExtend = Vector3f::Left()*radius; - Vector3f uExtend = Vector3f::Up()*radius; + Vector3f lExtend = Vector3f::Left() * radius; + Vector3f uExtend = Vector3f::Up() * radius; - // Et on ajoute ensuite les quatres extrémités de la pyramide + // And we add the four extremities of our pyramid box.ExtendTo(base + lExtend + uExtend); box.ExtendTo(base + lExtend - uExtend); box.ExtendTo(base - lExtend + uExtend); @@ -194,6 +249,10 @@ namespace Nz } } + /*! + * \brief Updates the shadow map + */ + void Light::UpdateShadowMap() const { if (m_shadowCastingEnabled) diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 44ec0310d..24323960d 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #ifndef NAZARA_RENDERER_OPENGL -#define NAZARA_RENDERER_OPENGL // Nécessaire pour inclure les headers OpenGL +#define NAZARA_RENDERER_OPENGL // Mandatory to include the OpenGL headers #endif #include @@ -36,6 +36,17 @@ namespace Nz }; } + /*! + * \ingroup graphics + * \class Nz::Material + * \brief Graphics class that represents a material + */ + + /*! + * \brief Checks whether the parameters for the material are correct + * \return true If parameters are valid + */ + bool MaterialParams::IsValid() const { if (!UberShaderLibrary::Has(shaderName)) @@ -44,6 +55,15 @@ namespace Nz return true; } + /*! + * \brief Applies shader to the material + * \return Constant pointer to the shader + * + * \param shaderFlags Flags for the shader + * \param textureUnit Unit for the texture GL_TEXTURE"i" + * \param lastUsedUnit Optional argument to get the last texture unit + */ + const Shader* Material::Apply(UInt32 shaderFlags, UInt8 textureUnit, UInt8* lastUsedUnit) const { const ShaderInstance& instance = m_shaders[shaderFlags]; @@ -123,6 +143,13 @@ namespace Nz return instance.shader; } + /*! + * \brief Builds the material from parameters + * + * \param matData Data information for the material + * \param matParams Parameters for the material + */ + void Material::BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams) { Color color; @@ -283,6 +310,10 @@ namespace Nz SetShader(matParams.shaderName); } + /*! + * \brief Resets the material, cleans everything + */ + void Material::Reset() { OnMaterialReset(this); @@ -319,9 +350,15 @@ namespace Nz SetShader("Basic"); } + /*! + * \brief Copies the other material + * + * \param material Material to copy into this + */ + void Material::Copy(const Material& material) { - // Copie des états de base + // Copy of base states m_alphaTestEnabled = material.m_alphaTestEnabled; m_alphaThreshold = material.m_alphaThreshold; m_ambientColor = material.m_ambientColor; @@ -337,7 +374,7 @@ namespace Nz m_states = material.m_states; m_transformEnabled = material.m_transformEnabled; - // Copie des références de texture + // Copy of reference to the textures m_alphaMap = material.m_alphaMap; m_depthMaterial = material.m_depthMaterial; m_diffuseMap = material.m_diffuseMap; @@ -347,10 +384,16 @@ namespace Nz m_specularMap = material.m_specularMap; m_uberShader = material.m_uberShader; - // On copie les instances de shader par la même occasion - std::memcpy(&m_shaders[0], &material.m_shaders[0], (ShaderFlags_Max+1)*sizeof(ShaderInstance)); + // We copy the instances of the shader too + std::memcpy(&m_shaders[0], &material.m_shaders[0], (ShaderFlags_Max + 1) * sizeof(ShaderInstance)); } + /*! + * \brief Generates the shader based on flag + * + * \param flags Flag for the shaer + */ + void Material::GenerateShader(UInt32 flags) const { ParameterList list; @@ -396,6 +439,13 @@ namespace Nz #undef CacheUniform } + /*! + * \brief Initializes the material librairies + * \return true If successful + * + * \remark Produces a NazaraError if the material library failed to be initialized + */ + bool Material::Initialize() { if (!MaterialLibrary::Initialize()) @@ -462,6 +512,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the material librairies + */ + void Material::Uninitialize() { s_defaultMaterial.Reset(); diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index e8954a886..d382c77d9 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -12,11 +12,26 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Model + * \brief Graphics class that represents a model + */ + + /*! + * \brief Constructs a ModelParameters object by default + */ + ModelParameters::ModelParameters() { material.shaderName = "PhongLighting"; } + /*! + * \brief Checks whether the parameters for the model are correct + * \return true If parameters are valid + */ + bool ModelParameters::IsValid() const { if (loadMaterials && !material.IsValid()) @@ -25,6 +40,10 @@ namespace Nz return mesh.IsValid(); } + /*! + * \brief Constructs a Model object by default + */ + Model::Model() : m_matCount(0), m_skin(0), @@ -32,11 +51,24 @@ namespace Nz { } + /*! + * \brief Destructs the object and calls Reset + * + * \see Reset + */ + Model::~Model() { Reset(); } + /*! + * \brief Adds this model to the render queue + * + * \param renderQueue Queue to be added + * \param instanceData Data used for this instance + */ + void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { unsigned int submeshCount = m_mesh->GetSubMeshCount(); @@ -54,6 +86,17 @@ namespace Nz } } + /*! + * \brief Gets the material of the named submesh + * \return Pointer to the current material + * + * \param subMeshName Name of the subMesh + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material is invalid + */ + Material* Model::GetMaterial(const String& subMeshName) const { #if NAZARA_GRAPHICS_SAFE @@ -78,9 +121,18 @@ namespace Nz return nullptr; } - return m_materials[m_skin*m_matCount + matIndex]; + return m_materials[m_skin * m_matCount + matIndex]; } + /*! + * \brief Gets the material by index + * \return Pointer to the current material + * + * \param matIndex Index of the material + * + * \remark Produces a NazaraError if index is invalid + */ + Material* Model::GetMaterial(unsigned int matIndex) const { #if NAZARA_GRAPHICS_SAFE @@ -91,9 +143,21 @@ namespace Nz } #endif - return m_materials[m_skin*m_matCount + matIndex]; + return m_materials[m_skin * m_matCount + matIndex]; } + /*! + * \brief Gets the material by index of the named submesh + * \return Pointer to the current material + * + * \param skinIndex Index of the skin + * \param subMeshName Name of the subMesh + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material index is invalid + */ + Material* Model::GetMaterial(unsigned int skinIndex, const String& subMeshName) const { #if NAZARA_GRAPHICS_SAFE @@ -118,9 +182,20 @@ namespace Nz return nullptr; } - return m_materials[skinIndex*m_matCount + matIndex]; + return m_materials[skinIndex * m_matCount + matIndex]; } + /*! + * \brief Gets the material by index with skin + * \return Pointer to the current material + * + * \param skinIndex Index of the skin + * \param matIndex Index of the material + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if matIndex is invalid + */ + Material* Model::GetMaterial(unsigned int skinIndex, unsigned int matIndex) const { #if NAZARA_GRAPHICS_SAFE @@ -137,49 +212,103 @@ namespace Nz } #endif - return m_materials[skinIndex*m_matCount + matIndex]; + return m_materials[skinIndex * m_matCount + matIndex]; } + /*! + * \brief Gets the number of materials + * \return Current number of materials + */ + unsigned int Model::GetMaterialCount() const { return m_matCount; } + /*! + * \brief Gets the mesh + * \return Current mesh + */ + Mesh* Model::GetMesh() const { return m_mesh; } + /*! + * \brief Gets the skin + * \return Current skin + */ + unsigned int Model::GetSkin() const { return m_skin; } + /*! + * \brief Gets the number of skins + * \return Current number of skins + */ + unsigned int Model::GetSkinCount() const { return m_skinCount; } + /*! + * \brief Checks whether the model is animated + * \return false + */ + bool Model::IsAnimated() const { return false; } + /*! + * \brief Loads the model from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the model + */ + bool Model::LoadFromFile(const String& filePath, const ModelParameters& params) { return ModelLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the model from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the model + */ + bool Model::LoadFromMemory(const void* data, std::size_t size, const ModelParameters& params) { return ModelLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the model from stream + * \return true if loading is successful + * + * \param stream Stream to the model + * \param params Parameters for the model + */ + bool Model::LoadFromStream(Stream& stream, const ModelParameters& params) { return ModelLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Resets the model, cleans everything + */ + void Model::Reset() { m_matCount = 0; @@ -192,6 +321,17 @@ namespace Nz } } + /*! + * \brief Sets the material of the named submesh + * \return true If successful + * + * \param subMeshName Name of the subMesh + * \param material Pointer to the material + * + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material index is invalid + */ + bool Model::SetMaterial(const String& subMeshName, Material* material) { SubMesh* subMesh = m_mesh->GetSubMesh(subMeshName); @@ -208,7 +348,7 @@ namespace Nz return false; } - unsigned int index = m_skin*m_matCount + matIndex; + unsigned int index = m_skin * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -218,6 +358,16 @@ namespace Nz return true; } + /*! + * \brief Sets the material by index + * \return true If successful + * + * \param matIndex Index of the material + * \param material Pointer to the material + * + * \remark Produces a NazaraError with if NAZARA_GRAPHICS_SAFE defined index is invalid + */ + void Model::SetMaterial(unsigned int matIndex, Material* material) { #if NAZARA_GRAPHICS_SAFE @@ -228,7 +378,7 @@ namespace Nz } #endif - unsigned int index = m_skin*m_matCount + matIndex; + unsigned int index = m_skin * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -236,6 +386,19 @@ namespace Nz m_materials[index] = Material::GetDefault(); } + /*! + * \brief Sets the material by index of the named submesh + * \return true If successful + * + * \param skinIndex Index of the skin + * \param subMeshName Name of the subMesh + * \param material Pointer to the material + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError if there is no subMesh with that name + * \remark Produces a NazaraError if material index is invalid + */ + bool Model::SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material) { #if NAZARA_GRAPHICS_SAFE @@ -260,7 +423,7 @@ namespace Nz return false; } - unsigned int index = skinIndex*m_matCount + matIndex; + unsigned int index = skinIndex * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -270,6 +433,18 @@ namespace Nz return true; } + /*! + * \brief Sets the material by index with skin + * \return true If successful + * + * \param skinIndex Index of the skin + * \param matIndex Index of the material + * \param material Pointer to the material + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skinIndex is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if matIndex is invalid + */ + void Model::SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material) { #if NAZARA_GRAPHICS_SAFE @@ -286,7 +461,7 @@ namespace Nz } #endif - unsigned int index = skinIndex*m_matCount + matIndex; + unsigned int index = skinIndex * m_matCount + matIndex; if (material) m_materials[index] = material; @@ -294,6 +469,14 @@ namespace Nz m_materials[index] = Material::GetDefault(); } + /*! + * \brief Sets the mesh + * + * \param pointer to the mesh + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if mesh is invalid + */ + void Model::SetMesh(Mesh* mesh) { #if NAZARA_GRAPHICS_SAFE @@ -323,6 +506,14 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Sets the skin + * + * \param skin Skin to use + * + * \remark Produces a NazaraError if skin is invalid + */ + void Model::SetSkin(unsigned int skin) { #if NAZARA_GRAPHICS_SAFE @@ -336,6 +527,14 @@ namespace Nz m_skin = skin; } + /*! + * \brief Sets the number of skins + * + * \param skinCount Number of skins + * + * \remark Produces a NazaraError if skinCount equals zero + */ + void Model::SetSkinCount(unsigned int skinCount) { #if NAZARA_GRAPHICS_SAFE @@ -350,6 +549,10 @@ namespace Nz m_skinCount = skinCount; } + /* + * \brief Makes the bounding volume of this billboard + */ + void Model::MakeBoundingVolume() const { if (m_mesh) diff --git a/src/Nazara/Graphics/ParticleController.cpp b/src/Nazara/Graphics/ParticleController.cpp index 252887246..d46bb1621 100644 --- a/src/Nazara/Graphics/ParticleController.cpp +++ b/src/Nazara/Graphics/ParticleController.cpp @@ -7,17 +7,44 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleController + * \brief Graphics class which controls a flow of particles + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a ParticleController object by assignation + * + * \param controller ParticleController to copy into this + */ + ParticleController::ParticleController(const ParticleController& controller) : RefCounted() { NazaraUnused(controller); } + /*! + * \brief Destructs the object and calls OnParticleControllerRelease + * + * \see OnParticleControllerRelease + */ + ParticleController::~ParticleController() { OnParticleControllerRelease(this); } + /*! + * \brief Initializes the particle controller librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle controller library failed to be initialized + */ + bool ParticleController::Initialize() { if (!ParticleControllerLibrary::Initialize()) @@ -29,6 +56,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle controller librairies + */ + void ParticleController::Uninitialize() { ParticleControllerLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index 8d68b88ce..ecd09c752 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -15,23 +15,54 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleDeclaration + * \brief Graphics class that represents the declaration of the particle, works like an ECS + */ + + /*! + * \brief Constructs a ParticleDeclaration object by default + */ + ParticleDeclaration::ParticleDeclaration() : m_stride(0) { } + /*! + * \brief Constructs a ParticleDeclaration object by assignation + * + * \param declaration ParticleDeclaration to copy into this + */ + ParticleDeclaration::ParticleDeclaration(const ParticleDeclaration& declaration) : RefCounted(), m_stride(declaration.m_stride) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(ParticleComponent_Max+1)); + std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); } + /*! + * \brief Destructs the object and calls OnParticleDeclarationRelease + * + * \see OnParticleDeclarationRelease + */ + ParticleDeclaration::~ParticleDeclaration() { OnParticleDeclarationRelease(this); } + /*! + * \brief Disables a component + * + * \param component Component to disable in the declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG defined if enumeration is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if enumeration is equal to ParticleComponent_Unused + */ + void ParticleDeclaration::DisableComponent(ParticleComponent component) { #ifdef NAZARA_DEBUG @@ -58,6 +89,17 @@ namespace Nz } } + /*! + * \brief Enables a component + * + * \param component Component to enable in the declaration + * \param type Type of this component + * \param offset Offset in the declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG defined if enumeration is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if type is not supported + */ + void ParticleDeclaration::EnableComponent(ParticleComponent component, ComponentType type, unsigned int offset) { #ifdef NAZARA_DEBUG @@ -91,6 +133,18 @@ namespace Nz m_stride += Utility::ComponentStride[type]; } + /*! + * \brief Gets a component + * + * \param component Component in the declaration + * \param enabled Optional argument to get if this component is enabled + * \param type Optional argument to get if the type of the component + * \param offset Optional argument to get if the offset in the declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG defined if enumeration is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if enumeration is equal to ParticleComponent_Unused + */ + void ParticleDeclaration::GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, unsigned int* offset) const { #ifdef NAZARA_DEBUG @@ -121,24 +175,51 @@ namespace Nz *offset = particleComponent.offset; } + /*! + * \brief Gets the stride of the declaration + * \return Stride of the declaration + */ + unsigned int ParticleDeclaration::GetStride() const { return m_stride; } + /*! + * \brief Sets the stride of the declaration + * + * \param stride Stride of the declaration + */ + void ParticleDeclaration::SetStride(unsigned int stride) { m_stride = stride; } + /*! + * \brief Sets the current particle declaration with the content of the other one + * \return A reference to this + * + * \param declaration The other ParticleDeclaration + */ + ParticleDeclaration& ParticleDeclaration::operator=(const ParticleDeclaration& declaration) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(ParticleComponent_Max+1)); + std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); m_stride = declaration.m_stride; return *this; } + /*! + * \brief Gets the particle declaration based on the layout + * \return Pointer to the declaration + * + * \param layout Layout of the particle declaration + * + * \remark Produces a NazaraError with NAZARA_DEBUG if enumeration is invalid + */ + ParticleDeclaration* ParticleDeclaration::Get(ParticleLayout layout) { #ifdef NAZARA_DEBUG @@ -152,6 +233,15 @@ namespace Nz return &s_declarations[layout]; } + /*! + * \brief Checks whether the type is supported + * \return true If it is the case + * + * \param type Type of the component + * + * \remark Produces a NazaraError if enumeration is invalid + */ + bool ParticleDeclaration::IsTypeSupported(ComponentType type) { switch (type) @@ -177,6 +267,14 @@ namespace Nz return false; } + /*! + * \brief Initializes the particle declaration librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle declaration library failed to be initialized + * \remark Produces a NazaraAssert if memory layout of declaration does not match the corresponding structure + */ + bool ParticleDeclaration::Initialize() { if (!ParticleDeclarationLibrary::Initialize()) @@ -231,11 +329,15 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle declaration librairies + */ + void ParticleDeclaration::Uninitialize() { ParticleDeclarationLibrary::Uninitialize(); } - ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max+1]; + ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max + 1]; ParticleDeclarationLibrary::LibraryMap ParticleDeclaration::s_library; } diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index 9e87eb7c0..ded77d80e 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -14,6 +14,16 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleEmitter + * \brief Graphics class that represents an emitter of particles + */ + + /*! + * \brief Constructs a ParticleEmitter object by default + */ + ParticleEmitter::ParticleEmitter() : m_lagCompensationEnabled(false), m_emissionAccumulator(0.f), @@ -24,28 +34,35 @@ namespace Nz ParticleEmitter::~ParticleEmitter() = default; + /*! + * \brief Emits particles according to the delta time between the previous frame + * + * \param system Particle system to work on + * \param elapsedTime Delta time between the previous frame + */ + void ParticleEmitter::Emit(ParticleSystem& system, float elapsedTime) const { if (m_emissionRate > 0.f) { - // On accumule la partie réelle (pour éviter qu'un taux d'update élevé empêche des particules de se former) - m_emissionAccumulator += elapsedTime*m_emissionRate; + // We accumulate the real part (to avoid that a high emission rate prevents particles to form) + m_emissionAccumulator += elapsedTime * m_emissionRate; - float emissionCount = std::floor(m_emissionAccumulator); // Le nombre d'émissions de cette mise à jour - m_emissionAccumulator -= emissionCount; // On enlève la partie entière + float emissionCount = std::floor(m_emissionAccumulator); // The number of emissions in this update + m_emissionAccumulator -= emissionCount; // We get rid off the integer part if (emissionCount >= 1.f) { - // On calcule le nombre maximum de particules pouvant être émises cette fois-ci + // We compute the maximum number of particles which can be emitted unsigned int emissionCountInt = static_cast(emissionCount); - unsigned int maxParticleCount = emissionCountInt*m_emissionCount; + unsigned int maxParticleCount = emissionCountInt * m_emissionCount; - // On récupère le nombre de particules qu'il est possible de créer selon l'espace libre + // We get the number of particles that we are able to create (depending on the free space) unsigned int particleCount = std::min(maxParticleCount, system.GetMaxParticleCount() - system.GetParticleCount()); if (particleCount == 0) return; - // Et on émet nos particules + // And we emit our particles void* particles = system.GenerateParticles(particleCount); ParticleMapper mapper(particles, system.GetDeclaration()); @@ -53,40 +70,73 @@ namespace Nz if (m_lagCompensationEnabled) { - // On va maintenant appliquer les contrôleurs - float invEmissionRate = 1.f/m_emissionRate; + // We will now apply our controllers + float invEmissionRate = 1.f / m_emissionRate; for (unsigned int i = 1; i <= emissionCountInt; ++i) - system.ApplyControllers(mapper, std::min(m_emissionCount*i, particleCount), invEmissionRate); + system.ApplyControllers(mapper, std::min(m_emissionCount * i, particleCount), invEmissionRate); } } } } + /*! + * \brief Enables the lag compensation + * + * \param enable Should lag compensation be enabled + */ + void ParticleEmitter::EnableLagCompensation(bool enable) { m_lagCompensationEnabled = enable; } + /*! + * \brief Gets the emission count + * \return Current emission count + */ + unsigned int ParticleEmitter::GetEmissionCount() const { return m_emissionCount; } + /*! + * \brief Gets the emission rate + * \return Current emission rate + */ + float ParticleEmitter::GetEmissionRate() const { return m_emissionRate; } + /*! + * \brief Checks whether the lag compensation is enabled + * \return true If it is the case + */ + bool ParticleEmitter::IsLagCompensationEnabled() const { return m_lagCompensationEnabled; } + /*! + * \brief Sets the emission count + * + * \param count Emission count + */ + void ParticleEmitter::SetEmissionCount(unsigned int count) { m_emissionCount = count; } + /*! + * \brief Sets the emission rate + * + * \param rate Emission rate + */ + void ParticleEmitter::SetEmissionRate(float rate) { m_emissionRate = rate; diff --git a/src/Nazara/Graphics/ParticleGenerator.cpp b/src/Nazara/Graphics/ParticleGenerator.cpp index d5e3b80ff..304a99e8c 100644 --- a/src/Nazara/Graphics/ParticleGenerator.cpp +++ b/src/Nazara/Graphics/ParticleGenerator.cpp @@ -7,17 +7,44 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleGenerator + * \brief Graphics class which generates particles + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a ParticleGenerator object by assignation + * + * \param generator ParticleGenerator to copy into this + */ + ParticleGenerator::ParticleGenerator(const ParticleGenerator& generator) : RefCounted() { NazaraUnused(generator); } + /*! + * \brief Destructs the object and calls OnParticleGeneratorRelease + * + * \see OnParticleGeneratorRelease + */ + ParticleGenerator::~ParticleGenerator() { OnParticleGeneratorRelease(this); } + /*! + * \brief Initializes the particle generator librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle generator library failed to be initialized + */ + bool ParticleGenerator::Initialize() { if (!ParticleGeneratorLibrary::Initialize()) @@ -29,6 +56,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle generator librairies + */ + void ParticleGenerator::Uninitialize() { ParticleGeneratorLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/ParticleMapper.cpp b/src/Nazara/Graphics/ParticleMapper.cpp index ce883e6e0..27a4b4075 100644 --- a/src/Nazara/Graphics/ParticleMapper.cpp +++ b/src/Nazara/Graphics/ParticleMapper.cpp @@ -8,6 +8,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleMapper + * \brief Graphics class that represents the mapping between the internal buffer and the particle declaration + */ + + /*! + * \brief Constructs a ParticleMapper object with a raw buffer and a particle declaration + * + * \param buffer Raw buffer to store particles data + * \param declaration Declaration of the particle + */ + ParticleMapper::ParticleMapper(void* buffer, const ParticleDeclaration* declaration) : m_declaration(declaration), m_ptr(static_cast(buffer)) diff --git a/src/Nazara/Graphics/ParticleRenderer.cpp b/src/Nazara/Graphics/ParticleRenderer.cpp index 96ff3dd8a..e5fa56c74 100644 --- a/src/Nazara/Graphics/ParticleRenderer.cpp +++ b/src/Nazara/Graphics/ParticleRenderer.cpp @@ -7,17 +7,42 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleRenderer + * \brief Graphics class that represents the rendering of the particle + */ + + /*! + * \brief Constructs a ParticleRenderer object by assignation + * + * \param renderer ParticleRenderer to copy into this + */ + ParticleRenderer::ParticleRenderer(const ParticleRenderer& renderer) : RefCounted() { NazaraUnused(renderer); } + /*! + * \brief Destructs the object and calls OnParticleRendererRelease + * + * \see OnParticleRendererRelease + */ + ParticleRenderer::~ParticleRenderer() { OnParticleRendererRelease(this); } + /*! + * \brief Initializes the particle renderer librairies + * \return true If successful + * + * \remark Produces a NazaraError if the particle renderer library failed to be initialized + */ + bool ParticleRenderer::Initialize() { if (!ParticleRendererLibrary::Initialize()) @@ -29,6 +54,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the particle renderer librairies + */ + void ParticleRenderer::Uninitialize() { ParticleRendererLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/ParticleSystem.cpp b/src/Nazara/Graphics/ParticleSystem.cpp index 2ac54e4af..0783dd7fd 100644 --- a/src/Nazara/Graphics/ParticleSystem.cpp +++ b/src/Nazara/Graphics/ParticleSystem.cpp @@ -13,25 +13,51 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::ParticleSystem + * \brief Graphics class that represents the system to handle particles + */ + + /*! + * \brief Constructs a ParticleSystem object with a maximal number of particles and a layout + * + * \param maxParticleCount Maximum number of particles to generate + * \param layout Enumeration for the layout of data information for the particles + */ + ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout) : ParticleSystem(maxParticleCount, ParticleDeclaration::Get(layout)) { } + /*! + * \brief Constructs a ParticleSystem object with a maximal number of particles and a particle declaration + * + * \param maxParticleCount Maximum number of particles to generate + * \param declaration Data information for the particles + */ + ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : m_declaration(std::move(declaration)), m_processing(false), m_maxParticleCount(maxParticleCount), m_particleCount(0) { - // En cas d'erreur, un constructeur ne peut que lancer une exception + // In case of error, the constructor can only throw an exception ErrorFlags flags(ErrorFlag_ThrowException, true); - m_particleSize = m_declaration->GetStride(); // La taille de chaque particule + m_particleSize = m_declaration->GetStride(); // The size of each particle ResizeBuffer(); } + /*! + * \brief Constructs a ParticleSystem object by assignation + * + * \param system ParticleSystem to copy into this + */ + ParticleSystem::ParticleSystem(const ParticleSystem& system) : Renderable(system), m_controllers(system.m_controllers), @@ -47,12 +73,20 @@ namespace Nz ResizeBuffer(); - // On ne copie que les particules vivantes + // We only copy alive particles std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); } ParticleSystem::~ParticleSystem() = default; + /*! + * \brief Adds a controller to the particles + * + * \param controller Controller for the particles + * + * \remark Produces a NazaraAssert if controller is invalid + */ + void ParticleSystem::AddController(ParticleControllerRef controller) { NazaraAssert(controller, "Invalid particle controller"); @@ -60,6 +94,14 @@ namespace Nz m_controllers.emplace_back(std::move(controller)); } + /*! + * \brief Adds an emitter to the particles + * + * \param emitter Emitter for the particles + * + * \remark Produces a NazaraAssert if emitter is invalid + */ + void ParticleSystem::AddEmitter(ParticleEmitter* emitter) { NazaraAssert(emitter, "Invalid particle emitter"); @@ -67,6 +109,14 @@ namespace Nz m_emitters.emplace_back(emitter); } + /*! + * \brief Adds a generator to the particles + * + * \param generator Generator for the particles + * + * \remark Produces a NazaraAssert if generator is invalid + */ + void ParticleSystem::AddGenerator(ParticleGeneratorRef generator) { NazaraAssert(generator, "Invalid particle generator"); @@ -74,6 +124,16 @@ namespace Nz m_generators.emplace_back(std::move(generator)); } + /*! + * \brief Adds the particle system to the rendering queue + * + * \param renderQueue Queue to be added + * \param transformMatrix Transformation matrix for the system + * + * \remark Produces a NazaraAssert if inner renderer is invalid + * \remark Produces a NazaraAssert if renderQueue is invalid + */ + void ParticleSystem::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const { NazaraAssert(m_renderer, "Invalid particle renderer"); @@ -83,45 +143,63 @@ namespace Nz if (m_particleCount > 0) { ParticleMapper mapper(m_buffer.data(), m_declaration); - m_renderer->Render(*this, mapper, 0, m_particleCount-1, renderQueue); + m_renderer->Render(*this, mapper, 0, m_particleCount - 1, renderQueue); } } + /*! + * \brief Applies the controllers + * + * \param mapper Mapper containing layout information of each particle + * \param particleCount Number of particles + * \param elapsedTime Delta time between the previous frame + */ + void ParticleSystem::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) { m_processing = true; - // Pour éviter un verrouillage en cas d'exception + // To avoid a lock in case of exception CallOnExit onExit([this]() { m_processing = false; }); for (ParticleController* controller : m_controllers) - controller->Apply(*this, mapper, 0, particleCount-1, elapsedTime); + controller->Apply(*this, mapper, 0, particleCount - 1, elapsedTime); onExit.CallAndReset(); - // On tue maintenant les particules mortes durant la mise à jour + // We only kill now the dead particles during the update if (m_dyingParticles.size() < m_particleCount) { - // On tue les particules depuis la dernière vers la première (en terme de place), le std::set étant trié via std::greater - // La raison est simple, étant donné que la mort d'une particule signifie le déplacement de la dernière particule du buffer, - // sans cette solution certaines particules pourraient échapper à la mort + // We kill them in reverse order, std::set sorting them via std::greater + // The reason is simple, as the death of a particle means the move of the last particle in the buffer, + // without this solution, certain particles could avoid the death for (unsigned int index : m_dyingParticles) KillParticle(index); } else - KillParticles(); // Toutes les particules sont mortes, ceci est beaucoup plus rapide + KillParticles(); // Every particles are dead, this is way faster m_dyingParticles.clear(); } + /*! + * \brief Creates one particle + * \return Pointer to the particle memory buffer + */ + void* ParticleSystem::CreateParticle() { return CreateParticles(1); } + /*! + * \brief Creates multiple particles + * \return Pointer to the first particle memory buffer + */ + void* ParticleSystem::CreateParticles(unsigned int count) { if (count == 0) @@ -133,14 +211,24 @@ namespace Nz unsigned int particlesIndex = m_particleCount; m_particleCount += count; - return &m_buffer[particlesIndex*m_particleSize]; + return &m_buffer[particlesIndex * m_particleSize]; } + /*! + * \brief Generates one particle + * \return Pointer to the particle memory buffer + */ + void* ParticleSystem::GenerateParticle() { return GenerateParticles(1); } + /*! + * \brief Generates multiple particles + * \return Pointer to the first particle memory buffer + */ + void* ParticleSystem::GenerateParticles(unsigned int count) { void* ptr = CreateParticles(count); @@ -149,57 +237,108 @@ namespace Nz ParticleMapper mapper(ptr, m_declaration); for (ParticleGenerator* generator : m_generators) - generator->Generate(*this, mapper, 0, count-1); + generator->Generate(*this, mapper, 0, count - 1); return ptr; } + /*! + * \brief Gets the particle declaration + * \return Particle declaration + */ + const ParticleDeclarationConstRef& ParticleSystem::GetDeclaration() const { return m_declaration; } + /*! + * \brief Gets the fixed step size + * \return Current fixed step size + */ + float ParticleSystem::GetFixedStepSize() const { return m_stepSize; } + /*! + * \brief Gets the maximum number of particles + * \return Current maximum number + */ + unsigned int ParticleSystem::GetMaxParticleCount() const { return m_maxParticleCount; } + /*! + * \brief Gets the number of particles + * \return Current number + */ + unsigned int ParticleSystem::GetParticleCount() const { return m_particleCount; } + /*! + * \brief Gets the size of particles + * \return Current size + */ + unsigned int ParticleSystem::GetParticleSize() const { return m_particleSize; } + /*! + * \brief Checks whether the fixed step is enabled + * \return true If it is the case + */ + + bool ParticleSystem::IsFixedStepEnabled() const + { + return m_fixedStepEnabled; + } + + /*! + * \brief Kills one particle + * + * \param index Index of the particle + */ + void ParticleSystem::KillParticle(unsigned int index) { - ///FIXME: Vérifier index + ///FIXME: Verify the index if (m_processing) { - // Le buffer est en train d'être modifié, nous ne pouvons pas réduire sa taille, on place alors la particule dans une liste d'attente + // The buffer is being modified, we can not reduce its size, we put the particle in the waiting list m_dyingParticles.insert(index); return; } - // On déplace la dernière particule vivante à la place de celle-ci + // We move the last alive particle to the place of this one if (--m_particleCount > 0) - std::memcpy(&m_buffer[index*m_particleSize], &m_buffer[m_particleCount*m_particleSize], m_particleSize); + std::memcpy(&m_buffer[index * m_particleSize], &m_buffer[m_particleCount * m_particleSize], m_particleSize); } + /*! + * \brief Kills every particles + */ + void ParticleSystem::KillParticles() { m_particleCount = 0; } + /*! + * \brief Removes a controller to the particles + * + * \param controller Controller for the particles to remove + */ + void ParticleSystem::RemoveController(ParticleController* controller) { auto it = std::find(m_controllers.begin(), m_controllers.end(), controller); @@ -207,6 +346,12 @@ namespace Nz m_controllers.erase(it); } + /*! + * \brief Removes an emitter to the particles + * + * \param emitter Emitter for the particles to remove + */ + void ParticleSystem::RemoveEmitter(ParticleEmitter* emitter) { auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter); @@ -214,6 +359,12 @@ namespace Nz m_emitters.erase(it); } + /*! + * \brief Removes a generator to the particles + * + * \param generator Generator for the particles to remove + */ + void ParticleSystem::RemoveGenerator(ParticleGenerator* generator) { auto it = std::find(m_generators.begin(), m_generators.end(), generator); @@ -221,31 +372,55 @@ namespace Nz m_generators.erase(it); } + /*! + * \brief Sets the fixed step size + * + * \param stepSize Fixed step size + */ + void ParticleSystem::SetFixedStepSize(float stepSize) { m_stepSize = stepSize; } + /*! + * \brief Sets the renderer of the particles + * + * \param renderer Renderer for the particles + */ + void ParticleSystem::SetRenderer(ParticleRenderer* renderer) { m_renderer = renderer; } + /*! + * \brief Updates the system + * + * \param elapsedTime Delta time between the previous frame + */ + void ParticleSystem::Update(float elapsedTime) { - // Émission + // Emission for (ParticleEmitter* emitter : m_emitters) emitter->Emit(*this, elapsedTime); - // Mise à jour + // Update if (m_particleCount > 0) { - ///TODO: Mettre à jour en utilisant des threads + ///TODO: Update using threads ParticleMapper mapper(m_buffer.data(), m_declaration); ApplyControllers(mapper, m_particleCount, elapsedTime); } } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + */ + void ParticleSystem::UpdateBoundingVolume(const Matrix4f& transformMatrix) { NazaraUnused(transformMatrix); @@ -253,6 +428,13 @@ namespace Nz // Nothing to do here (our bounding volume is global) } + /*! + * \brief Sets the current particle system with the content of the other one + * \return A reference to this + * + * \param system The other ParticleSystem + */ + ParticleSystem& ParticleSystem::operator=(const ParticleSystem& system) { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -268,29 +450,39 @@ namespace Nz m_renderer = system.m_renderer; m_stepSize = system.m_stepSize; - // La copie ne peut pas (ou plutôt ne devrait pas) avoir lieu pendant une mise à jour, inutile de copier + // The copy can not (or should not) happen during the update, there is no use to copy m_dyingParticles.clear(); m_processing = false; m_stepAccumulator = 0.f; - m_buffer.clear(); // Pour éviter une recopie lors du resize() qui ne servira pas à grand chose + m_buffer.clear(); // To avoid a copy due to resize() which will be pointless ResizeBuffer(); - // On ne copie que les particules vivantes - std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); + // We only copy alive particles + std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount * m_particleSize); return *this; } + /*! + * \brief Makes the bounding volume of this text + */ + void ParticleSystem::MakeBoundingVolume() const { - ///TODO: Calculer l'AABB (prendre la taille des particules en compte s'il y a) + ///TODO: Compute the AABB (taking into account the size of particles) m_boundingVolume.MakeInfinite(); } + /*! + * \brief Resizes the internal buffer + * + * \remark Produces a NazaraError if resize did not work + */ + void ParticleSystem::ResizeBuffer() { - // Histoire de décrire un peu mieux l'erreur en cas d'échec + // Just to have a better description of our problem in case of error try { m_buffer.resize(m_maxParticleCount*m_particleSize); diff --git a/src/Nazara/Graphics/RenderTechniques.cpp b/src/Nazara/Graphics/RenderTechniques.cpp index df3eb5582..46d84d9c4 100644 --- a/src/Nazara/Graphics/RenderTechniques.cpp +++ b/src/Nazara/Graphics/RenderTechniques.cpp @@ -23,7 +23,7 @@ namespace Nz "User" }; - static_assert(sizeof(techniquesName)/sizeof(const char*) == RenderTechniqueType_Max+1, "Render technique type name array is incomplete"); + static_assert(sizeof(techniquesName) / sizeof(const char*) == RenderTechniqueType_Max + 1, "Render technique type name array is incomplete"); struct RenderTechnique { @@ -34,6 +34,22 @@ namespace Nz std::unordered_map s_renderTechniques; } + /*! + * \ingroup graphics + * \class Nz::RenderTechniques + * \brief Graphics class that represents the techniques used in rendering + */ + + /*! + * \brief Gets the technique by enumeration + * \return A reference to the newly created technique + * + * \param renderTechnique Enumeration of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if renderTechnique does not exist + */ + AbstractRenderTechnique* RenderTechniques::GetByEnum(RenderTechniqueType renderTechnique, int* techniqueRanking) { #ifdef NAZARA_DEBUG @@ -47,6 +63,16 @@ namespace Nz return GetByName(techniquesName[renderTechnique], techniqueRanking); } + /*! + * \brief Gets the technique by index + * \return A reference to the newly created technique + * + * \param index Index of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if index is out or range + */ + AbstractRenderTechnique* RenderTechniques::GetByIndex(unsigned int index, int* techniqueRanking) { #if NAZARA_GRAPHICS_SAFE @@ -66,6 +92,16 @@ namespace Nz return it->second.factory(); } + /*! + * \brief Gets the technique by name + * \return A reference to the newly created technique + * + * \param name Name of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if name does not exist or is invalid + */ + AbstractRenderTechnique* RenderTechniques::GetByName(const String& name, int* techniqueRanking) { #if NAZARA_GRAPHICS_SAFE @@ -89,6 +125,16 @@ namespace Nz return it->second.factory(); } + /*! + * \brief Gets the technique by ranking + * \return A reference to the newly created technique + * + * \param maxRanking Ranking maximum of the technique + * \param techniqueRanking Ranking for the technique + * + * \remark Produces a NazaraError if name does not exist or is invalid + */ + AbstractRenderTechnique* RenderTechniques::GetByRanking(int maxRanking, int* techniqueRanking) { if (maxRanking < 0) @@ -119,11 +165,28 @@ namespace Nz return technique->factory(); } + /*! + * \brief Gets the number of techniques available + * \return Number of techniques + */ + unsigned int RenderTechniques::GetCount() { return s_renderTechniques.size(); } + /*! + * \brief Registers a technique + * + * \param name Name of the technique + * \param ranking Ranking of the technique + * \param factory Factory to create the technique + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if name is empty + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if ranking is negative + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if factory is invalid is invalid + */ + void RenderTechniques::Register(const String& name, int ranking, RenderTechniqueFactory factory) { #if NAZARA_GRAPHICS_SAFE @@ -149,6 +212,15 @@ namespace Nz s_renderTechniques[name] = {factory, ranking}; } + /*! + * \brief Converts the enumeration to string + * \return String symbolizing the technique + * + * \param renderTechnique Enumeration of the technique + * + * \remark Produces a NazaraError if renderTechnique does not exist and returns "Error" + */ + String RenderTechniques::ToString(RenderTechniqueType renderTechnique) { #ifdef NAZARA_DEBUG @@ -162,6 +234,12 @@ namespace Nz return techniquesName[renderTechnique]; } + /*! + * \brief Unregisters a technique + * + * \param name Name of the technique + */ + void RenderTechniques::Unregister(const String& name) { s_renderTechniques.erase(name); diff --git a/src/Nazara/Graphics/Renderable.cpp b/src/Nazara/Graphics/Renderable.cpp index 932a8d127..5b02cd5cb 100644 --- a/src/Nazara/Graphics/Renderable.cpp +++ b/src/Nazara/Graphics/Renderable.cpp @@ -7,8 +7,24 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Renderable + * \brief Graphics class that represents a renderable element for our scene + * + * \remark This class is abstract + */ + Renderable::~Renderable() = default; + /*! + * \brief Culls the model if not in the frustum + * \return true If renderable is in the frustum + * + * \param frustum Symbolizing the field of view + * \param transformMatrix Matrix transformation for our object + */ + bool Renderable::Cull(const Frustumf& frustum, const Matrix4f& transformMatrix) const { NazaraUnused(transformMatrix); @@ -16,6 +32,11 @@ namespace Nz return frustum.Contains(m_boundingVolume); } + /*! + * \brief Gets the bounding volume + * \return Bounding volume of the renderable element + */ + const BoundingVolumef& Renderable::GetBoundingVolume() const { EnsureBoundingVolumeUpdated(); @@ -23,6 +44,12 @@ namespace Nz return m_boundingVolume; } + /*! + * \brief Updates the bounding volume by a matrix + * + * \param transformMatrix Matrix transformation for our bounding volume + */ + void Renderable::UpdateBoundingVolume(const Matrix4f& transformMatrix) { m_boundingVolume.Update(transformMatrix); diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index 12bf10b6d..b91ac0076 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -14,6 +14,17 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::SkeletalModel + * \brief Graphics class that represents a model with a skeleton + */ + + /*! + * \brief Checks whether the parameters for the skeletal mesh are correct + * \return true If parameters are valid + */ + bool SkeletalModelParameters::IsValid() const { if (!ModelParameters::IsValid()) @@ -25,12 +36,23 @@ namespace Nz return true; } + /*! + * \brief Constructs a SkeletalModel object by default + */ + SkeletalModel::SkeletalModel() : m_currentSequence(nullptr), m_animationEnabled(true) { } + /*! + * \brief Adds the skeletal mesh to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void SkeletalModel::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_mesh) @@ -51,6 +73,14 @@ namespace Nz } } + /*! + * \brief Updates the animation of the mesh + * + * \param elapsedTime Delta time between two frames + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if there is no animation + */ + void SkeletalModel::AdvanceAnimation(float elapsedTime) { #if NAZARA_GRAPHICS_SAFE @@ -67,7 +97,7 @@ namespace Nz m_interpolation -= 1.f; unsigned lastFrame = m_currentSequence->firstFrame + m_currentSequence->frameCount - 1; - if (m_nextFrame+1 > lastFrame) + if (m_nextFrame + 1 > lastFrame) { if (m_animation->IsLoopPointInterpolationEnabled()) { @@ -77,7 +107,7 @@ namespace Nz else { m_currentFrame = m_currentSequence->firstFrame; - m_nextFrame = m_currentFrame+1; + m_nextFrame = m_currentFrame + 1; } } else @@ -92,26 +122,52 @@ namespace Nz InvalidateBoundingVolume(); } + /*! + * \brief Clones this skeletal model + * \return Pointer to newly allocated SkeletalModel + */ + SkeletalModel* SkeletalModel::Clone() const { return new SkeletalModel(*this); } + /*! + * \brief Creates a default skeletal model + * \return Pointer to newly allocated SkeletalModel + */ + SkeletalModel* SkeletalModel::Create() const { return new SkeletalModel; } + /*! + * \brief Enables the animation of the model + * + * \param animation Should the model be animated + */ + void SkeletalModel::EnableAnimation(bool animation) { m_animationEnabled = animation; } + /*! + * \brief Gets the animation of the model + * \return Pointer to the animation + */ + Animation* SkeletalModel::GetAnimation() const { return m_animation; } + /*! + * \brief Gets the skeleton of the model + * \return Pointer to the skeleton + */ + Skeleton* SkeletalModel::GetSkeleton() { InvalidateBoundingVolume(); @@ -119,41 +175,96 @@ namespace Nz return &m_skeleton; } + /*! + * \brief Gets the skeleton of the model + * \return Constant pointer to the skeleton + */ + const Skeleton* SkeletalModel::GetSkeleton() const { return &m_skeleton; } + /*! + * \brief Checks whether the skeleton has an animation + * \return true If it is the case + * + * \see IsAnimated, IsAnimationEnabled + */ + bool SkeletalModel::HasAnimation() const { return m_animation != nullptr; } + /*! + * \brief Checks whether the skeleton is animated + * \return true + * + * \see HasAnimation, IsAnimationEnabled + */ + bool SkeletalModel::IsAnimated() const { return true; } + /*! + * \brief Checks whether the skeleton is currently animated + * \return true If it is the case + * + * \see HasAnimation, IsAnimated + */ + bool SkeletalModel::IsAnimationEnabled() const { return m_animationEnabled; } + /*! + * \brief Loads the skeleton model from file + * \return true if loading is successful + * + * \param filePath Path to the file + * \param params Parameters for the skeleton model + */ + bool SkeletalModel::LoadFromFile(const String& filePath, const SkeletalModelParameters& params) { return SkeletalModelLoader::LoadFromFile(this, filePath, params); } + /*! + * \brief Loads the skeleton model from memory + * \return true if loading is successful + * + * \param data Raw memory + * \param size Size of the memory + * \param params Parameters for the skeleton model + */ + bool SkeletalModel::LoadFromMemory(const void* data, std::size_t size, const SkeletalModelParameters& params) { return SkeletalModelLoader::LoadFromMemory(this, data, size, params); } + /*! + * \brief Loads the skeleton model from stream + * \return true if loading is successful + * + * \param stream Stream to the skeleton model + * \param params Parameters for the skeleton model + */ + bool SkeletalModel::LoadFromStream(Stream& stream, const SkeletalModelParameters& params) { return SkeletalModelLoader::LoadFromStream(this, stream, params); } + /*! + * \brief Resets the model + */ + void SkeletalModel::Reset() { Model::Reset(); @@ -161,6 +272,16 @@ namespace Nz m_skeleton.Destroy(); } + /*! + * \brief Sets the animation for the model + * \return true If successful + * + * \param animation Animation for the model + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if animation is invalid + */ + bool SkeletalModel::SetAnimation(Animation* animation) { #if NAZARA_GRAPHICS_SAFE @@ -204,6 +325,14 @@ namespace Nz return true; } + /*! + * \brief Sets the mesh for the model + * + * \param mesh Mesh for the model + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no mesh or if invalid + */ + void SkeletalModel::SetMesh(Mesh* mesh) { #if NAZARA_GRAPHICS_SAFE @@ -224,13 +353,23 @@ namespace Nz SetAnimation(nullptr); } - m_skeleton = *m_mesh->GetSkeleton(); // Copie du squelette template + m_skeleton = *m_mesh->GetSkeleton(); // Copy of skeleton template } } + /*! + * \brief Sets the sequence for the model + * \return true If successful + * + * \param sequenceName Name for the sequence animation + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation + */ + bool SkeletalModel::SetSequence(const String& sequenceName) { - ///TODO: Rendre cette erreur "safe" avec le nouveau système de gestions d'erreur (No-log) + ///TODO: Make this error "safe" with the new system of error handling (No-log) #if NAZARA_GRAPHICS_SAFE if (!m_animation) { @@ -240,11 +379,13 @@ namespace Nz #endif const Sequence* currentSequence = m_animation->GetSequence(sequenceName); + #if NAZARA_GRAPHICS_SAFE if (!currentSequence) { NazaraError("Sequence not found"); return false; } + #endif m_currentSequence = currentSequence; m_nextFrame = m_currentSequence->firstFrame; @@ -252,6 +393,15 @@ namespace Nz return true; } + /*! + * \brief Sets the sequence for the model + * + * \param sequenceIndex Index for the sequence animation + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if there is no animation + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE if sequence name does not exist for the current animation + */ + void SkeletalModel::SetSequence(unsigned int sequenceIndex) { #if NAZARA_GRAPHICS_SAFE @@ -275,13 +425,22 @@ namespace Nz m_nextFrame = m_currentSequence->firstFrame; } + /* + * \brief Makes the bounding volume of this text + */ + void SkeletalModel::MakeBoundingVolume() const { m_boundingVolume.Set(m_skeleton.GetAABB()); } + /*! + * \brief Updates the model + */ + void SkeletalModel::Update() { + ///TODO /*if (m_animationEnabled && m_animation) AdvanceAnimation(m_scene->GetUpdateTime());*/ } diff --git a/src/Nazara/Graphics/SkinningManager.cpp b/src/Nazara/Graphics/SkinningManager.cpp index 0f4b3140a..7391eeea6 100644 --- a/src/Nazara/Graphics/SkinningManager.cpp +++ b/src/Nazara/Graphics/SkinningManager.cpp @@ -46,6 +46,13 @@ namespace Nz SkeletonMap s_cache; std::vector s_skinningQueue; + /*! + * \brief Skins the mesh for a single thread context + * + * \param mesh Skeletal mesh to get vertex buffer from + * \param skeleton Skeleton to consider for getting data + * \param buffer Vertex buffer symbolizing the transition + */ void Skin_MonoCPU(const SkeletalMesh* mesh, const Skeleton* skeleton, VertexBuffer* buffer) { @@ -60,6 +67,14 @@ namespace Nz SkinPositionNormalTangent(skinningData, 0, mesh->GetVertexCount()); } + /*! + * \brief Skins the mesh for a multi-threaded context + * + * \param mesh Skeletal mesh to get vertex buffer from + * \param skeleton Skeleton to consider for getting data + * \param buffer Vertex buffer symbolizing the transition + */ + void Skin_MultiCPU(const SkeletalMesh* mesh, const Skeleton* skeleton, VertexBuffer* buffer) { BufferMapper inputMapper(mesh->GetVertexBuffer(), BufferAccess_ReadOnly); @@ -70,8 +85,8 @@ namespace Nz skinningData.outputVertex = static_cast(outputMapper.GetPointer()); skinningData.joints = skeleton->GetJoints(); - // Afin d'empêcher les différents threads de vouloir mettre à jour la même matrice en même temps, - // on se charge de la mettre à jour avant de les lancer + // To avoid different threads to update the same matrix at the same time + // We try to update them before launching the tasks unsigned int jointCount = skeleton->GetJointCount(); for (unsigned int i = 0; i < jointCount; ++i) skinningData.joints[i].EnsureSkinningMatrixUpdate(); @@ -87,6 +102,23 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::SkinningManager + * \brief Graphics class that represents the management of skinning + */ + + /*! + * \brief Gets the vertex buffer from a skeletal mesh with its skeleton + * \return A pointer to the vertex buffer newly created + * + * \param mesh Skeletal mesh to get vertex buffer from + * \param skeleton Skeleton to consider for getting data + * + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if mesh is invalid + * \remark Produces a NazaraError with NAZARA_GRAPHICS_SAFE defined if skeleton is invalid + */ + VertexBuffer* SkinningManager::GetBuffer(const SkeletalMesh* mesh, const Skeleton* skeleton) { #if NAZARA_GRAPHICS_SAFE @@ -149,6 +181,10 @@ namespace Nz return buffer; } + /*! + * \brief Skins the skeletal mesh + */ + void SkinningManager::Skin() { for (QueueData& data : s_skinningQueue) @@ -157,6 +193,11 @@ namespace Nz s_skinningQueue.clear(); } + /*! + * \brief Initializes the skinning librairies + * \return true + */ + bool SkinningManager::Initialize() { ///TODO: GPU Skinning @@ -165,9 +206,15 @@ namespace Nz else s_skinFunc = Skin_MonoCPU; - return true; // Rien de particulier à faire + return true; // Nothing particular to do } + /*! + * \brief Handle the destruction of a skeletal mesh + * + * \param mesh SkeletalMesh being destroyed + */ + void SkinningManager::OnSkeletalMeshDestroy(const SkeletalMesh* mesh) { for (auto& pair : s_cache) @@ -177,17 +224,33 @@ namespace Nz } } + /*! + * \brief Handle the invalidation of a skeletal mesh + * + * \param mesh SkeletalMesh being invalidated + */ + void SkinningManager::OnSkeletonInvalidated(const Skeleton* skeleton) { for (auto& pair : s_cache.at(skeleton).meshMap) pair.second.updated = false; } + /*! + * \brief Handle the release of a skeletal mesh + * + * \param skeleton SkeletalMesh being released + */ + void SkinningManager::OnSkeletonRelease(const Skeleton* skeleton) { s_cache.erase(skeleton); } + /*! + * \brief Uninitializes the skinning librairies + */ + void SkinningManager::Uninitialize() { s_cache.clear(); diff --git a/src/Nazara/Graphics/SkyboxBackground.cpp b/src/Nazara/Graphics/SkyboxBackground.cpp index a70a9dd2d..75bc0cc12 100644 --- a/src/Nazara/Graphics/SkyboxBackground.cpp +++ b/src/Nazara/Graphics/SkyboxBackground.cpp @@ -22,6 +22,18 @@ namespace Nz static VertexBufferRef s_vertexBuffer; } + /*! + * \ingroup graphics + * \class Nz::SkyboxBackground + * \brief Graphics class that represents a background with a cubemap texture + */ + + /*! + * \brief Constructs a SkyboxBackground object with a cubemap texture + * + * \param cubemapTexture Cubemap texture + */ + SkyboxBackground::SkyboxBackground(TextureRef cubemapTexture) : m_movementOffset(Vector3f::Zero()), m_movementScale(0.f) @@ -31,6 +43,12 @@ namespace Nz SetTexture(std::move(cubemapTexture)); } + /*! + * \brief Draws this relatively to the viewer + * + * \param viewer Viewer for the background + */ + void SkyboxBackground::Draw(const AbstractViewer* viewer) const { Matrix4f skyboxMatrix(viewer->GetViewMatrix()); @@ -65,14 +83,26 @@ namespace Nz Renderer::SetMatrix(MatrixType_View, viewer->GetViewMatrix()); } + /*! + * \brief Gets the background type + * \return Type of background + */ + BackgroundType SkyboxBackground::GetBackgroundType() const { return BackgroundType_Skybox; } + /*! + * \brief Initializes the skybox + * \return true If successful + * + * \remark Produces a NazaraError if initialization failed + */ + bool SkyboxBackground::Initialize() { - const UInt16 indices[6*6] = + const UInt16 indices[6 * 6] = { 0, 1, 2, 0, 2, 3, 3, 2, 6, 3, 6, 7, @@ -170,6 +200,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the skybox + */ + void SkyboxBackground::Uninitialize() { s_indexBuffer.Reset(); diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index fd4ab758f..76bf5fff2 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -11,6 +11,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::Sprite + * \brief Graphics class that represents the rendering of a sprite + */ + + /*! + * \brief Adds the sprite to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void Sprite::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_material) @@ -20,11 +33,21 @@ namespace Nz renderQueue->AddSprites(instanceData.renderOrder, m_material, vertices, 1); } + /*! + * \brief Makes the bounding volume of this text + */ + void Sprite::MakeBoundingVolume() const { m_boundingVolume.Set(Vector3f(0.f), m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); } + /*! + * \brief Updates the data of the sprite + * + * \param instanceData Data of the instance + */ + void Sprite::UpdateData(InstanceData* instanceData) const { instanceData->data.resize(4 * sizeof(VertexStruct_XYZ_Color_UV)); @@ -51,6 +74,13 @@ namespace Nz *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } + /*! + * \brief Initializes the sprite librairies + * \return true If successful + * + * \remark Produces a NazaraError if the sprite library failed to be initialized + */ + bool Sprite::Initialize() { if (!SpriteLibrary::Initialize()) @@ -62,6 +92,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the sprite librairies + */ + void Sprite::Uninitialize() { SpriteLibrary::Uninitialize(); diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 6d0e41f52..3459b22cd 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -13,6 +13,19 @@ namespace Nz { + /*! + * \ingroup graphics + * \class Nz::TextSprite + * \brief Graphics class that represents the rendering of a sprite containing text + */ + + /*! + * \brief Adds the text to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void TextSprite::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const { if (!m_material) @@ -26,11 +39,19 @@ namespace Nz if (indices.count > 0) { const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(instanceData.data.data()); - renderQueue->AddSprites(instanceData.renderOrder, m_material, &vertices[indices.first*4], indices.count, overlay); + renderQueue->AddSprites(instanceData.renderOrder, m_material, &vertices[indices.first * 4], indices.count, overlay); } } } + /*! + * \brief Updates the text + * + * \param drawer Drawer used to compose the text + * + * \remark Produces a NazaraAssert if atlas does not use a hardware storage + */ + void TextSprite::Update(const AbstractTextDrawer& drawer) { CallOnExit clearOnFail([this]() @@ -138,8 +159,8 @@ namespace Nz // First, compute the uv coordinates from our atlas rect Vector2ui size(texture->GetSize()); - float invWidth = 1.f/size.x; - float invHeight = 1.f/size.y; + float invWidth = 1.f / size.x; + float invHeight = 1.f / size.y; Rectf uvRect(glyph.atlasRect); uvRect.x *= invWidth; @@ -155,9 +176,9 @@ namespace Nz for (unsigned int j = 0; j < 4; ++j) { // Remember that indices->count is a counter here, not a count value - m_localVertices[indices->count*4 + j].color = glyph.color; - m_localVertices[indices->count*4 + j].position.Set(glyph.corners[j]); - m_localVertices[indices->count*4 + j].uv.Set(uvRect.GetCorner((glyph.flipped) ? flippedCorners[j] : normalCorners[j])); + m_localVertices[indices->count * 4 + j].color = glyph.color; + m_localVertices[indices->count * 4 + j].position.Set(glyph.corners[j]); + m_localVertices[indices->count * 4 + j].uv.Set(uvRect.GetCorner((glyph.flipped) ? flippedCorners[j] : normalCorners[j])); } // Increment the counter, go to next glyph @@ -172,15 +193,25 @@ namespace Nz clearOnFail.Reset(); } + /* + * \brief Makes the bounding volume of this text + */ + void TextSprite::MakeBoundingVolume() const { Rectf bounds(m_localBounds); Vector2f max = bounds.GetMaximum(); Vector2f min = bounds.GetMinimum(); - m_boundingVolume.Set(min.x*Vector3f::Right() + min.y*Vector3f::Down(), max.x*Vector3f::Right() + max.y*Vector3f::Down()); + m_boundingVolume.Set(min.x * Vector3f::Right() + min.y * Vector3f::Down(), max.x * Vector3f::Right() + max.y * Vector3f::Down()); } + /*! + * \brief Handle the invalidation of an atlas + * + * \param atlas Atlas being invalidated + */ + void TextSprite::OnAtlasInvalidated(const AbstractAtlas* atlas) { #ifdef NAZARA_DEBUG @@ -195,6 +226,14 @@ namespace Nz Clear(); } + /*! + * \brief Handle the invalidation of an atlas layer + * + * \param atlas Atlas being invalidated + * \param oldLayer Pointer to the previous layer + * \param newLayer Pointer to the new layer + */ + void TextSprite::OnAtlasLayerChange(const AbstractAtlas* atlas, AbstractImage* oldLayer, AbstractImage* newLayer) { NazaraUnused(atlas); @@ -207,23 +246,23 @@ namespace Nz } #endif - // La texture d'un atlas vient d'être recréée (changement de taille) - // nous devons ajuster les coordonnées de textures et la texture du rendu + // The texture of an atlas have just been recreated (size change) + // we have to adjust the coordinates of the texture and the rendering texture Texture* oldTexture = static_cast(oldLayer); Texture* newTexture = static_cast(newLayer); - // Il est possible que nous n'utilisions pas la texture en question (l'atlas nous prévenant pour chacun de ses layers) + // It is possible that we don't use the texture (the atlas warning us for each of its layers) auto it = m_renderInfos.find(oldTexture); if (it != m_renderInfos.end()) { - // Nous utilisons bien cette texture, nous devons mettre à jour les coordonnées de texture + // We indeed use this texture, we have to update its coordinates RenderIndices indices = std::move(it->second); Vector2ui oldSize(oldTexture->GetSize()); Vector2ui newSize(newTexture->GetSize()); - Vector2f scale = Vector2f(oldSize)/Vector2f(newSize); // ratio ancienne et nouvelle taille + Vector2f scale = Vector2f(oldSize) / Vector2f(newSize); // ratio of the old one to the new one - // On va maintenant parcourir toutes les coordonnées de texture concernées pour les multiplier par ce ratio + // Now we will iterate through each coordinates of the concerned texture to multiply them by the ratio SparsePtr texCoordPtr(&m_localVertices[indices.first].uv, sizeof(VertexStruct_XYZ_Color_UV)); for (unsigned int i = 0; i < indices.count; ++i) { @@ -231,12 +270,18 @@ namespace Nz m_localVertices[i*4 + j].uv *= scale; } - // Nous enlevons l'ancienne texture et rajoutons la nouvelle à sa place (pour les mêmes indices) + // We get rid off the old texture and we set the new one at the place (same for indices) m_renderInfos.erase(it); m_renderInfos.insert(std::make_pair(newTexture, std::move(indices))); } } + /*! + * \brief Updates the data of the sprite + * + * \param instanceData Data of the instance + */ + void TextSprite::UpdateData(InstanceData* instanceData) const { instanceData->data.resize(m_localVertices.size() * sizeof(VertexStruct_XYZ_Color_UV)); @@ -246,18 +291,18 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); - // Nous allons maintenant initialiser les sommets finaux (ceux envoyés à la RenderQueue) - // à l'aide du repère, de la matrice et de notre attribut de couleur + // We will not initialize the final vertices (those send to the RenderQueue) + // With the help of the coordinates axis, the matrix and our color attribute for (auto& pair : m_renderInfos) { RenderIndices& indices = pair.second; if (indices.count == 0) continue; //< Ignore empty render indices - SparsePtr color = colorPtr + indices.first*4; - SparsePtr pos = posPtr + indices.first*4; - SparsePtr uv = texCoordPtr + indices.first*4; - VertexStruct_XY_Color_UV* localVertex = &m_localVertices[indices.first*4]; + SparsePtr color = colorPtr + indices.first * 4; + SparsePtr pos = posPtr + indices.first * 4; + SparsePtr uv = texCoordPtr + indices.first * 4; + VertexStruct_XY_Color_UV* localVertex = &m_localVertices[indices.first * 4]; for (unsigned int i = 0; i < indices.count; ++i) { for (unsigned int j = 0; j < 4; ++j) diff --git a/src/Nazara/Graphics/TextureBackground.cpp b/src/Nazara/Graphics/TextureBackground.cpp index 9ceb633e6..1b2e53e72 100644 --- a/src/Nazara/Graphics/TextureBackground.cpp +++ b/src/Nazara/Graphics/TextureBackground.cpp @@ -11,6 +11,11 @@ namespace Nz { namespace { + /*! + * \brief Defines render states + * \return RenderStates for the color background + */ + RenderStates BuildRenderStates() { RenderStates states; @@ -24,6 +29,18 @@ namespace Nz } } + /*! + * \ingroup graphics + * \class Nz::TextureBackground + * \brief Graphics class that represents a background with a texture + */ + + /*! + * \brief Constructs a TextureBackground object with a texture + * + * \param texture Texture + */ + TextureBackground::TextureBackground(TextureRef texture) { m_uberShader = UberShaderLibrary::Get("Basic"); @@ -43,6 +60,12 @@ namespace Nz SetTexture(std::move(texture)); } + /*! + * \brief Draws this relatively to the viewer + * + * \param viewer Viewer for the background + */ + void TextureBackground::Draw(const AbstractViewer* viewer) const { NazaraUnused(viewer); @@ -62,6 +85,11 @@ namespace Nz Renderer::DrawFullscreenQuad(); } + /*! + * \brief Gets the background type + * \return Type of background + */ + BackgroundType TextureBackground::GetBackgroundType() const { return BackgroundType_Texture; diff --git a/tests/Engine/Graphics/Billboard.cpp b/tests/Engine/Graphics/Billboard.cpp new file mode 100644 index 000000000..5136e3af6 --- /dev/null +++ b/tests/Engine/Graphics/Billboard.cpp @@ -0,0 +1,34 @@ +#include +#include + +SCENARIO("Billboard", "[GRAPHICS][BILLBOARD]") +{ + GIVEN("A default billboard") + { + Nz::Billboard billboard; + + WHEN("We assign it to another") + { + Nz::MaterialRef materialRef = Nz::Material::New(); + materialRef->LoadFromFile("resources/Engine/Graphics/Nazara.png"); + Nz::Color materialColor = materialRef->GetDiffuseColor(); + Nz::BillboardRef otherBillboard = Nz::Billboard::New(materialRef); + + billboard = *otherBillboard; + + THEN("The old one has the same properties than the new one") + { + REQUIRE(billboard.GetColor() == materialColor); + REQUIRE(billboard.GetMaterial().Get() == materialRef.Get()); + REQUIRE(billboard.GetRotation() == Approx(0.f)); + REQUIRE(billboard.GetSize() == Nz::Vector2f(64.f, 64.f)); // Default sizes + } + + THEN("We set it with our new material and ask for its real size") + { + billboard.SetMaterial(materialRef, true); + REQUIRE(billboard.GetSize() == Nz::Vector2f(765.f, 212.f)); // Nazara.png sizes + } + } + } +} diff --git a/tests/Engine/Graphics/ColorBackground.cpp b/tests/Engine/Graphics/ColorBackground.cpp new file mode 100644 index 000000000..f4a88eb30 --- /dev/null +++ b/tests/Engine/Graphics/ColorBackground.cpp @@ -0,0 +1,20 @@ +#include +#include + +SCENARIO("ColorBackground", "[GRAPHICS][COLORBACKGROUND]") +{ + GIVEN("A default color background") + { + Nz::ColorBackground colorBackground; + + WHEN("We assign it a color") + { + colorBackground.SetColor(Nz::Color::Red); + + THEN("We can get it") + { + REQUIRE(colorBackground.GetColor() == Nz::Color::Red); + } + } + } +} diff --git a/tests/Engine/Graphics/DeferredRenderTechnique.cpp b/tests/Engine/Graphics/DeferredRenderTechnique.cpp new file mode 100644 index 000000000..f61c9800c --- /dev/null +++ b/tests/Engine/Graphics/DeferredRenderTechnique.cpp @@ -0,0 +1,29 @@ +#include +#include + +SCENARIO("DeferredRenderTechnique", "[GRAPHICS][DEFERREDRENDERTECHNIQUE]") +{ + GIVEN("A default deferred render technique") + { + Nz::DeferredRenderTechnique deferredRenderTechnique; + + WHEN("We can disable a pass") + { + REQUIRE(deferredRenderTechnique.IsPassEnabled(Nz::RenderPassType::RenderPassType_AA, 0)); + deferredRenderTechnique.EnablePass(Nz::RenderPassType::RenderPassType_AA, 0, false); + + THEN("It is disabled") + { + REQUIRE(!deferredRenderTechnique.IsPassEnabled(Nz::RenderPassType::RenderPassType_AA, 0)); + } + + AND_THEN("We reset it, it is disabled and not the same as the old one") + { + Nz::DeferredRenderPass* oldPass = deferredRenderTechnique.GetPass(Nz::RenderPassType::RenderPassType_AA, 0); + deferredRenderTechnique.ResetPass(Nz::RenderPassType::RenderPassType_AA, 0); + REQUIRE(!deferredRenderTechnique.IsPassEnabled(Nz::RenderPassType::RenderPassType_AA, 0)); + REQUIRE(deferredRenderTechnique.GetPass(Nz::RenderPassType::RenderPassType_AA, 0) != oldPass); + } + } + } +} diff --git a/tests/Engine/Graphics/Light.cpp b/tests/Engine/Graphics/Light.cpp new file mode 100644 index 000000000..bd5f1c7f9 --- /dev/null +++ b/tests/Engine/Graphics/Light.cpp @@ -0,0 +1,31 @@ +#include +#include + +SCENARIO("Light", "[GRAPHICS][LIGHT]") +{ + GIVEN("Different light") + { + Nz::Light directionalLight(Nz::LightType_Directional); + Nz::Light pointLight(Nz::LightType_Point); + Nz::Light spotLight(Nz::LightType_Spot); + + WHEN("We try to cull") + { + Nz::Frustumf frustum; + frustum.Build(90.f, 16.f / 9.f, 1.f, 1000.f, Nz::Vector3f::Zero(), Nz::Vector3f::UnitX()); + Nz::Matrix4f Unit3InX = Nz::Matrix4f::Translate(Nz::Vector3f::UnitX() * 3.f); + Nz::Matrix4f rotationTowardsY = Unit3InX * Nz::Matrix4f::Rotate(Nz::EulerAnglesf(Nz::FromDegrees(90.f), 0.f, 0.f).ToQuaternion()); + + THEN("These results are expected") + { + REQUIRE(directionalLight.Cull(frustum, Unit3InX)); + REQUIRE(pointLight.Cull(frustum, Unit3InX)); + REQUIRE(!spotLight.Cull(frustum, Unit3InX)); + + REQUIRE(directionalLight.Cull(frustum, rotationTowardsY)); + REQUIRE(pointLight.Cull(frustum, rotationTowardsY)); + REQUIRE(!spotLight.Cull(frustum, rotationTowardsY)); + } + } + } +} diff --git a/tests/Engine/Graphics/Model.cpp b/tests/Engine/Graphics/Model.cpp new file mode 100644 index 000000000..d67a261bb --- /dev/null +++ b/tests/Engine/Graphics/Model.cpp @@ -0,0 +1,24 @@ +#include +#include + +SCENARIO("Model", "[GRAPHICS][MODEL]") +{ + GIVEN("The standford dragon model") + { + WHEN("We get general informations") + { + THEN("These results are expected") + { + Nz::ModelRef model = Nz::Model::New(); + REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj")); + + REQUIRE(model->GetMaterialCount() == 2); + REQUIRE(model->GetSkin() == 0); + REQUIRE(model->GetSkinCount() == 1); + + Nz::Material* material = model->GetMaterial(0); + REQUIRE(material->GetAmbientColor() == Nz::Color(128)); + } + } + } +} diff --git a/tests/Engine/Graphics/ParticleDeclaration.cpp b/tests/Engine/Graphics/ParticleDeclaration.cpp new file mode 100644 index 000000000..1bc1739d3 --- /dev/null +++ b/tests/Engine/Graphics/ParticleDeclaration.cpp @@ -0,0 +1,29 @@ +#include +#include + +SCENARIO("ParticleDeclaration", "[GRAPHICS][PARTICLEDECLARATION]") +{ + GIVEN("A particle declaration of a model") + { + Nz::ParticleDeclaration* particleDeclaration = Nz::ParticleDeclaration::Get(Nz::ParticleLayout_Model); + + WHEN("We disable a component") + { + bool enabled; + Nz::ComponentType type; + unsigned int offset; + particleDeclaration->GetComponent(Nz::ParticleComponent_Position, &enabled, &type, &offset); + REQUIRE(enabled); + unsigned int oldStride = particleDeclaration->GetStride(); + + particleDeclaration->DisableComponent(Nz::ParticleComponent_Position); + REQUIRE(oldStride != particleDeclaration->GetStride()); + + THEN("We can enable it and the stride is back") + { + particleDeclaration->EnableComponent(Nz::ParticleComponent_Position, type, offset); + REQUIRE(oldStride == particleDeclaration->GetStride()); + } + } + } +} diff --git a/tests/Engine/Graphics/ParticleSystem.cpp b/tests/Engine/Graphics/ParticleSystem.cpp new file mode 100644 index 000000000..32f5f01f9 --- /dev/null +++ b/tests/Engine/Graphics/ParticleSystem.cpp @@ -0,0 +1,103 @@ +#include +#include + +#include +#include + +class TestParticleController : public Nz::ParticleController +{ + public: + // Be aware that the interval is [startId, endId] and NOT [startId, endId) + void Apply(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override + { + Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); + Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); + Nz::SparsePtr lifePtr = mapper.GetComponentPtr(Nz::ParticleComponent_Life); + + for (unsigned int i = startId; i <= endId; ++i) + { + Nz::Vector3f& particlePosition = positionPtr[i]; + Nz::Vector3f& particleVelocity = velocityPtr[i]; + float& particleLife = lifePtr[i]; + + particleLife -= elapsedTime; + if (particleLife <= 0.f) + system.KillParticle(i); + } + } +}; + +class TestParticleEmitter : public Nz::ParticleEmitter +{ + public: + ~TestParticleEmitter() override = default; + + void Emit(Nz::ParticleSystem& system, float elapsedTime) const override + { + system.GenerateParticles(GetEmissionCount()); + } + + private: + void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override + { + } +}; + +class TestParticleGenerator : public Nz::ParticleGenerator +{ + public: + ~TestParticleGenerator() override = default; + + // Be aware that the interval is [startId, endId] and NOT [startId, endId) + void Generate(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override + { + Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); + Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); + Nz::SparsePtr lifePtr = mapper.GetComponentPtr(Nz::ParticleComponent_Life); + + for (unsigned int i = startId; i <= endId; ++i) + { + Nz::Vector3f& particlePosition = positionPtr[i]; + Nz::Vector3f& particleVelocity = velocityPtr[i]; + float& particleLife = lifePtr[i]; + + particlePosition = Nz::Vector3f::Zero(); + particleVelocity = Nz::Vector3f::UnitX(); + particleLife = 1.3f; + } + } +}; + +SCENARIO("ParticleSystem", "[GRAPHICS][PARTICLESYSTEM]") +{ + GIVEN("A particle system of maximum 10 billboards with its generators") + { + // These need to be alive longer than the particle system + TestParticleController particleController; + TestParticleGenerator particleGenerator; + Nz::ParticleSystem particleSystem(10, Nz::ParticleLayout_Billboard); + + particleSystem.AddController(&particleController); + TestParticleEmitter particleEmitter; + particleEmitter.SetEmissionCount(10); + particleSystem.AddEmitter(&particleEmitter); + + particleSystem.AddGenerator(&particleGenerator); + + WHEN("We update to generate 10 particles") + { + particleSystem.Update(1.f); + + THEN("There must be 10 particles") + { + REQUIRE(particleSystem.GetParticleCount() == 10); + } + + AND_THEN("We update to make them die") + { + particleSystem.Update(2.f); + REQUIRE(particleSystem.GetParticleCount() == 0); + } + } + } +} diff --git a/tests/Engine/Graphics/RenderTechniques.cpp b/tests/Engine/Graphics/RenderTechniques.cpp new file mode 100644 index 000000000..ac5849da9 --- /dev/null +++ b/tests/Engine/Graphics/RenderTechniques.cpp @@ -0,0 +1,47 @@ +#include +#include + +#include +#include + +SCENARIO("RenderTechniques", "[GRAPHICS][RENDERTECHNIQUES]") +{ + GIVEN("Nothing") + { + WHEN("We try to get a technique") + { + THEN("We should get it") + { + std::unique_ptr forwardByEnum(Nz::RenderTechniques::GetByEnum(Nz::RenderTechniqueType_BasicForward)); + REQUIRE(forwardByEnum->GetType() == Nz::RenderTechniqueType_BasicForward); + + std::unique_ptr forwardByIndex(Nz::RenderTechniques::GetByIndex(1)); + REQUIRE(forwardByIndex->GetType() == Nz::RenderTechniqueType_BasicForward); + + std::unique_ptr forwardByName(Nz::RenderTechniques::GetByName(Nz::RenderTechniques::ToString(Nz::RenderTechniqueType_BasicForward))); + REQUIRE(forwardByName->GetType() == Nz::RenderTechniqueType_BasicForward); + } + + THEN("We can register a render technique") + { + unsigned int previousCount = Nz::RenderTechniques::GetCount(); + + Nz::RenderTechniques::Register("test", 23, []() -> Nz::AbstractRenderTechnique* { + return new Nz::ForwardRenderTechnique; + }); + + REQUIRE(previousCount < Nz::RenderTechniques::GetCount()); + + std::unique_ptr forwardByRanking(Nz::RenderTechniques::GetByRanking(23)); + REQUIRE(forwardByRanking->GetType() == Nz::RenderTechniqueType_BasicForward); + + std::unique_ptr forwardByName(Nz::RenderTechniques::GetByName("test")); + REQUIRE(forwardByName->GetType() == Nz::RenderTechniqueType_BasicForward); + + Nz::RenderTechniques::Unregister("test"); + + REQUIRE(previousCount == Nz::RenderTechniques::GetCount()); + } + } + } +} \ No newline at end of file diff --git a/tests/Engine/Graphics/SkeletalModel.cpp b/tests/Engine/Graphics/SkeletalModel.cpp new file mode 100644 index 000000000..87d2e43f1 --- /dev/null +++ b/tests/Engine/Graphics/SkeletalModel.cpp @@ -0,0 +1,26 @@ +#include +#include + +SCENARIO("SkeletalModel", "[GRAPHICS][SKELETALMODEL]") +{ + GIVEN("A default skeletal model") + { + Nz::SkeletalModel skeletalModel; + Nz::AnimationRef animation = Nz::Animation::New(); + + WHEN("We can load the bob lamp") + { + REQUIRE(skeletalModel.LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5mesh")); + REQUIRE(animation->LoadFromFile("resources/Engine/Graphics/Bob lamp/bob_lamp_update.md5anim")); + skeletalModel.SetAnimation(animation); + + THEN("We can enable its animation") + { + REQUIRE(skeletalModel.HasAnimation()); + skeletalModel.EnableAnimation(true); + skeletalModel.AdvanceAnimation(0.10f); + REQUIRE(skeletalModel.IsAnimationEnabled()); + } + } + } +} diff --git a/tests/Engine/Graphics/SkyboxBackground.cpp b/tests/Engine/Graphics/SkyboxBackground.cpp new file mode 100644 index 000000000..36ceb0db5 --- /dev/null +++ b/tests/Engine/Graphics/SkyboxBackground.cpp @@ -0,0 +1,25 @@ +#include +#include + +SCENARIO("SkyboxBackground", "[GRAPHICS][SKYBOXBACKGROUND]") +{ + GIVEN("A skybox background with a loaded image") + { + Nz::TextureRef textureRef = Nz::Texture::New(); + textureRef->LoadCubemapFromFile("resources/Engine/Graphics/skybox.png"); + Nz::SkyboxBackgroundRef skyboxBackgroundRef = Nz::SkyboxBackground::New(textureRef); + + WHEN("We assign it parameters") + { + skyboxBackgroundRef->SetMovementOffset(Nz::Vector3f::Unit()); + skyboxBackgroundRef->SetMovementScale(1.f); + + THEN("We can get it") + { + REQUIRE(skyboxBackgroundRef->GetMovementOffset() == Nz::Vector3f::Unit()); + REQUIRE(skyboxBackgroundRef->GetMovementScale() == Approx(1.f)); + REQUIRE(skyboxBackgroundRef->GetTexture().Get() == textureRef.Get()); + } + } + } +} diff --git a/tests/Engine/Graphics/TextureBackground.cpp b/tests/Engine/Graphics/TextureBackground.cpp new file mode 100644 index 000000000..33178d87f --- /dev/null +++ b/tests/Engine/Graphics/TextureBackground.cpp @@ -0,0 +1,20 @@ +#include +#include + +SCENARIO("TextureBackground", "[GRAPHICS][TEXTUREBACKGROUND]") +{ + GIVEN("A default texture background") + { + Nz::TextureRef textureRef = Nz::Texture::New(); + textureRef->LoadFromFile("resources/Engine/Graphics/skybox.png"); + Nz::TextureBackgroundRef textureBackgroundRef = Nz::TextureBackground::New(textureRef); + + WHEN("We assign it parameters") + { + THEN("We can get it") + { + REQUIRE(textureBackgroundRef->GetTexture().Get() == textureRef.Get()); + } + } + } +} \ No newline at end of file diff --git a/tests/Engine/Math/Sphere.cpp b/tests/Engine/Math/Sphere.cpp index 1820acd35..ef13ffb38 100644 --- a/tests/Engine/Math/Sphere.cpp +++ b/tests/Engine/Math/Sphere.cpp @@ -39,14 +39,14 @@ SCENARIO("Sphere", "[MATH][SPHERE]") WHEN("We ask for distance") { - THEN("These results are expected") + THEN("These results are expected because we don't take into account the border") { - REQUIRE(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX()) == Approx(1.f)); - REQUIRE(firstCenterAndUnit.SquaredDistance(Nz::Vector3f::UnitX()) == Approx(1.f)); + REQUIRE(firstCenterAndUnit.Distance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f)); + REQUIRE(firstCenterAndUnit.SquaredDistance(Nz::Vector3f::UnitX() * 2.f) == Approx(1.f)); Nz::Spheref tmp(Nz::Vector3f::UnitX(), 1.f); - REQUIRE(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Approx(3.f)); - REQUIRE(tmp.SquaredDistance(Nz::Vector3f::UnitX() * 4.f) == Approx(9.f)); + REQUIRE(tmp.Distance(Nz::Vector3f::UnitX() * 4.f) == Approx(2.f)); + REQUIRE(tmp.SquaredDistance(Nz::Vector3f::UnitX() * 4.f) == Approx(4.f)); } } @@ -84,7 +84,7 @@ SCENARIO("Sphere", "[MATH][SPHERE]") THEN("Sphere must contain it and distance should be good") { CHECK(firstCenterAndUnit.Contains(point)); - REQUIRE(firstCenterAndUnit.Distance(point) == 2.f); + REQUIRE(firstCenterAndUnit.Distance(point) == 1.f); } } diff --git a/tests/main.cpp b/tests/main.cpp index 7be81a57e..5ba9e8e01 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,2 +1,16 @@ -#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_RUNNER #include + +#include +#include +#include +#include + +int main(int argc, char* const argv[]) +{ + Nz::Initializer modules; + + int result = Catch::Session().run(argc, argv); + + return result; +} diff --git a/tests/resources/Engine/Graphics/Bob lamp/Readme.txt b/tests/resources/Engine/Graphics/Bob lamp/Readme.txt new file mode 100644 index 000000000..bd605ec7d --- /dev/null +++ b/tests/resources/Engine/Graphics/Bob lamp/Readme.txt @@ -0,0 +1,24 @@ +############################# +MD5 sample mesh and animation +############################# + +INFORMATION & USAGE +=================== +File includes *.blend source files and TGA format textures for MD5 animated mesh testing. +For extensive information and usage instructions visit http://www.katsbits.com/smforum/index.php?topic=178.0 + + - bob_lamp_update.blend contain mesh and armature as would be prior to preparation for export. + - bob_lamp_update_export contains triangulated mesh ready for export. + +NOTES +===== +Included files are for use in **Blender 2.69** or above; opening files in older versions may result in errors dues to internal differences between Blender versions. +Files and media are provided "as is" without any warranties of functionality. + +COPYRIGHT & DISTRIBUTION +======================== +Copyright © 2014 KatsBits. All Rights Reserved. +For more information visit http://www.katsbits.com/ or email info@katsbits.com + +For NON-COMMERCIAL USE ONLY. This file and/or its contents and/or associated materials may not be reproduced, duplicated, distributed or otherwise 'monetised' without prior consent. +Contact info@katsbits.com or visit http://copyright.katsbits.com/ for further details regarding this material and/or distribution/copyright. diff --git a/tests/resources/Engine/Graphics/copyrights.txt b/tests/resources/Engine/Graphics/copyrights.txt new file mode 100644 index 000000000..7cd13413c --- /dev/null +++ b/tests/resources/Engine/Graphics/copyrights.txt @@ -0,0 +1,82 @@ +skybox.png + +https://commons.wikimedia.org/wiki/File:Skybox_example.png + +Original file: +Skybox example.ogg ‎(Ogg Vorbis sound file, length 1 min 3 s, 378 kbps) + +Summary: + +Description: English: An example of a skybox and how the faces can be aligned +Date: 8 June 2011 +Source: Own work +Author: Creator:Arieee + +Description: The Belgian national anthem (instrumental version) performed by the United States Navy Band. Direct link is at http://www.navyband.navy.mil/anthems/ANTHEMS/Belgium.mp3. +Date: 19 October 2004 +Source: http://www.navyband.navy.mil/anthems/national_anthems.htm +Author: United States Navy Band (rendition), uploaded to Wikimedia by Keith Lehwald + +Licencing: + +This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. + + You are free: + + to share – to copy, distribute and transmit the work + to remix – to adapt the work + + Under the following conditions: + + attribution – You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). + share alike – If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. + +------------------------------------------------------------------------------------------------- + +Bob lamp + +http://www.katsbits.com/download/models/md5-example.php + +Original file: +bob_lamp_update.zip (Animated MD5 sample file) + +Summary: + +Description: Updated version of "Bob", a low-poly character mesh for general export and testing of MD5 mesh and animation - "*.md5mesh" and "*.md5anim". File and it's contents should be opened in Blender 2.69 or above to avoid compatibility issues with older versions of Blender and/or resulting MD5 exports (md5mesh & md5anim). + +File includes two versions of the source file, one 'working' - mesh is intact with surfaces in 'quad' form; and one 'prepped' (exported) - mesh has been tessilated (triangulated) for export. +Date: Januari 2014 +Source: http://www.katsbits.com/download/models/md5-example.php +Author: KatsBits + +Licencing: + +Please, refer to "Bob lamp/Readme.txt" file. + +------------------------------------------------------------------------------------------------- + +Standford dragon + +http://graphics.stanford.edu/data/3Dscanrep/ + +Original file: +dragon_recon.tar.gz (PLY files) + +Summary: + +Dragon +Source: Stanford University Computer Graphics Laboratory +Scanner: Cyberware 3030 MS + spacetime analysis +Number of scans: ~70 +Total size of scans: 2,748,318 points (about 5,500,000 triangles) +Reconstruction: vrip (conservatively decimated) +Size of reconstruction: 566,098 vertices, 1,132,830 triangles +Comments: contains numerous small holes +Date: 1996 +Source: http://graphics.stanford.edu/data/3Dscanrep/ +Author: Stanford University Computer Graphics Laboratory + +Licencing: + +Please be sure to acknowledge the source of the data and models you take from this repository. In each of the listings below, we have cited the source of the range data and reconstructed models. You are welcome to use the data and models for research purposes. You are also welcome to mirror or redistribute them for free. Finally, you may publish images made using these models, or the images on this web site, in a scholarly article or book - as long as credit is given to the Stanford Computer Graphics Laboratory. However, such models or images are not to be used for commercial purposes, nor should they appear in a product for sale (with the exception of scholarly journals or books), without our permission. +Please, refer to "dragon_recon/README" file. diff --git a/tests/resources/Engine/Graphics/dragon_recon/README b/tests/resources/Engine/Graphics/dragon_recon/README new file mode 100644 index 000000000..af64a50fe --- /dev/null +++ b/tests/resources/Engine/Graphics/dragon_recon/README @@ -0,0 +1,27 @@ + Surface Reconstructions + + Stanford Range Repository + Computer Graphics Laboratory + Stanford University + + August 4, 1996 + + +These files are the result of reconstructing a set of range images +using the "vrip" program. The first file is the high resolution +result, while the "_res*" files are decimated versions. Note that +these decimations were performed using a crude algorithm that does not +necessarily preserve mesh topology. While they are not beautiful, +they are suitable for interactive rendering. + +Note that this model is a decimated version of the original which was +constructed at the voxel resolution of 0.35 mm. The original model +has no holes in it, however, the decimated model has some holes that +we detected with software, but not by inspection. Apparently, the +decimation software introduced these holes. + +For more information, consult the web pages of the Stanford Graphics +Laboratory: + + http://www-graphics.stanford.edu + From 0a99058c4d171c73c8285be62f6bd175099a1a20 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:22:31 +0200 Subject: [PATCH 060/383] Documentation for module: Network Former-commit-id: d36042138d0883eb118cc9a70f94f3522214dd46 --- include/Nazara/Network/AbstractSocket.inl | 31 ++++ include/Nazara/Network/Config.hpp | 15 +- include/Nazara/Network/ConfigCheck.hpp | 4 +- include/Nazara/Network/DebugOff.hpp | 2 +- include/Nazara/Network/IpAddress.inl | 164 ++++++++++++++++++++- include/Nazara/Network/NetPacket.inl | 93 ++++++++++++ include/Nazara/Network/RUdpConnection.inl | 87 ++++++++++- include/Nazara/Network/TcpClient.hpp | 2 +- include/Nazara/Network/TcpClient.inl | 35 +++++ include/Nazara/Network/TcpServer.inl | 31 ++++ include/Nazara/Network/UdpSocket.hpp | 1 - include/Nazara/Network/UdpSocket.inl | 53 ++++++- src/Nazara/Network/AbstractSocket.cpp | 68 +++++++++ src/Nazara/Network/AlgorithmNetwork.cpp | 42 +++++- src/Nazara/Network/IpAddress.cpp | 50 +++++++ src/Nazara/Network/NetPacket.cpp | 70 +++++++++ src/Nazara/Network/Network.cpp | 27 +++- src/Nazara/Network/RUdpConnection.cpp | 157 +++++++++++++++++++- src/Nazara/Network/TcpClient.cpp | 168 ++++++++++++++++++++++ src/Nazara/Network/TcpServer.cpp | 34 +++++ src/Nazara/Network/UdpSocket.cpp | 84 +++++++++++ tests/Engine/Network/IpAddress.cpp | 47 ++++++ tests/Engine/Network/RUdpConnection.cpp | 40 ++++++ tests/Engine/Network/TCP.cpp | 49 +++++++ tests/Engine/Network/UdpSocket.cpp | 39 +++++ 25 files changed, 1368 insertions(+), 25 deletions(-) create mode 100644 tests/Engine/Network/IpAddress.cpp create mode 100644 tests/Engine/Network/RUdpConnection.cpp create mode 100644 tests/Engine/Network/TCP.cpp create mode 100644 tests/Engine/Network/UdpSocket.cpp diff --git a/include/Nazara/Network/AbstractSocket.inl b/include/Nazara/Network/AbstractSocket.inl index 8bebabfdb..5b5174b98 100644 --- a/include/Nazara/Network/AbstractSocket.inl +++ b/include/Nazara/Network/AbstractSocket.inl @@ -6,31 +6,62 @@ namespace Nz { + /*! + * \brief Gets the last error + * \return Socket error + */ + inline SocketError AbstractSocket::GetLastError() const { return m_lastError; } + /*! + * \brief Gets the internal socket handle + * \return Socket handle + */ + inline SocketHandle AbstractSocket::GetNativeHandle() const { return m_handle; } + /*! + * \brief Gets the internal state + * \return Socket state + */ + inline SocketState AbstractSocket::GetState() const { return m_state; } + /*! + * \brief Gets the internal type + * \return Socket type + */ + inline SocketType AbstractSocket::GetType() const { return m_type; } + /*! + * \brief Checks whether the blocking is enabled + * \return true If successful + */ + inline bool AbstractSocket::IsBlockingEnabled() const { return m_isBlockingEnabled; } + /*! + * \brief Updates the state of the socket + * + * \param newState Next state for the socket + */ + inline void AbstractSocket::UpdateState(SocketState newState) { if (m_state != newState) diff --git a/include/Nazara/Network/Config.hpp b/include/Nazara/Network/Config.hpp index 727108061..2d73c26bb 100644 --- a/include/Nazara/Network/Config.hpp +++ b/include/Nazara/Network/Config.hpp @@ -27,17 +27,22 @@ #ifndef NAZARA_CONFIG_NETWORK_HPP #define NAZARA_CONFIG_NETWORK_HPP -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci +/*! +* \defgroup network (NazaraNetwork) Network module +* Network/System module including classes to handle networking elements... +*/ -// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) +/// Each modification of a paramater of the module needs a recompilation of the unit + +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) #define NAZARA_NETWORK_MANAGE_MEMORY 0 -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) +// Activate the security tests based on the code (Advised for development) #define NAZARA_NETWORK_SAFE 1 -/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code +/// Each modification of a parameter following implies a modification (often minor) of the code -/// Vérification des valeurs et types de certaines constantes +/// Checking the values and types of certain constants #include #if defined(NAZARA_STATIC) diff --git a/include/Nazara/Network/ConfigCheck.hpp b/include/Nazara/Network/ConfigCheck.hpp index 73513ebc9..2f1ba1dc8 100644 --- a/include/Nazara/Network/ConfigCheck.hpp +++ b/include/Nazara/Network/ConfigCheck.hpp @@ -7,11 +7,11 @@ #ifndef NAZARA_CONFIG_CHECK_NETWORK_HPP #define NAZARA_CONFIG_CHECK_NETWORK_HPP -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp +/// This file is used to check the constant values defined in Config.hpp #include -// On force la valeur de MANAGE_MEMORY en mode debug +// We fore the value of MANAGE_MEMORY in debug #if defined(NAZARA_DEBUG) && !NAZARA_NETWORK_MANAGE_MEMORY #undef NAZARA_NETWORK_MANAGE_MEMORY #define NAZARA_NETWORK_MANAGE_MEMORY 0 diff --git a/include/Nazara/Network/DebugOff.hpp b/include/Nazara/Network/DebugOff.hpp index dd45ac45c..e9df99f1f 100644 --- a/include/Nazara/Network/DebugOff.hpp +++ b/include/Nazara/Network/DebugOff.hpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp +// We suppose that Debug.hpp is already included, same goes for Config.hpp #if NAZARA_NETWORK_MANAGE_MEMORY #undef delete #undef new diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index 3184bd34d..2fc9ac2bd 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -9,11 +9,22 @@ namespace Nz { + /*! + * \brief Constructs a IpAddress object by default + */ + inline IpAddress::IpAddress() : m_isValid(false) { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv4 address + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const IPv4& ip, UInt16 port) : m_ipv4(ip), m_protocol(NetProtocol_IPv4), @@ -22,6 +33,13 @@ namespace Nz { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv6 address + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const IPv6& ip, UInt16 port) : m_ipv6(ip), m_protocol(NetProtocol_IPv6), @@ -30,46 +48,100 @@ namespace Nz { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv4 address (a.b.c.d) + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const UInt8& a, const UInt8& b, const UInt8& c, const UInt8& d, UInt16 port) : IpAddress(IPv4{a, b, c, d}, port) { } + /*! + * \brief Constructs a IpAddress object with an IP and a port + * + * \param ip IPv6 address (a.b.c.d.e.f.g.h) + * \param port Port of the IP + */ + inline IpAddress::IpAddress(const UInt16& a, const UInt16& b, const UInt16& c, const UInt16& d, const UInt16& e, const UInt16& f, const UInt16& g, const UInt16& h, UInt16 port) : IpAddress(IPv6{a, b, c, d, e, f, g, h}, port) { } + /*! + * Constructs a IpAddress object with a C-string + * + * \param address Hostname or textual IP address + */ + inline IpAddress::IpAddress(const char* address) { BuildFromAddress(address); } + /*! + * Constructs a IpAddress object with a string + * + * \param address Hostname or textual IP address + */ + inline IpAddress::IpAddress(const String& address) { BuildFromAddress(address.GetConstBuffer()); } + /*! + * \brief Gets the port + * \return Port attached to the IP address + */ + inline UInt16 IpAddress::GetPort() const { return m_port; } + /*! + * \brief Gets the net protocol + * \return Protocol attached to the IP address + */ + inline NetProtocol IpAddress::GetProtocol() const { return m_protocol; } + /*! + * \brief Checks whether the IP address is valid + * \return true If successful + */ + inline bool IpAddress::IsValid() const { return m_isValid; } + /*! + * \brief Sets the port + * + * \param port Port attached to the IP address + */ + inline void IpAddress::SetPort(UInt16 port) { m_port = port; } + /*! + * \brief Converts IpAddress to IPv4 + * \return Corresponding IPv4 + * + * \remark Produces a NazaraAssert if net protocol is not IPv4 + */ + inline IpAddress::IPv4 IpAddress::ToIPv4() const { NazaraAssert(m_isValid && m_protocol == NetProtocol_IPv4, "Address is not a valid IPv4"); @@ -77,6 +149,13 @@ namespace Nz return m_ipv4; } + /*! + * \brief Converts IpAddress to IPv6 + * \return Corresponding IPv6 + * + * \remark Produces a NazaraAssert if net protocol is not IPv6 + */ + inline IpAddress::IPv6 IpAddress::ToIPv6() const { NazaraAssert(m_isValid && m_protocol == NetProtocol_IPv6, "IP is not a valid IPv6"); @@ -84,6 +163,13 @@ namespace Nz return m_ipv6; } + /*! + * \brief Converts IpAddress to UInt32 + * \return Corresponding UInt32 + * + * \remark Produces a NazaraAssert if net protocol is not IPv4 + */ + inline UInt32 IpAddress::ToUInt32() const { NazaraAssert(m_isValid && m_protocol == NetProtocol_IPv4, "Address is not a valid IPv4"); @@ -94,17 +180,40 @@ namespace Nz UInt32(m_ipv4[3]) << 0; } + /*! + * \brief Converts IpAddress to boolean + * \return true If IpAddress is valid + * + * \see IsValid + */ + inline IpAddress::operator bool() const { return IsValid(); } + /*! + * \brief Output operator + * \return The stream + * + * \param out The stream + * \param address The address to output + */ + inline std::ostream& operator<<(std::ostream& out, const IpAddress& address) { out << "IpAddress(" << address.ToString() << ')'; return out; } + /*! + * \brief Compares the IpAddress to other one + * \return true if the ip addresses are the same + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator==(const IpAddress& first, const IpAddress& second) { // We need to check the validity of each address before comparing them @@ -146,11 +255,27 @@ namespace Nz return true; } + /*! + * \brief Compares the IpAddress to other one + * \return false if the ip addresses are the same + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator!=(const IpAddress& first, const IpAddress& second) { return !operator==(first, second); } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is inferior to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator<(const IpAddress& first, const IpAddress& second) { // If the second address is invalid, there's no way we're lower than it @@ -196,16 +321,40 @@ namespace Nz return false; //< Same address } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is inferior or equal to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator<=(const IpAddress& first, const IpAddress& second) { return !operator<(second, first); } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is greather to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator>(const IpAddress& first, const IpAddress& second) { return second < first; } + /*! + * \brief Compares the IpAddress to other one + * \return true if this ip address is greather or equal to the other one + * + * \param first First ip address to compare + * \param second Second ip address to compare with + */ + inline bool operator>=(const IpAddress& first, const IpAddress& second) { return !operator<(first, second); @@ -217,6 +366,13 @@ namespace std template<> struct hash { + /*! + * \brief Converts IpAddress to hash + * \return Hash of the IpAddress + * + * \param ip IpAddress to hash + */ + size_t operator()(const Nz::IpAddress& ip) const { if (!ip) @@ -224,7 +380,7 @@ namespace std // This is SDBM adapted for IP addresses, tested to generate the least collisions possible // (It doesn't mean it cannot be improved though) - std::size_t h = 0; + std::size_t hash = 0; switch (ip.GetProtocol()) { case Nz::NetProtocol_Any: @@ -233,20 +389,20 @@ namespace std case Nz::NetProtocol_IPv4: { - h = ip.ToUInt32() + (h << 6) + (h << 16) - h; + hash = ip.ToUInt32() + (hash << 6) + (hash << 16) - hash; break; } case Nz::NetProtocol_IPv6: { Nz::IpAddress::IPv6 v6 = ip.ToIPv6(); for (std::size_t i = 0; i < v6.size(); i++) - h = v6[i] + (h << 6) + (h << 16) - h; + hash = v6[i] + (hash << 6) + (hash << 16) - hash; break; } } - return ip.GetPort() + (h << 6) + (h << 16) - h; + return ip.GetPort() + (hash << 6) + (hash << 16) - hash; } }; } diff --git a/include/Nazara/Network/NetPacket.inl b/include/Nazara/Network/NetPacket.inl index c9bbed681..e9765c9dc 100644 --- a/include/Nazara/Network/NetPacket.inl +++ b/include/Nazara/Network/NetPacket.inl @@ -9,21 +9,46 @@ namespace Nz { + /*! + * \brief Constructs a NetPacket object by default + */ + inline NetPacket::NetPacket() : m_netCode(NetCode_Invalid) { } + /*! + * \brief Constructs a NetPacket object with a packet number and a minimal capacity + * + * \param netCode Packet number + * \param minCapacity Minimal capacity of the packet + */ + inline NetPacket::NetPacket(UInt16 netCode, std::size_t minCapacity) { Reset(netCode, minCapacity); } + /*! + * \brief Constructs a NetPacket object with a packet number and raw memory + * + * \param netCode Packet number + * \param ptr Raw memory + * \param size Size of the memory + */ + inline NetPacket::NetPacket(UInt16 netCode, const void* ptr, std::size_t size) { Reset(netCode, ptr, size); } + /*! + * \brief Constructs a NetPacket object with another one by move semantic + * + * \param packet NetPacket to move into this + */ + inline NetPacket::NetPacket(NetPacket&& packet) : ByteStream(std::move(packet)), m_buffer(std::move(packet.m_buffer)), @@ -35,12 +60,23 @@ namespace Nz SetStream(&m_memoryStream); } + /*! + * \brief Destructs the object + */ + inline NetPacket::~NetPacket() { FlushBits(); //< Needs to be done here as the stream will be freed before ByteStream calls it FreeStream(); } + /*! + * \brief Gets the raw buffer + * \return Constant raw buffer + * + * \remark Produces a NazaraAssert if internal buffer is invalid + */ + inline const UInt8* NetPacket::GetConstData() const { NazaraAssert(m_buffer, "Invalid buffer"); @@ -48,6 +84,13 @@ namespace Nz return m_buffer->GetConstBuffer(); } + /*! + * \brief Gets the raw buffer + * \return Raw buffer + * + * \remark Produces a NazaraAssert if internal buffer is invalid + */ + inline UInt8* NetPacket::GetData() const { NazaraAssert(m_buffer, "Invalid buffer"); @@ -55,6 +98,11 @@ namespace Nz return m_buffer->GetBuffer(); } + /*! + * \brief Gets the size of the data + * \return Size of the data + */ + inline size_t NetPacket::GetDataSize() const { if (m_buffer) @@ -63,22 +111,46 @@ namespace Nz return 0; } + /*! + * \brief Gets the packet number + * \return Packet number + */ + inline UInt16 NetPacket::GetNetCode() const { return m_netCode; } + /*! + * \brief Resets the packet + */ + inline void NetPacket::Reset() { FreeStream(); } + /*! + * \brief Resets the packet with a packet number and a minimal capacity + * + * \param netCode Packet number + * \param minCapacity Minimal capacity of the packet + */ + inline void NetPacket::Reset(UInt16 netCode, std::size_t minCapacity) { InitStream(HeaderSize + minCapacity, HeaderSize, OpenMode_ReadWrite); m_netCode = netCode; } + /*! + * \brief Resets the packet with a packet number and raw memory + * + * \param netCode Packet number + * \param ptr Raw memory + * \param size Size of the memory + */ + inline void NetPacket::Reset(UInt16 netCode, const void* ptr, std::size_t size) { InitStream(HeaderSize + size, HeaderSize, OpenMode_ReadOnly); @@ -88,6 +160,14 @@ namespace Nz m_netCode = netCode; } + /*! + * \brief Resizes the packet + * + * \param newSize Size for the resizing operation + * + * \remark Produces a NazaraAssert if internal buffer is invalid + */ + inline void NetPacket::Resize(std::size_t newSize) { NazaraAssert(m_buffer, "Invalid buffer"); @@ -95,11 +175,24 @@ namespace Nz m_buffer->Resize(newSize); } + /*! + * \brief Sets the packet number + * + * \param netCode Packet number + */ + inline void NetPacket::SetNetCode(UInt16 netCode) { m_netCode = netCode; } + /*! + * \brief Moves the NetPacket into this + * \return A reference to this + * + * \param packet NetPacket to move in this + */ + inline NetPacket& Nz::NetPacket::operator=(NetPacket&& packet) { FreeStream(); diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index b2372285d..53e797b59 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -8,31 +8,66 @@ namespace Nz { + /*! + * \brief Closes the connection + */ + inline void RUdpConnection::Close() { m_socket.Close(); } + /*! + * \brief Disconnects the connection + * + * \see Close + */ + inline void RUdpConnection::Disconnect() { Close(); } + /*! + * \brief Gets the bound address + * \return IpAddress we are linked to + */ + inline IpAddress RUdpConnection::GetBoundAddress() const { return m_socket.GetBoundAddress(); } + /*! + * \brief Gets the port of the bound address + * \return Port we are linked to + */ + inline UInt16 RUdpConnection::GetBoundPort() const { return m_socket.GetBoundPort(); } + /*! + * \brief Gets the last error + * \return Socket error + */ + inline SocketError RUdpConnection::GetLastError() const { return m_lastError; } + /*! + * \brief Listens to a socket + * \return true If successfully bound + * + * \param protocol Net protocol to listen to + * \param port Port to listen to + * + * \remark Produces a NazaraAssert if protocol is unknown or any + */ + inline bool RUdpConnection::Listen(NetProtocol protocol, UInt16 port) { NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO @@ -59,16 +94,36 @@ namespace Nz return Listen(any); } + /*! + * \brief Sets the protocol id + * + * \param protocolId Protocol ID like NNet + */ + inline void RUdpConnection::SetProtocolId(UInt32 protocolId) { m_protocol = protocolId; } + /*! + * \brief Sets the time before ack + * + * \param Time before acking to send many together (in ms) + */ + inline void RUdpConnection::SetTimeBeforeAck(UInt32 ms) { m_forceAckSendTime = ms * 1000; //< Store in microseconds for easier handling } - + + /*! + * \brief Computes the difference of sequence + * \return Delta between the two sequences + * + * \param sequence First sequence + * \param sequence2 Second sequence + */ + inline unsigned int RUdpConnection::ComputeSequenceDifference(SequenceIndex sequence, SequenceIndex sequence2) { unsigned int difference; @@ -80,6 +135,13 @@ namespace Nz return 0; } + /*! + * \brief Checks whether the peer has pending packets + * \return true If it is the case + * + * \param peer Data relative to the peer + */ + inline bool RUdpConnection::HasPendingPackets(PeerData& peer) { for (unsigned int priority = PacketPriority_Highest; priority <= PacketPriority_Lowest; ++priority) @@ -94,6 +156,14 @@ namespace Nz return false; } + /*! + * \brief Checks whether the ack is more recent + * \return true If it is the case + * + * \param ack First sequence + * \param ack2 Second sequence + */ + inline bool RUdpConnection::IsAckMoreRecent(SequenceIndex ack, SequenceIndex ack2) { constexpr SequenceIndex maxDifference = std::numeric_limits::max() / 2; @@ -106,6 +176,13 @@ namespace Nz return false; ///< Same ack } + /*! + * \brief Checks whether the connection is reliable + * \return true If it is the case + * + * \remark Produces a NazaraError if enumeration is invalid + */ + inline bool RUdpConnection::IsReliable(PacketReliability reliability) { switch (reliability) @@ -122,6 +199,14 @@ namespace Nz return false; } + /*! + * \brief Simulates the loss of packets on network + * + * \param packetLoss Ratio of packet loss according to bernoulli distribution + * + * \remark Produces a NazaraAssert if packetLoss is not in between 0.0 and 1.0 + */ + inline void RUdpConnection::SimulateNetwork(double packetLoss) { NazaraAssert(packetLoss >= 0.0 && packetLoss <= 1.0, "Packet loss must be in range [0..1]"); diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index 0fcedcf39..fda4671f9 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -79,8 +79,8 @@ namespace Nz PendingPacket m_pendingPacket; UInt64 m_keepAliveInterval; UInt64 m_keepAliveTime; - bool m_isKeepAliveEnabled; bool m_isLowDelayEnabled; + bool m_isKeepAliveEnabled; }; } diff --git a/include/Nazara/Network/TcpClient.inl b/include/Nazara/Network/TcpClient.inl index da292b982..23f5412da 100644 --- a/include/Nazara/Network/TcpClient.inl +++ b/include/Nazara/Network/TcpClient.inl @@ -7,6 +7,10 @@ namespace Nz { + /*! + * \brief Constructs a TcpClient object by default + */ + inline TcpClient::TcpClient() : AbstractSocket(SocketType_TCP), Stream(StreamOption_Sequential), @@ -17,31 +21,62 @@ namespace Nz { } + /*! + * \brief Disconnects the connection + * + * \see Close + */ + inline void TcpClient::Disconnect() { Close(); } + /*! + * \brief Gets the interval between two keep alive pings + * \return Interval in milliseconds between two pings + */ + inline UInt64 TcpClient::GetKeepAliveInterval() const { return m_keepAliveInterval; } + /*! + * \brief Gets the time before expiration of connection + * \return Time in milliseconds before expiration + */ + inline UInt64 TcpClient::GetKeepAliveTime() const { return m_keepAliveTime; } + /*! + * \brief Gets the remote address + * \return Address of peer + */ + inline IpAddress TcpClient::GetRemoteAddress() const { return m_peerAddress; } + /*! + * \brief Checks whether low delay is enabled + * \return true If it is the case + */ + inline bool TcpClient::IsLowDelayEnabled() const { return m_isLowDelayEnabled; } + /*! + * \brief Checks whether the keep alive flag is enabled + * \return true If it is the case + */ + inline bool TcpClient::IsKeepAliveEnabled() const { return m_isKeepAliveEnabled; diff --git a/include/Nazara/Network/TcpServer.inl b/include/Nazara/Network/TcpServer.inl index 5350a58ee..1fcb4eb32 100644 --- a/include/Nazara/Network/TcpServer.inl +++ b/include/Nazara/Network/TcpServer.inl @@ -7,27 +7,58 @@ namespace Nz { + /*! + * \brief Constructs a TcpServer object by default + */ + inline TcpServer::TcpServer() : AbstractSocket(SocketType_TCP) { } + /*! + * \brief Constructs a TcpServer object with another one by move semantic + * + * \param tcpServer TcpServer to move into this + */ + inline TcpServer::TcpServer(TcpServer&& tcpServer) : AbstractSocket(std::move(tcpServer)), m_boundAddress(std::move(tcpServer.m_boundAddress)) { } + /*! + * \brief Gets the bound address + * \return IpAddress we are linked to + */ + inline IpAddress TcpServer::GetBoundAddress() const { return m_boundAddress; } + /*! + * \brief Gets the port of the bound address + * \return Port we are linked to + */ + inline UInt16 TcpServer::GetBoundPort() const { return m_boundAddress.GetPort(); } + /*! + * \brief Listens to a socket + * \return State of the socket + * + * \param protocol Net protocol to listen to + * \param port Port to listen to + * \param queueSize Size of the queue + * + * \remark Produces a NazaraAssert if protocol is unknown or any + */ + inline SocketState TcpServer::Listen(NetProtocol protocol, UInt16 port, unsigned int queueSize) { NazaraAssert(protocol != NetProtocol_Any, "Any protocol not supported for Listen"); //< TODO diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index 96c391436..2aac124af 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -49,7 +49,6 @@ namespace Nz void OnOpened() override; IpAddress m_boundAddress; - SocketState m_state; bool m_isBroadCastingEnabled; }; } diff --git a/include/Nazara/Network/UdpSocket.inl b/include/Nazara/Network/UdpSocket.inl index 9ad4d067b..4096d8c04 100644 --- a/include/Nazara/Network/UdpSocket.inl +++ b/include/Nazara/Network/UdpSocket.inl @@ -6,24 +6,46 @@ namespace Nz { + /*! + * \brief Constructs a UdpSocket object by default + */ + inline UdpSocket::UdpSocket() : AbstractSocket(SocketType_UDP) { } + /*! + * \brief Constructs a UdpSocket object with a net protocol + * + * \param protocol Net protocol to use + */ + inline UdpSocket::UdpSocket(NetProtocol protocol) : UdpSocket() { Create(protocol); } + /*! + * \brief Constructs a UdpSocket object with another one by move semantic + * + * \param udpSocket UdpSocket to move into this + */ + inline UdpSocket::UdpSocket(UdpSocket&& udpSocket) : AbstractSocket(std::move(udpSocket)), - m_boundAddress(std::move(udpSocket.m_boundAddress)), - m_state(udpSocket.m_state) + m_boundAddress(std::move(udpSocket.m_boundAddress)) { } + /*! + * \brief Binds a specific port + * \return State of the socket + * + * \param port Port to bind + */ + inline SocketState UdpSocket::Bind(UInt16 port) { IpAddress any; @@ -47,6 +69,13 @@ namespace Nz return Bind(any); } + /*! + * \brief Creates a UDP socket + * \return true If successful + * + * \param protocol Net protocol to use + */ + bool UdpSocket::Create(NetProtocol protocol) { NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol"); @@ -54,21 +83,41 @@ namespace Nz return Open(protocol); } + /*! + * \brief Gets the bound address + * \return IpAddress we are linked to + */ + inline IpAddress UdpSocket::GetBoundAddress() const { return m_boundAddress; } + /*! + * \brief Gets the port of the bound address + * \return Port we are linked to + */ + inline UInt16 UdpSocket::GetBoundPort() const { return m_boundAddress.GetPort(); } + /*! + * \brief Gets the state of the socket + * \return State of the socket + */ + inline SocketState UdpSocket::GetState() const { return m_state; } + /*! + * \brief Checks whether the broadcasting is enabled + * \return true If it is the case + */ + inline bool UdpSocket::IsBroadcastingEnabled() const { return m_isBroadCastingEnabled; diff --git a/src/Nazara/Network/AbstractSocket.cpp b/src/Nazara/Network/AbstractSocket.cpp index e46a5906a..516364373 100644 --- a/src/Nazara/Network/AbstractSocket.cpp +++ b/src/Nazara/Network/AbstractSocket.cpp @@ -17,6 +17,18 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::AbstractSocket + * \brief Network class that represents the base of socket + * + * \remark This class is abstract + */ + + /*! + * \brief Constructs a AbstractSocket object with a type + */ + AbstractSocket::AbstractSocket(SocketType type) : m_lastError(SocketError_NoError), m_handle(SocketImpl::InvalidHandle), @@ -26,6 +38,12 @@ namespace Nz { } + /*! + * \brief Constructs a AbstractSocket object with another one by move semantic + * + * \param abstractSocket AbstractSocket to move into this + */ + AbstractSocket::AbstractSocket(AbstractSocket&& abstractSocket) : m_protocol(abstractSocket.m_protocol), m_lastError(abstractSocket.m_lastError), @@ -37,11 +55,21 @@ namespace Nz abstractSocket.m_handle = SocketImpl::InvalidHandle; } + /*! + * \brief Destructs the object and calls Close + * + * \see Close + */ + AbstractSocket::~AbstractSocket() { Close(); } + /*! + * \brief Closes the socket + */ + void AbstractSocket::Close() { if (m_handle != SocketImpl::InvalidHandle) @@ -53,6 +81,12 @@ namespace Nz } } + /*! + * \brief Enables blocking + * + * \param blocking Should the read block + */ + void AbstractSocket::EnableBlocking(bool blocking) { if (m_isBlockingEnabled != blocking) @@ -64,6 +98,11 @@ namespace Nz } } + /*! + * \brief Queries the available bytes + * \return Number of bytes which can be read + */ + std::size_t AbstractSocket::QueryAvailableBytes() const { if (m_handle == SocketImpl::InvalidHandle) @@ -72,11 +111,21 @@ namespace Nz return SocketImpl::QueryAvailableBytes(m_handle); } + /*! + * \brief Operation to do when closing socket + */ + void AbstractSocket::OnClose() { UpdateState(SocketState_NotConnected); } + /*! + * \brief Operation to do when opening socket + * + * \remark Produces a NazaraWarning if blocking failed + */ + void AbstractSocket::OnOpened() { SocketError errorCode; @@ -84,6 +133,11 @@ namespace Nz NazaraWarning("Failed to set socket blocking mode (0x" + String::Number(errorCode, 16) + ')'); } + /*! + * \brief Opens the socket according to a net protocol + * \return true If successful + */ + bool AbstractSocket::Open(NetProtocol protocol) { if (m_handle == SocketImpl::InvalidHandle || m_protocol != protocol) @@ -99,6 +153,13 @@ namespace Nz return true; } + /*! + * \brief Opens the socket according to a socket handle + * \return true If successful + * + * \remark Produces a NazaraAssert if handle is invalid + */ + void AbstractSocket::Open(SocketHandle handle) { NazaraAssert(handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -109,6 +170,13 @@ namespace Nz OnOpened(); } + /*! + * \brief Moves the AbstractSocket into this + * \return A reference to this + * + * \param abstractSocket AbstractSocket to move in this + */ + AbstractSocket& AbstractSocket::operator=(AbstractSocket&& abstractSocket) { Close(); diff --git a/src/Nazara/Network/AlgorithmNetwork.cpp b/src/Nazara/Network/AlgorithmNetwork.cpp index 273169005..307ac679a 100644 --- a/src/Nazara/Network/AlgorithmNetwork.cpp +++ b/src/Nazara/Network/AlgorithmNetwork.cpp @@ -11,6 +11,15 @@ namespace Nz { namespace Detail { + /*! + * \brief Parses a decimal number + * \return true If successful + * + * \param str C-string symbolizing the string to parse + * \param number Optional argument to return the number parsed + * \param endOfRead Optional argument to determine where parsing stopped + */ + bool ParseDecimal(const char* str, unsigned int* number, const char** endOfRead) { const char* ptr = str; @@ -35,6 +44,15 @@ namespace Nz return true; } + /*! + * \brief Parses a hexadecimal number + * \return true If successful + * + * \param str C-string symbolizing the string to parse + * \param number Optional argument to return the number parsed + * \param endOfRead Optional argument to determine where parsing stopped + */ + bool ParseHexadecimal(const char* str, unsigned int* number, const char** endOfRead) { const char* ptr = str; @@ -60,10 +78,26 @@ namespace Nz } } - // From http://rosettacode.org/wiki/Parse_an_IP_Address - // Parse a textual IPv4 or IPv6 address, optionally with port, into a binary - // array (for the address, in host order), and an optionally provided port. - // Also, indicate which of those forms (4 or 6) was parsed. + /*! + * \ingroup network + * \brief Parse a textual IPv4 or IPv6 address + * \return true If successful + * + * From http://rosettacode.org/wiki/Parse_an_IP_Address + * Parse a textual IPv4 or IPv6 address, optionally with port, into a binary + * array (for the address, in host order), and an optionally provided port. + * Also, indicate which of those forms (4 or 6) was parsed. + * + * \param addressPtr C-string which symbolizes the ip adress + * \param result Byte array to return the result in + * \param port Optional argument to resolve according to a specific port + * \param isIPv6 Optional argument to determine if the address is IPv6 + * \param endOfRead Optional argument to determine where parsing stopped + * + * \remark Produces a NazaraAssert if addressPtr is invalid + * \remark Produces a NazaraAssert if result is invalid + */ + bool ParseIPAddress(const char* addressPtr, UInt8 result[16], UInt16* port, bool* isIPv6, const char** endOfRead) { NazaraAssert(addressPtr, "Invalid address string"); diff --git a/src/Nazara/Network/IpAddress.cpp b/src/Nazara/Network/IpAddress.cpp index d40e2a581..29be756ea 100644 --- a/src/Nazara/Network/IpAddress.cpp +++ b/src/Nazara/Network/IpAddress.cpp @@ -22,6 +22,19 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::IpAddress + * \brief Network class that represents an IP address + */ + + /*! + * \brief Builds the IP from a hostname + * \return true If successful + * + * \remark address C-string symbolizing the IP address or hostname + */ + bool IpAddress::BuildFromAddress(const char* address) { m_isValid = false; @@ -50,6 +63,13 @@ namespace Nz return true; } + /*! + * \brief Checks whether the IP address is loopback + * \return true If it is the case + * + * \remark Produces a NazaraAssert if internal protocol is invalid (should never happen) + */ + bool IpAddress::IsLoopback() const { if (!m_isValid) @@ -73,6 +93,13 @@ namespace Nz return false; } + /*! + * \brief Gives a string representation + * \return A string representation of the object + * + * \remark Produces a NazaraAssert if internal protocol is invalid (should never happen) + */ + String IpAddress::ToString() const { StringStream stream; @@ -153,6 +180,17 @@ namespace Nz return stream; } + /*! + * \brief Resolves the address based on the IP + * \return Hostname of the address + * + * \param address IP address to resolve + * \param service Optional argument to specify the protocol used + * \param error Optional argument to get the error + * + * \remark Produces a NazaraAssert if address is invalid + */ + String IpAddress::ResolveAddress(const IpAddress& address, String* service, ResolveError* error) { NazaraAssert(address.IsValid(), "Invalid address"); @@ -163,6 +201,18 @@ namespace Nz return hostname; } + /*! + * \brief Resolves the address based on the hostname + * \return Informations about the host: IP(s) of the address, names, ... + * + * \param protocol Net protocol to use + * \param hostname Hostname to resolve + * \param service Specify the service used (http, ...) + * \param error Optional argument to get the error + * + * \remark Produces a NazaraAssert if net protocol is set to unknown + */ + std::vector IpAddress::ResolveHostname(NetProtocol protocol, const String& hostname, const String& service, ResolveError* error) { NazaraAssert(protocol != NetProtocol_Unknown, "Invalid protocol"); diff --git a/src/Nazara/Network/NetPacket.cpp b/src/Nazara/Network/NetPacket.cpp index 7a1c0d7f5..0823f5258 100644 --- a/src/Nazara/Network/NetPacket.cpp +++ b/src/Nazara/Network/NetPacket.cpp @@ -9,11 +9,36 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::NetPacket + * \brief Network class that represents a packet + */ + + /*! + * \brief Operation to do when receiving data + * + * \param netCode Packet number + * \param data Raw memory + * \param size Size of the memory + */ + void NetPacket::OnReceive(UInt16 netCode, const void* data, std::size_t size) { Reset(netCode, data, size); } + /*! + * \brief Operation to do when sending data + * \return Beggining of the raw memory + * + * \param newSize Size of the memory to send + * + * \remark Produces a NazaraAssert if newSize is invalid + * \remark Produces a NazaraAssert if net code is invalid + * \remark Produces a NazaraError if header could not be encoded + */ + const void* NetPacket::OnSend(std::size_t* newSize) const { NazaraAssert(newSize, "Invalid size pointer"); @@ -30,6 +55,15 @@ namespace Nz return m_buffer->GetBuffer(); } + /*! + * \brief Decodes the header of the packet + * \return true If successful + * + * \param data Raw memory + * \param packetSize Size of the packet + * \param netCode Packet number + */ + bool NetPacket::DecodeHeader(const void* data, UInt16* packetSize, UInt16* netCode) { MemoryView stream(data, HeaderSize); @@ -40,6 +74,15 @@ namespace Nz return Unserialize(context, packetSize) && Unserialize(context, netCode); } + /*! + * \brief Encodes the header of the packet + * \return true If successful + * + * \param data Raw memory + * \param packetSize Size of the packet + * \param netCode Packet number + */ + bool NetPacket::EncodeHeader(void* data, UInt16 packetSize, UInt16 netCode) { MemoryView stream(data, HeaderSize); @@ -50,11 +93,19 @@ namespace Nz return Serialize(context, packetSize) && Serialize(context, netCode); } + /*! + * \brief Operation to do when stream is empty + */ + void NetPacket::OnEmptyStream() { Reset(0); } + /*! + * \brief Frees the stream + */ + void NetPacket::FreeStream() { if (!m_buffer) @@ -66,6 +117,16 @@ namespace Nz s_availableBuffers.emplace_back(std::make_pair(size, std::move(m_buffer))); } + /*! + * \brief Inits the internal stream + * + * \param minCapacity Minimal capacity of the stream + * \param cursorPos Position of the cursor in the stream + * \param openMode Flag of the stream + * + * \remark Produces a NazaraAssert if cursor position is greather than the capacity + */ + void NetPacket::InitStream(std::size_t minCapacity, UInt64 cursorPos, UInt32 openMode) { NazaraAssert(minCapacity >= cursorPos, "Cannot init stream with a smaller capacity than wanted cursor pos"); @@ -92,12 +153,21 @@ namespace Nz SetStream(&m_memoryStream); } + /*! + * \brief Initializes the NetPacket class + * \return true If initialization is successful + */ + bool NetPacket::Initialize() { s_availableBuffersMutex = std::make_unique(); return true; } + /*! + * \brief Uninitializes the NetPacket class + */ + void NetPacket::Uninitialize() { s_availableBuffers.clear(); diff --git a/src/Nazara/Network/Network.cpp b/src/Nazara/Network/Network.cpp index 41868b79b..fa3813dd4 100644 --- a/src/Nazara/Network/Network.cpp +++ b/src/Nazara/Network/Network.cpp @@ -24,9 +24,23 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::Network + * \brief Network class that represents the module initializer of Network + */ + + /*! + * \brief Initializes the Network module + * \return true if initialization is successful + * + * \remark Produces a NazaraNotice + * \remark Produces a NazaraError if one submodule failed + */ + bool Network::Initialize() { - if (s_moduleReferenceCounter > 0) + if (IsInitialized()) { s_moduleReferenceCounter++; return true; // Already initialized @@ -68,11 +82,22 @@ namespace Nz return true; } + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + bool Network::IsInitialized() { return s_moduleReferenceCounter != 0; } + /*! + * \brief Uninitializes the Core module + * + * \remark Produces a NazaraNotice + */ + void Network::Uninitialize() { if (s_moduleReferenceCounter != 1) diff --git a/src/Nazara/Network/RUdpConnection.cpp b/src/Nazara/Network/RUdpConnection.cpp index 451d08f1e..1b374d604 100644 --- a/src/Nazara/Network/RUdpConnection.cpp +++ b/src/Nazara/Network/RUdpConnection.cpp @@ -10,6 +10,16 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::RUdpConnection + * \brief Network class that represents a reliable UDP connection + */ + + /*! + * \brief Constructs a RUdpConnection object by default + */ + RUdpConnection::RUdpConnection() : m_peerIterator(0), m_forceAckSendTime(10'000), //< 10ms @@ -23,9 +33,20 @@ namespace Nz { } + /*! + * \brief Connects to the IpAddress + * \return true + * + * \param remoteAddress Address to connect to + * + * \remark Produces a NazaraAssert if socket is not bound + * \remark Produces a NazaraAssert if remote is invalid + * \remark Produces a NazaraAssert if port is not specified + */ + bool RUdpConnection::Connect(const IpAddress& remoteAddress) { - NazaraAssert(m_socket.GetState() != SocketState_Bound, "Socket must be bound first"); + NazaraAssert(m_socket.GetState() == SocketState_Bound, "Socket must be bound first"); NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); NazaraAssert(remoteAddress.GetPort() != 0, "Remote address has no port"); @@ -39,6 +60,16 @@ namespace Nz return true; } + /*! + * \brief Connects to the hostname + * \return true If successful + * + * \param hostName Hostname of the remote + * \param protocol Net protocol to use + * \param service Specify the protocol used + * \param error Optional argument to get the error + */ + bool RUdpConnection::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error) { std::vector results = IpAddress::ResolveHostname(protocol, hostName, service, error); @@ -64,6 +95,13 @@ namespace Nz return Connect(hostnameAddress); } + /*! + * \brief Listens to a socket + * \return true If successfully bound + * + * \param remoteAddress Address to listen to + */ + bool RUdpConnection::Listen(const IpAddress& address) { if (!InitSocket(address.GetProtocol())) @@ -72,8 +110,19 @@ namespace Nz return m_socket.Bind(address) == SocketState_Bound; } + /*! + * \brief Polls the message + * \return true If there is a message + * + * \param message Message to poll + * + * \remark Produces a NazaraAssert if message is invalid + */ + bool RUdpConnection::PollMessage(RUdpMessage* message) { + NazaraAssert(message, "Invalid message"); + if (m_receivedMessages.empty()) return false; @@ -82,6 +131,16 @@ namespace Nz return true; } + /*! + * \brief Sends the packet to a peer + * \return true If peer exists (false may result from disconnected client) + * + * \param peerIp IpAddress of the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + bool RUdpConnection::Send(const IpAddress& peerIp, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) { auto it = m_peerByIP.find(peerIp); @@ -92,6 +151,10 @@ namespace Nz return true; } + /*! + * \brief Updates the reliable connection + */ + void RUdpConnection::Update() { m_currentTime = m_clock.GetMicroseconds(); @@ -156,6 +219,14 @@ namespace Nz //m_activeClients.Reset(); } + /*! + * \brief Disconnects a peer + * + * \param peerIndex Index of the peer + * + * \remark Produces a NazaraNotice + */ + void RUdpConnection::DisconnectPeer(std::size_t peerIndex) { PeerData& peer = m_peers[peerIndex]; @@ -193,6 +264,15 @@ namespace Nz m_peers.pop_back(); } + /*! + * \brief Enqueues a packet in the sending list + * + * \param peer Data relative to the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + void RUdpConnection::EnqueuePacket(PeerData& peer, PacketPriority priority, PacketReliability reliability, const NetPacket& packet) { UInt16 protocolBegin = static_cast(m_protocol & 0xFFFF); @@ -208,6 +288,15 @@ namespace Nz EnqueuePacketInternal(peer, priority, reliability, std::move(data)); } + /*! + * \brief Enqueues internally a packet in the sending list + * + * \param peer Data relative to the peer + * \param priority Priority of the packet + * \param reliability Policy of reliability of the packet + * \param packet Packet to send + */ + void RUdpConnection::EnqueuePacketInternal(PeerData& peer, PacketPriority priority, PacketReliability reliability, NetPacket&& data) { PendingPacket pendingPacket; @@ -219,6 +308,13 @@ namespace Nz m_activeClients.UnboundedSet(peer.index); } + /*! + * \brief Inits the internal socket + * \return true If successful + * + * \param protocol Net protocol to use + */ + bool RUdpConnection::InitSocket(NetProtocol protocol) { CallOnExit updateLastError([this] @@ -233,6 +329,14 @@ namespace Nz return true; } + /*! + * \brief Processes the acks + * + * \param peer Data relative to the peer + * \param lastAck Last index of the ack + * \param ackBits Bits for acking + */ + void RUdpConnection::ProcessAcks(PeerData& peer, SequenceIndex lastAck, UInt32 ackBits) { auto it = peer.pendingAckQueue.begin(); @@ -257,6 +361,14 @@ namespace Nz } } + /*! + * \brief Registers a peer + * \return Data relative to the peer + * + * \param address Address of the peer + * \param state Status of the peer + */ + RUdpConnection::PeerData& RUdpConnection::RegisterPeer(const IpAddress& address, PeerState state) { PeerData data; @@ -266,7 +378,7 @@ namespace Nz data.index = m_peers.size(); data.lastPacketTime = m_currentTime; data.lastPingTime = m_currentTime; - data.roundTripTime = 1000000; ///< Okay that's quite a lot + data.roundTripTime = 1'000'000; ///< Okay that's quite a lot data.state = state; m_activeClients.UnboundedSet(data.index); @@ -276,6 +388,14 @@ namespace Nz return m_peers.back(); } + /*! + * \brief Operation to do when client requests a connection + * + * \param address Address of the peer + * \param sequenceId Sequence index for the ack + * \param token Token for connection + */ + void RUdpConnection::OnClientRequestingConnection(const IpAddress& address, SequenceIndex sequenceId, UInt64 token) { // Call hook to check if client should be accepted or not @@ -292,6 +412,13 @@ namespace Nz EnqueuePacket(client, PacketPriority_Immediate, PacketReliability_Reliable, connectionAcceptedPacket); } + /*! + * \brief Operation to do when a packet is lost + * + * \param peer Data relative to the peer + * \param packet Pending packet + */ + void RUdpConnection::OnPacketLost(PeerData& peer, PendingAckPacket&& packet) { //NazaraNotice(m_socket.GetBoundAddress().ToString() + ": Lost packet " + String::Number(packet.sequenceId)); @@ -300,6 +427,14 @@ namespace Nz EnqueuePacketInternal(peer, packet.priority, packet.reliability, std::move(packet.data)); } + /*! + * \brief Operation to do when receiving a packet + * + * \param peerIndex Index of the peer + * + * \remark Produces a NazaraNotice + */ + void RUdpConnection::OnPacketReceived(const IpAddress& peerIp, NetPacket&& packet) { UInt16 protocolBegin; @@ -436,6 +571,13 @@ namespace Nz } } + /*! + * \brief Sends a packet to a peer + * + * \param peer Data relative to the peer + * \param packet Pending packet + */ + void RUdpConnection::SendPacket(PeerData& peer, PendingPacket&& packet) { if (peer.state == PeerState_WillAck) @@ -448,7 +590,7 @@ namespace Nz { if (ack == remoteSequence) continue; - + unsigned int difference = ComputeSequenceDifference(remoteSequence, ack); if (difference <= 32U) previousAcks |= (1U << (difference - 1)); @@ -473,6 +615,11 @@ namespace Nz peer.pendingAckQueue.emplace_back(std::move(pendingAckPacket)); } + /*! + * \brief Initializes the RUdpConnection class + * \return true + */ + bool RUdpConnection::Initialize() { std::random_device device; @@ -481,6 +628,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the RUdpConnection class + */ + void RUdpConnection::Uninitialize() { } diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index a134cf870..cf123ff89 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -20,6 +20,22 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::TcpClient + * \brief Network class that represents a client in a TCP connection + */ + + /*! + * \brief Connects to the IpAddress + * \return State of the socket + * + * \param remoteAddress Address to connect to + * + * \remark Produces a NazaraAssert if remote is invalid + * \remark Produces a NazaraAssert if remote's port is not specified + */ + SocketState TcpClient::Connect(const IpAddress& remoteAddress) { NazaraAssert(remoteAddress.IsValid(), "Invalid remote address"); @@ -45,6 +61,17 @@ namespace Nz return state; } + + /*! + * \brief Connects to the hostname + * \return State of the socket + * + * \param hostName Hostname of the remote + * \param protocol Net protocol to use + * \param service Specify the protocol used + * \param error Optional argument to get the error + */ + SocketState TcpClient::Connect(const String& hostName, NetProtocol protocol, const String& service, ResolveError* error) { UpdateState(SocketState_Resolving); @@ -73,6 +100,14 @@ namespace Nz return Connect(hostnameAddress); } + /*! + * \brief Enables low delay in emitting + * + * \param lowDelay Should low delay be used + * + * \remark This may produce lag + */ + void TcpClient::EnableLowDelay(bool lowDelay) { if (m_isLowDelayEnabled != lowDelay) @@ -84,6 +119,14 @@ namespace Nz } } + /*! + * \brief Enables the keep alive flag + * + * \param keepAlive Should the connection be kept alive + * \param msTime Time in milliseconds before expiration + * \param msInterval Interval in milliseconds between two pings + */ + void TcpClient::EnableKeepAlive(bool keepAlive, UInt64 msTime, UInt64 msInterval) { if (m_isKeepAliveEnabled != keepAlive || m_keepAliveTime != msTime || m_keepAliveInterval != msInterval) @@ -97,22 +140,51 @@ namespace Nz } } + /*! + * \brief Checks whether the stream reached the end of the stream + * \return true if there is no more available bytes + */ + bool TcpClient::EndOfStream() const { return QueryAvailableBytes() == 0; } + /*! + * \brief Gets the position of the cursor + * \return 0 + * + * \remark Produces a NazaraError because it is a special stream + */ + UInt64 TcpClient::GetCursorPos() const { NazaraError("GetCursorPos() cannot be used on sequential streams"); return 0; } + /*! + * \brief Gets the size of the raw memory available + * \return Size of the memory available + */ + UInt64 TcpClient::GetSize() const { return QueryAvailableBytes(); } + /*! + * \brief Receives the data available + * \return true If data received + * + * \param buffer Raw memory to write + * \param size Size of the buffer + * \param received Optional argument to get the number of bytes received + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool TcpClient::Receive(void* buffer, std::size_t size, std::size_t* received) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -142,6 +214,17 @@ namespace Nz return true; } + /*! + * \brief Receives the packet available + * \return true If packet received + * + * \param packet Packet to receive + * + * \remark Produces a NazaraAssert if packet is invalid + * \remark Produces a NazaraAssert if packet size is inferior to the header size + * \remark Produces a NazaraWarning if packet's header is invalid + */ + bool TcpClient::ReceivePacket(NetPacket* packet) { //TODO: Every packet requires at least two Receive call, using an internal buffer of a fixed size would prevent this @@ -157,6 +240,7 @@ namespace Nz m_pendingPacket.received += received; + //TODO: Should never happen in production ! NazaraAssert(m_pendingPacket.received <= NetPacket::HeaderSize, "Received more data than header size"); if (m_pendingPacket.received >= NetPacket::HeaderSize) { @@ -185,6 +269,7 @@ namespace Nz m_pendingPacket.received += received; + //TODO: Should never happen in production ! NazaraAssert(m_pendingPacket.received <= packetSize, "Received more data than packet size"); if (m_pendingPacket.received >= packetSize) { @@ -202,6 +287,19 @@ namespace Nz return false; } + /*! + * \brief Sends the data available + * \return true If data sended + * + * \param buffer Raw memory to read + * \param size Size of the buffer + * \param sent Optional argument to get the number of bytes sent + * + * \remark Large sending are handled, you do not need to call this multiple time + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool TcpClient::Send(const void* buffer, std::size_t size, std::size_t* sent) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -244,6 +342,15 @@ namespace Nz return true; } + /*! + * \brief Sends the packet available + * \return true If packet sent + * + * \param packet Packet to send + * + * \remark Produces a NazaraError if packet could not be prepared for sending + */ + bool TcpClient::SendPacket(const NetPacket& packet) { std::size_t size = 0; @@ -258,12 +365,30 @@ namespace Nz return Send(ptr, size, nullptr); } + /*! + * \brief Sets the position of the cursor + * \return false + * + * \param offset Offset according to the beginning of the stream + * + * \remark Produces a NazaraError because it is a special stream + */ + bool TcpClient::SetCursorPos(UInt64 offset) { NazaraError("SetCursorPos() cannot be used on sequential streams"); return false; } + /*! + * \brief Waits for being connected before time out + * \return true If connection is successful + * + * \param msTimeout Time in milliseconds before time out + * + * \remark Produces a NazaraAssert if socket is invalid + */ + bool TcpClient::WaitForConnected(UInt64 msTimeout) { switch (m_state) @@ -308,10 +433,18 @@ namespace Nz return false; } + /*! + * \brief Flushes the stream + */ + void TcpClient::FlushStream() { } + /*! + * \brief Operation to do when closing socket + */ + void TcpClient::OnClose() { AbstractSocket::OnClose(); @@ -320,6 +453,12 @@ namespace Nz m_peerAddress = IpAddress::Invalid; } + /*! + * \brief Operation to do when opening socket + * + * \remark Produces a NazaraWarning if delay mode or keep alive failed + */ + void TcpClient::OnOpened() { AbstractSocket::OnOpened(); @@ -336,6 +475,16 @@ namespace Nz m_openMode = OpenMode_ReadWrite; } + /*! + * \brief Reads blocks + * \return Number of blocks read + * + * \param buffer Preallocated buffer to contain information read + * \param size Size of the read and thus of the buffer + * + * \remark Produces a NazaraAssert if socket is invalid + */ + std::size_t TcpClient::ReadBlock(void* buffer, std::size_t size) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -357,6 +506,13 @@ namespace Nz return received; } + /*! + * \brief Resets the connection with a new socket and a peer address + * + * \param handle Socket to connect + * \param peerAddress Address to connect to + */ + void TcpClient::Reset(SocketHandle handle, const IpAddress& peerAddress) { Open(handle); @@ -365,8 +521,20 @@ namespace Nz UpdateState(SocketState_Connected); } + /*! + * \brief Writes blocks + * \return Number of blocks written + * + * \param buffer Preallocated buffer containing information to write + * \param size Size of the writting and thus of the buffer + * + * \remark Produces a NazaraAssert if buffer is nullptr + * \remark Produces a NazaraAssert if socket is invalid + */ + std::size_t TcpClient::WriteBlock(const void* buffer, std::size_t size) { + NazaraAssert(buffer, "Invalid buffer"); NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); CallOnExit restoreBlocking; diff --git a/src/Nazara/Network/TcpServer.cpp b/src/Nazara/Network/TcpServer.cpp index b5995b6f5..7a33c066b 100644 --- a/src/Nazara/Network/TcpServer.cpp +++ b/src/Nazara/Network/TcpServer.cpp @@ -19,6 +19,22 @@ namespace Nz { + /*! + * \ingroup network + * \class Nz::TcpServer + * \brief Network class that represents a server in a TCP connection + */ + + /*! + * \brief Accepts a client + * \return true If client'socket is valid + * + * \param newClient Client connection + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if newClient is invalid + */ + bool TcpServer::AcceptClient(TcpClient* newClient) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Server isn't listening"); @@ -35,6 +51,16 @@ namespace Nz return false; } + /*! + * \brief Listens to a socket + * \return State of the socket + * + * \param address Address to listen to + * \param queueSize Size of the queue + * + * \remark Produces a NazaraAssert if address is invalid + */ + SocketState TcpServer::Listen(const IpAddress& address, unsigned int queueSize) { NazaraAssert(address.IsValid(), "Invalid address"); @@ -49,6 +75,10 @@ namespace Nz return state; } + /*! + * \brief Operation to do when closing socket + */ + void TcpServer::OnClose() { AbstractSocket::OnClose(); @@ -56,6 +86,10 @@ namespace Nz m_boundAddress = IpAddress::Invalid; } + /*! + * \brief Operation to do when opening socket + */ + void TcpServer::OnOpened() { AbstractSocket::OnOpened(); diff --git a/src/Nazara/Network/UdpSocket.cpp b/src/Nazara/Network/UdpSocket.cpp index a233881ea..b49aedcf3 100644 --- a/src/Nazara/Network/UdpSocket.cpp +++ b/src/Nazara/Network/UdpSocket.cpp @@ -17,6 +17,16 @@ namespace Nz { + /*! + * \brief Binds a specific IpAddress + * \return State of the socket + * + * \param address Address to bind + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if address is invalid + */ + SocketState UdpSocket::Bind(const IpAddress& address) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket hasn't been created"); @@ -30,6 +40,14 @@ namespace Nz return state; } + /*! + * \brief Enables broadcasting + * + * \param broadcasting Should the UDP broadcast + * + * \remark Produces a NazaraAssert if socket is invalid + */ + void UdpSocket::EnableBroadcasting(bool broadcasting) { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); @@ -41,6 +59,13 @@ namespace Nz } } + /*! + * \brief Gets the maximum datagram size allowed + * \return Number of bytes + * + * \remark Produces a NazaraAssert if socket is invalid + */ + std::size_t UdpSocket::QueryMaxDatagramSize() { NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket hasn't been created"); @@ -48,8 +73,22 @@ namespace Nz return SocketImpl::QueryMaxDatagramSize(m_handle, &m_lastError); } + /*! + * \brief Receives the data available + * \return true If data received + * + * \param buffer Raw memory to write + * \param size Size of the buffer + * \param from IpAddress of the peer + * \param received Optional argument to get the number of bytes received + * + * \remark Produces a NazaraAssert if socket is invalid + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool UdpSocket::Receive(void* buffer, std::size_t size, IpAddress* from, std::size_t* received) { + NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Socket hasn't been created"); NazaraAssert(buffer && size > 0, "Invalid buffer"); int read; @@ -62,8 +101,21 @@ namespace Nz return true; } + /*! + * \brief Receives the packet available + * \return true If packet received + * + * \param packet Packet to receive + * \param from IpAddress of the peer + * + * \remark Produces a NazaraAssert if packet is invalid + * \remark Produces a NazaraWarning if packet's header is invalid + */ + bool UdpSocket::ReceivePacket(NetPacket* packet, IpAddress* from) { + NazaraAssert(packet, "Invalid packet"); + // I'm not sure what's the best between having a 65k bytes buffer ready for any datagram size // or querying the next datagram size every time, for now I'll leave it as is packet->Reset(NetCode_Invalid, std::numeric_limits::max()); @@ -97,6 +149,20 @@ namespace Nz return true; } + /*! + * \brief Sends the data available + * \return true If data sended + * + * \param to IpAddress of the peer + * \param buffer Raw memory to read + * \param size Size of the buffer + * \param sent Optional argument to get the number of bytes sent + * + * \remark Produces a NazaraAssert if peer address is invalid + * \remark Produces a NazaraAssert if protocol of communication is not the same than the peer + * \remark Produces a NazaraAssert if buffer and its size is invalid + */ + bool UdpSocket::Send(const IpAddress& to, const void* buffer, std::size_t size, std::size_t* sent) { NazaraAssert(to.IsValid(), "Invalid ip address"); @@ -113,6 +179,16 @@ namespace Nz return true; } + /*! + * \brief Sends the packet available + * \return true If packet sent + * + * \param to IpAddress of the peer + * \param packet Packet to send + * + * \remark Produces a NazaraError if packet could not be prepared for sending + */ + bool UdpSocket::SendPacket(const IpAddress& to, const NetPacket& packet) { std::size_t size = 0; @@ -127,6 +203,10 @@ namespace Nz return Send(to, ptr, size, nullptr); } + /*! + * \brief Operation to do when closing socket + */ + void UdpSocket::OnClose() { AbstractSocket::OnClose(); @@ -134,6 +214,10 @@ namespace Nz m_boundAddress = IpAddress::Invalid; } + /*! + * \brief Operation to do when opening socket + */ + void UdpSocket::OnOpened() { AbstractSocket::OnOpened(); diff --git a/tests/Engine/Network/IpAddress.cpp b/tests/Engine/Network/IpAddress.cpp new file mode 100644 index 000000000..8bb3e7d16 --- /dev/null +++ b/tests/Engine/Network/IpAddress.cpp @@ -0,0 +1,47 @@ +#include +#include + +SCENARIO("IpAddress", "[NETWORK][IPADDRESS]") +{ + GIVEN("Two default IpAddress") + { + Nz::IpAddress ipAddressV4; + Nz::IpAddress ipAddressV6; + + WHEN("We parse localhost") + { + Nz::String localhostIPv4 = "127.0.0.1"; + Nz::String localhostIPv6 = "::1"; + REQUIRE(ipAddressV4.BuildFromAddress(localhostIPv4.GetConstBuffer())); + REQUIRE(ipAddressV6.BuildFromAddress(localhostIPv6.GetConstBuffer())); + + THEN("It's the loop back") + { + REQUIRE(ipAddressV4.IsLoopback()); + REQUIRE(ipAddressV6.IsLoopback()); + } + } + } + + GIVEN("No IpAddress") + { + WHEN("We get the IP of Nazara") + { + std::vector hostnameInfos = Nz::IpAddress::ResolveHostname(Nz::NetProtocol_IPv4, "nazara.digitalpulsesoftware.net"); + + THEN("Result is not null") + { + REQUIRE(!hostnameInfos.empty()); + } + } + + WHEN("We convert IP to hostname") + { + Nz::IpAddress google(8, 8, 8, 8); + THEN("Google (DNS) is 8.8.8.8") + { + REQUIRE(Nz::IpAddress::ResolveAddress(google) == "google-public-dns-a.google.com"); + } + } + } +} diff --git a/tests/Engine/Network/RUdpConnection.cpp b/tests/Engine/Network/RUdpConnection.cpp new file mode 100644 index 000000000..a39100e94 --- /dev/null +++ b/tests/Engine/Network/RUdpConnection.cpp @@ -0,0 +1,40 @@ +#include +#include + +#include + +SCENARIO("RUdpConnection", "[NETWORK][RUDPCONNECTION]") +{ + GIVEN("Two RUdpConnection, one client, one server") + { + Nz::UInt16 port = 64266; + Nz::RUdpConnection server; + REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port)); + Nz::IpAddress serverIP = server.GetBoundAddress(); + REQUIRE(serverIP.IsValid()); + Nz::RUdpConnection client; + REQUIRE(client.Listen(Nz::NetProtocol_IPv4, port + 1)); + Nz::IpAddress clientIP = client.GetBoundAddress(); + REQUIRE(client.Connect(serverIP)); + REQUIRE(clientIP.IsValid()); + + WHEN("We send data from client") + { + Nz::NetPacket packet(1); + Nz::Vector3f vector123(1.f, 2.f, 3.f); + packet << vector123; + REQUIRE(client.Send(serverIP, Nz::PacketPriority_Immediate, Nz::PacketReliability_Reliable, packet)); + client.Update(); + + THEN("We should get it on the server") + { + Nz::RUdpMessage rudpMessage; + server.Update(); + REQUIRE(server.PollMessage(&rudpMessage)); + Nz::Vector3f result; + rudpMessage.data >> result; + REQUIRE(result == vector123); + } + } + } +} diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp new file mode 100644 index 000000000..63b4fe2df --- /dev/null +++ b/tests/Engine/Network/TCP.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +#include +#include + +#include + +SCENARIO("TCP", "[NETWORK][TCP]") +{ + GIVEN("Two TCP, one client, one server") + { + // Avoid reusing the same socket + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dis(1025, 64245); + + Nz::UInt16 port = dis(gen); + Nz::TcpServer server; + REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound); + Nz::IpAddress serverIP = server.GetBoundAddress(); + REQUIRE(serverIP.IsValid()); + Nz::TcpClient client; + REQUIRE(client.Connect(serverIP) == Nz::SocketState_Connecting); + Nz::IpAddress clientIP = client.GetRemoteAddress(); + REQUIRE(clientIP.IsValid()); + + Nz::TcpClient serverToClient; + REQUIRE(server.AcceptClient(&serverToClient)); + + WHEN("We send data from client") + { + Nz::NetPacket packet(1); + Nz::Vector3f vector123(1.f, 2.f, 3.f); + packet << vector123; + REQUIRE(client.SendPacket(packet)); + + THEN("We should get it on the server") + { + Nz::NetPacket resultPacket; + REQUIRE(serverToClient.ReceivePacket(&resultPacket)); + Nz::Vector3f result; + resultPacket >> result; + REQUIRE(result == vector123); + } + } + } +} diff --git a/tests/Engine/Network/UdpSocket.cpp b/tests/Engine/Network/UdpSocket.cpp new file mode 100644 index 000000000..3f199f09e --- /dev/null +++ b/tests/Engine/Network/UdpSocket.cpp @@ -0,0 +1,39 @@ +#include +#include + +#include +#include + +SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]") +{ + GIVEN("Two UdpSocket, one client, one server") + { + Nz::UInt16 port = 64256; + Nz::UdpSocket server(Nz::NetProtocol_IPv4); + REQUIRE(server.Bind(port) == Nz::SocketState_Bound); + Nz::IpAddress serverIP = server.GetBoundAddress(); + REQUIRE(serverIP.IsValid()); + Nz::UdpSocket client(Nz::NetProtocol_IPv4); + REQUIRE(client.Bind(port + 1) == Nz::SocketState_Bound); + Nz::IpAddress clientIP = client.GetBoundAddress(); + REQUIRE(clientIP.IsValid()); + + WHEN("We send data from client") + { + Nz::NetPacket packet(1); + Nz::Vector3f vector123(1.f, 2.f, 3.f); + packet << vector123; + REQUIRE(client.SendPacket(serverIP, packet)); + + THEN("We should get it on the server") + { + Nz::NetPacket resultPacket; + Nz::IpAddress fromIp; + REQUIRE(server.ReceivePacket(&resultPacket, &fromIp)); + Nz::Vector3f result; + resultPacket >> result; + REQUIRE(result == vector123); + } + } + } +} From aa86db9a880f13840c19067e12661c23fbee5458 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:26:32 +0200 Subject: [PATCH 061/383] Fix loading of MD5 Former-commit-id: 06120fb3631516af6dd6dc7a295a7393823d8874 --- src/Nazara/Utility/Animation.cpp | 2 ++ src/Nazara/Utility/Formats/MD5AnimParser.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index bbd57b1df..62591344b 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -37,6 +37,8 @@ namespace Nz Animation::~Animation() { OnAnimationRelease(this); + + Destroy(); } bool Animation::AddSequence(const Sequence& sequence) diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index 321ee8692..9cd930c2e 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -285,7 +285,8 @@ namespace Nz if (!Advance()) return false; - if (std::sscanf(&m_currentLine[0], "( %f %f %f ) ( %f %f %f )", &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, + // Space is important for the buffer of \n + if (std::sscanf(&m_currentLine[0], " ( %f %f %f ) ( %f %f %f )", &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 6) { UnrecognizedLine(true); @@ -324,7 +325,8 @@ namespace Nz return false; Vector3f min, max; - if (std::sscanf(&m_currentLine[0], "( %f %f %f ) ( %f %f %f )", &min.x, &min.y, &min.z, &max.x, &max.y, &max.z) != 6) + // Space is important for the buffer of \n + if (std::sscanf(&m_currentLine[0], " ( %f %f %f ) ( %f %f %f )", &min.x, &min.y, &min.z, &max.x, &max.y, &max.z) != 6) { UnrecognizedLine(true); return false; From 9f14f63ce8781a05d604e13fda6a5b1522a27f16 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:27:07 +0200 Subject: [PATCH 062/383] Slightly faster (about 5%) Former-commit-id: db83aebd174362887b475c7c55a8a027f1ab0bef --- src/Nazara/Utility/AlgorithmUtility.cpp | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index 7f4dbaf44..c13d393dd 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -105,9 +105,9 @@ namespace Nz for (unsigned int i = 0; i < recursionLevel; ++i) { std::size_t triangleCount = triangles.size(); - for (std::size_t j = 0; j < triangleCount; ++j) + for (std::size_t i = 0; i < triangleCount; ++i) { - Vector3ui& triangle = triangles[j]; + Vector3ui& triangle = triangles[i]; unsigned int a = GetMiddleVertex(triangle.x, triangle.y); unsigned int b = GetMiddleVertex(triangle.y, triangle.z); @@ -333,21 +333,20 @@ namespace Nz } private: - float CalculateVertexScore(unsigned int vertex) const + float CalculateVertexScore(VertexCacheData& vertex) const { - const VertexCacheData* v = &m_vertices[vertex]; - if (v->remaining_valence <= 0) + if (vertex.remaining_valence <= 0) // No tri needs this vertex! return -1.0f; float ret = 0.0f; - if (v->position_in_cache < 0) + if (vertex.position_in_cache < 0) { // Vertex is not in FIFO cache - no score. } else { - if (v->position_in_cache < 3) + if (vertex.position_in_cache < 3) { // This vertex was used in the last triangle, // so it has a fixed score, whichever of the three @@ -360,14 +359,14 @@ namespace Nz { // Points for being high in the cache. const float Scaler = 1.0f / (32 - 3); - ret = 1.0f - (v->position_in_cache - 3) * Scaler; + ret = 1.0f - (vertex.position_in_cache - 3) * Scaler; ret = std::pow(ret, m_cacheDecayPower); } } // Bonus points for having a low number of tris still to // use the vert, so we get rid of lone verts quickly. - float valence_boost = std::pow(static_cast(v->remaining_valence), -m_valenceBoostPower); + float valence_boost = std::pow(static_cast(vertex.remaining_valence), -m_valenceBoostPower); ret += m_valenceBoostScale * valence_boost; return ret; @@ -378,8 +377,8 @@ namespace Nz int FullScoreRecalculation() { // calculate score for all vertices - for (unsigned int i = 0; i < m_vertices.size(); ++i) - m_vertices[i].current_score = CalculateVertexScore(i); + for (VertexCacheData& vertex : m_vertices) + vertex.current_score = CalculateVertexScore(vertex); // calculate scores for all active triangles float max_score = std::numeric_limits::lowest(); @@ -548,13 +547,13 @@ namespace Nz float sum = 0.f; for (unsigned int i = 0; i < 3; ++i) { - VertexCacheData* v = &m_vertices[t->verts[i]]; - float sc = v->current_score; - if (!v->calculated) - sc = CalculateVertexScore(t->verts[i]); + VertexCacheData& v = m_vertices[t->verts[i]]; + float sc = v.current_score; + if (!v.calculated) + sc = CalculateVertexScore(v); - v->current_score = sc; - v->calculated = true; + v.current_score = sc; + v.calculated = true; sum += sc; } From a81cc4a2958ab7d452ca5a3d8c3b56031cd4751b Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 14:27:31 +0200 Subject: [PATCH 063/383] Default behaviour without precision on name Former-commit-id: 28959f509e5baee43109a66e17a8703a480288e4 --- src/Nazara/Graphics/Formats/MeshLoader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index ffd2b423e..6769072bb 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -27,6 +27,12 @@ namespace Nz String filePath; if (matData.GetStringParameter(MaterialData::FilePath, &filePath)) { + if (!File::Exists(filePath)) + { + NazaraWarning("Shader name does not refer to an existing file, \".tga\" is used by default"); + filePath += ".tga"; + } + MaterialRef material = Material::New(); if (material->LoadFromFile(filePath, parameters.material)) model->SetMaterial(i, std::move(material)); From 6a583b8231810399a8d3cbed423618fbaa486ed3 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Mon, 30 May 2016 20:43:27 +0200 Subject: [PATCH 064/383] Fail in copy-paste Former-commit-id: 01bb59a1dcdc1dcf2e5ea36efbda52b1311ce3f1 --- src/Nazara/Utility/AlgorithmUtility.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index c13d393dd..d82af98af 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -105,9 +105,9 @@ namespace Nz for (unsigned int i = 0; i < recursionLevel; ++i) { std::size_t triangleCount = triangles.size(); - for (std::size_t i = 0; i < triangleCount; ++i) + for (std::size_t j = 0; j < triangleCount; ++j) { - Vector3ui& triangle = triangles[i]; + Vector3ui& triangle = triangles[j]; unsigned int a = GetMiddleVertex(triangle.x, triangle.y); unsigned int b = GetMiddleVertex(triangle.y, triangle.z); From 6557fedf4724046d477c22bb16565d755ff8bff1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 31 May 2016 09:02:35 +0200 Subject: [PATCH 065/383] Physics: Upgrade Newton to 3.13 Former-commit-id: 9e3777a39842ab18e103a75a590d8d58d25b10c5 --- include/Nazara/Physics/Geom.hpp | 2 +- include/Nazara/Physics/PhysObject.hpp | 2 +- include/Nazara/Physics/PhysWorld.hpp | 2 +- src/Nazara/Physics/PhysObject.cpp | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/Nazara/Physics/Geom.hpp b/include/Nazara/Physics/Geom.hpp index 34b6c58ba..23a02c72b 100644 --- a/include/Nazara/Physics/Geom.hpp +++ b/include/Nazara/Physics/Geom.hpp @@ -20,7 +20,7 @@ #include #include -struct NewtonCollision; +class NewtonCollision; namespace Nz { diff --git a/include/Nazara/Physics/PhysObject.hpp b/include/Nazara/Physics/PhysObject.hpp index 7df72b1d1..d4d9c61b7 100644 --- a/include/Nazara/Physics/PhysObject.hpp +++ b/include/Nazara/Physics/PhysObject.hpp @@ -15,7 +15,7 @@ #include #include -struct NewtonBody; +class NewtonBody; namespace Nz { diff --git a/include/Nazara/Physics/PhysWorld.hpp b/include/Nazara/Physics/PhysWorld.hpp index b6fd7eae3..0300048b5 100644 --- a/include/Nazara/Physics/PhysWorld.hpp +++ b/include/Nazara/Physics/PhysWorld.hpp @@ -12,7 +12,7 @@ #include #include -struct NewtonWorld; +class NewtonWorld; namespace Nz { diff --git a/src/Nazara/Physics/PhysObject.cpp b/src/Nazara/Physics/PhysObject.cpp index 1b4816ee6..1ee4a44d5 100644 --- a/src/Nazara/Physics/PhysObject.cpp +++ b/src/Nazara/Physics/PhysObject.cpp @@ -68,7 +68,7 @@ namespace Nz PhysObject::~PhysObject() { if (m_body) - NewtonDestroyBody(m_world->GetHandle(), m_body); + NewtonDestroyBody(m_body); } void PhysObject::AddForce(const Vector3f& force, CoordSys coordSys) @@ -304,11 +304,13 @@ namespace Nz Vector3f min, max; NewtonBodyGetAABB(m_body, min, max); - NewtonWorldForEachBodyInAABBDo(m_world->GetHandle(), min, max, [](const NewtonBody* const body, void* const userData) + NewtonWorldForEachBodyInAABBDo(m_world->GetHandle(), min, max, [](const NewtonBody* const body, void* const userData) -> int { NazaraUnused(userData); NewtonBodySetSleepState(body, 0); - }, nullptr); + return 1; + }, + nullptr); } /*for (std::set::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) (*it)->PhysObjectOnUpdate(this);*/ @@ -317,7 +319,7 @@ namespace Nz PhysObject& PhysObject::operator=(PhysObject&& object) { if (m_body) - NewtonDestroyBody(m_world->GetHandle(), m_body); + NewtonDestroyBody(m_body); m_body = object.m_body; m_forceAccumulator = std::move(object.m_forceAccumulator); From 6d4a09022be6b565c17fb128ed3382dc1b0dffc1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 31 May 2016 09:06:24 +0200 Subject: [PATCH 066/383] Physics: Add new libraries for Windows Former-commit-id: 93deb21045e66e786819066593dad466e7ce9742 --- build/scripts/modules/physics.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/modules/physics.lua b/build/scripts/modules/physics.lua index fbf6f39c8..f6d485a67 100644 --- a/build/scripts/modules/physics.lua +++ b/build/scripts/modules/physics.lua @@ -2,5 +2,5 @@ MODULE.Name = "Physics" MODULE.Libraries = { "NazaraCore", - "newton" + "Newton" } From db8a222f629b56394f36bf102d1f9d34a019e62e Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Tue, 31 May 2016 21:50:31 +0200 Subject: [PATCH 069/383] Fix for problems signaled by clang static analyzer Former-commit-id: 835f639c45509b0d55fe716e51e3285ea2a89da4 --- include/Nazara/Network/RUdpConnection.inl | 2 +- src/Nazara/Core/Posix/FileImpl.cpp | 13 +++++++- src/Nazara/Core/String.cpp | 31 ++++++-------------- src/Nazara/Graphics/DepthRenderTechnique.cpp | 3 +- tests/Engine/Core/String.cpp | 20 +++++++++++++ 5 files changed, 43 insertions(+), 26 deletions(-) diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index 53e797b59..48173bd77 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -132,7 +132,7 @@ namespace Nz else difference = sequence - sequence2; - return 0; + return difference; } /*! diff --git a/src/Nazara/Core/Posix/FileImpl.cpp b/src/Nazara/Core/Posix/FileImpl.cpp index f6e8b3bcc..b9a6b0a31 100644 --- a/src/Nazara/Core/Posix/FileImpl.cpp +++ b/src/Nazara/Core/Posix/FileImpl.cpp @@ -143,7 +143,18 @@ namespace Nz return false; } - mode_t permissions; // TODO : get permission from first file + mode_t permissions; + struct stat sb; + if (fstat(fd1, &sb) == -1) // get permission from first file + { + NazaraWarning("Could not get permissions of source file"); + permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + } + else + { + permissions = sb.st_mode & ~S_IFMT; // S_IFMT: bit mask for the file type bit field -> ~S_IFMT: general permissions + } + int fd2 = open64(targetPath.GetConstBuffer(), O_WRONLY | O_TRUNC, permissions); if (fd2 == -1) { diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index a57d89861..20d1c1897 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -2827,21 +2827,15 @@ namespace Nz { const char* c = oldCharacters; char character = Detail::ToLower(*ptr); - bool found = false; + + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + EnsureOwnership(); + ptr = &m_sharedString->string[offset]; + do { if (character == Detail::ToLower(*c)) { - if (!found) - { - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - - EnsureOwnership(); - - ptr = &m_sharedString->string[offset]; - found = true; - } - *ptr = replaceCharacter; ++count; break; @@ -2853,19 +2847,12 @@ namespace Nz } else { - bool found = false; + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + EnsureOwnership(); + ptr = &m_sharedString->string[offset]; + while ((ptr = std::strpbrk(ptr, oldCharacters)) != nullptr) { - if (!found) - { - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - - EnsureOwnership(); - - ptr = &m_sharedString->string[offset]; - found = true; - } - *ptr++ = replaceCharacter; ++count; } diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 233eb9c72..8badefcc9 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -464,7 +464,6 @@ namespace Nz void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; - const ShaderUniforms* shaderUniforms = nullptr; for (auto& matIt : layer.opaqueModels) { @@ -488,7 +487,7 @@ namespace Nz if (shader != lastShader) { // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); + GetShaderUniforms(shader); lastShader = shader; } diff --git a/tests/Engine/Core/String.cpp b/tests/Engine/Core/String.cpp index eac5eaef6..fe9c80c30 100644 --- a/tests/Engine/Core/String.cpp +++ b/tests/Engine/Core/String.cpp @@ -122,5 +122,25 @@ SCENARIO("String", "[CORE][STRING]") } } }*/ + + GIVEN("A string") + { + Nz::String replaceAny("abapeilomuky"); + Nz::String replaceAnyWithCase("abapEilOmuky"); + + WHEN("We replace any of vowels after character 3") + { + unsigned int nbrOfChanges = replaceAny.ReplaceAny("aeiouy", '$', 3); + unsigned int nbrOfChangesWithCase = replaceAnyWithCase.ReplaceAny("AEIOUY", '$', 3); + + THEN("These results are expected") + { + REQUIRE(replaceAny == "abap$$l$m$k$"); + REQUIRE(nbrOfChanges == 5); + REQUIRE(replaceAnyWithCase == "abap$il$muky"); + REQUIRE(nbrOfChangesWithCase == 2); + } + } + } } From d5b354c3796b75357b6486881c2531dd223f8f26 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 08:34:44 +0200 Subject: [PATCH 070/383] Sdk: Fix uninitialization of components and systems Former-commit-id: 84f6ce6c6801dc3f4df528781892fa54783115bf [formerly 34e78a610a036478be9fff2fcb28b7d5cd17c13f] Former-commit-id: da5197094f56618eb065223c0c128f14e2a0f3f5 --- SDK/src/NDK/Sdk.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 21bfd236f..7f29bb18e 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -112,6 +112,12 @@ namespace Ndk // Uninitialize the SDK s_referenceCounter = 0; + // Components + BaseComponent::Uninitialize(); + + // Systems + BaseSystem::Uninitialize(); + // Uninitialize the engine #ifndef NDK_SERVER From 65f43182f6521122b00cd3f39257c0bb38d1a478 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 09:34:42 +0200 Subject: [PATCH 071/383] Remove Visual Studio 2015 database file Former-commit-id: da62e49ea2b8860bcd4025d4add74980d458f5ca [formerly c79c0719d67cd594c90f0be4c8f6c83ccca4fd50] Former-commit-id: b3e346736b0401296f4eab6bd374cd1d04a3c94a --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 258594792..f3b8b2bbd 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ build/**/*.vcxprojResolveAssemblyReference.cache build/**/*.nativecodeanalysis.all.xml build/**/*.nativecodeanalysis.xml build/**/*.VC.opendb +build/**/*.VC.db # Compiled Object files build/**/*.slo From 5d98ce3639a9de122187afeeb10f2225a2419047 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 09:36:01 +0200 Subject: [PATCH 072/383] Build/Vulkan: Fix compilation under Linux Former-commit-id: 3223e11738aad41c0d8716050392b0ddc23d8384 [formerly 68a2ae998cae8c84718f6cf074d2f09d4142296c] Former-commit-id: 9d6edbe4792cc8ed56315489d2b2c29dfe178089 --- build/scripts/modules/vulkan.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/scripts/modules/vulkan.lua b/build/scripts/modules/vulkan.lua index a8e674d03..760a4e58c 100644 --- a/build/scripts/modules/vulkan.lua +++ b/build/scripts/modules/vulkan.lua @@ -10,10 +10,10 @@ MODULE.Libraries = { } MODULE.OsDefines.Linux = { - "VK_USE_PLATFORM_MIR_KHR", - "VK_USE_PLATFORM_XCB_KHR", - "VK_USE_PLATFORM_XLIB_KHR", - "VK_USE_PLATFORM_WAYLAND_KHR" +-- "VK_USE_PLATFORM_MIR_KHR", + "VK_USE_PLATFORM_XCB_KHR" +-- "VK_USE_PLATFORM_XLIB_KHR", +-- "VK_USE_PLATFORM_WAYLAND_KHR" } MODULE.OsDefines.BSD = MODULE.OsDefines.Linux From d17d6e12da3e20c3a40f3f68bbf53d7f005c29de Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:06:32 +0200 Subject: [PATCH 073/383] Vulkan/Surface: Fix compilation under Linux Former-commit-id: af4efdf4f46f7817f75ca5c2f83fbe72c84e9ecb [formerly 1a431ff653263d46079162f2626cc6a05b688859] Former-commit-id: ac76a5219f0ed014a666bbc78eb1358afb254026 --- include/Nazara/Vulkan/VkSurface.inl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl index b6cb3a28f..f64c24af0 100644 --- a/include/Nazara/Vulkan/VkSurface.inl +++ b/include/Nazara/Vulkan/VkSurface.inl @@ -34,7 +34,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_ANDROID_KHR inline bool Surface::Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateAndroidSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateAndroidSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } @@ -55,7 +55,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_MIR_KHR inline bool Surface::Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateMirSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateMirSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } @@ -77,7 +77,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_XCB_KHR inline bool Surface::Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateXcbSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateXcbSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } @@ -99,7 +99,7 @@ namespace Nz #ifdef VK_USE_PLATFORM_XLIB_KHR inline bool Surface::Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.PFN_vkCreateXlibSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); + m_lastErrorCode = m_instance.vkCreateXlibSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); return Create(allocator); } From 19a1cbb7e0a2f254a9a38832d7e0dab7db8333e7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:08:13 +0200 Subject: [PATCH 074/383] Vulkan/CommandBuffer: Fix warning for GCC Former-commit-id: 702d3b186c232cdef5768631ad6e6a2e1feac516 [formerly 469a768929fb16bfd6dd72be91c883fa7bb9038a] Former-commit-id: 8a805356facb558f23e25d59162eef04b528e067 --- include/Nazara/Vulkan/VkCommandBuffer.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index d9944e33b..d2d6f50d7 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -77,7 +77,7 @@ namespace Nz renderPass, subpass, framebuffer, - (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), queryFlags, pipelineStatistics }; @@ -102,7 +102,7 @@ namespace Nz VK_NULL_HANDLE, 0, VK_NULL_HANDLE, - (occlusionQueryEnable) ? VK_TRUE : VK_FALSE, + VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), queryFlags, pipelineStatistics }; From b6be16b3c3113aa1076ee236882547cc98ab518d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:51:32 +0200 Subject: [PATCH 075/383] Build: Add server option, allows to compile only the server-side part of Nazara Former-commit-id: 28347f372b3d4b0afef0fcf8f54ebf45589470a3 [formerly b432be7d6e4404bd1c5a10c4b0a7ef43fceed307] Former-commit-id: 1622472689c5f87d5d77ffe391f1dde9cece815d --- SDK/include/NDK/Components.hpp | 13 ++--- .../NDK/Components/CameraComponent.hpp | 2 + .../NDK/Components/GraphicsComponent.hpp | 2 + SDK/include/NDK/Components/LightComponent.hpp | 2 + .../NDK/Components/ListenerComponent.hpp | 2 + SDK/include/NDK/Systems.hpp | 9 +-- SDK/include/NDK/Systems/ListenerSystem.hpp | 2 + SDK/include/NDK/Systems/RenderSystem.hpp | 2 + build/scripts/common.lua | 57 +++++++++++++++---- build/scripts/modules/audio.lua | 2 + build/scripts/modules/renderer.lua | 2 + build/scripts/modules/vulkan.lua | 2 + build/scripts/tools/ndk.lua | 19 +++---- build/scripts/tools/ndk_server.lua | 19 ++++--- 14 files changed, 92 insertions(+), 43 deletions(-) diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp index 46392ab7c..ca993b5b6 100644 --- a/SDK/include/NDK/Components.hpp +++ b/SDK/include/NDK/Components.hpp @@ -1,20 +1,17 @@ -// This file was automatically generated on 03 Mar 2016 at 14:09:12 +// This file was automatically generated on 01 Jun 2016 at 13:11:09 #pragma once #ifndef NDK_COMPONENTS_GLOBAL_HPP #define NDK_COMPONENTS_GLOBAL_HPP +#include #include +#include +#include +#include #include #include #include -#ifndef NDK_SERVER -#include -#include -#include -#include -#endif - #endif // NDK_COMPONENTS_GLOBAL_HPP diff --git a/SDK/include/NDK/Components/CameraComponent.hpp b/SDK/include/NDK/Components/CameraComponent.hpp index d5951109b..af2245b11 100644 --- a/SDK/include/NDK/Components/CameraComponent.hpp +++ b/SDK/include/NDK/Components/CameraComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_CAMERACOMPONENT_HPP #define NDK_COMPONENTS_CAMERACOMPONENT_HPP @@ -108,3 +109,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_CAMERACOMPONENT_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index f8fa2bf66..86cefb782 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP #define NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP @@ -80,3 +81,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/LightComponent.hpp b/SDK/include/NDK/Components/LightComponent.hpp index c55ae57bb..80f84a759 100644 --- a/SDK/include/NDK/Components/LightComponent.hpp +++ b/SDK/include/NDK/Components/LightComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_LIGHTCOMPONENT_HPP #define NDK_COMPONENTS_LIGHTCOMPONENT_HPP @@ -28,3 +29,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_LIGHTCOMPONENT_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Components/ListenerComponent.hpp b/SDK/include/NDK/Components/ListenerComponent.hpp index bee1ac14a..3d472bed3 100644 --- a/SDK/include/NDK/Components/ListenerComponent.hpp +++ b/SDK/include/NDK/Components/ListenerComponent.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_COMPONENTS_LISTENERCOMPONENT_HPP #define NDK_COMPONENTS_LISTENERCOMPONENT_HPP @@ -30,3 +31,4 @@ namespace Ndk #include #endif // NDK_COMPONENTS_LISTENERCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp index 193438b5e..176a956ee 100644 --- a/SDK/include/NDK/Systems.hpp +++ b/SDK/include/NDK/Systems.hpp @@ -1,16 +1,13 @@ -// This file was automatically generated on 03 Mar 2016 at 14:09:12 +// This file was automatically generated on 01 Jun 2016 at 13:11:09 #pragma once #ifndef NDK_SYSTEMS_GLOBAL_HPP #define NDK_SYSTEMS_GLOBAL_HPP +#include #include +#include #include -#ifndef NDK_SERVER -#include -#include -#endif - #endif // NDK_SYSTEMS_GLOBAL_HPP diff --git a/SDK/include/NDK/Systems/ListenerSystem.hpp b/SDK/include/NDK/Systems/ListenerSystem.hpp index 6f40fcdf9..bb166a4c1 100644 --- a/SDK/include/NDK/Systems/ListenerSystem.hpp +++ b/SDK/include/NDK/Systems/ListenerSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_LISTENERSYSTEM_HPP #define NDK_SYSTEMS_LISTENERSYSTEM_HPP @@ -27,3 +28,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_LISTENERSYSTEM_HPP +#endif // NDK_SERVER diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 72aa1efb1..f2fbc7a65 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP #define NDK_SYSTEMS_RENDERSYSTEM_HPP @@ -70,3 +71,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_RENDERSYSTEM_HPP +#endif // NDK_SERVER diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 822067ea2..6cf0025ba 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -196,9 +196,7 @@ function NazaraBuild:Execute() targetdir("../lib/" .. makeLibDir .. "/x64") -- Copy the module binaries to the example folder - if (os.is("windows")) then - self:MakeCopyAfterBuild(moduleTable) - end + self:MakeCopyAfterBuild(moduleTable) configuration({"vs*", "x86"}) libdirs("../extlibs/lib/msvc/x86") @@ -310,7 +308,7 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end - -- Copy the module binaries to the example folder + -- Copy the tool binaries to the example folder if (toolTable.CopyTargetToExampleDir) then self:MakeCopyAfterBuild(toolTable) end @@ -450,6 +448,11 @@ end function NazaraBuild:Initialize() -- Commençons par les options + newoption({ + trigger = "server", + description = "Excludes client-only modules/tools/examples" + }) + newoption({ trigger = "united", description = "Builds all the modules as one united library" @@ -605,13 +608,20 @@ function NazaraBuild:Initialize() self.OrderedExtLibs = {} self.OrderedModules = {} self.OrderedTools = {} - local tables = {self.Examples, self.ExtLibs, self.Modules, self.Tools} - local orderedTables = {self.OrderedExamples, self.OrderedExtLibs, self.OrderedModules, self.OrderedTools} + local tables = {self.ExtLibs, self.Modules, self.Tools, self.Examples} + local orderedTables = {self.OrderedExtLibs, self.OrderedModules, self.OrderedTools, self.OrderedExamples} for k,projects in ipairs(tables) do + -- Begin by resolving every project (because of dependencies in the same category) for projectId,projectTable in pairs(projects) do - self:Process(projectTable) - - table.insert(orderedTables[k], projectTable) + self:Resolve(projectTable) + end + + for projectId,projectTable in pairs(projects) do + if (self:Process(projectTable)) then + table.insert(orderedTables[k], projectTable) + else + print("Rejected client-only " .. projectTable.Name .. " " .. projectTable.Type) + end end table.sort(orderedTables[k], function (a, b) return a.Name < b.Name end) @@ -772,13 +782,22 @@ local PosixOSes = { } function NazaraBuild:Process(infoTable) - local libraries = {} + if (infoTable.ClientOnly and _OPTIONS["server"]) then + return false + end + + local libraries = {} for k, library in pairs(infoTable.Libraries) do local moduleName = library:match("Nazara(%w+)") local moduleTable = moduleName and self.Modules[moduleName:lower()] local toolTable = moduleName and self.Tools[moduleName:lower()] if (moduleTable) then + if (moduleTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + if (_OPTIONS["united"]) then library = "NazaraEngine" else @@ -794,6 +813,11 @@ function NazaraBuild:Process(infoTable) else local extLibTable = self.ExtLibs[library:lower()] if (extLibTable) then + if (extLibTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + library = extLibTable.Name table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") @@ -802,6 +826,11 @@ function NazaraBuild:Process(infoTable) table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") else if (toolTable and toolTable.Kind == "library") then + if (toolTable.ClientOnly and _OPTIONS["server"]) then + infoTable.ClientOnly = true + return false -- We depend on a client-only library + end + library = "Nazara" .. toolTable.Name -- Import tools includes @@ -862,6 +891,14 @@ function NazaraBuild:Process(infoTable) end end end + + return true +end + +function NazaraBuild:Resolve(infoTable) + if (type(infoTable.Libraries) == "function") then + infoTable.Libraries = infoTable.Libraries() + end end function NazaraBuild:MakeCopyAfterBuild(infoTable) diff --git a/build/scripts/modules/audio.lua b/build/scripts/modules/audio.lua index 27e49a08c..509972dc3 100644 --- a/build/scripts/modules/audio.lua +++ b/build/scripts/modules/audio.lua @@ -1,5 +1,7 @@ MODULE.Name = "Audio" +MODULE.ClientOnly = true + MODULE.Defines = { "NAZARA_AUDIO_OPENAL" } diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index 7e3edadbe..bbc472b75 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -1,5 +1,7 @@ MODULE.Name = "Renderer" +MODULE.ClientOnly = true + MODULE.Defines = { "NAZARA_RENDERER_OPENGL" } diff --git a/build/scripts/modules/vulkan.lua b/build/scripts/modules/vulkan.lua index 760a4e58c..62a00a745 100644 --- a/build/scripts/modules/vulkan.lua +++ b/build/scripts/modules/vulkan.lua @@ -1,5 +1,7 @@ MODULE.Name = "Vulkan" +MODULE.ClientOnly = true + MODULE.Defines = { "VK_NO_PROTOTYPES" } diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 5a1084f48..961fa6d7f 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -22,14 +22,11 @@ TOOL.Files = { "../SDK/src/NDK/**.cpp" } -TOOL.Libraries = { - "NazaraCore", - "NazaraAudio", - "NazaraLua", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility", - "NazaraRenderer", - "NazaraGraphics" -} +TOOL.Libraries = function() + local libraries = {} + for k,v in pairs(NazaraBuild.Modules) do + table.insert(libraries, "Nazara" .. v.Name) + end + + return libraries +end \ No newline at end of file diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 978d620be..b1a71453e 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -37,11 +37,14 @@ TOOL.FilesExcluded = { "../SDK/**/LuaBinding_Renderer.*" } -TOOL.Libraries = { - "NazaraCore", - "NazaraLua", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility" -} + +TOOL.Libraries = function() + local libraries = {} + for k,v in pairs(NazaraBuild.Modules) do + if (not v.ClientOnly) then + table.insert(libraries, "Nazara" .. v.Name) + end + end + + return libraries +end From 14541deb764526699fa6f9b4b517ae1bc6d77655 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 13:52:59 +0200 Subject: [PATCH 076/383] Build: Fix with-extlibs option being required for compilation Former-commit-id: d549ed954e4285f34399e610e3dcfde33c0ad83d [formerly 239e7cd99680e8bd35fdde4e0e137818f1b1bce9] Former-commit-id: 5233a5e6923162f630bfa186192259123d1ab3da --- build/scripts/common.lua | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 6cf0025ba..7e3cb2c33 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -15,7 +15,7 @@ function NazaraBuild:Execute() if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" - if (#self.OrderedExtLibs > 0) then + if (_OPTIONS["with-extlibs"]) then workspace("NazaraExtlibs") platforms(platformData) @@ -494,26 +494,24 @@ function NazaraBuild:Initialize() ACTION = nil -- Extern libraries - if (_OPTIONS["with-extlibs"]) then - local extlibs = os.matchfiles("../extlibs/build/*.lua") - for k,v in pairs(extlibs) do - local f, err = loadfile(v) - if (f) then - LIBRARY = {} - self:SetupInfoTable(LIBRARY) + local extlibs = os.matchfiles("../extlibs/build/*.lua") + for k,v in pairs(extlibs) do + local f, err = loadfile(v) + if (f) then + LIBRARY = {} + self:SetupInfoTable(LIBRARY) - f() + f() - local succeed, err = self:RegisterExternLibrary(LIBRARY) - if (not succeed) then - print("Unable to register extern library: " .. err) - end - else - print("Unable to load extern library file: " .. err) - end - end - LIBRARY = nil - end + local succeed, err = self:RegisterExternLibrary(LIBRARY) + if (not succeed) then + print("Unable to register extern library: " .. err) + end + else + print("Unable to load extern library file: " .. err) + end + end + LIBRARY = nil -- Then the modules local modules = os.matchfiles("scripts/modules/*.lua") From 94ed1cca326b2af65387440bccc9aef3753f0db8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 14:11:58 +0200 Subject: [PATCH 077/383] Sdk/World: Fix compilation error when submitting arguments on system creation Former-commit-id: a5ace06c0f4c0d7378fb81694db8db1d9f57b33d [formerly 2a232722761dfb72bbd9f3dc9ba8353d65311e7d] Former-commit-id: f6a65203b37acb49276e22cad0bab4ff7075eb3a --- SDK/include/NDK/World.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index 91ebc3922..ba2b33bd4 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -44,7 +44,7 @@ namespace Ndk static_assert(std::is_base_of::value, "SystemType is not a component"); // Allocation et affectation du component - std::unique_ptr ptr(new SystemType(std::forward(args)...)); + std::unique_ptr ptr(new SystemType(std::forward(args)...)); return static_cast(AddSystem(std::move(ptr))); } From e94dc90f065d6784317b9b468496ef8394140efd Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Jun 2016 13:49:30 +0200 Subject: [PATCH 078/383] Graphics: Prevent shadow-mapping code to compile without shadow-mapping Temporary fix for OpenGL 3.3 Former-commit-id: 38067e4e19ce5e7e0a804fdeb4c1ad9fcc9f415e [formerly c9878c521ccb78ff86ba5ce823acb009717b9bb8] Former-commit-id: 22915443375dd97584f9e5408dcf308d5801f7b0 --- src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h | 2 +- src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag | 2 ++ src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h | 2 +- src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h b/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h index 993c7291b..7c3081f31 100644 --- a/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h +++ b/src/Nazara/Graphics/Resources/Shaders/Basic/core.vert.h @@ -1 +1 @@ -47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,10,35,101,108,115,101,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,35,101,110,100,105,102,10,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,10,35,101,108,115,101,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,10,35,101,110,100,105,102,10,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,10,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,10,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,10,9,35,101,108,115,101,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,10,9,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,9,35,101,110,100,105,102,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,10,35,101,108,115,101,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,108,115,101,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,110,100,105,102,10,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,116,101,120,67,111,111,114,100,115,41,59,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,118,101,99,50,40,116,101,120,67,111,111,114,100,115,41,59,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index 94184d6ab..61ed69632 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -94,6 +94,7 @@ float VectorToDepthValue(vec3 vec, float zNear, float zFar) return (normZ + 1.0) * 0.5; } +#if SHADOW_MAPPING float CalculateDirectionalShadowFactor(int lightIndex) { vec4 lightSpacePos = vLightSpacePos[lightIndex]; @@ -119,6 +120,7 @@ float CalculateSpotShadowFactor(int lightIndex) return visibility; } +#endif void main() { diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index b3c3f2c63..6f1495308 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,10,35,101,110,100,105,102,10,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,99,111,108,111,114,59,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,10,125,59,10,10,47,47,32,76,117,109,105,195,168,114,101,115,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,10,47,47,32,77,97,116,195,169,114,105,97,117,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,47,47,32,65,117,116,114,101,115,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,10,123,10,9,118,101,99,51,32,99,111,108,111,114,59,10,10,9,102,32,42,61,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,10,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,10,125,10,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,10,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,10,123,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,10,125,10,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,10,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,10,9,102,108,111,97,116,32,120,44,121,59,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,10,9,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,10,125,10,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,10,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,35,101,108,115,101,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,10,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,10,35,101,110,100,105,102,10,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,9,35,101,110,100,105,102,10,9,9,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,10,10,9,35,105,102,32,76,73,71,72,84,73,78,71,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,9,35,101,110,100,105,102,10,10,9,47,42,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,10,9,42,47,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,10,9,35,101,108,115,101,32,47,47,32,76,73,71,72,84,73,78,71,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,10,9,35,101,110,100,105,102,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,76,73,71,72,84,73,78,71,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,9,35,101,110,100,105,102,10,9,9,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,10,9,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,125,10,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,9,35,101,108,115,101,32,47,47,32,76,73,71,72,84,73,78,71,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h index fbdd39607..c1611105a 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h @@ -1 +1 @@ -47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,10,35,101,108,115,101,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,35,101,110,100,105,102,10,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,10,35,101,108,115,101,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,10,35,101,110,100,105,102,10,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,10,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,10,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,10,9,35,101,108,115,101,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,10,9,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,10,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,10,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,9,35,101,110,100,105,102,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,10,35,101,108,115,101,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,108,115,101,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,35,101,108,115,101,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,10,9,9,9,35,101,108,115,101,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,9,9,9,35,101,110,100,105,102,10,9,9,35,101,110,100,105,102,10,9,35,101,110,100,105,102,10,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,10,10,35,105,102,32,76,73,71,72,84,73,78,71,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,10,9,35,101,108,115,101,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,10,9,35,101,110,100,105,102,10,9,10,9,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,10,9,35,101,108,115,101,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,10,35,101,110,100,105,102,10,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,10,9,35,101,110,100,105,102,10,35,101,110,100,105,102,10,125,10, \ No newline at end of file +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,13,10,9,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,13,10,9,35,101,110,100,105,102,13,10,9,13,10,9,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,13,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file From baf999467594e9ca219fc710681f84b7cbb44fc1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Jun 2016 19:10:33 +0200 Subject: [PATCH 079/383] Utility/PixelFormat: Fix ComputeSize for DXT formats Former-commit-id: e16835382aa80ea53c7cdc747cc0b04c493cb645 [formerly 565512d61f3ef1131c89cc0c1ffc140ff1112f91] Former-commit-id: 95e9c965e95176857452a7c270cbecd75e86cd8d --- include/Nazara/Utility/PixelFormat.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index e30701d3d..e384d8574 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -156,7 +156,7 @@ namespace Nz case PixelFormatType_DXT1: case PixelFormatType_DXT3: case PixelFormatType_DXT5: - return (((width + 3) / 4) * ((height + 3) / 4) * (format == PixelFormatType_DXT1) ? 8 : 16) * depth; + return (((width + 3) / 4) * ((height + 3) / 4) * ((format == PixelFormatType_DXT1) ? 8 : 16)) * depth; default: NazaraError("Unsupported format"); From 400bb9027b956922bba88fe56b9c8aae87b53fe8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 12:58:04 +0200 Subject: [PATCH 082/383] Network/Windows: Fix build on compilers with outdated windows.h Former-commit-id: fcff03e6328d1ce6fed4f14f5606245d0ca7a495 [formerly a35c4aeaf8e6030b1f3a7665b448c3fb57d095e7] Former-commit-id: 33d61f93f2a53e81a4f7a79f8bddaa5daa831e6d --- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 ++ src/Nazara/Network/Win32/IpAddressImpl.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 9f3918574..54d8ee4f5 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -100,6 +100,7 @@ namespace Nz return IpAddress::Invalid; } + #if NAZARA_CORE_WINDOWS_VISTA IpAddress IpAddressImpl::FromAddrinfo(const addrinfoW* info) { switch (info->ai_family) @@ -121,6 +122,7 @@ namespace Nz return IpAddress::Invalid; } + #endif IpAddress IpAddressImpl::FromSockAddr(const sockaddr* address) { diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index 4b27bef32..960092839 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -17,7 +17,9 @@ namespace Nz ~IpAddressImpl() = delete; static IpAddress FromAddrinfo(const addrinfo* info); + #if NAZARA_CORE_WINDOWS_VISTA static IpAddress FromAddrinfo(const addrinfoW* info); + #endif static IpAddress FromSockAddr(const sockaddr* address); static IpAddress FromSockAddr(const sockaddr_in* addressv4); static IpAddress FromSockAddr(const sockaddr_in6* addressv6); From 6b42e5a604901a836c8d3a50a7c198a023bb3a22 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 12:58:04 +0200 Subject: [PATCH 083/383] Network/Windows: Fix build on compilers with outdated windows.h (Fixes 63) Former-commit-id: d035029cb037dd4a8a91a85f0b750572a2b938c0 [formerly 693cb8be89964f7f2c752a6a928e07c042210e76] Former-commit-id: a4d4255872b47193c3456c65926041d0bd73b5ed --- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 ++ src/Nazara/Network/Win32/IpAddressImpl.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 9f3918574..54d8ee4f5 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -100,6 +100,7 @@ namespace Nz return IpAddress::Invalid; } + #if NAZARA_CORE_WINDOWS_VISTA IpAddress IpAddressImpl::FromAddrinfo(const addrinfoW* info) { switch (info->ai_family) @@ -121,6 +122,7 @@ namespace Nz return IpAddress::Invalid; } + #endif IpAddress IpAddressImpl::FromSockAddr(const sockaddr* address) { diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index 4b27bef32..960092839 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -17,7 +17,9 @@ namespace Nz ~IpAddressImpl() = delete; static IpAddress FromAddrinfo(const addrinfo* info); + #if NAZARA_CORE_WINDOWS_VISTA static IpAddress FromAddrinfo(const addrinfoW* info); + #endif static IpAddress FromSockAddr(const sockaddr* address); static IpAddress FromSockAddr(const sockaddr_in* addressv4); static IpAddress FromSockAddr(const sockaddr_in6* addressv6); From 4710da1f6ca115a6dc4bf91e9fcaf732d2f632df Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Wed, 8 Jun 2016 14:13:19 +0200 Subject: [PATCH 084/383] Revert changes Former-commit-id: 25a7ecad35f3fe38638f608f375ed9c8c5df873e [formerly fa3383a06a186551d427aee0e3def1e543b73a1b] Former-commit-id: 5923cbbb60c4464741449c997c39212d2bc075f8 --- src/Nazara/Core/String.cpp | 31 ++++++++++++++------ src/Nazara/Graphics/DepthRenderTechnique.cpp | 3 +- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 20d1c1897..a57d89861 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -2827,15 +2827,21 @@ namespace Nz { const char* c = oldCharacters; char character = Detail::ToLower(*ptr); - - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - EnsureOwnership(); - ptr = &m_sharedString->string[offset]; - + bool found = false; do { if (character == Detail::ToLower(*c)) { + if (!found) + { + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + + EnsureOwnership(); + + ptr = &m_sharedString->string[offset]; + found = true; + } + *ptr = replaceCharacter; ++count; break; @@ -2847,12 +2853,19 @@ namespace Nz } else { - std::ptrdiff_t offset = ptr - m_sharedString->string.get(); - EnsureOwnership(); - ptr = &m_sharedString->string[offset]; - + bool found = false; while ((ptr = std::strpbrk(ptr, oldCharacters)) != nullptr) { + if (!found) + { + std::ptrdiff_t offset = ptr - m_sharedString->string.get(); + + EnsureOwnership(); + + ptr = &m_sharedString->string[offset]; + found = true; + } + *ptr++ = replaceCharacter; ++count; } diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 8badefcc9..233eb9c72 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -464,6 +464,7 @@ namespace Nz void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { const Shader* lastShader = nullptr; + const ShaderUniforms* shaderUniforms = nullptr; for (auto& matIt : layer.opaqueModels) { @@ -487,7 +488,7 @@ namespace Nz if (shader != lastShader) { // Index of uniforms in the shader - GetShaderUniforms(shader); + shaderUniforms = GetShaderUniforms(shader); lastShader = shader; } From d26395ba6dda8971d2433da3ad4603f008d6e0a1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 18:45:56 +0200 Subject: [PATCH 085/383] Network/Windows: Fix build on some plateforms (Hi MinGW) Former-commit-id: d8bab0668373c3e8f6f15296e7d19d4547559fce [formerly 46afd404ab3cf4bfd8e1981cc20574707dbf703c] Former-commit-id: 29c558c519e2783641b87747de4215cd9652e1b2 --- src/Nazara/Network/Win32/IpAddressImpl.cpp | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 54d8ee4f5..0fd5cd88a 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -84,16 +84,21 @@ namespace Nz { sockaddr_in* ipv4 = reinterpret_cast(info->ai_addr); - auto& rawIpV4 = ipv4->sin_addr.S_un.S_un_b; - return IpAddress(rawIpV4.s_b1, rawIpV4.s_b2, rawIpV4.s_b3, rawIpV4.s_b4, ntohs(ipv4->sin_port)); + auto& rawIpV4 = ipv4->sin_addr; + return IpAddress(rawIpV4.s_net, rawIpV4.s_host, rawIpV4.s_lh, rawIpV4.s_impno, ntohs(ipv4->sin_port)); } case AF_INET6: { sockaddr_in6* ipv6 = reinterpret_cast(info->ai_addr); - auto& rawIpV6 = ipv6->sin6_addr.u.Word; - return IpAddress(rawIpV6[0], rawIpV6[1], rawIpV6[2], rawIpV6[3], rawIpV6[4], rawIpV6[5], rawIpV6[6], rawIpV6[7], ntohs(ipv6->sin6_port)); + auto& rawIpV6 = ipv6->sin6_addr.s6_addr; + + IpAddress::IPv6 structIpV6; + for (unsigned int i = 0; i < 8; ++i) + structIpV6[i] = UInt16(rawIpV6[i * 2]) << 8 | UInt16(rawIpV6[i * 2 + 1]); + + return IpAddress(structIpV6, ntohs(ipv6->sin6_port)); } } @@ -146,8 +151,13 @@ namespace Nz IpAddress IpAddressImpl::FromSockAddr(const sockaddr_in6* addressv6) { - auto& rawIpV6 = addressv6->sin6_addr.u.Word; - return IpAddress(rawIpV6[0], rawIpV6[1], rawIpV6[2], rawIpV6[3], rawIpV6[4], rawIpV6[5], rawIpV6[6], rawIpV6[7], ntohs(addressv6->sin6_port)); + auto& rawIpV6 = addressv6->sin6_addr.s6_addr; + + IpAddress::IPv6 ipv6; + for (unsigned int i = 0; i < 8; ++i) + ipv6[i] = rawIpV6[i*2] << 8 | rawIpV6[i*2+1]; + + return IpAddress(ipv6, ntohs(addressv6->sin6_port)); } bool IpAddressImpl::ResolveAddress(const IpAddress& ipAddress, String* hostname, String* service, ResolveError* error) @@ -223,7 +233,7 @@ namespace Nz std::memset(socketAddress, 0, sizeof(sockaddr_in)); socketAddress->sin_family = AF_INET; socketAddress->sin_port = htons(ipAddress.GetPort()); - socketAddress->sin_addr.S_un.S_addr = htonl(ipAddress.ToUInt32()); + socketAddress->sin_addr.s_addr = htonl(ipAddress.ToUInt32()); return sizeof(sockaddr_in); } @@ -238,7 +248,10 @@ namespace Nz IpAddress::IPv6 address = ipAddress.ToIPv6(); for (unsigned int i = 0; i < 8; ++i) - socketAddress->sin6_addr.u.Word[i] = htons(address[i]); + { + socketAddress->sin6_addr.s6_addr[i * 2 + 0] = htons(address[i]) >> 8; + socketAddress->sin6_addr.s6_addr[i * 2 + 1] = htons(address[i]) >> 0; + } return sizeof(sockaddr_in6); } From 63ac80c7ffdd65714816682a5d9c5e616b48d2ad Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:46:44 +0200 Subject: [PATCH 086/383] Utility/Mesh: Replace scale by transform matrix Former-commit-id: b02de61fe0213f5fdd074dfa868db415e9c770c3 [formerly e185f2b410f2a3e04a0f11be28665cf6e8dcb617] Former-commit-id: d0c7e88fe2b5f8a4aa97640d050751def83f3783 --- SDK/include/NDK/LuaAPI.inl | 2 +- include/Nazara/Utility/Mesh.hpp | 4 ++-- plugins/Assimp/Plugin.cpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 13 +++++++------ src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 5 +++-- src/Nazara/Utility/Formats/OBJLoader.cpp | 3 +-- src/Nazara/Utility/Mesh.cpp | 6 +++--- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index a42479cae..a09d6c459 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -100,8 +100,8 @@ namespace Nz params->animated = instance.CheckField("Animated", params->animated); params->center = instance.CheckField("Center", params->center); params->flipUVs = instance.CheckField("FlipUVs", params->flipUVs); + //params->matrix = instance.CheckField("Matrix", params->matrix); params->optimizeIndexBuffers = instance.CheckField("OptimizeIndexBuffers", params->optimizeIndexBuffers); - params->scale = instance.CheckField("Scale", params->scale); return 1; } diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index ff11b5d4d..865a228a9 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -29,8 +29,8 @@ namespace Nz { MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement) - // La mise à l'échelle éventuelle que subira le mesh - Vector3f scale = Vector3f::Unit(); + // La transformation appliquée à tous les sommets du mesh + Matrix4f matrix = Matrix4f::Identity(); // Si ceci sera le stockage utilisé par les buffers UInt32 storage = DataStorage_Hardware; diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 68c443b29..d571e1ef6 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -209,7 +209,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) aiVector3D tangent = (iMesh->HasTangentsAndBitangents()) ? iMesh->mTangents[j] : aiVector3D(0.f, 1.f, 0.f); aiVector3D uv = (iMesh->HasTextureCoords(0)) ? iMesh->mTextureCoords[0][j] : aiVector3D(0.f); - vertex->position = parameters.scale * Vector3f(position.x, position.y, position.z); + vertex->position = parameters.matrix * Vector3f(position.x, position.y, position.z); vertex->normal.Set(normal.x, normal.y, normal.z); vertex->tangent.Set(tangent.x, tangent.y, tangent.z); vertex->uv.Set(uv.x, uv.y); diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index eef4ac63d..126eeaa35 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -188,11 +188,10 @@ namespace Nz SwapBytes(&translate.z, sizeof(float)); #endif - // Un personnage de taille moyenne fait ~50 unités de haut dans Quake 2 - // Avec Nazara, 1 unité = 1 mètre, nous devons donc adapter l'échelle - Vector3f s(parameters.scale/29.f); // 50/29 = 1.72 (Soit 1.72 mètre, proche de la taille moyenne d'un individu) - scale *= s; - translate *= s; + constexpr float ScaleAdjust = 1.f / 27.8f; // Make a 50 Quake 2 units character a 1.8 unit long + + scale *= ScaleAdjust; + translate *= ScaleAdjust; BufferMapper vertexMapper(vertexBuffer, BufferAccess_DiscardAndWrite); MeshVertex* vertex = static_cast(vertexMapper.GetPointer()); @@ -215,11 +214,13 @@ namespace Nz /// Chargement des positions // Pour que le modèle soit correctement aligné, on génère un quaternion que nous appliquerons à chacune des vertices Quaternionf rotationQuat = EulerAnglesf(-90.f, 90.f, 0.f); + Nz::Matrix4f matrix = Matrix4f::Transform(translate, rotationQuat, scale); + matrix *= parameters.matrix; for (unsigned int v = 0; v < header.num_vertices; ++v) { const MD2_Vertex& vert = vertices[v]; - Vector3f position = rotationQuat * Vector3f(vert.x*scale.x + translate.x, vert.y*scale.y + translate.y, vert.z*scale.z + translate.z); + Vector3f position = matrix * Vector3f(vert.x, vert.y, vert.z); vertex->position = position; vertex->normal = rotationQuat * md2Normals[vert.n]; diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index cda183313..ce56b136a 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -48,7 +48,8 @@ namespace Nz // Le hellknight de Doom 3 fait ~120 unités, et il est dit qu'il fait trois mètres // Nous réduisons donc la taille générale des fichiers MD5 de 1/40 - Vector3f scale(parameters.scale/40.f); + Matrix4f matrix = Matrix4f::Transform(Nz::Vector3f::Zero(), rotationQuat, Vector3f(1.f / 40.f)); + matrix *= parameters.matrix; const MD5MeshParser::Joint* joints = parser.GetJoints(); const MD5MeshParser::Mesh* meshes = parser.GetMeshes(); @@ -267,7 +268,7 @@ namespace Nz } // On retourne le modèle dans le bon sens - vertex->position = scale * (rotationQuat * finalPos); + vertex->position = matrix * finalPos; vertex->uv.Set(md5Vertex.uv.x, (parameters.flipUVs) ? 1.f - md5Vertex.uv.y : md5Vertex.uv.y); // Inversion des UV si demandé vertex++; } diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 75b5ba22f..05b39f81f 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -234,8 +234,7 @@ namespace Nz MeshVertex& vertex = meshVertices[index]; const Vector4f& vec = positions[vertexIndices.position]; - vertex.position.Set(vec.x, vec.y, vec.z); - vertex.position *= parameters.scale/vec.w; + vertex.position = Vector3f(parameters.matrix * vec); if (vertexIndices.normal >= 0) vertex.normal = normals[vertexIndices.normal]; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index fca38e415..f41f67440 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -39,9 +39,9 @@ namespace Nz return false; } - if (scale == Vector3f::Zero()) + if (matrix == Matrix4f::Zero()) { - NazaraError("Invalid scale"); + NazaraError("Invalid matrix"); return false; } @@ -111,7 +111,7 @@ namespace Nz VertexBufferRef vertexBuffer; Matrix4f matrix(primitive.matrix); - matrix.ApplyScale(params.scale); + matrix *= params.matrix; VertexDeclaration* declaration = VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent); From cc49b559c3ff11471c841f143af056741dd4c9dc Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:47:08 +0200 Subject: [PATCH 087/383] Utility/MaterialData: Add Material name information Former-commit-id: f680fd0d6e8c4a10a44ee8393e6b08e164fceabf [formerly b906d2ed5d98ee0bc0199f71d4955a93c18657f7] Former-commit-id: 50620f9c773ecadec81a257b9c3ad280a97f0c24 --- include/Nazara/Utility/MaterialData.hpp | 1 + plugins/Assimp/Plugin.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index 0f69c9846..ea8ffd0f5 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -41,6 +41,7 @@ namespace Nz static constexpr const char* HeightTexturePath = "MatHeightTexturePath"; static constexpr const char* Lighting = "MatLighting"; static constexpr const char* LineWidth = "MatLineWidth"; + static constexpr const char* Name = "MatName"; static constexpr const char* NormalTexturePath = "MatNormalTexturePath"; static constexpr const char* PointSize = "MatPointSize"; static constexpr const char* ScissorTest = "MatScissorTest"; diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index d571e1ef6..f82d51f7b 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -291,6 +291,10 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) ConvertTexture(aiTextureType_OPACITY, MaterialData::AlphaTexturePath); ConvertTexture(aiTextureType_SPECULAR, MaterialData::SpecularTexturePath, MaterialData::SpecularWrap); + aiString name; + if (aiGetMaterialString(aiMat, AI_MATKEY_NAME, &name) == aiReturn_SUCCESS) + matData.SetParameter(MaterialData::Name, String(name.data, name.length)); + int iValue; if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue)) matData.SetParameter(MaterialData::FaceCulling, !iValue); From 91be8bf6ed12b6f971c03c91b9b941ef7447d90c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:47:43 +0200 Subject: [PATCH 088/383] Plugins/Assimp: Fix FaceCulling parameter retrieval Former-commit-id: d7390465f872eec27db9dab9b48219187b0a1b84 [formerly 874eaee9651cf2550fb6870da98725b556233acd] Former-commit-id: 7219679c217dd39aaac18d918a454af1f9a7e134 --- plugins/Assimp/Plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index f82d51f7b..312bbf48e 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -296,7 +296,7 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) matData.SetParameter(MaterialData::Name, String(name.data, name.length)); int iValue; - if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue)) + if (aiGetMaterialInteger(aiMat, AI_MATKEY_TWOSIDED, &iValue) == aiReturn_SUCCESS) matData.SetParameter(MaterialData::FaceCulling, !iValue); matIt = materials.insert(std::make_pair(iMesh->mMaterialIndex, std::make_pair(materials.size(), std::move(matData)))).first; From 0e01bdaa3e09f607ee36ef24f1ac488f67b2e45b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:48:04 +0200 Subject: [PATCH 089/383] Graphics/Material: Ugly spaces to tabs Former-commit-id: 05162affc594bfa6e72bb32b4c49c3d322fd42ab [formerly 71fa5849249e9770184d693176c3e50393988f4d] Former-commit-id: d0042378fa707d7e42303ffe3445a847596a482d --- src/Nazara/Graphics/Material.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 44ec0310d..0b4b887c3 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -442,22 +442,22 @@ namespace Nz s_defaultMaterial->SetFaceFilling(FaceFilling_Line); MaterialLibrary::Register("Default", s_defaultMaterial); - MaterialRef mat; + MaterialRef mat; - mat = New(); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - MaterialLibrary::Register("Basic2D", std::move(mat)); + mat = New(); + mat->Enable(RendererParameter_DepthWrite, false); + mat->Enable(RendererParameter_FaceCulling, false); + mat->EnableLighting(false); + MaterialLibrary::Register("Basic2D", std::move(mat)); - mat = New(); - mat->Enable(RendererParameter_Blend, true); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - mat->SetDstBlend(BlendFunc_InvSrcAlpha); - mat->SetSrcBlend(BlendFunc_SrcAlpha); - MaterialLibrary::Register("Translucent2D", std::move(mat)); + mat = New(); + mat->Enable(RendererParameter_Blend, true); + mat->Enable(RendererParameter_DepthWrite, false); + mat->Enable(RendererParameter_FaceCulling, false); + mat->EnableLighting(false); + mat->SetDstBlend(BlendFunc_InvSrcAlpha); + mat->SetSrcBlend(BlendFunc_SrcAlpha); + MaterialLibrary::Register("Translucent2D", std::move(mat)); return true; } From a2b4146645b562453e718b589acf43d3c269f884 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:48:35 +0200 Subject: [PATCH 090/383] Sdk/Application: Add MakeExitOnLastWindowClosed At least it's explicit Former-commit-id: 1db6523fe5ad0085056b1192cbf8ff8b714dd795 [formerly 1e02bb893158e39d69201c6044501149722bc308] Former-commit-id: eee14cb25425b7a368d084fcb552996784e4a70e --- SDK/include/NDK/Application.hpp | 4 ++++ SDK/include/NDK/Application.inl | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 5d918ef8e..6a375776c 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -33,6 +33,10 @@ namespace Ndk bool Run(); + #ifndef NDK_SERVER + inline void MakeExitOnLastWindowClosed(bool exitOnClosedWindows); + #endif + inline void Quit(); Application& operator=(const Application&) = delete; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index f44ff9e8c..96e8768ce 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -61,6 +61,13 @@ namespace Ndk return m_updateTime; } + #ifndef NDK_SERVER + inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows) + { + m_exitOnClosedWindows = exitOnClosedWindows; + } + #endif + inline void Application::Quit() { m_shouldQuit = true; From f80dc7cf45d69e544c01e6ea4978e2eb095dc336 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 08:49:01 +0200 Subject: [PATCH 091/383] Graphics/Material: Add errors when failed to query texture Former-commit-id: b848a6552b442edf87260bbbb6b3703bf155a4b7 [formerly b4720a11771bd5f2e61f54afc69c361b7c412555] Former-commit-id: b3aa1119d7ca9efe3030f40f1f5d1f0c79b416fd --- include/Nazara/Graphics/Material.inl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index c8559e11f..d348d7581 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -289,7 +289,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get alpha map \"" + textureName + "\""); return false; + } } SetAlphaMap(std::move(texture)); @@ -335,7 +338,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get diffuse map \"" + textureName + "\""); return false; + } } SetDiffuseMap(std::move(texture)); @@ -366,7 +372,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get emissive map \"" + textureName + "\""); return false; + } } SetEmissiveMap(std::move(texture)); @@ -397,7 +406,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get height map \"" + textureName + "\""); return false; + } } SetHeightMap(std::move(texture)); @@ -418,7 +430,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get normal map \"" + textureName + "\""); return false; + } } SetNormalMap(std::move(texture)); @@ -471,7 +486,10 @@ namespace Nz { texture = TextureManager::Get(textureName); if (!texture) + { + NazaraError("Failed to get specular map \"" + textureName + "\""); return false; + } } SetSpecularMap(std::move(texture)); From 70167ce10607d0651e41870304a09709387b32e2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 12:32:04 +0200 Subject: [PATCH 092/383] Build: Fix build on Premake4 Former-commit-id: 90e0b92e48bbb285a95db0300a8eeaa4125f4d81 [formerly c9fe9513e9e4b6ce4fb53a2f2a2f61f779f756e8] Former-commit-id: ca9ea9c6931d4857af7f0aab8f43465eb462dd2e --- build/scripts/common.lua | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 7e3cb2c33..5124dcace 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -7,9 +7,9 @@ function NazaraBuild:Execute() local platformData if (os.is64bit()) then - platformData = {"x64", "x86"} + platformData = {"x64", "x32"} else - platformData = {"x86", "x64"} + platformData = {"x32", "x64"} end if (self.Actions[_ACTION] == nil) then @@ -30,13 +30,13 @@ function NazaraBuild:Execute() location(_ACTION) kind("StaticLib") - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") targetdir("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -47,7 +47,7 @@ function NazaraBuild:Execute() configuration("vs*") buildoptions("/MP") - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") targetdir("../extlibs/lib/msvc/x86") @@ -55,7 +55,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x64") targetdir("../extlibs/lib/msvc/x64") - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../extlibs/lib/xcode/x86") targetdir("../extlibs/lib/xcode/x86") @@ -178,14 +178,14 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") targetdir("../lib/" .. makeLibDir .. "/x86") @@ -198,7 +198,7 @@ function NazaraBuild:Execute() -- Copy the module binaries to the example folder self:MakeCopyAfterBuild(moduleTable) - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") targetdir("../lib/msvc/x86") @@ -208,7 +208,7 @@ function NazaraBuild:Execute() libdirs("../lib/msvc/x64") targetdir("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") targetdir("../lib/xcode/x86") @@ -283,14 +283,14 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then @@ -313,7 +313,7 @@ function NazaraBuild:Execute() self:MakeCopyAfterBuild(toolTable) end - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") if (toolTable.Kind == "library") then @@ -331,7 +331,7 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x64") end - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") if (toolTable.Kind == "library") then @@ -411,26 +411,26 @@ function NazaraBuild:Execute() includedirs(exampleTable.Includes) links(exampleTable.Libraries) - configuration("x86") + configuration("x32") libdirs("../extlibs/lib/common/x86") configuration("x64") defines("NAZARA_PLATFORM_x64") libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x86"}) + configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../lib/" .. makeLibDir .. "/x86") configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../lib/" .. makeLibDir .. "/x64") - configuration({"vs*", "x86"}) + configuration({"vs*", "x32"}) libdirs("../lib/msvc/x86") configuration({"vs*", "x64"}) libdirs("../lib/msvc/x64") - configuration({"xcode3 or xcode4", "x86"}) + configuration({"xcode3 or xcode4", "x32"}) libdirs("../lib/xcode/x86") configuration({"xcode3 or xcode4", "x64"}) @@ -906,8 +906,8 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do local paths = {} - table.insert(paths, {"x86", "../extlibs/lib/common/x86/" .. v .. ".dll"}) - table.insert(paths, {"x86", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) + table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) + table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) From e70b1f57aed613c6dde8348e46a66c60c5f75e72 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 9 Jun 2016 13:02:02 +0200 Subject: [PATCH 093/383] Fix compilation for CodeBlocks 16.01 ! (Fixes #65) Former-commit-id: 4cddcf427228260249ac1578283896ee2b7ecbfc [formerly 7bf4124ba228559456f38f4247116ed71a45c227] Former-commit-id: 2b1a728de56c163627fcb6b59231102708f57513 --- build/scripts/common.lua | 6 +++++- src/Nazara/Network/Win32/SocketImpl.cpp | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 5124dcace..f08828e3b 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -83,7 +83,7 @@ function NazaraBuild:Execute() targetsuffix("-s") configuration("codeblocks or codelite or gmake or xcode3 or xcode4") - buildoptions({"-fPIC", "-std=c++14"}) + buildoptions({"-fPIC", "-std=c++14", "-U__STRICT_ANSI__"}) for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) @@ -900,6 +900,10 @@ function NazaraBuild:Resolve(infoTable) end function NazaraBuild:MakeCopyAfterBuild(infoTable) + if (PremakeVersion < 50) then + return + end + if (os.is("windows")) then configuration({}) postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 35d4b2371..9e5846471 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -6,7 +6,22 @@ #include #include #include -#include + +#include +#ifdef NAZARA_COMPILER_MINGW +// MinGW is lacking Mstcpip.h and that's too bad +struct tcp_keepalive +{ + u_long onoff; + u_long keepalivetime; + u_long keepaliveinterval; +}; + +#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) +#else + #include +#endif // NAZARA_COMPILER_MINGW + #include namespace Nz @@ -93,7 +108,7 @@ namespace Nz IpAddressImpl::SockAddrBuffer nameBuffer; int bufferLength = IpAddressImpl::ToSockAddr(address, nameBuffer.data()); - + if (error) *error = SocketError_NoError; @@ -365,7 +380,7 @@ namespace Nz return IpAddress(); } - + if (error) *error = SocketError_NoError; @@ -566,7 +581,7 @@ namespace Nz return true; } - + bool SocketImpl::SetBroadcasting(SocketHandle handle, bool broadcasting, SocketError* error) { NazaraAssert(handle != InvalidHandle, "Invalid handle"); From 8509c7c068abcb38fdb9f45ac3dfb90cb9a34607 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Jun 2016 12:40:31 +0200 Subject: [PATCH 094/383] Network/RUdpConnection: Remove useless line Former-commit-id: 8f55377c62171e3976f4d4d339da9c5e06df9d52 [formerly 4e8143782a1b3814596ce84a7108ebf623352674] Former-commit-id: b58d42df10f79f54c2f104480cc897eaf943a1db --- include/Nazara/Network/RUdpConnection.inl | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index 48173bd77..2960cbced 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -149,8 +149,6 @@ namespace Nz std::vector& pendingPackets = peer.pendingPackets[priority]; if (!pendingPackets.empty()) return true; - - pendingPackets.clear(); } return false; From 116699a313ba0f28e8403ea772d6477b8dec2484 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 11 Jun 2016 13:13:53 +0200 Subject: [PATCH 095/383] Math/Algorithm: Fix IntegralLog2Pot case with sizeof(T) > 4 and %32 bits Former-commit-id: c354e6edf2bd2c69926ff7c2503ec65862eb70ca [formerly 0363386806402faccdfe600341d5d9de5afc26f3] Former-commit-id: 294c14ea78a84558ecbbeeb3276117a411b3d9e5 --- include/Nazara/Math/Algorithm.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index e7e205e45..524f0bd4c 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -90,7 +90,7 @@ namespace Nz // Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse unsigned int log2 = IntegralLog2Pot(val); - if (log2) + if (log2 || val == 1) return log2 + i*8; } From 3a1498b9a42d33b20b00fd9f7b7da91b164767b5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:03:05 +0200 Subject: [PATCH 096/383] Build: Remake exclusion system Allows to excludes pretty much everything and now also excludes projects relying on an excluded dependency Former-commit-id: abb175217d473b85f4add760e13fde3f2c6ff9fa [formerly 27ee2d61414ed907c8d828e5862b97ee40008f85] Former-commit-id: 48bce8d17f8f6c3e761eff000724c60735541ebe --- build/scripts/common.lua | 110 +++++++++++++++++---------------- build/scripts/modules/core.lua | 3 +- 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index f08828e3b..a6de8fca7 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -519,28 +519,19 @@ function NazaraBuild:Initialize() local moduleName = v:match(".*/(.*).lua") local moduleNameLower = moduleName:lower() - if (moduleNameLower ~= "core") then -- exclure le noyau n'aurait aucun sens - newoption({ - trigger = "exclude-" .. moduleNameLower, - description = "Exclude the " .. moduleName .. " module from the build system" - }) - end + local f, err = loadfile(v) + if (f) then + MODULE = {} + self:SetupInfoTable(MODULE) - if (not _OPTIONS["exclude-" .. moduleNameLower]) then - local f, err = loadfile(v) - if (f) then - MODULE = {} - self:SetupInfoTable(MODULE) + f() - f() - - local succeed, err = self:RegisterModule(MODULE) - if (not succeed) then - print("Unable to register module: " .. err) - end - else - print("Unable to load module file: " .. err) + local succeed, err = self:RegisterModule(MODULE) + if (not succeed) then + print("Unable to register module: " .. err) end + else + print("Unable to load module file: " .. err) end end MODULE = nil @@ -551,26 +542,19 @@ function NazaraBuild:Initialize() local toolName = v:match(".*/(.*).lua") local toolNameLower = toolName:lower() - newoption({ - trigger = "exclude-" .. toolNameLower, - description = "Exclude the " .. toolName .. " tool from the build system" - }) + local f, err = loadfile(v) + if (f) then + TOOL = {} + self:SetupInfoTable(TOOL) - if (not _OPTIONS["exclude-" .. toolNameLower]) then - local f, err = loadfile(v) - if (f) then - TOOL = {} - self:SetupInfoTable(TOOL) + f() - f() - - local succeed, err = self:RegisterTool(TOOL) - if (not succeed) then - print("Unable to register tool: " .. err) - end - else - print("Unable to load tool file: " .. err) + local succeed, err = self:RegisterTool(TOOL) + if (not succeed) then + print("Unable to register tool: " .. err) end + else + print("Unable to load tool file: " .. err) end end TOOL = nil @@ -616,9 +600,9 @@ function NazaraBuild:Initialize() for projectId,projectTable in pairs(projects) do if (self:Process(projectTable)) then - table.insert(orderedTables[k], projectTable) + table.insert(orderedTables[k], projectTable) else - print("Rejected client-only " .. projectTable.Name .. " " .. projectTable.Type) + print("Rejected " .. projectTable.Name .. " " .. string.lower(projectTable.Type) .. ": " .. projectTable.ExcludeReason) end end @@ -780,20 +764,17 @@ local PosixOSes = { } function NazaraBuild:Process(infoTable) - if (infoTable.ClientOnly and _OPTIONS["server"]) then - return false - end - local libraries = {} for k, library in pairs(infoTable.Libraries) do - local moduleName = library:match("Nazara(%w+)") - local moduleTable = moduleName and self.Modules[moduleName:lower()] - local toolTable = moduleName and self.Tools[moduleName:lower()] + local projectName = library:match("Nazara(%w+)") + local moduleTable = projectName and self.Modules[projectName:lower()] + local toolTable = projectName and self.Tools[projectName:lower()] if (moduleTable) then - if (moduleTable.ClientOnly and _OPTIONS["server"]) then - infoTable.ClientOnly = true - return false -- We depend on a client-only library + if (moduleTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module" + return false end if (_OPTIONS["united"]) then @@ -811,9 +792,10 @@ function NazaraBuild:Process(infoTable) else local extLibTable = self.ExtLibs[library:lower()] if (extLibTable) then - if (extLibTable.ClientOnly and _OPTIONS["server"]) then - infoTable.ClientOnly = true - return false -- We depend on a client-only library + if (extLibTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library" + return false end library = extLibTable.Name @@ -824,9 +806,10 @@ function NazaraBuild:Process(infoTable) table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") else if (toolTable and toolTable.Kind == "library") then - if (toolTable.ClientOnly and _OPTIONS["server"]) then - infoTable.ClientOnly = true - return false -- We depend on a client-only library + if (toolTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool" + return false end library = "Nazara" .. toolTable.Name @@ -894,6 +877,24 @@ function NazaraBuild:Process(infoTable) end function NazaraBuild:Resolve(infoTable) + if (infoTable.ClientOnly and _OPTIONS["server"]) then + infoTable.Excluded = true + infoTable.ExcludeReason = "excluded by command-line options (client-only)" + end + + if (infoTable.Excludable) then + local optionName = "excludes-" .. string.lower(infoTable.Type .. "-" .. infoTable.Name) + newoption({ + trigger = optionName, + description = "Excludes the " .. infoTable.Name .. " " .. string.lower(infoTable.Type) .. " and projects relying on it" + }) + + if (_OPTIONS[optionName]) then + infoTable.Excluded = true + infoTable.ExcludeReason = "excluded by command-line options" + end + end + if (type(infoTable.Libraries) == "function") then infoTable.Libraries = infoTable.Libraries() end @@ -932,6 +933,7 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) end function NazaraBuild:SetupInfoTable(infoTable) + infoTable.Excludable = true infoTable.ConfigurationLibraries = {} infoTable.ConfigurationLibraries.DebugStatic = {} infoTable.ConfigurationLibraries.ReleaseStatic = {} diff --git a/build/scripts/modules/core.lua b/build/scripts/modules/core.lua index 7156ef2f6..b33c0b61f 100644 --- a/build/scripts/modules/core.lua +++ b/build/scripts/modules/core.lua @@ -1,6 +1,7 @@ MODULE.Name = "Core" +MODULE.Excludable = false -- Excluding the core makes no sense as everything relies on it -MODULE.Files = { -- Les autres fichiers seront ajoutés automatiquement +MODULE.Files = { -- Other files will be automatically added "../include/Nazara/Prerequesites.hpp", "../include/Nazara/Math/**.hpp", "../include/Nazara/Math/**.inl", From daa49db2daa4e0f8568130d32576616b1ed0b84e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:03:39 +0200 Subject: [PATCH 097/383] Build: Remove -fPIC on Windows Former-commit-id: 5cd3d0c7fa9af5022c71c582859b019f695c5b3d [formerly 1f81da6357e1a8664649015fb2cc58a4dac433e7] Former-commit-id: f58c4b94b53994f2e506acdc085e245d8419c4fa --- build/scripts/common.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index a6de8fca7..056f5c022 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -82,8 +82,11 @@ function NazaraBuild:Execute() configuration("ReleaseStatic") targetsuffix("-s") + configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"}) + buildoptions("-fPIC") + configuration("codeblocks or codelite or gmake or xcode3 or xcode4") - buildoptions({"-fPIC", "-std=c++14", "-U__STRICT_ANSI__"}) + buildoptions({"-std=c++14", "-U__STRICT_ANSI__"}) for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) From bd785b9e0e6893c7df2b1df0680f5f27698cddd4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:06:27 +0200 Subject: [PATCH 098/383] Build: Convert spaces to tabs Former-commit-id: c6be47cd6c0945a43472d79efdae28c4ff633b04 [formerly 858f001b7ee5f7e0e8af2421cbc01222fca6d576] Former-commit-id: fa48639f86989da1aa99d8e43c5293a27a8a10b4 --- build/scripts/common.lua | 142 +++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 056f5c022..e51729268 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -11,11 +11,11 @@ function NazaraBuild:Execute() else platformData = {"x32", "x64"} end - + if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" - - if (_OPTIONS["with-extlibs"]) then + + if (_OPTIONS["with-extlibs"]) then workspace("NazaraExtlibs") platforms(platformData) @@ -68,9 +68,9 @@ function NazaraBuild:Execute() configuration("Release*") flags("NoFramePointer") - optimize("Speed") - rtti("Off") - vectorextensions("SSE2") + optimize("Speed") + rtti("Off") + vectorextensions("SSE2") configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"}) buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants @@ -82,7 +82,7 @@ function NazaraBuild:Execute() configuration("ReleaseStatic") targetsuffix("-s") - configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"}) + configuration({"not windows", "codeblocks or codelite or gmake or xcode3 or xcode4"}) buildoptions("-fPIC") configuration("codeblocks or codelite or gmake or xcode3 or xcode4") @@ -90,7 +90,7 @@ function NazaraBuild:Execute() for k, libTable in ipairs(self.OrderedExtLibs) do project(libTable.Name) - + language(libTable.Language) location(_ACTION .. "/extlibs") @@ -106,7 +106,7 @@ function NazaraBuild:Execute() configuration(k) links(v) end - + configuration({}) end end @@ -130,10 +130,10 @@ function NazaraBuild:Execute() flags("Symbols") configuration("Release*") - flags("NoFramePointer") - optimize("Speed") - rtti("Off") - vectorextensions("SSE2") + flags("NoFramePointer") + optimize("Speed") + rtti("Off") + vectorextensions("SSE2") configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"}) buildoptions("-mfpmath=sse") -- Utilisation du SSE pour les calculs flottants @@ -250,17 +250,17 @@ function NazaraBuild:Execute() configuration(k) links(v) end - + configuration({}) end - + -- Tools for k, toolTable in ipairs(self.OrderedTools) do local prefix = "Nazara" if (toolTable.Kind == "plugin") then prefix = "Plugin" end - + project(prefix .. toolTable.Name) location(_ACTION .. "/tools") @@ -358,7 +358,7 @@ function NazaraBuild:Execute() configuration("*Dynamic") kind("SharedLib") - + configuration("DebugStatic") targetsuffix("-s-d") @@ -443,7 +443,7 @@ function NazaraBuild:Execute() configuration(k) links(v) end - + configuration({}) end end @@ -497,24 +497,24 @@ function NazaraBuild:Initialize() ACTION = nil -- Extern libraries - local extlibs = os.matchfiles("../extlibs/build/*.lua") - for k,v in pairs(extlibs) do - local f, err = loadfile(v) - if (f) then - LIBRARY = {} - self:SetupInfoTable(LIBRARY) + local extlibs = os.matchfiles("../extlibs/build/*.lua") + for k,v in pairs(extlibs) do + local f, err = loadfile(v) + if (f) then + LIBRARY = {} + self:SetupInfoTable(LIBRARY) - f() + f() - local succeed, err = self:RegisterExternLibrary(LIBRARY) - if (not succeed) then - print("Unable to register extern library: " .. err) - end - else - print("Unable to load extern library file: " .. err) - end - end - LIBRARY = nil + local succeed, err = self:RegisterExternLibrary(LIBRARY) + if (not succeed) then + print("Unable to register extern library: " .. err) + end + else + print("Unable to load extern library file: " .. err) + end + end + LIBRARY = nil -- Then the modules local modules = os.matchfiles("scripts/modules/*.lua") @@ -587,7 +587,7 @@ function NazaraBuild:Initialize() end EXAMPLE = nil end - + -- Once everything is registred, let's process all the tables self.OrderedExamples = {} self.OrderedExtLibs = {} @@ -596,19 +596,19 @@ function NazaraBuild:Initialize() local tables = {self.ExtLibs, self.Modules, self.Tools, self.Examples} local orderedTables = {self.OrderedExtLibs, self.OrderedModules, self.OrderedTools, self.OrderedExamples} for k,projects in ipairs(tables) do - -- Begin by resolving every project (because of dependencies in the same category) + -- Begin by resolving every project (because of dependencies in the same category) for projectId,projectTable in pairs(projects) do - self:Resolve(projectTable) - end + self:Resolve(projectTable) + end for projectId,projectTable in pairs(projects) do if (self:Process(projectTable)) then table.insert(orderedTables[k], projectTable) - else - print("Rejected " .. projectTable.Name .. " " .. string.lower(projectTable.Type) .. ": " .. projectTable.ExcludeReason) - end + else + print("Rejected " .. projectTable.Name .. " " .. string.lower(projectTable.Type) .. ": " .. projectTable.ExcludeReason) + end end - + table.sort(orderedTables[k], function (a, b) return a.Name < b.Name end) end end @@ -668,13 +668,13 @@ function NazaraBuild:RegisterExample(exampleTable) if (#exampleTable.Files == 0) then return false, "This example has no files" end - + local files = {} for k, file in ipairs(exampleTable.Files) do table.insert(files, "../examples/" .. exampleTable.Directory .. "/" .. file) end exampleTable.Files = files - + exampleTable.Type = "Example" self.Examples[lowerCaseName] = exampleTable return true @@ -719,7 +719,7 @@ function NazaraBuild:RegisterModule(moduleTable) table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.hpp") table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl") table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp") - + if (_OPTIONS["united"] and lowerCaseName ~= "core") then table.insert(moduleTable.FilesExcluded, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp") end @@ -767,18 +767,18 @@ local PosixOSes = { } function NazaraBuild:Process(infoTable) - local libraries = {} + local libraries = {} for k, library in pairs(infoTable.Libraries) do local projectName = library:match("Nazara(%w+)") local moduleTable = projectName and self.Modules[projectName:lower()] local toolTable = projectName and self.Tools[projectName:lower()] - + if (moduleTable) then - if (moduleTable.Excluded) then + if (moduleTable.Excluded) then infoTable.Excluded = true infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module" - return false - end + return false + end if (_OPTIONS["united"]) then library = "NazaraEngine" @@ -795,38 +795,38 @@ function NazaraBuild:Process(infoTable) else local extLibTable = self.ExtLibs[library:lower()] if (extLibTable) then - if (extLibTable.Excluded) then + if (extLibTable.Excluded) then infoTable.Excluded = true infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library" - return false - end + return false + end library = extLibTable.Name - + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") else if (toolTable and toolTable.Kind == "library") then - if (toolTable.Excluded) then + if (toolTable.Excluded) then infoTable.Excluded = true infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool" - return false - end + return false + end library = "Nazara" .. toolTable.Name - + -- Import tools includes for k,v in ipairs(toolTable.Includes) do table.insert(infoTable.Includes, v) end - + -- And libraries for k, v in pairs(toolTable.Libraries) do table.insert(infoTable.Libraries, v) end - + for config, libs in pairs(toolTable.ConfigurationLibraries) do for k,v in pairs(libs) do table.insert(infoTable.ConfigurationLibraries[config], v) @@ -876,14 +876,14 @@ function NazaraBuild:Process(infoTable) end end - return true + return true end function NazaraBuild:Resolve(infoTable) - if (infoTable.ClientOnly and _OPTIONS["server"]) then + if (infoTable.ClientOnly and _OPTIONS["server"]) then infoTable.Excluded = true infoTable.ExcludeReason = "excluded by command-line options (client-only)" - end + end if (infoTable.Excludable) then local optionName = "excludes-" .. string.lower(infoTable.Type .. "-" .. infoTable.Name) @@ -891,22 +891,22 @@ function NazaraBuild:Resolve(infoTable) trigger = optionName, description = "Excludes the " .. infoTable.Name .. " " .. string.lower(infoTable.Type) .. " and projects relying on it" }) - + if (_OPTIONS[optionName]) then infoTable.Excluded = true infoTable.ExcludeReason = "excluded by command-line options" end end - if (type(infoTable.Libraries) == "function") then - infoTable.Libraries = infoTable.Libraries() - end + if (type(infoTable.Libraries) == "function") then + infoTable.Libraries = infoTable.Libraries() + end end function NazaraBuild:MakeCopyAfterBuild(infoTable) - if (PremakeVersion < 50) then - return - end + if (PremakeVersion < 50) then + return + end if (os.is("windows")) then configuration({}) @@ -942,7 +942,7 @@ function NazaraBuild:SetupInfoTable(infoTable) infoTable.ConfigurationLibraries.ReleaseStatic = {} infoTable.ConfigurationLibraries.DebugDynamic = {} infoTable.ConfigurationLibraries.ReleaseDynamic = {} - + local infos = {"Defines", "DynLib", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"} for k,v in ipairs(infos) do infoTable[v] = {} From 3be6ab3666acd418b3e750c1504935fef5b2b88b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 10:14:36 +0200 Subject: [PATCH 099/383] Build: Remove duplicate Former-commit-id: ced72a69471a434dedaa211d105e6ee4a170b487 [formerly d5548d8765668abbad846266e181c7a6e8320926] Former-commit-id: e882b5914602c508deb7a90e60bcd00b4a697fbd --- build/scripts/common.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index e51729268..c359a60c4 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -148,9 +148,6 @@ function NazaraBuild:Execute() configuration({"linux or bsd or macosx", "gmake"}) buildoptions("-fvisibility=hidden") - configuration({"linux or bsd or macosx", "gmake"}) - buildoptions("-fvisibility=hidden") - configuration("vs*") buildoptions("/MP") -- Multiprocessus build flags("NoMinimalRebuild") From 7cca8401db3b0816c689e84c334bff483773400d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 11:39:31 +0200 Subject: [PATCH 100/383] Build: Remake install system Former-commit-id: deb30606621cac3e2142a797158f5472e219d573 [formerly 834b361d6ad2f3cb3626985874996b13b98d5985] Former-commit-id: c56755b94f8f35bbcfae36528fd41aa8db77c7e9 --- build/scripts/common.lua | 122 ++++++++++++++++++++++------- build/scripts/tools/assimp.lua | 2 - build/scripts/tools/ndk.lua | 2 - build/scripts/tools/ndk_server.lua | 4 +- build/scripts/tools/unittests.lua | 3 +- examples/DopplerEffect/build.lua | 2 +- examples/FirstScene/build.lua | 2 +- examples/MeshInfos/build.lua | 2 +- examples/Tut00/build.lua | 2 +- examples/Tut01/build.lua | 2 +- 10 files changed, 102 insertions(+), 41 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index c359a60c4..e7d4929c5 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -1,5 +1,14 @@ NazaraBuild = {} -- L'équivalent d'un namespace en Lua est une table +function NazaraBuild:AddExecutablePath(path) + self.ExecutableDir[path] = true + self.InstallDir[path] = true +end + +function NazaraBuild:AddInstallPath(path) + self.InstallDir[path] = true +end + function NazaraBuild:Execute() if (_ACTION == nil) then -- Si aucune action n'est spécifiée return -- Alors l'utilisateur voulait probablement savoir comment utiliser le programme, on ne fait rien @@ -196,7 +205,7 @@ function NazaraBuild:Execute() targetdir("../lib/" .. makeLibDir .. "/x64") -- Copy the module binaries to the example folder - self:MakeCopyAfterBuild(moduleTable) + self:MakeInstallCommands(moduleTable) configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") @@ -265,12 +274,16 @@ function NazaraBuild:Execute() if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then kind("SharedLib") - elseif (toolTable.Kind == "consoleapp") then + + -- Copy the tool binaries to the example folder + self:MakeInstallCommands(toolTable) + elseif (toolTable.Kind == "application") then debugdir(toolTable.Directory) - kind("ConsoleApp") - elseif (toolTable.Kind == "windowapp") then - debugdir(toolTable.Directory) - kind("WindowedApp") + if (toolTable.EnableConsole) then + kind("ConsoleApp") + else + kind("WindowedApp") + end else assert(false, "Invalid tool Kind") end @@ -308,11 +321,6 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end - -- Copy the tool binaries to the example folder - if (toolTable.CopyTargetToExampleDir) then - self:MakeCopyAfterBuild(toolTable) - end - configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") @@ -385,23 +393,34 @@ function NazaraBuild:Execute() end for k, exampleTable in ipairs(self.OrderedExamples) do + local destPath = "../examples/bin" + project("Demo" .. exampleTable.Name) location(_ACTION .. "/examples") - if (exampleTable.Console) then - kind("ConsoleApp") + if (exampleTable.Kind == "plugin" or exampleTable.Kind == "library") then + kind("SharedLib") + + self:MakeInstallCommands(toolTable) + elseif (exampleTable.Kind == "application") then + debugdir(exampleTable.Directory) + if (exampleTable.EnableConsole) then + kind("ConsoleApp") + else + kind("WindowedApp") + end else - kind("Window") + assert(false, "Invalid tool Kind") end - debugdir("../examples/bin") + debugdir(destPath) includedirs({ "../include", "../extlibs/include" }) libdirs("../lib") - targetdir("../examples/bin") + targetdir(destPath) files(exampleTable.Files) excludes(exampleTable.FilesExcluded) @@ -448,6 +467,11 @@ end function NazaraBuild:Initialize() -- Commençons par les options + newoption({ + trigger = "install-path", + description = "Setup additionnals install directories (library binaries will be copied there)" + }) + newoption({ trigger = "server", description = "Excludes client-only modules/tools/examples" @@ -470,9 +494,18 @@ function NazaraBuild:Initialize() self.Actions = {} self.Examples = {} + self.ExecutableDir = {} self.ExtLibs = {} + self.InstallDir = {} self.Modules = {} self.Tools = {} + + if (_OPTIONS["install-path"]) then + local paths = string.explode(_OPTIONS["install-path"], ";") + for k,v in pairs(paths) do + self:AddInstallPath(v) + end + end -- Actions modules = os.matchfiles("scripts/actions/*.lua") @@ -499,7 +532,7 @@ function NazaraBuild:Initialize() local f, err = loadfile(v) if (f) then LIBRARY = {} - self:SetupInfoTable(LIBRARY) + self:SetupExtlibTable(LIBRARY) f() @@ -522,7 +555,7 @@ function NazaraBuild:Initialize() local f, err = loadfile(v) if (f) then MODULE = {} - self:SetupInfoTable(MODULE) + self:SetupModuleTable(MODULE) f() @@ -545,7 +578,7 @@ function NazaraBuild:Initialize() local f, err = loadfile(v) if (f) then TOOL = {} - self:SetupInfoTable(TOOL) + self:SetupToolTable(TOOL) f() @@ -569,7 +602,7 @@ function NazaraBuild:Initialize() if (f) then EXAMPLE = {} EXAMPLE.Directory = dirName - self:SetupInfoTable(EXAMPLE) + self:SetupExampleTable(EXAMPLE) f() @@ -745,7 +778,7 @@ function NazaraBuild:RegisterTool(toolTable) end local lowerCaseKind = toolTable.Kind:lower() - if (lowerCaseKind == "library" or lowerCaseKind == "plugin" or lowerCaseKind == "consoleapp" or lowerCaseKind == "windowapp") then + if (lowerCaseKind == "library" or lowerCaseKind == "plugin" or lowerCaseKind == "application") then toolTable.Kind = lowerCaseKind else return false, "Invalid tool type" @@ -873,6 +906,10 @@ function NazaraBuild:Process(infoTable) end end + if (infoTable.Kind == "application") then + self:AddExecutablePath(infoTable.Directory) + end + return true end @@ -900,14 +937,18 @@ function NazaraBuild:Resolve(infoTable) end end -function NazaraBuild:MakeCopyAfterBuild(infoTable) +function NazaraBuild:MakeInstallCommands(infoTable) if (PremakeVersion < 50) then return end if (os.is("windows")) then configuration({}) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "..\..\..\examples\bin\" /E /Y]]}) + + for k,v in pairs(self.InstallDir) do + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]}) + end for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do local paths = {} @@ -918,14 +959,18 @@ function NazaraBuild:MakeCopyAfterBuild(infoTable) for k,v in pairs(paths) do local config = v[1] - local path = v[2] - if (os.isfile(path)) then + local srcPath = v[2] + if (os.isfile(srcPath)) then if (infoTable.Kind == "plugin") then - path = "../../" .. path + srcPath = "../../" .. srcPath end configuration(config) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. path .. [[")}" "..\..\..\examples\bin\" /E /Y]]}) + + for k,v in pairs(self.ExecutableDir) do + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}" "]] .. destPath .. [[\" /E /Y]]}) + end end end end @@ -945,4 +990,25 @@ function NazaraBuild:SetupInfoTable(infoTable) infoTable[v] = {} infoTable["Os" .. v] = {} end -end \ No newline at end of file +end + +function NazaraBuild:SetupExampleTable(infoTable) + self:SetupInfoTable(infoTable) + + infoTable.Directory = "../example/bin" + infoTable.Kind = "application" +end + +function NazaraBuild:SetupExtlibTable(infoTable) + self:SetupInfoTable(infoTable) + + infoTable.Kind = "library" +end + +function NazaraBuild:SetupModuleTable(infoTable) + self:SetupInfoTable(infoTable) + + infoTable.Kind = "library" +end + +NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable \ No newline at end of file diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index 3a1ca093b..0eecbcd54 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -3,8 +3,6 @@ TOOL.Name = "Assimp" TOOL.Directory = "../SDK/lib" TOOL.Kind = "Plugin" -TOOL.CopyTargetToExampleDir = true - TOOL.Includes = { "../include", "../plugins/Assimp" diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 961fa6d7f..d2038342b 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -1,7 +1,5 @@ TOOL.Name = "SDK" -TOOL.CopyTargetToExampleDir = true - TOOL.Directory = "../SDK/lib" TOOL.Kind = "Library" diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index b1a71453e..91a0fd170 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -1,7 +1,5 @@ TOOL.Name = "SDKServer" -TOOL.CopyTargetToExampleDir = true - TOOL.Directory = "../SDK/lib" TOOL.Kind = "Library" @@ -23,7 +21,7 @@ TOOL.Files = { "../SDK/src/NDK/**.cpp" } --- Exlude client-only files +-- Excludes client-only files TOOL.FilesExcluded = { "../SDK/**/CameraComponent.*", "../SDK/**/Console.*", diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index cc6051297..349932cb6 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -1,7 +1,8 @@ TOOL.Name = "UnitTests" TOOL.Directory = "../tests" -TOOL.Kind = "ConsoleApp" +TOOL.EnableConsole = true +TOOL.Kind = "Application" TOOL.Defines = { } diff --git a/examples/DopplerEffect/build.lua b/examples/DopplerEffect/build.lua index 8298ef526..302011b81 100644 --- a/examples/DopplerEffect/build.lua +++ b/examples/DopplerEffect/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "DopplerEffect" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/FirstScene/build.lua b/examples/FirstScene/build.lua index 14bf8a42f..612965b5a 100644 --- a/examples/FirstScene/build.lua +++ b/examples/FirstScene/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "FirstScene" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/MeshInfos/build.lua b/examples/MeshInfos/build.lua index 9372ef5c1..4e26f318b 100644 --- a/examples/MeshInfos/build.lua +++ b/examples/MeshInfos/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "MeshInfos" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/Tut00/build.lua b/examples/Tut00/build.lua index d0c499df6..ed5ea5995 100644 --- a/examples/Tut00/build.lua +++ b/examples/Tut00/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "Tut00_EmptyProject" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" diff --git a/examples/Tut01/build.lua b/examples/Tut01/build.lua index c12dc35b5..c195cbc1b 100644 --- a/examples/Tut01/build.lua +++ b/examples/Tut01/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "Tut01_HelloWorld" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Files = { "main.cpp" From 0cc1986460c650251f5d79eaccdc3eadd7ae9420 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 12:46:38 +0200 Subject: [PATCH 101/383] Update .gitignore Former-commit-id: f406588a3ab4c6a38ef868f099be34d27c35ca9c [formerly c4e39da58aafda2d21775f94062e59818fce3612] Former-commit-id: 8b62ec060e6bdb6b4a26533f1d3a145a1606a0bd --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f3b8b2bbd..c930343f4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ examples/bin/*.dll examples/bin/*.so tests/*.exe tests/*.pdb +tests/*.dll +tests/*.so lib/* # Feature page From f36eec7346e854282736cf1fb802de4f705e8e08 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 12 Jun 2016 12:46:56 +0200 Subject: [PATCH 102/383] Build: Fix typo Former-commit-id: 5037b445f99a56806ef1b512e603e83b1fd717aa [formerly 80d13514491997daabb265e22aaa6738ecb12c0c] Former-commit-id: 4bb75843b3b70ce460594b01e89205efde53686d --- build/scripts/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index e7d4929c5..66aa12513 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -995,7 +995,7 @@ end function NazaraBuild:SetupExampleTable(infoTable) self:SetupInfoTable(infoTable) - infoTable.Directory = "../example/bin" + infoTable.Directory = "../examples/bin" infoTable.Kind = "application" end From 819b46f5fc5ae737352a0e7044aeae13366685c6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 21:09:55 +0200 Subject: [PATCH 103/383] Fix a shitload of warnings in 64 bits mode Former-commit-id: c7792a7d5b1f85ab934da25324831b9daa3f47ff [formerly 3469974c48432be1f65808bff0ea39d9e22f5b50] Former-commit-id: 5080815e9e1a3aebe237ff9a291b908ce0292eca --- SDK/include/NDK/BaseComponent.inl | 2 +- .../NDK/Components/GraphicsComponent.hpp | 2 +- SDK/src/NDK/Components/GraphicsComponent.cpp | 2 +- build/scripts/common.lua | 4 +- include/Nazara/Core/Bitset.hpp | 50 ++++---- include/Nazara/Core/Bitset.inl | 114 +++++++++--------- include/Nazara/Core/Endianness.inl | 4 +- include/Nazara/Core/ResourceLoader.hpp | 2 +- include/Nazara/Core/ResourceLoader.inl | 2 +- include/Nazara/Lua/LuaInstance.hpp | 12 +- include/Nazara/Renderer/Texture.hpp | 4 +- include/Nazara/Utility/AbstractAtlas.hpp | 2 +- include/Nazara/Utility/AbstractImage.hpp | 4 +- include/Nazara/Utility/AbstractTextDrawer.hpp | 8 +- include/Nazara/Utility/Font.hpp | 4 +- .../Nazara/Utility/Formats/MD5AnimParser.hpp | 8 +- .../Nazara/Utility/Formats/MD5MeshParser.hpp | 4 +- .../Nazara/Utility/GuillotineImageAtlas.hpp | 13 +- include/Nazara/Utility/Image.hpp | 4 +- include/Nazara/Utility/PixelFormat.inl | 4 +- include/Nazara/Utility/SimpleTextDrawer.hpp | 8 +- src/Nazara/Core/Win32/FileImpl.cpp | 8 +- src/Nazara/Core/Win32/TaskSchedulerImpl.cpp | 8 +- src/Nazara/Core/Win32/TaskSchedulerImpl.hpp | 2 +- src/Nazara/Graphics/TextSprite.cpp | 8 +- src/Nazara/Lua/LuaInstance.cpp | 16 +-- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 +- src/Nazara/Network/Win32/SocketImpl.cpp | 2 +- src/Nazara/Renderer/Renderer.cpp | 6 +- src/Nazara/Renderer/Texture.cpp | 4 +- src/Nazara/Utility/Font.cpp | 6 +- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 10 +- src/Nazara/Utility/Formats/MD5AnimParser.cpp | 8 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 18 +-- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 4 +- src/Nazara/Utility/GuillotineImageAtlas.cpp | 2 +- src/Nazara/Utility/Image.cpp | 4 +- src/Nazara/Utility/SimpleTextDrawer.cpp | 8 +- src/Nazara/Utility/Win32/WindowImpl.cpp | 6 +- 39 files changed, 191 insertions(+), 188 deletions(-) diff --git a/SDK/include/NDK/BaseComponent.inl b/SDK/include/NDK/BaseComponent.inl index 71f8ee2c1..341ddb651 100644 --- a/SDK/include/NDK/BaseComponent.inl +++ b/SDK/include/NDK/BaseComponent.inl @@ -26,7 +26,7 @@ namespace Ndk inline ComponentIndex BaseComponent::RegisterComponent(ComponentId id, Factory factoryFunc) { // Nous allons rajouter notre composant à la fin - ComponentIndex index = s_entries.size(); + ComponentIndex index = static_cast(s_entries.size()); s_entries.resize(index + 1); // On récupère et on affecte diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 86cefb782..c94cec4ab 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -40,7 +40,7 @@ namespace Ndk private: inline void InvalidateBoundingVolume(); - void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index); + void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index); inline void InvalidateRenderables(); inline void InvalidateTransformMatrix(); diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index e345bdb85..88ccd4ca1 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -9,7 +9,7 @@ namespace Ndk { - void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, unsigned int index) + void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index) { NazaraAssert(index < m_renderables.size(), "Invalid renderable index"); NazaraUnused(renderable); diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 66aa12513..12aa13d70 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -54,7 +54,7 @@ function NazaraBuild:Execute() targetdir("../extlibs/lib/" .. makeLibDir .. "/x64") configuration("vs*") - buildoptions("/MP") + buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj configuration({"vs*", "x32"}) libdirs("../extlibs/lib/msvc/x86") @@ -158,7 +158,7 @@ function NazaraBuild:Execute() buildoptions("-fvisibility=hidden") configuration("vs*") - buildoptions("/MP") -- Multiprocessus build + buildoptions({"/MP", "/bigobj"}) -- Multiprocessus build and big .obj flags("NoMinimalRebuild") defines("_CRT_SECURE_NO_WARNINGS") defines("_SCL_SECURE_NO_WARNINGS") diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index 3b440278c..e4e2d8042 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -26,9 +26,9 @@ namespace Nz class Bit; Bitset(); - explicit Bitset(unsigned int bitCount, bool val); + explicit Bitset(std::size_t bitCount, bool val); explicit Bitset(const char* bits); - Bitset(const char* bits, unsigned int bitCount); + Bitset(const char* bits, std::size_t bitCount); Bitset(const Bitset& bitset) = default; explicit Bitset(const String& bits); template Bitset(T value); @@ -36,16 +36,16 @@ namespace Nz ~Bitset() noexcept = default; void Clear() noexcept; - unsigned int Count() const; + std::size_t Count() const; void Flip(); - unsigned int FindFirst() const; - unsigned int FindNext(unsigned int bit) const; + std::size_t FindFirst() const; + std::size_t FindNext(std::size_t bit) const; - Block GetBlock(unsigned int i) const; - unsigned int GetBlockCount() const; - unsigned int GetCapacity() const; - unsigned int GetSize() const; + Block GetBlock(std::size_t i) const; + std::size_t GetBlockCount() const; + std::size_t GetCapacity() const; + std::size_t GetSize() const; void PerformsAND(const Bitset& a, const Bitset& b); void PerformsNOT(const Bitset& a); @@ -54,19 +54,19 @@ namespace Nz bool Intersects(const Bitset& bitset) const; - void Reserve(unsigned int bitCount); - void Resize(unsigned int bitCount, bool defaultVal = false); + void Reserve(std::size_t bitCount); + void Resize(std::size_t bitCount, bool defaultVal = false); void Reset(); - void Reset(unsigned int bit); + void Reset(std::size_t bit); void Set(bool val = true); - void Set(unsigned int bit, bool val = true); - void SetBlock(unsigned int i, Block block); + void Set(std::size_t bit, bool val = true); + void SetBlock(std::size_t i, Block block); void Swap(Bitset& bitset); - bool Test(unsigned int bit) const; + bool Test(std::size_t bit) const; bool TestAll() const; bool TestAny() const; bool TestNone() const; @@ -74,9 +74,9 @@ namespace Nz template T To() const; String ToString() const; - void UnboundedReset(unsigned int bit); - void UnboundedSet(unsigned int bit, bool val = true); - bool UnboundedTest(unsigned int bit) const; + void UnboundedReset(std::size_t bit); + void UnboundedSet(std::size_t bit, bool val = true); + bool UnboundedTest(std::size_t bit) const; Bit operator[](int index); bool operator[](int index) const; @@ -93,20 +93,20 @@ namespace Nz Bitset& operator^=(const Bitset& bitset); static constexpr Block fullBitMask = std::numeric_limits::max(); - static constexpr unsigned int bitsPerBlock = std::numeric_limits::digits; - static constexpr unsigned int npos = std::numeric_limits::max(); + static constexpr std::size_t bitsPerBlock = std::numeric_limits::digits; + static constexpr std::size_t npos = std::numeric_limits::max(); private: - unsigned int FindFirstFrom(unsigned int blockIndex) const; + std::size_t FindFirstFrom(std::size_t blockIndex) const; Block GetLastBlockMask() const; void ResetExtraBits(); - static unsigned int ComputeBlockCount(unsigned int bitCount); - static unsigned int GetBitIndex(unsigned int bit); - static unsigned int GetBlockIndex(unsigned int bit); + static std::size_t ComputeBlockCount(std::size_t bitCount); + static std::size_t GetBitIndex(std::size_t bit); + static std::size_t GetBlockIndex(std::size_t bit); std::vector m_blocks; - unsigned int m_bitCount; + std::size_t m_bitCount; }; template diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index f7256bdbb..21457d7c7 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -42,7 +42,7 @@ namespace Nz */ template - Bitset::Bitset(unsigned int bitCount, bool val) : + Bitset::Bitset(std::size_t bitCount, bool val) : Bitset() { Resize(bitCount, val); @@ -72,11 +72,11 @@ namespace Nz */ template - Bitset::Bitset(const char* bits, unsigned int bitCount) : + Bitset::Bitset(const char* bits, std::size_t bitCount) : m_blocks(ComputeBlockCount(bitCount), 0U), m_bitCount(bitCount) { - for (unsigned int i = 0; i < bitCount; ++i) + for (std::size_t i = 0; i < bitCount; ++i) { switch (*bits++) { @@ -126,7 +126,7 @@ namespace Nz else { // Note: I was kinda tired when I wrote this, there's probably a much easier method than checking bits to write bits - for (unsigned int bitPos = 0; bitPos < std::numeric_limits::digits; bitPos++) + for (std::size_t bitPos = 0; bitPos < std::numeric_limits::digits; bitPos++) { if (value & (T(1U) << bitPos)) UnboundedSet(bitPos, true); @@ -153,13 +153,13 @@ namespace Nz */ template - unsigned int Bitset::Count() const + std::size_t Bitset::Count() const { if (m_blocks.empty()) return 0; - unsigned int count = 0; - for (unsigned int i = 0; i < m_blocks.size(); ++i) + std::size_t count = 0; + for (std::size_t i = 0; i < m_blocks.size(); ++i) count += CountBits(m_blocks[i]); return count; @@ -184,7 +184,7 @@ namespace Nz */ template - unsigned int Bitset::FindFirst() const + std::size_t Bitset::FindFirst() const { return FindFirstFrom(0); } @@ -199,7 +199,7 @@ namespace Nz */ template - unsigned int Bitset::FindNext(unsigned int bit) const + std::size_t Bitset::FindNext(std::size_t bit) const { NazaraAssert(bit < m_bitCount, "Bit index out of range"); @@ -207,8 +207,8 @@ namespace Nz return npos; // The block of the bit and its index - unsigned int blockIndex = GetBlockIndex(bit); - unsigned int bitIndex = GetBitIndex(bit); + std::size_t blockIndex = GetBlockIndex(bit); + std::size_t bitIndex = GetBitIndex(bit); // We get the block Block block = m_blocks[blockIndex]; @@ -233,7 +233,7 @@ namespace Nz */ template - Block Bitset::GetBlock(unsigned int i) const + Block Bitset::GetBlock(std::size_t i) const { NazaraAssert(i < m_blocks.size(), "Block index out of range"); @@ -246,7 +246,7 @@ namespace Nz */ template - unsigned int Bitset::GetBlockCount() const + std::size_t Bitset::GetBlockCount() const { return m_blocks.size(); } @@ -257,7 +257,7 @@ namespace Nz */ template - unsigned int Bitset::GetCapacity() const + std::size_t Bitset::GetCapacity() const { return m_blocks.capacity()*bitsPerBlock; } @@ -268,7 +268,7 @@ namespace Nz */ template - unsigned int Bitset::GetSize() const + std::size_t Bitset::GetSize() const { return m_bitCount; } @@ -285,7 +285,7 @@ namespace Nz template void Bitset::PerformsAND(const Bitset& a, const Bitset& b) { - std::pair minmax = std::minmax(a.GetBlockCount(), b.GetBlockCount()); + std::pair minmax = std::minmax(a.GetBlockCount(), b.GetBlockCount()); // We reinitialise our blocks with zero m_blocks.clear(); @@ -293,7 +293,7 @@ namespace Nz m_bitCount = std::max(a.GetSize(), b.GetSize()); // In case of the "AND", we can stop with the smallest size (because x & 0 = 0) - for (unsigned int i = 0; i < minmax.first; ++i) + for (std::size_t i = 0; i < minmax.first; ++i) m_blocks[i] = a.GetBlock(i) & b.GetBlock(i); ResetExtraBits(); @@ -311,7 +311,7 @@ namespace Nz m_blocks.resize(a.GetBlockCount()); m_bitCount = a.GetSize(); - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) m_blocks[i] = ~a.GetBlock(i); ResetExtraBits(); @@ -332,15 +332,15 @@ namespace Nz const Bitset& greater = (a.GetSize() > b.GetSize()) ? a : b; const Bitset& lesser = (a.GetSize() > b.GetSize()) ? b : a; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); m_blocks.resize(maxBlockCount); m_bitCount = greater.GetSize(); - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) m_blocks[i] = a.GetBlock(i) | b.GetBlock(i); - for (unsigned int i = minBlockCount; i < maxBlockCount; ++i) + for (std::size_t i = minBlockCount; i < maxBlockCount; ++i) m_blocks[i] = greater.GetBlock(i); // (x | 0 = x) ResetExtraBits(); @@ -361,15 +361,15 @@ namespace Nz const Bitset& greater = (a.GetSize() > b.GetSize()) ? a : b; const Bitset& lesser = (a.GetSize() > b.GetSize()) ? b : a; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); m_blocks.resize(maxBlockCount); m_bitCount = greater.GetSize(); - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) m_blocks[i] = a.GetBlock(i) ^ b.GetBlock(i); - for (unsigned int i = minBlockCount; i < maxBlockCount; ++i) + for (std::size_t i = minBlockCount; i < maxBlockCount; ++i) m_blocks[i] = greater.GetBlock(i); // (x ^ 0 = x) ResetExtraBits(); @@ -385,8 +385,8 @@ namespace Nz bool Bitset::Intersects(const Bitset& bitset) const { // We only test the blocks in common - unsigned int sharedBlocks = std::min(GetBlockCount(), bitset.GetBlockCount()); - for (unsigned int i = 0; i < sharedBlocks; ++i) + std::size_t sharedBlocks = std::min(GetBlockCount(), bitset.GetBlockCount()); + for (std::size_t i = 0; i < sharedBlocks; ++i) { Block a = GetBlock(i); Block b = bitset.GetBlock(i); @@ -404,7 +404,7 @@ namespace Nz */ template - void Bitset::Reserve(unsigned int bitCount) + void Bitset::Reserve(std::size_t bitCount) { m_blocks.reserve(ComputeBlockCount(bitCount)); } @@ -417,13 +417,13 @@ namespace Nz */ template - void Bitset::Resize(unsigned int bitCount, bool defaultVal) + void Bitset::Resize(std::size_t bitCount, bool defaultVal) { // We begin with changing the size of container, with the correct value of initialisation - unsigned int lastBlockIndex = m_blocks.size() - 1; + std::size_t lastBlockIndex = m_blocks.size() - 1; m_blocks.resize(ComputeBlockCount(bitCount), (defaultVal) ? fullBitMask : 0U); - unsigned int remainingBits = GetBitIndex(m_bitCount); + std::size_t remainingBits = GetBitIndex(m_bitCount); if (bitCount > m_bitCount && remainingBits > 0 && defaultVal) // Initialisation of unused bits in the last block before the size change m_blocks[lastBlockIndex] |= fullBitMask << remainingBits; @@ -451,7 +451,7 @@ namespace Nz */ template - void Bitset::Reset(unsigned int bit) + void Bitset::Reset(std::size_t bit) { Set(bit, false); } @@ -482,7 +482,7 @@ namespace Nz */ template - void Bitset::Set(unsigned int bit, bool val) + void Bitset::Set(std::size_t bit, bool val) { NazaraAssert(bit < m_bitCount, "Bit index out of range"); @@ -503,7 +503,7 @@ namespace Nz * \remark Produce a NazaraAssert if i is greather than number of blocks in bitset */ template - void Bitset::SetBlock(unsigned int i, Block block) + void Bitset::SetBlock(std::size_t i, Block block) { NazaraAssert(i < m_blocks.size(), "Block index out of range"); @@ -537,7 +537,7 @@ namespace Nz */ template - bool Bitset::Test(unsigned int bit) const + bool Bitset::Test(std::size_t bit) const { NazaraAssert(bit < m_bitCount, "Bit index out of range"); @@ -555,7 +555,7 @@ namespace Nz // Special case for the last block Block lastBlockMask = GetLastBlockMask(); - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) { Block mask = (i == m_blocks.size() - 1) ? lastBlockMask : fullBitMask; if (m_blocks[i] == mask) // The extra bits are set to zero, thus we can't test without proceeding with a mask @@ -576,7 +576,7 @@ namespace Nz if (m_blocks.empty()) return false; - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) { if (m_blocks[i]) return true; @@ -612,7 +612,7 @@ namespace Nz NazaraAssert(m_bitCount <= std::numeric_limits::digits, "Bit count cannot be greater than T bit count"); T value = 0; - for (unsigned int i = 0; i < m_blocks.size(); ++i) + for (std::size_t i = 0; i < m_blocks.size(); ++i) value |= static_cast(m_blocks[i]) << i*bitsPerBlock; return value; @@ -628,7 +628,7 @@ namespace Nz { String str(m_bitCount, '0'); - for (unsigned int i = 0; i < m_bitCount; ++i) + for (std::size_t i = 0; i < m_bitCount; ++i) { if (Test(i)) str[m_bitCount - i - 1] = '1'; // Inversion de l'indice @@ -648,7 +648,7 @@ namespace Nz */ template - void Bitset::UnboundedReset(unsigned int bit) + void Bitset::UnboundedReset(std::size_t bit) { UnboundedSet(bit, false); } @@ -665,7 +665,7 @@ namespace Nz */ template - void Bitset::UnboundedSet(unsigned int bit, bool val) + void Bitset::UnboundedSet(std::size_t bit, bool val) { if (bit < m_bitCount) Set(bit, val); @@ -687,7 +687,7 @@ namespace Nz */ template - bool Bitset::UnboundedTest(unsigned int bit) const + bool Bitset::UnboundedTest(std::size_t bit) const { if (bit < m_bitCount) return Test(bit); @@ -816,13 +816,13 @@ namespace Nz */ template - unsigned int Bitset::FindFirstFrom(unsigned int blockIndex) const + std::size_t Bitset::FindFirstFrom(std::size_t blockIndex) const { if (blockIndex >= m_blocks.size()) return npos; // We are looking for the first non-null block - unsigned int i = blockIndex; + std::size_t i = blockIndex; for (; i < m_blocks.size(); ++i) { if (m_blocks[i]) @@ -868,7 +868,7 @@ namespace Nz */ template - unsigned int Bitset::ComputeBlockCount(unsigned int bitCount) + std::size_t Bitset::ComputeBlockCount(std::size_t bitCount) { return GetBlockIndex(bitCount) + ((GetBitIndex(bitCount) != 0U) ? 1U : 0U); } @@ -879,7 +879,7 @@ namespace Nz */ template - unsigned int Bitset::GetBitIndex(unsigned int bit) + std::size_t Bitset::GetBitIndex(std::size_t bit) { return bit & (bitsPerBlock - 1U); // bit % bitsPerBlock } @@ -890,7 +890,7 @@ namespace Nz */ template - unsigned int Bitset::GetBlockIndex(unsigned int bit) + std::size_t Bitset::GetBlockIndex(std::size_t bit) { return bit / bitsPerBlock; } @@ -1106,18 +1106,18 @@ namespace Nz const Bitset& greater = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? lhs : rhs; const Bitset& lesser = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? rhs : lhs; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); // We test the blocks in common to check the equality of bits - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) { if (lhs.GetBlock(i) != rhs.GetBlock(i)) return false; } // Now we check for the blocks that only the biggest bitset owns, and to be equal, they must be set to '0' - for (unsigned int i = minBlockCount; i < maxBlockCount; ++i) + for (std::size_t i = minBlockCount; i < maxBlockCount; ++i) if (greater.GetBlock(i)) return false; @@ -1152,20 +1152,20 @@ namespace Nz const Bitset& greater = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? lhs : rhs; const Bitset& lesser = (lhs.GetBlockCount() > rhs.GetBlockCount()) ? rhs : lhs; - unsigned int maxBlockCount = greater.GetBlockCount(); - unsigned int minBlockCount = lesser.GetBlockCount(); + std::size_t maxBlockCount = greater.GetBlockCount(); + std::size_t minBlockCount = lesser.GetBlockCount(); // If the greatest bitset has a single bit active in a block outside the lesser bitset range, then it is greater - for (unsigned int i = maxBlockCount; i > minBlockCount; ++i) + for (std::size_t i = maxBlockCount; i > minBlockCount; ++i) { if (greater.GetBlock(i)) return lhs.GetBlockCount() < rhs.GetBlockCount(); } // Compare the common blocks - for (unsigned int i = 0; i < minBlockCount; ++i) + for (std::size_t i = 0; i < minBlockCount; ++i) { - unsigned int index = (minBlockCount - i - 1); // Compare from the most significant block to the less significant block + std::size_t index = (minBlockCount - i - 1); // Compare from the most significant block to the less significant block if (lhs.GetBlock(index) < rhs.GetBlock(index)) return true; } diff --git a/include/Nazara/Core/Endianness.inl b/include/Nazara/Core/Endianness.inl index ee0d094ca..67df87c45 100644 --- a/include/Nazara/Core/Endianness.inl +++ b/include/Nazara/Core/Endianness.inl @@ -33,8 +33,8 @@ namespace Nz inline void SwapBytes(void* buffer, std::size_t size) { UInt8* bytes = static_cast(buffer); - unsigned int i = 0; - unsigned int j = size - 1; + std::size_t i = 0; + std::size_t j = size - 1; while (i < j) std::swap(bytes[i++], bytes[j--]); diff --git a/include/Nazara/Core/ResourceLoader.hpp b/include/Nazara/Core/ResourceLoader.hpp index b0640dcbc..8af3e3cd3 100644 --- a/include/Nazara/Core/ResourceLoader.hpp +++ b/include/Nazara/Core/ResourceLoader.hpp @@ -39,7 +39,7 @@ namespace Nz static bool IsExtensionSupported(const String& extension); static bool LoadFromFile(Type* resource, const String& filePath, const Parameters& parameters = Parameters()); - static bool LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters = Parameters()); + static bool LoadFromMemory(Type* resource, const void* data, std::size_t size, const Parameters& parameters = Parameters()); static bool LoadFromStream(Type* resource, Stream& stream, const Parameters& parameters = Parameters()); static void RegisterLoader(ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader = nullptr, MemoryLoader memoryLoader = nullptr); diff --git a/include/Nazara/Core/ResourceLoader.inl b/include/Nazara/Core/ResourceLoader.inl index 74e59067d..2ac72c6df 100644 --- a/include/Nazara/Core/ResourceLoader.inl +++ b/include/Nazara/Core/ResourceLoader.inl @@ -160,7 +160,7 @@ namespace Nz * \remark Produces a NazaraError if all loaders failed or no loader was found */ template - bool ResourceLoader::LoadFromMemory(Type* resource, const void* data, unsigned int size, const Parameters& parameters) + bool ResourceLoader::LoadFromMemory(Type* resource, const void* data, std::size_t size, const Parameters& parameters) { NazaraAssert(resource, "Invalid resource"); NazaraAssert(data, "Invalid data pointer"); diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index b924f6a05..9affe6f87 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -84,7 +84,7 @@ namespace Nz bool Execute(const String& code); bool ExecuteFromFile(const String& filePath); - bool ExecuteFromMemory(const void* data, unsigned int size); + bool ExecuteFromMemory(const void* data, std::size_t size); bool ExecuteFromStream(Stream& stream); int GetAbsIndex(int index) const; @@ -142,10 +142,10 @@ namespace Nz void PushNumber(double value) const; void PushReference(int ref) const; void PushString(const char* str) const; - void PushString(const char* str, unsigned int size) const; + void PushString(const char* str, std::size_t size) const; void PushString(const String& str) const; void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0) const; - void* PushUserdata(unsigned int size) const; + void* PushUserdata(std::size_t size) const; void PushValue(int index) const; void Remove(int index) const; @@ -158,7 +158,7 @@ namespace Nz void SetMetatable(const char* tname) const; void SetMetatable(const String& tname) const; void SetMetatable(int index) const; - void SetMemoryLimit(UInt32 memoryLimit); + void SetMemoryLimit(std::size_t memoryLimit); void SetTable(int index = -3) const; void SetTimeLimit(UInt32 timeLimit); @@ -185,8 +185,8 @@ namespace Nz static int ProxyFunc(lua_State* state); static void TimeLimiter(lua_State* state, lua_Debug* debug); - UInt32 m_memoryLimit; - UInt32 m_memoryUsage; + std::size_t m_memoryLimit; + std::size_t m_memoryUsage; UInt32 m_timeLimit; Clock m_clock; String m_lastError; diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index 73069aa37..2fd368b53 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -59,8 +59,8 @@ namespace Nz unsigned int GetHeight(UInt8 level = 0) const; UInt8 GetLevelCount() const; UInt8 GetMaxLevel() const; - unsigned int GetMemoryUsage() const; - unsigned int GetMemoryUsage(UInt8 level) const; + std::size_t GetMemoryUsage() const; + std::size_t GetMemoryUsage(UInt8 level) const; Vector3ui GetSize(UInt8 level = 0) const; ImageType GetType() const; unsigned int GetWidth(UInt8 level = 0) const; diff --git a/include/Nazara/Utility/AbstractAtlas.hpp b/include/Nazara/Utility/AbstractAtlas.hpp index 4d135d465..16d09235f 100644 --- a/include/Nazara/Utility/AbstractAtlas.hpp +++ b/include/Nazara/Utility/AbstractAtlas.hpp @@ -29,7 +29,7 @@ namespace Nz virtual void Clear() = 0; virtual void Free(SparsePtr rects, SparsePtr layers, unsigned int count) = 0; virtual AbstractImage* GetLayer(unsigned int layerIndex) const = 0; - virtual unsigned int GetLayerCount() const = 0; + virtual std::size_t GetLayerCount() const = 0; virtual UInt32 GetStorage() const = 0; virtual bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex) = 0; diff --git a/include/Nazara/Utility/AbstractImage.hpp b/include/Nazara/Utility/AbstractImage.hpp index 3a09f3a06..93821e105 100644 --- a/include/Nazara/Utility/AbstractImage.hpp +++ b/include/Nazara/Utility/AbstractImage.hpp @@ -28,8 +28,8 @@ namespace Nz virtual unsigned int GetHeight(UInt8 level = 0) const = 0; virtual UInt8 GetLevelCount() const = 0; virtual UInt8 GetMaxLevel() const = 0; - virtual unsigned int GetMemoryUsage() const = 0; - virtual unsigned int GetMemoryUsage(UInt8 level) const = 0; + virtual std::size_t GetMemoryUsage() const = 0; + virtual std::size_t GetMemoryUsage(UInt8 level) const = 0; virtual Vector3ui GetSize(UInt8 level = 0) const = 0; virtual ImageType GetType() const = 0; virtual unsigned int GetWidth(UInt8 level = 0) const = 0; diff --git a/include/Nazara/Utility/AbstractTextDrawer.hpp b/include/Nazara/Utility/AbstractTextDrawer.hpp index ffd704f6a..9f941b9c9 100644 --- a/include/Nazara/Utility/AbstractTextDrawer.hpp +++ b/include/Nazara/Utility/AbstractTextDrawer.hpp @@ -27,10 +27,10 @@ namespace Nz virtual ~AbstractTextDrawer(); virtual const Recti& GetBounds() const = 0; - virtual Font* GetFont(unsigned int index) const = 0; - virtual unsigned int GetFontCount() const = 0; - virtual const Glyph& GetGlyph(unsigned int index) const = 0; - virtual unsigned int GetGlyphCount() const = 0; + virtual Font* GetFont(std::size_t index) const = 0; + virtual std::size_t GetFontCount() const = 0; + virtual const Glyph& GetGlyph(std::size_t index) const = 0; + virtual std::size_t GetGlyphCount() const = 0; struct Glyph { diff --git a/include/Nazara/Utility/Font.hpp b/include/Nazara/Utility/Font.hpp index 257e91245..9a226d91e 100644 --- a/include/Nazara/Utility/Font.hpp +++ b/include/Nazara/Utility/Font.hpp @@ -61,8 +61,8 @@ namespace Nz bool ExtractGlyph(unsigned int characterSize, char32_t character, UInt32 style, FontGlyph* glyph) const; const std::shared_ptr& GetAtlas() const; - unsigned int GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const; - unsigned int GetCachedGlyphCount() const; + std::size_t GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const; + std::size_t GetCachedGlyphCount() const; String GetFamilyName() const; int GetKerning(unsigned int characterSize, char32_t first, char32_t second) const; const Glyph& GetGlyph(unsigned int characterSize, UInt32 style, char32_t character) const; diff --git a/include/Nazara/Utility/Formats/MD5AnimParser.hpp b/include/Nazara/Utility/Formats/MD5AnimParser.hpp index cfba9fdc4..558608142 100644 --- a/include/Nazara/Utility/Formats/MD5AnimParser.hpp +++ b/include/Nazara/Utility/Formats/MD5AnimParser.hpp @@ -47,12 +47,12 @@ namespace Nz Ternary Check(); - unsigned int GetAnimatedComponentCount() const; + std::size_t GetAnimatedComponentCount() const; const Frame* GetFrames() const; - unsigned int GetFrameCount() const; - unsigned int GetFrameRate() const; + std::size_t GetFrameCount() const; + std::size_t GetFrameRate() const; const Joint* GetJoints() const; - unsigned int GetJointCount() const; + std::size_t GetJointCount() const; bool Parse(); diff --git a/include/Nazara/Utility/Formats/MD5MeshParser.hpp b/include/Nazara/Utility/Formats/MD5MeshParser.hpp index 5d114bdbb..cd2d19309 100644 --- a/include/Nazara/Utility/Formats/MD5MeshParser.hpp +++ b/include/Nazara/Utility/Formats/MD5MeshParser.hpp @@ -58,9 +58,9 @@ namespace Nz Ternary Check(); const Joint* GetJoints() const; - unsigned int GetJointCount() const; + std::size_t GetJointCount() const; const Mesh* GetMeshes() const; - unsigned int GetMeshCount() const; + std::size_t GetMeshCount() const; bool Parse(); diff --git a/include/Nazara/Utility/GuillotineImageAtlas.hpp b/include/Nazara/Utility/GuillotineImageAtlas.hpp index f26ae13ea..318b92d6b 100644 --- a/include/Nazara/Utility/GuillotineImageAtlas.hpp +++ b/include/Nazara/Utility/GuillotineImageAtlas.hpp @@ -23,16 +23,17 @@ namespace Nz GuillotineImageAtlas(); virtual ~GuillotineImageAtlas(); - void Clear(); - void Free(SparsePtr rects, SparsePtr layers, unsigned int count); + void Clear() override; + + void Free(SparsePtr rects, SparsePtr layers, unsigned int count) override; GuillotineBinPack::FreeRectChoiceHeuristic GetRectChoiceHeuristic() const; GuillotineBinPack::GuillotineSplitHeuristic GetRectSplitHeuristic() const; - AbstractImage* GetLayer(unsigned int layerIndex) const; - unsigned int GetLayerCount() const; - UInt32 GetStorage() const; + AbstractImage* GetLayer(unsigned int layerIndex) const override; + std::size_t GetLayerCount() const override; + UInt32 GetStorage() const override; - bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex); + bool Insert(const Image& image, Rectui* rect, bool* flipped, unsigned int* layerIndex) override; void SetRectChoiceHeuristic(GuillotineBinPack::FreeRectChoiceHeuristic heuristic); void SetRectSplitHeuristic(GuillotineBinPack::GuillotineSplitHeuristic heuristic); diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index 65c03d6bd..d936ee4d8 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -84,8 +84,8 @@ namespace Nz unsigned int GetHeight(UInt8 level = 0) const; UInt8 GetLevelCount() const; UInt8 GetMaxLevel() const; - unsigned int GetMemoryUsage() const; - unsigned int GetMemoryUsage(UInt8 level) const; + std::size_t GetMemoryUsage() const; + std::size_t GetMemoryUsage(UInt8 level) const; Color GetPixelColor(unsigned int x, unsigned int y = 0, unsigned int z = 0) const; UInt8* GetPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0); Vector3ui GetSize(UInt8 level = 0) const; diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index e384d8574..bf827c4c0 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -100,7 +100,7 @@ namespace Nz counter |= blueMask; counter |= alphaMask; - bitsPerPixel = counter.Count(); + bitsPerPixel = static_cast(counter.Count()); } inline bool PixelFormatInfo::Validate() const @@ -116,7 +116,7 @@ namespace Nz for (unsigned int i = 0; i < 4; ++i) { - unsigned int usedBits = masks[i]->Count(); + UInt8 usedBits = static_cast(masks[i]->Count()); if (usedBits == 0) continue; diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index f5532ca8f..b2f2bf4f9 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -32,10 +32,10 @@ namespace Nz unsigned int GetCharacterSize() const; const Color& GetColor() const; Font* GetFont() const; - Font* GetFont(unsigned int index) const override; - unsigned int GetFontCount() const override; - const Glyph& GetGlyph(unsigned int index) const override; - unsigned int GetGlyphCount() const override; + Font* GetFont(std::size_t index) const override; + std::size_t GetFontCount() const override; + const Glyph& GetGlyph(std::size_t index) const override; + std::size_t GetGlyphCount() const override; UInt32 GetStyle() const; const String& GetText() const; diff --git a/src/Nazara/Core/Win32/FileImpl.cpp b/src/Nazara/Core/Win32/FileImpl.cpp index dcce3d29a..5ed051adb 100644 --- a/src/Nazara/Core/Win32/FileImpl.cpp +++ b/src/Nazara/Core/Win32/FileImpl.cpp @@ -96,7 +96,7 @@ namespace Nz //UInt64 oldCursorPos = GetCursorPos(); DWORD read = 0; - if (ReadFile(m_handle, buffer, size, &read, nullptr)) + if (ReadFile(m_handle, buffer, static_cast(size), &read, nullptr)) { m_endOfFile = (read != size); m_endOfFileUpdated = true; @@ -191,9 +191,9 @@ namespace Nz LARGE_INTEGER cursorPos; cursorPos.QuadPart = GetCursorPos(); - LockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, size, 0); - WriteFile(m_handle, buffer, size, &written, nullptr); - UnlockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, size, 0); + LockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, static_cast(size), 0); + WriteFile(m_handle, buffer, static_cast(size), &written, nullptr); + UnlockFile(m_handle, cursorPos.LowPart, cursorPos.HighPart, static_cast(size), 0); m_endOfFileUpdated = false; diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp index 5b5d7153d..ef83e4b28 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp @@ -24,7 +24,7 @@ namespace Nz } #endif - s_workerCount = workerCount; + s_workerCount = static_cast(workerCount); s_doneEvents.reset(new HANDLE[workerCount]); s_workers.reset(new Worker[workerCount]); s_workerThreads.reset(new HANDLE[workerCount]); @@ -64,7 +64,7 @@ namespace Nz // On s'assure que des tâches ne sont pas déjà en cours WaitForMultipleObjects(s_workerCount, &s_doneEvents[0], true, INFINITE); - std::ldiv_t div = std::ldiv(count, s_workerCount); // Division et modulo en une opération, y'a pas de petit profit + std::lldiv_t div = std::lldiv(count, s_workerCount); // Division et modulo en une opération, y'a pas de petit profit for (std::size_t i = 0; i < s_workerCount; ++i) { // On va maintenant répartir les tâches entre chaque worker et les envoyer dans la queue de chacun @@ -78,7 +78,7 @@ namespace Nz } // On les lance une fois qu'ils sont tous initialisés (pour éviter qu'un worker ne passe en pause détectant une absence de travaux) - for (unsigned int i = 0; i < s_workerCount; ++i) + for (std::size_t i = 0; i < s_workerCount; ++i) { ResetEvent(s_doneEvents[i]); SetEvent(s_workers[i].wakeEvent); @@ -244,5 +244,5 @@ namespace Nz std::unique_ptr TaskSchedulerImpl::s_doneEvents; // Doivent être contigus std::unique_ptr TaskSchedulerImpl::s_workers; std::unique_ptr TaskSchedulerImpl::s_workerThreads; // Doivent être contigus - std::size_t TaskSchedulerImpl::s_workerCount; + DWORD TaskSchedulerImpl::s_workerCount; } diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp index 00fdec634..aabd58b86 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp @@ -44,7 +44,7 @@ namespace Nz static std::unique_ptr s_doneEvents; // Doivent être contigus static std::unique_ptr s_workers; static std::unique_ptr s_workerThreads; // Doivent être contigus - static std::size_t s_workerCount; + static DWORD s_workerCount; }; } diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 3459b22cd..42dba4aaf 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -64,8 +64,8 @@ namespace Nz pair.second.used = false; // ... until they are marked as used by the drawer - unsigned int fontCount = drawer.GetFontCount(); - for (unsigned int i = 0; i < fontCount; ++i) + std::size_t fontCount = drawer.GetFontCount(); + for (std::size_t i = 0; i < fontCount; ++i) { Font* font = drawer.GetFont(i); const AbstractAtlas* atlas = font->GetAtlas().get(); @@ -95,7 +95,7 @@ namespace Nz ++atlasIt; } - unsigned int glyphCount = drawer.GetGlyphCount(); + std::size_t glyphCount = drawer.GetGlyphCount(); m_localVertices.resize(glyphCount * 4); // Reset glyph count for every texture to zero @@ -105,7 +105,7 @@ namespace Nz // Count glyph count for each texture Texture* lastTexture = nullptr; unsigned int* count = nullptr; - for (unsigned int i = 0; i < glyphCount; ++i) + for (std::size_t i = 0; i < glyphCount; ++i) { const AbstractTextDrawer::Glyph& glyph = drawer.GetGlyph(i); diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 23f852921..0ecf4c063 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -401,7 +401,7 @@ namespace Nz return false; } - unsigned int length = static_cast(file.GetSize()); + std::size_t length = static_cast(file.GetSize()); String source(length, '\0'); @@ -416,7 +416,7 @@ namespace Nz return Execute(source); } - bool LuaInstance::ExecuteFromMemory(const void* data, unsigned int size) + bool LuaInstance::ExecuteFromMemory(const void* data, std::size_t size) { MemoryView stream(data, size); return ExecuteFromStream(stream); @@ -679,7 +679,7 @@ namespace Nz lua_pushstring(m_state, str); } - void LuaInstance::PushString(const char* str, unsigned int size) const + void LuaInstance::PushString(const char* str, std::size_t size) const { lua_pushlstring(m_state, str, size); } @@ -694,7 +694,7 @@ namespace Nz lua_createtable(m_state, sequenceElementCount, arrayElementCount); } - void* LuaInstance::PushUserdata(unsigned int size) const + void* LuaInstance::PushUserdata(std::size_t size) const { return lua_newuserdata(m_state, size); } @@ -749,7 +749,7 @@ namespace Nz lua_setmetatable(m_state, index); } - void LuaInstance::SetMemoryLimit(UInt32 memoryLimit) + void LuaInstance::SetMemoryLimit(std::size_t memoryLimit) { m_memoryLimit = memoryLimit; } @@ -860,8 +860,8 @@ namespace Nz void* LuaInstance::MemoryAllocator(void* ud, void* ptr, std::size_t osize, std::size_t nsize) { LuaInstance* instance = static_cast(ud); - UInt32& memoryLimit = instance->m_memoryLimit; - UInt32& memoryUsage = instance->m_memoryUsage; + std::size_t& memoryLimit = instance->m_memoryLimit; + std::size_t& memoryUsage = instance->m_memoryUsage; if (nsize == 0) { @@ -872,7 +872,7 @@ namespace Nz } else { - UInt32 usage = memoryUsage + nsize; + std::size_t usage = memoryUsage + nsize; if (ptr) usage -= osize; diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 0fd5cd88a..cbcebb83b 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -56,7 +56,7 @@ namespace Nz std::array hostnameBuffer; std::array serviceBuffer; - int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), hostnameBuffer.size(), serviceBuffer.data(), serviceBuffer.size(), flags); + int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); if (result == 0) { if (hostname) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 9e5846471..ab7ba7fe3 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -328,7 +328,7 @@ namespace Nz return code == TRUE; } - unsigned int SocketImpl::QueryMaxDatagramSize(SocketHandle handle, SocketError* error) + std::size_t SocketImpl::QueryMaxDatagramSize(SocketHandle handle, SocketError* error) { unsigned int code; int codeLength = sizeof(code); diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 1093f1fd1..e49db2cec 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -227,7 +227,8 @@ namespace Nz } GLenum type; - UInt8* offset = reinterpret_cast(s_indexBuffer->GetStartOffset()); + UInt8* offset = nullptr; + offset += s_indexBuffer->GetStartOffset(); if (s_indexBuffer->HasLargeIndices()) { @@ -290,7 +291,8 @@ namespace Nz } GLenum type; - UInt8* offset = reinterpret_cast(s_indexBuffer->GetStartOffset()); + UInt8* offset = nullptr; + offset += s_indexBuffer->GetStartOffset(); if (s_indexBuffer->HasLargeIndices()) { diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index 835dce85e..b8bed61a0 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -364,7 +364,7 @@ namespace Nz return Image::GetMaxLevel(m_impl->type, m_impl->width, m_impl->height, m_impl->depth); } - unsigned int Texture::GetMemoryUsage() const + std::size_t Texture::GetMemoryUsage() const { #if NAZARA_RENDERER_SAFE if (!m_impl) @@ -399,7 +399,7 @@ namespace Nz return size * PixelFormat::GetBytesPerPixel(m_impl->format); } - unsigned int Texture::GetMemoryUsage(UInt8 level) const + std::size_t Texture::GetMemoryUsage(UInt8 level) const { #if NAZARA_UTILITY_SAFE if (!m_impl) diff --git a/src/Nazara/Utility/Font.cpp b/src/Nazara/Utility/Font.cpp index a29d28671..b5914aa58 100644 --- a/src/Nazara/Utility/Font.cpp +++ b/src/Nazara/Utility/Font.cpp @@ -127,7 +127,7 @@ namespace Nz return m_atlas; } - unsigned int Font::GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const + std::size_t Font::GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const { UInt64 key = ComputeKey(characterSize, style); auto it = m_glyphes.find(key); @@ -137,9 +137,9 @@ namespace Nz return it->second.size(); } - unsigned int Font::GetCachedGlyphCount() const + std::size_t Font::GetCachedGlyphCount() const { - unsigned int count = 0; + std::size_t count = 0; for (auto& pair : m_glyphes) count += pair.second.size(); diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index d079dc426..e61f6dda2 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -37,10 +37,10 @@ namespace Nz } const MD5AnimParser::Frame* frames = parser.GetFrames(); - unsigned int frameCount = parser.GetFrameCount(); - unsigned int frameRate = parser.GetFrameRate(); + std::size_t frameCount = parser.GetFrameCount(); + std::size_t frameRate = parser.GetFrameRate(); const MD5AnimParser::Joint* joints = parser.GetJoints(); - unsigned int jointCount = parser.GetJointCount(); + std::size_t jointCount = parser.GetJointCount(); // À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation animation->CreateSkeletal(frameCount, jointCount); @@ -59,10 +59,10 @@ namespace Nz Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) * Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { int parent = joints[i].parent; - for (unsigned int j = 0; j < frameCount; ++j) + for (std::size_t j = 0; j < frameCount; ++j) { SequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i]; diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index 9cd930c2e..105944858 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -48,7 +48,7 @@ namespace Nz return Ternary_False; } - unsigned int MD5AnimParser::GetAnimatedComponentCount() const + std::size_t MD5AnimParser::GetAnimatedComponentCount() const { return m_animatedComponents.size(); } @@ -58,12 +58,12 @@ namespace Nz return m_frames.data(); } - unsigned int MD5AnimParser::GetFrameCount() const + std::size_t MD5AnimParser::GetFrameCount() const { return m_frames.size(); } - unsigned int MD5AnimParser::GetFrameRate() const + std::size_t MD5AnimParser::GetFrameRate() const { return m_frameRate; } @@ -73,7 +73,7 @@ namespace Nz return m_joints.data(); } - unsigned int MD5AnimParser::GetJointCount() const + std::size_t MD5AnimParser::GetJointCount() const { return m_joints.size(); } diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index ce56b136a..cd8a6813a 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -53,15 +53,15 @@ namespace Nz const MD5MeshParser::Joint* joints = parser.GetJoints(); const MD5MeshParser::Mesh* meshes = parser.GetMeshes(); - unsigned int jointCount = parser.GetJointCount(); - unsigned int meshCount = parser.GetMeshCount(); + std::size_t jointCount = parser.GetJointCount(); + std::size_t meshCount = parser.GetMeshCount(); if (parameters.animated) { mesh->CreateSkeletal(jointCount); Skeleton* skeleton = mesh->GetSkeleton(); - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { Joint* joint = skeleton->GetJoint(i); @@ -82,12 +82,12 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (unsigned int i = 0; i < meshCount; ++i) + for (std::size_t i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; - unsigned int indexCount = md5Mesh.triangles.size()*3; - unsigned int vertexCount = md5Mesh.vertices.size(); + std::size_t indexCount = md5Mesh.triangles.size()*3; + std::size_t vertexCount = md5Mesh.vertices.size(); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -227,11 +227,11 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (unsigned int i = 0; i < meshCount; ++i) + for (std::size_t i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; - unsigned int indexCount = md5Mesh.triangles.size()*3; - unsigned int vertexCount = md5Mesh.vertices.size(); + std::size_t indexCount = md5Mesh.triangles.size()*3; + std::size_t vertexCount = md5Mesh.vertices.size(); // Index buffer bool largeIndices = (vertexCount > std::numeric_limits::max()); diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index 56e384bf0..b4fd04a33 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -58,7 +58,7 @@ namespace Nz return m_joints.data(); } - unsigned int MD5MeshParser::GetJointCount() const + std::size_t MD5MeshParser::GetJointCount() const { return m_joints.size(); } @@ -68,7 +68,7 @@ namespace Nz return m_meshes.data(); } - unsigned int MD5MeshParser::GetMeshCount() const + std::size_t MD5MeshParser::GetMeshCount() const { return m_meshes.size(); } diff --git a/src/Nazara/Utility/GuillotineImageAtlas.cpp b/src/Nazara/Utility/GuillotineImageAtlas.cpp index 35beab566..b3e630921 100644 --- a/src/Nazara/Utility/GuillotineImageAtlas.cpp +++ b/src/Nazara/Utility/GuillotineImageAtlas.cpp @@ -70,7 +70,7 @@ namespace Nz return layer.image.get(); } - unsigned int GuillotineImageAtlas::GetLayerCount() const + std::size_t GuillotineImageAtlas::GetLayerCount() const { return m_layers.size(); } diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index c8f3e49f1..9e0213cf6 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -666,7 +666,7 @@ namespace Nz return GetMaxLevel(m_sharedImage->type, m_sharedImage->width, m_sharedImage->height, m_sharedImage->depth); } - unsigned int Image::GetMemoryUsage() const + std::size_t Image::GetMemoryUsage() const { unsigned int width = m_sharedImage->width; unsigned int height = m_sharedImage->height; @@ -693,7 +693,7 @@ namespace Nz return size * PixelFormat::GetBytesPerPixel(m_sharedImage->format); } - unsigned int Image::GetMemoryUsage(UInt8 level) const + std::size_t Image::GetMemoryUsage(UInt8 level) const { return PixelFormat::ComputeSize(m_sharedImage->format, GetLevelSize(m_sharedImage->width, level), GetLevelSize(m_sharedImage->height, level), ((m_sharedImage->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level))); } diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index ae2dc8762..03a95f35a 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -72,19 +72,19 @@ namespace Nz return m_font; } - Font* SimpleTextDrawer::GetFont(unsigned int index) const + Font* SimpleTextDrawer::GetFont(std::size_t index) const { NazaraAssert(index == 0, "Font index out of range"); return m_font; } - unsigned int SimpleTextDrawer::GetFontCount() const + std::size_t SimpleTextDrawer::GetFontCount() const { return 1; } - const AbstractTextDrawer::Glyph& SimpleTextDrawer::GetGlyph(unsigned int index) const + const AbstractTextDrawer::Glyph& SimpleTextDrawer::GetGlyph(std::size_t index) const { if (!m_glyphUpdated) UpdateGlyphs(); @@ -94,7 +94,7 @@ namespace Nz return m_glyphs[index]; } - unsigned int SimpleTextDrawer::GetGlyphCount() const + std::size_t SimpleTextDrawer::GetGlyphCount() const { if (!m_glyphUpdated) UpdateGlyphs(); diff --git a/src/Nazara/Utility/Win32/WindowImpl.cpp b/src/Nazara/Utility/Win32/WindowImpl.cpp index 2bf9c9d02..b494a7789 100644 --- a/src/Nazara/Utility/Win32/WindowImpl.cpp +++ b/src/Nazara/Utility/Win32/WindowImpl.cpp @@ -394,7 +394,7 @@ namespace Nz void WindowImpl::SetMaximumSize(int width, int height) { RECT rect = {0, 0, width, height}; - AdjustWindowRect(&rect, GetWindowLongPtr(m_handle, GWL_STYLE), false); + AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); if (width != -1) m_maxSize.x = rect.right-rect.left; @@ -410,7 +410,7 @@ namespace Nz void WindowImpl::SetMinimumSize(int width, int height) { RECT rect = {0, 0, width, height}; - AdjustWindowRect(&rect, GetWindowLongPtr(m_handle, GWL_STYLE), false); + AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); if (width != -1) m_minSize.x = rect.right-rect.left; @@ -432,7 +432,7 @@ namespace Nz { // SetWindowPos demande la taille totale de la fenêtre RECT rect = {0, 0, static_cast(width), static_cast(height)}; - AdjustWindowRect(&rect, GetWindowLongPtr(m_handle, GWL_STYLE), false); + AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); SetWindowPos(m_handle, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER); } From d90a7353722bc2d1130a2abb9d3f10928b627058 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 21:19:12 +0200 Subject: [PATCH 104/383] Build: Fix example path Former-commit-id: 3cdf26b3497439c344bbc8b3738df6a316f6bef6 [formerly c25cd61df2ea180fa2d79585bd031027c75f2007] Former-commit-id: 96a3ee99070e34f05b9dabb582ee878a82801c65 --- build/scripts/common.lua | 12 ++++++------ build/scripts/tools/assimp.lua | 3 ++- build/scripts/tools/ndk.lua | 3 ++- build/scripts/tools/ndk_server.lua | 3 ++- build/scripts/tools/unittests.lua | 1 + 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 12aa13d70..2b4906569 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -270,7 +270,7 @@ function NazaraBuild:Execute() project(prefix .. toolTable.Name) location(_ACTION .. "/tools") - targetdir(toolTable.Directory) + targetdir(toolTable.TargetDirectory) if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then kind("SharedLib") @@ -278,7 +278,7 @@ function NazaraBuild:Execute() -- Copy the tool binaries to the example folder self:MakeInstallCommands(toolTable) elseif (toolTable.Kind == "application") then - debugdir(toolTable.Directory) + debugdir(toolTable.TargetDirectory) if (toolTable.EnableConsole) then kind("ConsoleApp") else @@ -404,7 +404,7 @@ function NazaraBuild:Execute() self:MakeInstallCommands(toolTable) elseif (exampleTable.Kind == "application") then - debugdir(exampleTable.Directory) + debugdir(exampleTable.TargetDirectory) if (exampleTable.EnableConsole) then kind("ConsoleApp") else @@ -769,7 +769,7 @@ function NazaraBuild:RegisterTool(toolTable) return false, "This tool name is already in use" end - if (toolTable.Directory == nil or type(toolTable.Directory) ~= "string" or string.len(toolTable.Directory) == 0) then + if (toolTable.TargetDirectory == nil or type(toolTable.TargetDirectory) ~= "string" or string.len(toolTable.TargetDirectory) == 0) then return false, "Invalid tool directory" end @@ -907,7 +907,7 @@ function NazaraBuild:Process(infoTable) end if (infoTable.Kind == "application") then - self:AddExecutablePath(infoTable.Directory) + self:AddExecutablePath(infoTable.TargetDirectory) end return true @@ -995,8 +995,8 @@ end function NazaraBuild:SetupExampleTable(infoTable) self:SetupInfoTable(infoTable) - infoTable.Directory = "../examples/bin" infoTable.Kind = "application" + infoTable.TargetDirectory = "../examples/bin" end function NazaraBuild:SetupExtlibTable(infoTable) diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index 0eecbcd54..08688ef72 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -1,7 +1,8 @@ TOOL.Name = "Assimp" -TOOL.Directory = "../SDK/lib" +TOOL.Directory = "../plugins/Assimp" TOOL.Kind = "Plugin" +TOOL.TargetDirectory = "../SDK/lib" TOOL.Includes = { "../include", diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index d2038342b..8a40ea170 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -1,7 +1,8 @@ TOOL.Name = "SDK" -TOOL.Directory = "../SDK/lib" +TOOL.Directory = "../SDK" TOOL.Kind = "Library" +TOOL.TargetDirectory = "../SDK/lib" TOOL.Defines = { "NDK_BUILD" diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 91a0fd170..2881c56fc 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -1,7 +1,8 @@ TOOL.Name = "SDKServer" -TOOL.Directory = "../SDK/lib" +TOOL.Directory = "../SDK" TOOL.Kind = "Library" +TOOL.TargetDirectory = "../SDK/lib" TOOL.Defines = { "NDK_BUILD", diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index 349932cb6..fc0f4bad6 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -3,6 +3,7 @@ TOOL.Name = "UnitTests" TOOL.Directory = "../tests" TOOL.EnableConsole = true TOOL.Kind = "Application" +TOOL.TargetDirectory = TOOL.Directory TOOL.Defines = { } From 108a6af39fddea8f8de215385175943b4ee511bf Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 17 Jun 2016 22:30:29 +0200 Subject: [PATCH 105/383] Fix some more warnings Former-commit-id: d5a845b6a2c468c08e1c40ccbcfc87b2a49f67be [formerly 8829226909d7280607fcdf6bba6b2b79ca0eec1d] Former-commit-id: af76bbeec9543055d14ec142726cc4b85afa1985 --- SDK/src/NDK/Entity.cpp | 10 +++++----- SDK/src/NDK/World.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 17730a234..f037e5f9a 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -51,7 +51,7 @@ namespace Ndk BaseComponent& component = *m_components[index].get(); component.SetEntity(this); - for (unsigned int i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) { if (i != index) m_components[i]->OnComponentAttached(component); @@ -73,8 +73,8 @@ namespace Ndk void Entity::RemoveAllComponents() { - for (unsigned int i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) - RemoveComponent(i); + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + RemoveComponent(static_cast(i)); NazaraAssert(m_componentBits.TestNone(), "All components should be gone"); @@ -90,7 +90,7 @@ namespace Ndk { // On récupère le component et on informe les composants du détachement BaseComponent& component = *m_components[index].get(); - for (unsigned int i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) { if (i != index) m_components[i]->OnComponentDetached(component); @@ -114,7 +114,7 @@ namespace Ndk void Entity::Destroy() { // On informe chaque système - for (SystemIndex index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) + for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) { if (m_world->HasSystem(index)) { diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index fc53143dd..e95785896 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -94,7 +94,7 @@ namespace Ndk void World::Update() { // Gestion des entités tuées depuis le dernier appel - for (unsigned int i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) + for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) { EntityBlock& block = m_entities[i]; Entity& entity = block.entity; @@ -127,7 +127,7 @@ namespace Ndk m_killedEntities.Reset(); // Gestion des entités nécessitant une mise à jour de leurs systèmes - for (unsigned int i = m_dirtyEntities.FindFirst(); i != m_dirtyEntities.npos; i = m_dirtyEntities.FindNext(i)) + for (std::size_t i = m_dirtyEntities.FindFirst(); i != m_dirtyEntities.npos; i = m_dirtyEntities.FindNext(i)) { NazaraAssert(i < m_entities.size(), "Entity index out of range"); From 752fd3d4d23c35ded2b94b938546ba471df964e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 18 Jun 2016 07:04:15 +0200 Subject: [PATCH 106/383] Examples: Fix compilation of FirstScene Former-commit-id: 8534eca8f43c4d3f6114dadd0400d8a4620bbc07 [formerly 1c1c6961b43355862474e8c8c9de3b25d3376931] Former-commit-id: 4b6bb56832f2d5088ebb8614a4e8720a8f5a3112 --- examples/FirstScene/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 24fef574f..385b054e0 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -29,7 +29,7 @@ Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& ta int main() { - // Pour commencer, nous initialisons le SDK de Nazara, celui-ci va préparer le terrain en initialisant le moteur, + // Pour commencer, nous initialisons le SDK de Nazara, celui-ci va préparer le terrain en initialisant le moteur, // les composants, systèmes, etc. // NzInitializer est une classe RAII appelant Initialize dans son constructeur et Uninitialize dans son destructeur. // Autrement dit, une fois ceci fait nous n'avons plus à nous soucier de la libération du moteur. @@ -101,7 +101,7 @@ int main() // Le format OBJ ne précise aucune échelle pour ses données, contrairement à Nazara (une unité = un mètre en 3D). // Comme le vaisseau est très grand (Des centaines de mètres de long), nous allons le rendre plus petit pour les besoins de la démo. // Ce paramètre sert à indiquer la mise à l'échelle désirée lors du chargement du modèle. - params.mesh.scale.Set(0.01f); // Un centième de la taille originelle + params.mesh.matrix.MakeScale(Nz::Vector3f(0.01f)); // Un centième de la taille originelle // Les UVs de ce fichier sont retournées (repère OpenGL, origine coin bas-gauche) par rapport à ce que le moteur attend (haut-gauche) // Nous devons donc indiquer au moteur de les retourner lors du chargement @@ -156,7 +156,7 @@ int main() // Nous devons donc lui rajouter les composants que nous voulons. // Un NodeComponent donne à notre entité une position, rotation, échelle, et nous permet de l'attacher à d'autres entités (ce que nous ne ferons pas ici). - // Étant donné que par défaut, un NodeComponent se place en (0,0,0) sans rotation et avec une échelle de 1,1,1 et que cela nous convient, + // Étant donné que par défaut, un NodeComponent se place en (0,0,0) sans rotation et avec une échelle de 1,1,1 et que cela nous convient, // nous n'avons pas besoin d'agir sur le composant créé. spaceship->AddComponent(); From 81245a9c4305103697c3cc937a045a851430a700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 18 Jun 2016 07:52:33 +0200 Subject: [PATCH 107/383] Noise: Refresh module using ZNoise https://github.com/Overdrivr/ZNoise Former-commit-id: 3f7be1c8fd14e074826ca667676412ea4989621c [formerly 882d0bdad12c264766dc00869ac07bbecbee7306] Former-commit-id: b12a4654bb5b9ff3fdd474704d66aa10fd2d756d --- include/Nazara/Noise/Abstract2DNoise.hpp | 26 - include/Nazara/Noise/Abstract3DNoise.hpp | 26 - include/Nazara/Noise/Abstract4DNoise.hpp | 26 - include/Nazara/Noise/ComplexNoiseBase.hpp | 41 -- include/Nazara/Noise/Config.hpp | 2 +- include/Nazara/Noise/ConfigCheck.hpp | 2 +- include/Nazara/Noise/Debug.hpp | 2 +- include/Nazara/Noise/DebugOff.hpp | 2 +- include/Nazara/Noise/Enums.hpp | 18 + include/Nazara/Noise/FBM.hpp | 30 ++ include/Nazara/Noise/FBM2D.hpp | 31 -- include/Nazara/Noise/FBM3D.hpp | 32 -- include/Nazara/Noise/FBM4D.hpp | 32 -- include/Nazara/Noise/HybridMultiFractal.hpp | 34 ++ include/Nazara/Noise/HybridMultiFractal2D.hpp | 36 -- include/Nazara/Noise/HybridMultiFractal3D.hpp | 36 -- include/Nazara/Noise/HybridMultiFractal4D.hpp | 36 -- include/Nazara/Noise/MappedNoiseBase.hpp | 35 -- include/Nazara/Noise/MixerBase.hpp | 38 ++ include/Nazara/Noise/Noise.hpp | 2 +- include/Nazara/Noise/NoiseBase.hpp | 36 +- include/Nazara/Noise/NoiseTools.hpp | 14 + include/Nazara/Noise/Perlin.hpp | 36 ++ include/Nazara/Noise/Perlin2D.hpp | 39 -- include/Nazara/Noise/Perlin3D.hpp | 40 -- include/Nazara/Noise/Perlin4D.hpp | 39 -- include/Nazara/Noise/Simplex.hpp | 43 ++ include/Nazara/Noise/Simplex2D.hpp | 42 -- include/Nazara/Noise/Simplex3D.hpp | 42 -- include/Nazara/Noise/Simplex4D.hpp | 44 -- include/Nazara/Noise/Worley.hpp | 41 ++ src/Nazara/Noise/Abstract2DNoise.cpp | 24 - src/Nazara/Noise/Abstract3DNoise.cpp | 24 - src/Nazara/Noise/Abstract4DNoise.cpp | 24 - src/Nazara/Noise/ComplexNoiseBase.cpp | 83 ---- src/Nazara/Noise/FBM.cpp | 31 ++ src/Nazara/Noise/FBM2D.cpp | 54 --- src/Nazara/Noise/FBM3D.cpp | 54 --- src/Nazara/Noise/FBM4D.cpp | 54 --- src/Nazara/Noise/HybridMultiFractal.cpp | 42 ++ src/Nazara/Noise/HybridMultiFractal3D.cpp | 67 --- src/Nazara/Noise/HybridMultiFractal4D.cpp | 67 --- src/Nazara/Noise/HybridMultifractal2D.cpp | 67 --- src/Nazara/Noise/MappedNoiseBase.cpp | 56 --- src/Nazara/Noise/MixerBase.cpp | 56 +++ src/Nazara/Noise/NoiseBase.cpp | 68 +-- src/Nazara/Noise/NoiseTools.cpp | 28 ++ src/Nazara/Noise/Perlin.cpp | 325 +++++++++++++ src/Nazara/Noise/Perlin2D.cpp | 75 --- src/Nazara/Noise/Perlin3D.cpp | 98 ---- src/Nazara/Noise/Perlin4D.cpp | 156 ------ src/Nazara/Noise/Simplex.cpp | 459 ++++++++++++++++++ src/Nazara/Noise/Simplex2D.cpp | 94 ---- src/Nazara/Noise/Simplex3D.cpp | 176 ------- src/Nazara/Noise/Simplex4D.cpp | 169 ------- src/Nazara/Noise/Worley.cpp | 171 +++++++ 56 files changed, 1408 insertions(+), 2017 deletions(-) delete mode 100644 include/Nazara/Noise/Abstract2DNoise.hpp delete mode 100644 include/Nazara/Noise/Abstract3DNoise.hpp delete mode 100644 include/Nazara/Noise/Abstract4DNoise.hpp delete mode 100644 include/Nazara/Noise/ComplexNoiseBase.hpp create mode 100644 include/Nazara/Noise/Enums.hpp create mode 100644 include/Nazara/Noise/FBM.hpp delete mode 100644 include/Nazara/Noise/FBM2D.hpp delete mode 100644 include/Nazara/Noise/FBM3D.hpp delete mode 100644 include/Nazara/Noise/FBM4D.hpp create mode 100644 include/Nazara/Noise/HybridMultiFractal.hpp delete mode 100644 include/Nazara/Noise/HybridMultiFractal2D.hpp delete mode 100644 include/Nazara/Noise/HybridMultiFractal3D.hpp delete mode 100644 include/Nazara/Noise/HybridMultiFractal4D.hpp delete mode 100644 include/Nazara/Noise/MappedNoiseBase.hpp create mode 100644 include/Nazara/Noise/MixerBase.hpp create mode 100644 include/Nazara/Noise/NoiseTools.hpp create mode 100644 include/Nazara/Noise/Perlin.hpp delete mode 100644 include/Nazara/Noise/Perlin2D.hpp delete mode 100644 include/Nazara/Noise/Perlin3D.hpp delete mode 100644 include/Nazara/Noise/Perlin4D.hpp create mode 100644 include/Nazara/Noise/Simplex.hpp delete mode 100644 include/Nazara/Noise/Simplex2D.hpp delete mode 100644 include/Nazara/Noise/Simplex3D.hpp delete mode 100644 include/Nazara/Noise/Simplex4D.hpp create mode 100644 include/Nazara/Noise/Worley.hpp delete mode 100644 src/Nazara/Noise/Abstract2DNoise.cpp delete mode 100644 src/Nazara/Noise/Abstract3DNoise.cpp delete mode 100644 src/Nazara/Noise/Abstract4DNoise.cpp delete mode 100644 src/Nazara/Noise/ComplexNoiseBase.cpp create mode 100644 src/Nazara/Noise/FBM.cpp delete mode 100644 src/Nazara/Noise/FBM2D.cpp delete mode 100644 src/Nazara/Noise/FBM3D.cpp delete mode 100644 src/Nazara/Noise/FBM4D.cpp create mode 100644 src/Nazara/Noise/HybridMultiFractal.cpp delete mode 100644 src/Nazara/Noise/HybridMultiFractal3D.cpp delete mode 100644 src/Nazara/Noise/HybridMultiFractal4D.cpp delete mode 100644 src/Nazara/Noise/HybridMultifractal2D.cpp delete mode 100644 src/Nazara/Noise/MappedNoiseBase.cpp create mode 100644 src/Nazara/Noise/MixerBase.cpp create mode 100644 src/Nazara/Noise/NoiseTools.cpp create mode 100644 src/Nazara/Noise/Perlin.cpp delete mode 100644 src/Nazara/Noise/Perlin2D.cpp delete mode 100644 src/Nazara/Noise/Perlin3D.cpp delete mode 100644 src/Nazara/Noise/Perlin4D.cpp create mode 100644 src/Nazara/Noise/Simplex.cpp delete mode 100644 src/Nazara/Noise/Simplex2D.cpp delete mode 100644 src/Nazara/Noise/Simplex3D.cpp delete mode 100644 src/Nazara/Noise/Simplex4D.cpp create mode 100644 src/Nazara/Noise/Worley.cpp diff --git a/include/Nazara/Noise/Abstract2DNoise.hpp b/include/Nazara/Noise/Abstract2DNoise.hpp deleted file mode 100644 index 0eb5c23e5..000000000 --- a/include/Nazara/Noise/Abstract2DNoise.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ABSTRACT2DNOISE_HPP -#define NAZARA_ABSTRACT2DNOISE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Abstract2DNoise : public MappedNoiseBase - { - public: - virtual ~Abstract2DNoise(); - - float GetBasicValue(float x, float y); - float GetMappedValue(float x, float y); - virtual float GetValue(float x, float y, float resolution) = 0; - }; -} - -#endif // NAZARA_ABSTRACT2DNOISE_HPP diff --git a/include/Nazara/Noise/Abstract3DNoise.hpp b/include/Nazara/Noise/Abstract3DNoise.hpp deleted file mode 100644 index 19a0c765c..000000000 --- a/include/Nazara/Noise/Abstract3DNoise.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ABSTRACT3DNOISE_HPP -#define NAZARA_ABSTRACT3DNOISE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Abstract3DNoise : public MappedNoiseBase - { - public: - virtual ~Abstract3DNoise(); - - float GetBasicValue(float x, float y, float z); - float GetMappedValue(float x, float y, float z); - virtual float GetValue(float x, float y, float z, float resolution) = 0; - }; -} - -#endif // NAZARA_ABSTRACT3DNOISE_HPP diff --git a/include/Nazara/Noise/Abstract4DNoise.hpp b/include/Nazara/Noise/Abstract4DNoise.hpp deleted file mode 100644 index 631228020..000000000 --- a/include/Nazara/Noise/Abstract4DNoise.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ABSTRACT4DNOISE_HPP -#define NAZARA_ABSTRACT4DNOISE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Abstract4DNoise : public MappedNoiseBase - { - public: - virtual ~Abstract4DNoise(); - - float GetBasicValue(float x, float y, float z, float w); - float GetMappedValue(float x, float y, float z, float w); - virtual float GetValue(float x, float y, float z, float w, float resolution) = 0; - }; -} - -#endif // NAZARA_ABSTRACT4DNOISE_HPP diff --git a/include/Nazara/Noise/ComplexNoiseBase.hpp b/include/Nazara/Noise/ComplexNoiseBase.hpp deleted file mode 100644 index 6be8667a5..000000000 --- a/include/Nazara/Noise/ComplexNoiseBase.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef COMPLEXNOISEBASE_HPP -#define COMPLEXNOISEBASE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API ComplexNoiseBase - { - public: - ComplexNoiseBase(); - ~ComplexNoiseBase() = default; - - float GetHurstParameter() const; - float GetLacunarity() const; - float GetOctaveNumber() const; - void SetHurstParameter(float h); - void SetLacunarity(float lacunarity); - void SetOctavesNumber(float octaves); - void RecomputeExponentArray(); - - protected: - float m_lacunarity; - float m_hurst; - float m_octaves; - std::array m_exponent_array; - float m_sum; - - private: - bool m_parametersModified; - }; -} - -#endif // COMPLEXNOISEBASE_HPP diff --git a/include/Nazara/Noise/Config.hpp b/include/Nazara/Noise/Config.hpp index 5df2d6dc4..afe6d577e 100644 --- a/include/Nazara/Noise/Config.hpp +++ b/include/Nazara/Noise/Config.hpp @@ -1,7 +1,7 @@ /* Nazara Engine - Noise module - Copyright (C) 2015 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) + Copyright (C) 2016 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/include/Nazara/Noise/ConfigCheck.hpp b/include/Nazara/Noise/ConfigCheck.hpp index f7682bd28..9c6df7851 100644 --- a/include/Nazara/Noise/ConfigCheck.hpp +++ b/include/Nazara/Noise/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Debug.hpp b/include/Nazara/Noise/Debug.hpp index 377ae7b1c..4696c79b9 100644 --- a/include/Nazara/Noise/Debug.hpp +++ b/include/Nazara/Noise/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/DebugOff.hpp b/include/Nazara/Noise/DebugOff.hpp index 75903b6cc..4b368b6ea 100644 --- a/include/Nazara/Noise/DebugOff.hpp +++ b/include/Nazara/Noise/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/Enums.hpp b/include/Nazara/Noise/Enums.hpp new file mode 100644 index 000000000..7962d8415 --- /dev/null +++ b/include/Nazara/Noise/Enums.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_ENUMS_NOISE_HPP +#define NAZARA_ENUMS_NOISE_HPP + +namespace Nz +{ + enum WorleyFunction + { + WorleyFunction_F1 = 0, + WorleyFunction_F2 = 1, + WorleyFunction_F3 = 2, + WorleyFunction_F4 = 3 + }; +} +#endif // NAZARA_ENUMS_NOISE_HPP diff --git a/include/Nazara/Noise/FBM.hpp b/include/Nazara/Noise/FBM.hpp new file mode 100644 index 000000000..ded4aa069 --- /dev/null +++ b/include/Nazara/Noise/FBM.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_FBM_HPP +#define NAZARA_FBM_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API FBM : public MixerBase + { + public: + FBM(const NoiseBase& source); + FBM(const FBM&) = delete; + ~FBM() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + FBM& operator=(const FBM&) = delete; + + private: + const NoiseBase& m_source; + }; +} + +#endif // NAZARA_FBM_HPP diff --git a/include/Nazara/Noise/FBM2D.hpp b/include/Nazara/Noise/FBM2D.hpp deleted file mode 100644 index 9b456de0a..000000000 --- a/include/Nazara/Noise/FBM2D.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef FBM2D_HPP -#define FBM2D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API FBM2D : public Abstract2DNoise, public ComplexNoiseBase - { - public: - FBM2D(NoiseType source, unsigned int seed); - float GetValue(float x, float y, float resolution); - ~FBM2D(); - - private: - Abstract2DNoise* m_source; - float m_value; - float m_remainder; - NoiseType m_noiseType; - }; -} - -#endif // FBM2D_HPP diff --git a/include/Nazara/Noise/FBM3D.hpp b/include/Nazara/Noise/FBM3D.hpp deleted file mode 100644 index 722ad843d..000000000 --- a/include/Nazara/Noise/FBM3D.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef FBM3D_HPP -#define FBM3D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API FBM3D : public Abstract3DNoise, public ComplexNoiseBase - { - public: - FBM3D(NoiseType source, unsigned int seed); - float GetValue(float x, float y, float z, float resolution); - ~FBM3D(); - - private: - Abstract3DNoise* m_source; - float m_value; - float m_remainder; - NoiseType m_noiseType; - }; -} - -#endif // FBM3D_HPP - diff --git a/include/Nazara/Noise/FBM4D.hpp b/include/Nazara/Noise/FBM4D.hpp deleted file mode 100644 index e18c93111..000000000 --- a/include/Nazara/Noise/FBM4D.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef FBM4D_HPP -#define FBM4D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API FBM4D : public Abstract4DNoise, public ComplexNoiseBase - { - public: - FBM4D(NoiseType source, unsigned int seed); - float GetValue(float x, float y, float z, float w, float resolution); - ~FBM4D(); - - private: - Abstract4DNoise* m_source; - float m_value; - float m_remainder; - NoiseType m_noiseType; - }; -} - -#endif // FBM4D_HPP - diff --git a/include/Nazara/Noise/HybridMultiFractal.hpp b/include/Nazara/Noise/HybridMultiFractal.hpp new file mode 100644 index 000000000..a211a4767 --- /dev/null +++ b/include/Nazara/Noise/HybridMultiFractal.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_HYBRIDMULTIFRACTAL_HPP +#define NAZARA_HYBRIDMULTIFRACTAL_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API HybridMultiFractal : public MixerBase + { + public: + HybridMultiFractal(const NoiseBase & source); + HybridMultiFractal(const HybridMultiFractal&) = delete; + ~HybridMultiFractal() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + HybridMultiFractal& operator=(const HybridMultiFractal&) = delete; + + private: + const NoiseBase& m_source; + float m_value; + float m_remainder; + float m_offset; + float m_weight; + float m_signal; + }; +} + +#endif // NAZARA_HYBRIDMULTIFRACTAL_HPP diff --git a/include/Nazara/Noise/HybridMultiFractal2D.hpp b/include/Nazara/Noise/HybridMultiFractal2D.hpp deleted file mode 100644 index 4b0ad9bc6..000000000 --- a/include/Nazara/Noise/HybridMultiFractal2D.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef HYBRIDMULTIFRACTAL2D_HPP -#define HYBRIDMULTIFRACTAL2D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API HybridMultiFractal2D : public Abstract2DNoise, public ComplexNoiseBase - { - public: - HybridMultiFractal2D(NoiseType source, unsigned int seed); - ~HybridMultiFractal2D(); - - float GetValue(float x, float y, float resolution); - - private: - Abstract2DNoise* m_source; - float m_value; - float m_remainder; - float m_offset; - float m_weight; - float m_signal; - NoiseType m_noiseType; - }; -} - -#endif // HYBRIDMULTIFRACTAL2D_HPP - diff --git a/include/Nazara/Noise/HybridMultiFractal3D.hpp b/include/Nazara/Noise/HybridMultiFractal3D.hpp deleted file mode 100644 index 34d554292..000000000 --- a/include/Nazara/Noise/HybridMultiFractal3D.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef HYBRIDMULTIFRACTAL3D_HPP -#define HYBRIDMULTIFRACTAL3D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API HybridMultiFractal3D : public Abstract3DNoise, public ComplexNoiseBase - { - public: - HybridMultiFractal3D(NoiseType source, unsigned int seed); - ~HybridMultiFractal3D(); - - float GetValue(float x, float y, float z, float resolution); - - private: - Abstract3DNoise* m_source; - float m_value; - float m_remainder; - float m_offset; - float m_weight; - float m_signal; - NoiseType m_noiseType; - }; -} - -#endif // HYBRIDMULTIFRACTAL3D_HPP - diff --git a/include/Nazara/Noise/HybridMultiFractal4D.hpp b/include/Nazara/Noise/HybridMultiFractal4D.hpp deleted file mode 100644 index 859ed8087..000000000 --- a/include/Nazara/Noise/HybridMultiFractal4D.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef HYBRIDMULTIFRACTAL4D_HPP -#define HYBRIDMULTIFRACTAL4D_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API HybridMultiFractal4D : public Abstract4DNoise, public ComplexNoiseBase - { - public: - HybridMultiFractal4D(NoiseType source, unsigned int seed); - ~HybridMultiFractal4D(); - - float GetValue(float x, float y, float z, float w, float resolution); - - private: - Abstract4DNoise* m_source; - float m_value; - float m_remainder; - float m_offset; - float m_weight; - float m_signal; - NoiseType m_noiseType; - }; -} - -#endif // HYBRIDMULTIFRACTAL4D_HPP - diff --git a/include/Nazara/Noise/MappedNoiseBase.hpp b/include/Nazara/Noise/MappedNoiseBase.hpp deleted file mode 100644 index 7e5106a31..000000000 --- a/include/Nazara/Noise/MappedNoiseBase.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_MAPPEDNOISEBASE_HPP -#define NAZARA_MAPPEDNOISEBASE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API MappedNoiseBase : public NoiseBase - { - public: - MappedNoiseBase(); - ~MappedNoiseBase() = default; - - float GetGain() const; - float GetOffset() const; - float GetResolution() const; - void SetGain(float gain); - void SetOffset(float offset); - void SetResolution(float resolution); - - protected: - float m_gain; - float m_offset; - float m_resolution; - }; -} - -#endif // NAZARA_MAPPEDNOISEBASE_HPP diff --git a/include/Nazara/Noise/MixerBase.hpp b/include/Nazara/Noise/MixerBase.hpp new file mode 100644 index 000000000..3c7a131b0 --- /dev/null +++ b/include/Nazara/Noise/MixerBase.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_MIXERBASE_HPP +#define NAZARA_MIXERBASE_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API MixerBase + { + public: + MixerBase(); + ~MixerBase() = default; + + float GetHurstParameter() const; + float GetLacunarity() const; + float GetOctaveNumber() const; + + void SetParameters(float hurst, float lacunarity, float octaves); + + protected: + float m_hurst; + float m_lacunarity; + float m_octaves; + std::vector m_exponent_array; + float m_sum; + + private: + void Recompute(); + }; +} + +#endif // NAZARA_MIXERBASE_HPP diff --git a/include/Nazara/Noise/Noise.hpp b/include/Nazara/Noise/Noise.hpp index a1e5b7d11..c1ec5b1da 100644 --- a/include/Nazara/Noise/Noise.hpp +++ b/include/Nazara/Noise/Noise.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp index bd268ee8c..6a5c5c37f 100644 --- a/include/Nazara/Noise/NoiseBase.hpp +++ b/include/Nazara/Noise/NoiseBase.hpp @@ -1,48 +1,38 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp -#pragma once - -#ifndef NOISEBASE_HPP -#define NOISEBASE_HPP +#ifndef NAZARA_NOISEBASE_HPP +#define NAZARA_NOISEBASE_HPP #include #include +#include namespace Nz { - enum NoiseType - { - PERLIN, - SIMPLEX, - CELL - }; - class NAZARA_NOISE_API NoiseBase { public: NoiseBase(unsigned int seed = 0); ~NoiseBase() = default; - void SetNewSeed(unsigned int seed); + virtual float Get(std::initializer_list coordinates, float scale) const = 0; + float GetScale(); - void ShufflePermutationTable(); + void SetScale(float scale); + void SetSeed(unsigned int seed); - unsigned int GetUniformRandomValue(); - - int fastfloor(float n); - int JenkinsHash(int a, int b, int c); + void Shuffle(); + void Shuffle(unsigned int amount); protected: unsigned int perm[512]; + float m_scale; private: - unsigned int Ua, Uc, Um; - unsigned int UcurrentSeed; - unsigned int Uprevious, Ulast; - + std::default_random_engine generator; }; } -#endif // NOISEBASE_HPP +#endif // NAZARA_NOISEBASE_HPP diff --git a/include/Nazara/Noise/NoiseTools.hpp b/include/Nazara/Noise/NoiseTools.hpp new file mode 100644 index 000000000..6238caec3 --- /dev/null +++ b/include/Nazara/Noise/NoiseTools.hpp @@ -0,0 +1,14 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_NOISETOOLS_HPP +#define NAZARA_NOISETOOLS_HPP + +namespace Nz +{ + int fastfloor(float n); + int JenkinsHash(int a, int b, int c); +} + +#endif // NAZARA_NOISETOOLS_HPP diff --git a/include/Nazara/Noise/Perlin.hpp b/include/Nazara/Noise/Perlin.hpp new file mode 100644 index 000000000..058a3ada5 --- /dev/null +++ b/include/Nazara/Noise/Perlin.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_PERLIN_HPP +#define NAZARA_PERLIN_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API Perlin : public NoiseBase + { + public: + Perlin(); + Perlin(unsigned int seed); + ~Perlin() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + protected: + float _2D(std::initializer_list coordinates, float scale) const; + float _3D(std::initializer_list coordinates, float scale) const; + float _4D(std::initializer_list coordinates, float scale) const; + + private: + const float gradient2[8][2]; + const float gradient3[16][3]; + const float gradient4[32][4]; + }; +} + +#endif // NAZARA_PERLIN_HPP diff --git a/include/Nazara/Noise/Perlin2D.hpp b/include/Nazara/Noise/Perlin2D.hpp deleted file mode 100644 index 88a98155b..000000000 --- a/include/Nazara/Noise/Perlin2D.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef PERLIN2D_HPP -#define PERLIN2D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Perlin2D : public Abstract2DNoise - { - public: - Perlin2D(); - Perlin2D(unsigned int seed); - ~Perlin2D() = default; - - float GetValue(float x, float y, float resolution); - - private: - int x0, y0; - int gi0,gi1,gi2,gi3; - int ii, jj; - float gradient2[8][2]; - float s,t,u,v; - float Cx,Cy; - float Li1, Li2; - Vector2 temp; - }; -} - -#endif // PERLIN2D_HPP - diff --git a/include/Nazara/Noise/Perlin3D.hpp b/include/Nazara/Noise/Perlin3D.hpp deleted file mode 100644 index 47be7f29b..000000000 --- a/include/Nazara/Noise/Perlin3D.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef PERLIN3D_HPP -#define PERLIN3D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Perlin3D : public Abstract3DNoise - { - public: - Perlin3D(); - Perlin3D(unsigned int seed); - ~Perlin3D() = default; - - float GetValue(float x, float y, float z, float resolution); - - private: - int x0,y0,z0; - int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; - int ii,jj,kk; - float gradient3[16][3]; - float Li1,Li2,Li3,Li4,Li5,Li6; - float s[2],t[2],u[2],v[2]; - float Cx,Cy,Cz; - float nx,ny,nz; - float tmp; - Vector3 temp; - }; -} - -#endif // PERLIN3D_HPP diff --git a/include/Nazara/Noise/Perlin4D.hpp b/include/Nazara/Noise/Perlin4D.hpp deleted file mode 100644 index 66d7a1b7b..000000000 --- a/include/Nazara/Noise/Perlin4D.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef PERLIN4D_HPP -#define PERLIN4D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Perlin4D : public Abstract4DNoise - { - public: - Perlin4D(); - Perlin4D(unsigned int seed); - ~Perlin4D() = default; - - float GetValue(float x, float y, float z, float w, float resolution); - - private: - int x0,y0,z0,w0; - int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; - int ii,jj,kk,ll; - float gradient4[32][4]; - float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; - float s[4],t[4],u[4],v[4]; - float Cx,Cy,Cz,Cw; - float tmp; - Vector4 temp; - }; -} - -#endif // PERLIN4D_HPP diff --git a/include/Nazara/Noise/Simplex.hpp b/include/Nazara/Noise/Simplex.hpp new file mode 100644 index 000000000..f131387b6 --- /dev/null +++ b/include/Nazara/Noise/Simplex.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef SIMPLEX_HPP +#define SIMPLE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API Simplex : public NoiseBase + { + public: + Simplex(); + Simplex(unsigned int seed); + ~Simplex() = default; + + float Get(std::initializer_list coordinates, float scale) const; + + protected: + float _2D(std::initializer_list coordinates, float scale) const; + float _3D(std::initializer_list coordinates, float scale) const; + float _4D(std::initializer_list coordinates, float scale) const; + + private: + const float gradient2[8][2]; + const float gradient3[16][3]; + const float gradient4[32][4]; + const float UnskewCoeff2D; + const float SkewCoeff2D; + const float UnskewCoeff3D; + const float SkewCoeff3D; + const float UnskewCoeff4D; + const float SkewCoeff4D; + const int lookupTable4D[64][4]; + }; +} + +#endif // SIMPLEX_HPP diff --git a/include/Nazara/Noise/Simplex2D.hpp b/include/Nazara/Noise/Simplex2D.hpp deleted file mode 100644 index 69a73478d..000000000 --- a/include/Nazara/Noise/Simplex2D.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef SIMPLEX2D_HPP -#define SIMPLEX2D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Simplex2D : public Abstract2DNoise - { - public: - Simplex2D(); - Simplex2D(unsigned int seed); - virtual ~Simplex2D() = default; - - float GetValue(float x, float y, float resolution); - - private: - int ii,jj; - int gi0,gi1,gi2; - Vector2i skewedCubeOrigin,off1; - float n1,n2,n3; - float c1,c2,c3; - float gradient2[8][2]; - float UnskewCoeff2D; - float SkewCoeff2D; - float sum; - Vector2 unskewedCubeOrigin, unskewedDistToOrigin; - Vector2 d1,d2,d3; - }; -} - -#endif // SIMPLEX2D_HPP - diff --git a/include/Nazara/Noise/Simplex3D.hpp b/include/Nazara/Noise/Simplex3D.hpp deleted file mode 100644 index ecfc4c2a4..000000000 --- a/include/Nazara/Noise/Simplex3D.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef SIMPLEX3D_HPP -#define SIMPLEX3D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Simplex3D : public Abstract3DNoise - { - public: - Simplex3D(); - Simplex3D(unsigned int seed); - ~Simplex3D() = default; - - float GetValue(float x, float y, float z, float resolution); - - private: - int ii,jj,kk; - int gi0,gi1,gi2,gi3; - Vector3i skewedCubeOrigin,off1,off2; - float n1,n2,n3,n4; - float c1,c2,c3,c4; - float gradient3[12][3]; - float UnskewCoeff3D; - float SkewCoeff3D; - float sum; - Vector3 unskewedCubeOrigin, unskewedDistToOrigin; - Vector3 d1,d2,d3,d4; - }; -} - -#endif // SIMPLEX3D_HPP - diff --git a/include/Nazara/Noise/Simplex4D.hpp b/include/Nazara/Noise/Simplex4D.hpp deleted file mode 100644 index 545c5f290..000000000 --- a/include/Nazara/Noise/Simplex4D.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef SIMPLEX4D_HPP -#define SIMPLEX4D_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_NOISE_API Simplex4D : public Abstract4DNoise - { - public: - Simplex4D(); - Simplex4D(unsigned int seed); - ~Simplex4D() = default; - - float GetValue(float x, float y, float z, float w, float resolution); - - private: - int ii,jj,kk,ll; - int gi0,gi1,gi2,gi3,gi4; - Vector4i skewedCubeOrigin,off1,off2,off3; - int lookupTable4D[64][4]; - int c; - float n1,n2,n3,n4,n5; - float c1,c2,c3,c4,c5,c6; - float gradient4[32][4]; - float UnskewCoeff4D; - float SkewCoeff4D; - float sum; - Vector4 unskewedCubeOrigin, unskewedDistToOrigin; - Vector4 d1,d2,d3,d4,d5; - }; -} - -#endif // SIMPLEX4D_H - diff --git a/include/Nazara/Noise/Worley.hpp b/include/Nazara/Noise/Worley.hpp new file mode 100644 index 000000000..249da999f --- /dev/null +++ b/include/Nazara/Noise/Worley.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#ifndef NAZARA_WORLEY_HPP +#define NAZARA_WORLEY_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_NOISE_API Worley : public NoiseBase + { + public: + Worley(); + Worley(unsigned int seed); + ~Worley() = default; + + void Set(WorleyFunction func); + + float Get(std::initializer_list coordinates, float scale) const; + + protected: + float _2D(std::initializer_list coordinates, float scale) const; + float _3D(std::initializer_list coordinates, float scale) const; + float _4D(std::initializer_list coordinates, float scale) const; + void _SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const; + + private: + const float scales[4]; + WorleyFunction function; + }; +} + +#endif // NAZARA_WORLEY_HPP diff --git a/src/Nazara/Noise/Abstract2DNoise.cpp b/src/Nazara/Noise/Abstract2DNoise.cpp deleted file mode 100644 index 51cfeddcc..000000000 --- a/src/Nazara/Noise/Abstract2DNoise.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - Abstract2DNoise::~Abstract2DNoise() = default; - - float Abstract2DNoise::GetBasicValue(float x, float y) - { - return this->GetValue(x,y,m_resolution); - } - - float Abstract2DNoise::GetMappedValue(float x, float y) - { - return (this->GetValue(x,y,m_resolution) + m_offset) * m_gain; - } -} diff --git a/src/Nazara/Noise/Abstract3DNoise.cpp b/src/Nazara/Noise/Abstract3DNoise.cpp deleted file mode 100644 index 6456babec..000000000 --- a/src/Nazara/Noise/Abstract3DNoise.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - Abstract3DNoise::~Abstract3DNoise() = default; - - float Abstract3DNoise::GetBasicValue(float x, float y, float z) - { - return this->GetValue(x,y,z,m_resolution); - } - - float Abstract3DNoise::GetMappedValue(float x, float y, float z) - { - return (this->GetValue(x,y,z,m_resolution) + m_offset) * m_gain ; - } -} diff --git a/src/Nazara/Noise/Abstract4DNoise.cpp b/src/Nazara/Noise/Abstract4DNoise.cpp deleted file mode 100644 index 44bde3b0f..000000000 --- a/src/Nazara/Noise/Abstract4DNoise.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - Abstract4DNoise::~Abstract4DNoise() = default; - - float Abstract4DNoise::GetBasicValue(float x, float y, float z, float w) - { - return this->GetValue(x,y,z,w,m_resolution); - } - - float Abstract4DNoise::GetMappedValue(float x, float y, float z, float w) - { - return (this->GetValue(x,y,z,w,m_resolution) + m_offset) * m_gain ; - } -} diff --git a/src/Nazara/Noise/ComplexNoiseBase.cpp b/src/Nazara/Noise/ComplexNoiseBase.cpp deleted file mode 100644 index c62ad8a8f..000000000 --- a/src/Nazara/Noise/ComplexNoiseBase.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - ComplexNoiseBase::ComplexNoiseBase() - { - m_parametersModified = true; - m_lacunarity = 5.0f; - m_hurst = 1.2f; - m_octaves = 3.0f; - - for (int i(0) ; i < m_octaves; ++i) - { - m_exponent_array[i] = 0; - } - } - - float ComplexNoiseBase::GetLacunarity() const - { - - return m_lacunarity; - } - - float ComplexNoiseBase::GetHurstParameter() const - { - return m_hurst; - } - - float ComplexNoiseBase::GetOctaveNumber() const - { - return m_octaves; - } - - void ComplexNoiseBase::SetLacunarity(float lacunarity) - { - m_lacunarity = lacunarity; - m_parametersModified = true; - - } - - void ComplexNoiseBase::SetHurstParameter(float h) - { - m_hurst = h; - m_parametersModified = true; - } - - void ComplexNoiseBase::SetOctavesNumber(float octaves) - { - if(octaves <= 30.0f) - m_octaves = octaves; - else - m_octaves = 30.0f; - - m_parametersModified = true; - } - - void ComplexNoiseBase::RecomputeExponentArray() - { - if(m_parametersModified) - { - float frequency = 1.0; - m_sum = 0.f; - for (int i(0) ; i < static_cast(m_octaves) ; ++i) - { - - m_exponent_array[i] = std::pow( frequency, -m_hurst ); - frequency *= m_lacunarity; - - m_sum += m_exponent_array[i]; - - } - m_parametersModified = false; - } - } -} diff --git a/src/Nazara/Noise/FBM.cpp b/src/Nazara/Noise/FBM.cpp new file mode 100644 index 000000000..f61bf8f44 --- /dev/null +++ b/src/Nazara/Noise/FBM.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + FBM::FBM(const NoiseBase & source): m_source(source) + { + } + + float FBM::Get(std::initializer_list coordinates, float scale) const + { + float value = 0.0; + + for(int i(0); i < m_octaves; ++i) + { + value += m_source.Get(coordinates,scale) * m_exponent_array.at(i); + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if(std::fabs(remainder) > 0.01f) + value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum; + } +} diff --git a/src/Nazara/Noise/FBM2D.cpp b/src/Nazara/Noise/FBM2D.cpp deleted file mode 100644 index 5a4670b80..000000000 --- a/src/Nazara/Noise/FBM2D.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - FBM2D::FBM2D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin2D(); - break; - - default: - m_source = new Simplex2D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float FBM2D::GetValue(float x, float y, float resolution) - { - this->RecomputeExponentArray(); - - m_value = 0.0; - - for (int i(0); i < m_octaves; ++i) - { - m_value += m_source->GetValue(x,y,resolution) * m_exponent_array[i]; - resolution *= m_lacunarity; - } - m_remainder = m_octaves - static_cast(m_octaves); - - if(!NumberEquals(m_remainder, static_cast(0.0))) - m_value += m_remainder * m_source->GetValue(x,y,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum; - } - - FBM2D::~FBM2D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/FBM3D.cpp b/src/Nazara/Noise/FBM3D.cpp deleted file mode 100644 index f0ee6143e..000000000 --- a/src/Nazara/Noise/FBM3D.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - FBM3D::FBM3D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin3D(); - break; - - default: - m_source = new Simplex3D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float FBM3D::GetValue(float x, float y, float z, float resolution) - { - this->RecomputeExponentArray(); - - m_value = 0.0; - - for (int i(0); i < m_octaves; ++i) - { - m_value += m_source->GetValue(x,y,z,resolution) * m_exponent_array[i]; - resolution *= m_lacunarity; - } - m_remainder = m_octaves - static_cast(m_octaves); - - if(!NumberEquals(m_remainder, static_cast(0.0))) - m_value += m_remainder * m_source->GetValue(x,y,z,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum; - } - - FBM3D::~FBM3D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/FBM4D.cpp b/src/Nazara/Noise/FBM4D.cpp deleted file mode 100644 index dace704d7..000000000 --- a/src/Nazara/Noise/FBM4D.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - FBM4D::FBM4D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin4D(); - break; - - default: - m_source = new Simplex4D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float FBM4D::GetValue(float x, float y, float z, float w, float resolution) - { - this->RecomputeExponentArray(); - - m_value = 0.0; - - for (int i(0); i < m_octaves; ++i) - { - m_value += m_source->GetValue(x,y,z,w,resolution) * m_exponent_array[i]; - resolution *= m_lacunarity; - } - m_remainder = m_octaves - static_cast(m_octaves); - - if(!NumberEquals(m_remainder, static_cast(0.0))) - m_value += m_remainder * m_source->GetValue(x,y,z,w,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum; - } - - FBM4D::~FBM4D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/HybridMultiFractal.cpp b/src/Nazara/Noise/HybridMultiFractal.cpp new file mode 100644 index 000000000..3f20809d3 --- /dev/null +++ b/src/Nazara/Noise/HybridMultiFractal.cpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + HybridMultiFractal::HybridMultiFractal(const NoiseBase & source) : + m_source(source) + { + } + + float HybridMultiFractal::Get(std::initializer_list coordinates, float scale) const + { + float offset = 1.0f; + float value = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(0); + float weight = value; + float signal = 0.f; + + scale *= m_lacunarity; + + for(int i(1) ; i < m_octaves; ++i) + { + if (weight > 1.f) + weight = 1.f; + + signal = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(i); + value += weight * signal; + weight *= signal; + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if (remainder > 0.f) + value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum - offset; + } +} diff --git a/src/Nazara/Noise/HybridMultiFractal3D.cpp b/src/Nazara/Noise/HybridMultiFractal3D.cpp deleted file mode 100644 index e97ce3497..000000000 --- a/src/Nazara/Noise/HybridMultiFractal3D.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HybridMultiFractal3D::HybridMultiFractal3D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin3D(); - break; - - default: - m_source = new Simplex3D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float HybridMultiFractal3D::GetValue(float x, float y, float z, float resolution) - { - this->RecomputeExponentArray(); - - m_offset = 1.0f; - - m_value = (m_source->GetValue(x,y,z,resolution) + m_offset) * m_exponent_array[0]; - m_weight = m_value; - m_signal = 0.f; - - resolution *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (m_weight > 1.f) - m_weight = 1.f; - - m_signal = (m_source->GetValue(x,y,z,resolution) + m_offset) * m_exponent_array[i]; - m_value += m_weight * m_signal; - - m_weight *= m_signal; - - resolution *= m_lacunarity; - } - - m_remainder = m_octaves - static_cast(m_octaves); - if (m_remainder > 0.f) - m_value += m_remainder * m_source->GetValue(x,y,z,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum - m_offset; - } - - HybridMultiFractal3D::~HybridMultiFractal3D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/HybridMultiFractal4D.cpp b/src/Nazara/Noise/HybridMultiFractal4D.cpp deleted file mode 100644 index 06ddf87a1..000000000 --- a/src/Nazara/Noise/HybridMultiFractal4D.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HybridMultiFractal4D::HybridMultiFractal4D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin4D(); - break; - - default: - m_source = new Simplex4D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float HybridMultiFractal4D::GetValue(float x, float y, float z, float w, float resolution) - { - this->RecomputeExponentArray(); - - m_offset = 1.0f; - - m_value = (m_source->GetValue(x,y,z,w,resolution) + m_offset) * m_exponent_array[0]; - m_weight = m_value; - m_signal = 0.f; - - resolution *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (m_weight > 1.f) - m_weight = 1.f; - - m_signal = (m_source->GetValue(x,y,z,w,resolution) + m_offset) * m_exponent_array[i]; - m_value += m_weight * m_signal; - - m_weight *= m_signal; - - resolution *= m_lacunarity; - } - - m_remainder = m_octaves - static_cast(m_octaves); - if (m_remainder > 0.f) - m_value += m_remainder * m_source->GetValue(x,y,z,w,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum - m_offset; - } - - HybridMultiFractal4D::~HybridMultiFractal4D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/HybridMultifractal2D.cpp b/src/Nazara/Noise/HybridMultifractal2D.cpp deleted file mode 100644 index 007ff78d0..000000000 --- a/src/Nazara/Noise/HybridMultifractal2D.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HybridMultiFractal2D::HybridMultiFractal2D(NoiseType source, unsigned int seed) - { - switch(source) - { - case PERLIN: - m_source = new Perlin2D(); - break; - - default: - m_source = new Simplex2D(); - break; - } - m_source->SetNewSeed(seed); - m_source->ShufflePermutationTable(); - m_noiseType = source; - } - - float HybridMultiFractal2D::GetValue(float x, float y, float resolution) - { - this->RecomputeExponentArray(); - - m_offset = 1.0f; - - m_value = (m_source->GetValue(x,y,resolution) + m_offset) * m_exponent_array[0]; - m_weight = m_value; - m_signal = 0.f; - - resolution *= m_lacunarity; - - for(int i(1) ; i < m_octaves; ++i) - { - if (m_weight > 1.f) - m_weight = 1.f; - - m_signal = (m_source->GetValue(x,y,resolution) + m_offset) * m_exponent_array[i]; - m_value += m_weight * m_signal; - - m_weight *= m_signal; - - resolution *= m_lacunarity; - } - - m_remainder = m_octaves - static_cast(m_octaves); - if (m_remainder > 0.f) - m_value += m_remainder * m_source->GetValue(x,y,resolution) * m_exponent_array[static_cast(m_octaves-1)]; - - return m_value/this->m_sum - m_offset; - } - - HybridMultiFractal2D::~HybridMultiFractal2D() - { - delete m_source; - } -} diff --git a/src/Nazara/Noise/MappedNoiseBase.cpp b/src/Nazara/Noise/MappedNoiseBase.cpp deleted file mode 100644 index 77d8e0eb3..000000000 --- a/src/Nazara/Noise/MappedNoiseBase.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - MappedNoiseBase::MappedNoiseBase() : m_gain(1.f), m_offset(0.f), m_resolution(30.f) - { - - } - - float MappedNoiseBase::GetGain() const - { - return m_gain; - } - - float MappedNoiseBase::GetOffset() const - { - return m_offset; - } - - float MappedNoiseBase::GetResolution() const - { - return m_resolution; - } - - void MappedNoiseBase::SetGain(float gain) - { - m_gain = gain; - } - - void MappedNoiseBase::SetOffset(float offset) - { - m_offset = offset; - } - - void MappedNoiseBase::SetResolution(float resolution) - { - if (NumberEquals(resolution, 0.f)) - { - StringStream ss; - ss << __FILE__ << ':' << __LINE__ << " : resolution cannot be 0.0f"; - - throw std::domain_error(ss.ToString()); - } - m_resolution = resolution; - } -} diff --git a/src/Nazara/Noise/MixerBase.cpp b/src/Nazara/Noise/MixerBase.cpp new file mode 100644 index 000000000..d3dd82acc --- /dev/null +++ b/src/Nazara/Noise/MixerBase.cpp @@ -0,0 +1,56 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + MixerBase::MixerBase() : + m_hurst(1.2f), + m_lacunarity(5.f), + m_octaves(3.f) + { + Recompute(); + } + + float MixerBase::GetHurstParameter() const + { + return m_hurst; + } + + float MixerBase::GetLacunarity() const + { + return m_lacunarity; + } + + float MixerBase::GetOctaveNumber() const + { + return m_octaves; + } + + void MixerBase::SetParameters(float hurst, float lacunarity, float octaves) + { + m_hurst = hurst; + m_lacunarity = lacunarity; + m_octaves = octaves; + + Recompute(); + } + + void MixerBase::Recompute() + { + float frequency = 1.0; + m_sum = 0.f; + m_exponent_array.clear(); + + for (int i(0) ; i < static_cast(m_octaves) ; ++i) + { + m_exponent_array.push_back(std::pow( frequency, -m_hurst )); + frequency *= m_lacunarity; + m_sum += m_exponent_array.at(i); + } + } +} diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp index 550579227..0cbee9eec 100644 --- a/src/Nazara/Noise/NoiseBase.cpp +++ b/src/Nazara/Noise/NoiseBase.cpp @@ -1,43 +1,37 @@ -// Copyright (C) 2015 Rémi Bèges +// Copyright (C) 2016 Rémi Bèges // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include -#include #include namespace Nz { NoiseBase::NoiseBase(unsigned int seed) { - Ua = 16807; - Uc = 0; - Um = 2147483647; - UcurrentSeed = 0; - Uprevious = 0; + SetSeed(seed); + m_scale = 0.05f; - SetNewSeed(seed); - - for(int i(0) ; i < 512 ; i++) + for(unsigned int i(0) ; i < 512; ++i) perm[i] = i & 255; - } - void NoiseBase::SetNewSeed(unsigned int seed) + float NoiseBase::GetScale() { - Uprevious = seed; - UcurrentSeed = seed; + return m_scale; } - unsigned int NoiseBase::GetUniformRandomValue() + void NoiseBase::SetScale(float scale) { - Ulast = Ua*Uprevious + Uc%Um; - Uprevious = Ulast; - return Ulast; + m_scale = scale; } - void NoiseBase::ShufflePermutationTable() + void NoiseBase::SetSeed(unsigned int seed) + { + generator.seed(seed); + } + + void NoiseBase::Shuffle() { int xchanger; unsigned int ncase; @@ -45,35 +39,21 @@ namespace Nz for(unsigned int i(0) ; i < 256 ; i++) perm[i] = i; - for(unsigned int j(0) ; j < 20 ; ++j) - for (unsigned int i(0); i < 256 ; ++i) - { - ncase = this->GetUniformRandomValue() & 255; - xchanger = perm[i]; - perm[i] = perm[ncase]; - perm[ncase] = xchanger; - } + for (unsigned int i(0); i < 256 ; ++i) + { + ncase = generator() & 255; + xchanger = perm[i]; + perm[i] = perm[ncase]; + perm[ncase] = xchanger; + } for(unsigned int i(256) ; i < 512; ++i) perm[i] = perm[i & 255]; } - int NoiseBase::fastfloor(float n) + void NoiseBase::Shuffle(unsigned int amount) { - return (n >= 0) ? static_cast(n) : static_cast(n-1); - } - - int NoiseBase::JenkinsHash(int a, int b, int c) - { - a = a-b; a = a - c; a = a^(static_cast(c) >> 13); - b = b-c; b = b - a; b = b^(a << 8); - c = c-a; c = c - b; c = c^(static_cast(b) >> 13); - a = a-b; a = a - c; a = a^(static_cast(c) >> 12); - b = b-c; b = b - a; b = b^(a << 16); - c = c-a; c = c - b; c = c^(static_cast(b) >> 5); - a = a-b; a = a - c; a = a^(static_cast(c) >> 3); - b = b-c; b = b - a; b = b^(a << 10); - c = c-a; c = c - b; c = c^(static_cast(b) >> 15); - return c; + for(unsigned int j(0) ; j < amount ; ++j) + Shuffle(); } } diff --git a/src/Nazara/Noise/NoiseTools.cpp b/src/Nazara/Noise/NoiseTools.cpp new file mode 100644 index 000000000..9cf6efd39 --- /dev/null +++ b/src/Nazara/Noise/NoiseTools.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + int fastfloor(float n) + { + return (n >= 0) ? static_cast(n) : static_cast(n-1); + } + + int JenkinsHash(int a, int b, int c) + { + a = a-b; a = a - c; a = a^(static_cast(c) >> 13); + b = b-c; b = b - a; b = b^(a << 8); + c = c-a; c = c - b; c = c^(static_cast(b) >> 13); + a = a-b; a = a - c; a = a^(static_cast(c) >> 12); + b = b-c; b = b - a; b = b^(a << 16); + c = c-a; c = c - b; c = c^(static_cast(b) >> 5); + a = a-b; a = a - c; a = a^(static_cast(c) >> 3); + b = b-c; b = b - a; b = b^(a << 10); + c = c-a; c = c - b; c = c^(static_cast(b) >> 15); + return c; + } +} diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp new file mode 100644 index 000000000..f184702de --- /dev/null +++ b/src/Nazara/Noise/Perlin.cpp @@ -0,0 +1,325 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + Perlin::Perlin() : + gradient2{ + {1.f,1.f},{-1.f,1.f},{1.f,-1.f},{-1.f,-1.f}, + {1.f,0.f},{-1.f,0.f},{0.f,1.f},{0.f,-1.f} + }, + gradient3{ + {1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}, + {1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1}, + {0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}, + {1,1,0},{-1,1,0},{0,-1,1},{0,-1,-1} + }, + gradient4{ + {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, + {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, + {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, + {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, + {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, + {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, + {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, + {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} + } + { + + } + + Perlin::Perlin(unsigned int seed) : Perlin() + { + SetSeed(seed); + Shuffle(); + } + + float Perlin::Get(std::initializer_list coordinates, float scale) const + { + switch(coordinates.size()) + { + case 2: + return this->_2D(coordinates,scale); + case 3: + return this->_3D(coordinates,scale); + case 4: + return this->_4D(coordinates,scale); + default: + throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + } + } + + float Perlin::_2D(std::initializer_list coordinates, float scale) const + { + thread_local float xc, yc; + thread_local int x0, y0; + thread_local int gi0,gi1,gi2,gi3; + thread_local int ii, jj; + + thread_local float s,t,u,v; + thread_local float Cx,Cy; + thread_local float Li1, Li2; + thread_local float tempx,tempy; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + + ii = x0 & 255; + jj = y0 & 255; + + gi0 = perm[ii + perm[jj]] & 7; + gi1 = perm[ii + 1 + perm[jj]] & 7; + gi2 = perm[ii + perm[jj + 1]] & 7; + gi3 = perm[ii + 1 + perm[jj + 1]] & 7; + + tempx = xc - x0; + tempy = yc - y0; + + Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); + Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); + + s = gradient2[gi0][0]*tempx + gradient2[gi0][1]*tempy; + + tempx = xc - (x0 + 1); + t = gradient2[gi1][0]*tempx + gradient2[gi1][1]*tempy; + + tempy = yc - (y0 + 1); + v = gradient2[gi3][0]*tempx + gradient2[gi3][1]*tempy; + + tempx = xc - x0; + u = gradient2[gi2][0]*tempx + gradient2[gi2][1]*tempy; + + Li1 = s + Cx*(t-s); + Li2 = u + Cx*(v-u); + + return Li1 + Cy*(Li2-Li1); + } + + float Perlin::_3D(std::initializer_list coordinates, float scale) const + { + thread_local float xc, yc, zc; + thread_local int x0, y0, z0; + thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; + thread_local int ii, jj, kk; + + thread_local float Li1,Li2,Li3,Li4,Li5,Li6; + thread_local float s[2],t[2],u[2],v[2]; + thread_local float Cx,Cy,Cz; + thread_local float nx,ny,nz; + + thread_local float tmp; + thread_local float tempx,tempy,tempz; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + zc = *(++it) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + z0 = fastfloor(zc); + + ii = x0 & 255; + jj = y0 & 255; + kk = z0 & 255; + + gi0 = perm[ii + perm[jj + perm[kk]]] & 15; + gi1 = perm[ii + 1 + perm[jj + perm[kk]]] & 15; + gi2 = perm[ii + perm[jj + 1 + perm[kk]]] & 15; + gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk]]] & 15; + + gi4 = perm[ii + perm[jj + perm[kk + 1]]] & 15; + gi5 = perm[ii + 1 + perm[jj + perm[kk + 1]]] & 15; + gi6 = perm[ii + perm[jj + 1 + perm[kk + 1]]] & 15; + gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1]]] & 15; + + tempx = xc - x0; + tempy = yc - y0; + tempz = zc - z0; + + Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); + Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); + Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); + + s[0] = gradient3[gi0][0]*tempx + gradient3[gi0][1]*tempy + gradient3[gi0][2]*tempz; + + tempx = xc - (x0 + 1); + t[0] = gradient3[gi1][0]*tempx + gradient3[gi1][1]*tempy + gradient3[gi1][2]*tempz; + + tempy = yc - (y0 + 1); + v[0] = gradient3[gi3][0]*tempx + gradient3[gi3][1]*tempy + gradient3[gi3][2]*tempz; + + tempx = xc - x0; + u[0] = gradient3[gi2][0]*tempx + gradient3[gi2][1]*tempy + gradient3[gi2][2]*tempz; + + tempy = yc - y0; + tempz = zc - (z0 + 1); + s[1] = gradient3[gi4][0]*tempx + gradient3[gi4][1]*tempy + gradient3[gi4][2]*tempz; + + tempx = xc - (x0 + 1); + t[1] = gradient3[gi5][0]*tempx + gradient3[gi5][1]*tempy + gradient3[gi5][2]*tempz; + + tempy = yc - (y0 + 1); + v[1] = gradient3[gi7][0]*tempx + gradient3[gi7][1]*tempy + gradient3[gi7][2]*tempz; + + tempx = xc - x0; + u[1] = gradient3[gi6][0]*tempx + gradient3[gi6][1]*tempy + gradient3[gi6][2]*tempz; + + Li1 = s[0] + Cx*(t[0]-s[0]); + Li2 = u[0] + Cx*(v[0]-u[0]); + Li3 = s[1] + Cx*(t[1]-s[1]); + Li4 = u[1] + Cx*(v[1]-u[1]); + + Li5 = Li1 + Cy * (Li2-Li1); + Li6 = Li3 + Cy * (Li4-Li3); + + return Li5 + Cz * (Li6-Li5); + } + + float Perlin::_4D(std::initializer_list coordinates, float scale) const + { + thread_local float xc,yc,zc,wc; + thread_local int x0,y0,z0,w0; + thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; + thread_local int ii,jj,kk,ll; + + thread_local float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; + thread_local float s[4],t[4],u[4],v[4]; + thread_local float Cx,Cy,Cz,Cw; + + thread_local float tmp; + thread_local float tempx,tempy,tempz,tempw; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + zc = *(++it) * scale; + wc = *(++it) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + z0 = fastfloor(zc); + w0 = fastfloor(wc); + + ii = x0 & 255; + jj = y0 & 255; + kk = z0 & 255; + ll = w0 & 255; + + gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; + gi1 = perm[ii + 1 + perm[jj + perm[kk + perm[ll]]]] & 31; + gi2 = perm[ii + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; + gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; + + gi4 = perm[ii + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; + gi5 = perm[ii + 1 + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; + gi6 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; + gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; + + gi8 = perm[ii + perm[jj + perm[kk + perm[ll + 1]]]] & 31; + gi9 = perm[ii + 1 + perm[jj + perm[kk + perm[ll + 1]]]] & 31; + gi10 = perm[ii + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; + gi11 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; + + gi12 = perm[ii + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi13 = perm[ii + 1 + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi14 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi15 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; + + tempx = xc - x0; + tempy = yc - y0; + tempz = zc - z0; + tempw = wc - w0; + + Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); + Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); + Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); + Cw = tempw * tempw * tempw * (tempw * (tempw * 6 - 15) + 10); + + s[0] = gradient4[gi0][0]*tempx + gradient4[gi0][1]*tempy + gradient4[gi0][2]*tempz + gradient4[gi0][3]*tempw; + + tempx = xc - (x0+1); + t[0] = gradient4[gi1][0]*tempx + gradient4[gi1][1]*tempy + gradient4[gi1][2]*tempz + gradient4[gi1][3]*tempw; + + tempy = yc - (y0+1); + v[0] = gradient4[gi3][0]*tempx + gradient4[gi3][1]*tempy + gradient4[gi3][2]*tempz + gradient4[gi3][3]*tempw; + + tempx = xc - x0; + u[0] = gradient4[gi2][0]*tempx + gradient4[gi2][1]*tempy + gradient4[gi2][2]*tempz + gradient4[gi2][3]*tempw; + + tempy = yc - y0; + tempz = zc - (z0+1); + s[1] = gradient4[gi4][0]*tempx + gradient4[gi4][1]*tempy + gradient4[gi4][2]*tempz + gradient4[gi4][3]*tempw; + + tempx = xc - (x0+1); + t[1] = gradient4[gi5][0]*tempx + gradient4[gi5][1]*tempy + gradient4[gi5][2]*tempz + gradient4[gi5][3]*tempw; + + tempy = yc - (y0+1); + v[1] = gradient4[gi7][0]*tempx + gradient4[gi7][1]*tempy + gradient4[gi7][2]*tempz + gradient4[gi7][3]*tempw; + + tempx = xc - x0; + u[1] = gradient4[gi6][0]*tempx + gradient4[gi6][1]*tempy + gradient4[gi6][2]*tempz + gradient4[gi6][3]*tempw; + + + tempy = yc - y0; + tempz = zc - z0; + tempw = wc - (w0+1); + s[2] = gradient4[gi8][0]*tempx + gradient4[gi8][1]*tempy + gradient4[gi8][2]*tempz + gradient4[gi8][3]*tempw; + + tempx = xc - (x0+1); + t[2] = gradient4[gi9][0]*tempx + gradient4[gi9][1]*tempy + gradient4[gi9][2]*tempz + gradient4[gi9][3]*tempw; + + tempy = yc - (y0+1); + v[2] = gradient4[gi11][0]*tempx + gradient4[gi11][1]*tempy + gradient4[gi11][2]*tempz + gradient4[gi11][3]*tempw; + + tempx = xc - x0; + u[2] = gradient4[gi10][0]*tempx + gradient4[gi10][1]*tempy + gradient4[gi10][2]*tempz + gradient4[gi10][3]*tempw; + + + tempy = yc - y0; + tempz = zc - (z0+1); + s[3] = gradient4[gi12][0]*tempx + gradient4[gi12][1]*tempy + gradient4[gi12][2]*tempz + gradient4[gi12][3]*tempw; + + tempx = xc - (x0+1); + t[3] = gradient4[gi13][0]*tempx + gradient4[gi13][1]*tempy + gradient4[gi13][2]*tempz + gradient4[gi13][3]*tempw; + + tempy = yc - (y0+1); + v[3] = gradient4[gi15][0]*tempx + gradient4[gi15][1]*tempy + gradient4[gi15][2]*tempz + gradient4[gi15][3]*tempw; + + tempx = xc - x0; + u[3] = gradient4[gi14][0]*tempx + gradient4[gi14][1]*tempy + gradient4[gi14][2]*tempz + gradient4[gi14][3]*tempw; + + Li1 = s[0] + Cx*(t[0]-s[0]); + Li2 = u[0] + Cx*(v[0]-u[0]); + Li3 = s[1] + Cx*(t[1]-s[1]); + Li4 = u[1] + Cx*(v[1]-u[1]); + Li5 = s[2] + Cx*(t[2]-s[2]); + Li6 = u[2] + Cx*(v[2]-u[2]); + Li7 = s[3] + Cx*(t[3]-s[3]); + Li8 = u[3] + Cx*(v[3]-u[3]); + + Li9 = Li1 + Cy*(Li2-Li1); + Li10 = Li3 + Cy*(Li4-Li3); + Li11 = Li5 + Cy*(Li6-Li5); + Li12 = Li7 + Cy*(Li8-Li7); + + Li13 = Li9 + Cz*(Li10-Li9); + Li14 = Li11 + Cz*(Li12-Li11); + + return Li13 + Cw*(Li14-Li13); + } +} diff --git a/src/Nazara/Noise/Perlin2D.cpp b/src/Nazara/Noise/Perlin2D.cpp deleted file mode 100644 index 1d26c01e2..000000000 --- a/src/Nazara/Noise/Perlin2D.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Perlin2D::Perlin2D() - { - float grad2Temp[][2] = { - {1.f,1.f}, - {-1.f,1.f}, - {1.f,-1.f}, - {-1.f,-1.f}, - - {1.f,0.f}, - {-1.f,0.f}, - {0.f,1.f}, - {0.f,-1.f} - }; - - for(int i(0) ; i < 8 ; ++i) - for(int j(0) ; j < 2 ; ++j) - gradient2[i][j] = grad2Temp[i][j]; - } - - Perlin2D::Perlin2D(unsigned int seed) : Perlin2D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Perlin2D::GetValue(float x, float y, float resolution) - { - x *= resolution; - y *= resolution; - - x0 = fastfloor(x); - y0 = fastfloor(y); - - ii = x0 & 255; - jj = y0 & 255; - - gi0 = perm[ii + perm[jj]] & 7; - gi1 = perm[ii + 1 + perm[jj]] & 7; - gi2 = perm[ii + perm[jj + 1]] & 7; - gi3 = perm[ii + 1 + perm[jj + 1]] & 7; - - temp.x = x-x0; - temp.y = y-y0; - - Cx = temp.x * temp.x * temp.x * (temp.x * (temp.x * 6 - 15) + 10); - Cy = temp.y * temp.y * temp.y * (temp.y * (temp.y * 6 - 15) + 10); - - s = gradient2[gi0][0]*temp.x + gradient2[gi0][1]*temp.y; - - temp.x = x-(x0+1); - t = gradient2[gi1][0]*temp.x + gradient2[gi1][1]*temp.y; - - temp.y = y-(y0+1); - v = gradient2[gi3][0]*temp.x + gradient2[gi3][1]*temp.y; - - temp.x = x-x0; - u = gradient2[gi2][0]*temp.x + gradient2[gi2][1]*temp.y; - - Li1 = s + Cx*(t-s); - Li2 = u + Cx*(v-u); - - return Li1 + Cy*(Li2-Li1); - } -} diff --git a/src/Nazara/Noise/Perlin3D.cpp b/src/Nazara/Noise/Perlin3D.cpp deleted file mode 100644 index 2e91154f6..000000000 --- a/src/Nazara/Noise/Perlin3D.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Perlin3D::Perlin3D() - { - float grad3Temp[][3] = { - {1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}, - {1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1}, - {0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}, - {1,1,0},{-1,1,0},{0,-1,1},{0,-1,-1} - }; - - for(int i(0) ; i < 16 ; ++i) - for(int j(0) ; j < 3 ; ++j) - gradient3[i][j] = grad3Temp[i][j]; - } - - Perlin3D::Perlin3D(unsigned int seed) : Perlin3D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Perlin3D::GetValue(float x, float y, float z, float resolution) - { - x /= resolution; - y /= resolution; - z /= resolution; - - x0 = fastfloor(x); - y0 = fastfloor(y); - z0 = fastfloor(z); - - ii = x0 & 255; - jj = y0 & 255; - kk = z0 & 255; - - gi0 = perm[ii + perm[jj + perm[kk]]] & 15; - gi1 = perm[ii + 1 + perm[jj + perm[kk]]] & 15; - gi2 = perm[ii + perm[jj + 1 + perm[kk]]] & 15; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk]]] & 15; - - gi4 = perm[ii + perm[jj + perm[kk + 1]]] & 15; - gi5 = perm[ii + 1 + perm[jj + perm[kk + 1]]] & 15; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1]]] & 15; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1]]] & 15; - - temp.x = x-x0; - temp.y = y-y0; - temp.z = z-z0; - - Cx = temp.x * temp.x * temp.x * (temp.x * (temp.x * 6 - 15) + 10); - Cy = temp.y * temp.y * temp.y * (temp.y * (temp.y * 6 - 15) + 10); - Cz = temp.z * temp.z * temp.z * (temp.z * (temp.z * 6 - 15) + 10); - - s[0] = gradient3[gi0][0]*temp.x + gradient3[gi0][1]*temp.y + gradient3[gi0][2]*temp.z; - - temp.x = x-(x0+1); - t[0] = gradient3[gi1][0]*temp.x + gradient3[gi1][1]*temp.y + gradient3[gi1][2]*temp.z; - - temp.y = y-(y0+1); - v[0] = gradient3[gi3][0]*temp.x + gradient3[gi3][1]*temp.y + gradient3[gi3][2]*temp.z; - - temp.x = x-x0; - u[0] = gradient3[gi2][0]*temp.x + gradient3[gi2][1]*temp.y + gradient3[gi2][2]*temp.z; - - temp.y = y-y0; - temp.z = z-(z0+1); - s[1] = gradient3[gi4][0]*temp.x + gradient3[gi4][1]*temp.y + gradient3[gi4][2]*temp.z; - - temp.x = x-(x0+1); - t[1] = gradient3[gi5][0]*temp.x + gradient3[gi5][1]*temp.y + gradient3[gi5][2]*temp.z; - - temp.y = y-(y0+1); - v[1] = gradient3[gi7][0]*temp.x + gradient3[gi7][1]*temp.y + gradient3[gi7][2]*temp.z; - - temp.x = x-x0; - u[1] = gradient3[gi6][0]*temp.x + gradient3[gi6][1]*temp.y + gradient3[gi6][2]*temp.z; - - Li1 = s[0] + Cx*(t[0]-s[0]); - Li2 = u[0] + Cx*(v[0]-u[0]); - Li3 = s[1] + Cx*(t[1]-s[1]); - Li4 = u[1] + Cx*(v[1]-u[1]); - - Li5 = Li1 + Cy*(Li2-Li1); - Li6 = Li3 + Cy*(Li4-Li3); - - return Li5 + Cz*(Li6-Li5); - } -} diff --git a/src/Nazara/Noise/Perlin4D.cpp b/src/Nazara/Noise/Perlin4D.cpp deleted file mode 100644 index b321616f6..000000000 --- a/src/Nazara/Noise/Perlin4D.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Perlin4D::Perlin4D() - { - float grad4Temp[][4] = - { - {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, - {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, - {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, - {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, - {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, - {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, - {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, - {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} - }; - - for(int i(0) ; i < 32 ; ++i) - for(int j(0) ; j < 4 ; ++j) - gradient4[i][j] = grad4Temp[i][j]; - } - - Perlin4D::Perlin4D(unsigned int seed) : Perlin4D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Perlin4D::GetValue(float x, float y, float z, float w, float resolution) - { - x *= resolution; - y *= resolution; - z *= resolution; - w *= resolution; - - x0 = fastfloor(x); - y0 = fastfloor(y); - z0 = fastfloor(z); - w0 = fastfloor(w); - - ii = x0 & 255; - jj = y0 & 255; - kk = z0 & 255; - ll = w0 & 255; - - gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; - gi1 = perm[ii + 1 + perm[jj + perm[kk + perm[ll]]]] & 31; - gi2 = perm[ii + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; - - gi4 = perm[ii + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi5 = perm[ii + 1 + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; - - gi8 = perm[ii + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi9 = perm[ii + 1 + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi10 = perm[ii + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; - gi11 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; - - gi12 = perm[ii + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi13 = perm[ii + 1 + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi14 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi15 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; - - temp.x = x-x0; - temp.y = y-y0; - temp.z = z-z0; - temp.w = w-w0; - - Cx = temp.x * temp.x * temp.x * (temp.x * (temp.x * 6 - 15) + 10); - Cy = temp.y * temp.y * temp.y * (temp.y * (temp.y * 6 - 15) + 10); - Cz = temp.z * temp.z * temp.z * (temp.z * (temp.z * 6 - 15) + 10); - Cw = temp.w * temp.w * temp.w * (temp.w * (temp.w * 6 - 15) + 10); - - s[0] = gradient4[gi0][0]*temp.x + gradient4[gi0][1]*temp.y + gradient4[gi0][2]*temp.z + gradient4[gi0][3]*temp.w; - - temp.x = x-(x0+1); - t[0] = gradient4[gi1][0]*temp.x + gradient4[gi1][1]*temp.y + gradient4[gi1][2]*temp.z + gradient4[gi1][3]*temp.w; - - temp.y = y-(y0+1); - v[0] = gradient4[gi3][0]*temp.x + gradient4[gi3][1]*temp.y + gradient4[gi3][2]*temp.z + gradient4[gi3][3]*temp.w; - - temp.x = x-x0; - u[0] = gradient4[gi2][0]*temp.x + gradient4[gi2][1]*temp.y + gradient4[gi2][2]*temp.z + gradient4[gi2][3]*temp.w; - - temp.y = y-y0; - temp.z = z-(z0+1); - s[1] = gradient4[gi4][0]*temp.x + gradient4[gi4][1]*temp.y + gradient4[gi4][2]*temp.z + gradient4[gi4][3]*temp.w; - - temp.x = x-(x0+1); - t[1] = gradient4[gi5][0]*temp.x + gradient4[gi5][1]*temp.y + gradient4[gi5][2]*temp.z + gradient4[gi5][3]*temp.w; - - temp.y = y-(y0+1); - v[1] = gradient4[gi7][0]*temp.x + gradient4[gi7][1]*temp.y + gradient4[gi7][2]*temp.z + gradient4[gi7][3]*temp.w; - - temp.x = x-x0; - u[1] = gradient4[gi6][0]*temp.x + gradient4[gi6][1]*temp.y + gradient4[gi6][2]*temp.z + gradient4[gi6][3]*temp.w; - - - temp.y = y-y0; - temp.z = z-z0; - temp.w = w-(w0+1); - s[2] = gradient4[gi8][0]*temp.x + gradient4[gi8][1]*temp.y + gradient4[gi8][2]*temp.z + gradient4[gi8][3]*temp.w; - - temp.x = x-(x0+1); - t[2] = gradient4[gi9][0]*temp.x + gradient4[gi9][1]*temp.y + gradient4[gi9][2]*temp.z + gradient4[gi9][3]*temp.w; - - temp.y = y-(y0+1); - v[2] = gradient4[gi11][0]*temp.x + gradient4[gi11][1]*temp.y + gradient4[gi11][2]*temp.z + gradient4[gi11][3]*temp.w; - - temp.x = x-x0; - u[2] = gradient4[gi10][0]*temp.x + gradient4[gi10][1]*temp.y + gradient4[gi10][2]*temp.z + gradient4[gi10][3]*temp.w; - - - temp.y = y-y0; - temp.z = z-(z0+1); - s[3] = gradient4[gi12][0]*temp.x + gradient4[gi12][1]*temp.y + gradient4[gi12][2]*temp.z + gradient4[gi12][3]*temp.w; - - temp.x = x-(x0+1); - t[3] = gradient4[gi13][0]*temp.x + gradient4[gi13][1]*temp.y + gradient4[gi13][2]*temp.z + gradient4[gi13][3]*temp.w; - - temp.y = y-(y0+1); - v[3] = gradient4[gi15][0]*temp.x + gradient4[gi15][1]*temp.y + gradient4[gi15][2]*temp.z + gradient4[gi15][3]*temp.w; - - temp.x = x-x0; - u[3] = gradient4[gi14][0]*temp.x + gradient4[gi14][1]*temp.y + gradient4[gi14][2]*temp.z + gradient4[gi14][3]*temp.w; - - Li1 = s[0] + Cx*(t[0]-s[0]); - Li2 = u[0] + Cx*(v[0]-u[0]); - Li3 = s[1] + Cx*(t[1]-s[1]); - Li4 = u[1] + Cx*(v[1]-u[1]); - Li5 = s[2] + Cx*(t[2]-s[2]); - Li6 = u[2] + Cx*(v[2]-u[2]); - Li7 = s[3] + Cx*(t[3]-s[3]); - Li8 = u[3] + Cx*(v[3]-u[3]); - - Li9 = Li1 + Cy*(Li2-Li1); - Li10 = Li3 + Cy*(Li4-Li3); - Li11 = Li5 + Cy*(Li6-Li5); - Li12 = Li7 + Cy*(Li8-Li7); - - Li13 = Li9 + Cz*(Li10-Li9); - Li14 = Li11 + Cz*(Li12-Li11); - - return Li13 + Cw*(Li14-Li13); - } -} diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp new file mode 100644 index 000000000..c93a226d4 --- /dev/null +++ b/src/Nazara/Noise/Simplex.cpp @@ -0,0 +1,459 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + Simplex::Simplex() : + gradient2{ + {1,1},{-1,1},{1,-1},{-1,-1}, + {1,0},{-1,0},{0,1},{0,-1} + }, + gradient3{ + {1.f,1.f,0.f},{-1.f,1.f,0.f},{1.f,-1.f,0.f},{-1.f,-1.f,0.f}, + {1.f,0.f,1.f},{-1.f,0.f,1.f},{1.f,0.f,-1.f},{-1.f,0.f,-1.f}, + {0.f,1.f,1.f},{0.f,-1.f,1.f},{0.f,1.f,-1.f},{0.f,-1.f,-1.f} + }, + gradient4{ + {0.f,1.f,1.f,1.f}, {0.f,1.f,1.f,-1.f}, {0.f,1.f,-1.f,1.f}, {0.f,1.f,-1.f,-1.f}, + {0.f,-1.f,1.f,1.f},{0.f,-1.f,1.f,-1.f},{0.f,-1.f,-1.f,1.f},{0.f,-1.f,-1.f,-1.f}, + {1.f,0.f,1.f,1.f}, {1.f,0.f,1.f,-1.f}, {1.f,0.f,-1.f,1.f}, {1.f,0.f,-1.f,-1.f}, + {-1.f,0.f,1.f,1.f},{-1.f,0.f,1.f,-1.f},{-1.f,0.f,-1.f,1.f},{-1.f,0.f,-1.f,-1.f}, + {1.f,1.f,0.f,1.f}, {1.f,1.f,0.f,-1.f}, {1.f,-1.f,0.f,1.f}, {1.f,-1.f,0.f,-1.f}, + {-1.f,1.f,0.f,1.f},{-1.f,1.f,0.f,-1.f},{-1.f,-1.f,0.f,1.f},{-1.f,-1.f,0.f,-1.f}, + {1.f,1.f,1.f,0.f}, {1.f,1.f,-1.f,0.f}, {1.f,-1.f,1.f,0.f}, {1.f,-1.f,-1.f,0.f}, + {-1.f,1.f,1.f,0.f},{-1.f,1.f,-1.f,0.f},{-1.f,-1.f,1.f,0.f},{-1.f,-1.f,-1.f,0.f} + }, + lookupTable4D{ + {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, + {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, + {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, + {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, + {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, + {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, + {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, + {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0} + }, + SkewCoeff2D (0.5f*(std::sqrt(3.f) - 1.f)), + UnskewCoeff2D((3.f-std::sqrt(3.f))/6.f), + SkewCoeff3D (1/3.f), + UnskewCoeff3D (1/6.f), + SkewCoeff4D ((std::sqrt(5.f) - 1.f)/4.f), + UnskewCoeff4D ((5.f - std::sqrt(5.f))/20.f) + { + + } + + Simplex::Simplex(unsigned int seed) : Simplex() + { + SetSeed(seed); + Shuffle(); + } + + float Simplex::Get(std::initializer_list coordinates, float scale) const + { + switch(coordinates.size()) + { + case 2: + return this->_2D(coordinates,scale); + case 3: + return this->_3D(coordinates,scale); + case 4: + return this->_4D(coordinates,scale); + default: + throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + } + } + + float Simplex::_2D(std::initializer_list coordinates, float scale) const + { + thread_local float xc,yc; + thread_local int ii,jj; + thread_local int gi0,gi1,gi2; + thread_local int skewedCubeOriginx,skewedCubeOriginy; + thread_local int off1x,off1y; + thread_local float n1,n2,n3; + thread_local float c1,c2,c3; + thread_local float sum; + thread_local float unskewedCubeOriginx,unskewedCubeOriginy; + thread_local float unskewedDistToOriginx,unskewedDistToOriginy; + thread_local float d1x,d1y; + thread_local float d2x,d2y; + thread_local float d3x,d3y; + + std::initializer_list::const_iterator it = coordinates.begin(); + + xc = *(it ) * scale; + yc = *(++it) * scale; + + sum = (xc + yc) * SkewCoeff2D; + skewedCubeOriginx = fastfloor(xc + sum); + skewedCubeOriginy = fastfloor(yc + sum); + + sum = (skewedCubeOriginx + skewedCubeOriginy) * UnskewCoeff2D; + unskewedCubeOriginx = skewedCubeOriginx - sum; + unskewedCubeOriginy = skewedCubeOriginy - sum; + + unskewedDistToOriginx = xc - unskewedCubeOriginx;// Difference with 3d and 4d + unskewedDistToOriginy = yc - unskewedCubeOriginy; + + if(unskewedDistToOriginx > unskewedDistToOriginy) + { + off1x = 1; + off1y = 0; + } + else + { + off1x = 0; + off1y = 1; + } + + d1x = - unskewedDistToOriginx; + d1y = - unskewedDistToOriginy; + + d2x = d1x + off1x - UnskewCoeff2D; + d2y = d1y + off1y - UnskewCoeff2D; + + d3x = d1x + 1.f - 2.f * UnskewCoeff2D; + d3y = d1y + 1.f - 2.f * UnskewCoeff2D; + + ii = skewedCubeOriginx & 255; + jj = skewedCubeOriginy & 255; + + gi0 = perm[ii + perm[jj ]] & 7; + gi1 = perm[ii + off1x + perm[jj + off1y ]] & 7; + gi2 = perm[ii + 1 + perm[jj + 1 ]] & 7; + + c1 = 0.5f - d1x * d1x - d1y * d1y; + c2 = 0.5f - d2x * d2x - d2y * d2y; + c3 = 0.5f - d3x * d3x - d3y * d3y; + + if(c1 < 0) + n1 = 0; + else + n1 = c1*c1*c1*c1*(gradient2[gi0][0] * d1x + gradient2[gi0][1] * d1y); + + if(c2 < 0) + n2 = 0; + else + n2 = c2*c2*c2*c2*(gradient2[gi1][0] * d2x + gradient2[gi1][1] * d2y); + + if(c3 < 0) + n3 = 0; + else + n3 = c3*c3*c3*c3*(gradient2[gi2][0] * d3x + gradient2[gi2][1] * d3y); + + return (n1+n2+n3)*70.f; + } + + float Simplex::_3D(std::initializer_list coordinates, float scale) const + { + thread_local float xc, yc, zc; + thread_local float x,y,z; + thread_local int ii,jj,kk; + thread_local int gi0,gi1,gi2,gi3; + thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz; + + thread_local int off1x,off1y,off1z; + thread_local int off2x,off2y,off2z; + thread_local float n1,n2,n3,n4; + thread_local float c1,c2,c3,c4; + + thread_local float sum; + thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz; + thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz; + thread_local float d1x,d1y,d1z; + thread_local float d2x,d2y,d2z; + thread_local float d3x,d3y,d3z; + thread_local float d4x,d4y,d4z; + + std::initializer_list::const_iterator it = coordinates.begin(); + + x = *(it ); + y = *(++it); + z = *(++it); + + xc = x * scale; + yc = y * scale; + zc = z * scale; + + sum = (xc + yc + zc) * SkewCoeff3D; + skewedCubeOriginx = fastfloor(xc + sum); + skewedCubeOriginy = fastfloor(yc + sum); + skewedCubeOriginz = fastfloor(zc + sum); + + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz) * UnskewCoeff3D; + unskewedCubeOriginx = skewedCubeOriginx - sum; + unskewedCubeOriginy = skewedCubeOriginy - sum; + unskewedCubeOriginz = skewedCubeOriginz - sum; + + unskewedDistToOriginx = xc - unskewedCubeOriginx; + unskewedDistToOriginy = yc - unskewedCubeOriginy; + unskewedDistToOriginz = zc - unskewedCubeOriginz; + + if(unskewedDistToOriginx >= unskewedDistToOriginy) + { + if(unskewedDistToOriginy >= unskewedDistToOriginz) + { + off1x = 1; + off1y = 0; + off1z = 0; + off2x = 1; + off2y = 1; + off2z = 0; + } + else if(unskewedDistToOriginx >= unskewedDistToOriginz) + { + off1x = 1; + off1y = 0; + off1z = 0; + off2x = 1; + off2y = 0; + off2z = 1; + } + else + { + off1x = 0; + off1y = 0; + off1z = 1; + off2x = 1; + off2y = 0; + off2z = 1; + } + } + else + { + if(unskewedDistToOriginy < unskewedDistToOriginz) + { + off1x = 0; + off1y = 0; + off1z = 1; + off2x = 0; + off2y = 1; + off2z = 1; + } + else if(unskewedDistToOriginx < unskewedDistToOriginz) + { + off1x = 0; + off1y = 1; + off1z = 0; + off2x = 0; + off2y = 1; + off2z = 1; + } + else + { + off1x = 0; + off1y = 1; + off1z = 0; + off2x = 1; + off2y = 1; + off2z = 0; + } + } + + d1x = unskewedDistToOriginx; + d1y = unskewedDistToOriginy; + d1z = unskewedDistToOriginz; + + d2x = d1x - off1x + UnskewCoeff3D; + d2y = d1y - off1y + UnskewCoeff3D; + d2z = d1z - off1z + UnskewCoeff3D; + + d3x = d1x - off2x + 2.f*UnskewCoeff3D; + d3y = d1y - off2y + 2.f*UnskewCoeff3D; + d3z = d1z - off2z + 2.f*UnskewCoeff3D; + + d4x = d1x - 1.f + 3.f*UnskewCoeff3D; + d4y = d1y - 1.f + 3.f*UnskewCoeff3D; + d4z = d1z - 1.f + 3.f*UnskewCoeff3D; + + ii = skewedCubeOriginx & 255; + jj = skewedCubeOriginy & 255; + kk = skewedCubeOriginz & 255; + + gi0 = perm[ii + perm[jj + perm[kk ]]] % 12; + gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z ]]] % 12; + gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z ]]] % 12; + gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 ]]] % 12; + + c1 = 0.6f - d1x * d1x - d1y * d1y - d1z * d1z; + c2 = 0.6f - d2x * d2x - d2y * d2y - d2z * d2z; + c3 = 0.6f - d3x * d3x - d3y * d3y - d3z * d3z; + c4 = 0.6f - d4x * d4x - d4y * d4y - d4z * d4z; + + if(c1 < 0) + n1 = 0; + else + n1 = c1*c1*c1*c1*(gradient3[gi0][0] * d1x + gradient3[gi0][1] * d1y + gradient3[gi0][2] * d1z); + + if(c2 < 0) + n2 = 0; + else + n2 = c2*c2*c2*c2*(gradient3[gi1][0] * d2x + gradient3[gi1][1] * d2y + gradient3[gi1][2] * d2z); + + if(c3 < 0) + n3 = 0; + else + n3 = c3*c3*c3*c3*(gradient3[gi2][0] * d3x + gradient3[gi2][1] * d3y + gradient3[gi2][2] * d3z); + + if(c4 < 0) + n4 = 0; + else + n4 = c4*c4*c4*c4*(gradient3[gi3][0] * d4x + gradient3[gi3][1] * d4y + gradient3[gi3][2] * d4z); + + return (n1+n2+n3+n4)*32; + } + + float Simplex::_4D(std::initializer_list coordinates, float scale) const + { + thread_local float xc,yc,zc,wc; + thread_local float x,y,z,w; + thread_local int ii,jj,kk,ll; + thread_local int gi0,gi1,gi2,gi3,gi4; + thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz,skewedCubeOriginw; + + thread_local int off1x,off1y,off1z,off1w; + thread_local int off2x,off2y,off2z,off2w; + thread_local int off3x,off3y,off3z,off3w; + + thread_local int c; + thread_local float n1,n2,n3,n4,n5; + thread_local float c1,c2,c3,c4,c5,c6; + + thread_local float sum; + thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; + thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz,unskewedDistToOriginw; + thread_local float d1x,d2x,d3x,d4x,d5x; + thread_local float d1y,d2y,d3y,d4y,d5y; + thread_local float d1z,d2z,d3z,d4z,d5z; + thread_local float d1w,d2w,d3w,d4w,d5w; + + std::initializer_list::const_iterator it = coordinates.begin(); + + x = *(it ); + y = *(++it); + z = *(++it); + w = *(++it); + + xc = x * scale; + yc = y * scale; + zc = z * scale; + wc = w * scale; + + sum = (xc + yc + zc + wc) * SkewCoeff4D; + skewedCubeOriginx = fastfloor(xc + sum); + skewedCubeOriginy = fastfloor(yc + sum); + skewedCubeOriginz = fastfloor(zc + sum); + skewedCubeOriginw = fastfloor(wc + sum); + + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz + skewedCubeOriginw) * UnskewCoeff4D; + unskewedCubeOriginx = skewedCubeOriginx - sum; + unskewedCubeOriginy = skewedCubeOriginy - sum; + unskewedCubeOriginz = skewedCubeOriginz - sum; + unskewedCubeOriginw = skewedCubeOriginw - sum; + + unskewedDistToOriginx = xc - unskewedCubeOriginx; + unskewedDistToOriginy = yc - unskewedCubeOriginy; + unskewedDistToOriginz = zc - unskewedCubeOriginz; + unskewedDistToOriginw = wc - unskewedCubeOriginw; + + c1 = (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0; + c2 = (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0; + c3 = (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0; + c4 = (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0; + c5 = (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0; + c6 = (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; + c = c1 + c2 + c3 + c4 + c5 + c6; + + off1x = lookupTable4D[c][0] >= 3 ? 1 : 0; + off1y = lookupTable4D[c][1] >= 3 ? 1 : 0; + off1z = lookupTable4D[c][2] >= 3 ? 1 : 0; + off1w = lookupTable4D[c][3] >= 3 ? 1 : 0; + + off2x = lookupTable4D[c][0] >= 2 ? 1 : 0; + off2y = lookupTable4D[c][1] >= 2 ? 1 : 0; + off2z = lookupTable4D[c][2] >= 2 ? 1 : 0; + off2w = lookupTable4D[c][3] >= 2 ? 1 : 0; + + off3x = lookupTable4D[c][0] >= 1 ? 1 : 0; + off3y = lookupTable4D[c][1] >= 1 ? 1 : 0; + off3z = lookupTable4D[c][2] >= 1 ? 1 : 0; + off3w = lookupTable4D[c][3] >= 1 ? 1 : 0; + + d1x = unskewedDistToOriginx; + d1y = unskewedDistToOriginy; + d1z = unskewedDistToOriginz; + d1w = unskewedDistToOriginw; + + d2x = d1x - off1x + UnskewCoeff4D; + d2y = d1y - off1y + UnskewCoeff4D; + d2z = d1z - off1z + UnskewCoeff4D; + d2w = d1w - off1w + UnskewCoeff4D; + + d3x = d1x - off2x + 2.f*UnskewCoeff4D; + d3y = d1y - off2y + 2.f*UnskewCoeff4D; + d3z = d1z - off2z + 2.f*UnskewCoeff4D; + d3w = d1w - off2w + 2.f*UnskewCoeff4D; + + d4x = d1x - off3x + 3.f*UnskewCoeff4D; + d4y = d1y - off3y + 3.f*UnskewCoeff4D; + d4z = d1z - off3z + 3.f*UnskewCoeff4D; + d4w = d1w - off3w + 3.f*UnskewCoeff4D; + + d5x = d1x - 1.f + 4*UnskewCoeff4D; + d5y = d1y - 1.f + 4*UnskewCoeff4D; + d5z = d1z - 1.f + 4*UnskewCoeff4D; + d5w = d1w - 1.f + 4*UnskewCoeff4D; + + ii = skewedCubeOriginx & 255; + jj = skewedCubeOriginy & 255; + kk = skewedCubeOriginz & 255; + ll = skewedCubeOriginw & 255; + + gi0 = perm[ii + perm[jj + perm[kk + perm[ll ]]]] & 31; + gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z + perm[ll + off1w]]]] & 31; + gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z + perm[ll + off2w]]]] & 31; + gi3 = perm[ii + off3x + perm[jj + off3y + perm[kk + off3z + perm[ll + off3w]]]] & 31; + gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1 ]]]] % 32; + + c1 = 0.6f - d1x*d1x - d1y*d1y - d1z*d1z - d1w*d1w; + c2 = 0.6f - d2x*d2x - d2y*d2y - d2z*d2z - d2w*d2w; + c3 = 0.6f - d3x*d3x - d3y*d3y - d3z*d3z - d3w*d3w; + c4 = 0.6f - d4x*d4x - d4y*d4y - d4z*d4z - d4w*d4w; + c5 = 0.6f - d5x*d5x - d5y*d5y - d5z*d5z - d5w*d5w; + + if(c1 < 0) + n1 = 0; + else + n1 = c1*c1*c1*c1*(gradient4[gi0][0]*d1x + gradient4[gi0][1]*d1y + gradient4[gi0][2]*d1z + gradient4[gi0][3]*d1w); + + if(c2 < 0) + n2 = 0; + else + n2 = c2*c2*c2*c2*(gradient4[gi1][0]*d2x + gradient4[gi1][1]*d2y + gradient4[gi1][2]*d2z + gradient4[gi1][3]*d2w); + + if(c3 < 0) + n3 = 0; + else + n3 = c3*c3*c3*c3*(gradient4[gi2][0]*d3x + gradient4[gi2][1]*d3y + gradient4[gi2][2]*d3z + gradient4[gi2][3]*d3w); + + if(c4 < 0) + n4 = 0; + else + n4 = c4*c4*c4*c4*(gradient4[gi3][0]*d4x + gradient4[gi3][1]*d4y + gradient4[gi3][2]*d4z + gradient4[gi3][3]*d4w); + + if(c5 < 0) + n5 = 0; + else + n5 = c5*c5*c5*c5*(gradient4[gi4][0]*d5x + gradient4[gi4][1]*d5y + gradient4[gi4][2]*d5z + gradient4[gi4][3]*d5w); + + return (n1+n2+n3+n4+n5)*27.f; + } +} diff --git a/src/Nazara/Noise/Simplex2D.cpp b/src/Nazara/Noise/Simplex2D.cpp deleted file mode 100644 index b5e50c996..000000000 --- a/src/Nazara/Noise/Simplex2D.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Simplex2D::Simplex2D() - { - float grad2Temp[][2] = {{1,1},{-1,1},{1,-1},{-1,-1}, - {1,0},{-1,0},{0,1},{0,-1}}; - - for(int i(0) ; i < 8 ; ++i) - for(int j(0) ; j < 2 ; ++j) - gradient2[i][j] = grad2Temp[i][j]; - - SkewCoeff2D = 0.5f*(std::sqrt(3.f) - 1.f); - UnskewCoeff2D = (3.f-std::sqrt(3.f))/6.f; - } - - Simplex2D::Simplex2D(unsigned int seed) : Simplex2D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Simplex2D::GetValue(float x, float y, float resolution) - { - x *= resolution; - y *= resolution; - - sum = (x + y) * SkewCoeff2D; - skewedCubeOrigin.x = fastfloor(x + sum); - skewedCubeOrigin.y = fastfloor(y + sum); - - sum = (skewedCubeOrigin.x + skewedCubeOrigin.y) * UnskewCoeff2D; - unskewedCubeOrigin.x = skewedCubeOrigin.x - sum; - unskewedCubeOrigin.y = skewedCubeOrigin.y - sum; - - unskewedDistToOrigin.x = x - unskewedCubeOrigin.x; - unskewedDistToOrigin.y = y - unskewedCubeOrigin.y; - - if(unskewedDistToOrigin.x > unskewedDistToOrigin.y) - { - off1.x = 1; - off1.y = 0; - } - else - { - off1.x = 0; - off1.y = 1; - } - - d1 = - unskewedDistToOrigin; - - d2.x = d1.x + off1.x - UnskewCoeff2D; - d2.y = d1.y + off1.y - UnskewCoeff2D; - - d3.x = d1.x + 1.f - 2.f * UnskewCoeff2D; - d3.y = d1.y + 1.f - 2.f * UnskewCoeff2D; - - ii = skewedCubeOrigin.x & 255; - jj = skewedCubeOrigin.y & 255; - - gi0 = perm[ii + perm[jj ]] & 7; - gi1 = perm[ii + off1.x + perm[jj + off1.y]] & 7; - gi2 = perm[ii + 1 + perm[jj + 1 ]] & 7; - - c1 = 0.5f - d1.x * d1.x - d1.y * d1.y; - c2 = 0.5f - d2.x * d2.x - d2.y * d2.y; - c3 = 0.5f - d3.x * d3.x - d3.y * d3.y; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient2[gi0][0] * d1.x + gradient2[gi0][1] * d1.y); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient2[gi1][0] * d2.x + gradient2[gi1][1] * d2.y); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient2[gi2][0] * d3.x + gradient2[gi2][1] * d3.y); - - return (n1+n2+n3)*70.f; - } -} diff --git a/src/Nazara/Noise/Simplex3D.cpp b/src/Nazara/Noise/Simplex3D.cpp deleted file mode 100644 index 5848f38ce..000000000 --- a/src/Nazara/Noise/Simplex3D.cpp +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Simplex3D::Simplex3D() - { - SkewCoeff3D = 1/3.f; - UnskewCoeff3D = 1/6.f; - - float grad3Temp[][3] = { - {1.f,1.f,0.f}, - {-1.f,1.f,0.f}, - {1.f,-1.f,0.f}, - {-1.f,-1.f,0.f}, - - {1.f,0.f,1.f}, - {-1.f,0.f,1.f}, - {1.f,0.f,-1.f}, - {-1.f,0.f,-1.f}, - - {0.f,1.f,1.f}, - {0.f,-1.f,1.f}, - {0.f,1.f,-1.f}, - {0.f,-1.f,-1.f} - }; - - for(int i(0) ; i < 12 ; ++i) - for(int j(0) ; j < 3 ; ++j) - gradient3[i][j] = grad3Temp[i][j]; - } - - Simplex3D::Simplex3D(unsigned int seed) : Simplex3D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Simplex3D::GetValue(float x, float y, float z, float resolution) - { - x *= resolution; - y *= resolution; - z *= resolution; - - sum = (x + y + z) * SkewCoeff3D; - skewedCubeOrigin.x = fastfloor(x + sum); - skewedCubeOrigin.y = fastfloor(y + sum); - skewedCubeOrigin.z = fastfloor(z + sum); - - sum = (skewedCubeOrigin.x + skewedCubeOrigin.y + skewedCubeOrigin.z) * UnskewCoeff3D; - unskewedCubeOrigin.x = skewedCubeOrigin.x - sum; - unskewedCubeOrigin.y = skewedCubeOrigin.y - sum; - unskewedCubeOrigin.z = skewedCubeOrigin.z - sum; - - unskewedDistToOrigin.x = x - unskewedCubeOrigin.x; - unskewedDistToOrigin.y = y - unskewedCubeOrigin.y; - unskewedDistToOrigin.z = z - unskewedCubeOrigin.z; - - if(unskewedDistToOrigin.x >= unskewedDistToOrigin.y) - { - if(unskewedDistToOrigin.y >= unskewedDistToOrigin.z) - { - off1.x = 1; - off1.y = 0; - off1.z = 0; - off2.x = 1; - off2.y = 1; - off2.z = 0; - } - else if(unskewedDistToOrigin.x >= unskewedDistToOrigin.z) - { - off1.x = 1; - off1.y = 0; - off1.z = 0; - off2.x = 1; - off2.y = 0; - off2.z = 1; - } - else - { - off1.x = 0; - off1.y = 0; - off1.z = 1; - off2.x = 1; - off2.y = 0; - off2.z = 1; - } - } - else - { - if(unskewedDistToOrigin.y < unskewedDistToOrigin.z) - { - off1.x = 0; - off1.y = 0; - off1.z = 1; - off2.x = 0; - off2.y = 1; - off2.z = 1; - } - else if(unskewedDistToOrigin.x < unskewedDistToOrigin.z) - { - off1.x = 0; - off1.y = 1; - off1.z = 0; - off2.x = 0; - off2.y = 1; - off2.z = 1; - } - else - { - off1.x = 0; - off1.y = 1; - off1.z = 0; - off2.x = 1; - off2.y = 1; - off2.z = 0; - } - } - - d1 = unskewedDistToOrigin; - - d2.x = d1.x - off1.x + UnskewCoeff3D; - d2.y = d1.y - off1.y + UnskewCoeff3D; - d2.z = d1.z - off1.z + UnskewCoeff3D; - - d3.x = d1.x - off2.x + 2.f*UnskewCoeff3D; - d3.y = d1.y - off2.y + 2.f*UnskewCoeff3D; - d3.z = d1.z - off2.z + 2.f*UnskewCoeff3D; - - d4.x = d1.x - 1.f + 3.f*UnskewCoeff3D; - d4.y = d1.y - 1.f + 3.f*UnskewCoeff3D; - d4.z = d1.z - 1.f + 3.f*UnskewCoeff3D; - - ii = skewedCubeOrigin.x & 255; - jj = skewedCubeOrigin.y & 255; - kk = skewedCubeOrigin.z & 255; - - gi0 = perm[ii + perm[jj + perm[kk ]]] % 12; - gi1 = perm[ii + off1.x + perm[jj + off1.y + perm[kk + off1.z]]] % 12; - gi2 = perm[ii + off2.x + perm[jj + off2.y + perm[kk + off2.z]]] % 12; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 ]]] % 12; - - c1 = 0.6f - d1.x * d1.x - d1.y * d1.y - d1.z * d1.z; - c2 = 0.6f - d2.x * d2.x - d2.y * d2.y - d2.z * d2.z; - c3 = 0.6f - d3.x * d3.x - d3.y * d3.y - d3.z * d3.z; - c4 = 0.6f - d4.x * d4.x - d4.y * d4.y - d4.z * d4.z; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient3[gi0][0] * d1.x + gradient3[gi0][1] * d1.y + gradient3[gi0][2] * d1.z); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient3[gi1][0] * d2.x + gradient3[gi1][1] * d2.y + gradient3[gi1][2] * d2.z); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient3[gi2][0] * d3.x + gradient3[gi2][1] * d3.y + gradient3[gi2][2] * d3.z); - - if(c4 < 0) - n4 = 0; - else - n4 = c4*c4*c4*c4*(gradient3[gi3][0] * d4.x + gradient3[gi3][1] * d4.y + gradient3[gi3][2] * d4.z); - - return (n1+n2+n3+n4)*32; - } -} diff --git a/src/Nazara/Noise/Simplex4D.cpp b/src/Nazara/Noise/Simplex4D.cpp deleted file mode 100644 index b515d5958..000000000 --- a/src/Nazara/Noise/Simplex4D.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (C) 2015 Rémi Bèges -// This file is part of the "Nazara Engine - Noise module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - Simplex4D::Simplex4D() - { - SkewCoeff4D = (std::sqrt(5.f) - 1.f)/4.f; - UnskewCoeff4D = (5.f - std::sqrt(5.f))/20.f; - - int lookupTemp4D[][4] = - { - {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, - {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, - {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, - {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0} - }; - - for(int i(0) ; i < 64 ; ++i) - for(int j(0) ; j < 4 ; ++j) - lookupTable4D[i][j] = lookupTemp4D[i][j]; - - float grad4Temp[][4] = - { - {0.f,1.f,1.f,1.f}, {0.f,1.f,1.f,-1.f}, {0.f,1.f,-1.f,1.f}, {0.f,1.f,-1.f,-1.f}, - {0.f,-1.f,1.f,1.f},{0.f,-1.f,1.f,-1.f},{0.f,-1.f,-1.f,1.f},{0.f,-1.f,-1.f,-1.f}, - {1.f,0.f,1.f,1.f}, {1.f,0.f,1.f,-1.f}, {1.f,0.f,-1.f,1.f}, {1.f,0.f,-1.f,-1.f}, - {-1.f,0.f,1.f,1.f},{-1.f,0.f,1.f,-1.f},{-1.f,0.f,-1.f,1.f},{-1.f,0.f,-1.f,-1.f}, - {1.f,1.f,0.f,1.f}, {1.f,1.f,0.f,-1.f}, {1.f,-1.f,0.f,1.f}, {1.f,-1.f,0.f,-1.f}, - {-1.f,1.f,0.f,1.f},{-1.f,1.f,0.f,-1.f},{-1.f,-1.f,0.f,1.f},{-1.f,-1.f,0.f,-1.f}, - {1.f,1.f,1.f,0.f}, {1.f,1.f,-1.f,0.f}, {1.f,-1.f,1.f,0.f}, {1.f,-1.f,-1.f,0.f}, - {-1.f,1.f,1.f,0.f},{-1.f,1.f,-1.f,0.f},{-1.f,-1.f,1.f,0.f},{-1.f,-1.f,-1.f,0.f} - }; - - for(int i(0) ; i < 32 ; ++i) - for(int j(0) ; j < 4 ; ++j) - gradient4[i][j] = grad4Temp[i][j]; - } - - Simplex4D::Simplex4D(unsigned int seed) : Simplex4D() - { - this->SetNewSeed(seed); - this->ShufflePermutationTable(); - } - - float Simplex4D::GetValue(float x, float y, float z, float w, float resolution) - { - x *= resolution; - y *= resolution; - z *= resolution; - w *= resolution; - - sum = (x + y + z + w) * SkewCoeff4D; - skewedCubeOrigin.x = fastfloor(x + sum); - skewedCubeOrigin.y = fastfloor(y + sum); - skewedCubeOrigin.z = fastfloor(z + sum); - skewedCubeOrigin.w = fastfloor(w + sum); - - sum = (skewedCubeOrigin.x + skewedCubeOrigin.y + skewedCubeOrigin.z + skewedCubeOrigin.w) * UnskewCoeff4D; - unskewedCubeOrigin.x = skewedCubeOrigin.x - sum; - unskewedCubeOrigin.y = skewedCubeOrigin.y - sum; - unskewedCubeOrigin.z = skewedCubeOrigin.z - sum; - unskewedCubeOrigin.w = skewedCubeOrigin.w - sum; - - unskewedDistToOrigin.x = x - unskewedCubeOrigin.x; - unskewedDistToOrigin.y = y - unskewedCubeOrigin.y; - unskewedDistToOrigin.z = z - unskewedCubeOrigin.z; - unskewedDistToOrigin.w = w - unskewedCubeOrigin.w; - - c1 = (unskewedDistToOrigin.x > unskewedDistToOrigin.y) ? 32 : 0; - c2 = (unskewedDistToOrigin.x > unskewedDistToOrigin.z) ? 16 : 0; - c3 = (unskewedDistToOrigin.y > unskewedDistToOrigin.z) ? 8 : 0; - c4 = (unskewedDistToOrigin.x > unskewedDistToOrigin.w) ? 4 : 0; - c5 = (unskewedDistToOrigin.y > unskewedDistToOrigin.w) ? 2 : 0; - c6 = (unskewedDistToOrigin.z > unskewedDistToOrigin.w) ? 1 : 0; - c = c1 + c2 + c3 + c4 + c5 + c6; - - off1.x = lookupTable4D[c][0] >= 3 ? 1 : 0; - off1.y = lookupTable4D[c][1] >= 3 ? 1 : 0; - off1.z = lookupTable4D[c][2] >= 3 ? 1 : 0; - off1.w = lookupTable4D[c][3] >= 3 ? 1 : 0; - - off2.x = lookupTable4D[c][0] >= 2 ? 1 : 0; - off2.y = lookupTable4D[c][1] >= 2 ? 1 : 0; - off2.z = lookupTable4D[c][2] >= 2 ? 1 : 0; - off2.w = lookupTable4D[c][3] >= 2 ? 1 : 0; - - off3.x = lookupTable4D[c][0] >= 1 ? 1 : 0; - off3.y = lookupTable4D[c][1] >= 1 ? 1 : 0; - off3.z = lookupTable4D[c][2] >= 1 ? 1 : 0; - off3.w = lookupTable4D[c][3] >= 1 ? 1 : 0; - - d1 = unskewedDistToOrigin; - - d2.x = d1.x - off1.x + UnskewCoeff4D; - d2.y = d1.y - off1.y + UnskewCoeff4D; - d2.z = d1.z - off1.z + UnskewCoeff4D; - d2.w = d1.w - off1.w + UnskewCoeff4D; - - d3.x = d1.x - off2.x + 2.f*UnskewCoeff4D; - d3.y = d1.y - off2.y + 2.f*UnskewCoeff4D; - d3.z = d1.z - off2.z + 2.f*UnskewCoeff4D; - d3.w = d1.w - off2.w + 2.f*UnskewCoeff4D; - - d4.x = d1.x - off3.x + 3.f*UnskewCoeff4D; - d4.y = d1.y - off3.y + 3.f*UnskewCoeff4D; - d4.z = d1.z - off3.z + 3.f*UnskewCoeff4D; - d4.w = d1.w - off3.w + 3.f*UnskewCoeff4D; - - d5.x = d1.x - 1.f + 4*UnskewCoeff4D; - d5.y = d1.y - 1.f + 4*UnskewCoeff4D; - d5.z = d1.z - 1.f + 4*UnskewCoeff4D; - d5.w = d1.w - 1.f + 4*UnskewCoeff4D; - - ii = skewedCubeOrigin.x & 255; - jj = skewedCubeOrigin.y & 255; - kk = skewedCubeOrigin.z & 255; - ll = skewedCubeOrigin.w & 255; - - gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; - gi1 = perm[ii + off1.x + perm[jj + off1.y + perm[kk + off1.z + perm[ll + off1.w]]]] & 31; - gi2 = perm[ii + off2.x + perm[jj + off2.y + perm[kk + off2.z + perm[ll + off2.w]]]] & 31; - gi3 = perm[ii + off3.x + perm[jj + off3.y + perm[kk + off3.z + perm[ll + off3.w]]]] & 31; - gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32; - - c1 = 0.6f - d1.x*d1.x - d1.y*d1.y - d1.z*d1.z - d1.w*d1.w; - c2 = 0.6f - d2.x*d2.x - d2.y*d2.y - d2.z*d2.z - d2.w*d2.w; - c3 = 0.6f - d3.x*d3.x - d3.y*d3.y - d3.z*d3.z - d3.w*d3.w; - c4 = 0.6f - d4.x*d4.x - d4.y*d4.y - d4.z*d4.z - d4.w*d4.w; - c5 = 0.6f - d5.x*d5.x - d5.y*d5.y - d5.z*d5.z - d5.w*d5.w; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient4[gi0][0]*d1.x + gradient4[gi0][1]*d1.y + gradient4[gi0][2]*d1.z + gradient4[gi0][3]*d1.w); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient4[gi1][0]*d2.x + gradient4[gi1][1]*d2.y + gradient4[gi1][2]*d2.z + gradient4[gi1][3]*d2.w); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient4[gi2][0]*d3.x + gradient4[gi2][1]*d3.y + gradient4[gi2][2]*d3.z + gradient4[gi2][3]*d3.w); - - if(c4 < 0) - n4 = 0; - else - n4 = c4*c4*c4*c4*(gradient4[gi3][0]*d4.x + gradient4[gi3][1]*d4.y + gradient4[gi3][2]*d4.z + gradient4[gi3][3]*d4.w); - - if(c5 < 0) - n5 = 0; - else - n5 = c5*c5*c5*c5*(gradient4[gi4][0]*d5.x + gradient4[gi4][1]*d5.y + gradient4[gi4][2]*d5.z + gradient4[gi4][3]*d5.w); - - return (n1+n2+n3+n4+n5)*27.f; - } -} diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp new file mode 100644 index 000000000..603820706 --- /dev/null +++ b/src/Nazara/Noise/Worley.cpp @@ -0,0 +1,171 @@ +// Copyright (C) 2016 Rémi Bèges +// This file is part of the "Nazara Engine - Noise module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + Worley::Worley() : + scales{ + 1.f / std::sqrt(2), + 0.5f / std::sqrt(2), + 0.5f / std::sqrt(2), + 0.5f / std::sqrt(2) + } + { + function = WorleyFunction_F1; + } + + Worley::Worley(unsigned int seed) : Worley() + { + SetSeed(seed); + Shuffle(); + } + + void Worley::Set(WorleyFunction func) + { + function = func; + } + + float Worley::Get(std::initializer_list coordinates, float scale) const + { + switch(coordinates.size()) + { + case 2: + return this->_2D(coordinates,scale); + case 3: + return this->_3D(coordinates,scale); + case 4: + return this->_4D(coordinates,scale); + default: + throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + } + } + + float Worley::_2D(std::initializer_list coordinates, float scale) const + { + std::map featurePoints; + std::map::iterator it; + + float xc, yc; + int x0, y0; + float fractx, fracty; + + std::initializer_list::const_iterator c = coordinates.begin(); + + xc = *(c ) * scale; + yc = *(++c) * scale; + + x0 = fastfloor(xc); + y0 = fastfloor(yc); + + fractx = xc - static_cast(x0); + fracty = yc - static_cast(y0); + + featurePoints.clear(); + + _SquareTest(x0,y0,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fractx < it->first) + _SquareTest(x0 - 1,y0,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fractx < it->first) + _SquareTest(x0 + 1,y0,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fracty < it->first) + _SquareTest(x0,y0 - 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fracty < it->first) + _SquareTest(x0,y0 + 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fractx < it->first && + fracty < it->first) + _SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fractx < it->first && + fracty < it->first) + _SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(fractx < it->first && + 1.f - fracty < it->first) + _SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + if(1.f - fractx < it->first && + 1.f - fracty < it->first) + _SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); + + it = featurePoints.begin(); + std::advance(it,function); + + return it->first * scales[function]; + } + + float Worley::_3D(std::initializer_list coordinates, float scale) const + { + throw std::runtime_error("Worley 3D not available yet."); + } + + float Worley::_4D(std::initializer_list coordinates, float scale) const + { + throw std::runtime_error("Worley 4D not available yet."); + } + + + void Worley::_SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const + { + int ii = xi & 255; + int jj = yi & 255; + + int seed = perm[ii + perm[jj]]; + + //On initialise notre rng avec seed + std::minstd_rand0 randomNumberGenerator(seed); + + //On prend un nombre de points à déterminer dans le cube, compris entre 1 et 8 + unsigned int m = (seed & 7) + 1; + + //On calcule les emplacements des différents points + for(unsigned int i(0) ; i < m ; ++i) + { + Nz::Vector2f featurePoint; + featurePoint.x = (randomNumberGenerator() & 1023) / 1023.f + static_cast(xi); + featurePoint.y = (randomNumberGenerator() & 1023) / 1023.f + static_cast(yi); + + // TODO : Check order is correct + float distance = std::sqrt((featurePoint.x - x) * (featurePoint.x - x) + + (featurePoint.y - y) * (featurePoint.y - y)); + + //Insertion dans la liste triée + featurePoints[distance] = featurePoint; + } + } +} From 59706820354191edc7f5941f2f9a4bd711fdf36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 18 Jun 2016 12:36:20 +0200 Subject: [PATCH 108/383] Noise: First pass of refactoring Former-commit-id: 77de49ee01fea466cb97b22771e4c625389fd95c [formerly edce9427bc009c8ea6a6df35d9ce134a83ab985c] Former-commit-id: 76227519c8be75a45f6f65250a0870c2eb866953 --- include/Nazara/Math/Algorithm.hpp | 5 + include/Nazara/Noise/FBM.hpp | 4 +- include/Nazara/Noise/HybridMultiFractal.hpp | 4 +- include/Nazara/Noise/MixerBase.hpp | 4 + include/Nazara/Noise/NoiseBase.hpp | 17 +- include/Nazara/Noise/Perlin.hpp | 20 +- include/Nazara/Noise/Simplex.hpp | 27 +- include/Nazara/Noise/Worley.hpp | 23 +- src/Nazara/Noise/FBM.cpp | 45 ++- src/Nazara/Noise/HybridMultiFractal.cpp | 64 +++- src/Nazara/Noise/NoiseBase.cpp | 62 ++-- src/Nazara/Noise/Perlin.cpp | 239 +++++------- src/Nazara/Noise/Simplex.cpp | 388 ++++++++------------ src/Nazara/Noise/Worley.cpp | 118 +++--- 14 files changed, 485 insertions(+), 535 deletions(-) diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp index 74cc45593..45281bb50 100644 --- a/include/Nazara/Math/Algorithm.hpp +++ b/include/Nazara/Math/Algorithm.hpp @@ -1,3 +1,4 @@ + // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -28,6 +29,10 @@ #define M_SQRT3 1.7320508075688772935274463 #endif +#ifndef M_SQRT5 +#define M_SQRT5 2.23606797749979 +#endif + namespace Nz { template /*constexpr*/ T Approach(T value, T objective, T increment); diff --git a/include/Nazara/Noise/FBM.hpp b/include/Nazara/Noise/FBM.hpp index ded4aa069..584fb3a10 100644 --- a/include/Nazara/Noise/FBM.hpp +++ b/include/Nazara/Noise/FBM.hpp @@ -18,7 +18,9 @@ namespace Nz FBM(const FBM&) = delete; ~FBM() = default; - float Get(std::initializer_list coordinates, float scale) const; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; FBM& operator=(const FBM&) = delete; diff --git a/include/Nazara/Noise/HybridMultiFractal.hpp b/include/Nazara/Noise/HybridMultiFractal.hpp index a211a4767..c73dafc73 100644 --- a/include/Nazara/Noise/HybridMultiFractal.hpp +++ b/include/Nazara/Noise/HybridMultiFractal.hpp @@ -17,7 +17,9 @@ namespace Nz HybridMultiFractal(const HybridMultiFractal&) = delete; ~HybridMultiFractal() = default; - float Get(std::initializer_list coordinates, float scale) const; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; HybridMultiFractal& operator=(const HybridMultiFractal&) = delete; diff --git a/include/Nazara/Noise/MixerBase.hpp b/include/Nazara/Noise/MixerBase.hpp index 3c7a131b0..8b7a99d56 100644 --- a/include/Nazara/Noise/MixerBase.hpp +++ b/include/Nazara/Noise/MixerBase.hpp @@ -17,6 +17,10 @@ namespace Nz MixerBase(); ~MixerBase() = default; + virtual float Get(float x, float y, float scale) const = 0; + virtual float Get(float x, float y, float z, float scale) const = 0; + virtual float Get(float x, float y, float z, float w, float scale) const = 0; + float GetHurstParameter() const; float GetLacunarity() const; float GetOctaveNumber() const; diff --git a/include/Nazara/Noise/NoiseBase.hpp b/include/Nazara/Noise/NoiseBase.hpp index 6a5c5c37f..f7f9eba09 100644 --- a/include/Nazara/Noise/NoiseBase.hpp +++ b/include/Nazara/Noise/NoiseBase.hpp @@ -6,7 +6,11 @@ #define NAZARA_NOISEBASE_HPP #include +#include +#include +#include #include +#include #include namespace Nz @@ -17,21 +21,26 @@ namespace Nz NoiseBase(unsigned int seed = 0); ~NoiseBase() = default; - virtual float Get(std::initializer_list coordinates, float scale) const = 0; + virtual float Get(float x, float y, float scale) const = 0; + virtual float Get(float x, float y, float z, float scale) const = 0; + virtual float Get(float x, float y, float z, float w, float scale) const = 0; float GetScale(); void SetScale(float scale); void SetSeed(unsigned int seed); void Shuffle(); - void Shuffle(unsigned int amount); protected: - unsigned int perm[512]; + std::array m_permutations; float m_scale; + static std::array s_gradients2; + static std::array s_gradients3; + static std::array s_gradients4; + private: - std::default_random_engine generator; + std::default_random_engine m_randomEngine; }; } diff --git a/include/Nazara/Noise/Perlin.hpp b/include/Nazara/Noise/Perlin.hpp index 058a3ada5..781d03148 100644 --- a/include/Nazara/Noise/Perlin.hpp +++ b/include/Nazara/Noise/Perlin.hpp @@ -15,21 +15,13 @@ namespace Nz class NAZARA_NOISE_API Perlin : public NoiseBase { public: - Perlin(); - Perlin(unsigned int seed); - ~Perlin() = default; + Perlin() = default; + Perlin(unsigned int seed); + ~Perlin() = default; - float Get(std::initializer_list coordinates, float scale) const; - - protected: - float _2D(std::initializer_list coordinates, float scale) const; - float _3D(std::initializer_list coordinates, float scale) const; - float _4D(std::initializer_list coordinates, float scale) const; - - private: - const float gradient2[8][2]; - const float gradient3[16][3]; - const float gradient4[32][4]; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; }; } diff --git a/include/Nazara/Noise/Simplex.hpp b/include/Nazara/Noise/Simplex.hpp index f131387b6..ae018f7bf 100644 --- a/include/Nazara/Noise/Simplex.hpp +++ b/include/Nazara/Noise/Simplex.hpp @@ -15,28 +15,13 @@ namespace Nz class NAZARA_NOISE_API Simplex : public NoiseBase { public: - Simplex(); - Simplex(unsigned int seed); - ~Simplex() = default; + Simplex() = default; + Simplex(unsigned int seed); + ~Simplex() = default; - float Get(std::initializer_list coordinates, float scale) const; - - protected: - float _2D(std::initializer_list coordinates, float scale) const; - float _3D(std::initializer_list coordinates, float scale) const; - float _4D(std::initializer_list coordinates, float scale) const; - - private: - const float gradient2[8][2]; - const float gradient3[16][3]; - const float gradient4[32][4]; - const float UnskewCoeff2D; - const float SkewCoeff2D; - const float UnskewCoeff3D; - const float SkewCoeff3D; - const float UnskewCoeff4D; - const float SkewCoeff4D; - const int lookupTable4D[64][4]; + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; }; } diff --git a/include/Nazara/Noise/Worley.hpp b/include/Nazara/Noise/Worley.hpp index 249da999f..6b9f21f73 100644 --- a/include/Nazara/Noise/Worley.hpp +++ b/include/Nazara/Noise/Worley.hpp @@ -18,23 +18,20 @@ namespace Nz class NAZARA_NOISE_API Worley : public NoiseBase { public: - Worley(); - Worley(unsigned int seed); - ~Worley() = default; + Worley(); + Worley(unsigned int seed); + ~Worley() = default; - void Set(WorleyFunction func); + float Get(float x, float y, float scale) const override; + float Get(float x, float y, float z, float scale) const override; + float Get(float x, float y, float z, float w, float scale) const override; - float Get(std::initializer_list coordinates, float scale) const; - - protected: - float _2D(std::initializer_list coordinates, float scale) const; - float _3D(std::initializer_list coordinates, float scale) const; - float _4D(std::initializer_list coordinates, float scale) const; - void _SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const; + void Set(WorleyFunction func); private: - const float scales[4]; - WorleyFunction function; + void SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const; + + WorleyFunction m_function; }; } diff --git a/src/Nazara/Noise/FBM.cpp b/src/Nazara/Noise/FBM.cpp index f61bf8f44..96126ec60 100644 --- a/src/Nazara/Noise/FBM.cpp +++ b/src/Nazara/Noise/FBM.cpp @@ -11,20 +11,51 @@ namespace Nz { } - float FBM::Get(std::initializer_list coordinates, float scale) const + ///TODO: Handle with variadic templates + float FBM::Get(float x, float y, float scale) const { - float value = 0.0; - - for(int i(0); i < m_octaves; ++i) + float value = 0.f; + for(int i = 0; i < m_octaves; ++i) { - value += m_source.Get(coordinates,scale) * m_exponent_array.at(i); + value += m_source.Get(x, y, scale) * m_exponent_array.at(i); scale *= m_lacunarity; } float remainder = m_octaves - static_cast(m_octaves); - if(std::fabs(remainder) > 0.01f) - value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + value += remainder * m_source.Get(x, y, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum; + } + + float FBM::Get(float x, float y, float z, float scale) const + { + float value = 0.f; + for(int i = 0; i < m_octaves; ++i) + { + value += m_source.Get(x, y, z, scale) * m_exponent_array.at(i); + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + if(std::fabs(remainder) > 0.01f) + value += remainder * m_source.Get(x, y, z, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum; + } + + float FBM::Get(float x, float y, float z, float w, float scale) const + { + float value = 0.f; + for(int i = 0; i < m_octaves; ++i) + { + value += m_source.Get(x, y, z, w, scale) * m_exponent_array.at(i); + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + if(std::fabs(remainder) > 0.01f) + value += remainder * m_source.Get(x, y, z, w, scale) * m_exponent_array.at(static_cast(m_octaves-1)); return value / m_sum; } diff --git a/src/Nazara/Noise/HybridMultiFractal.cpp b/src/Nazara/Noise/HybridMultiFractal.cpp index 3f20809d3..4278d23b2 100644 --- a/src/Nazara/Noise/HybridMultiFractal.cpp +++ b/src/Nazara/Noise/HybridMultiFractal.cpp @@ -12,10 +12,10 @@ namespace Nz { } - float HybridMultiFractal::Get(std::initializer_list coordinates, float scale) const + float HybridMultiFractal::Get(float x, float y, float scale) const { float offset = 1.0f; - float value = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(0); + float value = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(0); float weight = value; float signal = 0.f; @@ -26,7 +26,7 @@ namespace Nz if (weight > 1.f) weight = 1.f; - signal = (m_source.Get(coordinates,scale) + offset) * m_exponent_array.at(i); + signal = (m_source.Get(x, y, scale) + offset) * m_exponent_array.at(i); value += weight * signal; weight *= signal; scale *= m_lacunarity; @@ -35,7 +35,63 @@ namespace Nz float remainder = m_octaves - static_cast(m_octaves); if (remainder > 0.f) - value += remainder * m_source.Get(coordinates,scale) * m_exponent_array.at(static_cast(m_octaves-1)); + value += remainder * m_source.Get(x, y, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum - offset; + } + + float HybridMultiFractal::Get(float x, float y, float z, float scale) const + { + float offset = 1.0f; + float value = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(0); + float weight = value; + float signal = 0.f; + + scale *= m_lacunarity; + + for(int i(1) ; i < m_octaves; ++i) + { + if (weight > 1.f) + weight = 1.f; + + signal = (m_source.Get(x, y, z, scale) + offset) * m_exponent_array.at(i); + value += weight * signal; + weight *= signal; + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if (remainder > 0.f) + value += remainder * m_source.Get(x, y, z, scale) * m_exponent_array.at(static_cast(m_octaves-1)); + + return value / m_sum - offset; + } + + float HybridMultiFractal::Get(float x, float y, float z, float w, float scale) const + { + float offset = 1.0f; + float value = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(0); + float weight = value; + float signal = 0.f; + + scale *= m_lacunarity; + + for(int i(1) ; i < m_octaves; ++i) + { + if (weight > 1.f) + weight = 1.f; + + signal = (m_source.Get(x, y, z, w, scale) + offset) * m_exponent_array.at(i); + value += weight * signal; + weight *= signal; + scale *= m_lacunarity; + } + + float remainder = m_octaves - static_cast(m_octaves); + + if (remainder > 0.f) + value += remainder * m_source.Get(x, y, z, w, scale) * m_exponent_array.at(static_cast(m_octaves-1)); return value / m_sum - offset; } diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp index 0cbee9eec..fa5a2c92f 100644 --- a/src/Nazara/Noise/NoiseBase.cpp +++ b/src/Nazara/Noise/NoiseBase.cpp @@ -7,13 +7,13 @@ namespace Nz { - NoiseBase::NoiseBase(unsigned int seed) + NoiseBase::NoiseBase(unsigned int seed) : + m_scale(0.05f) { SetSeed(seed); - m_scale = 0.05f; - for(unsigned int i(0) ; i < 512; ++i) - perm[i] = i & 255; + // Fill permutations with initial values + std::iota(m_permutations.begin(), m_permutations.begin() + 256, 0); } float NoiseBase::GetScale() @@ -28,32 +28,46 @@ namespace Nz void NoiseBase::SetSeed(unsigned int seed) { - generator.seed(seed); + m_randomEngine.seed(seed); } void NoiseBase::Shuffle() { - int xchanger; - unsigned int ncase; + std::shuffle(m_permutations.begin(), m_permutations.begin() + 256, m_randomEngine); - for(unsigned int i(0) ; i < 256 ; i++) - perm[i] = i; - - for (unsigned int i(0); i < 256 ; ++i) - { - ncase = generator() & 255; - xchanger = perm[i]; - perm[i] = perm[ncase]; - perm[ncase] = xchanger; - } - - for(unsigned int i(256) ; i < 512; ++i) - perm[i] = perm[i & 255]; + for(std::size_t i = 1; i < (m_permutations.size() / 256); ++i) + std::copy(m_permutations.begin(), m_permutations.begin() + 256, m_permutations.begin() + 256 * i); } - void NoiseBase::Shuffle(unsigned int amount) + std::array NoiseBase::s_gradients2 = { - for(unsigned int j(0) ; j < amount ; ++j) - Shuffle(); - } + { + {1.f, 1.f}, {-1.f, 1.f}, {1.f, -1.f}, {-1.f, -1.f}, + {1.f, 0.f}, {-1.f, 0.f}, {0.f, 1.f}, { 0.f, -1.f} + } + }; + + std::array NoiseBase::s_gradients3 = + { + { + {1.f,1.f,0.f}, {-1.f, 1.f, 0.f}, {1.f, -1.f, 0.f}, {-1.f, -1.f, 0.f}, + {1.f,0.f,1.f}, {-1.f, 0.f, 1.f}, {1.f, 0.f, -1.f}, {-1.f, 0.f, -1.f}, + {0.f,1.f,1.f}, { 0.f, -1.f, 1.f}, {0.f, 1.f, -1.f}, {0.f, -1.f, -1.f}, + {1.f,1.f,0.f}, {-1.f, 1.f, 0.f}, {0.f, -1.f, 1.f}, {0.f, -1.f, -1.f} + } + }; + + std::array NoiseBase::s_gradients4 = + { + { + {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, + {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, + {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, + {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, + {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, + {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, + {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, + {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} + } + }; } diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp index f184702de..e6440eb3d 100644 --- a/src/Nazara/Noise/Perlin.cpp +++ b/src/Nazara/Noise/Perlin.cpp @@ -10,68 +10,27 @@ namespace Nz { - Perlin::Perlin() : - gradient2{ - {1.f,1.f},{-1.f,1.f},{1.f,-1.f},{-1.f,-1.f}, - {1.f,0.f},{-1.f,0.f},{0.f,1.f},{0.f,-1.f} - }, - gradient3{ - {1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}, - {1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1}, - {0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}, - {1,1,0},{-1,1,0},{0,-1,1},{0,-1,-1} - }, - gradient4{ - {0,1,1,1}, {0,1,1,-1}, {0,1,-1,1}, {0,1,-1,-1}, - {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, - {1,0,1,1}, {1,0,1,-1}, {1,0,-1,1}, {1,0,-1,-1}, - {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, - {1,1,0,1}, {1,1,0,-1}, {1,-1,0,1}, {1,-1,0,-1}, - {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, - {1,1,1,0}, {1,1,-1,0}, {1,-1,1,0}, {1,-1,-1,0}, - {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} - } - { - - } - - Perlin::Perlin(unsigned int seed) : Perlin() + Perlin::Perlin(unsigned int seed) : + Perlin() { SetSeed(seed); Shuffle(); } - float Perlin::Get(std::initializer_list coordinates, float scale) const + float Perlin::Get(float x, float y, float scale) const { - switch(coordinates.size()) - { - case 2: - return this->_2D(coordinates,scale); - case 3: - return this->_3D(coordinates,scale); - case 4: - return this->_4D(coordinates,scale); - default: - throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); - } - } + float xc, yc; + int x0, y0; + int gi0,gi1,gi2,gi3; + int ii, jj; - float Perlin::_2D(std::initializer_list coordinates, float scale) const - { - thread_local float xc, yc; - thread_local int x0, y0; - thread_local int gi0,gi1,gi2,gi3; - thread_local int ii, jj; + float s,t,u,v; + float Cx,Cy; + float Li1, Li2; + float tempx,tempy; - thread_local float s,t,u,v; - thread_local float Cx,Cy; - thread_local float Li1, Li2; - thread_local float tempx,tempy; - - std::initializer_list::const_iterator it = coordinates.begin(); - - xc = *(it ) * scale; - yc = *(++it) * scale; + xc = x * scale; + yc = y * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -79,10 +38,10 @@ namespace Nz ii = x0 & 255; jj = y0 & 255; - gi0 = perm[ii + perm[jj]] & 7; - gi1 = perm[ii + 1 + perm[jj]] & 7; - gi2 = perm[ii + perm[jj + 1]] & 7; - gi3 = perm[ii + 1 + perm[jj + 1]] & 7; + gi0 = m_permutations[ii + m_permutations[jj]] & 7; + gi1 = m_permutations[ii + 1 + m_permutations[jj]] & 7; + gi2 = m_permutations[ii + m_permutations[jj + 1]] & 7; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1]] & 7; tempx = xc - x0; tempy = yc - y0; @@ -90,16 +49,16 @@ namespace Nz Cx = tempx * tempx * tempx * (tempx * (tempx * 6 - 15) + 10); Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); - s = gradient2[gi0][0]*tempx + gradient2[gi0][1]*tempy; + s = s_gradients2[gi0][0]*tempx + s_gradients2[gi0][1]*tempy; tempx = xc - (x0 + 1); - t = gradient2[gi1][0]*tempx + gradient2[gi1][1]*tempy; + t = s_gradients2[gi1][0]*tempx + s_gradients2[gi1][1]*tempy; tempy = yc - (y0 + 1); - v = gradient2[gi3][0]*tempx + gradient2[gi3][1]*tempy; + v = s_gradients2[gi3][0]*tempx + s_gradients2[gi3][1]*tempy; tempx = xc - x0; - u = gradient2[gi2][0]*tempx + gradient2[gi2][1]*tempy; + u = s_gradients2[gi2][0]*tempx + s_gradients2[gi2][1]*tempy; Li1 = s + Cx*(t-s); Li2 = u + Cx*(v-u); @@ -107,26 +66,24 @@ namespace Nz return Li1 + Cy*(Li2-Li1); } - float Perlin::_3D(std::initializer_list coordinates, float scale) const + float Perlin::Get(float x, float y, float z, float scale) const { - thread_local float xc, yc, zc; - thread_local int x0, y0, z0; - thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; - thread_local int ii, jj, kk; + float xc, yc, zc; + int x0, y0, z0; + int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7; + int ii, jj, kk; - thread_local float Li1,Li2,Li3,Li4,Li5,Li6; - thread_local float s[2],t[2],u[2],v[2]; - thread_local float Cx,Cy,Cz; - thread_local float nx,ny,nz; + float Li1,Li2,Li3,Li4,Li5,Li6; + float s[2],t[2],u[2],v[2]; + float Cx,Cy,Cz; + float nx,ny,nz; - thread_local float tmp; - thread_local float tempx,tempy,tempz; + float tmp; + float tempx,tempy,tempz; - std::initializer_list::const_iterator it = coordinates.begin(); - - xc = *(it ) * scale; - yc = *(++it) * scale; - zc = *(++it) * scale; + xc = x * scale; + yc = y * scale; + zc = z * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -136,15 +93,15 @@ namespace Nz jj = y0 & 255; kk = z0 & 255; - gi0 = perm[ii + perm[jj + perm[kk]]] & 15; - gi1 = perm[ii + 1 + perm[jj + perm[kk]]] & 15; - gi2 = perm[ii + perm[jj + 1 + perm[kk]]] & 15; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk]]] & 15; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk]]] & 15; + gi1 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk]]] & 15; + gi2 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk]]] & 15; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk]]] & 15; - gi4 = perm[ii + perm[jj + perm[kk + 1]]] & 15; - gi5 = perm[ii + 1 + perm[jj + perm[kk + 1]]] & 15; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1]]] & 15; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1]]] & 15; + gi4 = m_permutations[ii + m_permutations[jj + m_permutations[kk + 1]]] & 15; + gi5 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + 1]]] & 15; + gi6 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1]]] & 15; + gi7 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1]]] & 15; tempx = xc - x0; tempy = yc - y0; @@ -154,29 +111,29 @@ namespace Nz Cy = tempy * tempy * tempy * (tempy * (tempy * 6 - 15) + 10); Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); - s[0] = gradient3[gi0][0]*tempx + gradient3[gi0][1]*tempy + gradient3[gi0][2]*tempz; + s[0] = s_gradients3[gi0][0]*tempx + s_gradients3[gi0][1]*tempy + s_gradients3[gi0][2]*tempz; tempx = xc - (x0 + 1); - t[0] = gradient3[gi1][0]*tempx + gradient3[gi1][1]*tempy + gradient3[gi1][2]*tempz; + t[0] = s_gradients3[gi1][0]*tempx + s_gradients3[gi1][1]*tempy + s_gradients3[gi1][2]*tempz; tempy = yc - (y0 + 1); - v[0] = gradient3[gi3][0]*tempx + gradient3[gi3][1]*tempy + gradient3[gi3][2]*tempz; + v[0] = s_gradients3[gi3][0]*tempx + s_gradients3[gi3][1]*tempy + s_gradients3[gi3][2]*tempz; tempx = xc - x0; - u[0] = gradient3[gi2][0]*tempx + gradient3[gi2][1]*tempy + gradient3[gi2][2]*tempz; + u[0] = s_gradients3[gi2][0]*tempx + s_gradients3[gi2][1]*tempy + s_gradients3[gi2][2]*tempz; tempy = yc - y0; tempz = zc - (z0 + 1); - s[1] = gradient3[gi4][0]*tempx + gradient3[gi4][1]*tempy + gradient3[gi4][2]*tempz; + s[1] = s_gradients3[gi4][0]*tempx + s_gradients3[gi4][1]*tempy + s_gradients3[gi4][2]*tempz; tempx = xc - (x0 + 1); - t[1] = gradient3[gi5][0]*tempx + gradient3[gi5][1]*tempy + gradient3[gi5][2]*tempz; + t[1] = s_gradients3[gi5][0]*tempx + s_gradients3[gi5][1]*tempy + s_gradients3[gi5][2]*tempz; tempy = yc - (y0 + 1); - v[1] = gradient3[gi7][0]*tempx + gradient3[gi7][1]*tempy + gradient3[gi7][2]*tempz; + v[1] = s_gradients3[gi7][0]*tempx + s_gradients3[gi7][1]*tempy + s_gradients3[gi7][2]*tempz; tempx = xc - x0; - u[1] = gradient3[gi6][0]*tempx + gradient3[gi6][1]*tempy + gradient3[gi6][2]*tempz; + u[1] = s_gradients3[gi6][0]*tempx + s_gradients3[gi6][1]*tempy + s_gradients3[gi6][2]*tempz; Li1 = s[0] + Cx*(t[0]-s[0]); Li2 = u[0] + Cx*(v[0]-u[0]); @@ -189,26 +146,24 @@ namespace Nz return Li5 + Cz * (Li6-Li5); } - float Perlin::_4D(std::initializer_list coordinates, float scale) const + float Perlin::Get(float x, float y, float z, float w, float scale) const { - thread_local float xc,yc,zc,wc; - thread_local int x0,y0,z0,w0; - thread_local int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; - thread_local int ii,jj,kk,ll; + float xc,yc,zc,wc; + int x0,y0,z0,w0; + int gi0,gi1,gi2,gi3,gi4,gi5,gi6,gi7,gi8,gi9,gi10,gi11,gi12,gi13,gi14,gi15; + int ii,jj,kk,ll; - thread_local float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; - thread_local float s[4],t[4],u[4],v[4]; - thread_local float Cx,Cy,Cz,Cw; + float Li1,Li2,Li3,Li4,Li5,Li6,Li7,Li8,Li9,Li10,Li11,Li12,Li13,Li14; + float s[4],t[4],u[4],v[4]; + float Cx,Cy,Cz,Cw; - thread_local float tmp; - thread_local float tempx,tempy,tempz,tempw; + float tmp; + float tempx,tempy,tempz,tempw; - std::initializer_list::const_iterator it = coordinates.begin(); - - xc = *(it ) * scale; - yc = *(++it) * scale; - zc = *(++it) * scale; - wc = *(++it) * scale; + xc = x * scale; + yc = y * scale; + zc = z * scale; + wc = w * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -220,25 +175,25 @@ namespace Nz kk = z0 & 255; ll = w0 & 255; - gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] & 31; - gi1 = perm[ii + 1 + perm[jj + perm[kk + perm[ll]]]] & 31; - gi2 = perm[ii + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll]]]] & 31; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll]]]] & 31; + gi1 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + m_permutations[ll]]]] & 31; + gi2 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll]]]] & 31; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll]]]] & 31; - gi4 = perm[ii + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi5 = perm[ii + 1 + perm[jj + + perm[kk + 1 + perm[ll]]]] & 31; - gi6 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; - gi7 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll]]]] & 31; + gi4 = m_permutations[ii + m_permutations[jj + + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; + gi5 = m_permutations[ii + 1 + m_permutations[jj + + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; + gi6 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; + gi7 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll]]]] & 31; - gi8 = perm[ii + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi9 = perm[ii + 1 + perm[jj + perm[kk + perm[ll + 1]]]] & 31; - gi10 = perm[ii + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; - gi11 = perm[ii + 1 + perm[jj + 1 + perm[kk + perm[ll + 1]]]] & 31; + gi8 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll + 1]]]] & 31; + gi9 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + m_permutations[ll + 1]]]] & 31; + gi10 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll + 1]]]] & 31; + gi11 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + m_permutations[ll + 1]]]] & 31; - gi12 = perm[ii + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi13 = perm[ii + 1 + perm[jj + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi14 = perm[ii + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; - gi15 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] & 31; + gi12 = m_permutations[ii + m_permutations[jj + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; + gi13 = m_permutations[ii + 1 + m_permutations[jj + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; + gi14 = m_permutations[ii + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; + gi15 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1]]]] & 31; tempx = xc - x0; tempy = yc - y0; @@ -250,58 +205,58 @@ namespace Nz Cz = tempz * tempz * tempz * (tempz * (tempz * 6 - 15) + 10); Cw = tempw * tempw * tempw * (tempw * (tempw * 6 - 15) + 10); - s[0] = gradient4[gi0][0]*tempx + gradient4[gi0][1]*tempy + gradient4[gi0][2]*tempz + gradient4[gi0][3]*tempw; + s[0] = s_gradients4[gi0][0]*tempx + s_gradients4[gi0][1]*tempy + s_gradients4[gi0][2]*tempz + s_gradients4[gi0][3]*tempw; tempx = xc - (x0+1); - t[0] = gradient4[gi1][0]*tempx + gradient4[gi1][1]*tempy + gradient4[gi1][2]*tempz + gradient4[gi1][3]*tempw; + t[0] = s_gradients4[gi1][0]*tempx + s_gradients4[gi1][1]*tempy + s_gradients4[gi1][2]*tempz + s_gradients4[gi1][3]*tempw; tempy = yc - (y0+1); - v[0] = gradient4[gi3][0]*tempx + gradient4[gi3][1]*tempy + gradient4[gi3][2]*tempz + gradient4[gi3][3]*tempw; + v[0] = s_gradients4[gi3][0]*tempx + s_gradients4[gi3][1]*tempy + s_gradients4[gi3][2]*tempz + s_gradients4[gi3][3]*tempw; tempx = xc - x0; - u[0] = gradient4[gi2][0]*tempx + gradient4[gi2][1]*tempy + gradient4[gi2][2]*tempz + gradient4[gi2][3]*tempw; + u[0] = s_gradients4[gi2][0]*tempx + s_gradients4[gi2][1]*tempy + s_gradients4[gi2][2]*tempz + s_gradients4[gi2][3]*tempw; tempy = yc - y0; tempz = zc - (z0+1); - s[1] = gradient4[gi4][0]*tempx + gradient4[gi4][1]*tempy + gradient4[gi4][2]*tempz + gradient4[gi4][3]*tempw; + s[1] = s_gradients4[gi4][0]*tempx + s_gradients4[gi4][1]*tempy + s_gradients4[gi4][2]*tempz + s_gradients4[gi4][3]*tempw; tempx = xc - (x0+1); - t[1] = gradient4[gi5][0]*tempx + gradient4[gi5][1]*tempy + gradient4[gi5][2]*tempz + gradient4[gi5][3]*tempw; + t[1] = s_gradients4[gi5][0]*tempx + s_gradients4[gi5][1]*tempy + s_gradients4[gi5][2]*tempz + s_gradients4[gi5][3]*tempw; tempy = yc - (y0+1); - v[1] = gradient4[gi7][0]*tempx + gradient4[gi7][1]*tempy + gradient4[gi7][2]*tempz + gradient4[gi7][3]*tempw; + v[1] = s_gradients4[gi7][0]*tempx + s_gradients4[gi7][1]*tempy + s_gradients4[gi7][2]*tempz + s_gradients4[gi7][3]*tempw; tempx = xc - x0; - u[1] = gradient4[gi6][0]*tempx + gradient4[gi6][1]*tempy + gradient4[gi6][2]*tempz + gradient4[gi6][3]*tempw; + u[1] = s_gradients4[gi6][0]*tempx + s_gradients4[gi6][1]*tempy + s_gradients4[gi6][2]*tempz + s_gradients4[gi6][3]*tempw; tempy = yc - y0; tempz = zc - z0; tempw = wc - (w0+1); - s[2] = gradient4[gi8][0]*tempx + gradient4[gi8][1]*tempy + gradient4[gi8][2]*tempz + gradient4[gi8][3]*tempw; + s[2] = s_gradients4[gi8][0]*tempx + s_gradients4[gi8][1]*tempy + s_gradients4[gi8][2]*tempz + s_gradients4[gi8][3]*tempw; tempx = xc - (x0+1); - t[2] = gradient4[gi9][0]*tempx + gradient4[gi9][1]*tempy + gradient4[gi9][2]*tempz + gradient4[gi9][3]*tempw; + t[2] = s_gradients4[gi9][0]*tempx + s_gradients4[gi9][1]*tempy + s_gradients4[gi9][2]*tempz + s_gradients4[gi9][3]*tempw; tempy = yc - (y0+1); - v[2] = gradient4[gi11][0]*tempx + gradient4[gi11][1]*tempy + gradient4[gi11][2]*tempz + gradient4[gi11][3]*tempw; + v[2] = s_gradients4[gi11][0]*tempx + s_gradients4[gi11][1]*tempy + s_gradients4[gi11][2]*tempz + s_gradients4[gi11][3]*tempw; tempx = xc - x0; - u[2] = gradient4[gi10][0]*tempx + gradient4[gi10][1]*tempy + gradient4[gi10][2]*tempz + gradient4[gi10][3]*tempw; + u[2] = s_gradients4[gi10][0]*tempx + s_gradients4[gi10][1]*tempy + s_gradients4[gi10][2]*tempz + s_gradients4[gi10][3]*tempw; tempy = yc - y0; tempz = zc - (z0+1); - s[3] = gradient4[gi12][0]*tempx + gradient4[gi12][1]*tempy + gradient4[gi12][2]*tempz + gradient4[gi12][3]*tempw; + s[3] = s_gradients4[gi12][0]*tempx + s_gradients4[gi12][1]*tempy + s_gradients4[gi12][2]*tempz + s_gradients4[gi12][3]*tempw; tempx = xc - (x0+1); - t[3] = gradient4[gi13][0]*tempx + gradient4[gi13][1]*tempy + gradient4[gi13][2]*tempz + gradient4[gi13][3]*tempw; + t[3] = s_gradients4[gi13][0]*tempx + s_gradients4[gi13][1]*tempy + s_gradients4[gi13][2]*tempz + s_gradients4[gi13][3]*tempw; tempy = yc - (y0+1); - v[3] = gradient4[gi15][0]*tempx + gradient4[gi15][1]*tempy + gradient4[gi15][2]*tempz + gradient4[gi15][3]*tempw; + v[3] = s_gradients4[gi15][0]*tempx + s_gradients4[gi15][1]*tempy + s_gradients4[gi15][2]*tempz + s_gradients4[gi15][3]*tempw; tempx = xc - x0; - u[3] = gradient4[gi14][0]*tempx + gradient4[gi14][1]*tempy + gradient4[gi14][2]*tempz + gradient4[gi14][3]*tempw; + u[3] = s_gradients4[gi14][0]*tempx + s_gradients4[gi14][1]*tempy + s_gradients4[gi14][2]*tempz + s_gradients4[gi14][3]*tempw; Li1 = s[0] + Cx*(t[0]-s[0]); Li2 = u[0] + Cx*(v[0]-u[0]); diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp index c93a226d4..c2ce28c3f 100644 --- a/src/Nazara/Noise/Simplex.cpp +++ b/src/Nazara/Noise/Simplex.cpp @@ -10,185 +10,95 @@ namespace Nz { - Simplex::Simplex() : - gradient2{ - {1,1},{-1,1},{1,-1},{-1,-1}, - {1,0},{-1,0},{0,1},{0,-1} - }, - gradient3{ - {1.f,1.f,0.f},{-1.f,1.f,0.f},{1.f,-1.f,0.f},{-1.f,-1.f,0.f}, - {1.f,0.f,1.f},{-1.f,0.f,1.f},{1.f,0.f,-1.f},{-1.f,0.f,-1.f}, - {0.f,1.f,1.f},{0.f,-1.f,1.f},{0.f,1.f,-1.f},{0.f,-1.f,-1.f} - }, - gradient4{ - {0.f,1.f,1.f,1.f}, {0.f,1.f,1.f,-1.f}, {0.f,1.f,-1.f,1.f}, {0.f,1.f,-1.f,-1.f}, - {0.f,-1.f,1.f,1.f},{0.f,-1.f,1.f,-1.f},{0.f,-1.f,-1.f,1.f},{0.f,-1.f,-1.f,-1.f}, - {1.f,0.f,1.f,1.f}, {1.f,0.f,1.f,-1.f}, {1.f,0.f,-1.f,1.f}, {1.f,0.f,-1.f,-1.f}, - {-1.f,0.f,1.f,1.f},{-1.f,0.f,1.f,-1.f},{-1.f,0.f,-1.f,1.f},{-1.f,0.f,-1.f,-1.f}, - {1.f,1.f,0.f,1.f}, {1.f,1.f,0.f,-1.f}, {1.f,-1.f,0.f,1.f}, {1.f,-1.f,0.f,-1.f}, - {-1.f,1.f,0.f,1.f},{-1.f,1.f,0.f,-1.f},{-1.f,-1.f,0.f,1.f},{-1.f,-1.f,0.f,-1.f}, - {1.f,1.f,1.f,0.f}, {1.f,1.f,-1.f,0.f}, {1.f,-1.f,1.f,0.f}, {1.f,-1.f,-1.f,0.f}, - {-1.f,1.f,1.f,0.f},{-1.f,1.f,-1.f,0.f},{-1.f,-1.f,1.f,0.f},{-1.f,-1.f,-1.f,0.f} - }, - lookupTable4D{ - {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, - {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, - {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, - {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, - {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, - {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0} - }, - SkewCoeff2D (0.5f*(std::sqrt(3.f) - 1.f)), - UnskewCoeff2D((3.f-std::sqrt(3.f))/6.f), - SkewCoeff3D (1/3.f), - UnskewCoeff3D (1/6.f), - SkewCoeff4D ((std::sqrt(5.f) - 1.f)/4.f), - UnskewCoeff4D ((5.f - std::sqrt(5.f))/20.f) + namespace { - + constexpr float s_SkewCoeff2D = 0.5f * (M_SQRT3 - 1.f); + constexpr float s_UnskewCoeff2D = (3.f - M_SQRT3)/6.f; + constexpr float s_SkewCoeff3D = 1.f / 3.f; + constexpr float s_UnskewCoeff3D = 1.f / 6.f; + constexpr float s_SkewCoeff4D = (M_SQRT5 - 1.f)/4.f; + constexpr float s_UnskewCoeff4D = (5.f - M_SQRT5)/20.f; } - Simplex::Simplex(unsigned int seed) : Simplex() + Simplex::Simplex(unsigned int seed) { SetSeed(seed); Shuffle(); } - float Simplex::Get(std::initializer_list coordinates, float scale) const + float Simplex::Get(float x, float y, float scale) const { - switch(coordinates.size()) + float xc = x * scale; + float yc = y * scale; + + float sum = (xc + yc) * s_SkewCoeff2D; + Vector2i skewedCubeOrigin(fastfloor(xc + sum), fastfloor(yc + sum)); + + sum = (skewedCubeOrigin.x + skewedCubeOrigin.y) * s_UnskewCoeff2D; + Vector2f unskewedCubeOrigin(skewedCubeOrigin.x - sum, skewedCubeOrigin.y - sum); + + Vector2f unskewedDistToOrigin(xc - unskewedCubeOrigin.x, yc - unskewedCubeOrigin.y); + + Vector2f off1; + if(unskewedDistToOrigin.x > unskewedDistToOrigin.y) + off1.Set(1, 0); + else + off1.Set(0, 1); + + std::array d; + d[0] = -unskewedDistToOrigin; + d[1] = d[0] + off1 - Vector2f(s_UnskewCoeff2D); + d[2] = d[0] + Vector2f(1.f - 2.f * s_UnskewCoeff2D); + + Vector2i offset(skewedCubeOrigin.x & 255, skewedCubeOrigin.y & 255); + std::array gi = { - case 2: - return this->_2D(coordinates,scale); - case 3: - return this->_3D(coordinates,scale); - case 4: - return this->_4D(coordinates,scale); - default: - throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); + m_permutations[offset.x + m_permutations[offset.y]] & 7, + m_permutations[offset.x + off1.x + m_permutations[offset.y + off1.y]] & 7, + m_permutations[offset.x + 1 + m_permutations[offset.y + 1]] & 7 + }; + + float n = 0.f; + for (unsigned int i = 0; i < 3; ++i) + { + float c = 0.5f - d[i].x * d[i].x - d[i].y *d[i].y; + if (c > 0.f) + n += c * c * c * c * (s_gradients2[gi[i]].x * d[i].x + s_gradients2[gi[i]].y * d[i].y); } + + return n*70.f; } - float Simplex::_2D(std::initializer_list coordinates, float scale) const + float Simplex::Get(float x, float y, float z, float scale) const { - thread_local float xc,yc; - thread_local int ii,jj; - thread_local int gi0,gi1,gi2; - thread_local int skewedCubeOriginx,skewedCubeOriginy; - thread_local int off1x,off1y; - thread_local float n1,n2,n3; - thread_local float c1,c2,c3; - thread_local float sum; - thread_local float unskewedCubeOriginx,unskewedCubeOriginy; - thread_local float unskewedDistToOriginx,unskewedDistToOriginy; - thread_local float d1x,d1y; - thread_local float d2x,d2y; - thread_local float d3x,d3y; + float xc, yc, zc; + int ii,jj,kk; + int gi0,gi1,gi2,gi3; + int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz; - std::initializer_list::const_iterator it = coordinates.begin(); + int off1x,off1y,off1z; + int off2x,off2y,off2z; + float n1,n2,n3,n4; + float c1,c2,c3,c4; - xc = *(it ) * scale; - yc = *(++it) * scale; - - sum = (xc + yc) * SkewCoeff2D; - skewedCubeOriginx = fastfloor(xc + sum); - skewedCubeOriginy = fastfloor(yc + sum); - - sum = (skewedCubeOriginx + skewedCubeOriginy) * UnskewCoeff2D; - unskewedCubeOriginx = skewedCubeOriginx - sum; - unskewedCubeOriginy = skewedCubeOriginy - sum; - - unskewedDistToOriginx = xc - unskewedCubeOriginx;// Difference with 3d and 4d - unskewedDistToOriginy = yc - unskewedCubeOriginy; - - if(unskewedDistToOriginx > unskewedDistToOriginy) - { - off1x = 1; - off1y = 0; - } - else - { - off1x = 0; - off1y = 1; - } - - d1x = - unskewedDistToOriginx; - d1y = - unskewedDistToOriginy; - - d2x = d1x + off1x - UnskewCoeff2D; - d2y = d1y + off1y - UnskewCoeff2D; - - d3x = d1x + 1.f - 2.f * UnskewCoeff2D; - d3y = d1y + 1.f - 2.f * UnskewCoeff2D; - - ii = skewedCubeOriginx & 255; - jj = skewedCubeOriginy & 255; - - gi0 = perm[ii + perm[jj ]] & 7; - gi1 = perm[ii + off1x + perm[jj + off1y ]] & 7; - gi2 = perm[ii + 1 + perm[jj + 1 ]] & 7; - - c1 = 0.5f - d1x * d1x - d1y * d1y; - c2 = 0.5f - d2x * d2x - d2y * d2y; - c3 = 0.5f - d3x * d3x - d3y * d3y; - - if(c1 < 0) - n1 = 0; - else - n1 = c1*c1*c1*c1*(gradient2[gi0][0] * d1x + gradient2[gi0][1] * d1y); - - if(c2 < 0) - n2 = 0; - else - n2 = c2*c2*c2*c2*(gradient2[gi1][0] * d2x + gradient2[gi1][1] * d2y); - - if(c3 < 0) - n3 = 0; - else - n3 = c3*c3*c3*c3*(gradient2[gi2][0] * d3x + gradient2[gi2][1] * d3y); - - return (n1+n2+n3)*70.f; - } - - float Simplex::_3D(std::initializer_list coordinates, float scale) const - { - thread_local float xc, yc, zc; - thread_local float x,y,z; - thread_local int ii,jj,kk; - thread_local int gi0,gi1,gi2,gi3; - thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz; - - thread_local int off1x,off1y,off1z; - thread_local int off2x,off2y,off2z; - thread_local float n1,n2,n3,n4; - thread_local float c1,c2,c3,c4; - - thread_local float sum; - thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz; - thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz; - thread_local float d1x,d1y,d1z; - thread_local float d2x,d2y,d2z; - thread_local float d3x,d3y,d3z; - thread_local float d4x,d4y,d4z; - - std::initializer_list::const_iterator it = coordinates.begin(); - - x = *(it ); - y = *(++it); - z = *(++it); + float sum; + float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz; + float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz; + float d1x,d1y,d1z; + float d2x,d2y,d2z; + float d3x,d3y,d3z; + float d4x,d4y,d4z; xc = x * scale; yc = y * scale; zc = z * scale; - sum = (xc + yc + zc) * SkewCoeff3D; + sum = (xc + yc + zc) * s_SkewCoeff3D; skewedCubeOriginx = fastfloor(xc + sum); skewedCubeOriginy = fastfloor(yc + sum); skewedCubeOriginz = fastfloor(zc + sum); - sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz) * UnskewCoeff3D; + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz) * s_UnskewCoeff3D; unskewedCubeOriginx = skewedCubeOriginx - sum; unskewedCubeOriginy = skewedCubeOriginy - sum; unskewedCubeOriginz = skewedCubeOriginz - sum; @@ -262,26 +172,26 @@ namespace Nz d1y = unskewedDistToOriginy; d1z = unskewedDistToOriginz; - d2x = d1x - off1x + UnskewCoeff3D; - d2y = d1y - off1y + UnskewCoeff3D; - d2z = d1z - off1z + UnskewCoeff3D; + d2x = d1x - off1x + s_UnskewCoeff3D; + d2y = d1y - off1y + s_UnskewCoeff3D; + d2z = d1z - off1z + s_UnskewCoeff3D; - d3x = d1x - off2x + 2.f*UnskewCoeff3D; - d3y = d1y - off2y + 2.f*UnskewCoeff3D; - d3z = d1z - off2z + 2.f*UnskewCoeff3D; + d3x = d1x - off2x + 2.f*s_UnskewCoeff3D; + d3y = d1y - off2y + 2.f*s_UnskewCoeff3D; + d3z = d1z - off2z + 2.f*s_UnskewCoeff3D; - d4x = d1x - 1.f + 3.f*UnskewCoeff3D; - d4y = d1y - 1.f + 3.f*UnskewCoeff3D; - d4z = d1z - 1.f + 3.f*UnskewCoeff3D; + d4x = d1x - 1.f + 3.f*s_UnskewCoeff3D; + d4y = d1y - 1.f + 3.f*s_UnskewCoeff3D; + d4z = d1z - 1.f + 3.f*s_UnskewCoeff3D; ii = skewedCubeOriginx & 255; jj = skewedCubeOriginy & 255; kk = skewedCubeOriginz & 255; - gi0 = perm[ii + perm[jj + perm[kk ]]] % 12; - gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z ]]] % 12; - gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z ]]] % 12; - gi3 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 ]]] % 12; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk ]]] % 12; + gi1 = m_permutations[ii + off1x + m_permutations[jj + off1y + m_permutations[kk + off1z ]]] % 12; + gi2 = m_permutations[ii + off2x + m_permutations[jj + off2y + m_permutations[kk + off2z ]]] % 12; + gi3 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 ]]] % 12; c1 = 0.6f - d1x * d1x - d1y * d1y - d1z * d1z; c2 = 0.6f - d2x * d2x - d2y * d2y - d2z * d2z; @@ -291,69 +201,75 @@ namespace Nz if(c1 < 0) n1 = 0; else - n1 = c1*c1*c1*c1*(gradient3[gi0][0] * d1x + gradient3[gi0][1] * d1y + gradient3[gi0][2] * d1z); + n1 = c1*c1*c1*c1*(s_gradients3[gi0][0] * d1x + s_gradients3[gi0][1] * d1y + s_gradients3[gi0][2] * d1z); if(c2 < 0) n2 = 0; else - n2 = c2*c2*c2*c2*(gradient3[gi1][0] * d2x + gradient3[gi1][1] * d2y + gradient3[gi1][2] * d2z); + n2 = c2*c2*c2*c2*(s_gradients3[gi1][0] * d2x + s_gradients3[gi1][1] * d2y + s_gradients3[gi1][2] * d2z); if(c3 < 0) n3 = 0; else - n3 = c3*c3*c3*c3*(gradient3[gi2][0] * d3x + gradient3[gi2][1] * d3y + gradient3[gi2][2] * d3z); + n3 = c3*c3*c3*c3*(s_gradients3[gi2][0] * d3x + s_gradients3[gi2][1] * d3y + s_gradients3[gi2][2] * d3z); if(c4 < 0) n4 = 0; else - n4 = c4*c4*c4*c4*(gradient3[gi3][0] * d4x + gradient3[gi3][1] * d4y + gradient3[gi3][2] * d4z); + n4 = c4*c4*c4*c4*(s_gradients3[gi3][0] * d4x + s_gradients3[gi3][1] * d4y + s_gradients3[gi3][2] * d4z); return (n1+n2+n3+n4)*32; } - float Simplex::_4D(std::initializer_list coordinates, float scale) const + float Simplex::Get(float x, float y, float z, float w, float scale) const { - thread_local float xc,yc,zc,wc; - thread_local float x,y,z,w; - thread_local int ii,jj,kk,ll; - thread_local int gi0,gi1,gi2,gi3,gi4; - thread_local int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz,skewedCubeOriginw; + static std::array lookupTable = + { + { + {0,1,2,3}, {0,1,3,2}, {0,0,0,0}, {0,2,3,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,2,3,0}, + {0,2,1,3}, {0,0,0,0}, {0,3,1,2}, {0,3,2,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,3,2,0}, + {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, + {1,2,0,3}, {0,0,0,0}, {1,3,0,2}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,3,0,1}, {2,3,1,0}, + {1,0,2,3}, {1,0,3,2}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {2,0,3,1}, {0,0,0,0}, {2,1,3,0}, + {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, + {2,0,1,3}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {3,0,1,2}, {3,0,2,1}, {0,0,0,0}, {3,1,2,0}, + {2,1,0,3}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {3,1,0,2}, {0,0,0,0}, {3,2,0,1}, {3,2,1,0} + } + }; - thread_local int off1x,off1y,off1z,off1w; - thread_local int off2x,off2y,off2z,off2w; - thread_local int off3x,off3y,off3z,off3w; + float xc,yc,zc,wc; + int ii,jj,kk,ll; + int gi0,gi1,gi2,gi3,gi4; + int skewedCubeOriginx,skewedCubeOriginy,skewedCubeOriginz,skewedCubeOriginw; - thread_local int c; - thread_local float n1,n2,n3,n4,n5; - thread_local float c1,c2,c3,c4,c5,c6; + int off1x,off1y,off1z,off1w; + int off2x,off2y,off2z,off2w; + int off3x,off3y,off3z,off3w; - thread_local float sum; - thread_local float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; - thread_local float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz,unskewedDistToOriginw; - thread_local float d1x,d2x,d3x,d4x,d5x; - thread_local float d1y,d2y,d3y,d4y,d5y; - thread_local float d1z,d2z,d3z,d4z,d5z; - thread_local float d1w,d2w,d3w,d4w,d5w; + int c; + float n1,n2,n3,n4,n5; + float c1,c2,c3,c4,c5,c6; - std::initializer_list::const_iterator it = coordinates.begin(); - - x = *(it ); - y = *(++it); - z = *(++it); - w = *(++it); + float sum; + float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; + float unskewedDistToOriginx,unskewedDistToOriginy,unskewedDistToOriginz,unskewedDistToOriginw; + float d1x,d2x,d3x,d4x,d5x; + float d1y,d2y,d3y,d4y,d5y; + float d1z,d2z,d3z,d4z,d5z; + float d1w,d2w,d3w,d4w,d5w; xc = x * scale; yc = y * scale; zc = z * scale; wc = w * scale; - sum = (xc + yc + zc + wc) * SkewCoeff4D; + sum = (xc + yc + zc + wc) * s_SkewCoeff4D; skewedCubeOriginx = fastfloor(xc + sum); skewedCubeOriginy = fastfloor(yc + sum); skewedCubeOriginz = fastfloor(zc + sum); skewedCubeOriginw = fastfloor(wc + sum); - sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz + skewedCubeOriginw) * UnskewCoeff4D; + sum = (skewedCubeOriginx + skewedCubeOriginy + skewedCubeOriginz + skewedCubeOriginw) * s_UnskewCoeff4D; unskewedCubeOriginx = skewedCubeOriginx - sum; unskewedCubeOriginy = skewedCubeOriginy - sum; unskewedCubeOriginz = skewedCubeOriginz - sum; @@ -372,56 +288,56 @@ namespace Nz c6 = (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; c = c1 + c2 + c3 + c4 + c5 + c6; - off1x = lookupTable4D[c][0] >= 3 ? 1 : 0; - off1y = lookupTable4D[c][1] >= 3 ? 1 : 0; - off1z = lookupTable4D[c][2] >= 3 ? 1 : 0; - off1w = lookupTable4D[c][3] >= 3 ? 1 : 0; + off1x = lookupTable[c][0] >= 3 ? 1 : 0; + off1y = lookupTable[c][1] >= 3 ? 1 : 0; + off1z = lookupTable[c][2] >= 3 ? 1 : 0; + off1w = lookupTable[c][3] >= 3 ? 1 : 0; - off2x = lookupTable4D[c][0] >= 2 ? 1 : 0; - off2y = lookupTable4D[c][1] >= 2 ? 1 : 0; - off2z = lookupTable4D[c][2] >= 2 ? 1 : 0; - off2w = lookupTable4D[c][3] >= 2 ? 1 : 0; + off2x = lookupTable[c][0] >= 2 ? 1 : 0; + off2y = lookupTable[c][1] >= 2 ? 1 : 0; + off2z = lookupTable[c][2] >= 2 ? 1 : 0; + off2w = lookupTable[c][3] >= 2 ? 1 : 0; - off3x = lookupTable4D[c][0] >= 1 ? 1 : 0; - off3y = lookupTable4D[c][1] >= 1 ? 1 : 0; - off3z = lookupTable4D[c][2] >= 1 ? 1 : 0; - off3w = lookupTable4D[c][3] >= 1 ? 1 : 0; + off3x = lookupTable[c][0] >= 1 ? 1 : 0; + off3y = lookupTable[c][1] >= 1 ? 1 : 0; + off3z = lookupTable[c][2] >= 1 ? 1 : 0; + off3w = lookupTable[c][3] >= 1 ? 1 : 0; d1x = unskewedDistToOriginx; d1y = unskewedDistToOriginy; d1z = unskewedDistToOriginz; d1w = unskewedDistToOriginw; - d2x = d1x - off1x + UnskewCoeff4D; - d2y = d1y - off1y + UnskewCoeff4D; - d2z = d1z - off1z + UnskewCoeff4D; - d2w = d1w - off1w + UnskewCoeff4D; + d2x = d1x - off1x + s_UnskewCoeff4D; + d2y = d1y - off1y + s_UnskewCoeff4D; + d2z = d1z - off1z + s_UnskewCoeff4D; + d2w = d1w - off1w + s_UnskewCoeff4D; - d3x = d1x - off2x + 2.f*UnskewCoeff4D; - d3y = d1y - off2y + 2.f*UnskewCoeff4D; - d3z = d1z - off2z + 2.f*UnskewCoeff4D; - d3w = d1w - off2w + 2.f*UnskewCoeff4D; + d3x = d1x - off2x + 2.f*s_UnskewCoeff4D; + d3y = d1y - off2y + 2.f*s_UnskewCoeff4D; + d3z = d1z - off2z + 2.f*s_UnskewCoeff4D; + d3w = d1w - off2w + 2.f*s_UnskewCoeff4D; - d4x = d1x - off3x + 3.f*UnskewCoeff4D; - d4y = d1y - off3y + 3.f*UnskewCoeff4D; - d4z = d1z - off3z + 3.f*UnskewCoeff4D; - d4w = d1w - off3w + 3.f*UnskewCoeff4D; + d4x = d1x - off3x + 3.f*s_UnskewCoeff4D; + d4y = d1y - off3y + 3.f*s_UnskewCoeff4D; + d4z = d1z - off3z + 3.f*s_UnskewCoeff4D; + d4w = d1w - off3w + 3.f*s_UnskewCoeff4D; - d5x = d1x - 1.f + 4*UnskewCoeff4D; - d5y = d1y - 1.f + 4*UnskewCoeff4D; - d5z = d1z - 1.f + 4*UnskewCoeff4D; - d5w = d1w - 1.f + 4*UnskewCoeff4D; + d5x = d1x - 1.f + 4*s_UnskewCoeff4D; + d5y = d1y - 1.f + 4*s_UnskewCoeff4D; + d5z = d1z - 1.f + 4*s_UnskewCoeff4D; + d5w = d1w - 1.f + 4*s_UnskewCoeff4D; ii = skewedCubeOriginx & 255; jj = skewedCubeOriginy & 255; kk = skewedCubeOriginz & 255; ll = skewedCubeOriginw & 255; - gi0 = perm[ii + perm[jj + perm[kk + perm[ll ]]]] & 31; - gi1 = perm[ii + off1x + perm[jj + off1y + perm[kk + off1z + perm[ll + off1w]]]] & 31; - gi2 = perm[ii + off2x + perm[jj + off2y + perm[kk + off2z + perm[ll + off2w]]]] & 31; - gi3 = perm[ii + off3x + perm[jj + off3y + perm[kk + off3z + perm[ll + off3w]]]] & 31; - gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1 ]]]] % 32; + gi0 = m_permutations[ii + m_permutations[jj + m_permutations[kk + m_permutations[ll ]]]] & 31; + gi1 = m_permutations[ii + off1x + m_permutations[jj + off1y + m_permutations[kk + off1z + m_permutations[ll + off1w]]]] & 31; + gi2 = m_permutations[ii + off2x + m_permutations[jj + off2y + m_permutations[kk + off2z + m_permutations[ll + off2w]]]] & 31; + gi3 = m_permutations[ii + off3x + m_permutations[jj + off3y + m_permutations[kk + off3z + m_permutations[ll + off3w]]]] & 31; + gi4 = m_permutations[ii + 1 + m_permutations[jj + 1 + m_permutations[kk + 1 + m_permutations[ll + 1 ]]]] % 32; c1 = 0.6f - d1x*d1x - d1y*d1y - d1z*d1z - d1w*d1w; c2 = 0.6f - d2x*d2x - d2y*d2y - d2z*d2z - d2w*d2w; @@ -432,27 +348,27 @@ namespace Nz if(c1 < 0) n1 = 0; else - n1 = c1*c1*c1*c1*(gradient4[gi0][0]*d1x + gradient4[gi0][1]*d1y + gradient4[gi0][2]*d1z + gradient4[gi0][3]*d1w); + n1 = c1*c1*c1*c1*(s_gradients4[gi0][0]*d1x + s_gradients4[gi0][1]*d1y + s_gradients4[gi0][2]*d1z + s_gradients4[gi0][3]*d1w); if(c2 < 0) n2 = 0; else - n2 = c2*c2*c2*c2*(gradient4[gi1][0]*d2x + gradient4[gi1][1]*d2y + gradient4[gi1][2]*d2z + gradient4[gi1][3]*d2w); + n2 = c2*c2*c2*c2*(s_gradients4[gi1][0]*d2x + s_gradients4[gi1][1]*d2y + s_gradients4[gi1][2]*d2z + s_gradients4[gi1][3]*d2w); if(c3 < 0) n3 = 0; else - n3 = c3*c3*c3*c3*(gradient4[gi2][0]*d3x + gradient4[gi2][1]*d3y + gradient4[gi2][2]*d3z + gradient4[gi2][3]*d3w); + n3 = c3*c3*c3*c3*(s_gradients4[gi2][0]*d3x + s_gradients4[gi2][1]*d3y + s_gradients4[gi2][2]*d3z + s_gradients4[gi2][3]*d3w); if(c4 < 0) n4 = 0; else - n4 = c4*c4*c4*c4*(gradient4[gi3][0]*d4x + gradient4[gi3][1]*d4y + gradient4[gi3][2]*d4z + gradient4[gi3][3]*d4w); + n4 = c4*c4*c4*c4*(s_gradients4[gi3][0]*d4x + s_gradients4[gi3][1]*d4y + s_gradients4[gi3][2]*d4z + s_gradients4[gi3][3]*d4w); if(c5 < 0) n5 = 0; else - n5 = c5*c5*c5*c5*(gradient4[gi4][0]*d5x + gradient4[gi4][1]*d5y + gradient4[gi4][2]*d5z + gradient4[gi4][3]*d5w); + n5 = c5*c5*c5*c5*(s_gradients4[gi4][0]*d5x + s_gradients4[gi4][1]*d5y + s_gradients4[gi4][2]*d5z + s_gradients4[gi4][3]*d5w); return (n1+n2+n3+n4+n5)*27.f; } diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp index 603820706..9d262f6b1 100644 --- a/src/Nazara/Noise/Worley.cpp +++ b/src/Nazara/Noise/Worley.cpp @@ -10,56 +10,38 @@ namespace Nz { - Worley::Worley() : - scales{ - 1.f / std::sqrt(2), - 0.5f / std::sqrt(2), - 0.5f / std::sqrt(2), - 0.5f / std::sqrt(2) - } + namespace + { + static constexpr std::array m_functionScales = + { + 1.f / M_SQRT2, + 0.5f / M_SQRT2, + 0.5f / M_SQRT2, + 0.5f / M_SQRT2 + }; + } + Worley::Worley() : + m_function(WorleyFunction_F1) { - function = WorleyFunction_F1; } - Worley::Worley(unsigned int seed) : Worley() + Worley::Worley(unsigned int seed) : + Worley() { SetSeed(seed); Shuffle(); } - void Worley::Set(WorleyFunction func) - { - function = func; - } - - float Worley::Get(std::initializer_list coordinates, float scale) const - { - switch(coordinates.size()) - { - case 2: - return this->_2D(coordinates,scale); - case 3: - return this->_3D(coordinates,scale); - case 4: - return this->_4D(coordinates,scale); - default: - throw std::invalid_argument("Number of coordinates elements not comprised between 2 and 4"); - } - } - - float Worley::_2D(std::initializer_list coordinates, float scale) const + float Worley::Get(float x, float y, float scale) const { std::map featurePoints; - std::map::iterator it; float xc, yc; int x0, y0; float fractx, fracty; - std::initializer_list::const_iterator c = coordinates.begin(); - - xc = *(c ) * scale; - yc = *(++c) * scale; + xc = x * scale; + yc = y * scale; x0 = fastfloor(xc); y0 = fastfloor(yc); @@ -69,83 +51,83 @@ namespace Nz featurePoints.clear(); - _SquareTest(x0,y0,xc,yc,featurePoints); + SquareTest(x0,y0,xc,yc,featurePoints); - it = featurePoints.begin(); - std::advance(it,function); + auto it = featurePoints.begin(); + std::advance(it, m_function); if(fractx < it->first) - _SquareTest(x0 - 1,y0,xc,yc,featurePoints); + SquareTest(x0 - 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); if(1.f - fractx < it->first) - _SquareTest(x0 + 1,y0,xc,yc,featurePoints); + SquareTest(x0 + 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); if(fracty < it->first) - _SquareTest(x0,y0 - 1,xc,yc,featurePoints); + SquareTest(x0,y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(1.f - fracty < it->first) - _SquareTest(x0,y0 + 1,xc,yc,featurePoints); + if (1.f - fracty < it->first) + SquareTest(x0,y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(fractx < it->first && - fracty < it->first) - _SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); + if (fractx < it->first && fracty < it->first) + SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(1.f - fractx < it->first && - fracty < it->first) - _SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); + if (1.f - fractx < it->first && fracty < it->first) + SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(fractx < it->first && - 1.f - fracty < it->first) - _SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); + if (fractx < it->first && 1.f - fracty < it->first) + SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - if(1.f - fractx < it->first && - 1.f - fracty < it->first) - _SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); + if(1.f - fractx < it->first && 1.f - fracty < it->first) + SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it,function); + std::advance(it, m_function); - return it->first * scales[function]; + return it->first * m_functionScales[m_function]; } - float Worley::_3D(std::initializer_list coordinates, float scale) const + float Worley::Get(float x, float y, float z, float scale) const { throw std::runtime_error("Worley 3D not available yet."); } - float Worley::_4D(std::initializer_list coordinates, float scale) const + float Worley::Get(float x, float y, float z, float w, float scale) const { throw std::runtime_error("Worley 4D not available yet."); } + void Worley::Set(WorleyFunction func) + { + m_function = func; + } - void Worley::_SquareTest(int xi, int yi, float x, float y, std::map & featurePoints) const + void Worley::SquareTest(int xi, int yi, float x, float y, std::map& featurePoints) const { int ii = xi & 255; int jj = yi & 255; - int seed = perm[ii + perm[jj]]; + int seed = m_permutations[ii + m_permutations[jj]]; //On initialise notre rng avec seed std::minstd_rand0 randomNumberGenerator(seed); From c7d4f7ca8327880038d57470fac275c15048c61b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Jun 2016 16:09:22 +0200 Subject: [PATCH 109/383] Noise: Fix errors/warnings Former-commit-id: 1b0766a947b41e6154ef6d0ce7a9dbd58a718f35 [formerly 5204c1e68556379ca8cc69a1db8684eccb5e188d] Former-commit-id: 75dbce8928d51b58555c319705c965616b5b965a --- src/Nazara/Noise/NoiseBase.cpp | 1 + src/Nazara/Noise/Perlin.cpp | 4 ---- src/Nazara/Noise/Simplex.cpp | 28 ++++++++++++------------- src/Nazara/Noise/Worley.cpp | 38 ++++++++++++++++++---------------- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/Nazara/Noise/NoiseBase.cpp b/src/Nazara/Noise/NoiseBase.cpp index fa5a2c92f..1dc74595a 100644 --- a/src/Nazara/Noise/NoiseBase.cpp +++ b/src/Nazara/Noise/NoiseBase.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz diff --git a/src/Nazara/Noise/Perlin.cpp b/src/Nazara/Noise/Perlin.cpp index e6440eb3d..a400972ff 100644 --- a/src/Nazara/Noise/Perlin.cpp +++ b/src/Nazara/Noise/Perlin.cpp @@ -76,9 +76,6 @@ namespace Nz float Li1,Li2,Li3,Li4,Li5,Li6; float s[2],t[2],u[2],v[2]; float Cx,Cy,Cz; - float nx,ny,nz; - - float tmp; float tempx,tempy,tempz; xc = x * scale; @@ -157,7 +154,6 @@ namespace Nz float s[4],t[4],u[4],v[4]; float Cx,Cy,Cz,Cw; - float tmp; float tempx,tempy,tempz,tempw; xc = x * scale; diff --git a/src/Nazara/Noise/Simplex.cpp b/src/Nazara/Noise/Simplex.cpp index c2ce28c3f..8d4748bff 100644 --- a/src/Nazara/Noise/Simplex.cpp +++ b/src/Nazara/Noise/Simplex.cpp @@ -12,12 +12,12 @@ namespace Nz { namespace { - constexpr float s_SkewCoeff2D = 0.5f * (M_SQRT3 - 1.f); - constexpr float s_UnskewCoeff2D = (3.f - M_SQRT3)/6.f; + constexpr float s_SkewCoeff2D = 0.5f * (float(M_SQRT3) - 1.f); + constexpr float s_UnskewCoeff2D = (3.f - float(M_SQRT3))/6.f; constexpr float s_SkewCoeff3D = 1.f / 3.f; constexpr float s_UnskewCoeff3D = 1.f / 6.f; - constexpr float s_SkewCoeff4D = (M_SQRT5 - 1.f)/4.f; - constexpr float s_UnskewCoeff4D = (5.f - M_SQRT5)/20.f; + constexpr float s_SkewCoeff4D = (float(M_SQRT5) - 1.f)/4.f; + constexpr float s_UnskewCoeff4D = (5.f - float(M_SQRT5))/20.f; } Simplex::Simplex(unsigned int seed) @@ -39,7 +39,7 @@ namespace Nz Vector2f unskewedDistToOrigin(xc - unskewedCubeOrigin.x, yc - unskewedCubeOrigin.y); - Vector2f off1; + Vector2ui off1; if(unskewedDistToOrigin.x > unskewedDistToOrigin.y) off1.Set(1, 0); else @@ -47,7 +47,7 @@ namespace Nz std::array d; d[0] = -unskewedDistToOrigin; - d[1] = d[0] + off1 - Vector2f(s_UnskewCoeff2D); + d[1] = d[0] + Vector2f(off1) - Vector2f(s_UnskewCoeff2D); d[2] = d[0] + Vector2f(1.f - 2.f * s_UnskewCoeff2D); Vector2i offset(skewedCubeOrigin.x & 255, skewedCubeOrigin.y & 255); @@ -248,7 +248,7 @@ namespace Nz int c; float n1,n2,n3,n4,n5; - float c1,c2,c3,c4,c5,c6; + float c1,c2,c3,c4,c5; float sum; float unskewedCubeOriginx,unskewedCubeOriginy,unskewedCubeOriginz,unskewedCubeOriginw; @@ -280,13 +280,13 @@ namespace Nz unskewedDistToOriginz = zc - unskewedCubeOriginz; unskewedDistToOriginw = wc - unskewedCubeOriginw; - c1 = (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0; - c2 = (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0; - c3 = (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0; - c4 = (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0; - c5 = (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0; - c6 = (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; - c = c1 + c2 + c3 + c4 + c5 + c6; + c = 0; + c += (unskewedDistToOriginx > unskewedDistToOriginy) ? 32 : 0; + c += (unskewedDistToOriginx > unskewedDistToOriginz) ? 16 : 0; + c += (unskewedDistToOriginy > unskewedDistToOriginz) ? 8 : 0; + c += (unskewedDistToOriginx > unskewedDistToOriginw) ? 4 : 0; + c += (unskewedDistToOriginy > unskewedDistToOriginw) ? 2 : 0; + c += (unskewedDistToOriginz > unskewedDistToOriginw) ? 1 : 0; off1x = lookupTable[c][0] >= 3 ? 1 : 0; off1y = lookupTable[c][1] >= 3 ? 1 : 0; diff --git a/src/Nazara/Noise/Worley.cpp b/src/Nazara/Noise/Worley.cpp index 9d262f6b1..cc98fa378 100644 --- a/src/Nazara/Noise/Worley.cpp +++ b/src/Nazara/Noise/Worley.cpp @@ -14,10 +14,10 @@ namespace Nz { static constexpr std::array m_functionScales = { - 1.f / M_SQRT2, - 0.5f / M_SQRT2, - 0.5f / M_SQRT2, - 0.5f / M_SQRT2 + 1.f / float(M_SQRT2), + 0.5f / float(M_SQRT2), + 0.5f / float(M_SQRT2), + 0.5f / float(M_SQRT2) }; } Worley::Worley() : @@ -53,58 +53,60 @@ namespace Nz SquareTest(x0,y0,xc,yc,featurePoints); + std::size_t functionIndex = static_cast(m_function); + auto it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(fractx < it->first) SquareTest(x0 - 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(1.f - fractx < it->first) SquareTest(x0 + 1,y0,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(fracty < it->first) SquareTest(x0,y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (1.f - fracty < it->first) SquareTest(x0,y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (fractx < it->first && fracty < it->first) SquareTest(x0 - 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (1.f - fractx < it->first && fracty < it->first) SquareTest(x0 + 1, y0 - 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if (fractx < it->first && 1.f - fracty < it->first) SquareTest(x0 - 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); if(1.f - fractx < it->first && 1.f - fracty < it->first) SquareTest(x0 + 1, y0 + 1,xc,yc,featurePoints); it = featurePoints.begin(); - std::advance(it, m_function); + std::advance(it, functionIndex); - return it->first * m_functionScales[m_function]; + return it->first * m_functionScales[functionIndex]; } float Worley::Get(float x, float y, float z, float scale) const @@ -127,16 +129,16 @@ namespace Nz int ii = xi & 255; int jj = yi & 255; - int seed = m_permutations[ii + m_permutations[jj]]; + std::size_t seed = m_permutations[ii + m_permutations[jj]]; //On initialise notre rng avec seed - std::minstd_rand0 randomNumberGenerator(seed); + std::minstd_rand0 randomNumberGenerator(static_cast(seed)); //On prend un nombre de points à déterminer dans le cube, compris entre 1 et 8 - unsigned int m = (seed & 7) + 1; + std::size_t m = (seed & 7) + 1; //On calcule les emplacements des différents points - for(unsigned int i(0) ; i < m ; ++i) + for(std::size_t i(0) ; i < m; ++i) { Nz::Vector2f featurePoint; featurePoint.x = (randomNumberGenerator() & 1023) / 1023.f + static_cast(xi); From 53517ff63478e0c8b13785d0d445d64be7e879a7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 09:05:22 +0200 Subject: [PATCH 110/383] Examples/FirstScene: Add console and Ndk::Application Former-commit-id: 3eeb8a0cfdb26b0f9f27713cea85b006ecaeafab [formerly d406ae7f2f01bf6cdf2bf1b4c4e620276acb6433] Former-commit-id: 9415e852e0b001c843bfa4cc862a7f061bf0c456 --- examples/FirstScene/main.cpp | 212 +++++++++++++++++++++++------------ 1 file changed, 142 insertions(+), 70 deletions(-) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 385b054e0..07e26cd1c 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -1,25 +1,27 @@ /* -** FirstScene - Première scène graphique -** Prérequis: Aucun -** Utilisation du module utilitaire et graphique -** Présente: -** - Création et gestion d'une fenêtre (Traitement des évènements clavier/souris) -** - Gestion du clavier (Récupération de l'état d'une touche) -** - Des outils pour afficher une scène basique via le chargement d'un modèle (et son affichage) -** - Éclairage directionnel -** - Gestion d'une caméra free-fly (Avec déplacement fluide) -** - Gestion basique d'une horloge +* FirstScene - Première scène graphique +* Prérequis: Aucun +* Utilisation du module utilitaire et graphique +** Présente : + * -Création et gestion d'une fenêtre (Traitement des évènements clavier/souris) + * -Gestion du clavier(Récupération de l'état d'une touche) + * -Des outils pour afficher une scène basique via le chargement d'un modèle (et son affichage) + * -Éclairage directionnel + * -Gestion d'une caméra free-fly (Avec déplacement fluide) + * -Gestion basique d'une horloge + * -Console */ #include // Horloges +#include // Module de scripting #include // Module graphique #include // Module de rendu #include // Module utilitaire -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -29,26 +31,15 @@ Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& ta int main() { - // Pour commencer, nous initialisons le SDK de Nazara, celui-ci va préparer le terrain en initialisant le moteur, - // les composants, systèmes, etc. - // NzInitializer est une classe RAII appelant Initialize dans son constructeur et Uninitialize dans son destructeur. - // Autrement dit, une fois ceci fait nous n'avons plus à nous soucier de la libération du moteur. - Nz::Initializer nazara; - if (!nazara) - { - // Une erreur s'est produite dans l'initialisation d'un des modules - std::cout << "Failed to initialize Nazara, see NazaraLog.log for further informations" << std::endl; - std::getchar(); // On laise le temps de voir l'erreur - - return EXIT_FAILURE; - } + // Ndk::Application est une classe s'occupant de l'initialisation du moteur ainsi que de la gestion de beaucoup de choses + Ndk::Application application; // Nazara étant initialisé, nous pouvons créer le monde pour contenir notre scène. // Dans un ECS, le monde représente bien ce que son nom indique, c'est l'ensemble de ce qui existe au niveau de l'application. // Il contient les systèmes et les entités, ces dernières contiennent les composants. // Il est possible d'utiliser plusieurs mondes au sein d'une même application, par exemple pour gérer un mélange de 2D et de 3D, // mais nous verrons cela dans un prochain exemple. - Ndk::World world; + Ndk::WorldHandle world = application.AddWorld().CreateHandle(); // Nous pouvons maintenant ajouter des systèmes, mais dans cet exemple nous nous contenterons de ceux de base. @@ -73,7 +64,7 @@ int main() Nz::SkyboxBackgroundRef skybox = Nz::SkyboxBackground::New(std::move(texture)); // Accédons maintenant au système de rendu faisant partie du monde - Ndk::RenderSystem& renderSystem = world.GetSystem(); // Une assertion valide la précondition "le système doit faire partie du monde" + Ndk::RenderSystem& renderSystem = world->GetSystem(); // Une assertion valide la précondition "le système doit faire partie du monde" // Nous assignons ensuite notre skybox comme "fond par défaut" du système // La notion "par défaut" existe parce qu'une caméra pourrait utiliser son propre fond lors du rendu, @@ -146,7 +137,7 @@ int main() // Bien, nous avons un modèle valide, mais celui-ci ne consiste qu'en des informations de rendu, de matériaux et de textures. // Commençons donc par créer une entité vide, cela se fait en demandant au monde de générer une nouvelle entité. - Ndk::EntityHandle spaceship = world.CreateEntity(); + Ndk::EntityHandle spaceship = world->CreateEntity(); // Note: Nous ne récupérons pas l'entité directement mais un "handle" vers elle, ce dernier est un pointeur intelligent non-propriétaire. // Pour des raisons techniques, le pointeur de l'entité peut venir à changer, ou l'entité être simplement détruite pour n'importe quelle raison. @@ -159,6 +150,7 @@ int main() // Étant donné que par défaut, un NodeComponent se place en (0,0,0) sans rotation et avec une échelle de 1,1,1 et que cela nous convient, // nous n'avons pas besoin d'agir sur le composant créé. spaceship->AddComponent(); + //spaceship->AddComponent().linearVelocity.Set(-1.f, 0.f, 0.f); // Bien, notre entité nouvellement créé dispose maintenant d'une position dans la scène, mais est toujours invisible // Nous lui ajoutons donc un GraphicsComponent @@ -178,7 +170,7 @@ int main() // Nous créons donc une seconde entité // Note: La création d'entité est une opération légère au sein du moteur, mais plus vous aurez d'entités et plus le processeur devra travailler. - Ndk::EntityHandle camera = world.CreateEntity(); + Ndk::EntityHandle camera = world->CreateEntity(); // Notre caméra a elle aussi besoin d'être positionnée dans la scène Ndk::NodeComponent& cameraNode = camera->AddComponent(); @@ -188,6 +180,9 @@ int main() // Et dispose d'un composant pour chaque point de vue de la scène, le CameraComponent Ndk::CameraComponent& cameraComp = camera->AddComponent(); + // Ajoutons un composant écouteur, si nous venions à avoir du son + camera->AddComponent(); + // Et on n'oublie pas de définir les plans délimitant le champs de vision // (Seul ce qui se trouvera entre les deux plans sera rendu) @@ -208,7 +203,7 @@ int main() // Nous allons créer une lumière directionnelle pour représenter la nébuleuse de notre skybox // Encore une fois, nous créons notre entité - Ndk::EntityHandle nebulaLight = world.CreateEntity(); + Ndk::EntityHandle nebulaLight = world->CreateEntity(); // Lui ajoutons une position dans la scène Ndk::NodeComponent& nebulaLightNode = nebulaLight->AddComponent(); @@ -246,7 +241,7 @@ int main() Nz::RenderTargetParameters parameters; parameters.antialiasingLevel = 4; - Nz::RenderWindow window(mode, windowTitle, style, parameters); + Nz::RenderWindow& window = application.AddWindow(mode, windowTitle, style, parameters); if (!window.IsValid()) { std::cout << "Failed to create render window" << std::endl; @@ -272,8 +267,70 @@ int main() bool smoothMovement = true; Nz::Vector3f targetPos = cameraNode.GetPosition(); - // Début de la boucle de rendu du programme - while (window.IsOpen()) + // Pour ajouter une console à notre application, nous avons besoin d'un monde 2D pour gérer ces rendus + Ndk::WorldHandle world2D = application.AddWorld().CreateHandle(); + world2D->GetSystem().SetDefaultBackground(nullptr); + world2D->GetSystem().SetGlobalUp(Nz::Vector3f::Down()); + + // Nous ajoutons une caméra comme précédement + Ndk::EntityHandle viewEntity = world2D->CreateEntity(); + viewEntity->AddComponent(); + + // À la différence que celui-ci effectuera une projection orthogonale + Ndk::CameraComponent& viewer = viewEntity->AddComponent(); + viewer.SetTarget(&window); + viewer.SetProjectionType(Nz::ProjectionType_Orthogonal); + + // Nous créons un environnement Lua pour gérer nos scripts + Nz::LuaInstance lua; + + // Faisons en sorte d'enregistrer les classes du moteur dans cet environnement + Ndk::LuaAPI::RegisterClasses(lua); + + // Ensuite nous créons la console en elle-même + Ndk::Console console(*world2D, Nz::Vector2f(window.GetWidth(), window.GetHeight() / 4), lua); + + // Nous redirigeons les logs vers cette console + Nz::Log::OnLogWriteType::ConnectionGuard logGuard = Nz::Log::OnLogWrite.Connect([&console] (const Nz::String& str) + { + console.AddLine(str); + }); + + // Nous réécrivons la fonction "print" du Lua pour la rediriger vers la console + lua.PushFunction([&console] (Nz::LuaInstance& instance) + { + Nz::StringStream stream; + + unsigned int argCount = instance.GetStackTop(); + instance.GetGlobal("tostring"); + for (unsigned int i = 1; i <= argCount; ++i) + { + instance.PushValue(-1); // ToString + instance.PushValue(i); // Arg + instance.Call(1, 1); + + std::size_t length; + const char* str = instance.CheckString(-1, &length); + if (i > 1) + stream << '\t'; + + stream << Nz::String(str, length); + instance.Pop(1); + } + + console.AddLine(stream); + return 0; + }); + lua.SetGlobal("print"); + + // Définissons quelques variables de base + lua.PushGlobal("Application", Ndk::Application::Instance()); + lua.PushGlobal("Console", console.CreateHandle()); + lua.PushGlobal("Spaceship", spaceship->CreateHandle()); + lua.PushGlobal("World", world->CreateHandle()); + + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) + while (application.Run()) { // Ensuite nous allons traiter les évènements (Étape indispensable pour la fenêtre) Nz::WindowEvent event; @@ -283,6 +340,9 @@ int main() { case Nz::WindowEventType_MouseMoved: // La souris a bougé { + if (console.IsVisible()) + break; + // Gestion de la caméra free-fly (Rotation) float sensitivity = 0.3f; // Sensibilité de la souris @@ -297,15 +357,18 @@ int main() // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved - Nz::Mouse::SetPosition(window.GetWidth()/2, window.GetHeight()/2, window); + Nz::Mouse::SetPosition(window.GetWidth() / 2, window.GetHeight() / 2, window); break; } case Nz::WindowEventType_Quit: // L'utilisateur a cliqué sur la croix, ou l'OS veut terminer notre programme - window.Close(); // On demande la fermeture de la fenêtre (Qui aura lieu au prochain tour de boucle) + application.Quit(); break; case Nz::WindowEventType_KeyPressed: // Une touche a été pressée ! + if (console.IsVisible()) + console.SendEvent(event); + if (event.key.code == Nz::Keyboard::Key::Escape) window.Close(); else if (event.key.code == Nz::Keyboard::F1) @@ -318,6 +381,19 @@ int main() else smoothMovement = true; } + else if (event.key.code == Nz::Keyboard::F9) + console.Show(!console.IsVisible()); + break; + + case Nz::WindowEventType_TextEntered: + { + if (console.IsVisible()) + console.SendCharacter(event.text.character); + break; + } + + case Nz::WindowEventType_Resized: + console.SetSize({float(event.size.width), event.size.height / 4.f}); break; default: @@ -337,52 +413,48 @@ int main() { // Le temps écoulé en seconde depuis la dernière fois que ce bloc a été exécuté float elapsedTime = updateAccumulator / 1000000.f; - std::cout << elapsedTime << std::endl; // Vitesse de déplacement de la caméra float cameraSpeed = 3.f * elapsedTime; // Trois mètres par seconde - // Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space)) - cameraSpeed *= 2.f; + if (!console.IsVisible()) + { + // Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space)) + cameraSpeed *= 2.f; - // Pour que nos déplacement soient liés à la rotation de la caméra, nous allons utiliser - // les directions locales de la caméra + // Pour que nos déplacement soient liés à la rotation de la caméra, nous allons utiliser + // les directions locales de la caméra - // Si la flèche du haut ou la touche Z (vive ZQSD) est pressée, on avance - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z)) - targetPos += cameraNode.GetForward() * cameraSpeed; + // Si la flèche du haut ou la touche Z (vive ZQSD) est pressée, on avance + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z)) + targetPos += cameraNode.GetForward() * cameraSpeed; - // Si la flèche du bas ou la touche S est pressée, on recule - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S)) - targetPos += cameraNode.GetBackward() * cameraSpeed; + // Si la flèche du bas ou la touche S est pressée, on recule + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S)) + targetPos += cameraNode.GetBackward() * cameraSpeed; - // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q)) - targetPos += cameraNode.GetLeft() * cameraSpeed; + // Etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q)) + targetPos += cameraNode.GetLeft() * cameraSpeed; - // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D)) - targetPos += cameraNode.GetRight() * cameraSpeed; + // Etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D)) + targetPos += cameraNode.GetRight() * cameraSpeed; - // Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation) - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) - targetPos += Nz::Vector3f::Up() * cameraSpeed; + // Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) + targetPos += Nz::Vector3f::Up() * cameraSpeed; - // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl)) - targetPos += Nz::Vector3f::Down() * cameraSpeed; + // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl)) + targetPos += Nz::Vector3f::Down() * cameraSpeed; + } cameraNode.SetPosition((smoothMovement) ? DampedString(cameraNode.GetPosition(), targetPos, elapsedTime) : targetPos, Nz::CoordSys_Global); - updateAccumulator = 0; } - // Et maintenant pour rendre la scène, il nous suffit de mettre à jour le monde en lui envoyant le temps depuis la dernière mise à jour - // Note: La plupart des systèmes, à l'exception de celui de rendu, ont une fréquence de mise à jour fixe (modifiable) - // Il n'est donc pas nécessaire de limiter vous-même les mises à jour du monde - world.Update(elapsedUS / 1000000.f); - // Après avoir dessiné sur la fenêtre, il faut s'assurer qu'elle affiche cela // Cet appel ne fait rien d'autre qu'échanger les buffers de rendu (Double Buffering) window.Display(); @@ -410,7 +482,7 @@ int main() } } - return EXIT_SUCCESS; + return EXIT_SUCCESS; } Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& targetPos, float frametime, float springStrength) @@ -430,7 +502,7 @@ Nz::Vector3f DampedString(const Nz::Vector3f& currentPos, const Nz::Vector3f& ta if (Nz::NumberEquals(displacementLength, 0.f)) return currentPos; - float invDisplacementLength = 1.f/displacementLength; + float invDisplacementLength = 1.f / displacementLength; const float dampConstant = 0.000065f; // Something v.small to offset 1/ displacement length From 499f9e0dff0ade0d47ddce1570b0de722966fdff Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 13:10:09 +0200 Subject: [PATCH 111/383] Core/ObjectRef: Add comparison operators Former-commit-id: 87b6480dfad8fd49da249890c62e698afdcfca8e [formerly 3d82a1d9f1f0358975b23a25274ac4a8c75ef37f] Former-commit-id: 9031aab557ae8c9b89025725fa65f0309b5b32ee --- include/Nazara/Core/ObjectRef.hpp | 29 +++- include/Nazara/Core/ObjectRef.inl | 235 ++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/ObjectRef.hpp b/include/Nazara/Core/ObjectRef.hpp index 6f3ccab9a..d1cd13ec0 100644 --- a/include/Nazara/Core/ObjectRef.hpp +++ b/include/Nazara/Core/ObjectRef.hpp @@ -44,8 +44,33 @@ namespace Nz T* m_object; }; - template struct PointedType> {typedef T type;}; - template struct PointedType const> {typedef T type;}; + template bool operator==(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator==(const T& lhs, const ObjectRef& rhs); + template bool operator==(const ObjectRef& lhs, const T& rhs); + + template bool operator!=(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator!=(const T& lhs, const ObjectRef& rhs); + template bool operator!=(const ObjectRef& lhs, const T& rhs); + + template bool operator<(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator<(const T& lhs, const ObjectRef& rhs); + template bool operator<(const ObjectRef& lhs, const T& rhs); + + template bool operator<=(const ObjectRef, const ObjectRef& rhs); + template bool operator<=(const T& lhs, const ObjectRef& rhs); + template bool operator<=(const ObjectRef& lhs, const T& rhs); + + template bool operator>(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator>(const T& lhs, const ObjectRef& rhs); + template bool operator>(const ObjectRef& lhs, const T& rhs); + + template bool operator>=(const ObjectRef& lhs, const ObjectRef& rhs); + template bool operator>=(const T& lhs, const ObjectRef& rhs); + template bool operator>=(const ObjectRef& lhs, const T& rhs); + + + template struct PointedType> { typedef T type; }; + template struct PointedType const> { typedef T type; }; } #include diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index ad74b4f2e..8dab06948 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -245,6 +245,241 @@ namespace Nz return *this; } + + + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator==(const ObjectRef& lhs, const ObjectRef& rhs) + { + return lhs.Get() == rhs.Get(); + } + + /*! + * \brief Checks whether the object is equal to the second object handle + * \return true if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator==(const T& lhs, const ObjectRef& rhs) + { + return &lhs == rhs.Get(); + } + + /*! + * \brief Checks whether the object handle is equal to the second object + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second Object to compare in right hand side + */ + template + bool operator==(const ObjectRef& lhs, const T& rhs) + { + return lhs.Get() == &rhs; + } + + /*! + * \brief Checks whether the first object handle is equal to the second object handle + * \return false if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator!=(const ObjectRef& lhs, const ObjectRef& rhs) + { + return !(lhs == rhs); + } + + /*! + * \brief Checks whether the object is equal to the second object handle + * \return false if it is the case + * + * \param first Object to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator!=(const T& lhs, const ObjectRef& rhs) + { + return !(lhs == rhs); + } + + /*! + * \brief Checks whether the object handle is equal to the second object + * \return false if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second Object to compare in right hand side + */ + template + bool operator!=(const ObjectRef& lhs, const T& rhs) + { + return !(lhs == rhs); + } + + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<(const ObjectRef& lhs, const ObjectRef& rhs) + { + return lhs.m_object < rhs.m_object; + } + + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<(const T& lhs, const ObjectRef& rhs) + { + return &lhs < rhs.m_object; + } + + /*! + * \brief Checks whether the first object handle is less than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<(const ObjectRef& lhs, const T& rhs) + { + return lhs.m_object < &rhs; + } + + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<=(const ObjectRef& lhs, const ObjectRef& rhs) + { + return !(lhs > rhs); + } + + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<=(const T& lhs, const ObjectRef& rhs) + { + return !(lhs > rhs); + } + + /*! + * \brief Checks whether the first object handle is less or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator<=(const ObjectRef& lhs, const T& rhs) + { + return !(lhs > rhs); + } + + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>(const ObjectRef& lhs, const ObjectRef& rhs) + { + return rhs < lhs; + } + + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>(const T& lhs, const ObjectRef& rhs) + { + return rhs < lhs; + } + + /*! + * \brief Checks whether the first object handle is greather than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>(const ObjectRef& lhs, const T& rhs) + { + return rhs < lhs; + } + + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>=(const ObjectRef& lhs, const ObjectRef& rhs) + { + return !(lhs < rhs); + } + + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>=(const T& lhs, const ObjectRef& rhs) + { + return !(lhs < rhs); + } + + /*! + * \brief Checks whether the first object handle is greather or equal than the second object handle + * \return true if it is the case + * + * \param first ObjectRef to compare in left hand side + * \param second ObjectRef to compare in right hand side + */ + template + bool operator>=(const ObjectRef& lhs, const T& rhs) + { + return !(lhs < rhs); + } } namespace std From e0071b196aa592d0e1b6a48ed146077e55439a68 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 13:11:31 +0200 Subject: [PATCH 112/383] Sdk/GraphicsComponent: Add Detach method Former-commit-id: b80b7e52f4736f61c439a4242531adaefbdb75a2 [formerly 2c336b6480ae9a11ca1104ee1140e8f449bb2a02] Former-commit-id: 54f77c634ce1f9bfc93a00d9a14567bd25a06b26 --- .../NDK/Components/GraphicsComponent.hpp | 18 ++++++++++++++++++ .../NDK/Components/GraphicsComponent.inl | 13 +++++++++++++ .../Nazara/Graphics/InstancedRenderable.hpp | 17 +++++++++++++++-- src/Nazara/Core/String.cpp | 2 +- src/Nazara/Graphics/Billboard.cpp | 2 +- src/Nazara/Graphics/InstancedRenderable.cpp | 2 +- src/Nazara/Graphics/Model.cpp | 2 +- src/Nazara/Graphics/SkeletalModel.cpp | 2 +- src/Nazara/Graphics/Sprite.cpp | 8 ++++---- src/Nazara/Graphics/TextSprite.cpp | 2 +- 10 files changed, 56 insertions(+), 12 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index c94cec4ab..f079303b8 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -31,6 +31,8 @@ namespace Ndk inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); + inline void Detach(Nz::InstancedRenderableRef renderable); + inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; @@ -63,6 +65,22 @@ namespace Ndk { } + Renderable(Renderable&& renderable) noexcept : + data(std::move(renderable.data)), + renderable(std::move(renderable.renderable)), + dataUpdated(renderable.dataUpdated) + { + } + + Renderable& operator=(Renderable&& r) noexcept + { + data = std::move(r.data); + dataUpdated = r.dataUpdated; + renderable = std::move(r.renderable); + + return *this; + } + NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot); mutable Nz::InstancedRenderable::InstanceData data; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index c330da5eb..c736ecc48 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include "GraphicsComponent.hpp" namespace Ndk { @@ -46,6 +47,18 @@ namespace Ndk InvalidateBoundingVolume(); } + inline void GraphicsComponent::Detach(Nz::InstancedRenderableRef renderable) + { + for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) + { + if (it->renderable == renderable) + { + m_renderables.erase(it); + break; + } + } + } + inline void GraphicsComponent::EnsureBoundingVolumeUpdate() const { if (!m_boundingVolumeUpdated) diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index 561cc4c97..d1c07bf9b 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -55,14 +55,27 @@ namespace Nz struct InstanceData { InstanceData(Matrix4f& referenceMatrix) : - transformMatrix(referenceMatrix), + transformMatrix(&referenceMatrix), flags(0) { } + InstanceData(InstanceData&& instanceData) noexcept = default; + + InstanceData& operator=(InstanceData&& instanceData) noexcept + { + data = std::move(instanceData.data); + flags = instanceData.flags; + renderOrder = instanceData.renderOrder; + transformMatrix = instanceData.transformMatrix; + volume = instanceData.volume; + + return *this; + } + std::vector data; BoundingVolumef volume; - Matrix4f& transformMatrix; + Matrix4f* transformMatrix; UInt32 flags; int renderOrder; }; diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index a57d89861..21831bcdf 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -211,7 +211,7 @@ namespace Nz */ String::String(const std::string& string) : - String(string.c_str(), string.size()) + String(string.data(), string.size()) { } diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 6f47e9847..e06d3c921 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -30,7 +30,7 @@ namespace Nz if (!m_material) return; - renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix.GetTranslation(), m_size, m_sinCos, m_color); + renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix->GetTranslation(), m_size, m_sinCos, m_color); } /* diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index ef5f62b96..03da17984 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -80,7 +80,7 @@ namespace Nz NazaraAssert(instanceData, "Invalid instance data"); NazaraUnused(instanceData); - instanceData->volume.Update(instanceData->transformMatrix); + instanceData->volume.Update(*instanceData->transformMatrix); } /*! diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index d382c77d9..2b9e03cc1 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -82,7 +82,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = mesh->GetVertexBuffer(); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), *instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index b91ac0076..8621d1fce 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -69,7 +69,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = SkinningManager::GetBuffer(mesh, &m_skeleton); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), *instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 76bf5fff2..4bf076183 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -58,19 +58,19 @@ namespace Nz SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(0.f)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 42dba4aaf..2f1d733b4 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -310,7 +310,7 @@ namespace Nz Vector3f localPos = localVertex->position.x*Vector3f::Right() + localVertex->position.y*Vector3f::Down(); localPos *= m_scale; - *pos++ = instanceData->transformMatrix.Transform(localPos); + *pos++ = instanceData->transformMatrix->Transform(localPos); *color++ = m_color * localVertex->color; *uv++ = localVertex->uv; From 77cf413f6ae3f0545782cfa09c9908b3419ff137 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 20 Jun 2016 13:12:09 +0200 Subject: [PATCH 113/383] Renderer/RenderWindow: Fix visibility of OnWindow*() events Former-commit-id: 9e756e4a50d8f14bbf9cded7b580bd6787515332 [formerly d8a7f7a52aec51b3480ddfe0e71ffb6568f35440] Former-commit-id: 61e0ee78490dc00e64c8efd72953cfe5ceee195f --- include/Nazara/Renderer/RenderWindow.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index d9889d803..1cda9d63d 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -65,12 +65,11 @@ namespace Nz protected: bool Activate() const override; void EnsureTargetUpdated() const override; - - private: bool OnWindowCreated() override; void OnWindowDestroy() override; void OnWindowResized() override; + private: mutable std::vector m_buffer; Clock m_clock; ContextParameters m_parameters; From 31ce28a177d4366d5de4ee2bf6f98ef27725a505 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 21 Jun 2016 19:14:29 +0200 Subject: [PATCH 114/383] Sdk/GraphicsComponent: Add Clear method Former-commit-id: adcb195b1865ffdde91dcc1859005e82e5f2d047 [formerly c1886292500dfe3664f6f998de5b77f5d5e52f87] Former-commit-id: f24214e506c412dd9c330e33c53727b59c3c1b93 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 4 +++- SDK/include/NDK/Components/GraphicsComponent.inl | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index f079303b8..aed427105 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -31,7 +31,9 @@ namespace Ndk inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); - inline void Detach(Nz::InstancedRenderableRef renderable); + inline void Clear(); + + inline void Detach(const Nz::InstancedRenderableRef& renderable); inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index c736ecc48..9ca100d0e 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -47,12 +47,20 @@ namespace Ndk InvalidateBoundingVolume(); } - inline void GraphicsComponent::Detach(Nz::InstancedRenderableRef renderable) + inline void GraphicsComponent::Clear() + { + m_renderables.clear(); + + InvalidateBoundingVolume(); + } + + inline void GraphicsComponent::Detach(const Nz::InstancedRenderableRef& renderable) { for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) { if (it->renderable == renderable) { + InvalidateBoundingVolume(); m_renderables.erase(it); break; } From 039e02fda06a362b8616dea77abdd0613925ea95 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 23 Jun 2016 00:37:32 +0200 Subject: [PATCH 115/383] Core/PluginManager: Fix usage of Mount(Plugin) Former-commit-id: 84167787661b2d2022dafcb1b98f9497bffe91df [formerly 14cb32cb9779cf42c14c1100f48e9b932c48e7bc] Former-commit-id: fc6b344fc63e71650718eacda4e29532f9349c6c --- src/Nazara/Core/PluginManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Core/PluginManager.cpp b/src/Nazara/Core/PluginManager.cpp index 24fbafcfb..b71af6677 100644 --- a/src/Nazara/Core/PluginManager.cpp +++ b/src/Nazara/Core/PluginManager.cpp @@ -19,8 +19,7 @@ namespace Nz String s_pluginFiles[] = { - "NazaraAssimp", // Plugin_Assimp - "NazaraFreetype" // Plugin_FreeType + "PluginAssimp", // Plugin_Assimp }; } @@ -80,7 +79,13 @@ namespace Nz bool PluginManager::Mount(Plugin plugin) { - return Mount(s_pluginFiles[plugin]); + Nz::String pluginName = s_pluginFiles[plugin]; + #ifdef NAZARA_DEBUG + if (Mount(pluginName + "-d", true)) + return true; + #endif + + return Mount(pluginName, true); } /*! From 18cb5f9da380bba8a94b2ed9e8c541643177c802 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:56:18 +0200 Subject: [PATCH 116/383] Graphics/Material: Add SaveToParameters Former-commit-id: 706770cc1eaf00e0849d9a6f6878b0ab9b69d3aa [formerly be281a7eaaa21f25c80ff65bf7b79c93c03e1e1d] Former-commit-id: b54f61ec5be56a9ae51decaf625ff96b2ab5c62d --- include/Nazara/Graphics/Material.hpp | 2 + src/Nazara/Graphics/Material.cpp | 100 ++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 85c4d315c..b30c215c1 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -120,6 +120,8 @@ namespace Nz void Reset(); + void SaveToParameters(ParameterList* matData); + inline bool SetAlphaMap(const String& textureName); inline void SetAlphaMap(TextureRef alphaMap); inline void SetAlphaThreshold(float alphaThreshold); diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index bfc6ee88a..14da83eb0 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -310,10 +310,108 @@ namespace Nz SetShader(matParams.shaderName); } + void Material::SaveToParameters(ParameterList* matData) + { + NazaraAssert(matData, "Invalid ParameterList"); + + matData->SetParameter(MaterialData::AlphaTest, IsAlphaTestEnabled()); + matData->SetParameter(MaterialData::AlphaThreshold, GetAlphaThreshold()); + matData->SetParameter(MaterialData::AmbientColor, GetAmbientColor()); + matData->SetParameter(MaterialData::CullingSide, int(GetFaceCulling())); + matData->SetParameter(MaterialData::DepthFunc, int(GetDepthFunc())); + matData->SetParameter(MaterialData::DepthSorting, IsDepthSortingEnabled()); + matData->SetParameter(MaterialData::DiffuseColor, GetDiffuseColor()); + matData->SetParameter(MaterialData::DstBlend, int(GetDstBlend())); + matData->SetParameter(MaterialData::FaceFilling, int(GetFaceFilling())); + matData->SetParameter(MaterialData::Lighting, IsLightingEnabled()); + matData->SetParameter(MaterialData::LineWidth, GetRenderStates().lineWidth); + matData->SetParameter(MaterialData::PointSize, GetRenderStates().pointSize); + matData->SetParameter(MaterialData::Shininess, GetShininess()); + matData->SetParameter(MaterialData::SpecularColor, GetSpecularColor()); + matData->SetParameter(MaterialData::SrcBlend, int(GetSrcBlend())); + matData->SetParameter(MaterialData::Transform, IsTransformEnabled()); + + // RendererParameter + matData->SetParameter(MaterialData::Blending, GetRenderStates().parameters[RendererParameter_Blend]); + matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().parameters[RendererParameter_ColorWrite]); + matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().parameters[RendererParameter_DepthBuffer]); + matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().parameters[RendererParameter_DepthWrite]); + matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().parameters[RendererParameter_FaceCulling]); + matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().parameters[RendererParameter_ScissorTest]); + matData->SetParameter(MaterialData::StencilTest, GetRenderStates().parameters[RendererParameter_StencilTest]); + + // Samplers + matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, int(GetDiffuseSampler().GetAnisotropicLevel())); + matData->SetParameter(MaterialData::DiffuseFilter, int(GetDiffuseSampler().GetFilterMode())); + matData->SetParameter(MaterialData::DiffuseWrap, int(GetDiffuseSampler().GetWrapMode())); + + matData->SetParameter(MaterialData::SpecularAnisotropyLevel, int(GetSpecularSampler().GetAnisotropicLevel())); + matData->SetParameter(MaterialData::SpecularFilter, int(GetSpecularSampler().GetFilterMode())); + matData->SetParameter(MaterialData::SpecularWrap, int(GetSpecularSampler().GetWrapMode())); + + // Stencil + matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().frontFace.stencilCompare)); + matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().frontFace.stencilFail)); + matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().frontFace.stencilPass)); + matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().frontFace.stencilZFail)); + matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().frontFace.stencilMask)); + matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().frontFace.stencilReference)); + + // Stencil (back) + matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().backFace.stencilCompare)); + matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().backFace.stencilFail)); + matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().backFace.stencilPass)); + matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().backFace.stencilZFail)); + matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().backFace.stencilMask)); + matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().backFace.stencilReference)); + + // Textures + if (HasAlphaMap()) + { + const String& path = GetAlphaMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::AlphaTexturePath, path); + } + + if (HasDiffuseMap()) + { + const String& path = GetDiffuseMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::DiffuseTexturePath, path); + } + + if (HasEmissiveMap()) + { + const String& path = GetEmissiveMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::EmissiveTexturePath, path); + } + + if (HasHeightMap()) + { + const String& path = GetHeightMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::HeightTexturePath, path); + } + + if (HasNormalMap()) + { + const String& path = GetNormalMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::NormalTexturePath, path); + } + + if (HasSpecularMap()) + { + const String& path = GetSpecularMap()->GetFilePath(); + if (!path.IsEmpty()) + matData->SetParameter(MaterialData::SpecularTexturePath, path); + } + } + /*! * \brief Resets the material, cleans everything */ - void Material::Reset() { OnMaterialReset(this); From 4f29015c05818e37169f79acbb3300edacfd63ed Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:56:45 +0200 Subject: [PATCH 117/383] Core/StringStream: Add Clear and GetBufferSize methods Former-commit-id: 0efb57d6bbbe6f5a3ef96b1468428e99ec2f209e [formerly 831a749e3ce3a62e62dff8b5ec5a623ea15cd5fd] Former-commit-id: ab163c4086613046227165aa01606a8ed6edad75 --- include/Nazara/Core/StringStream.hpp | 4 +++ src/Nazara/Core/StringStream.cpp | 41 +++++++++++++--------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/Nazara/Core/StringStream.hpp b/include/Nazara/Core/StringStream.hpp index da68e8b27..f727ed35c 100644 --- a/include/Nazara/Core/StringStream.hpp +++ b/include/Nazara/Core/StringStream.hpp @@ -22,6 +22,10 @@ namespace Nz StringStream(const StringStream&) = default; StringStream(StringStream&&) noexcept = default; + void Clear(); + + std::size_t GetBufferSize() const; + String ToString() const; StringStream& operator=(const StringStream&) = default; diff --git a/src/Nazara/Core/StringStream.cpp b/src/Nazara/Core/StringStream.cpp index ebd509c65..14d35799d 100644 --- a/src/Nazara/Core/StringStream.cpp +++ b/src/Nazara/Core/StringStream.cpp @@ -1,3 +1,4 @@ +#include "..\..\..\include\Nazara\Core\StringStream.hpp" // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -16,7 +17,6 @@ namespace Nz /*! * \brief Constructs a StringStream object by default */ - StringStream::StringStream() : m_bufferSize(0) { @@ -27,18 +27,34 @@ namespace Nz * * \param str First value of the stream */ - StringStream::StringStream(const String& str) : m_bufferSize(str.GetSize()) { m_strings.push_back(str); } + /*! + * \brief Resets the state of the stream, erasing every contained text + */ + void StringStream::Clear() + { + m_bufferSize = 0; + m_strings.clear(); + } + + /*! + * \brief Get the current buffer size + * \return The internal accumulation buffer size, this is equivalent to the size of the final string + */ + std::size_t StringStream::GetBufferSize() const + { + return m_bufferSize; + } + /*! * \brief Gives a string representation * \return A string representation of the object where every objects of the stream has been converted with Nz::String */ - String StringStream::ToString() const { String string; @@ -56,7 +72,6 @@ namespace Nz * * \param boolean Boolean value */ - StringStream& StringStream::operator<<(bool boolean) { m_strings.push_back(String::Boolean(boolean)); @@ -71,7 +86,6 @@ namespace Nz * * \param number Short value */ - StringStream& StringStream::operator<<(short number) { m_strings.push_back(String::Number(number)); @@ -86,7 +100,6 @@ namespace Nz * * \param number Short value */ - StringStream& StringStream::operator<<(unsigned short number) { m_strings.push_back(String::Number(number)); @@ -101,7 +114,6 @@ namespace Nz * * \param number Int value */ - StringStream& StringStream::operator<<(int number) { m_strings.push_back(String::Number(number)); @@ -116,7 +128,6 @@ namespace Nz * * \param number Int value */ - StringStream& StringStream::operator<<(unsigned int number) { m_strings.push_back(String::Number(number)); @@ -131,7 +142,6 @@ namespace Nz * * \param number Long value */ - StringStream& StringStream::operator<<(long number) { m_strings.push_back(String::Number(number)); @@ -146,7 +156,6 @@ namespace Nz * * \param number Long value */ - StringStream& StringStream::operator<<(unsigned long number) { m_strings.push_back(String::Number(number)); @@ -161,7 +170,6 @@ namespace Nz * * \param number Long long value */ - StringStream& StringStream::operator<<(long long number) { m_strings.push_back(String::Number(number)); @@ -176,7 +184,6 @@ namespace Nz * * \param number Long long value */ - StringStream& StringStream::operator<<(unsigned long long number) { m_strings.push_back(String::Number(number)); @@ -191,7 +198,6 @@ namespace Nz * * \param number Float value */ - StringStream& StringStream::operator<<(float number) { m_strings.push_back(String::Number(number)); @@ -206,7 +212,6 @@ namespace Nz * * \param number Double value */ - StringStream& StringStream::operator<<(double number) { m_strings.push_back(String::Number(number)); @@ -221,7 +226,6 @@ namespace Nz * * \param number Long double value */ - StringStream& StringStream::operator<<(long double number) { m_strings.push_back(String::Number(number)); @@ -236,7 +240,6 @@ namespace Nz * * \param character Char value */ - StringStream& StringStream::operator<<(char character) { m_strings.push_back(String(character)); @@ -251,7 +254,6 @@ namespace Nz * * \param character Char value */ - StringStream& StringStream::operator<<(unsigned char character) { m_strings.push_back(String(static_cast(character))); @@ -266,7 +268,6 @@ namespace Nz * * \param string String value */ - StringStream& StringStream::operator<<(const char* string) { m_strings.push_back(string); @@ -281,7 +282,6 @@ namespace Nz * * \param string String value */ - StringStream& StringStream::operator<<(const std::string& string) { m_strings.push_back(string); @@ -296,7 +296,6 @@ namespace Nz * * \param string String value */ - StringStream& StringStream::operator<<(const String& string) { m_strings.push_back(string); @@ -311,7 +310,6 @@ namespace Nz * * \param ptr Pointer value */ - StringStream& StringStream::operator<<(const void* ptr) { m_strings.push_back(String::Pointer(ptr)); @@ -324,7 +322,6 @@ namespace Nz * \brief Converts this to Nz::String * \return The string representation of the stream */ - StringStream::operator String() const { return ToString(); From 884c8528f44efa62e78d6a4e21c5f00f5fdaca2d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:57:11 +0200 Subject: [PATCH 118/383] Utility/MaterialData: Fix FaceCulling being used for FaceSide Former-commit-id: c6dea66694fbcce15d266e280e8048048e2523fa [formerly be83776dfb6acd33b6e86bf4e8aa74eaf253826a] Former-commit-id: 018a5d60be15d1e476ccd739a9b171cc997ee355 --- include/Nazara/Utility/MaterialData.hpp | 1 + src/Nazara/Graphics/Material.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index ea8ffd0f5..66df97689 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -22,6 +22,7 @@ namespace Nz static constexpr const char* BackFaceStencilReference = "MatBackFaceStencilReference"; static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail"; static constexpr const char* Blending = "MatBlending"; + static constexpr const char* CullingSide = "MatCullingSide"; static constexpr const char* CustomDefined = "MatCustomDefined"; static constexpr const char* ColorWrite = "MatColorWrite"; static constexpr const char* DepthBuffer = "MatDepthBuffer"; diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 14da83eb0..651f2581c 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -170,6 +170,9 @@ namespace Nz if (matData.GetColorParameter(MaterialData::AmbientColor, &color)) SetAmbientColor(color); + if (matData.GetIntegerParameter(MaterialData::CullingSide, &iValue)) + SetFaceCulling(static_cast(iValue)); + if (matData.GetIntegerParameter(MaterialData::DepthFunc, &iValue)) SetDepthFunc(static_cast(iValue)); @@ -182,9 +185,6 @@ namespace Nz if (matData.GetIntegerParameter(MaterialData::DstBlend, &iValue)) SetDstBlend(static_cast(iValue)); - if (matData.GetIntegerParameter(MaterialData::FaceCulling, &iValue)) - SetFaceCulling(static_cast(iValue)); - if (matData.GetIntegerParameter(MaterialData::FaceFilling, &iValue)) SetFaceFilling(static_cast(iValue)); From 88e337cb7397bdd2ca4a2a9e1c3f70b2da9d8d7b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 08:57:29 +0200 Subject: [PATCH 119/383] Renderer/Texture: Remember FilePath when loading from an image Former-commit-id: ee6fbe380c66acd01db4ff9d30f3b7cfc0715d54 [formerly 0344d8b24eeee05094eba564c0a6a0f683244437] Former-commit-id: 2ed1b3bbad9bfa9eefdf69dcf664b7e6b9821dd8 --- src/Nazara/Renderer/Texture.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index b8bed61a0..458fb9992 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -582,6 +582,9 @@ namespace Nz } } + // Keep resource path info + SetFilePath(image.GetFilePath()); + destroyOnExit.Reset(); return true; From 84e9b3e148b3740ff56a08cf0197e8310fa8cde0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 09:00:35 +0200 Subject: [PATCH 120/383] Utility/OBJParser: Optimized loading Former-commit-id: f84e73928d0596d5933cadea572465ded864192f [formerly 0621b0e5e8f674273190ed08e5d984c085d190a9] Former-commit-id: 7dae4cbeff3644cdb0246ac3d077ddcb5bc7b51f --- include/Nazara/Utility/Formats/OBJParser.hpp | 50 ++-- include/Nazara/Utility/Formats/OBJParser.inl | 88 +++++++ src/Nazara/Utility/Formats/OBJLoader.cpp | 22 +- src/Nazara/Utility/Formats/OBJParser.cpp | 253 +++++++------------ 4 files changed, 222 insertions(+), 191 deletions(-) create mode 100644 include/Nazara/Utility/Formats/OBJParser.inl diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 90e653f93..64fd0ce4c 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -29,51 +29,59 @@ namespace Nz struct Face { - std::vector vertices; + std::size_t firstVertex; + std::size_t vertexCount; }; struct Mesh { std::vector faces; + std::vector vertices; String name; - unsigned int material; + std::size_t material; }; - OBJParser(Stream& stream$); - ~OBJParser(); + OBJParser() = default; + ~OBJParser() = default; - const String* GetMaterials() const; - unsigned int GetMaterialCount() const; - const Mesh* GetMeshes() const; - unsigned int GetMeshCount() const; - const String& GetMtlLib() const; - const Vector3f* GetNormals() const; - unsigned int GetNormalCount() const; - const Vector4f* GetPositions() const; - unsigned int GetPositionCount() const; - const Vector3f* GetTexCoords() const; - unsigned int GetTexCoordCount() const; + inline const String* GetMaterials() const; + inline unsigned int GetMaterialCount() const; + inline const Mesh* GetMeshes() const; + inline unsigned int GetMeshCount() const; + inline const String& GetMtlLib() const; + inline const Vector3f* GetNormals() const; + inline unsigned int GetNormalCount() const; + inline const Vector4f* GetPositions() const; + inline unsigned int GetPositionCount() const; + inline const Vector3f* GetTexCoords() const; + inline unsigned int GetTexCoordCount() const; - bool Parse(std::size_t reservedVertexCount = 100); + bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); private: bool Advance(bool required = true); - void Error(const String& message); - void Warning(const String& message); - void UnrecognizedLine(bool error = false); + template void Emit(const T& text) const; + inline void EmitLine() const; + template void EmitLine(const T& line) const; + inline void Error(const String& message); + inline void Flush() const; + inline void Warning(const String& message); + inline void UnrecognizedLine(bool error = false); std::vector m_meshes; std::vector m_materials; std::vector m_normals; std::vector m_positions; std::vector m_texCoords; - Stream& m_stream; + mutable Stream* m_currentStream; String m_currentLine; String m_mtlLib; + mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; - unsigned int m_streamFlags; }; } +#include + #endif // NAZARA_FORMATS_OBJPARSER_HPP diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl new file mode 100644 index 000000000..c8ea75e8c --- /dev/null +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -0,0 +1,88 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline const String* OBJParser::GetMaterials() const + { + return m_materials.data(); + } + + inline unsigned int OBJParser::GetMaterialCount() const + { + return m_materials.size(); + } + + inline const OBJParser::Mesh* OBJParser::GetMeshes() const + { + return m_meshes.data(); + } + + inline unsigned int OBJParser::GetMeshCount() const + { + return m_meshes.size(); + } + + inline const String& OBJParser::GetMtlLib() const + { + return m_mtlLib; + } + + inline const Vector3f* OBJParser::GetNormals() const + { + return m_normals.data(); + } + + inline unsigned int OBJParser::GetNormalCount() const + { + return m_normals.size(); + } + + inline const Vector4f* OBJParser::GetPositions() const + { + return m_positions.data(); + } + + inline unsigned int OBJParser::GetPositionCount() const + { + return m_positions.size(); + } + + inline const Vector3f* OBJParser::GetTexCoords() const + { + return m_texCoords.data(); + } + + inline unsigned int OBJParser::GetTexCoordCount() const + { + return m_texCoords.size(); + } + + + inline void OBJParser::Error(const String& message) + { + NazaraError(message + " at line #" + String::Number(m_lineCount)); + } + + inline void OBJParser::Warning(const String& message) + { + NazaraWarning(message + " at line #" + String::Number(m_lineCount)); + } + + inline void OBJParser::UnrecognizedLine(bool error) + { + String message = "Unrecognized \"" + m_currentLine + '"'; + + if (error) + Error(message); + else + Warning(message); + } +} + +#include diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 05b39f81f..720b5ec5d 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -123,8 +123,8 @@ namespace Nz if (!parameters.custom.GetIntegerParameter("NativeOBJLoader_VertexCount", &reservedVertexCount)) reservedVertexCount = 100; - OBJParser parser(stream); - if (!parser.Parse(reservedVertexCount)) + OBJParser parser; + if (!parser.Parse(stream, reservedVertexCount)) { NazaraError("OBJ parser failed"); return false; @@ -177,23 +177,24 @@ namespace Nz { bool operator()(const OBJParser::FaceVertex& lhs, const OBJParser::FaceVertex& rhs) const { - return lhs.normal == rhs.normal && + return lhs.normal == rhs.normal && lhs.position == rhs.position && lhs.texCoord == rhs.texCoord; } }; std::unordered_map vertices; + vertices.reserve(meshes[i].vertices.size()); unsigned int vertexCount = 0; for (unsigned int j = 0; j < faceCount; ++j) { - unsigned int faceVertexCount = meshes[i].faces[j].vertices.size(); + unsigned int faceVertexCount = meshes[i].faces[j].vertexCount; faceIndices.resize(faceVertexCount); for (unsigned int k = 0; k < faceVertexCount; ++k) { - const OBJParser::FaceVertex& vertex = meshes[i].faces[j].vertices[k]; + const OBJParser::FaceVertex& vertex = meshes[i].vertices[meshes[i].faces[j].firstVertex + k]; auto it = vertices.find(vertex); if (it == vertices.end()) @@ -202,6 +203,7 @@ namespace Nz faceIndices[k] = it->second; } + // Triangulation for (unsigned int k = 1; k < faceVertexCount-1; ++k) { indices.push_back(faceIndices[0]); @@ -233,17 +235,17 @@ namespace Nz MeshVertex& vertex = meshVertices[index]; - const Vector4f& vec = positions[vertexIndices.position]; + const Vector4f& vec = positions[vertexIndices.position-1]; vertex.position = Vector3f(parameters.matrix * vec); - if (vertexIndices.normal >= 0) - vertex.normal = normals[vertexIndices.normal]; + if (vertexIndices.normal > 0) + vertex.normal = normals[vertexIndices.normal-1]; else hasNormals = false; - if (vertexIndices.texCoord >= 0) + if (vertexIndices.texCoord > 0) { - const Vector3f& uvw = texCoords[vertexIndices.texCoord]; + const Vector3f& uvw = texCoords[vertexIndices.texCoord-1]; vertex.uv.Set(uvw.x, (parameters.flipUVs) ? 1.f - uvw.y : uvw.y); // Inversion des UVs si demandé } else diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index c0daf1f84..03a251d5a 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include #include #include @@ -13,77 +13,22 @@ namespace Nz { - OBJParser::OBJParser(Stream& stream) : - m_stream(stream), - m_streamFlags(stream.GetStreamOptions()) //< Saves stream flags + bool OBJParser::Parse(Nz::Stream& stream, std::size_t reservedVertexCount) { - m_stream.EnableTextMode(true); - } + m_currentStream = &stream; - OBJParser::~OBJParser() - { - // Reset stream flags - if ((m_streamFlags & StreamOption_Text) == 0) - m_stream.EnableTextMode(false); - } + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); - const String* OBJParser::GetMaterials() const - { - return m_materials.data(); - } + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } - unsigned int OBJParser::GetMaterialCount() const - { - return m_materials.size(); - } - - const OBJParser::Mesh* OBJParser::GetMeshes() const - { - return m_meshes.data(); - } - - unsigned int OBJParser::GetMeshCount() const - { - return m_meshes.size(); - } - - const String& OBJParser::GetMtlLib() const - { - return m_mtlLib; - } - - const Vector3f* OBJParser::GetNormals() const - { - return m_normals.data(); - } - - unsigned int OBJParser::GetNormalCount() const - { - return m_normals.size(); - } - - const Vector4f* OBJParser::GetPositions() const - { - return m_positions.data(); - } - - unsigned int OBJParser::GetPositionCount() const - { - return m_positions.size(); - } - - const Vector3f* OBJParser::GetTexCoords() const - { - return m_texCoords.data(); - } - - unsigned int OBJParser::GetTexCoordCount() const - { - return m_texCoords.size(); - } - - bool OBJParser::Parse(std::size_t reservedVertexCount) - { String matName, meshName; matName = meshName = "default"; m_keepLastLine = false; @@ -100,32 +45,56 @@ namespace Nz m_positions.reserve(reservedVertexCount); m_texCoords.reserve(reservedVertexCount); - // On va regrouper les meshs par nom et par matériau - using FaceVec = std::vector; - using MatPair = std::pair; - std::unordered_map> meshes; + // Sort meshes by material and group + using MatPair = std::pair; + std::unordered_map> meshesByName; - unsigned int matIndex = 0; - auto GetMaterial = [&meshes, &matIndex] (const String& mesh, const String& material) -> FaceVec* + std::size_t faceReserve = 0; + std::size_t vertexReserve = 0; + unsigned int matCount = 0; + auto GetMaterial = [&] (const String& meshName, const String& matName) -> Mesh* { - auto& map = meshes[mesh]; - auto it = map.find(material); + auto& map = meshesByName[meshName]; + auto it = map.find(matName); if (it == map.end()) - it = map.insert(std::make_pair(material, MatPair(FaceVec(), matIndex++))).first; + it = map.insert(std::make_pair(matName, MatPair(Mesh(), matCount++))).first; + + Mesh& mesh = it->second.first; + + mesh.faces.reserve(faceReserve); + mesh.vertices.reserve(vertexReserve); + faceReserve = 0; + vertexReserve = 0; return &(it->second.first); }; // On prépare le mesh par défaut - FaceVec* currentMesh = nullptr; + Mesh* currentMesh = nullptr; while (Advance(false)) { switch (std::tolower(m_currentLine[0])) { - case 'f': // Une face + case '#': //< Comment + // Some softwares write comments to gives the number of vertex/faces an importer can expect + std::size_t data; + if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %zu", &data) == 1) + m_positions.reserve(data); + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %zu", &data) == 1) + m_normals.reserve(data); + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %zu", &data) == 1) + m_texCoords.reserve(data); + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %zu", &data) == 1) + faceReserve = data; + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %zu", &data) == 1) + vertexReserve = data; + + break; + + case 'f': //< Face { - if (m_currentLine.GetSize() < 7) // Le minimum syndical pour définir une face de trois sommets (f 1 2 3) + if (m_currentLine.GetSize() < 7) // Since we only treat triangles, this is the minimum length of a face line (f 1 2 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); @@ -142,17 +111,23 @@ namespace Nz break; } + if (!currentMesh) + currentMesh = GetMaterial(meshName, matName); + Face face; - face.vertices.resize(vertexCount); + face.firstVertex = currentMesh->vertices.size(); + face.vertexCount = vertexCount; + + currentMesh->vertices.resize(face.firstVertex + vertexCount, FaceVertex{0, 0, 0}); bool error = false; unsigned int pos = 2; for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - int& n = face.vertices[i].normal; - int& p = face.vertices[i].position; - int& t = face.vertices[i].texCoord; + int& n = currentMesh->vertices[face.firstVertex + i].normal; + int& p = currentMesh->vertices[face.firstVertex + i].position; + int& t = currentMesh->vertices[face.firstVertex + i].texCoord; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { @@ -168,22 +143,13 @@ namespace Nz error = true; break; } - else - { - n = 0; - t = 0; - } } - else - n = 0; } - else - t = 0; } if (p < 0) { - p += m_positions.size(); + p += m_positions.size() - 1; if (p < 0) { Error("Vertex index out of range (" + String::Number(p) + " < 0"); @@ -191,48 +157,42 @@ namespace Nz break; } } - else - p--; if (n < 0) { - n += m_normals.size(); + n += m_normals.size() - 1; if (n < 0) { - Error("Vertex index out of range (" + String::Number(n) + " < 0"); + Error("Normal index out of range (" + String::Number(n) + " < 0"); error = true; break; } } - else - n--; if (t < 0) { - t += m_texCoords.size(); + t += m_texCoords.size() - 1; if (t < 0) { - Error("Vertex index out of range (" + String::Number(t) + " < 0"); + Error("Texture coordinates index out of range (" + String::Number(t) + " < 0"); error = true; break; } } - else - t--; - if (static_cast(p) >= m_positions.size()) + if (static_cast(p) > m_positions.size()) { Error("Vertex index out of range (" + String::Number(p) + " >= " + String::Number(m_positions.size()) + ')'); error = true; break; } - else if (n >= 0 && static_cast(n) >= m_normals.size()) + else if (n != 0 && static_cast(n) > m_normals.size()) { Error("Normal index out of range (" + String::Number(n) + " >= " + String::Number(m_normals.size()) + ')'); error = true; break; } - else if (t >= 0 && static_cast(t) >= m_texCoords.size()) + else if (t != 0 && static_cast(t) > m_texCoords.size()) { Error("TexCoord index out of range (" + String::Number(t) + " >= " + String::Number(m_texCoords.size()) + ')'); error = true; @@ -243,17 +203,14 @@ namespace Nz } if (!error) - { - if (!currentMesh) - currentMesh = GetMaterial(meshName, matName); - - currentMesh->push_back(std::move(face)); - } + currentMesh->faces.push_back(std::move(face)); + else + currentMesh->vertices.resize(face.firstVertex); //< Remove vertices break; } - case 'm': + case 'm': //< MTLLib #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0).ToLower() != "mtllib") UnrecognizedLine(); @@ -262,8 +219,8 @@ namespace Nz m_mtlLib = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); break; - case 'g': - case 'o': + case 'g': //< Group (inside a mesh) + case 'o': //< Object (defines a mesh) { if (m_currentLine.GetSize() <= 2 || m_currentLine[1] != ' ') { @@ -283,12 +240,12 @@ namespace Nz } meshName = objectName; - currentMesh = GetMaterial(meshName, matName); + currentMesh = nullptr; break; } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - case 's': + case 's': //< Smooth if (m_currentLine.GetSize() <= 2 || m_currentLine[1] == ' ') { String param = m_currentLine.SubString(2); @@ -298,15 +255,16 @@ namespace Nz else UnrecognizedLine(); break; - #endif + #endif - case 'u': + case 'u': //< Usemtl #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0) != "usemtl") UnrecognizedLine(); #endif matName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); + currentMesh = nullptr; if (matName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING @@ -314,18 +272,16 @@ namespace Nz #endif break; } - - currentMesh = GetMaterial(meshName, matName); break; - case 'v': + case 'v': //< Position/Normal/Texcoords { String word = m_currentLine.GetWord(0).ToLower(); if (word == 'v') { Vector4f vertex(Vector3f::Zero(), 1.f); unsigned int paramCount = std::sscanf(&m_currentLine[2], "%f %f %f %f", &vertex.x, &vertex.y, &vertex.z, &vertex.w); - if (paramCount >= 3) + if (paramCount >= 1) m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else @@ -371,26 +327,24 @@ namespace Nz } std::unordered_map materials; - m_materials.resize(matIndex); + m_materials.resize(matCount); - for (auto& meshIt : meshes) + for (auto& meshPair : meshesByName) { - for (auto& matIt : meshIt.second) + for (auto& matPair : meshPair.second) { - auto& faceVec = matIt.second.first; - unsigned int index = matIt.second.second; - if (!faceVec.empty()) + Mesh& mesh = matPair.second.first; + unsigned int index = matPair.second.second; + if (!mesh.faces.empty()) { - Mesh mesh; - mesh.faces = std::move(faceVec); - mesh.name = meshIt.first; + mesh.name = meshPair.first; - auto it = materials.find(matIt.first); + auto it = materials.find(matPair.first); if (it == materials.end()) { mesh.material = index; - materials[matIt.first] = index; - m_materials[index] = matIt.first; + materials[matPair.first] = index; + m_materials[index] = matPair.first; } else mesh.material = it->second; @@ -415,7 +369,7 @@ namespace Nz { do { - if (m_stream.EndOfStream()) + if (m_currentStream->EndOfStream()) { if (required) Error("Incomplete OBJ file"); @@ -425,9 +379,8 @@ namespace Nz m_lineCount++; - m_currentLine = m_stream.ReadLine(); - m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires - m_currentLine.Simplify(); // Pour un traitement plus simple + m_currentLine = m_currentStream->ReadLine(); + m_currentLine.Simplify(); // Simplify lines (convert multiple blanks into a single space and trims) } while (m_currentLine.IsEmpty()); } @@ -436,24 +389,4 @@ namespace Nz return true; } - - void OBJParser::Error(const String& message) - { - NazaraError(message + " at line #" + String::Number(m_lineCount)); - } - - void OBJParser::Warning(const String& message) - { - NazaraWarning(message + " at line #" + String::Number(m_lineCount)); - } - - void OBJParser::UnrecognizedLine(bool error) - { - String message = "Unrecognized \"" + m_currentLine + '"'; - - if (error) - Error(message); - else - Warning(message); - } } From 087c3b104b6bdf42f1a72878783e932b27801153 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 09:00:50 +0200 Subject: [PATCH 121/383] Utility/OBJParser: Add saving Former-commit-id: e05fec0cb2309c0a935ff1293b698433390675a7 [formerly bffd283b0c04e45df50adaa7b061aacdda10a0ec] Former-commit-id: 7792044687e73fa8d5862aa15de373370023249a --- include/Nazara/Utility/Formats/OBJParser.hpp | 2 + include/Nazara/Utility/Formats/OBJParser.inl | 25 ++++ src/Nazara/Utility/Formats/OBJParser.cpp | 142 +++++++++++++++++++ 3 files changed, 169 insertions(+) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 64fd0ce4c..79aa1824a 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -58,6 +58,8 @@ namespace Nz bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); + bool Save(Stream& stream) const; + private: bool Advance(bool required = true); template void Emit(const T& text) const; diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index c8ea75e8c..7cd0060b4 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -63,12 +63,37 @@ namespace Nz return m_texCoords.size(); } + template + void OBJParser::Emit(const T& text) const + { + m_outputStream << text; + if (m_outputStream.GetBufferSize() > 1024 * 1024) + Flush(); + } + + inline void OBJParser::EmitLine() const + { + Emit('\n'); + } + + template + void OBJParser::EmitLine(const T& line) const + { + Emit(line); + Emit('\n'); + } inline void OBJParser::Error(const String& message) { NazaraError(message + " at line #" + String::Number(m_lineCount)); } + inline void OBJParser::Flush() const + { + m_currentStream->Write(m_outputStream); + m_outputStream.Clear(); + } + inline void OBJParser::Warning(const String& message) { NazaraWarning(message + " at line #" + String::Number(m_lineCount)); diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 03a251d5a..a05ef6960 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -363,6 +363,148 @@ namespace Nz return true; } + bool OBJParser::Save(Stream& stream) const + { + m_currentStream = &stream; + + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); + + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } + + m_outputStream.Clear(); + + EmitLine("# Exported by Nazara Engine"); + + if (!m_mtlLib.IsEmpty()) + { + Emit("mtlib "); + EmitLine(m_mtlLib); + EmitLine(); + } + + Emit("# position count: "); + EmitLine(m_positions.size()); + + for (const Nz::Vector4f& position : m_positions) + { + Emit("v "); + Emit(position.x); + Emit(' '); + Emit(position.y); + if (!NumberEquals(position.z, 0.f) || !NumberEquals(position.w, 1.f)) + { + Emit(' '); + Emit(position.z); + + if (!NumberEquals(position.w, 1.f)) + { + Emit(' '); + Emit(position.w); + } + } + EmitLine(); + } + EmitLine(); + + Emit("# normal count: "); + EmitLine(m_normals.size()); + + for (const Nz::Vector3f& normal : m_normals) + { + Emit("vn "); + Emit(normal.x); + Emit(' '); + Emit(normal.y); + Emit(' '); + Emit(normal.y); + EmitLine(); + } + EmitLine(); + + Emit("# texcoords count: "); + EmitLine(m_texCoords.size()); + + for (const Nz::Vector3f& uvw : m_texCoords) + { + Emit("vt "); + Emit(uvw.x); + Emit(' '); + Emit(uvw.y); + if (NumberEquals(uvw.z, 0.f)) + { + Emit(' '); + Emit(uvw.z); + } + EmitLine(); + } + EmitLine(); + + std::unordered_map /* meshes*/> meshesByMaterials; + std::size_t meshIndex = 0; + for (const Mesh& mesh : m_meshes) + meshesByMaterials[mesh.material].push_back(meshIndex++); + + for (auto& pair : meshesByMaterials) + { + Emit("usemtl "); + EmitLine(m_materials[pair.first]); + Emit("# groups count: "); + EmitLine(pair.second.size()); + EmitLine(); + + for (std::size_t meshIndex : pair.second) + { + const Mesh& mesh = m_meshes[meshIndex]; + + Emit("g "); + EmitLine(mesh.name); + EmitLine(); + + Emit("# face count: "); + EmitLine(mesh.faces.size()); + Emit("# vertex count: "); + EmitLine(mesh.vertices.size()); + + for (const Face& face : mesh.faces) + { + Emit('f'); + for (std::size_t i = 0; i < face.vertexCount; ++i) + { + Emit(' '); + const FaceVertex& faceVertex = mesh.vertices[face.firstVertex + i]; + Emit(faceVertex.position); + if (faceVertex.texCoord != 0 || faceVertex.normal != 0) + { + Emit('/'); + if (faceVertex.texCoord != 0) + Emit(faceVertex.texCoord); + + if (faceVertex.normal != 0) + { + Emit('/'); + Emit(faceVertex.normal); + } + } + } + EmitLine(); + } + } + EmitLine(); + } + + Flush(); + + return true; + } + bool OBJParser::Advance(bool required) { if (!m_keepLastLine) From 9a6de9f7ac243b67f237cabbd0f3cc544da4ad8b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 09:01:08 +0200 Subject: [PATCH 122/383] Math/Vector4: Fix w value when converting from Vector3 Former-commit-id: 0ad39219de839bb1de859baac059441e36c04444 [formerly d2516303dd597418bd2939f737617f0fad1f0da4] Former-commit-id: 7d5223e4e34b50dbb4ec9e0d22c7801470099d2a --- include/Nazara/Math/Vector4.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index d1e51433a..b84a4cb17 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -28,7 +28,7 @@ namespace Nz explicit Vector4(T scale); Vector4(const T vec[4]); Vector4(const Vector2& vec, T Z = 0.0, T W = 1.0); - Vector4(const Vector3& vec, T W = 0.0); + Vector4(const Vector3& vec, T W = 1.0); template explicit Vector4(const Vector4& vec); Vector4(const Vector4& vec) = default; ~Vector4() = default; From 1b3cf51d6d2644ca520c8a29d890a3b1ea7715f5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:07:43 +0200 Subject: [PATCH 123/383] Ndk/GraphicsComponent: Add GetAttachedRenderables Former-commit-id: 8668ac5a0684b27740cf67caaedc0dad22b6489f [formerly 6a0ea4747d98b53aa30e8a68a0c1d752c902acfe] Former-commit-id: 9291bad16c33dc5fe117e63a2fcb459b38c70a65 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 5 +++++ SDK/include/NDK/Components/GraphicsComponent.inl | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index aed427105..4ea76d0d8 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -23,6 +23,8 @@ namespace Ndk friend class RenderSystem; public: + using RenderableList = std::vector; + GraphicsComponent() = default; inline GraphicsComponent(const GraphicsComponent& graphicsComponent); ~GraphicsComponent() = default; @@ -38,6 +40,9 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; + inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline std::size_t GetAttachedRenderableCount() const; + inline const Nz::BoundingVolumef& GetBoundingVolume() const; static ComponentIndex componentIndex; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 9ca100d0e..b38ce6dd6 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -79,6 +79,20 @@ namespace Ndk UpdateTransformMatrix(); } + inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const + { + NazaraAssert(renderables, "Invalid renderable list"); + + renderables->reserve(renderables->size() + m_renderables.size()); + for (const Renderable& r : m_renderables) + renderables->push_back(r.renderable); + } + + inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const + { + return m_renderables.size(); + } + inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const { EnsureBoundingVolumeUpdate(); From 5ba73bf379d4160ac145456f6f080b19617e77f3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:17:18 +0200 Subject: [PATCH 124/383] Fix typo Former-commit-id: 035f2fbce2bec447f0a1b08dd5e590de5a098a7c [formerly 970c0e10c43e7d0ea2e7818382ef2667e3bd61dc] Former-commit-id: ddc449ede5f389146a73e461542fc3779039b305 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 4ea76d0d8..a7ac3ebc2 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -40,7 +40,7 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; - inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline void GetAttachedRenderables(RenderableList* renderables) const; inline std::size_t GetAttachedRenderableCount() const; inline const Nz::BoundingVolumef& GetBoundingVolume() const; From 26289139a38b9ad2973d50cc6943e18476aefb8c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:34:45 +0200 Subject: [PATCH 125/383] Utility/OBJParser: Prepare for saving Former-commit-id: 89d82ac533c72033927557251278dd1544002a54 [formerly dc3b1ff5e00608ed0dfdee9b57ff6986a1d5ac33] Former-commit-id: ee2b46fbfb0a0f7cd96ae1b35ec1af30342cd2fb --- include/Nazara/Utility/Formats/OBJParser.hpp | 67 ++++++++++++-------- include/Nazara/Utility/Formats/OBJParser.inl | 64 +++++++++++++++++++ src/Nazara/Utility/Formats/OBJLoader.cpp | 4 +- src/Nazara/Utility/Formats/OBJLoader.hpp | 4 +- src/Nazara/Utility/Formats/OBJParser.cpp | 10 ++- 5 files changed, 117 insertions(+), 32 deletions(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 79aa1824a..b9c5e41c3 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -20,12 +20,41 @@ namespace Nz class NAZARA_UTILITY_API OBJParser { public: - struct FaceVertex - { - int normal; - int position; - int texCoord; - }; + struct Face; + struct FaceVertex; + struct Mesh; + + OBJParser() = default; + ~OBJParser() = default; + + inline void Clear(); + + inline String* GetMaterials(); + inline const String* GetMaterials() const; + inline unsigned int GetMaterialCount() const; + inline Mesh* GetMeshes(); + inline const Mesh* GetMeshes() const; + inline unsigned int GetMeshCount() const; + inline const String& GetMtlLib() const; + inline Vector3f* GetNormals(); + inline const Vector3f* GetNormals() const; + inline unsigned int GetNormalCount() const; + inline Vector4f* GetPositions(); + inline const Vector4f* GetPositions() const; + inline unsigned int GetPositionCount() const; + inline Vector3f* GetTexCoords(); + inline const Vector3f* GetTexCoords() const; + inline unsigned int GetTexCoordCount() const; + + bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); + + bool Save(Stream& stream) const; + + inline String* SetMaterialCount(std::size_t materialCount); + inline Mesh* SetMeshCount(std::size_t meshCount); + inline Vector3f* SetNormalCount(std::size_t normalCount); + inline Vector4f* SetPositionCount(std::size_t positionCount); + inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); struct Face { @@ -33,6 +62,13 @@ namespace Nz std::size_t vertexCount; }; + struct FaceVertex + { + std::size_t normal; + std::size_t position; + std::size_t texCoord; + }; + struct Mesh { std::vector faces; @@ -41,25 +77,6 @@ namespace Nz std::size_t material; }; - OBJParser() = default; - ~OBJParser() = default; - - inline const String* GetMaterials() const; - inline unsigned int GetMaterialCount() const; - inline const Mesh* GetMeshes() const; - inline unsigned int GetMeshCount() const; - inline const String& GetMtlLib() const; - inline const Vector3f* GetNormals() const; - inline unsigned int GetNormalCount() const; - inline const Vector4f* GetPositions() const; - inline unsigned int GetPositionCount() const; - inline const Vector3f* GetTexCoords() const; - inline unsigned int GetTexCoordCount() const; - - bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); - - bool Save(Stream& stream) const; - private: bool Advance(bool required = true); template void Emit(const T& text) const; diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 7cd0060b4..a4fcffaec 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -8,6 +8,20 @@ namespace Nz { + inline void OBJParser::Clear() + { + m_materials.clear(); + m_meshes.clear(); + m_positions.clear(); + m_normals.clear(); + m_texCoords.clear(); + } + + inline String* OBJParser::GetMaterials() + { + return m_materials.data(); + } + inline const String* OBJParser::GetMaterials() const { return m_materials.data(); @@ -18,6 +32,11 @@ namespace Nz return m_materials.size(); } + inline OBJParser::Mesh* OBJParser::GetMeshes() + { + return m_meshes.data(); + } + inline const OBJParser::Mesh* OBJParser::GetMeshes() const { return m_meshes.data(); @@ -33,6 +52,11 @@ namespace Nz return m_mtlLib; } + inline Vector3f* OBJParser::GetNormals() + { + return m_normals.data(); + } + inline const Vector3f* OBJParser::GetNormals() const { return m_normals.data(); @@ -43,6 +67,11 @@ namespace Nz return m_normals.size(); } + inline Vector4f* OBJParser::GetPositions() + { + return m_positions.data(); + } + inline const Vector4f* OBJParser::GetPositions() const { return m_positions.data(); @@ -53,6 +82,11 @@ namespace Nz return m_positions.size(); } + inline Vector3f* OBJParser::GetTexCoords() + { + return m_texCoords.data(); + } + inline const Vector3f* OBJParser::GetTexCoords() const { return m_texCoords.data(); @@ -63,6 +97,36 @@ namespace Nz return m_texCoords.size(); } + inline String* OBJParser::SetMaterialCount(std::size_t materialCount) + { + m_materials.resize(materialCount); + return m_materials.data(); + } + + inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount) + { + m_meshes.resize(meshCount); + return m_meshes.data(); + } + + inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) + { + m_normals.resize(normalCount); + return m_normals.data(); + } + + inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount) + { + m_positions.resize(positionCount); + return m_positions.data(); + } + + inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount) + { + m_texCoords.resize(texCoordCount); + return m_texCoords.data(); + } + template void OBJParser::Emit(const T& text) const { diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 720b5ec5d..a8d5d68ec 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -298,12 +298,12 @@ namespace Nz namespace Loaders { - void RegisterOBJ() + void RegisterOBJLoader() { MeshLoader::RegisterLoader(IsSupported, Check, Load); } - void UnregisterOBJ() + void UnregisterOBJLoader() { MeshLoader::UnregisterLoader(IsSupported, Check, Load); } diff --git a/src/Nazara/Utility/Formats/OBJLoader.hpp b/src/Nazara/Utility/Formats/OBJLoader.hpp index 05a3efdff..46dd8d976 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.hpp +++ b/src/Nazara/Utility/Formats/OBJLoader.hpp @@ -13,8 +13,8 @@ namespace Nz { namespace Loaders { - void RegisterOBJ(); - void UnregisterOBJ(); + void RegisterOBJLoader(); + void UnregisterOBJLoader(); } } diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index a05ef6960..5c941e938 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - int& n = currentMesh->vertices[face.firstVertex + i].normal; - int& p = currentMesh->vertices[face.firstVertex + i].position; - int& t = currentMesh->vertices[face.firstVertex + i].texCoord; + std::size_t n = 0; + std::size_t p = 0; + std::size_t t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { @@ -199,6 +199,10 @@ namespace Nz break; } + currentMesh->vertices[face.firstVertex + i].normal = static_cast(n); + currentMesh->vertices[face.firstVertex + i].position = static_cast(p); + currentMesh->vertices[face.firstVertex + i].texCoord = static_cast(t); + pos += offset; } From b9051067e0ab4da0012b7d7c5046160dca94b077 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:35:36 +0200 Subject: [PATCH 126/383] Utility/IndexMapper: Makes it work without index buffers (sequential mode) Former-commit-id: 93f33efed85f0f3464fa7db604dbaaa488679fcd [formerly 77614134455dd70c2bebdb611aa1043da078da9b] Former-commit-id: 635b19330864dbbba3a15deb7cb1a70742e65cd5 --- include/Nazara/Utility/IndexMapper.hpp | 7 +- src/Nazara/Utility/IndexMapper.cpp | 89 +++++++++++++++----------- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/include/Nazara/Utility/IndexMapper.hpp b/include/Nazara/Utility/IndexMapper.hpp index 9dd6a5c46..7f632f196 100644 --- a/include/Nazara/Utility/IndexMapper.hpp +++ b/include/Nazara/Utility/IndexMapper.hpp @@ -23,9 +23,10 @@ namespace Nz class NAZARA_UTILITY_API IndexMapper { public: - IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite); - IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly); - IndexMapper(const SubMesh* subMesh); + IndexMapper(IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadWrite, std::size_t indexCount = 0); + IndexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite); + IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access = BufferAccess_ReadOnly, std::size_t indexCount = 0); + IndexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly); ~IndexMapper() = default; UInt32 Get(unsigned int i) const; diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index adf80a764..5a664128c 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -12,6 +12,13 @@ namespace Nz { namespace { + UInt32 GetterSequential(const void* buffer, unsigned int i) + { + NazaraUnused(buffer); + + return i; + } + UInt32 Getter16(const void* buffer, unsigned int i) { const UInt16* ptr = static_cast(buffer); @@ -42,61 +49,67 @@ namespace Nz } } - IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access) : - m_indexCount(indexBuffer->GetIndexCount()) + IndexMapper::IndexMapper(IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) : + m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount()) { - #if NAZARA_UTILITY_SAFE - if (!indexBuffer) - { - NazaraError("Index buffer must be valid"); - return; - } - #endif + NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer"); - if (!m_mapper.Map(indexBuffer, access)) - NazaraError("Failed to map buffer"); ///TODO: Unexcepted - - if (indexBuffer->HasLargeIndices()) + if (indexBuffer) { - m_getter = Getter32; - if (access != BufferAccess_ReadOnly) - m_setter = Setter32; + if (!m_mapper.Map(indexBuffer, access)) + NazaraError("Failed to map buffer"); ///TODO: Unexcepted + + if (indexBuffer->HasLargeIndices()) + { + m_getter = Getter32; + if (access != BufferAccess_ReadOnly) + m_setter = Setter32; + else + m_setter = SetterError; + } else - m_setter = SetterError; + { + m_getter = Getter16; + if (access != BufferAccess_ReadOnly) + m_setter = Setter16; + else + m_setter = SetterError; + } } else { - m_getter = Getter16; - if (access != BufferAccess_ReadOnly) - m_setter = Setter16; - else - m_setter = SetterError; + m_getter = GetterSequential; + m_setter = SetterError; } } - IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access) : + IndexMapper::IndexMapper(SubMesh* subMesh, BufferAccess access) : + IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount()) + { + } + + IndexMapper::IndexMapper(const IndexBuffer* indexBuffer, BufferAccess access, std::size_t indexCount) : m_setter(SetterError), - m_indexCount(indexBuffer->GetIndexCount()) + m_indexCount((indexCount != 0) ? indexCount : indexBuffer->GetIndexCount()) { - #if NAZARA_UTILITY_SAFE - if (!indexBuffer) + NazaraAssert(indexCount != 0 || indexBuffer, "Invalid index count with invalid index buffer"); + + if (indexBuffer) { - NazaraError("Index buffer must be valid"); - return; + if (!m_mapper.Map(indexBuffer, access)) + NazaraError("Failed to map buffer"); ///TODO: Unexcepted + + if (indexBuffer->HasLargeIndices()) + m_getter = Getter32; + else + m_getter = Getter16; } - #endif - - if (!m_mapper.Map(indexBuffer, access)) - NazaraError("Failed to map buffer"); ///TODO: Unexcepted - - if (indexBuffer->HasLargeIndices()) - m_getter = Getter32; else - m_getter = Getter16; + m_getter = GetterSequential; } - IndexMapper::IndexMapper(const SubMesh* subMesh) : - IndexMapper(subMesh->GetIndexBuffer()) + IndexMapper::IndexMapper(const SubMesh* subMesh, BufferAccess access) : + IndexMapper(subMesh->GetIndexBuffer(), access, (subMesh->GetIndexBuffer()) ? 0 : subMesh->GetVertexCount()) { } From 18e03246faf2e4066498cc68ad73173eeefa33b2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:35:48 +0200 Subject: [PATCH 127/383] Utility: Fix an oopsie Former-commit-id: 18e56c87721c6498b6e77da4e4de307e6afeb10c [formerly bea39556b13d62b2a48207b2e6dfac1ab9b551cc] Former-commit-id: 4fa98afe5a20b95cd90a3f3ad66391efe6d31930 --- src/Nazara/Utility/Utility.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 78553ce54..ae5b5066d 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -124,7 +124,7 @@ namespace Nz Loaders::RegisterMD5Anim(); // Loader de fichiers .md5anim (v10) // Mesh (text) - Loaders::RegisterOBJ(); + Loaders::RegisterOBJLoader(); // Mesh Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8) @@ -162,7 +162,7 @@ namespace Nz Loaders::UnregisterMD2(); Loaders::UnregisterMD5Anim(); Loaders::UnregisterMD5Mesh(); - Loaders::UnregisterOBJ(); + Loaders::UnregisterOBJLoader(); Loaders::UnregisterPCX(); Loaders::UnregisterSTBLoader(); Loaders::UnregisterSTBSaver(); From 96dd854ec97d05d808ab38d2b982b053216842f4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:36:42 +0200 Subject: [PATCH 128/383] Utility: Allow TriangleIterator and VertexMapper to take constant submesh Former-commit-id: f2a4eeeecf5868a2e51289d3d25d878be9b6bf3d [formerly 028fafc2cf156502a22dd269ac8b14a9accaf80c] Former-commit-id: 32c9bb55cb63030e67f3287d4c26ef29f1edccbf --- include/Nazara/Utility/TriangleIterator.hpp | 2 +- include/Nazara/Utility/VertexMapper.hpp | 2 ++ src/Nazara/Utility/TriangleIterator.cpp | 13 ++++++-- src/Nazara/Utility/VertexMapper.cpp | 36 +++++++++++++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Utility/TriangleIterator.hpp b/include/Nazara/Utility/TriangleIterator.hpp index 0addb1836..32c9ceb07 100644 --- a/include/Nazara/Utility/TriangleIterator.hpp +++ b/include/Nazara/Utility/TriangleIterator.hpp @@ -19,7 +19,7 @@ namespace Nz { public: TriangleIterator(PrimitiveMode primitiveMode, const IndexBuffer* indexBuffer); - TriangleIterator(SubMesh* subMesh); + TriangleIterator(const SubMesh* subMesh); ~TriangleIterator() = default; bool Advance(); diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index 3dc9accdb..e18250d7c 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -22,6 +22,8 @@ namespace Nz public: VertexMapper(SubMesh* subMesh, BufferAccess access = BufferAccess_ReadWrite); VertexMapper(VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadWrite); + VertexMapper(const SubMesh* subMesh, BufferAccess access = BufferAccess_ReadOnly); + VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly); ~VertexMapper(); template SparsePtr GetComponentPtr(VertexComponent component); diff --git a/src/Nazara/Utility/TriangleIterator.cpp b/src/Nazara/Utility/TriangleIterator.cpp index 0c6830c87..53086ddb8 100644 --- a/src/Nazara/Utility/TriangleIterator.cpp +++ b/src/Nazara/Utility/TriangleIterator.cpp @@ -17,12 +17,19 @@ namespace Nz m_triangleIndices[1] = m_indexMapper.Get(1); m_triangleIndices[2] = m_indexMapper.Get(2); - m_indexCount = indexBuffer->GetIndexCount(); + m_indexCount = m_indexMapper.GetIndexCount(); } - TriangleIterator::TriangleIterator(SubMesh* subMesh) : - TriangleIterator(subMesh->GetPrimitiveMode(), subMesh->GetIndexBuffer()) + TriangleIterator::TriangleIterator(const SubMesh* subMesh) : + m_primitiveMode(subMesh->GetPrimitiveMode()), + m_indexMapper(subMesh, BufferAccess_ReadOnly) { + m_currentIndex = 3; + m_triangleIndices[0] = m_indexMapper.Get(0); + m_triangleIndices[1] = m_indexMapper.Get(1); + m_triangleIndices[2] = m_indexMapper.Get(2); + + m_indexCount = m_indexMapper.GetIndexCount(); } bool TriangleIterator::Advance() diff --git a/src/Nazara/Utility/VertexMapper.cpp b/src/Nazara/Utility/VertexMapper.cpp index 1edbdc7f8..158dae801 100644 --- a/src/Nazara/Utility/VertexMapper.cpp +++ b/src/Nazara/Utility/VertexMapper.cpp @@ -47,6 +47,42 @@ namespace Nz ErrorFlags flags(ErrorFlag_ThrowException, true); m_mapper.Map(vertexBuffer, access); } + + VertexMapper::VertexMapper(const SubMesh* subMesh, BufferAccess access) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + + const VertexBuffer* buffer = nullptr; + switch (subMesh->GetAnimationType()) + { + case AnimationType_Skeletal: + { + const SkeletalMesh* skeletalMesh = static_cast(subMesh); + buffer = skeletalMesh->GetVertexBuffer(); + break; + } + + case AnimationType_Static: + { + const StaticMesh* staticMesh = static_cast(subMesh); + buffer = staticMesh->GetVertexBuffer(); + break; + } + } + + if (!buffer) + { + NazaraInternalError("Animation type not handled (0x" + String::Number(subMesh->GetAnimationType(), 16) + ')'); + } + + m_mapper.Map(buffer, access); + } + + VertexMapper::VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + m_mapper.Map(vertexBuffer, access); + } VertexMapper::~VertexMapper() = default; From 384e11bf79a4c1d371632ce5af6065e07b6fb551 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:36:54 +0200 Subject: [PATCH 129/383] Utility/STBSaver: Fix error message Former-commit-id: 2ef6f33b8391a3c9fb595845f661cc9b1b79df87 [formerly 609d0b1dcc5484cdcca589f9f49061a4bda7c544] Former-commit-id: 2cfd8315e60f7eb153642bd3012e6cbc4b88cb29 --- src/Nazara/Utility/Formats/STBSaver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Utility/Formats/STBSaver.cpp b/src/Nazara/Utility/Formats/STBSaver.cpp index 4166de86f..1b65312fe 100644 --- a/src/Nazara/Utility/Formats/STBSaver.cpp +++ b/src/Nazara/Utility/Formats/STBSaver.cpp @@ -121,7 +121,7 @@ namespace Nz ImageType type = image.GetType(); if (type != ImageType_1D && type != ImageType_2D) { - NazaraError("Image type 0x" + String::Number(type, 16) + " is not "); + NazaraError("Image type 0x" + String::Number(type, 16) + " is not in a supported format"); return false; } From 71b070185aef880eb28acb038cc216da9a723115 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:37:22 +0200 Subject: [PATCH 130/383] Utility/Mesh: Add MeshSaver Former-commit-id: f471e1f0ef048ae24ecb55b5f5013e648a56ad3d [formerly a117421434222a45b299c8f70c2ce9a96fd43ed2] Former-commit-id: d8e33063b36dcb1cba9c80c71733d1243f94d749 --- include/Nazara/Utility/Mesh.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 865a228a9..11e7c14bd 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ namespace Nz using MeshLoader = ResourceLoader; using MeshManager = ResourceManager; using MeshRef = ObjectRef; + using MeshSaver = ResourceSaver; struct MeshImpl; From 9aac1875893dc7399e00fe3e612afdd4c4ae9db5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:38:34 +0200 Subject: [PATCH 131/383] Utility/OBJParser: Fix mistake Former-commit-id: a3bbd969e5fddb00011b3343356189df3864c615 [formerly c07e85fcbffe985fa7ac8f11e18160c1440306cc] Former-commit-id: f218dce6fd6606ffc60d884914b31012d2e568b8 --- src/Nazara/Utility/Formats/OBJParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 5c941e938..cec716442 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - std::size_t n = 0; - std::size_t p = 0; - std::size_t t = 0; + int n = 0; + int p = 0; + int t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { From afc278ebd22bf8e34d59962fb39c3614fd475264 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:40:51 +0200 Subject: [PATCH 132/383] Utility/Mesh: Fix linking Former-commit-id: 954ba6b61a949efaf21fcaa7e0bb28b414438181 [formerly 57fa786549e65d92c82c559d3ea710e8d88b5708] Former-commit-id: 22e63411636bd8a345f01c823b15f3d1ad979455 --- src/Nazara/Utility/Mesh.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index f41f67440..0401a9a10 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -697,4 +697,5 @@ namespace Nz MeshLoader::LoaderList Mesh::s_loaders; MeshManager::ManagerMap Mesh::s_managerMap; MeshManager::ManagerParams Mesh::s_managerParameters; + MeshSaver::SaverList Mesh::s_savers; } From 60ada65a974d202a2cb76354edca17a36b8c06d3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 12:40:25 +0200 Subject: [PATCH 134/383] Utility/Mesh: Fix error Former-commit-id: e54693f1f3f447e67ac93c747aa2c6e88984dd32 [formerly 54cef149c70c78da552aeb9493d0d1bfa9415732] Former-commit-id: 2b532fce8a6ccecb23961180c697ce38544b7edf --- include/Nazara/Utility/Mesh.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 11e7c14bd..36798e689 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -148,6 +148,7 @@ namespace Nz static MeshLoader::LoaderList s_loaders; static MeshManager::ManagerMap s_managerMap; static MeshManager::ManagerParams s_managerParameters; + static MeshSaver::SaverList s_savers; }; } From 970416b95e9baedbe1d81e8312ddc7d30af2af0a Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 18:02:19 +0200 Subject: [PATCH 135/383] Core/ParameterList: Fix GetIntegerParameter Former-commit-id: 1ae4359084a2707599cf2bda6fdb85bc2b2f35f5 [formerly 992c7be965f1a786b74b62bdacfb2883284ecc5f] Former-commit-id: 7f74a8170f43d0dcd3689c38e6001f8bcf7ddebd --- src/Nazara/Core/ParameterList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index abe93c640..bda37b4d4 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -249,7 +249,7 @@ namespace Nz case ParameterType_Integer: *value = it->second.value.intVal; - return false; + return true; case ParameterType_String: { From e4bdb3cdcbbc08e30721fef37428d986aaec2052 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:34:45 +0200 Subject: [PATCH 136/383] Utility/OBJParser: Prepare for saving Former-commit-id: 5c22f8c9e0f3ab3c336598f24c1fbe8359eec9d9 [formerly e600681b453f363027e0a97a5625c7f8c6592f90] Former-commit-id: 1eee39365464d38bfe13131b89c87660cfb05273 --- src/Nazara/Utility/Formats/OBJParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index cec716442..5c941e938 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - int n = 0; - int p = 0; - int t = 0; + std::size_t n = 0; + std::size_t p = 0; + std::size_t t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { From 07c8cbd510283d352b583cd420cee4d247b7d8c4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 08:38:34 +0200 Subject: [PATCH 137/383] Utility/OBJParser: Fix mistake Former-commit-id: 0e78ba2e8dbcbaa3891f2f789ffab854b7bd753e [formerly b7bbafa45b5e4e2ea4ffd0d796b24ce9ed007f58] Former-commit-id: 60837af91b5e10d63ea4dfbe0fdec69ac3f97cfd --- src/Nazara/Utility/Formats/OBJParser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 5c941e938..cec716442 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -125,9 +125,9 @@ namespace Nz for (unsigned int i = 0; i < vertexCount; ++i) { int offset; - std::size_t n = 0; - std::size_t p = 0; - std::size_t t = 0; + int n = 0; + int p = 0; + int t = 0; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { From f97b0081466f2ef49556ee00ff8dc19f1d6297da Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:09:31 +0200 Subject: [PATCH 138/383] Core/ResourceSaver: Truncate output file Former-commit-id: e3a7446aa574b9f1909179b875f34b7697fd8735 [formerly e7601765426fa2a75f2c82762f7ba7d0660ff452] Former-commit-id: 73328e695bd19701deb247e2566a0ab00a4b5c5b --- include/Nazara/Core/ResourceSaver.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/ResourceSaver.inl b/include/Nazara/Core/ResourceSaver.inl index 11d3f2a44..85f95fd3a 100644 --- a/include/Nazara/Core/ResourceSaver.inl +++ b/include/Nazara/Core/ResourceSaver.inl @@ -84,7 +84,7 @@ namespace Nz } else { - if (!file.Open(OpenMode_WriteOnly)) + if (!file.Open(OpenMode_WriteOnly | OpenMode_Truncate)) { NazaraError("Failed to save to file: unable to open \"" + filePath + "\" in write mode"); return false; From e0e0b448b1f68e64d6bb06f2ff40be157660ad6e Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:09:42 +0200 Subject: [PATCH 139/383] Build/Examples: Fix HardwareInfo console Former-commit-id: 125fd04e48974f979ee277462f1b4deba95a480c [formerly c7fd2400cbbd0bacdbbf63a48b292f3860dd87c8] Former-commit-id: 559e8f5501ee847ad5f405d105750153d90db4fa --- examples/HardwareInfo/build.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/HardwareInfo/build.lua b/examples/HardwareInfo/build.lua index e1b487bd6..afcc7b544 100644 --- a/examples/HardwareInfo/build.lua +++ b/examples/HardwareInfo/build.lua @@ -1,6 +1,6 @@ EXAMPLE.Name = "HardwareInfo" -EXAMPLE.Console = true +EXAMPLE.EnableConsole = true EXAMPLE.Defines = { "NAZARA_RENDERER_OPENGL" From 269b0668cb493dabcb9cfdc3ad16d136df83a9ec Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:10:12 +0200 Subject: [PATCH 140/383] Utility/Formats: Make MD2Loader specify diffuse texture path instead of material filepath Former-commit-id: dc073017799c9cdbd74fc52f9f33cd4cba2f6967 [formerly 0f99dbc95d1787c1af9caa5143976690668f9dcf] Former-commit-id: 2ae072cad50c2412da655c21f2f3798905d51b85 --- src/Nazara/Utility/Formats/MD2Loader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index 126eeaa35..d1d03cf52 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -102,7 +102,8 @@ namespace Nz stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::FilePath, baseDir + skin); + matData.SetParameter(MaterialData::CustomDefined, true); + matData.SetParameter(MaterialData::DiffuseTexturePath, baseDir + skin); mesh->SetMaterialData(i, std::move(matData)); } From ab43085fe7cdb6d18075924b7259745a8ac36d2d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:11:03 +0200 Subject: [PATCH 141/383] Utility: Add MTL exporting Former-commit-id: cceef7a11d10cc235bd06655a7c5b10ee1cfdec6 [formerly e68c9322634c9a3f93771d941ae581f24dc98116] Former-commit-id: 1a117f7cd11d869c1fb179cba54254c9ec6924f2 --- include/Nazara/Utility/Formats/MTLParser.hpp | 39 +++- include/Nazara/Utility/Formats/MTLParser.inl | 83 +++++++ include/Nazara/Utility/Formats/OBJParser.hpp | 1 + include/Nazara/Utility/Formats/OBJParser.inl | 5 + src/Nazara/Utility/Formats/MTLParser.cpp | 234 +++++++++++++------ src/Nazara/Utility/Formats/OBJLoader.cpp | 28 ++- src/Nazara/Utility/Formats/OBJParser.cpp | 17 +- 7 files changed, 316 insertions(+), 91 deletions(-) create mode 100644 include/Nazara/Utility/Formats/MTLParser.inl diff --git a/include/Nazara/Utility/Formats/MTLParser.hpp b/include/Nazara/Utility/Formats/MTLParser.hpp index d58148ec7..9c5b49828 100644 --- a/include/Nazara/Utility/Formats/MTLParser.hpp +++ b/include/Nazara/Utility/Formats/MTLParser.hpp @@ -19,6 +19,22 @@ namespace Nz class NAZARA_UTILITY_API MTLParser { public: + struct Material; + + MTLParser() = default; + ~MTLParser() = default; + + inline Material* AddMaterial(const String& matName); + + inline void Clear(); + + inline const Material* GetMaterial(const String& materialName) const; + inline const std::unordered_map& GetMaterials() const; + + bool Parse(Stream& stream); + + bool Save(Stream& stream) const; + struct Material { Color ambient = Color::White; @@ -39,27 +55,26 @@ namespace Nz unsigned int illumModel = 0; }; - MTLParser(Stream& stream$); - ~MTLParser(); - - const Material* GetMaterial(const String& materialName) const; - const std::unordered_map& GetMaterials() const; - - bool Parse(); - private: bool Advance(bool required = true); - void Error(const String& message); - void Warning(const String& message); - void UnrecognizedLine(bool error = false); + template void Emit(const T& text) const; + inline void EmitLine() const; + template void EmitLine(const T& line) const; + inline void Error(const String& message); + inline void Flush() const; + inline void Warning(const String& message); + inline void UnrecognizedLine(bool error = false); std::unordered_map m_materials; - Stream& m_stream; + mutable Stream* m_currentStream; String m_currentLine; + mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; unsigned int m_streamFlags; }; } +#include + #endif // NAZARA_FORMATS_MTLPARSER_HPP diff --git a/include/Nazara/Utility/Formats/MTLParser.inl b/include/Nazara/Utility/Formats/MTLParser.inl new file mode 100644 index 000000000..0f8cd4f66 --- /dev/null +++ b/include/Nazara/Utility/Formats/MTLParser.inl @@ -0,0 +1,83 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline MTLParser::Material* MTLParser::AddMaterial(const String& matName) + { + return &m_materials[matName]; + } + + inline void MTLParser::Clear() + { + m_materials.clear(); + } + + inline const MTLParser::Material* MTLParser::GetMaterial(const String& materialName) const + { + auto it = m_materials.find(materialName); + if (it != m_materials.end()) + return &it->second; + else + return nullptr; + } + + inline const std::unordered_map& MTLParser::GetMaterials() const + { + return m_materials; + } + + template + void MTLParser::Emit(const T& text) const + { + m_outputStream << text; + if (m_outputStream.GetBufferSize() > 1024 * 1024) + Flush(); + } + + inline void MTLParser::EmitLine() const + { + Emit('\n'); + } + + template + void MTLParser::EmitLine(const T& line) const + { + Emit(line); + Emit('\n'); + } + + inline void MTLParser::Error(const String& message) + { + NazaraError(message + " at line #" + String::Number(m_lineCount)); + } + + inline void MTLParser::Flush() const + { + m_currentStream->Write(m_outputStream); + m_outputStream.Clear(); + } + + inline void MTLParser::Warning(const String& message) + { + NazaraWarning(message + " at line #" + String::Number(m_lineCount)); + } + + inline void MTLParser::UnrecognizedLine(bool error) + { + String message = "Unrecognized \"" + m_currentLine + '"'; + + if (error) + Error(message); + else + Warning(message); + } +} + +#include +#include "MTLParser.hpp" diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index b9c5e41c3..50fa58900 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -52,6 +52,7 @@ namespace Nz inline String* SetMaterialCount(std::size_t materialCount); inline Mesh* SetMeshCount(std::size_t meshCount); + inline void SetMtlLib(const String& mtlLib); inline Vector3f* SetNormalCount(std::size_t normalCount); inline Vector4f* SetPositionCount(std::size_t positionCount); inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index a4fcffaec..9d961d54f 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -109,6 +109,11 @@ namespace Nz return m_meshes.data(); } + inline void OBJParser::SetMtlLib(const String& mtlLib) + { + m_mtlLib = mtlLib; + } + inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) { m_normals.resize(normalCount); diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 2398ccb3f..6685bcd04 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -12,36 +13,22 @@ namespace Nz { - MTLParser::MTLParser(Stream& stream) : - m_stream(stream), - m_streamFlags(stream.GetStreamOptions()) //< Saves stream flags + bool MTLParser::Parse(Stream& stream) { - m_stream.EnableTextMode(true); - } + m_currentStream = &stream; - MTLParser::~MTLParser() - { - // Reset stream flags - if ((m_streamFlags & StreamOption_Text) == 0) - m_stream.EnableTextMode(false); - } + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); - const MTLParser::Material* MTLParser::GetMaterial(const String& materialName) const - { - auto it = m_materials.find(materialName); - if (it != m_materials.end()) - return &it->second; - else - return nullptr; - } + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } - const std::unordered_map& MTLParser::GetMaterials() const - { - return m_materials; - } - - bool MTLParser::Parse() - { m_keepLastLine = false; m_lineCount = 0; m_materials.clear(); @@ -57,7 +44,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->ambient = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); } @@ -72,7 +59,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->diffuse = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); } @@ -87,7 +74,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->specular = Color(static_cast(r*255.f), static_cast(g*255.f), static_cast(b*255.f)); } @@ -102,7 +89,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f", &density) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->refractionIndex = density; } @@ -117,7 +104,7 @@ namespace Nz if (std::sscanf(&m_currentLine[3], "%f", &coef) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->shininess = coef; } @@ -132,7 +119,7 @@ namespace Nz if (std::sscanf(&m_currentLine[(keyword[0] == 'd') ? 2 : 3], "%f", &alpha) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->alpha = alpha; } @@ -147,7 +134,7 @@ namespace Nz if (std::sscanf(&m_currentLine[(keyword[0] == 'd') ? 2 : 3], "%f", &alpha) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->alpha = 1.f - alpha; // tr vaut pour la "valeur de transparence", 0 = opaque } @@ -162,7 +149,7 @@ namespace Nz if (std::sscanf(&m_currentLine[6], "%u", &model) == 1) { if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->illumModel = model; } @@ -178,7 +165,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->ambientMap = map; } @@ -190,7 +177,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->diffuseMap = map; } @@ -202,7 +189,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->specularMap = map; } @@ -214,7 +201,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->bumpMap = map; } @@ -226,7 +213,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->alphaMap = map; } @@ -238,7 +225,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->decalMap = map; } @@ -250,7 +237,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->displacementMap = map; } @@ -262,7 +249,7 @@ namespace Nz { String map = m_currentLine.SubString(mapPos); if (!currentMaterial) - currentMaterial = &m_materials["default"]; + currentMaterial = AddMaterial("default"); currentMaterial->reflectionMap = map; } @@ -271,7 +258,7 @@ namespace Nz { String materialName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); if (!materialName.IsEmpty()) - currentMaterial = &m_materials[materialName]; + currentMaterial = AddMaterial(materialName); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else UnrecognizedLine(); @@ -286,13 +273,150 @@ namespace Nz return true; } + bool MTLParser::Save(Stream& stream) const + { + m_currentStream = &stream; + + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); + + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } + + m_outputStream.Clear(); + + EmitLine("# Exported by Nazara Engine"); + EmitLine(); + + Emit("# material count: "); + Emit(m_materials.size()); + EmitLine(); + + for (auto& pair : m_materials) + { + const String& matName = pair.first; + const Material& mat = pair.second; + + Emit("newmtl "); + EmitLine(pair.first); + EmitLine(); + + Emit("Ka "); + Emit(mat.ambient.r / 255.f); + Emit(' '); + Emit(mat.ambient.g / 255.f); + Emit(' '); + Emit(mat.ambient.b / 255.f); + EmitLine(); + + Emit("Kd "); + Emit(mat.diffuse.r / 255.f); + Emit(' '); + Emit(mat.diffuse.g / 255.f); + Emit(' '); + Emit(mat.diffuse.b / 255.f); + EmitLine(); + + Emit("Ks "); + Emit(mat.specular.r / 255.f); + Emit(' '); + Emit(mat.specular.g / 255.f); + Emit(' '); + Emit(mat.specular.b / 255.f); + EmitLine(); + + if (mat.alpha != 1.f) + { + Emit("d "); + EmitLine(mat.alpha); + } + + if (mat.refractionIndex != 1.f) + { + Emit("ni "); + EmitLine(mat.refractionIndex); + } + + if (mat.shininess != 1.f) + { + Emit("ns "); + EmitLine(mat.shininess); + } + + if (mat.illumModel != 0) + { + Emit("illum "); + EmitLine(mat.illumModel); + } + + if (!mat.ambientMap.IsEmpty()) + { + Emit("map_Ka "); + EmitLine(mat.ambientMap); + } + + if (!mat.diffuseMap.IsEmpty()) + { + Emit("map_Kd "); + EmitLine(mat.diffuseMap); + } + + if (!mat.specularMap.IsEmpty()) + { + Emit("map_Ks "); + EmitLine(mat.specularMap); + } + + if (!mat.bumpMap.IsEmpty()) + { + Emit("map_bump "); + EmitLine(mat.bumpMap); + } + + if (!mat.alphaMap.IsEmpty()) + { + Emit("map_d "); + EmitLine(mat.alphaMap); + } + + if (!mat.decalMap.IsEmpty()) + { + Emit("map_decal "); + EmitLine(mat.decalMap); + } + + if (!mat.displacementMap.IsEmpty()) + { + Emit("map_disp "); + EmitLine(mat.displacementMap); + } + + if (!mat.reflectionMap.IsEmpty()) + { + Emit("map_refl "); + EmitLine(mat.reflectionMap); + } + EmitLine(); + } + + Flush(); + + return true; + } + bool MTLParser::Advance(bool required) { if (!m_keepLastLine) { do { - if (m_stream.EndOfStream()) + if (m_currentStream->EndOfStream()) { if (required) Error("Incomplete MTL file"); @@ -302,7 +426,7 @@ namespace Nz m_lineCount++; - m_currentLine = m_stream.ReadLine(); + m_currentLine = m_currentStream->ReadLine(); m_currentLine = m_currentLine.SubStringTo("#"); // On ignore les commentaires m_currentLine.Simplify(); // Pour un traitement plus simple } @@ -313,24 +437,4 @@ namespace Nz return true; } - - void MTLParser::Error(const String& message) - { - NazaraError(message + " at line #" + String::Number(m_lineCount)); - } - - void MTLParser::Warning(const String& message) - { - NazaraWarning(message + " at line #" + String::Number(m_lineCount)); - } - - void MTLParser::UnrecognizedLine(bool error) - { - String message = "Unrecognized \"" + m_currentLine + '"'; - - if (error) - Error(message); - else - Warning(message); - } } diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index a8d5d68ec..1b1835b2b 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -49,8 +49,8 @@ namespace Nz return false; } - MTLParser materialParser(file); - if (!materialParser.Parse()) + MTLParser materialParser; + if (!materialParser.Parse(file)) { NazaraError("MTL parser failed"); return false; @@ -90,13 +90,31 @@ namespace Nz data.SetParameter(MaterialData::SpecularColor, specularColor); if (!mtlMat->alphaMap.IsEmpty()) - data.SetParameter(MaterialData::AlphaTexturePath, baseDir + mtlMat->alphaMap); + { + String fullPath = mtlMat->alphaMap; + if (!Nz::File::IsAbsolute(fullPath)) + fullPath.Prepend(baseDir); + + data.SetParameter(MaterialData::AlphaTexturePath, fullPath); + } if (!mtlMat->diffuseMap.IsEmpty()) - data.SetParameter(MaterialData::DiffuseTexturePath, baseDir + mtlMat->diffuseMap); + { + String fullPath = mtlMat->diffuseMap; + if (!Nz::File::IsAbsolute(fullPath)) + fullPath.Prepend(baseDir); + + data.SetParameter(MaterialData::DiffuseTexturePath, fullPath); + } if (!mtlMat->specularMap.IsEmpty()) - data.SetParameter(MaterialData::SpecularTexturePath, baseDir + mtlMat->specularMap); + { + String fullPath = mtlMat->specularMap; + if (!Nz::File::IsAbsolute(fullPath)) + fullPath.Prepend(baseDir); + + data.SetParameter(MaterialData::SpecularTexturePath, fullPath); + } // If we either have an alpha value or an alpha map, let's configure the material for transparency if (alphaValue != 255 || !mtlMat->alphaMap.IsEmpty()) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index cec716442..bd189305f 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -386,10 +386,11 @@ namespace Nz m_outputStream.Clear(); EmitLine("# Exported by Nazara Engine"); + EmitLine(); if (!m_mtlLib.IsEmpty()) { - Emit("mtlib "); + Emit("mtllib "); EmitLine(m_mtlLib); EmitLine(); } @@ -403,17 +404,15 @@ namespace Nz Emit(position.x); Emit(' '); Emit(position.y); - if (!NumberEquals(position.z, 0.f) || !NumberEquals(position.w, 1.f)) + Emit(' '); + Emit(position.z); + + if (!NumberEquals(position.w, 1.f)) { Emit(' '); - Emit(position.z); - - if (!NumberEquals(position.w, 1.f)) - { - Emit(' '); - Emit(position.w); - } + Emit(position.w); } + EmitLine(); } EmitLine(); From d641336654b2bb4abdaa496ae3ab5fbb7b70102b Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:11:25 +0200 Subject: [PATCH 142/383] Utility/Mesh: Add MeshSaver properly Former-commit-id: 8f6c3db5e5cd208a6a7b0b330ef3d8722fe38696 [formerly c87b832ede1355a7a1526aae0bcb402d4265ead7] Former-commit-id: 1efc45f812129e86c6907e71d4523d77a1ceda12 --- include/Nazara/Utility/Mesh.hpp | 4 ++++ src/Nazara/Utility/Mesh.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 36798e689..62a372384 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -71,6 +71,7 @@ namespace Nz friend MeshLibrary; friend MeshLoader; friend MeshManager; + friend MeshSaver; friend class Utility; public: @@ -126,6 +127,9 @@ namespace Nz void RemoveSubMesh(const String& identifier); void RemoveSubMesh(unsigned int index); + bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams()); + bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams()); + void SetAnimation(const String& animationPath); void SetMaterialCount(unsigned int matCount); void SetMaterialData(unsigned int matIndex, ParameterList data); diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 0401a9a10..84559abda 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -606,6 +606,16 @@ namespace Nz InvalidateAABB(); } + bool Mesh::SaveToFile(const String& filePath, const MeshParams& params) + { + return MeshSaver::SaveToFile(*this, filePath, params); + } + + bool Mesh::SaveToStream(Stream& stream, const String& format, const MeshParams& params) + { + return MeshSaver::SaveToStream(*this, stream, format, params); + } + void Mesh::SetAnimation(const String& animationPath) { NazaraAssert(m_impl, "Mesh should be created first"); From 4555a523174454e6dde50d280e21ed27e9f0a27e Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 08:11:50 +0200 Subject: [PATCH 143/383] Utility/Formats: Add OBJSaver (WIP) Former-commit-id: d45e18a1c36ace696f07277923368540cca84850 [formerly 916fe15a35f125c17a318038ef417e34be878510] Former-commit-id: fd5b56061baae2ceebbaa968b15ad5a01455d90e --- src/Nazara/Utility/Formats/OBJSaver.cpp | 228 ++++++++++++++++++++++++ src/Nazara/Utility/Formats/OBJSaver.hpp | 21 +++ src/Nazara/Utility/Utility.cpp | 4 + 3 files changed, 253 insertions(+) create mode 100644 src/Nazara/Utility/Formats/OBJSaver.cpp create mode 100644 src/Nazara/Utility/Formats/OBJSaver.hpp diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp new file mode 100644 index 000000000..4fe468135 --- /dev/null +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -0,0 +1,228 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + template + class VertexCache + { + public: + VertexCache(T* ptr) : + m_count(0), + m_buffer(ptr) + { + } + + std::size_t GetCount() const + { + return m_count; + } + + std::size_t Insert(const T& data) + { + auto it = m_cache.find(data); + if (it == m_cache.end()) + { + it = m_cache.insert(std::make_pair(data, m_count)).first; + m_buffer[m_count] = data; + m_count++; + } + + return it->second + 1; + } + + private: + std::size_t m_count; + std::map m_cache; + T* m_buffer; + }; + + bool IsSupported(const String& extension) + { + return (extension == "obj"); + } + + bool SaveToStream(const Mesh& mesh, const String& format, Stream& stream, const MeshParams& parameters) + { + if (!mesh.IsValid()) + { + NazaraError("Invalid mesh"); + return false; + } + + if (mesh.IsAnimable()) + { + NazaraError("An animated mesh cannot be saved to " + format + " format"); + return false; + } + + std::size_t worstCacheVertexCount = mesh.GetVertexCount(); + OBJParser objFormat; + objFormat.SetNormalCount(worstCacheVertexCount); + objFormat.SetPositionCount(worstCacheVertexCount); + objFormat.SetTexCoordCount(worstCacheVertexCount); + + String mtlPath = stream.GetPath(); + if (!mtlPath.IsEmpty()) + { + mtlPath.Replace(".obj", ".mtl"); + String fileName = mtlPath.SubStringFrom(NAZARA_DIRECTORY_SEPARATOR, -1, true); + if (!fileName.IsEmpty()) + objFormat.SetMtlLib(fileName); + } + + VertexCache normalCache(objFormat.GetNormals()); + VertexCache positionCache(objFormat.GetPositions()); + VertexCache texCoordsCache(objFormat.GetTexCoords()); + + // Materials + MTLParser mtlFormat; + std::unordered_set registredMaterials; + + std::size_t matCount = mesh.GetMaterialCount(); + String* materialNames = objFormat.SetMaterialCount(matCount); + for (std::size_t i = 0; i < matCount; ++i) + { + const ParameterList& matData = mesh.GetMaterialData(i); + + String name; + if (!matData.GetStringParameter(MaterialData::Name, &name)) + name = "material_" + String::Number(i); + + // Makes sure we only have one material of that name + while (registredMaterials.find(name) != registredMaterials.end()) + name += '_'; + + registredMaterials.insert(name); + materialNames[i] = name; + + MTLParser::Material* material = mtlFormat.AddMaterial(name); + + bool bValue; + String strVal; + if (matData.GetBooleanParameter(MaterialData::CustomDefined, &bValue) && bValue) + { + Color colorVal; + float fValue; + + if (matData.GetColorParameter(MaterialData::AmbientColor, &colorVal)) + material->ambient = colorVal; + + if (matData.GetColorParameter(MaterialData::DiffuseColor, &colorVal)) + material->diffuse = colorVal; + + if (matData.GetColorParameter(MaterialData::SpecularColor, &colorVal)) + material->specular = colorVal; + + if (matData.GetFloatParameter(MaterialData::Shininess, &fValue)) + material->shininess = fValue; + + if (matData.GetStringParameter(MaterialData::AlphaTexturePath, &strVal)) + material->alphaMap = strVal; + + if (matData.GetStringParameter(MaterialData::DiffuseTexturePath, &strVal)) + material->diffuseMap = strVal; + + if (matData.GetStringParameter(MaterialData::SpecularTexturePath, &strVal)) + material->specularMap = strVal; + } + else if (matData.GetStringParameter(MaterialData::FilePath, &strVal)) + material->diffuseMap = strVal; + } + + // Meshes + std::size_t meshCount = mesh.GetSubMeshCount(); + OBJParser::Mesh* meshes = objFormat.SetMeshCount(meshCount); + for (std::size_t i = 0; i < meshCount; ++i) + { + const StaticMesh* staticMesh = static_cast(mesh.GetSubMesh(i)); + + std::size_t triangleCount = staticMesh->GetTriangleCount(); + std::size_t vertexCount = staticMesh->GetVertexCount(); + + meshes[i].faces.resize(triangleCount); + meshes[i].vertices.resize(triangleCount * 3); + + { + VertexMapper vertexMapper(staticMesh); + + SparsePtr normalPtr = vertexMapper.GetComponentPtr(VertexComponent_Normal); + SparsePtr positionPtr = vertexMapper.GetComponentPtr(VertexComponent_Position); + SparsePtr texCoordsPtr = vertexMapper.GetComponentPtr(VertexComponent_TexCoord); + + std::size_t faceIndex = 0; + TriangleIterator triangle(staticMesh); + do + { + OBJParser::Face& face = meshes[i].faces[faceIndex]; + face.firstVertex = faceIndex * 3; + face.vertexCount = 3; + + for (std::size_t j = 0; j < 3; ++j) + { + OBJParser::FaceVertex& vertexIndices = meshes[i].vertices[face.firstVertex + j]; + + std::size_t index = triangle[j]; + vertexIndices.normal = normalCache.Insert(normalPtr[index]); + vertexIndices.position = positionCache.Insert(positionPtr[index]); + vertexIndices.texCoord = texCoordsCache.Insert(texCoordsPtr[index]); + } + + faceIndex++; + } + while (triangle.Advance()); + } + } + + objFormat.SetNormalCount(normalCache.GetCount()); + objFormat.SetPositionCount(positionCache.GetCount()); + objFormat.SetTexCoordCount(texCoordsCache.GetCount()); + + objFormat.Save(stream); + + if (!mtlPath.IsEmpty()) + { + File mtlFile(mtlPath, OpenMode_WriteOnly | OpenMode_Truncate); + if (mtlFile.IsOpen()) + mtlFormat.Save(mtlFile); + } + + return true; + } + } + + namespace Loaders + { + void RegisterOBJSaver() + { + MeshSaver::RegisterSaver(IsSupported, SaveToStream); + } + + void UnregisterOBJSaver() + { + MeshSaver::UnregisterSaver(IsSupported, SaveToStream); + } + } +} diff --git a/src/Nazara/Utility/Formats/OBJSaver.hpp b/src/Nazara/Utility/Formats/OBJSaver.hpp new file mode 100644 index 000000000..ed909f165 --- /dev/null +++ b/src/Nazara/Utility/Formats/OBJSaver.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_FORMATS_OBJSAVER_HPP +#define NAZARA_FORMATS_OBJSAVER_HPP + +#include + +namespace Nz +{ + namespace Loaders + { + void RegisterOBJSaver(); + void UnregisterOBJSaver(); + } +} + +#endif // NAZARA_FORMATS_OBJSAVER_HPP diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index ae5b5066d..6b2f66353 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -125,10 +126,12 @@ namespace Nz // Mesh (text) Loaders::RegisterOBJLoader(); + Loaders::RegisterOBJSaver(); // Mesh Loaders::RegisterMD2(); // Loader de fichiers .md2 (v8) Loaders::RegisterMD5Mesh(); // Loader de fichiers .md5mesh (v10) + Loaders::RegisterOBJLoader(); // Loader de fichiers .md5mesh (v10) // Image Loaders::RegisterPCX(); // Loader de fichiers .pcx (1, 4, 8, 24 bits) @@ -163,6 +166,7 @@ namespace Nz Loaders::UnregisterMD5Anim(); Loaders::UnregisterMD5Mesh(); Loaders::UnregisterOBJLoader(); + Loaders::UnregisterOBJSaver(); Loaders::UnregisterPCX(); Loaders::UnregisterSTBLoader(); Loaders::UnregisterSTBSaver(); From e5b84033712b6939156c205d68cab1c28e942c2d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jul 2016 17:16:20 +0200 Subject: [PATCH 144/383] Delete Image.inl.save-failed Former-commit-id: 2992e8ec1076efb6138374f80ffefdef9809f143 [formerly 2e731027778013668a6ab552e4783bd1cb1d561f] Former-commit-id: e47ffdb65bfdba1c0c5cc07452ef5545fddd7d82 --- include/Nazara/Utility/Image.inl.save-failed | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 include/Nazara/Utility/Image.inl.save-failed diff --git a/include/Nazara/Utility/Image.inl.save-failed b/include/Nazara/Utility/Image.inl.save-failed deleted file mode 100644 index 5cb8ef42f..000000000 --- a/include/Nazara/Utility/Image.inl.save-failed +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Utility module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - template - ImageRef Image::New(Args&&... args) - { - std::unique_ptr object(new Image(std::forward(args)...)); - object->SetPersistent(false); - - return object.release(); - } -} - -#include From c55e6fd0dc667b5dee12a66d9c2424eb79cb0206 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:26:38 +0200 Subject: [PATCH 145/383] Prevent GitHub to count external libraries into the project files Former-commit-id: 2d1a0fbc2f6d0fe7abf8e5c20cd6dddb65d35ad9 [formerly f370f91ca0b79f2241c501d057d7bc5dcf649cfc] Former-commit-id: 54bbae2a5c305192272840babb0df0cab2713090 --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index dfe077042..a788acb7e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ # Auto detect text files and perform LF normalization * text=auto +extlibs/* linguist-vendored +NazaraModuleTemplate/* linguist-vendored From 1b72b080e11158130fa2cd71dca393342cb49ac0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:27:30 +0200 Subject: [PATCH 146/383] Update global headers Former-commit-id: 978fdad88b03d1d8806f46ee9e07fe7eeca73e2c [formerly 4b80a873263e0bdb53504f31e05c5595cb53e27d] Former-commit-id: 11641ec31886b4da1387e2d8600324f53a56b8b1 --- include/Nazara/Graphics.hpp | 4 +++- include/Nazara/Noise.hpp | 29 ++++++++++------------------- include/Nazara/Utility.hpp | 3 ++- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 465aeb999..17b10e9a1 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 17 Nov 2015 at 13:20:45 +// This file was automatically generated on 12 Jul 2016 at 17:44:43 /* Nazara Engine - Graphics module @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/include/Nazara/Noise.hpp b/include/Nazara/Noise.hpp index 45b240378..e1d14460e 100644 --- a/include/Nazara/Noise.hpp +++ b/include/Nazara/Noise.hpp @@ -1,9 +1,9 @@ -// This file was automatically generated on 17 Nov 2015 at 13:20:45 +// This file was automatically generated on 12 Jul 2016 at 17:44:43 /* Nazara Engine - Noise module - Copyright (C) 2015 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) + Copyright (C) 2016 Rémi "Overdrivr" Bèges (remi.beges@laposte.net) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -29,25 +29,16 @@ #ifndef NAZARA_GLOBAL_NOISE_HPP #define NAZARA_GLOBAL_NOISE_HPP -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #endif // NAZARA_GLOBAL_NOISE_HPP diff --git a/include/Nazara/Utility.hpp b/include/Nazara/Utility.hpp index 156ca6389..d7676277e 100644 --- a/include/Nazara/Utility.hpp +++ b/include/Nazara/Utility.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 24 Jun 2015 at 13:55:50 +// This file was automatically generated on 12 Jul 2016 at 17:44:43 /* Nazara Engine - Utility module @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include From 3b335ada9d79e4a4688f47e4eb4e00be5781feee Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 17 Jul 2016 21:10:20 +0200 Subject: [PATCH 147/383] Utility/OBJSaver: Fix multiple materials saving Former-commit-id: 003f1dee7556318bb0c42b84ce178b4ee687c9a1 [formerly 17eb0eab5b018ef6a127ade58d4db4b815378dd0] Former-commit-id: 0e984242a33c40c8f1a1ee0c0754ac24ea96d79d --- src/Nazara/Utility/Formats/MD2Loader.cpp | 2 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index d1d03cf52..c61dffd09 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -102,7 +102,7 @@ namespace Nz stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::CustomDefined, true); + matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(MaterialData::DiffuseTexturePath, baseDir + skin); mesh->SetMaterialData(i, std::move(matData)); diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 4fe468135..9a79638bc 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -122,7 +122,7 @@ namespace Nz bool bValue; String strVal; - if (matData.GetBooleanParameter(MaterialData::CustomDefined, &bValue) && bValue) + if (matData.HasParameter(MaterialData::CustomDefined)) { Color colorVal; float fValue; @@ -160,9 +160,10 @@ namespace Nz const StaticMesh* staticMesh = static_cast(mesh.GetSubMesh(i)); std::size_t triangleCount = staticMesh->GetTriangleCount(); - std::size_t vertexCount = staticMesh->GetVertexCount(); meshes[i].faces.resize(triangleCount); + meshes[i].material = staticMesh->GetMaterialIndex(); + meshes[i].name = "mesh_" + String::Number(i); meshes[i].vertices.resize(triangleCount * 3); { From ff47eda7d211315b1573e73cbd3692ed3ad49469 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 18 Jul 2016 19:07:12 +0200 Subject: [PATCH 148/383] Build/Assimp: Fix compilation error because of missing includes Former-commit-id: dba6d044f3575ad69b03d56aa5a91c22671d97f5 [formerly b7093d6e2a1e21eccbe3ee6bb54265da98c49001] Former-commit-id: d229e251df3032d9d60357fa12276c24eda8db27 --- build/scripts/tools/assimp.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index 08688ef72..c810d6c0a 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -5,6 +5,7 @@ TOOL.Kind = "Plugin" TOOL.TargetDirectory = "../SDK/lib" TOOL.Includes = { + "../extlibs/include", "../include", "../plugins/Assimp" } From ceaac9be13989a0c263dc047da593ee8b4aefdc9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 21 Jul 2016 23:00:09 +0200 Subject: [PATCH 149/383] Renderer/RenderStates: Update RenderStates structure (preparing for renderer update) Former-commit-id: 8839ceda70dfa0384e8da43205a208c89f1eb7bf [formerly f5434c9c44a52e02fdc6970e443cd7d3e9e99e6b] Former-commit-id: 6a4846a2e2c8b60160598812ebd02da17a2f6947 --- include/Nazara/Graphics/Material.inl | 62 +++++++++- include/Nazara/Renderer/RenderStates.hpp | 84 +++++++++---- include/Nazara/Renderer/RenderStates.inl | 42 +------ src/Nazara/Graphics/ColorBackground.cpp | 8 +- src/Nazara/Graphics/DeferredBloomPass.cpp | 2 +- src/Nazara/Graphics/DeferredDOFPass.cpp | 2 +- src/Nazara/Graphics/DeferredFXAAPass.cpp | 2 +- src/Nazara/Graphics/DeferredFinalPass.cpp | 2 +- src/Nazara/Graphics/DeferredFogPass.cpp | 2 +- src/Nazara/Graphics/DeferredGeometryPass.cpp | 10 +- .../Graphics/DeferredPhongLightingPass.cpp | 30 ++--- src/Nazara/Graphics/Material.cpp | 66 +++++----- src/Nazara/Graphics/SkyboxBackground.cpp | 8 +- src/Nazara/Graphics/TextureBackground.cpp | 8 +- src/Nazara/Renderer/DebugDrawer.cpp | 6 +- src/Nazara/Renderer/OpenGL.cpp | 113 ++++++++++-------- src/Nazara/Renderer/Renderer.cpp | 110 ++++++++++++----- 17 files changed, 339 insertions(+), 218 deletions(-) diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 1e59e6157..6d5315640 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -53,7 +53,36 @@ namespace Nz { NazaraAssert(renderParameter <= RendererParameter_Max, "Renderer parameter out of enum"); - m_states.parameters[renderParameter] = enable; + switch (renderParameter) + { + case RendererParameter_Blend: + m_states.blending = enable; + return; + + case RendererParameter_ColorWrite: + m_states.colorWrite = enable; + return; + + case RendererParameter_DepthBuffer: + m_states.depthBuffer = enable; + return; + + case RendererParameter_DepthWrite: + m_states.depthWrite = enable; + return; + + case RendererParameter_FaceCulling: + m_states.faceCulling = enable; + return; + + case RendererParameter_ScissorTest: + m_states.scissorTest = enable; + return; + + case RendererParameter_StencilTest: + m_states.stencilTest = enable; + return; + } } /*! @@ -257,7 +286,7 @@ namespace Nz inline FaceSide Material::GetFaceCulling() const { - return m_states.faceCulling; + return m_states.cullingSide; } /*! @@ -489,7 +518,32 @@ namespace Nz { NazaraAssert(parameter <= RendererParameter_Max, "Renderer parameter out of enum"); - return m_states.parameters[parameter]; + switch (parameter) + { + case RendererParameter_Blend: + return m_states.blending; + + case RendererParameter_ColorWrite: + return m_states.colorWrite; + + case RendererParameter_DepthBuffer: + return m_states.depthBuffer; + + case RendererParameter_DepthWrite: + return m_states.depthWrite; + + case RendererParameter_FaceCulling: + return m_states.faceCulling; + + case RendererParameter_ScissorTest: + return m_states.scissorTest; + + case RendererParameter_StencilTest: + return m_states.stencilTest; + } + + NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); + return false; } /*! @@ -778,7 +832,7 @@ namespace Nz inline void Material::SetFaceCulling(FaceSide faceSide) { - m_states.faceCulling = faceSide; + m_states.cullingSide = faceSide; } /*! diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index 4040bec55..a885b2a7d 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -8,37 +8,75 @@ #define NAZARA_RENDERSTATES_HPP #include +#include namespace Nz { struct RenderStates { - RenderStates(); - RenderStates(const RenderStates& states); - ~RenderStates() = default; + BlendFunc dstBlend = BlendFunc_Zero; + BlendFunc srcBlend = BlendFunc_One; + FaceFilling faceFilling = FaceFilling_Fill; + FaceSide cullingSide = FaceSide_Back; + RendererComparison depthFunc = RendererComparison_Less; - RenderStates& operator=(const RenderStates& states); - - struct Face + struct { - RendererComparison stencilCompare; - StencilOperation stencilFail; - StencilOperation stencilPass; - StencilOperation stencilZFail; - UInt32 stencilMask; - unsigned int stencilReference; - }; + RendererComparison back = RendererComparison_Always; + RendererComparison front = RendererComparison_Always; + } stencilCompare; - Face backFace; - Face frontFace; - BlendFunc dstBlend; - BlendFunc srcBlend; - FaceFilling faceFilling; - FaceSide faceCulling; - RendererComparison depthFunc; - bool parameters[RendererParameter_Max+1]; - float lineWidth; - float pointSize; + struct + { + UInt32 back = 0xFFFFFFFF; + UInt32 front = 0xFFFFFFFF; + } stencilCompareMask; + + struct + { + StencilOperation back = StencilOperation_Keep; + StencilOperation front = StencilOperation_Keep; + } stencilDepthFail; + + struct + { + StencilOperation back = StencilOperation_Keep; + StencilOperation front = StencilOperation_Keep; + } stencilFail; + + struct + { + StencilOperation back = StencilOperation_Keep; + StencilOperation front = StencilOperation_Keep; + } stencilPass; + + struct + { + UInt32 back = 0U; + UInt32 front = 0U; + } stencilReference; + + struct + { + UInt32 back = 0xFFFFFFFF; + UInt32 front = 0xFFFFFFFF; + } stencilWriteMask; + + bool blending = false; + bool colorWrite = true; + bool depthBuffer = false; + bool depthWrite = true; + bool faceCulling = false; + bool scissorTest = false; + bool stencilTest = false; + + float lineWidth = 1.f; + float pointSize = 1.f; + }; + + struct RenderPipeline : RenderStates + { + ShaderConstRef shader; }; } diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 6840d3b5f..1f7564166 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -2,52 +2,12 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include namespace Nz { - inline RenderStates::RenderStates() : - dstBlend(BlendFunc_Zero), - srcBlend(BlendFunc_One), - faceFilling(FaceFilling_Fill), - faceCulling(FaceSide_Back), - depthFunc(RendererComparison_Less), - lineWidth(1.f), - pointSize(1.f) - { - parameters[RendererParameter_Blend] = false; - parameters[RendererParameter_ColorWrite] = true; - parameters[RendererParameter_DepthBuffer] = false; - parameters[RendererParameter_DepthWrite] = true; - parameters[RendererParameter_FaceCulling] = false; - parameters[RendererParameter_ScissorTest] = false; - parameters[RendererParameter_StencilTest] = false; - - for (unsigned int i = 0; i < 2; ++i) - { - Face& face = (i == 0) ? backFace : frontFace; - - face.stencilCompare = RendererComparison_Always; - face.stencilFail = StencilOperation_Keep; - face.stencilMask = 0xFFFFFFFF; - face.stencilPass = StencilOperation_Keep; - face.stencilReference = 0; - face.stencilZFail = StencilOperation_Keep; - } - } - - inline RenderStates::RenderStates(const RenderStates& states) - { - std::memcpy(this, &states, sizeof(RenderStates)); - } - - inline RenderStates& RenderStates::operator=(const RenderStates& states) - { - std::memcpy(this, &states, sizeof(RenderStates)); - - return *this; - } } #include diff --git a/src/Nazara/Graphics/ColorBackground.cpp b/src/Nazara/Graphics/ColorBackground.cpp index 33c282390..dcacb1a46 100644 --- a/src/Nazara/Graphics/ColorBackground.cpp +++ b/src/Nazara/Graphics/ColorBackground.cpp @@ -19,11 +19,11 @@ namespace Nz RenderStates BuildRenderStates() { RenderStates states; + states.cullingSide = FaceSide_Back; states.depthFunc = RendererComparison_Equal; - states.faceCulling = FaceSide_Back; - states.parameters[RendererParameter_DepthBuffer] = true; - states.parameters[RendererParameter_DepthWrite] = false; - states.parameters[RendererParameter_FaceCulling] = true; + states.depthBuffer = true; + states.depthWrite = false; + states.faceCulling = true; return states; } diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index c902c7615..9cf39831a 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -32,7 +32,7 @@ namespace Nz m_bloomBrightShader = ShaderLibrary::Get("DeferredBloomBright"); m_bloomFinalShader = ShaderLibrary::Get("DeferredBloomFinal"); - m_bloomStates.parameters[RendererParameter_DepthBuffer] = false; + m_bloomStates.depthBuffer = false; m_gaussianBlurShader = ShaderLibrary::Get("DeferredGaussianBlur"); m_gaussianBlurShaderFilterLocation = m_gaussianBlurShader->GetUniformLocation("Filter"); diff --git a/src/Nazara/Graphics/DeferredDOFPass.cpp b/src/Nazara/Graphics/DeferredDOFPass.cpp index 63df2c400..b39085400 100644 --- a/src/Nazara/Graphics/DeferredDOFPass.cpp +++ b/src/Nazara/Graphics/DeferredDOFPass.cpp @@ -127,7 +127,7 @@ namespace Nz m_pointSampler.SetFilterMode(SamplerFilter_Nearest); m_pointSampler.SetWrapMode(SamplerWrap_Clamp); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; } DeferredDOFPass::~DeferredDOFPass() = default; diff --git a/src/Nazara/Graphics/DeferredFXAAPass.cpp b/src/Nazara/Graphics/DeferredFXAAPass.cpp index 3f1e9395a..d4ba72ddf 100644 --- a/src/Nazara/Graphics/DeferredFXAAPass.cpp +++ b/src/Nazara/Graphics/DeferredFXAAPass.cpp @@ -28,7 +28,7 @@ namespace Nz m_pointSampler.SetFilterMode(SamplerFilter_Nearest); m_pointSampler.SetWrapMode(SamplerWrap_Clamp); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; } DeferredFXAAPass::~DeferredFXAAPass() = default; diff --git a/src/Nazara/Graphics/DeferredFinalPass.cpp b/src/Nazara/Graphics/DeferredFinalPass.cpp index 091c95af6..c4ab348eb 100644 --- a/src/Nazara/Graphics/DeferredFinalPass.cpp +++ b/src/Nazara/Graphics/DeferredFinalPass.cpp @@ -26,7 +26,7 @@ namespace Nz m_pointSampler.SetFilterMode(SamplerFilter_Nearest); m_pointSampler.SetWrapMode(SamplerWrap_Clamp); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; m_uberShader = UberShaderLibrary::Get("Basic"); diff --git a/src/Nazara/Graphics/DeferredFogPass.cpp b/src/Nazara/Graphics/DeferredFogPass.cpp index f64521daf..f47a4ea56 100644 --- a/src/Nazara/Graphics/DeferredFogPass.cpp +++ b/src/Nazara/Graphics/DeferredFogPass.cpp @@ -141,7 +141,7 @@ namespace Nz m_shader = BuildFogShader(); m_shaderEyePositionLocation = m_shader->GetUniformLocation("EyePosition"); - m_states.parameters[RendererParameter_DepthBuffer] = false; + m_states.depthBuffer = false; } DeferredFogPass::~DeferredFogPass() = default; diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 08b111a70..86815558c 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -31,12 +31,12 @@ namespace Nz DeferredGeometryPass::DeferredGeometryPass() { m_clearShader = ShaderLibrary::Get("DeferredGBufferClear"); - m_clearStates.parameters[RendererParameter_DepthBuffer] = true; - m_clearStates.parameters[RendererParameter_FaceCulling] = true; - m_clearStates.parameters[RendererParameter_StencilTest] = true; + m_clearStates.depthBuffer = true; + m_clearStates.faceCulling = true; + m_clearStates.stencilTest = true; m_clearStates.depthFunc = RendererComparison_Always; - m_clearStates.frontFace.stencilCompare = RendererComparison_Always; - m_clearStates.frontFace.stencilPass = StencilOperation_Zero; + m_clearStates.stencilCompare.front = RendererComparison_Always; + m_clearStates.stencilPass.front = StencilOperation_Zero; } DeferredGeometryPass::~DeferredGeometryPass() = default; diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index efcc88e75..afe17ed13 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -120,9 +120,9 @@ namespace Nz RenderStates lightStates; lightStates.dstBlend = BlendFunc_One; lightStates.srcBlend = BlendFunc_One; - lightStates.parameters[RendererParameter_Blend] = true; - lightStates.parameters[RendererParameter_DepthBuffer] = false; - lightStates.parameters[RendererParameter_DepthWrite] = false; + lightStates.blending = true; + lightStates.depthBuffer = false; + lightStates.depthWrite = false; // Directional lights if (!m_renderQueue->directionalLights.empty()) @@ -146,18 +146,18 @@ namespace Nz if (!m_renderQueue->pointLights.empty() || !m_renderQueue->spotLights.empty()) { // http://www.altdevblogaday.com/2011/08/08/stencil-buffer-optimisation-for-deferred-lights/ - lightStates.parameters[RendererParameter_StencilTest] = true; - lightStates.faceCulling = FaceSide_Front; - lightStates.backFace.stencilMask = 0xFF; - lightStates.backFace.stencilReference = 0; - lightStates.backFace.stencilFail = StencilOperation_Keep; - lightStates.backFace.stencilPass = StencilOperation_Keep; - lightStates.backFace.stencilZFail = StencilOperation_Invert; - lightStates.frontFace.stencilMask = 0xFF; - lightStates.frontFace.stencilReference = 0; - lightStates.frontFace.stencilFail = StencilOperation_Keep; - lightStates.frontFace.stencilPass = StencilOperation_Keep; - lightStates.frontFace.stencilZFail = StencilOperation_Invert; + lightStates.cullingSide = FaceSide_Front; + lightStates.stencilTest = true; + lightStates.stencilDepthFail.back = StencilOperation_Invert; + lightStates.stencilDepthFail.front = StencilOperation_Invert; + lightStates.stencilFail.back = StencilOperation_Keep; + lightStates.stencilFail.front = StencilOperation_Keep; + lightStates.stencilPass.back = StencilOperation_Keep; + lightStates.stencilPass.front = StencilOperation_Keep; + lightStates.stencilReference.back = 0; + lightStates.stencilReference.front = 0; + lightStates.stencilWriteMask.back = 0xFF; + lightStates.stencilWriteMask.front = 0xFF; Renderer::SetRenderStates(lightStates); diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 651f2581c..53e0e3e3e 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -252,41 +252,41 @@ namespace Nz // Stencil if (matData.GetIntegerParameter(MaterialData::StencilCompare, &iValue)) - m_states.frontFace.stencilCompare = static_cast(iValue); + m_states.stencilCompare.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilFail, &iValue)) - m_states.frontFace.stencilFail = static_cast(iValue); + m_states.stencilFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilPass, &iValue)) - m_states.frontFace.stencilPass = static_cast(iValue); + m_states.stencilPass.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilZFail, &iValue)) - m_states.frontFace.stencilZFail = static_cast(iValue); + m_states.stencilDepthFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilMask, &iValue)) - m_states.frontFace.stencilMask = static_cast(iValue); + m_states.stencilWriteMask.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilReference, &iValue)) - m_states.frontFace.stencilReference = static_cast(iValue); + m_states.stencilReference.front = static_cast(iValue); // Stencil (back) if (matData.GetIntegerParameter(MaterialData::BackFaceStencilCompare, &iValue)) - m_states.backFace.stencilCompare = static_cast(iValue); + m_states.stencilCompare.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilFail, &iValue)) - m_states.backFace.stencilFail = static_cast(iValue); + m_states.stencilFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilPass, &iValue)) - m_states.backFace.stencilPass = static_cast(iValue); + m_states.stencilPass.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilZFail, &iValue)) - m_states.backFace.stencilZFail = static_cast(iValue); + m_states.stencilDepthFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilMask, &iValue)) - m_states.backFace.stencilMask = static_cast(iValue); + m_states.stencilWriteMask.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilReference, &iValue)) - m_states.backFace.stencilReference = static_cast(iValue); + m_states.stencilReference.back = static_cast(iValue); // Textures if (matParams.loadAlphaMap && matData.GetStringParameter(MaterialData::AlphaTexturePath, &path)) @@ -332,13 +332,13 @@ namespace Nz matData->SetParameter(MaterialData::Transform, IsTransformEnabled()); // RendererParameter - matData->SetParameter(MaterialData::Blending, GetRenderStates().parameters[RendererParameter_Blend]); - matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().parameters[RendererParameter_ColorWrite]); - matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().parameters[RendererParameter_DepthBuffer]); - matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().parameters[RendererParameter_DepthWrite]); - matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().parameters[RendererParameter_FaceCulling]); - matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().parameters[RendererParameter_ScissorTest]); - matData->SetParameter(MaterialData::StencilTest, GetRenderStates().parameters[RendererParameter_StencilTest]); + matData->SetParameter(MaterialData::Blending, GetRenderStates().blending); + matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().colorWrite); + matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().depthBuffer); + matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().depthWrite); + matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().faceCulling); + matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().scissorTest); + matData->SetParameter(MaterialData::StencilTest, GetRenderStates().stencilTest); // Samplers matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, int(GetDiffuseSampler().GetAnisotropicLevel())); @@ -350,20 +350,20 @@ namespace Nz matData->SetParameter(MaterialData::SpecularWrap, int(GetSpecularSampler().GetWrapMode())); // Stencil - matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().frontFace.stencilCompare)); - matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().frontFace.stencilFail)); - matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().frontFace.stencilPass)); - matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().frontFace.stencilZFail)); - matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().frontFace.stencilMask)); - matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().frontFace.stencilReference)); + matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().stencilCompare.front)); + matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().stencilFail.front)); + matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().stencilPass.front)); + matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().stencilDepthFail.front)); + matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().stencilWriteMask.front)); + matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().stencilReference.front)); // Stencil (back) - matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().backFace.stencilCompare)); - matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().backFace.stencilFail)); - matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().backFace.stencilPass)); - matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().backFace.stencilZFail)); - matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().backFace.stencilMask)); - matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().backFace.stencilReference)); + matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().stencilCompare.back)); + matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().stencilFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().stencilPass.back)); + matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().stencilDepthFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().stencilWriteMask.back)); + matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().stencilReference.back)); // Textures if (HasAlphaMap()) @@ -441,8 +441,8 @@ namespace Nz m_specularColor = Color::White; m_specularSampler = TextureSampler(); m_states = RenderStates(); - m_states.parameters[RendererParameter_DepthBuffer] = true; - m_states.parameters[RendererParameter_FaceCulling] = true; + m_states.depthBuffer = true; + m_states.faceCulling = true; m_transformEnabled = true; SetShader("Basic"); diff --git a/src/Nazara/Graphics/SkyboxBackground.cpp b/src/Nazara/Graphics/SkyboxBackground.cpp index 75bc0cc12..fa7faefac 100644 --- a/src/Nazara/Graphics/SkyboxBackground.cpp +++ b/src/Nazara/Graphics/SkyboxBackground.cpp @@ -181,10 +181,10 @@ namespace Nz // Renderstates s_renderStates.depthFunc = RendererComparison_Equal; - s_renderStates.faceCulling = FaceSide_Front; - s_renderStates.parameters[RendererParameter_DepthBuffer] = true; - s_renderStates.parameters[RendererParameter_DepthWrite] = false; - s_renderStates.parameters[RendererParameter_FaceCulling] = true; + s_renderStates.cullingSide = FaceSide_Front; + s_renderStates.depthBuffer = true; + s_renderStates.depthWrite = false; + s_renderStates.faceCulling = true; // Exception-free zone s_indexBuffer = std::move(indexBuffer); diff --git a/src/Nazara/Graphics/TextureBackground.cpp b/src/Nazara/Graphics/TextureBackground.cpp index 1b2e53e72..a990f4af6 100644 --- a/src/Nazara/Graphics/TextureBackground.cpp +++ b/src/Nazara/Graphics/TextureBackground.cpp @@ -20,10 +20,10 @@ namespace Nz { RenderStates states; states.depthFunc = RendererComparison_Equal; - states.faceCulling = FaceSide_Back; - states.parameters[RendererParameter_DepthBuffer] = true; - states.parameters[RendererParameter_DepthWrite] = false; - states.parameters[RendererParameter_FaceCulling] = true; + states.cullingSide = FaceSide_Back; + states.depthBuffer = true; + states.depthWrite = false; + states.faceCulling = true; return states; } diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index 5623e6e8d..9f06c880f 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -652,7 +652,7 @@ namespace Nz void DebugDrawer::EnableDepthBuffer(bool depthBuffer) { - s_renderStates.parameters[RendererParameter_DepthBuffer] = depthBuffer; + s_renderStates.depthBuffer = depthBuffer; } float DebugDrawer::GetLineWidth() @@ -698,7 +698,7 @@ namespace Nz } s_primaryColor = Color::Red; - s_renderStates.parameters[RendererParameter_DepthBuffer] = true; + s_renderStates.depthBuffer = true; s_secondaryColor = Color::Green; s_initialized = true; @@ -709,7 +709,7 @@ namespace Nz bool DebugDrawer::IsDepthBufferEnabled() { - return s_renderStates.parameters[RendererParameter_DepthBuffer]; + return s_renderStates.depthBuffer; } void DebugDrawer::SetLineWidth(float width) diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index b77319997..ba17fe015 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -158,7 +158,7 @@ namespace Nz RenderStates& currentRenderStates = s_contextStates->renderStates; // Les fonctions de blend n'a aucun intérêt sans blending - if (states.parameters[RendererParameter_Blend]) + if (states.blending) { if (currentRenderStates.dstBlend != states.dstBlend || currentRenderStates.srcBlend != states.srcBlend) @@ -169,7 +169,7 @@ namespace Nz } } - if (states.parameters[RendererParameter_DepthBuffer]) + if (states.depthBuffer) { // La comparaison de profondeur n'a aucun intérêt sans depth buffer if (currentRenderStates.depthFunc != states.depthFunc) @@ -179,20 +179,20 @@ namespace Nz } // Le DepthWrite n'a aucune importance si le DepthBuffer est désactivé - if (currentRenderStates.parameters[RendererParameter_DepthWrite] != states.parameters[RendererParameter_DepthWrite]) + if (currentRenderStates.depthWrite != states.depthWrite) { - glDepthMask((states.parameters[RendererParameter_DepthWrite]) ? GL_TRUE : GL_FALSE); - currentRenderStates.parameters[RendererParameter_DepthWrite] = states.parameters[RendererParameter_DepthWrite]; + glDepthMask((states.depthWrite) ? GL_TRUE : GL_FALSE); + currentRenderStates.depthWrite = states.depthWrite; } } // Inutile de changer le mode de face culling s'il n'est pas actif - if (states.parameters[RendererParameter_FaceCulling]) + if (states.faceCulling) { - if (currentRenderStates.faceCulling != states.faceCulling) + if (currentRenderStates.cullingSide != states.cullingSide) { - glCullFace(FaceSide[states.faceCulling]); - currentRenderStates.faceCulling = states.faceCulling; + glCullFace(FaceSide[states.cullingSide]); + currentRenderStates.cullingSide = states.cullingSide; } } @@ -203,33 +203,46 @@ namespace Nz } // Ici encore, ça ne sert à rien de se soucier des fonctions de stencil sans qu'il soit activé - if (states.parameters[RendererParameter_StencilTest]) + if (states.stencilTest) { - for (unsigned int i = 0; i < 2; ++i) + if (currentRenderStates.stencilCompare.back != states.stencilCompare.back || + currentRenderStates.stencilReference.back != states.stencilReference.back || + currentRenderStates.stencilWriteMask.back != states.stencilWriteMask.back) { - GLenum face = (i == 0) ? GL_BACK : GL_FRONT; - const RenderStates::Face& srcStates = (i == 0) ? states.backFace : states.frontFace; - RenderStates::Face& dstStates = (i == 0) ? currentRenderStates.backFace : currentRenderStates.frontFace; + glStencilFuncSeparate(GL_BACK, RendererComparison[states.stencilCompare.back], states.stencilReference.back, states.stencilWriteMask.back); + currentRenderStates.stencilCompare.back = states.stencilCompare.back; + currentRenderStates.stencilReference.back = states.stencilReference.back; + currentRenderStates.stencilWriteMask.back = states.stencilWriteMask.back; + } - if (dstStates.stencilCompare != srcStates.stencilCompare || - dstStates.stencilMask != srcStates.stencilMask || - dstStates.stencilReference != srcStates.stencilReference) - { - glStencilFuncSeparate(face, RendererComparison[srcStates.stencilCompare], srcStates.stencilReference, srcStates.stencilMask); - dstStates.stencilCompare = srcStates.stencilCompare; - dstStates.stencilMask = srcStates.stencilMask; - dstStates.stencilReference = srcStates.stencilReference; - } + if (currentRenderStates.stencilDepthFail.back != states.stencilDepthFail.back || + currentRenderStates.stencilFail.back != states.stencilFail.back || + currentRenderStates.stencilPass.back != states.stencilPass.back) + { + glStencilOpSeparate(GL_BACK, StencilOperation[states.stencilFail.back], StencilOperation[states.stencilDepthFail.back], StencilOperation[states.stencilPass.back]); + currentRenderStates.stencilDepthFail.back = states.stencilDepthFail.back; + currentRenderStates.stencilFail.back = states.stencilFail.back; + currentRenderStates.stencilPass.back = states.stencilPass.back; + } - if (dstStates.stencilFail != srcStates.stencilFail || - dstStates.stencilPass != srcStates.stencilPass || - dstStates.stencilZFail != srcStates.stencilZFail) - { - glStencilOpSeparate(face, StencilOperation[srcStates.stencilFail], StencilOperation[srcStates.stencilZFail], StencilOperation[srcStates.stencilPass]); - dstStates.stencilFail = srcStates.stencilFail; - dstStates.stencilPass = srcStates.stencilPass; - dstStates.stencilZFail = srcStates.stencilZFail; - } + if (currentRenderStates.stencilCompare.front != states.stencilCompare.front || + currentRenderStates.stencilReference.front != states.stencilReference.front || + currentRenderStates.stencilWriteMask.front != states.stencilWriteMask.front) + { + glStencilFuncSeparate(GL_FRONT, RendererComparison[states.stencilCompare.front], states.stencilReference.front, states.stencilWriteMask.front); + currentRenderStates.stencilCompare.front = states.stencilCompare.front; + currentRenderStates.stencilReference.front = states.stencilReference.front; + currentRenderStates.stencilWriteMask.front = states.stencilWriteMask.front; + } + + if (currentRenderStates.stencilDepthFail.front != states.stencilDepthFail.front || + currentRenderStates.stencilFail.front != states.stencilFail.front || + currentRenderStates.stencilPass.front != states.stencilPass.front) + { + glStencilOpSeparate(GL_FRONT, StencilOperation[states.stencilFail.front], StencilOperation[states.stencilDepthFail.front], StencilOperation[states.stencilPass.front]); + currentRenderStates.stencilDepthFail.front = states.stencilDepthFail.front; + currentRenderStates.stencilFail.front = states.stencilFail.front; + currentRenderStates.stencilPass.front = states.stencilPass.front; } } @@ -246,62 +259,62 @@ namespace Nz } // Paramètres de rendu - if (currentRenderStates.parameters[RendererParameter_Blend] != states.parameters[RendererParameter_Blend]) + if (currentRenderStates.blending != states.blending) { - if (states.parameters[RendererParameter_Blend]) + if (states.blending) glEnable(GL_BLEND); else glDisable(GL_BLEND); - currentRenderStates.parameters[RendererParameter_Blend] = states.parameters[RendererParameter_Blend]; + currentRenderStates.blending = states.blending; } - if (currentRenderStates.parameters[RendererParameter_ColorWrite] != states.parameters[RendererParameter_ColorWrite]) + if (currentRenderStates.colorWrite != states.colorWrite) { - GLboolean param = (states.parameters[RendererParameter_ColorWrite]) ? GL_TRUE : GL_FALSE; + GLboolean param = (states.colorWrite) ? GL_TRUE : GL_FALSE; glColorMask(param, param, param, param); - currentRenderStates.parameters[RendererParameter_ColorWrite] = states.parameters[RendererParameter_ColorWrite]; + currentRenderStates.colorWrite = states.colorWrite; } - if (currentRenderStates.parameters[RendererParameter_DepthBuffer] != states.parameters[RendererParameter_DepthBuffer]) + if (currentRenderStates.depthBuffer != states.depthBuffer) { - if (states.parameters[RendererParameter_DepthBuffer]) + if (states.depthBuffer) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); - currentRenderStates.parameters[RendererParameter_DepthBuffer] = states.parameters[RendererParameter_DepthBuffer]; + currentRenderStates.depthBuffer = states.depthBuffer; } - if (currentRenderStates.parameters[RendererParameter_FaceCulling] != states.parameters[RendererParameter_FaceCulling]) + if (currentRenderStates.faceCulling != states.faceCulling) { - if (states.parameters[RendererParameter_FaceCulling]) + if (states.faceCulling) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); - currentRenderStates.parameters[RendererParameter_FaceCulling] = states.parameters[RendererParameter_FaceCulling]; + currentRenderStates.faceCulling = states.faceCulling; } - if (currentRenderStates.parameters[RendererParameter_ScissorTest] != states.parameters[RendererParameter_ScissorTest]) + if (currentRenderStates.scissorTest != states.scissorTest) { - if (states.parameters[RendererParameter_ScissorTest]) + if (states.scissorTest) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST); - currentRenderStates.parameters[RendererParameter_ScissorTest] = states.parameters[RendererParameter_ScissorTest]; + currentRenderStates.scissorTest = states.scissorTest; } - if (currentRenderStates.parameters[RendererParameter_StencilTest] != states.parameters[RendererParameter_StencilTest]) + if (currentRenderStates.stencilTest != states.stencilTest) { - if (states.parameters[RendererParameter_StencilTest]) + if (states.stencilTest) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST); - currentRenderStates.parameters[RendererParameter_StencilTest] = states.parameters[RendererParameter_StencilTest]; + currentRenderStates.stencilTest = states.stencilTest; } } diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index e49db2cec..028f7513f 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -396,7 +396,38 @@ namespace Nz } #endif - s_states.parameters[parameter] = enable; + switch (parameter) + { + case RendererParameter_Blend: + s_states.blending = enable; + return; + + case RendererParameter_ColorWrite: + s_states.colorWrite = enable; + return; + + case RendererParameter_DepthBuffer: + s_states.depthBuffer = enable; + return; + + case RendererParameter_DepthWrite: + s_states.depthWrite = enable; + return; + + case RendererParameter_FaceCulling: + s_states.faceCulling = enable; + return; + + case RendererParameter_ScissorTest: + s_states.scissorTest = enable; + return; + + case RendererParameter_StencilTest: + s_states.stencilTest = enable; + return; + } + + NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); } void Renderer::EndCondition() @@ -762,7 +793,32 @@ namespace Nz } #endif - return s_states.parameters[parameter]; + switch (parameter) + { + case RendererParameter_Blend: + return s_states.blending; + + case RendererParameter_ColorWrite: + return s_states.colorWrite; + + case RendererParameter_DepthBuffer: + return s_states.depthBuffer; + + case RendererParameter_DepthWrite: + return s_states.depthWrite; + + case RendererParameter_FaceCulling: + return s_states.faceCulling; + + case RendererParameter_ScissorTest: + return s_states.scissorTest; + + case RendererParameter_StencilTest: + return s_states.stencilTest; + } + + NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); + return false; } bool Renderer::IsInitialized() @@ -865,7 +921,7 @@ namespace Nz } #endif - s_states.faceCulling = faceSide; + s_states.cullingSide = faceSide; } void Renderer::SetFaceFilling(FaceFilling fillingMode) @@ -1042,16 +1098,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilCompare = compareFunc; + s_states.stencilCompare.back = compareFunc; break; case FaceSide_Front: - s_states.frontFace.stencilCompare = compareFunc; + s_states.stencilCompare.front = compareFunc; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilCompare = compareFunc; - s_states.frontFace.stencilCompare = compareFunc; + s_states.stencilCompare.back = compareFunc; + s_states.stencilCompare.front = compareFunc; break; } } @@ -1075,16 +1131,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilFail = failOperation; + s_states.stencilFail.back = failOperation; break; case FaceSide_Front: - s_states.frontFace.stencilFail = failOperation; + s_states.stencilFail.front = failOperation; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilFail = failOperation; - s_states.frontFace.stencilFail = failOperation; + s_states.stencilFail.back = failOperation; + s_states.stencilFail.front = failOperation; break; } } @@ -1102,16 +1158,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilMask = mask; + s_states.stencilWriteMask.back = mask; break; case FaceSide_Front: - s_states.frontFace.stencilMask = mask; + s_states.stencilWriteMask.front = mask; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilMask = mask; - s_states.frontFace.stencilMask = mask; + s_states.stencilWriteMask.back = mask; + s_states.stencilWriteMask.front = mask; break; } } @@ -1135,16 +1191,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilPass = passOperation; + s_states.stencilPass.back = passOperation; break; case FaceSide_Front: - s_states.frontFace.stencilPass = passOperation; + s_states.stencilPass.front = passOperation; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilPass = passOperation; - s_states.frontFace.stencilPass = passOperation; + s_states.stencilPass.back = passOperation; + s_states.stencilPass.front = passOperation; break; } } @@ -1162,16 +1218,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilReference = refValue; + s_states.stencilReference.back = refValue; break; case FaceSide_Front: - s_states.frontFace.stencilReference = refValue; + s_states.stencilReference.front = refValue; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilReference = refValue; - s_states.frontFace.stencilReference = refValue; + s_states.stencilReference.back = refValue; + s_states.stencilReference.front = refValue; break; } } @@ -1195,16 +1251,16 @@ namespace Nz switch (faceSide) { case FaceSide_Back: - s_states.backFace.stencilZFail = zfailOperation; + s_states.stencilDepthFail.back = zfailOperation; break; case FaceSide_Front: - s_states.frontFace.stencilZFail = zfailOperation; + s_states.stencilDepthFail.front = zfailOperation; break; case FaceSide_FrontAndBack: - s_states.backFace.stencilZFail = zfailOperation; - s_states.frontFace.stencilZFail = zfailOperation; + s_states.stencilDepthFail.back = zfailOperation; + s_states.stencilDepthFail.front = zfailOperation; break; } } From 4d307c07f9b35f1b71870f87f0966df638173a62 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 Jul 2016 18:06:17 +0200 Subject: [PATCH 150/383] Graphics: Add TileMap class Former-commit-id: ecc9f3f1e786da4017ef24322a2f2510eab33a6c [formerly 2d18b57f6ef6c8480f83226082cfcceff3779093] Former-commit-id: 531e4724efe7fa76f64c1e252665be31d1754e7b --- include/Nazara/Graphics/TileMap.hpp | 97 ++++++ include/Nazara/Graphics/TileMap.inl | 441 ++++++++++++++++++++++++++++ src/Nazara/Graphics/Graphics.cpp | 8 + src/Nazara/Graphics/TileMap.cpp | 110 +++++++ 4 files changed, 656 insertions(+) create mode 100644 include/Nazara/Graphics/TileMap.hpp create mode 100644 include/Nazara/Graphics/TileMap.inl create mode 100644 src/Nazara/Graphics/TileMap.cpp diff --git a/include/Nazara/Graphics/TileMap.hpp b/include/Nazara/Graphics/TileMap.hpp new file mode 100644 index 000000000..89a901b9a --- /dev/null +++ b/include/Nazara/Graphics/TileMap.hpp @@ -0,0 +1,97 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_TILEMAP_HPP +#define NAZARA_TILEMAP_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class TileMap; + + using TileMapConstRef = ObjectRef; + using TileMapLibrary = ObjectLibrary; + using TileMapRef = ObjectRef; + + class NAZARA_GRAPHICS_API TileMap : public InstancedRenderable + { + friend TileMapLibrary; + friend class Graphics; + + public: + struct Tile; + + inline TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount = 1); + TileMap(const TileMap& TileMap) = default; + TileMap(TileMap&&) = delete; + ~TileMap() = default; + + void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; + + inline void DisableTile(const Vector2ui& tilePos); + inline void DisableTiles(); + inline void DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount); + + inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); + inline void EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); + + inline const MaterialRef& GetMaterial(std::size_t index) const; + inline std::size_t GetMaterialCount() const; + inline const Vector2ui& GetMapSize() const; + inline Vector2f GetSize() const; + inline const Tile& GetTile(const Vector2ui& tilePos) const; + inline const Vector2f& GetTileSize() const; + + inline void SetMaterial(std::size_t index, MaterialRef material); + + inline TileMap& operator=(const TileMap& TileMap); + TileMap& operator=(TileMap&& TileMap) = delete; + + template static TileMapRef New(Args&&... args); + + struct Tile + { + std::size_t layerIndex = 0U; + Color color = Color::White; + Rectf textureCoords = Rectf::Zero(); + bool enabled = false; + }; + + private: + void MakeBoundingVolume() const override; + void UpdateData(InstanceData* instanceData) const override; + + static bool Initialize(); + static void Uninitialize(); + + struct Layer + { + MaterialRef material; + std::set tiles; + }; + + std::vector m_tiles; + std::vector m_layers; + Vector2ui m_mapSize; + Vector2f m_tileSize; + + static TileMapLibrary::LibraryMap s_library; + }; +} + +#include + +#endif // NAZARA_TILEMAP_HPP diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl new file mode 100644 index 000000000..684b21387 --- /dev/null +++ b/include/Nazara/Graphics/TileMap.inl @@ -0,0 +1,441 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + /*! + * \brief Constructs a TileMap object, containing mapSize tileSize-sized tiles + * + * \param mapSize Number of tiles in each dimension, must be + * \param tileSize Size of each tile of the TileMap + * \param materialCount The maximum number of differents Material this TileMap will use + * + * \remark When constructed, a TileMap has no tile active and will not be rendered + * To use it, you have to enable some tiles. + * + * \remark The default material is used for every material requested + */ + inline TileMap::TileMap(const Nz::Vector2ui& mapSize, const Nz::Vector2f& tileSize, std::size_t materialCount) : + m_tiles(mapSize.x * mapSize.y), + m_layers(materialCount), + m_mapSize(mapSize), + m_tileSize(tileSize) + { + NazaraAssert(m_tiles.size() != 0U, "Invalid map size"); + NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size"); + NazaraAssert(m_layers.size() != 0U, "Invalid material count"); + + for (Layer& layer : m_layers) + layer.material = Material::GetDefault(); + + InvalidateBoundingVolume(); + } + + /*! + * \brief Disable the tile at position tilePos, disabling rendering at this location + * + * \param tilePos Position of the tile to disable + * + * \seealso DisableTiles + */ + inline void TileMap::DisableTile(const Vector2ui& tilePos) + { + NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds"); + + std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x; + Tile& tile = m_tiles[tileIndex]; + tile.enabled = false; + + m_layers[tile.layerIndex].tiles.erase(tileIndex); + + InvalidateInstanceData(1U << tile.layerIndex); + } + + /*! + * \brief Disable all tiles + */ + inline void TileMap::DisableTiles() + { + for (Tile& tile : m_tiles) + tile.enabled = false; + + for (Layer& layer : m_layers) + layer.tiles.clear(); + + InvalidateInstanceData(0xFFFFFFFF); + } + + /*! + * \brief Disable tileCount tiles at positions contained at tilesPos location, disabling rendering at those locations + * + * This is equivalent to calling tileCount times DisableTile with the positions contained at tilesPos + * + * \param tilesPos Pointer to a valid array of at least tileCount positions + * \param tileCount Number of tiles to disable + * + * \remark if tileCount is zero, this is a no-op and the value of tilesPos is not used + * + * \seealso DisableTile + */ + inline void TileMap::DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount) + { + NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount"); + + UInt32 invalidatedLayers = 0; + + for (std::size_t i = 0; i < tileCount; ++i) + { + NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds"); + + std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x; + Tile& tile = m_tiles[tileIndex]; + tile.enabled = false; + + m_layers[tile.layerIndex].tiles.erase(tileIndex); + + invalidatedLayers |= 1U << tile.layerIndex; + + tilesPos++; + } + + if (tileCount > 0) + InvalidateInstanceData(invalidatedLayers); + } + + /*! + * \brief Enable and sets the tile at position tilePos + * + * Setup the tile at position tilePos using color, normalized coordinates coords and materialIndex + * + * \param tilePos Position of the tile to enable + * \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \seealso EnableTiles + */ + inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color, std::size_t materialIndex) + { + NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds"); + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + UInt32 invalidatedLayers = 1U << materialIndex; + + std::size_t tileIndex = tilePos.y * m_mapSize.x + tilePos.x; + Tile& tile = m_tiles[tilePos.y * m_mapSize.x + tilePos.x]; + + if (!tile.enabled) + m_layers[materialIndex].tiles.insert(tileIndex); + else if (materialIndex != tile.layerIndex) + { + m_layers[materialIndex].tiles.erase(tileIndex); + m_layers[tile.layerIndex].tiles.insert(tileIndex); + + invalidatedLayers |= 1U << tile.layerIndex; + } + + tile.enabled = true; + tile.color = color; + tile.textureCoords = coords; + tile.layerIndex = materialIndex; + + InvalidateInstanceData(invalidatedLayers); + } + + /*! + * \brief Enable and sets the tile at position tilePos + * + * Setup the tile at position tilePos using color, unnormalized coordinates rect and materialIndex + * + * \param tilePos Position of the tile to enable + * \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTiles + */ + inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map"); + + Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); + + Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); + EnableTile(tilePos, unnormalizedCoords, color, materialIndex); + } + + /*! + * \brief Enable and sets all the tiles + * + * Setup all tiles using color, normalized coordinates coords and materialIndex + * + * \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Rectf& coords, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + for (Layer& layer : m_layers) + layer.tiles.clear(); + + std::size_t tileIndex = 0; + for (Tile& tile : m_tiles) + { + tile.enabled = true; + tile.color = color; + tile.textureCoords = coords; + tile.layerIndex = materialIndex; + + m_layers[materialIndex].tiles.insert(tileIndex++); + } + + InvalidateInstanceData(0xFFFFFFFF); + } + + /*! + * \brief Enable and sets all the tiles + * + * Setup all tiles using color, unnormalized coordinates coords and materialIndex + * + * \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Rectui& rect, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); + + Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); + EnableTiles(unnormalizedCoords, color, materialIndex); + } + + /*! + * \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations + * + * Setup all tiles using color, normalized coordinates coords and materialIndex + * + * \param tilesPos Pointer to a valid array of at least tileCount positions + * \param tileCount Number of tiles to enable + * \param coords Normalized coordinates ([0..1]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color, std::size_t materialIndex) + { + NazaraAssert(tilesPos || tileCount == 0, "Invalid tile position array with a non-zero tileCount"); + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + + UInt32 invalidatedLayers = 1U << materialIndex; + + for (std::size_t i = 0; i < tileCount; ++i) + { + NazaraAssert(tilesPos->x < m_mapSize.x && tilesPos->y < m_mapSize.y, "Tile position is out of bounds"); + + std::size_t tileIndex = tilesPos->y * m_mapSize.x + tilesPos->x; + Tile& tile = m_tiles[tileIndex]; + + if (!tile.enabled) + m_layers[materialIndex].tiles.insert(tileIndex); + else if (materialIndex != tile.layerIndex) + { + m_layers[materialIndex].tiles.erase(tileIndex); + m_layers[tile.layerIndex].tiles.insert(tileIndex); + + invalidatedLayers |= 1U << tile.layerIndex; + } + + tile.enabled = true; + tile.color = color; + tile.textureCoords = coords; + tile.layerIndex = materialIndex; + tilesPos++; + } + + if (tileCount > 0) + InvalidateInstanceData(invalidatedLayers); + } + + /*! + * \brief Enable and sets tileCount tiles at positions contained at tilesPos location, enabling rendering at those locations + * + * Setup all tiles using color, unnormalized coordinates coords and materialIndex + * + * \param tilesPos Pointer to a valid array of at least tileCount positions + * \param tileCount Number of tiles to enable + * \param coords Unnormalized coordinates ([0..size]) used to specify which region of the material textures will be used + * \param color The multiplicative color applied to the tile + * \param materialIndex The material which will be used for rendering this tile + * + * \remark The material at [materialIndex] must have a valid diffuse map before using this function, + * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. + * + * \seealso EnableTile + */ + inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color, std::size_t materialIndex) + { + NazaraAssert(materialIndex < m_layers.size(), "Material out of bounds"); + NazaraAssert(m_layers[materialIndex].material->HasDiffuseMap(), "Material has no diffuse map"); + + Texture* diffuseMap = m_layers[materialIndex].material->GetDiffuseMap(); + float invWidth = 1.f / diffuseMap->GetWidth(); + float invHeight = 1.f / diffuseMap->GetHeight(); + + Rectf unnormalizedCoords(invWidth * rect.x, invHeight * rect.y, invWidth * rect.width, invHeight * rect.height); + EnableTiles(tilesPos, tileCount, unnormalizedCoords, color, materialIndex); + } + + /*! + * \brief Gets the material at position index used by the TileMap + * + * \param index Index of the material to query + * + * \return Material at index + */ + inline const MaterialRef& TileMap::GetMaterial(std::size_t index) const + { + NazaraAssert(index < m_layers.size(), "Material out of bounds"); + + return m_layers[index].material; + } + + /*! + * \brief Gets the maximum material count this TileMap can use + * \return Material count + */ + inline std::size_t TileMap::GetMaterialCount() const + { + return m_layers.size(); + } + + /*! + * \brief Gets the tilemap size (i.e. number of tiles in each dimension) + * \return Number of tiles in each dimension + * + * \seealso GetSize + * \seealso GetTileSize + */ + inline const Vector2ui& TileMap::GetMapSize() const + { + return m_mapSize; + } + + /*! + * \brief Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize()) + * \return Maximum size in units occupied by this tilemap + * + * \seealso GetMapSize + * \seealso GetTileSize + */ + inline Vector2f TileMap::GetSize() const + { + return Vector2f(m_mapSize) * m_tileSize; + } + + /*! + * \brief Returns informations about a particular tile + * + * \param tilePos Position of the tile to get (enabled or not) + * + * \return Maximum size in units occupied by this tilemap + */ + inline const TileMap::Tile& TileMap::GetTile(const Vector2ui& tilePos) const + { + NazaraAssert(tilePos.x < m_mapSize.x && tilePos.y < m_mapSize.y, "Tile position is out of bounds"); + + return m_tiles[tilePos.y * m_mapSize.x + tilePos.x]; + } + + /*! + * \brief Gets the tile size (i.e. number of units occupied by a tile in each dimension) + * \return Tile size in each dimension + * + * \seealso GetMapSize + * \seealso GetSize + */ + inline const Vector2f& TileMap::GetTileSize() const + { + return m_tileSize; + } + + /*! + * \brief Sets a material of the TileMap + * + * \param index Index of the material to change + * \param material Material for the TileMap + */ + inline void TileMap::SetMaterial(std::size_t index, MaterialRef material) + { + NazaraAssert(index < m_layers.size(), "Material out of bounds"); + + m_layers[index].material = std::move(material); + } + + /*! + * \brief Sets the current TileMap with the content of the other one + * \return A reference to this + * + * \param TileMap The other TileMap + */ + inline TileMap& TileMap::operator=(const TileMap& TileMap) + { + InstancedRenderable::operator=(TileMap); + + m_layers = TileMap.m_layers; + m_mapSize = TileMap.m_mapSize; + m_tiles = TileMap.m_tiles; + m_tileSize = TileMap.m_tileSize; + + // We do not copy final vertices because it's highly probable that our parameters are modified and they must be regenerated + InvalidateBoundingVolume(); + InvalidateInstanceData(0xFFFFFFFF); + + return *this; + } + + /*! + * \brief Creates a new TileMap from the arguments + * \return A reference to the newly created TileMap + * + * \param args Arguments for the TileMap + */ + template + TileMapRef TileMap::New(Args&&... args) + { + std::unique_ptr object(new TileMap(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index c9cc652a8..5e6cd72b7 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -110,6 +111,12 @@ namespace Nz return false; } + if (!TileMap::Initialize()) + { + NazaraError("Failed to initialize tilemaps"); + return false; + } + // Generic loaders Loaders::RegisterMesh(); Loaders::RegisterTexture(); @@ -217,6 +224,7 @@ namespace Nz Material::Uninitialize(); SkyboxBackground::Uninitialize(); Sprite::Uninitialize(); + TileMap::Uninitialize(); NazaraNotice("Uninitialized: Graphics module"); diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp new file mode 100644 index 000000000..9d835cb24 --- /dev/null +++ b/src/Nazara/Graphics/TileMap.cpp @@ -0,0 +1,110 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::TileMap + * \brief Graphics class that represent several tiles of the same size assembled into a grid + * This class is far more efficient than using a sprite for every tile + */ + + /*! + * \brief Adds the TileMap to the rendering queue + * + * \param renderQueue Queue to be added + * \param instanceData Data for the instance + */ + void TileMap::AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const + { + const VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(instanceData.data.data()); + + std::size_t spriteCount = 0; + for (const Layer& layer : m_layers) + { + if (layer.material) + renderQueue->AddSprites(instanceData.renderOrder, layer.material, &vertices[spriteCount], layer.tiles.size()); + + spriteCount += layer.tiles.size(); + } + } + + void TileMap::MakeBoundingVolume() const + { + Nz::Vector2f size = GetSize(); + m_boundingVolume.Set(Vector3f(0.f), size.x*Vector3f::Right() + size.y*Vector3f::Down()); + } + + void TileMap::UpdateData(InstanceData* instanceData) const + { + std::size_t spriteCount = 0; + for (const Layer& layer : m_layers) + spriteCount += layer.tiles.size(); + + instanceData->data.resize(4 * spriteCount * sizeof(VertexStruct_XYZ_Color_UV)); + VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(instanceData->data.data()); + + spriteCount = 0; + for (const Layer& layer : m_layers) + { + SparsePtr colorPtr(&vertices[spriteCount].color, sizeof(VertexStruct_XYZ_Color_UV)); + SparsePtr posPtr(&vertices[spriteCount].position, sizeof(VertexStruct_XYZ_Color_UV)); + SparsePtr texCoordPtr(&vertices[spriteCount].uv, sizeof(VertexStruct_XYZ_Color_UV)); + + for (std::size_t tileIndex : layer.tiles) + { + const Tile& tile = m_tiles[tileIndex]; + NazaraAssert(tile.enabled, "Tile specified for rendering is not enabled"); + + std::size_t x = tileIndex % m_mapSize.x; + std::size_t y = tileIndex / m_mapSize.x; + Vector3f tileLeftCorner(x * m_tileSize.x, y * -m_tileSize.y, 0.f); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftTop); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right()); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightTop); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.y * Vector3f::Down()); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftBottom); + + *colorPtr++ = tile.color; + *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right() + m_tileSize.y * Vector3f::Down()); + *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightBottom); + } + spriteCount += layer.tiles.size(); + } + } + + bool TileMap::Initialize() + { + if (!TileMapLibrary::Initialize()) + { + NazaraError("Failed to initialise library"); + return false; + } + + return true; + } + + void TileMap::Uninitialize() + { + TileMapLibrary::Uninitialize(); + } + + TileMapLibrary::LibraryMap TileMap::s_library; +} From c673a6610e83fdc72930a60771c330526ec8c25b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 Jul 2016 18:24:27 +0200 Subject: [PATCH 151/383] Doc: Fix \see Former-commit-id: 37558d45346d83d3f8bbf0cd1d83a9498cf557db [formerly 57482a1bb5c279fefdf40ea84a506879514a7cbd] Former-commit-id: 749e8e13129fa523554315fa248798db102874c3 --- include/Nazara/Core/ResourceSaver.inl | 4 ++-- include/Nazara/Graphics/TileMap.inl | 28 +++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/Nazara/Core/ResourceSaver.inl b/include/Nazara/Core/ResourceSaver.inl index 85f95fd3a..a22c29d60 100644 --- a/include/Nazara/Core/ResourceSaver.inl +++ b/include/Nazara/Core/ResourceSaver.inl @@ -48,7 +48,7 @@ namespace Nz * \remark The previous file content will be discarded, to prevent this behavior you should use SaveToStream * \remark The file extension will be used as format for the saver ("image.png" => "png", to write a specified format to a user-specified extension you should use SaveToStream * - * \seealso SaveToStream + * \see SaveToStream */ template bool ResourceSaver::SaveToFile(const Type& resource, const String& filePath, const Parameters& parameters) @@ -114,7 +114,7 @@ namespace Nz * \param format Data format to save the resource to * \param parameters Parameters for the saving * - * \seealso SaveToFile + * \see SaveToFile */ template bool ResourceSaver::SaveToStream(const Type& resource, Stream& stream, const String& format, const Parameters& parameters) diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 684b21387..405683f40 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -42,7 +42,7 @@ namespace Nz * * \param tilePos Position of the tile to disable * - * \seealso DisableTiles + * \see DisableTiles */ inline void TileMap::DisableTile(const Vector2ui& tilePos) { @@ -81,7 +81,7 @@ namespace Nz * * \remark if tileCount is zero, this is a no-op and the value of tilesPos is not used * - * \seealso DisableTile + * \see DisableTile */ inline void TileMap::DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount) { @@ -118,7 +118,7 @@ namespace Nz * \param color The multiplicative color applied to the tile * \param materialIndex The material which will be used for rendering this tile * - * \seealso EnableTiles + * \see EnableTiles */ inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color, std::size_t materialIndex) { @@ -161,7 +161,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTiles + * \see EnableTiles */ inline void TileMap::EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color, std::size_t materialIndex) { @@ -188,7 +188,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Rectf& coords, const Color& color, std::size_t materialIndex) { @@ -223,7 +223,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Rectui& rect, const Color& color, std::size_t materialIndex) { @@ -248,7 +248,7 @@ namespace Nz * \param color The multiplicative color applied to the tile * \param materialIndex The material which will be used for rendering this tile * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectf& coords, const Color& color, std::size_t materialIndex) { @@ -299,7 +299,7 @@ namespace Nz * \remark The material at [materialIndex] must have a valid diffuse map before using this function, * as the size of the material diffuse map is used to compute normalized texture coordinates before returning. * - * \seealso EnableTile + * \see EnableTile */ inline void TileMap::EnableTiles(const Vector2ui* tilesPos, std::size_t tileCount, const Rectui& rect, const Color& color, std::size_t materialIndex) { @@ -341,8 +341,8 @@ namespace Nz * \brief Gets the tilemap size (i.e. number of tiles in each dimension) * \return Number of tiles in each dimension * - * \seealso GetSize - * \seealso GetTileSize + * \see GetSize + * \see GetTileSize */ inline const Vector2ui& TileMap::GetMapSize() const { @@ -353,8 +353,8 @@ namespace Nz * \brief Returns the size of the tilemap in units (which is equivalent to GetMapSize() * GetTileSize()) * \return Maximum size in units occupied by this tilemap * - * \seealso GetMapSize - * \seealso GetTileSize + * \see GetMapSize + * \see GetTileSize */ inline Vector2f TileMap::GetSize() const { @@ -379,8 +379,8 @@ namespace Nz * \brief Gets the tile size (i.e. number of units occupied by a tile in each dimension) * \return Tile size in each dimension * - * \seealso GetMapSize - * \seealso GetSize + * \see GetMapSize + * \see GetSize */ inline const Vector2f& TileMap::GetTileSize() const { From 1cd5eb2dd0df92d08fad18c208acdd5788def321 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 Jul 2016 12:11:36 +0200 Subject: [PATCH 152/383] Add LICENSE file Former-commit-id: 9d520967f8a839af7e5e2b83114c1c362881fdea [formerly 18834c4bd4af10822b71c0f759c3b9ce73253e5a] Former-commit-id: bcb83176edf4987893963fd13dd5e34a8c89eab8 --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..aa1920df5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Jérôme Leclercq + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 705359e3b73ca39a4bf4964d6e9300ab723c12cd Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 Jul 2016 21:00:39 +0200 Subject: [PATCH 153/383] Build/UnitTest: Fix linking against Network module Former-commit-id: 69422c73fa14328306e372346a2bae2ead5412e0 [formerly bbff8882d6c5b8eb811a04f4f0561161d93dd2aa] Former-commit-id: 33a1050adac4332ae0c3e9a68c0f5294253a7cc0 --- build/scripts/tools/unittests.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index fc0f4bad6..0d3dcc7d2 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -21,9 +21,10 @@ TOOL.Libraries = { "NazaraCore", "NazaraAudio", "NazaraLua", + "NazaraGraphics", + "NazaraRenderer", + "NazaraNetwork", "NazaraNoise", "NazaraPhysics", - "NazaraUtility", - "NazaraRenderer", - "NazaraGraphics" + "NazaraUtility" } From f9a02f36d483ab2e73824068941ff14eab38c2c4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 Jul 2016 21:07:20 +0200 Subject: [PATCH 154/383] Sdk/State: Make destructor virtual Former-commit-id: 160f97ed46bebe76c8d74ebd2b0ee609052d1182 [formerly 422657a7e1576bc590e66c9d26c9dda68988c37c] Former-commit-id: 459cf63dfe7225687ce7f6e6373273ff7d8c24c5 --- SDK/include/NDK/State.hpp | 2 +- SDK/src/NDK/State.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 SDK/src/NDK/State.cpp diff --git a/SDK/include/NDK/State.hpp b/SDK/include/NDK/State.hpp index 613a504ab..f60cd6c4d 100644 --- a/SDK/include/NDK/State.hpp +++ b/SDK/include/NDK/State.hpp @@ -17,7 +17,7 @@ namespace Ndk { public: State() = default; - ~State() = default; + virtual ~State(); virtual void Enter(StateMachine& fsm) = 0; virtual void Leave(StateMachine& fsm) = 0; diff --git a/SDK/src/NDK/State.cpp b/SDK/src/NDK/State.cpp new file mode 100644 index 000000000..e256a7f1c --- /dev/null +++ b/SDK/src/NDK/State.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#include + +namespace Ndk +{ + State::~State() = default; +} From 676e76e4948badac300acc91b91ad01505354d22 Mon Sep 17 00:00:00 2001 From: Ardakaniz Date: Wed, 27 Jul 2016 20:33:42 +0200 Subject: [PATCH 155/383] Sdk/State: Fix State link error Former-commit-id: 09c6bbaba4661aed630602dfe016bfd2f475031b [formerly 7ee629153c4539e7dd8eb64d584baf73f6c51293] Former-commit-id: 38ef96c34e23453ad15c8ac43034f46be5cc4d12 --- SDK/include/NDK/State.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/State.hpp b/SDK/include/NDK/State.hpp index f60cd6c4d..621227fbe 100644 --- a/SDK/include/NDK/State.hpp +++ b/SDK/include/NDK/State.hpp @@ -13,7 +13,7 @@ namespace Ndk { class StateMachine; - class State + class NDK_API State { public: State() = default; From 96dc8c001eb5cfd42fddd0bc56ae96a81b65e4c1 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Thu, 28 Jul 2016 19:22:41 +0200 Subject: [PATCH 156/383] Various fixes Former-commit-id: 26dfbdb3388c845a6e3039f816f19ffbb462d7b8 [formerly a6437e0b6e48dbd630440f8d2629b32e4756b48e] Former-commit-id: 8a1855fc1d4d7c343b7e1fdcd3c6a31f3134a59a --- include/Nazara/Core/Algorithm.inl | 3 +- include/Nazara/Core/ByteArray.inl | 38 ++++++------- include/Nazara/Core/ObjectHandle.inl | 75 +++++++++++++------------- include/Nazara/Core/ObjectRef.inl | 74 ++++++++++++------------- include/Nazara/Core/String.inl | 15 +++--- include/Nazara/Graphics/Renderable.inl | 4 +- include/Nazara/Math/Algorithm.inl | 6 +-- include/Nazara/Math/BoundingVolume.hpp | 1 + include/Nazara/Math/Box.hpp | 1 + include/Nazara/Math/Box.inl | 2 +- include/Nazara/Math/EulerAngles.hpp | 1 + include/Nazara/Math/Frustum.hpp | 2 + include/Nazara/Math/Matrix4.inl | 8 +-- include/Nazara/Math/OrientedBox.hpp | 1 + include/Nazara/Math/OrientedBox.inl | 2 +- include/Nazara/Math/Plane.hpp | 2 + include/Nazara/Math/Ray.hpp | 1 + include/Nazara/Math/Rect.hpp | 1 + include/Nazara/Math/Rect.inl | 10 ++-- include/Nazara/Math/Sphere.hpp | 1 + include/Nazara/Math/Vector2.hpp | 1 + include/Nazara/Math/Vector3.hpp | 1 + include/Nazara/Math/Vector4.hpp | 1 + src/Nazara/Core/File.cpp | 6 +-- src/Nazara/Core/StringStream.cpp | 1 - src/Nazara/Utility/Image.cpp | 9 ++++ 26 files changed, 141 insertions(+), 126 deletions(-) diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 6997f8d1e..c77a5c3bb 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -78,7 +78,7 @@ namespace Nz * \param v Object to hash * * \remark a HashAppend specialization for type T is required - * + * * \see ComputeHash */ template @@ -124,6 +124,7 @@ namespace Nz template constexpr std::size_t CountOf(T(&name)[N]) noexcept { + NazaraUnused(name); return N; } diff --git a/include/Nazara/Core/ByteArray.inl b/include/Nazara/Core/ByteArray.inl index 1ff9bf185..068bee4b6 100644 --- a/include/Nazara/Core/ByteArray.inl +++ b/include/Nazara/Core/ByteArray.inl @@ -23,10 +23,10 @@ namespace Nz /*! * \brief Constructs a ByteArray object with a raw memory and a size * - * \param ptr Pointer to raw memory + * \param buffer Pointer to raw memory * \param n Size that can be accessed * - * \remark If preallocated space of ptr is less than the size, the behaviour is undefined + * \remark If preallocated space of buffer is less than the size, the behaviour is undefined */ inline ByteArray::ByteArray(const void* buffer, size_type n) : @@ -62,10 +62,10 @@ namespace Nz /*! * \brief Appends the content of raw memory * - * \param ptr Constant pointer to raw memory + * \param buffer Constant pointer to raw memory * \param n Size that can be read * - * \remark If preallocated space of ptr is less than the size, the behaviour is undefined + * \remark If preallocated space of buffer is less than the size, the behaviour is undefined * * \see Insert */ @@ -298,11 +298,11 @@ namespace Nz } /*! - * \brief Inserts n times the same value at the iterator position + * \brief Inserts n times the same byte at the iterator position * * \param pos Iterator to the position * \param n Number of repetitions - * \param value Value to repeat + * \param byte Value to repeat */ inline ByteArray::iterator ByteArray::Insert(const_iterator pos, size_type n, value_type byte) @@ -359,10 +359,10 @@ namespace Nz /*! * \brief Prepends the content of raw memory * - * \param ptr Constant pointer to raw memory + * \param buffer Constant pointer to raw memory * \param n Size that can be read * - * \remark If preallocated space of ptr is less than the size, the behaviour is undefined + * \remark If preallocated space of buffer is less than the size, the behaviour is undefined * * \see Insert */ @@ -682,8 +682,7 @@ namespace Nz * \brief Checks whether the first byte array is equal to the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator==(const ByteArray& rhs) const @@ -695,8 +694,7 @@ namespace Nz * \brief Checks whether the first byte array is equal to the second byte array * \return false if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator!=(const ByteArray& rhs) const @@ -708,8 +706,7 @@ namespace Nz * \brief Checks whether the first byte array is less than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator<(const ByteArray& rhs) const @@ -721,8 +718,7 @@ namespace Nz * \brief Checks whether the first byte array is less or equal than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator<=(const ByteArray& rhs) const @@ -731,11 +727,10 @@ namespace Nz } /*! - * \brief Checks whether the first byte array is greather than the second byte array + * \brief Checks whether the first byte array is greater than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator>(const ByteArray& rhs) const @@ -744,11 +739,10 @@ namespace Nz } /*! - * \brief Checks whether the first byte array is greather or equal than the second byte array + * \brief Checks whether the first byte array is greater or equal than the second byte array * \return true if it is the case * - * \param first ByteArray to compare in left hand side - * \param second ByteArray to compare in right hand side + * \param rhs ByteArray to compare with */ inline bool ByteArray::operator>=(const ByteArray& rhs) const diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index ee6e26268..d5badc964 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -291,15 +291,16 @@ namespace Nz template std::ostream& operator<<(std::ostream& out, const ObjectHandle& handle) { - return handle.ToString(); + out << handle.ToString(); + return out; } /*! * \brief Checks whether the first object handle is equal to the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator==(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -311,8 +312,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return true if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator==(const T& lhs, const ObjectHandle& rhs) @@ -324,8 +325,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator==(const ObjectHandle& lhs, const T& rhs) @@ -337,8 +338,8 @@ namespace Nz * \brief Checks whether the first object handle is equal to the second object handle * \return false if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator!=(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -350,8 +351,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return false if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator!=(const T& lhs, const ObjectHandle& rhs) @@ -363,8 +364,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return false if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator!=(const ObjectHandle& lhs, const T& rhs) @@ -376,8 +377,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -389,8 +390,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<(const T& lhs, const ObjectHandle& rhs) @@ -402,8 +403,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<(const ObjectHandle& lhs, const T& rhs) @@ -415,8 +416,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<=(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -428,8 +429,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<=(const T& lhs, const ObjectHandle& rhs) @@ -441,8 +442,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator<=(const ObjectHandle& lhs, const T& rhs) @@ -454,8 +455,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -467,8 +468,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>(const T& lhs, const ObjectHandle& rhs) @@ -480,8 +481,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>(const ObjectHandle& lhs, const T& rhs) @@ -493,8 +494,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>=(const ObjectHandle& lhs, const ObjectHandle& rhs) @@ -506,8 +507,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>=(const T& lhs, const ObjectHandle& rhs) @@ -519,8 +520,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectHandle to compare in left hand side - * \param second ObjectHandle to compare in right hand side + * \param lhs ObjectHandle to compare in left hand side + * \param rhs ObjectHandle to compare in right hand side */ template bool operator>=(const ObjectHandle& lhs, const T& rhs) diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index 8dab06948..85baff8bf 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -184,7 +184,7 @@ namespace Nz { return m_object; } - + /*! * \brief Assigns the object into this * \return A reference to this @@ -251,8 +251,8 @@ namespace Nz * \brief Checks whether the first object handle is equal to the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator==(const ObjectRef& lhs, const ObjectRef& rhs) @@ -264,8 +264,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return true if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator==(const T& lhs, const ObjectRef& rhs) @@ -277,8 +277,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator==(const ObjectRef& lhs, const T& rhs) @@ -290,8 +290,8 @@ namespace Nz * \brief Checks whether the first object handle is equal to the second object handle * \return false if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator!=(const ObjectRef& lhs, const ObjectRef& rhs) @@ -303,8 +303,8 @@ namespace Nz * \brief Checks whether the object is equal to the second object handle * \return false if it is the case * - * \param first Object to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs Object to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator!=(const T& lhs, const ObjectRef& rhs) @@ -316,8 +316,8 @@ namespace Nz * \brief Checks whether the object handle is equal to the second object * \return false if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second Object to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs Object to compare in right hand side */ template bool operator!=(const ObjectRef& lhs, const T& rhs) @@ -329,8 +329,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<(const ObjectRef& lhs, const ObjectRef& rhs) @@ -342,8 +342,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<(const T& lhs, const ObjectRef& rhs) @@ -355,8 +355,8 @@ namespace Nz * \brief Checks whether the first object handle is less than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<(const ObjectRef& lhs, const T& rhs) @@ -368,8 +368,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<=(const ObjectRef& lhs, const ObjectRef& rhs) @@ -381,8 +381,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<=(const T& lhs, const ObjectRef& rhs) @@ -394,8 +394,8 @@ namespace Nz * \brief Checks whether the first object handle is less or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator<=(const ObjectRef& lhs, const T& rhs) @@ -407,8 +407,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>(const ObjectRef& lhs, const ObjectRef& rhs) @@ -420,8 +420,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>(const T& lhs, const ObjectRef& rhs) @@ -433,8 +433,8 @@ namespace Nz * \brief Checks whether the first object handle is greather than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>(const ObjectRef& lhs, const T& rhs) @@ -446,8 +446,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>=(const ObjectRef& lhs, const ObjectRef& rhs) @@ -459,8 +459,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>=(const T& lhs, const ObjectRef& rhs) @@ -472,8 +472,8 @@ namespace Nz * \brief Checks whether the first object handle is greather or equal than the second object handle * \return true if it is the case * - * \param first ObjectRef to compare in left hand side - * \param second ObjectRef to compare in right hand side + * \param lhs ObjectRef to compare in left hand side + * \param rhs ObjectRef to compare in right hand side */ template bool operator>=(const ObjectRef& lhs, const T& rhs) diff --git a/include/Nazara/Core/String.inl b/include/Nazara/Core/String.inl index aa4343371..a5e099a3c 100644 --- a/include/Nazara/Core/String.inl +++ b/include/Nazara/Core/String.inl @@ -45,7 +45,7 @@ namespace Nz */ inline String::SharedString::SharedString(std::size_t strSize) : - capacity(strSize), + capacity(strSize), size(strSize), string(new char[strSize + 1]) { @@ -84,16 +84,15 @@ namespace Nz namespace std { - /*! - * \brief Specialisation of std to hash - * \return Result of the hash - * - * \param str String to hash - */ - template<> struct hash { + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param str String to hash + */ size_t operator()(const Nz::String& str) const { // Algorithme DJB2 diff --git a/include/Nazara/Graphics/Renderable.inl b/include/Nazara/Graphics/Renderable.inl index 9a69329a5..804567814 100644 --- a/include/Nazara/Graphics/Renderable.inl +++ b/include/Nazara/Graphics/Renderable.inl @@ -24,9 +24,7 @@ namespace Nz } /*! - * \brief Updates the bounding volume by a matrix - * - * \param transformMatrix Matrix transformation for our bounding volume + * \brief Updates the bounding volume */ inline void Renderable::UpdateBoundingVolume() const diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 524f0bd4c..2c865ad1b 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -105,7 +105,7 @@ namespace Nz * * \param value Initial value * \param objective Target value - * \parma increment One step value + * \param increment One step value */ template @@ -412,7 +412,7 @@ namespace Nz * \brief Gets the log in base 2 of integral number, only works for power of two ! * \return Log of the number * - * \param number To get log in base 2 + * \param pot To get log in base 2 * * \remark Only works for power of two * \remark If number is 0, 0 is returned @@ -431,7 +431,7 @@ namespace Nz * \return base^exponent for integral * * \param base Base of the exponentation - * \parma exponent Power for the base + * \param exponent Power for the base */ //TODO: Mark as constexpr when supported by all major compilers diff --git a/include/Nazara/Math/BoundingVolume.hpp b/include/Nazara/Math/BoundingVolume.hpp index 6f1f4b804..6c863b729 100644 --- a/include/Nazara/Math/BoundingVolume.hpp +++ b/include/Nazara/Math/BoundingVolume.hpp @@ -53,6 +53,7 @@ namespace Nz void Update(const Vector3& translation); BoundingVolume operator*(T scalar) const; + BoundingVolume& operator=(const BoundingVolume& other) = default; BoundingVolume& operator*=(T scalar); diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index a2a6f25d1..25e9a8069 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -79,6 +79,7 @@ namespace Nz Box operator*(T scalar) const; Box operator*(const Vector3& vec) const; + Box& operator=(const Box& other) = default; Box& operator*=(T scalar); Box& operator*=(const Vector3& vec); diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index a6200cbe4..71c98a70b 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -787,7 +787,7 @@ namespace Nz * \brief Multiplies the lengths with the scalar * \return A box where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar * - * \param scale The scalar to multiply width, height and depth with + * \param scalar The scalar to multiply width, height and depth with */ template diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index 6ada39982..ab267e81f 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -47,6 +47,7 @@ namespace Nz EulerAngles operator-(const EulerAngles& angles) const; /*EulerAngles operator*(const EulerAngles& angles) const; EulerAngles operator/(const EulerAngles& angles) const;*/ + EulerAngles& operator=(const EulerAngles& other) = default; EulerAngles& operator+=(const EulerAngles& angles); EulerAngles& operator-=(const EulerAngles& angles); diff --git a/include/Nazara/Math/Frustum.hpp b/include/Nazara/Math/Frustum.hpp index 2e51c0bd6..96c78004c 100644 --- a/include/Nazara/Math/Frustum.hpp +++ b/include/Nazara/Math/Frustum.hpp @@ -50,6 +50,8 @@ namespace Nz IntersectionSide Intersect(const Sphere& sphere) const; IntersectionSide Intersect(const Vector3* points, unsigned int pointCount) const; + Frustum& operator=(const Frustum& other) = default; + Frustum& Set(const Frustum& frustum); template Frustum& Set(const Frustum& frustum); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index b0decee2a..4cf2eaa6e 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -750,7 +750,7 @@ namespace Nz * \brief Inverts this matrix * \return A reference to this matrix inverted * - * \param bool Optional argument to know if matrix has been successfully inverted + * \param succeeded Optional argument to know if matrix has been successfully inverted * * \see InverseAffine */ @@ -769,7 +769,7 @@ namespace Nz * \brief Inverts this matrix * \return A reference to this matrix inverted * - * \param bool Optional argument to know if matrix has been successfully inverted + * \param succeeded Optional argument to know if matrix has been successfully inverted * * \see Inverse */ @@ -1487,7 +1487,7 @@ namespace Nz * \brief Compares the matrix to other one * \return true if the matrices are the same * - * \param matrix Other matrix to compare with + * \param mat Other matrix to compare with */ template @@ -1504,7 +1504,7 @@ namespace Nz * \brief Compares the matrix to other one * \return false if the matrices are the same * - * \param matrix Other matrix to compare with + * \param mat Other matrix to compare with */ template diff --git a/include/Nazara/Math/OrientedBox.hpp b/include/Nazara/Math/OrientedBox.hpp index 43d4b1aaf..2b806e56b 100644 --- a/include/Nazara/Math/OrientedBox.hpp +++ b/include/Nazara/Math/OrientedBox.hpp @@ -52,6 +52,7 @@ namespace Nz Vector3 operator()(unsigned int i) const; OrientedBox operator*(T scalar) const; + OrientedBox& operator=(const OrientedBox& other) = default; OrientedBox& operator*=(T scalar); diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index 9bcd94e1d..3320dce1a 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -340,7 +340,7 @@ namespace Nz * \brief Multiplies the lengths with the scalar * \return A OrientedBox where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar * - * \param scale The scalar to multiply width, height and depth with + * \param scalar The scalar to multiply width, height and depth with */ template diff --git a/include/Nazara/Math/Plane.hpp b/include/Nazara/Math/Plane.hpp index f37fc90c7..0eb201123 100644 --- a/include/Nazara/Math/Plane.hpp +++ b/include/Nazara/Math/Plane.hpp @@ -45,6 +45,8 @@ namespace Nz String ToString() const; + Plane& operator=(const Plane& other) = default; + bool operator==(const Plane& plane) const; bool operator!=(const Plane& plane) const; diff --git a/include/Nazara/Math/Ray.hpp b/include/Nazara/Math/Ray.hpp index b391ad866..7e8c0790a 100644 --- a/include/Nazara/Math/Ray.hpp +++ b/include/Nazara/Math/Ray.hpp @@ -61,6 +61,7 @@ namespace Nz String ToString() const; Vector3 operator*(T lambda) const; + Ray& operator=(const Ray& other) = default; bool operator==(const Ray& ray) const; bool operator!=(const Ray& ray) const; diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index 393d8d116..843ff6126 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -71,6 +71,7 @@ namespace Nz Rect operator*(const Vector2& vec) const; Rect operator/(T scalar) const; Rect operator/(const Vector2& vec) const; + Rect& operator=(const Rect& other) = default; Rect& operator*=(T scalar); Rect& operator*=(const Vector2& vec); diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index f53dd0c0f..21d0e7e93 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -629,7 +629,7 @@ namespace Nz * \brief Multiplies the lengths with the scalar * \return A rectangle where the position is the same and width and height are the product of the old width and height and the scalar * - * \param scale The scalar to multiply width and height with + * \param scalar The scalar to multiply width and height with */ template @@ -655,13 +655,13 @@ namespace Nz * \brief Divides the lengths with the scalar * \return A rectangle where the position is the same and width and height are the quotient of the old width and height and the scalar * - * \param scale The scalar to divide width and height with + * \param scalar The scalar to divide width and height with */ template Rect Rect::operator/(T scalar) const { - return Rect(x, y, width/scalar, height/scalar); + return Rect(x, y, width / scalar, height / scalar); } /*! @@ -745,7 +745,7 @@ namespace Nz * \brief Compares the rectangle to other one * \return true if the rectangles are the same * - * \param rec Other rectangle to compare with + * \param rect Other rectangle to compare with */ template @@ -759,7 +759,7 @@ namespace Nz * \brief Compares the rectangle to other one * \return false if the rectangles are the same * - * \param rec Other rectangle to compare with + * \param rect Other rectangle to compare with */ template diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index 929c1ec71..8f7ac9e14 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -67,6 +67,7 @@ namespace Nz T operator[](unsigned int i) const; Sphere operator*(T scalar) const; + Sphere& operator=(const Sphere& other) = default; Sphere& operator*=(T scalar); diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index b275d0544..e0ac1d68d 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -76,6 +76,7 @@ namespace Nz Vector2 operator*(T scale) const; Vector2 operator/(const Vector2& vec) const; Vector2 operator/(T scale) const; + Vector2& operator=(const Vector2& other) = default; Vector2& operator+=(const Vector2& vec); Vector2& operator-=(const Vector2& vec); diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 7743e7a35..4e6da14ec 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -87,6 +87,7 @@ namespace Nz Vector3 operator*(T scale) const; Vector3 operator/(const Vector3& vec) const; Vector3 operator/(T scale) const; + Vector3& operator=(const Vector3& vec) = default; Vector3& operator+=(const Vector3& vec); Vector3& operator-=(const Vector3& vec); diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index b84a4cb17..0f8e907fc 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -74,6 +74,7 @@ namespace Nz Vector4 operator*(T scale) const; Vector4 operator/(const Vector4& vec) const; Vector4 operator/(T scale) const; + Vector4& operator=(const Vector4& other) = default; Vector4& operator+=(const Vector4& vec); Vector4& operator-=(const Vector4& vec); diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 97504b0ee..131ceb7f3 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -385,7 +385,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param pos Position of the cursor @@ -404,7 +404,7 @@ namespace Nz } /*! - * \brief Sets the position of the cursor + * \brief Sets the position of the cursor * \return true if cursor is successfully positioned * * \param offset Offset according to the cursor begin position @@ -725,7 +725,7 @@ namespace Nz return true; else if (path.Match("\\\\*")) // Ex: \\Laptop return true; - else if (path.StartsWith('\\')) // Special : '\' refering to the root + else if (path.StartsWith('\\')) // Special : '\' referring to the root return true; else return false; diff --git a/src/Nazara/Core/StringStream.cpp b/src/Nazara/Core/StringStream.cpp index 14d35799d..0b27077e5 100644 --- a/src/Nazara/Core/StringStream.cpp +++ b/src/Nazara/Core/StringStream.cpp @@ -1,4 +1,3 @@ -#include "..\..\..\include\Nazara\Core\StringStream.hpp" // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 9e0213cf6..4b780eef1 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -1352,6 +1352,15 @@ namespace Nz void Image::Copy(UInt8* destination, const UInt8* source, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, unsigned int dstWidth, unsigned int dstHeight, unsigned int srcWidth, unsigned int srcHeight) { + #if NAZARA_UTILITY_SAFE + if (width == 0) + NazaraError("Width must be greater than zero"); + if (height == 0) + NazaraError("Height must be greater than zero"); + if (depth == 0) + NazaraError("Depth must be greater than zero"); + #endif + if (dstWidth == 0) dstWidth = width; From b273a0857147d6e0dedf4d99218bb2f43e2d53c2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:24:19 +0200 Subject: [PATCH 157/383] Graphics: Rename ParticleSystem to ParticleGroup Preparing for integration into the ECS Former-commit-id: 9ca871117d0be3d4c655225d3f3dad6b0277cdd8 [formerly 9343fd818957da74e0bb7a5715a2172eefc325e5] Former-commit-id: 93cf58c80f0cd396211df0c95063f0ad05449e75 --- include/Nazara/Graphics.hpp | 2 +- .../Nazara/Graphics/ParticleController.hpp | 4 +- include/Nazara/Graphics/ParticleEmitter.hpp | 4 +- include/Nazara/Graphics/ParticleGenerator.hpp | 4 +- .../{ParticleSystem.hpp => ParticleGroup.hpp} | 18 ++--- include/Nazara/Graphics/ParticleRenderer.hpp | 4 +- src/Nazara/Graphics/ParticleEmitter.cpp | 4 +- .../{ParticleSystem.cpp => ParticleGroup.cpp} | 66 +++++++++---------- .../{ParticleSystem.cpp => ParticleGroup.cpp} | 26 ++++---- 9 files changed, 66 insertions(+), 66 deletions(-) rename include/Nazara/Graphics/{ParticleSystem.hpp => ParticleGroup.hpp} (84%) rename src/Nazara/Graphics/{ParticleSystem.cpp => ParticleGroup.cpp} (83%) rename tests/Engine/Graphics/{ParticleSystem.cpp => ParticleGroup.cpp} (75%) diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 17b10e9a1..4809d9481 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -63,10 +63,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/include/Nazara/Graphics/ParticleController.hpp b/include/Nazara/Graphics/ParticleController.hpp index 17e4ac9e1..05537ba55 100644 --- a/include/Nazara/Graphics/ParticleController.hpp +++ b/include/Nazara/Graphics/ParticleController.hpp @@ -18,7 +18,7 @@ namespace Nz { class ParticleController; class ParticleMapper; - class ParticleSystem; + class ParticleGroup; using ParticleControllerConstRef = ObjectRef; using ParticleControllerLibrary = ObjectLibrary; @@ -34,7 +34,7 @@ namespace Nz ParticleController(const ParticleController& controller); virtual ~ParticleController(); - virtual void Apply(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0; + virtual void Apply(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0; // Signals: NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/); diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index d5e3c8ea8..b6acee156 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -14,7 +14,7 @@ namespace Nz { class ParticleMapper; - class ParticleSystem; + class ParticleGroup; class NAZARA_GRAPHICS_API ParticleEmitter : public Node { @@ -24,7 +24,7 @@ namespace Nz ParticleEmitter(ParticleEmitter&& emitter) = default; virtual ~ParticleEmitter(); - virtual void Emit(ParticleSystem& system, float elapsedTime) const; + virtual void Emit(ParticleGroup& system, float elapsedTime) const; void EnableLagCompensation(bool enable); diff --git a/include/Nazara/Graphics/ParticleGenerator.hpp b/include/Nazara/Graphics/ParticleGenerator.hpp index d9d2a789a..d072ae346 100644 --- a/include/Nazara/Graphics/ParticleGenerator.hpp +++ b/include/Nazara/Graphics/ParticleGenerator.hpp @@ -18,7 +18,7 @@ namespace Nz { class ParticleGenerator; class ParticleMapper; - class ParticleSystem; + class ParticleGroup; using ParticleGeneratorConstRef = ObjectRef; using ParticleGeneratorLibrary = ObjectLibrary; @@ -34,7 +34,7 @@ namespace Nz ParticleGenerator(const ParticleGenerator& generator); virtual ~ParticleGenerator(); - virtual void Generate(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0; + virtual void Generate(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0; // Signals: NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/); diff --git a/include/Nazara/Graphics/ParticleSystem.hpp b/include/Nazara/Graphics/ParticleGroup.hpp similarity index 84% rename from include/Nazara/Graphics/ParticleSystem.hpp rename to include/Nazara/Graphics/ParticleGroup.hpp index 76b834f6e..aaa65bb7f 100644 --- a/include/Nazara/Graphics/ParticleSystem.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_PARTICLESYSTEM_HPP -#define NAZARA_PARTICLESYSTEM_HPP +#ifndef NAZARA_PARTICLEGROUP_HPP +#define NAZARA_PARTICLEGROUP_HPP #include #include @@ -22,13 +22,13 @@ namespace Nz { - class NAZARA_GRAPHICS_API ParticleSystem : public Renderable + class NAZARA_GRAPHICS_API ParticleGroup : public Renderable { public: - ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout); - ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration); - ParticleSystem(const ParticleSystem& emitter); - ~ParticleSystem(); + ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout); + ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration); + ParticleGroup(const ParticleGroup& emitter); + ~ParticleGroup(); void AddController(ParticleControllerRef controller); void AddEmitter(ParticleEmitter* emitter); @@ -66,7 +66,7 @@ namespace Nz void Update(float elapsedTime); void UpdateBoundingVolume(const Matrix4f& transformMatrix) override; - ParticleSystem& operator=(const ParticleSystem& emitter); + ParticleGroup& operator=(const ParticleGroup& emitter); private: void MakeBoundingVolume() const override; @@ -89,4 +89,4 @@ namespace Nz }; } -#endif // NAZARA_PARTICLESYSTEM_HPP +#endif // NAZARA_PARTICLEGROUP_HPP diff --git a/include/Nazara/Graphics/ParticleRenderer.hpp b/include/Nazara/Graphics/ParticleRenderer.hpp index d79d448f2..2ddca18b3 100644 --- a/include/Nazara/Graphics/ParticleRenderer.hpp +++ b/include/Nazara/Graphics/ParticleRenderer.hpp @@ -19,7 +19,7 @@ namespace Nz class AbstractRenderQueue; class ParticleMapper; class ParticleRenderer; - class ParticleSystem; + class ParticleGroup; using ParticleRendererConstRef = ObjectRef; using ParticleRendererLibrary = ObjectLibrary; @@ -35,7 +35,7 @@ namespace Nz ParticleRenderer(const ParticleRenderer& renderer); virtual ~ParticleRenderer(); - virtual void Render(const ParticleSystem& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0; + virtual void Render(const ParticleGroup& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0; // Signals: NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/); diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index ded77d80e..b11cfdfe9 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleEmitter::Emit(ParticleSystem& system, float elapsedTime) const + void ParticleEmitter::Emit(ParticleGroup& system, float elapsedTime) const { if (m_emissionRate > 0.f) { diff --git a/src/Nazara/Graphics/ParticleSystem.cpp b/src/Nazara/Graphics/ParticleGroup.cpp similarity index 83% rename from src/Nazara/Graphics/ParticleSystem.cpp rename to src/Nazara/Graphics/ParticleGroup.cpp index 0783dd7fd..08fb03f39 100644 --- a/src/Nazara/Graphics/ParticleSystem.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -26,8 +26,8 @@ namespace Nz * \param layout Enumeration for the layout of data information for the particles */ - ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout) : - ParticleSystem(maxParticleCount, ParticleDeclaration::Get(layout)) + ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout) : + ParticleGroup(maxParticleCount, ParticleDeclaration::Get(layout)) { } @@ -38,7 +38,7 @@ namespace Nz * \param declaration Data information for the particles */ - ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : + ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : m_declaration(std::move(declaration)), m_processing(false), m_maxParticleCount(maxParticleCount), @@ -58,7 +58,7 @@ namespace Nz * \param system ParticleSystem to copy into this */ - ParticleSystem::ParticleSystem(const ParticleSystem& system) : + ParticleGroup::ParticleGroup(const ParticleGroup& system) : Renderable(system), m_controllers(system.m_controllers), m_generators(system.m_generators), @@ -77,7 +77,7 @@ namespace Nz std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); } - ParticleSystem::~ParticleSystem() = default; + ParticleGroup::~ParticleGroup() = default; /*! * \brief Adds a controller to the particles @@ -87,7 +87,7 @@ namespace Nz * \remark Produces a NazaraAssert if controller is invalid */ - void ParticleSystem::AddController(ParticleControllerRef controller) + void ParticleGroup::AddController(ParticleControllerRef controller) { NazaraAssert(controller, "Invalid particle controller"); @@ -102,7 +102,7 @@ namespace Nz * \remark Produces a NazaraAssert if emitter is invalid */ - void ParticleSystem::AddEmitter(ParticleEmitter* emitter) + void ParticleGroup::AddEmitter(ParticleEmitter* emitter) { NazaraAssert(emitter, "Invalid particle emitter"); @@ -117,7 +117,7 @@ namespace Nz * \remark Produces a NazaraAssert if generator is invalid */ - void ParticleSystem::AddGenerator(ParticleGeneratorRef generator) + void ParticleGroup::AddGenerator(ParticleGeneratorRef generator) { NazaraAssert(generator, "Invalid particle generator"); @@ -134,7 +134,7 @@ namespace Nz * \remark Produces a NazaraAssert if renderQueue is invalid */ - void ParticleSystem::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const + void ParticleGroup::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const { NazaraAssert(m_renderer, "Invalid particle renderer"); NazaraAssert(renderQueue, "Invalid renderqueue"); @@ -155,7 +155,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleSystem::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) + void ParticleGroup::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) { m_processing = true; @@ -190,7 +190,7 @@ namespace Nz * \return Pointer to the particle memory buffer */ - void* ParticleSystem::CreateParticle() + void* ParticleGroup::CreateParticle() { return CreateParticles(1); } @@ -200,7 +200,7 @@ namespace Nz * \return Pointer to the first particle memory buffer */ - void* ParticleSystem::CreateParticles(unsigned int count) + void* ParticleGroup::CreateParticles(unsigned int count) { if (count == 0) return nullptr; @@ -219,7 +219,7 @@ namespace Nz * \return Pointer to the particle memory buffer */ - void* ParticleSystem::GenerateParticle() + void* ParticleGroup::GenerateParticle() { return GenerateParticles(1); } @@ -229,7 +229,7 @@ namespace Nz * \return Pointer to the first particle memory buffer */ - void* ParticleSystem::GenerateParticles(unsigned int count) + void* ParticleGroup::GenerateParticles(unsigned int count) { void* ptr = CreateParticles(count); if (!ptr) @@ -247,7 +247,7 @@ namespace Nz * \return Particle declaration */ - const ParticleDeclarationConstRef& ParticleSystem::GetDeclaration() const + const ParticleDeclarationConstRef& ParticleGroup::GetDeclaration() const { return m_declaration; } @@ -257,7 +257,7 @@ namespace Nz * \return Current fixed step size */ - float ParticleSystem::GetFixedStepSize() const + float ParticleGroup::GetFixedStepSize() const { return m_stepSize; } @@ -267,7 +267,7 @@ namespace Nz * \return Current maximum number */ - unsigned int ParticleSystem::GetMaxParticleCount() const + unsigned int ParticleGroup::GetMaxParticleCount() const { return m_maxParticleCount; } @@ -277,7 +277,7 @@ namespace Nz * \return Current number */ - unsigned int ParticleSystem::GetParticleCount() const + unsigned int ParticleGroup::GetParticleCount() const { return m_particleCount; } @@ -287,7 +287,7 @@ namespace Nz * \return Current size */ - unsigned int ParticleSystem::GetParticleSize() const + unsigned int ParticleGroup::GetParticleSize() const { return m_particleSize; } @@ -297,7 +297,7 @@ namespace Nz * \return true If it is the case */ - bool ParticleSystem::IsFixedStepEnabled() const + bool ParticleGroup::IsFixedStepEnabled() const { return m_fixedStepEnabled; } @@ -308,7 +308,7 @@ namespace Nz * \param index Index of the particle */ - void ParticleSystem::KillParticle(unsigned int index) + void ParticleGroup::KillParticle(unsigned int index) { ///FIXME: Verify the index @@ -328,7 +328,7 @@ namespace Nz * \brief Kills every particles */ - void ParticleSystem::KillParticles() + void ParticleGroup::KillParticles() { m_particleCount = 0; } @@ -339,7 +339,7 @@ namespace Nz * \param controller Controller for the particles to remove */ - void ParticleSystem::RemoveController(ParticleController* controller) + void ParticleGroup::RemoveController(ParticleController* controller) { auto it = std::find(m_controllers.begin(), m_controllers.end(), controller); if (it != m_controllers.end()) @@ -352,7 +352,7 @@ namespace Nz * \param emitter Emitter for the particles to remove */ - void ParticleSystem::RemoveEmitter(ParticleEmitter* emitter) + void ParticleGroup::RemoveEmitter(ParticleEmitter* emitter) { auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter); if (it != m_emitters.end()) @@ -365,7 +365,7 @@ namespace Nz * \param generator Generator for the particles to remove */ - void ParticleSystem::RemoveGenerator(ParticleGenerator* generator) + void ParticleGroup::RemoveGenerator(ParticleGenerator* generator) { auto it = std::find(m_generators.begin(), m_generators.end(), generator); if (it != m_generators.end()) @@ -378,7 +378,7 @@ namespace Nz * \param stepSize Fixed step size */ - void ParticleSystem::SetFixedStepSize(float stepSize) + void ParticleGroup::SetFixedStepSize(float stepSize) { m_stepSize = stepSize; } @@ -389,7 +389,7 @@ namespace Nz * \param renderer Renderer for the particles */ - void ParticleSystem::SetRenderer(ParticleRenderer* renderer) + void ParticleGroup::SetRenderer(ParticleRenderer* renderer) { m_renderer = renderer; } @@ -400,7 +400,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleSystem::Update(float elapsedTime) + void ParticleGroup::Update(float elapsedTime) { // Emission for (ParticleEmitter* emitter : m_emitters) @@ -421,7 +421,7 @@ namespace Nz * \param transformMatrix Matrix transformation for our bounding volume */ - void ParticleSystem::UpdateBoundingVolume(const Matrix4f& transformMatrix) + void ParticleGroup::UpdateBoundingVolume(const Matrix4f& transformMatrix) { NazaraUnused(transformMatrix); @@ -435,7 +435,7 @@ namespace Nz * \param system The other ParticleSystem */ - ParticleSystem& ParticleSystem::operator=(const ParticleSystem& system) + ParticleGroup& ParticleGroup::operator=(const ParticleGroup& system) { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -468,7 +468,7 @@ namespace Nz * \brief Makes the bounding volume of this text */ - void ParticleSystem::MakeBoundingVolume() const + void ParticleGroup::MakeBoundingVolume() const { ///TODO: Compute the AABB (taking into account the size of particles) m_boundingVolume.MakeInfinite(); @@ -480,7 +480,7 @@ namespace Nz * \remark Produces a NazaraError if resize did not work */ - void ParticleSystem::ResizeBuffer() + void ParticleGroup::ResizeBuffer() { // Just to have a better description of our problem in case of error try diff --git a/tests/Engine/Graphics/ParticleSystem.cpp b/tests/Engine/Graphics/ParticleGroup.cpp similarity index 75% rename from tests/Engine/Graphics/ParticleSystem.cpp rename to tests/Engine/Graphics/ParticleGroup.cpp index 32f5f01f9..36ad2cb0b 100644 --- a/tests/Engine/Graphics/ParticleSystem.cpp +++ b/tests/Engine/Graphics/ParticleGroup.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,7 +8,7 @@ class TestParticleController : public Nz::ParticleController { public: // Be aware that the interval is [startId, endId] and NOT [startId, endId) - void Apply(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override + void Apply(Nz::ParticleGroup& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override { Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); @@ -32,7 +32,7 @@ class TestParticleEmitter : public Nz::ParticleEmitter public: ~TestParticleEmitter() override = default; - void Emit(Nz::ParticleSystem& system, float elapsedTime) const override + void Emit(Nz::ParticleGroup& system, float elapsedTime) const override { system.GenerateParticles(GetEmissionCount()); } @@ -49,7 +49,7 @@ class TestParticleGenerator : public Nz::ParticleGenerator ~TestParticleGenerator() override = default; // Be aware that the interval is [startId, endId] and NOT [startId, endId) - void Generate(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override + void Generate(Nz::ParticleGroup& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override { Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); @@ -68,35 +68,35 @@ class TestParticleGenerator : public Nz::ParticleGenerator } }; -SCENARIO("ParticleSystem", "[GRAPHICS][PARTICLESYSTEM]") +SCENARIO("ParticleGroup", "[GRAPHICS][PARTICLEGROUP]") { GIVEN("A particle system of maximum 10 billboards with its generators") { // These need to be alive longer than the particle system TestParticleController particleController; TestParticleGenerator particleGenerator; - Nz::ParticleSystem particleSystem(10, Nz::ParticleLayout_Billboard); + Nz::ParticleGroup particleGroup(10, Nz::ParticleLayout_Billboard); - particleSystem.AddController(&particleController); + particleGroup.AddController(&particleController); TestParticleEmitter particleEmitter; particleEmitter.SetEmissionCount(10); - particleSystem.AddEmitter(&particleEmitter); + particleGroup.AddEmitter(&particleEmitter); - particleSystem.AddGenerator(&particleGenerator); + particleGroup.AddGenerator(&particleGenerator); WHEN("We update to generate 10 particles") { - particleSystem.Update(1.f); + particleGroup.Update(1.f); THEN("There must be 10 particles") { - REQUIRE(particleSystem.GetParticleCount() == 10); + REQUIRE(particleGroup.GetParticleCount() == 10); } AND_THEN("We update to make them die") { - particleSystem.Update(2.f); - REQUIRE(particleSystem.GetParticleCount() == 0); + particleGroup.Update(2.f); + REQUIRE(particleGroup.GetParticleCount() == 0); } } } From f9d6f27e9242aeb15166e1008e94e95e84c853bf Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:37:44 +0200 Subject: [PATCH 158/383] Utility/OBJParser: Abort parsing when there's more than one error per two line Former-commit-id: 37075de6e7d10996af4c30ffcf74ead74b27905f [formerly 25597dd190b82dc40de1eaf7f4c75c9b058784ec] Former-commit-id: 5383d58fd326b61cce4c415707dd06a0376e6dbe --- include/Nazara/Utility/Formats/OBJParser.hpp | 3 +- include/Nazara/Utility/Formats/OBJParser.inl | 12 ++++- src/Nazara/Utility/Formats/OBJParser.cpp | 53 ++++++++++++-------- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 50fa58900..114f72635 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -86,7 +86,7 @@ namespace Nz inline void Error(const String& message); inline void Flush() const; inline void Warning(const String& message); - inline void UnrecognizedLine(bool error = false); + inline bool UnrecognizedLine(bool error = false); std::vector m_meshes; std::vector m_materials; @@ -99,6 +99,7 @@ namespace Nz mutable StringStream m_outputStream; bool m_keepLastLine; unsigned int m_lineCount; + unsigned int m_errorCount; }; } diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 9d961d54f..054d57754 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -168,7 +168,7 @@ namespace Nz NazaraWarning(message + " at line #" + String::Number(m_lineCount)); } - inline void OBJParser::UnrecognizedLine(bool error) + inline bool OBJParser::UnrecognizedLine(bool error) { String message = "Unrecognized \"" + m_currentLine + '"'; @@ -176,6 +176,16 @@ namespace Nz Error(message); else Warning(message); + + m_errorCount++; + + if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50) + { + NazaraError("Aborting parsing because of error percentage"); + return false; //< Abort parsing if error percentage is too high + } + + return true; } } diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index bd189305f..7d3019c39 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -97,7 +97,8 @@ namespace Nz if (m_currentLine.GetSize() < 7) // Since we only treat triangles, this is the minimum length of a face line (f 1 2 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -106,7 +107,8 @@ namespace Nz if (vertexCount < 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -138,7 +140,8 @@ namespace Nz if (std::sscanf(&m_currentLine[pos], "%d%n", &p, &offset) != 1) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif error = true; break; @@ -217,7 +220,8 @@ namespace Nz case 'm': //< MTLLib #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0).ToLower() != "mtllib") - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif m_mtlLib = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); @@ -229,7 +233,8 @@ namespace Nz if (m_currentLine.GetSize() <= 2 || m_currentLine[1] != ' ') { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -238,7 +243,8 @@ namespace Nz if (objectName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -254,17 +260,20 @@ namespace Nz { String param = m_currentLine.SubString(2); if (param != "all" && param != "on" && param != "off" && !param.IsNumber()) - UnrecognizedLine(); + { + if (!UnrecognizedLine()) + return false; + } } - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + return false; break; #endif case 'u': //< Usemtl #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - if (m_currentLine.GetWord(0) != "usemtl") - UnrecognizedLine(); + if (m_currentLine.GetWord(0) != "usemtl" && !UnrecognizedLine()) + return false; #endif matName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); @@ -272,7 +281,8 @@ namespace Nz if (matName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } @@ -288,8 +298,8 @@ namespace Nz if (paramCount >= 1) m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif } else if (word == "vn") @@ -299,8 +309,8 @@ namespace Nz if (paramCount == 3) m_normals.push_back(normal); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif } else if (word == "vt") @@ -310,13 +320,13 @@ namespace Nz if (paramCount >= 2) m_texCoords.push_back(uvw); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - else - UnrecognizedLine(); + else if (!UnrecognizedLine()) + false; #endif break; @@ -324,7 +334,8 @@ namespace Nz default: #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING - UnrecognizedLine(); + if (!UnrecognizedLine()) + return false; #endif break; } From 2203d5781860f3a77d615e4977ddf871282526de Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:38:00 +0200 Subject: [PATCH 159/383] UnitTests: Fix blocking case Former-commit-id: 10d46cfff7380c1c98942a34386b462f41c8ccb7 [formerly fa3e8494f3c0912fcd6afed3eef746abbd7a38f0] Former-commit-id: 8fca4ecb8466e1240c489eacdee5303ed461f24b --- tests/Engine/Graphics/Model.cpp | 5 ++++- tests/Engine/Network/TCP.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Engine/Graphics/Model.cpp b/tests/Engine/Graphics/Model.cpp index d67a261bb..b363a0be2 100644 --- a/tests/Engine/Graphics/Model.cpp +++ b/tests/Engine/Graphics/Model.cpp @@ -9,8 +9,11 @@ SCENARIO("Model", "[GRAPHICS][MODEL]") { THEN("These results are expected") { + Nz::ModelParameters params; + params.mesh.optimizeIndexBuffers = false; + Nz::ModelRef model = Nz::Model::New(); - REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj")); + REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj", params)); REQUIRE(model->GetMaterialCount() == 2); REQUIRE(model->GetSkin() == 0); diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp index 63b4fe2df..a613cf0c6 100644 --- a/tests/Engine/Network/TCP.cpp +++ b/tests/Engine/Network/TCP.cpp @@ -18,6 +18,8 @@ SCENARIO("TCP", "[NETWORK][TCP]") Nz::UInt16 port = dis(gen); Nz::TcpServer server; + server.EnableBlocking(false); + REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound); Nz::IpAddress serverIP = server.GetBoundAddress(); REQUIRE(serverIP.IsValid()); From 2468fd63a4df325c109c8e3f2891d159341429ec Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 13:55:59 +0200 Subject: [PATCH 160/383] Graphics/ParticleGroup: Remove fixed step parameter (wasn't used) Former-commit-id: 9e0d603d8bf47cb971bdacbaa662f3068d035515 [formerly afc7e78d0e517d87ea1239fea4105f6a07ab3aea] Former-commit-id: 3c972ba5345592c2f35e1caf886ce6aa87560d4a --- include/Nazara/Graphics/ParticleGroup.hpp | 9 ------ src/Nazara/Graphics/ParticleGroup.cpp | 38 ++--------------------- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index aaa65bb7f..412b94511 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -40,19 +40,14 @@ namespace Nz void* CreateParticle(); void* CreateParticles(unsigned int count); - void EnableFixedStep(bool fixedStep); - void* GenerateParticle(); void* GenerateParticles(unsigned int count); const ParticleDeclarationConstRef& GetDeclaration() const; - float GetFixedStepSize() const; unsigned int GetMaxParticleCount() const; unsigned int GetParticleCount() const; unsigned int GetParticleSize() const; - bool IsFixedStepEnabled() const; - void KillParticle(unsigned int index); void KillParticles(); @@ -60,7 +55,6 @@ namespace Nz void RemoveEmitter(ParticleEmitter* emitter); void RemoveGenerator(ParticleGenerator* generator); - void SetFixedStepSize(float stepSize); void SetRenderer(ParticleRenderer* renderer); void Update(float elapsedTime); @@ -79,10 +73,7 @@ namespace Nz std::vector m_generators; ParticleDeclarationConstRef m_declaration; ParticleRendererRef m_renderer; - bool m_fixedStepEnabled; bool m_processing; - float m_stepAccumulator; - float m_stepSize; unsigned int m_maxParticleCount; unsigned int m_particleCount; unsigned int m_particleSize; diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index 08fb03f39..d93c085db 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -154,7 +154,6 @@ namespace Nz * \param particleCount Number of particles * \param elapsedTime Delta time between the previous frame */ - void ParticleGroup::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) { m_processing = true; @@ -174,8 +173,8 @@ namespace Nz if (m_dyingParticles.size() < m_particleCount) { // We kill them in reverse order, std::set sorting them via std::greater - // The reason is simple, as the death of a particle means the move of the last particle in the buffer, - // without this solution, certain particles could avoid the death + // The reason is simple, as the death of a particle means moving the last particle in the buffer, + // without this solution, certain particles could avoid death for (unsigned int index : m_dyingParticles) KillParticle(index); } @@ -252,16 +251,6 @@ namespace Nz return m_declaration; } - /*! - * \brief Gets the fixed step size - * \return Current fixed step size - */ - - float ParticleGroup::GetFixedStepSize() const - { - return m_stepSize; - } - /*! * \brief Gets the maximum number of particles * \return Current maximum number @@ -292,16 +281,6 @@ namespace Nz return m_particleSize; } - /*! - * \brief Checks whether the fixed step is enabled - * \return true If it is the case - */ - - bool ParticleGroup::IsFixedStepEnabled() const - { - return m_fixedStepEnabled; - } - /*! * \brief Kills one particle * @@ -372,17 +351,6 @@ namespace Nz m_generators.erase(it); } - /*! - * \brief Sets the fixed step size - * - * \param stepSize Fixed step size - */ - - void ParticleGroup::SetFixedStepSize(float stepSize) - { - m_stepSize = stepSize; - } - /*! * \brief Sets the renderer of the particles * @@ -448,12 +416,10 @@ namespace Nz m_particleCount = system.m_particleCount; m_particleSize = system.m_particleSize; m_renderer = system.m_renderer; - m_stepSize = system.m_stepSize; // The copy can not (or should not) happen during the update, there is no use to copy m_dyingParticles.clear(); m_processing = false; - m_stepAccumulator = 0.f; m_buffer.clear(); // To avoid a copy due to resize() which will be pointless ResizeBuffer(); From a7041185deab42bf1975db251aba146271fb6f03 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 18:49:16 +0200 Subject: [PATCH 161/383] SDK/ListenerComponent: Fix warnings Former-commit-id: b35d788a58590ab4eab4a8dfabe33e002e0c7339 [formerly 0b1e9ef21d7344214ef4ec2ef8238220b1c4eab8] Former-commit-id: ba79bb2a7f5dae94ab0dc077d6667670c09860f3 --- SDK/include/NDK/Components/ListenerComponent.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Components/ListenerComponent.hpp b/SDK/include/NDK/Components/ListenerComponent.hpp index 3d472bed3..a2b9d59d2 100644 --- a/SDK/include/NDK/Components/ListenerComponent.hpp +++ b/SDK/include/NDK/Components/ListenerComponent.hpp @@ -15,11 +15,11 @@ namespace Ndk class NDK_API ListenerComponent : public Component { public: - ListenerComponent(); + inline ListenerComponent(); ~ListenerComponent() = default; - bool IsActive() const; - void SetActive(bool active = true); + inline bool IsActive() const; + inline void SetActive(bool active = true); static ComponentIndex componentIndex; From f3fa95ee4fe2157137ae1cb7b920904e24189fca Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 23:47:09 +0200 Subject: [PATCH 162/383] Build: Add a separate config file and library/binary search paths support Former-commit-id: cdab236bb7e31f9a49f60c88de22a2d7b4c63a8a [formerly 7fa3e521de3428ce9d451c3117629a5e84ec675f] Former-commit-id: 71abf8891e423fecdfea0d80a13c156ed9a427a2 --- build/config.lua | 17 ++ build/scripts/common.lua | 500 ++++++++++++++++++++++----------------- 2 files changed, 304 insertions(+), 213 deletions(-) create mode 100644 build/config.lua diff --git a/build/config.lua b/build/config.lua new file mode 100644 index 000000000..8370331c7 --- /dev/null +++ b/build/config.lua @@ -0,0 +1,17 @@ +-- This file contains special configurations values, such as directories to extern libraries (Qt) +-- Editing this file is not required to use/compile the engine, as default values should be enough + +-- Builds Nazara extern libraries (such as lua/STB) +BuildDependencies = true + +-- Builds Nazara examples +BuildExamples = true + +-- Setup additionnals install directories, separated by a semi-colon ; (library binaries will be copied there) +--InstallDir = "/usr/local/lib64" + +-- Excludes client-only modules/tools/examples +ServerMode = false + +-- Builds modules as one united library (useless on POSIX systems) +UniteModules = false diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 2b4906569..66345ef7e 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -24,7 +24,7 @@ function NazaraBuild:Execute() if (self.Actions[_ACTION] == nil) then local makeLibDir = os.is("windows") and "mingw" or "gmake" - if (_OPTIONS["with-extlibs"]) then + if (self.Config["BuildDependencies"]) then workspace("NazaraExtlibs") platforms(platformData) @@ -39,12 +39,6 @@ function NazaraBuild:Execute() location(_ACTION) kind("StaticLib") - configuration("x32") - libdirs("../extlibs/lib/common/x86") - - configuration("x64") - libdirs("../extlibs/lib/common/x64") - configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") targetdir("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -111,6 +105,12 @@ function NazaraBuild:Execute() includedirs(libTable.Includes) links(libTable.Libraries) + configuration("x32") + libdirs(libTable.LibraryPaths.x86) + + configuration("x64") + libdirs(libTable.LibraryPaths.x64) + for k,v in pairs(libTable.ConfigurationLibraries) do configuration(k) links(v) @@ -188,11 +188,11 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/common") configuration("x32") - libdirs("../extlibs/lib/common/x86") + libdirs(moduleTable.LibraryPaths.x86) configuration("x64") defines("NAZARA_PLATFORM_x64") - libdirs("../extlibs/lib/common/x64") + libdirs(moduleTable.LibraryPaths.x64) configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -297,11 +297,11 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/common") configuration("x32") - libdirs("../extlibs/lib/common/x86") + libdirs(toolTable.LibraryPaths.x86) configuration("x64") defines("NAZARA_PLATFORM_x64") - libdirs("../extlibs/lib/common/x64") + libdirs(toolTable.LibraryPaths.x64) configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") @@ -431,11 +431,11 @@ function NazaraBuild:Execute() links(exampleTable.Libraries) configuration("x32") - libdirs("../extlibs/lib/common/x86") + libdirs(exampleTable.LibraryPaths.x86) configuration("x64") defines("NAZARA_PLATFORM_x64") - libdirs("../extlibs/lib/common/x64") + libdirs(exampleTable.LibraryPaths.x64) configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../lib/" .. makeLibDir .. "/x86") @@ -465,33 +465,29 @@ function NazaraBuild:Execute() end end +function NazaraBuild:GetConfig() + return self.Config +end + +function NazaraBuild:GetDependency(infoTable, name) + local projectName = name:match("Nazara(%w+)") + if (projectName) then + -- tool or module + local moduleTable = self.Modules[projectName:lower()] + if (moduleTable) then + return moduleTable + else + local toolTable = self.Tools[projectName:lower()] + if (toolTable) then + return toolTable + end + end + else + return self.ExtLibs[name:lower()] + end +end + function NazaraBuild:Initialize() - -- Commençons par les options - newoption({ - trigger = "install-path", - description = "Setup additionnals install directories (library binaries will be copied there)" - }) - - newoption({ - trigger = "server", - description = "Excludes client-only modules/tools/examples" - }) - - newoption({ - trigger = "united", - description = "Builds all the modules as one united library" - }) - - newoption({ - trigger = "with-extlibs", - description = "Builds the extern libraries" - }) - - newoption({ - trigger = "with-examples", - description = "Builds the examples" - }) - self.Actions = {} self.Examples = {} self.ExecutableDir = {} @@ -500,12 +496,8 @@ function NazaraBuild:Initialize() self.Modules = {} self.Tools = {} - if (_OPTIONS["install-path"]) then - local paths = string.explode(_OPTIONS["install-path"], ";") - for k,v in pairs(paths) do - self:AddInstallPath(v) - end - end + self.Config = {} + self:LoadConfig() -- Actions modules = os.matchfiles("scripts/actions/*.lua") @@ -593,7 +585,7 @@ function NazaraBuild:Initialize() TOOL = nil -- Examples - if (_OPTIONS["with-examples"]) then + if (self.Config["BuildExamples"]) then local examples = os.matchdirs("../examples/*") for k,v in pairs(examples) do local dirName = v:match(".*/(.*)") @@ -643,6 +635,236 @@ function NazaraBuild:Initialize() end end +function NazaraBuild:LoadConfig() + local f = io.open("config.lua", "r") + if (not f) then + print("Failed to open config.lua") + return + end + + local content = f:read("*a") + f:close() + + local func, err = loadstring(content) + if (not func) then + print("Failed to parse config.lua: " .. err) + return + end + + setfenv(func, self.Config) + + local status, err = pcall(func) + if (not status) then + print("Failed to load config.lua: " .. err) + return + end + + local configTable = self.Config + local AddBoolOption = function (option, name, description) + newoption({ + trigger = name, + description = description + }) + + local str = _OPTIONS[name] + if (str) then + if (#str == 0 or str == "1" or str == "yes" or str == "true") then + configTable[option] = true + elseif (str == "0" or str == "no" or str == "false") then + configTable[option] = false + else + error("Invalid entry for " .. name .. " option: \"" .. str .. "\"") + end + end + end + + AddBoolOption("BuildDependencies", "with-extlibs", "Builds the extern libraries") + AddBoolOption("BuildExamples", "with-examples", "Builds the examples") + AddBoolOption("ServerMode", "server", "Excludes client-only modules/tools/examples") + AddBoolOption("UniteModules", "united", "Builds all the modules as one united library") + + -- InstallDir + newoption({ + trigger = "install-path", + description = "Setup additionnals install directories (library binaries will be copied there)" + }) + + self.Config["InstallDir"] = self.Config["InstallDir"] or "" + if (_OPTIONS["install-path"] ~= nil) then + self.Config["InstallDir"] = self.Config["InstallDir"] .. ";" .. _OPTIONS["install-path"] + end + + local paths = string.explode(self.Config["InstallDir"], ";") + for k,v in pairs(paths) do + self:AddInstallPath(v) + end +end + +function NazaraBuild:MakeInstallCommands(infoTable) + if (PremakeVersion < 50) then + return + end + + if (os.is("windows")) then + configuration({}) + + for k,v in pairs(self.InstallDir) do + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]}) + end + + for k,fileName in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do + local paths = {} + for k,v in pairs(infoTable.BinaryPaths.x86) do + table.insert(paths, {"x32", v .. "/" .. fileName .. ".dll"}) + table.insert(paths, {"x32", v .. "/lib" .. fileName .. ".dll"}) + end + + for k,v in pairs(infoTable.BinaryPaths.x64) do + table.insert(paths, {"x64", v .. "/" .. fileName .. ".dll"}) + table.insert(paths, {"x64", v .. "/lib" .. fileName .. ".dll"}) + end + + for k,v in pairs(paths) do + local config = v[1] + local srcPath = v[2] + if (os.isfile(srcPath)) then + if (infoTable.Kind == "plugin") then + srcPath = "../../" .. srcPath + end + + configuration(config) + + for k,v in pairs(self.ExecutableDir) do + local srcPath = path.isabsolute(srcPath) and path.translate(srcPath) or [[%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}]] + local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) + postbuildcommands({[[xcopy "]] .. srcPath .. [[" "]] .. destPath .. [[\" /E /Y]]}) + end + end + end + end + end +end + +local PosixOSes = { + ["bsd"] = true, + ["linux"] = true, + ["macosx"] = true, + ["solaris"] = true +} + +function NazaraBuild:Process(infoTable) + local libraries = {} + for k, library in pairs(infoTable.Libraries) do + local libraryTable = self:GetDependency(infoTable, library) + if (libraryTable) then + if (libraryTable.Excluded) then + infoTable.Excluded = true + infoTable.ExcludeReason = "depends on excluded " .. library .. " " .. libraryTable.Type:lower() + return false + end + + if (libraryTable.Type == "Module") then + if (_OPTIONS["united"]) then + library = "NazaraEngine" + else + library = "Nazara" .. libraryTable.Name + end + + if (not self.Config["UniteModules"] or infoTable.Type ~= "Module") then + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) + end + elseif (libraryTable.Type == "ExternLib") then + library = libraryTable.Name + + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") + elseif (libraryTable.Type == "Tool") then + library = "Nazara" .. libraryTable.Name + + -- Import tools includes + for k,v in ipairs(libraryTable.Includes) do + table.insert(infoTable.Includes, v) + end + + -- And libraries + for k, v in pairs(libraryTable.Libraries) do + table.insert(infoTable.Libraries, v) + end + + for config, libs in pairs(libraryTable.ConfigurationLibraries) do + for k,v in pairs(libs) do + table.insert(infoTable.ConfigurationLibraries[config], v) + end + end + + table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") + table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") + table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) + else + infoTable.Excluded = true + infoTable.ExcludeReason = "dependency " .. library .. " has invalid type \"" .. libraryTable.Type .. "\"" + return false + end + else + table.insert(libraries, library) + end + end + infoTable.Libraries = libraries + + for k,v in pairs(infoTable) do + local target = k:match("Os(%w+)") + if (target) then + local targetTable = infoTable[target] + if (targetTable) then + local excludeTargetTable = infoTable[target .. "Excluded"] + for platform, defineTable in pairs(v) do + platform = string.lower(platform) + if (platform == "posix") then + local osname = os.get() + if (PosixOSes[osname]) then + platform = osname + end + end + + if (os.is(platform)) then + for k,v in ipairs(defineTable) do + table.insert(targetTable, v) + end + elseif (excludeTargetTable) then + for k,v in ipairs(defineTable) do + table.insert(excludeTargetTable, v) + end + end + end + + infoTable[k] = nil + end + end + end + + if (infoTable.Kind == "application") then + self:AddExecutablePath(infoTable.TargetDirectory) + end + + if (infoTable.Validate) then + local ret, err = infoTable:Validate() + if (not ret) then + infoTable.Excluded = true + infoTable.ExcludeReason = "validation failed: " .. err + return false + end + end + + return true +end + function NazaraBuild:RegisterAction(actionTable) if (actionTable.Name == nil or type(actionTable.Name) ~= "string" or string.len(actionTable.Name) == 0) then return false, "Invalid action name" @@ -750,7 +972,7 @@ function NazaraBuild:RegisterModule(moduleTable) table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.inl") table.insert(moduleTable.Files, "../src/Nazara/" .. moduleTable.Name .. "/**.cpp") - if (_OPTIONS["united"] and lowerCaseName ~= "core") then + if (self.Config["UniteModules"] and lowerCaseName ~= "core") then table.insert(moduleTable.FilesExcluded, "../src/Nazara/" .. moduleTable.Name .. "/Debug/NewOverload.cpp") end @@ -789,132 +1011,8 @@ function NazaraBuild:RegisterTool(toolTable) return true end -local PosixOSes = { - ["bsd"] = true, - ["linux"] = true, - ["macosx"] = true, - ["solaris"] = true -} - -function NazaraBuild:Process(infoTable) - local libraries = {} - for k, library in pairs(infoTable.Libraries) do - local projectName = library:match("Nazara(%w+)") - local moduleTable = projectName and self.Modules[projectName:lower()] - local toolTable = projectName and self.Tools[projectName:lower()] - - if (moduleTable) then - if (moduleTable.Excluded) then - infoTable.Excluded = true - infoTable.ExcludeReason = "depends on excluded " .. projectName .. " module" - return false - end - - if (_OPTIONS["united"]) then - library = "NazaraEngine" - else - library = "Nazara" .. moduleTable.Name - end - - if (not _OPTIONS["united"] or infoTable.Type ~= "Module") then - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) - end - else - local extLibTable = self.ExtLibs[library:lower()] - if (extLibTable) then - if (extLibTable.Excluded) then - infoTable.Excluded = true - infoTable.ExcludeReason = "depends on excluded " .. extLibTable.Name .. " external library" - return false - end - - library = extLibTable.Name - - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") - else - if (toolTable and toolTable.Kind == "library") then - if (toolTable.Excluded) then - infoTable.Excluded = true - infoTable.ExcludeReason = "depends on excluded " .. toolTable.Name .. " tool" - return false - end - - library = "Nazara" .. toolTable.Name - - -- Import tools includes - for k,v in ipairs(toolTable.Includes) do - table.insert(infoTable.Includes, v) - end - - -- And libraries - for k, v in pairs(toolTable.Libraries) do - table.insert(infoTable.Libraries, v) - end - - for config, libs in pairs(toolTable.ConfigurationLibraries) do - for k,v in pairs(libs) do - table.insert(infoTable.ConfigurationLibraries[config], v) - end - end - - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) - else - table.insert(libraries, library) - end - end - end - end - infoTable.Libraries = libraries - - for k,v in pairs(infoTable) do - local target = k:match("Os(%w+)") - if (target) then - local targetTable = infoTable[target] - if (targetTable) then - local excludeTargetTable = infoTable[target .. "Excluded"] - for platform, defineTable in pairs(v) do - platform = string.lower(platform) - if (platform == "posix") then - local osname = os.get() - if (PosixOSes[osname]) then - platform = osname - end - end - - if (os.is(platform)) then - for k,v in ipairs(defineTable) do - table.insert(targetTable, v) - end - elseif (excludeTargetTable) then - for k,v in ipairs(defineTable) do - table.insert(excludeTargetTable, v) - end - end - end - - infoTable[k] = nil - end - end - end - - if (infoTable.Kind == "application") then - self:AddExecutablePath(infoTable.TargetDirectory) - end - - return true -end - function NazaraBuild:Resolve(infoTable) - if (infoTable.ClientOnly and _OPTIONS["server"]) then + if (infoTable.ClientOnly and self.Config["ServerMode"]) then infoTable.Excluded = true infoTable.ExcludeReason = "excluded by command-line options (client-only)" end @@ -937,53 +1035,19 @@ function NazaraBuild:Resolve(infoTable) end end -function NazaraBuild:MakeInstallCommands(infoTable) - if (PremakeVersion < 50) then - return - end - - if (os.is("windows")) then - configuration({}) - - for k,v in pairs(self.InstallDir) do - local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath):sub(1, -5) .. ".dll"}" "]] .. destPath .. [[\" /E /Y]]}) - end - - for k,v in pairs(table.join(infoTable.Libraries, infoTable.DynLib)) do - local paths = {} - table.insert(paths, {"x32", "../extlibs/lib/common/x86/" .. v .. ".dll"}) - table.insert(paths, {"x32", "../extlibs/lib/common/x86/lib" .. v .. ".dll"}) - table.insert(paths, {"x64", "../extlibs/lib/common/x64/" .. v .. ".dll"}) - table.insert(paths, {"x64", "../extlibs/lib/common/x64/lib" .. v .. ".dll"}) - - for k,v in pairs(paths) do - local config = v[1] - local srcPath = v[2] - if (os.isfile(srcPath)) then - if (infoTable.Kind == "plugin") then - srcPath = "../../" .. srcPath - end - - configuration(config) - - for k,v in pairs(self.ExecutableDir) do - local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) - postbuildcommands({[[xcopy "%{path.translate(cfg.linktarget.relpath:sub(1, -#cfg.linktarget.name - 1) .. "../../]] .. srcPath .. [[")}" "]] .. destPath .. [[\" /E /Y]]}) - end - end - end - end - end -end - function NazaraBuild:SetupInfoTable(infoTable) - infoTable.Excludable = true + infoTable.BinaryPaths = {} + infoTable.BinaryPaths.x86 = {} + infoTable.BinaryPaths.x64 = {} infoTable.ConfigurationLibraries = {} infoTable.ConfigurationLibraries.DebugStatic = {} infoTable.ConfigurationLibraries.ReleaseStatic = {} infoTable.ConfigurationLibraries.DebugDynamic = {} infoTable.ConfigurationLibraries.ReleaseDynamic = {} + infoTable.Excludable = true + infoTable.LibraryPaths = {} + infoTable.LibraryPaths.x86 = {} + infoTable.LibraryPaths.x64 = {} local infos = {"Defines", "DynLib", "Files", "FilesExcluded", "Flags", "Includes", "Libraries"} for k,v in ipairs(infos) do @@ -1003,12 +1067,22 @@ function NazaraBuild:SetupExtlibTable(infoTable) self:SetupInfoTable(infoTable) infoTable.Kind = "library" + + table.insert(infoTable.BinaryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.BinaryPaths.x64, "../extlibs/lib/common/x64") + table.insert(infoTable.LibraryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64") end function NazaraBuild:SetupModuleTable(infoTable) self:SetupInfoTable(infoTable) infoTable.Kind = "library" + + table.insert(infoTable.BinaryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.BinaryPaths.x64, "../extlibs/lib/common/x64") + table.insert(infoTable.LibraryPaths.x86, "../extlibs/lib/common/x86") + table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64") end NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable \ No newline at end of file From 5ece0e35ab5c5a67bb9769a445f0cd64ef9ab231 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 Jul 2016 23:56:38 +0200 Subject: [PATCH 163/383] Add build/config.lua to .gitignore Former-commit-id: 6dca505992e40866a85de509c540c09bdb9ebbc3 [formerly 0cb39cbb71ba523d02a88895707302ed378ddec6] Former-commit-id: 18aa6ec9509c49bfa9e0fd555e29dc8c05e84e37 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c930343f4..463291bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Nazara build +build/config.lua examples/bin/*.exe examples/bin/*.pdb examples/bin/*.dll From 0cf5a12067a7f30b7ac5fcaf2b073c4d6102f4a7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 14:06:29 +0200 Subject: [PATCH 164/383] Build: Remove "united" shortcuts (since we have config.lua now) Former-commit-id: 358174c0ab2eb0d2e385d09ee0515a80a2cbb05f [formerly afeb8d1db8e218257cfb19a3f99d142991f7bf11] Former-commit-id: ca5aca6f930d90dc10e67144ad649f7ee62fc27f --- build/Build_CodeBlocks.bat | 2 +- build/Build_CodeBlocks_OneLibrary.bat | 1 - build/Build_CodeLite.bat | 2 +- build/Build_CodeLite_OneLibrary.bat | 1 - build/Build_VS2015.bat | 2 +- build/Build_VS2015_OneLibrary.bat | 1 - 6 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 build/Build_CodeBlocks_OneLibrary.bat delete mode 100644 build/Build_CodeLite_OneLibrary.bat delete mode 100644 build/Build_VS2015_OneLibrary.bat diff --git a/build/Build_CodeBlocks.bat b/build/Build_CodeBlocks.bat index 983c7ae80..439c5efac 100644 --- a/build/Build_CodeBlocks.bat +++ b/build/Build_CodeBlocks.bat @@ -1 +1 @@ -premake4 --with-extlibs --with-examples codeblocks \ No newline at end of file +premake4 codeblocks \ No newline at end of file diff --git a/build/Build_CodeBlocks_OneLibrary.bat b/build/Build_CodeBlocks_OneLibrary.bat deleted file mode 100644 index b7c5ab4c9..000000000 --- a/build/Build_CodeBlocks_OneLibrary.bat +++ /dev/null @@ -1 +0,0 @@ -premake4 --united --with-extlibs --with-examples codeblocks \ No newline at end of file diff --git a/build/Build_CodeLite.bat b/build/Build_CodeLite.bat index 8584e6d9b..170e7a451 100644 --- a/build/Build_CodeLite.bat +++ b/build/Build_CodeLite.bat @@ -1 +1 @@ -premake5 --with-extlibs --with-examples codelite \ No newline at end of file +premake5 codelite \ No newline at end of file diff --git a/build/Build_CodeLite_OneLibrary.bat b/build/Build_CodeLite_OneLibrary.bat deleted file mode 100644 index 52a80f504..000000000 --- a/build/Build_CodeLite_OneLibrary.bat +++ /dev/null @@ -1 +0,0 @@ -premake5 --united --with-extlibs --with-examples codelite \ No newline at end of file diff --git a/build/Build_VS2015.bat b/build/Build_VS2015.bat index 2dd6e578a..6d0726faf 100644 --- a/build/Build_VS2015.bat +++ b/build/Build_VS2015.bat @@ -1 +1 @@ -premake5 --with-extlibs --with-examples vs2015 \ No newline at end of file +premake5 vs2015 \ No newline at end of file diff --git a/build/Build_VS2015_OneLibrary.bat b/build/Build_VS2015_OneLibrary.bat deleted file mode 100644 index aaab1938c..000000000 --- a/build/Build_VS2015_OneLibrary.bat +++ /dev/null @@ -1 +0,0 @@ -premake5 --united --with-extlibs --with-examples vs2015 \ No newline at end of file From e950118263d934b713ef1a395884914d05877fac Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 15:50:02 +0200 Subject: [PATCH 165/383] Sdk: Components no longer need to be default-constructibles Former-commit-id: 995fb3dc8acff9b298603740812e9f689d800162 [formerly d67c4d851d711a0c26dd0967a9bcfa6bf5564061] Former-commit-id: bb864925dcb9541615c6bac341a851ddffd75ac5 --- SDK/include/NDK/Component.inl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SDK/include/NDK/Component.inl b/SDK/include/NDK/Component.inl index e39091224..833395957 100644 --- a/SDK/include/NDK/Component.inl +++ b/SDK/include/NDK/Component.inl @@ -28,13 +28,11 @@ namespace Ndk template ComponentIndex Component::RegisterComponent(ComponentId id) { - // Il faut que notre composant possède un constructeur par défaut (pour la factory) - static_assert(std::is_default_constructible::value, "ComponentType must be default-constructible"); - // On utilise les lambda pour créer une fonction factory auto factory = []() -> BaseComponent* { - return new ComponentType; + return nullptr; //< Temporary workaround to allow non-default-constructed components, will be updated for serialization + //return new ComponentType; }; return BaseComponent::RegisterComponent(id, factory); From e6a4bcca0d73b07e6cee622c83659e3e0e21a8ea Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 15:50:41 +0200 Subject: [PATCH 166/383] Graphics/ParticleEmitter: No longer inherit from Node Former-commit-id: fec622ceafaab7a07117c64058e8993edae36d6d [formerly df9758c40bc509df2e756c0b7ab73b1aad01ef93] Former-commit-id: 928dec25115886adf4d9963da9e12714563ee95b --- include/Nazara/Graphics/ParticleEmitter.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index b6acee156..7e2c6a7f8 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -9,14 +9,13 @@ #include #include -#include namespace Nz { class ParticleMapper; class ParticleGroup; - class NAZARA_GRAPHICS_API ParticleEmitter : public Node + class NAZARA_GRAPHICS_API ParticleEmitter { public: ParticleEmitter(); From 70ee053f3f7229104aff6066b50fb6d3e38a509e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 Jul 2016 15:51:46 +0200 Subject: [PATCH 167/383] Sdk: Integrate particles Former-commit-id: fa4474b434340d15363ff2ffc91b58d2df3a62fc [formerly 8a52795fc49a847e7b558425fc03915b21139521] Former-commit-id: ac159c0cf652699400f720ef6fdad0fbf649308f --- SDK/include/NDK/Components.hpp | 4 +- .../Components/ParticleEmitterComponent.hpp | 45 ++++++++++++++ .../Components/ParticleEmitterComponent.inl | 18 ++++++ .../NDK/Components/ParticleGroupComponent.hpp | 35 +++++++++++ .../NDK/Components/ParticleGroupComponent.inl | 17 ++++++ SDK/include/NDK/Systems.hpp | 3 +- SDK/include/NDK/Systems/ParticleSystem.hpp | 29 +++++++++ SDK/include/NDK/Systems/ParticleSystem.inl | 3 + SDK/include/NDK/Systems/RenderSystem.hpp | 1 + .../Components/ParticleEmitterComponent.cpp | 59 +++++++++++++++++++ .../NDK/Components/ParticleGroupComponent.cpp | 10 ++++ SDK/src/NDK/Sdk.cpp | 6 ++ SDK/src/NDK/Systems/ParticleSystem.cpp | 26 ++++++++ SDK/src/NDK/Systems/RenderSystem.cpp | 16 +++++ SDK/src/NDK/World.cpp | 2 + 15 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 SDK/include/NDK/Components/ParticleEmitterComponent.hpp create mode 100644 SDK/include/NDK/Components/ParticleEmitterComponent.inl create mode 100644 SDK/include/NDK/Components/ParticleGroupComponent.hpp create mode 100644 SDK/include/NDK/Components/ParticleGroupComponent.inl create mode 100644 SDK/include/NDK/Systems/ParticleSystem.hpp create mode 100644 SDK/include/NDK/Systems/ParticleSystem.inl create mode 100644 SDK/src/NDK/Components/ParticleEmitterComponent.cpp create mode 100644 SDK/src/NDK/Components/ParticleGroupComponent.cpp create mode 100644 SDK/src/NDK/Systems/ParticleSystem.cpp diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp index ca993b5b6..79bc196f7 100644 --- a/SDK/include/NDK/Components.hpp +++ b/SDK/include/NDK/Components.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 01 Jun 2016 at 13:11:09 +// This file was automatically generated on 30 Jul 2016 at 15:29:16 #pragma once @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp new file mode 100644 index 000000000..add138ee9 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#pragma once + +#ifndef NDK_SERVER +#ifndef NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP +#define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP + +#include +#include + +namespace Ndk +{ + class NDK_API ParticleEmitterComponent : public Component, public Nz::ParticleEmitter + { + public: + using SetupFunc = std::function; + + ParticleEmitterComponent(Nz::ParticleGroup* group); + ParticleEmitterComponent(const ParticleEmitterComponent& emitter); + ~ParticleEmitterComponent(); + + inline bool IsActive() const; + + void SetActive(bool active = true); + void SetGroup(Nz::ParticleGroup* group); + inline void SetSetupFunc(SetupFunc func); + + static ComponentIndex componentIndex; + + private: + void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override; + + SetupFunc m_setupFunc; + Nz::ParticleGroup* m_particleGroup; + bool m_isActive; + }; +} + +#include + +#endif // NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NDK/Components/ParticleEmitterComponent.inl new file mode 100644 index 000000000..6cc9e8c29 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.inl @@ -0,0 +1,18 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#include + +namespace Ndk +{ + inline bool ParticleEmitterComponent::IsActive() const + { + return m_isActive; + } + + inline void Ndk::ParticleEmitterComponent::SetSetupFunc(SetupFunc func) + { + m_setupFunc = std::move(func); + } +} diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NDK/Components/ParticleGroupComponent.hpp new file mode 100644 index 000000000..638f877d3 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleGroupComponent.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#pragma once + +#ifndef NDK_SERVER +#ifndef NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP +#define NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP + +#include +#include + +namespace Ndk +{ + class ParticleGroupComponent; + + using ParticleGroupComponentHandle = Nz::ObjectHandle; + + class NDK_API ParticleGroupComponent : public Component, public Nz::ParticleGroup + { + public: + inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout); + inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration); + ParticleGroupComponent(const ParticleGroupComponent&) = default; + ~ParticleGroupComponent() = default; + + static ComponentIndex componentIndex; + }; +} + +#include + +#endif // NDK_COMPONENTS_PARTICLEGROUPCOMPONENT_HPP +#endif // NDK_SERVER \ No newline at end of file diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NDK/Components/ParticleGroupComponent.inl new file mode 100644 index 000000000..7aefdad56 --- /dev/null +++ b/SDK/include/NDK/Components/ParticleGroupComponent.inl @@ -0,0 +1,17 @@ +#include "ParticleGroupComponent.hpp" +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +namespace Ndk +{ + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) : + ParticleGroup(maxParticleCount, layout) + { + } + + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration) : + ParticleGroup(maxParticleCount, std::move(declaration)) + { + } +} diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp index 176a956ee..269bead6f 100644 --- a/SDK/include/NDK/Systems.hpp +++ b/SDK/include/NDK/Systems.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 01 Jun 2016 at 13:11:09 +// This file was automatically generated on 30 Jul 2016 at 15:29:16 #pragma once @@ -6,6 +6,7 @@ #define NDK_SYSTEMS_GLOBAL_HPP #include +#include #include #include #include diff --git a/SDK/include/NDK/Systems/ParticleSystem.hpp b/SDK/include/NDK/Systems/ParticleSystem.hpp new file mode 100644 index 000000000..3ae00a995 --- /dev/null +++ b/SDK/include/NDK/Systems/ParticleSystem.hpp @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#pragma once + +#ifndef NDK_SYSTEMS_PARTICLESYSTEM_HPP +#define NDK_SYSTEMS_PARTICLESYSTEM_HPP + +#include + +namespace Ndk +{ + class NDK_API ParticleSystem : public System + { + public: + ParticleSystem(); + ~ParticleSystem() = default; + + static SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override; + }; +} + +#include + +#endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP diff --git a/SDK/include/NDK/Systems/ParticleSystem.inl b/SDK/include/NDK/Systems/ParticleSystem.inl new file mode 100644 index 000000000..e5f296d27 --- /dev/null +++ b/SDK/include/NDK/Systems/ParticleSystem.inl @@ -0,0 +1,3 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index f2fbc7a65..82e558773 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -60,6 +60,7 @@ namespace Ndk EntityList m_directionalLights; EntityList m_lights; EntityList m_pointSpotLights; + EntityList m_particleGroups; Nz::BackgroundRef m_background; Nz::DepthRenderTechnique m_shadowTechnique; Nz::Matrix4f m_coordinateSystemMatrix; diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp new file mode 100644 index 000000000..6a3cfeb7e --- /dev/null +++ b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp @@ -0,0 +1,59 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#include +#include + +namespace Ndk +{ + ParticleEmitterComponent::ParticleEmitterComponent(Nz::ParticleGroup* group) : + m_particleGroup(group), + m_isActive(true) + { + if (m_particleGroup) + m_particleGroup->AddEmitter(this); + } + + ParticleEmitterComponent::ParticleEmitterComponent(const ParticleEmitterComponent& emitter) : + m_particleGroup(emitter.m_particleGroup), + m_isActive(emitter.m_isActive) + { + if (m_isActive) + m_particleGroup->AddEmitter(this); + } + + ParticleEmitterComponent::~ParticleEmitterComponent() + { + m_particleGroup->RemoveEmitter(this); + } + + inline void Ndk::ParticleEmitterComponent::SetActive(bool active) + { + if (m_isActive != active) + { + if (active) + m_particleGroup->AddEmitter(this); + else + m_particleGroup->RemoveEmitter(this); + } + } + + void ParticleEmitterComponent::SetGroup(Nz::ParticleGroup* group) + { + if (m_particleGroup) + m_particleGroup->RemoveEmitter(this); + + m_particleGroup = group; + if (m_particleGroup && m_isActive) + m_particleGroup = group; + } + + inline void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const + { + if (m_setupFunc) + m_setupFunc(m_entity, mapper, count); + } + + ComponentIndex ParticleEmitterComponent::componentIndex; +} diff --git a/SDK/src/NDK/Components/ParticleGroupComponent.cpp b/SDK/src/NDK/Components/ParticleGroupComponent.cpp new file mode 100644 index 000000000..4e0845871 --- /dev/null +++ b/SDK/src/NDK/Components/ParticleGroupComponent.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#include + +namespace Ndk +{ + ComponentIndex ParticleGroupComponent::componentIndex; +} diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 7f29bb18e..964913bf8 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include #endif @@ -71,6 +74,8 @@ namespace Ndk InitializeComponent("NdkLight"); InitializeComponent("NdkList"); InitializeComponent("NdkGfx"); + InitializeComponent("NdkPaEmi"); + InitializeComponent("NdkPaGrp"); #endif // Systems @@ -84,6 +89,7 @@ namespace Ndk #ifndef NDK_SERVER // Client systems InitializeSystem(); + InitializeSystem(); InitializeSystem(); #endif diff --git a/SDK/src/NDK/Systems/ParticleSystem.cpp b/SDK/src/NDK/Systems/ParticleSystem.cpp new file mode 100644 index 000000000..a9f63cb6c --- /dev/null +++ b/SDK/src/NDK/Systems/ParticleSystem.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Development Kit" +// For conditions of distribution and use, see copyright notice in Prerequesites.hpp + +#include +#include + +namespace Ndk +{ + ParticleSystem::ParticleSystem() + { + Requires(); + } + + void ParticleSystem::OnUpdate(float elapsedTime) + { + for (const Ndk::EntityHandle& entity : GetEntities()) + { + ParticleGroupComponent& group = entity->GetComponent(); + + group.Update(elapsedTime); + } + } + + SystemIndex ParticleSystem::systemIndex; +} diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index 7b90761b6..fcfd5c6a5 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace Ndk { @@ -25,8 +26,11 @@ namespace Ndk void RenderSystem::OnEntityRemoved(Entity* entity) { m_cameras.Remove(entity); + m_directionalLights.Remove(entity); m_drawables.Remove(entity); m_lights.Remove(entity); + m_particleGroups.Remove(entity); + m_pointSpotLights.Remove(entity); } void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded) @@ -71,6 +75,11 @@ namespace Ndk m_lights.Remove(entity); m_pointSpotLights.Remove(entity); } + + if (entity->HasComponent()) + m_particleGroups.Insert(entity); + else + m_particleGroups.Remove(entity); } void RenderSystem::OnUpdate(float elapsedTime) @@ -118,6 +127,13 @@ namespace Ndk lightComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::ConcatenateAffine(m_coordinateSystemMatrix, lightNode.GetTransformMatrix())); } + for (const Ndk::EntityHandle& particleGroup : m_particleGroups) + { + ParticleGroupComponent& groupComponent = particleGroup->GetComponent(); + + groupComponent.AddToRenderQueue(renderQueue, Nz::Matrix4f::Identity()); //< ParticleGroup doesn't use Matrix4f + } + camComponent.ApplyView(); Nz::SceneData sceneData; diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index e95785896..5d0e4900b 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -9,6 +9,7 @@ #ifndef NDK_SERVER #include +#include #include #endif @@ -27,6 +28,7 @@ namespace Ndk #ifndef NDK_SERVER AddSystem(); + AddSystem(); AddSystem(); #endif } From b2351e6ef2b737b081b4e3f7513b55a2b3f309a8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 31 Jul 2016 11:01:07 +0200 Subject: [PATCH 168/383] Build: Fix command line arguments being ignored if config.lua loading failed Former-commit-id: a0b9389550d838dbb1257ad68f190f1191bf1987 [formerly 6888f45b376814ff8cea69054c87110b0842bae4] Former-commit-id: 13522b14991d0e08341798d29344b6e5d6f0a9bd --- build/scripts/common.lua | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 66345ef7e..fa610e85c 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -637,28 +637,25 @@ end function NazaraBuild:LoadConfig() local f = io.open("config.lua", "r") - if (not f) then + if (f) then + local content = f:read("*a") + f:close() + + local func, err = loadstring(content) + if (func) then + setfenv(func, self.Config) + + local status, err = pcall(func) + if (not status) then + print("Failed to load config.lua: " .. err) + end + else + print("Failed to parse config.lua: " .. err) + end + else print("Failed to open config.lua") - return end - local content = f:read("*a") - f:close() - - local func, err = loadstring(content) - if (not func) then - print("Failed to parse config.lua: " .. err) - return - end - - setfenv(func, self.Config) - - local status, err = pcall(func) - if (not status) then - print("Failed to load config.lua: " .. err) - return - end - local configTable = self.Config local AddBoolOption = function (option, name, description) newoption({ From e4a7a7e8584851ccd244e7320d7ec0b6d9ff56b5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 31 Jul 2016 11:01:47 +0200 Subject: [PATCH 169/383] Build/NDKServer: Fix dependencies, allowing it to exists in server mode Former-commit-id: 3e6b164743c5b0ef10f0dc214c09fef247a13878 [formerly 0890cc70c875ac0e0aba3090aa7afa344b5b1e52] Former-commit-id: 56bb3c78830d2e5b64b4a9812020b2eeb9c15979 --- build/scripts/tools/ndk_server.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index 2881c56fc..e536f1036 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -37,13 +37,11 @@ TOOL.FilesExcluded = { } -TOOL.Libraries = function() - local libraries = {} - for k,v in pairs(NazaraBuild.Modules) do - if (not v.ClientOnly) then - table.insert(libraries, "Nazara" .. v.Name) - end - end - - return libraries -end +TOOL.Libraries = { + "NazaraCore", + "NazaraLua", + "NazaraNetwork", + "NazaraNoise", + "NazaraPhysics", + "NazaraUtility" +} From fdfd07833569528dda8a569e7843287d917fe5eb Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 31 Jul 2016 12:59:04 +0200 Subject: [PATCH 170/383] Build: Fix empty install commands Former-commit-id: 42abd0d02836ee466821da11bc34bbe4acc30389 [formerly 0031006522b6c8910fae4c7b72eaf05cda23dcea] Former-commit-id: 11ed91151aa8db729bea196ca9705a6e60f260bb --- .../Components/ParticleEmitterComponent.hpp | 5 ++++ build/scripts/common.lua | 4 +++- include/Nazara/Graphics/ParticleEmitter.hpp | 9 +++++-- include/Nazara/Graphics/ParticleGroup.hpp | 4 ++++ src/Nazara/Graphics/ParticleEmitter.cpp | 24 ++++++++++++++++++- src/Nazara/Graphics/ParticleGroup.cpp | 5 +++- 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp index add138ee9..b874e0818 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -20,6 +20,7 @@ namespace Ndk ParticleEmitterComponent(Nz::ParticleGroup* group); ParticleEmitterComponent(const ParticleEmitterComponent& emitter); + ParticleEmitterComponent(ParticleEmitterComponent&& emitter); ~ParticleEmitterComponent(); inline bool IsActive() const; @@ -31,8 +32,12 @@ namespace Ndk static ComponentIndex componentIndex; private: + void OnParticleGroupRelease(const Nz::ParticleGroup* particleGroup); + void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override; + NazaraSlot(Nz::ParticleGroup, OnParticleGroupRelease, m_particleGroupRelease); + SetupFunc m_setupFunc; Nz::ParticleGroup* m_particleGroup; bool m_isActive; diff --git a/build/scripts/common.lua b/build/scripts/common.lua index fa610e85c..b467eb9c5 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -693,7 +693,9 @@ function NazaraBuild:LoadConfig() local paths = string.explode(self.Config["InstallDir"], ";") for k,v in pairs(paths) do - self:AddInstallPath(v) + if (#v > 0) then + self:AddInstallPath(v) + end end end diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index 7e2c6a7f8..b7a168262 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -8,6 +8,7 @@ #define NAZARA_PARTICLEEMITTER_HPP #include +#include #include namespace Nz @@ -20,7 +21,7 @@ namespace Nz public: ParticleEmitter(); ParticleEmitter(const ParticleEmitter& emitter) = default; - ParticleEmitter(ParticleEmitter&& emitter) = default; + ParticleEmitter(ParticleEmitter&& emitter); virtual ~ParticleEmitter(); virtual void Emit(ParticleGroup& system, float elapsedTime) const; @@ -36,7 +37,11 @@ namespace Nz void SetEmissionRate(float rate); ParticleEmitter& operator=(const ParticleEmitter& emitter) = default; - ParticleEmitter& operator=(ParticleEmitter&& emitter) = default; + ParticleEmitter& operator=(ParticleEmitter&& emitter); + + // Signals: + NazaraSignal(OnParticleEmitterMove, const ParticleEmitter* /*oldParticleEmitter*/, const ParticleEmitter* /*newParticleEmitter*/); + NazaraSignal(OnParticleEmitterRelease, const ParticleEmitter* /*particleEmitter*/); private: virtual void SetupParticles(ParticleMapper& mapper, unsigned int count) const = 0; diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 412b94511..4d4704171 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -8,6 +8,7 @@ #define NAZARA_PARTICLEGROUP_HPP #include +#include #include #include #include @@ -62,6 +63,9 @@ namespace Nz ParticleGroup& operator=(const ParticleGroup& emitter); + // Signals: + NazaraSignal(OnParticleGroupRelease, const ParticleGroup* /*particleGroup*/); + private: void MakeBoundingVolume() const override; void ResizeBuffer(); diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index b11cfdfe9..10f057dce 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -32,7 +32,19 @@ namespace Nz { } - ParticleEmitter::~ParticleEmitter() = default; + ParticleEmitter::ParticleEmitter(ParticleEmitter&& emitter) : + m_lagCompensationEnabled(emitter.m_lagCompensationEnabled), + m_emissionAccumulator(0.f), + m_emissionRate(emitter.m_emissionRate), + m_emissionCount(emitter.m_emissionCount) + { + OnParticleEmitterMove(&emitter, this); + } + + ParticleEmitter::~ParticleEmitter() + { + OnParticleEmitterRelease(this); + } /*! * \brief Emits particles according to the delta time between the previous frame @@ -141,4 +153,14 @@ namespace Nz { m_emissionRate = rate; } + + ParticleEmitter& ParticleEmitter::operator=(ParticleEmitter && emitter) + { + m_emissionCount = emitter.m_emissionCount; + m_emissionRate = emitter.m_emissionRate; + m_lagCompensationEnabled = emitter.m_lagCompensationEnabled; + + OnParticleEmitterMove(&emitter, this); + return *this; + } } diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index d93c085db..87dbb390c 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -77,7 +77,10 @@ namespace Nz std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); } - ParticleGroup::~ParticleGroup() = default; + ParticleGroup::~ParticleGroup() + { + OnParticleGroupRelease(this); + } /*! * \brief Adds a controller to the particles From 870305b40346e9b6475dc0c48b97f32319ef01f1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 1 Aug 2016 12:04:15 +0200 Subject: [PATCH 171/383] SDK/ParticleEmitterComponent: Fix missing include Former-commit-id: 63e47c72265c27d3fd7dd866f2c14781035e55d6 [formerly ff931366578e3d8aa9be0b7165d769cd3c2fe663] Former-commit-id: 63ec82a8fca534c0a03d974076572f8e5f21c52f --- SDK/include/NDK/Components/ParticleEmitterComponent.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp index b874e0818..8d93e0495 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -9,6 +9,7 @@ #define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP #include +#include #include namespace Ndk From 755bf0b04bc2334a635402b827f43ff9b4bef0c1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 12:52:49 +0200 Subject: [PATCH 172/383] Core/RefCounted: Remove persistent boolean Former-commit-id: 6661b29e0e5e1dee8f4588688dc42865ce76e9ba [formerly 55e47c5ec3851e55243fb0e8e85d7fcc22f6cc1b] Former-commit-id: 5442ab91a3a4b7da93c10bd06889785ac1faf034 --- include/Nazara/Audio/SoundBuffer.inl | 2 - include/Nazara/Core/RefCounted.hpp | 7 +--- include/Nazara/Graphics/Billboard.inl | 2 - include/Nazara/Graphics/ColorBackground.inl | 2 - include/Nazara/Graphics/Material.inl | 2 - include/Nazara/Graphics/Model.inl | 2 - include/Nazara/Graphics/SkyboxBackground.inl | 2 - include/Nazara/Graphics/Sprite.inl | 2 - include/Nazara/Graphics/TextSprite.inl | 2 - include/Nazara/Graphics/TextureBackground.inl | 2 - include/Nazara/Graphics/TileMap.inl | 2 - include/Nazara/Physics/Geom.inl | 16 -------- include/Nazara/Renderer/RenderBuffer.inl | 2 - include/Nazara/Renderer/Shader.inl | 2 - include/Nazara/Renderer/Texture.inl | 2 - .../Renderer/UberShaderPreprocessor.inl | 2 - include/Nazara/Utility/Animation.inl | 2 - include/Nazara/Utility/Buffer.inl | 2 - include/Nazara/Utility/Font.inl | 2 - include/Nazara/Utility/Image.inl | 2 - include/Nazara/Utility/IndexBuffer.inl | 2 - include/Nazara/Utility/Mesh.inl | 2 - include/Nazara/Utility/SkeletalMesh.inl | 2 - include/Nazara/Utility/Skeleton.inl | 2 - include/Nazara/Utility/StaticMesh.inl | 2 - include/Nazara/Utility/VertexBuffer.inl | 2 - include/Nazara/Utility/VertexDeclaration.inl | 2 - src/Nazara/Core/RefCounted.cpp | 41 ++----------------- 28 files changed, 4 insertions(+), 110 deletions(-) diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index a4c42be69..22ed4b19a 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -18,8 +18,6 @@ namespace Nz SoundBufferRef SoundBuffer::New(Args&&... args) { std::unique_ptr object(new SoundBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index 542784787..42936ff7e 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -22,7 +22,7 @@ namespace Nz class NAZARA_CORE_API RefCounted { public: - RefCounted(bool persistent = true); + RefCounted(); RefCounted(const RefCounted&) = delete; RefCounted(RefCounted&&) = default; virtual ~RefCounted(); @@ -31,17 +31,12 @@ namespace Nz unsigned int GetReferenceCount() const; - bool IsPersistent() const; - bool RemoveReference() const; - bool SetPersistent(bool persistent = true, bool checkReferenceCount = false); - RefCounted& operator=(const RefCounted&) = delete; RefCounted& operator=(RefCounted&&) = default; private: - std::atomic_bool m_persistent; mutable std::atomic_uint m_referenceCount; }; } diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 6c4a1e0a9..95a0e5b87 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -234,8 +234,6 @@ namespace Nz BillboardRef Billboard::New(Args&&... args) { std::unique_ptr object(new Billboard(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 67b1f2558..49efd4874 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -18,8 +18,6 @@ namespace Nz ColorBackgroundRef ColorBackground::New(Args&&... args) { std::unique_ptr object(new ColorBackground(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 6d5315640..801e341ae 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -1099,8 +1099,6 @@ namespace Nz MaterialRef Material::New(Args&&... args) { std::unique_ptr object(new Material(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index a2b4c3967..fba9655ec 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -18,8 +18,6 @@ namespace Nz ModelRef Model::New(Args&&... args) { std::unique_ptr object(new Model(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 6171f1e28..15d3eb137 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -119,8 +119,6 @@ namespace Nz SkyboxBackgroundRef SkyboxBackground::New(Args&&... args) { std::unique_ptr object(new SkyboxBackground(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 840a930e6..166807f2b 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -271,8 +271,6 @@ namespace Nz SpriteRef Sprite::New(Args&&... args) { std::unique_ptr object(new Sprite(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index baeeb50db..48b0c061b 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -210,8 +210,6 @@ namespace Nz TextSpriteRef TextSprite::New(Args&&... args) { std::unique_ptr object(new TextSprite(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index 31067f36c..423ab5a81 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -41,8 +41,6 @@ namespace Nz TextureBackgroundRef TextureBackground::New(Args&&... args) { std::unique_ptr object(new TextureBackground(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 405683f40..0f7c8faca 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -432,8 +432,6 @@ namespace Nz TileMapRef TileMap::New(Args&&... args) { std::unique_ptr object(new TileMap(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Physics/Geom.inl b/include/Nazara/Physics/Geom.inl index 9699cac96..0a21fbd23 100644 --- a/include/Nazara/Physics/Geom.inl +++ b/include/Nazara/Physics/Geom.inl @@ -11,8 +11,6 @@ namespace Nz BoxGeomRef BoxGeom::New(Args&&... args) { std::unique_ptr object(new BoxGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -20,8 +18,6 @@ namespace Nz CapsuleGeomRef CapsuleGeom::New(Args&&... args) { std::unique_ptr object(new CapsuleGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -29,8 +25,6 @@ namespace Nz CompoundGeomRef CompoundGeom::New(Args&&... args) { std::unique_ptr object(new CompoundGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -38,8 +32,6 @@ namespace Nz ConeGeomRef ConeGeom::New(Args&&... args) { std::unique_ptr object(new ConeGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -47,8 +39,6 @@ namespace Nz ConvexHullGeomRef ConvexHullGeom::New(Args&&... args) { std::unique_ptr object(new ConvexHullGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -56,8 +46,6 @@ namespace Nz CylinderGeomRef CylinderGeom::New(Args&&... args) { std::unique_ptr object(new CylinderGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -65,8 +53,6 @@ namespace Nz NullGeomRef NullGeom::New(Args&&... args) { std::unique_ptr object(new NullGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } @@ -74,8 +60,6 @@ namespace Nz SphereGeomRef SphereGeom::New(Args&&... args) { std::unique_ptr object(new SphereGeom(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl index bd81e7a17..59a9a5dd8 100644 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -11,8 +11,6 @@ namespace Nz RenderBufferRef RenderBuffer::New(Args&&... args) { std::unique_ptr object(new RenderBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Renderer/Shader.inl b/include/Nazara/Renderer/Shader.inl index b868c540e..0e8309008 100644 --- a/include/Nazara/Renderer/Shader.inl +++ b/include/Nazara/Renderer/Shader.inl @@ -11,8 +11,6 @@ namespace Nz ShaderRef Shader::New(Args&&... args) { std::unique_ptr object(new Shader(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl index 4dc53464b..c9813ac73 100644 --- a/include/Nazara/Renderer/Texture.inl +++ b/include/Nazara/Renderer/Texture.inl @@ -11,8 +11,6 @@ namespace Nz TextureRef Texture::New(Args&&... args) { std::unique_ptr object(new Texture(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.inl b/include/Nazara/Renderer/UberShaderPreprocessor.inl index 1e6528775..fb9477030 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.inl +++ b/include/Nazara/Renderer/UberShaderPreprocessor.inl @@ -11,8 +11,6 @@ namespace Nz UberShaderPreprocessorRef UberShaderPreprocessor::New(Args&&... args) { std::unique_ptr object(new UberShaderPreprocessor(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Animation.inl b/include/Nazara/Utility/Animation.inl index 0ae58c0f4..f742e4c0e 100644 --- a/include/Nazara/Utility/Animation.inl +++ b/include/Nazara/Utility/Animation.inl @@ -11,8 +11,6 @@ namespace Nz AnimationRef Animation::New(Args&&... args) { std::unique_ptr object(new Animation(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Buffer.inl b/include/Nazara/Utility/Buffer.inl index 8703fd82c..39c1960f7 100644 --- a/include/Nazara/Utility/Buffer.inl +++ b/include/Nazara/Utility/Buffer.inl @@ -11,8 +11,6 @@ namespace Nz BufferRef Buffer::New(Args&&... args) { std::unique_ptr object(new Buffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Font.inl b/include/Nazara/Utility/Font.inl index 241915a3e..5f8e94c2c 100644 --- a/include/Nazara/Utility/Font.inl +++ b/include/Nazara/Utility/Font.inl @@ -11,8 +11,6 @@ namespace Nz FontRef Font::New(Args&&... args) { std::unique_ptr object(new Font(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Image.inl b/include/Nazara/Utility/Image.inl index 5cb8ef42f..ca111f9e9 100644 --- a/include/Nazara/Utility/Image.inl +++ b/include/Nazara/Utility/Image.inl @@ -11,8 +11,6 @@ namespace Nz ImageRef Image::New(Args&&... args) { std::unique_ptr object(new Image(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index 1c1d16a18..789019f91 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -11,8 +11,6 @@ namespace Nz IndexBufferRef IndexBuffer::New(Args&&... args) { std::unique_ptr object(new IndexBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Mesh.inl b/include/Nazara/Utility/Mesh.inl index 4877e03fe..21d52bf7d 100644 --- a/include/Nazara/Utility/Mesh.inl +++ b/include/Nazara/Utility/Mesh.inl @@ -11,8 +11,6 @@ namespace Nz MeshRef Mesh::New(Args&&... args) { std::unique_ptr object(new Mesh(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/SkeletalMesh.inl b/include/Nazara/Utility/SkeletalMesh.inl index 69119dc87..f6a590902 100644 --- a/include/Nazara/Utility/SkeletalMesh.inl +++ b/include/Nazara/Utility/SkeletalMesh.inl @@ -11,8 +11,6 @@ namespace Nz SkeletalMeshRef SkeletalMesh::New(Args&&... args) { std::unique_ptr object(new SkeletalMesh(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/Skeleton.inl b/include/Nazara/Utility/Skeleton.inl index 4c0ef4546..839227462 100644 --- a/include/Nazara/Utility/Skeleton.inl +++ b/include/Nazara/Utility/Skeleton.inl @@ -11,8 +11,6 @@ namespace Nz SkeletonRef Skeleton::New(Args&&... args) { std::unique_ptr object(new Skeleton(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/StaticMesh.inl b/include/Nazara/Utility/StaticMesh.inl index 06afcec95..a18ae32f5 100644 --- a/include/Nazara/Utility/StaticMesh.inl +++ b/include/Nazara/Utility/StaticMesh.inl @@ -11,8 +11,6 @@ namespace Nz StaticMeshRef StaticMesh::New(Args&&... args) { std::unique_ptr object(new StaticMesh(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index 24268e9cb..a4ebef1be 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -11,8 +11,6 @@ namespace Nz VertexBufferRef VertexBuffer::New(Args&&... args) { std::unique_ptr object(new VertexBuffer(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index beed900d5..f74e29a7c 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -11,8 +11,6 @@ namespace Nz VertexDeclarationRef VertexDeclaration::New(Args&&... args) { std::unique_ptr object(new VertexDeclaration(std::forward(args)...)); - object->SetPersistent(false); - return object.release(); } } diff --git a/src/Nazara/Core/RefCounted.cpp b/src/Nazara/Core/RefCounted.cpp index 31e749515..f37300c32 100644 --- a/src/Nazara/Core/RefCounted.cpp +++ b/src/Nazara/Core/RefCounted.cpp @@ -23,13 +23,10 @@ namespace Nz */ /*! - * \brief Constructs a RefCounted object with a persistance aspect - * - * \param persistent if false, object is destroyed when no more referenced + * \brief Constructs a RefCounted object */ - RefCounted::RefCounted(bool persistent) : - m_persistent(persistent), + RefCounted::RefCounted() : m_referenceCount(0) { } @@ -67,16 +64,6 @@ namespace Nz return m_referenceCount; } - /*! - * \brief Checks whether the object is persistent - * \return true if object is not destroyed when no more referenced - */ - - bool RefCounted::IsPersistent() const - { - return m_persistent; - } - /*! * \brief Removes a reference to the object * \return true if object is deleted because no more referenced @@ -94,7 +81,7 @@ namespace Nz } #endif - if (--m_referenceCount == 0 && !m_persistent) + if (--m_referenceCount == 0) { delete this; // Suicide @@ -103,26 +90,4 @@ namespace Nz else return false; } - - /*! - * \brief Sets the persistence of the object - * \return true if object is deleted because no more referenced - * - * \param persistent Sets the persistence of the object - * \param checkReferenceCount Checks if the object should be destroyed if true - */ - - bool RefCounted::SetPersistent(bool persistent, bool checkReferenceCount) - { - m_persistent = persistent; - - if (checkReferenceCount && !persistent && m_referenceCount == 0) - { - delete this; - - return true; - } - else - return false; - } } From f41bbfbf792047b675bbfc77afdb8fdd64acc8eb Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 12:56:03 +0200 Subject: [PATCH 173/383] Fix compile Former-commit-id: 7ae323d1a7816fdea1634325c5edf3a468089495 [formerly 51214a2f11742919093c73a60dc74910d2610be1] Former-commit-id: 2b787569abc0dc73637dc5ecb43018b1766e2c28 --- src/Nazara/Utility/SubMesh.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index 8b0589808..fd706e7a6 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -15,7 +15,6 @@ namespace Nz { SubMesh::SubMesh(const Mesh* parent) : - RefCounted(false), // Un SubMesh n'est pas persistant par défaut m_primitiveMode(PrimitiveMode_TriangleList), m_parent(parent), m_matIndex(0) From 0e44e0eb15f61ee9af3a7e723aa5d195615a5960 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 13:20:31 +0200 Subject: [PATCH 174/383] Revert "Fix compile" This reverts commit df4e466ee49accc9c19b2fe6da3c14e2779ca12b [formerly 752e14ea33208e0a1298a21b2be1c6aee56dfde1] [formerly a3eb1f7d2f090e0a63f64b3451198631e8d2c47e [formerly 4b89c5fafdc15330f909c62fd75a23885c7364e1]] [formerly 0b09aea025e4d8df0bdf33917571e81f1fe5c6a2 [formerly e192bf206e80f55897d26faf541bcc5afa0437fc] [formerly e9f0b2cd7d7dd709f6a0419b3ea4f6a599cbb823 [formerly 273f4a73bfed75ebec68969db3ae235ccec8600c]]]. Former-commit-id: ac8998b1a9ee363bcacfc3c9163e805cb1cbd93e [formerly 00d103e705e266c89cc508f3c4b06bab2b20bd4f] [formerly ba1b3fa7a77eb7e258234d5c12e89f0e883870cd [formerly cc0071350fc26ac76a1a49b2705b59871ac6c6f2]] Former-commit-id: 6f83e8ded662a4ba85ab379f41809f541f83a628 [formerly 1ecb471c3812b741f0edd43e27ab0a1e567d8c18] Former-commit-id: 4b0bd20ee74057669cce771c7a66520698980aa0 --- src/Nazara/Utility/SubMesh.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index fd706e7a6..8b0589808 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -15,6 +15,7 @@ namespace Nz { SubMesh::SubMesh(const Mesh* parent) : + RefCounted(false), // Un SubMesh n'est pas persistant par défaut m_primitiveMode(PrimitiveMode_TriangleList), m_parent(parent), m_matIndex(0) From 5fa5186480b156755aa940ce1539543a8990b0bb Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 13:20:34 +0200 Subject: [PATCH 175/383] Revert "Core/RefCounted: Remove persistent boolean" This reverts commit db2ef3e90c3871290d114a9e6437b412e96c65aa [formerly a3f6ff88a25e63374eb6ce5b18269da2ba743b06] [formerly cfa12604fbb0da76fc27288b210ee1254a8b3a38 [formerly dee6ce858398e2de38ef1af00c1c630fd0126e09]] [formerly 1a23f0fddcd80ac33030061b7a00a3cfd43cb7fe [formerly d3cb17069c71449ae3f1cba6de55ea70f509e7a4] [formerly b2f8f82e9f3427310204f2e8a61d7bdfd96202d2 [formerly 5d117720d08d6d6243b3428d4b3f8aea1abef845]]]. Former-commit-id: 13a54266823fed88610753b1a90f4ef2c6fe932d [formerly 508d1a01cceee4a577063c684244fcf598ff6cb5] [formerly 2c99faae4d65dc222d05d2f98913a380b38d58ef [formerly 0117f7aec15e3db31cacdd0ef874064907c41ba8]] Former-commit-id: 140d69126443b821a232a1a8b012712fc2e74b0f [formerly 501a63bd435f64d9da932279c90400ed95d0c1be] Former-commit-id: d2d74a42d070eae9c1f158a59238c5f1ac40edb3 --- include/Nazara/Audio/SoundBuffer.inl | 2 + include/Nazara/Core/RefCounted.hpp | 7 +++- include/Nazara/Graphics/Billboard.inl | 2 + include/Nazara/Graphics/ColorBackground.inl | 2 + include/Nazara/Graphics/Material.inl | 2 + include/Nazara/Graphics/Model.inl | 2 + include/Nazara/Graphics/SkyboxBackground.inl | 2 + include/Nazara/Graphics/Sprite.inl | 2 + include/Nazara/Graphics/TextSprite.inl | 2 + include/Nazara/Graphics/TextureBackground.inl | 2 + include/Nazara/Graphics/TileMap.inl | 2 + include/Nazara/Physics/Geom.inl | 16 ++++++++ include/Nazara/Renderer/RenderBuffer.inl | 2 + include/Nazara/Renderer/Shader.inl | 2 + include/Nazara/Renderer/Texture.inl | 2 + .../Renderer/UberShaderPreprocessor.inl | 2 + include/Nazara/Utility/Animation.inl | 2 + include/Nazara/Utility/Buffer.inl | 2 + include/Nazara/Utility/Font.inl | 2 + include/Nazara/Utility/Image.inl | 2 + include/Nazara/Utility/IndexBuffer.inl | 2 + include/Nazara/Utility/Mesh.inl | 2 + include/Nazara/Utility/SkeletalMesh.inl | 2 + include/Nazara/Utility/Skeleton.inl | 2 + include/Nazara/Utility/StaticMesh.inl | 2 + include/Nazara/Utility/VertexBuffer.inl | 2 + include/Nazara/Utility/VertexDeclaration.inl | 2 + src/Nazara/Core/RefCounted.cpp | 41 +++++++++++++++++-- 28 files changed, 110 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index 22ed4b19a..a4c42be69 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -18,6 +18,8 @@ namespace Nz SoundBufferRef SoundBuffer::New(Args&&... args) { std::unique_ptr object(new SoundBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index 42936ff7e..542784787 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -22,7 +22,7 @@ namespace Nz class NAZARA_CORE_API RefCounted { public: - RefCounted(); + RefCounted(bool persistent = true); RefCounted(const RefCounted&) = delete; RefCounted(RefCounted&&) = default; virtual ~RefCounted(); @@ -31,12 +31,17 @@ namespace Nz unsigned int GetReferenceCount() const; + bool IsPersistent() const; + bool RemoveReference() const; + bool SetPersistent(bool persistent = true, bool checkReferenceCount = false); + RefCounted& operator=(const RefCounted&) = delete; RefCounted& operator=(RefCounted&&) = default; private: + std::atomic_bool m_persistent; mutable std::atomic_uint m_referenceCount; }; } diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 95a0e5b87..6c4a1e0a9 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -234,6 +234,8 @@ namespace Nz BillboardRef Billboard::New(Args&&... args) { std::unique_ptr object(new Billboard(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 49efd4874..67b1f2558 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -18,6 +18,8 @@ namespace Nz ColorBackgroundRef ColorBackground::New(Args&&... args) { std::unique_ptr object(new ColorBackground(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 801e341ae..6d5315640 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -1099,6 +1099,8 @@ namespace Nz MaterialRef Material::New(Args&&... args) { std::unique_ptr object(new Material(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index fba9655ec..a2b4c3967 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -18,6 +18,8 @@ namespace Nz ModelRef Model::New(Args&&... args) { std::unique_ptr object(new Model(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 15d3eb137..6171f1e28 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -119,6 +119,8 @@ namespace Nz SkyboxBackgroundRef SkyboxBackground::New(Args&&... args) { std::unique_ptr object(new SkyboxBackground(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 166807f2b..840a930e6 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -271,6 +271,8 @@ namespace Nz SpriteRef Sprite::New(Args&&... args) { std::unique_ptr object(new Sprite(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index 48b0c061b..baeeb50db 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -210,6 +210,8 @@ namespace Nz TextSpriteRef TextSprite::New(Args&&... args) { std::unique_ptr object(new TextSprite(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index 423ab5a81..31067f36c 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -41,6 +41,8 @@ namespace Nz TextureBackgroundRef TextureBackground::New(Args&&... args) { std::unique_ptr object(new TextureBackground(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 0f7c8faca..405683f40 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -432,6 +432,8 @@ namespace Nz TileMapRef TileMap::New(Args&&... args) { std::unique_ptr object(new TileMap(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Physics/Geom.inl b/include/Nazara/Physics/Geom.inl index 0a21fbd23..9699cac96 100644 --- a/include/Nazara/Physics/Geom.inl +++ b/include/Nazara/Physics/Geom.inl @@ -11,6 +11,8 @@ namespace Nz BoxGeomRef BoxGeom::New(Args&&... args) { std::unique_ptr object(new BoxGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -18,6 +20,8 @@ namespace Nz CapsuleGeomRef CapsuleGeom::New(Args&&... args) { std::unique_ptr object(new CapsuleGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -25,6 +29,8 @@ namespace Nz CompoundGeomRef CompoundGeom::New(Args&&... args) { std::unique_ptr object(new CompoundGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -32,6 +38,8 @@ namespace Nz ConeGeomRef ConeGeom::New(Args&&... args) { std::unique_ptr object(new ConeGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -39,6 +47,8 @@ namespace Nz ConvexHullGeomRef ConvexHullGeom::New(Args&&... args) { std::unique_ptr object(new ConvexHullGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -46,6 +56,8 @@ namespace Nz CylinderGeomRef CylinderGeom::New(Args&&... args) { std::unique_ptr object(new CylinderGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -53,6 +65,8 @@ namespace Nz NullGeomRef NullGeom::New(Args&&... args) { std::unique_ptr object(new NullGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } @@ -60,6 +74,8 @@ namespace Nz SphereGeomRef SphereGeom::New(Args&&... args) { std::unique_ptr object(new SphereGeom(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl index 59a9a5dd8..bd81e7a17 100644 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -11,6 +11,8 @@ namespace Nz RenderBufferRef RenderBuffer::New(Args&&... args) { std::unique_ptr object(new RenderBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Renderer/Shader.inl b/include/Nazara/Renderer/Shader.inl index 0e8309008..b868c540e 100644 --- a/include/Nazara/Renderer/Shader.inl +++ b/include/Nazara/Renderer/Shader.inl @@ -11,6 +11,8 @@ namespace Nz ShaderRef Shader::New(Args&&... args) { std::unique_ptr object(new Shader(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl index c9813ac73..4dc53464b 100644 --- a/include/Nazara/Renderer/Texture.inl +++ b/include/Nazara/Renderer/Texture.inl @@ -11,6 +11,8 @@ namespace Nz TextureRef Texture::New(Args&&... args) { std::unique_ptr object(new Texture(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.inl b/include/Nazara/Renderer/UberShaderPreprocessor.inl index fb9477030..1e6528775 100644 --- a/include/Nazara/Renderer/UberShaderPreprocessor.inl +++ b/include/Nazara/Renderer/UberShaderPreprocessor.inl @@ -11,6 +11,8 @@ namespace Nz UberShaderPreprocessorRef UberShaderPreprocessor::New(Args&&... args) { std::unique_ptr object(new UberShaderPreprocessor(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Animation.inl b/include/Nazara/Utility/Animation.inl index f742e4c0e..0ae58c0f4 100644 --- a/include/Nazara/Utility/Animation.inl +++ b/include/Nazara/Utility/Animation.inl @@ -11,6 +11,8 @@ namespace Nz AnimationRef Animation::New(Args&&... args) { std::unique_ptr object(new Animation(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Buffer.inl b/include/Nazara/Utility/Buffer.inl index 39c1960f7..8703fd82c 100644 --- a/include/Nazara/Utility/Buffer.inl +++ b/include/Nazara/Utility/Buffer.inl @@ -11,6 +11,8 @@ namespace Nz BufferRef Buffer::New(Args&&... args) { std::unique_ptr object(new Buffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Font.inl b/include/Nazara/Utility/Font.inl index 5f8e94c2c..241915a3e 100644 --- a/include/Nazara/Utility/Font.inl +++ b/include/Nazara/Utility/Font.inl @@ -11,6 +11,8 @@ namespace Nz FontRef Font::New(Args&&... args) { std::unique_ptr object(new Font(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Image.inl b/include/Nazara/Utility/Image.inl index ca111f9e9..5cb8ef42f 100644 --- a/include/Nazara/Utility/Image.inl +++ b/include/Nazara/Utility/Image.inl @@ -11,6 +11,8 @@ namespace Nz ImageRef Image::New(Args&&... args) { std::unique_ptr object(new Image(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index 789019f91..1c1d16a18 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -11,6 +11,8 @@ namespace Nz IndexBufferRef IndexBuffer::New(Args&&... args) { std::unique_ptr object(new IndexBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Mesh.inl b/include/Nazara/Utility/Mesh.inl index 21d52bf7d..4877e03fe 100644 --- a/include/Nazara/Utility/Mesh.inl +++ b/include/Nazara/Utility/Mesh.inl @@ -11,6 +11,8 @@ namespace Nz MeshRef Mesh::New(Args&&... args) { std::unique_ptr object(new Mesh(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/SkeletalMesh.inl b/include/Nazara/Utility/SkeletalMesh.inl index f6a590902..69119dc87 100644 --- a/include/Nazara/Utility/SkeletalMesh.inl +++ b/include/Nazara/Utility/SkeletalMesh.inl @@ -11,6 +11,8 @@ namespace Nz SkeletalMeshRef SkeletalMesh::New(Args&&... args) { std::unique_ptr object(new SkeletalMesh(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/Skeleton.inl b/include/Nazara/Utility/Skeleton.inl index 839227462..4c0ef4546 100644 --- a/include/Nazara/Utility/Skeleton.inl +++ b/include/Nazara/Utility/Skeleton.inl @@ -11,6 +11,8 @@ namespace Nz SkeletonRef Skeleton::New(Args&&... args) { std::unique_ptr object(new Skeleton(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/StaticMesh.inl b/include/Nazara/Utility/StaticMesh.inl index a18ae32f5..06afcec95 100644 --- a/include/Nazara/Utility/StaticMesh.inl +++ b/include/Nazara/Utility/StaticMesh.inl @@ -11,6 +11,8 @@ namespace Nz StaticMeshRef StaticMesh::New(Args&&... args) { std::unique_ptr object(new StaticMesh(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index a4ebef1be..24268e9cb 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -11,6 +11,8 @@ namespace Nz VertexBufferRef VertexBuffer::New(Args&&... args) { std::unique_ptr object(new VertexBuffer(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index f74e29a7c..beed900d5 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -11,6 +11,8 @@ namespace Nz VertexDeclarationRef VertexDeclaration::New(Args&&... args) { std::unique_ptr object(new VertexDeclaration(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } diff --git a/src/Nazara/Core/RefCounted.cpp b/src/Nazara/Core/RefCounted.cpp index f37300c32..31e749515 100644 --- a/src/Nazara/Core/RefCounted.cpp +++ b/src/Nazara/Core/RefCounted.cpp @@ -23,10 +23,13 @@ namespace Nz */ /*! - * \brief Constructs a RefCounted object + * \brief Constructs a RefCounted object with a persistance aspect + * + * \param persistent if false, object is destroyed when no more referenced */ - RefCounted::RefCounted() : + RefCounted::RefCounted(bool persistent) : + m_persistent(persistent), m_referenceCount(0) { } @@ -64,6 +67,16 @@ namespace Nz return m_referenceCount; } + /*! + * \brief Checks whether the object is persistent + * \return true if object is not destroyed when no more referenced + */ + + bool RefCounted::IsPersistent() const + { + return m_persistent; + } + /*! * \brief Removes a reference to the object * \return true if object is deleted because no more referenced @@ -81,7 +94,7 @@ namespace Nz } #endif - if (--m_referenceCount == 0) + if (--m_referenceCount == 0 && !m_persistent) { delete this; // Suicide @@ -90,4 +103,26 @@ namespace Nz else return false; } + + /*! + * \brief Sets the persistence of the object + * \return true if object is deleted because no more referenced + * + * \param persistent Sets the persistence of the object + * \param checkReferenceCount Checks if the object should be destroyed if true + */ + + bool RefCounted::SetPersistent(bool persistent, bool checkReferenceCount) + { + m_persistent = persistent; + + if (checkReferenceCount && !persistent && m_referenceCount == 0) + { + delete this; + + return true; + } + else + return false; + } } From ca1b9c19881107df8290367b5860a3c1df7142b7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 2 Aug 2016 13:31:09 +0200 Subject: [PATCH 176/383] Improved declarations Former-commit-id: 567f98b44eada10ffb797cc19cfcdbca584a2461 [formerly 01826c3bfd8385abd6a47f770c7eba7980ae9199] [formerly 6c54c8e8e6a8515387fc61f665bfa5d2cc2d8cdf [formerly f507b9604c2395a4d1eec0f12a07e3cd8b47e4f6]] Former-commit-id: 1723f76155d68f5aac2006f5ebf5bd96b4ac81e7 [formerly 04f3ed2688c3519923edbb0693e259ee3653256b] Former-commit-id: e37a8744e6756f5eb331881b422d491171adb362 --- .../Nazara/Graphics/ParticleDeclaration.hpp | 8 ++++++-- .../Nazara/Graphics/ParticleDeclaration.inl | 18 ++++++++++++++++++ include/Nazara/Utility/VertexDeclaration.hpp | 7 ++++--- src/Nazara/Graphics/ParticleDeclaration.cpp | 14 ++++---------- src/Nazara/Utility/Formats/OBJSaver.cpp | 1 - src/Nazara/Utility/VertexDeclaration.cpp | 14 ++++---------- 6 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 include/Nazara/Graphics/ParticleDeclaration.inl diff --git a/include/Nazara/Graphics/ParticleDeclaration.hpp b/include/Nazara/Graphics/ParticleDeclaration.hpp index 0edfba85f..278d25961 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.hpp +++ b/include/Nazara/Graphics/ParticleDeclaration.hpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace Nz { @@ -46,6 +47,7 @@ namespace Nz static ParticleDeclaration* Get(ParticleLayout layout); static bool IsTypeSupported(ComponentType type); + template static ParticleDeclarationRef New(Args&&... args); // Signals: NazaraSignal(OnParticleDeclarationRelease, const ParticleDeclaration* /*particleDeclaration*/); @@ -68,12 +70,14 @@ namespace Nz */ }; - Component m_components[ParticleComponent_Max + 1]; + std::array m_components; unsigned int m_stride; - static ParticleDeclaration s_declarations[ParticleLayout_Max + 1]; + static std::array s_declarations; static ParticleDeclarationLibrary::LibraryMap s_library; }; } +#include + #endif // NAZARA_PARTICLEDECLARATION_HPP diff --git a/include/Nazara/Graphics/ParticleDeclaration.inl b/include/Nazara/Graphics/ParticleDeclaration.inl new file mode 100644 index 000000000..27cd92a22 --- /dev/null +++ b/include/Nazara/Graphics/ParticleDeclaration.inl @@ -0,0 +1,18 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + template + ParticleDeclarationRef ParticleDeclaration::New(Args&&... args) + { + std::unique_ptr object(new ParticleDeclaration(std::forward(args)...)); + return object.release(); + } +} + +#include diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index f5dea6457..8c1e4b55a 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace Nz { @@ -69,14 +70,14 @@ namespace Nz */ }; - Component m_components[VertexComponent_Max+1]; + std::array m_components; std::size_t m_stride; - static VertexDeclaration s_declarations[VertexLayout_Max+1]; + static std::array s_declarations; static VertexDeclarationLibrary::LibraryMap s_library; }; } -#include +#include #endif // NAZARA_VERTEXDECLARATION_HPP diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index ecd09c752..62cf321ab 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -38,9 +38,9 @@ namespace Nz ParticleDeclaration::ParticleDeclaration(const ParticleDeclaration& declaration) : RefCounted(), + m_components(declaration.m_components), m_stride(declaration.m_stride) { - std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); } /*! @@ -205,7 +205,7 @@ namespace Nz ParticleDeclaration& ParticleDeclaration::operator=(const ParticleDeclaration& declaration) { - std::memcpy(m_components, declaration.m_components, sizeof(Component) * (ParticleComponent_Max + 1)); + m_components = declaration.m_components; m_stride = declaration.m_stride; return *this; @@ -222,13 +222,7 @@ namespace Nz ParticleDeclaration* ParticleDeclaration::Get(ParticleLayout layout) { - #ifdef NAZARA_DEBUG - if (layout > ParticleLayout_Max) - { - NazaraError("Particle layout out of enum"); - return nullptr; - } - #endif + NazaraAssert(layout <= ParticleLayout_Max, "Particle layout out of enum"); return &s_declarations[layout]; } @@ -338,6 +332,6 @@ namespace Nz ParticleDeclarationLibrary::Uninitialize(); } - ParticleDeclaration ParticleDeclaration::s_declarations[ParticleLayout_Max + 1]; + std::array ParticleDeclaration::s_declarations; ParticleDeclarationLibrary::LibraryMap ParticleDeclaration::s_library; } diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 9a79638bc..baf54e44b 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -120,7 +120,6 @@ namespace Nz MTLParser::Material* material = mtlFormat.AddMaterial(name); - bool bValue; String strVal; if (matData.HasParameter(MaterialData::CustomDefined)) { diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 998f12f8b..945888406 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -22,9 +22,9 @@ namespace Nz VertexDeclaration::VertexDeclaration(const VertexDeclaration& declaration) : RefCounted(), + m_components(declaration.m_components), m_stride(declaration.m_stride) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(VertexComponent_Max+1)); } VertexDeclaration::~VertexDeclaration() @@ -133,7 +133,7 @@ namespace Nz VertexDeclaration& VertexDeclaration::operator=(const VertexDeclaration& declaration) { - std::memcpy(m_components, declaration.m_components, sizeof(Component)*(VertexComponent_Max+1)); + m_components = declaration.m_components; m_stride = declaration.m_stride; return *this; @@ -141,13 +141,7 @@ namespace Nz VertexDeclaration* VertexDeclaration::Get(VertexLayout layout) { - #ifdef NAZARA_DEBUG - if (layout > VertexLayout_Max) - { - NazaraError("Vertex layout out of enum"); - return nullptr; - } - #endif + NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum"); return &s_declarations[layout]; } @@ -301,6 +295,6 @@ namespace Nz VertexDeclarationLibrary::Uninitialize(); } - VertexDeclaration VertexDeclaration::s_declarations[VertexLayout_Max+1]; + std::array VertexDeclaration::s_declarations; VertexDeclarationLibrary::LibraryMap VertexDeclaration::s_library; } From e7b940c6cf58edfb6c8a837664227888b21788b8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Aug 2016 13:46:42 +0200 Subject: [PATCH 177/383] SDK/StateMachine: Add GetCurrentState function Former-commit-id: 3fb462b92a8b1190c974f16079458fccbcc0135a [formerly 4092a64ff127dd696ea0f824687670a18367e28f] [formerly 926df48c28edb7db9682e4a16613f5a6e12e8f26 [formerly 2cff9c75a1b974b6407fd0ff577dd50d620f18e2]] Former-commit-id: 3555eea4a1e89a4c6e750349c55e603b6d4dc237 [formerly b60dbd584782aafc339acaa666cd45508ef9891d] Former-commit-id: 0ddbe91d5bab84c65429e651ed8585d7129e04f0 --- SDK/include/NDK/StateMachine.hpp | 2 ++ SDK/include/NDK/StateMachine.inl | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/SDK/include/NDK/StateMachine.hpp b/SDK/include/NDK/StateMachine.hpp index 8e7ad2f64..c36464fea 100644 --- a/SDK/include/NDK/StateMachine.hpp +++ b/SDK/include/NDK/StateMachine.hpp @@ -23,6 +23,8 @@ namespace Ndk inline void ChangeState(std::shared_ptr state); + inline const std::shared_ptr& GetCurrentState() const; + inline bool Update(float elapsedTime); inline StateMachine& operator=(StateMachine&& fsm) = default; diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NDK/StateMachine.inl index fc4c7f787..7b5109ab5 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NDK/StateMachine.inl @@ -26,6 +26,11 @@ namespace Ndk m_nextState = std::move(state); } + inline const std::shared_ptr& StateMachine::GetCurrentState() const + { + return m_currentState; + } + inline bool StateMachine::Update(float elapsedTime) { if (m_nextState) From cf8224b9e19737962110e37f45e54dafd52ec585 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Aug 2016 13:47:17 +0200 Subject: [PATCH 178/383] Graphics: Change ParticleStruct_Sprite position and velocity type from Vector2f to Vector3f Former-commit-id: 3e608a9622d6c759ca0d9cc42d5f5460a6e4488a [formerly b31994657a126489c141ca6bbd4f7745876b0fb3] [formerly 833df21d1208e31b5141dca3d9777c4822556ddd [formerly 638d3aa5c15845fc49c97727aa00aca2d670bedf]] Former-commit-id: bb2418f3523c525691ebedf044b47314fcdec6bb [formerly 43c4cae99f5b0a20431e6118f2b134e0a930633f] Former-commit-id: ffb8160b1574acd1063dab4ca151f420ff0940e8 --- include/Nazara/Graphics/ParticleStruct.hpp | 4 ++-- src/Nazara/Graphics/ParticleDeclaration.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Graphics/ParticleStruct.hpp b/include/Nazara/Graphics/ParticleStruct.hpp index b68836935..72ce961b9 100644 --- a/include/Nazara/Graphics/ParticleStruct.hpp +++ b/include/Nazara/Graphics/ParticleStruct.hpp @@ -35,8 +35,8 @@ namespace Nz struct ParticleStruct_Sprite { Color color; - Vector2f position; - Vector2f velocity; + Vector3f position; + Vector3f velocity; UInt32 life; float rotation; }; diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index 62cf321ab..dff382d2c 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -308,9 +308,9 @@ namespace Nz declaration = &s_declarations[ParticleLayout_Sprite]; declaration->EnableComponent(ParticleComponent_Color, ComponentType_Color, NazaraOffsetOf(ParticleStruct_Sprite, color)); declaration->EnableComponent(ParticleComponent_Life, ComponentType_Int1, NazaraOffsetOf(ParticleStruct_Sprite, life)); - declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float2, NazaraOffsetOf(ParticleStruct_Sprite, position)); + declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Sprite, position)); declaration->EnableComponent(ParticleComponent_Rotation, ComponentType_Float1, NazaraOffsetOf(ParticleStruct_Sprite, rotation)); - declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float2, NazaraOffsetOf(ParticleStruct_Sprite, velocity)); + declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Sprite, velocity)); NazaraAssert(declaration->GetStride() == sizeof(ParticleStruct_Sprite), "Invalid stride for declaration ParticleLayout_Sprite"); } From af01e7242c233658d4c0289945c2eb71094d6a79 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Aug 2016 01:12:06 +0200 Subject: [PATCH 179/383] Utility/MaterialData: Remove CustomDefined Former-commit-id: 4c3c2012ae06bdc4679fed40ee6ad50027664a8f [formerly d0454f47bbecdbb2513d7afc629b00b53543f671] [formerly 07f50ad9e366215fc51280232c26cc8cdbf8236d [formerly 27fbbc6106dc22f72d3ddb382049672e82833cd8]] Former-commit-id: e45fd2e87fcadbdf0a56c410d6c1ff36d9ea4b4a [formerly 0453e3ba57d326859fc78105b741cd7f1cb97bd6] Former-commit-id: 9f7082ef9da8e8baefaef5c141e630ba99b32a83 --- examples/MeshInfos/main.cpp | 7 +------ include/Nazara/Utility/MaterialData.hpp | 1 - plugins/Assimp/Plugin.cpp | 3 --- src/Nazara/Graphics/Formats/MeshLoader.cpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 1 - src/Nazara/Utility/Formats/OBJLoader.cpp | 2 -- src/Nazara/Utility/Formats/OBJSaver.cpp | 6 +++--- 7 files changed, 5 insertions(+), 17 deletions(-) diff --git a/examples/MeshInfos/main.cpp b/examples/MeshInfos/main.cpp index 73864abaa..e95a2a4c2 100644 --- a/examples/MeshInfos/main.cpp +++ b/examples/MeshInfos/main.cpp @@ -173,12 +173,7 @@ int main() Nz::String data; if (!matData.GetStringParameter(Nz::MaterialData::FilePath, &data)) - { - if (matData.HasParameter(Nz::MaterialData::CustomDefined)) - data = ""; - else - data = ""; - } + data = ""; std::cout << "\t" << (i+1) << ": " << data << std::endl; } diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index 66df97689..0c1e28cdd 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -23,7 +23,6 @@ namespace Nz static constexpr const char* BackFaceStencilZFail = "MatBackFaceStencilZFail"; static constexpr const char* Blending = "MatBlending"; static constexpr const char* CullingSide = "MatCullingSide"; - static constexpr const char* CustomDefined = "MatCustomDefined"; static constexpr const char* ColorWrite = "MatColorWrite"; static constexpr const char* DepthBuffer = "MatDepthBuffer"; static constexpr const char* DepthFunc = "MatDepthfunc"; diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 312bbf48e..39b645c65 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -237,8 +237,6 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) aiColor4D color; if (aiGetMaterialColor(aiMat, aiKey, aiType, aiIndex, &color) == aiReturn_SUCCESS) { - matData.SetParameter(MaterialData::CustomDefined); - matData.SetParameter(colorKey, Color(static_cast(color.r * 255), static_cast(color.g * 255), static_cast(color.b * 255), static_cast(color.a * 255))); } }; @@ -249,7 +247,6 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) aiTextureMapMode mapMode[3]; if (aiGetMaterialTexture(aiMat, aiType, 0, &path, nullptr, nullptr, nullptr, nullptr, &mapMode[0], nullptr) == aiReturn_SUCCESS) { - matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(textureKey, stream.GetDirectory() + String(path.data, path.length)); if (wrapKey) diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index 6769072bb..38f836e90 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -39,7 +39,7 @@ namespace Nz else NazaraWarning("Failed to load material from file " + String::Number(i)); } - else if (matData.HasParameter(MaterialData::CustomDefined)) + else { MaterialRef material = Material::New(); material->BuildFromParameters(matData, parameters.material); diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index c61dffd09..dde203482 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -102,7 +102,6 @@ namespace Nz stream.Read(skin, 68*sizeof(char)); ParameterList matData; - matData.SetParameter(MaterialData::CustomDefined); matData.SetParameter(MaterialData::DiffuseTexturePath, baseDir + skin); mesh->SetMaterialData(i, std::move(matData)); diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 1b1835b2b..405c845ea 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -73,8 +73,6 @@ namespace Nz { ParameterList data; - data.SetParameter(MaterialData::CustomDefined); - UInt8 alphaValue = static_cast(mtlMat->alpha*255.f); Color ambientColor(mtlMat->ambient); diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index baf54e44b..a7a2cda0b 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -121,7 +121,9 @@ namespace Nz MTLParser::Material* material = mtlFormat.AddMaterial(name); String strVal; - if (matData.HasParameter(MaterialData::CustomDefined)) + if (matData.GetStringParameter(MaterialData::FilePath, &strVal)) + material->diffuseMap = strVal; + else { Color colorVal; float fValue; @@ -147,8 +149,6 @@ namespace Nz if (matData.GetStringParameter(MaterialData::SpecularTexturePath, &strVal)) material->specularMap = strVal; } - else if (matData.GetStringParameter(MaterialData::FilePath, &strVal)) - material->diffuseMap = strVal; } // Meshes From c8f759c14dcd783e909797e6bfe03258cb99222b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Aug 2016 01:12:17 +0200 Subject: [PATCH 180/383] Plugins/Assimp: Handle assimp errors Former-commit-id: 00deff57456a3ad24252c0184d836cdc58dd2f0c [formerly 44d87e7a002c4096a19d8023d4f7de0c8817a6bf] [formerly 9c53c4d2fbf328d92d1a2760d8205cb1a3249674 [formerly 941b8f3855ca200cd9936d4f62ad4c89d61c8e63]] Former-commit-id: 3018201ef2111ced094c0f0318e80cd9bdada436 [formerly 649dc357ee2b9202e81305ca09a29b4b87333368] Former-commit-id: 8004da412aca6ed948162b3b231bed2f2756d0ac --- plugins/Assimp/Plugin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 39b645c65..d1d0ace26 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -23,6 +23,7 @@ SOFTWARE. */ #include +#include #include #include #include @@ -130,6 +131,12 @@ bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters) const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties); aiReleasePropertyStore(properties); + if (!scene) + { + NazaraError("Assimp failed to import file: " + Nz::String(aiGetErrorString())); + return false; + } + std::set joints; bool animatedMesh = false; From 812a41a4b260608af16c1ca2e3847ccfb269170c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 09:08:45 +0200 Subject: [PATCH 181/383] Core/String: Consider tabspace as separator Former-commit-id: 83188efd0af64eb3cbc683fd1ddb73ea3fa1adcc [formerly d0d8a4870433c3791ac38c9f2aa4e513ecf473f9] [formerly 6f9a95341216bb79e5a964900f76621b25b03b6c [formerly 6c51f4af08d55ca09da4a801f01cbe4c82e8b097]] Former-commit-id: 6ee9a65c18432d62c60222e19a364f015a98e046 [formerly 7a2dce7db255019b5bcb547938a30765520b8062] Former-commit-id: 2fac38a14d3e6ab16816e837d45847e084a6bb40 --- src/Nazara/Core/String.cpp | 91 ++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 21831bcdf..fbd29c97c 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -23,6 +23,11 @@ namespace Nz { namespace Detail { + inline bool IsSpace(char32_t character) + { + return character == '\t' || Unicode::GetCategory(character) & Unicode::Category_Separator; + } + // This algorithm is inspired by the documentation of Qt inline std::size_t GetNewSize(std::size_t newSize) { @@ -1379,7 +1384,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1391,7 +1396,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1421,7 +1426,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1433,7 +1438,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1465,7 +1470,7 @@ namespace Nz if (ptr != m_sharedString->string.get()) { --ptr; - if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*ptr++)) continue; } @@ -1475,7 +1480,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr-m_sharedString->string.get(); else break; @@ -1503,7 +1508,7 @@ namespace Nz if (ptr != m_sharedString->string.get()) { --ptr; - if (!(Unicode::GetCategory(*ptr++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*ptr++)) continue; } @@ -1513,7 +1518,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr-m_sharedString->string.get(); else break; @@ -1579,7 +1584,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1591,7 +1596,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1621,7 +1626,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1633,7 +1638,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*tIt) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*tIt)) return it.base() - m_sharedString->string.get(); else break; @@ -1664,7 +1669,7 @@ namespace Nz if (Detail::ToLower(*ptr) == c) { char nextC = *(ptr + 1); - if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0) + if (nextC != '\0' && (Detail::IsSpace(nextC)) == 0) continue; const char* p = &string.m_sharedString->string[string.m_sharedString->size-1]; @@ -1675,7 +1680,7 @@ namespace Nz if (p == &string.m_sharedString->string[0]) { - if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) + if (ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr-1))) return ptr-m_sharedString->string.get(); else break; @@ -1695,7 +1700,7 @@ namespace Nz if (*ptr == string.m_sharedString->string[string.m_sharedString->size-1]) { char nextC = *(ptr + 1); - if (nextC != '\0' && (Unicode::GetCategory(nextC) & Unicode::Category_Separator_Space) == 0) + if (nextC != '\0' && !Detail::IsSpace(nextC)) continue; const char* p = &string.m_sharedString->string[string.m_sharedString->size-1]; @@ -1706,7 +1711,7 @@ namespace Nz if (p == &string.m_sharedString->string[0]) { - if (ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator_Space) + if (ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr - 1))) return ptr-m_sharedString->string.get(); else break; @@ -1766,7 +1771,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1778,7 +1783,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -1806,7 +1811,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1818,7 +1823,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -1844,7 +1849,7 @@ namespace Nz { if (Detail::ToLower(*ptr) == c) { - if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr - 1)) & Unicode::Category_Separator) == 0) + if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr - 1))) continue; const char* p = &string[1]; @@ -1853,7 +1858,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr - m_sharedString->string.get(); else break; @@ -1875,7 +1880,7 @@ namespace Nz { if (*ptr == string[0]) { - if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator) == 0) + if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr-1))) continue; const char* p = &string[1]; @@ -1884,7 +1889,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr - m_sharedString->string.get(); else break; @@ -1947,7 +1952,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1959,7 +1964,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -1987,7 +1992,7 @@ namespace Nz if (it.base() != m_sharedString->string.get()) { --it; - if (!(Unicode::GetCategory(*it++) & Unicode::Category_Separator)) + if (!Detail::IsSpace(*it++)) continue; } @@ -1999,7 +2004,7 @@ namespace Nz { if (*p == '\0') { - if (*tIt == '\0' || Unicode::GetCategory(*it++) & Unicode::Category_Separator) + if (*tIt == '\0' || Detail::IsSpace(*it++)) return it.base() - m_sharedString->string.get(); else break; @@ -2026,7 +2031,7 @@ namespace Nz { if (Detail::ToLower(*ptr) == c) { - if (ptr != m_sharedString->string.get() && (Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) == 0) + if (ptr != m_sharedString->string.get() && !Detail::IsSpace(*(ptr-1))) continue; const char* p = &string.m_sharedString->string[1]; @@ -2035,7 +2040,7 @@ namespace Nz { if (*p == '\0') { - if (*tPtr == '\0' || Unicode::GetCategory(*tPtr) & Unicode::Category_Separator_Space) + if (*tPtr == '\0' || Detail::IsSpace(*tPtr)) return ptr - m_sharedString->string.get(); else break; @@ -2056,7 +2061,7 @@ namespace Nz while ((ptr = std::strstr(ptr, string.GetConstBuffer())) != nullptr) { // If the word is really alone - if ((ptr == m_sharedString->string.get() || Unicode::GetCategory(*(ptr-1)) & Unicode::Category_Separator_Space) && (*(ptr+m_sharedString->size) == '\0' || Unicode::GetCategory(*(ptr+m_sharedString->size)) & Unicode::Category_Separator_Space)) + if ((ptr == m_sharedString->string.get() || Detail::IsSpace(*(ptr-1))) && (*(ptr+m_sharedString->size) == '\0' || Detail::IsSpace(*(ptr+m_sharedString->size)))) return ptr - m_sharedString->string.get(); ptr++; @@ -2219,7 +2224,7 @@ namespace Nz utf8::unchecked::iterator it(ptr); do { - if (Unicode::GetCategory(*it) & Unicode::Category_Separator) + if (Detail::IsSpace(*it)) { endPos = static_cast(it.base() - m_sharedString->string.get() - 1); break; @@ -2231,7 +2236,7 @@ namespace Nz { do { - if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator) + if (Detail::IsSpace(*ptr)) { endPos = static_cast(ptr - m_sharedString->string.get() - 1); break; @@ -2265,7 +2270,7 @@ namespace Nz utf8::unchecked::iterator it(ptr); do { - if (Unicode::GetCategory(*it) & Unicode::Category_Separator) + if (Detail::IsSpace(*it)) inWord = false; else { @@ -2283,7 +2288,7 @@ namespace Nz { do { - if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator) + if (Detail::IsSpace(*ptr)) inWord = false; else { @@ -3414,7 +3419,7 @@ namespace Nz utf8::unchecked::iterator it(ptr); do { - if (Unicode::GetCategory(*it) & Unicode::Category_Separator) + if (Detail::IsSpace(*it)) { if (inword) { @@ -3435,7 +3440,7 @@ namespace Nz const char* limit = &m_sharedString->string[m_sharedString->size]; do { - if (Unicode::GetCategory(*ptr) & Unicode::Category_Separator) + if (Detail::IsSpace(*ptr)) { if (inword) { @@ -4240,7 +4245,7 @@ namespace Nz utf8::unchecked::iterator it(m_sharedString->string.get()); do { - if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) + if (!Detail::IsSpace(*it)) break; } while (*++it); @@ -4255,7 +4260,7 @@ namespace Nz utf8::unchecked::iterator it(&m_sharedString->string[m_sharedString->size]); while ((it--).base() != m_sharedString->string.get()) { - if (*it != '\t' && (Unicode::GetCategory(*it) & Unicode::Category_Separator) == 0) + if (!Detail::IsSpace(*it)) break; } @@ -4271,8 +4276,8 @@ namespace Nz { for (; startPos < m_sharedString->size; ++startPos) { - char c = m_sharedString->string[startPos]; - if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0) + char c = m_sharedString->string[startPos]; + if (!Detail::IsSpace(c)) break; } } @@ -4282,8 +4287,8 @@ namespace Nz { for (; endPos > 0; --endPos) { - char c = m_sharedString->string[endPos]; - if (c != '\t' && (Unicode::GetCategory(c) & Unicode::Category_Separator) == 0) + char c = m_sharedString->string[endPos]; + if (!Detail::IsSpace(c)) break; } } From 3ed7990319af3bfffc88b2dd1be980b92a01eff8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 09:08:56 +0200 Subject: [PATCH 182/383] Graphics/Model: Add AddToRenderQueue(renderQueue, matrix, order) overload Former-commit-id: 73ed5be4b011b26e651172e2384f0c2b24d04e52 [formerly ea024fbb0f25d22c4f63e3a0f75f87f1ee27ef22] [formerly 09b28b026cc770840151e431e5c417dea8d60da6 [formerly 22fcaf3aa60bbeaa3bbcf8cce34ff8fd29de0945]] Former-commit-id: b54b0b8ff0c4ba1c266179069ca81750c08d07ca [formerly a784f77e7bd901e98a60d50e71a84dc14789725f] Former-commit-id: 700465d059adaa119e6ab0b6051253825a495258 --- include/Nazara/Graphics/Model.hpp | 1 + include/Nazara/Graphics/Model.inl | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index f119072c8..b1755c7d8 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -45,6 +45,7 @@ namespace Nz virtual ~Model(); void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; + inline void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder = 0); Material* GetMaterial(const String& subMeshName) const; Material* GetMaterial(unsigned int matIndex) const; diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index a2b4c3967..243611fb5 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -7,6 +7,22 @@ namespace Nz { + /*! + * \brief Adds this model to a render queue, using user-specified transform matrix and render order + * + * This can be useful when drawing particles + * + * \param renderQueue Queue to be added + * \param transformMatrix Transform matrix to be used for rendering the model + * \param renderOrder Specify the renderqueue layer to be used + */ + inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder) + { + InstanceData instanceData(transformMatrix); + instanceData.renderOrder = renderOrder; + return AddToRenderQueue(renderQueue, instanceData); + } + /*! * \brief Creates a new Model from the arguments * \return A reference to the newly created model From b79cb84b09afb362f3c4dc6a36b46e98fc438ffb Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 09:09:14 +0200 Subject: [PATCH 183/383] Graphics/InstancedRenderable: Take a const reference to the matrix instead of a non-const one Former-commit-id: 7b2476238be361818cfb02cb4a0e425097854027 [formerly f6551951502fa86158ccba1e3e5e6ff4c5c6bcc3] [formerly ee7a6ccecb0e572be66b5ddc0fb3ebb3be4d9f37 [formerly 9417bcb7a725bff89f21af518de9634942afcd4e]] Former-commit-id: 3f8556fba2a463a9ad170d3e9bcd5d6681c6b211 [formerly 6e7a249b442e1d3dd7f03fa1736bbbfd9c3ea532] Former-commit-id: 6ee9e742d25a71962953557137c6e9bdf9be669b --- SDK/include/NDK/Components/GraphicsComponent.hpp | 2 +- include/Nazara/Graphics/InstancedRenderable.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index a7ac3ebc2..92aeeed2f 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -66,7 +66,7 @@ namespace Ndk struct Renderable { - Renderable(Nz::Matrix4f& transformMatrix) : + Renderable(const Nz::Matrix4f& transformMatrix) : data(transformMatrix), dataUpdated(false) { diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index d1c07bf9b..d854a41d6 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -54,7 +54,7 @@ namespace Nz struct InstanceData { - InstanceData(Matrix4f& referenceMatrix) : + InstanceData(const Matrix4f& referenceMatrix) : transformMatrix(&referenceMatrix), flags(0) { @@ -75,7 +75,7 @@ namespace Nz std::vector data; BoundingVolumef volume; - Matrix4f* transformMatrix; + const Matrix4f* transformMatrix; UInt32 flags; int renderOrder; }; From 8fbe279a50e44ab241209143427af1a395bc4a73 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 21:55:26 +0200 Subject: [PATCH 184/383] Graphics/AbstractRenderQueue: Remove AddBillboard method Former-commit-id: 454c84a97accb0cddddadbe48a2e08225b9cc98b [formerly a4e5d1e4511e5c1f02b8fd4e129192f88adf315f] [formerly d10b981f4e27d0dc6afc76b2c8dc60ab860cebbd [formerly 0e8c9cea9e8f06e82597924e608d0881d6735433]] Former-commit-id: 43f5b9d50bd672aa347f00ed2f87c54e9c9148ee [formerly 3ce48d5f0e61153fdf0cc957e06d6a5985e40577] Former-commit-id: d6def9dd70839c5caa8cc8a7d84d714321e81b88 --- .../Nazara/Graphics/AbstractRenderQueue.hpp | 1 - .../Nazara/Graphics/DeferredRenderQueue.hpp | 1 - include/Nazara/Graphics/DepthRenderQueue.hpp | 1 - .../Nazara/Graphics/ForwardRenderQueue.hpp | 1 - src/Nazara/Graphics/Billboard.cpp | 3 +- src/Nazara/Graphics/DeferredRenderQueue.cpp | 16 --------- src/Nazara/Graphics/DepthRenderQueue.cpp | 29 ---------------- src/Nazara/Graphics/ForwardRenderQueue.cpp | 34 ------------------- 8 files changed, 2 insertions(+), 84 deletions(-) diff --git a/include/Nazara/Graphics/AbstractRenderQueue.hpp b/include/Nazara/Graphics/AbstractRenderQueue.hpp index 50c6e0832..a245787ab 100644 --- a/include/Nazara/Graphics/AbstractRenderQueue.hpp +++ b/include/Nazara/Graphics/AbstractRenderQueue.hpp @@ -38,7 +38,6 @@ namespace Nz // Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards, // mais je n'ai pas d'autre solution tout aussi performante pour le moment... - virtual void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) = 0; virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) = 0; virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) = 0; virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) = 0; diff --git a/include/Nazara/Graphics/DeferredRenderQueue.hpp b/include/Nazara/Graphics/DeferredRenderQueue.hpp index fecd507be..6ac8e8c6c 100644 --- a/include/Nazara/Graphics/DeferredRenderQueue.hpp +++ b/include/Nazara/Graphics/DeferredRenderQueue.hpp @@ -29,7 +29,6 @@ namespace Nz DeferredRenderQueue(ForwardRenderQueue* forwardQueue); ~DeferredRenderQueue() = default; - void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) override; diff --git a/include/Nazara/Graphics/DepthRenderQueue.hpp b/include/Nazara/Graphics/DepthRenderQueue.hpp index 0b8a1fc5d..81ec921c0 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.hpp +++ b/include/Nazara/Graphics/DepthRenderQueue.hpp @@ -26,7 +26,6 @@ namespace Nz DepthRenderQueue(); ~DepthRenderQueue() = default; - void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) override; diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index c358e331c..7f88e80bf 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -31,7 +31,6 @@ namespace Nz ForwardRenderQueue() = default; ~ForwardRenderQueue() = default; - void AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos = Vector2f(0.f, 1.f), const Color& color = Color::White) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr = nullptr, SparsePtr colorPtr = nullptr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr sinCosPtr, SparsePtr alphaPtr) override; void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr positionPtr, SparsePtr sizePtr, SparsePtr anglePtr, SparsePtr colorPtr = nullptr) override; diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index e06d3c921..17a2ad065 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -30,7 +30,8 @@ namespace Nz if (!m_material) return; - renderQueue->AddBillboard(instanceData.renderOrder, m_material, instanceData.transformMatrix->GetTranslation(), m_size, m_sinCos, m_color); + Nz::Vector3f position = instanceData.transformMatrix->GetTranslation(); + renderQueue->AddBillboards(instanceData.renderOrder, m_material, 1, &position, &m_size, &m_sinCos, &m_color); } /* diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 738e7b799..0b15c5a44 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -29,22 +29,6 @@ namespace Nz { } - /*! - * \brief Adds billboard to the queue - * - * \param renderOrder Order of rendering - * \param material Material of the billboard - * \param position Position of the billboard - * \param size Sizes of the billboard - * \param sinCos Rotation of the billboard - * \param color Color of the billboard - */ - - void DeferredRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) - { - m_forwardQueue->AddBillboard(renderOrder, material, position, size, sinCos, color); - } - /*! * \brief Adds multiple billboards to the queue * diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index dc31d2a45..c658fe7bd 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -28,35 +28,6 @@ namespace Nz //m_baseMaterial->SetFaceCulling(FaceSide_Front); } - /*! - * \brief Adds billboard to the queue - * - * \param renderOrder Order of rendering - * \param material Material of the billboard - * \param position Position of the billboard - * \param size Sizes of the billboard - * \param sinCos Rotation of the billboard - * \param color Color of the billboard - * - * \remark Produces a NazaraAssert if material is invalid - */ - - void DepthRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) - { - NazaraAssert(material, "Invalid material"); - NazaraUnused(renderOrder); - - if (!IsMaterialSuitable(material)) - return; - - if (material->HasDepthMaterial()) - material = material->GetDepthMaterial(); - else - material = m_baseMaterial; - - ForwardRenderQueue::AddBillboard(0, material, position, size, sinCos, color); - } - /*! * \brief Adds multiple billboards to the queue * diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 0f182a185..b9077e1b9 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -17,40 +17,6 @@ namespace Nz * \brief Graphics class that represents the rendering queue for forward rendering */ - /*! - * \brief Adds billboard to the queue - * - * \param renderOrder Order of rendering - * \param material Material of the billboard - * \param position Position of the billboard - * \param size Sizes of the billboard - * \param sinCos Rotation of the billboard - * \param color Color of the billboard - * - * \remark Produces a NazaraAssert if material is invalid - */ - - void ForwardRenderQueue::AddBillboard(int renderOrder, const Material* material, const Vector3f& position, const Vector2f& size, const Vector2f& sinCos, const Color& color) - { - NazaraAssert(material, "Invalid material"); - - auto& billboards = GetLayer(renderOrder).billboards; - - auto it = billboards.find(material); - if (it == billboards.end()) - { - BatchedBillboardEntry entry; - entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - - it = billboards.insert(std::make_pair(material, std::move(entry))).first; - } - - BatchedBillboardEntry& entry = it->second; - - auto& billboardVector = entry.billboards; - billboardVector.push_back(BillboardData{color, position, size, sinCos}); - } - /*! * \brief Adds multiple billboards to the queue * From 87b5047b1424a1902dcff23d432e4bcb311e2838 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 22:09:39 +0200 Subject: [PATCH 185/383] Graphics: Separate pipeline state from Material into a new class, MaterialPipeline This allows much more efficient batching, along with pipeline reusage and preparation for the Vulkan API Former-commit-id: 4ed2f66567f7da6b6b6ee073e4d855b9a935000d [formerly b540f468fc700a16d5136d4dbb8632e23882fd3d] [formerly 37fff624ec65cc387130875410b6ea35c1a5bcfb [formerly ab9a88f514f46f6596499e285981fa6da588bb03]] Former-commit-id: a2e8859196c0f72b7d7ffd8764a887e6c8173743 [formerly c886cdade14769db243ff993a1741f6052a2eb2a] Former-commit-id: e1d02662fb1ac165c7e888380afee7601350060f --- SDK/src/NDK/Console.cpp | 4 +- include/Nazara/Graphics.hpp | 3 +- include/Nazara/Graphics/Billboard.inl | 3 +- .../Nazara/Graphics/DeferredRenderQueue.hpp | 29 +- include/Nazara/Graphics/DepthRenderQueue.inl | 2 +- .../Nazara/Graphics/DepthRenderTechnique.hpp | 1 + .../Nazara/Graphics/ForwardRenderQueue.hpp | 66 +- .../Graphics/ForwardRenderTechnique.hpp | 1 + include/Nazara/Graphics/Material.hpp | 64 +- include/Nazara/Graphics/Material.inl | 783 ++++++++++++------ include/Nazara/Graphics/MaterialPipeline.hpp | 95 +++ include/Nazara/Graphics/MaterialPipeline.inl | 143 ++++ include/Nazara/Graphics/Sprite.inl | 3 +- include/Nazara/Graphics/TextSprite.inl | 7 +- include/Nazara/Renderer/RenderPipeline.hpp | 42 + include/Nazara/Renderer/RenderPipeline.inl | 48 ++ include/Nazara/Renderer/RenderStates.hpp | 7 +- include/Nazara/Renderer/RenderStates.inl | 134 ++- src/Nazara/Graphics/DeferredGeometryPass.cpp | 192 +++-- src/Nazara/Graphics/DeferredRenderQueue.cpp | 129 +-- src/Nazara/Graphics/DepthRenderQueue.cpp | 4 +- src/Nazara/Graphics/DepthRenderTechnique.cpp | 502 ++++++----- src/Nazara/Graphics/ForwardRenderQueue.cpp | 223 +++-- .../Graphics/ForwardRenderTechnique.cpp | 632 +++++++------- src/Nazara/Graphics/Graphics.cpp | 26 +- src/Nazara/Graphics/Material.cpp | 302 ++----- src/Nazara/Graphics/MaterialPipeline.cpp | 168 ++++ .../Resources/Shaders/PhongLighting/core.frag | 36 +- .../Shaders/PhongLighting/core.frag.h | 2 +- .../Resources/Shaders/PhongLighting/core.vert | 18 +- .../Shaders/PhongLighting/core.vert.h | 2 +- 31 files changed, 2249 insertions(+), 1422 deletions(-) create mode 100644 include/Nazara/Graphics/MaterialPipeline.hpp create mode 100644 include/Nazara/Graphics/MaterialPipeline.inl create mode 100644 include/Nazara/Renderer/RenderPipeline.hpp create mode 100644 include/Nazara/Renderer/RenderPipeline.inl create mode 100644 src/Nazara/Graphics/MaterialPipeline.cpp diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 48ad10196..d157d7dbe 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -28,8 +28,8 @@ namespace Ndk m_characterSize(24) { Nz::MaterialRef backgroundMaterial = Nz::Material::New(); - backgroundMaterial->Enable(Nz::RendererParameter_Blend, true); - backgroundMaterial->Enable(Nz::RendererParameter_DepthBuffer, false); + backgroundMaterial->EnableBlending(true); + backgroundMaterial->EnableDepthBuffer(false); backgroundMaterial->SetDstBlend(Nz::BlendFunc_InvSrcAlpha); backgroundMaterial->SetSrcBlend(Nz::BlendFunc_SrcAlpha); diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 4809d9481..0195c123c 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 12 Jul 2016 at 17:44:43 +// This file was automatically generated on 20 Jul 2016 at 13:49:17 /* Nazara Engine - Graphics module @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index 6c4a1e0a9..45c2ef918 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -121,8 +121,7 @@ namespace Nz inline void Billboard::SetDefaultMaterial() { MaterialRef material = Material::New(); - material->Enable(RendererParameter_FaceCulling, true); - material->EnableLighting(false); + material->EnableFaceCulling(true); SetMaterial(std::move(material)); } diff --git a/include/Nazara/Graphics/DeferredRenderQueue.hpp b/include/Nazara/Graphics/DeferredRenderQueue.hpp index 6ac8e8c6c..922174df6 100644 --- a/include/Nazara/Graphics/DeferredRenderQueue.hpp +++ b/include/Nazara/Graphics/DeferredRenderQueue.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -21,8 +21,6 @@ namespace Nz { - class ForwardRenderQueue; - class NAZARA_GRAPHICS_API DeferredRenderQueue : public AbstractRenderQueue { public: @@ -43,11 +41,6 @@ namespace Nz void Clear(bool fully = false) override; - struct MeshDataComparator - { - bool operator()(const MeshData& data1, const MeshData& data2) const; - }; - struct MeshInstanceEntry { NazaraSlot(IndexBuffer, OnIndexBufferRelease, indexBufferReleaseSlot); @@ -56,12 +49,7 @@ namespace Nz std::vector instances; }; - typedef std::map MeshInstanceContainer; - - struct BatchedModelMaterialComparator - { - bool operator()(const Material* mat1, const Material* mat2) const; - }; + typedef std::map MeshInstanceContainer; struct BatchedModelEntry { @@ -69,14 +57,21 @@ namespace Nz MeshInstanceContainer meshMap; bool enabled = false; - bool instancingEnabled = false; }; - typedef std::map ModelBatches; + typedef std::map MeshMaterialBatches; + + struct BatchedMaterialEntry + { + std::size_t maxInstanceCount = 0; + MeshMaterialBatches materialMap; + }; + + typedef std::map MeshPipelineBatches; struct Layer { - ModelBatches opaqueModels; + MeshPipelineBatches opaqueModels; unsigned int clearCount = 0; }; diff --git a/include/Nazara/Graphics/DepthRenderQueue.inl b/include/Nazara/Graphics/DepthRenderQueue.inl index a8a8da45e..8fbce164b 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.inl +++ b/include/Nazara/Graphics/DepthRenderQueue.inl @@ -18,7 +18,7 @@ namespace Nz { NazaraAssert(material, "Invalid material"); - return material->HasDepthMaterial() || (material->IsEnabled(RendererParameter_DepthBuffer) && material->IsEnabled(RendererParameter_DepthWrite) && material->IsShadowCastingEnabled()); + return material->HasDepthMaterial() || (material->IsDepthBufferEnabled() && material->IsDepthWriteEnabled() && material->IsShadowCastingEnabled()); } } diff --git a/include/Nazara/Graphics/DepthRenderTechnique.hpp b/include/Nazara/Graphics/DepthRenderTechnique.hpp index 42b7f6e0a..9d4ba601f 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.hpp +++ b/include/Nazara/Graphics/DepthRenderTechnique.hpp @@ -63,6 +63,7 @@ namespace Nz mutable std::unordered_map m_shaderUniforms; Buffer m_vertexBuffer; mutable DepthRenderQueue m_renderQueue; + Texture m_whiteTexture; VertexBuffer m_billboardPointBuffer; VertexBuffer m_spriteBuffer; diff --git a/include/Nazara/Graphics/ForwardRenderQueue.hpp b/include/Nazara/Graphics/ForwardRenderQueue.hpp index 7f88e80bf..99be2743e 100644 --- a/include/Nazara/Graphics/ForwardRenderQueue.hpp +++ b/include/Nazara/Graphics/ForwardRenderQueue.hpp @@ -47,6 +47,16 @@ namespace Nz void Sort(const AbstractViewer* viewer); + struct MaterialComparator + { + bool operator()(const Material* mat1, const Material* mat2) const; + }; + + struct MaterialPipelineComparator + { + bool operator()(const MaterialPipeline* pipeline1, const MaterialPipeline* pipeline2) const; + }; + /// Billboards struct BillboardData { @@ -56,11 +66,6 @@ namespace Nz Vector2f sinCos; }; - struct BatchedBillboardComparator - { - bool operator()(const Material* mat1, const Material* mat2) const; - }; - struct BatchedBillboardEntry { NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot); @@ -68,7 +73,15 @@ namespace Nz std::vector billboards; }; - typedef std::map BatchedBillboardContainer; + typedef std::map BatchedBillboardContainer; + + struct BatchedBillboardPipelineEntry + { + BatchedBillboardContainer materialMap; + bool enabled = false; + }; + + typedef std::map BillboardPipelineBatches; /// Sprites struct SpriteChain_XYZ_Color_UV @@ -84,22 +97,25 @@ namespace Nz std::vector spriteChains; }; - struct BatchedSpriteMaterialComparator - { - bool operator()(const Material* mat1, const Material* mat2); - }; - - typedef std::map BasicSpriteOverlayContainer; + typedef std::map SpriteOverlayBatches; struct BatchedBasicSpriteEntry { NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot); - BasicSpriteOverlayContainer overlayMap; + SpriteOverlayBatches overlayMap; bool enabled = false; }; - typedef std::map BasicSpriteBatches; + typedef std::map SpriteMaterialBatches; + + struct BatchedSpritePipelineEntry + { + SpriteMaterialBatches materialMap; + bool enabled = false; + }; + + typedef std::map SpritePipelineBatches; /// Meshes struct MeshDataComparator @@ -118,21 +134,23 @@ namespace Nz typedef std::map MeshInstanceContainer; - struct BatchedModelMaterialComparator - { - bool operator()(const Material* mat1, const Material* mat2) const; - }; - struct BatchedModelEntry { NazaraSlot(Material, OnMaterialRelease, materialReleaseSlot); MeshInstanceContainer meshMap; bool enabled = false; - bool instancingEnabled = false; }; - typedef std::map ModelBatches; + typedef std::map MeshMaterialBatches; + + struct BatchedMaterialEntry + { + std::size_t maxInstanceCount = 0; + MeshMaterialBatches materialMap; + }; + + typedef std::map MeshPipelineBatches; struct TransparentModelData { @@ -146,9 +164,9 @@ namespace Nz struct Layer { - BatchedBillboardContainer billboards; - BasicSpriteBatches basicSprites; - ModelBatches opaqueModels; + BillboardPipelineBatches billboards; + SpritePipelineBatches basicSprites; + MeshPipelineBatches opaqueModels; TransparentModelContainer transparentModels; std::vector transparentModelData; std::vector otherDrawables; diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index 21b3a0899..5d82c4bf9 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -84,6 +84,7 @@ namespace Nz mutable std::vector m_lights; Buffer m_vertexBuffer; mutable ForwardRenderQueue m_renderQueue; + Texture m_whiteTexture; VertexBuffer m_billboardPointBuffer; VertexBuffer m_spriteBuffer; unsigned int m_maxLightPassPerObject; diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index b30c215c1..f7d15d6fe 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -58,20 +58,33 @@ namespace Nz public: inline Material(); + inline Material(const MaterialPipeline* pipeline); + inline Material(const MaterialPipelineInfo& pipelineInfo); + inline Material(const String& pipelineName); inline Material(const Material& material); inline ~Material(); - const Shader* Apply(UInt32 shaderFlags = 0, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const; + void Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit = 0, UInt8* lastUsedUnit = nullptr) const; void BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams = MaterialParams()); - inline void Enable(RendererParameter renderParameter, bool enable); + inline void Configure(const MaterialPipeline* pipeline); + inline void Configure(const MaterialPipelineInfo& pipelineInfo); + inline bool Configure(const String& pipelineName); + inline void EnableAlphaTest(bool alphaTest); + inline void EnableBlending(bool blending); + inline void EnableColorWrite(bool colorWrite); + inline void EnableDepthBuffer(bool depthBuffer); inline void EnableDepthSorting(bool depthSorting); - inline void EnableLighting(bool lighting); + inline void EnableDepthWrite(bool depthWrite); + inline void EnableFaceCulling(bool faceCulling); + inline void EnableScissorTest(bool scissorTest); inline void EnableShadowCasting(bool castShadows); inline void EnableShadowReceive(bool receiveShadows); - inline void EnableTransform(bool transform); + inline void EnableStencilTest(bool stencilTest); + + inline void EnsurePipelineUpdate() const; inline const TextureRef& GetAlphaMap() const; inline float GetAlphaThreshold() const; @@ -87,10 +100,12 @@ namespace Nz inline FaceSide GetFaceCulling() const; inline FaceFilling GetFaceFilling() const; inline const TextureRef& GetHeightMap() const; + inline float GetLineWidth() const; inline const TextureRef& GetNormalMap() const; - inline const RenderStates& GetRenderStates() const; + inline const MaterialPipeline* GetPipeline() const; + inline const MaterialPipelineInfo& GetPipelineInfo() const; + inline float GetPointSize() const; inline const UberShader* GetShader() const; - inline const UberShaderInstance* GetShaderInstance(UInt32 flags = ShaderFlags_None) const; inline float GetShininess() const; inline Color GetSpecularColor() const; inline const TextureRef& GetSpecularMap() const; @@ -107,12 +122,16 @@ namespace Nz inline bool HasSpecularMap() const; inline bool IsAlphaTestEnabled() const; + inline bool IsBlendingEnabled() const; + inline bool IsColorWriteEnabled() const; + inline bool IsDepthBufferEnabled() const; inline bool IsDepthSortingEnabled() const; - inline bool IsEnabled(RendererParameter renderParameter) const; - inline bool IsLightingEnabled() const; + inline bool IsDepthWriteEnabled() const; + inline bool IsFaceCullingEnabled() const; + inline bool IsScissorTestEnabled() const; + inline bool IsStencilTestEnabled() const; inline bool IsShadowCastingEnabled() const; inline bool IsShadowReceiveEnabled() const; - inline bool IsTransformEnabled() const; inline bool LoadFromFile(const String& filePath, const MaterialParams& params = MaterialParams()); inline bool LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params = MaterialParams()); @@ -139,9 +158,10 @@ namespace Nz inline void SetFaceFilling(FaceFilling filling); inline bool SetHeightMap(const String& textureName); inline void SetHeightMap(TextureRef textureName); + inline void SetLineWidth(float lineWidth); inline bool SetNormalMap(const String& textureName); inline void SetNormalMap(TextureRef textureName); - inline void SetRenderStates(const RenderStates& states); + inline void SetPointSize(float pointSize); inline void SetShader(UberShaderConstRef uberShader); inline bool SetShader(const String& uberShaderName); inline void SetShininess(float shininess); @@ -161,16 +181,9 @@ namespace Nz NazaraSignal(OnMaterialReset, const Material* /*material*/); private: - struct ShaderInstance - { - const Shader* shader; - UberShaderInstance* uberInstance = nullptr; - int uniforms[MaterialUniform_Max + 1]; - }; - void Copy(const Material& material); - void GenerateShader(UInt32 flags) const; - inline void InvalidateShaders(); + inline void InvalidatePipeline(); + inline void UpdatePipeline() const; static bool Initialize(); static void Uninitialize(); @@ -179,7 +192,8 @@ namespace Nz Color m_diffuseColor; Color m_specularColor; MaterialRef m_depthMaterial; //< Materialception - RenderStates m_states; + mutable const MaterialPipeline* m_pipeline; + MaterialPipelineInfo m_pipelineInfo; TextureSampler m_diffuseSampler; TextureSampler m_specularSampler; TextureRef m_alphaMap; @@ -188,14 +202,8 @@ namespace Nz TextureRef m_heightMap; TextureRef m_normalMap; TextureRef m_specularMap; - UberShaderConstRef m_uberShader; - mutable ShaderInstance m_shaders[ShaderFlags_Max + 1]; - bool m_alphaTestEnabled; - bool m_depthSortingEnabled; - bool m_lightingEnabled; + mutable bool m_pipelineUpdated; bool m_shadowCastingEnabled; - bool m_shadowReceiveEnabled; - bool m_transformEnabled; float m_alphaThreshold; float m_shininess; diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index 6d5315640..cec965e6e 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -2,26 +2,74 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include namespace Nz { /*! - * \brief Constructs a Material object by default + * \brief Constructs a Material object with default states + * + * \see Reset */ - inline Material::Material() { Reset(); } + /*! + * \brief Constructs a Material object using a MaterialPipeline + * + * Calls Configure with the pipeline parameter + * + * \see Configure + */ + inline Material::Material(const MaterialPipeline* pipeline) + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + Reset(); + Configure(pipeline); + } + + /*! + * \brief Constructs a Material object using a MaterialPipelineInfo + * + * Calls Configure with the pipelineInfo parameter + * + * \see Configure + */ + inline Material::Material(const MaterialPipelineInfo& pipelineInfo) + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + Reset(); + Configure(pipelineInfo); + } + + /*! + * \brief Constructs a Material object using a MaterialPipeline name + * + * Calls Configure with the pipelineName parameter + * + * \remark In case of error (ie. named pipeline is not registered), throw an exception + * + * \see Configure + */ + inline Material::Material(const String& pipelineName) + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + Reset(); + Configure(pipelineName); + } + /*! * \brief Constructs a Material object by assignation * * \param material Material to copy into this */ - inline Material::Material(const Material& material) : RefCounted(), Resource(material) @@ -34,156 +82,325 @@ namespace Nz * * \see OnMaterialRelease */ - inline Material::~Material() { OnMaterialRelease(this); } /*! - * \brief Enables a renderer parameter + * \brief Reset material pipeline state * - * \param renderParameter Parameter for the rendering - * \param enable Should the parameter be enabled + * Sets the material pipeline * - * \remark Produces a NazaraAssert if enumeration is invalid + * \remark pipeline must be valid + * + * \see Configure */ - - inline void Material::Enable(RendererParameter renderParameter, bool enable) + inline void Material::Configure(const MaterialPipeline* pipeline) { - NazaraAssert(renderParameter <= RendererParameter_Max, "Renderer parameter out of enum"); + NazaraAssert(pipeline, "Invalid material pipeline"); - switch (renderParameter) - { - case RendererParameter_Blend: - m_states.blending = enable; - return; - - case RendererParameter_ColorWrite: - m_states.colorWrite = enable; - return; - - case RendererParameter_DepthBuffer: - m_states.depthBuffer = enable; - return; - - case RendererParameter_DepthWrite: - m_states.depthWrite = enable; - return; - - case RendererParameter_FaceCulling: - m_states.faceCulling = enable; - return; - - case RendererParameter_ScissorTest: - m_states.scissorTest = enable; - return; - - case RendererParameter_StencilTest: - m_states.stencilTest = enable; - return; - } + m_pipeline = pipeline; + m_pipelineInfo = m_pipeline->GetInfo(); + m_pipelineUpdated = true; } /*! - * \brief Enables the alpha test + * \brief Reset material pipeline state * - * \param alphaTest Should the parameter be enabled + * Sets the material pipeline using pipeline info * - * \remark Invalidates the shaders + * \remark pipeline must be valid + * + * \see Configure */ + inline void Material::Configure(const MaterialPipelineInfo& pipelineInfo) + { + m_pipelineInfo = pipelineInfo; + InvalidatePipeline(); + } + + /*! + * \brief Reset material pipeline state + * + * Sets the material pipeline using a name to lookup in the MaterialPipelineLibrary + * + * \return True if the material pipeline was found in the library + * + * \see Configure + */ + inline bool Material::Configure(const String& pipelineName) + { + MaterialPipelineRef pipeline = MaterialPipelineLibrary::Query(pipelineName); + if (!pipeline) + { + NazaraError("Failed to get pipeline \"" + pipelineName + "\""); + return false; + } + + Configure(std::move(pipeline)); + return true; + } + + /*! + * \brief Enable/Disable alpha test for this material + * + * When enabled, all objects using this material will be rendered using alpha testing, + * rejecting pixels if their alpha component is under a defined threshold. + * This allows some kind of transparency with a much cheaper cost as it doesn't prevent any optimization (as deferred rendering or batching). + * + * \param alphaTest Defines if this material will use alpha testing + * + * \remark Invalidates the pipeline + * + * \see IsAlphaTestEnabled + * \see SetAlphaThreshold + */ inline void Material::EnableAlphaTest(bool alphaTest) { - m_alphaTestEnabled = alphaTest; + m_pipelineInfo.alphaTest = alphaTest; - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Enables the depth sorting + * \brief Enable/Disable blending for this material * - * \param depthSorting Should the parameter be enabled + * When enabled, all objects using this material will be rendered using blending, obeying the dstBlend and srcBlend parameters + * This is useful with translucent objects, but will reduces performance as it prevents some optimizations (as deferred rendering) + * + * \param blending Defines if this material will use blending + * + * \remark Invalidates the pipeline + * + * \see IsBlendingEnabled + * \see SetDstBlend + * \see SetSrcBlend */ + inline void Material::EnableBlending(bool blending) + { + m_pipelineInfo.blending = blending; + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable color writing for this material + * + * \param colorWrite Defines if this material will use color writing + * + * \remark Invalidates the pipeline + * + * \see IsColorWritingEnabled + */ + inline void Material::EnableColorWrite(bool colorWrite) + { + m_pipelineInfo.colorWrite = colorWrite; + + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable depth buffer for this material + * + * When enabled, all objects using this material will be rendered using a depth buffer, if the RenderTarget has one. + * This will enable Depth Test, preventing further fragments to render on top of closer ones. + * + * This parameter is required for depth writing. + * + * In order to enable depth writing without enabling depth test, set the depth comparison function to RendererComparison_Never + * + * \param depthBuffer Defines if this material will use depth buffer + * + * \remark Invalidates the pipeline + * + * \see EnableDepthWrite + * \see IsDepthBufferEnabled + * \see SetDepthFunc + */ + inline void Material::EnableDepthBuffer(bool depthBuffer) + { + m_pipelineInfo.depthBuffer = depthBuffer; + + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable depth sorting for this material + * + * When enabled, all objects using this material will be rendered far from near + * This is useful with translucent objects, but will reduces performance as it breaks batching + * + * \param depthSorting Defines if this material will use depth sorting + * + * \remark Depth sorting may not be perfect (may be object-sorting instead of triangle-sorting) + * \remark Invalidates the pipeline + * + * \see IsDepthSortingEnabled + */ inline void Material::EnableDepthSorting(bool depthSorting) { - // Has no influence on shaders - m_depthSortingEnabled = depthSorting; + m_pipelineInfo.depthSorting = depthSorting; + + InvalidatePipeline(); } /*! - * \brief Enables the lighting + * \brief Enable/Disable depth writing for this material * - * \param lighting Should the parameter be enabled + * When enabled, and if depth buffer is enabled and present, all fragments generated with this material will write + * to the depth buffer if they pass depth test. * - * \remark Invalidates the shaders + * This is usually disabled with translucent objects, as depth test is wanted to prevent them from rendering on top of opaque objects but + * not depth writing (which could make other translucent fragments to fail depth test) + * + * \param depthBuffer Defines if this material will use depth write + * + * \remark Invalidates the pipeline + * + * \see EnableDepthBuffer + * \see IsDepthWriteEnabled */ - - inline void Material::EnableLighting(bool lighting) + inline void Material::EnableDepthWrite(bool depthWrite) { - m_lightingEnabled = lighting; + m_pipelineInfo.depthWrite = depthWrite; - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Enables the shadow casting + * \brief Enable/Disable face culling for this material * - * \param castShadows Should shadow casting be enabled + * When enabled, the material prevents front and/or back faces from rendering. + * This is commonly used as an optimization to prevent processing of hidden faces by the rendering device. + * + * Use SetFaceCulling to control which side will be eliminated. + * + * \param faceCulling Defines if this material will use face culling + * + * \remark Invalidates the pipeline + * + * \see IsFaceCullingEnabled + * \see SetFaceCulling */ + inline void Material::EnableFaceCulling(bool faceCulling) + { + m_pipelineInfo.faceCulling = faceCulling; + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable scissor test for this material + * + * When enabled, the material prevents fragments out of the scissor box to be rendered. + * This can be useful with GUI, where widgets must not be rendered outside of their parent rendering area. + * + * \param scissorTest Defines if this material will use scissor test + * + * \remark Invalidates the pipeline + * + * \see IsScissorTestEnabled + */ + inline void Material::EnableScissorTest(bool scissorTest) + { + m_pipelineInfo.scissorTest = scissorTest; + + InvalidatePipeline(); + } + + /*! + * \brief Enable/Disable shadow casting for this material + * + * When enabled, all objects using this material will be allowed to cast shadows upon any objects using a material with shadow receiving enabled. + * The depth material replaces this one when rendering shadows. + * + * \param castShadows Defines if this material will be allowed to cast shadows + * + * \remark Does not invalidate the pipeline + * + * \see EnableShadowReceive + * \see IsShadowCastingEnabled + * \see SetDepthMaterial + */ inline void Material::EnableShadowCasting(bool castShadows) { - // Has no influence on shaders + // Has no influence on pipeline m_shadowCastingEnabled = castShadows; } /*! - * \brief Enables the shadow on receiving object + * \brief Enable/Disable shadow receiving for this material * - * \param receiveShadow Should receiving object have shadows enabled + * When enabled, all objects using this material will be allowed to be casted shadows upon themselves + * Disabling this can be helpful to prevent some rendering artifacts (especially with translucent objects) * - * \remark Invalidates the shaders + * \param receiveShadows Defines if this material will be able to receive shadows + * + * \remark Invalidates the pipeline + * + * \see IsShadowReceiveEnabled */ - inline void Material::EnableShadowReceive(bool receiveShadows) { - m_shadowReceiveEnabled = receiveShadows; + m_pipelineInfo.shadowReceive = receiveShadows; - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Enables the transformation + * \brief Enable/Disable stencil test for this material * - * \param transform Should the parameter be enabled + * When enabled, all fragments must pass the stencil test to be rendered. * - * \remark Invalidates the shaders + * \param scissorTest Defines if this material will use stencil test + * + * \remark Invalidates the pipeline + * + * \see IsStencilTestEnabled */ - - inline void Material::EnableTransform(bool transform) + inline void Material::EnableStencilTest(bool stencilTest) { - m_transformEnabled = transform; + m_pipelineInfo.stencilTest = stencilTest; - InvalidateShaders(); + InvalidatePipeline(); + } + + /*! + * \brief Ensures the pipeline gets updated + * + * When the pipeline gets invalidated, it's not updated until required (per example by calling GetPipeline). + * Using this function forces the pipeline update, making GetPipeline thread-safe as long as the pipeline does not get invalidated. + * + * \see GetPipeline + */ + inline void Material::EnsurePipelineUpdate() const + { + if (!m_pipelineUpdated) + UpdatePipeline(); } /*! * \brief Gets the alpha map + * * \return Constant reference to the current texture + * + * \see SetAlphaMap */ - inline const TextureRef& Material::GetAlphaMap() const { return m_alphaMap; } /*! - * \brief Gets the alpha threshold - * \return The threshold value for the alpha + * \brief Gets the alpha test threshold + * + * \return The threshold value for the alpha test + * + * \see EnableAlphaTest + * \see SetAlphaThreshold */ - inline float Material::GetAlphaThreshold() const { return m_alphaThreshold; @@ -191,9 +408,11 @@ namespace Nz /*! * \brief Gets the ambient color + * * \return Ambient color + * + * \see SetAmbientColor */ - inline Color Material::GetAmbientColor() const { return m_ambientColor; @@ -201,19 +420,24 @@ namespace Nz /*! * \brief Gets the function to compare depth + * * \return Function comparing the depth of two materials + * + * \see EnableDepthTest + * \see SetAmbientColor */ - inline RendererComparison Material::GetDepthFunc() const { - return m_states.depthFunc; + return m_pipelineInfo.depthFunc; } /*! * \brief Gets the depth material + * * \return Constant reference to the depth material + * + * \see EnableShadowCasting */ - inline const MaterialRef& Material::GetDepthMaterial() const { return m_depthMaterial; @@ -221,9 +445,11 @@ namespace Nz /*! * \brief Gets the diffuse color + * * \return Diffuse color + * + * \see SetDiffuseColor */ - inline Color Material::GetDiffuseColor() const { return m_diffuseColor; @@ -231,9 +457,11 @@ namespace Nz /*! * \brief Gets the diffuse sampler + * * \return Reference to the current texture sampler for the diffuse + * + * \see SetDiffuseSampler */ - inline TextureSampler& Material::GetDiffuseSampler() { return m_diffuseSampler; @@ -241,9 +469,11 @@ namespace Nz /*! * \brief Gets the diffuse sampler + * * \return Constant reference to the current texture sampler for the diffuse + * + * \see SetDiffuseSampler */ - inline const TextureSampler& Material::GetDiffuseSampler() const { return m_diffuseSampler; @@ -251,9 +481,11 @@ namespace Nz /*! * \brief Gets the diffuse map + * * \return Constant reference to the texture + * + * \see SetDiffuseMap */ - const TextureRef& Material::GetDiffuseMap() const { return m_diffuseMap; @@ -261,19 +493,23 @@ namespace Nz /*! * \brief Gets the dst in blend + * * \return Function for dst blending + * + * \see SetDstBlend */ - inline BlendFunc Material::GetDstBlend() const { - return m_states.dstBlend; + return m_pipelineInfo.dstBlend; } /*! * \brief Gets the emissive map + * * \return Constant reference to the texture + * + * \see SetEmissiveMap */ - inline const TextureRef& Material::GetEmissiveMap() const { return m_emissiveMap; @@ -281,34 +517,43 @@ namespace Nz /*! * \brief Gets the face culling + * * \return Current face culling side + * + * \see SetFaceCulling */ - inline FaceSide Material::GetFaceCulling() const { - return m_states.cullingSide; + return m_pipelineInfo.cullingSide; } /*! * \brief Gets the face filling * \return Current face filling */ - inline FaceFilling Material::GetFaceFilling() const { - return m_states.faceFilling; + return m_pipelineInfo.faceFilling; } /*! * \brief Gets the height map * \return Constant reference to the texture */ - inline const TextureRef& Material::GetHeightMap() const { return m_heightMap; } + /*! + * \brief Gets the line width of this material + * \return Line width + */ + inline float Material::GetLineWidth() const + { + return m_pipelineInfo.lineWidth; + } + /*! * \brief Gets the normal map * \return Constant reference to the texture @@ -323,43 +568,44 @@ namespace Nz * \brief Gets the render states * \return Constant reference to the render states */ - - inline const RenderStates& Material::GetRenderStates() const + inline const MaterialPipeline* Material::GetPipeline() const { - return m_states; + EnsurePipelineUpdate(); + + return m_pipeline; } /*! - * \brief Gets the shader of this material - * \return Constant pointer to the ubershader used + * \brief Gets the pipeline informations + * \return Constant reference to the pipeline info */ + inline const MaterialPipelineInfo& Material::GetPipelineInfo() const + { + return m_pipelineInfo; + } + /*! + * \brief Gets the point size of this material + * \return Point size + */ + inline float Material::GetPointSize() const + { + return m_pipelineInfo.pointSize; + } + + /*! + * \brief Gets the über-shader used by this material + * \return Constant pointer to the über-shader used + */ inline const UberShader* Material::GetShader() const { - return m_uberShader; - } - - /*! - * \brief Gets the shader instance based on the flag - * \return Constant pointer to the ubershader instance - * - * \param flags Flag of the shader - */ - - inline const UberShaderInstance* Material::GetShaderInstance(UInt32 flags) const - { - const ShaderInstance& instance = m_shaders[flags]; - if (!instance.uberInstance) - GenerateShader(flags); - - return instance.uberInstance; + return m_pipelineInfo.uberShader; } /*! * \brief Gets the shininess * \return Current shininess */ - inline float Material::GetShininess() const { return m_shininess; @@ -369,7 +615,6 @@ namespace Nz * \brief Gets the specular color * \return Specular color */ - inline Color Material::GetSpecularColor() const { return m_specularColor; @@ -379,7 +624,6 @@ namespace Nz * \brief Gets the specular map * \return Constant reference to the texture */ - inline const TextureRef& Material::GetSpecularMap() const { return m_specularMap; @@ -389,7 +633,6 @@ namespace Nz * \brief Gets the specular sampler * \return Reference to the current texture sampler for the specular */ - inline TextureSampler& Material::GetSpecularSampler() { return m_specularSampler; @@ -399,7 +642,6 @@ namespace Nz * \brief Gets the specular sampler * \return Constant reference to the current texture sampler for the specular */ - inline const TextureSampler& Material::GetSpecularSampler() const { return m_specularSampler; @@ -409,17 +651,15 @@ namespace Nz * \brief Gets the src in blend * \return Function for src blending */ - inline BlendFunc Material::GetSrcBlend() const { - return m_states.srcBlend; + return m_pipelineInfo.srcBlend; } /*! * \brief Checks whether this material has an alpha map * \return true If it is the case */ - inline bool Material::HasAlphaMap() const { return m_alphaMap.IsValid(); @@ -429,7 +669,6 @@ namespace Nz * \brief Checks whether this material has a depth material * \return true If it is the case */ - inline bool Material::HasDepthMaterial() const { return m_depthMaterial.IsValid(); @@ -439,7 +678,6 @@ namespace Nz * \brief Checks whether this material has a diffuse map * \return true If it is the case */ - inline bool Material::HasDiffuseMap() const { return m_diffuseMap.IsValid(); @@ -449,7 +687,6 @@ namespace Nz * \brief Checks whether this material has a emissive map * \return true If it is the case */ - inline bool Material::HasEmissiveMap() const { return m_emissiveMap.IsValid(); @@ -459,7 +696,6 @@ namespace Nz * \brief Checks whether this material has a height map * \return true If it is the case */ - inline bool Material::HasHeightMap() const { return m_heightMap.IsValid(); @@ -469,7 +705,6 @@ namespace Nz * \brief Checks whether this material has a normal map * \return true If it is the case */ - inline bool Material::HasNormalMap() const { return m_normalMap.IsValid(); @@ -479,7 +714,6 @@ namespace Nz * \brief Checks whether this material has a specular map * \return true If it is the case */ - inline bool Material::HasSpecularMap() const { return m_specularMap.IsValid(); @@ -489,78 +723,87 @@ namespace Nz * \brief Checks whether this material has alpha test enabled * \return true If it is the case */ - inline bool Material::IsAlphaTestEnabled() const { - return m_alphaTestEnabled; + return m_pipelineInfo.alphaTest; + } + + /*! + * \brief Checks whether this material has blending enabled + * \return true If it is the case + */ + inline bool Material::IsBlendingEnabled() const + { + return m_pipelineInfo.blending; + } + + /*! + * \brief Checks whether this material has color write enabled + * \return true If it is the case + */ + inline bool Material::IsColorWriteEnabled() const + { + return m_pipelineInfo.colorWrite; + } + + /*! + * \brief Checks whether this material has depth buffer enabled + * \return true If it is the case + */ + inline bool Material::IsDepthBufferEnabled() const + { + return m_pipelineInfo.depthBuffer; } /*! * \brief Checks whether this material has depth sorting enabled * \return true If it is the case */ - inline bool Material::IsDepthSortingEnabled() const { - return m_depthSortingEnabled; + return m_pipelineInfo.depthSorting; } /*! - * \brief Checks whether this material has the render parameter enabled + * \brief Checks whether this material has depth writing enabled * \return true If it is the case - * - * \param parameter Parameter for the rendering - * - * \remark Produces a NazaraAssert if enumeration is invalid */ - - inline bool Material::IsEnabled(RendererParameter parameter) const + inline bool Material::IsDepthWriteEnabled() const { - NazaraAssert(parameter <= RendererParameter_Max, "Renderer parameter out of enum"); - - switch (parameter) - { - case RendererParameter_Blend: - return m_states.blending; - - case RendererParameter_ColorWrite: - return m_states.colorWrite; - - case RendererParameter_DepthBuffer: - return m_states.depthBuffer; - - case RendererParameter_DepthWrite: - return m_states.depthWrite; - - case RendererParameter_FaceCulling: - return m_states.faceCulling; - - case RendererParameter_ScissorTest: - return m_states.scissorTest; - - case RendererParameter_StencilTest: - return m_states.stencilTest; - } - - NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); - return false; + return m_pipelineInfo.depthWrite; } /*! - * \brief Checks whether this material has lightning enabled + * \brief Checks whether this material has face culling enabled * \return true If it is the case */ - - inline bool Material::IsLightingEnabled() const + inline bool Material::IsFaceCullingEnabled() const { - return m_lightingEnabled; + return m_pipelineInfo.faceCulling; + } + + /*! + * \brief Checks whether this material has scissor test enabled + * \return true If it is the case + */ + inline bool Material::IsScissorTestEnabled() const + { + return m_pipelineInfo.scissorTest; + } + + /*! + * \brief Checks whether this material has stencil test enabled + * \return true If it is the case + */ + inline bool Material::IsStencilTestEnabled() const + { + return m_pipelineInfo.stencilTest; } /*! * \brief Checks whether this material cast shadow * \return true If it is the case */ - inline bool Material::IsShadowCastingEnabled() const { return m_shadowCastingEnabled; @@ -570,20 +813,9 @@ namespace Nz * \brief Checks whether this material receive shadow * \return true If it is the case */ - inline bool Material::IsShadowReceiveEnabled() const { - return m_shadowReceiveEnabled; - } - - /*! - * \brief Checks whether this material has transformation enabled - * \return true If it is the case - */ - - inline bool Material::IsTransformEnabled() const - { - return m_transformEnabled; + return m_pipelineInfo.shadowReceive; } /*! @@ -593,7 +825,6 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the material */ - inline bool Material::LoadFromFile(const String& filePath, const MaterialParams& params) { return MaterialLoader::LoadFromFile(this, filePath, params); @@ -607,7 +838,6 @@ namespace Nz * \param size Size of the memory * \param params Parameters for the material */ - inline bool Material::LoadFromMemory(const void* data, std::size_t size, const MaterialParams& params) { return MaterialLoader::LoadFromMemory(this, data, size, params); @@ -620,7 +850,6 @@ namespace Nz * \param stream Stream to the material * \param params Parameters for the material */ - inline bool Material::LoadFromStream(Stream& stream, const MaterialParams& params) { return MaterialLoader::LoadFromStream(this, stream, params); @@ -632,7 +861,6 @@ namespace Nz * * \param textureName Named texture */ - inline bool Material::SetAlphaMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -656,14 +884,14 @@ namespace Nz * * \param alphaMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline */ - inline void Material::SetAlphaMap(TextureRef alphaMap) { m_alphaMap = std::move(alphaMap); + m_pipelineInfo.hasAlphaMap = m_alphaMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! @@ -671,7 +899,6 @@ namespace Nz * * \param alphaThreshold Threshold for the alpha */ - inline void Material::SetAlphaThreshold(float alphaThreshold) { m_alphaThreshold = alphaThreshold; @@ -682,7 +909,6 @@ namespace Nz * * \param ambient Color for ambient */ - inline void Material::SetAmbientColor(const Color& ambient) { m_ambientColor = ambient; @@ -692,11 +918,14 @@ namespace Nz * \brief Sets the depth functor * * \param depthFunc + * + * \remark Invalidates the pipeline */ - inline void Material::SetDepthFunc(RendererComparison depthFunc) { - m_states.depthFunc = depthFunc; + m_pipelineInfo.depthFunc = depthFunc; + + InvalidatePipeline(); } /*! @@ -705,7 +934,6 @@ namespace Nz * * \param depthMaterial Material for depth */ - inline void Material::SetDepthMaterial(MaterialRef depthMaterial) { m_depthMaterial = std::move(depthMaterial); @@ -716,7 +944,6 @@ namespace Nz * * \param diffuse Color for diffuse */ - inline void Material::SetDiffuseColor(const Color& diffuse) { m_diffuseColor = diffuse; @@ -727,8 +954,9 @@ namespace Nz * \return true If successful * * \param textureName Named texture + * + * \remark Invalidates the pipeline */ - inline bool Material::SetDiffuseMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -752,14 +980,14 @@ namespace Nz * * \param diffuseMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline */ - inline void Material::SetDiffuseMap(TextureRef diffuseMap) { m_diffuseMap = std::move(diffuseMap); + m_pipelineInfo.hasDiffuseMap = m_diffuseMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! @@ -777,11 +1005,14 @@ namespace Nz * \brief Sets the dst in blend * * \param func Function for dst blending + * + * \remark Invalidates the pipeline */ - inline void Material::SetDstBlend(BlendFunc func) { - m_states.dstBlend = func; + m_pipelineInfo.dstBlend = func; + + InvalidatePipeline(); } /*! @@ -789,8 +1020,9 @@ namespace Nz * \return true If successful * * \param textureName Named texture + * + * \see GetEmissiveMap */ - inline bool Material::SetEmissiveMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -814,45 +1046,52 @@ namespace Nz * * \param emissiveMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline */ - inline void Material::SetEmissiveMap(TextureRef emissiveMap) { m_emissiveMap = std::move(emissiveMap); + m_pipelineInfo.hasEmissiveMap = m_emissiveMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! * \brief Sets the face culling * * \param faceSide Face to cull + * + * \remark Invalidates the pipeline */ - inline void Material::SetFaceCulling(FaceSide faceSide) { - m_states.cullingSide = faceSide; + m_pipelineInfo.cullingSide = faceSide; + + InvalidatePipeline(); } /*! * \brief Sets the face filling * * \param filling Face to fill + * + * \remark Invalidates the pipeline */ - inline void Material::SetFaceFilling(FaceFilling filling) { - m_states.faceFilling = filling; + m_pipelineInfo.faceFilling = filling; + + InvalidatePipeline(); } /*! - * \brief Sets the height map by name + * \brief Sets the height map by path or name * \return true If successful * * \param textureName Named texture + * + * \see GetHeightMap */ - inline bool Material::SetHeightMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -872,27 +1111,49 @@ namespace Nz /*! * \brief Sets the height map with a reference to a texture - * \return true If successful * * \param heightMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetHeightMap */ - inline void Material::SetHeightMap(TextureRef heightMap) { m_heightMap = std::move(heightMap); + m_pipelineInfo.hasHeightMap = m_heightMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Sets the normal map by name + * \brief Sets the line width for this material + * + * This parameter is used when rendering lines, to define the width (in pixels) the line will take on the framebuffer + * + * \param lineWidth Width of the line + * + * \remark Invalidates the pipeline + * + * \see GetLineWidth + */ + inline void Material::SetLineWidth(float lineWidth) + { + m_pipelineInfo.lineWidth = lineWidth; + + InvalidatePipeline(); + } + + /*! + * \brief Sets the normal map by path or name * \return true If successful * * \param textureName Named texture + * + * \remark Invalidates the pipeline + * + * \see GetNormalMap */ - inline bool Material::SetNormalMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -916,25 +1177,34 @@ namespace Nz * * \param normalMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetNormalMap */ - inline void Material::SetNormalMap(TextureRef normalMap) { m_normalMap = std::move(normalMap); + m_pipelineInfo.hasNormalMap = m_normalMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! - * \brief Sets the render states + * \brief Sets the point size for this material * - * \param states States for the rendering + * This parameter is used when rendering points, to define the size (in pixels) the point will take on the framebuffer + * + * \param pointSize Size of the point + * + * \remark Invalidates the pipeline + * + * \see GetPointSize */ - - inline void Material::SetRenderStates(const RenderStates& states) + inline void Material::SetPointSize(float pointSize) { - m_states = states; + m_pipelineInfo.pointSize = pointSize; + + InvalidatePipeline(); } /*! @@ -942,14 +1212,15 @@ namespace Nz * * \param uberShader Uber shader to apply * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetShader */ - inline void Material::SetShader(UberShaderConstRef uberShader) { - m_uberShader = std::move(uberShader); + m_pipelineInfo.uberShader = std::move(uberShader); - InvalidateShaders(); + InvalidatePipeline(); } /*! @@ -958,7 +1229,6 @@ namespace Nz * * \param uberShaderName Named shader */ - inline bool Material::SetShader(const String& uberShaderName) { UberShaderConstRef uberShader = UberShaderLibrary::Get(uberShaderName); @@ -974,7 +1244,6 @@ namespace Nz * * \param shininess Value of the shininess */ - inline void Material::SetShininess(float shininess) { m_shininess = shininess; @@ -985,7 +1254,6 @@ namespace Nz * * \param specular Color */ - inline void Material::SetSpecularColor(const Color& specular) { m_specularColor = specular; @@ -996,8 +1264,9 @@ namespace Nz * \return true If successful * * \param textureName Named texture + * + * \remark Invalidates the pipeline */ - inline bool Material::SetSpecularMap(const String& textureName) { TextureRef texture = TextureLibrary::Query(textureName); @@ -1021,22 +1290,25 @@ namespace Nz * * \param specularMap Texture * - * \remark Invalidates the shaders + * \remark Invalidates the pipeline + * + * \see GetSpecularMap */ - inline void Material::SetSpecularMap(TextureRef specularMap) { m_specularMap = std::move(specularMap); + m_pipelineInfo.hasSpecularMap = m_specularMap.IsValid(); - InvalidateShaders(); + InvalidatePipeline(); } /*! * \brief Sets the specular sampler * * \param sampler Specular sample + * + * \see GetSpecularSampler */ - inline void Material::SetSpecularSampler(const TextureSampler& sampler) { m_specularSampler = sampler; @@ -1046,11 +1318,16 @@ namespace Nz * \brief Sets the src in blend * * \param func Function for src blending + * + * \remark Invalidates the pipeline + * + * \see GetSrcBlend */ - inline void Material::SetSrcBlend(BlendFunc func) { - m_states.srcBlend = func; + m_pipelineInfo.srcBlend = func; + + InvalidatePipeline(); } /*! @@ -1059,7 +1336,6 @@ namespace Nz * * \param material The other Material */ - inline Material& Material::operator=(const Material& material) { Resource::operator=(material); @@ -1070,22 +1346,25 @@ namespace Nz /*! * \brief Gets the default material + * * \return Reference to the default material + * + * \remark This material should NOT be modified as it would affect all objects using it */ - inline MaterialRef Material::GetDefault() { return s_defaultMaterial; } - /*! - * \brief Invalidates the shaders - */ - - inline void Material::InvalidateShaders() + inline void Material::InvalidatePipeline() { - for (ShaderInstance& instance : m_shaders) - instance.uberInstance = nullptr; + m_pipelineUpdated = false; + } + + inline void Material::UpdatePipeline() const + { + m_pipeline = MaterialPipeline::GetPipeline(m_pipelineInfo); + m_pipelineUpdated = true; } /*! @@ -1094,7 +1373,6 @@ namespace Nz * * \param args Arguments for the material */ - template MaterialRef Material::New(Args&&... args) { @@ -1106,3 +1384,4 @@ namespace Nz } #include +#include "Material.hpp" diff --git a/include/Nazara/Graphics/MaterialPipeline.hpp b/include/Nazara/Graphics/MaterialPipeline.hpp new file mode 100644 index 000000000..cf64d5e40 --- /dev/null +++ b/include/Nazara/Graphics/MaterialPipeline.hpp @@ -0,0 +1,95 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_MATERIALPIPELINE_HPP +#define NAZARA_MATERIALPIPELINE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + struct MaterialPipelineInfo : RenderStates + { + bool alphaTest = false; + bool depthSorting = false; + bool hasAlphaMap = false; + bool hasDiffuseMap = false; + bool hasEmissiveMap = false; + bool hasHeightMap = false; + bool hasNormalMap = false; + bool hasSpecularMap = false; + bool shadowReceive = true; + + UberShaderConstRef uberShader; + }; + + inline bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs); + inline bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs); + + class MaterialPipeline; + + using MaterialPipelineConstRef = ObjectRef; + using MaterialPipelineLibrary = ObjectLibrary; + using MaterialPipelineRef = ObjectRef; + + class NAZARA_GRAPHICS_API MaterialPipeline : public RefCounted + { + friend class Graphics; + friend MaterialPipelineLibrary; + + public: + struct Instance; + + MaterialPipeline(const MaterialPipeline&) = delete; + MaterialPipeline(MaterialPipeline&&) = delete; + ~MaterialPipeline() = default; + + inline const Instance& Apply(UInt32 flags = ShaderFlags_None) const; + + MaterialPipeline& operator=(const MaterialPipeline&) = delete; + MaterialPipeline& operator=(MaterialPipeline&&) = delete; + + inline const MaterialPipelineInfo& GetInfo() const; + inline const Instance& GetInstance(UInt32 flags = ShaderFlags_None) const; + + static MaterialPipelineRef GetPipeline(const MaterialPipelineInfo& pipelineInfo); + + struct Instance + { + RenderPipeline renderPipeline; + UberShaderInstance* uberInstance = nullptr; + std::array uniforms; + }; + + private: + inline MaterialPipeline(const MaterialPipelineInfo& pipelineInfo); + + void GenerateRenderPipeline(UInt32 flags) const; + + static bool Initialize(); + template static MaterialPipelineRef New(Args&&... args); + static void Uninitialize(); + + MaterialPipelineInfo m_pipelineInfo; + mutable std::array m_instances; + + using PipelineCache = std::unordered_map; + static PipelineCache s_pipelineCache; + + static MaterialPipelineLibrary::LibraryMap s_library; + }; +} + +#include + +#endif // NAZARA_MATERIALPIPELINE_HPP diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl new file mode 100644 index 000000000..ebd94a9ee --- /dev/null +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -0,0 +1,143 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + inline MaterialPipeline::MaterialPipeline(const MaterialPipelineInfo& pipelineInfo) : + m_pipelineInfo(pipelineInfo) + { + } + + /*! + * \brief Enable pipeline states for rendering + * + * \param flags Shader flags + */ + inline const MaterialPipeline::Instance& MaterialPipeline::Apply(UInt32 flags) const + { + const Instance& instance = GetInstance(flags); + instance.uberInstance->Activate(); + + Renderer::SetRenderStates(m_pipelineInfo); + + return instance; + } + + /*! + * \brief Retrieve a MaterialPipelineInfo object describing this pipeline + * + * \return Pipeline informations + */ + const MaterialPipelineInfo& MaterialPipeline::GetInfo() const + { + return m_pipelineInfo; + } + + /*! + * \brief Retrieve (and generate if required) a pipeline instance using shader flags without applying it + * + * \param flags Shader flags + * + * \return Pipeline instance + */ + inline const MaterialPipeline::Instance& MaterialPipeline::GetInstance(UInt32 flags) const + { + const Instance& instance = m_instances[flags]; + if (!instance.uberInstance) + GenerateRenderPipeline(flags); + + return instance; + } + + bool operator==(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs) + { + if (!operator==(static_cast(lhs), static_cast(rhs))) + return false; + + #define NazaraPipelineMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraPipelineBoolMember NazaraPipelineMember + + NazaraPipelineBoolMember(alphaTest); + NazaraPipelineBoolMember(depthSorting); + NazaraPipelineBoolMember(hasAlphaMap); + NazaraPipelineBoolMember(hasDiffuseMap); + NazaraPipelineBoolMember(hasEmissiveMap); + NazaraPipelineBoolMember(hasHeightMap); + NazaraPipelineBoolMember(hasNormalMap); + NazaraPipelineBoolMember(hasSpecularMap); + NazaraPipelineBoolMember(shadowReceive); + + NazaraPipelineMember(uberShader); + + #undef NazaraPipelineMember + #undef NazaraPipelineBoolMember + + return true; + } + + bool operator!=(const MaterialPipelineInfo& lhs, const MaterialPipelineInfo& rhs) + { + return !operator==(lhs, rhs); + } + + /*! + * \brief Creates a new MaterialPipeline from the arguments + * \return A reference to the newly created material pipeline + * + * \param args Arguments for the material pipeline + */ + template + MaterialPipelineRef MaterialPipeline::New(Args&&... args) + { + std::unique_ptr object(new MaterialPipeline(std::forward(args)...)); + return object.release(); + } +} + +namespace std +{ + template<> + struct hash + { + size_t operator()(const Nz::MaterialPipelineInfo& pipelineInfo) const + { + hash parentHash; + + std::size_t seed = parentHash(pipelineInfo); + + Nz::UInt16 parameterHash = 0; + Nz::UInt16 parameterIndex = 0; + + #define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.##member) + #define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + + NazaraPipelineBoolMember(alphaTest); + NazaraPipelineBoolMember(depthSorting); + NazaraPipelineBoolMember(hasAlphaMap); + NazaraPipelineBoolMember(hasDiffuseMap); + NazaraPipelineBoolMember(hasEmissiveMap); + NazaraPipelineBoolMember(hasHeightMap); + NazaraPipelineBoolMember(hasNormalMap); + NazaraPipelineBoolMember(hasSpecularMap); + NazaraPipelineBoolMember(shadowReceive); + + NazaraPipelineMember(uberShader); + + #undef NazaraPipelineMember + #undef NazaraPipelineBoolMember + + Nz::HashCombine(seed, parameterHash); + + return seed; + } + }; +} + +#include diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 840a930e6..f0e05c5a2 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -123,8 +123,7 @@ namespace Nz inline void Sprite::SetDefaultMaterial() { MaterialRef material = Material::New(); - material->Enable(RendererParameter_FaceCulling, false); - material->EnableLighting(false); + material->EnableFaceCulling(false); SetMaterial(std::move(material)); } diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index baeeb50db..2ed880a38 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -119,10 +119,9 @@ namespace Nz inline void TextSprite::SetDefaultMaterial() { MaterialRef material = Material::New(); - material->Enable(RendererParameter_Blend, true); - material->Enable(RendererParameter_DepthWrite, false); - material->Enable(RendererParameter_FaceCulling, false); - material->EnableLighting(false); + material->EnableBlending(true); + material->EnableDepthWrite(false); + material->EnableFaceCulling(false); material->SetDstBlend(BlendFunc_InvSrcAlpha); material->SetSrcBlend(BlendFunc_SrcAlpha); diff --git a/include/Nazara/Renderer/RenderPipeline.hpp b/include/Nazara/Renderer/RenderPipeline.hpp new file mode 100644 index 000000000..aee5584b7 --- /dev/null +++ b/include/Nazara/Renderer/RenderPipeline.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERPIPELINE_HPP +#define NAZARA_RENDERPIPELINE_HPP + +#include +#include +#include + +namespace Nz +{ + struct RenderPipelineInfo : RenderStates + { + ShaderConstRef shader; + }; + + class RenderPipeline + { + public: + inline RenderPipeline(); + inline ~RenderPipeline(); + + inline bool Create(const RenderPipelineInfo& pipelineInfo); + inline void Destroy(); + + inline const RenderPipelineInfo& GetInfo() const; + + inline bool IsValid() const; + + private: + RenderPipelineInfo m_pipelineInfo; + bool m_valid; + }; +} + +#include + +#endif // NAZARA_RENDERPIPELINE_HPP diff --git a/include/Nazara/Renderer/RenderPipeline.inl b/include/Nazara/Renderer/RenderPipeline.inl new file mode 100644 index 000000000..5982b0562 --- /dev/null +++ b/include/Nazara/Renderer/RenderPipeline.inl @@ -0,0 +1,48 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline RenderPipeline::RenderPipeline() : + m_valid(false) + { + } + + inline RenderPipeline::~RenderPipeline() + { + } + + inline bool RenderPipeline::Create(const RenderPipelineInfo& pipelineInfo) + { + NazaraAssert(pipelineInfo.shader, "Invalid shader"); + + m_pipelineInfo = pipelineInfo; + m_valid = true; + + return true; + } + + inline void RenderPipeline::Destroy() + { + m_valid = false; + } + + inline const RenderPipelineInfo& RenderPipeline::GetInfo() const + { + NazaraAssert(m_valid, "Invalid pipeline info"); + + return m_pipelineInfo; + } + + inline bool RenderPipeline::IsValid() const + { + return m_valid; + } +} + +#include diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index a885b2a7d..fc4d10eeb 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -7,8 +7,8 @@ #ifndef NAZARA_RENDERSTATES_HPP #define NAZARA_RENDERSTATES_HPP +#include #include -#include namespace Nz { @@ -74,10 +74,7 @@ namespace Nz float pointSize = 1.f; }; - struct RenderPipeline : RenderStates - { - ShaderConstRef shader; - }; + inline bool operator==(const RenderStates& lhs, const RenderStates& rhs); } #include diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 1f7564166..d9b6bfc31 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -3,11 +3,143 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include +#include +#include #include namespace Nz { + bool operator==(const RenderStates& lhs, const RenderStates& rhs) + { + #define NazaraRenderStateMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraRenderStateBoolMember NazaraRenderStateMember + #define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.##field, rhs.##field, maxDiff)) return false + + NazaraRenderStateBoolMember(blending); + NazaraRenderStateBoolMember(colorWrite); + NazaraRenderStateBoolMember(depthBuffer); + NazaraRenderStateBoolMember(faceCulling); + NazaraRenderStateBoolMember(scissorTest); + NazaraRenderStateBoolMember(stencilTest); + + if (lhs.depthBuffer) + NazaraRenderStateBoolMember(depthWrite); + + NazaraRenderStateMember(faceFilling); + + if (lhs.blending) //< Remember, at this time we know lhs.blending == rhs.blending + { + NazaraRenderStateMember(dstBlend); + NazaraRenderStateMember(srcBlend); + } + + if (lhs.depthBuffer) + NazaraRenderStateMember(depthFunc); + + if (lhs.faceCulling) + NazaraRenderStateMember(cullingSide); + + if (lhs.stencilTest) + { + NazaraRenderStateMember(stencilCompare.back); + NazaraRenderStateMember(stencilCompare.front); + NazaraRenderStateMember(stencilCompareMask.back); + NazaraRenderStateMember(stencilCompareMask.front); + NazaraRenderStateMember(stencilDepthFail.back); + NazaraRenderStateMember(stencilDepthFail.front); + NazaraRenderStateMember(stencilFail.back); + NazaraRenderStateMember(stencilFail.front); + NazaraRenderStateMember(stencilPass.back); + NazaraRenderStateMember(stencilPass.front); + NazaraRenderStateMember(stencilReference.back); + NazaraRenderStateMember(stencilReference.front); + NazaraRenderStateMember(stencilWriteMask.back); + NazaraRenderStateMember(stencilWriteMask.front); + } + + NazaraRenderStateFloatMember(lineWidth, 0.001f); + NazaraRenderStateFloatMember(pointSize, 0.001f); + + #undef NazaraRenderStateMember + #undef NazaraRenderStateBoolMember + #undef NazaraRenderStateFloatMember + + return true; + } +} + +namespace std +{ + template<> + struct hash + { + size_t operator()(const Nz::RenderStates& pipelineInfo) const + { + std::size_t seed = 0; + + Nz::UInt8 parameterHash = 0; + Nz::UInt8 parameterIndex = 0; + + #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.##member) + #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.##dependency && pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.##member / maxDiff) * maxDiff) + + NazaraRenderStateBoolMember(blending); + NazaraRenderStateBoolMember(colorWrite); + NazaraRenderStateBoolMember(depthBuffer); + NazaraRenderStateBoolMember(faceCulling); + NazaraRenderStateBoolMember(scissorTest); + NazaraRenderStateBoolMember(stencilTest); + + NazaraRenderStateBoolMemberDep(depthBuffer, depthWrite); + + NazaraRenderStateMember(faceFilling); + + if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending + { + NazaraRenderStateMember(dstBlend); + NazaraRenderStateMember(srcBlend); + } + + if (pipelineInfo.depthBuffer) + NazaraRenderStateMember(depthFunc); + + if (pipelineInfo.faceCulling) + NazaraRenderStateMember(cullingSide); + + if (pipelineInfo.stencilTest) + { + NazaraRenderStateMember(stencilCompare.back); + NazaraRenderStateMember(stencilCompare.front); + NazaraRenderStateMember(stencilCompareMask.back); + NazaraRenderStateMember(stencilCompareMask.front); + NazaraRenderStateMember(stencilDepthFail.back); + NazaraRenderStateMember(stencilDepthFail.front); + NazaraRenderStateMember(stencilFail.back); + NazaraRenderStateMember(stencilFail.front); + NazaraRenderStateMember(stencilPass.back); + NazaraRenderStateMember(stencilPass.front); + NazaraRenderStateMember(stencilReference.back); + NazaraRenderStateMember(stencilReference.front); + NazaraRenderStateMember(stencilWriteMask.back); + NazaraRenderStateMember(stencilWriteMask.front); + } + + NazaraRenderStateFloatMember(lineWidth, 0.001f); + NazaraRenderStateFloatMember(pointSize, 0.001f); + + #undef NazaraRenderStateMember + #undef NazaraRenderStateBoolMember + #undef NazaraRenderStateBoolMemberDep + #undef NazaraRenderStateFloatMember + + Nz::HashCombine(seed, parameterHash); + + return seed; + } + }; } #include diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 86815558c..3cdcb99fe 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -73,122 +73,132 @@ namespace Nz const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; - for (auto& pair : m_renderQueue->layers) + for (auto& layerPair : m_renderQueue->layers) { - DeferredRenderQueue::Layer& layer = pair.second; - - for (auto& matIt : layer.opaqueModels) + for (auto& pipelinePair : layerPair.second.opaqueModels) { - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.maxInstanceCount > 0) { - DeferredRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; + bool instancing = (pipelineEntry.maxInstanceCount > NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT); - if (!meshInstances.empty()) + UInt32 flags = ShaderFlags_Deferred; + if (instancing) + flags |= ShaderFlags_Instancing; + + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(flags); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Material* material = matIt.first; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - bool useInstancing = instancingEnabled && matEntry.instancingEnabled; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // We begin by getting the program for materials - UInt32 flags = ShaderFlags_Deferred; - if (useInstancing) - flags |= ShaderFlags_Instancing; + lastShader = shader; + } - const Shader* shader = material->Apply(flags); + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; - // The uniforms are conserved in our program, there's no point to send them back if they don't change - if (shader != lastShader) + if (matEntry.enabled) { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); + DeferredRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; - // Ambient color for the scene - shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - - lastShader = shader; - } - - // Meshes - for (auto& meshIt : meshInstances) - { - const MeshData& meshData = meshIt.first; - auto& meshEntry = meshIt.second; - - std::vector& instances = meshEntry.instances; - if (!instances.empty()) + if (!meshInstances.empty()) { - const IndexBuffer* indexBuffer = meshData.indexBuffer; - const VertexBuffer* vertexBuffer = meshData.vertexBuffer; + material->Apply(pipelineInstance); - // Handle draw call before rendering loop - Renderer::DrawCall drawFunc; - Renderer::DrawCallInstanced instancedDrawFunc; - unsigned int indexCount; - - if (indexBuffer) + // Meshes + for (auto& meshIt : meshInstances) { - drawFunc = Renderer::DrawIndexedPrimitives; - instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; - indexCount = indexBuffer->GetIndexCount(); - } - else - { - drawFunc = Renderer::DrawPrimitives; - instancedDrawFunc = Renderer::DrawPrimitivesInstanced; - indexCount = vertexBuffer->GetVertexCount(); - } + const MeshData& meshData = meshIt.first; + auto& meshEntry = meshIt.second; - Renderer::SetIndexBuffer(indexBuffer); - Renderer::SetVertexBuffer(vertexBuffer); - - if (useInstancing) - { - // We get the buffer for instance of Renderer and we configure it to work with matrices - VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); - instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - - const Matrix4f* instanceMatrices = &instances[0]; - unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer - - while (instanceCount > 0) + std::vector& instances = meshEntry.instances; + if (!instances.empty()) { - // We compute the number of instances that we will be able to show this time (Depending on the instance buffer size) - unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); - instanceCount -= renderedInstanceCount; + const IndexBuffer* indexBuffer = meshData.indexBuffer; + const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - // We fill the instancing buffer with our world matrices - instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); - instanceMatrices += renderedInstanceCount; + // Handle draw call before rendering loop + Renderer::DrawCall drawFunc; + Renderer::DrawCallInstanced instancedDrawFunc; + unsigned int indexCount; - // And we show - instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + if (indexBuffer) + { + drawFunc = Renderer::DrawIndexedPrimitives; + instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; + indexCount = indexBuffer->GetIndexCount(); + } + else + { + drawFunc = Renderer::DrawPrimitives; + instancedDrawFunc = Renderer::DrawPrimitivesInstanced; + indexCount = vertexBuffer->GetVertexCount(); + } + + Renderer::SetIndexBuffer(indexBuffer); + Renderer::SetVertexBuffer(vertexBuffer); + + if (instancing) + { + // We get the buffer for instance of Renderer and we configure it to work with matrices + VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); + instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); + + const Matrix4f* instanceMatrices = &instances[0]; + unsigned int instanceCount = instances.size(); + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The number of matrices that can be hold in the buffer + + while (instanceCount > 0) + { + // We compute the number of instances that we will be able to show this time (Depending on the instance buffer size) + unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); + instanceCount -= renderedInstanceCount; + + // We fill the instancing buffer with our world matrices + instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); + instanceMatrices += renderedInstanceCount; + + // And we show + instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + } + } + else + { + // Without instancing, we must do one draw call for each instance + // This may be faster than instancing under a threshold + // Due to the time to modify the instancing buffer + for (const Matrix4f& matrix : instances) + { + Renderer::SetMatrix(MatrixType_World, matrix); + drawFunc(meshData.primitiveMode, 0, indexCount); + } + } + + instances.clear(); } } - else - { - // Without instancing, we must do one draw call for each instance - // This may be faster than instancing under a threshold - // Due to the time to modify the instancing buffer - for (const Matrix4f& matrix : instances) - { - Renderer::SetMatrix(MatrixType_World, matrix); - drawFunc(meshData.primitiveMode, 0, indexCount); - } - } - - instances.clear(); } + + // And we set it back data to zero + matEntry.enabled = false; } } - // Abd we set it back data to zero - matEntry.enabled = false; - matEntry.instancingEnabled = false; + pipelineEntry.maxInstanceCount = 0; } } } diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 0b15c5a44..8623904a6 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -191,27 +191,39 @@ namespace Nz void DeferredRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { - if (material->IsEnabled(RendererParameter_Blend)) + if (material->IsBlendingEnabled()) // One transparent material ? I don't like it, go see if I'm in the forward queue m_forwardQueue->AddMesh(renderOrder, material, meshData, meshAABB, transformMatrix); else { Layer& currentLayer = GetLayer(renderOrder); - auto& opaqueModels = currentLayer.opaqueModels; + MeshPipelineBatches& opaqueModels = currentLayer.opaqueModels; - auto it = opaqueModels.find(material); - if (it == opaqueModels.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = opaqueModels.find(materialPipeline); + if (pipelineIt == opaqueModels.end()) + { + BatchedMaterialEntry materialEntry; + pipelineIt = opaqueModels.insert(MeshPipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + } + + BatchedMaterialEntry& materialEntry = pipelineIt->second; + MeshMaterialBatches& materialMap = materialEntry.materialMap; + + auto materialIt = materialMap.find(material); + if (materialIt == materialMap.end()) { BatchedModelEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &DeferredRenderQueue::OnMaterialInvalidation); - it = opaqueModels.insert(std::make_pair(material, std::move(entry))).first; + materialIt = materialMap.insert(MeshMaterialBatches::value_type(material, std::move(entry))).first; } - BatchedModelEntry& entry = it->second; + BatchedModelEntry& entry = materialIt->second; entry.enabled = true; - auto& meshMap = entry.meshMap; + MeshInstanceContainer& meshMap = entry.meshMap; auto it2 = meshMap.find(meshData); if (it2 == meshMap.end()) @@ -225,13 +237,8 @@ namespace Nz it2 = meshMap.insert(std::make_pair(meshData, std::move(instanceEntry))).first; } - // We add matrices to the list of instances of this object std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - - // Do we have enough instances to perform instancing ? - if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Thus we can activate it } } @@ -293,7 +300,7 @@ namespace Nz return layer; } - + /*! * \brief Handle the invalidation of an index buffer * @@ -306,16 +313,19 @@ namespace Nz { Layer& layer = pair.second; - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.indexBuffer == indexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.indexBuffer == indexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } @@ -333,7 +343,8 @@ namespace Nz { Layer& layer = pair.second; - layer.opaqueModels.erase(material); + for (auto& pipelineEntry : layer.opaqueModels) + pipelineEntry.second.materialMap.erase(material); } } @@ -348,73 +359,21 @@ namespace Nz for (auto& pair : layers) { Layer& layer = pair.second; - - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.vertexBuffer == vertexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.vertexBuffer == vertexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } } - - /*! - * \brief Functor to compare two batched model with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool DeferredRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const - { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance(ShaderFlags_Deferred)->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance(ShaderFlags_Deferred)->GetShader(); - if (shader1 != shader2) - return shader1 < shader2; - - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); - const Texture* diffuseMap2 = mat2->GetDiffuseMap(); - if (diffuseMap1 != diffuseMap2) - return diffuseMap1 < diffuseMap2; - - return mat1 < mat2; - } - - /*! - * \brief Functor to compare two mesh data - * \return true If first mesh is "smaller" than the second one - * - * \param data1 First mesh to compare - * \param data2 Second mesh to compare - */ - - bool DeferredRenderQueue::MeshDataComparator::operator()(const MeshData& data1, const MeshData& data2) const - { - const Buffer* buffer1; - const Buffer* buffer2; - - buffer1 = (data1.indexBuffer) ? data1.indexBuffer->GetBuffer() : nullptr; - buffer2 = (data2.indexBuffer) ? data2.indexBuffer->GetBuffer() : nullptr; - if (buffer1 != buffer2) - return buffer1 < buffer2; - - buffer1 = data1.vertexBuffer->GetBuffer(); - buffer2 = data2.vertexBuffer->GetBuffer(); - if (buffer1 != buffer2) - return buffer1 < buffer2; - - return data1.primitiveMode < data2.primitiveMode; - } } diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index c658fe7bd..fbc24bb19 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -23,8 +23,8 @@ namespace Nz { // Material m_baseMaterial = Material::New(); - m_baseMaterial->Enable(RendererParameter_ColorWrite, false); - m_baseMaterial->Enable(RendererParameter_FaceCulling, false); + m_baseMaterial->EnableColorWrite(false); + m_baseMaterial->EnableFaceCulling(false); //m_baseMaterial->SetFaceCulling(FaceSide_Front); } diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 233eb9c72..46b1c3407 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -52,6 +52,10 @@ namespace Nz { ErrorFlags flags(ErrorFlag_ThrowException, true); + std::array whitePixel = {255, 255, 255, 255}; + m_whiteTexture.Create(ImageType_2D, PixelFormatType_RGBA8, 1, 1); + m_whiteTexture.Update(whitePixel.data()); + m_vertexBuffer.Create(s_vertexBufferSize, DataStorage_Hardware, BufferUsage_Dynamic); m_billboardPointBuffer.Reset(&s_billboardVertexDeclaration, &m_vertexBuffer); @@ -208,6 +212,8 @@ namespace Nz void DepthRenderTechnique::DrawBasicSprites(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { + NazaraAssert(sceneData.viewer, "Invalid viewer"); + const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; @@ -215,95 +221,102 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); Renderer::SetVertexBuffer(&m_spriteBuffer); - for (auto& matIt : layer.basicSprites) + for (auto& pipelinePair : layer.basicSprites) { - const Material* material = matIt.first; - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.enabled) { - auto& overlayMap = matEntry.overlayMap; - for (auto& overlayIt : overlayMap) + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_TextureOverlay | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Texture* overlay = overlayIt.first; - auto& spriteChainVector = overlayIt.second.spriteChains; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - unsigned int spriteChainCount = spriteChainVector.size(); - if (spriteChainCount > 0) - { - // We begin to apply the material (and get the shader activated doing so) - UInt32 flags = 0; - if (overlay) - flags |= ShaderFlags_TextureOverlay; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - UInt8 overlayUnit; - const Shader* shader = material->Apply(flags, 0, &overlayUnit); - - if (overlay) - { - overlayUnit++; - Renderer::SetTexture(overlayUnit, overlay); - Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); - } - - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) - { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); - - // Overlay - shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); - - lastShader = shader; - } - - unsigned int spriteChain = 0; // Which chain of sprites are we treating - unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain - - do - { - // We open the buffer in writing mode - BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); - VertexStruct_XYZ_Color_UV* vertices = reinterpret_cast(vertexMapper.GetPointer()); - - unsigned int spriteCount = 0; - unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount()/4); - - do - { - ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; - unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); - - std::memcpy(vertices, currentChain.vertices + spriteChainOffset*4, 4*count*sizeof(VertexStruct_XYZ_Color_UV)); - vertices += count*4; - - spriteCount += count; - spriteChainOffset += count; - - // Have we treated the entire chain ? - if (spriteChainOffset == currentChain.spriteCount) - { - spriteChain++; - spriteChainOffset = 0; - } - } - while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); - - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount*6); - } - while (spriteChain < spriteChainCount); - - spriteChainVector.clear(); - } + lastShader = shader; } - // On remet à zéro - matEntry.enabled = false; + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + UInt8 overlayUnit; + material->Apply(pipelineInstance, 0, &overlayUnit); + overlayUnit++; + + shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); + + Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); + + auto& overlayMap = matEntry.overlayMap; + for (auto& overlayIt : overlayMap) + { + const Texture* overlay = overlayIt.first; + auto& spriteChainVector = overlayIt.second.spriteChains; + + unsigned int spriteChainCount = spriteChainVector.size(); + if (spriteChainCount > 0) + { + Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); + + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain + + do + { + // We open the buffer in writing mode + BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); + VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); + + unsigned int spriteCount = 0; + unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); + + do + { + ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; + unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); + + std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); + vertices += count * 4; + + spriteCount += count; + spriteChainOffset += count; + + // Have we treated the entire chain ? + if (spriteChainOffset == currentChain.spriteCount) + { + spriteChain++; + spriteChainOffset = 0; + } + } while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); + } while (spriteChain < spriteChainCount); + + spriteChainVector.clear(); + } + } + + // We set it back to zero + matEntry.enabled = false; + } + } + pipelineEntry.enabled = false; } } } @@ -314,9 +327,11 @@ namespace Nz * \param sceneData Data of the scene * \param layer Layer of the rendering */ - + void DepthRenderTechnique::DrawBillboards(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { + NazaraAssert(sceneData.viewer, "Invalid viewer"); + const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; @@ -327,17 +342,16 @@ namespace Nz Renderer::SetVertexBuffer(&s_quadVertexBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -345,27 +359,43 @@ namespace Nz // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - instanceBuffer->Fill(data, 0, renderedBillboardCount, true); - data += renderedBillboardCount; + unsigned int billboardCount = billboardVector.size(); + if (billboardCount > 0) + { + // We begin to apply the material (and get the shader activated doing so) + material->Apply(pipelineInstance); - Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); + do + { + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; + + instanceBuffer->Fill(data, 0, renderedBillboardCount, true); + data += renderedBillboardCount; + + Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + } + while (billboardCount > 0); + + billboardVector.clear(); + } } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -374,17 +404,16 @@ namespace Nz Renderer::SetIndexBuffer(&s_quadIndexBuffer); Renderer::SetVertexBuffer(&m_billboardPointBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -392,63 +421,73 @@ namespace Nz // Index of uniforms in the shader shaderUniforms = GetShaderUniforms(shader); + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, Renderer::GetMatrix(MatrixType_ViewProj).GetTranslation()); + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount()/4); - - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount*4); - BillboardPoint* vertices = reinterpret_cast(vertexMapper.GetPointer()); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); - for (unsigned int i = 0; i < renderedBillboardCount; ++i) + unsigned int billboardCount = billboardVector.size(); + do { - const ForwardRenderQueue::BillboardData& billboard = *data++; + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 1.f); - vertices++; + BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); + BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 1.f); - vertices++; + for (unsigned int i = 0; i < renderedBillboardCount; ++i) + { + const ForwardRenderQueue::BillboardData& billboard = *data++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 1.f); + vertices++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 1.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 0.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 0.f); + vertices++; + } + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); } + while (billboardCount > 0); - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount*6); + billboardVector.clear(); } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -460,116 +499,131 @@ namespace Nz * \param sceneData Data of the scene * \param layer Layer of the rendering */ - + void DepthRenderTechnique::DrawOpaqueModels(const SceneData& sceneData, ForwardRenderQueue::Layer& layer) const { + NazaraAssert(sceneData.viewer, "Invalid viewer"); + const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; - for (auto& matIt : layer.opaqueModels) + for (auto& pipelinePair : layer.opaqueModels) { - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.maxInstanceCount > 0) { - ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; + bool instancing = (pipelineEntry.maxInstanceCount > NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply((instancing) ? ShaderFlags_Instancing : 0); - if (!meshInstances.empty()) + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Material* material = matIt.first; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - bool instancing = m_instancingEnabled && matEntry.instancingEnabled; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // We begin to apply the material (and get the shader activated doing so) - UInt8 freeTextureUnit; - const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); + lastShader = shader; + } - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); - lastShader = shader; - } + UInt8 freeTextureUnit; + material->Apply(pipelineInstance, 0, &freeTextureUnit); - // Meshes - for (auto& meshIt : meshInstances) - { - const MeshData& meshData = meshIt.first; - auto& meshEntry = meshIt.second; + ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; - const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; - std::vector& instances = meshEntry.instances; - - if (!instances.empty()) + // Meshes + for (auto& meshIt : meshInstances) { - const IndexBuffer* indexBuffer = meshData.indexBuffer; - const VertexBuffer* vertexBuffer = meshData.vertexBuffer; + const MeshData& meshData = meshIt.first; + auto& meshEntry = meshIt.second; - // Handle draw call before rendering loop - Renderer::DrawCall drawFunc; - Renderer::DrawCallInstanced instancedDrawFunc; - unsigned int indexCount; + const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; + std::vector& instances = meshEntry.instances; - if (indexBuffer) + if (!instances.empty()) { - drawFunc = Renderer::DrawIndexedPrimitives; - instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; - indexCount = indexBuffer->GetIndexCount(); - } - else - { - drawFunc = Renderer::DrawPrimitives; - instancedDrawFunc = Renderer::DrawPrimitivesInstanced; - indexCount = vertexBuffer->GetVertexCount(); - } + const IndexBuffer* indexBuffer = meshData.indexBuffer; + const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - Renderer::SetIndexBuffer(indexBuffer); - Renderer::SetVertexBuffer(vertexBuffer); + // Handle draw call before rendering loop + Renderer::DrawCall drawFunc; + Renderer::DrawCallInstanced instancedDrawFunc; + unsigned int indexCount; - if (instancing) - { - // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); - instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); + if (indexBuffer) + { + drawFunc = Renderer::DrawIndexedPrimitives; + instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; + indexCount = indexBuffer->GetIndexCount(); + } + else + { + drawFunc = Renderer::DrawPrimitives; + instancedDrawFunc = Renderer::DrawPrimitivesInstanced; + indexCount = vertexBuffer->GetVertexCount(); + } - const Matrix4f* instanceMatrices = &instances[0]; - unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // The maximum number of instances in one batch + Renderer::SetIndexBuffer(indexBuffer); + Renderer::SetVertexBuffer(vertexBuffer); - while (instanceCount > 0) + if (instancing) { // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); - instanceCount -= renderedInstanceCount; + VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); + instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - // We fill the instancing buffer with our world matrices - instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); - instanceMatrices += renderedInstanceCount; + const Matrix4f* instanceMatrices = &instances[0]; + unsigned int instanceCount = instances.size(); + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch - // And we draw - instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + while (instanceCount > 0) + { + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) + unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); + instanceCount -= renderedInstanceCount; + + // We fill the instancing buffer with our world matrices + instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); + instanceMatrices += renderedInstanceCount; + + // And we draw + instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + } } - } - else - { - // Without instancing, we must do a draw call for each instance + else + { + // Without instancing, we must do a draw call for each instance // This may be faster than instancing under a certain number // Due to the time to modify the instancing buffer - for (const Matrix4f& matrix : instances) - { - Renderer::SetMatrix(MatrixType_World, matrix); - drawFunc(meshData.primitiveMode, 0, indexCount); + for (const Matrix4f& matrix : instances) + { + Renderer::SetMatrix(MatrixType_World, matrix); + drawFunc(meshData.primitiveMode, 0, indexCount); + } } + instances.clear(); } - instances.clear(); } + + matEntry.enabled = false; } } - // And we set the data back to zero - matEntry.enabled = false; - matEntry.instancingEnabled = false; + pipelineEntry.maxInstanceCount = 0; } } } diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index b9077e1b9..882a6f61e 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -372,12 +372,11 @@ namespace Nz * * \remark Produces a NazaraAssert if material is invalid */ - void ForwardRenderQueue::AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) { NazaraAssert(material, "Invalid material"); - if (material->IsEnabled(RendererParameter_Blend)) + if (material->IsBlendingEnabled()) { Layer& currentLayer = GetLayer(renderOrder); auto& transparentModels = currentLayer.transparentModels; @@ -398,21 +397,33 @@ namespace Nz else { Layer& currentLayer = GetLayer(renderOrder); - auto& opaqueModels = currentLayer.opaqueModels; + MeshPipelineBatches& opaqueModels = currentLayer.opaqueModels; - auto it = opaqueModels.find(material); - if (it == opaqueModels.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = opaqueModels.find(materialPipeline); + if (pipelineIt == opaqueModels.end()) + { + BatchedMaterialEntry materialEntry; + pipelineIt = opaqueModels.insert(MeshPipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + } + + BatchedMaterialEntry& materialEntry = pipelineIt->second; + MeshMaterialBatches& materialMap = materialEntry.materialMap; + + auto materialIt = materialMap.find(material); + if (materialIt == materialMap.end()) { BatchedModelEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - it = opaqueModels.insert(std::make_pair(material, std::move(entry))).first; + materialIt = materialMap.insert(MeshMaterialBatches::value_type(material, std::move(entry))).first; } - BatchedModelEntry& entry = it->second; + BatchedModelEntry& entry = materialIt->second; entry.enabled = true; - auto& meshMap = entry.meshMap; + MeshInstanceContainer& meshMap = entry.meshMap; auto it2 = meshMap.find(meshData); if (it2 == meshMap.end()) @@ -431,9 +442,7 @@ namespace Nz std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); - // Do we have enough instances to perform instancing ? - if (instances.size() >= NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT) - entry.instancingEnabled = true; // Thus we can activate it + materialEntry.maxInstanceCount = std::max(materialEntry.maxInstanceCount, instances.size()); } } @@ -448,21 +457,34 @@ namespace Nz * * \remark Produces a NazaraAssert if material is invalid */ - void ForwardRenderQueue::AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const Texture* overlay) { NazaraAssert(material, "Invalid material"); Layer& currentLayer = GetLayer(renderOrder); - auto& basicSprites = currentLayer.basicSprites; + SpritePipelineBatches& basicSprites = currentLayer.basicSprites; - auto matIt = basicSprites.find(material); - if (matIt == basicSprites.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = basicSprites.find(materialPipeline); + if (pipelineIt == basicSprites.end()) + { + BatchedSpritePipelineEntry materialEntry; + pipelineIt = basicSprites.insert(SpritePipelineBatches::value_type(materialPipeline, std::move(materialEntry))).first; + } + + BatchedSpritePipelineEntry& pipelineEntry = pipelineIt->second; + pipelineEntry.enabled = true; + + SpriteMaterialBatches& materialMap = pipelineEntry.materialMap; + + auto matIt = materialMap.find(material); + if (matIt == materialMap.end()) { BatchedBasicSpriteEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - matIt = basicSprites.insert(std::make_pair(material, std::move(entry))).first; + matIt = materialMap.insert(SpriteMaterialBatches::value_type(material, std::move(entry))).first; } BatchedBasicSpriteEntry& entry = matIt->second; @@ -541,19 +563,22 @@ namespace Nz return nearPlane.Distance(position1) > nearPlane.Distance(position2); }); - for (auto& pair : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* mat = pair.first; - - if (mat->IsDepthSortingEnabled()) + for (auto& matPair : pipelinePair.second.materialMap) { - BatchedBillboardEntry& entry = pair.second; - auto& billboardVector = entry.billboards; + const Material* mat = matPair.first; - std::sort(billboardVector.begin(), billboardVector.end(), [&viewerPos] (const BillboardData& data1, const BillboardData& data2) + if (mat->IsDepthSortingEnabled()) { - return viewerPos.SquaredDistance(data1.center) > viewerPos.SquaredDistance(data2.center); - }); + BatchedBillboardEntry& entry = matPair.second; + auto& billboardVector = entry.billboards; + + std::sort(billboardVector.begin(), billboardVector.end(), [&viewerPos] (const BillboardData& data1, const BillboardData& data2) + { + return viewerPos.SquaredDistance(data1.center) > viewerPos.SquaredDistance(data2.center); + }); + } } } } @@ -571,13 +596,26 @@ namespace Nz { auto& billboards = GetLayer(renderOrder).billboards; - auto it = billboards.find(material); - if (it == billboards.end()) + const MaterialPipeline* materialPipeline = material->GetPipeline(); + + auto pipelineIt = billboards.find(materialPipeline); + if (pipelineIt == billboards.end()) + { + BatchedBillboardPipelineEntry pipelineEntry; + pipelineIt = billboards.insert(BillboardPipelineBatches::value_type(materialPipeline, std::move(pipelineEntry))).first; + } + BatchedBillboardPipelineEntry& pipelineEntry = pipelineIt->second; + pipelineEntry.enabled = true; + + BatchedBillboardContainer& materialMap = pipelineEntry.materialMap; + + auto it = materialMap.find(material); + if (it == materialMap.end()) { BatchedBillboardEntry entry; entry.materialReleaseSlot.Connect(material->OnMaterialRelease, this, &ForwardRenderQueue::OnMaterialInvalidation); - it = billboards.insert(std::make_pair(material, std::move(entry))).first; + it = materialMap.insert(BatchedBillboardContainer::value_type(material, std::move(entry))).first; } BatchedBillboardEntry& entry = it->second; @@ -620,16 +658,19 @@ namespace Nz { Layer& layer = pair.second; - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.indexBuffer == indexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.indexBuffer == indexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } @@ -647,9 +688,14 @@ namespace Nz { Layer& layer = pair.second; - layer.basicSprites.erase(material); - layer.billboards.erase(material); - layer.opaqueModels.erase(material); + for (auto& pipelineEntry : layer.basicSprites) + pipelineEntry.second.materialMap.erase(material); + + for (auto& pipelineEntry : layer.billboards) + pipelineEntry.second.materialMap.erase(material); + + for (auto& pipelineEntry : layer.opaqueModels) + pipelineEntry.second.materialMap.erase(material); } } @@ -664,10 +710,10 @@ namespace Nz for (auto& pair : layers) { Layer& layer = pair.second; - for (auto matIt = layer.basicSprites.begin(); matIt != layer.basicSprites.end(); ++matIt) + for (auto& pipelineEntry : layer.basicSprites) { - auto& overlayMap = matIt->second.overlayMap; - overlayMap.erase(texture); + for (auto& materialEntry : pipelineEntry.second.materialMap) + materialEntry.second.overlayMap.erase(texture); } } } @@ -683,41 +729,26 @@ namespace Nz for (auto& pair : layers) { Layer& layer = pair.second; - for (auto& modelPair : layer.opaqueModels) + for (auto& pipelineEntry : layer.opaqueModels) { - MeshInstanceContainer& meshes = modelPair.second.meshMap; - for (auto it = meshes.begin(); it != meshes.end();) + for (auto& materialEntry : pipelineEntry.second.materialMap) { - const MeshData& renderData = it->first; - if (renderData.vertexBuffer == vertexBuffer) - it = meshes.erase(it); - else - ++it; + MeshInstanceContainer& meshes = materialEntry.second.meshMap; + for (auto it = meshes.begin(); it != meshes.end();) + { + const MeshData& renderData = it->first; + if (renderData.vertexBuffer == vertexBuffer) + it = meshes.erase(it); + else + ++it; + } } } } } - /*! - * \brief Functor to compare two batched billboard with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool ForwardRenderQueue::BatchedBillboardComparator::operator()(const Material* mat1, const Material* mat2) const + bool ForwardRenderQueue::MaterialComparator::operator()(const Material* mat1, const Material* mat2) const { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance(ShaderFlags_Billboard | ShaderFlags_VertexColor)->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance(ShaderFlags_Billboard | ShaderFlags_VertexColor)->GetShader(); - if (shader1 != shader2) - return shader1 < shader2; - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); const Texture* diffuseMap2 = mat2->GetDiffuseMap(); if (diffuseMap1 != diffuseMap2) @@ -726,60 +757,14 @@ namespace Nz return mat1 < mat2; } - /*! - * \brief Functor to compare two batched model with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool ForwardRenderQueue::BatchedModelMaterialComparator::operator()(const Material* mat1, const Material* mat2) const + bool ForwardRenderQueue::MaterialPipelineComparator::operator()(const MaterialPipeline* pipeline1, const MaterialPipeline* pipeline2) const { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance()->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance()->GetShader(); + const Shader* shader1 = pipeline1->GetInstance().renderPipeline.GetInfo().shader; + const Shader* shader2 = pipeline2->GetInstance().renderPipeline.GetInfo().shader; if (shader1 != shader2) return shader1 < shader2; - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); - const Texture* diffuseMap2 = mat2->GetDiffuseMap(); - if (diffuseMap1 != diffuseMap2) - return diffuseMap1 < diffuseMap2; - - return mat1 < mat2; - } - - /*! - * \brief Functor to compare two batched sprites with material - * \return true If first material is "smaller" than the second one - * - * \param mat1 First material to compare - * \param mat2 Second material to compare - */ - - bool ForwardRenderQueue::BatchedSpriteMaterialComparator::operator()(const Material* mat1, const Material* mat2) - { - const UberShader* uberShader1 = mat1->GetShader(); - const UberShader* uberShader2 = mat2->GetShader(); - if (uberShader1 != uberShader2) - return uberShader1 < uberShader2; - - const Shader* shader1 = mat1->GetShaderInstance()->GetShader(); - const Shader* shader2 = mat2->GetShaderInstance()->GetShader(); - if (shader1 != shader2) - return shader1 < shader2; - - const Texture* diffuseMap1 = mat1->GetDiffuseMap(); - const Texture* diffuseMap2 = mat2->GetDiffuseMap(); - if (diffuseMap1 != diffuseMap2) - return diffuseMap1 < diffuseMap2; - - return mat1 < mat2; + return pipeline1 < pipeline2; } /*! diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 482852347..aad29ab88 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -53,6 +53,10 @@ namespace Nz { ErrorFlags flags(ErrorFlag_ThrowException, true); + std::array whitePixel = {255, 255, 255, 255}; + m_whiteTexture.Create(ImageType_2D, PixelFormatType_RGBA8, 1, 1); + m_whiteTexture.Update(whitePixel.data()); + m_vertexBuffer.Create(s_vertexBufferSize, DataStorage_Hardware, BufferUsage_Dynamic); m_billboardPointBuffer.Reset(&s_billboardVertexDeclaration, &m_vertexBuffer); @@ -297,97 +301,102 @@ namespace Nz Renderer::SetMatrix(MatrixType_World, Matrix4f::Identity()); Renderer::SetVertexBuffer(&m_spriteBuffer); - for (auto& matIt : layer.basicSprites) + for (auto& pipelinePair : layer.basicSprites) { - const Material* material = matIt.first; - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.enabled) { - auto& overlayMap = matEntry.overlayMap; - for (auto& overlayIt : overlayMap) + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_TextureOverlay | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Texture* overlay = overlayIt.first; - auto& spriteChainVector = overlayIt.second.spriteChains; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - unsigned int spriteChainCount = spriteChainVector.size(); - if (spriteChainCount > 0) - { - // We begin to apply the material (and get the shader activated doing so) - UInt32 flags = ShaderFlags_VertexColor; - if (overlay) - flags |= ShaderFlags_TextureOverlay; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - UInt8 overlayUnit; - const Shader* shader = material->Apply(flags, 0, &overlayUnit); - - if (overlay) - { - overlayUnit++; - Renderer::SetTexture(overlayUnit, overlay); - Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); - } - - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) - { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); - - // Ambiant color of the scene - shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Overlay - shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - - lastShader = shader; - } - - unsigned int spriteChain = 0; // Which chain of sprites are we treating - unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain - - do - { - // We open the buffer in writing mode - BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); - VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); - - unsigned int spriteCount = 0; - unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); - - do - { - ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; - unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); - - std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); - vertices += count * 4; - - spriteCount += count; - spriteChainOffset += count; - - // Have we treated the entire chain ? - if (spriteChainOffset == currentChain.spriteCount) - { - spriteChain++; - spriteChainOffset = 0; - } - } - while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); - - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); - } - while (spriteChain < spriteChainCount); - - spriteChainVector.clear(); - } + lastShader = shader; } - // We set it back to zero - matEntry.enabled = false; + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + UInt8 overlayUnit; + material->Apply(pipelineInstance, 0, &overlayUnit); + overlayUnit++; + + shader->SendInteger(shaderUniforms->textureOverlay, overlayUnit); + + Renderer::SetTextureSampler(overlayUnit, material->GetDiffuseSampler()); + + auto& overlayMap = matEntry.overlayMap; + for (auto& overlayIt : overlayMap) + { + const Texture* overlay = overlayIt.first; + auto& spriteChainVector = overlayIt.second.spriteChains; + + unsigned int spriteChainCount = spriteChainVector.size(); + if (spriteChainCount > 0) + { + Renderer::SetTexture(overlayUnit, (overlay) ? overlay : &m_whiteTexture); + + unsigned int spriteChain = 0; // Which chain of sprites are we treating + unsigned int spriteChainOffset = 0; // Where was the last offset where we stopped in the last chain + + do + { + // We open the buffer in writing mode + BufferMapper vertexMapper(m_spriteBuffer, BufferAccess_DiscardAndWrite); + VertexStruct_XYZ_Color_UV* vertices = static_cast(vertexMapper.GetPointer()); + + unsigned int spriteCount = 0; + unsigned int maxSpriteCount = std::min(s_maxQuads, m_spriteBuffer.GetVertexCount() / 4); + + do + { + ForwardRenderQueue::SpriteChain_XYZ_Color_UV& currentChain = spriteChainVector[spriteChain]; + unsigned int count = std::min(maxSpriteCount - spriteCount, currentChain.spriteCount - spriteChainOffset); + + std::memcpy(vertices, currentChain.vertices + spriteChainOffset * 4, 4 * count * sizeof(VertexStruct_XYZ_Color_UV)); + vertices += count * 4; + + spriteCount += count; + spriteChainOffset += count; + + // Have we treated the entire chain ? + if (spriteChainOffset == currentChain.spriteCount) + { + spriteChain++; + spriteChainOffset = 0; + } + } while (spriteCount < maxSpriteCount && spriteChain < spriteChainCount); + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); + } while (spriteChain < spriteChainCount); + + spriteChainVector.clear(); + } + } + + // We set it back to zero + matEntry.enabled = false; + } + } + pipelineEntry.enabled = false; } } } @@ -415,17 +424,16 @@ namespace Nz Renderer::SetVertexBuffer(&s_quadVertexBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_Instancing | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -441,21 +449,35 @@ namespace Nz lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - instanceBuffer->Fill(data, 0, renderedBillboardCount, true); - data += renderedBillboardCount; + unsigned int billboardCount = billboardVector.size(); + if (billboardCount > 0) + { + // We begin to apply the material (and get the shader activated doing so) + material->Apply(pipelineInstance); - Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = instanceBuffer->GetVertexCount(); + do + { + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; + + instanceBuffer->Fill(data, 0, renderedBillboardCount, true); + data += renderedBillboardCount; + + Renderer::DrawPrimitivesInstanced(renderedBillboardCount, PrimitiveMode_TriangleStrip, 0, 4); + } + while (billboardCount > 0); + + billboardVector.clear(); + } } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -464,17 +486,16 @@ namespace Nz Renderer::SetIndexBuffer(&s_quadIndexBuffer); Renderer::SetVertexBuffer(&m_billboardPointBuffer); - for (auto& matIt : layer.billboards) + for (auto& pipelinePair : layer.billboards) { - const Material* material = matIt.first; - auto& entry = matIt.second; - auto& billboardVector = entry.billboards; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - unsigned int billboardCount = billboardVector.size(); - if (billboardCount > 0) + if (pipelineEntry.enabled) { - // We begin to apply the material (and get the shader activated doing so) - const Shader* shader = material->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(ShaderFlags_Billboard | ShaderFlags_VertexColor); + + const Shader* shader = pipelineInstance.uberInstance->GetShader(); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) @@ -490,57 +511,65 @@ namespace Nz lastShader = shader; } - const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; - unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); - - do + for (auto& matIt : pipelinePair.second.materialMap) { - unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); - billboardCount -= renderedBillboardCount; + const Material* material = matIt.first; + auto& entry = matIt.second; + auto& billboardVector = entry.billboards; - BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); - BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); + const ForwardRenderQueue::BillboardData* data = &billboardVector[0]; + unsigned int maxBillboardPerDraw = std::min(s_maxQuads, m_billboardPointBuffer.GetVertexCount() / 4); - for (unsigned int i = 0; i < renderedBillboardCount; ++i) + unsigned int billboardCount = billboardVector.size(); + do { - const ForwardRenderQueue::BillboardData& billboard = *data++; + unsigned int renderedBillboardCount = std::min(billboardCount, maxBillboardPerDraw); + billboardCount -= renderedBillboardCount; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 1.f); - vertices++; + BufferMapper vertexMapper(m_billboardPointBuffer, BufferAccess_DiscardAndWrite, 0, renderedBillboardCount * 4); + BillboardPoint* vertices = static_cast(vertexMapper.GetPointer()); - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 1.f); - vertices++; + for (unsigned int i = 0; i < renderedBillboardCount; ++i) + { + const ForwardRenderQueue::BillboardData& billboard = *data++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(0.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 1.f); + vertices++; - vertices->color = billboard.color; - vertices->position = billboard.center; - vertices->sinCos = billboard.sinCos; - vertices->size = billboard.size; - vertices->uv.Set(1.f, 0.f); - vertices++; + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 1.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(0.f, 0.f); + vertices++; + + vertices->color = billboard.color; + vertices->position = billboard.center; + vertices->sinCos = billboard.sinCos; + vertices->size = billboard.size; + vertices->uv.Set(1.f, 0.f); + vertices++; + } + + vertexMapper.Unmap(); + + Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); } + while (billboardCount > 0); - vertexMapper.Unmap(); - - Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, renderedBillboardCount * 6); + billboardVector.clear(); } - while (billboardCount > 0); - - billboardVector.clear(); } } } @@ -562,158 +591,98 @@ namespace Nz const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; - for (auto& matIt : layer.opaqueModels) + for (auto& pipelinePair : layer.opaqueModels) { - auto& matEntry = matIt.second; + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; - if (matEntry.enabled) + if (pipelineEntry.maxInstanceCount > 0) { - ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; + bool instancing = (pipelineEntry.maxInstanceCount > NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT); + const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply((instancing) ? ShaderFlags_Instancing : 0); - if (!meshInstances.empty()) + const Shader* shader = pipelineInstance.uberInstance->GetShader(); + + // Uniforms are conserved in our program, there's no point to send them back until they change + if (shader != lastShader) { - const Material* material = matIt.first; + // Index of uniforms in the shader + shaderUniforms = GetShaderUniforms(shader); - // We only use instancing when no light (other than directional) is active - // This is because instancing is not compatible with the search of nearest lights - // Deferred shading does not have this problem - bool noPointSpotLight = m_renderQueue.pointLights.empty() && m_renderQueue.spotLights.empty(); - bool instancing = m_instancingEnabled && (!material->IsLightingEnabled() || noPointSpotLight) && matEntry.instancingEnabled; + // Ambiant color of the scene + shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); + // Position of the camera + shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); - // We begin to apply the material (and get the shader activated doing so) - UInt8 freeTextureUnit; - const Shader* shader = material->Apply((instancing) ? ShaderFlags_Instancing : 0, 0, &freeTextureUnit); + lastShader = shader; + } - // Uniforms are conserved in our program, there's no point to send them back until they change - if (shader != lastShader) + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) { - // Index of uniforms in the shader - shaderUniforms = GetShaderUniforms(shader); + UInt8 freeTextureUnit; + material->Apply(pipelineInstance, 0, &freeTextureUnit); - // Ambiant color of the scene - shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor); - // Position of the camera - shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition()); + ForwardRenderQueue::MeshInstanceContainer& meshInstances = matEntry.meshMap; - lastShader = shader; - } - - // Meshes - for (auto& meshIt : meshInstances) - { - const MeshData& meshData = meshIt.first; - auto& meshEntry = meshIt.second; - - const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; - std::vector& instances = meshEntry.instances; - - if (!instances.empty()) + // Meshes + for (auto& meshIt : meshInstances) { - const IndexBuffer* indexBuffer = meshData.indexBuffer; - const VertexBuffer* vertexBuffer = meshData.vertexBuffer; + const MeshData& meshData = meshIt.first; + auto& meshEntry = meshIt.second; - // Handle draw call before rendering loop - Renderer::DrawCall drawFunc; - Renderer::DrawCallInstanced instancedDrawFunc; - unsigned int indexCount; + const Spheref& squaredBoundingSphere = meshEntry.squaredBoundingSphere; + std::vector& instances = meshEntry.instances; - if (indexBuffer) + if (!instances.empty()) { - drawFunc = Renderer::DrawIndexedPrimitives; - instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; - indexCount = indexBuffer->GetIndexCount(); - } - else - { - drawFunc = Renderer::DrawPrimitives; - instancedDrawFunc = Renderer::DrawPrimitivesInstanced; - indexCount = vertexBuffer->GetVertexCount(); - } + const IndexBuffer* indexBuffer = meshData.indexBuffer; + const VertexBuffer* vertexBuffer = meshData.vertexBuffer; - Renderer::SetIndexBuffer(indexBuffer); - Renderer::SetVertexBuffer(vertexBuffer); + // Handle draw call before rendering loop + Renderer::DrawCall drawFunc; + Renderer::DrawCallInstanced instancedDrawFunc; + unsigned int indexCount; - if (instancing) - { - // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); - instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); - - // With instancing, impossible to select the lights for each object - // So, it's only activated for directional lights - unsigned int lightCount = m_renderQueue.directionalLights.size(); - unsigned int lightIndex = 0; - RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); - - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; - for (unsigned int pass = 0; pass < passCount; ++pass) + if (indexBuffer) { - if (shaderUniforms->hasLightUniforms) - { - unsigned int renderedLightCount = std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); - lightCount -= renderedLightCount; - - if (pass == 1) - { - // To add the result of light computations - // We won't interfeer with materials parameters because we only render opaques objects - // (A.K.A., without blending) - // About the depth function, it must be applied only the first time - Renderer::Enable(RendererParameter_Blend, true); - Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); - Renderer::SetDepthFunc(RendererComparison_Equal); - } - - // Sends the uniforms - for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); - - // And we give them to draw - drawFunc(meshData.primitiveMode, 0, indexCount); - } - - const Matrix4f* instanceMatrices = &instances[0]; - unsigned int instanceCount = instances.size(); - unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch - - while (instanceCount > 0) - { - // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) - unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); - instanceCount -= renderedInstanceCount; - - // We fill the instancing buffer with our world matrices - instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); - instanceMatrices += renderedInstanceCount; - - // And we draw - instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); - } + drawFunc = Renderer::DrawIndexedPrimitives; + instancedDrawFunc = Renderer::DrawIndexedPrimitivesInstanced; + indexCount = indexBuffer->GetIndexCount(); + } + else + { + drawFunc = Renderer::DrawPrimitives; + instancedDrawFunc = Renderer::DrawPrimitivesInstanced; + indexCount = vertexBuffer->GetVertexCount(); } - // We don't forget to disable the blending to avoid to interfeer with the rest of the rendering - Renderer::Enable(RendererParameter_Blend, false); - Renderer::SetDepthFunc(oldDepthFunc); - } - else - { - if (shaderUniforms->hasLightUniforms) + Renderer::SetIndexBuffer(indexBuffer); + Renderer::SetVertexBuffer(vertexBuffer); + + if (instancing) { - for (const Matrix4f& matrix : instances) + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) + VertexBuffer* instanceBuffer = Renderer::GetInstanceBuffer(); + instanceBuffer->SetVertexDeclaration(VertexDeclaration::Get(VertexLayout_Matrix4)); + + // With instancing, impossible to select the lights for each object + // So, it's only activated for directional lights + unsigned int lightCount = m_renderQueue.directionalLights.size(); + unsigned int lightIndex = 0; + RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); + + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + for (unsigned int pass = 0; pass < passCount; ++pass) { - // Choose the lights depending on an object position and apparent radius - ChooseLights(Spheref(matrix.GetTranslation() + squaredBoundingSphere.GetPosition(), squaredBoundingSphere.radius)); - - unsigned int lightCount = m_lights.size(); - - Renderer::SetMatrix(MatrixType_World, matrix); - unsigned int lightIndex = 0; - RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it - - unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; - for (unsigned int pass = 0; pass < passCount; ++pass) + if (shaderUniforms->hasLightUniforms) { - lightCount -= std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); + unsigned int renderedLightCount = std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); + lightCount -= renderedLightCount; if (pass == 1) { @@ -726,38 +695,98 @@ namespace Nz Renderer::SetDepthFunc(RendererComparison_Equal); } - // Sends the light uniforms to the shader + // Sends the uniforms for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) - SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); - - // And we draw - drawFunc(meshData.primitiveMode, 0, indexCount); + SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset * i, freeTextureUnit + i); } - Renderer::Enable(RendererParameter_Blend, false); - Renderer::SetDepthFunc(oldDepthFunc); + const Matrix4f* instanceMatrices = &instances[0]; + unsigned int instanceCount = instances.size(); + unsigned int maxInstanceCount = instanceBuffer->GetVertexCount(); // Maximum number of instance in one batch + + while (instanceCount > 0) + { + // We compute the number of instances that we will be able to draw this time (depending on the instancing buffer size) + unsigned int renderedInstanceCount = std::min(instanceCount, maxInstanceCount); + instanceCount -= renderedInstanceCount; + + // We fill the instancing buffer with our world matrices + instanceBuffer->Fill(instanceMatrices, 0, renderedInstanceCount, true); + instanceMatrices += renderedInstanceCount; + + // And we draw + instancedDrawFunc(renderedInstanceCount, meshData.primitiveMode, 0, indexCount); + } } + + // We don't forget to disable the blending to avoid to interferering with the rest of the rendering + Renderer::Enable(RendererParameter_Blend, false); + Renderer::SetDepthFunc(oldDepthFunc); } else { - // Without instancing, we must do a draw call for each instance - // This may be faster than instancing under a certain number - // Due to the time to modify the instancing buffer - for (const Matrix4f& matrix : instances) + if (shaderUniforms->hasLightUniforms) { - Renderer::SetMatrix(MatrixType_World, matrix); - drawFunc(meshData.primitiveMode, 0, indexCount); + for (const Matrix4f& matrix : instances) + { + // Choose the lights depending on an object position and apparent radius + ChooseLights(Spheref(matrix.GetTranslation() + squaredBoundingSphere.GetPosition(), squaredBoundingSphere.radius)); + + unsigned int lightCount = m_lights.size(); + + Renderer::SetMatrix(MatrixType_World, matrix); + unsigned int lightIndex = 0; + RendererComparison oldDepthFunc = Renderer::GetDepthFunc(); // In the case where we have to change it + + unsigned int passCount = (lightCount == 0) ? 1 : (lightCount - 1) / NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS + 1; + for (unsigned int pass = 0; pass < passCount; ++pass) + { + lightCount -= std::min(lightCount, NazaraSuffixMacro(NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS, U)); + + if (pass == 1) + { + // To add the result of light computations + // We won't interfeer with materials parameters because we only render opaques objects + // (A.K.A., without blending) + // About the depth function, it must be applied only the first time + Renderer::Enable(RendererParameter_Blend, true); + Renderer::SetBlendFunc(BlendFunc_One, BlendFunc_One); + Renderer::SetDepthFunc(RendererComparison_Equal); + } + + // Sends the light uniforms to the shader + for (unsigned int i = 0; i < NAZARA_GRAPHICS_MAX_LIGHT_PER_PASS; ++i) + SendLightUniforms(shader, shaderUniforms->lightUniforms, lightIndex++, shaderUniforms->lightOffset*i, freeTextureUnit + i); + + // And we draw + drawFunc(meshData.primitiveMode, 0, indexCount); + } + + Renderer::Enable(RendererParameter_Blend, false); + Renderer::SetDepthFunc(oldDepthFunc); + } + } + else + { + // Without instancing, we must do a draw call for each instance + // This may be faster than instancing under a certain number + // Due to the time to modify the instancing buffer + for (const Matrix4f& matrix : instances) + { + Renderer::SetMatrix(MatrixType_World, matrix); + drawFunc(meshData.primitiveMode, 0, indexCount); + } } } + instances.clear(); } - instances.clear(); } + + matEntry.enabled = false; } } - // And we set the data back to zero - matEntry.enabled = false; - matEntry.instancingEnabled = false; + pipelineEntry.maxInstanceCount = 0; } } } @@ -775,6 +804,8 @@ namespace Nz { NazaraAssert(sceneData.viewer, "Invalid viewer"); + const MaterialPipeline* lastPipeline = nullptr; + const MaterialPipeline::Instance* pipelineInstance = nullptr; const Shader* lastShader = nullptr; const ShaderUniforms* shaderUniforms = nullptr; unsigned int lightCount = 0; @@ -786,9 +817,16 @@ namespace Nz // Material const Material* material = modelData.material; + const MaterialPipeline* pipeline = material->GetPipeline(); + if (pipeline != lastPipeline) + { + pipelineInstance = &pipeline->Apply(); + lastPipeline = pipeline; + } + // We begin to apply the material (and get the shader activated doing so) UInt8 freeTextureUnit; - const Shader* shader = material->Apply(0, 0, &freeTextureUnit); + const Shader* shader = material->Apply(*pipelineInstance, 0, &freeTextureUnit); // Uniforms are conserved in our program, there's no point to send them back until they change if (shader != lastShader) diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index 5e6cd72b7..6e1c3ee5f 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -63,12 +63,20 @@ namespace Nz // Initialisation of the module CallOnExit onExit(Graphics::Uninitialize); + // Materials + if (!MaterialPipeline::Initialize()) + { + NazaraError("Failed to initialize material pipelines"); + return false; + } + if (!Material::Initialize()) { NazaraError("Failed to initialize materials"); return false; } + // Renderables if (!ParticleController::Initialize()) { NazaraError("Failed to initialize particle controllers"); @@ -121,7 +129,7 @@ namespace Nz Loaders::RegisterMesh(); Loaders::RegisterTexture(); - // RenderTechniques + // Render techniques if (!DepthRenderTechnique::Initialize()) { NazaraError("Failed to initialize Depth Rendering"); @@ -213,19 +221,25 @@ namespace Nz Loaders::UnregisterMesh(); Loaders::UnregisterTexture(); - DeferredRenderTechnique::Uninitialize(); - DepthRenderTechnique::Uninitialize(); - ForwardRenderTechnique::Uninitialize(); - SkinningManager::Uninitialize(); + // Renderables ParticleRenderer::Uninitialize(); ParticleGenerator::Uninitialize(); ParticleDeclaration::Uninitialize(); ParticleController::Uninitialize(); - Material::Uninitialize(); SkyboxBackground::Uninitialize(); Sprite::Uninitialize(); TileMap::Uninitialize(); + // Render techniques + DeferredRenderTechnique::Uninitialize(); + DepthRenderTechnique::Uninitialize(); + ForwardRenderTechnique::Uninitialize(); + SkinningManager::Uninitialize(); + + // Materials + Material::Uninitialize(); + MaterialPipeline::Uninitialize(); + NazaraNotice("Uninitialized: Graphics module"); // Free of dependances diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 53e0e3e3e..b81bd82b4 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -2,40 +2,15 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#ifndef NAZARA_RENDERER_OPENGL -#define NAZARA_RENDERER_OPENGL // Mandatory to include the OpenGL headers -#endif - #include #include -#include #include -#include #include #include #include namespace Nz { - namespace - { - const UInt8 r_basicFragmentShader[] = { - #include - }; - - const UInt8 r_basicVertexShader[] = { - #include - }; - - const UInt8 r_phongLightingFragmentShader[] = { - #include - }; - - const UInt8 r_phongLightingVertexShader[] = { - #include - }; - } - /*! * \ingroup graphics * \class Nz::Material @@ -46,7 +21,6 @@ namespace Nz * \brief Checks whether the parameters for the material are correct * \return true If parameters are valid */ - bool MaterialParams::IsValid() const { if (!UberShaderLibrary::Has(shaderName)) @@ -57,41 +31,35 @@ namespace Nz /*! * \brief Applies shader to the material - * \return Constant pointer to the shader * - * \param shaderFlags Flags for the shader + * \param instance Pipeline instance to update * \param textureUnit Unit for the texture GL_TEXTURE"i" * \param lastUsedUnit Optional argument to get the last texture unit */ - - const Shader* Material::Apply(UInt32 shaderFlags, UInt8 textureUnit, UInt8* lastUsedUnit) const + void Material::Apply(const MaterialPipeline::Instance& instance, UInt8 textureUnit, UInt8* lastUsedUnit) const { - const ShaderInstance& instance = m_shaders[shaderFlags]; - if (!instance.uberInstance) - GenerateShader(shaderFlags); - - instance.uberInstance->Activate(); + const Shader* shader = instance.renderPipeline.GetInfo().shader; if (instance.uniforms[MaterialUniform_AlphaThreshold] != -1) - instance.shader->SendFloat(instance.uniforms[MaterialUniform_AlphaThreshold], m_alphaThreshold); + shader->SendFloat(instance.uniforms[MaterialUniform_AlphaThreshold], m_alphaThreshold); if (instance.uniforms[MaterialUniform_Ambient] != -1) - instance.shader->SendColor(instance.uniforms[MaterialUniform_Ambient], m_ambientColor); + shader->SendColor(instance.uniforms[MaterialUniform_Ambient], m_ambientColor); if (instance.uniforms[MaterialUniform_Diffuse] != -1) - instance.shader->SendColor(instance.uniforms[MaterialUniform_Diffuse], m_diffuseColor); + shader->SendColor(instance.uniforms[MaterialUniform_Diffuse], m_diffuseColor); if (instance.uniforms[MaterialUniform_Shininess] != -1) - instance.shader->SendFloat(instance.uniforms[MaterialUniform_Shininess], m_shininess); + shader->SendFloat(instance.uniforms[MaterialUniform_Shininess], m_shininess); if (instance.uniforms[MaterialUniform_Specular] != -1) - instance.shader->SendColor(instance.uniforms[MaterialUniform_Specular], m_specularColor); + shader->SendColor(instance.uniforms[MaterialUniform_Specular], m_specularColor); if (m_alphaMap && instance.uniforms[MaterialUniform_AlphaMap] != -1) { Renderer::SetTexture(textureUnit, m_alphaMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_AlphaMap], textureUnit); textureUnit++; } @@ -99,7 +67,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_diffuseMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_DiffuseMap], textureUnit); textureUnit++; } @@ -107,7 +75,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_emissiveMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_EmissiveMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_EmissiveMap], textureUnit); textureUnit++; } @@ -115,7 +83,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_heightMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_HeightMap], textureUnit); textureUnit++; } @@ -123,7 +91,7 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_normalMap); Renderer::SetTextureSampler(textureUnit, m_diffuseSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_NormalMap], textureUnit); textureUnit++; } @@ -131,25 +99,20 @@ namespace Nz { Renderer::SetTexture(textureUnit, m_specularMap); Renderer::SetTextureSampler(textureUnit, m_specularSampler); - instance.shader->SendInteger(instance.uniforms[MaterialUniform_SpecularMap], textureUnit); + shader->SendInteger(instance.uniforms[MaterialUniform_SpecularMap], textureUnit); textureUnit++; } - Renderer::SetRenderStates(m_states); - if (lastUsedUnit) *lastUsedUnit = textureUnit; - - return instance.shader; } /*! - * \brief Builds the material from parameters + * \brief Builds the material from a parameter list * * \param matData Data information for the material - * \param matParams Parameters for the material + * \param matParams Additional parameters for the material */ - void Material::BuildFromParameters(const ParameterList& matData, const MaterialParams& matParams) { Color color; @@ -160,7 +123,6 @@ namespace Nz ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled, true); - if (matData.GetFloatParameter(MaterialData::AlphaThreshold, &fValue)) SetAlphaThreshold(fValue); @@ -188,14 +150,11 @@ namespace Nz if (matData.GetIntegerParameter(MaterialData::FaceFilling, &iValue)) SetFaceFilling(static_cast(iValue)); - if (matData.GetBooleanParameter(MaterialData::Lighting, &isEnabled)) - EnableLighting(isEnabled); - if (matData.GetFloatParameter(MaterialData::LineWidth, &fValue)) - m_states.lineWidth = fValue; + SetLineWidth(fValue); if (matData.GetFloatParameter(MaterialData::PointSize, &fValue)) - m_states.pointSize = fValue; + SetPointSize(fValue); if (matData.GetColorParameter(MaterialData::SpecularColor, &color)) SetSpecularColor(color); @@ -206,30 +165,27 @@ namespace Nz if (matData.GetIntegerParameter(MaterialData::SrcBlend, &iValue)) SetSrcBlend(static_cast(iValue)); - if (matData.GetBooleanParameter(MaterialData::Transform, &isEnabled)) - EnableTransform(isEnabled); - // RendererParameter if (matData.GetBooleanParameter(MaterialData::Blending, &isEnabled)) - Enable(RendererParameter_Blend, isEnabled); + EnableBlending(isEnabled); if (matData.GetBooleanParameter(MaterialData::ColorWrite, &isEnabled)) - Enable(RendererParameter_ColorWrite, isEnabled); + EnableColorWrite(isEnabled); if (matData.GetBooleanParameter(MaterialData::DepthBuffer, &isEnabled)) - Enable(RendererParameter_DepthBuffer, isEnabled); + EnableDepthBuffer(isEnabled); if (matData.GetBooleanParameter(MaterialData::DepthWrite, &isEnabled)) - Enable(RendererParameter_DepthWrite, isEnabled); + EnableDepthWrite(isEnabled); if (matData.GetBooleanParameter(MaterialData::FaceCulling, &isEnabled)) - Enable(RendererParameter_FaceCulling, isEnabled); + EnableFaceCulling(isEnabled); if (matData.GetBooleanParameter(MaterialData::ScissorTest, &isEnabled)) - Enable(RendererParameter_ScissorTest, isEnabled); + EnableScissorTest(isEnabled); if (matData.GetBooleanParameter(MaterialData::StencilTest, &isEnabled)) - Enable(RendererParameter_StencilTest, isEnabled); + EnableStencilTest(isEnabled); // Samplers if (matData.GetIntegerParameter(MaterialData::DiffuseAnisotropyLevel, &iValue)) @@ -252,41 +208,43 @@ namespace Nz // Stencil if (matData.GetIntegerParameter(MaterialData::StencilCompare, &iValue)) - m_states.stencilCompare.front = static_cast(iValue); + m_pipelineInfo.stencilCompare.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilFail, &iValue)) - m_states.stencilFail.front = static_cast(iValue); + m_pipelineInfo.stencilFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilPass, &iValue)) - m_states.stencilPass.front = static_cast(iValue); + m_pipelineInfo.stencilPass.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilZFail, &iValue)) - m_states.stencilDepthFail.front = static_cast(iValue); + m_pipelineInfo.stencilDepthFail.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilMask, &iValue)) - m_states.stencilWriteMask.front = static_cast(iValue); + m_pipelineInfo.stencilWriteMask.front = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::StencilReference, &iValue)) - m_states.stencilReference.front = static_cast(iValue); + m_pipelineInfo.stencilReference.front = static_cast(iValue); // Stencil (back) if (matData.GetIntegerParameter(MaterialData::BackFaceStencilCompare, &iValue)) - m_states.stencilCompare.back = static_cast(iValue); + m_pipelineInfo.stencilCompare.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilFail, &iValue)) - m_states.stencilFail.back = static_cast(iValue); + m_pipelineInfo.stencilFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilPass, &iValue)) - m_states.stencilPass.back = static_cast(iValue); + m_pipelineInfo.stencilPass.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilZFail, &iValue)) - m_states.stencilDepthFail.back = static_cast(iValue); + m_pipelineInfo.stencilDepthFail.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilMask, &iValue)) - m_states.stencilWriteMask.back = static_cast(iValue); + m_pipelineInfo.stencilWriteMask.back = static_cast(iValue); if (matData.GetIntegerParameter(MaterialData::BackFaceStencilReference, &iValue)) - m_states.stencilReference.back = static_cast(iValue); + m_pipelineInfo.stencilReference.back = static_cast(iValue); + + InvalidatePipeline(); // Textures if (matParams.loadAlphaMap && matData.GetStringParameter(MaterialData::AlphaTexturePath, &path)) @@ -310,6 +268,11 @@ namespace Nz SetShader(matParams.shaderName); } + /*! + * \brief Builds a ParameterList with material data + * + * \param matData Destination parameter list which will receive material data + */ void Material::SaveToParameters(ParameterList* matData) { NazaraAssert(matData, "Invalid ParameterList"); @@ -323,22 +286,20 @@ namespace Nz matData->SetParameter(MaterialData::DiffuseColor, GetDiffuseColor()); matData->SetParameter(MaterialData::DstBlend, int(GetDstBlend())); matData->SetParameter(MaterialData::FaceFilling, int(GetFaceFilling())); - matData->SetParameter(MaterialData::Lighting, IsLightingEnabled()); - matData->SetParameter(MaterialData::LineWidth, GetRenderStates().lineWidth); - matData->SetParameter(MaterialData::PointSize, GetRenderStates().pointSize); + matData->SetParameter(MaterialData::LineWidth, GetLineWidth()); + matData->SetParameter(MaterialData::PointSize, GetPointSize()); matData->SetParameter(MaterialData::Shininess, GetShininess()); matData->SetParameter(MaterialData::SpecularColor, GetSpecularColor()); matData->SetParameter(MaterialData::SrcBlend, int(GetSrcBlend())); - matData->SetParameter(MaterialData::Transform, IsTransformEnabled()); // RendererParameter - matData->SetParameter(MaterialData::Blending, GetRenderStates().blending); - matData->SetParameter(MaterialData::ColorWrite, GetRenderStates().colorWrite); - matData->SetParameter(MaterialData::DepthBuffer, GetRenderStates().depthBuffer); - matData->SetParameter(MaterialData::DepthWrite, GetRenderStates().depthWrite); - matData->SetParameter(MaterialData::FaceCulling, GetRenderStates().faceCulling); - matData->SetParameter(MaterialData::ScissorTest, GetRenderStates().scissorTest); - matData->SetParameter(MaterialData::StencilTest, GetRenderStates().stencilTest); + matData->SetParameter(MaterialData::Blending, IsBlendingEnabled()); + matData->SetParameter(MaterialData::ColorWrite, IsColorWriteEnabled()); + matData->SetParameter(MaterialData::DepthBuffer, IsDepthBufferEnabled()); + matData->SetParameter(MaterialData::DepthWrite, IsDepthWriteEnabled()); + matData->SetParameter(MaterialData::FaceCulling, IsFaceCullingEnabled()); + matData->SetParameter(MaterialData::ScissorTest, IsScissorTestEnabled()); + matData->SetParameter(MaterialData::StencilTest, IsStencilTestEnabled()); // Samplers matData->SetParameter(MaterialData::DiffuseAnisotropyLevel, int(GetDiffuseSampler().GetAnisotropicLevel())); @@ -350,20 +311,20 @@ namespace Nz matData->SetParameter(MaterialData::SpecularWrap, int(GetSpecularSampler().GetWrapMode())); // Stencil - matData->SetParameter(MaterialData::StencilCompare, int(GetRenderStates().stencilCompare.front)); - matData->SetParameter(MaterialData::StencilFail, int(GetRenderStates().stencilFail.front)); - matData->SetParameter(MaterialData::StencilPass, int(GetRenderStates().stencilPass.front)); - matData->SetParameter(MaterialData::StencilZFail, int(GetRenderStates().stencilDepthFail.front)); - matData->SetParameter(MaterialData::StencilMask, int(GetRenderStates().stencilWriteMask.front)); - matData->SetParameter(MaterialData::StencilReference, int(GetRenderStates().stencilReference.front)); + matData->SetParameter(MaterialData::StencilCompare, int(GetPipelineInfo().stencilCompare.front)); + matData->SetParameter(MaterialData::StencilFail, int(GetPipelineInfo().stencilFail.front)); + matData->SetParameter(MaterialData::StencilPass, int(GetPipelineInfo().stencilPass.front)); + matData->SetParameter(MaterialData::StencilZFail, int(GetPipelineInfo().stencilDepthFail.front)); + matData->SetParameter(MaterialData::StencilMask, int(GetPipelineInfo().stencilWriteMask.front)); + matData->SetParameter(MaterialData::StencilReference, int(GetPipelineInfo().stencilReference.front)); // Stencil (back) - matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetRenderStates().stencilCompare.back)); - matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetRenderStates().stencilFail.back)); - matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetRenderStates().stencilPass.back)); - matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetRenderStates().stencilDepthFail.back)); - matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetRenderStates().stencilWriteMask.back)); - matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetRenderStates().stencilReference.back)); + matData->SetParameter(MaterialData::BackFaceStencilCompare, int(GetPipelineInfo().stencilCompare.back)); + matData->SetParameter(MaterialData::BackFaceStencilFail, int(GetPipelineInfo().stencilFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilPass, int(GetPipelineInfo().stencilPass.back)); + matData->SetParameter(MaterialData::BackFaceStencilZFail, int(GetPipelineInfo().stencilDepthFail.back)); + matData->SetParameter(MaterialData::BackFaceStencilMask, int(GetPipelineInfo().stencilWriteMask.back)); + matData->SetParameter(MaterialData::BackFaceStencilReference, int(GetPipelineInfo().stencilReference.back)); // Textures if (HasAlphaMap()) @@ -411,6 +372,8 @@ namespace Nz /*! * \brief Resets the material, cleans everything + * + * \remark Invalidates the pipeline */ void Material::Reset() { @@ -423,29 +386,22 @@ namespace Nz m_heightMap.Reset(); m_normalMap.Reset(); m_specularMap.Reset(); - m_uberShader.Reset(); - - for (ShaderInstance& instance : m_shaders) - instance.uberInstance = nullptr; m_alphaThreshold = 0.2f; - m_alphaTestEnabled = false; m_ambientColor = Color(128, 128, 128); - m_depthSortingEnabled = false; m_diffuseColor = Color::White; m_diffuseSampler = TextureSampler(); - m_lightingEnabled = true; m_shadowCastingEnabled = true; - m_shadowReceiveEnabled = true; m_shininess = 50.f; m_specularColor = Color::White; m_specularSampler = TextureSampler(); - m_states = RenderStates(); - m_states.depthBuffer = true; - m_states.faceCulling = true; - m_transformEnabled = true; + m_pipelineInfo = MaterialPipelineInfo(); + m_pipelineInfo.depthBuffer = true; + m_pipelineInfo.faceCulling = true; SetShader("Basic"); + + InvalidatePipeline(); } /*! @@ -453,24 +409,18 @@ namespace Nz * * \param material Material to copy into this */ - void Material::Copy(const Material& material) { // Copy of base states - m_alphaTestEnabled = material.m_alphaTestEnabled; m_alphaThreshold = material.m_alphaThreshold; m_ambientColor = material.m_ambientColor; - m_depthSortingEnabled = material.m_depthSortingEnabled; m_diffuseColor = material.m_diffuseColor; m_diffuseSampler = material.m_diffuseSampler; - m_lightingEnabled = material.m_lightingEnabled; + m_pipelineInfo = material.m_pipelineInfo; m_shininess = material.m_shininess; m_shadowCastingEnabled = material.m_shadowCastingEnabled; - m_shadowReceiveEnabled = material.m_shadowReceiveEnabled; m_specularColor = material.m_specularColor; m_specularSampler = material.m_specularSampler; - m_states = material.m_states; - m_transformEnabled = material.m_transformEnabled; // Copy of reference to the textures m_alphaMap = material.m_alphaMap; @@ -480,61 +430,8 @@ namespace Nz m_heightMap = material.m_heightMap; m_normalMap = material.m_normalMap; m_specularMap = material.m_specularMap; - m_uberShader = material.m_uberShader; - // We copy the instances of the shader too - std::memcpy(&m_shaders[0], &material.m_shaders[0], (ShaderFlags_Max + 1) * sizeof(ShaderInstance)); - } - - /*! - * \brief Generates the shader based on flag - * - * \param flags Flag for the shaer - */ - - void Material::GenerateShader(UInt32 flags) const - { - ParameterList list; - list.SetParameter("ALPHA_MAPPING", m_alphaMap.IsValid()); - list.SetParameter("ALPHA_TEST", m_alphaTestEnabled); - list.SetParameter("COMPUTE_TBNMATRIX", m_normalMap.IsValid() || m_heightMap.IsValid()); - list.SetParameter("DIFFUSE_MAPPING", m_diffuseMap.IsValid()); - list.SetParameter("EMISSIVE_MAPPING", m_emissiveMap.IsValid()); - list.SetParameter("LIGHTING", m_lightingEnabled); - list.SetParameter("NORMAL_MAPPING", m_normalMap.IsValid()); - list.SetParameter("PARALLAX_MAPPING", m_heightMap.IsValid()); - list.SetParameter("SHADOW_MAPPING", m_shadowReceiveEnabled); - list.SetParameter("SPECULAR_MAPPING", m_specularMap.IsValid()); - list.SetParameter("TEXTURE_MAPPING", m_alphaMap.IsValid() || m_diffuseMap.IsValid() || m_emissiveMap.IsValid() || - m_normalMap.IsValid() || m_heightMap.IsValid() || m_specularMap.IsValid() || - flags & ShaderFlags_TextureOverlay); - list.SetParameter("TRANSFORM", m_transformEnabled); - - list.SetParameter("FLAG_BILLBOARD", static_cast((flags & ShaderFlags_Billboard) != 0)); - list.SetParameter("FLAG_DEFERRED", static_cast((flags & ShaderFlags_Deferred) != 0)); - list.SetParameter("FLAG_INSTANCING", static_cast((flags & ShaderFlags_Instancing) != 0)); - list.SetParameter("FLAG_TEXTUREOVERLAY", static_cast((flags & ShaderFlags_TextureOverlay) != 0)); - list.SetParameter("FLAG_VERTEXCOLOR", static_cast((flags & ShaderFlags_VertexColor) != 0)); - - ShaderInstance& instance = m_shaders[flags]; - instance.uberInstance = m_uberShader->Get(list); - instance.shader = instance.uberInstance->GetShader(); - - #define CacheUniform(name) instance.uniforms[MaterialUniform_##name] = instance.shader->GetUniformLocation("Material" #name) - - CacheUniform(AlphaMap); - CacheUniform(AlphaThreshold); - CacheUniform(Ambient); - CacheUniform(Diffuse); - CacheUniform(DiffuseMap); - CacheUniform(EmissiveMap); - CacheUniform(HeightMap); - CacheUniform(NormalMap); - CacheUniform(Shininess); - CacheUniform(Specular); - CacheUniform(SpecularMap); - - #undef CacheUniform + InvalidatePipeline(); } /*! @@ -543,7 +440,6 @@ namespace Nz * * \remark Produces a NazaraError if the material library failed to be initialized */ - bool Material::Initialize() { if (!MaterialLibrary::Initialize()) @@ -558,67 +454,21 @@ namespace Nz return false; } - // Basic shader - { - UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); - - String fragmentShader(reinterpret_cast(r_basicFragmentShader), sizeof(r_basicFragmentShader)); - String vertexShader(reinterpret_cast(r_basicVertexShader), sizeof(r_basicVertexShader)); - - uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING"); - uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_INSTANCING FLAG_VERTEXCOLOR TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); - - UberShaderLibrary::Register("Basic", uberShader); - } - - // PhongLighting shader - { - UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); - - String fragmentShader(reinterpret_cast(r_phongLightingFragmentShader), sizeof(r_phongLightingFragmentShader)); - String vertexShader(reinterpret_cast(r_phongLightingVertexShader), sizeof(r_phongLightingVertexShader)); - - uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_DEFERRED FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING EMISSIVE_MAPPING LIGHTING NORMAL_MAPPING PARALLAX_MAPPING SHADOW_MAPPING SPECULAR_MAPPING"); - uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_DEFERRED FLAG_INSTANCING FLAG_VERTEXCOLOR COMPUTE_TBNMATRIX LIGHTING PARALLAX_MAPPING SHADOW_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); - - UberShaderLibrary::Register("PhongLighting", uberShader); - } - - // Once the base shaders are registered, we can now set some default materials s_defaultMaterial = New(); - s_defaultMaterial->Enable(RendererParameter_FaceCulling, false); + s_defaultMaterial->EnableFaceCulling(false); s_defaultMaterial->SetFaceFilling(FaceFilling_Line); MaterialLibrary::Register("Default", s_defaultMaterial); - MaterialRef mat; - - mat = New(); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - MaterialLibrary::Register("Basic2D", std::move(mat)); - - mat = New(); - mat->Enable(RendererParameter_Blend, true); - mat->Enable(RendererParameter_DepthWrite, false); - mat->Enable(RendererParameter_FaceCulling, false); - mat->EnableLighting(false); - mat->SetDstBlend(BlendFunc_InvSrcAlpha); - mat->SetSrcBlend(BlendFunc_SrcAlpha); - MaterialLibrary::Register("Translucent2D", std::move(mat)); - return true; } /*! * \brief Uninitializes the material librairies */ - void Material::Uninitialize() { s_defaultMaterial.Reset(); - UberShaderLibrary::Unregister("PhongLighting"); - UberShaderLibrary::Unregister("Basic"); + MaterialManager::Uninitialize(); MaterialLibrary::Uninitialize(); } diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp new file mode 100644 index 000000000..01e9ffe5d --- /dev/null +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -0,0 +1,168 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include + +#ifndef NAZARA_RENDERER_OPENGL +#define NAZARA_RENDERER_OPENGL // Mandatory to include the OpenGL headers +#endif + +#include +#include +#include + +namespace Nz +{ + namespace + { + const UInt8 r_basicFragmentShader[] = { + #include + }; + + const UInt8 r_basicVertexShader[] = { + #include + }; + + const UInt8 r_phongLightingFragmentShader[] = { + #include + }; + + const UInt8 r_phongLightingVertexShader[] = { + #include + }; + } + + /*! + * \ingroup graphics + * \class Nz::MaterialPipeline + * + * \brief Graphics class used to contains all rendering states that are not allowed to change individually on rendering devices + */ + + /*! + * \brief Returns a reference to a MaterialPipeline built with MaterialPipelineInfo + * + * This function is using a cache, calling it multiples times with the same MaterialPipelineInfo will returns references to a single MaterialPipeline + * + * \param pipelineInfo Pipeline informations used to build/retrieve a MaterialPipeline object + */ + MaterialPipelineRef MaterialPipeline::GetPipeline(const MaterialPipelineInfo& pipelineInfo) + { + auto it = s_pipelineCache.lower_bound(pipelineInfo); + if (it == s_pipelineCache.end() || it->first != pipelineInfo) + it = s_pipelineCache.insert(it, PipelineCache::value_type(pipelineInfo, New(pipelineInfo))); + + return it->second; + } + + void MaterialPipeline::GenerateRenderPipeline(UInt32 flags) const + { + ParameterList list; + list.SetParameter("ALPHA_MAPPING", m_pipelineInfo.hasAlphaMap); + list.SetParameter("ALPHA_TEST", m_pipelineInfo.alphaTest); + list.SetParameter("COMPUTE_TBNMATRIX", m_pipelineInfo.hasNormalMap || m_pipelineInfo.hasHeightMap); + list.SetParameter("DIFFUSE_MAPPING", m_pipelineInfo.hasDiffuseMap); + list.SetParameter("EMISSIVE_MAPPING", m_pipelineInfo.hasEmissiveMap); + list.SetParameter("NORMAL_MAPPING", m_pipelineInfo.hasNormalMap); + list.SetParameter("PARALLAX_MAPPING", m_pipelineInfo.hasHeightMap); + list.SetParameter("SHADOW_MAPPING", m_pipelineInfo.shadowReceive); + list.SetParameter("SPECULAR_MAPPING", m_pipelineInfo.hasSpecularMap); + list.SetParameter("TEXTURE_MAPPING", m_pipelineInfo.hasAlphaMap || m_pipelineInfo.hasDiffuseMap || m_pipelineInfo.hasEmissiveMap || + m_pipelineInfo.hasNormalMap || m_pipelineInfo.hasHeightMap || m_pipelineInfo.hasSpecularMap || + flags & ShaderFlags_TextureOverlay); + list.SetParameter("TRANSFORM", true); + + list.SetParameter("FLAG_BILLBOARD", static_cast((flags & ShaderFlags_Billboard) != 0)); + list.SetParameter("FLAG_DEFERRED", static_cast((flags & ShaderFlags_Deferred) != 0)); + list.SetParameter("FLAG_INSTANCING", static_cast((flags & ShaderFlags_Instancing) != 0)); + list.SetParameter("FLAG_TEXTUREOVERLAY", static_cast((flags & ShaderFlags_TextureOverlay) != 0)); + list.SetParameter("FLAG_VERTEXCOLOR", static_cast((flags & ShaderFlags_VertexColor) != 0)); + + Instance& instance = m_instances[flags]; + instance.uberInstance = m_pipelineInfo.uberShader->Get(list); + + RenderPipelineInfo renderPipelineInfo; + static_cast(renderPipelineInfo).operator=(m_pipelineInfo); // Not my proudest line + + renderPipelineInfo.shader = instance.uberInstance->GetShader(); + + instance.renderPipeline.Create(renderPipelineInfo); + + #define CacheUniform(name) instance.uniforms[MaterialUniform_##name] = renderPipelineInfo.shader->GetUniformLocation("Material" #name) + + CacheUniform(AlphaMap); + CacheUniform(AlphaThreshold); + CacheUniform(Ambient); + CacheUniform(Diffuse); + CacheUniform(DiffuseMap); + CacheUniform(EmissiveMap); + CacheUniform(HeightMap); + CacheUniform(NormalMap); + CacheUniform(Shininess); + CacheUniform(Specular); + CacheUniform(SpecularMap); + + #undef CacheUniform + } + + bool MaterialPipeline::Initialize() + { + // Basic shader + { + UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); + + String fragmentShader(reinterpret_cast(r_basicFragmentShader), sizeof(r_basicFragmentShader)); + String vertexShader(reinterpret_cast(r_basicVertexShader), sizeof(r_basicVertexShader)); + + uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING"); + uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_INSTANCING FLAG_VERTEXCOLOR TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); + + UberShaderLibrary::Register("Basic", uberShader); + } + + // PhongLighting shader + { + UberShaderPreprocessorRef uberShader = UberShaderPreprocessor::New(); + + String fragmentShader(reinterpret_cast(r_phongLightingFragmentShader), sizeof(r_phongLightingFragmentShader)); + String vertexShader(reinterpret_cast(r_phongLightingVertexShader), sizeof(r_phongLightingVertexShader)); + + uberShader->SetShader(ShaderStageType_Fragment, fragmentShader, "FLAG_DEFERRED FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING EMISSIVE_MAPPING NORMAL_MAPPING PARALLAX_MAPPING SHADOW_MAPPING SPECULAR_MAPPING"); + uberShader->SetShader(ShaderStageType_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_DEFERRED FLAG_INSTANCING FLAG_VERTEXCOLOR COMPUTE_TBNMATRIX PARALLAX_MAPPING SHADOW_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH"); + + UberShaderLibrary::Register("PhongLighting", uberShader); + } + + // Once the base shaders are registered, we can now set some default materials + MaterialPipelineInfo pipelineInfo; + + // Basic 2D - No depth write/face culling + pipelineInfo.depthWrite = false; + pipelineInfo.faceCulling = false; + + MaterialPipelineLibrary::Register("Basic2D", GetPipeline(pipelineInfo)); + + // Translucent 2D - Alpha blending with no depth write/face culling + pipelineInfo.blending = false; + pipelineInfo.depthWrite = false; + pipelineInfo.faceCulling = false; + pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; + pipelineInfo.srcBlend = BlendFunc_SrcAlpha; + + MaterialPipelineLibrary::Register("Translucent2D", GetPipeline(pipelineInfo)); + + return true; + } + + void MaterialPipeline::Uninitialize() + { + s_pipelineCache.clear(); + UberShaderLibrary::Unregister("PhongLighting"); + UberShaderLibrary::Unregister("Basic"); + MaterialPipelineLibrary::Uninitialize(); + } + + MaterialPipelineLibrary::LibraryMap MaterialPipeline::s_library; + MaterialPipeline::PipelineCache MaterialPipeline::s_pipelineCache; +} \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index 61ed69632..a3391be91 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -132,7 +132,7 @@ void main() vec2 texCoord = vTexCoord; #endif -#if LIGHTING && PARALLAX_MAPPING +#if PARALLAX_MAPPING float height = texture(MaterialHeightMap, texCoord).r; float v = height*ParallaxScale + ParallaxBias; @@ -159,17 +159,16 @@ void main() discard; #endif // ALPHA_TEST - #if LIGHTING - #if NORMAL_MAPPING + #if NORMAL_MAPPING vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0)); - #else + #else vec3 normal = normalize(vNormal); - #endif // NORMAL_MAPPING + #endif // NORMAL_MAPPING vec3 specularColor = MaterialSpecular.rgb; - #if SPECULAR_MAPPING + #if SPECULAR_MAPPING specularColor *= texture(MaterialSpecularMap, texCoord).rgb; - #endif + #endif /* Texture0: Diffuse Color + Specular @@ -179,9 +178,6 @@ void main() RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11))); RenderTarget1 = vec4(EncodeNormal(normal)); RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf - #else // LIGHTING - RenderTarget0 = vec4(diffuseColor.rgb, 0.0); - #endif #else // FLAG_DEFERRED #if ALPHA_MAPPING diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r; @@ -192,16 +188,15 @@ void main() discard; #endif - #if LIGHTING vec3 lightAmbient = vec3(0.0); vec3 lightDiffuse = vec3(0.0); vec3 lightSpecular = vec3(0.0); - #if NORMAL_MAPPING + #if NORMAL_MAPPING vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0)); - #else + #else vec3 normal = normalize(vNormal); - #endif + #endif if (MaterialShininess > 0.0) { @@ -459,24 +454,21 @@ void main() } lightSpecular *= MaterialSpecular.rgb; - #if SPECULAR_MAPPING + #if SPECULAR_MAPPING lightSpecular *= texture(MaterialSpecularMap, texCoord).rgb; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens - #endif + #endif vec3 lightColor = (lightAmbient + lightDiffuse + lightSpecular); vec4 fragmentColor = vec4(lightColor, 1.0) * diffuseColor; - #if EMISSIVE_MAPPING + #if EMISSIVE_MAPPING float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11)); vec3 emissionColor = MaterialDiffuse.rgb * texture(MaterialEmissiveMap, texCoord).rgb; RenderTarget0 = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a); - #else - RenderTarget0 = fragmentColor; - #endif // EMISSIVE_MAPPING #else - RenderTarget0 = diffuseColor; - #endif // LIGHTING + RenderTarget0 = fragmentColor; + #endif // EMISSIVE_MAPPING #endif // FLAG_DEFERRED } diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index 6f1495308..c77a33db2 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,9,35,101,108,115,101,32,47,47,32,76,73,71,72,84,73,78,71,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,48,46,48,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,76,73,71,72,84,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,10,35,101,110,100,105,102,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,99,111,108,111,114,59,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,10,125,59,10,10,47,47,32,76,117,109,105,195,168,114,101,115,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,10,47,47,32,77,97,116,195,169,114,105,97,117,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,47,47,32,65,117,116,114,101,115,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,10,123,10,9,118,101,99,51,32,99,111,108,111,114,59,10,10,9,102,32,42,61,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,10,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,10,125,10,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,10,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,10,123,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,10,125,10,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,10,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,10,125,10,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,10,9,102,108,111,97,116,32,120,44,121,59,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,10,9,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,10,125,10,35,101,110,100,105,102,10,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,10,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,35,101,108,115,101,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,10,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,10,35,101,110,100,105,102,10,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,9,35,101,110,100,105,102,10,9,9,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,35,101,110,100,105,102,10,10,9,47,42,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,10,9,42,47,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,10,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,35,101,110,100,105,102,10,9,9,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,125,10,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert index 0f4c869a6..8943c5935 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert @@ -12,6 +12,7 @@ in vec3 VertexPosition; in vec3 VertexNormal; in vec3 VertexTangent; in vec2 VertexTexCoord; +in vec4 VertexUserdata0; /********************Sortant********************/ out vec4 vColor; @@ -27,6 +28,7 @@ uniform vec3 EyePosition; uniform mat4 InvViewMatrix; uniform mat4 LightViewProjMatrix[3]; uniform float VertexDepth; +uniform mat4 ViewMatrix; uniform mat4 ViewProjMatrix; uniform mat4 WorldMatrix; uniform mat4 WorldViewProjMatrix; @@ -107,21 +109,19 @@ void main() vColor = color; -#if LIGHTING - #if FLAG_INSTANCING +#if FLAG_INSTANCING mat3 rotationMatrix = mat3(InstanceData0); - #else +#else mat3 rotationMatrix = mat3(WorldMatrix); - #endif +#endif - #if COMPUTE_TBNMATRIX +#if COMPUTE_TBNMATRIX vec3 binormal = cross(VertexNormal, VertexTangent); vLightToWorld[0] = normalize(rotationMatrix * VertexTangent); vLightToWorld[1] = normalize(rotationMatrix * binormal); vLightToWorld[2] = normalize(rotationMatrix * VertexNormal); - #else +#else vNormal = normalize(rotationMatrix * VertexNormal); - #endif #endif #if SHADOW_MAPPING @@ -133,12 +133,12 @@ void main() vTexCoord = VertexTexCoord; #endif -#if LIGHTING && PARALLAX_MAPPING +#if PARALLAX_MAPPING vViewDir = EyePosition - VertexPosition; vViewDir *= vLightToWorld; #endif -#if LIGHTING && !FLAG_DEFERRED +#if !FLAG_DEFERRED #if FLAG_INSTANCING vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0)); #else diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h index c1611105a..bed6edcab 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.vert.h @@ -1 +1 @@ -47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,13,10,9,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,13,10,9,35,101,110,100,105,102,13,10,9,13,10,9,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,13,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,76,73,71,72,84,73,78,71,32,38,38,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file +47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,105,110,32,118,101,99,51,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,32,47,47,32,99,101,110,116,101,114,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,49,59,32,47,47,32,115,105,122,101,32,124,32,115,105,110,32,99,111,115,13,10,105,110,32,118,101,99,52,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,32,47,47,32,99,111,108,111,114,13,10,35,101,108,115,101,13,10,105,110,32,109,97,116,52,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,35,101,110,100,105,102,13,10,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,84,97,110,103,101,110,116,59,13,10,105,110,32,118,101,99,50,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,52,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,111,117,116,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,111,117,116,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,111,117,116,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,111,117,116,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,111,117,116,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,111,117,116,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,51,93,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,86,101,114,116,101,120,68,101,112,116,104,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,35,105,102,32,70,76,65,71,95,86,69,82,84,69,88,67,79,76,79,82,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,86,101,114,116,101,120,67,111,108,111,114,59,13,10,35,101,108,115,101,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,118,101,99,52,40,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,115,59,13,10,13,10,35,105,102,32,70,76,65,71,95,66,73,76,76,66,79,65,82,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,101,99,51,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,49,46,122,119,59,13,10,9,118,101,99,52,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,50,59,13,10,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,98,105,108,108,98,111,97,114,100,67,101,110,116,101,114,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,99,111,108,111,114,32,61,32,98,105,108,108,98,111,97,114,100,67,111,108,111,114,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,32,43,32,48,46,53,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,32,45,32,48,46,53,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,122,101,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,120,121,59,13,10,9,118,101,99,50,32,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,32,61,32,86,101,114,116,101,120,85,115,101,114,100,97,116,97,48,46,122,119,59,13,10,9,13,10,9,118,101,99,50,32,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,45,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,32,61,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,121,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,121,32,43,32,98,105,108,108,98,111,97,114,100,67,111,114,110,101,114,46,120,42,98,105,108,108,98,111,97,114,100,83,105,110,67,111,115,46,120,59,13,10,9,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,32,42,61,32,98,105,108,108,98,111,97,114,100,83,105,122,101,59,13,10,13,10,9,118,101,99,51,32,99,97,109,101,114,97,82,105,103,104,116,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,48,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,48,93,41,59,13,10,9,118,101,99,51,32,99,97,109,101,114,97,85,112,32,61,32,118,101,99,51,40,86,105,101,119,77,97,116,114,105,120,91,48,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,49,93,91,49,93,44,32,86,105,101,119,77,97,116,114,105,120,91,50,93,91,49,93,41,59,13,10,9,118,101,99,51,32,118,101,114,116,101,120,80,111,115,32,61,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,32,43,32,99,97,109,101,114,97,82,105,103,104,116,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,120,32,43,32,99,97,109,101,114,97,85,112,42,114,111,116,97,116,101,100,80,111,115,105,116,105,111,110,46,121,59,13,10,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,101,114,116,101,120,80,111,115,44,32,49,46,48,41,59,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,9,35,101,110,100,105,102,13,10,9,116,101,120,67,111,111,114,100,115,46,121,32,61,32,49,46,48,32,45,32,116,101,120,67,111,111,114,100,115,46,121,59,13,10,35,101,108,115,101,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,108,115,101,13,10,9,9,35,105,102,32,84,82,65,78,83,70,79,82,77,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,35,101,108,115,101,13,10,9,9,9,35,105,102,32,85,78,73,70,79,82,77,95,86,69,82,84,69,88,95,68,69,80,84,72,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,46,120,121,44,32,86,101,114,116,101,120,68,101,112,116,104,44,32,49,46,48,41,59,13,10,9,9,9,35,101,108,115,101,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,9,9,9,35,101,110,100,105,102,13,10,9,9,35,101,110,100,105,102,13,10,9,35,101,110,100,105,102,13,10,13,10,9,116,101,120,67,111,111,114,100,115,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,9,118,67,111,108,111,114,32,61,32,99,111,108,111,114,59,13,10,13,10,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,41,59,13,10,35,101,108,115,101,13,10,9,109,97,116,51,32,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,61,32,109,97,116,51,40,87,111,114,108,100,77,97,116,114,105,120,41,59,13,10,35,101,110,100,105,102,13,10,9,13,10,35,105,102,32,67,79,77,80,85,84,69,95,84,66,78,77,65,84,82,73,88,13,10,9,118,101,99,51,32,98,105,110,111,114,109,97,108,32,61,32,99,114,111,115,115,40,86,101,114,116,101,120,78,111,114,109,97,108,44,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,48,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,84,97,110,103,101,110,116,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,49,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,98,105,110,111,114,109,97,108,41,59,13,10,9,118,76,105,103,104,116,84,111,87,111,114,108,100,91,50,93,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,35,101,108,115,101,13,10,9,118,78,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,114,111,116,97,116,105,111,110,77,97,116,114,105,120,32,42,32,86,101,114,116,101,120,78,111,114,109,97,108,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,105,93,32,61,32,76,105,103,104,116,86,105,101,119,80,114,111,106,77,97,116,114,105,120,91,105,93,32,42,32,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,84,69,88,84,85,82,69,95,77,65,80,80,73,78,71,13,10,9,118,84,101,120,67,111,111,114,100,32,61,32,86,101,114,116,101,120,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,118,86,105,101,119,68,105,114,32,61,32,69,121,101,80,111,115,105,116,105,111,110,32,45,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,32,13,10,9,118,86,105,101,119,68,105,114,32,42,61,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,33,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,70,76,65,71,95,73,78,83,84,65,78,67,73,78,71,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,73,110,115,116,97,110,99,101,68,97,116,97,48,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,87,111,114,108,100,80,111,115,32,61,32,118,101,99,51,40,87,111,114,108,100,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,41,59,13,10,9,35,101,110,100,105,102,13,10,35,101,110,100,105,102,13,10,125,13,10, \ No newline at end of file From 465801836d132cca566500b406f3175e5f9c1647 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Aug 2016 22:58:14 +0200 Subject: [PATCH 186/383] Graphics: Fix build Former-commit-id: f90f824361033d6accd56e6f11262c7f7bbc72d0 [formerly 7578444e26141f23e5f501d2f0deb1e60fc9e0fa] [formerly 94496fe3569ab91a47b46b9c5190f8e713df1bcd [formerly b5229f1ec2d406c8c6dee27b49664ce06784f649]] Former-commit-id: 1b1a32242c7b6db509cf0a042974ccd8f60e6b46 [formerly 4bc3be4a64b03d166c685164a80ca332dc52ae56] Former-commit-id: 1089d9778bd3060c453eb1b64c0c1259bb290ca8 --- src/Nazara/Graphics/ForwardRenderTechnique.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index aad29ab88..91507ee68 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -824,11 +824,12 @@ namespace Nz lastPipeline = pipeline; } - // We begin to apply the material (and get the shader activated doing so) + // We begin to apply the material UInt8 freeTextureUnit; - const Shader* shader = material->Apply(*pipelineInstance, 0, &freeTextureUnit); + material->Apply(*pipelineInstance, 0, &freeTextureUnit); // Uniforms are conserved in our program, there's no point to send them back until they change + const Shader* shader = pipelineInstance->uberInstance->GetShader(); if (shader != lastShader) { // Index of uniforms in the shader From 55d14a8b8866295d95abe508ecd287fcd847d4db Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 6 Aug 2016 01:07:09 +0200 Subject: [PATCH 187/383] Graphics/ParticleGroup: Emitters are now updated in case of move and removed in case of release Former-commit-id: ade351eb66716c1870de6450e6e499a927cd40b5 [formerly 0fa763b512136b5eea96269b7d60dffd350ec990] [formerly 8d17f072fb762cc7ff17752ed63d87613d69584e [formerly f5df4cfe375057859d62096fd01c20b5f3cdefba]] Former-commit-id: 1e248d44ea1aaf65711c033e0a716220d22ee3f8 [formerly db200dbdbd6c8a12c0445476477061ad6bd26323] Former-commit-id: c3d6857dac1325bc9b62bbc1503987253c3cad68 --- include/Nazara/Graphics/ParticleEmitter.hpp | 4 +- include/Nazara/Graphics/ParticleGroup.hpp | 12 +++++- src/Nazara/Graphics/ParticleEmitter.cpp | 8 ++++ src/Nazara/Graphics/ParticleGroup.cpp | 42 ++++++++++++++++++--- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index b7a168262..8bd26a4bd 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -20,7 +20,7 @@ namespace Nz { public: ParticleEmitter(); - ParticleEmitter(const ParticleEmitter& emitter) = default; + ParticleEmitter(const ParticleEmitter& emitter); ParticleEmitter(ParticleEmitter&& emitter); virtual ~ParticleEmitter(); @@ -40,7 +40,7 @@ namespace Nz ParticleEmitter& operator=(ParticleEmitter&& emitter); // Signals: - NazaraSignal(OnParticleEmitterMove, const ParticleEmitter* /*oldParticleEmitter*/, const ParticleEmitter* /*newParticleEmitter*/); + NazaraSignal(OnParticleEmitterMove, ParticleEmitter* /*oldParticleEmitter*/, ParticleEmitter* /*newParticleEmitter*/); NazaraSignal(OnParticleEmitterRelease, const ParticleEmitter* /*particleEmitter*/); private: diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 4d4704171..9e48d5797 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -68,12 +68,22 @@ namespace Nz private: void MakeBoundingVolume() const override; + void OnEmitterMove(ParticleEmitter* oldEmitter, ParticleEmitter* newEmitter); + void OnEmitterRelease(const ParticleEmitter* emitter); void ResizeBuffer(); + struct EmitterEntry + { + NazaraSlot(ParticleEmitter, OnParticleEmitterMove, moveSlot); + NazaraSlot(ParticleEmitter, OnParticleEmitterRelease, releaseSlot); + + ParticleEmitter* emitter; + }; + std::set> m_dyingParticles; mutable std::vector m_buffer; std::vector m_controllers; - std::vector m_emitters; + std::vector m_emitters; std::vector m_generators; ParticleDeclarationConstRef m_declaration; ParticleRendererRef m_renderer; diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index 10f057dce..fe27575e7 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -32,6 +32,14 @@ namespace Nz { } + ParticleEmitter::ParticleEmitter(const ParticleEmitter& emitter) : + m_lagCompensationEnabled(emitter.m_lagCompensationEnabled), + m_emissionAccumulator(0.f), + m_emissionRate(emitter.m_emissionRate), + m_emissionCount(emitter.m_emissionCount) + { + } + ParticleEmitter::ParticleEmitter(ParticleEmitter&& emitter) : m_lagCompensationEnabled(emitter.m_lagCompensationEnabled), m_emissionAccumulator(0.f), diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index 87dbb390c..5aca6c2b4 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -109,7 +109,12 @@ namespace Nz { NazaraAssert(emitter, "Invalid particle emitter"); - m_emitters.emplace_back(emitter); + EmitterEntry entry; + entry.emitter = emitter; + entry.moveSlot.Connect(emitter->OnParticleEmitterMove, this, &ParticleGroup::OnEmitterMove); + entry.releaseSlot.Connect(emitter->OnParticleEmitterRelease, this, &ParticleGroup::OnEmitterRelease); + + m_emitters.emplace_back(std::move(entry)); } /*! @@ -336,9 +341,14 @@ namespace Nz void ParticleGroup::RemoveEmitter(ParticleEmitter* emitter) { - auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter); - if (it != m_emitters.end()) - m_emitters.erase(it); + for (auto it = m_emitters.begin(); it != m_emitters.end(); ++it) + { + if (it->emitter == emitter) + { + m_emitters.erase(it); + break; + } + } } /*! @@ -374,8 +384,8 @@ namespace Nz void ParticleGroup::Update(float elapsedTime) { // Emission - for (ParticleEmitter* emitter : m_emitters) - emitter->Emit(*this, elapsedTime); + for (const EmitterEntry& entry : m_emitters) + entry.emitter->Emit(*this, elapsedTime); // Update if (m_particleCount > 0) @@ -443,6 +453,26 @@ namespace Nz m_boundingVolume.MakeInfinite(); } + void ParticleGroup::OnEmitterMove(ParticleEmitter* oldEmitter, ParticleEmitter* newEmitter) + { + for (EmitterEntry& entry : m_emitters) + { + if (entry.emitter == oldEmitter) + entry.emitter = newEmitter; + } + } + + void ParticleGroup::OnEmitterRelease(const ParticleEmitter* emitter) + { + for (auto it = m_emitters.begin(); it != m_emitters.end();) + { + if (it->emitter == emitter) + it = m_emitters.erase(it); + else + ++it; + } + } + /*! * \brief Resizes the internal buffer * From 715355628e6618d5eaa654bdac9a681b9800dfe9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 6 Aug 2016 01:09:13 +0200 Subject: [PATCH 188/383] Sdk/ParticleEmitterComponent: Update emitter (they are no longer attached to groups) They are no longer attached to groups, groups attach emitters Former-commit-id: c3a9f015dd46be1a4344c034ea2a191f0328acae [formerly 8e342bc0982853cf376535bf196e7ab8876301eb] [formerly b7c3afed37877838e2e7caefa28d7c1b4bf654a9 [formerly 886646b5d5f90b63b7af6942d693bdaab4db441d]] Former-commit-id: 85cb514f954ba68699022e73f7fbe1ad4cfd036e [formerly 6247fbfeb86c09464b27bfc11fa4a5e059d63065] Former-commit-id: 1d8badfef268dbdecdeda8ad91e988b3f936b865 --- .../Components/ParticleEmitterComponent.hpp | 17 +++---- .../Components/ParticleEmitterComponent.inl | 10 ++++ .../Components/ParticleEmitterComponent.cpp | 46 +------------------ 3 files changed, 18 insertions(+), 55 deletions(-) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp index 8d93e0495..6ad3e3981 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.hpp +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.hpp @@ -19,28 +19,23 @@ namespace Ndk public: using SetupFunc = std::function; - ParticleEmitterComponent(Nz::ParticleGroup* group); - ParticleEmitterComponent(const ParticleEmitterComponent& emitter); - ParticleEmitterComponent(ParticleEmitterComponent&& emitter); - ~ParticleEmitterComponent(); + inline ParticleEmitterComponent(); + ParticleEmitterComponent(const ParticleEmitterComponent& emitter) = default; + ParticleEmitterComponent(ParticleEmitterComponent&& emitter) = default; + ~ParticleEmitterComponent() = default; + + void Enable(bool active = true); inline bool IsActive() const; - void SetActive(bool active = true); - void SetGroup(Nz::ParticleGroup* group); inline void SetSetupFunc(SetupFunc func); static ComponentIndex componentIndex; private: - void OnParticleGroupRelease(const Nz::ParticleGroup* particleGroup); - void SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const override; - NazaraSlot(Nz::ParticleGroup, OnParticleGroupRelease, m_particleGroupRelease); - SetupFunc m_setupFunc; - Nz::ParticleGroup* m_particleGroup; bool m_isActive; }; } diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NDK/Components/ParticleEmitterComponent.inl index 6cc9e8c29..342b5e56f 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.inl +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.inl @@ -6,6 +6,16 @@ namespace Ndk { + inline ParticleEmitterComponent::ParticleEmitterComponent() : + m_isActive(true) + { + } + + inline void Ndk::ParticleEmitterComponent::Enable(bool active) + { + m_isActive = active; + } + inline bool ParticleEmitterComponent::IsActive() const { return m_isActive; diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp index 6a3cfeb7e..2ae4365e6 100644 --- a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp +++ b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp @@ -7,51 +7,9 @@ namespace Ndk { - ParticleEmitterComponent::ParticleEmitterComponent(Nz::ParticleGroup* group) : - m_particleGroup(group), - m_isActive(true) + void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const { - if (m_particleGroup) - m_particleGroup->AddEmitter(this); - } - - ParticleEmitterComponent::ParticleEmitterComponent(const ParticleEmitterComponent& emitter) : - m_particleGroup(emitter.m_particleGroup), - m_isActive(emitter.m_isActive) - { - if (m_isActive) - m_particleGroup->AddEmitter(this); - } - - ParticleEmitterComponent::~ParticleEmitterComponent() - { - m_particleGroup->RemoveEmitter(this); - } - - inline void Ndk::ParticleEmitterComponent::SetActive(bool active) - { - if (m_isActive != active) - { - if (active) - m_particleGroup->AddEmitter(this); - else - m_particleGroup->RemoveEmitter(this); - } - } - - void ParticleEmitterComponent::SetGroup(Nz::ParticleGroup* group) - { - if (m_particleGroup) - m_particleGroup->RemoveEmitter(this); - - m_particleGroup = group; - if (m_particleGroup && m_isActive) - m_particleGroup = group; - } - - inline void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const - { - if (m_setupFunc) + if (m_isActive && m_setupFunc) m_setupFunc(m_entity, mapper, count); } From cae38ffbac879ad78f4f10364327db92dc0fb85c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 6 Aug 2016 01:11:05 +0200 Subject: [PATCH 189/383] Sdk/LuaBinding: Fix Vector3 constructor Former-commit-id: 7f0539d0465ba9309c69bf80a14351f7dee63ec5 [formerly 8f24db083650581423ba6535051778d7497313d0] [formerly 8fdec67a71994305b5ea876e3e0a35cecd2d8917 [formerly c549961cb2597c6adca61c257c731b8ac7037953]] Former-commit-id: 949ad572fb7f2f9a5b80a98a13d6bbd202b04853 [formerly a056600b068abcca888951aa950021f968f7fd00] Former-commit-id: 3bb8567bf2e99db24f1cb307778938237c1cc91b --- SDK/src/NDK/LuaBinding_Math.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index 7db9ae9e2..c1d7b487e 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -205,7 +205,7 @@ namespace Ndk { case Nz::LuaType_Number: { - long long index = lua.CheckInteger(1); + auto index = lua.CheckBoundInteger(1); if (index < 1 || index > 4) return false; @@ -258,7 +258,7 @@ namespace Ndk { case Nz::LuaType_Number: { - long long index = lua.CheckInteger(1); + auto index = lua.CheckBoundInteger(1); if (index < 1 || index > 4) return false; @@ -537,11 +537,12 @@ namespace Ndk case 0: case 3: Nz::PlacementNew(vector, lua.CheckNumber(1, 0.0), lua.CheckNumber(2, 0.0), lua.CheckNumber(3, 0.0)); + return true; case 1: { if (lua.IsOfType(1, Nz::LuaType_Number)) - Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.ToUserdata(1))); + Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(1, "Vector2"))); else if (lua.IsOfType(1, "Vector2")) Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); else if (lua.IsOfType(1, "Vector3")) From 77e822b954ff0675b9b3d2a4bb97c5fdc4047ab2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 9 Aug 2016 00:08:31 +0200 Subject: [PATCH 190/383] Utility/OBJParser: Fix failure to load some OBJ because of their "high error rate" Former-commit-id: 000e1e453f889ef686e2cc988e335c6e17d72224 [formerly d2e54a6c3a0ae7576b1ead3b9a5842d1cd75391e] [formerly c7e66ca673942b97a798fb60ddb900e74a2b5de1 [formerly 310b53ffe51db23112d2d1ed645515f48f51145f]] Former-commit-id: 1b33bf9ddaa0054a69b05fac297c0457b1125e53 [formerly c1928b6f285b4c255f8746671175733b954e99f9] Former-commit-id: 10c0e65d6e983909e70a66349bb6e688b2557512 --- include/Nazara/Utility/Formats/OBJParser.inl | 2 +- src/Nazara/Utility/Formats/OBJParser.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index 054d57754..b04506fdf 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -179,7 +179,7 @@ namespace Nz m_errorCount++; - if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50) + if (m_errorCount > 10 && (m_errorCount * 100 / m_lineCount) > 50) { NazaraError("Aborting parsing because of error percentage"); return false; //< Abort parsing if error percentage is too high diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 7d3019c39..403950a97 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -31,6 +31,7 @@ namespace Nz String matName, meshName; matName = meshName = "default"; + m_errorCount = 0; m_keepLastLine = false; m_lineCount = 0; m_meshes.clear(); From 634c146038c1c9d8a720eb4e8c3349a904ca527d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 9 Aug 2016 00:08:57 +0200 Subject: [PATCH 191/383] SDK/VelocitySystem: Make VelocitySystem move the node in the global space Former-commit-id: 08ebdc2f27d0db5593bdc8015f5a015b8f0c00d1 [formerly ce4757ee938c9650369249cbfe5ebbafa913e23b] [formerly 9a39f1cef2d4c8b84b606a0f09a06b10e0a0a4e6 [formerly b76eea176c029afc16ce82441b495f15c6336223]] Former-commit-id: a22651c5e792ef56ab07faf41f6915dfd06987f4 [formerly 0b739de8689d6718e123915d5b4f78d8c96a96dc] Former-commit-id: 4630834309173de5f659a14fe98d7eaedd0430bd --- SDK/src/NDK/Systems/VelocitySystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/Systems/VelocitySystem.cpp b/SDK/src/NDK/Systems/VelocitySystem.cpp index 882b45728..2d3264039 100644 --- a/SDK/src/NDK/Systems/VelocitySystem.cpp +++ b/SDK/src/NDK/Systems/VelocitySystem.cpp @@ -22,7 +22,7 @@ namespace Ndk NodeComponent& node = entity->GetComponent(); const VelocityComponent& velocity = entity->GetComponent(); - node.Move(velocity.linearVelocity * elapsedTime); + node.Move(velocity.linearVelocity * elapsedTime, Nz::CoordSys_Global); } } From 021ddffdea9c9616580d0a3f3b30dcb075da3abf Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 14:08:20 +0200 Subject: [PATCH 192/383] Graphics: Deferred Shading is back! Former-commit-id: b231aa4a5c13be870e334ab7b780317b3fb5e94e [formerly f155bbf9fab223b7f6a931f70361ddde63ef5d46] [formerly 002dcb36444c752d9cdbaf70b255008073a8670f [formerly b37e872dcca19c3607e318f2032f7842a7698d6d]] Former-commit-id: eee04dd3b14e7b1049e1662156de19683e5c2b14 [formerly ccd0956ed19b806581237aef58416e8338544875] Former-commit-id: 09c603760da3c4edc512e3fd311f2702a2ebe180 --- src/Nazara/Graphics/DeferredRenderQueue.cpp | 2 ++ src/Nazara/Renderer/RenderTexture.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 8623904a6..7d214b217 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -239,6 +239,8 @@ namespace Nz std::vector& instances = it2->second.instances; instances.push_back(transformMatrix); + + materialEntry.maxInstanceCount = std::max(materialEntry.maxInstanceCount, instances.size()); } } diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp index c6e78df86..647b8ff91 100644 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ b/src/Nazara/Renderer/RenderTexture.cpp @@ -588,7 +588,7 @@ namespace Nz std::memcpy(&m_impl->colorTargets[0], targets, targetCount*sizeof(UInt8)); m_impl->userDefinedTargets = true; - InvalidateDrawBuffers(); + InvalidateTargets(); } void RenderTexture::SetColorTargets(const std::initializer_list& targets) const @@ -614,7 +614,7 @@ namespace Nz *ptr++ = index; m_impl->userDefinedTargets = true; - InvalidateDrawBuffers(); + InvalidateTargets(); } void RenderTexture::Unlock() const From 767a0feda010efcf7cd3517e448915d50e199bd2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 14:09:48 +0200 Subject: [PATCH 193/383] Sdk/RenderSystem: Make ChangeRenderTechnique return a reference to the render technique Former-commit-id: f97e9d4a3048c0dfd934b263fd2e3facdec1f839 [formerly 856e89966d172f0cc55a6b7d6dbe0f33f0dad493] [formerly 2c537c041b5c32831d034e5de8a9b738597c5ee8 [formerly 6c47f159c502de0b37d8c0847dd6b6ece1df321b]] Former-commit-id: 820d117c97286893c9ec7b4b611546e09a7bfd24 [formerly 44daa92d72f776fa879a957e814496882190d302] Former-commit-id: ca11c6fe9726d380a77650dd4dff26049ac07386 --- SDK/include/NDK/Systems/RenderSystem.hpp | 4 ++-- SDK/include/NDK/Systems/RenderSystem.inl | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/SDK/include/NDK/Systems/RenderSystem.hpp b/SDK/include/NDK/Systems/RenderSystem.hpp index 82e558773..488d1a7d4 100644 --- a/SDK/include/NDK/Systems/RenderSystem.hpp +++ b/SDK/include/NDK/Systems/RenderSystem.hpp @@ -28,8 +28,8 @@ namespace Ndk inline RenderSystem(const RenderSystem& renderSystem); ~RenderSystem() = default; - template void ChangeRenderTechnique(); - inline void ChangeRenderTechnique(std::unique_ptr&& renderTechnique); + template T& ChangeRenderTechnique(); + inline Nz::AbstractRenderTechnique& ChangeRenderTechnique(std::unique_ptr&& renderTechnique); inline const Nz::BackgroundRef& GetDefaultBackground() const; inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const; diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NDK/Systems/RenderSystem.inl index b85ace59f..ada237615 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NDK/Systems/RenderSystem.inl @@ -10,14 +10,15 @@ namespace Ndk } template - inline void RenderSystem::ChangeRenderTechnique() + inline T& RenderSystem::ChangeRenderTechnique() { - ChangeRenderTechnique(std::make_unique()); + return *static_cast(ChangeRenderTechnique(std::make_unique())); } - inline void RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) + inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) { m_renderTechnique = std::move(renderTechnique); + return *m_renderTechnique.get(); } inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const From 50a06030465f321234bafe89402c05233dd46cde Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 19:10:40 +0200 Subject: [PATCH 194/383] SDK/RenderSystem: Fix an oopsie Former-commit-id: 08c14494557ddac011302fc0659d4b2fbc1847eb [formerly bcff6463582c59fd5ecb8e05f9722e005851de6e] [formerly 90134bee9e2e855740cb8b72bf1907adec985b1c [formerly 820af27e6e3af55ff3316c5cb946272c09b7e0f4]] Former-commit-id: a92198f8334b3d6cf693bf27e598f1988e0a7add [formerly 96ecbbaefad563dec8ef32c9016defc210062ef4] Former-commit-id: 6b24f10a63b0f4669bd509bc4f92f4c19969e0e1 --- SDK/include/NDK/Systems/RenderSystem.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NDK/Systems/RenderSystem.inl index ada237615..4f7afe63d 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NDK/Systems/RenderSystem.inl @@ -12,7 +12,7 @@ namespace Ndk template inline T& RenderSystem::ChangeRenderTechnique() { - return *static_cast(ChangeRenderTechnique(std::make_unique())); + return static_cast(ChangeRenderTechnique(std::make_unique())); } inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) From e0fa458f40af3b5aec087d28f54f9028c26a110e Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 22:17:55 +0200 Subject: [PATCH 195/383] Fix compilation with GCC/Clang Thanks to @Gawaboumga Former-commit-id: b8cc59cab55fd7d3b286dda28e70ee0ddb753230 [formerly c734175c33bf84226eedb76953e773f5bb91f631] [formerly 01b6b7b89bffccf217e38ed8431e2b2921facc51 [formerly 03c3cd902be4a0a104db22a2831adeb675998929]] Former-commit-id: 89ce26d806f8b750854af1704aa6af899b7779b3 [formerly 782dbee06d75ba2f555632713b44f1c25666e3ab] Former-commit-id: 30ba1aff3bc8a8de9510fb6e4f417526fb31e125 --- SDK/include/NDK/Systems/ParticleSystem.hpp | 2 ++ build/scripts/tools/ndk_server.lua | 2 ++ include/Nazara/Core/Algorithm.inl | 2 +- include/Nazara/Graphics/MaterialPipeline.inl | 6 +++--- src/Nazara/Graphics/MaterialPipeline.cpp | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/SDK/include/NDK/Systems/ParticleSystem.hpp b/SDK/include/NDK/Systems/ParticleSystem.hpp index 3ae00a995..61149b206 100644 --- a/SDK/include/NDK/Systems/ParticleSystem.hpp +++ b/SDK/include/NDK/Systems/ParticleSystem.hpp @@ -4,6 +4,7 @@ #pragma once +#ifndef NDK_SERVER #ifndef NDK_SYSTEMS_PARTICLESYSTEM_HPP #define NDK_SYSTEMS_PARTICLESYSTEM_HPP @@ -27,3 +28,4 @@ namespace Ndk #include #endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP +#endif // NDK_SERVER diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index e536f1036..aa8548b80 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -30,6 +30,8 @@ TOOL.FilesExcluded = { "../SDK/**/LightComponent.*", "../SDK/**/ListenerComponent.*", "../SDK/**/ListenerSystem.*", + "../SDK/**/Particle*Component.*", + "../SDK/**/ParticleSystem.*", "../SDK/**/RenderSystem.*", "../SDK/**/LuaBinding_Audio.*", "../SDK/**/LuaBinding_Graphics.*", diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index c77a5c3bb..0cadd1631 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -124,7 +124,7 @@ namespace Nz template constexpr std::size_t CountOf(T(&name)[N]) noexcept { - NazaraUnused(name); + // NazaraUnused(name); //< Because "body of function is not a return-statement" >.> return N; } diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl index ebd94a9ee..ce937883d 100644 --- a/include/Nazara/Graphics/MaterialPipeline.inl +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -61,7 +61,7 @@ namespace Nz if (!operator==(static_cast(lhs), static_cast(rhs))) return false; - #define NazaraPipelineMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraPipelineMember(field) if (lhs.field != rhs.field) return false #define NazaraPipelineBoolMember NazaraPipelineMember NazaraPipelineBoolMember(alphaTest); @@ -115,8 +115,8 @@ namespace std Nz::UInt16 parameterHash = 0; Nz::UInt16 parameterIndex = 0; - #define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.##member) - #define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) + #define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.member) + #define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) NazaraPipelineBoolMember(alphaTest); NazaraPipelineBoolMember(depthSorting); diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 01e9ffe5d..4cbd56274 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -49,8 +49,8 @@ namespace Nz */ MaterialPipelineRef MaterialPipeline::GetPipeline(const MaterialPipelineInfo& pipelineInfo) { - auto it = s_pipelineCache.lower_bound(pipelineInfo); - if (it == s_pipelineCache.end() || it->first != pipelineInfo) + auto it = s_pipelineCache.find(pipelineInfo); + if (it == s_pipelineCache.end()) it = s_pipelineCache.insert(it, PipelineCache::value_type(pipelineInfo, New(pipelineInfo))); return it->second; From 279597b67545c16e08e954bb6d94aed1801ea921 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 22:52:29 +0200 Subject: [PATCH 196/383] SDK/ParticleGroupComponent: Add [Add|Remove]Emitter methods taking an entity The entity must have a ParticleEmitterComponent Former-commit-id: da22fc8252c42be7661808ffab5f1d8ff6ccc4ae [formerly 5d0c352f695f14ddb069115e933322bf47c1fda2] [formerly f591cdff659b524ec7bcdb0bfd04392731e1e80b [formerly 354da841577784c89f4a72522c116d12ce0feb10]] Former-commit-id: d588fc973d59ee90afc589b9d0cc3e80d308a074 [formerly 2732590a051ca851b9681e9c70e238aab3bba247] Former-commit-id: 96537373e3d143e49dd83c7dc5d70cc3fd28a3fc --- .../NDK/Components/ParticleGroupComponent.hpp | 6 +++++ .../NDK/Components/ParticleGroupComponent.inl | 23 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NDK/Components/ParticleGroupComponent.hpp index 638f877d3..0dce5dd23 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.hpp +++ b/SDK/include/NDK/Components/ParticleGroupComponent.hpp @@ -25,6 +25,12 @@ namespace Ndk ParticleGroupComponent(const ParticleGroupComponent&) = default; ~ParticleGroupComponent() = default; + void AddEmitter(Entity* emitter); + using ParticleGroup::AddEmitter; + + void RemoveEmitter(Entity* emitter); + using ParticleGroup::RemoveEmitter; + static ComponentIndex componentIndex; }; } diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NDK/Components/ParticleGroupComponent.inl index 7aefdad56..c6e0cba7b 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.inl +++ b/SDK/include/NDK/Components/ParticleGroupComponent.inl @@ -1,8 +1,11 @@ -#include "ParticleGroupComponent.hpp" // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include +#include +#include + namespace Ndk { inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) : @@ -14,4 +17,22 @@ namespace Ndk ParticleGroup(maxParticleCount, std::move(declaration)) { } + + inline void ParticleGroupComponent::AddEmitter(Entity* emitter) + { + NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); + NazaraAssert(emitter->HasComponent(), "Entity must have a NodeComponent"); + + auto& emitterComponent = emitter->GetComponent(); + ParticleGroup::AddEmitter(&emitterComponent); + } + + inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter) + { + NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); + NazaraAssert(emitter->HasComponent(), "Entity must have a NodeComponent"); + + auto& emitterComponent = emitter->GetComponent(); + ParticleGroup::RemoveEmitter(&emitterComponent); + } } From e6fc3edeca6d01d58055be6a7ace987e3e637746 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:12:22 +0200 Subject: [PATCH 197/383] Renderer/RenderStates: Fix compilation with GCC/Clang Former-commit-id: 802d2d15fc5c1d7f5a350ce18e1c105cdb001b5f [formerly 76d7c26fba7510d64aadbac3b142a699afdfad16] [formerly a1ec278f7404f5bd1ecad4e0c3c511bdf638e67e [formerly 0f98c7716944aad42b0c5ac58af360526757dc2f]] Former-commit-id: 118f5cf639bb5f7fc0330519a9e8e464203859b5 [formerly 96bcd9ce1d3e4f43dc4ffc0389de27e6bd66ca71] Former-commit-id: 94a2d27a97be7040287bedee2c8c3695a021115e --- include/Nazara/Renderer/RenderStates.inl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index d9b6bfc31..9b7c1be62 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -12,9 +12,9 @@ namespace Nz { bool operator==(const RenderStates& lhs, const RenderStates& rhs) { - #define NazaraRenderStateMember(field) if (lhs.##field != rhs.##field) return false + #define NazaraRenderStateMember(field) if (lhs.field != rhs.field) return false #define NazaraRenderStateBoolMember NazaraRenderStateMember - #define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.##field, rhs.##field, maxDiff)) return false + #define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.field, rhs.field, maxDiff)) return false NazaraRenderStateBoolMember(blending); NazaraRenderStateBoolMember(colorWrite); @@ -81,10 +81,10 @@ namespace std Nz::UInt8 parameterHash = 0; Nz::UInt8 parameterIndex = 0; - #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.##member) - #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.##dependency && pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.##member / maxDiff) * maxDiff) + #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.member) + #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) NazaraRenderStateBoolMember(blending); NazaraRenderStateBoolMember(colorWrite); From 032ae7821bc3e3c22c6d97abff1d6841abfd4c74 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:17:25 +0200 Subject: [PATCH 198/383] Ditto Former-commit-id: de116d9f995865b3bf3687b0ec58dc06a2ed7f0a [formerly 20da754cca992573ffc4f34bc54f6df1c8197147] [formerly 6ad83121710e258d999671bdcc88eab49a026f6c [formerly 6e3f8edf77443a6b11c45562fb05c09369d19026]] Former-commit-id: 30f51b03ded349aa9c1d4f17671ce9a061e113d4 [formerly 2c25e268591713c7eb898e6cffdaf1921189c087] Former-commit-id: 29caff3ced232e9dc014427545158502ef623185 --- include/Nazara/Renderer/RenderStates.inl | 72 ++++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 9b7c1be62..525491162 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -81,59 +81,59 @@ namespace std Nz::UInt8 parameterHash = 0; Nz::UInt8 parameterIndex = 0; - #define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.member) - #define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) + #define NazaraRenderStateBool(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateBoolDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) + #define NazaraRenderStateEnum(member) Nz::HashCombine(seed, static_cast(pipelineInfo.member)) + #define NazaraRenderStateFloat(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) - NazaraRenderStateBoolMember(blending); - NazaraRenderStateBoolMember(colorWrite); - NazaraRenderStateBoolMember(depthBuffer); - NazaraRenderStateBoolMember(faceCulling); - NazaraRenderStateBoolMember(scissorTest); - NazaraRenderStateBoolMember(stencilTest); + NazaraRenderStateBool(blending); + NazaraRenderStateBool(colorWrite); + NazaraRenderStateBool(depthBuffer); + NazaraRenderStateBool(faceCulling); + NazaraRenderStateBool(scissorTest); + NazaraRenderStateBool(stencilTest); - NazaraRenderStateBoolMemberDep(depthBuffer, depthWrite); + NazaraRenderStateBoolDep(depthBuffer, depthWrite); - NazaraRenderStateMember(faceFilling); + NazaraRenderStateEnum(faceFilling); if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending { - NazaraRenderStateMember(dstBlend); - NazaraRenderStateMember(srcBlend); + NazaraRenderStateEnum(dstBlend); + NazaraRenderStateEnum(srcBlend); } if (pipelineInfo.depthBuffer) - NazaraRenderStateMember(depthFunc); + NazaraRenderStateEnum(depthFunc); if (pipelineInfo.faceCulling) - NazaraRenderStateMember(cullingSide); + NazaraRenderStateEnum(cullingSide); if (pipelineInfo.stencilTest) { - NazaraRenderStateMember(stencilCompare.back); - NazaraRenderStateMember(stencilCompare.front); - NazaraRenderStateMember(stencilCompareMask.back); - NazaraRenderStateMember(stencilCompareMask.front); - NazaraRenderStateMember(stencilDepthFail.back); - NazaraRenderStateMember(stencilDepthFail.front); - NazaraRenderStateMember(stencilFail.back); - NazaraRenderStateMember(stencilFail.front); - NazaraRenderStateMember(stencilPass.back); - NazaraRenderStateMember(stencilPass.front); - NazaraRenderStateMember(stencilReference.back); - NazaraRenderStateMember(stencilReference.front); - NazaraRenderStateMember(stencilWriteMask.back); - NazaraRenderStateMember(stencilWriteMask.front); + NazaraRenderStateEnum(stencilCompare.back); + NazaraRenderStateEnum(stencilCompare.front); + NazaraRenderStateEnum(stencilCompareMask.back); + NazaraRenderStateEnum(stencilCompareMask.front); + NazaraRenderStateEnum(stencilDepthFail.back); + NazaraRenderStateEnum(stencilDepthFail.front); + NazaraRenderStateEnum(stencilFail.back); + NazaraRenderStateEnum(stencilFail.front); + NazaraRenderStateEnum(stencilPass.back); + NazaraRenderStateEnum(stencilPass.front); + NazaraRenderStateEnum(stencilReference.back); + NazaraRenderStateEnum(stencilReference.front); + NazaraRenderStateEnum(stencilWriteMask.back); + NazaraRenderStateEnum(stencilWriteMask.front); } - NazaraRenderStateFloatMember(lineWidth, 0.001f); - NazaraRenderStateFloatMember(pointSize, 0.001f); + NazaraRenderStateFloat(lineWidth, 0.001f); + NazaraRenderStateFloat(pointSize, 0.001f); - #undef NazaraRenderStateMember - #undef NazaraRenderStateBoolMember - #undef NazaraRenderStateBoolMemberDep - #undef NazaraRenderStateFloatMember + #undef NazaraRenderStateBool + #undef NazaraRenderStateBoolDep + #undef NazaraRenderStateEnum + #undef NazaraRenderStateFloat Nz::HashCombine(seed, parameterHash); From 9d54bb8700248805878c7ab8095f5568f691e1c0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:18:49 +0200 Subject: [PATCH 199/383] Graphics/ParticleGroup: Fix include name Former-commit-id: ef6e348d212392631ac904f1a7ae43934674bba6 [formerly 2677f45b4c6004bb9088c6af1e92e701e0f53b48] [formerly 6f2483cfa8b8448f52683b965946f7efa231a5c8 [formerly aa6d158e4094f223c8c38496ba27347f2b790c86]] Former-commit-id: 2dfc3a0763d2030b7f7310aebea9cd6e0db9c606 [formerly 5ea68861a0b9bae0fa69f0ab601ac222f7290dab] Former-commit-id: 8c8531dce27be25186f31a50c9a33c1a35f867dd --- include/Nazara/Graphics/ParticleGroup.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 9e48d5797..409090284 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -8,7 +8,7 @@ #define NAZARA_PARTICLEGROUP_HPP #include -#include +#include #include #include #include From c1b2f3af001e2706e42ac0f49257e9e824e72478 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 23:50:51 +0200 Subject: [PATCH 200/383] Core/Log: Fix errors not being written in NazaraLog.log >.> Former-commit-id: 0aaaced48b71709efbe19255f12053d2ee3c1cd0 [formerly bdfff4f0dbc3f85c39d16966f0060706039a34a3] [formerly 6084c5725e4b55a72a1c23682b296507f8ef87e2 [formerly eaef4ab9e73788599dbfab43d11566c21435a334]] Former-commit-id: 4762ce471a7cb88c8bbc6f551daa5db31e57a38c [formerly b2e6b592bfdab34e367674ea48e79659934a08a5] Former-commit-id: 9f7ab7e7441f6c50f74c8d9a9b0a5fc9363a74e9 --- include/Nazara/Core/Signal.hpp | 2 +- include/Nazara/Core/Signal.inl | 7 +++++++ src/Nazara/Core/AbstractLogger.cpp | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index 613502f80..b7aebe591 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -34,7 +34,7 @@ namespace Nz Signal(); Signal(const Signal&) = delete; Signal(Signal&& signal); - ~Signal() = default; + ~Signal(); void Clear(); diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index 466d87537..d8ea871c6 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -36,6 +36,12 @@ namespace Nz operator=(std::move(signal)); } + template + Signal::~Signal() + { + NazaraWarning("~Signal(" + String::Pointer(this) + ')'); + } + /*! * \brief Clears the list of actions attached to the signal */ @@ -429,3 +435,4 @@ namespace Nz } #include +#include "Signal.hpp" diff --git a/src/Nazara/Core/AbstractLogger.cpp b/src/Nazara/Core/AbstractLogger.cpp index ceac9eff8..a1bf859a7 100644 --- a/src/Nazara/Core/AbstractLogger.cpp +++ b/src/Nazara/Core/AbstractLogger.cpp @@ -47,5 +47,7 @@ namespace Nz if (line != 0 && file && function) stream << " (" << file << ':' << line << ": " << function << ')'; + + Write(stream); } } From b096096e8342cc696bfaf60e8df7bd63c908403c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 00:04:10 +0200 Subject: [PATCH 201/383] Graphics: Allow OpenGL 3.3 to use the engine (with shadow disabled) I still have a figure a better solution Former-commit-id: 9a3dcc73288ef2d094f87b7d89fb964be3bcd7c0 [formerly c231ae17e7603200529c31b750f7679af8b03931] [formerly 2fa92f5bf7d2aa2d0161e1c8522100b4912f0d1b [formerly 3efc46381638ed065edcb4a3cf16a9d10f5b8cc3]] Former-commit-id: b46272bfc3d671a876eafff1fd31643bc37bb49c [formerly 219ff5ec8d057e5d6efe3c73d3e59156da1e7575] Former-commit-id: 18b860c45d7176848b832b62a57dff00dbeb7ffe --- .../Graphics/Resources/Shaders/PhongLighting/core.frag | 7 +++++++ .../Graphics/Resources/Shaders/PhongLighting/core.frag.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index a3391be91..d5eef7a3c 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -2,6 +2,13 @@ layout(early_fragment_tests) in; #endif +// HACK UNTIL PROPER FIX +#if GLSL_VERSION < 400 + #undef SHADOW_MAPPING + #define SHADOW_MAPPING 0 +#endif +// HACK + #define LIGHT_DIRECTIONAL 0 #define LIGHT_POINT 1 #define LIGHT_SPOT 2 diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index c77a33db2..650b62ccd 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,10,35,101,110,100,105,102,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,115,116,114,117,99,116,32,76,105,103,104,116,10,123,10,9,105,110,116,32,116,121,112,101,59,10,9,118,101,99,52,32,99,111,108,111,114,59,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,10,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,10,125,59,10,10,47,47,32,76,117,109,105,195,168,114,101,115,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,10,10,47,47,32,77,97,116,195,169,114,105,97,117,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,10,10,47,47,32,65,117,116,114,101,115,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,10,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,10,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,10,123,10,9,118,101,99,51,32,99,111,108,111,114,59,10,10,9,102,32,42,61,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,10,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,10,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,10,125,10,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,10,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,10,123,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,10,125,10,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,10,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,10,125,10,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,10,123,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,125,10,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,10,123,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,10,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,10,9,102,108,111,97,116,32,120,44,121,59,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,10,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,10,9,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,10,125,10,35,101,110,100,105,102,10,10,118,111,105,100,32,109,97,105,110,40,41,10,123,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,10,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,10,35,101,108,115,101,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,10,35,101,110,100,105,102,10,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,10,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,10,35,101,110,100,105,102,10,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,10,35,101,110,100,105,102,10,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,9,35,101,110,100,105,102,10,9,9,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,35,101,110,100,105,102,10,10,9,47,42,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,10,9,42,47,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,10,9,35,101,110,100,105,102,10,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,10,9,9,100,105,115,99,97,114,100,59,10,9,35,101,110,100,105,102,10,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,10,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,10,9,35,101,108,115,101,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,10,9,35,101,110,100,105,102,10,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,10,9,123,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,10,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,10,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,101,108,115,101,10,9,123,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,10,9,9,123,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,10,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,10,9,9,9,123,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,10,9,9,9,9,9,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,125,10,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,10,9,9,9,9,123,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,10,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,10,9,9,9,9,9,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,10,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,10,9,9,9,9,9,123,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,10,9,9,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,9,9,9,9,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,10,9,9,9,9,9,125,10,9,9,9,9,9,35,101,110,100,105,102,10,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,10,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,10,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,10,9,9,9,9,125,10,9,9,9,9,10,9,9,9,9,100,101,102,97,117,108,116,58,10,9,9,9,9,9,98,114,101,97,107,59,10,9,9,9,125,10,9,9,125,10,9,125,10,9,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,10,9,35,101,110,100,105,102,10,9,9,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,10,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,10,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,10,9,35,101,108,115,101,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,10,125,10,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,47,47,32,72,65,67,75,32,85,78,84,73,76,32,80,82,79,80,69,82,32,70,73,88,13,10,35,105,102,32,71,76,83,76,95,86,69,82,83,73,79,78,32,60,32,52,48,48,13,10,9,35,117,110,100,101,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,35,100,101,102,105,110,101,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,32,48,13,10,35,101,110,100,105,102,13,10,47,47,32,72,65,67,75,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file From 1fc0d564ce6d268660aae6c7dc6d5c1f2ec8ddd2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:02:40 +0200 Subject: [PATCH 202/383] SDK/Entity: Delay component removal until world update Allows system to freely remove components while updating Former-commit-id: db5877bc20e6a0dfadd69f81a339f0a57d8404df [formerly 74327b8f1429855625613f258894b37d026041fe] [formerly 65b8f2ba78d2690b7a469d4b9818b189524633db [formerly 71be95adb46b7183261a8038352c4d8bd17cacc3]] Former-commit-id: ba91d5abad60792e648d47e646ae49d43a1c94b5 [formerly 8d0667574ff665e151e7fda5f854fc11a16c854d] Former-commit-id: eb7b06c2739ef698a153a6221870a8d0956dc875 --- SDK/include/NDK/Entity.hpp | 9 ++++-- SDK/include/NDK/Entity.inl | 19 +++++++++++++ SDK/src/NDK/Entity.cpp | 56 +++++++++++++++----------------------- SDK/src/NDK/World.cpp | 5 ++++ 4 files changed, 53 insertions(+), 36 deletions(-) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index 6069a13c0..ae6b1acf5 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -52,8 +52,8 @@ namespace Ndk inline bool IsEnabled() const; inline bool IsValid() const; - void RemoveAllComponents(); - void RemoveComponent(ComponentIndex index); + inline void RemoveAllComponents(); + inline void RemoveComponent(ComponentIndex index); template void RemoveComponent(); inline Nz::String ToString() const; @@ -67,6 +67,10 @@ namespace Ndk void Create(); void Destroy(); + void DestroyComponent(ComponentIndex index); + + inline Nz::Bitset<>& GetRemovedComponentBits(); + inline void RegisterSystem(SystemIndex index); inline void SetWorld(World* world) noexcept; @@ -75,6 +79,7 @@ namespace Ndk std::vector> m_components; Nz::Bitset<> m_componentBits; + Nz::Bitset<> m_removedComponentBits; Nz::Bitset<> m_systemBits; EntityId m_id; World* m_world; diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index 799ffd97e..c7937b786 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -103,12 +103,31 @@ namespace Ndk RemoveComponent(index); } + inline void Entity::RemoveAllComponents() + { + m_removedComponentBits = m_componentBits; + + Invalidate(); + } + + inline void Entity::RemoveComponent(ComponentIndex index) + { + m_removedComponentBits.UnboundedSet(index); + + Invalidate(); + } + inline Nz::String Entity::ToString() const { Nz::StringStream ss; return ss << "Entity(" << GetId() << ')'; } + inline Nz::Bitset<>& Entity::GetRemovedComponentBits() + { + return m_removedComponentBits; + } + inline void Entity::RegisterSystem(SystemIndex index) { m_systemBits.UnboundedSet(index); diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index f037e5f9a..680ff56d9 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -44,6 +44,7 @@ namespace Ndk // Affectation et retour du component m_components[index] = std::move(componentPtr); m_componentBits.UnboundedSet(index); + m_removedComponentBits.UnboundedReset(index); Invalidate(); @@ -71,40 +72,6 @@ namespace Ndk m_world->Invalidate(m_id); } - void Entity::RemoveAllComponents() - { - for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) - RemoveComponent(static_cast(i)); - - NazaraAssert(m_componentBits.TestNone(), "All components should be gone"); - - m_components.clear(); - - Invalidate(); - } - - void Entity::RemoveComponent(ComponentIndex index) - { - ///DOC: N'a aucun effet si le component n'est pas présent - if (HasComponent(index)) - { - // On récupère le component et on informe les composants du détachement - BaseComponent& component = *m_components[index].get(); - for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) - { - if (i != index) - m_components[i]->OnComponentDetached(component); - } - - component.SetEntity(nullptr); - - m_components[index].reset(); - m_componentBits.Reset(index); - - Invalidate(); - } - } - void Entity::Create() { m_enabled = true; @@ -128,4 +95,25 @@ namespace Ndk m_valid = false; } + + void Entity::DestroyComponent(ComponentIndex index) + { + ///DOC: N'a aucun effet si le component n'est pas présent + if (HasComponent(index)) + { + // On récupère le component et on informe les composants du détachement + BaseComponent& component = *m_components[index].get(); + for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) + { + if (i != index) + m_components[i]->OnComponentDetached(component); + } + + component.SetEntity(nullptr); + + m_components[index].reset(); + m_componentBits.Reset(index); + } + } + } diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 5d0e4900b..e5b2d874a 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -139,6 +139,11 @@ namespace Ndk if (!entity->IsValid()) continue; + Nz::Bitset<>& removedComponents = entity->GetRemovedComponentBits(); + for (std::size_t j = removedComponents.FindFirst(); j != m_dirtyEntities.npos; j = removedComponents.FindNext(j)) + entity->DestroyComponent(j); + removedComponents.Reset(); + for (auto& system : m_systems) { // Ignore non-existent systems From dbe6bdb546e98a4a72eb9228efc55f77b3545277 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:03:53 +0200 Subject: [PATCH 203/383] SDK/GraphicsComponent: Fix invalidation slot disconnection in case Detach has been called Former-commit-id: efaa7d24bcde02c6b5296fd3732d3a5011ae4078 [formerly 141bc763bee78e9380ae2b419b38c57a3034849f] [formerly 458f733410b7f62a61463d02efc738f653baeee5 [formerly 5c9b322291f2e6c80538bf2ac9ddb42afb3d240f]] Former-commit-id: 910a33e54597fd059ec6db0741fd6ded38594d56 [formerly e0b2a8b16b0f7ea1f7e533fce89773f2c3caccbe] Former-commit-id: 341f70e4f541ede37e3b2197e70f4aabdb691fd5 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 6 ++++-- SDK/include/NDK/Components/GraphicsComponent.inl | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 92aeeed2f..6e0e78604 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -35,7 +35,7 @@ namespace Ndk inline void Clear(); - inline void Detach(const Nz::InstancedRenderableRef& renderable); + inline void Detach(const Nz::InstancedRenderable* renderable); inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; @@ -75,7 +75,8 @@ namespace Ndk Renderable(Renderable&& renderable) noexcept : data(std::move(renderable.data)), renderable(std::move(renderable.renderable)), - dataUpdated(renderable.dataUpdated) + dataUpdated(renderable.dataUpdated), + renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)), { } @@ -84,6 +85,7 @@ namespace Ndk data = std::move(r.data); dataUpdated = r.dataUpdated; renderable = std::move(r.renderable); + renderableInvalidationSlot = std::move(r.renderableInvalidationSlot); return *this; } diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index b38ce6dd6..a835c845d 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -54,7 +54,7 @@ namespace Ndk InvalidateBoundingVolume(); } - inline void GraphicsComponent::Detach(const Nz::InstancedRenderableRef& renderable) + inline void GraphicsComponent::Detach(const Nz::InstancedRenderable* renderable) { for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) { From 7c2add0a652fbf4d6954293b6237a4364efd0513 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:06:21 +0200 Subject: [PATCH 204/383] Core/Signal: Remove debug log that got accidentaly commited Former-commit-id: 435e861f9d695e09995c3a0f4a1eacd43c1d883d [formerly a995326be759d5dd467d938f363bc2fe727123d3] [formerly 1c38e003106ee292dd7f94fbc68e3308e9be9a86 [formerly cf359837241bce8143a16394c72a14a8c614aa53]] Former-commit-id: cc354e782c2f2a13350c742e2a016bbc656842fb [formerly f72def4abc3b8b27a72ee4d53d11015d0d2bbcd4] Former-commit-id: 85a57ad329db63764ba3f26375926dfdb40ff821 --- include/Nazara/Core/Signal.hpp | 2 +- include/Nazara/Core/Signal.inl | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index b7aebe591..613502f80 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -34,7 +34,7 @@ namespace Nz Signal(); Signal(const Signal&) = delete; Signal(Signal&& signal); - ~Signal(); + ~Signal() = default; void Clear(); diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index d8ea871c6..93e0166c0 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include #include @@ -36,12 +37,6 @@ namespace Nz operator=(std::move(signal)); } - template - Signal::~Signal() - { - NazaraWarning("~Signal(" + String::Pointer(this) + ')'); - } - /*! * \brief Clears the list of actions attached to the signal */ @@ -435,4 +430,3 @@ namespace Nz } #include -#include "Signal.hpp" From 9bf253f09dcb06b5add84dc267b7955549292b29 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 01:07:46 +0200 Subject: [PATCH 205/383] SDK/GraphicsComponent: Makes component watch over renderable destruction Allows to use persistent (not using the internal counter) InstancedRenderable Former-commit-id: 84a84f6e175dd7afa69bfa68c0efdbae8023ceec [formerly 3239c8fe9289c5773b57b4026fa165a40fb594be] [formerly 3840928f4c52a72f6813f1e8480f8a9cb62da9a1 [formerly 3f5eb580f5cb8b0b80815780282bc08f06110f61]] Former-commit-id: 44f423605454c90a4fc3b186ec0e1da4073c7cbb [formerly a6a0affa8cd3e53553c09f3458ac8a40e316389b] Former-commit-id: ca295a898fe287407a6c9bdf1f1f72b040ff1335 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 9 +++++++++ SDK/include/NDK/Components/GraphicsComponent.inl | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 6e0e78604..ec16ba593 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -77,20 +77,29 @@ namespace Ndk renderable(std::move(renderable.renderable)), dataUpdated(renderable.dataUpdated), renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)), + renderableReleaseSlot(std::move(renderable.renderableReleaseSlot)) { } + ~Renderable() + { + // Disconnect release slot before releasing instanced renderable reference + renderableReleaseSlot.Disconnect(); + } + Renderable& operator=(Renderable&& r) noexcept { data = std::move(r.data); dataUpdated = r.dataUpdated; renderable = std::move(r.renderable); renderableInvalidationSlot = std::move(r.renderableInvalidationSlot); + renderableReleaseSlot = std::move(r.renderableReleaseSlot); return *this; } NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot); + NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableRelease, renderableReleaseSlot); mutable Nz::InstancedRenderable::InstanceData data; Nz::InstancedRenderableRef renderable; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index a835c845d..0d9cb7af4 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -42,7 +42,8 @@ namespace Ndk Renderable& r = m_renderables.back(); r.data.renderOrder = renderOrder; r.renderable = std::move(renderable); - r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size()-1)); + r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size() - 1)); + r.renderableReleaseSlot.Connect(r.renderable->OnInstancedRenderableRelease, this, &GraphicsComponent::Detach); InvalidateBoundingVolume(); } From 5fa172e7f5114f35b35d78492d1b82f003c19189 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 11 Aug 2016 22:00:05 +0200 Subject: [PATCH 206/383] SDK/Entity: Add entity cloning Former-commit-id: e855800df2110a15bbe808673549baed12c0a80d [formerly eee65fd713e594fbcb76b74bcee243ad7d670113] [formerly 00cab4a7320aacceeeddceeffba4475e48ee7c2e [formerly 256bcefb089172041e2a21c28e8486e70b288884]] Former-commit-id: 78fa9291af60f0b02858a9b0127d60fec6a96521 [formerly ae13e29e620506aa1921b0faecc54b1a63609097] Former-commit-id: ae1a27340b2b21f4d04e2df8f7a5aea3c50f6e3b --- SDK/include/NDK/Entity.hpp | 2 ++ SDK/include/NDK/World.hpp | 2 ++ SDK/src/NDK/Entity.cpp | 8 ++++++++ SDK/src/NDK/World.cpp | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index ae6b1acf5..33661eb50 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -34,6 +34,8 @@ namespace Ndk BaseComponent& AddComponent(std::unique_ptr&& component); template ComponentType& AddComponent(Args&&... args); + const EntityHandle& Clone() const; + inline void Enable(bool enable); inline BaseComponent& GetComponent(ComponentIndex index); diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index 40508e8e4..2e20d03a9 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -44,6 +44,8 @@ namespace Ndk void Clear() noexcept; + const EntityHandle& CloneEntity(EntityId id); + const EntityHandle& GetEntity(EntityId id); inline const EntityList& GetEntities(); inline BaseSystem& GetSystem(SystemIndex index); diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 680ff56d9..ecd74ebc0 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -61,6 +61,14 @@ namespace Ndk return component; } + const EntityHandle& Entity::Clone() const + { + ///DOC: The clone is enabled by default, even if the original entity is disabled + NazaraAssert(IsValid(), "Invalid entity"); + + return m_world->CloneEntity(m_id); + } + void Entity::Kill() { m_world->KillEntity(this); diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index e5b2d874a..8e5ff99f0 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -74,6 +75,27 @@ namespace Ndk m_killedEntities.Clear(); } + const EntityHandle& World::CloneEntity(EntityId id) + { + EntityHandle original = GetEntity(id); + if (!original) + { + NazaraError("Invalid entity ID"); + return EntityHandle::InvalidHandle; + } + + EntityHandle clone = CreateEntity(); + + const Nz::Bitset<>& componentBits = original->GetComponentBits(); + for (std::size_t i = componentBits.FindFirst(); i != componentBits.npos; i = componentBits.FindNext(i)) + { + std::unique_ptr component(original->GetComponent(ComponentIndex(i)).Clone()); + clone->AddComponent(std::move(component)); + } + + return GetEntity(clone->GetId()); + } + void World::KillEntity(Entity* entity) { ///DOC: Ignoré si l'entité est invalide From e0e0ed73799fbe9d5c11c08edce93f4c3c0ef537 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 13 Aug 2016 01:23:30 +0200 Subject: [PATCH 207/383] Utility/OBJParser: Fix a missing word.. hue Former-commit-id: 0ebca872e1043c5805d0b8ac89d9620a817d1a75 [formerly 48814eea375b7e12c0b76bef8c7b3d7c2e432e20] [formerly 628d94e43d5b7127a7b3a4141b54286ba3ed2824 [formerly 9f540cf0218292b5669c1511907f56448fca6faa]] Former-commit-id: 50f50cc4549d2d2810ab87e8e40d21994b9154b8 [formerly c729ce574727d200b23440cfdf491892028e0546] Former-commit-id: 5374d05311df71fb13b3e3acc509285489303f78 --- src/Nazara/Utility/Formats/OBJParser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 403950a97..e2b63b467 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -300,7 +300,7 @@ namespace Nz m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif } else if (word == "vn") @@ -311,7 +311,7 @@ namespace Nz m_normals.push_back(normal); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif } else if (word == "vt") @@ -322,12 +322,12 @@ namespace Nz m_texCoords.push_back(uvw); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else if (!UnrecognizedLine()) - false; + return false; #endif break; From c231d73f9ec030c94737d1cc1b44b35f55de8ea0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:54:37 +0200 Subject: [PATCH 208/383] Graphics/Particles: Add wrappers on functions controller/generator/renderer Former-commit-id: b4bc65fd61d304ab9c54f5eb960ee3ee111e4199 [formerly 6dc8ec4c126ec92253fcd1488f3d450a87cd2b0b] [formerly 72c62a62a1f34b633531c8e011e697a773ba574a [formerly d2aff554d20246c1fc5b47013e3e7c136c0b51a2]] Former-commit-id: 54227b0f67e85ff186ec4ee7a3df0f3aa70193d1 [formerly 49065827d43b04e836901c05fee0542667c50683] Former-commit-id: 013776ab4b91064bb48b18822317935376062a09 --- .../Graphics/ParticleFunctionController.hpp | 45 ++++++++++++++++++ .../Graphics/ParticleFunctionController.inl | 46 +++++++++++++++++++ .../Graphics/ParticleFunctionGenerator.hpp | 45 ++++++++++++++++++ .../Graphics/ParticleFunctionGenerator.inl | 46 +++++++++++++++++++ .../Graphics/ParticleFunctionRenderer.hpp | 45 ++++++++++++++++++ .../Graphics/ParticleFunctionRenderer.inl | 46 +++++++++++++++++++ .../Graphics/ParticleFunctionController.cpp | 29 ++++++++++++ .../Graphics/ParticleFunctionGenerator.cpp | 28 +++++++++++ .../Graphics/ParticleFunctionRenderer.cpp | 29 ++++++++++++ 9 files changed, 359 insertions(+) create mode 100644 include/Nazara/Graphics/ParticleFunctionController.hpp create mode 100644 include/Nazara/Graphics/ParticleFunctionController.inl create mode 100644 include/Nazara/Graphics/ParticleFunctionGenerator.hpp create mode 100644 include/Nazara/Graphics/ParticleFunctionGenerator.inl create mode 100644 include/Nazara/Graphics/ParticleFunctionRenderer.hpp create mode 100644 include/Nazara/Graphics/ParticleFunctionRenderer.inl create mode 100644 src/Nazara/Graphics/ParticleFunctionController.cpp create mode 100644 src/Nazara/Graphics/ParticleFunctionGenerator.cpp create mode 100644 src/Nazara/Graphics/ParticleFunctionRenderer.cpp diff --git a/include/Nazara/Graphics/ParticleFunctionController.hpp b/include/Nazara/Graphics/ParticleFunctionController.hpp new file mode 100644 index 000000000..6b3c4a974 --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionController.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP +#define NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP + +#include +#include +#include + +namespace Nz +{ + class ParticleFunctionController; + + using ParticleFunctionControllerConstRef = ObjectRef; + using ParticleFunctionControllerRef = ObjectRef; + + class NAZARA_GRAPHICS_API ParticleFunctionController : public ParticleController + { + public: + using Controller = std::function; + + inline ParticleFunctionController(Controller controller); + ParticleFunctionController(const ParticleFunctionController&) = default; + ~ParticleFunctionController() = default; + + void Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override final; + + inline const Controller& GetController() const; + + inline void SetController(Controller controller); + + template static ParticleFunctionControllerRef New(Args&&... args); + + private: + Controller m_controller; + }; +} + +#include + +#endif // NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP diff --git a/include/Nazara/Graphics/ParticleFunctionController.inl b/include/Nazara/Graphics/ParticleFunctionController.inl new file mode 100644 index 000000000..eb4365fda --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionController.inl @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline ParticleFunctionController::ParticleFunctionController(Controller controller) : + m_controller(std::move(controller)) + { + } + + /*! + * \brief Gets the controller function + * + * \return Controller function responsible for particle update + */ + inline const ParticleFunctionController::Controller& ParticleFunctionController::GetController() const + { + return m_controller; + } + + /*! + * \brief Sets the controller function + * + * \remark The controller function must be valid + */ + inline void ParticleFunctionController::SetController(Controller controller) + { + m_controller = std::move(controller); + } + + template + ParticleFunctionControllerRef ParticleFunctionController::New(Args&&... args) + { + std::unique_ptr object(new ParticleFunctionController(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.hpp b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp new file mode 100644 index 000000000..7aa5bb9f3 --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_PARTICLEFUNCTIONGENERATOR_HPP +#define NAZARA_PARTICLEFUNCTIONGENERATOR_HPP + +#include +#include +#include + +namespace Nz +{ + class ParticleFunctionGenerator; + + using ParticleFunctionGeneratorConstRef = ObjectRef; + using ParticleFunctionGeneratorRef = ObjectRef; + + class NAZARA_GRAPHICS_API ParticleFunctionGenerator : public ParticleGenerator + { + public: + using Generator = std::function; + + inline ParticleFunctionGenerator(Generator controller); + ParticleFunctionGenerator(const ParticleFunctionGenerator&) = default; + ~ParticleFunctionGenerator() = default; + + void Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId) override final; + + inline const Generator& GetGenerator() const; + + inline void SetGenerator(Generator generator); + + template static ParticleFunctionGeneratorRef New(Args&&... args); + + private: + Generator m_generator; + }; +} + +#include + +#endif // NAZARA_PARTICLEFUNCTIONGENERATOR_HPP diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.inl b/include/Nazara/Graphics/ParticleFunctionGenerator.inl new file mode 100644 index 000000000..9cb11683c --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.inl @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline ParticleFunctionGenerator::ParticleFunctionGenerator(Generator generator) : + m_generator(std::move(generator)) + { + } + + /*! + * \brief Gets the generator function + * + * \return Generator function responsible for particle creation + */ + inline const ParticleFunctionGenerator::Generator& ParticleFunctionGenerator::GetGenerator() const + { + return m_generator; + } + + /*! + * \brief Sets the generator function + * + * \remark The generator function must be valid + */ + inline void ParticleFunctionGenerator::SetGenerator(Generator generator) + { + m_generator = std::move(generator); + } + + template + ParticleFunctionGeneratorRef ParticleFunctionGenerator::New(Args&&... args) + { + std::unique_ptr object(new ParticleFunctionGenerator(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.hpp b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp new file mode 100644 index 000000000..810027ae9 --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_PARTICLEFUNCTIONRENDERER_HPP +#define NAZARA_PARTICLEFUNCTIONRENDERER_HPP + +#include +#include +#include + +namespace Nz +{ + class ParticleFunctionRenderer; + + using ParticleFunctionRendererConstRef = ObjectRef; + using ParticleFunctionRendererRef = ObjectRef; + + class NAZARA_GRAPHICS_API ParticleFunctionRenderer : public ParticleRenderer + { + public: + using Renderer = std::function; + + inline ParticleFunctionRenderer(Renderer renderer); + ParticleFunctionRenderer(const ParticleFunctionRenderer&) = default; + ~ParticleFunctionRenderer() = default; + + void Render(const ParticleGroup& group, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) override final; + + inline const Renderer& GetRenderer() const; + + inline void SetRenderer(Renderer renderer); + + template static ParticleFunctionRendererRef New(Args&&... args); + + private: + Renderer m_renderer; + }; +} + +#include + +#endif // NAZARA_PARTICLEFUNCTIONRENDERER_HPP diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.inl b/include/Nazara/Graphics/ParticleFunctionRenderer.inl new file mode 100644 index 000000000..cf859fbfe --- /dev/null +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.inl @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline ParticleFunctionRenderer::ParticleFunctionRenderer(Renderer renderer) : + m_renderer(std::move(renderer)) + { + } + + /*! + * \brief Gets the renderer function + * + * \return Renderer function responsible for particle rendering + */ + inline const ParticleFunctionRenderer::Renderer& ParticleFunctionRenderer::GetRenderer() const + { + return m_renderer; + } + + /*! + * \brief Sets the renderer function + * + * \remark The renderer function must be valid + */ + inline void ParticleFunctionRenderer::SetRenderer(Renderer renderer) + { + m_renderer = std::move(renderer); + } + + template + ParticleFunctionRendererRef ParticleFunctionRenderer::New(Args&&... args) + { + std::unique_ptr object(new ParticleFunctionRenderer(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/src/Nazara/Graphics/ParticleFunctionController.cpp b/src/Nazara/Graphics/ParticleFunctionController.cpp new file mode 100644 index 000000000..9b300f450 --- /dev/null +++ b/src/Nazara/Graphics/ParticleFunctionController.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::ParticleFunctionController + * \brief Helper class used to provide a function as a particle controller without going in the process of making a new class + */ + + /*! + * \brief Calls the controller function + * + * \param group Particle group responsible of the particles + * \param mapper Particle mapper, allowing access to the particle data + * \param startId The first ID of the particle to update (inclusive) + * \param endId The last ID of the particle to update (inclusive) + * \param elapsedTime Elapsed time in seconds since the last update + */ + void ParticleFunctionController::Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) + { + m_controller(group, mapper, startId, endId, elapsedTime); + } +} diff --git a/src/Nazara/Graphics/ParticleFunctionGenerator.cpp b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp new file mode 100644 index 000000000..67d43770d --- /dev/null +++ b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::ParticleFunctionGenerator + * \brief Helper class used to provide a function as a particle generator without going in the process of making a new class + */ + + /*! + * \brief Calls the generator function + * + * \param group Particle group responsible of the particles + * \param mapper Particle mapper, allowing access to the particle data + * \param startId The first ID of the particle to update (inclusive) + * \param endId The last ID of the particle to update (inclusive) + */ + void ParticleFunctionGenerator::Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId) + { + m_generator(group, mapper, startId, endId); + } +} diff --git a/src/Nazara/Graphics/ParticleFunctionRenderer.cpp b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp new file mode 100644 index 000000000..36dfea3df --- /dev/null +++ b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Graphics module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup graphics + * \class Nz::ParticleFunctionRenderer + * \brief Helper class used to provide a function as a particle renderer without going in the process of making a new class + */ + + /*! + * \brief Calls the renderer function + * + * \param group Particle group responsible of the particles + * \param mapper Particle mapper, allowing constant access to the particle data + * \param startId The first ID of the particle to update (inclusive) + * \param endId The last ID of the particle to update (inclusive) + * \param renderQueue The concerned render queue that will receive drawable informations + */ + void ParticleFunctionRenderer::Render(const ParticleGroup& group, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) + { + m_renderer(group, mapper, startId, endId, renderQueue); + } +} From 8bc5e618b196b2ac7bba106b088c9432874189e6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:56:01 +0200 Subject: [PATCH 209/383] SDK/System: Add possibility to disable systems without destroying them Former-commit-id: d72fc2252c8c55e0ef93aa28592fdf734e187d64 [formerly 84c57abb22494dbc67a02db65dc39e282fab0ec3] [formerly 4b302cfc908f0ddfa45facdf707199a1a41a98d1 [formerly a971f3d0eb400aabe9695613ca63672b0dbaeec2]] Former-commit-id: 3e03a4cd321c860dd3e264302839c5eb05bd2a85 [formerly 7db586c2246267f71fd54f4feb2c0b911e8c6387] Former-commit-id: aa53d5f6f7ca2428d9a76b6e4e1b6785ce4b1c1f --- SDK/include/NDK/BaseSystem.hpp | 5 +++++ SDK/include/NDK/BaseSystem.inl | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/SDK/include/NDK/BaseSystem.hpp b/SDK/include/NDK/BaseSystem.hpp index 8e828149d..969f2b773 100644 --- a/SDK/include/NDK/BaseSystem.hpp +++ b/SDK/include/NDK/BaseSystem.hpp @@ -27,6 +27,8 @@ namespace Ndk BaseSystem(BaseSystem&&) noexcept = default; virtual ~BaseSystem(); + inline void Enable(bool enable = true); + virtual BaseSystem* Clone() const = 0; bool Filters(const Entity* entity) const; @@ -36,6 +38,8 @@ namespace Ndk inline float GetUpdateRate() const; inline World& GetWorld() const; + inline bool IsEnabled() const; + inline bool HasEntity(const Entity* entity) const; inline void SetUpdateRate(float updatePerSecond); @@ -86,6 +90,7 @@ namespace Ndk Nz::Bitset<> m_requiredComponents; SystemIndex m_systemIndex; World* m_world; + bool m_updateEnabled; float m_updateCounter; float m_updateRate; diff --git a/SDK/include/NDK/BaseSystem.inl b/SDK/include/NDK/BaseSystem.inl index 0c2811ac0..490b32e76 100644 --- a/SDK/include/NDK/BaseSystem.inl +++ b/SDK/include/NDK/BaseSystem.inl @@ -2,12 +2,14 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include namespace Ndk { inline BaseSystem::BaseSystem(SystemIndex systemId) : + m_updateEnabled(true), m_systemIndex(systemId) { SetUpdateRate(30); @@ -17,11 +19,17 @@ namespace Ndk m_excludedComponents(system.m_excludedComponents), m_requiredComponents(system.m_requiredComponents), m_systemIndex(system.m_systemIndex), + m_updateEnabled(system.m_updateEnabled), m_updateCounter(0.f), m_updateRate(system.m_updateRate) { } + inline void BaseSystem::Enable(bool enable) + { + m_updateEnabled = enable; + } + inline const std::vector& BaseSystem::GetEntities() const { return m_entities; @@ -42,6 +50,11 @@ namespace Ndk return *m_world; } + inline bool BaseSystem::IsEnabled() const + { + return m_updateEnabled; + } + inline bool BaseSystem::HasEntity(const Entity* entity) const { if (!entity) @@ -58,6 +71,9 @@ namespace Ndk inline void BaseSystem::Update(float elapsedTime) { + if (!IsEnabled()) + return; + if (m_updateRate > 0.f) { m_updateCounter += elapsedTime; From 0c211acb783a538f6e4bf0c03d492a28da6f9885 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:56:36 +0200 Subject: [PATCH 210/383] SDK/ParticleGroupComponent: Fix ParticleGroupComponent not being a handled object Former-commit-id: be8510f6af37e42823ecd91bafb13811237eeb16 [formerly 88c87c25016860ad54af6190724092c3a8f6d68d] [formerly 0ebbf96f2c776d5c81d9f5aca0f38c26a52d6e71 [formerly b25f03bb3a25c92a26973fe1a561e8f2201e8637]] Former-commit-id: 41557956be4f10df7424a8f68e27d14a376b2c0f [formerly 77ffff76911d233219a13ac5d2d922949b1142cf] Former-commit-id: 3f2e9c12541a9c38578a192752c179c7db175c1e --- SDK/include/NDK/Components/ParticleGroupComponent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.hpp b/SDK/include/NDK/Components/ParticleGroupComponent.hpp index 0dce5dd23..549a6df5c 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.hpp +++ b/SDK/include/NDK/Components/ParticleGroupComponent.hpp @@ -17,7 +17,7 @@ namespace Ndk using ParticleGroupComponentHandle = Nz::ObjectHandle; - class NDK_API ParticleGroupComponent : public Component, public Nz::ParticleGroup + class NDK_API ParticleGroupComponent : public Component, public Nz::ParticleGroup, public Nz::HandledObject { public: inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout); From 5b39e8bac69fedd55ff83702b1b9ed0ec71fff79 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:57:53 +0200 Subject: [PATCH 211/383] Graphics/ParticleDeclaration: Fix particle declarations leak Former-commit-id: b0cd7f410ca94bd969943443b81e908b70c5e2d3 [formerly 066c3331d6c18f77900fe08c9c0bc82330a566a0] [formerly 39c3b995afdcaea91ed8f94a9aa7f137844e6c67 [formerly 9559f4534bf9e0fe6c6b3c9fe271d85fb1194416]] Former-commit-id: 42083171720cf53f79311ea901f445f3483b6e45 [formerly 31b97171d51bd90ceb5247436c979ca3cb53386b] Former-commit-id: f2f49e08f018f69523ca769530336e30668e128e --- include/Nazara/Graphics/ParticleDeclaration.inl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/Graphics/ParticleDeclaration.inl b/include/Nazara/Graphics/ParticleDeclaration.inl index 27cd92a22..dafa2653a 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.inl +++ b/include/Nazara/Graphics/ParticleDeclaration.inl @@ -11,6 +11,8 @@ namespace Nz ParticleDeclarationRef ParticleDeclaration::New(Args&&... args) { std::unique_ptr object(new ParticleDeclaration(std::forward(args)...)); + object->SetPersistent(false); + return object.release(); } } From 5e305a18febfc52c59f13ee63ce5f9e4b04c2385 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:58:38 +0200 Subject: [PATCH 212/383] Graphics/MaterialPipeline: Fix default pipeline not having an ubershader Former-commit-id: bcb9a8ff8490cbb067a577f5ec02c1fcbe161726 [formerly 7fbbad94a914bd6af32c88d4008a22fea064db0b] [formerly 4ccea598f463ebecf1f9bc48e9d85601974a9a0f [formerly 642ffb31b8578085001cd1bfaa59bf0f59a2fffe]] Former-commit-id: d33e25edd9114a56a74064b492e266cc160f91dd [formerly c2075c3d1d2582d0d213574ac034bca530138679] Former-commit-id: 8617c4a1edc70a96b9c34a386deb44b778f82f40 --- src/Nazara/Graphics/MaterialPipeline.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 4cbd56274..c3d35504f 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -58,6 +58,8 @@ namespace Nz void MaterialPipeline::GenerateRenderPipeline(UInt32 flags) const { + NazaraAssert(m_pipelineInfo.uberShader, "Material pipeline has no uber shader"); + ParameterList list; list.SetParameter("ALPHA_MAPPING", m_pipelineInfo.hasAlphaMap); list.SetParameter("ALPHA_TEST", m_pipelineInfo.alphaTest); @@ -136,6 +138,7 @@ namespace Nz // Once the base shaders are registered, we can now set some default materials MaterialPipelineInfo pipelineInfo; + pipelineInfo.uberShader = UberShaderLibrary::Get("Basic"); // Basic 2D - No depth write/face culling pipelineInfo.depthWrite = false; From 1d5e07133418d1a7ae46a5c4b7c5c6f1b18518ad Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 17:58:54 +0200 Subject: [PATCH 213/383] Graphics/MaterialPipeline: Fix Translucent2D material not having blending enabled Former-commit-id: e8a2fd043c1abdbb9ef727bca1e31575175a2dd6 [formerly a3bb0930322858029a3fb1f5e8d67ec02536c329] [formerly 444ef3fbd363cab6453057d3cc6687a1d7663f67 [formerly d54f03800504a0f1674844f6fc13716ea0860511]] Former-commit-id: 29e0c1232ad6a8bf29797a39dabbb7f0ade8d922 [formerly 3d93398d3ea500bc6758c800823e7a15b92901c1] Former-commit-id: def6c8b2c5ec67da18f2fe913e8c3dce427b97d3 --- src/Nazara/Graphics/MaterialPipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index c3d35504f..2ca062ad6 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -147,7 +147,7 @@ namespace Nz MaterialPipelineLibrary::Register("Basic2D", GetPipeline(pipelineInfo)); // Translucent 2D - Alpha blending with no depth write/face culling - pipelineInfo.blending = false; + pipelineInfo.blending = true; pipelineInfo.depthWrite = false; pipelineInfo.faceCulling = false; pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; From e3989b8656e300a88b9e9dec21dff15c5e79565b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 18:00:38 +0200 Subject: [PATCH 214/383] Graphics/MaterialPipeline: Add Translucent3D pipeline Former-commit-id: e947711e6be029a86c8a83b5ae2e48a0093caae2 [formerly 26782eac4659502817def9d7f008ac160bf6a339] [formerly 7dd4e62f7d12341237172777a84e3decf1fe6063 [formerly c362785d9aaa8693f6a753b1bf8127ec67bbf511]] Former-commit-id: 749bd125c56425fccd3cb290362138d534f3582e [formerly 7ffbdcaea4592d2ec6cf8b5260de834c6e724ff0] Former-commit-id: 3f37254ae01e54441226b9a873cc37fc278d4315 --- src/Nazara/Graphics/MaterialPipeline.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 2ca062ad6..07865c4cd 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -155,6 +155,16 @@ namespace Nz MaterialPipelineLibrary::Register("Translucent2D", GetPipeline(pipelineInfo)); + // Translucent 3D - Alpha blending with depth buffer and no depth write/face culling + pipelineInfo.blending = true; + pipelineInfo.depthBuffer = true; + pipelineInfo.depthWrite = false; + pipelineInfo.faceCulling = false; + pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha; + pipelineInfo.srcBlend = BlendFunc_SrcAlpha; + + MaterialPipelineLibrary::Register("Translucent3D", GetPipeline(pipelineInfo)); + return true; } From 6ab812b576c848580c215c0bd6e337df5a4fec07 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 18:01:23 +0200 Subject: [PATCH 215/383] SDK/Entity: Add constant component getter Former-commit-id: 1c7aa68fbf0c8e0bdfa8152632b2e9cdaa0f748e [formerly 676e34f3738632aa727470213928ad2c91368d9b] [formerly c3f162cad3a9c65da2bcaf037d7b55ea70ee5b53 [formerly 674d9d5ecaa0d561d002e470af4c0cf7dcf7e501]] Former-commit-id: bf5a07802efe57d0f6547a2c4b5ab8344e4515e9 [formerly 843780a0eaba37b46e59f9d81e56c3854a86ebde] Former-commit-id: 6849fc8cfe8d689f67d452d13fe317ea65ba2fec --- SDK/include/NDK/Entity.hpp | 2 ++ SDK/include/NDK/Entity.inl | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index 33661eb50..5aeeb8226 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -40,6 +40,8 @@ namespace Ndk inline BaseComponent& GetComponent(ComponentIndex index); template ComponentType& GetComponent(); + inline const BaseComponent& GetComponent(ComponentIndex index) const; + template const ComponentType& GetComponent() const; inline const Nz::Bitset<>& GetComponentBits() const; inline EntityId GetId() const; inline const Nz::Bitset<>& GetSystemBits() const; diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index c7937b786..a03130b0d 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include #include @@ -50,6 +51,27 @@ namespace Ndk return static_cast(GetComponent(index)); } + inline const BaseComponent& Entity::GetComponent(ComponentIndex index) const + { + ///DOC: Le component doit être présent + NazaraAssert(HasComponent(index), "This component is not part of the entity"); + + BaseComponent* component = m_components[index].get(); + NazaraAssert(component, "Invalid component pointer"); + + return *component; + } + + template + const ComponentType& Entity::GetComponent() const + { + ///DOC: Le component doit être présent + static_assert(std::is_base_of::value, "ComponentType is not a component"); + + ComponentIndex index = GetComponentIndex(); + return static_cast(GetComponent(index)); + } + inline const Nz::Bitset<>& Entity::GetComponentBits() const { return m_componentBits; From e501a93ae27855f8ef86915483e87a41b8be7bf0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 14 Aug 2016 18:02:30 +0200 Subject: [PATCH 216/383] Graphics/DeferredBloomPass: *bloom intensifies* Former-commit-id: fef9aca40577c522d6125f7d352b318e7556e103 [formerly ab11d22150f2e4010fe7a1ca4c1bf574a5d9cd41] [formerly cb388b47dd6c2438fde651ca51c6cab67b92520d [formerly af484ac159cdaf43a162b407f3679bfa905e7314]] Former-commit-id: 75e3fe6f35aa7b692e5135aa47f288dd655c96cd [formerly 0d44d17781c914790ab30431b0613a198092e180] Former-commit-id: 9ef45a44ce6177a90f31db8b7aaf3366cd9c74dd --- src/Nazara/Graphics/DeferredBloomPass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index 9cf39831a..643024ead 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -23,7 +23,7 @@ namespace Nz m_uniformUpdated(false), m_brightLuminance(0.8f), m_brightMiddleGrey(0.5f), - m_brightThreshold(0.8f), + m_brightThreshold(0.4f), m_blurPassCount(5) { m_bilinearSampler.SetAnisotropyLevel(1); From 705faa8d95c195448ec5a7458fbe4e66818a5999 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 15 Aug 2016 01:27:33 +0200 Subject: [PATCH 217/383] Graphics/DeferredRenderTechnique: Optimize Deferred Shading No longer copies depth twice Former-commit-id: fa946456f8196d2955efa278f2c47cdc9f6c0dac [formerly df5a55b487b02ebe7df1c31dc640ca60042ed49b] [formerly 5ebfb7cd0df4c998292a7f0b661438f4f2fc3b6d [formerly bd64449e3ecaa7443a4db86d6ef787fd42fbc314]] Former-commit-id: 7bd35cd3c2bd845f9ee8b3d2d2a48793f63047e7 [formerly 267393d8cb349d6f77bf9e707c6ce2d5344ed7d7] Former-commit-id: b9e45d39c4ec5a0ea4dd0cc37f478af0cf3e0caa --- include/Nazara/Graphics/DeferredRenderPass.hpp | 2 +- .../Nazara/Graphics/DeferredRenderTechnique.hpp | 6 +++--- src/Nazara/Graphics/DeferredGeometryPass.cpp | 6 +++--- .../Graphics/DeferredPhongLightingPass.cpp | 3 +++ src/Nazara/Graphics/DeferredRenderPass.cpp | 2 +- src/Nazara/Graphics/DeferredRenderTechnique.cpp | 8 +++++--- .../Shaders/DirectionalLight.frag | 9 ++------- .../Shaders/DirectionalLight.frag.h | 2 +- .../DeferredShading/Shaders/PointSpotLight.frag | 3 ++- .../Shaders/PointSpotLight.frag.h | 2 +- .../Resources/Shaders/PhongLighting/core.frag | 17 +---------------- .../Resources/Shaders/PhongLighting/core.frag.h | 2 +- 12 files changed, 24 insertions(+), 38 deletions(-) diff --git a/include/Nazara/Graphics/DeferredRenderPass.hpp b/include/Nazara/Graphics/DeferredRenderPass.hpp index 34a4020a6..7053bbaa5 100644 --- a/include/Nazara/Graphics/DeferredRenderPass.hpp +++ b/include/Nazara/Graphics/DeferredRenderPass.hpp @@ -47,9 +47,9 @@ namespace Nz Vector2ui m_dimensions; DeferredRenderTechnique* m_deferredTechnique; DeferredRenderQueue* m_renderQueue; - RenderBuffer* m_depthStencilBuffer; RenderTexture* m_GBufferRTT; RenderTexture* m_workRTT; + Texture* m_depthStencilTexture; Texture* m_GBuffer[4]; Texture* m_workTextures[2]; diff --git a/include/Nazara/Graphics/DeferredRenderTechnique.hpp b/include/Nazara/Graphics/DeferredRenderTechnique.hpp index e9e357184..36ac47c8b 100644 --- a/include/Nazara/Graphics/DeferredRenderTechnique.hpp +++ b/include/Nazara/Graphics/DeferredRenderTechnique.hpp @@ -37,7 +37,7 @@ namespace Nz void EnablePass(RenderPassType renderPass, int position, bool enable); - RenderBuffer* GetDepthStencilBuffer() const; + Texture* GetDepthStencilTexture() const; Texture* GetGBuffer(unsigned int i) const; RenderTexture* GetGBufferRTT() const; const ForwardRenderTechnique* GetForwardTechnique() const; @@ -69,14 +69,14 @@ namespace Nz std::map>, RenderPassComparator> m_passes; ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue DeferredRenderQueue m_renderQueue; - mutable RenderBufferRef m_depthStencilBuffer; + mutable TextureRef m_depthStencilTexture; mutable RenderTexture m_GBufferRTT; mutable RenderTexture m_workRTT; mutable TextureRef m_GBuffer[4]; mutable TextureRef m_workTextures[2]; mutable Vector2ui m_GBufferSize; const RenderTarget* m_viewerTarget; -}; + }; } #endif // NAZARA_FORWARDRENDERTECHNIQUE_HPP diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 3cdcb99fe..1c4f8b8bb 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -232,7 +232,7 @@ namespace Nz unsigned int width = dimensions.x; unsigned int height = dimensions.y; - m_depthStencilBuffer->Create(PixelFormatType_Depth24Stencil8, width, height); + m_depthStencilTexture->Create(ImageType_2D, PixelFormatType_Depth24Stencil8, width, height); m_GBuffer[0]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular m_GBuffer[1]->Create(ImageType_2D, PixelFormatType_RG16F, width, height); // Texture 1 : Encoded normal @@ -246,7 +246,7 @@ namespace Nz // Texture 3 : Emission map ? - m_GBufferRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer); + m_GBufferRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture); m_GBufferRTT->Unlock(); @@ -258,7 +258,7 @@ namespace Nz m_workRTT->AttachTexture(AttachmentPoint_Color, i, m_workTextures[i]); } - m_workRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer); + m_workRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture); m_workRTT->Unlock(); diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index afe17ed13..8f83f9a6b 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -114,6 +114,9 @@ namespace Nz Renderer::SetTexture(2, m_GBuffer[2]); Renderer::SetTextureSampler(2, m_pointSampler); + Renderer::SetTexture(3, m_depthStencilTexture); + Renderer::SetTextureSampler(3, m_pointSampler); + Renderer::SetClearColor(Color::Black); Renderer::Clear(RendererBuffer_Color); diff --git a/src/Nazara/Graphics/DeferredRenderPass.cpp b/src/Nazara/Graphics/DeferredRenderPass.cpp index da40c01da..280f6658c 100644 --- a/src/Nazara/Graphics/DeferredRenderPass.cpp +++ b/src/Nazara/Graphics/DeferredRenderPass.cpp @@ -48,7 +48,7 @@ namespace Nz m_deferredTechnique = technique; m_renderQueue = static_cast(technique->GetRenderQueue()); - m_depthStencilBuffer = technique->GetDepthStencilBuffer(); + m_depthStencilTexture = technique->GetDepthStencilTexture(); m_GBufferRTT = technique->GetGBufferRTT(); for (unsigned int i = 0; i < 3; ++i) diff --git a/src/Nazara/Graphics/DeferredRenderTechnique.cpp b/src/Nazara/Graphics/DeferredRenderTechnique.cpp index 585091406..45c8bf7c3 100644 --- a/src/Nazara/Graphics/DeferredRenderTechnique.cpp +++ b/src/Nazara/Graphics/DeferredRenderTechnique.cpp @@ -136,7 +136,7 @@ namespace Nz m_renderQueue(static_cast(m_forwardTechnique.GetRenderQueue())), m_GBufferSize(0U) { - m_depthStencilBuffer = RenderBuffer::New(); + m_depthStencilTexture = Texture::New(); for (unsigned int i = 0; i < 2; ++i) m_workTextures[i] = Texture::New(); @@ -305,9 +305,9 @@ namespace Nz * \return Pointer to the rendering buffer */ - RenderBuffer* DeferredRenderTechnique::GetDepthStencilBuffer() const + Texture* DeferredRenderTechnique::GetDepthStencilTexture() const { - return m_depthStencilBuffer; + return m_depthStencilTexture; } /*! @@ -652,6 +652,7 @@ namespace Nz shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0); shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1); shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2); + shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3); shader = RegisterDeferredShader("DeferredPointSpotLight", r_fragmentSource_PointSpotLight, sizeof(r_fragmentSource_PointSpotLight), basicVertexStage, &error); @@ -664,6 +665,7 @@ namespace Nz shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0); shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1); shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2); + shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3); // Shaders optionnels (S'ils ne sont pas présents, le rendu minimal sera quand même assuré) diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag index dfadac50e..fabb0e6f5 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag @@ -11,17 +11,12 @@ uniform vec4 LightDirection; uniform sampler2D GBuffer0; uniform sampler2D GBuffer1; uniform sampler2D GBuffer2; +uniform sampler2D DepthBuffer; uniform mat4 InvViewProjMatrix; uniform vec2 InvTargetSize; uniform vec4 SceneAmbient; -float ColorToFloat(vec3 color) -{ - const vec3 byte_to_float = vec3(1.0, 1.0/256, 1.0/(256*256)); - return dot(color, byte_to_float); -} - #define kPI 3.1415926536 vec3 DecodeNormal(in vec4 encodedNormal) @@ -44,7 +39,7 @@ void main() vec3 diffuseColor = gVec0.xyz; vec3 normal = DecodeNormal(gVec1); float specularMultiplier = gVec0.w; - float depth = ColorToFloat(gVec2.xyz); + float depth = textureLod(DepthBuffer, texCoord, 0.0).r; float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5); vec3 lightDir = -LightDirection.xyz; diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h index ef67feeb4..b8ba80ab6 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/DirectionalLight.frag.h @@ -1 +1 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,102,108,111,97,116,32,67,111,108,111,114,84,111,70,108,111,97,116,40,118,101,99,51,32,99,111,108,111,114,41,13,10,123,32,9,13,10,9,99,111,110,115,116,32,118,101,99,51,32,98,121,116,101,95,116,111,95,102,108,111,97,116,32,61,32,118,101,99,51,40,49,46,48,44,32,49,46,48,47,50,53,54,44,32,49,46,48,47,40,50,53,54,42,50,53,54,41,41,59,13,10,9,114,101,116,117,114,110,32,100,111,116,40,99,111,108,111,114,44,32,98,121,116,101,95,116,111,95,102,108,111,97,116,41,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,9,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,32,32,32,32,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,32,32,32,32,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,32,32,32,32,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,67,111,108,111,114,84,111,70,108,111,97,116,40,103,86,101,99,50,46,120,121,122,41,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,68,105,114,101,99,116,105,111,110,46,120,121,122,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file +35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,101,112,116,104,66,117,102,102,101,114,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,9,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,32,32,32,32,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,32,32,32,32,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,32,32,32,32,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,116,101,120,116,117,114,101,76,111,100,40,68,101,112,116,104,66,117,102,102,101,114,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,46,114,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,68,105,114,101,99,116,105,111,110,46,120,121,122,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag index bb85cbbe6..37b3f5e1a 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag @@ -19,6 +19,7 @@ uniform vec2 LightParameters3; uniform sampler2D GBuffer0; uniform sampler2D GBuffer1; uniform sampler2D GBuffer2; +uniform sampler2D DepthBuffer; uniform mat4 InvViewProjMatrix; uniform vec2 InvTargetSize; @@ -57,7 +58,7 @@ void main() vec3 diffuseColor = gVec0.xyz; vec3 normal = DecodeNormal(gVec1); float specularMultiplier = gVec0.w; - float depth = ColorToFloat(gVec2.xyz); + float depth = textureLod(DepthBuffer, texCoord, 0.0).r; float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5); vec3 viewSpace = vec3(texCoord*2.0 - 1.0, depth*2.0 - 1.0); diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h index 14376fb95..7f0de77ea 100644 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/PointSpotLight.frag.h @@ -1 +1 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,105,110,116,32,76,105,103,104,116,84,121,112,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,98,111,111,108,32,68,105,115,99,97,114,100,32,61,32,102,97,108,115,101,59,13,10,13,10,102,108,111,97,116,32,67,111,108,111,114,84,111,70,108,111,97,116,40,118,101,99,51,32,99,111,108,111,114,41,13,10,123,32,9,13,10,9,99,111,110,115,116,32,118,101,99,51,32,98,121,116,101,95,116,111,95,102,108,111,97,116,32,61,32,118,101,99,51,40,49,46,48,44,32,49,46,48,47,50,53,54,44,32,49,46,48,47,40,50,53,54,42,50,53,54,41,41,59,13,10,9,114,101,116,117,114,110,32,100,111,116,40,99,111,108,111,114,44,32,98,121,116,101,95,116,111,95,102,108,111,97,116,41,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,9,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,9,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,105,102,32,40,68,105,115,99,97,114,100,41,13,10,9,9,114,101,116,117,114,110,59,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,67,111,108,111,114,84,111,70,108,111,97,116,40,103,86,101,99,50,46,120,121,122,41,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,59,13,10,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,59,13,10,9,108,105,103,104,116,68,105,114,32,47,61,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,13,10,13,10,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,119,42,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,97,116,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,105,102,32,40,76,105,103,104,116,84,121,112,101,32,61,61,32,76,73,71,72,84,95,83,80,79,84,41,13,10,9,123,13,10,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,13,10,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,13,10,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,9,125,13,10,9,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file +35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,13,10,117,110,105,102,111,114,109,32,105,110,116,32,76,105,103,104,116,84,121,112,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,67,111,108,111,114,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,70,97,99,116,111,114,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,68,105,114,101,99,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,48,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,49,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,71,66,117,102,102,101,114,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,101,112,116,104,66,117,102,102,101,114,59,13,10,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,98,111,111,108,32,68,105,115,99,97,114,100,32,61,32,102,97,108,115,101,59,13,10,13,10,102,108,111,97,116,32,67,111,108,111,114,84,111,70,108,111,97,116,40,118,101,99,51,32,99,111,108,111,114,41,13,10,123,32,9,13,10,9,99,111,110,115,116,32,118,101,99,51,32,98,121,116,101,95,116,111,95,102,108,111,97,116,32,61,32,118,101,99,51,40,49,46,48,44,32,49,46,48,47,50,53,54,44,32,49,46,48,47,40,50,53,54,42,50,53,54,41,41,59,13,10,9,114,101,116,117,114,110,32,100,111,116,40,99,111,108,111,114,44,32,98,121,116,101,95,116,111,95,102,108,111,97,116,41,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,51,32,68,101,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,52,32,101,110,99,111,100,101,100,78,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,121,122,42,50,46,48,32,45,32,49,46,48,59,13,10,9,102,108,111,97,116,32,97,32,61,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,120,32,42,32,107,80,73,59,13,10,9,118,101,99,50,32,115,99,116,104,32,61,32,118,101,99,50,40,115,105,110,40,97,41,44,32,99,111,115,40,97,41,41,59,13,10,13,10,9,118,101,99,50,32,115,99,112,104,105,32,61,32,118,101,99,50,40,115,113,114,116,40,49,46,48,32,45,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,42,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,44,32,101,110,99,111,100,101,100,78,111,114,109,97,108,46,121,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,51,40,115,99,116,104,46,121,42,115,99,112,104,105,46,120,44,32,115,99,116,104,46,120,42,115,99,112,104,105,46,120,44,32,115,99,112,104,105,46,121,41,59,13,10,125,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,105,102,32,40,68,105,115,99,97,114,100,41,13,10,9,9,114,101,116,117,114,110,59,13,10,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,9,118,101,99,52,32,103,86,101,99,48,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,48,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,49,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,49,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,9,118,101,99,52,32,103,86,101,99,50,32,61,32,116,101,120,116,117,114,101,76,111,100,40,71,66,117,102,102,101,114,50,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,103,86,101,99,48,46,120,121,122,59,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,68,101,99,111,100,101,78,111,114,109,97,108,40,103,86,101,99,49,41,59,13,10,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,32,61,32,103,86,101,99,48,46,119,59,13,10,9,102,108,111,97,116,32,100,101,112,116,104,32,61,32,116,101,120,116,117,114,101,76,111,100,40,68,101,112,116,104,66,117,102,102,101,114,44,32,116,101,120,67,111,111,114,100,44,32,48,46,48,41,46,114,59,13,10,9,102,108,111,97,116,32,115,104,105,110,105,110,101,115,115,32,61,32,40,103,86,101,99,50,46,119,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,101,120,112,50,40,103,86,101,99,50,46,119,42,49,48,46,53,41,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,83,112,97,99,101,32,61,32,118,101,99,51,40,116,101,120,67,111,111,114,100,42,50,46,48,32,45,32,49,46,48,44,32,100,101,112,116,104,42,50,46,48,32,45,32,49,46,48,41,59,13,10,13,10,9,118,101,99,52,32,119,111,114,108,100,80,111,115,32,61,32,73,110,118,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,118,105,101,119,83,112,97,99,101,44,32,49,46,48,41,59,13,10,9,119,111,114,108,100,80,111,115,46,120,121,122,32,47,61,32,119,111,114,108,100,80,111,115,46,119,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,120,121,122,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,59,13,10,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,108,105,103,104,116,68,105,114,41,59,13,10,9,108,105,103,104,116,68,105,114,32,47,61,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,13,10,13,10,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,49,46,119,32,45,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,119,42,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,47,47,32,65,109,98,105,101,110,116,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,97,116,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,120,32,42,32,40,118,101,99,51,40,49,46,48,41,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,105,102,32,40,76,105,103,104,116,84,121,112,101,32,61,61,32,76,73,71,72,84,95,83,80,79,84,41,13,10,9,123,13,10,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,50,46,120,121,122,44,32,45,108,105,103,104,116,68,105,114,41,59,13,10,9,9,102,108,111,97,116,32,111,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,80,97,114,97,109,101,116,101,114,115,51,46,120,32,45,32,111,117,116,101,114,65,110,103,108,101,59,13,10,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,111,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,9,125,13,10,9,13,10,9,47,47,32,68,105,102,102,117,115,101,13,10,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,76,105,103,104,116,70,97,99,116,111,114,115,46,121,59,13,10,13,10,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,59,13,10,9,105,102,32,40,115,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,119,111,114,108,100,80,111,115,46,120,121,122,41,59,13,10,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,115,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,76,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,115,112,101,99,117,108,97,114,77,117,108,116,105,112,108,105,101,114,59,13,10,9,125,13,10,9,101,108,115,101,13,10,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,118,101,99,51,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,67,111,108,111,114,32,42,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,102,114,97,103,109,101,110,116,67,111,108,111,114,44,32,49,46,48,41,59,13,10,125, \ No newline at end of file diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index d5eef7a3c..e37df3fa3 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -68,21 +68,6 @@ uniform vec4 SceneAmbient; uniform sampler2D TextureOverlay; /********************Fonctions********************/ -vec3 FloatToColor(float f) -{ - vec3 color; - - f *= 256.0; - color.x = floor(f); - - f = (f - color.x) * 256.0; - color.y = floor(f); - - color.z = f - color.y; - color.xy *= 0.00390625; // *= 1.0/256 - - return color; -} #define kPI 3.1415926536 @@ -184,7 +169,7 @@ void main() */ RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11))); RenderTarget1 = vec4(EncodeNormal(normal)); - RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf + RenderTarget2 = vec4(0.0, 0.0, 0.0, (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf #else // FLAG_DEFERRED #if ALPHA_MAPPING diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r; diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h index 650b62ccd..b9e39fa11 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag.h @@ -1 +1 @@ -35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,47,47,32,72,65,67,75,32,85,78,84,73,76,32,80,82,79,80,69,82,32,70,73,88,13,10,35,105,102,32,71,76,83,76,95,86,69,82,83,73,79,78,32,60,32,52,48,48,13,10,9,35,117,110,100,101,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,35,100,101,102,105,110,101,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,32,48,13,10,35,101,110,100,105,102,13,10,47,47,32,72,65,67,75,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,101,99,51,32,70,108,111,97,116,84,111,67,111,108,111,114,40,102,108,111,97,116,32,102,41,13,10,123,13,10,9,118,101,99,51,32,99,111,108,111,114,59,13,10,13,10,9,102,32,42,61,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,120,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,102,32,61,32,40,102,32,45,32,99,111,108,111,114,46,120,41,32,42,32,50,53,54,46,48,59,13,10,9,99,111,108,111,114,46,121,32,61,32,102,108,111,111,114,40,102,41,59,13,10,13,10,9,99,111,108,111,114,46,122,32,61,32,102,32,45,32,99,111,108,111,114,46,121,59,13,10,9,99,111,108,111,114,46,120,121,32,42,61,32,48,46,48,48,51,57,48,54,50,53,59,32,47,47,32,42,61,32,49,46,48,47,50,53,54,13,10,13,10,9,114,101,116,117,114,110,32,99,111,108,111,114,59,13,10,125,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,70,108,111,97,116,84,111,67,111,108,111,114,40,103,108,95,70,114,97,103,67,111,111,114,100,46,122,41,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file +35,105,102,32,69,65,82,76,89,95,70,82,65,71,77,69,78,84,95,84,69,83,84,83,32,38,38,32,33,65,76,80,72,65,95,84,69,83,84,13,10,108,97,121,111,117,116,40,101,97,114,108,121,95,102,114,97,103,109,101,110,116,95,116,101,115,116,115,41,32,105,110,59,13,10,35,101,110,100,105,102,13,10,13,10,47,47,32,72,65,67,75,32,85,78,84,73,76,32,80,82,79,80,69,82,32,70,73,88,13,10,35,105,102,32,71,76,83,76,95,86,69,82,83,73,79,78,32,60,32,52,48,48,13,10,9,35,117,110,100,101,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,35,100,101,102,105,110,101,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,32,48,13,10,35,101,110,100,105,102,13,10,47,47,32,72,65,67,75,13,10,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,32,48,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,80,79,73,78,84,32,49,13,10,35,100,101,102,105,110,101,32,76,73,71,72,84,95,83,80,79,84,32,50,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,52,32,118,67,111,108,111,114,59,13,10,105,110,32,118,101,99,52,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,51,93,59,13,10,105,110,32,109,97,116,51,32,118,76,105,103,104,116,84,111,87,111,114,108,100,59,13,10,105,110,32,118,101,99,51,32,118,78,111,114,109,97,108,59,13,10,105,110,32,118,101,99,50,32,118,84,101,120,67,111,111,114,100,59,13,10,105,110,32,118,101,99,51,32,118,86,105,101,119,68,105,114,59,13,10,105,110,32,118,101,99,51,32,118,87,111,114,108,100,80,111,115,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,49,59,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,50,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,115,116,114,117,99,116,32,76,105,103,104,116,13,10,123,13,10,9,105,110,116,32,116,121,112,101,59,13,10,9,118,101,99,52,32,99,111,108,111,114,59,13,10,9,118,101,99,50,32,102,97,99,116,111,114,115,59,13,10,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,49,59,13,10,9,118,101,99,52,32,112,97,114,97,109,101,116,101,114,115,50,59,13,10,9,118,101,99,50,32,112,97,114,97,109,101,116,101,114,115,51,59,13,10,9,98,111,111,108,32,115,104,97,100,111,119,77,97,112,112,105,110,103,59,13,10,125,59,13,10,13,10,47,47,32,76,117,109,105,195,168,114,101,115,13,10,117,110,105,102,111,114,109,32,76,105,103,104,116,32,76,105,103,104,116,115,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,67,117,98,101,32,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,51,93,59,13,10,13,10,47,47,32,77,97,116,195,169,114,105,97,117,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,59,13,10,13,10,47,47,32,65,117,116,114,101,115,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,66,105,97,115,32,61,32,45,48,46,48,51,59,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,80,97,114,97,108,108,97,120,83,99,97,108,101,32,61,32,48,46,48,50,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,51,32,69,121,101,80,111,115,105,116,105,111,110,59,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,83,99,101,110,101,65,109,98,105,101,110,116,59,13,10,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,84,101,120,116,117,114,101,79,118,101,114,108,97,121,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,13,10,35,100,101,102,105,110,101,32,107,80,73,32,51,46,49,52,49,53,57,50,54,53,51,54,13,10,13,10,118,101,99,52,32,69,110,99,111,100,101,78,111,114,109,97,108,40,105,110,32,118,101,99,51,32,110,111,114,109,97,108,41,13,10,123,13,10,9,47,47,114,101,116,117,114,110,32,118,101,99,52,40,110,111,114,109,97,108,42,48,46,53,32,43,32,48,46,53,44,32,48,46,48,41,59,13,10,9,114,101,116,117,114,110,32,118,101,99,52,40,118,101,99,50,40,97,116,97,110,40,110,111,114,109,97,108,46,121,44,32,110,111,114,109,97,108,46,120,41,47,107,80,73,44,32,110,111,114,109,97,108,46,122,41,44,32,48,46,48,44,32,48,46,48,41,59,13,10,125,13,10,13,10,102,108,111,97,116,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,118,101,99,51,32,118,101,99,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,118,101,99,51,32,97,98,115,86,101,99,32,61,32,97,98,115,40,118,101,99,41,59,13,10,9,102,108,111,97,116,32,108,111,99,97,108,90,32,61,32,109,97,120,40,97,98,115,86,101,99,46,120,44,32,109,97,120,40,97,98,115,86,101,99,46,121,44,32,97,98,115,86,101,99,46,122,41,41,59,13,10,13,10,9,102,108,111,97,116,32,110,111,114,109,90,32,61,32,40,40,122,70,97,114,32,43,32,122,78,101,97,114,41,32,42,32,108,111,99,97,108,90,32,45,32,40,50,46,48,42,122,70,97,114,42,122,78,101,97,114,41,41,32,47,32,40,40,122,70,97,114,32,45,32,122,78,101,97,114,41,42,108,111,99,97,108,90,41,59,13,10,9,114,101,116,117,114,110,32,40,110,111,114,109,90,32,43,32,49,46,48,41,32,42,32,48,46,53,59,13,10,125,13,10,13,10,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,44,32,118,101,99,51,32,108,105,103,104,116,84,111,87,111,114,108,100,44,32,102,108,111,97,116,32,122,78,101,97,114,44,32,102,108,111,97,116,32,122,70,97,114,41,13,10,123,13,10,9,114,101,116,117,114,110,32,40,116,101,120,116,117,114,101,40,80,111,105,110,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,118,101,99,51,40,108,105,103,104,116,84,111,87,111,114,108,100,46,120,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,121,44,32,45,108,105,103,104,116,84,111,87,111,114,108,100,46,122,41,41,46,120,32,62,61,32,86,101,99,116,111,114,84,111,68,101,112,116,104,86,97,108,117,101,40,108,105,103,104,116,84,111,87,111,114,108,100,44,32,122,78,101,97,114,44,32,122,70,97,114,41,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,125,13,10,13,10,102,108,111,97,116,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,110,116,32,108,105,103,104,116,73,110,100,101,120,41,13,10,123,13,10,9,118,101,99,52,32,108,105,103,104,116,83,112,97,99,101,80,111,115,32,61,32,118,76,105,103,104,116,83,112,97,99,101,80,111,115,91,108,105,103,104,116,73,110,100,101,120,93,59,13,10,13,10,9,102,108,111,97,116,32,118,105,115,105,98,105,108,105,116,121,32,61,32,49,46,48,59,13,10,9,102,108,111,97,116,32,120,44,121,59,13,10,9,102,111,114,32,40,121,32,61,32,45,51,46,53,59,32,121,32,60,61,32,51,46,53,59,32,121,43,61,32,49,46,48,41,13,10,9,9,102,111,114,32,40,120,32,61,32,45,51,46,53,59,32,120,32,60,61,32,51,46,53,59,32,120,43,61,32,49,46,48,41,13,10,9,9,9,118,105,115,105,98,105,108,105,116,121,32,43,61,32,40,116,101,120,116,117,114,101,80,114,111,106,40,68,105,114,101,99,116,105,111,110,97,108,83,112,111,116,76,105,103,104,116,83,104,97,100,111,119,77,97,112,91,108,105,103,104,116,73,110,100,101,120,93,44,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,120,121,119,32,43,32,118,101,99,51,40,120,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,121,47,49,48,50,52,46,48,32,42,32,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,44,32,48,46,48,41,41,46,120,32,62,61,32,40,108,105,103,104,116,83,112,97,99,101,80,111,115,46,122,32,45,32,48,46,48,48,48,53,41,47,108,105,103,104,116,83,112,97,99,101,80,111,115,46,119,41,32,63,32,49,46,48,32,58,32,48,46,48,59,13,10,13,10,9,118,105,115,105,98,105,108,105,116,121,32,47,61,32,54,52,46,48,59,13,10,9,13,10,9,114,101,116,117,114,110,32,118,105,115,105,98,105,108,105,116,121,59,13,10,125,13,10,35,101,110,100,105,102,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,52,32,100,105,102,102,117,115,101,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,32,42,32,118,67,111,108,111,114,59,13,10,13,10,35,105,102,32,65,85,84,79,95,84,69,88,67,79,79,82,68,83,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,35,101,108,115,101,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,118,84,101,120,67,111,111,114,100,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,80,65,82,65,76,76,65,88,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,104,101,105,103,104,116,32,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,72,101,105,103,104,116,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,102,108,111,97,116,32,118,32,61,32,104,101,105,103,104,116,42,80,97,114,97,108,108,97,120,83,99,97,108,101,32,43,32,80,97,114,97,108,108,97,120,66,105,97,115,59,13,10,13,10,9,118,101,99,51,32,118,105,101,119,68,105,114,32,61,32,110,111,114,109,97,108,105,122,101,40,118,86,105,101,119,68,105,114,41,59,13,10,9,116,101,120,67,111,111,114,100,32,43,61,32,118,32,42,32,118,105,101,119,68,105,114,46,120,121,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,68,73,70,70,85,83,69,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,84,69,88,84,85,82,69,79,86,69,82,76,65,89,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,84,101,120,116,117,114,101,79,118,101,114,108,97,121,44,32,116,101,120,67,111,111,114,100,41,59,13,10,35,101,110,100,105,102,13,10,13,10,35,105,102,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,9,47,47,32,73,110,117,116,105,108,101,32,100,101,32,102,97,105,114,101,32,100,101,32,108,39,97,108,112,104,97,45,109,97,112,112,105,110,103,32,115,97,110,115,32,97,108,112,104,97,45,116,101,115,116,32,101,110,32,68,101,102,101,114,114,101,100,32,40,108,39,97,108,112,104,97,32,110,39,101,115,116,32,112,97,115,32,115,97,117,118,101,103,97,114,100,195,169,32,100,97,110,115,32,108,101,32,71,45,66,117,102,102,101,114,41,13,10,9,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,9,35,101,110,100,105,102,13,10,9,9,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,32,47,47,32,65,76,80,72,65,95,84,69,83,84,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,32,47,47,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,13,10,9,118,101,99,51,32,115,112,101,99,117,108,97,114,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,115,112,101,99,117,108,97,114,67,111,108,111,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,47,42,13,10,9,84,101,120,116,117,114,101,48,58,32,68,105,102,102,117,115,101,32,67,111,108,111,114,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,49,58,32,78,111,114,109,97,108,32,43,32,83,112,101,99,117,108,97,114,13,10,9,84,101,120,116,117,114,101,50,58,32,69,110,99,111,100,101,100,32,100,101,112,116,104,32,43,32,83,104,105,110,105,110,101,115,115,13,10,9,42,47,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,100,105,102,102,117,115,101,67,111,108,111,114,46,114,103,98,44,32,100,111,116,40,115,112,101,99,117,108,97,114,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,49,32,61,32,118,101,99,52,40,69,110,99,111,100,101,78,111,114,109,97,108,40,110,111,114,109,97,108,41,41,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,50,32,61,32,118,101,99,52,40,48,46,48,44,32,48,46,48,44,32,48,46,48,44,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,61,61,32,48,46,48,41,32,63,32,48,46,48,32,58,32,109,97,120,40,108,111,103,50,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,44,32,48,46,49,41,47,49,48,46,53,41,59,32,47,47,32,104,116,116,112,58,47,47,119,119,119,46,103,117,101,114,114,105,108,108,97,45,103,97,109,101,115,46,99,111,109,47,112,117,98,108,105,99,97,116,105,111,110,115,47,100,114,95,107,122,50,95,114,115,120,95,100,101,118,48,55,46,112,100,102,13,10,35,101,108,115,101,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,9,35,105,102,32,65,76,80,72,65,95,77,65,80,80,73,78,71,13,10,9,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,65,108,112,104,97,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,35,105,102,32,65,76,80,72,65,95,84,69,83,84,13,10,9,105,102,32,40,100,105,102,102,117,115,101,67,111,108,111,114,46,97,32,60,32,77,97,116,101,114,105,97,108,65,108,112,104,97,84,104,114,101,115,104,111,108,100,41,13,10,9,9,100,105,115,99,97,114,100,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,118,101,99,51,32,108,105,103,104,116,65,109,98,105,101,110,116,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,68,105,102,102,117,115,101,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,9,118,101,99,51,32,108,105,103,104,116,83,112,101,99,117,108,97,114,32,61,32,118,101,99,51,40,48,46,48,41,59,13,10,13,10,9,35,105,102,32,78,79,82,77,65,76,95,77,65,80,80,73,78,71,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,76,105,103,104,116,84,111,87,111,114,108,100,32,42,32,40,50,46,48,32,42,32,118,101,99,51,40,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,78,111,114,109,97,108,77,97,112,44,32,116,101,120,67,111,111,114,100,41,41,32,45,32,49,46,48,41,41,59,13,10,9,35,101,108,115,101,13,10,9,118,101,99,51,32,110,111,114,109,97,108,32,61,32,110,111,114,109,97,108,105,122,101,40,118,78,111,114,109,97,108,41,59,13,10,9,35,101,110,100,105,102,13,10,13,10,9,105,102,32,40,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,32,62,32,48,46,48,41,13,10,9,123,13,10,9,9,118,101,99,51,32,101,121,101,86,101,99,32,61,32,110,111,114,109,97,108,105,122,101,40,69,121,101,80,111,115,105,116,105,111,110,32,45,32,118,87,111,114,108,100,80,111,115,41,59,13,10,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,108,105,103,104,116,68,105,114,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,13,10,9,9,9,9,9,47,47,32,83,112,101,99,117,108,97,114,13,10,9,9,9,9,9,118,101,99,51,32,114,101,102,108,101,99,116,105,111,110,32,61,32,114,101,102,108,101,99,116,40,45,119,111,114,108,100,84,111,76,105,103,104,116,44,32,110,111,114,109,97,108,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,109,97,120,40,100,111,116,40,114,101,102,108,101,99,116,105,111,110,44,32,101,121,101,86,101,99,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,61,32,112,111,119,40,115,112,101,99,117,108,97,114,70,97,99,116,111,114,44,32,77,97,116,101,114,105,97,108,83,104,105,110,105,110,101,115,115,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,43,61,32,97,116,116,32,42,32,115,112,101,99,117,108,97,114,70,97,99,116,111,114,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,101,108,115,101,13,10,9,123,13,10,9,9,102,111,114,32,40,105,110,116,32,105,32,61,32,48,59,32,105,32,60,32,51,59,32,43,43,105,41,13,10,9,9,123,13,10,9,9,9,118,101,99,52,32,108,105,103,104,116,67,111,108,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,99,111,108,111,114,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,120,59,13,10,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,32,61,32,76,105,103,104,116,115,91,105,93,46,102,97,99,116,111,114,115,46,121,59,13,10,13,10,9,9,9,115,119,105,116,99,104,32,40,76,105,103,104,116,115,91,105,93,46,116,121,112,101,41,13,10,9,9,9,123,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,68,73,82,69,67,84,73,79,78,65,76,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,45,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,49,46,48,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,68,105,114,101,99,116,105,111,110,97,108,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,80,79,73,78,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,119,111,114,108,100,84,111,76,105,103,104,116,32,47,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,114,76,101,110,103,116,104,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,80,111,105,110,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,44,32,118,87,111,114,108,100,80,111,115,32,45,32,108,105,103,104,116,80,111,115,44,32,48,46,49,44,32,53,48,46,48,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,108,105,103,104,116,68,105,114,41,44,32,48,46,48,41,59,13,10,9,9,9,9,9,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,125,13,10,13,10,9,9,9,9,99,97,115,101,32,76,73,71,72,84,95,83,80,79,84,58,13,10,9,9,9,9,123,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,80,111,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,120,121,122,59,13,10,9,9,9,9,9,118,101,99,51,32,108,105,103,104,116,68,105,114,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,120,121,122,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,49,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,50,46,119,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,120,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,32,61,32,76,105,103,104,116,115,91,105,93,46,112,97,114,97,109,101,116,101,114,115,51,46,121,59,13,10,13,10,9,9,9,9,9,118,101,99,51,32,119,111,114,108,100,84,111,76,105,103,104,116,32,61,32,108,105,103,104,116,80,111,115,32,45,32,118,87,111,114,108,100,80,111,115,59,13,10,9,9,9,9,9,102,108,111,97,116,32,108,105,103,104,116,68,105,115,116,97,110,99,101,32,61,32,108,101,110,103,116,104,40,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,119,111,114,108,100,84,111,76,105,103,104,116,32,47,61,32,108,105,103,104,116,68,105,115,116,97,110,99,101,59,32,47,47,32,78,111,114,109,97,108,105,115,97,116,105,111,110,13,10,9,9,9,9,9,13,10,9,9,9,9,9,102,108,111,97,116,32,97,116,116,32,61,32,109,97,120,40,108,105,103,104,116,65,116,116,101,110,117,97,116,105,111,110,32,45,32,108,105,103,104,116,73,110,118,82,97,100,105,117,115,32,42,32,108,105,103,104,116,68,105,115,116,97,110,99,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,65,109,98,105,101,110,116,13,10,9,9,9,9,9,108,105,103,104,116,65,109,98,105,101,110,116,32,43,61,32,97,116,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,65,109,98,105,101,110,116,70,97,99,116,111,114,32,42,32,40,77,97,116,101,114,105,97,108,65,109,98,105,101,110,116,46,114,103,98,32,43,32,83,99,101,110,101,65,109,98,105,101,110,116,46,114,103,98,41,59,13,10,13,10,9,9,9,9,9,35,105,102,32,83,72,65,68,79,87,95,77,65,80,80,73,78,71,13,10,9,9,9,9,9,105,102,32,40,76,105,103,104,116,115,91,105,93,46,115,104,97,100,111,119,77,97,112,112,105,110,103,41,13,10,9,9,9,9,9,123,13,10,9,9,9,9,9,9,102,108,111,97,116,32,115,104,97,100,111,119,70,97,99,116,111,114,32,61,32,67,97,108,99,117,108,97,116,101,83,112,111,116,83,104,97,100,111,119,70,97,99,116,111,114,40,105,41,59,13,10,9,9,9,9,9,9,105,102,32,40,115,104,97,100,111,119,70,97,99,116,111,114,32,61,61,32,48,46,48,41,13,10,9,9,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,9,9,9,9,13,10,9,9,9,9,9,9,97,116,116,32,42,61,32,115,104,97,100,111,119,70,97,99,116,111,114,59,13,10,9,9,9,9,9,125,13,10,9,9,9,9,9,35,101,110,100,105,102,13,10,13,10,9,9,9,9,9,47,47,32,77,111,100,105,102,105,99,97,116,105,111,110,32,100,101,32,108,39,97,116,116,195,169,110,117,97,116,105,111,110,32,112,111,117,114,32,103,195,169,114,101,114,32,108,101,32,115,112,111,116,13,10,9,9,9,9,9,102,108,111,97,116,32,99,117,114,65,110,103,108,101,32,61,32,100,111,116,40,108,105,103,104,116,68,105,114,44,32,45,119,111,114,108,100,84,111,76,105,103,104,116,41,59,13,10,9,9,9,9,9,102,108,111,97,116,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,32,61,32,108,105,103,104,116,73,110,110,101,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,59,13,10,9,9,9,9,9,97,116,116,32,42,61,32,109,97,120,40,40,99,117,114,65,110,103,108,101,32,45,32,108,105,103,104,116,79,117,116,101,114,65,110,103,108,101,41,32,47,32,105,110,110,101,114,77,105,110,117,115,79,117,116,101,114,65,110,103,108,101,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,47,47,32,68,105,102,102,117,115,101,13,10,9,9,9,9,9,102,108,111,97,116,32,108,97,109,98,101,114,116,32,61,32,109,97,120,40,100,111,116,40,110,111,114,109,97,108,44,32,119,111,114,108,100,84,111,76,105,103,104,116,41,44,32,48,46,48,41,59,13,10,13,10,9,9,9,9,9,108,105,103,104,116,68,105,102,102,117,115,101,32,43,61,32,97,116,116,32,42,32,108,97,109,98,101,114,116,32,42,32,108,105,103,104,116,67,111,108,111,114,46,114,103,98,32,42,32,108,105,103,104,116,68,105,102,102,117,115,101,70,97,99,116,111,114,59,13,10,9,9,9,9,125,13,10,9,9,9,9,13,10,9,9,9,9,100,101,102,97,117,108,116,58,13,10,9,9,9,9,9,98,114,101,97,107,59,13,10,9,9,9,125,13,10,9,9,125,13,10,9,125,13,10,9,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,46,114,103,98,59,13,10,9,35,105,102,32,83,80,69,67,85,76,65,82,95,77,65,80,80,73,78,71,13,10,9,108,105,103,104,116,83,112,101,99,117,108,97,114,32,42,61,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,32,47,47,32,85,116,105,108,105,115,101,114,32,108,39,97,108,112,104,97,32,100,101,32,77,97,116,101,114,105,97,108,83,112,101,99,117,108,97,114,32,110,39,97,117,114,97,105,116,32,97,117,99,117,110,32,115,101,110,115,13,10,9,35,101,110,100,105,102,13,10,9,9,13,10,9,118,101,99,51,32,108,105,103,104,116,67,111,108,111,114,32,61,32,40,108,105,103,104,116,65,109,98,105,101,110,116,32,43,32,108,105,103,104,116,68,105,102,102,117,115,101,32,43,32,108,105,103,104,116,83,112,101,99,117,108,97,114,41,59,13,10,9,118,101,99,52,32,102,114,97,103,109,101,110,116,67,111,108,111,114,32,61,32,118,101,99,52,40,108,105,103,104,116,67,111,108,111,114,44,32,49,46,48,41,32,42,32,100,105,102,102,117,115,101,67,111,108,111,114,59,13,10,13,10,9,35,105,102,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,9,102,108,111,97,116,32,108,105,103,104,116,73,110,116,101,110,115,105,116,121,32,61,32,100,111,116,40,108,105,103,104,116,67,111,108,111,114,44,32,118,101,99,51,40,48,46,51,44,32,48,46,53,57,44,32,48,46,49,49,41,41,59,13,10,13,10,9,118,101,99,51,32,101,109,105,115,115,105,111,110,67,111,108,111,114,32,61,32,77,97,116,101,114,105,97,108,68,105,102,102,117,115,101,46,114,103,98,32,42,32,116,101,120,116,117,114,101,40,77,97,116,101,114,105,97,108,69,109,105,115,115,105,118,101,77,97,112,44,32,116,101,120,67,111,111,114,100,41,46,114,103,98,59,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,109,105,120,40,102,114,97,103,109,101,110,116,67,111,108,111,114,46,114,103,98,44,32,101,109,105,115,115,105,111,110,67,111,108,111,114,44,32,99,108,97,109,112,40,49,46,48,32,45,32,51,46,48,42,108,105,103,104,116,73,110,116,101,110,115,105,116,121,44,32,48,46,48,44,32,49,46,48,41,41,44,32,102,114,97,103,109,101,110,116,67,111,108,111,114,46,97,41,59,13,10,9,35,101,108,115,101,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,102,114,97,103,109,101,110,116,67,111,108,111,114,59,13,10,9,35,101,110,100,105,102,32,47,47,32,69,77,73,83,83,73,86,69,95,77,65,80,80,73,78,71,13,10,35,101,110,100,105,102,32,47,47,32,70,76,65,71,95,68,69,70,69,82,82,69,68,13,10,125,13,10,13,10, \ No newline at end of file From 9d04b7f924bdb2a125b0ffb86912574d647bf5e2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 12:20:58 +0200 Subject: [PATCH 218/383] Build: Remove Vulkan from modules list Since Vulkan support is not yet finished and pushing it to master was a mistake, I see no reason everyone should link against this module when using the engine. Former-commit-id: 44de71a230c128c60b93590031ab2c279e7096dc [formerly e83d7ef7825aa6deb15a162af8d7ce095dbc16f3] [formerly 61950174ad2ae51fe060d7f356c8c57605c30c34 [formerly 42a29df53f59f9c9821436347441ed313a566701]] Former-commit-id: 8dc9fcc4fd9e3bc50f80390ab7ca8d7a3067485e [formerly cf0d318213e013d43c5f8a83f270f61702b27f1f] Former-commit-id: 2ec36729351a647ef30f5bbf3853db43f63b785f --- build/scripts/modules/vulkan.lua | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 build/scripts/modules/vulkan.lua diff --git a/build/scripts/modules/vulkan.lua b/build/scripts/modules/vulkan.lua deleted file mode 100644 index 62a00a745..000000000 --- a/build/scripts/modules/vulkan.lua +++ /dev/null @@ -1,31 +0,0 @@ -MODULE.Name = "Vulkan" - -MODULE.ClientOnly = true - -MODULE.Defines = { - "VK_NO_PROTOTYPES" -} - -MODULE.Libraries = { - "NazaraCore", - "NazaraUtility" -} - -MODULE.OsDefines.Linux = { --- "VK_USE_PLATFORM_MIR_KHR", - "VK_USE_PLATFORM_XCB_KHR" --- "VK_USE_PLATFORM_XLIB_KHR", --- "VK_USE_PLATFORM_WAYLAND_KHR" -} - -MODULE.OsDefines.BSD = MODULE.OsDefines.Linux -MODULE.OsDefines.Solaris = MODULE.OsDefines.Linux - -MODULE.OsDefines.Windows = { - "VK_USE_PLATFORM_WIN32_KHR" -} - -MODULE.OsFiles.Windows = { - "../src/Nazara/Vulkan/Win32/**.hpp", - "../src/Nazara/Vulkan/Win32/**.cpp" -} From a7a98df1a2af55fb1cf4c6cd32b3839f41caecca Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 12:59:12 +0200 Subject: [PATCH 219/383] Build: Fix TargetDirectory not being taken into account Former-commit-id: ffaf52748cda6abf396dbe79284c6e011e21af95 [formerly 581bef8e7e4973147111c1ae2dbe204a2e2fe619] [formerly 182b31ea267d0d629dd1bafb9a067a2a70b4b234 [formerly 4e59f7f0ee7a2768cbc1d9e0a7923dda498ffda0]] Former-commit-id: 82e66db889b74c6614949d0755eae9b41dc889fa [formerly faffe8c22d70e23c041fad00dc735b268fc07d90] Former-commit-id: 32e116644ab6213d23f6e819bd8341ae512a74e2 --- build/scripts/common.lua | 18 +++++++++--------- build/scripts/tools/assimp.lua | 1 - build/scripts/tools/ndk.lua | 2 +- build/scripts/tools/ndk_server.lua | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index b467eb9c5..498b64ee0 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -270,7 +270,6 @@ function NazaraBuild:Execute() project(prefix .. toolTable.Name) location(_ACTION .. "/tools") - targetdir(toolTable.TargetDirectory) if (toolTable.Kind == "plugin" or toolTable.Kind == "library") then kind("SharedLib") @@ -296,6 +295,8 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") + targetdir(toolTable.TargetDirectory) + configuration("x32") libdirs(toolTable.LibraryPaths.x86) @@ -305,18 +306,17 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") - libdirs("../lib/" .. makeLibDir .. "/x86") + libdirs(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then - targetdir("../lib/" .. makeLibDir .. "/x86") + targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x86") end configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") - libdirs("../lib/" .. makeLibDir .. "/x64") if (toolTable.Kind == "library") then - targetdir("../lib/" .. makeLibDir .. "/x64") + targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/" .. makeLibDir .. "/x64") end @@ -325,7 +325,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x86") libdirs("../lib/msvc/x86") if (toolTable.Kind == "library") then - targetdir("../lib/msvc/x86") + targetdir(toolTable.TargetDirectory .. "/msvc/x86") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x86") end @@ -334,7 +334,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/msvc/x64") libdirs("../lib/msvc/x64") if (toolTable.Kind == "library") then - targetdir("../lib/msvc/x64") + targetdir(toolTable.TargetDirectory .. "/msvc/x64") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/msvc/x64") end @@ -343,7 +343,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/xcode/x86") libdirs("../lib/xcode/x86") if (toolTable.Kind == "library") then - targetdir("../lib/xcode/x86") + targetdir(toolTable.TargetDirectory .. "/xcode/x86") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/xcode/x86") end @@ -352,7 +352,7 @@ function NazaraBuild:Execute() libdirs("../extlibs/lib/xcode/x64") libdirs("../lib/xcode/x64") if (toolTable.Kind == "library") then - targetdir("../lib/xcode/x64") + targetdir(toolTable.TargetDirectory .. "/xcode/x64") elseif (toolTable.Kind == "plugin") then targetdir("../plugins/" .. toolTable.Name .. "/lib/xcode/x64") end diff --git a/build/scripts/tools/assimp.lua b/build/scripts/tools/assimp.lua index c810d6c0a..f834d6d11 100644 --- a/build/scripts/tools/assimp.lua +++ b/build/scripts/tools/assimp.lua @@ -2,7 +2,6 @@ TOOL.Name = "Assimp" TOOL.Directory = "../plugins/Assimp" TOOL.Kind = "Plugin" -TOOL.TargetDirectory = "../SDK/lib" TOOL.Includes = { "../extlibs/include", diff --git a/build/scripts/tools/ndk.lua b/build/scripts/tools/ndk.lua index 8a40ea170..66dcf9a17 100644 --- a/build/scripts/tools/ndk.lua +++ b/build/scripts/tools/ndk.lua @@ -2,7 +2,7 @@ TOOL.Name = "SDK" TOOL.Directory = "../SDK" TOOL.Kind = "Library" -TOOL.TargetDirectory = "../SDK/lib" +TOOL.TargetDirectory = "../lib" TOOL.Defines = { "NDK_BUILD" diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index aa8548b80..cebd158c6 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -2,7 +2,7 @@ TOOL.Name = "SDKServer" TOOL.Directory = "../SDK" TOOL.Kind = "Library" -TOOL.TargetDirectory = "../SDK/lib" +TOOL.TargetDirectory = "../lib" TOOL.Defines = { "NDK_BUILD", From 427bbedcec9454e7155a2dd322372c5092354f65 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 13:00:03 +0200 Subject: [PATCH 220/383] Remove Vulkan from master branch Former-commit-id: f8b920b86746690f4f0c40170f43ef30263dd9a5 [formerly a6671038c978ca76b86d45cb00552b027e6af9b6] [formerly e42912530fb1986eaec43a3f19e4791e0f04226f [formerly 54abe220c26a36ddad1db37aa4ec85f1078dca4d]] Former-commit-id: 52bc69afa7c072659a0ff4d0c97f522a9f886f11 [formerly d78eb693d63cd0bde6e55655405aa4400bc91531] Former-commit-id: e011ea3a03310be890ae7e3952982d7f7aa28279 --- include/Nazara/Vulkan/Config.hpp | 53 ---- include/Nazara/Vulkan/ConfigCheck.hpp | 22 -- include/Nazara/Vulkan/Debug.hpp | 8 - include/Nazara/Vulkan/DebugOff.hpp | 9 - include/Nazara/Vulkan/VkCommandBuffer.hpp | 58 ---- include/Nazara/Vulkan/VkCommandBuffer.inl | 150 ----------- include/Nazara/Vulkan/VkCommandPool.hpp | 53 ---- include/Nazara/Vulkan/VkCommandPool.inl | 53 ---- include/Nazara/Vulkan/VkDevice.hpp | 202 -------------- include/Nazara/Vulkan/VkDevice.inl | 96 ------- include/Nazara/Vulkan/VkDeviceObject.hpp | 50 ---- include/Nazara/Vulkan/VkDeviceObject.inl | 89 ------- include/Nazara/Vulkan/VkInstance.hpp | 141 ---------- include/Nazara/Vulkan/VkInstance.inl | 128 --------- include/Nazara/Vulkan/VkLoader.hpp | 52 ---- include/Nazara/Vulkan/VkLoader.inl | 19 -- include/Nazara/Vulkan/VkQueue.hpp | 52 ---- include/Nazara/Vulkan/VkQueue.inl | 102 ------- include/Nazara/Vulkan/VkSemaphore.hpp | 42 --- include/Nazara/Vulkan/VkSemaphore.inl | 41 --- include/Nazara/Vulkan/VkSurface.hpp | 94 ------- include/Nazara/Vulkan/VkSurface.inl | 311 ---------------------- include/Nazara/Vulkan/VkSwapchain.hpp | 51 ---- include/Nazara/Vulkan/VkSwapchain.inl | 90 ------- include/Nazara/Vulkan/Vulkan.hpp | 33 --- src/Nazara/Vulkan/Debug/NewOverload.cpp | 31 --- src/Nazara/Vulkan/VkCommandPool.cpp | 53 ---- src/Nazara/Vulkan/VkDevice.cpp | 178 ------------- src/Nazara/Vulkan/VkInstance.cpp | 193 -------------- src/Nazara/Vulkan/VkLoader.cpp | 117 -------- src/Nazara/Vulkan/Vulkan.cpp | 70 ----- 31 files changed, 2641 deletions(-) delete mode 100644 include/Nazara/Vulkan/Config.hpp delete mode 100644 include/Nazara/Vulkan/ConfigCheck.hpp delete mode 100644 include/Nazara/Vulkan/Debug.hpp delete mode 100644 include/Nazara/Vulkan/DebugOff.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandBuffer.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandBuffer.inl delete mode 100644 include/Nazara/Vulkan/VkCommandPool.hpp delete mode 100644 include/Nazara/Vulkan/VkCommandPool.inl delete mode 100644 include/Nazara/Vulkan/VkDevice.hpp delete mode 100644 include/Nazara/Vulkan/VkDevice.inl delete mode 100644 include/Nazara/Vulkan/VkDeviceObject.hpp delete mode 100644 include/Nazara/Vulkan/VkDeviceObject.inl delete mode 100644 include/Nazara/Vulkan/VkInstance.hpp delete mode 100644 include/Nazara/Vulkan/VkInstance.inl delete mode 100644 include/Nazara/Vulkan/VkLoader.hpp delete mode 100644 include/Nazara/Vulkan/VkLoader.inl delete mode 100644 include/Nazara/Vulkan/VkQueue.hpp delete mode 100644 include/Nazara/Vulkan/VkQueue.inl delete mode 100644 include/Nazara/Vulkan/VkSemaphore.hpp delete mode 100644 include/Nazara/Vulkan/VkSemaphore.inl delete mode 100644 include/Nazara/Vulkan/VkSurface.hpp delete mode 100644 include/Nazara/Vulkan/VkSurface.inl delete mode 100644 include/Nazara/Vulkan/VkSwapchain.hpp delete mode 100644 include/Nazara/Vulkan/VkSwapchain.inl delete mode 100644 include/Nazara/Vulkan/Vulkan.hpp delete mode 100644 src/Nazara/Vulkan/Debug/NewOverload.cpp delete mode 100644 src/Nazara/Vulkan/VkCommandPool.cpp delete mode 100644 src/Nazara/Vulkan/VkDevice.cpp delete mode 100644 src/Nazara/Vulkan/VkInstance.cpp delete mode 100644 src/Nazara/Vulkan/VkLoader.cpp delete mode 100644 src/Nazara/Vulkan/Vulkan.cpp diff --git a/include/Nazara/Vulkan/Config.hpp b/include/Nazara/Vulkan/Config.hpp deleted file mode 100644 index d5f616214..000000000 --- a/include/Nazara/Vulkan/Config.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - Nazara Engine - Vulkan - - Copyright (C) 2015 Jérôme "Lynix" Leclercq (Lynix680@gmail.com) - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#pragma once - -#ifndef NAZARA_CONFIG_VULKAN_HPP -#define NAZARA_CONFIG_VULKAN_HPP - -/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci - -// Utilise le MemoryManager pour gérer les allocations dynamiques (détecte les leaks au prix d'allocations/libérations dynamiques plus lentes) -#define NAZARA_VULKAN_MANAGE_MEMORY 0 - -// Active les tests de sécurité basés sur le code (Conseillé pour le développement) -#define NAZARA_VULKAN_SAFE 1 - -/// Chaque modification d'un paramètre ci-dessous implique une modification (souvent mineure) du code - -/// Vérification des valeurs et types de certaines constantes -#include - -#if !defined(NAZARA_STATIC) - #ifdef NAZARA_VULKAN_BUILD - #define NAZARA_VULKAN_API NAZARA_EXPORT - #else - #define NAZARA_VULKAN_API NAZARA_IMPORT - #endif -#else - #define NAZARA_VULKAN_API -#endif - -#endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/Vulkan/ConfigCheck.hpp b/include/Nazara/Vulkan/ConfigCheck.hpp deleted file mode 100644 index 22f334c6f..000000000 --- a/include/Nazara/Vulkan/ConfigCheck.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONFIG_CHECK_VULKANE_HPP -#define NAZARA_CONFIG_CHECK_VULKANE_HPP - -/// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp - -#include -#define CheckType(name, type, err) static_assert(std::is_ ##type ::value, #type err) -#define CheckTypeAndVal(name, type, op, val, err) static_assert(std::is_ ##type ::value && name op val, #type err) - -// On force la valeur de MANAGE_MEMORY en mode debug -#if defined(NAZARA_DEBUG) && !NAZARA_VULKAN_MANAGE_MEMORY - #undef NAZARA_MODULENAME_MANAGE_MEMORY - #define NAZARA_MODULENAME_MANAGE_MEMORY 0 -#endif - -#endif // NAZARA_CONFIG_CHECK_VULKAN_HPP diff --git a/include/Nazara/Vulkan/Debug.hpp b/include/Nazara/Vulkan/Debug.hpp deleted file mode 100644 index b5e44efae..000000000 --- a/include/Nazara/Vulkan/Debug.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_MODULENAME_MANAGE_MEMORY - #include -#endif diff --git a/include/Nazara/Vulkan/DebugOff.hpp b/include/Nazara/Vulkan/DebugOff.hpp deleted file mode 100644 index e57a2b946..000000000 --- a/include/Nazara/Vulkan/DebugOff.hpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// On suppose que Debug.hpp a déjà été inclus, tout comme Config.hpp -#if NAZARA_MODULENAME_MANAGE_MEMORY - #undef delete - #undef new -#endif diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp deleted file mode 100644 index 2dea341dd..000000000 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKCOMMANDBUFFER_HPP -#define NAZARA_VULKAN_VKCOMMANDBUFFER_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API CommandBuffer - { - friend CommandPool; - - public: - CommandBuffer(const CommandBuffer&) = delete; - CommandBuffer(CommandBuffer&& commandBuffer); - inline ~CommandBuffer(); - - inline bool Begin(const VkCommandBufferBeginInfo& info); - inline bool Begin(VkCommandBufferUsageFlags flags); - inline bool Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo); - inline bool Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); - inline bool Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics); - - inline bool End(); - - inline void Free(); - - inline VkResult GetLastErrorCode() const; - - CommandBuffer& operator=(const CommandBuffer&) = delete; - CommandBuffer& operator=(CommandBuffer&&) = delete; - - inline operator VkCommandBuffer(); - - private: - inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); - - CommandPoolHandle m_pool; - VkAllocationCallbacks m_allocator; - VkCommandBuffer m_handle; - VkResult m_lastErrorCode; - - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKCOMMANDBUFFER_HPP diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl deleted file mode 100644 index d2d6f50d7..000000000 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline CommandBuffer::CommandBuffer(CommandPool& pool, VkCommandBuffer handle) : - m_pool(&pool), - m_handle(handle) - { - } - - inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) : - m_pool(std::move(commandBuffer.m_pool)), - m_allocator(commandBuffer.m_allocator), - m_handle(commandBuffer.m_handle), - m_lastErrorCode(commandBuffer.m_lastErrorCode) - { - commandBuffer.m_handle = VK_NULL_HANDLE; - } - - inline CommandBuffer::~CommandBuffer() - { - Free(); - } - - inline bool CommandBuffer::Begin(const VkCommandBufferBeginInfo& info) - { - m_lastErrorCode = m_pool->GetDevice().vkBeginCommandBuffer(m_handle, &info); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to begin command buffer"); - return false; - } - - return true; - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags) - { - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - nullptr - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo& inheritanceInfo) - { - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, VkRenderPass renderPass, UInt32 subpass, VkFramebuffer framebuffer, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) - { - NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); - - VkCommandBufferInheritanceInfo inheritanceInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, - nullptr, - renderPass, - subpass, - framebuffer, - VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), - queryFlags, - pipelineStatistics - }; - - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::Begin(VkCommandBufferUsageFlags flags, bool occlusionQueryEnable, VkQueryControlFlags queryFlags, VkQueryPipelineStatisticFlags pipelineStatistics) - { - NazaraAssert(flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT, "Continue bit is required to ignore renderPass, subpass and framebuffer"); - - VkCommandBufferInheritanceInfo inheritanceInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, - nullptr, - VK_NULL_HANDLE, - 0, - VK_NULL_HANDLE, - VkBool32((occlusionQueryEnable) ? VK_TRUE : VK_FALSE), - queryFlags, - pipelineStatistics - }; - - VkCommandBufferBeginInfo beginInfo = { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - nullptr, - flags, - &inheritanceInfo - }; - - return Begin(beginInfo); - } - - inline bool CommandBuffer::End() - { - m_lastErrorCode = m_pool->GetDevice().vkEndCommandBuffer(m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to end command buffer"); - return false; - } - - return true; - } - - inline void CommandBuffer::Free() - { - if (m_handle) - m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); - } - - inline VkResult CommandBuffer::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline CommandBuffer::operator VkCommandBuffer() - { - return m_handle; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkCommandPool.hpp b/include/Nazara/Vulkan/VkCommandPool.hpp deleted file mode 100644 index b51061bb2..000000000 --- a/include/Nazara/Vulkan/VkCommandPool.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKCOMMANDPOOL_HPP -#define NAZARA_VULKAN_VKCOMMANDPOOL_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class CommandBuffer; - class CommandPool; - - using CommandPoolHandle = ObjectHandle; - - class NAZARA_VULKAN_API CommandPool : public DeviceObject, public HandledObject - { - friend DeviceObject; - - public: - inline CommandPool(Device& instance); - CommandPool(const CommandPool&) = delete; - CommandPool(CommandPool&&) = default; - ~CommandPool() = default; - - CommandBuffer AllocateCommandBuffer(VkCommandBufferLevel level); - std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); - - using DeviceObject::Create; - inline bool Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - - inline bool Reset(VkCommandPoolResetFlags flags); - - CommandPool& operator=(const CommandPool&) = delete; - CommandPool& operator=(CommandPool&&) = delete; - - private: - static inline VkResult CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); - static inline void DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKCOMMANDPOOL_HPP diff --git a/include/Nazara/Vulkan/VkCommandPool.inl b/include/Nazara/Vulkan/VkCommandPool.inl deleted file mode 100644 index 61cfeaa43..000000000 --- a/include/Nazara/Vulkan/VkCommandPool.inl +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline CommandPool::CommandPool(Device& device) : - DeviceObject(device) - { - } - - inline bool CommandPool::Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) - { - VkCommandPoolCreateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, - nullptr, - flags, - queueFamilyIndex - }; - - return Create(createInfo, allocator); - } - - inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) - { - m_lastErrorCode = m_device.vkResetCommandPool(m_device, m_handle, flags); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline VkResult CommandPool::CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) - { - return device.vkCreateCommandPool(device, createInfo, allocator, handle); - } - - inline void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyCommandPool(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp deleted file mode 100644 index 1b9d3a470..000000000 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKDEVICE_HPP -#define NAZARA_VULKAN_VKDEVICE_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Device; - class Queue; - class Instance; - - using DeviceHandle = ObjectHandle; - - class NAZARA_VULKAN_API Device : public HandledObject - { - public: - inline Device(Instance& instance); - Device(const Device&) = delete; - Device(Device&&) = delete; - inline ~Device(); - - bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); - inline Instance& GetInstance(); - inline const Instance& GetInstance() const; - inline VkResult GetLastErrorCode() const; - - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); - - inline bool WaitForIdle(); - - Device& operator=(const Device&) = delete; - Device& operator=(Device&&) = delete; - - inline operator VkDevice(); - - // Vulkan functions - #define NAZARA_VULKAN_DEVICE_FUNCTION(func) PFN_##func func - - // Vulkan core - NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBindBufferMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkBindImageMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBeginQuery); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBeginRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindIndexBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindPipeline); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBindVertexBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdBlitImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearAttachments); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearColorImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdClearDepthStencilImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyBufferToImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyImageToBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdCopyQueryPoolResults); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDispatch); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDispatchIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDraw); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexed); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdDrawIndirect); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdEndQuery); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdEndRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdExecuteCommands); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdFillBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdNextSubpass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdPipelineBarrier); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdPushConstants); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResetQueryPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdResolveImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetBlendConstants); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBias); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBounds); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetLineWidth); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetScissor); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilCompareMask); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilReference); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetStencilWriteMask); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdSetViewport); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdUpdateBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdWaitEvents); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCmdWriteTimestamp); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateBufferView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateComputePipelines); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateDescriptorSetLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateFramebuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateGraphicsPipelines); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImageView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreatePipelineLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSampler); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSemaphore); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateShaderModule); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyBufferView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyDevice); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyFramebuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImage); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImageView); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipeline); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipelineLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyRenderPass); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySampler); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySemaphore); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyShaderModule); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDeviceWaitIdle); - NAZARA_VULKAN_DEVICE_FUNCTION(vkEndCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeCommandBuffers); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFreeMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkFlushMappedMemoryRanges); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetBufferMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetDeviceMemoryCommitment); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetDeviceQueue); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetEventStatus); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetFenceStatus); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageSparseMemoryRequirements); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetImageSubresourceLayout); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetRenderAreaGranularity); - NAZARA_VULKAN_DEVICE_FUNCTION(vkInvalidateMappedMemoryRanges); - NAZARA_VULKAN_DEVICE_FUNCTION(vkMapMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkMergePipelineCaches); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueueSubmit); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueueWaitIdle); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetCommandBuffer); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetCommandPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetDescriptorPool); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetFences); - NAZARA_VULKAN_DEVICE_FUNCTION(vkResetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkSetEvent); - NAZARA_VULKAN_DEVICE_FUNCTION(vkUnmapMemory); - NAZARA_VULKAN_DEVICE_FUNCTION(vkUpdateDescriptorSets); - NAZARA_VULKAN_DEVICE_FUNCTION(vkWaitForFences); - - // VK_KHR_display_swapchain - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSharedSwapchainsKHR); - - // VK_KHR_surface - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_KHR_swapchain - NAZARA_VULKAN_DEVICE_FUNCTION(vkAcquireNextImageKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSwapchainKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySwapchainKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkGetSwapchainImagesKHR); - NAZARA_VULKAN_DEVICE_FUNCTION(vkQueuePresentKHR); - - #undef NAZARA_VULKAN_DEVICE_FUNCTION - - private: - inline PFN_vkVoidFunction GetProcAddr(const char* name); - - Instance& m_instance; - VkAllocationCallbacks m_allocator; - VkDevice m_device; - VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKDEVICE_HPP diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl deleted file mode 100644 index 77dc1e254..000000000 --- a/include/Nazara/Vulkan/VkDevice.inl +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Device::Device(Instance& instance) : - m_instance(instance), - m_device(nullptr) - { - } - - inline Device::~Device() - { - Destroy(); - } - - inline void Device::Destroy() - { - if (m_device) - { - vkDeviceWaitIdle(m_device); - vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - } - - inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) - { - VkQueue queue; - vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - - return Queue(*this, queue); - } - - inline Instance& Device::GetInstance() - { - return m_instance; - } - - inline const Instance& Device::GetInstance() const - { - return m_instance; - } - - inline VkResult Device::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Device::IsExtensionLoaded(const String& extensionName) - { - return m_loadedExtensions.count(extensionName) > 0; - } - - inline bool Device::IsLayerLoaded(const String& layerName) - { - return m_loadedLayers.count(layerName) > 0; - } - - inline bool Device::WaitForIdle() - { - m_lastErrorCode = vkDeviceWaitIdle(m_device); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to wait for device idle"); - return false; - } - - return true; - } - - inline Device::operator VkDevice() - { - return m_device; - } - - inline PFN_vkVoidFunction Device::GetProcAddr(const char* name) - { - PFN_vkVoidFunction func = m_instance.GetDeviceProcAddr(m_device, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp deleted file mode 100644 index dd9da38c9..000000000 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKDEVICEOBJECT_HPP -#define NAZARA_VULKAN_VKDEVICEOBJECT_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - template - class DeviceObject - { - public: - inline DeviceObject(Device& instance); - DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&&); - inline ~DeviceObject(); - - inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - inline Device& GetDevice(); - inline const Device& GetDevice() const; - inline VkResult GetLastErrorCode() const; - - DeviceObject& operator=(const DeviceObject&) = delete; - DeviceObject& operator=(DeviceObject&&) = delete; - - inline operator VkType(); - - protected: - Device& m_device; - VkAllocationCallbacks m_allocator; - VkType m_handle; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl deleted file mode 100644 index a3136156c..000000000 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - template - inline DeviceObject::DeviceObject(Device& device) : - m_device(device), - m_handle(VK_NULL_HANDLE) - { - } - - template - inline DeviceObject::DeviceObject(DeviceObject&& object) : - m_device(object.m_device), - m_allocator(object.m_allocator), - m_handle(object.m_handle), - m_lastErrorCode(object.m_lastErrorCode) - { - object.m_handle = VK_NULL_HANDLE; - } - - template - inline DeviceObject::~DeviceObject() - { - Destroy(); - } - - template - inline bool DeviceObject::Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan object"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - - template - inline void DeviceObject::Destroy() - { - if (m_handle != VK_NULL_HANDLE) - C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - template - inline Device& DeviceObject::GetDevice() - { - return m_device; - } - - template - inline const Device& DeviceObject::GetDevice() const - { - return m_device; - } - - template - inline VkResult DeviceObject::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - template - inline DeviceObject::operator VkType() - { - return m_handle; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkInstance.hpp b/include/Nazara/Vulkan/VkInstance.hpp deleted file mode 100644 index ded2b0ef7..000000000 --- a/include/Nazara/Vulkan/VkInstance.hpp +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKINSTANCE_HPP -#define NAZARA_VULKAN_VKINSTANCE_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API Instance - { - public: - inline Instance(); - Instance(const Instance&) = delete; - Instance(Instance&&) = delete; - inline ~Instance(); - - bool Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(const String& appName, UInt32 appVersion, const String& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); - - bool EnumeratePhysicalDevices(std::vector* physicalDevices); - - inline PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* name); - - inline void GetPhysicalDeviceFeatures(VkPhysicalDevice device, VkPhysicalDeviceFeatures* features); - inline void GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format, VkFormatProperties* formatProperties); - inline bool GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties); - inline void GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device, VkPhysicalDeviceMemoryProperties* properties); - inline void GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties* properties); - bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties); - - inline VkResult GetLastErrorCode() const; - - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); - - Instance& operator=(const Instance&) = delete; - Instance& operator=(Instance&&) = delete; - - inline operator VkInstance(); - - // Vulkan functions - #define NAZARA_VULKAN_INSTANCE_FUNCTION(func) PFN_##func func - - // Vulkan core - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDevice); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroyInstance); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDeviceProcAddr); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties); - - // VK_KHR_display - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDisplayModeKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayModePropertiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR); - - // VK_KHR_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_EXT_debug_report - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkDebugReportMessageEXT); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateMirSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMirPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateXcbSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceXcbPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateXlibSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceXlibPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateWaylandSurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - NAZARA_VULKAN_INSTANCE_FUNCTION(vkCreateWin32SurfaceKHR); - NAZARA_VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceWin32PresentationSupportKHR); - #endif - - #undef NAZARA_VULKAN_INSTANCE_FUNCTION - - private: - inline PFN_vkVoidFunction GetProcAddr(const char* name); - - VkAllocationCallbacks m_allocator; - VkInstance m_instance; - VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKINSTANCE_HPP diff --git a/include/Nazara/Vulkan/VkInstance.inl b/include/Nazara/Vulkan/VkInstance.inl deleted file mode 100644 index 801691855..000000000 --- a/include/Nazara/Vulkan/VkInstance.inl +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Instance::Instance() : - m_instance(nullptr) - { - } - - inline Instance::~Instance() - { - Destroy(); - } - - inline bool Instance::Create(const String& appName, UInt32 appVersion, const String& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator) - { - VkApplicationInfo appInfo = - { - VK_STRUCTURE_TYPE_APPLICATION_INFO, - nullptr, - appName.GetConstBuffer(), - appVersion, - engineName.GetConstBuffer(), - engineVersion - }; - - VkInstanceCreateInfo instanceInfo = - { - VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - nullptr, - 0, - &appInfo, - static_cast(layers.size()), - (!layers.empty()) ? layers.data() : nullptr, - static_cast(extensions.size()), - (!extensions.empty()) ? extensions.data() : nullptr - }; - - return Create(instanceInfo, allocator); - } - - inline void Instance::Destroy() - { - if (m_instance) - vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) - { - PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - - inline VkResult Instance::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Instance::IsExtensionLoaded(const String& extensionName) - { - return m_loadedExtensions.count(extensionName) > 0; - } - - inline bool Instance::IsLayerLoaded(const String& layerName) - { - return m_loadedLayers.count(layerName) > 0; - } - - inline Instance::operator VkInstance() - { - return m_instance; - } - - inline void Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device, VkPhysicalDeviceFeatures* features) - { - return vkGetPhysicalDeviceFeatures(device, features); - } - - inline void Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format, VkFormatProperties* formatProperties) - { - return vkGetPhysicalDeviceFormatProperties(device, format, formatProperties); - } - - inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) - { - m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get physical device image format properties"); - return false; - } - - return true; - } - - inline void Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device, VkPhysicalDeviceMemoryProperties* memoryProperties) - { - return vkGetPhysicalDeviceMemoryProperties(device, memoryProperties); - } - - inline void Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties* properties) - { - return vkGetPhysicalDeviceProperties(device, properties); - } - - inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) - { - PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name); - if (!func) - NazaraError("Failed to get " + String(name) + " address"); - - return func; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkLoader.hpp b/include/Nazara/Vulkan/VkLoader.hpp deleted file mode 100644 index f12429b28..000000000 --- a/include/Nazara/Vulkan/VkLoader.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKLOADER_HPP -#define NAZARA_VULKAN_VKLOADER_HPP - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class NAZARA_VULKAN_API Loader - { - public: - Loader() = delete; - ~Loader() = delete; - - static bool EnumerateInstanceExtensionProperties(std::vector* properties, const char* layerName = nullptr); - static bool EnumerateInstanceLayerProperties(std::vector* properties); - - static inline PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name); - - static bool Initialize(); - static void Uninitialize(); - - // Vulkan functions - #define NAZARA_VULKAN_GLOBAL_FUNCTION(func) static PFN_##func func - - NAZARA_VULKAN_GLOBAL_FUNCTION(vkCreateInstance); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION(vkGetInstanceProcAddr); - - #undef NAZARA_VULKAN_GLOBAL_FUNCTION - - private: - static DynLib s_vulkanLib; - static VkResult s_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKLOADER_HPP diff --git a/include/Nazara/Vulkan/VkLoader.inl b/include/Nazara/Vulkan/VkLoader.inl deleted file mode 100644 index 49467366d..000000000 --- a/include/Nazara/Vulkan/VkLoader.inl +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - namespace Vk - { - inline PFN_vkVoidFunction Loader::GetInstanceProcAddr(VkInstance instance, const char* name) - { - return vkGetInstanceProcAddr(instance, name); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp deleted file mode 100644 index 35c8d16e0..000000000 --- a/include/Nazara/Vulkan/VkQueue.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKQUEUE_HPP -#define NAZARA_VULKAN_VKQUEUE_HPP - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Queue - { - public: - inline Queue(Device& device, VkQueue queue); - inline Queue(const Queue& queue); - inline Queue(Queue&& queue); - inline ~Queue() = default; - - inline Device& GetDevice(); - inline VkResult GetLastErrorCode() const; - - inline bool Present(const VkPresentInfoKHR& presentInfo); - inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); - - inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE); - inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE); - - inline bool WaitIdle(); - - Queue& operator=(const Queue& queue) = delete; - Queue& operator=(Queue&&) = delete; - - inline operator VkQueue(); - - protected: - Device& m_device; - VkQueue m_handle; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKQUEUE_HPP diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl deleted file mode 100644 index a47918da3..000000000 --- a/include/Nazara/Vulkan/VkQueue.inl +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Queue::Queue(Device& device, VkQueue queue) : - m_device(device), - m_handle(queue), - m_lastErrorCode(VkResult::VK_SUCCESS) - { - } - - inline Queue::Queue(const Queue& queue) : - m_device(queue.m_device), - m_handle(queue.m_handle), - m_lastErrorCode(queue.m_lastErrorCode) - { - } - - inline Queue::Queue(Queue&& queue) : - m_device(queue.m_device), - m_handle(queue.m_handle), - m_lastErrorCode(queue.m_lastErrorCode) - { - } - - inline Device& Queue::GetDevice() - { - return m_device; - } - - inline VkResult Queue::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) - { - m_lastErrorCode = m_device.vkQueuePresentKHR(m_handle, &presentInfo); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) - { - VkPresentInfoKHR presentInfo = - { - VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, - nullptr, - (waitSemaphore) ? 1U : 0U, - &waitSemaphore, - 1U, - &swapchain, - &imageIndex, - nullptr - }; - - return Present(presentInfo); - } - - inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) - { - return Submit(1, &submit, fence); - } - - inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) - { - m_lastErrorCode = m_device.vkQueueSubmit(m_handle, submitCount, submits, fence); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline bool Queue::WaitIdle() - { - m_lastErrorCode = m_device.vkQueueWaitIdle(m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return false; - - return true; - } - - inline Queue::operator VkQueue() - { - return m_handle; - } - - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp deleted file mode 100644 index 138d726be..000000000 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKSEMAPHORE_HPP -#define NAZARA_VULKAN_VKSEMAPHORE_HPP - -#include -#include - -namespace Nz -{ - namespace Vk - { - class Semaphore : public DeviceObject - { - friend DeviceObject; - - public: - inline Semaphore(Device& instance); - Semaphore(const Semaphore&) = delete; - Semaphore(Semaphore&&) = default; - ~Semaphore() = default; - - using DeviceObject::Create; - inline bool Create(VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - - Semaphore& operator=(const Semaphore&) = delete; - Semaphore& operator=(Semaphore&&) = delete; - - private: - static VkResult CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); - static void DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSEMAPHORE_HPP diff --git a/include/Nazara/Vulkan/VkSemaphore.inl b/include/Nazara/Vulkan/VkSemaphore.inl deleted file mode 100644 index fd2bf3427..000000000 --- a/include/Nazara/Vulkan/VkSemaphore.inl +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Semaphore::Semaphore(Device& device) : - DeviceObject(device) - { - } - - inline bool Semaphore::Create(VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) - { - VkSemaphoreCreateInfo createInfo = - { - VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, - nullptr, - flags - }; - - return Create(createInfo, allocator); - } - - VkResult Semaphore::CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) - { - return device.vkCreateSemaphore(device, createInfo, allocator, handle); - } - - void Semaphore::DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroySemaphore(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp deleted file mode 100644 index 03a57d2fe..000000000 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKSURFACE_HPP -#define NAZARA_VULKAN_VKSURFACE_HPP - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - class Instance; - - class Surface - { - public: - inline Surface(Instance& instance); - Surface(const Surface&) = delete; - Surface(Surface&& surface); - inline ~Surface(); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - inline bool Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(ANativeWindow* window, VkAndroidSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - inline bool Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(MirConnection* connection, MirSurface* surface, VkMirSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - inline bool Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(xcb_connection_t* connection, xcb_window_t window, VkXcbSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - inline bool Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(Display* display, Window window, VkXlibSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - inline bool Create(const VkWaylandSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(wl_display* display, wl_surface* surface, VkWaylandSurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - inline bool Create(const VkWin32SurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(HINSTANCE instance, HWND handle, VkWin32SurfaceCreateFlagsKHR flags = 0, const VkAllocationCallbacks* allocator = nullptr); - #endif - - inline void Destroy(); - - bool GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities); - bool GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats); - bool GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes); - bool GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported); - - inline bool IsSupported() const; - - inline VkResult GetLastErrorCode() const; - - Surface& operator=(const Surface&) = delete; - Surface& operator=(Surface&&) = delete; - - inline operator VkSurfaceKHR(); - - private: - inline bool Create(const VkAllocationCallbacks* allocator); - - Instance& m_instance; - VkAllocationCallbacks m_allocator; - VkSurfaceKHR m_surface; - VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSURFACE_HPP diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl deleted file mode 100644 index f64c24af0..000000000 --- a/include/Nazara/Vulkan/VkSurface.inl +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Surface::Surface(Instance& instance) : - m_instance(instance), - m_surface(VK_NULL_HANDLE) - { - } - - inline Surface::Surface(Surface&& surface) : - m_instance(surface.m_instance), - m_allocator(surface.m_allocator), - m_surface(surface.m_surface), - m_lastErrorCode(surface.m_lastErrorCode) - { - surface.m_surface = VK_NULL_HANDLE; - } - - inline Surface::~Surface() - { - Destroy(); - } - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - inline bool Surface::Create(const VkAndroidSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateAndroidSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(ANativeWindow* window, VkAndroidSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkAndroidSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - inline bool Surface::Create(const VkMirSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateMirSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(MirConnection* connection, MirSurface* surface, VkMirSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkMirSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - connection, - surface - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - inline bool Surface::Create(const VkXcbSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateXcbSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(xcb_connection_t* connection, xcb_window_t window, VkXcbSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkXcbSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - connection, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - inline bool Surface::Create(const VkXlibSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateXlibSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(Display* display, Window window, VkXlibSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkXlibSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - display, - window - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - inline bool Surface::Create(const VkWaylandSurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateWaylandSurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(wl_display* display, wl_surface* surface, VkWaylandSurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkWaylandSurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - display, - surface - }; - - return Create(createInfo, allocator); - } - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - inline bool Surface::Create(const VkWin32SurfaceCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateWin32SurfaceKHR(m_instance, &createInfo, allocator, &m_surface); - return Create(allocator); - } - - inline bool Surface::Create(HINSTANCE instance, HWND handle, VkWin32SurfaceCreateFlagsKHR flags, const VkAllocationCallbacks* allocator) - { - VkWin32SurfaceCreateInfoKHR createInfo = - { - VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, - nullptr, - flags, - instance, - handle - }; - - return Create(createInfo, allocator); - } - #endif - - inline void Surface::Destroy() - { - if (m_surface != VK_NULL_HANDLE) - m_instance.vkDestroySurfaceKHR(m_instance, m_surface, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - - inline VkResult Surface::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - inline bool Surface::GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) - { - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surface, surfaceCapabilities); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query surface capabilities"); - return false; - } - - return true; - } - - inline bool Surface::GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) - { - // First, query format count - UInt32 surfaceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || surfaceCount == 0) - { - NazaraError("Failed to query format count"); - return false; - } - - // Now we can get the list of the available physical device - surfaceFormats->resize(surfaceCount); - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, surfaceFormats->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query formats"); - return false; - } - - return true; - } - - inline bool Surface::GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) - { - // First, query present modes count - UInt32 presentModeCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || presentModeCount == 0) - { - NazaraError("Failed to query present mode count"); - return false; - } - - // Now we can get the list of the available physical device - presentModes->resize(presentModeCount); - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, presentModes->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query present modes"); - return false; - } - - return true; - } - - inline bool Surface::GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) - { - VkBool32 presentationSupported = VK_FALSE; - m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, m_surface, &presentationSupported); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query surface capabilities"); - return false; - } - - *supported = (presentationSupported == VK_TRUE); - - return true; - } - - inline bool Surface::IsSupported() const - { - if (!m_instance.IsExtensionLoaded("VK_KHR_surface")) - return false; - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_android_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_mir_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_xcb_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_xlib_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_wayland_surface")) - return true; - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - if (m_instance.IsExtensionLoaded("VK_KHR_win32_surface")) - return true; - #endif - - return false; - } - - inline Surface::operator VkSurfaceKHR() - { - return m_surface; - } - - inline bool Surface::Create(const VkAllocationCallbacks* allocator) - { - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan surface"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - } -} - -#include diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp deleted file mode 100644 index 374ad88e6..000000000 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_VKSWAPCHAIN_HPP -#define NAZARA_VULKAN_VKSWAPCHAIN_HPP - -#include -#include - -namespace Nz -{ - namespace Vk - { - class Swapchain : public DeviceObject - { - friend DeviceObject; - - public: - inline Swapchain(Device& instance); - Swapchain(const Swapchain&) = delete; - Swapchain(Swapchain&&) = default; - ~Swapchain() = default; - - inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex); - - inline bool Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - - inline VkImage GetImage(UInt32 index) const; - inline const std::vector& GetImages() const; - inline UInt32 GetImageCount() const; - - inline bool IsSupported() const; - - Swapchain& operator=(const Swapchain&) = delete; - Swapchain& operator=(Swapchain&&) = delete; - - private: - static VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); - static void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); - - std::vector m_images; - }; - } -} - -#include - -#endif // NAZARA_VULKAN_VKSWAPCHAIN_HPP diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl deleted file mode 100644 index 8865012e4..000000000 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline Swapchain::Swapchain(Device& device) : - DeviceObject(device) - { - } - - inline bool Swapchain::AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) - { - m_lastErrorCode = m_device.vkAcquireNextImageKHR(m_device, m_handle, timeout, semaphore, fence, imageIndex); - switch (m_lastErrorCode) - { - case VkResult::VK_SUBOPTIMAL_KHR: - case VkResult::VK_SUCCESS: - return true; - - default: - return false; - } - } - - inline bool Swapchain::Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) - { - if (!DeviceObject::Create(createInfo, allocator)) - return false; - - UInt32 imageCount = 0; - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || imageCount == 0) - { - NazaraError("Failed to query swapchain image count"); - return false; - } - - m_images.resize(imageCount); - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, m_images.data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query swapchain images"); - return false; - } - - return true; - } - - inline VkImage Swapchain::GetImage(UInt32 index) const - { - return m_images[index]; - } - - inline const std::vector& Swapchain::GetImages() const - { - return m_images; - } - - inline UInt32 Swapchain::GetImageCount() const - { - return m_images.size(); - } - - inline bool Swapchain::IsSupported() const - { - if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) - return false; - } - - VkResult Swapchain::CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) - { - return device.vkCreateSwapchainKHR(device, createInfo, allocator, handle); - } - - void Swapchain::DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroySwapchainKHR(device, handle, allocator); - } - } -} - -#include diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp deleted file mode 100644 index 9d90202c2..000000000 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VULKAN_HPP -#define NAZARA_VULKAN_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_VULKAN_API Vulkan - { - public: - Vulkan() = delete; - ~Vulkan() = delete; - - static bool Initialize(); - - static bool IsInitialized(); - - static void Uninitialize(); - - private: - static unsigned int s_moduleReferenceCounter; - }; -} - -#endif // NAZARA_VULKAN_HPP diff --git a/src/Nazara/Vulkan/Debug/NewOverload.cpp b/src/Nazara/Vulkan/Debug/NewOverload.cpp deleted file mode 100644 index 410a53c76..000000000 --- a/src/Nazara/Vulkan/Debug/NewOverload.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2014 AUTHORS -// This file is part of the "Nazara Engine - Module name" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#if NAZARA_VULKAN_MANAGE_MEMORY - -#include -#include // Nécessaire ? - -void* operator new(std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, false); -} - -void* operator new[](std::size_t size) -{ - return Nz::MemoryManager::Allocate(size, true); -} - -void operator delete(void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, false); -} - -void operator delete[](void* pointer) noexcept -{ - Nz::MemoryManager::Free(pointer, true); -} - -#endif // NAZARA_VULKAN_MANAGE_MEMORY diff --git a/src/Nazara/Vulkan/VkCommandPool.cpp b/src/Nazara/Vulkan/VkCommandPool.cpp deleted file mode 100644 index 3ee53ab6f..000000000 --- a/src/Nazara/Vulkan/VkCommandPool.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - CommandBuffer CommandPool::AllocateCommandBuffer(VkCommandBufferLevel level) - { - VkCommandBufferAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - nullptr, - m_handle, - level, - 1U - }; - - VkCommandBuffer handle = VK_NULL_HANDLE; - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, &handle); - - return CommandBuffer(*this, handle); - } - - std::vector CommandPool::AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level) - { - VkCommandBufferAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - nullptr, - m_handle, - level, - 1U - }; - - std::vector handles(commandBufferCount, VK_NULL_HANDLE); - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, handles.data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - return std::vector(); - - std::vector commandBuffers; - for (UInt32 i = 0; i < commandBufferCount; ++i) - commandBuffers.emplace_back(CommandBuffer(*this, handles[i])); - - return commandBuffers; - } - } -} diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp deleted file mode 100644 index c2f39da76..000000000 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan device"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - // Parse extensions and layers - for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i) - m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]); - - for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) - m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); - - #define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) - - try - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - - NAZARA_VULKAN_LOAD_DEVICE(vkAllocateCommandBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkAllocateMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkBeginCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkBindBufferMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkBindImageMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBeginQuery); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBeginRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindIndexBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindPipeline); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBindVertexBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdBlitImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearAttachments); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearColorImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdClearDepthStencilImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyBufferToImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyImageToBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdCopyQueryPoolResults); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDispatch); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDispatchIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDraw); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndexed); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndexedIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdDrawIndirect); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdEndQuery); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdEndRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdExecuteCommands); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdFillBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdNextSubpass); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdPipelineBarrier); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdPushConstants); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResetQueryPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdResolveImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetBlendConstants); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetDepthBias); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetDepthBounds); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetLineWidth); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetScissor); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilCompareMask); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilReference); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetStencilWriteMask); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdSetViewport); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdUpdateBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdWaitEvents); - NAZARA_VULKAN_LOAD_DEVICE(vkCmdWriteTimestamp); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateBufferView); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateComputePipelines); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateDescriptorSetLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateFramebuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateGraphicsPipelines); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateImage); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateImageView); - NAZARA_VULKAN_LOAD_DEVICE(vkCreatePipelineLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSampler); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSemaphore); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateShaderModule); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyBufferView); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDescriptorSetLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyDevice); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyFramebuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImage); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImageView); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipeline); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipelineLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyRenderPass); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySampler); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySemaphore); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroyShaderModule); - NAZARA_VULKAN_LOAD_DEVICE(vkDeviceWaitIdle); - NAZARA_VULKAN_LOAD_DEVICE(vkEndCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeCommandBuffers); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkFreeMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkFlushMappedMemoryRanges); - NAZARA_VULKAN_LOAD_DEVICE(vkGetBufferMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetDeviceMemoryCommitment); - NAZARA_VULKAN_LOAD_DEVICE(vkGetDeviceQueue); - NAZARA_VULKAN_LOAD_DEVICE(vkGetEventStatus); - NAZARA_VULKAN_LOAD_DEVICE(vkGetFenceStatus); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageSparseMemoryRequirements); - NAZARA_VULKAN_LOAD_DEVICE(vkGetImageSubresourceLayout); - NAZARA_VULKAN_LOAD_DEVICE(vkGetRenderAreaGranularity); - NAZARA_VULKAN_LOAD_DEVICE(vkInvalidateMappedMemoryRanges); - NAZARA_VULKAN_LOAD_DEVICE(vkMapMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkMergePipelineCaches); - NAZARA_VULKAN_LOAD_DEVICE(vkQueueSubmit); - NAZARA_VULKAN_LOAD_DEVICE(vkQueueWaitIdle); - NAZARA_VULKAN_LOAD_DEVICE(vkResetCommandBuffer); - NAZARA_VULKAN_LOAD_DEVICE(vkResetCommandPool); - NAZARA_VULKAN_LOAD_DEVICE(vkResetDescriptorPool); - NAZARA_VULKAN_LOAD_DEVICE(vkResetFences); - NAZARA_VULKAN_LOAD_DEVICE(vkResetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkSetEvent); - NAZARA_VULKAN_LOAD_DEVICE(vkUnmapMemory); - NAZARA_VULKAN_LOAD_DEVICE(vkUpdateDescriptorSets); - NAZARA_VULKAN_LOAD_DEVICE(vkWaitForFences); - - // VK_KHR_display_swapchain - if (IsExtensionLoaded("VK_KHR_display_swapchain")) - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSharedSwapchainsKHR); - - // VK_KHR_swapchain - if (IsExtensionLoaded("VK_KHR_swapchain")) - { - NAZARA_VULKAN_LOAD_DEVICE(vkAcquireNextImageKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkCreateSwapchainKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkDestroySwapchainKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkGetSwapchainImagesKHR); - NAZARA_VULKAN_LOAD_DEVICE(vkQueuePresentKHR); - } - } - catch (const std::exception& e) - { - NazaraError(String("Failed to query device function: ") + e.what()); - return false; - } - - #undef NAZARA_VULKAN_LOAD_DEVICE - - return true; - } - } -} diff --git a/src/Nazara/Vulkan/VkInstance.cpp b/src/Nazara/Vulkan/VkInstance.cpp deleted file mode 100644 index 35378a699..000000000 --- a/src/Nazara/Vulkan/VkInstance.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - bool Instance::Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_lastErrorCode = Loader::vkCreateInstance(&createInfo, allocator, &m_instance); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create Vulkan instance"); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - // Parse extensions and layers - for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i) - m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]); - - for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) - m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); - - // And now load everything - #define NAZARA_VULKAN_LOAD_INSTANCE(func) func = reinterpret_cast(GetProcAddr(#func)) - - try - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - - // Vulkan core - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDevice); - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroyInstance); - NAZARA_VULKAN_LOAD_INSTANCE(vkEnumeratePhysicalDevices); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDeviceProcAddr); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceFeatures); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceProperties); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceQueueFamilyProperties); - - // VK_KHR_display - if (IsExtensionLoaded("VK_KHR_display")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDisplayModeKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayModePropertiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPropertiesKHR); - } - - // VK_KHR_surface - if (IsExtensionLoaded("VK_KHR_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroySurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceSupportKHR); - } - - // VK_EXT_debug_report - if (IsExtensionLoaded("VK_EXT_debug_report")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateDebugReportCallbackEXT); - NAZARA_VULKAN_LOAD_INSTANCE(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKAN_LOAD_INSTANCE(vkDebugReportMessageEXT); - } - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - if (IsExtensionLoaded("VK_KHR_android_surface")) - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - if (IsExtensionLoaded("VK_KHR_mir_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateMirSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceMirPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - if (IsExtensionLoaded("VK_KHR_xcb_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateXcbSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceXcbPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - if (IsExtensionLoaded("VK_KHR_xlib_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateXlibSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceXlibPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - if (IsExtensionLoaded("VK_KHR_wayland_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateWaylandSurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - if (IsExtensionLoaded("VK_KHR_win32_surface")) - { - NAZARA_VULKAN_LOAD_INSTANCE(vkCreateWin32SurfaceKHR); - NAZARA_VULKAN_LOAD_INSTANCE(vkGetPhysicalDeviceWin32PresentationSupportKHR); - } - #endif - } - catch (const std::exception& e) - { - NazaraError(String("Failed to query instance function: ") + e.what()); - return false; - } - - #undef NAZARA_VULKAN_LOAD_INSTANCE - - return true; - } - - bool Instance::EnumeratePhysicalDevices(std::vector* devices) - { - NazaraAssert(devices, "Invalid device vector"); - - // First, query physical device count - UInt32 deviceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr); - if (m_lastErrorCode != VkResult::VK_SUCCESS || deviceCount == 0) - { - NazaraError("Failed to query physical device count"); - return false; - } - - // Now we can get the list of the available physical device - devices->resize(deviceCount); - m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices->data()); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to query physical devices"); - return false; - } - - return true; - } - - bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties) - { - NazaraAssert(queueFamilyProperties, "Invalid device vector"); - - // First, query physical device count - UInt32 queueFamiliesCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, nullptr); - if (queueFamiliesCount == 0) - { - NazaraError("Failed to query physical device count"); - return false; - } - - // Now we can get the list of the available physical device - queueFamilyProperties->resize(queueFamiliesCount); - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamiliesCount, queueFamilyProperties->data()); - - return true; - } - - } -} diff --git a/src/Nazara/Vulkan/VkLoader.cpp b/src/Nazara/Vulkan/VkLoader.cpp deleted file mode 100644 index c9d2a360d..000000000 --- a/src/Nazara/Vulkan/VkLoader.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - namespace Vk - { - bool Loader::EnumerateInstanceExtensionProperties(std::vector* properties, const char* layerName) - { - NazaraAssert(properties, "Invalid device vector"); - - // First, query physical device count - UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get instance extension properties count"); - return false; - } - - // Now we can get the list of the available physical device - properties->resize(propertyCount); - s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to enumerate instance extension properties"); - return false; - } - - return true; - } - - bool Loader::EnumerateInstanceLayerProperties(std::vector* properties) - { - NazaraAssert(properties, "Invalid device vector"); - - // First, query physical device count - UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to get instance layer properties count"); - return false; - } - - // Now we can get the list of the available physical device - properties->resize(propertyCount); - s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); - if (s_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to enumerate instance layer properties"); - return false; - } - - return true; - } - - bool Loader::Initialize() - { - #ifdef NAZARA_PLATFORM_WINDOWS - s_vulkanLib.Load("vulkan-1.dll"); - #elif defined(NAZARA_PLATFORM_LINUX) - s_vulkanLib.Load("libvulkan.so"); - #else - #error Unhandled platform - #endif - - if (!s_vulkanLib.IsLoaded()) - { - NazaraError("Failed to open vulkan library: " + s_vulkanLib.GetLastError()); - return false; - } - - // vkGetInstanceProcAddr is the only function that's garantee to be exported - vkGetInstanceProcAddr = reinterpret_cast(s_vulkanLib.GetSymbol("vkGetInstanceProcAddr")); - if (!vkGetInstanceProcAddr) - { - NazaraError("Failed to get symbol \"vkGetInstanceProcAddr\": " + s_vulkanLib.GetLastError()); - return false; - } - - // all other functions should be loaded using vkGetInstanceProcAddr - #define NAZARA_VULKAN_LOAD_GLOBAL(func) func = reinterpret_cast(vkGetInstanceProcAddr(nullptr, #func)) - - NAZARA_VULKAN_LOAD_GLOBAL(vkCreateInstance); - NAZARA_VULKAN_LOAD_GLOBAL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_LOAD_GLOBAL(vkEnumerateInstanceLayerProperties); - - #undef NAZARA_VULKAN_LOAD_GLOBAL - - s_lastErrorCode = VkResult::VK_SUCCESS; - - return true; - } - - #define NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(func) PFN_##func Loader::func = nullptr - - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkCreateInstance); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceLayerProperties); - NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL(vkGetInstanceProcAddr); - - #undef NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL - - DynLib Loader::s_vulkanLib; - VkResult Loader::s_lastErrorCode; - - void Loader::Uninitialize() - { - s_vulkanLib.Unload(); - } - } -} diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp deleted file mode 100644 index 00bb55337..000000000 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Vulkan" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - bool Vulkan::Initialize() - { - if (s_moduleReferenceCounter > 0) - { - s_moduleReferenceCounter++; - return true; // Already initialized - } - - // Initialize module dependencies - if (!Utility::Initialize()) - { - NazaraError("Failed to initialize utility module"); - return false; - } - - s_moduleReferenceCounter++; - - CallOnExit onExit(Vulkan::Uninitialize); - - // Initialize module here - - onExit.Reset(); - - NazaraNotice("Initialized: Vulkan module"); - return true; - } - - bool Vulkan::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - void Vulkan::Uninitialize() - { - if (s_moduleReferenceCounter != 1) - { - // Either the module is not initialized, either it was initialized multiple times - if (s_moduleReferenceCounter > 1) - s_moduleReferenceCounter--; - - return; - } - - s_moduleReferenceCounter = 0; - - // Uninitialize module here - - NazaraNotice("Uninitialized: Vulkan module"); - - // Free module dependencies - Utility::Uninitialize(); - } - - unsigned int Vulkan::s_moduleReferenceCounter = 0; -} - From 658526ff581d029ddb9c13c152c7416bae5c6f78 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 13:05:41 +0200 Subject: [PATCH 221/383] Build/Assimp: Fix assimp rejection Former-commit-id: 4bd673c117b8450e4e7238dd09c0381e8a4f2c61 [formerly 8cc3af25b5c7baba115c80fe555ab8931def6ef1] [formerly 2d0bcd153b4441bc8b32137965f95e580b6570ab [formerly 567211701b7aca9f35b9b47713138d932673b71d]] Former-commit-id: db44829c31fcd67fb52643ea63f64bd127080c20 [formerly ded3811843b6d6d90058c238349bcd05c0bfe91b] Former-commit-id: 56684cc6b81490f9f7e8c445ded6abc4608e0ba1 --- build/scripts/common.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 498b64ee0..b8ca27e70 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -576,10 +576,10 @@ function NazaraBuild:Initialize() local succeed, err = self:RegisterTool(TOOL) if (not succeed) then - print("Unable to register tool: " .. err) + print("Unable to register tool " .. tostring(TOOL.Name) .. ": " .. err) end else - print("Unable to load tool file: " .. err) + print("Unable to load tool file " .. v .. ": " .. err) end end TOOL = nil @@ -990,10 +990,6 @@ function NazaraBuild:RegisterTool(toolTable) return false, "This tool name is already in use" end - if (toolTable.TargetDirectory == nil or type(toolTable.TargetDirectory) ~= "string" or string.len(toolTable.TargetDirectory) == 0) then - return false, "Invalid tool directory" - end - if (toolTable.Kind == nil or type(toolTable.Kind) ~= "string" or string.len(toolTable.Kind) == 0) then return false, "Invalid tool type" end @@ -1005,6 +1001,10 @@ function NazaraBuild:RegisterTool(toolTable) return false, "Invalid tool type" end + if (lowerCaseKind ~= "plugin" and (toolTable.TargetDirectory == nil or type(toolTable.TargetDirectory) ~= "string" or string.len(toolTable.TargetDirectory) == 0)) then + return false, "Invalid tool directory" + end + toolTable.Type = "Tool" self.Tools[lowerCaseName] = toolTable return true From 5d308d7812417d2dd3bd2200e0da0038f5842672 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Aug 2016 13:11:52 +0200 Subject: [PATCH 222/383] Build: Fix an oopsie Former-commit-id: f0f30058efb92e7a24d66f480bb65a945880ad68 [formerly e591e16a60ba1768e5a057ca42fe5b86ea68c64f] [formerly 8cda2a08263f38358814c22387afe94436976fd4 [formerly fb3768694da2c6d4311a73c5583293b2b26bf8f3]] Former-commit-id: 20cb578d12161750f9bd790f75c94de6b3ee5853 [formerly 78f6f9c6108bad01926e88b94bc27331190493be] Former-commit-id: af429ed967d8753ba3c0a041c393d1eaf6da3dd7 --- build/scripts/common.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index b8ca27e70..b20d213fa 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -278,6 +278,7 @@ function NazaraBuild:Execute() self:MakeInstallCommands(toolTable) elseif (toolTable.Kind == "application") then debugdir(toolTable.TargetDirectory) + targetdir(toolTable.TargetDirectory) if (toolTable.EnableConsole) then kind("ConsoleApp") else @@ -295,8 +296,6 @@ function NazaraBuild:Execute() libdirs("../lib") libdirs("../extlibs/lib/common") - targetdir(toolTable.TargetDirectory) - configuration("x32") libdirs(toolTable.LibraryPaths.x86) @@ -306,7 +305,7 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x32"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x86") - libdirs(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") + libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x86") elseif (toolTable.Kind == "plugin") then @@ -315,6 +314,7 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") + libdirs("../lib/" .. makeLibDir .. "/x86") if (toolTable.Kind == "library") then targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64") elseif (toolTable.Kind == "plugin") then From 576c7c3f5d72a187499b7443885653983b069df0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 19 Aug 2016 01:49:36 +0200 Subject: [PATCH 223/383] Fixed linking of tools on GCC 64bits Former-commit-id: e47425b9ff79fc0cb3342594422bb5e20cbc4250 [formerly 373a7d7f61de3a74cd4302389b94e78ccd47ed8d] [formerly cc40ac8e81efa2207d533729cf117b786922b92f [formerly 9fe0392a9506a796791b3a21c54236ad638bd6fc]] Former-commit-id: 18791f6f0c493e6cd28be214431f7e18a39e8741 [formerly 49f8a79996b9fc6698d091472c5347dd0c8d0081] Former-commit-id: 45316bf33503cd2fd1d0bbdbffe21dff6d22f565 --- build/scripts/common.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index b20d213fa..cf6fa6560 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -314,7 +314,7 @@ function NazaraBuild:Execute() configuration({"codeblocks or codelite or gmake", "x64"}) libdirs("../extlibs/lib/" .. makeLibDir .. "/x64") - libdirs("../lib/" .. makeLibDir .. "/x86") + libdirs("../lib/" .. makeLibDir .. "/x64") if (toolTable.Kind == "library") then targetdir(toolTable.TargetDirectory .. "/" .. makeLibDir .. "/x64") elseif (toolTable.Kind == "plugin") then @@ -1084,4 +1084,4 @@ function NazaraBuild:SetupModuleTable(infoTable) table.insert(infoTable.LibraryPaths.x64, "../extlibs/lib/common/x64") end -NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable \ No newline at end of file +NazaraBuild.SetupToolTable = NazaraBuild.SetupInfoTable From 40763370b9473c356b72e1974fa4eb4df2ccbc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 20 Aug 2016 17:12:20 +0200 Subject: [PATCH 224/383] Example/HardwareInfo: Fix generated file Former-commit-id: 52bf3fe6fae3381602479acc4c3eff893ce1bd2f [formerly 6ee9d195ce38bf504de0c9b56be4efe0878c2fa4] [formerly c5b7e5223a061866b3dbaa5ba90a4f22b8af66dd [formerly a8ebb981b3161b7610b1f62dbeaace151cc92d54]] Former-commit-id: 8a13ef79c41673716f8ddce6b9085f69e38ee429 [formerly a6b9c3201bc80717308147b42b082b5a4d0260cf] Former-commit-id: 8f4ca3784b3ce027eea7a6b69e2418aef02824ee --- .gitignore | 3 +++ examples/HardwareInfo/main.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 463291bc4..6266c2b6b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ tests/*.dll tests/*.so lib/* +# Example generated files +examples/bin/HardwareInfo.txt + # Feature page build/scripts/features/index.html diff --git a/examples/HardwareInfo/main.cpp b/examples/HardwareInfo/main.cpp index 401224315..820f42a62 100644 --- a/examples/HardwareInfo/main.cpp +++ b/examples/HardwareInfo/main.cpp @@ -94,7 +94,7 @@ int main() std::cout << oss.str() << std::endl; - Nz::File reportFile("RapportNz::HardwareInfo.txt"); + Nz::File reportFile("HardwareInfo.txt"); if (reportFile.Open(Nz::OpenMode_Text | Nz::OpenMode_Truncate | Nz::OpenMode_WriteOnly)) { reportFile.Write(oss.str()); // Conversion implicite en Nz::String From 5023e0f105a41f4e0da34093ad6032556fb89760 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 21 Aug 2016 13:47:43 +0200 Subject: [PATCH 225/383] Fix memory leak Former-commit-id: f76e17e36834c1b9af93f973ae87f7000b71df35 [formerly ceae57bf8bdbc37a273fe38c2a2a24133c87545e] [formerly 15212571531d85f97fe94173a6fafd08d565f66a [formerly 882de2c616328d69b82032c0c8ddc1aa2337d5be]] Former-commit-id: a2cc366f2802e3cdcbe5d3f09d9861375f693ec9 [formerly 58c365b7bd04a65069e777d43b584176d5ab167d] Former-commit-id: 611c679fbfd831ad8e1e4c3d97e23d87eacd5fb8 --- include/Nazara/Graphics/MaterialPipeline.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl index ce937883d..0cbea4e61 100644 --- a/include/Nazara/Graphics/MaterialPipeline.inl +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -97,6 +97,7 @@ namespace Nz MaterialPipelineRef MaterialPipeline::New(Args&&... args) { std::unique_ptr object(new MaterialPipeline(std::forward(args)...)); + object->SetPersistent(false); return object.release(); } } From 9eba331f347af8cf6c6f022b2998dbdf96a04a32 Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 21 Aug 2016 13:48:52 +0200 Subject: [PATCH 227/383] Documentation for module 'NDK' Former-commit-id: 63e1cac538c577a1f1aafa71fa7eef69a6d4daab [formerly b2d8769fd02a0e7d9c476d4ad7be1988a1fd6789] [formerly 636b5cb79bcb8da44d9aa45ba1023565bcf29f0d [formerly a2361ec2b8679d4d4ba096e543b5d4b91825dd62]] Former-commit-id: d402d35477f9db0135c553d55c401939426bf62d [formerly 607336ea0f42731e4604f3a8c2df06f3aecfc401] Former-commit-id: 69e23cd6c06723486de5e4641ce810012dac66da --- SDK/include/NDK/Algorithm.inl | 50 +- SDK/include/NDK/Application.inl | 48 +- SDK/include/NDK/BaseComponent.hpp | 2 +- SDK/include/NDK/BaseComponent.inl | 47 +- SDK/include/NDK/BaseSystem.hpp | 2 +- SDK/include/NDK/BaseSystem.inl | 153 +++++- SDK/include/NDK/Component.hpp | 2 +- SDK/include/NDK/Component.inl | 35 +- .../NDK/Components/CameraComponent.inl | 174 ++++++- .../NDK/Components/CollisionComponent.inl | 29 ++ .../NDK/Components/GraphicsComponent.inl | 67 +++ SDK/include/NDK/Components/LightComponent.inl | 4 + .../NDK/Components/ListenerComponent.inl | 15 + SDK/include/NDK/Components/NodeComponent.inl | 9 + .../Components/ParticleEmitterComponent.inl | 21 + .../NDK/Components/ParticleGroupComponent.inl | 39 ++ .../NDK/Components/PhysicsComponent.inl | 187 +++++++- .../NDK/Components/VelocityComponent.inl | 19 + SDK/include/NDK/Console.inl | 40 ++ SDK/include/NDK/Entity.inl | 173 ++++++- SDK/include/NDK/EntityList.inl | 42 +- SDK/include/NDK/EntityOwner.inl | 36 ++ SDK/include/NDK/LuaAPI.inl | 443 +++++++++++++++++- SDK/include/NDK/LuaBinding.inl | 28 ++ SDK/include/NDK/Prerequesites.hpp | 6 +- SDK/include/NDK/Sdk.inl | 5 + SDK/include/NDK/StateMachine.inl | 38 ++ SDK/include/NDK/System.hpp | 4 +- SDK/include/NDK/System.inl | 29 +- SDK/include/NDK/Systems/PhysicsSystem.inl | 10 + SDK/include/NDK/Systems/RenderSystem.inl | 77 +++ SDK/include/NDK/World.hpp | 1 - SDK/include/NDK/World.inl | 136 +++++- SDK/src/NDK/Application.cpp | 10 + SDK/src/NDK/BaseComponent.cpp | 28 ++ SDK/src/NDK/BaseSystem.cpp | 44 +- SDK/src/NDK/Components/CameraComponent.cpp | 88 ++++ SDK/src/NDK/Components/CollisionComponent.cpp | 43 +- SDK/src/NDK/Components/GraphicsComponent.cpp | 54 ++- .../Components/ParticleEmitterComponent.cpp | 13 + SDK/src/NDK/Components/PhysicsComponent.cpp | 32 ++ SDK/src/NDK/Console.cpp | 88 ++++ SDK/src/NDK/Entity.cpp | 80 +++- SDK/src/NDK/LuaAPI.cpp | 21 + SDK/src/NDK/LuaBinding.cpp | 16 + SDK/src/NDK/LuaBinding_Audio.cpp | 10 + SDK/src/NDK/LuaBinding_Core.cpp | 10 + SDK/src/NDK/LuaBinding_Graphics.cpp | 10 + SDK/src/NDK/LuaBinding_Math.cpp | 10 + SDK/src/NDK/LuaBinding_Network.cpp | 10 + SDK/src/NDK/LuaBinding_Renderer.cpp | 10 + SDK/src/NDK/LuaBinding_SDK.cpp | 18 + SDK/src/NDK/LuaBinding_Utility.cpp | 10 + SDK/src/NDK/Sdk.cpp | 19 + SDK/src/NDK/State.cpp | 6 + SDK/src/NDK/Systems/ListenerSystem.cpp | 26 +- SDK/src/NDK/Systems/ParticleSystem.cpp | 18 + SDK/src/NDK/Systems/PhysicsSystem.cpp | 40 +- SDK/src/NDK/Systems/RenderSystem.cpp | 44 ++ SDK/src/NDK/Systems/VelocitySystem.cpp | 19 + SDK/src/NDK/World.cpp | 95 +++- build/scripts/tools/unittests.lua | 13 +- tests/SDK/NDK/Application.cpp | 22 + tests/SDK/NDK/BaseSystem.cpp | 64 +++ tests/SDK/NDK/Component.cpp | 31 ++ tests/SDK/NDK/Entity.cpp | 101 ++++ tests/SDK/NDK/EntityList.cpp | 41 ++ tests/SDK/NDK/EntityOwner.cpp | 29 ++ tests/SDK/NDK/StateMachine.cpp | 48 ++ tests/SDK/NDK/System.cpp | 42 ++ tests/SDK/NDK/Systems/ListenerSystem.cpp | 43 ++ tests/SDK/NDK/Systems/PhysicsSystem.cpp | 34 ++ tests/SDK/NDK/Systems/RenderSystem.cpp | 44 ++ tests/SDK/NDK/Systems/VelocitySystem.cpp | 28 ++ tests/SDK/NDK/World.cpp | 103 ++++ 75 files changed, 3374 insertions(+), 112 deletions(-) create mode 100644 tests/SDK/NDK/Application.cpp create mode 100644 tests/SDK/NDK/BaseSystem.cpp create mode 100644 tests/SDK/NDK/Component.cpp create mode 100644 tests/SDK/NDK/Entity.cpp create mode 100644 tests/SDK/NDK/EntityList.cpp create mode 100644 tests/SDK/NDK/EntityOwner.cpp create mode 100644 tests/SDK/NDK/StateMachine.cpp create mode 100644 tests/SDK/NDK/System.cpp create mode 100644 tests/SDK/NDK/Systems/ListenerSystem.cpp create mode 100644 tests/SDK/NDK/Systems/PhysicsSystem.cpp create mode 100644 tests/SDK/NDK/Systems/RenderSystem.cpp create mode 100644 tests/SDK/NDK/Systems/VelocitySystem.cpp create mode 100644 tests/SDK/NDK/World.cpp diff --git a/SDK/include/NDK/Algorithm.inl b/SDK/include/NDK/Algorithm.inl index dd5f49cd4..fbdad365b 100644 --- a/SDK/include/NDK/Algorithm.inl +++ b/SDK/include/NDK/Algorithm.inl @@ -6,7 +6,15 @@ namespace Ndk { - ///TODO: constexpr avec le C++14 + /*! + * \ingroup NDK + * \brief Builds a component id based on a name + * \return Identifier for the component + * + * \param name Name to generate id from + */ + + ///TODO: constexpr with the C++14 template ComponentId BuildComponentId(const char (&name)[N]) { @@ -19,18 +27,38 @@ namespace Ndk return componentId; } + /*! + * \ingroup NDK + * \brief Gets the component id of a component + * \return Identifier for the component + */ + template ComponentIndex GetComponentIndex() { return ComponentType::componentIndex; } + /*! + * \ingroup NDK + * \brief Gets the system id of a system + * \return Identifier for the system + */ + template SystemIndex GetSystemIndex() { return SystemType::systemIndex; } + /*! + * \ingroup NDK + * \brief Initializes the a component + * \return Identifier for the component + * + * \param name Name to generate id from + */ + template ComponentIndex InitializeComponent(const char (&name)[N]) { @@ -38,6 +66,12 @@ namespace Ndk return ComponentType::componentIndex; } + /*! + * \ingroup NDK + * \brief Initializes the a system + * \return Identifier for the system + */ + template SystemIndex InitializeSystem() { @@ -45,12 +79,26 @@ namespace Ndk return SystemType::systemIndex; } + /*! + * \brief Checks whether the parameter is a component + * \return true If it is the case + * + * \param component Component to check + */ + template bool IsComponent(C& component) { return component.GetIndex() == GetComponentIndex(); } + /*! + * \brief Checks whether the parameter is a system + * \return true If it is the case + * + * \param system System to check + */ + template bool IsSystem(S& system) { diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 96e8768ce..0d21d1b94 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -8,6 +8,12 @@ namespace Ndk { + /*! + * \brief Constructs an Application object by default + * + * \remark Produces a NazaraAssert if there's more than one application instance currently running + */ + inline Application::Application() : #ifndef NDK_SERVER m_exitOnClosedWindows(true), @@ -24,6 +30,10 @@ namespace Ndk Sdk::Initialize(); } + /*! + * \brief Destructs the object + */ + inline Application::~Application() { m_worlds.clear(); @@ -31,13 +41,20 @@ namespace Ndk m_windows.clear(); #endif - // Libération du SDK + // Free of SDK Sdk::Uninitialize(); - // Libération automatique des modules + // Automatic free of modules s_application = nullptr; } + /*! + * \brief Adds a window to the application + * \return A reference to the newly created windows + * + * \param args Arguments used to create the window + */ + #ifndef NDK_SERVER template T& Application::AddWindow(Args&&... args) @@ -49,6 +66,13 @@ namespace Ndk } #endif + /*! + * \brief Adds a world to the application + * \return A reference to the newly created world + * + * \param args Arguments used to create the world + */ + template World& Application::AddWorld(Args&&... args) { @@ -56,11 +80,22 @@ namespace Ndk return m_worlds.back(); } + /*! + * \brief Gets the update time of the application + * \return Update rate + */ + inline float Application::GetUpdateTime() const { return m_updateTime; } + /*! + * \brief Makes the application exit when there's no more open window + * + * \param exitOnClosedWindows Should exit be called when no more window is open + */ + #ifndef NDK_SERVER inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows) { @@ -68,11 +103,20 @@ namespace Ndk } #endif + /*! + * \brief Quits the application + */ + inline void Application::Quit() { m_shouldQuit = true; } + /*! + * \brief Gets the singleton instance of the application + * \return Singleton application + */ + inline Application* Application::Instance() { return s_application; diff --git a/SDK/include/NDK/BaseComponent.hpp b/SDK/include/NDK/BaseComponent.hpp index f045ae2a6..0a48c394d 100644 --- a/SDK/include/NDK/BaseComponent.hpp +++ b/SDK/include/NDK/BaseComponent.hpp @@ -27,7 +27,7 @@ namespace Ndk BaseComponent(BaseComponent&&) = default; virtual ~BaseComponent(); - virtual BaseComponent* Clone() const = 0; + virtual std::unique_ptr Clone() const = 0; ComponentIndex GetIndex() const; diff --git a/SDK/include/NDK/BaseComponent.inl b/SDK/include/NDK/BaseComponent.inl index 341ddb651..0e8af931f 100644 --- a/SDK/include/NDK/BaseComponent.inl +++ b/SDK/include/NDK/BaseComponent.inl @@ -7,34 +7,60 @@ namespace Ndk { + /*! + * \brief Constructs a BaseComponent object with an index + * + * \param index Index of the component + */ + inline BaseComponent::BaseComponent(ComponentIndex index) : m_componentIndex(index), m_entity(nullptr) { } + /*! + * \brief Gets the index of the component + * \return Index of the component + */ + inline ComponentIndex BaseComponent::GetIndex() const { return m_componentIndex; } + /*! + * \brief Gets the maximal index of the components + * \return Index of the maximal component + */ + inline ComponentIndex BaseComponent::GetMaxComponentIndex() { return static_cast(s_entries.size()); } + /*! + * \brief Registers a component + * \return Index of the registered component + * + * \param id Index of the component + * \param factory Factory to create the component + * + * \remark Produces a NazaraAssert if the identifier is already in use + */ + inline ComponentIndex BaseComponent::RegisterComponent(ComponentId id, Factory factoryFunc) { - // Nous allons rajouter notre composant à la fin + // We add our component to the end ComponentIndex index = static_cast(s_entries.size()); s_entries.resize(index + 1); - // On récupère et on affecte + // We retrieve it and affect it ComponentEntry& entry = s_entries.back(); entry.factory = factoryFunc; entry.id = id; - // Une petite assertion pour s'assurer que l'identifiant n'est pas déjà utilisé + // We ensure that id is not already in use NazaraAssert(s_idToIndex.find(id) == s_idToIndex.end(), "This id is already in use"); s_idToIndex[id] = index; @@ -42,6 +68,10 @@ namespace Ndk return index; } + /*! + * \brief Sets the entity on which the component operates + */ + inline void BaseComponent::SetEntity(Entity* entity) { if (m_entity != entity) @@ -55,12 +85,21 @@ namespace Ndk } } + /*! + * \brief Initializes the BaseComponent + * \return true + */ + inline bool BaseComponent::Initialize() { - // Rien à faire + // Nothing to do return true; } + /*! + * \brief Uninitializes the BaseComponent + */ + inline void BaseComponent::Uninitialize() { s_entries.clear(); diff --git a/SDK/include/NDK/BaseSystem.hpp b/SDK/include/NDK/BaseSystem.hpp index 969f2b773..a4ff0bf41 100644 --- a/SDK/include/NDK/BaseSystem.hpp +++ b/SDK/include/NDK/BaseSystem.hpp @@ -29,7 +29,7 @@ namespace Ndk inline void Enable(bool enable = true); - virtual BaseSystem* Clone() const = 0; + virtual std::unique_ptr Clone() const = 0; bool Filters(const Entity* entity) const; diff --git a/SDK/include/NDK/BaseSystem.inl b/SDK/include/NDK/BaseSystem.inl index 490b32e76..1afc242c0 100644 --- a/SDK/include/NDK/BaseSystem.inl +++ b/SDK/include/NDK/BaseSystem.inl @@ -8,6 +8,12 @@ namespace Ndk { + /*! + * \brief Constructs a BaseSystem object with an index + * + * \param systemId Index of the system + */ + inline BaseSystem::BaseSystem(SystemIndex systemId) : m_updateEnabled(true), m_systemIndex(systemId) @@ -15,6 +21,12 @@ namespace Ndk SetUpdateRate(30); } + /*! + * \brief Constructs a BaseSystem object by copy semantic + * + * \param system System to copy + */ + inline BaseSystem::BaseSystem(const BaseSystem& system) : m_excludedComponents(system.m_excludedComponents), m_requiredComponents(system.m_requiredComponents), @@ -25,36 +37,74 @@ namespace Ndk { } + /*! + * \brief Enables the system + * + * \param enable Should the system be enabled + */ + inline void BaseSystem::Enable(bool enable) { m_updateEnabled = enable; } + /*! + * \brief Gets every entities that system handle + * \return A constant reference to the list of entities + */ + inline const std::vector& BaseSystem::GetEntities() const { return m_entities; } + /*! + * \brief Gets the index of the system + * \return Index of the system + */ + inline SystemIndex BaseSystem::GetIndex() const { return m_systemIndex; } + /*! + * \brief Gets the rate of update for the system + * \return Update rate + */ + inline float BaseSystem::GetUpdateRate() const { return (m_updateRate > 0.f) ? 1.f / m_updateRate : 0.f; } + /*! + * \brief Gets the world on which the system operate + * \return World in which the system is + */ + inline World& BaseSystem::GetWorld() const { return *m_world; } + /*! + * \brief Checks whether or not the system is enabled + * \return true If it is the case + */ + inline bool BaseSystem::IsEnabled() const { return m_updateEnabled; } + /*! + * \brief Checks whether or not the system has the entity + * \return true If it is the case + * + * \param entity Pointer to the entity + */ + inline bool BaseSystem::HasEntity(const Entity* entity) const { if (!entity) @@ -63,12 +113,24 @@ namespace Ndk return m_entityBits.UnboundedTest(entity->GetId()); } + /*! + * \brief Sets the rate of update for the system + * + * \param updatePerSecond Update rate, 0 means as much as possible + */ + inline void BaseSystem::SetUpdateRate(float updatePerSecond) { m_updateCounter = 0.f; m_updateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit } + /*! + * \brief Updates the system + * + * \param elapsedTime Delta time used for the update + */ + inline void BaseSystem::Update(float elapsedTime) { if (!IsEnabled()) @@ -88,6 +150,10 @@ namespace Ndk OnUpdate(elapsedTime); } + /*! + * \brief Excludes some component from the system + */ + template void BaseSystem::Excludes() { @@ -96,6 +162,10 @@ namespace Ndk ExcludesComponent(GetComponentIndex()); } + /*! + * \brief Excludes some components from the system + */ + template void BaseSystem::Excludes() { @@ -103,16 +173,31 @@ namespace Ndk Excludes(); } + /*! + * \brief Excludes some component from the system by index + * + * \param index Index of the component + */ + inline void BaseSystem::ExcludesComponent(ComponentIndex index) { m_excludedComponents.UnboundedSet(index); } + /*! + * \brief Gets the next index for the system + * \return Next unique index for the system + */ + inline SystemIndex BaseSystem::GetNextIndex() { return s_nextIndex++; } + /*! + * \brief Requires some component from the system + */ + template void BaseSystem::Requires() { @@ -121,6 +206,10 @@ namespace Ndk RequiresComponent(GetComponentIndex()); } + /*! + * \brief Requires some components from the system + */ + template void BaseSystem::Requires() { @@ -128,11 +217,21 @@ namespace Ndk Requires(); } + /*! + * \brief Requires some component for the system by index + * + * \param index Index of the component + */ + inline void BaseSystem::RequiresComponent(ComponentIndex index) { m_requiredComponents.UnboundedSet(index); } + /*! + * \brief Requires any component from the system + */ + template void BaseSystem::RequiresAny() { @@ -141,6 +240,10 @@ namespace Ndk RequiresAnyComponent(GetComponentIndex()); } + /*! + * \brief Requires any components from the system + */ + template void BaseSystem::RequiresAny() { @@ -148,11 +251,25 @@ namespace Ndk RequiresAny(); } + /*! + * \brief Requires any component for the system by index + * + * \param index Index of the component + */ + inline void BaseSystem::RequiresAnyComponent(ComponentIndex index) { m_requiredAnyComponents.UnboundedSet(index); } + /*! + * \brief Adds an entity to a system + * + * \param entity Pointer to the entity + * + * \remark Produces a NazaraAssert if entity is invalid + */ + inline void BaseSystem::AddEntity(Entity* entity) { NazaraAssert(entity, "Invalid entity"); @@ -165,6 +282,14 @@ namespace Ndk OnEntityAdded(entity); } + /*! + * \brief Removes an entity to a system + * + * \param entity Pointer to the entity + * + * \remark Produces a NazaraAssert if entity is invalid + */ + inline void BaseSystem::RemoveEntity(Entity* entity) { NazaraAssert(entity, "Invalid entity"); @@ -172,16 +297,25 @@ namespace Ndk auto it = std::find(m_entities.begin(), m_entities.end(), *entity); NazaraAssert(it != m_entities.end(), "Entity is not part of this system"); - // Pour éviter de déplacer beaucoup de handles, on swap le dernier avec celui à supprimer + // To avoid moving a lot of handles, we swap and pop std::swap(*it, m_entities.back()); - m_entities.pop_back(); // On le sort du vector + m_entities.pop_back(); // We get it out of the vector m_entityBits.Reset(entity->GetId()); entity->UnregisterSystem(m_systemIndex); - OnEntityRemoved(entity); // Et on appelle le callback + OnEntityRemoved(entity); // And we alert our callback } + /*! + * \brief Validates an entity to a system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + * + * \remark Produces a NazaraAssert if entity is invalid or if system does not hold this entity + */ + inline void BaseSystem::ValidateEntity(Entity* entity, bool justAdded) { NazaraAssert(entity, "Invalid entity"); @@ -190,11 +324,20 @@ namespace Ndk OnEntityValidation(entity, justAdded); } + /*! + * \brief Sets the world on which the system operates + */ + inline void BaseSystem::SetWorld(World* world) noexcept { m_world = world; } + /*! + * \brief Initializes the BaseSystem + * \return true + */ + inline bool BaseSystem::Initialize() { s_nextIndex = 0; @@ -202,6 +345,10 @@ namespace Ndk return true; } + /*! + * \brief Uninitializes the BaseSystem + */ + inline void BaseSystem::Uninitialize() { // Nothing to do diff --git a/SDK/include/NDK/Component.hpp b/SDK/include/NDK/Component.hpp index e3026dbad..b0f61fd92 100644 --- a/SDK/include/NDK/Component.hpp +++ b/SDK/include/NDK/Component.hpp @@ -18,7 +18,7 @@ namespace Ndk Component(); virtual ~Component(); - BaseComponent* Clone() const override; + std::unique_ptr Clone() const override; static ComponentIndex RegisterComponent(ComponentId id); diff --git a/SDK/include/NDK/Component.inl b/SDK/include/NDK/Component.inl index 833395957..6ca3f1944 100644 --- a/SDK/include/NDK/Component.inl +++ b/SDK/include/NDK/Component.inl @@ -7,6 +7,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Component + * \brief NDK class that represents a component for an entity which interacts with a system + * + * \remark This class is meant to be derived as CRTP: "Component" + */ + + /*! + * \brief Constructs a Component object by default + */ + template Component::Component() : BaseComponent(GetComponentIndex()) @@ -16,19 +28,30 @@ namespace Ndk template Component::~Component() = default; + /*! + * \brief Clones the component + * \return The clone newly created + * + * \remark The component to clone should be trivially copy constructible + */ + template - BaseComponent* Component::Clone() const + std::unique_ptr Component::Clone() const { ///FIXME: Pas encore supporté par GCC (4.9.2) //static_assert(std::is_trivially_copy_constructible::value, "ComponentType must be copy-constructible"); - return new ComponentType(static_cast(*this)); + return std::make_unique(static_cast(*this)); } + /*! + * \brief Registers the component by assigning it an index + */ + template ComponentIndex Component::RegisterComponent(ComponentId id) { - // On utilise les lambda pour créer une fonction factory + //We use the lambda to create a factory function auto factory = []() -> BaseComponent* { return nullptr; //< Temporary workaround to allow non-default-constructed components, will be updated for serialization @@ -38,11 +61,15 @@ namespace Ndk return BaseComponent::RegisterComponent(id, factory); } + /*! + * \brief Registers the component by assigning it an index based on the name + */ + template template ComponentIndex Component::RegisterComponent(const char (&name)[N]) { - // On récupère la chaîne de caractère sous la forme d'un nombre qui servira d'identifiant unique + // We convert the string to a number which will be used as unique identifier ComponentId id = BuildComponentId(name); return RegisterComponent(id); } diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index d91c357eb..d42d0e152 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -8,6 +8,10 @@ namespace Ndk { + /*! + * \brief Constructs an CameraComponent object by default + */ + inline CameraComponent::CameraComponent() : m_projectionType(Nz::ProjectionType_Perspective), m_targetRegion(0.f, 0.f, 1.f, 1.f), @@ -25,6 +29,12 @@ namespace Ndk { } + /*! + * \brief Constructs a CameraComponent object by copy semantic + * + * \param camera CameraComponent to copy + */ + inline CameraComponent::CameraComponent(const CameraComponent& camera) : Component(camera), AbstractViewer(camera), @@ -45,30 +55,51 @@ namespace Ndk SetTarget(camera.m_target); } + /*! + * \brief Ensures the frustum is up to date + */ + inline void CameraComponent::EnsureFrustumUpdate() const { if (!m_frustumUpdated) UpdateFrustum(); } + /*! + * \brief Ensures the projection matrix is up to date + */ + inline void CameraComponent::EnsureProjectionMatrixUpdate() const { if (!m_projectionMatrixUpdated) UpdateProjectionMatrix(); } + /*! + * \brief Ensures the view matrix is up to date + */ + inline void CameraComponent::EnsureViewMatrixUpdate() const { if (!m_viewMatrixUpdated) UpdateViewMatrix(); } + /*! + * \brief Ensures the view port is up to date + */ + inline void CameraComponent::EnsureViewportUpdate() const { if (!m_viewportUpdated) UpdateViewport(); } + /*! + * \brief Gets the aspect ratio of the camera + * \return Aspect ratio of the camera + */ + inline float CameraComponent::GetAspectRatio() const { EnsureViewportUpdate(); @@ -76,11 +107,21 @@ namespace Ndk return m_aspectRatio; } + /*! + * \brief Gets the field of view of the camera + * \return Field of view of the camera + */ + inline float CameraComponent::GetFOV() const { return m_fov; } + /*! + * \brief Gets the frutum of the camera + * \return A constant reference to the frustum of the camera + */ + inline const Nz::Frustumf& CameraComponent::GetFrustum() const { EnsureFrustumUpdate(); @@ -88,11 +129,21 @@ namespace Ndk return m_frustum; } + /*! + * \brief Gets the layer of the camera + * \return Layer of the camera + */ + inline unsigned int CameraComponent::GetLayer() const { return m_layer; } + /*! + * \brief Gets the projection matrix of the camera + * \return A constant reference to the projection matrix of the camera + */ + inline const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const { EnsureProjectionMatrixUpdate(); @@ -100,26 +151,51 @@ namespace Ndk return m_projectionMatrix; } + /*! + * \brief Gets the projection type of the camera + * \return Projection type of the camera + */ + inline Nz::ProjectionType CameraComponent::GetProjectionType() const { return m_projectionType; } + /*! + * \brief Gets the size of the camera + * \return Size of the camera + */ + inline const Nz::Vector2f & CameraComponent::GetSize() const { return m_size; } + /*! + * \brief Gets the target of the camera + * \return A constant reference to the render target of the camera + */ + inline const Nz::RenderTarget* CameraComponent::GetTarget() const { return m_target; } + /*! + * \brief Gets the target region of the camera + * \return A constant reference to the target region of the camera + */ + inline const Nz::Rectf& CameraComponent::GetTargetRegion() const { return m_targetRegion; } + /*! + * \brief Gets the view matrix of the camera + * \return A constant reference to the view matrix of the camera + */ + inline const Nz::Matrix4f& CameraComponent::GetViewMatrix() const { EnsureViewMatrixUpdate(); @@ -127,6 +203,11 @@ namespace Ndk return m_viewMatrix; } + /*! + * \brief Gets the view port of the camera + * \return A constant reference to the view port of the camera + */ + inline const Nz::Recti& CameraComponent::GetViewport() const { EnsureViewportUpdate(); @@ -134,16 +215,34 @@ namespace Ndk return m_viewport; } + /*! + * \brief Gets the Z far distance of the camera + * \return Z far distance of the camera + */ + inline float CameraComponent::GetZFar() const { return m_zFar; } + /*! + * \brief Gets the Z near distance of the camera + * \return Z near distance of the camera + */ + inline float CameraComponent::GetZNear() const { return m_zNear; } + /*! + * \brief Sets the field of view of the camera + * + * \param fov Field of view of the camera + * + * \remark Produces a NazaraAssert if angle is zero + */ + inline void CameraComponent::SetFOV(float fov) { NazaraAssert(!Nz::NumberEquals(fov, 0.f), "FOV must be different from zero"); @@ -152,6 +251,12 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the projection type of the camera + * + * \param projectionType Projection type of the camera + */ + inline void CameraComponent::SetProjectionType(Nz::ProjectionType projectionType) { m_projectionType = projectionType; @@ -159,6 +264,12 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the size of the camera + * + * \param size Size of the camera + */ + inline void CameraComponent::SetSize(const Nz::Vector2f& size) { m_size = size; @@ -166,11 +277,24 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the size of the camera + * + * \param width Size in X of the camera + * \param height Size in Y of the camera + */ + inline void CameraComponent::SetSize(float width, float height) { SetSize({width, height}); } + /*! + * \brief Sets the target of the camera + * + * \param renderTarget A constant reference to the render target of the camera + */ + inline void CameraComponent::SetTarget(const Nz::RenderTarget* renderTarget) { m_target = renderTarget; @@ -186,6 +310,12 @@ namespace Ndk } } + /*! + * \brief Sets the target region of the camera + * + * \param region A constant reference to the target region of the camera + */ + inline void CameraComponent::SetTargetRegion(const Nz::Rectf& region) { m_targetRegion = region; @@ -193,17 +323,31 @@ namespace Ndk InvalidateViewport(); } + /*! + * \brief Sets the view port of the camera + * + * \param viewport A constant reference to the view port of the camera + * + * \remark Produces a NazaraAssert if the camera has no target + */ + inline void CameraComponent::SetViewport(const Nz::Recti& viewport) { NazaraAssert(m_target, "Component has no render target"); - // On calcule la région nécessaire pour produire ce viewport avec la taille actuelle de la cible - float invWidth = 1.f/m_target->GetWidth(); - float invHeight = 1.f/m_target->GetHeight(); + // We compute the region necessary to make this view port with the actual size of the target + float invWidth = 1.f / m_target->GetWidth(); + float invHeight = 1.f / m_target->GetHeight(); SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height)); } + /*! + * \brief Sets the Z far distance of the camera + * + * \param zFar Z far distance of the camera + */ + inline void CameraComponent::SetZFar(float zFar) { m_zFar = zFar; @@ -211,6 +355,14 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Sets the Z near distance of the camera + * + * \param zNear Z near distance of the camera + * + * \remark Produces a NazaraAssert if zNear is zero + */ + inline void CameraComponent::SetZNear(float zNear) { NazaraAssert(!Nz::NumberEquals(zNear, 0.f), "zNear cannot be zero"); @@ -219,23 +371,39 @@ namespace Ndk InvalidateProjectionMatrix(); } + /*! + * \brief Invalidates the frustum + */ + inline void CameraComponent::InvalidateFrustum() const { m_frustumUpdated = false; } + /*! + * \brief Invalidates the projection matrix + */ + inline void CameraComponent::InvalidateProjectionMatrix() const { m_frustumUpdated = false; m_projectionMatrixUpdated = false; } + /*! + * \brief Invalidates the view matrix + */ + inline void CameraComponent::InvalidateViewMatrix() const { m_frustumUpdated = false; m_viewMatrixUpdated = false; } + /*! + * \brief Invalidates the view port + */ + inline void CameraComponent::InvalidateViewport() const { m_frustumUpdated = false; diff --git a/SDK/include/NDK/Components/CollisionComponent.inl b/SDK/include/NDK/Components/CollisionComponent.inl index 58356ac9e..b08e7054e 100644 --- a/SDK/include/NDK/Components/CollisionComponent.inl +++ b/SDK/include/NDK/Components/CollisionComponent.inl @@ -9,23 +9,47 @@ namespace Ndk { + /*! + * \brief Constructs a CollisionComponent object with a geometry + * + * \param geom Reference to a geometry symbolizing the entity + */ + inline CollisionComponent::CollisionComponent(Nz::PhysGeomRef geom) : m_geom(std::move(geom)), m_bodyUpdated(false) { } + /*! + * \brief Constructs a CollisionComponent object by copy semantic + * + * \param collision CollisionComponent to copy + */ + inline CollisionComponent::CollisionComponent(const CollisionComponent& collision) : m_geom(collision.m_geom), m_bodyUpdated(false) { } + /*! + * \brief Gets the geometry representing the entity + * \return A constant reference to the physics geometry + */ + inline const Nz::PhysGeomRef& CollisionComponent::GetGeom() const { return m_geom; } + /*! + * \brief Assigns the geometry to this component + * \return A reference to this + * + * \param geom Reference to a geometry symbolizing the entity + */ + inline CollisionComponent& CollisionComponent::operator=(Nz::PhysGeomRef geom) { SetGeom(geom); @@ -33,6 +57,11 @@ namespace Ndk return *this; } + /*! + * \brief Gets the static body used by the entity + * \return A pointer to the entity + */ + inline Nz::PhysObject* CollisionComponent::GetStaticBody() { return m_staticBody.get(); diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 0d9cb7af4..01cd7a2e3 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -7,6 +7,12 @@ namespace Ndk { + /*! + * \brief Constructs a GraphicsComponent object by copy semantic + * + * \param graphicsComponent GraphicsComponent to copy + */ + inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) : Component(graphicsComponent), HandledObject(graphicsComponent), @@ -20,6 +26,12 @@ namespace Ndk Attach(r.renderable, r.data.renderOrder); } + /*! + * \brief Adds the renderable elements to the render queue + * + * \param renderQueue Queue to be added + */ + inline void GraphicsComponent::AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const { EnsureTransformMatrixUpdate(); @@ -36,6 +48,13 @@ namespace Ndk } } + /*! + * \brief Attaches a renderable to the entity + * + * \param renderable Reference to a renderable element + * \param renderOrder Render order of the element + */ + inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, int renderOrder) { m_renderables.emplace_back(m_transformMatrix); @@ -48,6 +67,10 @@ namespace Ndk InvalidateBoundingVolume(); } + /*! + * \brief Clears every renderable elements + */ + inline void GraphicsComponent::Clear() { m_renderables.clear(); @@ -55,6 +78,12 @@ namespace Ndk InvalidateBoundingVolume(); } + /*! + * \brief Detaches a renderable to the entity + * + * \param renderable Reference to a renderable element + */ + inline void GraphicsComponent::Detach(const Nz::InstancedRenderable* renderable) { for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) @@ -68,18 +97,34 @@ namespace Ndk } } + /*! + * \brief Ensures the bounding volume is up to date + */ + inline void GraphicsComponent::EnsureBoundingVolumeUpdate() const { if (!m_boundingVolumeUpdated) UpdateBoundingVolume(); } + /*! + * \brief Ensures the transformation matrix is up to date + */ + inline void GraphicsComponent::EnsureTransformMatrixUpdate() const { if (!m_transformMatrixUpdated) UpdateTransformMatrix(); } + /*! + * \brief Gets the set of renderable elements + * + * \param renderables Pointer to the list of renderables + * + * \remark Produces a NazaraAssert if renderables is invalid + */ + inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const { NazaraAssert(renderables, "Invalid renderable list"); @@ -89,11 +134,21 @@ namespace Ndk renderables->push_back(r.renderable); } + /*! + * \brief Gets the number of renderable elements attached to the entity + * \return Number of renderable elements + */ + inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const { return m_renderables.size(); } + /*! + * \brief Gets the bouding volume of the entity + * \return A constant reference to the bounding volume + */ + inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const { EnsureBoundingVolumeUpdate(); @@ -101,17 +156,29 @@ namespace Ndk return m_boundingVolume; } + /*! + * \brief Invalidates the bounding volume + */ + inline void GraphicsComponent::InvalidateBoundingVolume() { m_boundingVolumeUpdated = false; } + /*! + * \brief Invalidates every renderable elements + */ + inline void GraphicsComponent::InvalidateRenderables() { for (Renderable& r : m_renderables) r.dataUpdated = false; } + /*! + * \brief Invalidates the transformation matrix + */ + inline void GraphicsComponent::InvalidateTransformMatrix() { m_boundingVolumeUpdated = false; diff --git a/SDK/include/NDK/Components/LightComponent.inl b/SDK/include/NDK/Components/LightComponent.inl index f06fcb24c..ba11703c5 100644 --- a/SDK/include/NDK/Components/LightComponent.inl +++ b/SDK/include/NDK/Components/LightComponent.inl @@ -4,6 +4,10 @@ namespace Ndk { + /*! + * \brief Constructs an LightComponent object with a light type + */ + inline LightComponent::LightComponent(Nz::LightType lightType) : Nz::Light(lightType) { diff --git a/SDK/include/NDK/Components/ListenerComponent.inl b/SDK/include/NDK/Components/ListenerComponent.inl index 7dc7b0391..f2276e439 100644 --- a/SDK/include/NDK/Components/ListenerComponent.inl +++ b/SDK/include/NDK/Components/ListenerComponent.inl @@ -4,16 +4,31 @@ namespace Ndk { + /*! + * \brief Constructs an ListenerComponent object by default + */ + inline ListenerComponent::ListenerComponent() : m_isActive(true) { } + /*! + * \brief Checks whether the listener is activated + * \param true If it is the case + */ + inline bool ListenerComponent::IsActive() const { return m_isActive; } + /*! + * \brief Enables the listener + * + * \param active Should the listener be active + */ + inline void ListenerComponent::SetActive(bool active) { m_isActive = active; diff --git a/SDK/include/NDK/Components/NodeComponent.inl b/SDK/include/NDK/Components/NodeComponent.inl index e6d49c9a9..0150cbbfa 100644 --- a/SDK/include/NDK/Components/NodeComponent.inl +++ b/SDK/include/NDK/Components/NodeComponent.inl @@ -7,6 +7,15 @@ namespace Ndk { + /*! + * \brief Sets the parent node of the entity + * + * \param entity Pointer to the entity considered as parent + * \param keepDerived Should this component considered as a derived + * + * \remark Produces a NazaraAssert if entity has no component NodeComponent + */ + inline void NodeComponent::SetParent(Entity* entity, bool keepDerived) { if (entity) diff --git a/SDK/include/NDK/Components/ParticleEmitterComponent.inl b/SDK/include/NDK/Components/ParticleEmitterComponent.inl index 342b5e56f..7f8e62cd8 100644 --- a/SDK/include/NDK/Components/ParticleEmitterComponent.inl +++ b/SDK/include/NDK/Components/ParticleEmitterComponent.inl @@ -6,21 +6,42 @@ namespace Ndk { + /*! + * \brief Constructs an ParticleEmitterComponent object by default + */ + inline ParticleEmitterComponent::ParticleEmitterComponent() : m_isActive(true) { } + /*! + * \brief Enables the emission of particles + * + * \param active Should the emitter be active + */ + inline void Ndk::ParticleEmitterComponent::Enable(bool active) { m_isActive = active; } + /*! + * \brief Checks whether the emission of particles is activated + * \param true If it is the case + */ + inline bool ParticleEmitterComponent::IsActive() const { return m_isActive; } + /*! + * \brief Sets the function use for setting up particles + * + * \param func Function to set up particles + */ + inline void Ndk::ParticleEmitterComponent::SetSetupFunc(SetupFunc func) { m_setupFunc = std::move(func); diff --git a/SDK/include/NDK/Components/ParticleGroupComponent.inl b/SDK/include/NDK/Components/ParticleGroupComponent.inl index c6e0cba7b..591e78605 100644 --- a/SDK/include/NDK/Components/ParticleGroupComponent.inl +++ b/SDK/include/NDK/Components/ParticleGroupComponent.inl @@ -8,16 +8,45 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ParticleGroupComponent + * \brief NDK class that represents the component for a group of particles + */ + + /*! + * \brief Constructs a ParticleGroupComponent object with a maximal number of particles and a layout + * + * \param maxParticleCount Maximum number of particles to generate + * \param layout Enumeration for the layout of data information for the particles + */ + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) : ParticleGroup(maxParticleCount, layout) { } + /*! + * \brief Constructs a ParticleGroupComponent object with a maximal number of particles and a particle declaration + * + * \param maxParticleCount Maximum number of particles to generate + * \param declaration Data information for the particles + */ + inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleDeclarationConstRef declaration) : ParticleGroup(maxParticleCount, std::move(declaration)) { } + /*! + * \brief Adds an emitter to the particles + * + * \param emitter Emitter for the particles + * + * \remark Produces a NazaraAssert if emitter is invalid + * \remark Produces a NazaraAssert if entity has no component of type ParticleEmitterComponent + */ + inline void ParticleGroupComponent::AddEmitter(Entity* emitter) { NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); @@ -27,6 +56,16 @@ namespace Ndk ParticleGroup::AddEmitter(&emitterComponent); } + + /*! + * \brief Removes an emitter to the particles + * + * \param emitter Emitter for the particles to remove + * + * \remark Produces a NazaraAssert if emitter is invalid + * \remark Produces a NazaraAssert if entity has no component of type ParticleEmitterComponent + */ + inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter) { NazaraAssert(emitter && emitter->IsValid(), "Invalid entity"); diff --git a/SDK/include/NDK/Components/PhysicsComponent.inl b/SDK/include/NDK/Components/PhysicsComponent.inl index f0847842d..5682603e0 100644 --- a/SDK/include/NDK/Components/PhysicsComponent.inl +++ b/SDK/include/NDK/Components/PhysicsComponent.inl @@ -6,12 +6,27 @@ namespace Ndk { + /*! + * \brief Constructs a PhysicsComponent object by copy semantic + * + * \param physics PhysicsComponent to copy + */ + inline PhysicsComponent::PhysicsComponent(const PhysicsComponent& physics) { - // Pas de copie de l'objet physique (étant donné que nous n'allons le créer qu'une fois attaché à une entité) + // No copy of physical object (because we only create it when attached to an entity) NazaraUnused(physics); } + /*! + * \brief Applies a force to the entity + * + * \param force Force to apply on the entity + * \param coordSys System coordinates to consider + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); @@ -19,6 +34,16 @@ namespace Ndk m_object->AddForce(force, coordSys); } + /*! + * \brief Applies a force to the entity + * + * \param force Force to apply on the entity + * \param point Point where to apply the force + * \param coordSys System coordinates to consider + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::AddForce(const Nz::Vector3f& force, const Nz::Vector3f& point, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); @@ -26,13 +51,30 @@ namespace Ndk m_object->AddForce(force, point, coordSys); } + /*! + * \brief Applies a torque to the entity + * + * \param torque Torque to apply on the entity + * \param coordSys System coordinates to consider + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys) { NazaraAssert(m_object, "Invalid physics object"); - m_object->AddForce(torque, coordSys); + m_object->AddTorque(torque, coordSys); } + /*! + * \brief Enables auto sleep of physics object + * + * \param autoSleep Should the physics of the object be disabled when too far from others + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::EnableAutoSleep(bool autoSleep) { NazaraAssert(m_object, "Invalid physics object"); @@ -40,6 +82,13 @@ namespace Ndk m_object->EnableAutoSleep(autoSleep); } + /*! + * \brief Gets the AABB of the physics object + * \return AABB of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline Nz::Boxf PhysicsComponent::GetAABB() const { NazaraAssert(m_object, "Invalid physics object"); @@ -47,6 +96,13 @@ namespace Ndk return m_object->GetAABB(); } + /*! + * \brief Gets the angular velocity of the physics object + * \return Angular velocity of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline Nz::Vector3f PhysicsComponent::GetAngularVelocity() const { NazaraAssert(m_object, "Invalid physics object"); @@ -54,6 +110,13 @@ namespace Ndk return m_object->GetAngularVelocity(); } + /*! + * \brief Gets the gravity factor of the physics object + * \return Gravity factor of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline float PhysicsComponent::GetGravityFactor() const { NazaraAssert(m_object, "Invalid physics object"); @@ -61,6 +124,13 @@ namespace Ndk return m_object->GetGravityFactor(); } + /*! + * \brief Gets the mass of the physics object + * \return Mass of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline float PhysicsComponent::GetMass() const { NazaraAssert(m_object, "Invalid physics object"); @@ -68,6 +138,15 @@ namespace Ndk return m_object->GetMass(); } + /*! + * \brief Gets the gravity center of the physics object + * \return Gravity center of the object + * + * \param coordSys System coordinates to consider + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline Nz::Vector3f PhysicsComponent::GetMassCenter(Nz::CoordSys coordSys) const { NazaraAssert(m_object, "Invalid physics object"); @@ -75,6 +154,13 @@ namespace Ndk return m_object->GetMassCenter(coordSys); } + /*! + * \brief Gets the matrix of the physics object + * \return Matrix of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline const Nz::Matrix4f& PhysicsComponent::GetMatrix() const { NazaraAssert(m_object, "Invalid physics object"); @@ -82,6 +168,13 @@ namespace Ndk return m_object->GetMatrix(); } + /*! + * \brief Gets the position of the physics object + * \return Position of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline Nz::Vector3f PhysicsComponent::GetPosition() const { NazaraAssert(m_object, "Invalid physics object"); @@ -89,6 +182,13 @@ namespace Ndk return m_object->GetPosition(); } + /*! + * \brief Gets the rotation of the physics object + * \return Rotation of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline Nz::Quaternionf PhysicsComponent::GetRotation() const { NazaraAssert(m_object, "Invalid physics object"); @@ -96,6 +196,13 @@ namespace Ndk return m_object->GetRotation(); } + /*! + * \brief Gets the velocity of the physics object + * \return Velocity of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline Nz::Vector3f PhysicsComponent::GetVelocity() const { NazaraAssert(m_object, "Invalid physics object"); @@ -103,6 +210,13 @@ namespace Ndk return m_object->GetVelocity(); } + /*! + * \brief Checks whether the auto sleep is enabled + * \return true If it is the case + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline bool PhysicsComponent::IsAutoSleepEnabled() const { NazaraAssert(m_object, "Invalid physics object"); @@ -110,6 +224,13 @@ namespace Ndk return m_object->IsAutoSleepEnabled(); } + /*! + * \brief Checks whether the entity is currently sleeping + * \return true If it is the case + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline bool PhysicsComponent::IsSleeping() const { NazaraAssert(m_object, "Invalid physics object"); @@ -117,6 +238,14 @@ namespace Ndk return m_object->IsSleeping(); } + /*! + * \brief Sets the angular velocity of the physics object + * + * \param angularVelocity Angular velocity of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::SetAngularVelocity(const Nz::Vector3f& angularVelocity) { NazaraAssert(m_object, "Invalid physics object"); @@ -124,6 +253,14 @@ namespace Ndk m_object->SetAngularVelocity(angularVelocity); } + /*! + * \brief Sets the gravity factor of the physics object + * + * \param gravityFactor Gravity factor of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::SetGravityFactor(float gravityFactor) { NazaraAssert(m_object, "Invalid physics object"); @@ -131,6 +268,15 @@ namespace Ndk m_object->SetGravityFactor(gravityFactor); } + /*! + * \brief Sets the mass of the physics object + * + * \param mass Mass of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + * \remark Produces a NazaraAssert if the mass is negative + */ + inline void PhysicsComponent::SetMass(float mass) { NazaraAssert(m_object, "Invalid physics object"); @@ -139,6 +285,14 @@ namespace Ndk m_object->SetMass(mass); } + /*! + * \brief Sets the gravity center of the physics object + * + * \param center Gravity center of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::SetMassCenter(const Nz::Vector3f& center) { NazaraAssert(m_object, "Invalid physics object"); @@ -146,6 +300,14 @@ namespace Ndk m_object->SetMassCenter(center); } + /*! + * \brief Sets the position of the physics object + * + * \param position Position of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::SetPosition(const Nz::Vector3f& position) { NazaraAssert(m_object, "Invalid physics object"); @@ -153,6 +315,14 @@ namespace Ndk m_object->SetPosition(position); } + /*! + * \brief Sets the rotation of the physics object + * + * \param rotation Rotation of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::SetRotation(const Nz::Quaternionf& rotation) { NazaraAssert(m_object, "Invalid physics object"); @@ -160,6 +330,14 @@ namespace Ndk m_object->SetRotation(rotation); } + /*! + * \brief Sets the velocity of the physics object + * + * \param velocity Velocity of the object + * + * \remark Produces a NazaraAssert if the physics object is invalid + */ + inline void PhysicsComponent::SetVelocity(const Nz::Vector3f& velocity) { NazaraAssert(m_object, "Invalid physics object"); @@ -167,6 +345,11 @@ namespace Ndk m_object->SetVelocity(velocity); } + /*! + * \brief Gets the underlying physics object + * \return A reference to the physics object + */ + inline Nz::PhysObject& PhysicsComponent::GetPhysObject() { return *m_object.get(); diff --git a/SDK/include/NDK/Components/VelocityComponent.inl b/SDK/include/NDK/Components/VelocityComponent.inl index 1c2f0ed87..e72eca8b7 100644 --- a/SDK/include/NDK/Components/VelocityComponent.inl +++ b/SDK/include/NDK/Components/VelocityComponent.inl @@ -7,11 +7,30 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::VelocityComponent + * \brief NDK class that represents the component for velocity + */ + + /*! + * \brief Constructs a VelocityComponent object with a velocity + * + * \param velocity Linear velocity + */ + inline VelocityComponent::VelocityComponent(const Nz::Vector3f& velocity) : linearVelocity(velocity) { } + /*! + * \brief Assigns the velocity to this component + * \return A reference to this + * + * \param vel Linear velocity + */ + inline VelocityComponent& VelocityComponent::operator=(const Nz::Vector3f& vel) { linearVelocity = vel; diff --git a/SDK/include/NDK/Console.inl b/SDK/include/NDK/Console.inl index 5fb16bb1b..94a6daf91 100644 --- a/SDK/include/NDK/Console.inl +++ b/SDK/include/NDK/Console.inl @@ -7,41 +7,81 @@ namespace Ndk { + /*! + * \brief Gets the character size + * \return Height of the character + */ + inline unsigned int Console::GetCharacterSize() const { return m_characterSize; } + /*! + * \brief Gets the entity representing the history of the console + * \return History of the console + */ + inline const EntityHandle& Console::GetHistory() const { return m_history; } + /*! + * \brief Gets the entity representing the background of the console's history + * \return Background history of the console + */ + inline const EntityHandle& Console::GetHistoryBackground() const { return m_historyBackground; } + /*! + * \brief Gets the entity representing the input of the console + * \return Input of the console + */ + inline const EntityHandle& Console::GetInput() const { return m_input; } + /*! + * \brief Gets the entity representing the background of the console's input + * \return Background input of the console + */ + inline const EntityHandle& Console::GetInputBackground() const { return m_inputBackground; } + /*! + * \brief Gets the size of the console + * \return Size (Width, Height) of the console + */ + inline const Nz::Vector2f& Console::GetSize() const { return m_size; } + /*! + * \brief Gets the font used by the console + * \return A reference to the font currenty used + */ + inline const Nz::FontRef& Console::GetTextFont() const { return m_defaultFont; } + /*! + * \brief Checks whether the console is visible + * \return true If it is the case + */ + inline bool Console::IsVisible() const { return m_opened; diff --git a/SDK/include/NDK/Entity.inl b/SDK/include/NDK/Entity.inl index a03130b0d..535f2c1f4 100644 --- a/SDK/include/NDK/Entity.inl +++ b/SDK/include/NDK/Entity.inl @@ -11,16 +11,29 @@ namespace Ndk { + /*! + * \brief Adds a component to the entity + * \return A reference to the newly added component + * + * \param args Arguments to create in place the component to add to the entity + */ + template ComponentType& Entity::AddComponent(Args&&... args) { static_assert(std::is_base_of::value, "ComponentType is not a component"); - // Allocation et affectation du component + // Affectation and return of the component std::unique_ptr ptr(new ComponentType(std::forward(args)...)); return static_cast(AddComponent(std::move(ptr))); } + /*! + * \brief Enables the entity + * + * \param enable Should the entity be enabled + */ + inline void Entity::Enable(bool enable) { if (m_enabled != enable) @@ -30,9 +43,17 @@ namespace Ndk } } + /*! + * \brief Gets a component in the entity by index + * \return A reference to the component + * + * \param index Index of the component + * + * \remark Produces a NazaraAssert if component is not available in this entity or is invalid + */ + inline BaseComponent& Entity::GetComponent(ComponentIndex index) { - ///DOC: Le component doit être présent NazaraAssert(HasComponent(index), "This component is not part of the entity"); BaseComponent* component = m_components[index].get(); @@ -41,19 +62,33 @@ namespace Ndk return *component; } + /*! + * \brief Gets a component in the entity by type + * \return A reference to the component + * + * \remark Produces a NazaraAssert if component is not available in this entity + */ + template ComponentType& Entity::GetComponent() { - ///DOC: Le component doit être présent static_assert(std::is_base_of::value, "ComponentType is not a component"); ComponentIndex index = GetComponentIndex(); return static_cast(GetComponent(index)); } + /*! + * \brief Gets a component in the entity by index + * \return A constant reference to the component + * + * \param index Index of the component + * + * \remark Produces a NazaraAssert if component is not available in this entity or is invalid + */ + inline const BaseComponent& Entity::GetComponent(ComponentIndex index) const { - ///DOC: Le component doit être présent NazaraAssert(HasComponent(index), "This component is not part of the entity"); BaseComponent* component = m_components[index].get(); @@ -62,41 +97,79 @@ namespace Ndk return *component; } + /*! + * \brief Gets a component in the entity by type + * \return A constant reference to the component + * + * \remark Produces a NazaraAssert if component is not available in this entity + */ + template const ComponentType& Entity::GetComponent() const { - ///DOC: Le component doit être présent static_assert(std::is_base_of::value, "ComponentType is not a component"); ComponentIndex index = GetComponentIndex(); return static_cast(GetComponent(index)); } + /*! + * \brief Gets the bits representing the components in the entiy + * \return A constant reference to the set of component's bits + */ + inline const Nz::Bitset<>& Entity::GetComponentBits() const { return m_componentBits; } + /*! + * \brief Gets the identifier of the entity + * \return Identifier of the entity + */ + inline EntityId Entity::GetId() const { return m_id; } + /*! + * \brief Gets the bits representing the systems in the entiy + * \return A constant reference to the set of system's bits + */ + inline const Nz::Bitset<>& Entity::GetSystemBits() const { return m_systemBits; } + /*! + * \brief Gets the world in which the entity is + * \return Pointer to the world + */ + inline World* Entity::GetWorld() const { return m_world; } + /*! + * \brief Checks whether or not a component is present in the entity by index + * \return true If it is the case + * + * \param index Index of the component + */ + inline bool Entity::HasComponent(ComponentIndex index) const { return m_componentBits.UnboundedTest(index); } + /*! + * \brief Checks whether or not a component is present in the entity by type + * \return true If it is the case + */ + template bool Entity::HasComponent() const { @@ -106,16 +179,54 @@ namespace Ndk return HasComponent(index); } + /*! + * \brief Checks whether or not the entity is enabled + * \return true If it is the case + */ + inline bool Entity::IsEnabled() const { return m_enabled; } + /*! + * \brief Checks whether or not the entity is valid + * \return true If it is the case + */ + inline bool Entity::IsValid() const { return m_valid; } + /*! + * \brief Removes every components + */ + + inline void Entity::RemoveAllComponents() + { + m_removedComponentBits = m_componentBits; + + Invalidate(); + } + + /*! + * \brief Removes a component in the entity by index + * + * \param index Index of the component + */ + + inline void Entity::RemoveComponent(ComponentIndex index) + { + m_removedComponentBits.UnboundedSet(index); + + Invalidate(); + } + + /*! + * \brief Removes a component in the entity by type + */ + template void Entity::RemoveComponent() { @@ -125,19 +236,10 @@ namespace Ndk RemoveComponent(index); } - inline void Entity::RemoveAllComponents() - { - m_removedComponentBits = m_componentBits; - - Invalidate(); - } - - inline void Entity::RemoveComponent(ComponentIndex index) - { - m_removedComponentBits.UnboundedSet(index); - - Invalidate(); - } + /*! + * \brief Gives a string representation + * \return A string representation of the object: "Entity(GetId())" + */ inline Nz::String Entity::ToString() const { @@ -145,16 +247,35 @@ namespace Ndk return ss << "Entity(" << GetId() << ')'; } + /*! + * \brief Gets the bits representing the removed components in the entiy + * \return A constant reference to the set of remove component's bits + */ + inline Nz::Bitset<>& Entity::GetRemovedComponentBits() { return m_removedComponentBits; } + /*! + * \brief Registers a system for the entity + * + * \param index Index of the system + */ + inline void Entity::RegisterSystem(SystemIndex index) { m_systemBits.UnboundedSet(index); } + /*! + * \brief Sets the world of the entity + * + * \param world World in which the entity will be + * + * \remark Produces a NazaraAssert if world is invalid + */ + inline void Entity::SetWorld(World* world) noexcept { NazaraAssert(world, "An entity must be attached to a world at any time"); @@ -162,6 +283,12 @@ namespace Ndk m_world = world; } + /*! + * \brief Unregisters a system for the entity + * + * \param index Index of the system + */ + inline void Entity::UnregisterSystem(SystemIndex index) { m_systemBits.UnboundedReset(index); @@ -173,10 +300,16 @@ namespace std template<> struct hash { + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param handle Entity to hash + */ size_t operator()(const Ndk::EntityHandle& handle) const { - // Hasher le pointeur fonctionnerait jusqu'à ce que l'entité soit mise à jour et déplacée - // pour cette raison, nous devons hasher l'ID de l'entité (qui reste constante) + // Hash the pointer will work until the entity is updated and moved + // so, we have to hash the ID of the entity (which is constant) Ndk::EntityId id = (handle.IsValid()) ? handle->GetId() : std::numeric_limits::max(); return hash()(id); diff --git a/SDK/include/NDK/EntityList.inl b/SDK/include/NDK/EntityList.inl index 94fa3472f..224fdd1dc 100644 --- a/SDK/include/NDK/EntityList.inl +++ b/SDK/include/NDK/EntityList.inl @@ -7,22 +7,54 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::EntityList + * \brief NDK class that represents a set of entities to help performing batch operations + */ + + /*! + * \brief Clears the set from every entities + */ + inline void EntityList::Clear() { m_entities.clear(); m_entityBits.Clear(); } + /*! + * \brief Checks whether or not the set contains the entity + * \return true If it is the case + * + * \param entity Pointer to the entity + */ + inline bool EntityList::Has(const Entity* entity) { return entity && entity->IsValid() && Has(entity->GetId()); } + /*! + * \brief Checks whether or not the set contains the entity by id + * \return true If it is the case + * + * \param id Identifier of the entity + */ + inline bool EntityList::Has(EntityId entity) { return m_entityBits.UnboundedTest(entity); } + /*! + * \brief Inserts the entity into the set + * + * \param entity Pointer to the entity + * + * \remark If entity is already contained, no action is performed + */ + inline void EntityList::Insert(Entity* entity) { if (!Has(entity)) @@ -32,6 +64,14 @@ namespace Ndk } } + /*! + * \brief Removes the entity from the set + * + * \param entity Pointer to the entity + * + * \remark If entity is not contained, no action is performed + */ + inline void EntityList::Remove(Entity* entity) { if (Has(entity)) @@ -40,7 +80,7 @@ namespace Ndk NazaraAssert(it != m_entities.end(), "Entity should be part of the vector"); std::swap(*it, m_entities.back()); - m_entities.pop_back(); // On le sort du vector + m_entities.pop_back(); // We get it out of the vector m_entityBits.UnboundedSet(entity->GetId(), false); } } diff --git a/SDK/include/NDK/EntityOwner.inl b/SDK/include/NDK/EntityOwner.inl index 6efc2b30e..2cb64f1e8 100644 --- a/SDK/include/NDK/EntityOwner.inl +++ b/SDK/include/NDK/EntityOwner.inl @@ -8,17 +8,41 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::EntityOwner + * \brief NDK class that represents the owner of the entity and so its lifetime + */ + + /*! + * \brief Constructs a EntityOwner object + * + * \param entity Entity to own + */ + inline EntityOwner::EntityOwner(Entity* entity) : EntityOwner() { Reset(entity); } + /*! + * \brief Destructs the object and calls Reset + * + * \see Reset + */ + inline EntityOwner::~EntityOwner() { Reset(nullptr); } + /*! + * \brief Resets the ownership of the entity, previous is killed + * + * \param entity Entity to own + */ + inline void EntityOwner::Reset(Entity* entity) { if (m_object) @@ -27,12 +51,24 @@ namespace Ndk EntityHandle::Reset(entity); } + /*! + * \brief Resets the ownership of the entity by move semantic + * + * \param handle EntityOwner to move into this + */ + inline void EntityOwner::Reset(EntityOwner&& handle) { Reset(handle.GetObject()); handle.m_object = nullptr; } + /*! + * \brief Resets the ownership of the entity to the affected one + * + * \param entity Entity to own + */ + inline EntityOwner& EntityOwner::operator=(Entity* entity) { Reset(entity); diff --git a/SDK/include/NDK/LuaAPI.inl b/SDK/include/NDK/LuaAPI.inl index a09d6c459..6f1b73234 100644 --- a/SDK/include/NDK/LuaAPI.inl +++ b/SDK/include/NDK/LuaAPI.inl @@ -26,6 +26,11 @@ namespace Ndk { + /*! + * \brief Gets the internal binding for Lua + * \return A pointer to the binding + */ + inline LuaBinding* LuaAPI::GetBinding() { return s_binding; @@ -34,6 +39,15 @@ namespace Ndk namespace Nz { + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param color Resulting color + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Color* color, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); @@ -46,6 +60,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param angles Resulting euler angles + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesd* angles, TypeTag) { switch (instance.GetType(index)) @@ -66,6 +89,15 @@ namespace Nz } } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param angles Resulting euler angles + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, EulerAnglesf* angles, TypeTag) { EulerAnglesd anglesDouble; @@ -75,6 +107,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param fontRef Resulting reference to a font + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontRef* fontRef, TypeTag) { *fontRef = *static_cast(instance.CheckUserdata(index, "Font")); @@ -82,6 +123,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param params Resulting parameters for a font + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, FontParams* params, TypeTag) { NazaraUnused(params); @@ -93,6 +143,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param params Resulting parameters for a mesh + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MeshParams* params, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); @@ -106,6 +165,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param rect Resulting rectangle + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectd* rect, TypeTag) { instance.CheckType(index, LuaType_Table); @@ -118,6 +186,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param rect Resulting rectangle + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectf* rect, TypeTag) { Rectd rectDouble; @@ -127,6 +204,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param rect Resulting rectangle + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Rectui* rect, TypeTag) { Rectd rectDouble; @@ -136,6 +222,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param quat Resulting quaternion + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaterniond* quat, TypeTag) { switch (instance.GetType(index)) @@ -156,6 +251,15 @@ namespace Nz } } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param quat Resulting quaternion + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Quaternionf* quat, TypeTag) { Quaterniond quatDouble; @@ -165,6 +269,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param address Resulting IP address + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, IpAddress* address, TypeTag) { switch (instance.GetType(index)) @@ -179,6 +292,15 @@ namespace Nz } } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param vec Resulting vector2D + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2d* vec, TypeTag) { switch (instance.GetType(index)) @@ -200,6 +322,15 @@ namespace Nz } } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param vec Resulting vector2D + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2f* vec, TypeTag) { Vector2d vecDouble; @@ -209,6 +340,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param vec Resulting vector2D + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector2ui* vec, TypeTag) { Vector2d vecDouble; @@ -218,6 +358,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param vec Resulting vector3D + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3d* vec, TypeTag) { switch (instance.GetType(index)) @@ -239,6 +388,15 @@ namespace Nz } } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param vec Resulting vector3D + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3f* vec, TypeTag) { Vector3d vecDouble; @@ -248,6 +406,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param vec Resulting vector3D + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Vector3ui* vec, TypeTag) { Vector3d vecDouble; @@ -257,6 +424,15 @@ namespace Nz return ret; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param handle Resulting entity + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::EntityHandle* handle, TypeTag) { *handle = *static_cast(instance.CheckUserdata(index, "Entity")); @@ -264,6 +440,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param handle Resulting world + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, Ndk::WorldHandle* handle, TypeTag) { *handle = *static_cast(instance.CheckUserdata(index, "World")); @@ -272,6 +457,16 @@ namespace Nz } #ifndef NDK_SERVER + + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param renderable Resulting reference to a instanced renderable + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, InstancedRenderableRef* renderable, TypeTag) { if (instance.IsOfType(index, "InstancedRenderable")) @@ -281,6 +476,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param params Resulting parameters for a material + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MaterialParams* params, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); @@ -295,6 +499,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param params Resulting parameters for a model + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, ModelParameters* params, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); @@ -307,6 +520,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param params Resulting parameters for a music + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, MusicParams* params, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); @@ -316,6 +538,15 @@ namespace Nz return 1; } + /*! + * \brief Queries arguments for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param index Index type + * \param params Resulting parameters for a sound buffer + */ + inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SoundBufferParams* params, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); @@ -324,9 +555,16 @@ namespace Nz return 1; } + #endif - + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting euler angles + */ inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesd&& val, TypeTag) { @@ -334,18 +572,42 @@ namespace Nz return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting euler angles + */ + inline int LuaImplReplyVal(const LuaInstance& instance, EulerAnglesf&& val, TypeTag) { instance.PushInstance("EulerAngles", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting reference to a font + */ + inline int LuaImplReplyVal(const LuaInstance& instance, FontRef&& val, TypeTag) { instance.PushInstance("Font", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting size information for a font + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Font::SizeInfo&& val, TypeTag) { instance.PushTable(); @@ -357,114 +619,266 @@ namespace Nz return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting quaternion + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Quaterniond&& val, TypeTag) { instance.PushInstance("Quaternion", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting quaternion + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Quaternionf&& val, TypeTag) { instance.PushInstance("Quaternion", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting IP address + */ + inline int LuaImplReplyVal(const LuaInstance& instance, IpAddress&& val, TypeTag) { instance.PushInstance("IpAddress", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting rectangle + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Rectd&& val, TypeTag) { instance.PushInstance("Rect", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting rectangle + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Rectf&& val, TypeTag) { instance.PushInstance("Rect", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting rectangle + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Rectui&& val, TypeTag) { instance.PushInstance("Rect", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting vector2D + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Vector2d&& val, TypeTag) { instance.PushInstance("Vector2", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting vector2D + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Vector2f&& val, TypeTag) { instance.PushInstance("Vector2", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting vector2D + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Vector2ui&& val, TypeTag) { instance.PushInstance("Vector2", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting vector3D + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d&& val, TypeTag) { instance.PushInstance("Vector3", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting vector3D + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f&& val, TypeTag) { instance.PushInstance("Vector3", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting vector3D + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui&& val, TypeTag) { instance.PushInstance("Vector3", val); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param ptr Resulting entity + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Entity* ptr, TypeTag) { instance.PushInstance("Entity", ptr); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param ptr Resulting application + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::Application* ptr, TypeTag) { instance.PushInstance("Application", ptr); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param handle Resulting entity + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::EntityHandle&& handle, TypeTag) { instance.PushInstance("Entity", handle); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param handle Resulting node component + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::NodeComponentHandle&& handle, TypeTag) { instance.PushInstance("NodeComponent", handle); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param handle Resulting velocity component + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::VelocityComponentHandle&& handle, TypeTag) { instance.PushInstance("VelocityComponent", handle); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param ptr Resulting world + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::World* ptr, TypeTag) { instance.PushInstance("World", ptr); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param ptr Resulting world + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::WorldHandle&& handle, TypeTag) { instance.PushInstance("World", handle); @@ -472,22 +886,49 @@ namespace Nz } #ifndef NDK_SERVER + + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param handle Resulting console + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::ConsoleHandle&& handle, TypeTag) { instance.PushInstance("Console", handle); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param handle Resulting graphics component + */ + inline int LuaImplReplyVal(const LuaInstance& instance, Ndk::GraphicsComponentHandle&& handle, TypeTag) { instance.PushInstance("GraphicsComponent", handle); return 1; } + /*! + * \brief Replies by value for Lua + * \return 1 in case of success + * + * \param instance Lua instance to interact with + * \param val Resulting sound buffer + */ + inline int LuaImplReplyVal(const LuaInstance& instance, const SoundBuffer* val, TypeTag) { instance.PushInstance("SoundBuffer", val); return 1; } + #endif + } diff --git a/SDK/include/NDK/LuaBinding.inl b/SDK/include/NDK/LuaBinding.inl index 64e3eb453..e4ae72254 100644 --- a/SDK/include/NDK/LuaBinding.inl +++ b/SDK/include/NDK/LuaBinding.inl @@ -6,6 +6,14 @@ namespace Ndk { + /*! + * \brief Binds a component to a name + * + * \param name Name used to retrieve the component + * + * \remark Produces a NazaraAssert if name is empty + */ + template void LuaBinding::BindComponent(const Nz::String& name) { @@ -24,6 +32,16 @@ namespace Ndk m_componentBindingByName[name] = T::componentIndex; } + /*! + * \brief Adds a component to an entity + * \return 1 in case of success + * + * \param instance Lua instance that will interact with the component + * \param handle Entity which component will be added to + * + * \remark T must be a subtype of BaseComponent + */ + template int AddComponentOfType(Nz::LuaInstance& lua, EntityHandle& handle) { @@ -34,6 +52,16 @@ namespace Ndk return 1; } + /*! + * \brief Pushes a component + * \return 1 in case of success + * + * \param instance Lua instance that will interact with the component + * \param component Component that will be pushed + * + * \remark T must be a subtype of BaseComponent + */ + template int PushComponentOfType(Nz::LuaInstance& lua, BaseComponent& component) { diff --git a/SDK/include/NDK/Prerequesites.hpp b/SDK/include/NDK/Prerequesites.hpp index d75ed0eb0..f3532c70d 100644 --- a/SDK/include/NDK/Prerequesites.hpp +++ b/SDK/include/NDK/Prerequesites.hpp @@ -27,11 +27,11 @@ #include -// Version du SDK +// Version of SDK #define NDK_VERSION_MAJOR 0 #define NDK_VERSION_MINOR 1 -// Importation/Exportation de l'API +// Importation/Exportation of the API #if defined(NAZARA_PLATFORM_WINDOWS) #if !defined(NDK_STATIC) #ifdef NDK_BUILD @@ -49,7 +49,7 @@ #define NDK_API #endif #else - // À commenter pour tenter quand même une compilation + // To comment to force a compilation #error This operating system is not fully supported by the Nazara Development Kit #define NDK_API diff --git a/SDK/include/NDK/Sdk.inl b/SDK/include/NDK/Sdk.inl index 0bdc1e2cd..3cbafab66 100644 --- a/SDK/include/NDK/Sdk.inl +++ b/SDK/include/NDK/Sdk.inl @@ -4,6 +4,11 @@ namespace Ndk { + /*! + * \brief Checks whether the module is initialized + * \return true if module is initialized + */ + inline bool Sdk::IsInitialized() { return s_referenceCounter != 0; diff --git a/SDK/include/NDK/StateMachine.inl b/SDK/include/NDK/StateMachine.inl index 7b5109ab5..c522f5431 100644 --- a/SDK/include/NDK/StateMachine.inl +++ b/SDK/include/NDK/StateMachine.inl @@ -8,6 +8,21 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::StateMachine + * \brief NDK class that represents a state machine, to represent the multiple states of your program + */ + + /*! + * \brief Constructs a StateMachine object with an original state + * + * \param originalState State which is the entry point of the application + * + * \remark Calls "Enter" on the state + * \remark Produces a NazaraAssert if nullptr is given + */ + inline StateMachine::StateMachine(std::shared_ptr originalState) : m_currentState(std::move(originalState)) { @@ -15,22 +30,45 @@ namespace Ndk m_currentState->Enter(*this); } + /*! + * \brief Destructs the object + * + * \remark Calls "Leave" on the state + */ + inline StateMachine::~StateMachine() { m_currentState->Leave(*this); } + /*! + * \brief Changes the current state of the machine + * + * \param state Next state to represent + */ inline void StateMachine::ChangeState(std::shared_ptr state) { m_nextState = std::move(state); } + /*! + * \brief Gets the current state of the machine + * \return A constant reference to the state + */ + inline const std::shared_ptr& StateMachine::GetCurrentState() const { return m_currentState; } + /*! + * \brief Updates the state + * \return True if update is successful + * + * \param elapsedTime Delta time used for the update + */ + inline bool StateMachine::Update(float elapsedTime) { if (m_nextState) diff --git a/SDK/include/NDK/System.hpp b/SDK/include/NDK/System.hpp index 6d1d423dc..b5a50f76f 100644 --- a/SDK/include/NDK/System.hpp +++ b/SDK/include/NDK/System.hpp @@ -11,7 +11,7 @@ namespace Ndk { - template + template class System : public BaseSystem { public: @@ -20,7 +20,7 @@ namespace Ndk System(System&&) = default; virtual ~System(); - BaseSystem* Clone() const override; + std::unique_ptr Clone() const override; System& operator=(const System&) = delete; System& operator=(System&&) = default; diff --git a/SDK/include/NDK/System.inl b/SDK/include/NDK/System.inl index 9b382d924..d0359cc63 100644 --- a/SDK/include/NDK/System.inl +++ b/SDK/include/NDK/System.inl @@ -7,6 +7,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::System + * \brief NDK class that represents a system which interacts on a world + * + * \remark This class is meant to be derived as CRTP: "System" + */ + + /*! + * \brief Constructs a System object by default + */ + template System::System() : BaseSystem(GetSystemIndex()) @@ -16,15 +28,26 @@ namespace Ndk template System::~System() = default; + /*! + * \brief Clones the system + * \return The clone newly created + * + * \remark The system to clone should be trivially copy constructible + */ + template - BaseSystem* System::Clone() const + std::unique_ptr System::Clone() const { - ///FIXME: Pas encore supporté par GCC (4.9.2) + ///FIXME: Not fully supported in GCC (4.9.2) //static_assert(std::is_trivially_copy_constructible::value, "SystemType should be copy-constructible"); - return new SystemType(static_cast(*this)); + return std::make_unique(static_cast(*this)); } + /*! + * \brief Registers the system by assigning it an index + */ + template SystemIndex System::RegisterSystem() { diff --git a/SDK/include/NDK/Systems/PhysicsSystem.inl b/SDK/include/NDK/Systems/PhysicsSystem.inl index e9fb52c49..bfe886cb1 100644 --- a/SDK/include/NDK/Systems/PhysicsSystem.inl +++ b/SDK/include/NDK/Systems/PhysicsSystem.inl @@ -4,11 +4,21 @@ namespace Ndk { + /*! + * \brief Gets the physical world + * \return A reference to the physical world + */ + inline Nz::PhysWorld& PhysicsSystem::GetWorld() { return m_world; } + /*! + * \brief Gets the physical world + * \return A constant reference to the physical world + */ + inline const Nz::PhysWorld& PhysicsSystem::GetWorld() const { return m_world; diff --git a/SDK/include/NDK/Systems/RenderSystem.inl b/SDK/include/NDK/Systems/RenderSystem.inl index 4f7afe63d..4b758aa92 100644 --- a/SDK/include/NDK/Systems/RenderSystem.inl +++ b/SDK/include/NDK/Systems/RenderSystem.inl @@ -4,58 +4,119 @@ namespace Ndk { + /*! + * \brief Constructs a RenderSystem object by copy semantic + * + * \param renderSystem RenderSystem to copy + */ + inline RenderSystem::RenderSystem(const RenderSystem& renderSystem) : System(renderSystem) { } + /*! + * \brief Changes the render technique used for the system + * \return A reference to the render technique type + */ + template inline T& RenderSystem::ChangeRenderTechnique() { + static_assert(std::is_base_of::value, "RenderTechnique is not a subtype of AbstractRenderTechnique"); return static_cast(ChangeRenderTechnique(std::make_unique())); } + /*! + * \brief Changes the render technique used for the system + * \return A reference to the abstract render technique + * + * \param renderTechnique Render technique to use + */ + inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr&& renderTechnique) { m_renderTechnique = std::move(renderTechnique); return *m_renderTechnique.get(); } + /*! + * \brief Gets the background used for rendering + * \return A reference to the background + */ + inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const { return m_background; } + /*! + * \brief Gets the coordinates matrix used for rendering + * \return A constant reference to the matrix of coordinates + */ + inline const Nz::Matrix4f& RenderSystem::GetCoordinateSystemMatrix() const { return m_coordinateSystemMatrix; } + /*! + * \brief Gets the "forward" global direction + * \return The forward direction, by default, it's -UnitZ() (Right hand coordinates) + */ + inline Nz::Vector3f RenderSystem::GetGlobalForward() const { return Nz::Vector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33); } + /*! + * \brief Gets the "right" global direction + * \return The right direction, by default, it's UnitX() (Right hand coordinates) + */ + inline Nz::Vector3f RenderSystem::GetGlobalRight() const { return Nz::Vector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31); } + /*! + * \brief Gets the "up" global direction + * \return The up direction, by default, it's UnitY() (Right hand coordinates) + */ + inline Nz::Vector3f RenderSystem::GetGlobalUp() const { return Nz::Vector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32); } + /*! + * \brief Gets the render technique used for rendering + * \return A reference to the abstract render technique being used + */ + inline Nz::AbstractRenderTechnique& RenderSystem::GetRenderTechnique() const { return *m_renderTechnique.get(); } + /*! + * \brief Sets the background used for rendering + * + * \param background A reference to the background + */ + inline void RenderSystem::SetDefaultBackground(Nz::BackgroundRef background) { m_background = std::move(background); } + /*! + * \brief Sets the "forward" global direction + * + * \param direction The new forward direction + */ + inline void RenderSystem::SetGlobalForward(const Nz::Vector3f& direction) { m_coordinateSystemMatrix.m13 = -direction.x; @@ -65,6 +126,12 @@ namespace Ndk InvalidateCoordinateSystem(); } + /*! + * \brief Sets the "right" global direction + * + * \param direction The new right direction + */ + inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction) { m_coordinateSystemMatrix.m11 = direction.x; @@ -74,6 +141,12 @@ namespace Ndk InvalidateCoordinateSystem(); } + /*! + * \brief Sets the "up" global direction + * + * \param direction The new up direction + */ + inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction) { m_coordinateSystemMatrix.m12 = direction.x; @@ -83,6 +156,10 @@ namespace Ndk InvalidateCoordinateSystem(); } + /*! + * \brief Invalidates the matrix of coordinates for the system + */ + inline void RenderSystem::InvalidateCoordinateSystem() { m_coordinateSystemInvalidated = true; diff --git a/SDK/include/NDK/World.hpp b/SDK/include/NDK/World.hpp index 2e20d03a9..5d1dabb77 100644 --- a/SDK/include/NDK/World.hpp +++ b/SDK/include/NDK/World.hpp @@ -43,7 +43,6 @@ namespace Ndk inline EntityList CreateEntities(unsigned int count); void Clear() noexcept; - const EntityHandle& CloneEntity(EntityId id); const EntityHandle& GetEntity(EntityId id); diff --git a/SDK/include/NDK/World.inl b/SDK/include/NDK/World.inl index ba2b33bd4..9960aef05 100644 --- a/SDK/include/NDK/World.inl +++ b/SDK/include/NDK/World.inl @@ -7,47 +7,80 @@ namespace Ndk { + /*! + * \brief Constructs a World object + * + * \param addDefaultSystems Should default provided systems be used + */ + inline World::World(bool addDefaultSystems) { if (addDefaultSystems) AddDefaultSystems(); } + /*! + * \brief Constructs a World object by move semantic + * + * \param world World to move into this + */ + inline World::World(World&& world) noexcept : HandledObject(std::move(world)) { operator=(std::move(world)); } + /*! + * \brief Adds a system to the world + * \return A reference to the newly created system + * + * \param system System to add to the world + */ + inline BaseSystem& World::AddSystem(std::unique_ptr&& system) { NazaraAssert(system, "System must be valid"); SystemIndex index = system->GetIndex(); - // Nous nous assurons que le vecteur de component est suffisamment grand pour contenir le nouveau component + // We must ensure that the vector is big enough to hold the new system if (index >= m_systems.size()) m_systems.resize(index + 1); - // Affectation et retour du système + // Affectation and return of system m_systems[index] = std::move(system); m_systems[index]->SetWorld(this); - Invalidate(); // On force une mise à jour de toutes les entités + Invalidate(); // We force an update for every entities return *m_systems[index].get(); } + /*! + * \brief Adds a system to the world + * \return A reference to the newly created system + * + * \param args Arguments used to create the system + */ + template SystemType& World::AddSystem(Args&&... args) { static_assert(std::is_base_of::value, "SystemType is not a component"); - // Allocation et affectation du component + // Allocation and affectation of the system std::unique_ptr ptr(new SystemType(std::forward(args)...)); return static_cast(AddSystem(std::move(ptr))); } + /*! + * \brief Creates multiple entities in the world + * \return The set of entities created + * + * \param count Number of entities to create + */ + inline World::EntityList World::CreateEntities(unsigned int count) { EntityList list; @@ -59,14 +92,27 @@ namespace Ndk return list; } + /*! + * \brief Gets every entities in the world + * \return A constant reference to the entities + */ + inline const World::EntityList& World::GetEntities() { return m_aliveEntities; } + /*! + * \brief Gets a system in the world by index + * \return A reference to the system + * + * \param index Index of the system + * + * \remark Produces a NazaraAssert if system is not available in this world + */ + inline BaseSystem& World::GetSystem(SystemIndex index) { - ///DOC: Le système doit être présent NazaraAssert(HasSystem(index), "This system is not part of the world"); BaseSystem* system = m_systems[index].get(); @@ -75,21 +121,39 @@ namespace Ndk return *system; } + /*! + * \brief Gets a system in the world by type + * \return A reference to the system + * + * \remark Produces a NazaraAssert if system is not available in this world + */ + template SystemType& World::GetSystem() { - ///DOC: Le système doit être présent static_assert(std::is_base_of::value, "SystemType is not a system"); SystemIndex index = GetSystemIndex(); return static_cast(GetSystem(index)); } + /*! + * \brief Checks whether or not a system is present in the world by index + * \return true If it is the case + * + * \param index Index of the system + */ + inline bool World::HasSystem(SystemIndex index) const { return index < m_systems.size() && m_systems[index]; } + /*! + * \brief Checks whether or not a system is present in the world by type + * \return true If it is the case + */ + template bool World::HasSystem() const { @@ -99,34 +163,69 @@ namespace Ndk return HasSystem(index); } + /*! + * \brief Kills a set of entities + * + * \param list Set of entities to kill + */ + inline void World::KillEntities(const EntityList& list) { for (const EntityHandle& entity : list) KillEntity(entity); } + /*! + * \brief Checks whether or not an entity is valid + * \return true If it is the case + * + * \param entity Pointer to the entity + */ + inline bool World::IsEntityValid(const Entity* entity) const { return entity && entity->GetWorld() == this && IsEntityIdValid(entity->GetId()); } + /*! + * \brief Checks whether or not an entity is valid + * \return true If it is the case + * + * \param id Identifier of the entity + */ + inline bool World::IsEntityIdValid(EntityId id) const { return id < m_entities.size() && m_entities[id].entity.IsValid(); } + /*! + * \brief Removes each system from the world + */ + inline void World::RemoveAllSystems() { m_systems.clear(); } + /*! + * \brief Removes a system from the world by index + * + * \param index Index of the system + * + * \remark No change is done if system is not present + */ + inline void World::RemoveSystem(SystemIndex index) { - ///DOC: N'a aucun effet si le système n'est pas présent if (HasSystem(index)) m_systems[index].reset(); } + /*! + * \brief Removes a system from the world by type + */ + template void World::RemoveSystem() { @@ -136,6 +235,12 @@ namespace Ndk RemoveSystem(index); } + /*! + * \brief Updates the world + * + * \param elapsedTime Delta time used for the update + */ + inline void World::Update(float elapsedTime) { Update(); //< Update entities @@ -148,17 +253,32 @@ namespace Ndk } } + /*! + * \brief Invalidates each entity in the world + */ + inline void World::Invalidate() { m_dirtyEntities.Resize(m_entities.size(), false); - m_dirtyEntities.Set(true); // Activation de tous les bits + m_dirtyEntities.Set(true); // Activation of all bits } + /*! + * \brief Invalidates an entity in the world + * + * \param id Identifier of the entity + */ + inline void World::Invalidate(EntityId id) { m_dirtyEntities.UnboundedSet(id, true); } + /*! + * \brief Moves a world into another world object + * \return A reference to the object + */ + inline World& World::operator=(World&& world) noexcept { m_aliveEntities = std::move(world.m_aliveEntities); diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index df2dfa12c..5e3331d73 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -6,6 +6,16 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Application + * \brief NDK class that represents the application, it offers a set of tools to ease the development + */ + + /*! + * \brief Runs the application by updating worlds, taking care about windows, ... + */ + bool Application::Run() { #ifndef NDK_SERVER diff --git a/SDK/src/NDK/BaseComponent.cpp b/SDK/src/NDK/BaseComponent.cpp index 1a0b85168..39d67d211 100644 --- a/SDK/src/NDK/BaseComponent.cpp +++ b/SDK/src/NDK/BaseComponent.cpp @@ -6,22 +6,50 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::BaseComponent + * \brief NDK class that represents the common base of all components + * + * \remark This class is meant to be purely abstract, for type erasure + */ + BaseComponent::~BaseComponent() = default; + /*! + * \brief Operation to perform when component is attached to an entity + */ + void BaseComponent::OnAttached() { } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void BaseComponent::OnComponentAttached(BaseComponent& component) { NazaraUnused(component); } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void BaseComponent::OnComponentDetached(BaseComponent& component) { NazaraUnused(component); } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void BaseComponent::OnDetached() { } diff --git a/SDK/src/NDK/BaseSystem.cpp b/SDK/src/NDK/BaseSystem.cpp index a69f13550..8a2a9dce5 100644 --- a/SDK/src/NDK/BaseSystem.cpp +++ b/SDK/src/NDK/BaseSystem.cpp @@ -6,12 +6,31 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::BaseSystem + * \brief NDK class that represents the common base of all systems + * + * \remark This class is meant to be purely abstract, for type erasure + */ + + /*! + * \brief Destructs the object and unregisters it-self on every entities + */ + BaseSystem::~BaseSystem() { for (const EntityHandle& entity : m_entities) entity->UnregisterSystem(m_systemIndex); } + /*! + * \brief Checks whether the key of the entity matches the lock of the system + * \return true If it is the case + * + * \param Pointer to the entity + */ + bool BaseSystem::Filters(const Entity* entity) const { if (!entity) @@ -21,13 +40,13 @@ namespace Ndk m_filterResult.PerformsAND(m_requiredComponents, components); if (m_filterResult != m_requiredComponents) - return false; // Au moins un component requis n'est pas présent + return false; // At least one required component is not available m_filterResult.PerformsAND(m_excludedComponents, components); if (m_filterResult.TestAny()) - return false; // Au moins un component exclu est présent + return false; // At least one excluded component is available - // Si nous avons une liste de composants nécessaires + // If we have a list of needed components if (m_requiredAnyComponents.TestAny()) { if (!m_requiredAnyComponents.Intersects(components)) @@ -37,16 +56,35 @@ namespace Ndk return true; } + /*! + * \brief Operation to perform when entity is added to the system + * + * \param Pointer to the entity + */ + void BaseSystem::OnEntityAdded(Entity* entity) { NazaraUnused(entity); } + /*! + * \brief Operation to perform when entity is removed to the system + * + * \param Pointer to the entity + */ + void BaseSystem::OnEntityRemoved(Entity* entity) { NazaraUnused(entity); } + /*! + * \brief Operation to perform when entity is validated for the system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + */ + void BaseSystem::OnEntityValidation(Entity* entity, bool justAdded) { NazaraUnused(entity); diff --git a/SDK/src/NDK/Components/CameraComponent.cpp b/SDK/src/NDK/Components/CameraComponent.cpp index 1b7a3e06d..71c653823 100644 --- a/SDK/src/NDK/Components/CameraComponent.cpp +++ b/SDK/src/NDK/Components/CameraComponent.cpp @@ -9,6 +9,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::CameraComponent + * \brief NDK class that represents the component for camera + */ + + /*! + * \brief Applys the view of the camera + * + * \remark Produces a NazaraAssert if the camera has no target + */ + void CameraComponent::ApplyView() const { NazaraAssert(m_target, "CameraComponent has no target"); @@ -23,6 +35,12 @@ namespace Ndk Nz::Renderer::SetViewport(m_viewport); } + /*! + * \brief Gets the eye position of the camera + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + Nz::Vector3f CameraComponent::GetEyePosition() const { NazaraAssert(m_entity && m_entity->HasComponent(), "CameraComponent requires NodeComponent"); @@ -30,6 +48,12 @@ namespace Ndk return m_entity->GetComponent().GetPosition(); } + /*! + * \brief Gets the forward direction of the camera + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + Nz::Vector3f CameraComponent::GetForward() const { NazaraAssert(m_entity && m_entity->HasComponent(), "CameraComponent requires NodeComponent"); @@ -37,6 +61,12 @@ namespace Ndk return m_entity->GetComponent().GetForward(); } + /*! + * \brief Sets the layer of the camera in case of multiples fields + * + * \param layer Layer of the camera + */ + void CameraComponent::SetLayer(unsigned int layer) { m_layer = layer; @@ -44,6 +74,10 @@ namespace Ndk m_entity->Invalidate(); // Invalidate the entity to make it passes through RenderSystem validation } + /*! + * \brief Operation to perform when component is attached to an entity + */ + void CameraComponent::OnAttached() { if (m_entity->HasComponent()) @@ -52,6 +86,12 @@ namespace Ndk InvalidateViewMatrix(); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void CameraComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) @@ -63,6 +103,12 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void CameraComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) @@ -73,6 +119,10 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void CameraComponent::OnDetached() { m_nodeInvalidationSlot.Disconnect(); @@ -80,6 +130,12 @@ namespace Ndk InvalidateViewMatrix(); } + /*! + * \brief Operation to perform when the node is invalidated + * + * \param node Pointer to the node + */ + void CameraComponent::OnNodeInvalidated(const Nz::Node* node) { NazaraUnused(node); @@ -88,6 +144,12 @@ namespace Ndk InvalidateViewMatrix(); } + /*! + * \brief Operation to perform when the render target is released + * + * \param renderTarget Pointer to the RenderTarget + */ + void CameraComponent::OnRenderTargetRelease(const Nz::RenderTarget* renderTarget) { if (renderTarget == m_target) @@ -96,6 +158,12 @@ namespace Ndk NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget)); } + /*! + * \brief Operation to perform when the render target has its size changed + * + * \param renderTarget Pointer to the RenderTarget + */ + void CameraComponent::OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget) { if (renderTarget == m_target) @@ -104,6 +172,10 @@ namespace Ndk NazaraInternalError("Not listening to " + Nz::String::Pointer(renderTarget)); } + /*! + * \brief Updates the frustum of the camera + */ + void CameraComponent::UpdateFrustum() const { EnsureProjectionMatrixUpdate(); @@ -114,6 +186,10 @@ namespace Ndk m_frustumUpdated = true; } + /*! + * \brief Updates the project matrix of the camera + */ + void CameraComponent::UpdateProjectionMatrix() const { switch (m_projectionType) @@ -139,6 +215,12 @@ namespace Ndk m_projectionMatrixUpdated = true; } + /*! + * \brief Updates the view matrix of the camera + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + void CameraComponent::UpdateViewMatrix() const { NazaraAssert(m_entity && m_entity->HasComponent(), "CameraComponent requires NodeComponent"); @@ -150,6 +232,12 @@ namespace Ndk m_viewMatrixUpdated = true; } + /*! + * \brief Updates the view port of the camera + * + * \remark Produces a NazaraAssert if entity has no target + */ + void CameraComponent::UpdateViewport() const { NazaraAssert(m_target, "CameraComponent has no target"); diff --git a/SDK/src/NDK/Components/CollisionComponent.cpp b/SDK/src/NDK/Components/CollisionComponent.cpp index 49e8d8328..0f812e73b 100644 --- a/SDK/src/NDK/Components/CollisionComponent.cpp +++ b/SDK/src/NDK/Components/CollisionComponent.cpp @@ -11,13 +11,27 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::CollisionComponent + * \brief NDK class that represents the component for collision (meant for static objects) + */ + + /*! + * \brief Sets geometry for the entity + * + * \param geom Geometry used for collisions + * + * \remark Produces a NazaraAssert if the entity has no physics component and has no static body + */ + void CollisionComponent::SetGeom(Nz::PhysGeomRef geom) { m_geom = std::move(geom); if (m_entity->HasComponent()) { - // On met à jour la géométrie du PhysObject associé au PhysicsComponent + // We update the geometry of the PhysiscsObject linked to the PhysicsComponent PhysicsComponent& physComponent = m_entity->GetComponent(); physComponent.GetPhysObject().SetGeom(m_geom); } @@ -28,6 +42,13 @@ namespace Ndk } } + /*! + * \brief Initializes the static body + * + * \remark Produces a NazaraAssert if entity is invalid + * \remark Produces a NazaraAssert if entity is not linked to a world, or the world has no physics system + */ + void CollisionComponent::InitializeStaticBody() { NazaraAssert(m_entity, "Invalid entity"); @@ -41,24 +62,44 @@ namespace Ndk m_staticBody->EnableAutoSleep(false); } + /*! + * \brief Operation to perform when component is attached to an entity + */ + void CollisionComponent::OnAttached() { if (!m_entity->HasComponent()) InitializeStaticBody(); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void CollisionComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) m_staticBody.reset(); } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void CollisionComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) InitializeStaticBody(); } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void CollisionComponent::OnDetached() { m_staticBody.reset(); diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index 88ccd4ca1..759d3f24b 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -9,7 +9,23 @@ namespace Ndk { - void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index) + /*! + * \ingroup NDK + * \class Ndk::GraphicsComponent + * \brief NDK class that represents the component for graphics + */ + + /*! + * \brief Invalidates the data for renderable + * + * \param renderable Renderable to invalidate + * \param flags Flags for the instance + * \param index Index of the renderable to invalidate + * + * \remark Produces a NazaraAssert if index is out of bound + */ + + void GraphicsComponent::InvalidateRenderableData(const Nz::InstancedRenderable* renderable , Nz::UInt32 flags, std::size_t index) { NazaraAssert(index < m_renderables.size(), "Invalid renderable index"); NazaraUnused(renderable); @@ -19,6 +35,10 @@ namespace Ndk r.renderable->InvalidateData(&r.data, flags); } + /*! + * \brief Operation to perform when component is attached to an entity + */ + void GraphicsComponent::OnAttached() { if (m_entity->HasComponent()) @@ -27,6 +47,12 @@ namespace Ndk InvalidateTransformMatrix(); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + */ + void GraphicsComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) @@ -38,6 +64,12 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + */ + void GraphicsComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) @@ -48,6 +80,10 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void GraphicsComponent::OnDetached() { m_nodeInvalidationSlot.Disconnect(); @@ -55,6 +91,12 @@ namespace Ndk InvalidateTransformMatrix(); } + /*! + * \brief Operation to perform when the node is invalidated + * + * \param node Pointer to the node + */ + void GraphicsComponent::OnNodeInvalidated(const Nz::Node* node) { NazaraUnused(node); @@ -63,6 +105,10 @@ namespace Ndk InvalidateTransformMatrix(); } + /*! + * \brief Updates the bounding volume + */ + void GraphicsComponent::UpdateBoundingVolume() const { EnsureTransformMatrixUpdate(); @@ -75,6 +121,12 @@ namespace Ndk m_boundingVolumeUpdated = true; } + /*! + * \brief Updates the transform matrix of the renderable + * + * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent + */ + void GraphicsComponent::UpdateTransformMatrix() const { NazaraAssert(m_entity && m_entity->HasComponent(), "GraphicsComponent requires NodeComponent"); diff --git a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp index 2ae4365e6..e700b6497 100644 --- a/SDK/src/NDK/Components/ParticleEmitterComponent.cpp +++ b/SDK/src/NDK/Components/ParticleEmitterComponent.cpp @@ -7,6 +7,19 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ParticleEmitterComponent + * \brief NDK class that represents the component emitter of particles + */ + + /*! + * \brief Sets up the particles + * + * \param mapper Mapper containing layout information of each particle + * \param count Number of particles + */ + void ParticleEmitterComponent::SetupParticles(Nz::ParticleMapper& mapper, unsigned int count) const { if (m_isActive && m_setupFunc) diff --git a/SDK/src/NDK/Components/PhysicsComponent.cpp b/SDK/src/NDK/Components/PhysicsComponent.cpp index cc23c0954..6cfd1077d 100644 --- a/SDK/src/NDK/Components/PhysicsComponent.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent.cpp @@ -12,6 +12,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::PhysicsComponent + * \brief NDK class that represents the component for physics (meant for dynamic objects) + */ + + /*! + * \brief Operation to perform when component is attached to an entity + * + * \remark Produces a NazaraAssert if the world does not have a physics system + */ + void PhysicsComponent::OnAttached() { World* entityWorld = m_entity->GetWorld(); @@ -33,6 +45,14 @@ namespace Ndk m_object->SetMass(1.f); } + /*! + * \brief Operation to perform when component is attached to this component + * + * \param component Component being attached + * + * \remark Produces a NazaraAssert if physical object is invalid + */ + void PhysicsComponent::OnComponentAttached(BaseComponent& component) { if (IsComponent(component)) @@ -42,6 +62,14 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from this component + * + * \param component Component being detached + * + * \remark Produces a NazaraAssert if physical object is invalid + */ + void PhysicsComponent::OnComponentDetached(BaseComponent& component) { if (IsComponent(component)) @@ -51,6 +79,10 @@ namespace Ndk } } + /*! + * \brief Operation to perform when component is detached from an entity + */ + void PhysicsComponent::OnDetached() { m_object.reset(); diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index d157d7dbe..dd379cd4a 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -19,6 +19,20 @@ namespace Ndk constexpr std::size_t s_inputPrefixSize = Nz::CountOf(s_inputPrefix) - 1; } + /*! + * \ingroup NDK + * \class Ndk::Console + * \brief NDK class that represents a console to help development with Lua scripting + */ + + /*! + * \brief Constructs a Console object with a world to interact with + * + * \param world World to interact with + * \param size (Width, Height) of the console + * \param instance Lua instance that will interact with the world + */ + Console::Console(World& world, const Nz::Vector2f& size, Nz::LuaInstance& instance) : m_historyPosition(0), m_defaultFont(Nz::Font::GetDefault()), @@ -86,18 +100,35 @@ namespace Ndk Layout(); } + /*! + * \brief Adds a line to the console + * + * \param text New line of text + * \param color Color for the text + */ + void Console::AddLine(const Nz::String& text, const Nz::Color& color) { AddLineInternal(text, color); RefreshHistory(); } + /*! + * \brief Clears the console + */ + void Console::Clear() { m_historyLines.clear(); RefreshHistory(); } + /*! + * \brief Sends a character to the console + * + * \param character Character that will be added to the console + */ + void Console::SendCharacter(char32_t character) { switch (character) @@ -131,6 +162,12 @@ namespace Ndk m_inputTextSprite->Update(m_inputDrawer); } + /*! + * \brief Sends an event to the console + * + * \param event Event to be takin into consideration by the console + */ + void Console::SendEvent(Nz::WindowEvent event) { switch (event.type) @@ -170,6 +207,12 @@ namespace Ndk } } + /*! + * \brief Sets the character size + * + * \param size Size of the font + */ + void Console::SetCharacterSize(unsigned int size) { m_characterSize = size; @@ -182,6 +225,12 @@ namespace Ndk Layout(); } + /*! + * \brief Sets the console size + * + * \param size (Width, Height) of the console + */ + void Console::SetSize(const Nz::Vector2f& size) { m_size = size; @@ -189,6 +238,14 @@ namespace Ndk Layout(); } + /*! + * \brief Sets the text font + * + * \param font Reference to a valid font + * + * \remark Produces a NazaraAssert if font is invalid or null + */ + void Console::SetTextFont(Nz::FontRef font) { NazaraAssert(font && font->IsValid(), "Invalid font"); @@ -200,6 +257,12 @@ namespace Ndk Layout(); } + /*! + * \brief Shows the console + * + * \param show Should the console be showed + */ + void Console::Show(bool show) { if (m_opened != show) @@ -213,11 +276,22 @@ namespace Ndk } } + /*! + * \brief Adds a line to the history of the console + * + * \param text New line of text + * \param color Color for the text + */ + void Console::AddLineInternal(const Nz::String& text, const Nz::Color& color) { m_historyLines.emplace_back(Line{color, text}); } + /*! + * \brief Performs this action when an input is added to the console + */ + void Console::ExecuteInput() { Nz::String input = m_inputDrawer.GetText(); @@ -237,12 +311,18 @@ namespace Ndk RefreshHistory(); } + /*! + * \brief Places the console according to its layout + */ + void Console::Layout() { unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight; Ndk::NodeComponent& inputNode = m_input->GetComponent(); + NazaraError(inputNode.GetPosition().ToString()); inputNode.SetPosition(0.f, m_size.y - lineHeight - 5.f); + NazaraError(inputNode.GetPosition().ToString()); float historyHeight = m_size.y - lineHeight - 5.f - 2.f; m_historyBackgroundSprite->SetSize(m_size.x, historyHeight); @@ -250,14 +330,22 @@ namespace Ndk m_maxHistoryLines = static_cast(std::ceil(historyHeight / lineHeight)); Ndk::NodeComponent& historyNode = m_history->GetComponent(); + NazaraError(historyNode.GetPosition().ToString()); historyNode.SetPosition(0.f, historyHeight - m_maxHistoryLines * lineHeight); + NazaraError(historyNode.GetPosition().ToString()); Ndk::NodeComponent& inputBackgroundNode = m_inputBackground->GetComponent(); + NazaraError(inputBackgroundNode.GetPosition().ToString()); inputBackgroundNode.SetPosition(0.f, historyHeight + 2.f); + NazaraError(inputBackgroundNode.GetPosition().ToString()); m_inputBackgroundSprite->SetSize(m_size.x, m_size.y - historyHeight); } + /*! + * \brief Refreshes the history of the console + */ + void Console::RefreshHistory() { m_historyDrawer.Clear(); diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index ecd74ebc0..815d0dc1b 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -8,6 +8,18 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Entity + * \brief NDK class that represents an entity in a world + */ + + /*! + * \brief Constructs a Entity object by move semantic + * + * \param entity Entity to move into this + */ + Entity::Entity(Entity&& entity) : HandledObject(std::move(entity)), m_components(std::move(entity.m_components)), @@ -20,35 +32,57 @@ namespace Ndk { } + /*! + * \brief Constructs a Entity object linked to a world and with an id + * + * \param world World in which the entity interact + * \param id Identifier of the entity + */ + Entity::Entity(World* world, EntityId id) : m_id(id), m_world(world) { } + /*! + * \brief Destructs the object and calls Destroy + * + * \see Destroy + */ + Entity::~Entity() { Destroy(); } + /*! + * \brief Adds a component to the entity + * \return A reference to the newly added component + * + * \param componentPtr Component to add to the entity + * + * \remark Produces a NazaraAssert if component is nullptr + */ + BaseComponent& Entity::AddComponent(std::unique_ptr&& componentPtr) { NazaraAssert(componentPtr, "Component must be valid"); ComponentIndex index = componentPtr->GetIndex(); - // Nous nous assurons que le vecteur de component est suffisamment grand pour contenir le nouveau component + // We ensure that the vector has enough space if (index >= m_components.size()) m_components.resize(index + 1); - // Affectation et retour du component + // Affectation and return of the component m_components[index] = std::move(componentPtr); m_componentBits.UnboundedSet(index); m_removedComponentBits.UnboundedReset(index); Invalidate(); - // On récupère le component et on informe les composants existants du nouvel arrivant + // We get the new component and we alert other existing components of the new one BaseComponent& component = *m_components[index].get(); component.SetEntity(this); @@ -61,34 +95,57 @@ namespace Ndk return component; } + /*! + * \brief Clones the entity + * \return The clone newly created + * + * \remark The close is enable by default, even if the original is disabled + * \remark Produces a NazaraAssert if the entity is not valid + */ + const EntityHandle& Entity::Clone() const { - ///DOC: The clone is enabled by default, even if the original entity is disabled NazaraAssert(IsValid(), "Invalid entity"); return m_world->CloneEntity(m_id); } + /*! + * \brief Kills the entity + */ + void Entity::Kill() { m_world->KillEntity(this); } + /*! + * \brief Invalidates the entity + */ + void Entity::Invalidate() { - // On informe le monde que nous avons besoin d'une mise à jour + // We alert everyone that we have been updated m_world->Invalidate(m_id); } + /*! + * \brief Creates the entity + */ + void Entity::Create() { m_enabled = true; m_valid = true; } + /*! + * \brief Destroys the entity + */ + void Entity::Destroy() { - // On informe chaque système + // We alert each system for (std::size_t index = m_systemBits.FindFirst(); index != m_systemBits.npos; index = m_systemBits.FindNext(index)) { if (m_world->HasSystem(index)) @@ -104,12 +161,19 @@ namespace Ndk m_valid = false; } + /*! + * \brief Destroys a component by index + * + * \param index Index of the component + * + * \remark If component is not available, no action is performed + */ + void Entity::DestroyComponent(ComponentIndex index) { - ///DOC: N'a aucun effet si le component n'est pas présent if (HasComponent(index)) { - // On récupère le component et on informe les composants du détachement + // We get the component and we alert existing components of the deleted one BaseComponent& component = *m_components[index].get(); for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i)) { diff --git a/SDK/src/NDK/LuaAPI.cpp b/SDK/src/NDK/LuaAPI.cpp index a1b84bf5d..1bf4eec35 100644 --- a/SDK/src/NDK/LuaAPI.cpp +++ b/SDK/src/NDK/LuaAPI.cpp @@ -5,12 +5,29 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::LuaAPI + * \brief NDK class that represents the api used for Lua + */ + + /*! + * \brief Initializes the LuaAPI module + * \return true if initialization is successful + */ + bool LuaAPI::Initialize() { s_binding = new LuaBinding; return true; } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the engine & SDK + */ + void LuaAPI::RegisterClasses(Nz::LuaInstance& instance) { if (!s_binding && !Initialize()) @@ -22,6 +39,10 @@ namespace Ndk s_binding->RegisterClasses(instance); } + /*! + * \brief Uninitializes the LuaAPI module + */ + void LuaAPI::Uninitialize() { delete s_binding; diff --git a/SDK/src/NDK/LuaBinding.cpp b/SDK/src/NDK/LuaBinding.cpp index 6acc05a46..822654a39 100644 --- a/SDK/src/NDK/LuaBinding.cpp +++ b/SDK/src/NDK/LuaBinding.cpp @@ -4,6 +4,16 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::LuaBinding + * \brief NDK class that represents the binding between the engine & the SDK with the Lua scripting + */ + + /*! + * \brief Binds modules to Lua + */ + LuaBinding::LuaBinding() : // Core clockClass("Clock"), @@ -65,6 +75,12 @@ namespace Ndk #endif } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the engine & SDK + */ + void LuaBinding::RegisterClasses(Nz::LuaInstance& instance) { RegisterCore(instance); diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index 89452d720..b825b1876 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Audio module to Lua + */ + void LuaBinding::BindAudio() { /*********************************** Nz::Music **********************************/ @@ -164,6 +168,12 @@ namespace Ndk soundEmitter.BindMethod("Stop", &Nz::SoundEmitter::Stop); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Audio classes + */ + void LuaBinding::RegisterAudio(Nz::LuaInstance& instance) { musicClass.Register(instance); diff --git a/SDK/src/NDK/LuaBinding_Core.cpp b/SDK/src/NDK/LuaBinding_Core.cpp index 09cbda604..78c73eea1 100644 --- a/SDK/src/NDK/LuaBinding_Core.cpp +++ b/SDK/src/NDK/LuaBinding_Core.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Core module to Lua + */ + void LuaBinding::BindCore() { /*********************************** Nz::Clock **********************************/ @@ -254,6 +258,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Core classes + */ + void LuaBinding::RegisterCore(Nz::LuaInstance& instance) { // Classes diff --git a/SDK/src/NDK/LuaBinding_Graphics.cpp b/SDK/src/NDK/LuaBinding_Graphics.cpp index 289002746..4c9288428 100644 --- a/SDK/src/NDK/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/LuaBinding_Graphics.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Graphics module to Lua + */ + void LuaBinding::BindGraphics() { /*********************************** Nz::InstancedRenderable ***********************************/ @@ -40,6 +44,12 @@ namespace Ndk modelClass.BindMethod("SetSkinCount", &Nz::Model::SetSkinCount); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Graphics classes + */ + void LuaBinding::RegisterGraphics(Nz::LuaInstance& instance) { instancedRenderable.Register(instance); diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index c1d7b487e..1c53caa69 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -7,6 +7,10 @@ namespace Ndk { + /*! + * \brief Binds Math module to Lua + */ + void LuaBinding::BindMath() { /*********************************** Nz::EulerAngles **********************************/ @@ -673,6 +677,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Math classes + */ + void LuaBinding::RegisterMath(Nz::LuaInstance& instance) { eulerAnglesClass.Register(instance); diff --git a/SDK/src/NDK/LuaBinding_Network.cpp b/SDK/src/NDK/LuaBinding_Network.cpp index dc17c5d00..67f40cb4d 100644 --- a/SDK/src/NDK/LuaBinding_Network.cpp +++ b/SDK/src/NDK/LuaBinding_Network.cpp @@ -5,6 +5,10 @@ namespace Ndk { + /*! + * \brief Binds Network module to Lua + */ + void LuaBinding::BindNetwork() { /*********************************** Nz::AbstractSocket **********************************/ @@ -132,6 +136,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Network classes + */ + void LuaBinding::RegisterNetwork(Nz::LuaInstance& instance) { // Classes diff --git a/SDK/src/NDK/LuaBinding_Renderer.cpp b/SDK/src/NDK/LuaBinding_Renderer.cpp index 78b9fe561..79f1780a3 100644 --- a/SDK/src/NDK/LuaBinding_Renderer.cpp +++ b/SDK/src/NDK/LuaBinding_Renderer.cpp @@ -7,10 +7,20 @@ namespace Ndk { + /*! + * \brief Binds Renderer module to Lua + */ + void LuaBinding::BindRenderer() { } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Renderer classes + */ + void LuaBinding::RegisterRenderer(Nz::LuaInstance& instance) { } diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index b371e76e3..5b6ad7dc9 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -7,6 +7,10 @@ namespace Ndk { + /*! + * \brief Binds SDK module to Lua + */ + void LuaBinding::BindSDK() { /*********************************** Ndk::Application **********************************/ @@ -143,6 +147,12 @@ namespace Ndk #endif } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the SDK classes + */ + void LuaBinding::RegisterSDK(Nz::LuaInstance& instance) { // Classes @@ -173,6 +183,14 @@ namespace Ndk instance.SetGlobal("ComponentType"); } + /*! + * \brief Gets the index of the component + * \return A pointer to the binding linked to a component + * + * \param instance Lua instance that will interact with the component + * \param argIndex Index of the component + */ + LuaBinding::ComponentBinding* LuaBinding::QueryComponentIndex(Nz::LuaInstance& instance, int argIndex) { switch (instance.GetType(argIndex)) diff --git a/SDK/src/NDK/LuaBinding_Utility.cpp b/SDK/src/NDK/LuaBinding_Utility.cpp index 4ccb18fa6..416662b23 100644 --- a/SDK/src/NDK/LuaBinding_Utility.cpp +++ b/SDK/src/NDK/LuaBinding_Utility.cpp @@ -6,6 +6,10 @@ namespace Ndk { + /*! + * \brief Binds Utility module to Lua + */ + void LuaBinding::BindUtility() { /*********************************** Nz::AbstractImage **********************************/ @@ -308,6 +312,12 @@ namespace Ndk }); } + /*! + * \brief Registers the classes that will be used by the Lua instance + * + * \param instance Lua instance that will interact with the Utility classes + */ + void LuaBinding::RegisterUtility(Nz::LuaInstance& instance) { abstractImage.Register(instance); diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index 964913bf8..bd3bf33e4 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -34,6 +34,19 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::Sdk + * \brief NDK class that represents the software development kit, a set of tools made to ease the conception of application + */ + + /*! + * \brief Initializes the Sdk module + * \return true if initialization is successful + * + * \remark Produces a NazaraNotice + */ + bool Sdk::Initialize() { if (s_referenceCounter++ > 0) @@ -104,6 +117,12 @@ namespace Ndk } } + /*! + * \brief Uninitializes the Sdk module + * + * \remark Produces a NazaraNotice + */ + void Sdk::Uninitialize() { if (s_referenceCounter != 1) diff --git a/SDK/src/NDK/State.cpp b/SDK/src/NDK/State.cpp index e256a7f1c..701b98565 100644 --- a/SDK/src/NDK/State.cpp +++ b/SDK/src/NDK/State.cpp @@ -6,5 +6,11 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::State + * \brief NDK class that represents a state of your application + */ + State::~State() = default; } diff --git a/SDK/src/NDK/Systems/ListenerSystem.cpp b/SDK/src/NDK/Systems/ListenerSystem.cpp index 28fce2e0a..9c7333d34 100644 --- a/SDK/src/NDK/Systems/ListenerSystem.cpp +++ b/SDK/src/NDK/Systems/ListenerSystem.cpp @@ -10,11 +10,29 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ListenerSystem + * \brief NDK class that represents the audio system + * + * \remark This system is enabled if the entity owns the trait: ListenerComponent and NodeComponent + */ + + /*! + * \brief Constructs an ListenerSystem object by default + */ + ListenerSystem::ListenerSystem() { Requires(); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void ListenerSystem::OnUpdate(float elapsedTime) { NazaraUnused(elapsedTime); @@ -23,18 +41,18 @@ namespace Ndk for (const Ndk::EntityHandle& entity : GetEntities()) { - // Le listener est-il actif ? + // Is the listener actif ? const ListenerComponent& listener = entity->GetComponent(); if (!listener.IsActive()) continue; - // On récupère la position et la rotation pour les affecter au listener + // We get the position and the rotation to affect these to the listener const NodeComponent& node = entity->GetComponent(); Nz::Audio::SetListenerPosition(node.GetPosition(Nz::CoordSys_Global)); Nz::Audio::SetListenerRotation(node.GetRotation(Nz::CoordSys_Global)); - // On vérifie la présence d'une donnée de vitesse, et on l'affecte - // (La vitesse du listener Audio ne le fait pas se déplacer, mais affecte par exemple l'effet Doppler) + // We verify the presence of a component of velocity + // (The listener'speed does not move it, but disturbs the sound like Doppler effect) if (entity->HasComponent()) { const VelocityComponent& velocity = entity->GetComponent(); diff --git a/SDK/src/NDK/Systems/ParticleSystem.cpp b/SDK/src/NDK/Systems/ParticleSystem.cpp index a9f63cb6c..9321c0ec2 100644 --- a/SDK/src/NDK/Systems/ParticleSystem.cpp +++ b/SDK/src/NDK/Systems/ParticleSystem.cpp @@ -7,11 +7,29 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::ParticleSystem + * \brief NDK class that represents the particle system + * + * \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: ParticleGroupComponent + */ + + /*! + * \brief Constructs an ParticleSystem object by default + */ + ParticleSystem::ParticleSystem() { Requires(); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void ParticleSystem::OnUpdate(float elapsedTime) { for (const Ndk::EntityHandle& entity : GetEntities()) diff --git a/SDK/src/NDK/Systems/PhysicsSystem.cpp b/SDK/src/NDK/Systems/PhysicsSystem.cpp index 3d429a686..442784c22 100644 --- a/SDK/src/NDK/Systems/PhysicsSystem.cpp +++ b/SDK/src/NDK/Systems/PhysicsSystem.cpp @@ -10,24 +10,50 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::PhysicsSystem + * \brief NDK class that represents the physics system + * + * \remark This system is enabled if the entity has the trait: NodeComponent and any of these two: CollisionComponent or PhysicsComponent + * \remark Static objects do not have a velocity specified by the physical engine + */ + + /*! + * \brief Constructs an PhysicsSystem object by default + */ + PhysicsSystem::PhysicsSystem() { Requires(); RequiresAny(); } + /*! + * \brief Constructs a PhysicsSystem object by copy semantic + * + * \param system PhysicsSystem to copy + */ + PhysicsSystem::PhysicsSystem(const PhysicsSystem& system) : System(system), m_world() { } + /*! + * \brief Operation to perform when entity is validated for the system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + */ + void PhysicsSystem::OnEntityValidation(Entity* entity, bool justAdded) { - // Si l'entité ne vient pas d'être ajoutée au système, il est possible qu'elle fasse partie du mauvais tableau + // If entity has not been just added to the system, it is possible that it does not own to the right array if (!justAdded) { - // On prend le tableau inverse de celui dont l'entité devrait faire partie + // We take the inverted array from which the entity should belong to auto& entities = (entity->HasComponent()) ? m_staticObjects : m_dynamicObjects; entities.Remove(entity); } @@ -36,6 +62,12 @@ namespace Ndk entities.Insert(entity); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void PhysicsSystem::OnUpdate(float elapsedTime) { m_world.Step(elapsedTime); @@ -63,8 +95,8 @@ namespace Ndk Nz::Quaternionf newRotation = node.GetRotation(Nz::CoordSys_Global); Nz::Vector3f newPosition = node.GetPosition(Nz::CoordSys_Global); - // Pour déplacer des objets statiques et assurer les collisions, il faut leur définir une vitesse - // (note importante: le moteur physique n'applique pas la vitesse sur les objets statiques) + // To move static objects and ensure their collisions, we have to specify them a velocity + // (/!\: the physical motor does not apply the speed on static objects) if (newPosition != oldPosition) { physObj->SetPosition(newPosition); diff --git a/SDK/src/NDK/Systems/RenderSystem.cpp b/SDK/src/NDK/Systems/RenderSystem.cpp index fcfd5c6a5..107676206 100644 --- a/SDK/src/NDK/Systems/RenderSystem.cpp +++ b/SDK/src/NDK/Systems/RenderSystem.cpp @@ -14,6 +14,21 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::RenderSystem + * \brief NDK class that represents the rendering system + * + * \remark This system is enabled if the entity is a 'camera' with the trait: CameraComponent and NodeComponent + * or a drawable element with trait: GraphicsComponent and NodeComponent + * or a light element with trait: LightComponent and NodeComponent + * or a set of particles with trait: ParticleGroupComponent + */ + + /*! + * \brief Constructs an RenderSystem object by default + */ + RenderSystem::RenderSystem() : m_coordinateSystemMatrix(Nz::Matrix4f::Identity()), m_coordinateSystemInvalidated(true) @@ -23,6 +38,12 @@ namespace Ndk SetUpdateRate(0.f); } + /*! + * \brief Operation to perform when an entity is removed + * + * \param entity Pointer to the entity + */ + void RenderSystem::OnEntityRemoved(Entity* entity) { m_cameras.Remove(entity); @@ -33,6 +54,13 @@ namespace Ndk m_pointSpotLights.Remove(entity); } + /*! + * \brief Operation to perform when entity is validated for the system + * + * \param entity Pointer to the entity + * \param justAdded Is the entity newly added + */ + void RenderSystem::OnEntityValidation(Entity* entity, bool justAdded) { NazaraUnused(justAdded); @@ -82,6 +110,12 @@ namespace Ndk m_particleGroups.Remove(entity); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void RenderSystem::OnUpdate(float elapsedTime) { NazaraUnused(elapsedTime); @@ -146,6 +180,12 @@ namespace Ndk } } + /*! + * \brief Updates the directional shadow maps according to the position of the viewer + * + * \param viewer Viewer of the scene + */ + void RenderSystem::UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer) { if (!m_shadowRT.IsValid()) @@ -191,6 +231,10 @@ namespace Ndk } } + /*! + * \brief Updates the point spot shadow maps + */ + void RenderSystem::UpdatePointSpotShadowMaps() { if (!m_shadowRT.IsValid()) diff --git a/SDK/src/NDK/Systems/VelocitySystem.cpp b/SDK/src/NDK/Systems/VelocitySystem.cpp index 2d3264039..e8cfe2f23 100644 --- a/SDK/src/NDK/Systems/VelocitySystem.cpp +++ b/SDK/src/NDK/Systems/VelocitySystem.cpp @@ -9,12 +9,31 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::VelocitySystem + * \brief NDK class that represents the velocity system + * + * \remark This system is enabled if the entity owns the trait: NodeComponent and VelocityComponent + * but it's disabled with the trait: PhysicsComponent + */ + + /*! + * \brief Constructs an VelocitySystem object by default + */ + VelocitySystem::VelocitySystem() { Requires(); Excludes(); } + /*! + * \brief Operation to perform when system is updated + * + * \param elapsedTime Delta time used for the update + */ + void VelocitySystem::OnUpdate(float elapsedTime) { for (const Ndk::EntityHandle& entity : GetEntities()) diff --git a/SDK/src/NDK/World.cpp b/SDK/src/NDK/World.cpp index 8e5ff99f0..938722feb 100644 --- a/SDK/src/NDK/World.cpp +++ b/SDK/src/NDK/World.cpp @@ -16,12 +16,28 @@ namespace Ndk { + /*! + * \ingroup NDK + * \class Ndk::World + * \brief NDK class that represents a world + */ + + /*! + * \brief Destructs the object and calls Clear + * + * \see Clear + */ + World::~World() noexcept { - // La destruction doit se faire dans un ordre précis + // The destruct must be done in an ordered way Clear(); } + /*! + * \brief Adds default systems to the world + */ + void World::AddDefaultSystems() { AddSystem(); @@ -34,40 +50,49 @@ namespace Ndk #endif } + /*! + * \brief Creates an entity in the world + * \return The entity created + */ + const EntityHandle& World::CreateEntity() { EntityId id; if (!m_freeIdList.empty()) { - // On récupère un identifiant + // We get an identifier id = m_freeIdList.back(); m_freeIdList.pop_back(); } else { - // On alloue une nouvelle entité + // We allocate a new entity id = m_entities.size(); - // Impossible d'utiliser emplace_back à cause de la portée + // We can't use emplace_back due to the scope m_entities.push_back(Entity(this, id)); } - // On initialise l'entité et on l'ajoute à la liste des entités vivantes + // We initialise the entity and we add it to the list of alive entities Entity& entity = m_entities[id].entity; entity.Create(); m_aliveEntities.emplace_back(&entity); - m_entities[id].aliveIndex = m_aliveEntities.size()-1; + m_entities[id].aliveIndex = m_aliveEntities.size() - 1; return m_aliveEntities.back(); } + /*! + * \brief Clears the world from every entities + * + * \remark Every handles are correctly invalidated, entities are immediately invalidated + */ + void World::Clear() noexcept { - ///DOC: Tous les handles sont correctement invalidés, les entités sont immédiatement invalidées - - // Destruction des entités d'abord, et des handles ensuite - // ceci pour éviter que les handles n'informent les entités inutilement lors de leur destruction + // First, destruction of entities, then handles + // This is made to avoid that handle warn uselessly entities before their destruction m_entities.clear(); m_aliveEntities.clear(); @@ -75,6 +100,15 @@ namespace Ndk m_killedEntities.Clear(); } + /*! + * \brief Clones the entity + * \return The clone newly created + * + * \param id Identifier of the entity + * + * \remark Produces a NazaraError if the entity to clone does not exist + */ + const EntityHandle& World::CloneEntity(EntityId id) { EntityHandle original = GetEntity(id); @@ -96,14 +130,29 @@ namespace Ndk return GetEntity(clone->GetId()); } + /*! + * \brief Kills an entity + * + * \param Pointer to the entity + * + * \remark No change is done if entity is invalid + */ + void World::KillEntity(Entity* entity) { - ///DOC: Ignoré si l'entité est invalide - if (IsEntityValid(entity)) m_killedEntities.UnboundedSet(entity->GetId(), true); } + /*! + * \brief Gets an entity + * \return A constant reference to the modified entity + * + * \param id Identifier of the entity + * + * \remark Produces a NazaraError if entity identifier is not valid + */ + const EntityHandle& World::GetEntity(EntityId id) { if (IsEntityIdValid(id)) @@ -115,9 +164,15 @@ namespace Ndk } } + /*! + * \brief Updates the world + * + * \remark Produces a NazaraAssert if an entity is invalid + */ + void World::Update() { - // Gestion des entités tuées depuis le dernier appel + // Handle killed entities before last call for (std::size_t i = m_killedEntities.FindFirst(); i != m_killedEntities.npos; i = m_killedEntities.FindNext(i)) { EntityBlock& block = m_entities[i]; @@ -125,32 +180,32 @@ namespace Ndk NazaraAssert(entity.IsValid(), "Entity must be valid"); - // Remise en file d'attente de l'identifiant d'entité + // Send back the identifier of the entity to the free queue m_freeIdList.push_back(entity.GetId()); - // Destruction de l'entité (invalidation du handle par la même occasion) + // Destruction of the entity (invalidation of handle by the same way) entity.Destroy(); - // Nous allons sortir le handle de la liste des entités vivantes - // en swappant le handle avec le dernier handle, avant de pop + // We take out the handle from the list of alive entities + // With the idiom swap and pop NazaraAssert(block.aliveIndex < m_aliveEntities.size(), "Alive index out of range"); - if (block.aliveIndex < m_aliveEntities.size()-1) // S'il ne s'agit pas du dernier handle + if (block.aliveIndex < m_aliveEntities.size() - 1) // If it's not the last handle { EntityHandle& lastHandle = m_aliveEntities.back(); EntityHandle& myHandle = m_aliveEntities[block.aliveIndex]; myHandle = std::move(lastHandle); - // On n'oublie pas de corriger l'indice associé à l'entité + // We don't forget to update the index associated to the entity m_entities[myHandle->GetId()].aliveIndex = block.aliveIndex; } m_aliveEntities.pop_back(); } m_killedEntities.Reset(); - // Gestion des entités nécessitant une mise à jour de leurs systèmes + // Handle of entities which need an update from the systems for (std::size_t i = m_dirtyEntities.FindFirst(); i != m_dirtyEntities.npos; i = m_dirtyEntities.FindNext(i)) { NazaraAssert(i < m_entities.size(), "Entity index out of range"); diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index 0d3dcc7d2..b423b390f 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -14,17 +14,10 @@ TOOL.Includes = { TOOL.Files = { "../tests/main.cpp", - "../tests/Engine/**.cpp" + "../tests/Engine/**.cpp", + "../tests/SDK/**.cpp" } TOOL.Libraries = { - "NazaraCore", - "NazaraAudio", - "NazaraLua", - "NazaraGraphics", - "NazaraRenderer", - "NazaraNetwork", - "NazaraNoise", - "NazaraPhysics", - "NazaraUtility" + "NazaraSDK" } diff --git a/tests/SDK/NDK/Application.cpp b/tests/SDK/NDK/Application.cpp new file mode 100644 index 000000000..994bd022b --- /dev/null +++ b/tests/SDK/NDK/Application.cpp @@ -0,0 +1,22 @@ +#include +#include + +SCENARIO("Application", "[NDK][APPLICATION]") +{ + GIVEN("An application") + { + Ndk::Application application; + application.AddWorld(); + Nz::Window& window = application.AddWindow(); + + WHEN("We close the open window") + { + window.Close(); + + THEN("Application should close") + { + REQUIRE(!application.Run()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/BaseSystem.cpp b/tests/SDK/NDK/BaseSystem.cpp new file mode 100644 index 000000000..e4ca2e1c9 --- /dev/null +++ b/tests/SDK/NDK/BaseSystem.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include + +namespace +{ + class TestSystem : public Ndk::System + { + public: + TestSystem() + { + Requires(); + Excludes(); + } + + ~TestSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + } + }; + + Ndk::SystemIndex TestSystem::systemIndex; +} + +SCENARIO("BaseSystem", "[NDK][BASESYSTEM]") +{ + GIVEN("Our TestSystem") + { + Ndk::World world; + Ndk::BaseSystem& system = world.AddSystem(); + REQUIRE(&system.GetWorld() == &world); + + WHEN("We add an entity") + { + const Ndk::EntityHandle& entity = world.CreateEntity(); + entity->AddComponent(); + + THEN("System should have it") + { + world.Update(1.f); + REQUIRE(system.HasEntity(entity)); + } + } + + WHEN("We add an entity with excluded component") + { + const Ndk::EntityHandle& entity = world.CreateEntity(); + entity->AddComponent(); + entity->AddComponent(); + + THEN("System should not have it") + { + world.Update(1.f); + REQUIRE(!system.HasEntity(entity)); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Component.cpp b/tests/SDK/NDK/Component.cpp new file mode 100644 index 000000000..f00bb9006 --- /dev/null +++ b/tests/SDK/NDK/Component.cpp @@ -0,0 +1,31 @@ +#include +#include + +namespace +{ + class TestComponent : public Ndk::Component + { + public: + static Ndk::ComponentIndex componentIndex; + }; + + Ndk::ComponentIndex TestComponent::componentIndex; +} + +SCENARIO("Component", "[NDK][COMPONENT]") +{ + GIVEN("Our TestComponent") + { + TestComponent testComponent; + + WHEN("We clone it") + { + std::unique_ptr clone = testComponent.Clone(); + + THEN("We should get a copy") + { + REQUIRE(dynamic_cast(clone.get()) != nullptr); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Entity.cpp b/tests/SDK/NDK/Entity.cpp new file mode 100644 index 000000000..d784e28ad --- /dev/null +++ b/tests/SDK/NDK/Entity.cpp @@ -0,0 +1,101 @@ +#include +#include +#include + +namespace +{ + class UpdatableComponent : public Ndk::Component + { + public: + bool IsUpdated() + { + return m_updated; + } + + void SetUpdated() + { + m_updated = true; + } + + static Ndk::ComponentIndex componentIndex; + + private: + bool m_updated = false; + }; + + Ndk::ComponentIndex UpdatableComponent::componentIndex; + + class UpdateSystem : public Ndk::System + { + public: + UpdateSystem() + { + Requires(); + } + + ~UpdateSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + for (const Ndk::EntityHandle& entity : GetEntities()) + { + UpdatableComponent& updatable = entity->GetComponent(); + updatable.SetUpdated(); + } + } + }; + + Ndk::SystemIndex UpdateSystem::systemIndex; +} + +SCENARIO("Entity", "[NDK][ENTITY]") +{ + GIVEN("A world & an entity") + { + Ndk::World world; + Ndk::BaseSystem& system = world.AddSystem(); + const Ndk::EntityHandle& entity = world.CreateEntity(); + + WHEN("We add our UpdateComponent") + { + UpdatableComponent& updatableComponent = entity->AddComponent(); + REQUIRE(!updatableComponent.IsUpdated()); + + THEN("Update the world should update the entity's component") + { + world.Update(1.f); + UpdatableComponent& updatableComponentGet = entity->GetComponent(); + REQUIRE(updatableComponentGet.IsUpdated()); + } + + THEN("Update the world should not update the entity's component if it's disabled") + { + entity->Enable(false); + world.Update(1.f); + UpdatableComponent& updatableComponentGet = entity->GetComponent(); + REQUIRE(!updatableComponentGet.IsUpdated()); + } + + THEN("We can remove its component") + { + entity->RemoveComponent(Ndk::GetComponentIndex()); + world.Update(1.f); + REQUIRE(!entity->HasComponent()); + } + } + + WHEN("We kill our entity") + { + entity->Kill(); + world.Update(1.f); + + THEN("It's no more valid") + { + REQUIRE(!world.IsEntityValid(entity)); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/EntityList.cpp b/tests/SDK/NDK/EntityList.cpp new file mode 100644 index 000000000..4b76766d5 --- /dev/null +++ b/tests/SDK/NDK/EntityList.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +SCENARIO("EntityList", "[NDK][ENTITYLIST]") +{ + GIVEN("A world & a set of entities") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::EntityList entityList; + entityList.Insert(entity); + + WHEN("We ask if entity is in there") + { + THEN("These results are expected") + { + REQUIRE(entityList.Has(entity->GetId())); + const Ndk::EntityHandle& entity = world.CreateEntity(); + REQUIRE(!entityList.Has(entity->GetId())); + } + } + + WHEN("We remove then insert") + { + entityList.Remove(*entityList.begin()); + + THEN("Set should be empty") + { + REQUIRE(entityList.empty()); + } + + entityList.Insert(entity); + + THEN("With one element") + { + REQUIRE(!entityList.empty()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/EntityOwner.cpp b/tests/SDK/NDK/EntityOwner.cpp new file mode 100644 index 000000000..eb9a29edf --- /dev/null +++ b/tests/SDK/NDK/EntityOwner.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]") +{ + GIVEN("A world & an entity") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + + WHEN("We set the ownership of the entity to our owner") + { + Ndk::EntityOwner entityOwner(entity); + + THEN("Entity is still valid") + { + REQUIRE(entity.IsValid()); + } + + THEN("Resetting or getting out of scope is no more valid") + { + entityOwner.Reset(); + world.Update(1.f); + REQUIRE(!entity.IsValid()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/StateMachine.cpp b/tests/SDK/NDK/StateMachine.cpp new file mode 100644 index 000000000..604aa6f9f --- /dev/null +++ b/tests/SDK/NDK/StateMachine.cpp @@ -0,0 +1,48 @@ +#include +#include + +class TestState : public Ndk::State +{ + public: + void Enter(Ndk::StateMachine& fsm) override + { + m_isUpdated = false; + } + + bool IsUpdated() const + { + return m_isUpdated; + } + + void Leave(Ndk::StateMachine& fsm) override + { + } + + bool Update(Ndk::StateMachine& fsm, float elapsedTime) override + { + m_isUpdated = true; + } + + private: + bool m_isUpdated; +}; + +SCENARIO("State & StateMachine", "[NDK][STATE]") +{ + GIVEN("A statemachine with our TestState") + { + std::shared_ptr testState = std::make_shared(); + Ndk::StateMachine stateMachine(testState); + REQUIRE(!testState->IsUpdated()); + + WHEN("We update our machine") + { + stateMachine.Update(1.f); + + THEN("Our state has been updated") + { + REQUIRE(testState->IsUpdated()); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/System.cpp b/tests/SDK/NDK/System.cpp new file mode 100644 index 000000000..ca1917124 --- /dev/null +++ b/tests/SDK/NDK/System.cpp @@ -0,0 +1,42 @@ +#include +#include + +namespace +{ + class TestSystem : public Ndk::System + { + public: + TestSystem() + { + } + + ~TestSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + } + }; + + Ndk::SystemIndex TestSystem::systemIndex; +} + +SCENARIO("System", "[NDK][SYSTEM]") +{ + GIVEN("Our TestSystem") + { + TestSystem testSystem; + + WHEN("We clone it") + { + std::unique_ptr clone = testSystem.Clone(); + + THEN("We should get a copy") + { + REQUIRE(dynamic_cast(clone.get()) != nullptr); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/ListenerSystem.cpp b/tests/SDK/NDK/Systems/ListenerSystem.cpp new file mode 100644 index 000000000..2792dbc25 --- /dev/null +++ b/tests/SDK/NDK/Systems/ListenerSystem.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include + +SCENARIO("ListenerSystem", "[NDK][LISTENERSYSTEM]") +{ + GIVEN("A world and an entity with listener & node components") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::ListenerComponent& listenerComponent = entity->AddComponent(); + Ndk::NodeComponent& nodeComponent = entity->AddComponent(); + + WHEN("We move our entity") + { + Nz::Vector3f position = Nz::Vector3f::Unit() * 3.f; + nodeComponent.SetPosition(position); + Nz::Quaternionf rotation = Nz::Quaternionf::RotationBetween(Nz::Vector3f::Forward(), Nz::Vector3f::Up()); + nodeComponent.SetRotation(rotation); + world.Update(1.f); + + THEN("Our listener should have moved") + { + REQUIRE(Nz::Audio::GetListenerPosition() == position); + REQUIRE(Nz::Audio::GetListenerRotation() == rotation); + } + + THEN("With a component of velocity") + { + Ndk::VelocityComponent& velocityComponent = entity->AddComponent(); + Nz::Vector3f velocity = Nz::Vector3f::Unit() * 2.f; + velocityComponent.linearVelocity = velocity; + + world.Update(1.f); + REQUIRE(Nz::Audio::GetListenerVelocity() == velocity); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/PhysicsSystem.cpp b/tests/SDK/NDK/Systems/PhysicsSystem.cpp new file mode 100644 index 000000000..2aa3c313e --- /dev/null +++ b/tests/SDK/NDK/Systems/PhysicsSystem.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include + +SCENARIO("PhysicsSystem", "[NDK][PHYSICSSYSTEM]") +{ + GIVEN("A world and a static entity & a dynamic entity") + { + Ndk::World world; + const Ndk::EntityHandle& staticEntity = world.CreateEntity(); + Ndk::CollisionComponent& collisionComponentStatic = staticEntity->AddComponent(); + Ndk::NodeComponent& nodeComponentStatic = staticEntity->AddComponent(); + + const Ndk::EntityHandle& dynamicEntity = world.CreateEntity(); + Ndk::NodeComponent& nodeComponentDynamic = dynamicEntity->AddComponent(); + Ndk::PhysicsComponent& physicsComponentDynamic = dynamicEntity->AddComponent(); + + WHEN("We make collide these two entities") + { + nodeComponentDynamic.SetPosition(-Nz::Vector3f::UnitZ()); + physicsComponentDynamic.AddForce(Nz::Vector3f::UnitZ()); + + THEN("The dynamic entity should have hit the static one") + { + world.Update(1.f); // On origin + world.Update(1.f); // On origin due to collision + REQUIRE(nodeComponentStatic.GetPosition().SquaredDistance(nodeComponentDynamic.GetPosition()) < 0.2f); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/RenderSystem.cpp b/tests/SDK/NDK/Systems/RenderSystem.cpp new file mode 100644 index 000000000..f106b3aae --- /dev/null +++ b/tests/SDK/NDK/Systems/RenderSystem.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +SCENARIO("RenderSystem", "[NDK][RenderSystem]") +{ + GIVEN("A world with a camera, a drawable, a light and some particles") + { + Ndk::World world; + const Ndk::EntityHandle& cameraEntity = world.CreateEntity(); + Ndk::CameraComponent& cameraComponentCamera = cameraEntity->AddComponent(); + Ndk::NodeComponent& nodeComponentCamera = cameraEntity->AddComponent(); + + const Ndk::EntityHandle& drawableEntity = world.CreateEntity(); + Ndk::GraphicsComponent& graphicsComponentDrawable = drawableEntity->AddComponent(); + Nz::SpriteRef sprite = Nz::Sprite::New(); + graphicsComponentDrawable.Attach(sprite); + Ndk::NodeComponent& nodeComponentDrawable = drawableEntity->AddComponent(); + + const Ndk::EntityHandle& lightEntity = world.CreateEntity(); + Ndk::LightComponent& lightComponentLight = lightEntity->AddComponent(); + Ndk::NodeComponent& nodeComponentLight = lightEntity->AddComponent(); + + const Ndk::EntityHandle& particlesEntity = world.CreateEntity(); + Ndk::ParticleGroupComponent& particleGroupComponentParticles = particlesEntity->AddComponent(1, Nz::ParticleLayout_Sprite); + + WHEN("We change the render technique to ForwardRenderTechnique") + { + Ndk::RenderSystem& renderSystem = world.GetSystem(); + renderSystem.ChangeRenderTechnique(); + + THEN("The render system should be ForwardRenderTechnique") + { + REQUIRE(renderSystem.GetRenderTechnique().GetType() == Nz::RenderTechniqueType_BasicForward); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/Systems/VelocitySystem.cpp b/tests/SDK/NDK/Systems/VelocitySystem.cpp new file mode 100644 index 000000000..bfde34896 --- /dev/null +++ b/tests/SDK/NDK/Systems/VelocitySystem.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include + +SCENARIO("VelocitySystem", "[NDK][VELOCITYSYSTEM]") +{ + GIVEN("A world and an entity with velocity & node components") + { + Ndk::World world; + const Ndk::EntityHandle& entity = world.CreateEntity(); + Ndk::VelocityComponent& velocityComponent = entity->AddComponent(); + Ndk::NodeComponent& nodeComponent = entity->AddComponent(); + + WHEN("We give a speed to our entity") + { + Nz::Vector3f velocity = Nz::Vector3f::Unit() * 2.f; + velocityComponent.linearVelocity = velocity; + world.Update(1.f); + + THEN("Our entity should have moved") + { + REQUIRE(nodeComponent.GetPosition().SquaredDistance(velocity) < 0.2f); + } + } + } +} \ No newline at end of file diff --git a/tests/SDK/NDK/World.cpp b/tests/SDK/NDK/World.cpp new file mode 100644 index 000000000..431490490 --- /dev/null +++ b/tests/SDK/NDK/World.cpp @@ -0,0 +1,103 @@ +#include +#include +#include + +namespace +{ + class UpdatableComponent : public Ndk::Component + { + public: + bool IsUpdated() + { + return m_updated; + } + + void SetUpdated() + { + m_updated = true; + } + + static Ndk::ComponentIndex componentIndex; + + private: + bool m_updated = false; + }; + + Ndk::ComponentIndex UpdatableComponent::componentIndex; + + class UpdateSystem : public Ndk::System + { + public: + UpdateSystem() + { + Requires(); + } + + ~UpdateSystem() = default; + + static Ndk::SystemIndex systemIndex; + + private: + void OnUpdate(float elapsedTime) override + { + for (const Ndk::EntityHandle& entity : GetEntities()) + { + UpdatableComponent& updatable = entity->GetComponent(); + updatable.SetUpdated(); + } + } + }; + + Ndk::SystemIndex UpdateSystem::systemIndex; +} + +SCENARIO("World", "[NDK][WORLD]") +{ + GIVEN("A brave new world and the update system") + { + Ndk::World world; + Ndk::BaseSystem& system = world.AddSystem(); + + WHEN("We had a new entity with an updatable component and a system") + { + const Ndk::EntityHandle& entity = world.CreateEntity(); + UpdatableComponent& component = entity->AddComponent(); + + THEN("We can get our entity and our system") + { + const Ndk::EntityHandle& fetchedEntity = world.GetEntity(entity->GetId()); + REQUIRE(fetchedEntity->GetWorld() == &world); + } + + THEN("We can clone it") + { + const Ndk::EntityHandle& clone = world.CloneEntity(entity->GetId()); + REQUIRE(world.IsEntityValid(clone)); + } + } + + AND_WHEN("We update our world with our entity") + { + REQUIRE(&world.GetSystem(UpdateSystem::systemIndex) == &world.GetSystem()); + const Ndk::EntityHandle& entity = world.CreateEntity(); + UpdatableComponent& component = entity->AddComponent(); + + THEN("Our entity component must be updated") + { + world.Update(1.f); + + REQUIRE(component.IsUpdated()); + } + + THEN("We kill our entity") + { + REQUIRE(entity->IsValid()); + + world.KillEntity(entity); + world.Update(1.f); + + REQUIRE(!world.IsEntityValid(entity)); + } + } + } +} \ No newline at end of file From 24d78613803335debabd83aac29ea18cdb1a33bc Mon Sep 17 00:00:00 2001 From: Gawaboumga Date: Sun, 21 Aug 2016 13:49:24 +0200 Subject: [PATCH 228/383] Fix documentation Former-commit-id: bdaff1e4efaaad685df60baa0d11af3e7951dc4d [formerly 409b51215b894006fbcae285c8dfd67c97c9ae11] [formerly 58a176f2944bc3d347ccba58360cbdee3bb1b8d3 [formerly e6bd6b34212946c04eeec6896954c3969d1baf5f]] Former-commit-id: 944b2ddd24acdcb0b6a5db07cfc75c13f407737a [formerly 7ed2f044fe8e50bf99a1c432e6079f7a445af573] Former-commit-id: a1bfe55ac944ea530578a0cc813dd253cc708b69 --- include/Nazara/Math/Algorithm.inl | 83 ++++++++++++++++--------------- src/Nazara/Graphics/Sprite.cpp | 4 +- src/Nazara/Graphics/TileMap.cpp | 11 ++++ src/Nazara/Network/Network.cpp | 2 +- 4 files changed, 56 insertions(+), 44 deletions(-) diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 2c865ad1b..b61d82916 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -45,20 +45,21 @@ namespace Nz } template - // Les parenthèses autour de la condition sont nécesaires pour que GCC compile ça + // The parentheses are needed for GCC typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2(T number) { static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed"); - // L'algorithme pour le logarithme base 2 (au dessus) ne fonctionne qu'avec des nombres au plus 32bits - // ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting + // Masking and shifting bits to the right (to bring it back to 32 bits) + + // Call of the function with 32 bits number, if the result is non-null we have our answer for (int i = sizeof(T)-sizeof(UInt32); i >= 0; i -= sizeof(UInt32)) { - // Le masque 32 bits sur la partie du nombre qu'on traite actuellement + // The 32 bits mask on the part we are treating T mask = T(std::numeric_limits::max()) << i*8; - T val = (number & mask) >> i*8; // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits) + T val = (number & mask) >> i*8; // Masking and shifting bits to the right (to bring it back to 32 bits) - // Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse + // Call of the function with 32 bits number, if the result is non-null we have our answer unsigned int log2 = IntegralLog2(val); if (log2) return log2 + i*8; @@ -75,20 +76,20 @@ namespace Nz } template - // Les parenthèses autour de la condition sont nécesaires pour que GCC compile ça + // The parentheses are needed for GCC typename std::enable_if<(sizeof(T) > sizeof(UInt32)), unsigned int>::type IntegralLog2Pot(T number) { static_assert(sizeof(T) % sizeof(UInt32) == 0, "Assertion failed"); - // L'algorithme pour le logarithme base 2 (au dessus) ne fonctionne qu'avec des nombres au plus 32bits - // ce code décompose les nombres plus grands en nombres 32 bits par masquage et bit shifting + // The algorithm for logarithm in base 2 only works with numbers greather than 32 bits + // This code subdivides the biggest number into 32 bits ones for (int i = sizeof(T)-sizeof(UInt32); i >= 0; i -= sizeof(UInt32)) { - // Le masque 32 bits sur la partie du nombre qu'on traite actuellement + // The 32 bits mask on the part we are treating T mask = T(std::numeric_limits::max()) << i*8; - UInt32 val = UInt32((number & mask) >> i*8); // Masquage et shifting des bits vers la droite (pour le ramener sur 32bits) + UInt32 val = UInt32((number & mask) >> i*8); // Masking and shifting bits to the right (to bring it back to 32 bits) - // Appel de la fonction avec le nombre 32bits, si le résultat est non-nul nous avons la réponse + // Call of the function with 32 bits number, if the result is non-null we have our answer unsigned int log2 = IntegralLog2Pot(val); if (log2 || val == 1) return log2 + i*8; @@ -99,7 +100,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Approaches the objective, beginning with value and with increment * \return The nearest value of the objective you can get with the value and the increment for one step * @@ -121,7 +122,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Clamps value between min and max and returns the expected value * \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval * @@ -137,7 +138,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets number of bits set in the number * \return The number of bits set to 1 * @@ -160,7 +161,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts degree to radian * \return The representation in radian of the angle in degree (0..2*pi) * @@ -174,7 +175,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the unit from degree and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express the degrees * @@ -192,7 +193,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the unit from radian and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express the radians * @@ -210,7 +211,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the nearest power of two for the number * \return First power of two containing the number * @@ -229,7 +230,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -257,7 +258,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -279,7 +280,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -295,7 +296,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -312,7 +313,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -328,7 +329,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits * @@ -345,7 +346,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits + 1 for the dot * @@ -360,7 +361,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits + 1 for the dot * @@ -375,7 +376,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the number of digits to represent the number in base 10 * \return Number of digits + 1 for the dot * @@ -390,7 +391,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the log in base 2 of integral number * \return Log of the number (floor) * @@ -408,7 +409,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the log in base 2 of integral number, only works for power of two ! * \return Log of the number * @@ -426,7 +427,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the power of integrals * \return base^exponent for integral * @@ -445,7 +446,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Interpolates the value to other one with a factor of interpolation * \return A new value which is the interpolation of two values * @@ -466,7 +467,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Multiplies X and Y, then add Z * \return The result of X * Y + Z * @@ -508,7 +509,7 @@ namespace Nz #endif /*! - * \ingroup math + * \ingroup math * \brief Normalizes the angle * \return Normalized value between 0..2*(pi if radian or 180 if degrees) * @@ -534,7 +535,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Checks whether two numbers are equal * \return true if they are equal within a certain epsilon * @@ -550,7 +551,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Checks whether two numbers are equal * \return true if they are equal within the max difference * @@ -571,7 +572,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts the number to String * \return String representation of the number * @@ -623,7 +624,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts radian to degree * \return The representation in degree of the angle in radian (0..360) * @@ -637,7 +638,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Converts the string to number * \return Number which is represented by the string * @@ -699,7 +700,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the degree from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express in degrees * @@ -717,7 +718,7 @@ namespace Nz } /*! - * \ingroup math + * \ingroup math * \brief Gets the radian from unit and convert it according to NAZARA_MATH_ANGLE_RADIAN * \return Express in radians * diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 4bf076183..5ef82cddf 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -75,7 +75,7 @@ namespace Nz } /*! - * \brief Initializes the sprite librairies + * \brief Initializes the sprite library * \return true If successful * * \remark Produces a NazaraError if the sprite library failed to be initialized @@ -93,7 +93,7 @@ namespace Nz } /*! - * \brief Uninitializes the sprite librairies + * \brief Uninitializes the sprite library */ void Sprite::Uninitialize() diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index 9d835cb24..2c6e26aa4 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -90,6 +90,13 @@ namespace Nz } } + /*! + * \brief Initializes the tilemap library + * \return true If successful + * + * \remark Produces a NazaraError if the tilemap library failed to be initialized + */ + bool TileMap::Initialize() { if (!TileMapLibrary::Initialize()) @@ -101,6 +108,10 @@ namespace Nz return true; } + /*! + * \brief Uninitializes the tilemap library + */ + void TileMap::Uninitialize() { TileMapLibrary::Uninitialize(); diff --git a/src/Nazara/Network/Network.cpp b/src/Nazara/Network/Network.cpp index fa3813dd4..3e798e681 100644 --- a/src/Nazara/Network/Network.cpp +++ b/src/Nazara/Network/Network.cpp @@ -93,7 +93,7 @@ namespace Nz } /*! - * \brief Uninitializes the Core module + * \brief Uninitializes the Network module * * \remark Produces a NazaraNotice */ From ab9bd52b1cac40be4998bfaff0b710341e6068ea Mon Sep 17 00:00:00 2001 From: S6066 Date: Tue, 23 Aug 2016 16:49:47 +0200 Subject: [PATCH 229/383] Update Entity.hpp Former-commit-id: 1d99c5e8ecc59365b5e7b8a38ca6b7d728afe61e [formerly 8ad7a1c88ab8bfc98b3d31cc475ba5f1da2b640a] [formerly b8e21adaa60f4709451afbf5b38546e3129a1d5e [formerly 29cf1e9d53f54156ec4d691c4155d510139a8f0b]] Former-commit-id: 0c981c02a27181bbb8771bf4c3524a0a3a935f60 [formerly aaf146a3ca97aaa7b0c9601b7e277b0a2b66936b] Former-commit-id: 4f2fda343a111f80d6f9827d3a377fe07d2f59b5 --- SDK/include/NDK/Entity.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Entity.hpp b/SDK/include/NDK/Entity.hpp index 5aeeb8226..dbe77815c 100644 --- a/SDK/include/NDK/Entity.hpp +++ b/SDK/include/NDK/Entity.hpp @@ -36,7 +36,7 @@ namespace Ndk const EntityHandle& Clone() const; - inline void Enable(bool enable); + inline void Enable(bool enable = true); inline BaseComponent& GetComponent(ComponentIndex index); template ComponentType& GetComponent(); From 2a0fb4ffdc5c2852362059c89ab247eefef2cf14 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 23 Aug 2016 18:22:09 +0200 Subject: [PATCH 230/383] Sdk/Binding: Fix Entity::Enable default argument Former-commit-id: 82181122fca24b99e78ba927c71ce9237b1b3674 [formerly ef758ac2d0aac925dbcd6e72effc21b9effa83c0] [formerly 2555ac6b28f36b220aea76f2aeb0012536665058 [formerly b28da55971c4db17ddbf7fd6bacd8c03d02ffcbd]] Former-commit-id: 8a84469ff40d37e114fbdee8c3fa16a3748ca010 [formerly 3f3cfc52071d469150feeaf2f7cdff8c33a8f46f] Former-commit-id: 8f522f2357b7564229ebdea1e8d4a2b3cc223366 --- SDK/src/NDK/LuaBinding_SDK.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 5b6ad7dc9..bf66cbf00 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -57,7 +57,7 @@ namespace Ndk #endif /*********************************** Ndk::Entity **********************************/ - entityClass.BindMethod("Enable", &Entity::Enable); + entityClass.BindMethod("Enable", &Entity::Enable, true); entityClass.BindMethod("GetId", &Entity::GetId); entityClass.BindMethod("GetWorld", &Entity::GetWorld); entityClass.BindMethod("Kill", &Entity::Kill); From de274b632ddff55b3fe5e9b51a1c329cd7f51a97 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 23 Aug 2016 18:25:10 +0200 Subject: [PATCH 231/383] Sdk/Console: Remove debug error Former-commit-id: d1ea434fd474fc66e7c7b751d656c88f7d782ddc [formerly 1c7a1aff7717bdd946cbd3b48d0ed6b7d2f326e3] [formerly c6877dcd98758602be9d2378cec991bb0e2e91c5 [formerly d114ffd6832788fecd0f167c11e8796b7cb2bf3a]] Former-commit-id: 1c163946a75f63bcf71acb39dda8674c82508a94 [formerly d8dd26e5087771e7d83ab97d6075594236c501f1] Former-commit-id: 30aa3c22d308ce012631f5c58d03f4843702a4f3 --- SDK/src/NDK/Console.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index dd379cd4a..94a80b749 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -320,9 +320,7 @@ namespace Ndk unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight; Ndk::NodeComponent& inputNode = m_input->GetComponent(); - NazaraError(inputNode.GetPosition().ToString()); inputNode.SetPosition(0.f, m_size.y - lineHeight - 5.f); - NazaraError(inputNode.GetPosition().ToString()); float historyHeight = m_size.y - lineHeight - 5.f - 2.f; m_historyBackgroundSprite->SetSize(m_size.x, historyHeight); @@ -330,14 +328,10 @@ namespace Ndk m_maxHistoryLines = static_cast(std::ceil(historyHeight / lineHeight)); Ndk::NodeComponent& historyNode = m_history->GetComponent(); - NazaraError(historyNode.GetPosition().ToString()); historyNode.SetPosition(0.f, historyHeight - m_maxHistoryLines * lineHeight); - NazaraError(historyNode.GetPosition().ToString()); Ndk::NodeComponent& inputBackgroundNode = m_inputBackground->GetComponent(); - NazaraError(inputBackgroundNode.GetPosition().ToString()); inputBackgroundNode.SetPosition(0.f, historyHeight + 2.f); - NazaraError(inputBackgroundNode.GetPosition().ToString()); m_inputBackgroundSprite->SetSize(m_size.x, m_size.y - historyHeight); } From 6621b6dd6045c20e4d1c08c87be2df8967861504 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 25 Aug 2016 13:07:19 +0200 Subject: [PATCH 232/383] Doc: Parse SDK files Former-commit-id: 57d6730ea85baa89caff212323c2aa62d2d720d6 [formerly f36024b268f43ed21b43bbb623de44157332d3cc] [formerly 193ae75a9b524ce038467e914f6b48292623639f [formerly 717d411e4631f7fe54050bbc5f7f0ede2295bfbe]] Former-commit-id: 0e8e8cb198ddfaf338e7170f81b693e00bd8c4cd [formerly 3b7d40477da76ec363107ad730386cd272ae44e0] Former-commit-id: 345dba1dbf3a5c158f9536fee36b2a48da12eeb9 --- Doxyfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doxyfile b/Doxyfile index 7ac8e5f8c..47af03df4 100644 --- a/Doxyfile +++ b/Doxyfile @@ -776,7 +776,9 @@ WARN_LOGFILE = # Note: If this tag is empty the current directory is searched. INPUT = include \ - src + src \ + SDK/include \ + SDK/src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses From 6b155f7e14f730c2a55548ea61da1c1667841bb9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 25 Aug 2016 16:28:25 +0200 Subject: [PATCH 233/383] Test/StateMachine: Fix compilation Former-commit-id: b941ed79168687628c27d3ebb2caf1863e968307 [formerly 6b0801514a3427900ea38124301fb3d833ac6bfa] [formerly f2cd5d78631c02468c54f602b19ca4c728a91243 [formerly 6262416d9bb0b6d7812fcbadb8f45d79d3391ec3]] Former-commit-id: 702008d7fd198ac4bd65b719cf7f7d639834cde0 [formerly 15ee4f1c843a1ce92a1a7d25f27d3c941fea115d] Former-commit-id: b12e457b17f44d2cda68b5c9a6138c4b02b7f1fe --- tests/SDK/NDK/StateMachine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/SDK/NDK/StateMachine.cpp b/tests/SDK/NDK/StateMachine.cpp index 604aa6f9f..44b0e0dfd 100644 --- a/tests/SDK/NDK/StateMachine.cpp +++ b/tests/SDK/NDK/StateMachine.cpp @@ -21,6 +21,7 @@ class TestState : public Ndk::State bool Update(Ndk::StateMachine& fsm, float elapsedTime) override { m_isUpdated = true; + return true; } private: @@ -45,4 +46,4 @@ SCENARIO("State & StateMachine", "[NDK][STATE]") } } } -} \ No newline at end of file +} From 618449c13a28e87baad355c21b25ae6bc2fc0786 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:08:38 +0200 Subject: [PATCH 234/383] Utility/Window: Add new event system, based on signals Old pooling-based system remains for now but is now deprecated Former-commit-id: 803c6f51e8287613610ede8433bef8112bc70352 [formerly 9f60f0fabea7fa0d0d62feba217e28c421522e36] [formerly f05d3dededee17402669ec9e4060c95d77c74bb4 [formerly 5b96073b92c3a10a5c485abcc7c33ecedb819fca]] Former-commit-id: 4280c668fb5ec67c0b765a80516b9b4fe466135d [formerly c8ce15aa230bf2f1040b00153ec81aa1f39ef48d] Former-commit-id: 71893d639b5e1628776d8a4577b0309437865c16 --- SDK/src/NDK/Application.cpp | 2 + examples/Tut01/main.cpp | 8 +-- include/Nazara/Utility/EventHandler.hpp | 47 ++++++++++++++ include/Nazara/Utility/EventHandler.inl | 82 +++++++++++++++++++++++++ include/Nazara/Utility/Window.hpp | 13 ++-- include/Nazara/Utility/Window.inl | 58 +++++++++-------- src/Nazara/Utility/Window.cpp | 9 +++ 7 files changed, 181 insertions(+), 38 deletions(-) create mode 100644 include/Nazara/Utility/EventHandler.hpp create mode 100644 include/Nazara/Utility/EventHandler.inl diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 5e3331d73..63e834bd0 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -26,6 +26,8 @@ namespace Ndk { Nz::Window& window = **it; + window.ProcessEvents(); + if (!window.IsOpen(true)) { it = m_windows.erase(it); diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index d1ebcd5d4..f5fca94a0 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -16,6 +16,7 @@ int main() Nz::RenderWindow& mainWindow = application.AddWindow(); mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test"); + Ndk::World& world = application.AddWorld(); world.GetSystem().SetGlobalUp(Nz::Vector3f::Down()); world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(192, 100, 100))); @@ -43,13 +44,6 @@ int main() while (application.Run()) { - Nz::WindowEvent event; - while (mainWindow.PollEvent(&event)) - { - if (event.type == Nz::WindowEventType_Quit) - application.Quit(); - } - mainWindow.Display(); } diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp new file mode 100644 index 000000000..b35ef96cf --- /dev/null +++ b/include/Nazara/Utility/EventHandler.hpp @@ -0,0 +1,47 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_EVENTHANDLER_HPP +#define NAZARA_EVENTHANDLER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class EventHandler + { + public: + EventHandler() = default; + EventHandler(const EventHandler&); + EventHandler(EventHandler&&) = default; + ~EventHandler() = default; + + inline void Dispatch(const WindowEvent& event); + + NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/); + NazaraSignal(OnLostFocus, const EventHandler* /*eventHandler*/); + NazaraSignal(OnKeyPressed, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/); + NazaraSignal(OnKeyReleased, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/); + NazaraSignal(OnMouseButtonDoubleClicked, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/); + NazaraSignal(OnMouseButtonPressed, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/); + NazaraSignal(OnMouseButtonReleased, const EventHandler* /*eventHandler*/, const WindowEvent::MouseButtonEvent& /*event*/); + NazaraSignal(OnMouseEntered, const EventHandler* /*eventHandler*/); + NazaraSignal(OnMouseLeft, const EventHandler* /*eventHandler*/); + NazaraSignal(OnMouseMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseMoveEvent& /*event*/); + NazaraSignal(OnMouseWheelMoved, const EventHandler* /*eventHandler*/, const WindowEvent::MouseWheelEvent& /*event*/); + NazaraSignal(OnMoved, const EventHandler* /*eventHandler*/, const WindowEvent::PositionEvent& /*event*/); + NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/); + NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/); + NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/); + }; +} + +#include + +#endif // NAZARA_EVENTHANDLER_HPP diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl new file mode 100644 index 000000000..4fadf6b43 --- /dev/null +++ b/include/Nazara/Utility/EventHandler.inl @@ -0,0 +1,82 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline EventHandler::EventHandler(const EventHandler&) + { + } + + inline void EventHandler::Dispatch(const WindowEvent& event) + { + switch (event.type) + { + case WindowEventType_GainedFocus: + OnGainedFocus(this); + break; + + case WindowEventType_KeyPressed: + OnKeyPressed(this, event.key); + break; + + case WindowEventType_KeyReleased: + OnKeyReleased(this, event.key); + break; + + case WindowEventType_LostFocus: + OnLostFocus(this); + break; + + case WindowEventType_MouseButtonDoubleClicked: + OnMouseButtonDoubleClicked(this, event.mouseButton); + break; + + case WindowEventType_MouseButtonPressed: + OnMouseButtonPressed(this, event.mouseButton); + break; + + case WindowEventType_MouseButtonReleased: + OnMouseButtonPressed(this, event.mouseButton); + break; + + case WindowEventType_MouseEntered: + OnMouseEntered(this); + break; + + case WindowEventType_MouseLeft: + OnMouseLeft(this); + break; + + case WindowEventType_MouseMoved: + OnMouseMoved(this, event.mouseMove); + break; + + case WindowEventType_MouseWheelMoved: + OnMouseWheelMoved(this, event.mouseWheel); + break; + + case WindowEventType_Moved: + OnMoved(this, event.position); + break; + + case WindowEventType_Quit: + OnQuit(this); + break; + + case WindowEventType_Resized: + OnResized(this, event.size); + break; + + case WindowEventType_TextEntered: + OnTextEntered(this, event.text); + break; + } + } +} + +#include diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index af23be7f1..ba67c17cb 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,9 +52,11 @@ namespace Nz void Destroy(); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable); void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); + EventHandler& GetEventHandler(); WindowHandle GetHandle() const; unsigned int GetHeight() const; Vector2i GetPosition() const; @@ -71,7 +73,9 @@ namespace Nz inline bool IsValid() const; bool IsVisible() const; - bool PollEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") bool PollEvent(WindowEvent* event); + + void ProcessEvents(bool block = false); void SetCursor(WindowCursor cursor); void SetCursor(const Cursor& cursor); @@ -90,7 +94,7 @@ namespace Nz void SetTitle(const String& title); void SetVisible(bool visible); - bool WaitEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")bool WaitEvent(WindowEvent* event); Window& operator=(const Window&) = delete; inline Window& operator=(Window&& window); @@ -114,10 +118,11 @@ namespace Nz ConditionVariable m_eventCondition; Mutex m_eventMutex; Mutex m_eventConditionMutex; - bool m_eventListener; bool m_waitForEvent; #endif + EventHandler m_eventHandler; bool m_closed; + bool m_eventPolling; bool m_ownsWindow; }; } diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index ebf5dfbee..349328e55 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -11,39 +11,24 @@ namespace Nz /*! * \class Nz::Window */ - inline Window::Window() : - #if NAZARA_UTILITY_THREADED_WINDOW m_impl(nullptr), - m_eventListener(true), - m_waitForEvent(false) - #else - m_impl(nullptr) + #if NAZARA_UTILITY_THREADED_WINDOW + m_waitForEvent(false), #endif + m_eventPolling(false) { } inline Window::Window(VideoMode mode, const String& title, UInt32 style) : - #if NAZARA_UTILITY_THREADED_WINDOW - m_impl(nullptr), - m_eventListener(true), - m_waitForEvent(false) - #else - m_impl(nullptr) - #endif + Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); Create(mode, title, style); } inline Window::Window(WindowHandle handle) : - #if NAZARA_UTILITY_THREADED_WINDOW - m_impl(nullptr), - m_eventListener(true), - m_waitForEvent(false) - #else - m_impl(nullptr) - #endif + Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); Create(handle); @@ -59,7 +44,7 @@ namespace Nz m_eventCondition(std::move(window.m_eventCondition)), m_eventMutex(std::move(window.m_eventMutex)), m_eventConditionMutex(std::move(window.m_eventConditionMutex)), - m_eventListener(window.m_eventListener), + m_eventPolling(window.m_eventPolling), m_waitForEvent(window.m_waitForEvent), #endif m_closed(window.m_closed), @@ -78,6 +63,21 @@ namespace Nz m_closed = true; // The window will be closed at the next non-const IsOpen() call } + inline void Window::EnableEventPolling(bool enable) + { + m_eventPolling = enable; + if (!m_eventPolling) + { + while (!m_events.empty()) + m_events.pop(); + } + } + + inline EventHandler& Nz::Window::GetEventHandler() + { + return m_eventHandler; + } + inline bool Window::IsOpen(bool checkClosed) { if (!m_impl) @@ -108,7 +108,11 @@ namespace Nz m_eventMutex.Lock(); #endif - m_events.push(event); + if (m_eventPolling) + m_events.push(event); + + m_eventHandler.Dispatch(event); + if (event.type == WindowEventType_Resized) OnWindowResized(); @@ -132,10 +136,11 @@ namespace Nz { Destroy(); - m_closed = window.m_closed; - m_impl = window.m_impl; - m_events = std::move(window.m_events); - m_ownsWindow = window.m_ownsWindow; + m_closed = window.m_closed; + m_eventPolling = window.m_eventPolling; + m_impl = window.m_impl; + m_events = std::move(window.m_events); + m_ownsWindow = window.m_ownsWindow; window.m_impl = nullptr; @@ -143,7 +148,6 @@ namespace Nz m_eventCondition = std::move(window.m_eventCondition); m_eventMutex = std::move(window.m_eventMutex); m_eventConditionMutex = std::move(window.m_eventConditionMutex); - m_eventListener = window.m_eventListener; m_waitForEvent = window.m_waitForEvent; #endif diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index e246144d2..02ed0f40a 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -325,6 +325,15 @@ namespace Nz return false; } + void Window::ProcessEvents(bool block) + { + NazaraAssert(m_impl, "Window not created"); + + #if !NAZARA_UTILITY_THREADED_WINDOW + m_impl->ProcessEvents(block); + #endif + } + void Window::SetCursor(WindowCursor cursor) { #if NAZARA_UTILITY_SAFE From 732a6d932292499b23b44da00e1a5e7ad752aafa Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:09:15 +0200 Subject: [PATCH 235/383] Utility/Window: Window now automatically close on quit event Former-commit-id: 3e3e84e1e89a2c643e19e183a1286d95550d2965 [formerly 813114f7beb2af1836f8dfd66fe089be66efb6d9] [formerly 881ff104de309ade91fed5b5ffdb66025775bc57 [formerly 3fd695c4ac86999600262c99160d8dd20740409c]] Former-commit-id: bce06f73894643e2f612c60c73fa340c54a4ad98 [formerly fe4a806707c5339aff9eada8e20e1921d1190141] Former-commit-id: 7a2012bd3d3930beb958bb729934d41cd6b81e69 --- include/Nazara/Utility/Window.hpp | 2 ++ include/Nazara/Utility/Window.inl | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index ba67c17cb..b46efd6b9 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -52,6 +52,7 @@ namespace Nz void Destroy(); + inline void EnableCloseOnQuit(bool closeOnQuit); NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable); void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); @@ -122,6 +123,7 @@ namespace Nz #endif EventHandler m_eventHandler; bool m_closed; + bool m_closeOnQuit; bool m_eventPolling; bool m_ownsWindow; }; diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index 349328e55..39c530e24 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -16,6 +16,7 @@ namespace Nz #if NAZARA_UTILITY_THREADED_WINDOW m_waitForEvent(false), #endif + m_closeOnQuit(true), m_eventPolling(false) { } @@ -44,10 +45,11 @@ namespace Nz m_eventCondition(std::move(window.m_eventCondition)), m_eventMutex(std::move(window.m_eventMutex)), m_eventConditionMutex(std::move(window.m_eventConditionMutex)), - m_eventPolling(window.m_eventPolling), m_waitForEvent(window.m_waitForEvent), #endif m_closed(window.m_closed), + m_closeOnQuit(window.m_closeOnQuit), + m_eventPolling(window.m_eventPolling), m_ownsWindow(window.m_ownsWindow) { window.m_impl = nullptr; @@ -63,6 +65,11 @@ namespace Nz m_closed = true; // The window will be closed at the next non-const IsOpen() call } + inline void Window::EnableCloseOnQuit(bool closeOnQuit) + { + m_closeOnQuit = closeOnQuit; + } + inline void Window::EnableEventPolling(bool enable) { m_eventPolling = enable; @@ -116,6 +123,9 @@ namespace Nz if (event.type == WindowEventType_Resized) OnWindowResized(); + if (event.type == WindowEventType_Quit && m_closeOnQuit) + Close(); + #if NAZARA_UTILITY_THREADED_WINDOW m_eventMutex.Unlock(); @@ -137,6 +147,7 @@ namespace Nz Destroy(); m_closed = window.m_closed; + m_closeOnQuit = window.m_closeOnQuit; m_eventPolling = window.m_eventPolling; m_impl = window.m_impl; m_events = std::move(window.m_events); From 134063a87d80e8382553e98a92726e517ff8685a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:09:40 +0200 Subject: [PATCH 236/383] Network/SocketImpl: Fix compilation for recent MinGW versions Former-commit-id: b32cdfc7c9341b56a2534f49304ed6a40889ef65 [formerly be0dcc051b3714196a74c2639d61f3377b1732cf] [formerly 4a3c9b84f8d4b5c55f3fe086df6609b9198ff2a0 [formerly d07e788c4b54277aa726e82810c36c64dae14084]] Former-commit-id: f71fe5191f9470facf8669ebd89ff86f8b9be9dc [formerly 96f25b63a8bb4ffa5523dd972bf2a24b8df80269] Former-commit-id: f1beb415423a8babbe61e95c3fe35ad9456c6622 --- src/Nazara/Network/Win32/SocketImpl.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index ab7ba7fe3..f35a4a078 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -8,8 +8,9 @@ #include #include -#ifdef NAZARA_COMPILER_MINGW -// MinGW is lacking Mstcpip.h and that's too bad + +// Some compilers (olders versions of MinGW) are lacking Mstcpip.h which defines the following struct/#define +// Define them ourself for now struct tcp_keepalive { u_long onoff; @@ -18,9 +19,6 @@ struct tcp_keepalive }; #define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) -#else - #include -#endif // NAZARA_COMPILER_MINGW #include From cda509da6fda81b82a59843f39cbd196f80cf35a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:20:31 +0200 Subject: [PATCH 237/383] Utility/Window: Improve visibility of deprecated methods Former-commit-id: f0f794407f33b485962dacf1f1ac39ea5beac7de [formerly b40cb93e11aa6bc2242c745607ee748567192f7c] [formerly 41f4a381d9742dd586673e0685be31541edf5864 [formerly 4190ba3ddbd098f79909b244b0dea90cbb924771]] Former-commit-id: 887f75b329b705181f5c1a5d00297b2377e0b626 [formerly c199d56deb1d59d95b19c5684c0f3529f6d62e58] Former-commit-id: 960ff4eab6b9886095c1ae079753161d4b5c6be1 --- include/Nazara/Utility/Window.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/Window.hpp b/include/Nazara/Utility/Window.hpp index b46efd6b9..e544093c5 100644 --- a/include/Nazara/Utility/Window.hpp +++ b/include/Nazara/Utility/Window.hpp @@ -53,7 +53,10 @@ namespace Nz void Destroy(); inline void EnableCloseOnQuit(bool closeOnQuit); - NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable); + + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") + inline void EnableEventPolling(bool enable); + void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); @@ -74,7 +77,8 @@ namespace Nz inline bool IsValid() const; bool IsVisible() const; - NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") bool PollEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") + bool PollEvent(WindowEvent* event); void ProcessEvents(bool block = false); @@ -95,7 +99,8 @@ namespace Nz void SetTitle(const String& title); void SetVisible(bool visible); - NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")bool WaitEvent(WindowEvent* event); + NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") + bool WaitEvent(WindowEvent* event); Window& operator=(const Window&) = delete; inline Window& operator=(Window&& window); From 1a7ac468933b1124a80f2502cd048640f3183a18 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 01:22:47 +0200 Subject: [PATCH 238/383] Example/FirstScene: Fix event handling Former-commit-id: a3d33e15303aee7de339f1bc6ba84866fcaea524 [formerly 391d9095d6b64cf1409f12ab62f1b95a721e8489] [formerly a609374620028cae9cc3f3ba66efda909bb33479 [formerly 2f3dbf79330334123da1e6ff0edd74ec9c8f53b4]] Former-commit-id: 69d9719acc6ba619e60b8580f4ba49bb543cbe9f [formerly bb65e744b18ef7e185c2960c5f07223a057a5496] Former-commit-id: 08a99a0241402466ac4463807b1127060095f827 --- examples/FirstScene/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 07e26cd1c..0a471acee 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -329,6 +329,8 @@ int main() lua.PushGlobal("Spaceship", spaceship->CreateHandle()); lua.PushGlobal("World", world->CreateHandle()); + window.EnableEventPolling(true); // Déprécié + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) while (application.Run()) { From 62cfdd6adee42394952630c86b82e9f3d10563e3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:02:07 +0200 Subject: [PATCH 239/383] Utility/EventHandler: Add OnEvent signal Former-commit-id: 2e598906e684b4328d99a9226ce03c90ad2573ad [formerly 653efe0750defdec35c094fa8ec72cb3b35a1ca0] [formerly d4fe9970a38bc851114697a315a561199dd4f146 [formerly 909526b7566949bf50375a90ef44264425b06f0e]] Former-commit-id: d8ef7a871bd700761eb87404131d11e5bb0bd324 [formerly 9e23fe05aeb8b4e042d0583960afa5ca8b2ce6ec] Former-commit-id: 5e8dacdd4f0323551f5ae2ae83f7841f5c7ac479 --- include/Nazara/Utility/EventHandler.hpp | 3 ++- include/Nazara/Utility/EventHandler.inl | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Utility/EventHandler.hpp b/include/Nazara/Utility/EventHandler.hpp index b35ef96cf..2464d5e72 100644 --- a/include/Nazara/Utility/EventHandler.hpp +++ b/include/Nazara/Utility/EventHandler.hpp @@ -18,12 +18,13 @@ namespace Nz { public: EventHandler() = default; - EventHandler(const EventHandler&); + explicit EventHandler(const EventHandler&); EventHandler(EventHandler&&) = default; ~EventHandler() = default; inline void Dispatch(const WindowEvent& event); + NazaraSignal(OnEvent, const EventHandler* /*eventHandler*/, const WindowEvent& /*event*/); NazaraSignal(OnGainedFocus, const EventHandler* /*eventHandler*/); NazaraSignal(OnLostFocus, const EventHandler* /*eventHandler*/); NazaraSignal(OnKeyPressed, const EventHandler* /*eventHandler*/, const WindowEvent::KeyEvent& /*event*/); diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl index 4fadf6b43..c066b6810 100644 --- a/include/Nazara/Utility/EventHandler.inl +++ b/include/Nazara/Utility/EventHandler.inl @@ -14,6 +14,8 @@ namespace Nz inline void EventHandler::Dispatch(const WindowEvent& event) { + OnEvent(this, event); + switch (event.type) { case WindowEventType_GainedFocus: From 07fe2f560e19184dde01257f9ed7ca9bbd849127 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:10:09 +0200 Subject: [PATCH 240/383] Sdk/Application: Add Console and FPSCounter overlays This allows any Nazara-powered application to enable a ready-to-use console or a working FPS counter Former-commit-id: 2b1c7ae5a7c72ea1c102734841f4e25742c2b42b [formerly f1fece5295a0a43147396752b3c61d84e0d7fc74] [formerly 40eff1e79a68fb5e0b7e1d4d6528fec318fed74c [formerly b17ee1558babcd4ed89525e447fb9c4e58b67033]] Former-commit-id: 1e1297789e402d25e7b5324dceebbbe8021a2217 [formerly 1c62735c3ff7f53efbef3e45c2284739fc22ec32] Former-commit-id: 3d331aae0e7db884e36d07b095a9d25a1dbe7926 --- SDK/include/NDK/Application.hpp | 76 +++++++++++- SDK/include/NDK/Application.inl | 199 ++++++++++++++++++++++++++++++-- SDK/src/NDK/Application.cpp | 132 ++++++++++++++++++++- SDK/src/NDK/LuaBinding_SDK.cpp | 7 ++ examples/FirstScene/main.cpp | 129 ++++----------------- 5 files changed, 423 insertions(+), 120 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 6a375776c..5eca90961 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -8,18 +8,34 @@ #define NDK_APPLICATION_HPP #include +#include #include #include -#include #include +#include #include +#ifndef NDK_SERVER +#include +#include +#include +#include +#include +#include +#endif + namespace Ndk { class NDK_API Application { public: + #ifndef NDK_SERVER + struct ConsoleOverlay; + struct FPSCounterOverlay; + #endif + inline Application(); + inline Application(int argc, const char* argv[]); Application(const Application&) = delete; Application(Application&&) = delete; inline ~Application(); @@ -29,8 +45,21 @@ namespace Ndk #endif template World& AddWorld(Args&&... args); + #ifndef NDK_SERVER + inline void EnableConsole(bool enable); + inline void EnableFPSCounter(bool enable); + + inline ConsoleOverlay& GetConsoleOverlay(std::size_t windowIndex = 0U); + inline FPSCounterOverlay& GetFPSCounterOverlay(std::size_t windowIndex = 0U); + #endif + inline float GetUpdateTime() const; + #ifndef NDK_SERVER + inline bool IsConsoleEnabled() const; + inline bool IsFPSCounterEnabled() const; + #endif + bool Run(); #ifndef NDK_SERVER @@ -44,13 +73,56 @@ namespace Ndk inline static Application* Instance(); + #ifndef NDK_SERVER + struct ConsoleOverlay + { + std::unique_ptr console; + Nz::LuaInstance lua; + + NazaraSlot(Nz::EventHandler, OnEvent, eventSlot); + NazaraSlot(Nz::EventHandler, OnKeyPressed, keyPressedSlot); + NazaraSlot(Nz::EventHandler, OnResized, resizedSlot); + NazaraSlot(Nz::Log, OnLogWrite, logSlot); + }; + + struct FPSCounterOverlay + { + Nz::TextSpriteRef sprite; + EntityOwner entity; + float elapsedTime = 0.f; + unsigned int frameCount = 0; + }; + #endif + private: #ifndef NDK_SERVER - std::vector> m_windows; + enum OverlayFlags + { + OverlayFlags_Console = 0x1, + OverlayFlags_FPSCounter = 0x2 + }; + + struct WindowInfo + { + inline WindowInfo(std::unique_ptr&& window); + + Nz::RenderTarget* renderTarget; + std::unique_ptr window; + std::unique_ptr console; + std::unique_ptr fpsCounter; + std::unique_ptr overlayWorld; + }; + + void SetupConsole(WindowInfo& info); + void SetupFPSCounter(WindowInfo& info); + void SetupOverlay(WindowInfo& info); + + std::vector m_windows; #endif std::list m_worlds; Nz::Clock m_updateClock; #ifndef NDK_SERVER + Nz::UInt32 m_overlayFlags; bool m_exitOnClosedWindows; #endif bool m_shouldQuit; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 0d21d1b94..19013c778 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include #include #include #include @@ -9,13 +10,15 @@ namespace Ndk { /*! - * \brief Constructs an Application object by default + * \brief Constructs an Application object without passing command-line arguments * - * \remark Produces a NazaraAssert if there's more than one application instance currently running + * This calls Sdk::Initialize() + * + * \remark Only one Application instance can exist at a time */ - inline Application::Application() : #ifndef NDK_SERVER + m_overlayFlags(0U), m_exitOnClosedWindows(true), #endif m_shouldQuit(false), @@ -31,9 +34,26 @@ namespace Ndk } /*! - * \brief Destructs the object + * \brief Constructs an Application object with command-line arguments + * + * Pass the argc and argv arguments from the main function. + * + * Command-line arguments can be retrieved by application methods + * + * This calls Sdk::Initialize() + * + * \remark Only one Application instance can exist at a time */ + inline Application::Application(int argc, const char* argv[]) : + Application() + { + } + /*! + * \brief Destructs the application object + * + * This destroy all worlds and windows and then calls Sdk::Uninitialize + */ inline Application::~Application() { m_worlds.clear(); @@ -61,8 +81,28 @@ namespace Ndk { static_assert(std::is_base_of::value, "Type must inherit Window"); - m_windows.emplace_back(new T(std::forward(args)...)); - return static_cast(*m_windows.back().get()); + m_windows.emplace_back(std::make_unique(std::forward(args)...)); + WindowInfo& info = m_windows.back(); + + T& window = static_cast(*info.window.get()); //< Warning: ugly + + if (std::is_base_of()) + { + info.renderTarget = &window; + + if (m_overlayFlags) + { + SetupOverlay(info); + + if (m_overlayFlags & OverlayFlags_Console) + SetupConsole(info); + + if (m_overlayFlags & OverlayFlags_FPSCounter) + SetupFPSCounter(info); + } + } + + return window; } #endif @@ -80,22 +120,159 @@ namespace Ndk return m_worlds.back(); } + /*! + * \brief Enable/disable debug console + * + * \param enable Should the console overlay be enabled + */ + inline void Application::EnableConsole(bool enable) + { + if (enable != ((m_overlayFlags & OverlayFlags_Console) != 0)) + { + if (enable) + { + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + SetupOverlay(info); + } + + for (WindowInfo& info : m_windows) + SetupConsole(info); + + m_overlayFlags |= OverlayFlags_Console; + + } + else + { + for (WindowInfo& info : m_windows) + info.console.reset(); + + m_overlayFlags &= ~OverlayFlags_Console; + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + info.overlayWorld.reset(); + } + } + } + } + + /*! + * \brief Enable/disable debug FPS counter + * + * \param enable Should the FPS counter be displayed + */ + inline void Application::EnableFPSCounter(bool enable) + { + if (enable != ((m_overlayFlags & OverlayFlags_FPSCounter) != 0)) + { + if (enable) + { + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + SetupOverlay(info); + } + + for (WindowInfo& info : m_windows) + SetupFPSCounter(info); + + m_overlayFlags |= OverlayFlags_FPSCounter; + + } + else + { + for (WindowInfo& info : m_windows) + info.fpsCounter.reset(); + + m_overlayFlags &= ~OverlayFlags_FPSCounter; + if (m_overlayFlags == 0) + { + for (WindowInfo& info : m_windows) + info.overlayWorld.reset(); + } + } + } + } + + /*! + * \brief Gets the console overlay for a specific window + * + * \param windowIndex Index of the window to get + * + * \remark The console overlay must be enabled + * + * \return A reference to the console overlay of the window + * + * \see IsConsoleOverlayEnabled + */ + inline Application::ConsoleOverlay& Application::GetConsoleOverlay(std::size_t windowIndex) + { + NazaraAssert(m_overlayFlags & OverlayFlags_Console, "Console overlay is not enabled"); + NazaraAssert(windowIndex <= m_windows.size(), "Window index is out of range"); + + return *m_windows[windowIndex].console; + } + + /*! + * \brief Gets the console overlay for a specific window + * + * \param windowIndex Index of the window to get + * + * \remark The console overlay must be enabled + * + * \return A reference to the console overlay of the window + * + * \see IsFPSCounterEnabled + */ + inline Application::FPSCounterOverlay& Application::GetFPSCounterOverlay(std::size_t windowIndex) + { + NazaraAssert(m_overlayFlags & OverlayFlags_FPSCounter, "FPS counter overlay is not enabled"); + NazaraAssert(windowIndex <= m_windows.size(), "Window index is out of range"); + + return *m_windows[windowIndex].fpsCounter; + } + /*! * \brief Gets the update time of the application * \return Update rate */ - inline float Application::GetUpdateTime() const { return m_updateTime; } + /*! + * \brief Checks if the console overlay is enabled + * + * \remark This has nothing to do with the visibility state of the console + * + * \return True if the console overlay is enabled + * + * \see GetConsoleOverlay + */ + inline bool Application::IsConsoleEnabled() const + { + return (m_overlayFlags & OverlayFlags_Console) != 0; + } + + /*! + * \brief Checks if the FPS counter overlay is enabled + * \return True if the FPS counter overlay is enabled + * + * \see GetFPSCounterOverlay + */ + inline bool Application::IsFPSCounterEnabled() const + { + return (m_overlayFlags & OverlayFlags_FPSCounter) != 0; + } + /*! * \brief Makes the application exit when there's no more open window * * \param exitOnClosedWindows Should exit be called when no more window is open */ - #ifndef NDK_SERVER inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows) { @@ -121,4 +298,10 @@ namespace Ndk { return s_application; } + + inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : + window(std::move(window)), + renderTarget(nullptr) + { + } } diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 63e834bd0..c4492eb0f 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -4,6 +4,15 @@ #include +#ifndef NDK_SERVER +#include +#include +#include +#include +#include +#include +#endif + namespace Ndk { /*! @@ -15,7 +24,6 @@ namespace Ndk /*! * \brief Runs the application by updating worlds, taking care about windows, ... */ - bool Application::Run() { #ifndef NDK_SERVER @@ -24,7 +32,7 @@ namespace Ndk auto it = m_windows.begin(); while (it != m_windows.end()) { - Nz::Window& window = **it; + Nz::Window& window = *it->window; window.ProcessEvents(); @@ -54,8 +62,128 @@ namespace Ndk for (World& world : m_worlds) world.Update(m_updateTime); + #ifndef NDK_SERVER + for (WindowInfo& info : m_windows) + { + if (info.fpsCounter) + { + FPSCounterOverlay& fpsCounter = *info.fpsCounter; + + fpsCounter.frameCount++; + + fpsCounter.elapsedTime += m_updateTime; + if (fpsCounter.elapsedTime >= 1.f) + { + fpsCounter.sprite->Update(Nz::SimpleTextDrawer::Draw("FPS: " + Nz::String::Number(fpsCounter.frameCount), 36)); + fpsCounter.frameCount = 0; + fpsCounter.elapsedTime = 0.f; + } + } + + info.overlayWorld->Update(m_updateTime); + } + #endif + return true; } + void Application::SetupConsole(WindowInfo& info) + { + std::unique_ptr overlay = std::make_unique(); + + overlay->console = std::make_unique(*info.overlayWorld, Nz::Vector2f(Nz::Vector2ui(info.window->GetWidth(), info.window->GetHeight() / 4)), overlay->lua); + + Console& consoleRef = *overlay->console; + // Redirect logs toward the console + overlay->logSlot.Connect(Nz::Log::OnLogWrite, [&consoleRef] (const Nz::String& str) + { + consoleRef.AddLine(str); + }); + + LuaAPI::RegisterClasses(overlay->lua); + + // Override "print" function to add a line in the console + overlay->lua.PushFunction([&consoleRef] (Nz::LuaInstance& instance) + { + Nz::StringStream stream; + + unsigned int argCount = instance.GetStackTop(); + instance.GetGlobal("tostring"); + for (unsigned int i = 1; i <= argCount; ++i) + { + instance.PushValue(-1); // tostring function + instance.PushValue(i); // argument + instance.Call(1, 1); + + std::size_t length; + const char* str = instance.CheckString(-1, &length); + if (i > 1) + stream << '\t'; + + stream << Nz::String(str, length); + instance.Pop(1); + } + + consoleRef.AddLine(stream); + return 0; + }); + overlay->lua.SetGlobal("print"); + + // Define a few base variables to allow our interface to interact with the application + overlay->lua.PushGlobal("Application", Ndk::Application::Instance()); + overlay->lua.PushGlobal("Console", consoleRef.CreateHandle()); + + // Setup a few event callback to handle the console + Nz::EventHandler& eventHandler = info.window->GetEventHandler(); + + overlay->eventSlot.Connect(eventHandler.OnEvent, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent& event) + { + if (consoleRef.IsVisible()) + consoleRef.SendEvent(event); + }); + + overlay->keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& event) + { + if (event.code == Nz::Keyboard::F9) + consoleRef.Show(!consoleRef.IsVisible()); + }); + + overlay->resizedSlot.Connect(eventHandler.OnResized, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::SizeEvent& event) + { + consoleRef.SetSize({float(event.width), event.height / 4.f}); + }); + + info.console = std::move(overlay); + } + + void Application::SetupFPSCounter(WindowInfo& info) + { + std::unique_ptr fpsCounter = std::make_unique(); + fpsCounter->sprite = Nz::TextSprite::New(); + + fpsCounter->entity = info.overlayWorld->CreateEntity(); + fpsCounter->entity->AddComponent(); + fpsCounter->entity->AddComponent().Attach(fpsCounter->sprite); + + info.fpsCounter = std::move(fpsCounter); + } + + void Application::SetupOverlay(WindowInfo& info) + { + info.overlayWorld = std::make_unique(false); //< No default system + + RenderSystem& renderSystem = info.overlayWorld->AddSystem(); + renderSystem.ChangeRenderTechnique(); + renderSystem.SetDefaultBackground(nullptr); + renderSystem.SetGlobalUp(Nz::Vector3f::Down()); + + EntityHandle viewer = info.overlayWorld->CreateEntity(); + CameraComponent& camComponent = viewer->AddComponent(); + viewer->AddComponent(); + + camComponent.SetProjectionType(Nz::ProjectionType_Orthogonal); + camComponent.SetTarget(info.renderTarget); + } + Application* Application::s_application = nullptr; } \ No newline at end of file diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index bf66cbf00..35c59ae68 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -17,7 +17,14 @@ namespace Ndk #ifndef NDK_SERVER //application.SetMethod("AddWindow", &Application::AddWindow); + + application.BindMethod("EnableConsole", &Application::EnableConsole); + application.BindMethod("EnableFPSCounter", &Application::EnableFPSCounter); + + application.BindMethod("IsConsoleEnabled", &Application::IsConsoleEnabled); + application.BindMethod("IsFPSCounterEnabled", &Application::IsFPSCounterEnabled); #endif + application.BindMethod("AddWorld", [] (Nz::LuaInstance& instance, Application* application) -> int { instance.Push(application->AddWorld().CreateHandle()); diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 0a471acee..b1e7e2a64 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -256,81 +256,19 @@ int main() // On lie la caméra à la fenêtre cameraComp.SetTarget(&window); - // Et on créé deux horloges pour gérer le temps - Nz::Clock secondClock, updateClock; + // Et on créé une horloge pour gérer le temps + Nz::Clock updateClock; Nz::UInt64 updateAccumulator = 0; - // Ainsi qu'un compteur de FPS improvisé - unsigned int fps = 0; - // Quelques variables de plus pour notre caméra bool smoothMovement = true; Nz::Vector3f targetPos = cameraNode.GetPosition(); - // Pour ajouter une console à notre application, nous avons besoin d'un monde 2D pour gérer ces rendus - Ndk::WorldHandle world2D = application.AddWorld().CreateHandle(); - world2D->GetSystem().SetDefaultBackground(nullptr); - world2D->GetSystem().SetGlobalUp(Nz::Vector3f::Down()); - - // Nous ajoutons une caméra comme précédement - Ndk::EntityHandle viewEntity = world2D->CreateEntity(); - viewEntity->AddComponent(); - - // À la différence que celui-ci effectuera une projection orthogonale - Ndk::CameraComponent& viewer = viewEntity->AddComponent(); - viewer.SetTarget(&window); - viewer.SetProjectionType(Nz::ProjectionType_Orthogonal); - - // Nous créons un environnement Lua pour gérer nos scripts - Nz::LuaInstance lua; - - // Faisons en sorte d'enregistrer les classes du moteur dans cet environnement - Ndk::LuaAPI::RegisterClasses(lua); - - // Ensuite nous créons la console en elle-même - Ndk::Console console(*world2D, Nz::Vector2f(window.GetWidth(), window.GetHeight() / 4), lua); - - // Nous redirigeons les logs vers cette console - Nz::Log::OnLogWriteType::ConnectionGuard logGuard = Nz::Log::OnLogWrite.Connect([&console] (const Nz::String& str) - { - console.AddLine(str); - }); - - // Nous réécrivons la fonction "print" du Lua pour la rediriger vers la console - lua.PushFunction([&console] (Nz::LuaInstance& instance) - { - Nz::StringStream stream; - - unsigned int argCount = instance.GetStackTop(); - instance.GetGlobal("tostring"); - for (unsigned int i = 1; i <= argCount; ++i) - { - instance.PushValue(-1); // ToString - instance.PushValue(i); // Arg - instance.Call(1, 1); - - std::size_t length; - const char* str = instance.CheckString(-1, &length); - if (i > 1) - stream << '\t'; - - stream << Nz::String(str, length); - instance.Pop(1); - } - - console.AddLine(stream); - return 0; - }); - lua.SetGlobal("print"); - - // Définissons quelques variables de base - lua.PushGlobal("Application", Ndk::Application::Instance()); - lua.PushGlobal("Console", console.CreateHandle()); - lua.PushGlobal("Spaceship", spaceship->CreateHandle()); - lua.PushGlobal("World", world->CreateHandle()); - window.EnableEventPolling(true); // Déprécié + application.EnableConsole(true); + application.EnableFPSCounter(true); + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) while (application.Run()) { @@ -342,8 +280,12 @@ int main() { case Nz::WindowEventType_MouseMoved: // La souris a bougé { - if (console.IsVisible()) - break; + if (application.IsConsoleEnabled()) + { + Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay(); + if (consoleOverlay.console->IsVisible()) + break; + } // Gestion de la caméra free-fly (Rotation) float sensitivity = 0.3f; // Sensibilité de la souris @@ -368,9 +310,6 @@ int main() break; case Nz::WindowEventType_KeyPressed: // Une touche a été pressée ! - if (console.IsVisible()) - console.SendEvent(event); - if (event.key.code == Nz::Keyboard::Key::Escape) window.Close(); else if (event.key.code == Nz::Keyboard::F1) @@ -383,19 +322,6 @@ int main() else smoothMovement = true; } - else if (event.key.code == Nz::Keyboard::F9) - console.Show(!console.IsVisible()); - break; - - case Nz::WindowEventType_TextEntered: - { - if (console.IsVisible()) - console.SendCharacter(event.text.character); - break; - } - - case Nz::WindowEventType_Resized: - console.SetSize({float(event.size.width), event.size.height / 4.f}); break; default: @@ -419,7 +345,16 @@ int main() // Vitesse de déplacement de la caméra float cameraSpeed = 3.f * elapsedTime; // Trois mètres par seconde - if (!console.IsVisible()) + bool move = true; + + if (application.IsConsoleEnabled()) + { + Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay(); + if (consoleOverlay.console->IsVisible()) + move = false; + } + + if (move) { // Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space)) @@ -460,28 +395,6 @@ int main() // Après avoir dessiné sur la fenêtre, il faut s'assurer qu'elle affiche cela // Cet appel ne fait rien d'autre qu'échanger les buffers de rendu (Double Buffering) window.Display(); - - // On incrémente le compteur de FPS improvisé - fps++; - - if (secondClock.GetMilliseconds() >= 1000) // Toutes les secondes - { - // Et on insère ces données dans le titre de la fenêtre - window.SetTitle(windowTitle + " - " + Nz::String::Number(fps) + " FPS"); - - /* - Note: En C++11 il est possible d'insérer de l'Unicode de façon standard, quel que soit l'encodage du fichier, - via quelque chose de similaire à u8"Cha\u00CEne de caract\u00E8res". - Cependant, si le code source est encodé en UTF-8 (Comme c'est le cas dans ce fichier), - cela fonctionnera aussi comme ceci : "Chaîne de caractères". - */ - - // Et on réinitialise le compteur de FPS - fps = 0; - - // Et on relance l'horloge pour refaire ça dans une seconde - secondClock.Restart(); - } } return EXIT_SUCCESS; From 11baa02ec32affb96e1f27a7f46264da52de2fe8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:16:35 +0200 Subject: [PATCH 241/383] SdkServer: Fix compilation Former-commit-id: ea7163d5af56b3e08b865d0fb6ac5aacc5ec9ab4 [formerly 3fcbe74d2738776bc3f92f59a572931f82aacf5a] [formerly 1f83d4bc4e639999892376bd7328536878b36ff4 [formerly d1617dde160d6b1415758f57759581b537f241ff]] Former-commit-id: b44ee9651c91d2362e61cb661479849d03a09e82 [formerly 34a3c0fb2093a9de6130b5d0d784e6dd76ae22c8] Former-commit-id: 6a87eec688dd737da6ec80ef882c9ce1fd168933 --- SDK/include/NDK/Application.inl | 15 ++++++++++++++- SDK/src/NDK/Application.cpp | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 19013c778..d7e0325d9 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -74,7 +74,6 @@ namespace Ndk * * \param args Arguments used to create the window */ - #ifndef NDK_SERVER template T& Application::AddWindow(Args&&... args) @@ -125,6 +124,7 @@ namespace Ndk * * \param enable Should the console overlay be enabled */ + #ifndef NDK_SERVER inline void Application::EnableConsole(bool enable) { if (enable != ((m_overlayFlags & OverlayFlags_Console) != 0)) @@ -157,12 +157,14 @@ namespace Ndk } } } + #endif /*! * \brief Enable/disable debug FPS counter * * \param enable Should the FPS counter be displayed */ + #ifndef NDK_SERVER inline void Application::EnableFPSCounter(bool enable) { if (enable != ((m_overlayFlags & OverlayFlags_FPSCounter) != 0)) @@ -195,6 +197,7 @@ namespace Ndk } } } + #endif /*! * \brief Gets the console overlay for a specific window @@ -207,6 +210,7 @@ namespace Ndk * * \see IsConsoleOverlayEnabled */ + #ifndef NDK_SERVER inline Application::ConsoleOverlay& Application::GetConsoleOverlay(std::size_t windowIndex) { NazaraAssert(m_overlayFlags & OverlayFlags_Console, "Console overlay is not enabled"); @@ -214,6 +218,7 @@ namespace Ndk return *m_windows[windowIndex].console; } + #endif /*! * \brief Gets the console overlay for a specific window @@ -226,6 +231,7 @@ namespace Ndk * * \see IsFPSCounterEnabled */ + #ifndef NDK_SERVER inline Application::FPSCounterOverlay& Application::GetFPSCounterOverlay(std::size_t windowIndex) { NazaraAssert(m_overlayFlags & OverlayFlags_FPSCounter, "FPS counter overlay is not enabled"); @@ -233,6 +239,7 @@ namespace Ndk return *m_windows[windowIndex].fpsCounter; } + #endif /*! * \brief Gets the update time of the application @@ -252,10 +259,12 @@ namespace Ndk * * \see GetConsoleOverlay */ + #ifndef NDK_SERVER inline bool Application::IsConsoleEnabled() const { return (m_overlayFlags & OverlayFlags_Console) != 0; } + #endif /*! * \brief Checks if the FPS counter overlay is enabled @@ -263,10 +272,12 @@ namespace Ndk * * \see GetFPSCounterOverlay */ + #ifndef NDK_SERVER inline bool Application::IsFPSCounterEnabled() const { return (m_overlayFlags & OverlayFlags_FPSCounter) != 0; } + #endif /*! * \brief Makes the application exit when there's no more open window @@ -299,9 +310,11 @@ namespace Ndk return s_application; } + #ifndef NDK_SERVER inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : window(std::move(window)), renderTarget(nullptr) { } + #endif } diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index c4492eb0f..bce62093a 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -87,6 +87,7 @@ namespace Ndk return true; } + #ifndef NDK_SERVER void Application::SetupConsole(WindowInfo& info) { std::unique_ptr overlay = std::make_unique(); @@ -184,6 +185,7 @@ namespace Ndk camComponent.SetProjectionType(Nz::ProjectionType_Orthogonal); camComponent.SetTarget(info.renderTarget); } + #endif Application* Application::s_application = nullptr; } \ No newline at end of file From c1835575c62e179e8e6d21b615dfca5219621811 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 18:26:35 +0200 Subject: [PATCH 242/383] Example/FirstScene: Setup Spaceship and World lua variables Former-commit-id: c113b91b5b13018cecab3e54fd74a92f728745eb [formerly ee0a0b6d6bfe0a1b66a85bf00700bbd2665a71b1] [formerly 626c1b3e83cf5c1d6fb381c75a93da461c2fcdbc [formerly 70589bc22f397ac5e3e3981e1e6963dafaf498f6]] Former-commit-id: 86c08c93a0f18ef60d9cc2d73f229ce6988c81c9 [formerly e9a73b6e5d65a109fe92e13c81625d9a3e54b2a1] Former-commit-id: 567a523fd81ac349eb7268299e928396d20dedca --- examples/FirstScene/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index b1e7e2a64..e7c5b2c90 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -269,6 +269,10 @@ int main() application.EnableConsole(true); application.EnableFPSCounter(true); + Ndk::Application::ConsoleOverlay& consoleOverlay = application.GetConsoleOverlay(); + consoleOverlay.lua.PushGlobal("Spaceship", spaceship->CreateHandle()); + consoleOverlay.lua.PushGlobal("World", world->CreateHandle()); + // Début de la boucle de rendu du programme (s'occupant par exemple de mettre à jour le monde) while (application.Run()) { From 303fe658cf91f9674209f8affb4128a79227f15f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 19:03:43 +0200 Subject: [PATCH 243/383] Lua/LuaInstance: Add move constructor/operator Former-commit-id: 8d5b28036983597b7b0fc324aa3795d25a9719b8 [formerly f4b8d4e3a69c0af27d909d9efd75b6480ab10126] [formerly f4574b549cc7645cdabb6d2aacb630090648753c [formerly 3ea26bacc97d0e3bd3ca69aabd29f243d07fb869]] Former-commit-id: 40f99457abbf7ed6a24760c2e62e3750d7866315 [formerly 6b881febbb5a07ab25b3e5e3580f9b8717a454d7] Former-commit-id: a5d8a7c3f8731c4dd9d3b059ebf04cd1598dacc7 --- include/Nazara/Lua/LuaInstance.hpp | 4 ++-- include/Nazara/Lua/LuaInstance.inl | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index 9affe6f87..e3bc517f8 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -31,7 +31,7 @@ namespace Nz public: LuaInstance(); LuaInstance(const LuaInstance&) = delete; - LuaInstance(LuaInstance&&) = delete; ///TODO + inline LuaInstance(LuaInstance&& instance) noexcept; ~LuaInstance(); void ArgCheck(bool condition, unsigned int argNum, const char* error); @@ -172,7 +172,7 @@ namespace Nz void* ToUserdata(int index, const String& tname) const; LuaInstance& operator=(const LuaInstance&) = delete; - LuaInstance& operator=(LuaInstance&&) = delete; ///TODO + inline LuaInstance& operator=(LuaInstance&& instance) noexcept; static int GetIndexOfUpValue(int upValue); static LuaInstance* GetInstance(lua_State* state); diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index 24d4fcf34..f9f5e662f 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -13,6 +13,33 @@ namespace Nz { + inline LuaInstance::LuaInstance(LuaInstance&& instance) noexcept : + m_memoryLimit(instance.m_memoryLimit), + m_memoryUsage(instance.m_memoryUsage), + m_timeLimit(m_timeLimit), + m_clock(std::move(m_clock)), + m_lastError(std::move(m_lastError)), + m_state(m_state), + m_level(m_level) + { + instance.m_state = nullptr; + } + + inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept + { + m_clock = std::move(m_clock); + m_lastError = std::move(m_lastError); + m_level = m_level; + m_memoryLimit = instance.m_memoryLimit; + m_memoryUsage = instance.m_memoryUsage; + m_state = m_state; + m_timeLimit = m_timeLimit; + + instance.m_state = nullptr; + + return *this; + } + // Functions args inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, bool* arg, TypeTag) { From 8caeba0a483d206f6980c2df5cfc053702b59057 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 19:53:38 +0200 Subject: [PATCH 244/383] Sdk/Application: Fix AddWindow Former-commit-id: 16b652d622e895dbb89dce0ce1a7cc4a4b19746c [formerly d34c513b12324c63a27d4baedb36e8ac41985710] [formerly 3f16d8cf446b553c3a4667efee3229c36c19f402 [formerly 0be44914271824bb2550ba775568c7efca8f9894]] Former-commit-id: b4ae45478a325782a2e7965e4f8115f4fd93ad90 [formerly 2c4f33beaa320b216274c325c87cdb7b0fa5e1d4] Former-commit-id: f68b68712b97356d50f76f3b444a81dddedbe210 --- SDK/include/NDK/Application.hpp | 3 +++ SDK/include/NDK/Application.inl | 48 +++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 5eca90961..7f4af6679 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -117,6 +117,9 @@ namespace Ndk void SetupFPSCounter(WindowInfo& info); void SetupOverlay(WindowInfo& info); + template void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/); + template void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/); + std::vector m_windows; #endif std::list m_worlds; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index d7e0325d9..a36ee3a13 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -85,21 +85,7 @@ namespace Ndk T& window = static_cast(*info.window.get()); //< Warning: ugly - if (std::is_base_of()) - { - info.renderTarget = &window; - - if (m_overlayFlags) - { - SetupOverlay(info); - - if (m_overlayFlags & OverlayFlags_Console) - SetupConsole(info); - - if (m_overlayFlags & OverlayFlags_FPSCounter) - SetupFPSCounter(info); - } - } + SetupWindow(info, &window, std::is_base_of()); return window; } @@ -138,7 +124,10 @@ namespace Ndk } for (WindowInfo& info : m_windows) - SetupConsole(info); + { + if (info.renderTarget) + SetupConsole(info); + } m_overlayFlags |= OverlayFlags_Console; @@ -178,7 +167,10 @@ namespace Ndk } for (WindowInfo& info : m_windows) - SetupFPSCounter(info); + { + if (info.renderTarget) + SetupFPSCounter(info); + } m_overlayFlags |= OverlayFlags_FPSCounter; @@ -310,6 +302,28 @@ namespace Ndk return s_application; } + template + inline void Application::SetupWindow(WindowInfo& info, T* renderTarget, std::true_type) + { + info.renderTarget = renderTarget; + + if (m_overlayFlags) + { + SetupOverlay(info); + + if (m_overlayFlags & OverlayFlags_Console) + SetupConsole(info); + + if (m_overlayFlags & OverlayFlags_FPSCounter) + SetupFPSCounter(info); + } + } + + template + inline void Application::SetupWindow(WindowInfo&, T*, std::false_type) + { + } + #ifndef NDK_SERVER inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : window(std::move(window)), From f0787cb5051583c5cff4786f933706434958c78c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 21:47:29 +0200 Subject: [PATCH 245/383] Sdk/Application: Add command-line arguments handling Former-commit-id: 9f98c2fea531e23540c213d3c1e4c85391fc9e1a [formerly b3cb8fff86ac0a754b72baf9e6278f20b407ef17] [formerly 8665dec44d98961698bdeaa63e670e2e15de7d1d [formerly d8dfeaae490b2efd430599f2b1fa02c531aa4de6]] Former-commit-id: 51c00f9263c4c7e193bf2ca8de860e03e9d0f402 [formerly d09b90f14e62f85c0056bf4ba872d9975efde1eb] Former-commit-id: f82b2332083d6d6099ebece01e239c99d15f3b5f --- SDK/include/NDK/Application.hpp | 11 ++++- SDK/include/NDK/Application.inl | 80 ++++++++++++++++++++++++++------- SDK/src/NDK/Application.cpp | 49 ++++++++++++++++++++ examples/Tut00/main.cpp | 16 +++---- examples/Tut01/main.cpp | 4 +- 5 files changed, 132 insertions(+), 28 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 7f4af6679..84b331e95 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,7 @@ namespace Ndk #endif inline Application(); - inline Application(int argc, const char* argv[]); + Application(int argc, char* argv[]); Application(const Application&) = delete; Application(Application&&) = delete; inline ~Application(); @@ -53,8 +54,14 @@ namespace Ndk inline FPSCounterOverlay& GetFPSCounterOverlay(std::size_t windowIndex = 0U); #endif + inline const std::set& GetOptions() const; + inline const std::map& GetParameters() const; + inline float GetUpdateTime() const; + inline bool HasOption(const Nz::String& option) const; + inline bool HasParameter(const Nz::String& key, Nz::String* value) const; + #ifndef NDK_SERVER inline bool IsConsoleEnabled() const; inline bool IsFPSCounterEnabled() const; @@ -120,6 +127,8 @@ namespace Ndk template void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/); template void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/); + std::map m_parameters; + std::set m_options; std::vector m_windows; #endif std::list m_worlds; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index a36ee3a13..7701160c5 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -33,22 +33,6 @@ namespace Ndk Sdk::Initialize(); } - /*! - * \brief Constructs an Application object with command-line arguments - * - * Pass the argc and argv arguments from the main function. - * - * Command-line arguments can be retrieved by application methods - * - * This calls Sdk::Initialize() - * - * \remark Only one Application instance can exist at a time - */ - inline Application::Application(int argc, const char* argv[]) : - Application() - { - } - /*! * \brief Destructs the application object * @@ -233,6 +217,30 @@ namespace Ndk } #endif + /*! + * \brief Gets the options used to start the application + * + * Options are defined as "-optionName" in command-line and are always lower-case + * + * \return Command-line options + */ + inline const std::set& Application::GetOptions() const + { + return m_options; + } + + /*! + * \brief Gets the parameters used to start the application + * + * Parameters are defined as "-key=value" in command-line, their key is lower-case but value capitals are kept. + * + * \return Command-line parameters + */ + inline const std::map& Application::GetParameters() const + { + return m_parameters; + } + /*! * \brief Gets the update time of the application * \return Update rate @@ -242,6 +250,46 @@ namespace Ndk return m_updateTime; } + /*! + * \brief Query for a command-line option + * + * \param option Option name + * + * \remark option must be lower-case + * + * \return True if option is present + * + * \see GetOptions + */ + inline bool Application::HasOption(const Nz::String& option) const + { + return m_options.count(option) != 0; + } + + /*! + * \brief Query for a command-line option + * + * \param key Parameter name + * \param value Optional string to receive the parameter value + * + * \remark key must be lower-case + * + * \return True if parameter is present + * + * \see GetParameters + */ + inline bool Application::HasParameter(const Nz::String& key, Nz::String* value) const + { + auto it = m_parameters.find(key); + if (it == m_parameters.end()) + return false; + + if (value) + *value = it->second; + + return true; + } + /*! * \brief Checks if the console overlay is enabled * diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index bce62093a..71301a13b 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include #ifndef NDK_SERVER #include @@ -21,6 +22,54 @@ namespace Ndk * \brief NDK class that represents the application, it offers a set of tools to ease the development */ + /*! + * \brief Constructs an Application object with command-line arguments + * + * Pass the argc and argv arguments from the main function. + * + * Command-line arguments can be retrieved by application methods + * + * This calls Sdk::Initialize() + * + * \remark Only one Application instance can exist at a time + */ + inline Application::Application(int argc, char* argv[]) : + Application() + { + std::regex optionRegex(R"(-(\w+))"); + std::regex valueRegex(R"(-(\w+)\s*=\s*(.+))"); + + std::smatch results; + + for (int i = 1; i < argc; ++i) + { + std::string argument(argv[i]); + if (std::regex_match(argument, results, valueRegex)) + { + Nz::String key(results[1].str()); + Nz::String value(results[2].str()); + + m_parameters[key.ToLower()] = value; + NazaraDebug("Registred parameter from command-line: " + key.ToLower() + "=" + value); + } + else if (std::regex_match(argument, results, optionRegex)) + { + Nz::String option(results[1].str()); + + m_options.insert(option); + NazaraDebug("Registred option from command-line: " + option); + } + else + NazaraWarning("Ignored command-line argument #" + Nz::String::Number(i) + " \"" + argument + '"'); + } + + if (HasOption("console")) + EnableConsole(true); + + if (HasOption("fpscounter")) + EnableFPSCounter(true); + } + /*! * \brief Runs the application by updating worlds, taking care about windows, ... */ diff --git a/examples/Tut00/main.cpp b/examples/Tut00/main.cpp index 472db3148..cfffa4c59 100644 --- a/examples/Tut00/main.cpp +++ b/examples/Tut00/main.cpp @@ -9,16 +9,14 @@ #include #include #include -#include -#include -int main() +int main(int argc, char* argv[]) { - // This "example" has only one purpose: Giving an empty project for you to test whatever you want - // If you wish to have multiple test projects, you only have to copy/paste this directory and change the name in the build.lua - Ndk::Application app; + // This "example" has only one purpose: Giving an empty project for you to test whatever you want + // If you wish to have multiple test projects, you only have to copy/paste this directory and change the name in the build.lua + Ndk::Application application(argc, argv); - // Do what you want here - - return EXIT_SUCCESS; + // Do what you want here + + return EXIT_SUCCESS; } \ No newline at end of file diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index f5fca94a0..9c33f6859 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -9,9 +9,9 @@ #include #include -int main() +int main(int argc, char* argv[]) { - Ndk::Application application; + Ndk::Application application(argc, argv); Nz::RenderWindow& mainWindow = application.AddWindow(); mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test"); From 88b54cb43ee4386494c923b002bc22ee945e9dac Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 28 Aug 2016 21:47:46 +0200 Subject: [PATCH 246/383] Sdk/Application: Fix crash when debug overlay are not used Former-commit-id: 25880e8ab32685946949a482537c85bd7ecc6225 [formerly 4c63a6c83734c26a1cd5741df796b2f5c43315e1] [formerly 6ecf816f9e269a958a0e6ac73e9b8f19ef00c51e [formerly feebf9391f65fcd2cb97fcc8992186ce83902a90]] Former-commit-id: 81fe40e209049bac74ad4bf694260e5ea19fdad0 [formerly 9f7291baf0f2d8c4e4668058dfb5a411c6bb3f2a] Former-commit-id: 26d073e246b875b4c6e0fe64f9562106e3239dbd --- SDK/src/NDK/Application.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 71301a13b..8ecb5d454 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -114,6 +114,9 @@ namespace Ndk #ifndef NDK_SERVER for (WindowInfo& info : m_windows) { + if (!info.overlayWorld) + continue; + if (info.fpsCounter) { FPSCounterOverlay& fpsCounter = *info.fpsCounter; From 11f4464d909f48bdad5be12a8abc64a75b58c3df Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 02:33:57 +0200 Subject: [PATCH 247/383] SDK: Fix console layer having trouble with late constructed windows Former-commit-id: 1af4cce1d920401963c3693661c19f0af5d23641 [formerly c5fb7cf9da6dd18a887b5d67fc2f43c135d5bee2] [formerly 9718a9b7c1bf161b46c085a82ab1bce46c045d6d [formerly cb26a07e6ce48b30727195e8f26e6fc6670ff86a]] Former-commit-id: ccd4866237e7d9d6cd3a83ff6a030d8acd053010 [formerly 9745165a6b024df81317dc96126e8209bee4bd32] Former-commit-id: 43b65ae9fb7793e9a9e79d1e8e9a718e4c3edce3 --- SDK/include/NDK/Application.hpp | 2 +- SDK/src/NDK/Application.cpp | 13 ++++++++++--- src/Nazara/Utility/Window.cpp | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 84b331e95..8c0eb18a9 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -88,7 +88,7 @@ namespace Ndk NazaraSlot(Nz::EventHandler, OnEvent, eventSlot); NazaraSlot(Nz::EventHandler, OnKeyPressed, keyPressedSlot); - NazaraSlot(Nz::EventHandler, OnResized, resizedSlot); + NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, resizedSlot); NazaraSlot(Nz::Log, OnLogWrite, logSlot); }; diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 8ecb5d454..68396f128 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -144,9 +144,16 @@ namespace Ndk { std::unique_ptr overlay = std::make_unique(); - overlay->console = std::make_unique(*info.overlayWorld, Nz::Vector2f(Nz::Vector2ui(info.window->GetWidth(), info.window->GetHeight() / 4)), overlay->lua); + Nz::Vector2ui windowDimensions; + if (info.window->IsValid()) + windowDimensions.Set(info.window->GetWidth(), info.window->GetHeight() / 4); + else + windowDimensions.MakeZero(); + + overlay->console = std::make_unique(*info.overlayWorld, Nz::Vector2f(windowDimensions), overlay->lua); Console& consoleRef = *overlay->console; + // Redirect logs toward the console overlay->logSlot.Connect(Nz::Log::OnLogWrite, [&consoleRef] (const Nz::String& str) { @@ -201,9 +208,9 @@ namespace Ndk consoleRef.Show(!consoleRef.IsVisible()); }); - overlay->resizedSlot.Connect(eventHandler.OnResized, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::SizeEvent& event) + overlay->resizedSlot.Connect(info.renderTarget->OnRenderTargetSizeChange, [&consoleRef] (const Nz::RenderTarget* renderTarget) { - consoleRef.SetSize({float(event.width), event.height / 4.f}); + consoleRef.SetSize({float(renderTarget->GetWidth()), renderTarget->GetHeight() / 4.f}); }); info.console = std::move(overlay); diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 02ed0f40a..7ba78dcb9 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -60,25 +61,22 @@ namespace Nz else if (style & WindowStyle_Closable || style & WindowStyle_Resizable) style |= WindowStyle_Titlebar; - m_impl = new WindowImpl(this); - if (!m_impl->Create(mode, title, style)) + std::unique_ptr impl = std::make_unique(this); + if (!impl->Create(mode, title, style)) { NazaraError("Failed to create window implementation"); - delete m_impl; - m_impl = nullptr; - return false; } + m_impl = impl.release(); + CallOnExit destroyOnFailure([this] () { Destroy(); }); + m_closed = false; m_ownsWindow = true; if (!OnWindowCreated()) { NazaraError("Failed to initialize window extension"); - delete m_impl; - m_impl = nullptr; - return false; } @@ -93,6 +91,10 @@ namespace Nz if (opened) m_impl->SetPosition(position.x, position.y); + OnWindowResized(); + + destroyOnFailure.Reset(); + return true; } From bb4b3080a355114362601c354abd1d46c9f96140 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 02:34:08 +0200 Subject: [PATCH 248/383] Lua/LuaInstance: Fix crash on moving Former-commit-id: da33b3c1be47ac876f5182ea30c89655ef1acac7 [formerly 14a7b0dc844cedaf02e16f5f61eaeab45e460e51] [formerly 5cebc7a6120670cbddad7983b688f0e02567c4d0 [formerly 2502f975d80666cd945224e477b26997d2e73e3b]] Former-commit-id: fbaee399b1bd606ff35e02f44dcd4aa4526464eb [formerly 85ff422793775d2bfd79a42b22ddb15fb2a19e72] Former-commit-id: 468f7f1b5f35c12c8f8d1e49053947b60fd33893 --- src/Nazara/Lua/LuaInstance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index 0ecf4c063..f31c6fe83 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -145,7 +145,8 @@ namespace Nz LuaInstance::~LuaInstance() { - lua_close(m_state); + if (m_state) + lua_close(m_state); } void LuaInstance::ArgCheck(bool condition, unsigned int argNum, const char* error) From 42db00a52c623a2b75ed8fd38c7173137cc8ce42 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 13:32:16 +0200 Subject: [PATCH 249/383] Example/Tut01: Improve background color Former-commit-id: 883a1115cb7fee2581c8a00db0e194482cf6561e [formerly 29bf1560e1953cf52b5c78ccff06cd4505412da3] [formerly a455d8601a37dff40f7f19b3298a7bab86f721ac [formerly 845a30ade4c32adba2d3b031c5bdf85ebbefb7bf]] Former-commit-id: cda183f3e044cf0798db4e356fc053286e22613d [formerly 17e2ff120bc690719ae5f9eb466afb8fb7728270] Former-commit-id: e1cd50d13b37cfc293a0405093e0fb57f3990c58 --- examples/Tut01/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Tut01/main.cpp b/examples/Tut01/main.cpp index 9c33f6859..b5e07074d 100644 --- a/examples/Tut01/main.cpp +++ b/examples/Tut01/main.cpp @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) Ndk::World& world = application.AddWorld(); world.GetSystem().SetGlobalUp(Nz::Vector3f::Down()); - world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(192, 100, 100))); + world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(117, 122, 214))); Ndk::EntityHandle viewEntity = world.CreateEntity(); From 3abaa6e5080fc4258e4d8b494c61ecd25972ac48 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 29 Aug 2016 18:16:33 +0200 Subject: [PATCH 250/383] Sdk/Application: Fix compilation in server mode Former-commit-id: a7dbe8b6e7c6b37c77b7fac62eaed60031d55f3c [formerly dfdc15e7fc150b930dbbff78aa50977cfb8a4721] [formerly 0829205432c0038facb131e46eb985253af9fb53 [formerly d651dccd41733fd467a0fbc21217baa1aa8c632c]] Former-commit-id: e1b114ffabe598f6eeb57671de06c7323b764aa1 [formerly ba92c6a3ae9c0851ace35830ac03d2b70f5dcca2] Former-commit-id: 4e8dc732d05a1f7d11b0b9b78c8b425ac59fa2f8 --- SDK/include/NDK/Application.hpp | 6 ++++-- SDK/include/NDK/Application.inl | 2 +- SDK/src/NDK/Application.cpp | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Application.hpp b/SDK/include/NDK/Application.hpp index 8c0eb18a9..b3f803fe1 100644 --- a/SDK/include/NDK/Application.hpp +++ b/SDK/include/NDK/Application.hpp @@ -127,12 +127,14 @@ namespace Ndk template void SetupWindow(WindowInfo& info, T* renderTarget, std::true_type /*isRenderTarget*/); template void SetupWindow(WindowInfo& /*info*/, T* /*renderTarget*/, std::false_type /*isNotRenderTarget*/); - std::map m_parameters; - std::set m_options; std::vector m_windows; #endif + + std::map m_parameters; + std::set m_options; std::list m_worlds; Nz::Clock m_updateClock; + #ifndef NDK_SERVER Nz::UInt32 m_overlayFlags; bool m_exitOnClosedWindows; diff --git a/SDK/include/NDK/Application.inl b/SDK/include/NDK/Application.inl index 7701160c5..2c74acb19 100644 --- a/SDK/include/NDK/Application.inl +++ b/SDK/include/NDK/Application.inl @@ -350,6 +350,7 @@ namespace Ndk return s_application; } + #ifndef NDK_SERVER template inline void Application::SetupWindow(WindowInfo& info, T* renderTarget, std::true_type) { @@ -372,7 +373,6 @@ namespace Ndk { } - #ifndef NDK_SERVER inline Application::WindowInfo::WindowInfo(std::unique_ptr&& window) : window(std::move(window)), renderTarget(nullptr) diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 68396f128..3cdff6978 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include #include #ifndef NDK_SERVER @@ -63,11 +64,13 @@ namespace Ndk NazaraWarning("Ignored command-line argument #" + Nz::String::Number(i) + " \"" + argument + '"'); } + #ifndef NDK_SERVER if (HasOption("console")) EnableConsole(true); if (HasOption("fpscounter")) EnableFPSCounter(true); + #endif } /*! From 85b2f416670a0d130e01bb9df073ec5fa9b313a7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 18:20:23 +0200 Subject: [PATCH 251/383] Core/HardwareInfo: Fix indentation (Windows) Former-commit-id: 7ba2d1623489a77445c5f687b329fffd8f85bfc0 [formerly 670207d53279fa6ff6a63ee0c701ac5691b3073c] [formerly 214e08cdb6fa4abe6289c139b62211a806f7545b [formerly 1774090b940bb9046ed51fcb70e7fc89e490cc67]] Former-commit-id: a6ebc85ef52dece75daf2dbd95b73cfad48e957c [formerly 00b7ddd2874d348d452ae8fd0bd668b90b7c4bcd] Former-commit-id: e9dd53029407209f3210cd47b16e1e0070e1ccfd --- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 30 +++++++++---------- .../Shaders/LightScatteringFinal.frag | 18 +++++++++++ .../Shaders/LightScatteringFinal.frag.h | 1 + src/Nazara/Graphics/Sprite.cpp | 10 ++++--- 4 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag create mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 7ce5e10a1..62b86bf91 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -76,25 +76,25 @@ namespace Nz #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) int supported; asm volatile (" pushfl\n" - " pop %%eax\n" - " mov %%eax, %%ecx\n" - " xor $0x200000, %%eax\n" - " push %%eax\n" - " popfl\n" - " pushfl\n" - " pop %%eax\n" - " xor %%ecx, %%eax\n" - " mov %%eax, %0\n" - " push %%ecx\n" - " popfl" - : "=m" (supported) // output - : // input - : "eax", "ecx", "memory"); // clobbered register + " pop %%eax\n" + " mov %%eax, %%ecx\n" + " xor $0x200000, %%eax\n" + " push %%eax\n" + " popfl\n" + " pushfl\n" + " pop %%eax\n" + " xor %%ecx, %%eax\n" + " mov %%eax, %0\n" + " push %%ecx\n" + " popfl" + : "=m" (supported) // output + : // input + : "eax", "ecx", "memory"); // clobbered register return supported != 0; #else return false; #endif #endif -} + } } diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag new file mode 100644 index 000000000..82a05410b --- /dev/null +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag @@ -0,0 +1,18 @@ +#version 140 + +out vec4 RenderTarget0; + +uniform float exposure = 0.92; +uniform sampler2D AccumulationTexture; +uniform sampler2D ColorTexture; +uniform vec2 InvTargetSize; + +void main() +{ + vec2 texCoord = gl_FragCoord.xy * InvTargetSize; + + vec4 color = texture(ColorTexture, texCoord); + vec4 lightScattering = texture(AccumulationTexture, texCoord); + + RenderTarget0 = vec4(lightScattering.rgb * exposure, 1.0) + color * 1.1; +} diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h new file mode 100644 index 000000000..0b0b3fe9d --- /dev/null +++ b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h @@ -0,0 +1 @@ +35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,101,120,112,111,115,117,114,101,32,61,32,48,46,57,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,67,111,108,111,114,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,116,101,120,116,117,114,101,40,67,111,108,111,114,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,9,118,101,99,52,32,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,32,61,32,116,101,120,116,117,114,101,40,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,46,114,103,98,32,42,32,101,120,112,111,115,117,114,101,44,32,49,46,48,41,32,43,32,99,111,108,111,114,32,42,32,49,46,49,59,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 5ef82cddf..23fd28181 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -57,20 +57,22 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); + const Nz::Vector3f origin(m_size.x / 2.f, m_size.y / -2.f, 0.f); + *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 1f2719fd17c5e9d8854b7107e167bd42fc72223a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 19:16:03 +0200 Subject: [PATCH 252/383] Revert "Core/HardwareInfo: Fix indentation (Windows)" This reverts commit a4019076ff9afd3cb7e2d98a54c9788fd2df1457 [formerly 3a39cd2e8a3aa8bb46f9f1465923f2abb8fc19a1] [formerly a23f6beee25e408579609874672806b124bf5fc0 [formerly be4cec088d5683bc18e54fd5daa2805134a88bb9]] [formerly dd94bfecaf16a96cdc39de9abd3c0749f17bf824 [formerly 539605da0eb694cbad2fb52fdb49b9a79c3a0d04] [formerly 00917e0bb4766a6f19f303040241c81a92778185 [formerly 48c4b5219e3d1f74f04099f164712c2baddf1d4b]]]. Former-commit-id: 153fd6ac243aee3971fda0a4a2ec9bed51a4ecbf [formerly 83b196ee86d8689cd331b8ac1e9256fc4158f4bb] [formerly 76dceaeb34c1e3156537ebaa3ba0a73950b03805 [formerly 10f813a3f75ef706c37c3e312ccc58a556b5e1f5]] Former-commit-id: 9e2e56623d1f2b95f013ee0f565a5ffdf0f450b9 [formerly 1e58bd22e6b1070954227f669d92794ce56581a6] Former-commit-id: c5ccf208507c40c8939ce9a92c8f4def6e231b79 --- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 30 +++++++++---------- .../Shaders/LightScatteringFinal.frag | 18 ----------- .../Shaders/LightScatteringFinal.frag.h | 1 - src/Nazara/Graphics/Sprite.cpp | 10 +++---- 4 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag delete mode 100644 src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 62b86bf91..7ce5e10a1 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -76,25 +76,25 @@ namespace Nz #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) int supported; asm volatile (" pushfl\n" - " pop %%eax\n" - " mov %%eax, %%ecx\n" - " xor $0x200000, %%eax\n" - " push %%eax\n" - " popfl\n" - " pushfl\n" - " pop %%eax\n" - " xor %%ecx, %%eax\n" - " mov %%eax, %0\n" - " push %%ecx\n" - " popfl" - : "=m" (supported) // output - : // input - : "eax", "ecx", "memory"); // clobbered register + " pop %%eax\n" + " mov %%eax, %%ecx\n" + " xor $0x200000, %%eax\n" + " push %%eax\n" + " popfl\n" + " pushfl\n" + " pop %%eax\n" + " xor %%ecx, %%eax\n" + " mov %%eax, %0\n" + " push %%ecx\n" + " popfl" + : "=m" (supported) // output + : // input + : "eax", "ecx", "memory"); // clobbered register return supported != 0; #else return false; #endif #endif - } +} } diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag deleted file mode 100644 index 82a05410b..000000000 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag +++ /dev/null @@ -1,18 +0,0 @@ -#version 140 - -out vec4 RenderTarget0; - -uniform float exposure = 0.92; -uniform sampler2D AccumulationTexture; -uniform sampler2D ColorTexture; -uniform vec2 InvTargetSize; - -void main() -{ - vec2 texCoord = gl_FragCoord.xy * InvTargetSize; - - vec4 color = texture(ColorTexture, texCoord); - vec4 lightScattering = texture(AccumulationTexture, texCoord); - - RenderTarget0 = vec4(lightScattering.rgb * exposure, 1.0) + color * 1.1; -} diff --git a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h b/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h deleted file mode 100644 index 0b0b3fe9d..000000000 --- a/src/Nazara/Graphics/Resources/DeferredShading/Shaders/LightScatteringFinal.frag.h +++ /dev/null @@ -1 +0,0 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,117,110,105,102,111,114,109,32,102,108,111,97,116,32,101,120,112,111,115,117,114,101,32,61,32,48,46,57,50,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,115,97,109,112,108,101,114,50,68,32,67,111,108,111,114,84,101,120,116,117,114,101,59,13,10,117,110,105,102,111,114,109,32,118,101,99,50,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,118,101,99,50,32,116,101,120,67,111,111,114,100,32,61,32,103,108,95,70,114,97,103,67,111,111,114,100,46,120,121,32,42,32,73,110,118,84,97,114,103,101,116,83,105,122,101,59,13,10,13,10,9,118,101,99,52,32,99,111,108,111,114,32,61,32,116,101,120,116,117,114,101,40,67,111,108,111,114,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,9,118,101,99,52,32,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,32,61,32,116,101,120,116,117,114,101,40,65,99,99,117,109,117,108,97,116,105,111,110,84,101,120,116,117,114,101,44,32,116,101,120,67,111,111,114,100,41,59,13,10,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,118,101,99,52,40,108,105,103,104,116,83,99,97,116,116,101,114,105,110,103,46,114,103,98,32,42,32,101,120,112,111,115,117,114,101,44,32,49,46,48,41,32,43,32,99,111,108,111,114,32,42,32,49,46,49,59,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 23fd28181..5ef82cddf 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -57,22 +57,20 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); - const Nz::Vector3f origin(m_size.x / 2.f, m_size.y / -2.f, 0.f); - *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(-origin + m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 280bf97ba9d6bde731a32af9da23b6fa5e9b94a9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 19:16:20 +0200 Subject: [PATCH 253/383] Core/HardwareInfo: Fix indentation (Windows) Former-commit-id: 671c53304bd94ae774a8c8520a5c97dbf7177ab6 [formerly fe014ab5c3605ddd3940e3e0c9da9fcc4be324a1] [formerly 51202a9ddac0b11adffc29bb706ec06a62e488c0 [formerly cd17653d4dad37f98c45b4a9293ea14fe86c97c8]] Former-commit-id: df48b40400b2f8e1652f6cb234b2fa0cf103b263 [formerly 59fe6beeb03df44323eaf57ab1f7019c0d3c3313] Former-commit-id: cf1af1dfed868d8a63130616f4e0d0135cd0c87b --- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 7ce5e10a1..62b86bf91 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -76,25 +76,25 @@ namespace Nz #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) int supported; asm volatile (" pushfl\n" - " pop %%eax\n" - " mov %%eax, %%ecx\n" - " xor $0x200000, %%eax\n" - " push %%eax\n" - " popfl\n" - " pushfl\n" - " pop %%eax\n" - " xor %%ecx, %%eax\n" - " mov %%eax, %0\n" - " push %%ecx\n" - " popfl" - : "=m" (supported) // output - : // input - : "eax", "ecx", "memory"); // clobbered register + " pop %%eax\n" + " mov %%eax, %%ecx\n" + " xor $0x200000, %%eax\n" + " push %%eax\n" + " popfl\n" + " pushfl\n" + " pop %%eax\n" + " xor %%ecx, %%eax\n" + " mov %%eax, %0\n" + " push %%ecx\n" + " popfl" + : "=m" (supported) // output + : // input + : "eax", "ecx", "memory"); // clobbered register return supported != 0; #else return false; #endif #endif -} + } } From 3755fc2487b21123882cef54d91802497f8427c0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 31 Aug 2016 20:53:27 +0200 Subject: [PATCH 254/383] Graphics/Sprite: Add Origin parameter Allows you to change center of translation/rotation/scale Former-commit-id: c5e8b3cf4b67e8a2765a4f0984d08bda3d1dc0ec [formerly 20f58bfa832c85f4837f325c3d74b0eef264b2bf] [formerly 830cae0d17c4cef7b538734d6cfe83539689dab3 [formerly 4dc889bfa34a04c59844969bb0d6b08599c1189a]] Former-commit-id: 949b6b78762b7b804e357ee5b3afe35456fd7f2d [formerly 92beb7207e1271941f4053255091d32806a19e9b] Former-commit-id: 5b1d9b37251f0bc3be87aef0ef0c3252ff82b4d0 --- include/Nazara/Graphics/Sprite.hpp | 3 +++ include/Nazara/Graphics/Sprite.inl | 33 +++++++++++++++++++++++++++++- src/Nazara/Graphics/Sprite.cpp | 14 ++++++++----- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index 3660bf872..3aa261d89 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -38,12 +38,14 @@ namespace Nz inline const Color& GetColor() const; inline const MaterialRef& GetMaterial() const; + inline const Vector3f& GetOrigin() const; inline const Vector2f& GetSize() const; inline const Rectf& GetTextureCoords() const; inline void SetColor(const Color& color); inline void SetDefaultMaterial(); inline void SetMaterial(MaterialRef material, bool resizeSprite = true); + inline void SetOrigin(const Vector3f& origin); inline void SetSize(const Vector2f& size); inline void SetSize(float sizeX, float sizeY); inline void SetTexture(TextureRef texture, bool resizeSprite = true); @@ -67,6 +69,7 @@ namespace Nz MaterialRef m_material; Rectf m_textureCoords; Vector2f m_size; + Vector3f m_origin; static SpriteLibrary::LibraryMap s_library; }; diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index f0e05c5a2..2cfc014a2 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -14,6 +14,7 @@ namespace Nz inline Sprite::Sprite() : m_color(Color::White), + m_origin(Nz::Vector3f::Zero()), m_textureCoords(0.f, 0.f, 1.f, 1.f), m_size(64.f, 64.f) { @@ -77,12 +78,23 @@ namespace Nz * \brief Gets the material of the sprite * \return Current material */ - inline const MaterialRef& Sprite::GetMaterial() const { return m_material; } + /*! + * \brief Gets the origin of the sprite + * + * \return Current material + * + * \see SetOrigin + */ + inline const Vector3f & Sprite::GetOrigin() const + { + return m_origin; + } + /*! * \brief Gets the size of the sprite * \return Current size @@ -146,6 +158,24 @@ namespace Nz } } + /*! + * \brief Sets the origin of the sprite + * + * The origin is the center of translation/rotation/scaling of the sprite. + * + * \param origin New origin for the sprite + * + * \see GetOrigin + */ + inline void Sprite::SetOrigin(const Vector3f& origin) + { + m_origin = origin; + + // On invalide la bounding box + InvalidateBoundingVolume(); + InvalidateVertices(); + } + /*! * \brief Sets the size of the sprite * @@ -277,3 +307,4 @@ namespace Nz } #include +#include "Sprite.hpp" diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 5ef82cddf..f4b2f0dab 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -39,7 +39,9 @@ namespace Nz void Sprite::MakeBoundingVolume() const { - m_boundingVolume.Set(Vector3f(0.f), m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); + + m_boundingVolume.Set(-origin, m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); } /*! @@ -57,20 +59,22 @@ namespace Nz SparsePtr posPtr(&vertices[0].position, sizeof(VertexStruct_XYZ_Color_UV)); SparsePtr texCoordPtr(&vertices[0].uv, sizeof(VertexStruct_XYZ_Color_UV)); + Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); + *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(0.f)); + *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 7781a276417d2b6c5dea68e820cec8907311ded7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 1 Sep 2016 13:02:46 +0200 Subject: [PATCH 255/383] Graphics: Clear instances in Clear method Former-commit-id: 66b0db92e353312b6cf3d68526417b5fb77c0bef [formerly 897579017072102b658dc637b91bc52d80a061cd] [formerly 7685fb2c3c18c030ce5a3ac6a29129bd39de88c8 [formerly 7ba2bc156951247f5f7ba7ebfb3d65bced1731e7]] Former-commit-id: a1eb128bba2d28589a7988f6f98a860839c07cfe [formerly 1fed3d7b8cbc84c528ce27db61123ce8fc562e97] Former-commit-id: cc56728a6e0a6b84c4969850287109c8e92281cd --- src/Nazara/Graphics/DeferredGeometryPass.cpp | 7 --- src/Nazara/Graphics/DeferredRenderQueue.cpp | 30 ++++++++++ src/Nazara/Graphics/ForwardRenderQueue.cpp | 56 +++++++++++++++++++ .../Graphics/ForwardRenderTechnique.cpp | 13 +---- 4 files changed, 88 insertions(+), 18 deletions(-) diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 1c4f8b8bb..dbdb95f5a 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -187,18 +187,11 @@ namespace Nz drawFunc(meshData.primitiveMode, 0, indexCount); } } - - instances.clear(); } } } - - // And we set it back data to zero - matEntry.enabled = false; } } - - pipelineEntry.maxInstanceCount = 0; } } } diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 7d214b217..41fb9d20b 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -278,6 +278,36 @@ namespace Nz Layer& layer = it->second; if (layer.clearCount++ >= 100) it = layers.erase(it); + else + { + for (auto& pipelinePair : layer.opaqueModels) + { + const MaterialPipeline* pipeline = pipelinePair.first; + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.maxInstanceCount > 0) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + MeshInstanceContainer& meshInstances = matEntry.meshMap; + + for (auto& meshIt : meshInstances) + { + auto& meshEntry = meshIt.second; + + meshEntry.instances.clear(); + } + matEntry.enabled = false; + } + } + pipelineEntry.maxInstanceCount = 0; + } + } + } } } diff --git a/src/Nazara/Graphics/ForwardRenderQueue.cpp b/src/Nazara/Graphics/ForwardRenderQueue.cpp index 882a6f61e..2de6b66e4 100644 --- a/src/Nazara/Graphics/ForwardRenderQueue.cpp +++ b/src/Nazara/Graphics/ForwardRenderQueue.cpp @@ -527,6 +527,62 @@ namespace Nz layers.erase(it++); else { + for (auto& pipelinePair : layer.basicSprites) + { + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.enabled) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + auto& overlayMap = matEntry.overlayMap; + for (auto& overlayIt : overlayMap) + { + const Texture* overlay = overlayIt.first; + auto& spriteChainVector = overlayIt.second.spriteChains; + + spriteChainVector.clear(); + } + + matEntry.enabled = false; + } + } + pipelineEntry.enabled = false; + } + } + + for (auto& pipelinePair : layer.opaqueModels) + { + auto& pipelineEntry = pipelinePair.second; + + if (pipelineEntry.maxInstanceCount > 0) + { + for (auto& materialPair : pipelineEntry.materialMap) + { + const Material* material = materialPair.first; + auto& matEntry = materialPair.second; + + if (matEntry.enabled) + { + MeshInstanceContainer& meshInstances = matEntry.meshMap; + + for (auto& meshIt : meshInstances) + { + auto& meshEntry = meshIt.second; + + meshEntry.instances.clear(); + } + matEntry.enabled = false; + } + } + pipelineEntry.maxInstanceCount = 0; + } + } + layer.otherDrawables.clear(); layer.transparentModels.clear(); layer.transparentModelData.clear(); diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 91507ee68..959ef2f03 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -386,17 +386,12 @@ namespace Nz vertexMapper.Unmap(); Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, spriteCount * 6); - } while (spriteChain < spriteChainCount); - - spriteChainVector.clear(); + } + while (spriteChain < spriteChainCount); } } - - // We set it back to zero - matEntry.enabled = false; } } - pipelineEntry.enabled = false; } } } @@ -781,12 +776,8 @@ namespace Nz instances.clear(); } } - - matEntry.enabled = false; } } - - pipelineEntry.maxInstanceCount = 0; } } } From cfba75812d3b5f11ee7b2f965208dd0ef6650bf9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 1 Sep 2016 21:07:08 +0200 Subject: [PATCH 256/383] Graphics/Sprite: Fix origin not being initialized/copied Former-commit-id: 2d97bcc693f4883f7ef0dea00ae6f3570ff50799 [formerly 6cd28f90af1105bf9dec88e61b1d483091fdcece] [formerly 9a1b25d55141a14c95e119dd8afbecca9fe25bcd [formerly b680a62e0d73cc74e47ec5c0768f5b5f7f655f68]] Former-commit-id: 9695deaf671680614ab8c0af81ac468867474f77 [formerly 3743b8d8a6bc9585cabcda5e7462b0284e653f5f] Former-commit-id: b0a32e045549e4abb52c9c0b3a933ace3ab7fbef --- include/Nazara/Graphics/Sprite.inl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 2cfc014a2..410b42478 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -14,9 +14,9 @@ namespace Nz inline Sprite::Sprite() : m_color(Color::White), - m_origin(Nz::Vector3f::Zero()), m_textureCoords(0.f, 0.f, 1.f, 1.f), - m_size(64.f, 64.f) + m_size(64.f, 64.f), + m_origin(Nz::Vector3f::Zero()) { SetDefaultMaterial(); } @@ -26,11 +26,8 @@ namespace Nz * * \param material Reference to a material */ - inline Sprite::Sprite(MaterialRef material) : - m_color(Color::White), - m_textureCoords(0.f, 0.f, 1.f, 1.f), - m_size(64.f, 64.f) + Sprite() { SetMaterial(std::move(material), true); } @@ -42,9 +39,7 @@ namespace Nz */ inline Sprite::Sprite(Texture* texture) : - m_color(Color::White), - m_textureCoords(0.f, 0.f, 1.f, 1.f), - m_size(64.f, 64.f) + Sprite() { SetTexture(texture, true); } @@ -60,7 +55,8 @@ namespace Nz m_color(sprite.m_color), m_material(sprite.m_material), m_textureCoords(sprite.m_textureCoords), - m_size(sprite.m_size) + m_size(sprite.m_size), + m_origin(sprite.m_origin) { } @@ -270,6 +266,7 @@ namespace Nz m_color = sprite.m_color; m_material = sprite.m_material; + m_origin = sprite.m_origin; m_textureCoords = sprite.m_textureCoords; m_size = sprite.m_size; From a311ff4cf1ab6aaafba82f13f04e59ddbc9da055 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 3 Sep 2016 21:13:00 +0200 Subject: [PATCH 257/383] Graphics/DeferredRenderQueue: Fix crash on layer removal Former-commit-id: 87fdfb051158d241754eb6f1f811d12e88811a47 [formerly c5ae03d7168851330dd2c087c515c7d30ad863c7] [formerly 0f5debff94e6a37dde830975fd219daf82382d9d [formerly 42297b9b5af5b42e4c12146d930b6641425de8f4]] Former-commit-id: b93ecd34f72724806ea06c6d335a41c7dd1afacb [formerly ad14d199f3ee381221df118b4af2cd647ab8fc24] Former-commit-id: 805f20df11668bf73d35065e23c4912800850427 --- src/Nazara/Graphics/DeferredRenderQueue.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Graphics/DeferredRenderQueue.cpp b/src/Nazara/Graphics/DeferredRenderQueue.cpp index 41fb9d20b..b240edcd7 100644 --- a/src/Nazara/Graphics/DeferredRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredRenderQueue.cpp @@ -273,7 +273,7 @@ namespace Nz layers.clear(); else { - for (auto it = layers.begin(); it != layers.end(); ++it) + for (auto it = layers.begin(); it != layers.end();) { Layer& layer = it->second; if (layer.clearCount++ >= 100) @@ -307,6 +307,8 @@ namespace Nz pipelineEntry.maxInstanceCount = 0; } } + + ++it; } } } From c28ea576f05f25c28d8994556e612ce8dcb07517 Mon Sep 17 00:00:00 2001 From: Ardakaniz Date: Sun, 4 Sep 2016 14:50:38 +0200 Subject: [PATCH 258/383] Utility/EventHandler: Fix OnMouseButtonReleased event Former-commit-id: 90e7b45bfa2ff0efaad03de9f8149b27d1de2059 [formerly 39c8a91094eee32da25ec9f46534552271befd30] [formerly 73bdf966290144c9d18ceb228c88d60d143f0b2f [formerly 7e2aefa781168e192b4ae15f6f8f34ba3ab484fa]] Former-commit-id: 67231fa9b439ea294b3f1e4f7cfe5888663978e3 [formerly 975ca5d0d4ff41d858643b824036fa6818551698] Former-commit-id: ef88d5479c2f2637b213caff7923e444cc4b143d --- include/Nazara/Utility/EventHandler.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Utility/EventHandler.inl b/include/Nazara/Utility/EventHandler.inl index c066b6810..719ffddcb 100644 --- a/include/Nazara/Utility/EventHandler.inl +++ b/include/Nazara/Utility/EventHandler.inl @@ -43,7 +43,7 @@ namespace Nz break; case WindowEventType_MouseButtonReleased: - OnMouseButtonPressed(this, event.mouseButton); + OnMouseButtonReleased(this, event.mouseButton); break; case WindowEventType_MouseEntered: From aabf10cc6123280b843837d5f8135c9e5a30ea84 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 19:56:11 +0200 Subject: [PATCH 259/383] Audio: Fix some type warning Former-commit-id: 9ed6d64e771e77d03b91060823efb4236739914b [formerly 0efc1b14cd61f3d33fc642dbe4eb6bf05d58ec7e] [formerly dbc079525b48a2efb8a7917b4b376a318f8d5fae [formerly 7c202e02ac2a8b745208e1b852ff44d2169ebaf0]] Former-commit-id: 27a65bcbd5e499dcc741f76a5c0a31bc9ae09e60 [formerly 97ed7176fd1f0f906229d19e68aedc335a7ca420] Former-commit-id: 1779855a4f20dc4216648aaed59542fd8c6d7bc8 --- include/Nazara/Audio/Algorithm.hpp | 2 +- include/Nazara/Audio/Algorithm.inl | 6 +- include/Nazara/Audio/Music.hpp | 2 +- include/Nazara/Audio/SoundBuffer.hpp | 6 +- include/Nazara/Audio/SoundStream.hpp | 6 +- src/Nazara/Audio/Formats/sndfileLoader.cpp | 18 +++--- src/Nazara/Audio/Music.cpp | 46 +++----------- src/Nazara/Audio/Sound.cpp | 34 +--------- src/Nazara/Audio/SoundBuffer.cpp | 74 +++++----------------- 9 files changed, 47 insertions(+), 147 deletions(-) diff --git a/include/Nazara/Audio/Algorithm.hpp b/include/Nazara/Audio/Algorithm.hpp index ddb72a6b0..ea5bd09b6 100644 --- a/include/Nazara/Audio/Algorithm.hpp +++ b/include/Nazara/Audio/Algorithm.hpp @@ -11,7 +11,7 @@ namespace Nz { - template void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount); + template void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount); } #include diff --git a/include/Nazara/Audio/Algorithm.inl b/include/Nazara/Audio/Algorithm.inl index 1075a8b57..ce3c87369 100644 --- a/include/Nazara/Audio/Algorithm.inl +++ b/include/Nazara/Audio/Algorithm.inl @@ -19,16 +19,16 @@ namespace Nz * \remark The input buffer may be the same as the output one */ template - void MixToMono(T* input, T* output, unsigned int channelCount, unsigned int frameCount) + void MixToMono(T* input, T* output, UInt32 channelCount, UInt64 frameCount) { // To avoid overflow, we use, as an accumulator, a type which is large enough: (u)int 64 bits for integers, double for floatings typedef typename std::conditional::value, UInt64, Int64>::type BiggestInt; typedef typename std::conditional::value, BiggestInt, double>::type Biggest; - for (unsigned int i = 0; i < frameCount; ++i) + for (UInt64 i = 0; i < frameCount; ++i) { Biggest acc = Biggest(0); - for (unsigned int j = 0; j < channelCount; ++j) + for (UInt32 j = 0; j < channelCount; ++j) acc += input[i * channelCount + j]; output[i] = static_cast(acc / channelCount); diff --git a/include/Nazara/Audio/Music.hpp b/include/Nazara/Audio/Music.hpp index d08732fa7..f31882890 100644 --- a/include/Nazara/Audio/Music.hpp +++ b/include/Nazara/Audio/Music.hpp @@ -48,7 +48,7 @@ namespace Nz UInt32 GetDuration() const; AudioFormat GetFormat() const; UInt32 GetPlayingOffset() const; - UInt32 GetSampleCount() const; + UInt64 GetSampleCount() const; UInt32 GetSampleRate() const; SoundStatus GetStatus() const; diff --git a/include/Nazara/Audio/SoundBuffer.hpp b/include/Nazara/Audio/SoundBuffer.hpp index 2b02847b4..6b8e5c385 100644 --- a/include/Nazara/Audio/SoundBuffer.hpp +++ b/include/Nazara/Audio/SoundBuffer.hpp @@ -50,18 +50,18 @@ namespace Nz public: SoundBuffer() = default; - SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples); + SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples); SoundBuffer(const SoundBuffer&) = delete; SoundBuffer(SoundBuffer&&) = delete; ~SoundBuffer(); - bool Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples); + bool Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples); void Destroy(); UInt32 GetDuration() const; AudioFormat GetFormat() const; const Int16* GetSamples() const; - UInt32 GetSampleCount() const; + UInt64 GetSampleCount() const; UInt32 GetSampleRate() const; bool IsValid() const; diff --git a/include/Nazara/Audio/SoundStream.hpp b/include/Nazara/Audio/SoundStream.hpp index 4edc7b412..8fd93f412 100644 --- a/include/Nazara/Audio/SoundStream.hpp +++ b/include/Nazara/Audio/SoundStream.hpp @@ -21,11 +21,11 @@ namespace Nz virtual UInt32 GetDuration() const = 0; virtual AudioFormat GetFormat() const = 0; - virtual UInt32 GetSampleCount() const = 0; + virtual UInt64 GetSampleCount() const = 0; virtual UInt32 GetSampleRate() const = 0; - virtual unsigned int Read(void* buffer, unsigned int sampleCount) = 0; - virtual void Seek(UInt32 offset) = 0; + virtual UInt64 Read(void* buffer, UInt64 sampleCount) = 0; + virtual void Seek(UInt64 offset) = 0; }; } diff --git a/src/Nazara/Audio/Formats/sndfileLoader.cpp b/src/Nazara/Audio/Formats/sndfileLoader.cpp index 2aca17976..055e3b6a6 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.cpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.cpp @@ -97,7 +97,7 @@ namespace Nz return m_format; } - UInt32 GetSampleCount() const override + UInt64 GetSampleCount() const override { return m_sampleCount; } @@ -131,7 +131,7 @@ namespace Nz bool Open(Stream& stream, bool forceMono) { SF_INFO infos; - infos.format = 0; // Format inconnu + infos.format = 0; // Unknown format m_handle = sf_open_virtual(&callbacks, SFM_READ, &infos, &stream); if (!m_handle) @@ -154,7 +154,7 @@ namespace Nz return false; } - m_sampleCount = static_cast(infos.channels*infos.frames); + m_sampleCount = infos.channels*infos.frames; m_sampleRate = infos.samplerate; // Durée de la musique (s) = samples / channels*rate @@ -180,7 +180,7 @@ namespace Nz return true; } - unsigned int Read(void* buffer, unsigned int sampleCount) override + UInt64 Read(void* buffer, UInt64 sampleCount) override { // Si la musique a été demandée en mono, nous devons la convertir à la volée lors de la lecture if (m_mixToMono) @@ -190,13 +190,13 @@ namespace Nz sf_count_t readSampleCount = sf_read_short(m_handle, m_mixBuffer.data(), m_format * sampleCount); MixToMono(m_mixBuffer.data(), static_cast(buffer), m_format, sampleCount); - return static_cast(readSampleCount / m_format); + return readSampleCount / m_format; } else - return static_cast(sf_read_short(m_handle, static_cast(buffer), sampleCount)); + return sf_read_short(m_handle, static_cast(buffer), sampleCount); } - void Seek(UInt32 offset) override + void Seek(UInt64 offset) override { sf_seek(m_handle, offset*m_sampleRate / 1000, SEEK_SET); } @@ -208,8 +208,8 @@ namespace Nz SNDFILE* m_handle; bool m_mixToMono; UInt32 m_duration; - unsigned int m_sampleCount; - unsigned int m_sampleRate; + UInt32 m_sampleRate; + UInt64 m_sampleCount; }; bool IsSupported(const String& extension) diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index 9e38c7114..1f0df6ba5 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -166,17 +166,10 @@ namespace Nz * * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - UInt32 Music::GetPlayingOffset() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return 0; - } - #endif - + NazaraAssert(m_impl, "Music not created"); + // Prevent music thread from enqueing new buffers while we're getting the count Nz::LockGuard lock(m_impl->bufferLock); @@ -192,16 +185,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - - UInt32 Music::GetSampleCount() const + UInt64 Music::GetSampleCount() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Music not created"); return m_impl->stream->GetSampleCount(); } @@ -212,16 +198,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - UInt32 Music::GetSampleRate() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Music not created"); return m_impl->sampleRate; } @@ -233,16 +212,9 @@ namespace Nz * \remark If the music is not playing, Stopped is returned * \remark Produces a NazaraError if there is no music with NAZARA_AUDIO_SAFE defined */ - SoundStatus Music::GetStatus() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Music not created"); - return SoundStatus_Stopped; - } - #endif + NazaraAssert(m_impl, "Music not created"); SoundStatus status = GetInternalStatus(); @@ -425,8 +397,8 @@ namespace Nz bool Music::FillAndQueueBuffer(unsigned int buffer) { - unsigned int sampleCount = m_impl->chunkSamples.size(); - unsigned int sampleRead = 0; + std::size_t sampleCount = m_impl->chunkSamples.size(); + std::size_t sampleRead = 0; // Fill the buffer by reading from the stream for (;;) @@ -446,7 +418,7 @@ namespace Nz // Update the buffer (send it to OpenAL) and queue it if we got any data if (sampleRead > 0) { - alBufferData(buffer, m_impl->audioFormat, &m_impl->chunkSamples[0], sampleRead*sizeof(Int16), m_impl->sampleRate); + alBufferData(buffer, m_impl->audioFormat, &m_impl->chunkSamples[0], static_cast(sampleRead*sizeof(Int16)), static_cast(m_impl->sampleRate)); alSourceQueueBuffers(m_source, 1, &buffer); } diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index d2b71318b..3e2e27faa 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -27,7 +27,6 @@ namespace Nz * * \param soundBuffer Buffer to read sound from */ - Sound::Sound(const SoundBuffer* soundBuffer) { SetBuffer(soundBuffer); @@ -38,7 +37,6 @@ namespace Nz * * \param sound Sound to copy */ - Sound::Sound(const Sound& sound) : SoundEmitter(sound) { @@ -50,7 +48,6 @@ namespace Nz * * \see Stop */ - Sound::~Sound() { Stop(); @@ -61,7 +58,6 @@ namespace Nz * * \param loop Should sound loop */ - void Sound::EnableLooping(bool loop) { alSourcei(m_source, AL_LOOPING, loop); @@ -71,7 +67,6 @@ namespace Nz * \brief Gets the internal buffer * \return Internal buffer */ - const SoundBuffer* Sound::GetBuffer() const { return m_buffer; @@ -83,7 +78,6 @@ namespace Nz * * \remark Produces a NazaraError if there is no buffer */ - UInt32 Sound::GetDuration() const { NazaraAssert(m_buffer, "Invalid sound buffer"); @@ -95,7 +89,6 @@ namespace Nz * \brief Gets the current offset in the sound * \return Offset in milliseconds (works with entire seconds) */ - UInt32 Sound::GetPlayingOffset() const { ALint samples = 0; @@ -108,7 +101,6 @@ namespace Nz * \brief Gets the status of the music * \return Enumeration of type SoundStatus (Playing, Stopped, ...) */ - SoundStatus Sound::GetStatus() const { return GetInternalStatus(); @@ -118,7 +110,6 @@ namespace Nz * \brief Checks whether the sound is looping * \return true if it is the case */ - bool Sound::IsLooping() const { ALint loop; @@ -141,7 +132,6 @@ namespace Nz * \brief Checks whether the sound is playing * \return true if it is the case */ - bool Sound::IsPlaying() const { return GetStatus() == SoundStatus_Playing; @@ -156,7 +146,6 @@ namespace Nz * * \remark Produces a NazaraError if loading failed */ - bool Sound::LoadFromFile(const String& filePath, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -180,7 +169,6 @@ namespace Nz * * \remark Produces a NazaraError if loading failed */ - bool Sound::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -203,7 +191,6 @@ namespace Nz * * \remark Produces a NazaraError if loading failed */ - bool Sound::LoadFromStream(Stream& stream, const SoundBufferParams& params) { SoundBufferRef buffer = SoundBuffer::New(); @@ -220,7 +207,6 @@ namespace Nz /*! * \brief Pauses the sound */ - void Sound::Pause() { alSourcePause(m_source); @@ -231,16 +217,9 @@ namespace Nz * * \remark Produces a NazaraError if the sound is not playable with NAZARA_AUDIO_SAFE defined */ - void Sound::Play() { - #if NAZARA_AUDIO_SAFE - if (!IsPlayable()) - { - NazaraError("Invalid sound buffer"); - return; - } - #endif + NazaraAssert(IsPlayable(), "Music is not playable"); alSourcePlay(m_source); } @@ -252,16 +231,9 @@ namespace Nz * * \remark Produces a NazaraError if buffer is invalid with NAZARA_AUDIO_SAFE defined */ - void Sound::SetBuffer(const SoundBuffer* buffer) { - #if NAZARA_AUDIO_SAFE - if (buffer && !buffer->IsValid()) - { - NazaraError("Invalid sound buffer"); - return; - } - #endif + NazaraAssert(!buffer || buffer->IsValid(), "Invalid sound buffer"); if (m_buffer == buffer) return; @@ -281,7 +253,6 @@ namespace Nz * * \param offset Offset in the sound in milliseconds */ - void Sound::SetPlayingOffset(UInt32 offset) { alSourcei(m_source, AL_SAMPLE_OFFSET, static_cast(offset/1000.f * m_buffer->GetSampleRate())); @@ -290,7 +261,6 @@ namespace Nz /*! * \brief Stops the sound */ - void Sound::Stop() { alSourceStop(m_source); diff --git a/src/Nazara/Audio/SoundBuffer.cpp b/src/Nazara/Audio/SoundBuffer.cpp index b59e74e23..4b2b0410e 100644 --- a/src/Nazara/Audio/SoundBuffer.cpp +++ b/src/Nazara/Audio/SoundBuffer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,7 @@ namespace Nz AudioFormat format; UInt32 duration; std::unique_ptr samples; - UInt32 sampleCount; + UInt64 sampleCount; UInt32 sampleRate; }; @@ -57,8 +58,7 @@ namespace Nz * * \see Create */ - - SoundBuffer::SoundBuffer(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) + SoundBuffer::SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples) { Create(format, sampleCount, sampleRate, samples); @@ -76,7 +76,6 @@ namespace Nz * * \see Destroy */ - SoundBuffer::~SoundBuffer() { OnSoundBufferRelease(this); @@ -96,8 +95,7 @@ namespace Nz * \remark Produces a NazaraError if creation went wrong with NAZARA_AUDIO_SAFE defined, * this could happen if parameters are invalid or creation of OpenAL buffers failed */ - - bool SoundBuffer::Create(AudioFormat format, unsigned int sampleCount, unsigned int sampleRate, const Int16* samples) + bool SoundBuffer::Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples) { Destroy(); @@ -132,19 +130,18 @@ namespace Nz ALuint buffer; alGenBuffers(1, &buffer); - if (alGetError() != AL_NO_ERROR) { NazaraError("Failed to create OpenAL buffer"); return false; } - alBufferData(buffer, OpenAL::AudioFormat[format], samples, sampleCount*sizeof(Int16), sampleRate); + CallOnExit clearBufferOnExit([buffer] () { alDeleteBuffers(1, &buffer); }); + + alBufferData(buffer, OpenAL::AudioFormat[format], samples, static_cast(sampleCount*sizeof(Int16)), static_cast(sampleRate)); if (alGetError() != AL_NO_ERROR) { - alDeleteBuffers(1, &buffer); - NazaraError("Failed to set OpenAL buffer"); return false; } @@ -158,6 +155,8 @@ namespace Nz m_impl->samples.reset(new Int16[sampleCount]); std::memcpy(&m_impl->samples[0], samples, sampleCount*sizeof(Int16)); + clearBufferOnExit.Reset(); + return true; } @@ -182,16 +181,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - UInt32 SoundBuffer::GetDuration() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->duration; } @@ -205,13 +197,7 @@ namespace Nz AudioFormat SoundBuffer::GetFormat() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return AudioFormat_Unknown; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->format; } @@ -222,16 +208,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - const Int16* SoundBuffer::GetSamples() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->samples.get(); } @@ -242,16 +221,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - - unsigned int SoundBuffer::GetSampleCount() const + UInt64 SoundBuffer::GetSampleCount() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->sampleCount; } @@ -262,16 +234,9 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - - unsigned int SoundBuffer::GetSampleRate() const + UInt32 SoundBuffer::GetSampleRate() const { - #if NAZARA_AUDIO_SAFE - if (!m_impl) - { - NazaraError("Sound buffer not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Sound buffer not created"); return m_impl->sampleRate; } @@ -293,7 +258,6 @@ namespace Nz * \param filePath Path to the file * \param params Parameters for the sound buffer */ - bool SoundBuffer::LoadFromFile(const String& filePath, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromFile(this, filePath, params); @@ -307,7 +271,6 @@ namespace Nz * \param size Size of the memory * \param params Parameters for the sound buffer */ - bool SoundBuffer::LoadFromMemory(const void* data, std::size_t size, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromMemory(this, data, size, params); @@ -320,7 +283,6 @@ namespace Nz * \param stream Stream to the sound buffer * \param params Parameters for the sound buffer */ - bool SoundBuffer::LoadFromStream(Stream& stream, const SoundBufferParams& params) { return SoundBufferLoader::LoadFromStream(this, stream, params); @@ -332,7 +294,6 @@ namespace Nz * * \param format Format to check */ - bool SoundBuffer::IsFormatSupported(AudioFormat format) { return Audio::IsFormatSupported(format); @@ -344,7 +305,6 @@ namespace Nz * * \remark Produces a NazaraError if there is no sound buffer with NAZARA_AUDIO_SAFE defined */ - unsigned int SoundBuffer::GetOpenALBuffer() const { #ifdef NAZARA_DEBUG @@ -364,7 +324,6 @@ namespace Nz * * \remark Produces a NazaraError if sub-initialization failed */ - bool SoundBuffer::Initialize() { if (!SoundBufferLibrary::Initialize()) @@ -385,7 +344,6 @@ namespace Nz /*! * \brief Uninitializes the libraries and managers */ - void SoundBuffer::Uninitialize() { SoundBufferManager::Uninitialize(); From e63e5754b90fd6157692bacdba9d45348bd1aba3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 19:58:22 +0200 Subject: [PATCH 260/383] Lua/LuaInstance: Improve code Former-commit-id: a998449fae2d50541ab4c5d1c68d9dff4e7238a6 [formerly a5734fdf64bc9d8acbe1d0923d70ddc553b3a14b] [formerly 4da841f9961603fffdf6c1112610d082db361ce7 [formerly d9cea98d520bef475ea472b4b0eceb5881ee6c90]] Former-commit-id: be40337660be3bc317c4f2def0e301ac2e0a0834 [formerly b08c4c9ca758ccdd92ad0f6fbbbd5a5f7ea70b58] Former-commit-id: 32908cf086667a25ea718f62a240d0d44628b016 --- include/Nazara/Lua/LuaInstance.hpp | 12 +++++------ include/Nazara/Lua/LuaInstance.inl | 25 +++++++++++++++++++++++ src/Nazara/Lua/LuaInstance.cpp | 32 ++++-------------------------- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.hpp b/include/Nazara/Lua/LuaInstance.hpp index e3bc517f8..c6d7c6385 100644 --- a/include/Nazara/Lua/LuaInstance.hpp +++ b/include/Nazara/Lua/LuaInstance.hpp @@ -92,16 +92,16 @@ namespace Nz LuaType GetField(const String& fieldName, int tableIndex = -1) const; LuaType GetGlobal(const char* name) const; LuaType GetGlobal(const String& name) const; - lua_State* GetInternalState() const; - String GetLastError() const; - UInt32 GetMemoryLimit() const; - UInt32 GetMemoryUsage() const; + inline lua_State* GetInternalState() const; + inline String GetLastError() const; + inline std::size_t GetMemoryLimit() const; + inline std::size_t GetMemoryUsage() const; LuaType GetMetatable(const char* tname) const; LuaType GetMetatable(const String& tname) const; bool GetMetatable(int index) const; unsigned int GetStackTop() const; LuaType GetTable(int index = -2) const; - UInt32 GetTimeLimit() const; + inline UInt32 GetTimeLimit() const; LuaType GetType(int index) const; const char* GetTypeName(LuaType type) const; @@ -144,7 +144,7 @@ namespace Nz void PushString(const char* str) const; void PushString(const char* str, std::size_t size) const; void PushString(const String& str) const; - void PushTable(unsigned int sequenceElementCount = 0, unsigned int arrayElementCount = 0) const; + void PushTable(std::size_t sequenceElementCount = 0, std::size_t arrayElementCount = 0) const; void* PushUserdata(std::size_t size) const; void PushValue(int index) const; diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index f9f5e662f..e6a4b5482 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -25,6 +25,31 @@ namespace Nz instance.m_state = nullptr; } + inline lua_State* LuaInstance::GetInternalState() const + { + return m_state; + } + + inline String LuaInstance::GetLastError() const + { + return m_lastError; + } + + inline std::size_t LuaInstance::GetMemoryLimit() const + { + return m_memoryLimit; + } + + inline std::size_t LuaInstance::GetMemoryUsage() const + { + return m_memoryUsage; + } + + inline UInt32 LuaInstance::GetTimeLimit() const + { + return m_timeLimit; + } + inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept { m_clock = std::move(m_clock); diff --git a/src/Nazara/Lua/LuaInstance.cpp b/src/Nazara/Lua/LuaInstance.cpp index f31c6fe83..f73c4a207 100644 --- a/src/Nazara/Lua/LuaInstance.cpp +++ b/src/Nazara/Lua/LuaInstance.cpp @@ -464,26 +464,6 @@ namespace Nz return FromLuaType(lua_getglobal(m_state, name.GetConstBuffer())); } - lua_State* LuaInstance::GetInternalState() const - { - return m_state; - } - - String LuaInstance::GetLastError() const - { - return m_lastError; - } - - UInt32 LuaInstance::GetMemoryLimit() const - { - return m_memoryLimit; - } - - UInt32 LuaInstance::GetMemoryUsage() const - { - return m_memoryUsage; - } - LuaType LuaInstance::GetMetatable(const char* tname) const { return FromLuaType(luaL_getmetatable(m_state, tname)); @@ -501,7 +481,7 @@ namespace Nz unsigned int LuaInstance::GetStackTop() const { - return lua_gettop(m_state); + return static_cast(lua_gettop(m_state)); } LuaType LuaInstance::GetTable(int index) const @@ -509,11 +489,6 @@ namespace Nz return FromLuaType(lua_gettable(m_state, index)); } - UInt32 LuaInstance::GetTimeLimit() const - { - return m_timeLimit; - } - LuaType LuaInstance::GetType(int index) const { return FromLuaType(lua_type(m_state, index)); @@ -690,9 +665,10 @@ namespace Nz lua_pushlstring(m_state, str.GetConstBuffer(), str.GetSize()); } - void LuaInstance::PushTable(unsigned int sequenceElementCount, unsigned int arrayElementCount) const + void LuaInstance::PushTable(std::size_t sequenceElementCount, std::size_t arrayElementCount) const { - lua_createtable(m_state, sequenceElementCount, arrayElementCount); + constexpr std::size_t maxInt = std::numeric_limits::max(); + lua_createtable(m_state, static_cast(std::min(sequenceElementCount, maxInt)), static_cast(std::min(arrayElementCount, maxInt))); } void* LuaInstance::PushUserdata(std::size_t size) const From ba6c5623677cd66b6414b679df9d0a23bbefcdbd Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 20:02:23 +0200 Subject: [PATCH 261/383] Sdk/GraphicsComponent: Allows to setup an offset to renderables Former-commit-id: a5e9ceb3f30e79a0d3b96b6866a06441cbc0b463 [formerly 8af071cedec0a6aca00ff9c12d66e8a0817049c6] [formerly cd7e7040fd68dd5a74a0b458a3a305c251257b51 [formerly 0f9382c169a260d5fa34fe9b1ab64c3d19dbd385]] Former-commit-id: 774af2326cb64824f85835c83464bc19884005e1 [formerly 4b676844f6dd56940b4f503c6a943905ea8a54c3] Former-commit-id: 0673e4d4cd88c99d24e0e153a61d2726e2e2c039 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 1 + SDK/include/NDK/Components/GraphicsComponent.inl | 13 ++++++++++++- SDK/src/NDK/Components/GraphicsComponent.cpp | 2 +- include/Nazara/Graphics/InstancedRenderable.hpp | 8 +++++--- include/Nazara/Graphics/Model.inl | 3 ++- src/Nazara/Graphics/Billboard.cpp | 2 +- src/Nazara/Graphics/InstancedRenderable.cpp | 2 +- src/Nazara/Graphics/Model.cpp | 2 +- src/Nazara/Graphics/SkeletalModel.cpp | 2 +- src/Nazara/Graphics/Sprite.cpp | 8 ++++---- src/Nazara/Graphics/TextSprite.cpp | 2 +- src/Nazara/Graphics/TileMap.cpp | 8 ++++---- 12 files changed, 34 insertions(+), 19 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index ec16ba593..b792cfd69 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -32,6 +32,7 @@ namespace Ndk inline void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const; inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); + inline void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0); inline void Clear(); diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 01cd7a2e3..bd3e6dbfb 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -2,8 +2,10 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp +#include +#include +#include #include -#include "GraphicsComponent.hpp" namespace Ndk { @@ -36,10 +38,13 @@ namespace Ndk { EnsureTransformMatrixUpdate(); + Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem(); + for (const Renderable& object : m_renderables) { if (!object.dataUpdated) { + object.data.transformMatrix = Nz::Matrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), Nz::Matrix4f::ConcatenateAffine(object.data.localMatrix, m_transformMatrix)); object.renderable->UpdateData(&object.data); object.dataUpdated = true; } @@ -56,9 +61,15 @@ namespace Ndk */ inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, int renderOrder) + { + return Attach(renderable, Nz::Matrix4f::Identity(), renderOrder); + } + + inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder) { m_renderables.emplace_back(m_transformMatrix); Renderable& r = m_renderables.back(); + r.data.localMatrix = localMatrix; r.data.renderOrder = renderOrder; r.renderable = std::move(renderable); r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size() - 1)); diff --git a/SDK/src/NDK/Components/GraphicsComponent.cpp b/SDK/src/NDK/Components/GraphicsComponent.cpp index 759d3f24b..e06890c97 100644 --- a/SDK/src/NDK/Components/GraphicsComponent.cpp +++ b/SDK/src/NDK/Components/GraphicsComponent.cpp @@ -133,7 +133,7 @@ namespace Ndk Ndk::RenderSystem& renderSystem = m_entity->GetWorld()->GetSystem(); - m_transformMatrix = Nz::Matrix4f::ConcatenateAffine(renderSystem.GetCoordinateSystemMatrix(), m_entity->GetComponent().GetTransformMatrix()); + m_transformMatrix = m_entity->GetComponent().GetTransformMatrix(); m_transformMatrixUpdated = true; } diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index d854a41d6..8b44d7512 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -54,8 +54,8 @@ namespace Nz struct InstanceData { - InstanceData(const Matrix4f& referenceMatrix) : - transformMatrix(&referenceMatrix), + InstanceData(const Matrix4f& transformationMatrix) : + localMatrix(transformationMatrix), flags(0) { } @@ -67,6 +67,7 @@ namespace Nz data = std::move(instanceData.data); flags = instanceData.flags; renderOrder = instanceData.renderOrder; + localMatrix = instanceData.localMatrix; transformMatrix = instanceData.transformMatrix; volume = instanceData.volume; @@ -75,7 +76,8 @@ namespace Nz std::vector data; BoundingVolumef volume; - const Matrix4f* transformMatrix; + Matrix4f localMatrix; + mutable Matrix4f transformMatrix; UInt32 flags; int renderOrder; }; diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index 243611fb5..8e659e869 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -18,8 +18,9 @@ namespace Nz */ inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder) { - InstanceData instanceData(transformMatrix); + InstanceData instanceData(Nz::Matrix4f::Identity()); instanceData.renderOrder = renderOrder; + instanceData.transformMatrix = transformMatrix; return AddToRenderQueue(renderQueue, instanceData); } diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 17a2ad065..4aed923ae 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -30,7 +30,7 @@ namespace Nz if (!m_material) return; - Nz::Vector3f position = instanceData.transformMatrix->GetTranslation(); + Nz::Vector3f position = instanceData.transformMatrix.GetTranslation(); renderQueue->AddBillboards(instanceData.renderOrder, m_material, 1, &position, &m_size, &m_sinCos, &m_color); } diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index 03da17984..ef5f62b96 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -80,7 +80,7 @@ namespace Nz NazaraAssert(instanceData, "Invalid instance data"); NazaraUnused(instanceData); - instanceData->volume.Update(*instanceData->transformMatrix); + instanceData->volume.Update(instanceData->transformMatrix); } /*! diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index 2b9e03cc1..d382c77d9 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -82,7 +82,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = mesh->GetVertexBuffer(); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), *instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, mesh->GetAABB(), instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index 8621d1fce..b91ac0076 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -69,7 +69,7 @@ namespace Nz meshData.primitiveMode = mesh->GetPrimitiveMode(); meshData.vertexBuffer = SkinningManager::GetBuffer(mesh, &m_skeleton); - renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), *instanceData.transformMatrix); + renderQueue->AddMesh(instanceData.renderOrder, material, meshData, m_skeleton.GetAABB(), instanceData.transformMatrix); } } diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index f4b2f0dab..8b950bf2a 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -62,19 +62,19 @@ namespace Nz Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(Vector3f(-origin)); + *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() - origin); + *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.y*Vector3f::Down() - origin); + *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = m_color; - *posPtr++ = instanceData->transformMatrix->Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); + *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 2f1d733b4..42dba4aaf 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -310,7 +310,7 @@ namespace Nz Vector3f localPos = localVertex->position.x*Vector3f::Right() + localVertex->position.y*Vector3f::Down(); localPos *= m_scale; - *pos++ = instanceData->transformMatrix->Transform(localPos); + *pos++ = instanceData->transformMatrix.Transform(localPos); *color++ = m_color * localVertex->color; *uv++ = localVertex->uv; diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index 2c6e26aa4..255685f43 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -71,19 +71,19 @@ namespace Nz Vector3f tileLeftCorner(x * m_tileSize.x, y * -m_tileSize.y, 0.f); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftTop); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right()); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right()); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightTop); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.y * Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner + m_tileSize.y * Vector3f::Down()); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_LeftBottom); *colorPtr++ = tile.color; - *posPtr++ = instanceData->transformMatrix->Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right() + m_tileSize.y * Vector3f::Down()); + *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner + m_tileSize.x * Vector3f::Right() + m_tileSize.y * Vector3f::Down()); *texCoordPtr++ = tile.textureCoords.GetCorner(RectCorner_RightBottom); } spriteCount += layer.tiles.size(); From 68d67cc9da443bf64a301e2fda9e0dfaf592f431 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 20:39:34 +0200 Subject: [PATCH 262/383] Utility: First code cleaning pass Former-commit-id: a73d38ce2db2e780ad5b02cdae1c590606081650 [formerly 3d21c0fa44481bf91418a15012fa187a210fc9ad] [formerly b80263df8e91b85f3fd091724c54dec7f05bc535 [formerly 7dcaabaabf74fbdf840289bfc435fdd8e88969d7]] Former-commit-id: a669a933edd2364d9ee487c7d1bb38e28ad87a2d [formerly b8c5c09df10ce2f831635f460393216799d44056] Former-commit-id: 6bbd5af22e30cc7fd4b4478162ae89e69b3d274e --- include/Nazara/Utility/Animation.hpp | 29 +- .../Nazara/Utility/Formats/MD5AnimParser.hpp | 14 +- .../Nazara/Utility/Formats/MD5MeshParser.hpp | 6 +- include/Nazara/Utility/Formats/OBJParser.hpp | 34 +- include/Nazara/Utility/Formats/OBJParser.inl | 30 +- include/Nazara/Utility/Mesh.hpp | 30 +- include/Nazara/Utility/Sequence.hpp | 6 +- include/Nazara/Utility/Skeleton.hpp | 10 +- include/Nazara/Utility/SubMesh.hpp | 10 +- include/Nazara/Utility/VertexMapper.inl | 2 +- src/Nazara/Utility/Animation.cpp | 326 +++--------------- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 12 +- src/Nazara/Utility/Formats/MD5AnimParser.cpp | 52 +-- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 12 +- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 18 +- src/Nazara/Utility/Formats/MTLParser.cpp | 16 +- src/Nazara/Utility/Formats/OBJLoader.cpp | 22 +- src/Nazara/Utility/Formats/OBJParser.cpp | 28 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 14 +- src/Nazara/Utility/Mesh.cpp | 58 ++-- src/Nazara/Utility/Skeleton.cpp | 32 +- src/Nazara/Utility/SubMesh.cpp | 4 +- 22 files changed, 276 insertions(+), 489 deletions(-) diff --git a/include/Nazara/Utility/Animation.hpp b/include/Nazara/Utility/Animation.hpp index e196a0f77..2ab1f2baa 100644 --- a/include/Nazara/Utility/Animation.hpp +++ b/include/Nazara/Utility/Animation.hpp @@ -20,16 +20,15 @@ #include #include #include -#include namespace Nz { struct NAZARA_UTILITY_API AnimationParams : ResourceParameters { // La frame de fin à charger - unsigned int endFrame = std::numeric_limits::max(); + UInt32 endFrame = 0xFFFFFFFF; // La frame de début à charger - unsigned int startFrame = 0; + UInt32 startFrame = 0; bool IsValid() const; }; @@ -57,27 +56,27 @@ namespace Nz ~Animation(); bool AddSequence(const Sequence& sequence); - void AnimateSkeleton(Skeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const; + void AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const; - bool CreateSkeletal(unsigned int frameCount, unsigned int jointCount); + bool CreateSkeletal(UInt32 frameCount, UInt32 jointCount); void Destroy(); void EnableLoopPointInterpolation(bool loopPointInterpolation); - unsigned int GetFrameCount() const; - unsigned int GetJointCount() const; + UInt32 GetFrameCount() const; + UInt32 GetJointCount() const; Sequence* GetSequence(const String& sequenceName); - Sequence* GetSequence(unsigned int index); + Sequence* GetSequence(UInt32 index); const Sequence* GetSequence(const String& sequenceName) const; - const Sequence* GetSequence(unsigned int index) const; - unsigned int GetSequenceCount() const; - int GetSequenceIndex(const String& sequenceName) const; - SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0); - const SequenceJoint* GetSequenceJoints(unsigned int frameIndex = 0) const; + const Sequence* GetSequence(UInt32 index) const; + UInt32 GetSequenceCount() const; + UInt32 GetSequenceIndex(const String& sequenceName) const; + SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0); + const SequenceJoint* GetSequenceJoints(UInt32 frameIndex = 0) const; AnimationType GetType() const; bool HasSequence(const String& sequenceName) const; - bool HasSequence(unsigned int index = 0) const; + bool HasSequence(UInt32 index = 0) const; bool IsLoopPointInterpolationEnabled() const; bool IsValid() const; @@ -87,7 +86,7 @@ namespace Nz bool LoadFromStream(Stream& stream, const AnimationParams& params = AnimationParams()); void RemoveSequence(const String& sequenceName); - void RemoveSequence(unsigned int index); + void RemoveSequence(UInt32 index); template static AnimationRef New(Args&&... args); diff --git a/include/Nazara/Utility/Formats/MD5AnimParser.hpp b/include/Nazara/Utility/Formats/MD5AnimParser.hpp index 558608142..3a9e2163d 100644 --- a/include/Nazara/Utility/Formats/MD5AnimParser.hpp +++ b/include/Nazara/Utility/Formats/MD5AnimParser.hpp @@ -34,12 +34,12 @@ namespace Nz struct Joint { + Int32 parent; Quaternionf bindOrient; String name; Vector3f bindPos; - int parent; - unsigned int flags; - unsigned int index; + UInt32 flags; + UInt32 index; }; MD5AnimParser(Stream& stream); @@ -47,12 +47,12 @@ namespace Nz Ternary Check(); - std::size_t GetAnimatedComponentCount() const; + UInt32 GetAnimatedComponentCount() const; const Frame* GetFrames() const; - std::size_t GetFrameCount() const; - std::size_t GetFrameRate() const; + UInt32 GetFrameCount() const; + UInt32 GetFrameRate() const; const Joint* GetJoints() const; - std::size_t GetJointCount() const; + UInt32 GetJointCount() const; bool Parse(); diff --git a/include/Nazara/Utility/Formats/MD5MeshParser.hpp b/include/Nazara/Utility/Formats/MD5MeshParser.hpp index cd2d19309..b515c1226 100644 --- a/include/Nazara/Utility/Formats/MD5MeshParser.hpp +++ b/include/Nazara/Utility/Formats/MD5MeshParser.hpp @@ -22,10 +22,10 @@ namespace Nz public: struct Joint { + Int32 parent; Quaternionf bindOrient; String name; Vector3f bindPos; - int parent; }; typedef Vector3ui Triangle; @@ -58,9 +58,9 @@ namespace Nz Ternary Check(); const Joint* GetJoints() const; - std::size_t GetJointCount() const; + UInt32 GetJointCount() const; const Mesh* GetMeshes() const; - std::size_t GetMeshCount() const; + UInt32 GetMeshCount() const; bool Parse(); diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 114f72635..6c0c35af4 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -31,43 +31,43 @@ namespace Nz inline String* GetMaterials(); inline const String* GetMaterials() const; - inline unsigned int GetMaterialCount() const; + inline UInt32 GetMaterialCount() const; inline Mesh* GetMeshes(); inline const Mesh* GetMeshes() const; - inline unsigned int GetMeshCount() const; + inline UInt32 GetMeshCount() const; inline const String& GetMtlLib() const; inline Vector3f* GetNormals(); inline const Vector3f* GetNormals() const; - inline unsigned int GetNormalCount() const; + inline UInt32 GetNormalCount() const; inline Vector4f* GetPositions(); inline const Vector4f* GetPositions() const; - inline unsigned int GetPositionCount() const; + inline UInt32 GetPositionCount() const; inline Vector3f* GetTexCoords(); inline const Vector3f* GetTexCoords() const; - inline unsigned int GetTexCoordCount() const; + inline UInt32 GetTexCoordCount() const; - bool Parse(Stream& stream, std::size_t reservedVertexCount = 100); + bool Parse(Stream& stream, UInt32 reservedVertexCount = 100); bool Save(Stream& stream) const; - inline String* SetMaterialCount(std::size_t materialCount); - inline Mesh* SetMeshCount(std::size_t meshCount); + inline String* SetMaterialCount(UInt32 materialCount); + inline Mesh* SetMeshCount(UInt32 meshCount); inline void SetMtlLib(const String& mtlLib); - inline Vector3f* SetNormalCount(std::size_t normalCount); - inline Vector4f* SetPositionCount(std::size_t positionCount); - inline Vector3f* SetTexCoordCount(std::size_t texCoordCount); + inline Vector3f* SetNormalCount(UInt32 normalCount); + inline Vector4f* SetPositionCount(UInt32 positionCount); + inline Vector3f* SetTexCoordCount(UInt32 texCoordCount); struct Face { - std::size_t firstVertex; - std::size_t vertexCount; + UInt32 firstVertex; + UInt32 vertexCount; }; struct FaceVertex { - std::size_t normal; - std::size_t position; - std::size_t texCoord; + UInt32 normal; + UInt32 position; + UInt32 texCoord; }; struct Mesh @@ -75,7 +75,7 @@ namespace Nz std::vector faces; std::vector vertices; String name; - std::size_t material; + UInt32 material; }; private: diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index b04506fdf..41e794f82 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -27,9 +27,9 @@ namespace Nz return m_materials.data(); } - inline unsigned int OBJParser::GetMaterialCount() const + inline UInt32 OBJParser::GetMaterialCount() const { - return m_materials.size(); + return static_cast(m_materials.size()); } inline OBJParser::Mesh* OBJParser::GetMeshes() @@ -42,9 +42,9 @@ namespace Nz return m_meshes.data(); } - inline unsigned int OBJParser::GetMeshCount() const + inline UInt32 OBJParser::GetMeshCount() const { - return m_meshes.size(); + return static_cast(m_meshes.size()); } inline const String& OBJParser::GetMtlLib() const @@ -62,9 +62,9 @@ namespace Nz return m_normals.data(); } - inline unsigned int OBJParser::GetNormalCount() const + inline UInt32 OBJParser::GetNormalCount() const { - return m_normals.size(); + return static_cast(m_normals.size()); } inline Vector4f* OBJParser::GetPositions() @@ -77,9 +77,9 @@ namespace Nz return m_positions.data(); } - inline unsigned int OBJParser::GetPositionCount() const + inline UInt32 OBJParser::GetPositionCount() const { - return m_positions.size(); + return static_cast(m_positions.size()); } inline Vector3f* OBJParser::GetTexCoords() @@ -92,18 +92,18 @@ namespace Nz return m_texCoords.data(); } - inline unsigned int OBJParser::GetTexCoordCount() const + inline UInt32 OBJParser::GetTexCoordCount() const { - return m_texCoords.size(); + return static_cast(m_texCoords.size()); } - inline String* OBJParser::SetMaterialCount(std::size_t materialCount) + inline String* OBJParser::SetMaterialCount(UInt32 materialCount) { m_materials.resize(materialCount); return m_materials.data(); } - inline OBJParser::Mesh* OBJParser::SetMeshCount(std::size_t meshCount) + inline OBJParser::Mesh* OBJParser::SetMeshCount(UInt32 meshCount) { m_meshes.resize(meshCount); return m_meshes.data(); @@ -114,19 +114,19 @@ namespace Nz m_mtlLib = mtlLib; } - inline Vector3f* OBJParser::SetNormalCount(std::size_t normalCount) + inline Vector3f* OBJParser::SetNormalCount(UInt32 normalCount) { m_normals.resize(normalCount); return m_normals.data(); } - inline Vector4f* OBJParser::SetPositionCount(std::size_t positionCount) + inline Vector4f* OBJParser::SetPositionCount(UInt32 positionCount) { m_positions.resize(positionCount); return m_positions.data(); } - inline Vector3f* OBJParser::SetTexCoordCount(std::size_t texCoordCount) + inline Vector3f* OBJParser::SetTexCoordCount(UInt32 texCoordCount) { m_texCoords.resize(texCoordCount); return m_texCoords.data(); diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 62a372384..60ccb98b1 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -84,7 +84,7 @@ namespace Nz SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams()); void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams()); - bool CreateSkeletal(unsigned int jointCount); + bool CreateSkeletal(UInt32 jointCount); bool CreateStatic(); void Destroy(); @@ -95,23 +95,23 @@ namespace Nz const Boxf& GetAABB() const; String GetAnimation() const; AnimationType GetAnimationType() const; - unsigned int GetJointCount() const; - ParameterList& GetMaterialData(unsigned int index); - const ParameterList& GetMaterialData(unsigned int index) const; - unsigned int GetMaterialCount() const; + UInt32 GetJointCount() const; + ParameterList& GetMaterialData(UInt32 index); + const ParameterList& GetMaterialData(UInt32 index) const; + UInt32 GetMaterialCount() const; Skeleton* GetSkeleton(); const Skeleton* GetSkeleton() const; SubMesh* GetSubMesh(const String& identifier); - SubMesh* GetSubMesh(unsigned int index); + SubMesh* GetSubMesh(UInt32 index); const SubMesh* GetSubMesh(const String& identifier) const; - const SubMesh* GetSubMesh(unsigned int index) const; - unsigned int GetSubMeshCount() const; - int GetSubMeshIndex(const String& identifier) const; - unsigned int GetTriangleCount() const; - unsigned int GetVertexCount() const; + const SubMesh* GetSubMesh(UInt32 index) const; + UInt32 GetSubMeshCount() const; + UInt32 GetSubMeshIndex(const String& identifier) const; + UInt32 GetTriangleCount() const; + UInt32 GetVertexCount() const; bool HasSubMesh(const String& identifier) const; - bool HasSubMesh(unsigned int index = 0) const; + bool HasSubMesh(UInt32 index = 0) const; void InvalidateAABB() const; @@ -125,14 +125,14 @@ namespace Nz void Recenter(); void RemoveSubMesh(const String& identifier); - void RemoveSubMesh(unsigned int index); + void RemoveSubMesh(UInt32 index); bool SaveToFile(const String& filePath, const MeshParams& params = MeshParams()); bool SaveToStream(Stream& stream, const String& format, const MeshParams& params = MeshParams()); void SetAnimation(const String& animationPath); - void SetMaterialCount(unsigned int matCount); - void SetMaterialData(unsigned int matIndex, ParameterList data); + void SetMaterialCount(UInt32 matCount); + void SetMaterialData(UInt32 matIndex, ParameterList data); void Transform(const Matrix4f& matrix); diff --git a/include/Nazara/Utility/Sequence.hpp b/include/Nazara/Utility/Sequence.hpp index 1c6812eb7..b8549a4bf 100644 --- a/include/Nazara/Utility/Sequence.hpp +++ b/include/Nazara/Utility/Sequence.hpp @@ -16,9 +16,9 @@ namespace Nz struct Sequence { String name; - unsigned int firstFrame; - unsigned int frameCount; - unsigned int frameRate; + UInt32 firstFrame; + UInt32 frameCount; + UInt32 frameRate; }; struct SequenceJoint diff --git a/include/Nazara/Utility/Skeleton.hpp b/include/Nazara/Utility/Skeleton.hpp index fa217e6d4..8312f967f 100644 --- a/include/Nazara/Utility/Skeleton.hpp +++ b/include/Nazara/Utility/Skeleton.hpp @@ -37,21 +37,21 @@ namespace Nz Skeleton(const Skeleton& skeleton); ~Skeleton(); - bool Create(unsigned int jointCount); + bool Create(UInt32 jointCount); void Destroy(); const Boxf& GetAABB() const; Joint* GetJoint(const String& jointName); - Joint* GetJoint(unsigned int index); + Joint* GetJoint(UInt32 index); const Joint* GetJoint(const String& jointName) const; - const Joint* GetJoint(unsigned int index) const; + const Joint* GetJoint(UInt32 index) const; Joint* GetJoints(); const Joint* GetJoints() const; - unsigned int GetJointCount() const; + UInt32 GetJointCount() const; int GetJointIndex(const String& jointName) const; void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation); - void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount); + void Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount); bool IsValid() const; diff --git a/include/Nazara/Utility/SubMesh.hpp b/include/Nazara/Utility/SubMesh.hpp index 6eee3a152..525930e0b 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -39,15 +39,15 @@ namespace Nz virtual const Boxf& GetAABB() const = 0; virtual AnimationType GetAnimationType() const = 0; virtual const IndexBuffer* GetIndexBuffer() const = 0; - unsigned int GetMaterialIndex() const; + UInt32 GetMaterialIndex() const; const Mesh* GetParent() const; PrimitiveMode GetPrimitiveMode() const; - unsigned int GetTriangleCount() const; - virtual unsigned int GetVertexCount() const = 0; + UInt32 GetTriangleCount() const; + virtual UInt32 GetVertexCount() const = 0; virtual bool IsAnimated() const = 0; - void SetMaterialIndex(unsigned int matIndex); + void SetMaterialIndex(UInt32 matIndex); void SetPrimitiveMode(PrimitiveMode mode); // Signals: @@ -56,7 +56,7 @@ namespace Nz protected: PrimitiveMode m_primitiveMode; const Mesh* m_parent; - unsigned int m_matIndex; + UInt32 m_matIndex; }; } diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index 7b36743eb..4a155bfbd 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -28,8 +28,8 @@ namespace Nz { NazaraError("Attribute 0x" + String::Number(component, 16) + " is not enabled"); return SparsePtr(); + } } } -} #include diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index 62591344b..a996f85a5 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -14,13 +14,13 @@ namespace Nz { struct AnimationImpl { - std::unordered_map sequenceMap; + std::unordered_map sequenceMap; std::vector sequences; std::vector sequenceJoints; // Uniquement pour les animations squelettiques AnimationType type; bool loopPointInterpolation = false; - unsigned int frameCount; - unsigned int jointCount; // Uniquement pour les animations squelettiques + UInt32 frameCount; + UInt32 jointCount; // Uniquement pour les animations squelettiques }; bool AnimationParams::IsValid() const @@ -43,40 +43,18 @@ namespace Nz bool Animation::AddSequence(const Sequence& sequence) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - - if (sequence.frameCount == 0) - { - NazaraError("Sequence frame count must be over zero"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(sequence.frameCount > 0, "Sequence frame count must be over zero"); if (m_impl->type == AnimationType_Skeletal) { - unsigned int endFrame = sequence.firstFrame + sequence.frameCount - 1; + UInt32 endFrame = sequence.firstFrame + sequence.frameCount - 1; if (endFrame >= m_impl->frameCount) { m_impl->frameCount = endFrame+1; m_impl->sequenceJoints.resize(m_impl->frameCount*m_impl->jointCount); } } - #if NAZARA_UTILITY_SAFE - else - { - unsigned int endFrame = sequence.firstFrame + sequence.frameCount - 1; - if (endFrame >= m_impl->frameCount) - { - NazaraError("Sequence end frame is over animation end frame"); - return false; - } - } - #endif if (!sequence.name.IsEmpty()) { @@ -84,12 +62,12 @@ namespace Nz auto it = m_impl->sequenceMap.find(sequence.name); if (it != m_impl->sequenceMap.end()) { - NazaraError("Sequence name \"" + sequence.name + "\" is already used"); + NazaraError("Sequence name \"" + sequence.name + "\" is already in use"); return false; } #endif - m_impl->sequenceMap[sequence.name] = m_impl->sequences.size(); + m_impl->sequenceMap[sequence.name] = static_cast(m_impl->sequences.size()); } m_impl->sequences.push_back(sequence); @@ -97,55 +75,16 @@ namespace Nz return true; } - void Animation::AnimateSkeleton(Skeleton* targetSkeleton, unsigned int frameA, unsigned int frameB, float interpolation) const + void Animation::AnimateSkeleton(Skeleton* targetSkeleton, UInt32 frameA, UInt32 frameB, float interpolation) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); + NazaraAssert(targetSkeleton && targetSkeleton->IsValid(), "Invalid skeleton"); + NazaraAssert(targetSkeleton->GetJointCount() == m_impl->jointCount, "Skeleton joint does not match animation joint count"); + NazaraAssert(frameA < m_impl->frameCount, "FrameA is out of range"); + NazaraAssert(frameB < m_impl->frameCount, "FrameB is out of range"); - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return; - } - - if (!targetSkeleton || !targetSkeleton->IsValid()) - { - NazaraError("Target skeleton is invalid"); - return; - } - - if (targetSkeleton->GetJointCount() != m_impl->jointCount) - { - NazaraError("Target skeleton joint count must match animation joint count"); - return; - } - - if (frameA >= m_impl->frameCount) - { - NazaraError("Frame A is out of range (" + String::Number(frameA) + " >= " + String::Number(m_impl->frameCount) + ')'); - return; - } - - if (frameB >= m_impl->frameCount) - { - NazaraError("Frame B is out of range (" + String::Number(frameB) + " >= " + String::Number(m_impl->frameCount) + ')'); - return; - } - #endif - - #ifdef NAZARA_DEBUG - if (interpolation < 0.f || interpolation > 1.f) - { - NazaraError("Interpolation must be in range [0..1] (Got " + String::Number(interpolation) + ')'); - return; - } - #endif - - for (unsigned int i = 0; i < m_impl->jointCount; ++i) + for (UInt32 i = 0; i < m_impl->jointCount; ++i) { Joint* joint = targetSkeleton->GetJoint(i); @@ -158,17 +97,12 @@ namespace Nz } } - bool Animation::CreateSkeletal(unsigned int frameCount, unsigned int jointCount) + bool Animation::CreateSkeletal(UInt32 frameCount, UInt32 jointCount) { - Destroy(); + NazaraAssert(frameCount > 0, "Frame count must be over zero"); + NazaraAssert(jointCount > 0, "Frame count must be over zero"); - #if NAZARA_UTILITY_SAFE - if (frameCount == 0) - { - NazaraError("Frame count must be over zero"); - return false; - } - #endif + Destroy(); m_impl = new AnimationImpl; m_impl->frameCount = frameCount; @@ -192,255 +126,130 @@ namespace Nz void Animation::EnableLoopPointInterpolation(bool loopPointInterpolation) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } - #endif + NazaraAssert(m_impl, "Animation not created"); m_impl->loopPointInterpolation = loopPointInterpolation; } - unsigned int Animation::GetFrameCount() const + UInt32 Animation::GetFrameCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->frameCount; } - unsigned int Animation::GetJointCount() const + UInt32 Animation::GetJointCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return 0; - } - - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return 0; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->jointCount; } Sequence* Animation::GetSequence(const String& sequenceName) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(sequenceName); - - #if NAZARA_UTILITY_SAFE if (it == m_impl->sequenceMap.end()) { NazaraError("Sequence not found"); return nullptr; } - #endif return &m_impl->sequences[it->second]; } - Sequence* Animation::GetSequence(unsigned int index) + Sequence* Animation::GetSequence(UInt32 index) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (index >= m_impl->sequences.size()) - { - NazaraError("Sequence index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->sequences.size()) + ')'); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); return &m_impl->sequences[index]; } const Sequence* Animation::GetSequence(const String& sequenceName) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(sequenceName); - - #if NAZARA_UTILITY_SAFE if (it == m_impl->sequenceMap.end()) { NazaraError("Sequence not found"); return nullptr; } - #endif return &m_impl->sequences[it->second]; } - const Sequence* Animation::GetSequence(unsigned int index) const + const Sequence* Animation::GetSequence(UInt32 index) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (index >= m_impl->sequences.size()) - { - NazaraError("Sequence index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->sequences.size()) + ')'); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); return &m_impl->sequences[index]; } - unsigned int Animation::GetSequenceCount() const + UInt32 Animation::GetSequenceCount() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return 0; - } - #endif + NazaraAssert(m_impl, "Animation not created"); - return m_impl->sequences.size(); + return static_cast(m_impl->sequences.size()); } - int Animation::GetSequenceIndex(const String& sequenceName) const + UInt32 Animation::GetSequenceIndex(const String& sequenceName) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return -1; - } - #endif + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(sequenceName); - - #if NAZARA_UTILITY_SAFE if (it == m_impl->sequenceMap.end()) { NazaraError("Sequence not found"); - return -1; + return 0xFFFFFFFF; } - #endif return it->second; } - SequenceJoint* Animation::GetSequenceJoints(unsigned int frameIndex) + SequenceJoint* Animation::GetSequenceJoints(UInt32 frameIndex) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); return &m_impl->sequenceJoints[frameIndex*m_impl->jointCount]; } - const SequenceJoint* Animation::GetSequenceJoints(unsigned int frameIndex) const + const SequenceJoint* Animation::GetSequenceJoints(UInt32 frameIndex) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return nullptr; - } - - if (m_impl->type != AnimationType_Skeletal) - { - NazaraError("Animation is not skeletal"); - return nullptr; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(m_impl->type == AnimationType_Skeletal, "Animation is not skeletal"); return &m_impl->sequenceJoints[frameIndex*m_impl->jointCount]; } AnimationType Animation::GetType() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return AnimationType_Static; // Ce qui est une valeur invalide pour Animation - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->type; } bool Animation::HasSequence(const String& sequenceName) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->sequenceMap.find(sequenceName) != m_impl->sequenceMap.end(); } - bool Animation::HasSequence(unsigned int index) const + bool Animation::HasSequence(UInt32 index) const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return index >= m_impl->sequences.size(); } bool Animation::IsLoopPointInterpolationEnabled() const { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return false; - } - #endif + NazaraAssert(m_impl, "Animation not created"); return m_impl->loopPointInterpolation; } @@ -467,12 +276,7 @@ namespace Nz void Animation::RemoveSequence(const String& identifier) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } + NazaraAssert(m_impl, "Animation not created"); auto it = m_impl->sequenceMap.find(identifier); if (it == m_impl->sequenceMap.end()) @@ -481,32 +285,16 @@ namespace Nz return; } - int index = it->second; - #else - int index = m_impl->sequenceMap[identifier]; - #endif + auto sequenceIt = m_impl->sequences.begin(); + std::advance(sequenceIt, it->second); - auto it2 = m_impl->sequences.begin(); - std::advance(it2, index); - - m_impl->sequences.erase(it2); + m_impl->sequences.erase(sequenceIt); } - void Animation::RemoveSequence(unsigned int index) + void Animation::RemoveSequence(UInt32 index) { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Animation not created"); - return; - } - - if (index >= m_impl->sequences.size()) - { - NazaraError("Sequence index out of range (" + String::Number(index) + " >= " + String::Number(m_impl->sequences.size()) + ')'); - return; - } - #endif + NazaraAssert(m_impl, "Animation not created"); + NazaraAssert(index < m_impl->sequences.size(), "Sequence index out of range"); auto it = m_impl->sequences.begin(); std::advance(it, index); diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index e61f6dda2..942b54f8e 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -37,10 +37,10 @@ namespace Nz } const MD5AnimParser::Frame* frames = parser.GetFrames(); - std::size_t frameCount = parser.GetFrameCount(); - std::size_t frameRate = parser.GetFrameRate(); + UInt32 frameCount = parser.GetFrameCount(); + UInt32 frameRate = parser.GetFrameRate(); const MD5AnimParser::Joint* joints = parser.GetJoints(); - std::size_t jointCount = parser.GetJointCount(); + UInt32 jointCount = parser.GetJointCount(); // À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation animation->CreateSkeletal(frameCount, jointCount); @@ -57,12 +57,12 @@ namespace Nz // Pour que le squelette soit correctement aligné, il faut appliquer un quaternion "de correction" aux joints à la base du squelette Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) * - Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); + Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up()); - for (std::size_t i = 0; i < jointCount; ++i) + for (UInt32 i = 0; i < jointCount; ++i) { int parent = joints[i].parent; - for (std::size_t j = 0; j < frameCount; ++j) + for (UInt32 j = 0; j < frameCount; ++j) { SequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i]; diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index 105944858..a1b02153b 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -48,9 +48,9 @@ namespace Nz return Ternary_False; } - std::size_t MD5AnimParser::GetAnimatedComponentCount() const + UInt32 MD5AnimParser::GetAnimatedComponentCount() const { - return m_animatedComponents.size(); + return static_cast(m_animatedComponents.size()); } const MD5AnimParser::Frame* MD5AnimParser::GetFrames() const @@ -58,12 +58,12 @@ namespace Nz return m_frames.data(); } - std::size_t MD5AnimParser::GetFrameCount() const + UInt32 MD5AnimParser::GetFrameCount() const { - return m_frames.size(); + return static_cast(m_frames.size()); } - std::size_t MD5AnimParser::GetFrameRate() const + UInt32 MD5AnimParser::GetFrameRate() const { return m_frameRate; } @@ -73,9 +73,9 @@ namespace Nz return m_joints.data(); } - std::size_t MD5AnimParser::GetJointCount() const + UInt32 MD5AnimParser::GetJointCount() const { - return m_joints.size(); + return static_cast(m_joints.size()); } bool MD5AnimParser::Parse() @@ -209,14 +209,14 @@ namespace Nz } } - unsigned int frameCount = m_frames.size(); + std::size_t frameCount = m_frames.size(); if (frameCount == 0) { NazaraError("Frame count is invalid or missing"); return false; } - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { NazaraError("Joint count is invalid or missing"); @@ -273,21 +273,21 @@ namespace Nz bool MD5AnimParser::ParseBaseframe() { - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); return false; } - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { if (!Advance()) return false; // Space is important for the buffer of \n if (std::sscanf(&m_currentLine[0], " ( %f %f %f ) ( %f %f %f )", &m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z, - &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 6) + &m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 6) { UnrecognizedLine(true); return false; @@ -312,14 +312,14 @@ namespace Nz bool MD5AnimParser::ParseBounds() { - unsigned int frameCount = m_frames.size(); + std::size_t frameCount = m_frames.size(); if (frameCount == 0) { Error("Frame count is invalid or missing"); return false; } - for (unsigned int i = 0; i < frameCount; ++i) + for (std::size_t i = 0; i < frameCount; ++i) { if (!Advance()) return false; @@ -353,14 +353,14 @@ namespace Nz bool MD5AnimParser::ParseFrame() { - unsigned int animatedComponentsCount = m_animatedComponents.size(); + std::size_t animatedComponentsCount = m_animatedComponents.size(); if (animatedComponentsCount == 0) { Error("Animated components count is missing or invalid"); return false; } - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); @@ -369,14 +369,14 @@ namespace Nz String line; - unsigned int count = 0; + std::size_t count = 0; do { if (!Advance()) return false; - unsigned int index = 0; - unsigned int size = m_currentLine.GetSize(); + std::size_t index = 0; + std::size_t size = m_currentLine.GetSize(); do { float f; @@ -399,11 +399,11 @@ namespace Nz m_frames[m_frameIndex].joints.resize(jointCount); - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { Quaternionf jointOrient = m_joints[i].bindOrient; Vector3f jointPos = m_joints[i].bindPos; - unsigned int j = 0; + UInt32 j = 0; if (m_joints[i].flags & 1) // Px jointPos.x = m_animatedComponents[m_joints[i].index + j++]; @@ -447,19 +447,19 @@ namespace Nz bool MD5AnimParser::ParseHierarchy() { - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); return false; } - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { if (!Advance()) return false; - unsigned int pos = m_currentLine.Find(' '); + std::size_t pos = m_currentLine.Find(' '); if (pos == String::npos) { UnrecognizedLine(true); @@ -482,10 +482,10 @@ namespace Nz m_joints[i].name = name; m_joints[i].name.Trim('"'); - int parent = m_joints[i].parent; + Int32 parent = m_joints[i].parent; if (parent >= 0) { - if (static_cast(parent) >= jointCount) + if (static_cast(parent) >= jointCount) { Error("Joint's parent is out of bounds (" + String::Number(parent) + " >= " + String::Number(jointCount) + ')'); return false; diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index cd8a6813a..59988405a 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -53,15 +53,15 @@ namespace Nz const MD5MeshParser::Joint* joints = parser.GetJoints(); const MD5MeshParser::Mesh* meshes = parser.GetMeshes(); - std::size_t jointCount = parser.GetJointCount(); - std::size_t meshCount = parser.GetMeshCount(); + UInt32 jointCount = parser.GetJointCount(); + UInt32 meshCount = parser.GetMeshCount(); if (parameters.animated) { mesh->CreateSkeletal(jointCount); Skeleton* skeleton = mesh->GetSkeleton(); - for (std::size_t i = 0; i < jointCount; ++i) + for (UInt32 i = 0; i < jointCount; ++i) { Joint* joint = skeleton->GetJoint(i); @@ -82,7 +82,7 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (std::size_t i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; @@ -100,7 +100,7 @@ namespace Nz // Le format définit un set de triangles nous permettant de retrouver facilement les indices // Cependant les sommets des triangles ne sont pas spécifiés dans le même ordre que ceux du moteur // (On parle ici de winding) - unsigned int index = 0; + UInt32 index = 0; for (const MD5MeshParser::Triangle& triangle : md5Mesh.triangles) { // On les respécifie dans le bon ordre (inversion du winding) @@ -227,7 +227,7 @@ namespace Nz } mesh->SetMaterialCount(meshCount); - for (std::size_t i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; std::size_t indexCount = md5Mesh.triangles.size()*3; diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index b4fd04a33..ce5264d01 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -58,9 +58,9 @@ namespace Nz return m_joints.data(); } - std::size_t MD5MeshParser::GetJointCount() const + UInt32 MD5MeshParser::GetJointCount() const { - return m_joints.size(); + return static_cast(m_joints.size()); } const MD5MeshParser::Mesh* MD5MeshParser::GetMeshes() const @@ -68,9 +68,9 @@ namespace Nz return m_meshes.data(); } - std::size_t MD5MeshParser::GetMeshCount() const + UInt32 MD5MeshParser::GetMeshCount() const { - return m_meshes.size(); + return static_cast(m_meshes.size()); } bool MD5MeshParser::Parse() @@ -211,19 +211,19 @@ namespace Nz bool MD5MeshParser::ParseJoints() { - unsigned int jointCount = m_joints.size(); + std::size_t jointCount = m_joints.size(); if (jointCount == 0) { Error("Joint count is invalid or missing"); return false; } - for (unsigned int i = 0; i < jointCount; ++i) + for (std::size_t i = 0; i < jointCount; ++i) { if (!Advance()) return false; - unsigned int pos = m_currentLine.Find(' '); + std::size_t pos = m_currentLine.Find(' '); if (pos == String::npos) { UnrecognizedLine(true); @@ -248,10 +248,10 @@ namespace Nz m_joints[i].name = name; m_joints[i].name.Trim('"'); - int parent = m_joints[i].parent; + Int32 parent = m_joints[i].parent; if (parent >= 0) { - if (static_cast(parent) >= jointCount) + if (static_cast(parent) >= jointCount) { Error("Joint's parent is out of bounds (" + String::Number(parent) + " >= " + String::Number(jointCount) + ')'); return false; diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 6685bcd04..b31ee24a9 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -160,7 +160,7 @@ namespace Nz } else if (keyword == "map_ka") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -172,7 +172,7 @@ namespace Nz } else if (keyword == "map_kd") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -184,7 +184,7 @@ namespace Nz } else if (keyword == "map_ks") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -196,7 +196,7 @@ namespace Nz } else if (keyword == "map_bump" || keyword == "bump") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -208,7 +208,7 @@ namespace Nz } else if (keyword == "map_d") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -220,7 +220,7 @@ namespace Nz } else if (keyword == "map_decal" || keyword == "decal") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -232,7 +232,7 @@ namespace Nz } else if (keyword == "map_disp" || keyword == "disp") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); @@ -244,7 +244,7 @@ namespace Nz } else if (keyword == "map_refl" || keyword == "refl") { - unsigned int mapPos = m_currentLine.GetWordPosition(1); + std::size_t mapPos = m_currentLine.GetWordPosition(1); if (mapPos != String::npos) { String map = m_currentLine.SubString(mapPos); diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 405c845ea..11029bada 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -40,7 +40,7 @@ namespace Nz return Ternary_Unknown; } - bool ParseMTL(Mesh* mesh, const String& filePath, const String* materials, const OBJParser::Mesh* meshes, unsigned int meshCount) + bool ParseMTL(Mesh* mesh, const String& filePath, const String* materials, const OBJParser::Mesh* meshes, UInt32 meshCount) { File file(filePath); if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) @@ -58,7 +58,7 @@ namespace Nz std::unordered_map materialCache; String baseDir = file.GetDirectory(); - for (unsigned int i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const String& matName = materials[meshes[i].material]; const MTLParser::Material* mtlMat = materialParser.GetMaterial(matName); @@ -154,21 +154,21 @@ namespace Nz const Vector3f* texCoords = parser.GetTexCoords(); const OBJParser::Mesh* meshes = parser.GetMeshes(); - unsigned int meshCount = parser.GetMeshCount(); + UInt32 meshCount = parser.GetMeshCount(); NazaraAssert(materials != nullptr && positions != nullptr && normals != nullptr && texCoords != nullptr && meshes != nullptr && meshCount > 0, "Invalid OBJParser output"); // Un conteneur temporaire pour contenir les indices de face avant triangulation - std::vector faceIndices(3); // Comme il y aura au moins trois sommets - for (unsigned int i = 0; i < meshCount; ++i) + std::vector faceIndices(3); // Comme il y aura au moins trois sommets + for (UInt32 i = 0; i < meshCount; ++i) { - unsigned int faceCount = meshes[i].faces.size(); + std::size_t faceCount = meshes[i].faces.size(); if (faceCount == 0) continue; - std::vector indices; + std::vector indices; indices.reserve(faceCount*3); // Pire cas si les faces sont des triangles // Afin d'utiliser OBJParser::FaceVertex comme clé dans un unordered_map, @@ -205,10 +205,10 @@ namespace Nz unsigned int vertexCount = 0; for (unsigned int j = 0; j < faceCount; ++j) { - unsigned int faceVertexCount = meshes[i].faces[j].vertexCount; + UInt32 faceVertexCount = meshes[i].faces[j].vertexCount; faceIndices.resize(faceVertexCount); - for (unsigned int k = 0; k < faceVertexCount; ++k) + for (UInt32 k = 0; k < faceVertexCount; ++k) { const OBJParser::FaceVertex& vertex = meshes[i].vertices[meshes[i].faces[j].firstVertex + k]; @@ -220,7 +220,7 @@ namespace Nz } // Triangulation - for (unsigned int k = 1; k < faceVertexCount-1; ++k) + for (UInt32 k = 1; k < faceVertexCount-1; ++k) { indices.push_back(faceIndices[0]); indices.push_back(faceIndices[k]); @@ -234,7 +234,7 @@ namespace Nz // Remplissage des indices IndexMapper indexMapper(indexBuffer, BufferAccess_WriteOnly); - for (unsigned int j = 0; j < indices.size(); ++j) + for (std::size_t j = 0; j < indices.size(); ++j) indexMapper.Set(j, indices[j]); indexMapper.Unmap(); // Pour laisser les autres tâches affecter l'index buffer diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index e2b63b467..a520d6be1 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -13,7 +13,7 @@ namespace Nz { - bool OBJParser::Parse(Nz::Stream& stream, std::size_t reservedVertexCount) + bool OBJParser::Parse(Nz::Stream& stream, UInt32 reservedVertexCount) { m_currentStream = &stream; @@ -50,8 +50,8 @@ namespace Nz using MatPair = std::pair; std::unordered_map> meshesByName; - std::size_t faceReserve = 0; - std::size_t vertexReserve = 0; + UInt32 faceReserve = 0; + UInt32 vertexReserve = 0; unsigned int matCount = 0; auto GetMaterial = [&] (const String& meshName, const String& matName) -> Mesh* { @@ -79,16 +79,16 @@ namespace Nz { case '#': //< Comment // Some softwares write comments to gives the number of vertex/faces an importer can expect - std::size_t data; - if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %zu", &data) == 1) + unsigned int data; + if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %u", &data) == 1) m_positions.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %u", &data) == 1) m_normals.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %u", &data) == 1) m_texCoords.reserve(data); - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %u", &data) == 1) faceReserve = data; - else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %zu", &data) == 1) + else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %u", &data) == 1) vertexReserve = data; break; @@ -118,8 +118,8 @@ namespace Nz currentMesh = GetMaterial(meshName, matName); Face face; - face.firstVertex = currentMesh->vertices.size(); - face.vertexCount = vertexCount; + face.firstVertex = static_cast(currentMesh->vertices.size()); + face.vertexCount = static_cast(vertexCount); currentMesh->vertices.resize(face.firstVertex + vertexCount, FaceVertex{0, 0, 0}); @@ -203,9 +203,9 @@ namespace Nz break; } - currentMesh->vertices[face.firstVertex + i].normal = static_cast(n); - currentMesh->vertices[face.firstVertex + i].position = static_cast(p); - currentMesh->vertices[face.firstVertex + i].texCoord = static_cast(t); + currentMesh->vertices[face.firstVertex + i].normal = static_cast(n); + currentMesh->vertices[face.firstVertex + i].position = static_cast(p); + currentMesh->vertices[face.firstVertex + i].texCoord = static_cast(t); pos += offset; } diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index a7a2cda0b..534eb1952 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -78,7 +78,7 @@ namespace Nz return false; } - std::size_t worstCacheVertexCount = mesh.GetVertexCount(); + UInt32 worstCacheVertexCount = mesh.GetVertexCount(); OBJParser objFormat; objFormat.SetNormalCount(worstCacheVertexCount); objFormat.SetPositionCount(worstCacheVertexCount); @@ -101,9 +101,9 @@ namespace Nz MTLParser mtlFormat; std::unordered_set registredMaterials; - std::size_t matCount = mesh.GetMaterialCount(); + UInt32 matCount = mesh.GetMaterialCount(); String* materialNames = objFormat.SetMaterialCount(matCount); - for (std::size_t i = 0; i < matCount; ++i) + for (UInt32 i = 0; i < matCount; ++i) { const ParameterList& matData = mesh.GetMaterialData(i); @@ -152,13 +152,13 @@ namespace Nz } // Meshes - std::size_t meshCount = mesh.GetSubMeshCount(); + UInt32 meshCount = mesh.GetSubMeshCount(); OBJParser::Mesh* meshes = objFormat.SetMeshCount(meshCount); - for (std::size_t i = 0; i < meshCount; ++i) + for (UInt32 i = 0; i < meshCount; ++i) { const StaticMesh* staticMesh = static_cast(mesh.GetSubMesh(i)); - std::size_t triangleCount = staticMesh->GetTriangleCount(); + UInt32 triangleCount = staticMesh->GetTriangleCount(); meshes[i].faces.resize(triangleCount); meshes[i].material = staticMesh->GetMaterialIndex(); @@ -180,7 +180,7 @@ namespace Nz face.firstVertex = faceIndex * 3; face.vertexCount = 3; - for (std::size_t j = 0; j < 3; ++j) + for (unsigned int j = 0; j < 3; ++j) { OBJParser::FaceVertex& vertexIndices = meshes[i].vertices[face.firstVertex + j]; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 84559abda..363be074d 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -55,7 +55,7 @@ namespace Nz materialData.resize(1); // Un matériau par défaut } - std::unordered_map subMeshMap; + std::unordered_map subMeshMap; std::vector materialData; std::vector subMeshes; AnimationType animationType; @@ -63,7 +63,7 @@ namespace Nz Skeleton skeleton; // Uniquement pour les meshs squelettiques String animationPath; bool aabbUpdated = false; - unsigned int jointCount; // Uniquement pour les meshs squelettiques + UInt32 jointCount; // Uniquement pour les meshs squelettiques }; Mesh::~Mesh() @@ -92,7 +92,7 @@ namespace Nz NazaraAssert(subMesh, "Invalid submesh"); NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type"); - int index = m_impl->subMeshes.size(); + UInt32 index = m_impl->subMeshes.size(); m_impl->subMeshes.push_back(subMesh); m_impl->subMeshMap[identifier] = index; @@ -276,11 +276,11 @@ namespace Nz void Mesh::BuildSubMeshes(const PrimitiveList& list, const MeshParams& params) { - for (unsigned int i = 0; i < list.GetSize(); ++i) + for (UInt32 i = 0; i < list.GetSize(); ++i) BuildSubMesh(list.GetPrimitive(i), params); } - bool Mesh::CreateSkeletal(unsigned int jointCount) + bool Mesh::CreateSkeletal(UInt32 jointCount) { Destroy(); @@ -349,11 +349,11 @@ namespace Nz if (!m_impl->aabbUpdated) { - unsigned int subMeshCount = m_impl->subMeshes.size(); + UInt32 subMeshCount = m_impl->subMeshes.size(); if (subMeshCount > 0) { m_impl->aabb.Set(m_impl->subMeshes[0]->GetAABB()); - for (unsigned int i = 1; i < subMeshCount; ++i) + for (UInt32 i = 1; i < subMeshCount; ++i) m_impl->aabb.ExtendTo(m_impl->subMeshes[i]->GetAABB()); } else @@ -379,7 +379,7 @@ namespace Nz return m_impl->animationType; } - unsigned int Mesh::GetJointCount() const + UInt32 Mesh::GetJointCount() const { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(m_impl->animationType == AnimationType_Skeletal, "Mesh is not skeletal"); @@ -387,7 +387,7 @@ namespace Nz return m_impl->jointCount; } - ParameterList& Mesh::GetMaterialData(unsigned int index) + ParameterList& Mesh::GetMaterialData(UInt32 index) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->materialData.size(), "Material index out of range"); @@ -395,7 +395,7 @@ namespace Nz return m_impl->materialData[index]; } - const ParameterList& Mesh::GetMaterialData(unsigned int index) const + const ParameterList& Mesh::GetMaterialData(UInt32 index) const { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->materialData.size(), "Material index out of range"); @@ -403,7 +403,7 @@ namespace Nz return m_impl->materialData[index]; } - unsigned int Mesh::GetMaterialCount() const + UInt32 Mesh::GetMaterialCount() const { NazaraAssert(m_impl, "Mesh should be created first"); @@ -436,7 +436,7 @@ namespace Nz return m_impl->subMeshes[it->second]; } - SubMesh* Mesh::GetSubMesh(unsigned int index) + SubMesh* Mesh::GetSubMesh(UInt32 index) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); @@ -454,7 +454,7 @@ namespace Nz return m_impl->subMeshes[it->second]; } - const SubMesh* Mesh::GetSubMesh(unsigned int index) const + const SubMesh* Mesh::GetSubMesh(UInt32 index) const { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); @@ -462,14 +462,14 @@ namespace Nz return m_impl->subMeshes[index]; } - unsigned int Mesh::GetSubMeshCount() const + UInt32 Mesh::GetSubMeshCount() const { NazaraAssert(m_impl, "Mesh should be created first"); return m_impl->subMeshes.size(); } - int Mesh::GetSubMeshIndex(const String& identifier) const + UInt32 Mesh::GetSubMeshIndex(const String& identifier) const { NazaraAssert(m_impl, "Mesh should be created first"); @@ -479,22 +479,22 @@ namespace Nz return it->second; } - unsigned int Mesh::GetTriangleCount() const + UInt32 Mesh::GetTriangleCount() const { NazaraAssert(m_impl, "Mesh should be created first"); - unsigned int triangleCount = 0; + UInt32 triangleCount = 0; for (SubMesh* subMesh : m_impl->subMeshes) triangleCount += subMesh->GetTriangleCount(); return triangleCount; } - unsigned int Mesh::GetVertexCount() const + UInt32 Mesh::GetVertexCount() const { NazaraAssert(m_impl, "Mesh should be created first"); - unsigned int vertexCount = 0; + UInt32 vertexCount = 0; for (SubMesh* subMesh : m_impl->subMeshes) vertexCount += subMesh->GetVertexCount(); @@ -515,7 +515,7 @@ namespace Nz return m_impl->subMeshMap.find(identifier) != m_impl->subMeshMap.end(); } - bool Mesh::HasSubMesh(unsigned int index) const + bool Mesh::HasSubMesh(UInt32 index) const { NazaraAssert(m_impl, "Mesh should be created first"); @@ -564,8 +564,8 @@ namespace Nz BufferMapper mapper(staticMesh->GetVertexBuffer(), BufferAccess_ReadWrite); MeshVertex* vertices = static_cast(mapper.GetPointer()); - unsigned int vertexCount = staticMesh->GetVertexCount(); - for (unsigned int i = 0; i < vertexCount; ++i) + UInt32 vertexCount = staticMesh->GetVertexCount(); + for (UInt32 i = 0; i < vertexCount; ++i) { vertices->position -= center; vertices++; @@ -583,7 +583,7 @@ namespace Nz void Mesh::RemoveSubMesh(const String& identifier) { - unsigned int index = GetSubMeshIndex(identifier); + UInt32 index = GetSubMeshIndex(identifier); // On déplace l'itérateur du début d'une distance de x auto it2 = m_impl->subMeshes.begin(); @@ -593,7 +593,7 @@ namespace Nz InvalidateAABB(); } - void Mesh::RemoveSubMesh(unsigned int index) + void Mesh::RemoveSubMesh(UInt32 index) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(index < m_impl->subMeshes.size(), "Submesh index out of range"); @@ -623,7 +623,7 @@ namespace Nz m_impl->animationPath = animationPath; } - void Mesh::SetMaterialData(unsigned int matIndex, ParameterList data) + void Mesh::SetMaterialData(UInt32 matIndex, ParameterList data) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(matIndex < m_impl->materialData.size(), "Material index out of range"); @@ -631,7 +631,7 @@ namespace Nz m_impl->materialData[matIndex] = std::move(data); } - void Mesh::SetMaterialCount(unsigned int matCount) + void Mesh::SetMaterialCount(UInt32 matCount) { NazaraAssert(m_impl, "Mesh should be created first"); NazaraAssert(matCount > 0, "A mesh should have at least a material"); @@ -641,7 +641,7 @@ namespace Nz #ifdef NAZARA_DEBUG for (SubMesh* subMesh : m_impl->subMeshes) { - unsigned int matIndex = subMesh->GetMaterialIndex(); + UInt32 matIndex = subMesh->GetMaterialIndex(); if (matIndex >= matCount) { subMesh->SetMaterialIndex(0); // To prevent a crash @@ -665,8 +665,8 @@ namespace Nz Boxf aabb(vertices->position.x, vertices->position.y, vertices->position.z, 0.f, 0.f, 0.f); - unsigned int vertexCount = staticMesh->GetVertexCount(); - for (unsigned int i = 0; i < vertexCount; ++i) + UInt32 vertexCount = staticMesh->GetVertexCount(); + for (UInt32 i = 0; i < vertexCount; ++i) { vertices->position = matrix.Transform(vertices->position); aabb.ExtendTo(vertices->position); diff --git a/src/Nazara/Utility/Skeleton.cpp b/src/Nazara/Utility/Skeleton.cpp index ad5632b90..70f7adb07 100644 --- a/src/Nazara/Utility/Skeleton.cpp +++ b/src/Nazara/Utility/Skeleton.cpp @@ -10,7 +10,7 @@ namespace Nz { struct SkeletonImpl { - std::unordered_map jointMap; + std::unordered_map jointMap; std::vector joints; Boxf aabb; bool aabbUpdated = false; @@ -31,7 +31,7 @@ namespace Nz Destroy(); } - bool Skeleton::Create(unsigned int jointCount) + bool Skeleton::Create(UInt32 jointCount) { #if NAZARA_UTILITY_SAFE if (jointCount == 0) @@ -72,12 +72,12 @@ namespace Nz if (!m_impl->aabbUpdated) { - unsigned int jointCount = m_impl->joints.size(); + UInt32 jointCount = m_impl->joints.size(); if (jointCount > 0) { Vector3f pos = m_impl->joints[0].GetPosition(); m_impl->aabb.Set(pos.x, pos.y, pos.z, 0.f, 0.f, 0.f); - for (unsigned int i = 1; i < jointCount; ++i) + for (UInt32 i = 1; i < jointCount; ++i) m_impl->aabb.ExtendTo(m_impl->joints[i].GetPosition()); } else @@ -117,7 +117,7 @@ namespace Nz return &m_impl->joints[it->second]; } - Joint* Skeleton::GetJoint(unsigned int index) + Joint* Skeleton::GetJoint(UInt32 index) { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -164,7 +164,7 @@ namespace Nz return &m_impl->joints[it->second]; } - const Joint* Skeleton::GetJoint(unsigned int index) const + const Joint* Skeleton::GetJoint(UInt32 index) const { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -209,7 +209,7 @@ namespace Nz return &m_impl->joints[0]; } - unsigned int Skeleton::GetJointCount() const + UInt32 Skeleton::GetJointCount() const { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -278,13 +278,13 @@ namespace Nz Joint* jointsA = &skeletonA.m_impl->joints[0]; Joint* jointsB = &skeletonB.m_impl->joints[0]; - for (unsigned int i = 0; i < m_impl->joints.size(); ++i) + for (std::size_t i = 0; i < m_impl->joints.size(); ++i) m_impl->joints[i].Interpolate(jointsA[i], jointsB[i], interpolation, CoordSys_Local); InvalidateJoints(); } - void Skeleton::Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, unsigned int* indices, unsigned int indiceCount) + void Skeleton::Interpolate(const Skeleton& skeletonA, const Skeleton& skeletonB, float interpolation, UInt32* indices, UInt32 indiceCount) { #if NAZARA_UTILITY_SAFE if (!m_impl) @@ -314,9 +314,9 @@ namespace Nz const Joint* jointsA = &skeletonA.m_impl->joints[0]; const Joint* jointsB = &skeletonB.m_impl->joints[0]; - for (unsigned int i = 0; i < indiceCount; ++i) + for (UInt32 i = 0; i < indiceCount; ++i) { - unsigned int index = indices[i]; + UInt32 index = indices[i]; #if NAZARA_UTILITY_SAFE if (index >= m_impl->joints.size()) @@ -351,16 +351,16 @@ namespace Nz m_impl->jointMapUpdated = skeleton.m_impl->jointMapUpdated; m_impl->joints = skeleton.m_impl->joints; - // Code crade mais son optimisation demanderait de stocker jointCount*sizeof(unsigned int) en plus + // Code crade mais son optimisation demanderait de stocker jointCount*sizeof(UInt32) en plus // Ce qui, pour juste une copie qui ne se fera que rarement, ne vaut pas le coup // L'éternel trade-off mémoire/calculs .. - unsigned int jointCount = skeleton.m_impl->joints.size(); - for (unsigned int i = 0; i < jointCount; ++i) + std::size_t jointCount = skeleton.m_impl->joints.size(); + for (std::size_t i = 0; i < jointCount; ++i) { const Node* parent = skeleton.m_impl->joints[i].GetParent(); if (parent) { - for (unsigned int j = 0; j < i; ++j) // Le parent se trouve forcément avant nous + for (std::size_t j = 0; j < i; ++j) // Le parent se trouve forcément avant nous { if (parent == &skeleton.m_impl->joints[j]) // A-t-on trouvé le parent ? { @@ -406,7 +406,7 @@ namespace Nz #endif m_impl->jointMap.clear(); - for (unsigned int i = 0; i < m_impl->joints.size(); ++i) + for (std::size_t i = 0; i < m_impl->joints.size(); ++i) { String name = m_impl->joints[i].GetName(); if (!name.IsEmpty()) diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index 8b0589808..c8da223f0 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -196,7 +196,7 @@ namespace Nz return 0; } - unsigned int SubMesh::GetMaterialIndex() const + UInt32 SubMesh::GetMaterialIndex() const { return m_matIndex; } @@ -206,7 +206,7 @@ namespace Nz m_primitiveMode = mode; } - void SubMesh::SetMaterialIndex(unsigned int matIndex) + void SubMesh::SetMaterialIndex(UInt32 matIndex) { m_matIndex = matIndex; } From 8a36442c3848af415cc4600e33358ea48657edbc Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 20:40:02 +0200 Subject: [PATCH 263/383] Clean up some code Former-commit-id: d1d166225cc95474130e59645f9397b6a4130267 [formerly 10b948f0d7e08992d86cecb54a1931de50d0abd4] [formerly a23d07003f7c7583a900b532119d9402a77b1830 [formerly 8418fb742937775772c79e6546b617382f0cb22a]] Former-commit-id: e628a175a930f2390cedfd3b26831826514b265f [formerly fa8c6a19f29e64e4cd90b212e01a5acf97f1740f] Former-commit-id: 795328aea7f39068b6575c948b5c51fc5adf9f12 --- include/Nazara/Physics/Geom.hpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 +- src/Nazara/Physics/Geom.cpp | 21 +++++++-------------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/include/Nazara/Physics/Geom.hpp b/include/Nazara/Physics/Geom.hpp index 23a02c72b..e228c3d07 100644 --- a/include/Nazara/Physics/Geom.hpp +++ b/include/Nazara/Physics/Geom.hpp @@ -134,7 +134,7 @@ namespace Nz class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom { public: - CompoundGeom(PhysGeom** geoms, unsigned int geomCount); + CompoundGeom(PhysGeom** geoms, std::size_t geomCount); const std::vector& GetGeoms() const; GeomType GetType() const override; diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index cbcebb83b..0097227ef 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -56,7 +56,7 @@ namespace Nz std::array hostnameBuffer; std::array serviceBuffer; - int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); + int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); if (result == 0) { if (hostname) diff --git a/src/Nazara/Physics/Geom.cpp b/src/Nazara/Physics/Geom.cpp index e814b8618..48d6f0090 100644 --- a/src/Nazara/Physics/Geom.cpp +++ b/src/Nazara/Physics/Geom.cpp @@ -125,16 +125,7 @@ namespace Nz PhysGeomRef PhysGeom::Build(const PrimitiveList& list) { - unsigned int primitiveCount = list.GetSize(); - - #if NAZARA_PHYSICS_SAFE - if (primitiveCount == 0) - { - NazaraError("PrimitiveList must have at least one primitive"); - return nullptr; - } - #endif - + std::size_t primitiveCount = list.GetSize(); if (primitiveCount > 1) { std::vector geoms(primitiveCount); @@ -144,8 +135,10 @@ namespace Nz return CompoundGeom::New(&geoms[0], primitiveCount); } - else + else if (primitiveCount > 0) return CreateGeomFromPrimitive(list.GetPrimitive(0)); + else + return NullGeom::New(); } bool PhysGeom::Initialize() @@ -246,10 +239,10 @@ namespace Nz /******************************* CompoundGeom ********************************/ - CompoundGeom::CompoundGeom(PhysGeom** geoms, unsigned int geomCount) + CompoundGeom::CompoundGeom(PhysGeom** geoms, std::size_t geomCount) { m_geoms.reserve(geomCount); - for (unsigned int i = 0; i < geomCount; ++i) + for (std::size_t i = 0; i < geomCount; ++i) m_geoms.emplace_back(geoms[i]); } @@ -349,7 +342,7 @@ namespace Nz NewtonCollision* ConvexHullGeom::CreateHandle(PhysWorld* world) const { - return NewtonCreateConvexHull(world->GetHandle(), m_vertices.size(), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); + return NewtonCreateConvexHull(world->GetHandle(), static_cast(m_vertices.size()), reinterpret_cast(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); } /******************************* CylinderGeom ********************************/ From da7216a2020bc21da2ab8ed9c6dc5999248489bd Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 4 Sep 2016 21:00:23 +0200 Subject: [PATCH 264/383] Utility/OBJSaver: Remove some warnings Former-commit-id: 7762f44e85efd99346752899b43d757512eee8fc [formerly 6b86a269f98d9421b60263f2e8435cf14445e469] [formerly ecd111f0499e4659638c11071ae1f472303fa0d9 [formerly d272286ae403222512e8ca9178419094f7da4a0c]] Former-commit-id: 4211533ae1db2ce95fda5721a0c1050afe3d67f9 [formerly 10f4944022e9fac77060407fd6f05ab40aa20e09] Former-commit-id: 12747ce9a2c9c3fc2e2b02233d06e9370b18f790 --- include/Nazara/Core/Bitset.inl | 2 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index 21457d7c7..d29315afd 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -121,7 +121,7 @@ namespace Nz if (sizeof(T) <= sizeof(Block)) { m_bitCount = std::numeric_limits::digits; - m_blocks.push_back(value); + m_blocks.push_back(static_cast(value)); } else { diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index 534eb1952..6ed15e717 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -35,12 +35,12 @@ namespace Nz { } - std::size_t GetCount() const + UInt32 GetCount() const { return m_count; } - std::size_t Insert(const T& data) + UInt32 Insert(const T& data) { auto it = m_cache.find(data); if (it == m_cache.end()) @@ -54,8 +54,8 @@ namespace Nz } private: - std::size_t m_count; - std::map m_cache; + UInt32 m_count; + std::map m_cache; T* m_buffer; }; @@ -172,7 +172,7 @@ namespace Nz SparsePtr positionPtr = vertexMapper.GetComponentPtr(VertexComponent_Position); SparsePtr texCoordsPtr = vertexMapper.GetComponentPtr(VertexComponent_TexCoord); - std::size_t faceIndex = 0; + UInt32 faceIndex = 0; TriangleIterator triangle(staticMesh); do { @@ -184,7 +184,7 @@ namespace Nz { OBJParser::FaceVertex& vertexIndices = meshes[i].vertices[face.firstVertex + j]; - std::size_t index = triangle[j]; + UInt32 index = triangle[j]; vertexIndices.normal = normalCache.Insert(normalPtr[index]); vertexIndices.position = positionCache.Insert(positionPtr[index]); vertexIndices.texCoord = texCoordsCache.Insert(texCoordsPtr[index]); From fb64f052dcf269ad30926f86114b324952e2b7db Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 6 Sep 2016 13:30:53 +0200 Subject: [PATCH 265/383] SDK/Binding: Fix compilation Former-commit-id: 16a69ef5de792f9093fc27ddafaa8e5677d9f66d [formerly 72c2eca09f8e48b414956056cbf16b40cd96b2e5] [formerly a73d622403c9a746ac5f39b3d45178bb21006a17 [formerly 095a0737f1aa42b7d4ba9e09fd897c5ab173b75b]] Former-commit-id: 0373630192183dd80d1250d6132ae676be0b7267 [formerly 4eee844b3dcec8789cd990f6f42fe9ac2e57c3fe] Former-commit-id: b50dd40211e104f15eba529b434c74e9151bb78e --- SDK/src/NDK/LuaBinding_SDK.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 35c59ae68..1ccd16342 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -139,7 +139,7 @@ namespace Ndk #ifndef NDK_SERVER /*********************************** Ndk::GraphicsComponent **********************************/ - graphicsComponent.BindMethod("Attach", &GraphicsComponent::Attach, 0); + graphicsComponent.BindMethod("Attach", (void(Ndk::GraphicsComponent::*)(Nz::InstancedRenderableRef, int)) &GraphicsComponent::Attach, 0); #endif From 7c3d9c563c2c6af86bb622018e580468b41fea1e Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 7 Sep 2016 13:04:58 +0200 Subject: [PATCH 266/383] Graphics/Sprite: Allows to set sprite corner color Former-commit-id: 0b892e363a4fbb18c729d289f543403d897b03c0 [formerly 28fcd5a7269c63b1f8c4c8c80c82e5dce9e17d1b] [formerly f8022fe7d864a6c1773c4e19843d7fc46590d328 [formerly 33fbfb6cd1700a3e05bc82875546cd57cfe6f6aa]] Former-commit-id: 3ef8f144f07c0cf7666b59cdcc135fc74348caf9 [formerly 8bae7631b9aaf2565ec52d68f9c0c1a7a81dc69f] Former-commit-id: 6eba237772ab4773180e3a86e9fe4f9b6b8e348d --- include/Nazara/Graphics/Sprite.hpp | 3 ++ include/Nazara/Graphics/Sprite.inl | 59 +++++++++++++++++++++++++++--- src/Nazara/Graphics/Sprite.cpp | 9 ++--- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index 3aa261d89..13bcc289b 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -37,12 +37,14 @@ namespace Nz void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; inline const Color& GetColor() const; + inline const Color& GetCornerColor(RectCorner corner) const; inline const MaterialRef& GetMaterial() const; inline const Vector3f& GetOrigin() const; inline const Vector2f& GetSize() const; inline const Rectf& GetTextureCoords() const; inline void SetColor(const Color& color); + inline void SetCornerColor(RectCorner corner, const Color& color); inline void SetDefaultMaterial(); inline void SetMaterial(MaterialRef material, bool resizeSprite = true); inline void SetOrigin(const Vector3f& origin); @@ -65,6 +67,7 @@ namespace Nz static bool Initialize(); static void Uninitialize(); + std::array m_cornerColor; Color m_color; MaterialRef m_material; Rectf m_textureCoords; diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 410b42478..bc27bf67c 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -18,6 +18,9 @@ namespace Nz m_size(64.f, 64.f), m_origin(Nz::Vector3f::Zero()) { + for (Color& color : m_cornerColor) + color = Color::White; + SetDefaultMaterial(); } @@ -62,14 +65,35 @@ namespace Nz /*! * \brief Gets the color of the sprite + * + * This is the global color of the sprite, independent from corner colors + * * \return Current color + * + * \see GetCornerColor + * \see SetColor */ - inline const Color& Sprite::GetColor() const { return m_color; } + /*! + * \brief Gets the color setup on a corner of the sprite + * + * \return Current color + * + * \param corner Corner of the sprite to query + * + * \see SetCornerColor + */ + inline const Color& Sprite::GetCornerColor(RectCorner corner) const + { + NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + + return m_cornerColor[corner]; + } + /*! * \brief Gets the material of the sprite * \return Current material @@ -86,7 +110,7 @@ namespace Nz * * \see SetOrigin */ - inline const Vector3f & Sprite::GetOrigin() const + inline const Vector3f& Sprite::GetOrigin() const { return m_origin; } @@ -105,18 +129,21 @@ namespace Nz * \brief Gets the texture coordinates of the sprite * \return Current texture coordinates */ - inline const Rectf& Sprite::GetTextureCoords() const { return m_textureCoords; } /*! - * \brief Sets the color of the billboard + * \brief Sets the global color of the sprite * - * \param color Color for the billboard + * This is independent from the corner color of the sprite + * + * \param color Color for the sprite + * + * \see GetColor + * \see SetCornerColor */ - inline void Sprite::SetColor(const Color& color) { m_color = color; @@ -124,6 +151,26 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets a color for a corner of the sprite + * + * This is independent from the sprite global color, which gets multiplied by the corner color when rendering the sprite. + * + * \param corner Corner of the sprite to set + * \param color Color for the sprite + * + * \see GetCornerColor + * \see SetColor + */ + inline void Sprite::SetCornerColor(RectCorner corner, const Color& color) + { + NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + + m_cornerColor[corner] = color; + + InvalidateVertices(); + } + /*! * \brief Sets the default material of the sprite (just default material) */ diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 8b950bf2a..1b14ab6de 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -49,7 +49,6 @@ namespace Nz * * \param instanceData Data of the instance */ - void Sprite::UpdateData(InstanceData* instanceData) const { instanceData->data.resize(4 * sizeof(VertexStruct_XYZ_Color_UV)); @@ -61,19 +60,19 @@ namespace Nz Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftTop]; *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_RightTop]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftBottom]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_RightBottom]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 1ce64258d8a1ad812e02ae9b4357da7efe665edc Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 9 Sep 2016 23:17:36 +0200 Subject: [PATCH 267/383] Sdk/Entity: Fix component cleaning on destruction Former-commit-id: 16ede7dcd3b58da549656d02a00296f3310184a0 [formerly 4375abfedc741682c2f36eb73a1b4445b1cbda8f] [formerly 3d53a5ff990895c025a130f1f6e7103425c316c9 [formerly 8896228a838acbaf2e4149b198e013392b5bac0c]] Former-commit-id: 46717838dc1ace6352a3c3d98f85c586d971972e [formerly 87607fba567be467e78f47972c80fbe500cec4a8] Former-commit-id: 30d8a37c62cec76c1dde27f15daf1dbff8e8317f --- SDK/src/NDK/Entity.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 815d0dc1b..a49a8f6aa 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -158,6 +158,9 @@ namespace Ndk UnregisterAllHandles(); + m_components.clear(); + m_componentBits.Reset(); + m_valid = false; } From c3945f84923d23c4a654bb7762d05c7cfc37d76e Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:29:12 +0200 Subject: [PATCH 268/383] Test AppVeyor Former-commit-id: fcc4e66322c3526f452974266e9707acb279c9b4 [formerly fe0d63e8b378effbc90bc690decf41872119fab3] [formerly 180ee0a987724f139bfd5a787d9f2fbcf32e5863 [formerly 7a4fd75231de24e3c3eb4631b3ccd267d9788257]] Former-commit-id: 8365cc00d18be9e1b3f4f762a4bf845d0e39ddc4 [formerly e9a8dad2c15e3114b7df56fbab3ec2d13614a449] Former-commit-id: 69379db76e5e944c106f1a1592e39860e7ec0a81 --- appveyor.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..756c1e14b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +shallow_clone: true + +os: + - Visual Studio 2015 + +environment: + matrix: + - TOOLSET: vs2010 + - TOOLSET: vs2013 + - TOOLSET: vs2015 + +install: + - cd build && "./premake5.exe" %TOOLSET% && cd .. + +configuration: + - Debug + - Release + +build: + project: NazaraEngine/build/$(TOOLSET)/NazaraEngine.sln + +after_test: + - NazaraEngine\tests\Tests.exe From e6f5ef46ad3997c3e1b3f4afdd043cb7bb62cb37 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:30:45 +0200 Subject: [PATCH 269/383] Try to fix build Former-commit-id: 499ff654ec4ae803f40ce607fac1f2ecd227ad78 [formerly 31ff66cb3d17c2d17002229b7ed56cb55c1d9d40] [formerly 1cce07c655bd8b87ba04c84dd683a9aabb30e60d [formerly 0918ea3e67a8471a662b4618be8164b74c2fdb81]] Former-commit-id: 121b4c7419260d282629b4a1c2c6f8135d29766d [formerly c149e9d3b4552711fefc71c73d9c45f2ae12d4b1] Former-commit-id: 1e5012bbfd1dc2915c42aa63597ef20259b24f92 --- appveyor.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 756c1e14b..498270c14 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,6 @@ os: environment: matrix: - - TOOLSET: vs2010 - - TOOLSET: vs2013 - TOOLSET: vs2015 install: @@ -17,7 +15,4 @@ configuration: - Release build: - project: NazaraEngine/build/$(TOOLSET)/NazaraEngine.sln - -after_test: - - NazaraEngine\tests\Tests.exe + project: build/$(TOOLSET)/NazaraEngine.sln \ No newline at end of file From fac97086ca0c4178f32e611d39872d9ed7f1838f Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:35:58 +0200 Subject: [PATCH 270/383] Damnit Former-commit-id: bb159672db85225cce3945f809c6e3dab5cc45ed [formerly 4de941226b9d851bedc5cffc9934b8547f01f7b9] [formerly 86a1dd7b8768a993a0d9edc6848e80974c9014fd [formerly 832d3b5a6ac4428e708943c4bfe06573d3449bad]] Former-commit-id: 06b9982f5c9de274cd70c4ec4d5a76b436a3e28b [formerly a7f4fb44ee5f2a4769849aaedfb1526fd64a530e] Former-commit-id: b8969759bb762818162abef970b14726bf9183b3 --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 498270c14..a705a4c8c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,5 @@ +version: '{branch}-rev{build}' +configuration: DebugDynamic, ReleaseDynamic shallow_clone: true os: From d8caea738f5684ce944fc28933f341e921515016 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:36:34 +0200 Subject: [PATCH 271/383] I'm a moron Former-commit-id: e0bc0cbf0810d92ec21569e47e25ff344754c45d [formerly 5de16df03c69dd12360d92b3f526f582a7788de3] [formerly a6391f964534e24dbb766fbd0ba7775f108bcf9b [formerly 42441b30de399dbe4d83d7156232a6db3044a7d6]] Former-commit-id: c320af3cdf8f44494f4edaf45288a8ac9cbfb6ea [formerly 26cf22fa23593ab18e3543210e7d17ad7a4380ed] Former-commit-id: 3ac65b75454925ccd9a48a1d8f92e97712fc9532 --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a705a4c8c..39ff8f7a8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: '{branch}-rev{build}' -configuration: DebugDynamic, ReleaseDynamic + shallow_clone: true os: @@ -13,8 +13,8 @@ install: - cd build && "./premake5.exe" %TOOLSET% && cd .. configuration: - - Debug - - Release + - DebugDynamic + - ReleaseDynamic build: project: build/$(TOOLSET)/NazaraEngine.sln \ No newline at end of file From 357128f0b656c969608afa9808358f83cd102743 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 13 Sep 2016 19:51:46 +0200 Subject: [PATCH 272/383] Graphics/Sprite: Fix warning in Sprite.inl Former-commit-id: acfa72fdbd3aa66e4bc0cb917a1a8cc7c0b8395e [formerly d9db1c38b03b447ef582abe4c1032fd6e9a2485a] [formerly 5d90dc0f2aa86933526a6d06e02500112f7b4d30 [formerly f270581870a1efe3d37f270e560210bf3cec84e3]] Former-commit-id: 69b6226e20f64bd3a2c2eab1ba0dc04c86160575 [formerly 03b7cd7f3c69d324c6d279ad3f1f8eda18a8551b] Former-commit-id: 9002c0116b59210fa094dc86851bdc5b48b0908c --- include/Nazara/Graphics/Sprite.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index bc27bf67c..35885a94a 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -89,7 +89,7 @@ namespace Nz */ inline const Color& Sprite::GetCornerColor(RectCorner corner) const { - NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + NazaraAssert(static_cast(corner) < m_cornerColor.size(), "Invalid corner"); return m_cornerColor[corner]; } @@ -164,7 +164,7 @@ namespace Nz */ inline void Sprite::SetCornerColor(RectCorner corner, const Color& color) { - NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + NazaraAssert(static_cast(corner) < m_cornerColor.size(), "Invalid corner"); m_cornerColor[corner] = color; From 8e009a1d6673431fa9a48e0d5d467a76cfdd6ab2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Sep 2016 00:46:59 +0200 Subject: [PATCH 273/383] Core/MemoryHelper: Add portable stack allocation Former-commit-id: 50b96029c53d1784f028148f1ec15ae2cf98d036 [formerly eb3398905190df3d0dc77c8a3b54bb455059e39b] [formerly bfac4638e043161208ee7cf4735a788b1427f73e [formerly 1ee0a59ab5aa407c995afd287a9aaa4307075754]] Former-commit-id: 521c4248c638e5141534cd1d223d8f563693b821 [formerly 203f6191b3b24ccb2e04d330372973dadfb81e1d] Former-commit-id: 140a5c705819055b4d27f43156b079d6142049a5 --- include/Nazara/Core/MemoryHelper.hpp | 35 +++++++++++++++++++++ include/Nazara/Core/MemoryHelper.inl | 46 ++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/include/Nazara/Core/MemoryHelper.hpp b/include/Nazara/Core/MemoryHelper.hpp index e2f295622..ff81ea083 100644 --- a/include/Nazara/Core/MemoryHelper.hpp +++ b/include/Nazara/Core/MemoryHelper.hpp @@ -7,6 +7,27 @@ #ifndef NAZARA_MEMORYHELPER_HPP #define NAZARA_MEMORYHELPER_HPP +#if defined(NAZARA_COMPILER_MSVC) + +#include + +#define NAZARA_ALLOCA(size) _alloca(size) +#define NAZARA_ALLOCA_SUPPORT + +#elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) +#include + +#define NAZARA_ALLOCA(size) alloca(size) +#define NAZARA_ALLOCA_SUPPORT + +#endif + +#ifdef NAZARA_ALLOCA_SUPPORT + #define NazaraStackAllocation(size) Nz::StackAllocation(NAZARA_ALLOCA(size)) +#else + #define NazaraStackAllocation(size) Nz::StackAllocation(Nz::OperatorNew(size)) +#endif + #include namespace Nz @@ -16,6 +37,20 @@ namespace Nz template T* PlacementNew(T* ptr, Args&&... args); + + class StackAllocation + { + public: + explicit StackAllocation(void* stackMemory); + ~StackAllocation(); + + void* GetPtr(); + + operator void*(); + + private: + void* m_ptr; + }; } #include diff --git a/include/Nazara/Core/MemoryHelper.inl b/include/Nazara/Core/MemoryHelper.inl index 23a745a44..d3fe43155 100644 --- a/include/Nazara/Core/MemoryHelper.inl +++ b/include/Nazara/Core/MemoryHelper.inl @@ -9,6 +9,7 @@ #define NAZARA_DEBUG_NEWREDEFINITION_DISABLE_REDEFINITION #endif +#include #include #include #include @@ -62,6 +63,51 @@ namespace Nz { return new (ptr) T(std::forward(args)...); } + + /*! + * \ingroup core + * \class Nz::StackAllocation + * \brief Core class that represents a stack allocation + */ + + + /*! + * \brief Constructs a StackAllocation object with a pointer to a memory allocated with NAZARA_ALLOCA or OperatorNew is alloca is not supported + * + * \param ptr Pointer to raw memory + */ + inline StackAllocation::StackAllocation(void* stackMemory) : + m_ptr(stackMemory) + { + } + + /*! + * \brief Destructs the object and release memory if necessary + */ + inline StackAllocation::~StackAllocation() + { + #ifndef NAZARA_ALLOCA_SUPPORT + OperatorDelete(m_ptr); + #endif + } + + /*! + * \brief Access the internal pointer + * \return internal memory pointer + */ + inline void* StackAllocation::GetPtr() + { + return m_ptr; + } + + /*! + * \brief Access the internal pointer + * \return internal memory pointer + */ + inline StackAllocation::operator void*() + { + return m_ptr; + } } #include From 9e1b2c69a9d95461d4437eacb081e4fb915eca9f Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 16 Sep 2016 14:19:42 +0200 Subject: [PATCH 274/383] Core/MemoryHelper: Fix compilation with MinGW Former-commit-id: d06a447e934ee66f3f5c399fdd58f2bc95260544 [formerly 18a9328df6edb35b500a57184a8c5155e0e8f6ed] [formerly ef18cf674c43bc0e5cd0f54f50897f184b74d327 [formerly 474225aa4a4843398bfdc5e9d6c9f3db88573170]] Former-commit-id: 3d5905c69b5fd68c585cecf5191bcffe1d3557f9 [formerly 4a1183e5d7a59d8efe05091b282b406c1c4049e3] Former-commit-id: 8755e653ff0730ec687db80117405f33a4b2e430 --- include/Nazara/Core/MemoryHelper.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/MemoryHelper.hpp b/include/Nazara/Core/MemoryHelper.hpp index ff81ea083..e2ed7fc3e 100644 --- a/include/Nazara/Core/MemoryHelper.hpp +++ b/include/Nazara/Core/MemoryHelper.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_MEMORYHELPER_HPP #define NAZARA_MEMORYHELPER_HPP -#if defined(NAZARA_COMPILER_MSVC) +#if defined(NAZARA_COMPILER_MSVC) || defined(NAZARA_COMPILER_MINGW) #include From 48eb9ee3b59cff196d4342ab0c6b12a84f50856f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 17 Sep 2016 12:08:44 +0200 Subject: [PATCH 275/383] Utility/Window: Fix destructor inline Former-commit-id: f55088c7edd5d14c4626a42fe11b7328fa3526b6 [formerly 6c5f0e4666989e8d57da06da103bc180ac1f0d8d] [formerly 2b8719258209c5c45d0b2d4257332b18f5594c3b [formerly fbc1e2f64d490e340d1b0054e7f9c2cacac18086]] Former-commit-id: b8b5f64fb182f7b5e1f4a3d270590da1f35be0f1 [formerly ee4b8d9204690c2a33bb94047515e1e64e6fcef3] Former-commit-id: 6413a1c4026dc7904026c259f7ead483342fcad2 --- include/Nazara/Utility/Window.inl | 7 +------ src/Nazara/Utility/Window.cpp | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/Nazara/Utility/Window.inl b/include/Nazara/Utility/Window.inl index 39c530e24..08b23fc04 100644 --- a/include/Nazara/Utility/Window.inl +++ b/include/Nazara/Utility/Window.inl @@ -55,11 +55,6 @@ namespace Nz window.m_impl = nullptr; } - inline Window::~Window() - { - Destroy(); - } - inline void Window::Close() { m_closed = true; // The window will be closed at the next non-const IsOpen() call @@ -146,7 +141,7 @@ namespace Nz { Destroy(); - m_closed = window.m_closed; + m_closed = window.m_closed; m_closeOnQuit = window.m_closeOnQuit; m_eventPolling = window.m_eventPolling; m_impl = window.m_impl; diff --git a/src/Nazara/Utility/Window.cpp b/src/Nazara/Utility/Window.cpp index 7ba78dcb9..078ff2bc5 100644 --- a/src/Nazara/Utility/Window.cpp +++ b/src/Nazara/Utility/Window.cpp @@ -29,6 +29,11 @@ namespace Nz Window* fullscreenWindow = nullptr; } + Window::~Window() + { + Destroy(); + } + bool Window::Create(VideoMode mode, const String& title, UInt32 style) { // Si la fenêtre est déjà ouverte, nous conservons sa position From e5218301b53da067299595f7da043946600882ea Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 19 Sep 2016 13:07:55 +0200 Subject: [PATCH 276/383] Graphics/TileMap: Add support for isometric tilemaps Former-commit-id: f89318c22ae2dcdab159f46dcfcbdb778af00ae6 [formerly 9912b85867bbb46cd785af9f3fe3a1dc72180149] [formerly a82344e574762f14805ea6c831a0a314cfe36a20 [formerly c234ec3cebd016381a38cd13f7d411511ae98164]] Former-commit-id: d170f0897b77bf29f984a8ddf9e5b193d63a5e60 [formerly 54a8819656b3c626c1485dbf5ccc8f015ad005f4] Former-commit-id: 0b0bf65c250219c29b27067b315a3735d8fbbd70 --- include/Nazara/Graphics/TileMap.hpp | 5 +++++ include/Nazara/Graphics/TileMap.inl | 30 ++++++++++++++++++++++++++++- src/Nazara/Graphics/TileMap.cpp | 7 ++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Graphics/TileMap.hpp b/include/Nazara/Graphics/TileMap.hpp index 89a901b9a..02371c33c 100644 --- a/include/Nazara/Graphics/TileMap.hpp +++ b/include/Nazara/Graphics/TileMap.hpp @@ -41,6 +41,8 @@ namespace Nz inline void DisableTiles(); inline void DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount); + inline void EnableIsometricMode(bool isometric); + inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U); inline void EnableTiles(const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U); @@ -55,6 +57,8 @@ namespace Nz inline const Tile& GetTile(const Vector2ui& tilePos) const; inline const Vector2f& GetTileSize() const; + inline bool IsIsometricModeEnabled() const; + inline void SetMaterial(std::size_t index, MaterialRef material); inline TileMap& operator=(const TileMap& TileMap); @@ -87,6 +91,7 @@ namespace Nz std::vector m_layers; Vector2ui m_mapSize; Vector2f m_tileSize; + bool m_isometricModeEnabled; static TileMapLibrary::LibraryMap s_library; }; diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index 405683f40..4473a8600 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -25,7 +25,8 @@ namespace Nz m_tiles(mapSize.x * mapSize.y), m_layers(materialCount), m_mapSize(mapSize), - m_tileSize(tileSize) + m_tileSize(tileSize), + m_isometricModeEnabled(false) { NazaraAssert(m_tiles.size() != 0U, "Invalid map size"); NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size"); @@ -108,6 +109,22 @@ namespace Nz InvalidateInstanceData(invalidatedLayers); } + /*! + * \brief Enable/Disable isometric mode + * + * If enabled, every odd line will overlap by half the tile size with the upper line + * + * \param isometric Should the isometric mode be enabled for this TileMap + * + * \see IsIsometricModeEnabled + */ + inline void TileMap::EnableIsometricMode(bool isometric) + { + m_isometricModeEnabled = isometric; + + InvalidateInstanceData(0xFFFFFFFF); + } + /*! * \brief Enable and sets the tile at position tilePos * @@ -387,6 +404,17 @@ namespace Nz return m_tileSize; } + /*! + * \brief Gets the actual state of the isometric mode + * \return True if the isometric mode is enabled + * + * \see EnableIsometricMode + */ + inline bool TileMap::IsIsometricModeEnabled() const + { + return m_isometricModeEnabled; + } + /*! * \brief Sets a material of the TileMap * diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index 255685f43..ab035a7e4 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -68,7 +68,12 @@ namespace Nz std::size_t x = tileIndex % m_mapSize.x; std::size_t y = tileIndex / m_mapSize.x; - Vector3f tileLeftCorner(x * m_tileSize.x, y * -m_tileSize.y, 0.f); + + Vector3f tileLeftCorner; + if (m_isometricModeEnabled) + tileLeftCorner.Set(x * m_tileSize.x + m_tileSize.x/2.f * (y % 2), y/2.f * -m_tileSize.y, 0.f); + else + tileLeftCorner.Set(x * m_tileSize.x, y * -m_tileSize.y, 0.f); *colorPtr++ = tile.color; *posPtr++ = instanceData->transformMatrix.Transform(tileLeftCorner); From 34c12082023edd06a7274d66b35f7c5b45fe4548 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 19 Sep 2016 13:16:16 +0200 Subject: [PATCH 277/383] Network/Windows: Fix compilation with MinGW Thanks to Maeiky Former-commit-id: 06501a2d834a10fad4db902b2a5015e6ac7a1fd8 [formerly f2ae3e67ba3fec2d8c740a4472b6fd32aa601a41] [formerly a13631a0e24cb5518e132d450c8d099f985d3fb2 [formerly 0b3ed439870f29acf33c6a6cfbbe8747fc3394ff]] Former-commit-id: 04e5439cd9d14ac7de4a5b126b0359aee42b0bd1 [formerly 6cab591aa8cf90d4ab3ddf6a883023caf1694b4d] Former-commit-id: fe7895dc9cd1c1f54a2c0b7df1d578220e06b180 --- src/Nazara/Network/Win32/SocketImpl.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index f35a4a078..5f1c84ba8 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -7,18 +7,21 @@ #include #include -#include - +#if defined(NAZARA_COMPILER_MINGW) && __GNUC__ < 5 // Some compilers (olders versions of MinGW) are lacking Mstcpip.h which defines the following struct/#define -// Define them ourself for now struct tcp_keepalive { - u_long onoff; - u_long keepalivetime; - u_long keepaliveinterval; + u_long onoff; + u_long keepalivetime; + u_long keepaliveinterval; }; #define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) +#else +#include +#endif + +#include #include From 0a656ca398f57ad6e20b6d088bdacdccc8c23dbc Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 20 Sep 2016 18:01:05 +0200 Subject: [PATCH 278/383] Renderer/UberShaderPreprocessor: Fix compilation error with some drivers Former-commit-id: 10cc42b1ab1249d59b7b911e700f3bf146abc4f5 [formerly cd1c27e41936c49793e6566e8ae0f9ec44cf6b82] [formerly 04b38622de068b9f93ee759570140c0dc45309a7 [formerly 999ce6bcfad58271c8c035305814993a60830a03]] Former-commit-id: b16a232eaac6611e6848ccf0c6ca92b91684528c [formerly be808b5c7dc569547012a91e7f6cd148ed1624cb] Former-commit-id: e4d594358f11b228969d347f0a230192cb2f46e6 --- src/Nazara/Renderer/UberShaderPreprocessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/UberShaderPreprocessor.cpp b/src/Nazara/Renderer/UberShaderPreprocessor.cpp index 2a08088f5..f0e46c7d3 100644 --- a/src/Nazara/Renderer/UberShaderPreprocessor.cpp +++ b/src/Nazara/Renderer/UberShaderPreprocessor.cpp @@ -76,7 +76,7 @@ namespace Nz code << "#define GLSL_VERSION " << glslVersion << "\n\n"; - code << "#define EARLY_FRAGMENT_TEST " << (glslVersion >= 420 || OpenGL::IsSupported(OpenGLExtension_Shader_ImageLoadStore)) << "\n\n"; + code << "#define EARLY_FRAGMENT_TEST " << ((glslVersion >= 420 || OpenGL::IsSupported(OpenGLExtension_Shader_ImageLoadStore)) ? '1' : '0') << "\n\n"; for (auto it = shaderStage.flags.begin(); it != shaderStage.flags.end(); ++it) code << "#define " << it->first << ' ' << ((stageFlags & it->second) ? '1' : '0') << '\n'; From 52cc7bcd2e6fa4fbc04ddfb62ba484478d0833cf Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 00:03:25 +0200 Subject: [PATCH 279/383] Enable Travis-CI service (By @Gawaboumga) Former-commit-id: c1d99b6d4143e8836ee0d78ff63069876c9ad79d [formerly ad183fdb6a31e9e7f7dfcde5000cf028a63df0b7] [formerly abd770532214b16cb0a30c11fb33eb36b6bb8198 [formerly 3bb0d4d7574707a52feb54ce585709f2fe53f8f7]] Former-commit-id: ff3f54eb9ea724597bd7b90ed48a8abc407f6a98 [formerly c922a4b3af5daae9555e4dfb645891e648588e7d] Former-commit-id: 59d8e6ffc8ebcf5cb9b92e50b5d2507e7930d962 --- .travis.yml | 25 +++++++++++++++++++++++++ Dockerfile | 11 +++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .travis.yml create mode 100644 Dockerfile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..0b3fef862 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: cpp +sudo: required +services: + - docker + +before_install: + - docker build -t nazara . + +script: + - docker run -v `pwd`:/NazaraEngine nazara + sh -c "cd build && + ./premake5-linux64 --with-examples gmake && + cd gmake && + make -j4 -f NazaraEngine.make && + cd ../../tests && + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ + " + +notifications: + email: true + +branches: + only: + - master + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..ac2568e3c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:xenial + +RUN apt-get update && apt-get -y install && \ + apt-get install -y libssl1.0.0 libssl-dev && \ + apt-get install -y libopenal-dev libsndfile1-dev && \ + apt-get install -y libxcb-cursor-dev libxcb-ewmh-dev libxcb-randr0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev && \ + apt-get install -y mesa-common-dev libgl1-mesa-dev && \ + apt-get install -y libassimp-dev + +RUN mkdir /NazaraEngine +WORKDIR /NazaraEngine From 9b72dc7f167640d535b5713686e2bd635664282f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 00:14:34 +0200 Subject: [PATCH 280/383] Dummy (checking Travis) Former-commit-id: 0a4750c4c18149a2fddccfc697ab4b077a4e40ed [formerly 1580efe5b88277bf0dd89116c8ba1adbe5fe7aef] [formerly 8f3722003187e02f6eb72f60b137450dd0202d5f [formerly bc6639eb71a842a731a5333aeae0c7a03cc56834]] Former-commit-id: d1ac46f69ae170fe2a10f74888610ed9bbb8c1ab [formerly aa852c6891a41d4a3cb844ebcc6ee48d32fcd9b1] Former-commit-id: 87a4634a7c238b7b2243ebc7b5cbe401b5b782fc --- dummy.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 dummy.txt diff --git a/dummy.txt b/dummy.txt new file mode 100644 index 000000000..390c386b7 --- /dev/null +++ b/dummy.txt @@ -0,0 +1 @@ +Remove me \ No newline at end of file From f3eaadcd8bb39a44e436fae3630eae7f91346f58 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 00:26:34 +0200 Subject: [PATCH 281/383] Sdk/Application: Fix wrong inline constructor Thanks Travis-CI ! Former-commit-id: 40bde8de004459e30e45b45005d8a7680ae321ca [formerly 94921ad26e3e4d8d8980a2002618b1b8bc134d23] [formerly abfe68167af6aee324ec64a1d55114c63f364ceb [formerly 79ab743755f65fd23200091380187675b2af7281]] Former-commit-id: 487d2ae56048c786e08f9b6b69d34483cabd6517 [formerly 28cef4f85f78fa47fb28430b75c0c7550b79c8a5] Former-commit-id: 3ce94333b5d83df940384dddac64e41cf3b5a5d2 --- SDK/src/NDK/Application.cpp | 2 +- dummy.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 dummy.txt diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index 3cdff6978..46e1db13d 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -34,7 +34,7 @@ namespace Ndk * * \remark Only one Application instance can exist at a time */ - inline Application::Application(int argc, char* argv[]) : + Application::Application(int argc, char* argv[]) : Application() { std::regex optionRegex(R"(-(\w+))"); diff --git a/dummy.txt b/dummy.txt deleted file mode 100644 index 390c386b7..000000000 --- a/dummy.txt +++ /dev/null @@ -1 +0,0 @@ -Remove me \ No newline at end of file From 61ea7f3e0e590e6c87616e93ab442ee5b9be9e28 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 00:54:04 +0200 Subject: [PATCH 282/383] Update readme Former-commit-id: 8e947ba710497070000ad834748eb6890e8079e0 [formerly 5cf6c0d507dd97b5b0934472c2a57d3442893cb6] [formerly 9fc16ab88c14c0da4306e040be89c4c6ea54816e [formerly acb28d545ce7d6ba366f69de3a3499a99b063807]] Former-commit-id: 688f139d2c6ff77cd218cb1319033eb18a63f304 [formerly 92cf401113dac5e442ceed89c403e8fac15d3fef] Former-commit-id: a94d7513ddbf716c8936840bb8d30dc04da532b5 --- readme.md | 33 ++++++++++++++++++++------------- readme_fr.md | 29 ++++++++++++++++++----------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/readme.md b/readme.md index 90a30fda5..eefdc2d76 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,10 @@ -Nazara Engine -============= +Platform | Build Status +------------ | ------------- +Windows | [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/dj5qx7axym4uakmy/branch/master?svg=true)](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master) +Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) + +# Nazara Engine +------- Nazara Engine is a fast, complete, cross-platform, object-oriented API which can help you in your daily developper life. Its goal is to provide a set of useful classes : Its core provides unicode strings, filesystem access, hashs, threads, ... @@ -8,26 +13,26 @@ It also provide a set of libraries, such as audio, network, physics, renderer, 2 You can use it in any kind of commercial/non-commercial applications without any restriction ([MIT license](http://opensource.org/licenses/MIT)). -Authors +## Authors ------- Jérôme "Lynix" Leclercq - main developper () Rémi "overdrivr" Bèges - developper & helper - Noise Module - () -Install +## Install ------- Use the premake build system in the build directory then compile the engine for your platform. -How to use +## How to use ---------- You can find tutorials on installation, compilation and use on the [official wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) -Contribute +## Contribute ---------- -#####Don't hesitate to contribute to Nazara Engine by:##### +##### Don't hesitate to contribute to Nazara Engine by: - Extending the [wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) - Submitting a patch to GitHub - Post suggestions/bugs on the forum or the [GitHub tracker](https://github.com/DigitalPulseSoftware/NazaraEngine/issues) @@ -35,14 +40,16 @@ Contribute - Talking about Nazara Engine to other people - Doing anything else that might help us -Links ------ -[Website](http://www.digitalpulsesoftware.net) +## Links +---------- +[Website](https://nazara.digitalpulsesoftware.net) [Wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) -[Forum](http://forum.digitalpulsesoftware.net) +[Forum](https://forum.digitalpulsesoftware.net) +[Mattermost](https://mattermost.digitalpulsesoftware.net) -###Thanks to:### +## Thanks to: +---------- - **RafBill** and **Raakz:** Finding bugs and/or testing - **Fissal "DrFisher" Hannoun**: Helping a lot in architecture design - **Alexandre "Danman" Janniaux**: Helping making the POSIX implementation -- **Youri "Gawaboumga" Hubaut**: Improving the engine code by merging on GitHub +- **Youri "Gawaboumga" Hubaut**: Improving the whole project by making the documentation, improving the code, and more. diff --git a/readme_fr.md b/readme_fr.md index fd0f42e7b..e88d8fb88 100644 --- a/readme_fr.md +++ b/readme_fr.md @@ -1,5 +1,10 @@ -Nazara Engine -============= +Platforme | Build Status +------------ | ------------- +Windows | [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/dj5qx7axym4uakmy/branch/master?svg=true)](https://ci.appveyor.com/project/DPSLynix/nazaraengine/branch/master) +Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) + +# Nazara Engine +------- Nazara Engine est une API rapide, complète, portable et orientée-objet qui peut vous aider dans votre vie de développeur de tous les jours. Son objectif est de fournir un ensemble de classes utiles : Son noyau dispose de chaînes de caractères unicode, de gestion du système de fichiers, hashs, threads, ... @@ -8,26 +13,26 @@ Il propose aussi un ensemble de bibliothèques, comme audio, réseau, physique, Vous pouvez également l'utiliser pour toute application commerciale sans aucune contrainte ([Licence MIT](http://opensource.org/licenses/MIT)). -Auteurs +## Auteurs ------- Jérôme "Lynix" Leclercq - développeur principal () Rémi "overdrivr" Bèges - développeur & aide - module Noise - () -Installation +## Installation ------------ Utilisez le système premake pour construire le projet du moteur, dans le dossier build, pour ensuite compiler le moteur pour votre plateforme. -Utilisation +## Utilisation ----------- Vous pouvez lire des tutoriaux sur l'installation, la compilation et l'utilisation sur le [wiki officiel](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) (**\*En cours de rédaction***) -Contribution +## Contribution ---------- -#####N'hésitez pas à contribuer à Nazara Engine en :##### +##### N'hésitez pas à contribuer à Nazara Engine en : - Contribuant au [wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) (**\*Lien brisé***) - Soumettant un patch sur GitHub - Postant des suggestions/bugs sur le forum ou sur le [tracker GitHub](https://github.com/DigitalPulseSoftware/NazaraEngine/issues) @@ -35,14 +40,16 @@ Contribution - Parlant du Nazara Engine à d'autres personnes - Faisant n'importe quoi d'autre qui pourrait nous aider -Liens ------ +## Liens +---------- [Website](http://www.digitalpulsesoftware.net) [Wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) [Forum](http://forum.digitalpulsesoftware.net) +[Mattermost](https://mattermost.digitalpulsesoftware.net) -###Remerciements:### +###Remerciements: +---------- - **RafBill** et **Raakz:** Recherche de bugs et/ou tests - **Fissal "DrFisher" Hannoun**: Aide et conseils lors de la conception de l'architecture du moteur - **Alexandre "Danman" Janniaux**: Aide sur l'implémentation POSIX -- **Youri "Gawaboumga" Hubaut**: Amélioration du code via le merging sur GitHub +- **Youri "Gawaboumga" Hubaut**: Amélioration du moteur tant au niveau du code que de sa documentation et du projet en général. From 9452b98f4941c1ddb9a3dc06653cf992f2dc8e6c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 18:16:39 +0200 Subject: [PATCH 283/383] Network: Add SocketPoller class Former-commit-id: 86b9266d904551d19e7ec8e8d6bbe5f137e8d29f [formerly 34575937d84f796cfe36a5ab97ea1f787c1506ba] [formerly 6c8c621523800958ad38eef118fcb3687c34b367 [formerly a1f1330fbe6f990a21bbe6dccfe727edec0e2b44]] Former-commit-id: 6635c463a753f744b835267181b51ed89620b627 [formerly 14e84c7155cd669ac20a5492e67704059a442925] Former-commit-id: 7becccdf2d8aac7cdf526d855215d7d144be284c --- include/Nazara/Network/SocketPoller.hpp | 44 +++++ include/Nazara/Network/SocketPoller.inl | 37 ++++ src/Nazara/Network/Posix/IpAddressImpl.hpp | 7 + src/Nazara/Network/Posix/SocketImpl.cpp | 18 ++ src/Nazara/Network/Posix/SocketImpl.hpp | 18 ++ src/Nazara/Network/Posix/SocketPollerImpl.cpp | 92 ++++++++++ src/Nazara/Network/Posix/SocketPollerImpl.hpp | 42 +++++ src/Nazara/Network/SocketPoller.cpp | 160 ++++++++++++++++++ src/Nazara/Network/Win32/IpAddressImpl.hpp | 7 + src/Nazara/Network/Win32/SocketImpl.cpp | 28 +++ src/Nazara/Network/Win32/SocketImpl.hpp | 18 ++ src/Nazara/Network/Win32/SocketPollerImpl.cpp | 148 ++++++++++++++++ src/Nazara/Network/Win32/SocketPollerImpl.hpp | 48 ++++++ 13 files changed, 667 insertions(+) create mode 100644 include/Nazara/Network/SocketPoller.hpp create mode 100644 include/Nazara/Network/SocketPoller.inl create mode 100644 src/Nazara/Network/Posix/SocketPollerImpl.cpp create mode 100644 src/Nazara/Network/Posix/SocketPollerImpl.hpp create mode 100644 src/Nazara/Network/SocketPoller.cpp create mode 100644 src/Nazara/Network/Win32/SocketPollerImpl.cpp create mode 100644 src/Nazara/Network/Win32/SocketPollerImpl.hpp diff --git a/include/Nazara/Network/SocketPoller.hpp b/include/Nazara/Network/SocketPoller.hpp new file mode 100644 index 000000000..31dd22892 --- /dev/null +++ b/include/Nazara/Network/SocketPoller.hpp @@ -0,0 +1,44 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SOCKETPOLLER_HPP +#define NAZARA_SOCKETPOLLER_HPP + +#include +#include +#include + +namespace Nz +{ + class SocketPollerImpl; + + class NAZARA_NETWORK_API SocketPoller + { + public: + SocketPoller(); + inline SocketPoller(SocketPoller&& socketPoller); + ~SocketPoller() = default; + + void Clear(); + + bool IsReady(const AbstractSocket& socket) const; + bool IsRegistered(const AbstractSocket& socket) const; + + bool RegisterSocket(AbstractSocket& socket); + void UnregisterSocket(AbstractSocket& socket); + + bool Wait(UInt64 msTimeout); + + inline SocketPoller& operator=(SocketPoller&& socketPoller); + + private: + SocketPollerImpl* m_impl; + }; +} + +#include + +#endif // NAZARA_SOCKETPOLLER_HPP \ No newline at end of file diff --git a/include/Nazara/Network/SocketPoller.inl b/include/Nazara/Network/SocketPoller.inl new file mode 100644 index 000000000..c3e415508 --- /dev/null +++ b/include/Nazara/Network/SocketPoller.inl @@ -0,0 +1,37 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + /*! + * \brief Constructs a SocketPoller object with another one by move semantic + * + * \param socketPoller SocketPoller to move into this + */ + inline SocketPoller::SocketPoller(SocketPoller&& socketPoller) : + m_impl(socketPoller.m_impl) + { + socketPoller.m_impl = nullptr; + } + + /*! + * \brief Moves the SocketPoller into this + * \return A reference to this + * + * \param socketPoller SocketPoller to move in this + */ + inline SocketPoller& SocketPoller::operator=(SocketPoller&& socketPoller) + { + m_impl = socketPoller.m_impl; + socketPoller.m_impl = nullptr; + + return *this; + } +} + +#include diff --git a/src/Nazara/Network/Posix/IpAddressImpl.hpp b/src/Nazara/Network/Posix/IpAddressImpl.hpp index 6ca919e78..fb435f9e1 100644 --- a/src/Nazara/Network/Posix/IpAddressImpl.hpp +++ b/src/Nazara/Network/Posix/IpAddressImpl.hpp @@ -2,6 +2,11 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp +#pragma once + +#ifndef NAZARA_IPADDRESSIMPL_HPP +#define NAZARA_IPADDRESSIMPL_HPP + #include #include #include @@ -30,3 +35,5 @@ namespace Nz static ResolveError TranslateEAIErrorToResolveError(int error); }; } + +#endif // NAZARA_IPADDRESSIMPL_HPP \ No newline at end of file diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index c2cf3a6f8..92588160c 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -397,6 +398,23 @@ namespace Nz return IpAddressImpl::FromSockAddr(reinterpret_cast(nameBuffer.data())); } + int SocketImpl::Poll(PollSocket* fdarray, unsigned long nfds, int timeout, SocketError* error) + { + NazaraAssert(fdarray && nfds > 0, "Invalid fdarray"); + + static_assert(sizeof(PollSocket) == sizeof(pollfd), "PollSocket size must match WSAPOLLFD size"); + + int result = poll(reinterpret_cast(fdarray), static_cast(nfds), timeout); + if (result < 0) + { + if (error) + *error = TranslateErrnoToResolveError(GetLastErrorCode()); + + return 0; + } + + return result; + } bool SocketImpl::Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error) { diff --git a/src/Nazara/Network/Posix/SocketImpl.hpp b/src/Nazara/Network/Posix/SocketImpl.hpp index 8896ce597..c120bd19a 100644 --- a/src/Nazara/Network/Posix/SocketImpl.hpp +++ b/src/Nazara/Network/Posix/SocketImpl.hpp @@ -2,12 +2,26 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp +#pragma once + +#ifndef NAZARA_SOCKETIMPL_HPP +#define NAZARA_SOCKETIMPL_HPP + #include #include #include +#define NAZARA_NETWORK_POLL_SUPPORT 1 + namespace Nz { + struct PollSocket + { + SocketHandle fd; + short events; + short revents; + }; + class SocketImpl { public: @@ -42,6 +56,8 @@ namespace Nz static IpAddress QueryPeerAddress(SocketHandle handle, SocketError* error = nullptr); static IpAddress QuerySocketAddress(SocketHandle handle, SocketError* error = nullptr); + static int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error); + static bool Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error); static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error); @@ -66,3 +82,5 @@ namespace Nz static socketID s_socket; }; } + +#endif // NAZARA_SOCKETIMPL_HPP \ No newline at end of file diff --git a/src/Nazara/Network/Posix/SocketPollerImpl.cpp b/src/Nazara/Network/Posix/SocketPollerImpl.cpp new file mode 100644 index 000000000..d94979863 --- /dev/null +++ b/src/Nazara/Network/Posix/SocketPollerImpl.cpp @@ -0,0 +1,92 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + void SocketPollerImpl::Clear() + { + m_activeSockets.clear(); + m_allSockets.clear(); + m_sockets.clear(); + } + + bool SocketPollerImpl::IsReady(SocketHandle socket) const + { + return m_activeSockets.count(socket) != 0; + } + + bool SocketPollerImpl::IsRegistered(SocketHandle socket) const + { + return m_allSockets.count(socket) != 0; + } + + bool SocketPollerImpl::RegisterSocket(SocketHandle socket) + { + NazaraAssert(!IsRegistered(socket), "Socket is already registered"); + + PollSocket entry = { + socket, + POLLRDNORM, + 0 + }; + + m_allSockets[socket] = m_sockets.size(); + m_sockets.emplace_back(entry); + + return true; + } + + void SocketPollerImpl::UnregisterSocket(SocketHandle socket) + { + NazaraAssert(IsRegistered(socket), "Socket is not registered"); + + if (m_sockets.size() > 1U) + { + // Instead of using vector::erase, let's move the last element to the now unoccupied position + std::size_t entry = m_allSockets[socket]; + + // Get the last element and update it's position + const PollSocket& lastElement = m_sockets.back(); + m_allSockets[lastElement.fd] = entry; + + // Now move it properly (lastElement is invalid after the following line) and pop it + m_sockets[entry] = std::move(m_sockets.back()); + } + + m_sockets.pop_back(); + m_activeSockets.erase(socket); + m_allSockets.erase(socket); + } + + int SocketPollerImpl::Wait(UInt64 msTimeout, SocketError* error) + { + int activeSockets; + + // Reset status of sockets + for (PollSocket& entry : m_sockets) + entry.revents = 0; + + activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); + + m_activeSockets.clear(); + if (activeSockets > 0U) + { + for (PollSocket& entry : m_sockets) + { + if (entry.revents & POLLRDNORM) + { + m_activeSockets.insert(entry.fd); + if (--activeSockets == 0) + break; + } + } + } + + return activeSockets; + } +} diff --git a/src/Nazara/Network/Posix/SocketPollerImpl.hpp b/src/Nazara/Network/Posix/SocketPollerImpl.hpp new file mode 100644 index 000000000..a561139fa --- /dev/null +++ b/src/Nazara/Network/Posix/SocketPollerImpl.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SOCKETPOLLERIMPL_HPP +#define NAZARA_SOCKETPOLLERIMPL_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class SocketPollerImpl + { + public: + SocketPollerImpl() = default; + ~SocketPollerImpl() = default; + + void Clear(); + + bool IsReady(SocketHandle socket) const; + bool IsRegistered(SocketHandle socket) const; + + bool RegisterSocket(SocketHandle socket); + void UnregisterSocket(SocketHandle socket); + + int Wait(UInt64 msTimeout, SocketError* error); + + private: + std::unordered_set m_activeSockets; + std::unordered_map m_allSockets; + std::vector m_sockets; + }; +} + +#endif // NAZARA_SOCKETPOLLERIMPL_HPP \ No newline at end of file diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp new file mode 100644 index 000000000..1364cb93d --- /dev/null +++ b/src/Nazara/Network/SocketPoller.cpp @@ -0,0 +1,160 @@ +// 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 + +#if defined(NAZARA_PLATFORM_WINDOWS) +#include +#elif defined(NAZARA_PLATFORM_POSIX) +#include +#else +#error Missing implementation: SocketPoller +#endif + +#include + +namespace Nz +{ + /*! + * \brief Constructs a SocketPoller object by default + */ + inline SocketPoller::SocketPoller() : + m_impl(new SocketPollerImpl) + { + } + + /*! + * \brief Destructs the SocketPoller + */ + SocketPoller::~SocketPoller() + { + delete m_impl; + } + + /*! + * \brief Clears the SocketPoller + * + * This function reverts the SocketPoller to the initial state, unregistering every socket from the SocketPoller. + * + * \see Unregister + */ + void SocketPoller::Clear() + { + m_impl->Clear(); + } + + /*! + * \brief Checks if a specific socket is ready to read data + * + * This function allows you to read the results of the last Wait operation and if a specific socket is ready. + * + * A socket in the ready state (with the exception of TcpServer) has incoming data and can be read without blocking. + * + * \remark When used on a TcpServer socket, this function returns true if the server is ready to accept a new client. + * \remark You must call Wait before using this function in order to refresh the state. + * + * \param socket Reference to the socket to check + * + * \return True if the socket is available for reading without blocking, false otherwise + * + * \see Wait + */ + bool SocketPoller::IsReady(const AbstractSocket& socket) const + { + NazaraAssert(IsRegistered(socket), "Socket is not registered in the poller"); + + return m_impl->IsReady(socket.GetNativeHandle()); + } + + /*! + * \brief Checks if a specific socket is registered in the SocketPoller + * + * A registered socket is part of the SocketPoller and will be checked by the next Wait operations. + * + * \param socket Reference to the socket to check + * + * \return True if the socket is registered, false otherwise + * + * \see RegisterSocket + * \see UnregisterSocket + */ + bool SocketPoller::IsRegistered(const AbstractSocket& socket) const + { + return m_impl->IsRegistered(socket.GetNativeHandle()); + } + + /*! + * \brief Register a socket in the SocketPoller + * + * A registered socket is part of the SocketPoller and will be checked by the next Wait operations. + * + * The SocketPoller keeps a reference to the internal handle of registered socket, which should not be freed while it is registered in the SocketPooler. + * + * It is possible for this function to fail if too many sockets are registered in the SocketPoller, the maximum number of socket handled limit is OS-dependent. + * + * \remark It is an error to register a socket twice in the same SocketPoller. + * \remark The socket should not be freed while it is registered in the SocketPooler. + * + * \param socket Reference to the socket to register + * + * \return True if the socket is registered, false otherwise + * + * \see IsRegistered + * \see UnregisterSocket + */ + bool SocketPoller::RegisterSocket(AbstractSocket& socket) + { + NazaraAssert(!IsRegistered(socket), "This socket is already registered in this SocketPoller"); + + return m_impl->RegisterSocket(socket.GetNativeHandle()); + } + + /*! + * \brief Unregister a socket from the SocketPoller + * + * After calling UnregisterSocket, the socket is no longer part of the SocketPoller and thus, not taken into account by any further Wait call until registered again. + * + * This function must be called before destroying a socket part of the SocketPoller. + * + * \remark It is an error to try to unregister a non-registered socket from a SocketPoller. + * + * \param socket Reference to the socket to unregister + * + * \see IsRegistered + * \see RegisterSocket + */ + void SocketPoller::UnregisterSocket(AbstractSocket& socket) + { + NazaraAssert(IsRegistered(socket), "This socket is not registered in this SocketPoller"); + + return m_impl->UnregisterSocket(socket.GetNativeHandle()); + } + + /*! + * \brief Wait until any registered socket switches to a ready state + * + * Waits a specific/undetermined amount of time until at least one socket part of the SocketPoller becomes ready. + * To query the ready state of the registered socket, use the IsReady function. + * + * \param msTimeout Maximum time to wait in milliseconds, 0 for infinity + * + * \remark It is an error to try to unregister a non-registered socket from a SocketPoller. + * + * \see IsReady + * \see RegisterSocket + */ + bool SocketPoller::Wait(UInt64 msTimeout) + { + SocketError error; + + int readySockets = m_impl->Wait(msTimeout, &error); + if (error != SocketError_NoError) + { + NazaraError("SocketPoller encountered an error (code: 0x" + String::Number(error, 16) + ')'); + return false; + } + + return readySockets > 0; + } +} diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index 960092839..000b407eb 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -2,6 +2,11 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp +#pragma once + +#ifndef NAZARA_IPADDRESSIMPL_HPP +#define NAZARA_IPADDRESSIMPL_HPP + #include #include #include @@ -33,3 +38,5 @@ namespace Nz static ResolveError TranslateWSAErrorToResolveError(int error); }; } + +#endif // NAZARA_IPADDRESSIMPL_HPP \ No newline at end of file diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index 5f1c84ba8..628d29807 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -415,6 +415,34 @@ namespace Nz return IpAddressImpl::FromSockAddr(reinterpret_cast(nameBuffer.data())); } + int SocketImpl::Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error) + { + NazaraAssert(fdarray && nfds > 0, "Invalid fdarray"); + + #if NAZARA_NETWORK_POLL_SUPPORT + static_assert(sizeof(PollSocket) == sizeof(WSAPOLLFD), "PollSocket size must match WSAPOLLFD size"); + + int result = WSAPoll(reinterpret_cast(fdarray), static_cast(nfds), timeout); + if (result == SOCKET_ERROR) + { + int errorCode = WSAGetLastError(); + if (error) + *error = TranslateWSAErrorToSocketError(errorCode); + + return 0; + } + + if (error) + *error = SocketError_NoError; + + return result; + #else + if (error) + *error = SocketError_NotSupported; + + return 0; + #endif + } bool SocketImpl::Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error) { diff --git a/src/Nazara/Network/Win32/SocketImpl.hpp b/src/Nazara/Network/Win32/SocketImpl.hpp index dc0d77e73..ab93085d9 100644 --- a/src/Nazara/Network/Win32/SocketImpl.hpp +++ b/src/Nazara/Network/Win32/SocketImpl.hpp @@ -2,13 +2,27 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp +#pragma once + +#ifndef NAZARA_SOCKETIMPL_HPP +#define NAZARA_SOCKETIMPL_HPP + #include #include #include #include +#define NAZARA_NETWORK_POLL_SUPPORT NAZARA_CORE_WINDOWS_VISTA + namespace Nz { + struct PollSocket + { + SocketHandle fd; + short events; + short revents; + }; + class SocketImpl { public: @@ -43,6 +57,8 @@ namespace Nz static IpAddress QueryPeerAddress(SocketHandle handle, SocketError* error = nullptr); static IpAddress QuerySocketAddress(SocketHandle handle, SocketError* error = nullptr); + static int Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error); + static bool Receive(SocketHandle handle, void* buffer, int length, int* read, SocketError* error); static bool ReceiveFrom(SocketHandle handle, void* buffer, int length, IpAddress* from, int* read, SocketError* error); @@ -66,3 +82,5 @@ namespace Nz static WSADATA s_WSA; }; } + +#endif // NAZARA_SOCKETIMPL_HPP \ No newline at end of file diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp new file mode 100644 index 000000000..b71e5107c --- /dev/null +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -0,0 +1,148 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + SocketPollerImpl::SocketPollerImpl() + { + #if !NAZARA_NETWORK_POLL_SUPPORT + FD_ZERO(&m_activeSockets); + FD_ZERO(&m_sockets); + #endif + } + + void SocketPollerImpl::Clear() + { + #if NAZARA_NETWORK_POLL_SUPPORT + m_activeSockets.clear(); + m_allSockets.clear(); + m_sockets.clear(); + #else + FD_ZERO(&m_activeSockets); + FD_ZERO(&m_sockets); + #endif + } + + bool SocketPollerImpl::IsReady(SocketHandle socket) const + { + #if NAZARA_NETWORK_POLL_SUPPORT + return m_activeSockets.count(socket) != 0; + #else + return FD_ISSET(socket, &m_activeSockets) != 0; + #endif + } + + bool SocketPollerImpl::IsRegistered(SocketHandle socket) const + { + #if NAZARA_NETWORK_POLL_SUPPORT + return m_allSockets.count(socket) != 0; + #else + return FD_ISSET(socket, &m_sockets) != 0; + #endif + } + + bool SocketPollerImpl::RegisterSocket(SocketHandle socket) + { + NazaraAssert(!IsRegistered(socket), "Socket is already registered"); + + #if NAZARA_NETWORK_POLL_SUPPORT + PollSocket entry = { + socket, + POLLRDNORM, + 0 + }; + + m_allSockets[socket] = m_sockets.size(); + m_sockets.emplace_back(entry); + #else + if (m_sockets.fd_count > FD_SETSIZE) + { + NazaraError("Socket count exceeding FD_SETSIZE (" + String::Number(FD_SETSIZE) + ")"); + return false; + } + + FD_SET(socket, &m_sockets); + #endif + + return true; + } + + void SocketPollerImpl::UnregisterSocket(SocketHandle socket) + { + NazaraAssert(IsRegistered(socket), "Socket is not registered"); + + #if NAZARA_NETWORK_POLL_SUPPORT + if (m_sockets.size() > 1U) + { + // Instead of using vector::erase, let's move the last element to the now unoccupied position + std::size_t entry = m_allSockets[socket]; + + // Get the last element and update it's position + const PollSocket& lastElement = m_sockets.back(); + m_allSockets[lastElement.fd] = entry; + + // Now move it properly (lastElement is invalid after the following line) and pop it + m_sockets[entry] = std::move(m_sockets.back()); + } + + m_sockets.pop_back(); + m_activeSockets.erase(socket); + m_allSockets.erase(socket); + #else + FD_CLR(socket, &m_activeSockets); + FD_CLR(socket, &m_sockets); + #endif + } + + int SocketPollerImpl::Wait(UInt64 msTimeout, SocketError* error) + { + int activeSockets; + + #if NAZARA_NETWORK_POLL_SUPPORT + // Reset status of sockets + for (PollSocket& entry : m_sockets) + entry.revents = 0; + + activeSockets = SocketImpl::Poll(m_sockets.data(), m_sockets.size(), static_cast(msTimeout), error); + + m_activeSockets.clear(); + if (activeSockets > 0U) + { + for (PollSocket& entry : m_sockets) + { + if (entry.revents & POLLRDNORM) + { + m_activeSockets.insert(entry.fd); + if (--activeSockets == 0) + break; + } + } + } + #else + + m_activeSockets = m_sockets; + + timeval tv; + tv.tv_sec = static_cast(msTimeout / 1000ULL); + tv.tv_usec = static_cast((msTimeout % 1000ULL) * 1000ULL); + + activeSockets = ::select(0xDEADBEEF, &m_activeSockets, nullptr, nullptr, (msTimeout > 0) ? &tv : nullptr); //< The first argument is ignored on Windows + if (activeSockets == SOCKET_ERROR) + { + if (error) + *error = SocketImpl::TranslateWSAErrorToSocketError(WSAGetLastError()); + + return 0; + } + + if (error) + *error = SocketError_NoError; + #endif + + return activeSockets; + } +} diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.hpp b/src/Nazara/Network/Win32/SocketPollerImpl.hpp new file mode 100644 index 000000000..a8a45a7de --- /dev/null +++ b/src/Nazara/Network/Win32/SocketPollerImpl.hpp @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SOCKETPOLLERIMPL_HPP +#define NAZARA_SOCKETPOLLERIMPL_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class SocketPollerImpl + { + public: + SocketPollerImpl(); + ~SocketPollerImpl() = default; + + void Clear(); + + bool IsReady(SocketHandle socket) const; + bool IsRegistered(SocketHandle socket) const; + + bool RegisterSocket(SocketHandle socket); + void UnregisterSocket(SocketHandle socket); + + int Wait(UInt64 msTimeout, SocketError* error); + + private: + #if NAZARA_NETWORK_POLL_SUPPORT + std::unordered_set m_activeSockets; + std::unordered_map m_allSockets; + std::vector m_sockets; + #else + fd_set m_sockets; + fd_set m_activeSockets; + #endif + }; +} + +#endif // NAZARA_SOCKETPOLLERIMPL_HPP \ No newline at end of file From 0b1ae4f16acc3a0e701407b857c6eb570c966db5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 18:17:29 +0200 Subject: [PATCH 284/383] Core/Config: Fix typo Former-commit-id: 8e9d1c6f4ef8231b9ff59d51abf224606795775d [formerly 5ff9f91c844593607b64df00b5ec9344da1aa864] [formerly 83084c13b439390fa313594332ef0d42e793df9a [formerly 317e9e476ef6a7a97e9906245682080a196dd82f]] Former-commit-id: 5b16e13e15bcc5054743387fd1cb738515a198d9 [formerly ec5e19e21a44489c2eaa0843b0f869341c5deb20] Former-commit-id: 60028fb6c993ddf6cee0458f9ed6d5d7fcca25bd --- include/Nazara/Core/Config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Core/Config.hpp b/include/Nazara/Core/Config.hpp index 955b98c75..87848b052 100644 --- a/include/Nazara/Core/Config.hpp +++ b/include/Nazara/Core/Config.hpp @@ -72,7 +72,7 @@ // Number of spinlocks to use with the Windows critical sections (0 to disable) #define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096 -// Optimize the Windows implementation with technologies of Windows vista (and greather) (Break the compatibility with XP) +// Optimize the Windows implementation with technologies of Windows vista (and greater) (Break the compatibility with XP) #define NAZARA_CORE_WINDOWS_VISTA 0 From 6fdf4478bd844e3bd5aef15b17b4c02a344a90db Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 18:17:59 +0200 Subject: [PATCH 285/383] Network/SocketPoller: Fix compilation Former-commit-id: ebb7105d949a924f5a454aab4f3704824e8c7e31 [formerly f2b5c057a8ded314be40d1752ad6bc86dcade278] [formerly 6487addceedb75d6f59c9c138b8e3635ea271ba2 [formerly 18f1b6e1d02b0377b382bec327f1df99c1b04f27]] Former-commit-id: 90fc36d0a362d402fd10a23addb1bbb407e4ffb9 [formerly 82f63c8797caafb24fd3e5c8de76b8814ec24585] Former-commit-id: 75da2a9a2dc4b2dbbbd5ad8de986ea58ee199c0f --- include/Nazara/Network/SocketPoller.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Network/SocketPoller.hpp b/include/Nazara/Network/SocketPoller.hpp index 31dd22892..0684ef41f 100644 --- a/include/Nazara/Network/SocketPoller.hpp +++ b/include/Nazara/Network/SocketPoller.hpp @@ -20,7 +20,7 @@ namespace Nz public: SocketPoller(); inline SocketPoller(SocketPoller&& socketPoller); - ~SocketPoller() = default; + ~SocketPoller(); void Clear(); From d7ae0c75ce27d3671636d2141f4c2adf9b9dec52 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 18:37:21 +0200 Subject: [PATCH 286/383] Network/SocketPollerImpl: Fix compilation on POSIX Thanks Travis CI! Former-commit-id: 2cd53feae4b3932e5bf9e7c66255e6358a8d19d5 [formerly 9ba688db99ae881c295e5a8311abbdcccbd1157f] [formerly e5da0484598567ea44283080497f2a56e5fe5111 [formerly 4a290f7e5ba137e43cf64a93a7a2489adfb5dea5]] Former-commit-id: 5c8bc90add749a1650d9b21e6672e19c2595d5b7 [formerly 4f9a5539c50af5307fbe6c78d3d71242c358fca6] Former-commit-id: 0cd70283de3052441db90417ae96b0f90a421f87 --- src/Nazara/Network/Posix/SocketPollerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/Posix/SocketPollerImpl.cpp b/src/Nazara/Network/Posix/SocketPollerImpl.cpp index d94979863..6b279ec50 100644 --- a/src/Nazara/Network/Posix/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Posix/SocketPollerImpl.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include From 8a50b3ec0e9ae5d0bf75e6be0127675703b2b102 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 22 Sep 2016 18:45:12 +0200 Subject: [PATCH 287/383] Network/SocketPollerImpl: Fix compilation on POSIX Yup, again. Former-commit-id: c3209f14988c5fb21315a47952a71345db0bb016 [formerly 5b404d3bd4bdc3e42f9edd2735f4ee1a90b3ea58] [formerly 79e52d19202a56696c573a38f670176615249341 [formerly 0502a91d67d15b1cfc7c53c1b4cdfb46b86b843c]] Former-commit-id: 88af57ddf2aac4d27ca9efb3bca979d5ce7b3a7a [formerly e5166f73aeee8823bfcc5e1ae2694750d94f8275] Former-commit-id: 9597ca83c35be3e631ff1a5784880b69dfbeeab7 --- src/Nazara/Network/Posix/SocketPollerImpl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Network/Posix/SocketPollerImpl.hpp b/src/Nazara/Network/Posix/SocketPollerImpl.hpp index a561139fa..3472c3265 100644 --- a/src/Nazara/Network/Posix/SocketPollerImpl.hpp +++ b/src/Nazara/Network/Posix/SocketPollerImpl.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -39,4 +39,4 @@ namespace Nz }; } -#endif // NAZARA_SOCKETPOLLERIMPL_HPP \ No newline at end of file +#endif // NAZARA_SOCKETPOLLERIMPL_HPP From c1e1d350282b54d015f39fe2f0dd22b98248ece0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 24 Sep 2016 21:18:32 +0200 Subject: [PATCH 288/383] Core/String: Fix Simplify/Simplified method, not adjusting string size Former-commit-id: 3996623190ee6195af1f8acf4f8cf07463046e0f [formerly e02718b2c559cd57f24c9315cfb0cf8542db1e92] [formerly f9047f74247e48ff63a96760d12be702ded86f13 [formerly 617cddeb7635631ac64c708ccfa45fa9895a99b8]] Former-commit-id: 4bf301a65420c8b7968736bc28a2f74163ca3c36 [formerly 50fe7ab0e3f53c6f2337ef5fd4c4a285e69fadef] Former-commit-id: b93130e3651c3e85551fa265fe334f5534134d34 --- src/Nazara/Core/String.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index fbd29c97c..3c97a5b4b 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -3461,6 +3461,7 @@ namespace Nz p--; *p = '\0'; + m_sharedString->size = p - str; return String(std::move(newString)); } From 19a6eee0446df8a2c2c548e6d5abe0a956a0ae73 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 01:43:02 +0200 Subject: [PATCH 289/383] Network/TcpClient: Fix error when receiving an empty packet Former-commit-id: 653a77b0b059968600777e89c02144d8a3e55cf3 [formerly 338bed3ccd44ad4a683e90cd1b99598660c47048] [formerly 8136c65b123704f0243edd20558ea19d636d2127 [formerly 4c158ec5ee63b97c1d9a828f4088a2f1908f3a32]] Former-commit-id: b8491dc53c5792acadb2f9f6479e9aaec472ae05 [formerly 79127a86db6256fc749591c59663fbe7cbaddc37] Former-commit-id: 2621271910cefb53cfd612cd8246af2e10ef4bd8 --- src/Nazara/Network/TcpClient.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index cf123ff89..8cdeafc69 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -262,6 +262,17 @@ namespace Nz if (m_pendingPacket.headerReceived) { UInt16 packetSize = static_cast(m_pendingPacket.data.GetSize()); //< Total packet size + if (packetSize == 0) + { + // Special case: our packet carry no data + packet->Reset(packetSize); + + // And reset every state + m_pendingPacket.data.Clear(); + m_pendingPacket.headerReceived = false; + m_pendingPacket.received = 0; + return true; + } std::size_t received; if (!Receive(&m_pendingPacket.data[m_pendingPacket.received], packetSize - m_pendingPacket.received, &received)) From f434b753ff920ee4fd1b9165439cc3f36b2cae4a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 01:48:57 +0200 Subject: [PATCH 290/383] Core/Algorithm: Add serialize/unserialize overload for std::string Former-commit-id: c4aa07b3ab8fcac85ac290ae5168bd841ce16dfd [formerly ee0f4fa822ec65aa72d43c9ab370402976713206] [formerly 9ec403e92a60b8ca97d7bc3e579ca5983089ba76 [formerly d7e17cc3ff72d43e23f11a70d785efcff3f4cba2]] Former-commit-id: 190337087a987ca5ef1ac9789f04e3b9f2fc47af [formerly fc6bed4363a90b165db7fde093a6df37eeb9f45a] Former-commit-id: 28d6dfe4b4217e91a7283e0fbe45d20ac982f79c --- include/Nazara/Core/Algorithm.hpp | 3 +++ include/Nazara/Core/Algorithm.inl | 38 +++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index b8a3206af..be25f4773 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -38,11 +39,13 @@ namespace Nz struct TypeTag {}; inline bool Serialize(SerializationContext& context, bool value); + inline bool Serialize(SerializationContext& context, const std::string& value); template std::enable_if_t::value, bool> Serialize(SerializationContext& context, T value); inline bool Unserialize(SerializationContext& context, bool* value); + inline bool Unserialize(SerializationContext& context, std::string* value); template std::enable_if_t::value, bool> Unserialize(SerializationContext& context, T* value); diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 0cadd1631..dc770eae6 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -6,6 +6,7 @@ // Merci à Ryan "FullMetal Alchemist" Lahfa // Merci aussi à Freedom de siteduzero.com +#include #include #include #include @@ -192,7 +193,7 @@ namespace Nz /*! * \ingroup core * \brief Serializes a boolean - * \return true if serialization succedeed + * \return true if serialization succeeded * * \param context Context for the serialization * \param value Boolean to serialize @@ -216,10 +217,26 @@ namespace Nz return true; } + /*! + * \ingroup core + * \brief Serializes a std::string + * \return true if successful + * + * \param context Context for the serialization + * \param value String to serialize + */ + bool Serialize(SerializationContext& context, const std::string& value) + { + if (!Serialize(context, value.size())) + return false; + + return context.stream->Write(value.data(), value.size()) == value.size(); + } + /*! * \ingroup core * \brief Serializes an arithmetic type - * \return true if serialization succedeed + * \return true if serialization succeeded * * \param context Context for the serialization * \param value Arithmetic type to serialize @@ -266,6 +283,23 @@ namespace Nz return true; } + /*! + * \brief Unserializes a string + * \return true if successful + * + * \param context Context of unserialization + * \param string std::string to unserialize + */ + bool Unserialize(SerializationContext& context, std::string* string) + { + UInt32 size; + if (!Unserialize(context, &size)) + return false; + + string->resize(size); + return context.stream->Read(&string[0], size) == size; + } + /*! * \ingroup core * \brief Unserializes an arithmetic type From 948273fe99664da9c80ecc9a4ccc9f0f12cb4b98 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 01:50:21 +0200 Subject: [PATCH 291/383] Graphics: Update global include Former-commit-id: 69414fbafbbdacfebb1afab54946f4a522ced71f [formerly 52c50d2e6e6424c697339e01acc4268b38721520] [formerly 6ed3e9faade44eceb3926c1463130c7b4844b0f9 [formerly c97e57ebcd52a9764330ce7758fd785bde6bde19]] Former-commit-id: b5790057312f0d0841d98fd1e0d23b8db8a6816d [formerly 9f3b2b008bc228cd4d9944f64c4eb57a9a985579] Former-commit-id: 5372d34593928b266d4761baa79f6e5a3af43410 --- include/Nazara/Graphics.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 0195c123c..b79e8e348 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 20 Jul 2016 at 13:49:17 +// This file was automatically generated on 15 Sep 2016 at 00:43:26 /* Nazara Engine - Graphics module @@ -58,17 +58,20 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -77,5 +80,6 @@ #include #include #include +#include #endif // NAZARA_GLOBAL_GRAPHICS_HPP From 10a1e16566920ca743452f4511bb9c4b0e3ddd04 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 01:56:05 +0200 Subject: [PATCH 292/383] Build: Add package action Former-commit-id: 515307c1cb9d10f2a6060f7ae107b969637e8882 [formerly bcb26c49c374e502732e3bff35f8367047accdc5] [formerly 72385d39c30f735fb43d70da3c44840468360efa [formerly 6563ce60169674309fdf8e36e16686b1b0be128e]] Former-commit-id: fbc9522ed2c0e75f58a3517344d780be3eb99ac4 [formerly ce264fe175de40c051229183d458273ad6cbead1] Former-commit-id: e312993f3cab7e1587bc09feb0e25ec289237224 --- .gitignore | 11 +- build/Package_MSVC.bat | 1 + build/Package_MinGW.bat | 1 + build/scripts/actions/package.lua | 189 ++++++++++++++++++++++++++++++ 4 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 build/Package_MSVC.bat create mode 100644 build/Package_MinGW.bat create mode 100644 build/scripts/actions/package.lua diff --git a/.gitignore b/.gitignore index 6266c2b6b..2e9057d9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,23 @@ # Nazara build build/config.lua + +# Nazara libraries +lib/* + +# Nazara package +package/* + +# Example files examples/bin/*.exe examples/bin/*.pdb examples/bin/*.dll examples/bin/*.so + +# Unit tests tests/*.exe tests/*.pdb tests/*.dll tests/*.so -lib/* # Example generated files examples/bin/HardwareInfo.txt diff --git a/build/Package_MSVC.bat b/build/Package_MSVC.bat new file mode 100644 index 000000000..3a5c45bce --- /dev/null +++ b/build/Package_MSVC.bat @@ -0,0 +1 @@ +premake5 --pack-libdir=msvc package \ No newline at end of file diff --git a/build/Package_MinGW.bat b/build/Package_MinGW.bat new file mode 100644 index 000000000..aaa7bbf9a --- /dev/null +++ b/build/Package_MinGW.bat @@ -0,0 +1 @@ +premake5 --pack-libdir=mingw package \ No newline at end of file diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua new file mode 100644 index 000000000..a03aaae2f --- /dev/null +++ b/build/scripts/actions/package.lua @@ -0,0 +1,189 @@ +newoption({ + trigger = "pack-libdir", + description = "Specifiy the subdirectory in lib/ to be used when packaging the project" +}) + +ACTION.Name = "Package" +ACTION.Description = "Pack Nazara binaries/include/lib together" + +ACTION.Function = function () + local libDir = _OPTIONS["pack-libdir"] + if (not libDir or #libDir == 0) then + local libDirs = os.matchdirs("../lib/*") + if (#libDirs > 1) then + error("More than one subdirectory was found in the lib directory, please use the --pack-libdir command to clarify which directory should be used") + elseif (#libDirs == 0) then + error("No subdirectory was found in the lib directory, have you built the engine yet?") + else + libDir = libDirs[1] + print("No directory was set by the --pack-libdir command, \"" .. libDir .. "\" will be used") + end + else + libDir = "../lib/" .. libDir .. "/" + end + + if (not os.isdir(libDir)) then + error(string.format("\"%s\" doesn't seem to be an existing directory", libDir)) + end + + local packageDir = "../package/" + + local copyTargets = { + { -- Engine headers + Masks = {"**.hpp", "**.inl"}, + Source = "../include/", + Target = "include/" + }, + { -- SDK headers + Masks = {"**.hpp", "**.inl"}, + Source = "../SDK/include/", + Target = "include/" + }, + { -- Examples files + Masks = {"**.hpp", "**.inl", "**.cpp"}, + Source = "../examples/", + Target = "examples/" + }, + { -- Demo resources + Masks = {"**.*"}, + Source = "../examples/bin/resources/", + Target = "examples/bin/resources/" + } + } + + if (os.is("windows")) then + -- Engine/SDK binaries + table.insert(copyTargets, { + Masks = {"**.dll"}, + Source = libDir, + Target = "bin/" + }) + + -- Engine/SDK libraries + table.insert(copyTargets, { + Masks = {"**.lib"}, + Source = libDir, + Target = "lib/" + }) + + -- 3rd party binary dep + table.insert(copyTargets, { + Masks = {"**.dll"}, + Source = "../extlibs/lib/common/", + Target = "bin/" + }) + + -- Demo executable (Windows) + table.insert(copyTargets, { + Masks = {"Demo*.exe"}, + Source = "../examples/bin", + Target = "examples/bin" + }) + elseif (os.is("macosx")) then + -- Engine/SDK binaries + table.insert(copyTargets, { + Masks = {"**.dynlib"}, + Source = libDir, + Target = "bin/" + }) + + -- Engine/SDK libraries + table.insert(copyTargets, { + Masks = {"**.a"}, + Source = libDir, + Target = "lib/" + }) + + -- 3rd party binary dep + table.insert(copyTargets, { + Masks = {"**.dynlib"}, + Source = "../extlibs/lib/common/", + Target = "bin/" + }) + + -- Demo executable (Windows) + table.insert(copyTargets, { + Masks = {"Demo*"}, + Filter = function (path) return path.getextension(path) == "" end, + Source = "../examples/bin", + Target = "examples/bin" + }) + else + -- Engine/SDK binaries + table.insert(copyTargets, { + Masks = {"**.so"}, + Source = libDir, + Target = "bin/" + }) + + -- Engine/SDK libraries + table.insert(copyTargets, { + Masks = {"**.a"}, + Source = libDir, + Target = "lib/" + }) + + -- 3rd party binary dep + table.insert(copyTargets, { + Masks = {"**.so"}, + Source = "../extlibs/lib/common/", + Target = "bin/" + }) + + -- Demo executable (Windows) + table.insert(copyTargets, { + Masks = {"Demo*"}, + Filter = function (path) return path.getextension(path) == "" end, + Source = "../examples/bin", + Target = "examples/bin" + }) + end + + + -- Processing + os.mkdir(packageDir) + + for k,v in pairs(copyTargets) do + local target = packageDir .. v.Target + local includePrefix = v.Source + for k,v in pairs(os.matchdirs(includePrefix .. "**")) do + local relPath = v:sub(#includePrefix + 1) + + local targetPath = target .. relPath + + if (not os.isdir(targetPath)) then + local ok, err = os.mkdir(targetPath) + if (not ok) then + print("Failed to create directory \"" .. targetPath .. "\": " .. err) + end + end + end + + local targetFiles = {} + for k, mask in pairs(v.Masks) do + local files = os.matchfiles(includePrefix .. mask) + if (v.Filter) then + for k,path in pairs(files) do + if (not v.Filter(v)) then + files[k] = nil + end + end + end + + targetFiles = table.join(targetFiles, files) + end + + for k,v in pairs(targetFiles) do + local relPath = v:sub(#includePrefix + 1) + + local targetPath = target .. relPath + + local ok, err = os.copyfile(v, targetPath) + if (not ok) then + print("Failed to copy \"" .. v .. "\" to \"" .. targetPath .. "\": " .. err) + end + end + end + + print(string.format("Package successfully created at \"%s\"", packageDir)) +end From 5ded56c6e51f2cc2418a2eca39ed355801a42686 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 02:02:05 +0200 Subject: [PATCH 293/383] Core: Fix warning of Serialize() Former-commit-id: d6ddb8947cd250e03a7918e6079b1ee0e4e9bc19 [formerly db49227b808f10e078925da7e293cd3474ea4fa7] [formerly 43f03d8bb5ce0f2ae1ad8989d5af99c6e780c622 [formerly 915b6943dc75ff7e550b6a028358bdb8cbe15203]] Former-commit-id: 1eeb94806f6053948945adf0e044563ad371d1e7 [formerly 2d9eeea263f8728588f6c0ce0d0e0e27006154b1] Former-commit-id: 417aa3f586b9615c2bf8d8f2127b616871be35e7 --- include/Nazara/Core/Algorithm.inl | 2 +- src/Nazara/Core/String.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index dc770eae6..4008f8860 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -227,7 +227,7 @@ namespace Nz */ bool Serialize(SerializationContext& context, const std::string& value) { - if (!Serialize(context, value.size())) + if (!Serialize(context, UInt32(value.size()))) return false; return context.stream->Write(value.data(), value.size()) == value.size(); diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 3c97a5b4b..b1c136eaa 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -5879,7 +5879,7 @@ namespace Nz */ bool Serialize(SerializationContext& context, const String& string) { - if (!Serialize(context, string.GetSize())) + if (!Serialize(context, UInt32(string.GetSize()))) return false; return context.stream->Write(string.GetConstBuffer(), string.GetSize()) == string.GetSize(); From 87437e80afd1d783d7cf9a980c13e38049cd688c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 02:41:57 +0200 Subject: [PATCH 294/383] Network/TcpClient: Fix empty packets being received with an invalid netcode Former-commit-id: e2485cc722c8baab43b78745af697536e996d1b3 [formerly c5396e006fda4a2c6e8afeb165c295312e35820d] [formerly 8810c67dd016aa11af2f81709a1047ac94f744c7 [formerly d53cab8d579848e02393b4c3c924e48c484d27eb]] Former-commit-id: 162f4e2a61ef51475ff0738d0cd3e1a5dfc44419 [formerly 00a51644441eea646fb9ac03bdc4885283460a0c] Former-commit-id: e5387fa08d184a34bac529da305c396ff2a85cf1 --- src/Nazara/Network/TcpClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index 8cdeafc69..1c84dc498 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -265,7 +265,7 @@ namespace Nz if (packetSize == 0) { // Special case: our packet carry no data - packet->Reset(packetSize); + packet->Reset(m_pendingPacket.netcode); // And reset every state m_pendingPacket.data.Clear(); From 48c0315ea6515f7eb85040ec84c4276794d8bfec Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 02:42:40 +0200 Subject: [PATCH 295/383] Build/Package: Fix copy of Nazara binaries/libraries in case of subdirectory detection Former-commit-id: 2d9c61f9b2bf807713006e3b07b1b75a1774bf4a [formerly 21dce208c2e7be41bf41f5b80f4f4e2b04958138] [formerly f0ae51fedea218bd271bb428ba3a4e0716448ab9 [formerly 42d377e32c3c37a20ff397fbcdefb6544be592ec]] Former-commit-id: 369f2d92b951e25c58069efdb8025f98200f0fd9 [formerly 505203a72e7e234bab68e55a25bdf1b5bdae1c5b] Former-commit-id: 676549eda0b4d80f310e3c75994fef339dfa406b --- build/scripts/actions/package.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index a03aaae2f..254bbec26 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -15,7 +15,7 @@ ACTION.Function = function () elseif (#libDirs == 0) then error("No subdirectory was found in the lib directory, have you built the engine yet?") else - libDir = libDirs[1] + libDir = libDirs[1] .. "/" print("No directory was set by the --pack-libdir command, \"" .. libDir .. "\" will be used") end else From 62be0e21df6dc2fb0892f402e7f6cd77ce07cb1a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 02:53:07 +0200 Subject: [PATCH 296/383] Win32: Fix compilation with NAZARA_CORE_WINDOWS_VISTA Former-commit-id: 6249451f41f2dce01652ea61866aa17053ffa4cc [formerly 3db7c2e797fbaa519b303fd533e0184c60781505] [formerly 3342dd5ea892e839757fb3e2e567352c718889de [formerly 174f4491e3141badbce1ded1e4f8e7f2cec2a3d7]] Former-commit-id: d80442b18af96bdecc17bc5409d42483a3a80cd2 [formerly 05adb7a04a120d5989c4307adfdd6f34beef313d] Former-commit-id: bce1c276014724556464f34d2112e6465202cf93 --- src/Nazara/Core/Win32/ConditionVariableImpl.cpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp index 388a7f587..002a9656a 100644 --- a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp +++ b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp @@ -57,7 +57,7 @@ namespace Nz bool ConditionVariableImpl::Wait(MutexImpl* mutex, UInt32 timeout) { #if NAZARA_CORE_WINDOWS_VISTA - return SleepConditionVariableCS(&m_cv, &mutex->m_criticalSection, timeout); + return SleepConditionVariableCS(&m_cv, &mutex->m_criticalSection, timeout) == TRUE; #else m_count++; diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 0097227ef..97d7a10e3 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -18,7 +18,7 @@ namespace Nz int GetAddressInfo(const String& hostname, const String& service, const addrinfoImpl* hints, addrinfoImpl** results) { - return GetAddrInfoW(hostname.GetWideString().c_str(), service.GetWideString().c_str(), &hints, &servinfo); + return GetAddrInfoW(hostname.GetWideString().c_str(), service.GetWideString().c_str(), hints, results); } int GetHostnameInfo(sockaddr* socketAddress, socklen_t socketLen, String* hostname, String* service, INT flags) @@ -26,14 +26,14 @@ namespace Nz std::array hostnameBuffer; std::array serviceBuffer; - int result = GetNameInfoW(socketAddress, socketLen, hostnameBuffer.data(), hostnameBuffer.size(), serviceBuffer.data(), serviceBuffer.size(), flags); + int result = GetNameInfoW(socketAddress, socketLen, hostnameBuffer.data(), static_cast(hostnameBuffer.size()), serviceBuffer.data(), static_cast(serviceBuffer.size()), flags); if (result == 0) { if (hostname) - hostname->Set(hostnameBuffer.data()); + *hostname = std::move(String::Unicode(hostnameBuffer.data())); if (service) - service->Set(serviceBuffer.data()); + *service = std::move(String::Unicode(serviceBuffer.data())); } return result; From 48ef3f6b30776968cbd7c35602cc9b704b7e13f8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 03:16:48 +0200 Subject: [PATCH 297/383] Network/SocketPoller: Fix poll implementation (Windows > Vista, Unix) Former-commit-id: dd5517d6b15bdb2ed9be4f89ff06ddeeeb3fec30 [formerly 4aef580c50c04256503fbbdfe21924f0b97b6c09] [formerly 9d904c520de9a74292cc1af09b6a5b46617a1d49 [formerly d31432a7eb98825413abb0de333b6ceb9c2d400b]] Former-commit-id: 362f4a43f24dce67763fe4978e34da74fbd39148 [formerly 93ca7cbcd7f3368f4ecd3fa87ed512a3b55faaba] Former-commit-id: e147094e1a7c7540afb972a9ccd116d7444e0fea --- src/Nazara/Network/Posix/SocketPollerImpl.cpp | 3 ++- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Network/Posix/SocketPollerImpl.cpp b/src/Nazara/Network/Posix/SocketPollerImpl.cpp index 6b279ec50..4242e79a9 100644 --- a/src/Nazara/Network/Posix/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Posix/SocketPollerImpl.cpp @@ -76,12 +76,13 @@ namespace Nz m_activeSockets.clear(); if (activeSockets > 0U) { + int socketRemaining = activeSockets; for (PollSocket& entry : m_sockets) { if (entry.revents & POLLRDNORM) { m_activeSockets.insert(entry.fd); - if (--activeSockets == 0) + if (--socketRemaining == 0) break; } } diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index b71e5107c..dd80c233d 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -112,12 +112,13 @@ namespace Nz m_activeSockets.clear(); if (activeSockets > 0U) { + int socketRemaining = activeSockets; for (PollSocket& entry : m_sockets) { if (entry.revents & POLLRDNORM) { m_activeSockets.insert(entry.fd); - if (--activeSockets == 0) + if (--socketRemaining == 0) break; } } From 25afa30187006b757128dbc74d689ab12630807c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 03:27:57 +0200 Subject: [PATCH 298/383] Update README (Add documentation link) Former-commit-id: b4aa269265f72205b72bf2caae86dd66ab143d44 [formerly a077d845f84b11138cddb6fa3d18127e453f0b9d] [formerly d873b4be5ac6b9a61b4bb9a6d37e9a850b48cf1c [formerly 821300bf9bf03bb400f10d7e1bc6edd9a8213e87]] Former-commit-id: 7e81e4df215174e322861dd561b8edb6dd13d15c [formerly 746009685b5f0220be1e1b4b91b5736892f7cec6] Former-commit-id: a7f95ef6f67c61f08ff888ca86887ac760b78f05 --- readme.md | 14 +++++--------- readme_fr.md | 16 ++++++---------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/readme.md b/readme.md index eefdc2d76..edb58080e 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,6 @@ Windows | [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/ Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) # Nazara Engine -------- Nazara Engine is a fast, complete, cross-platform, object-oriented API which can help you in your daily developper life. Its goal is to provide a set of useful classes : Its core provides unicode strings, filesystem access, hashs, threads, ... @@ -14,23 +13,19 @@ It also provide a set of libraries, such as audio, network, physics, renderer, 2 You can use it in any kind of commercial/non-commercial applications without any restriction ([MIT license](http://opensource.org/licenses/MIT)). ## Authors -------- Jérôme "Lynix" Leclercq - main developper () Rémi "overdrivr" Bèges - developper & helper - Noise Module - () ## Install -------- Use the premake build system in the build directory then compile the engine for your platform. ## How to use ----------- You can find tutorials on installation, compilation and use on the [official wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) ## Contribute ----------- ##### Don't hesitate to contribute to Nazara Engine by: - Extending the [wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) @@ -41,14 +36,15 @@ You can find tutorials on installation, compilation and use on the [official wik - Doing anything else that might help us ## Links ----------- + [Website](https://nazara.digitalpulsesoftware.net) +[Documentation](https://nazara.digitalpulsesoftware.net/doc) +[Mattermost](https://mattermost.digitalpulsesoftware.net) [Wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) -[Forum](https://forum.digitalpulsesoftware.net) -[Mattermost](https://mattermost.digitalpulsesoftware.net) +[Forum](https://forum.digitalpulsesoftware.net) ## Thanks to: ----------- + - **RafBill** and **Raakz:** Finding bugs and/or testing - **Fissal "DrFisher" Hannoun**: Helping a lot in architecture design - **Alexandre "Danman" Janniaux**: Helping making the POSIX implementation diff --git a/readme_fr.md b/readme_fr.md index e88d8fb88..d7aff37b9 100644 --- a/readme_fr.md +++ b/readme_fr.md @@ -4,7 +4,6 @@ Windows | [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/ Linux | [![Travis CI Build Status](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine.svg)](https://travis-ci.org/DigitalPulseSoftware/NazaraEngine) # Nazara Engine -------- Nazara Engine est une API rapide, complète, portable et orientée-objet qui peut vous aider dans votre vie de développeur de tous les jours. Son objectif est de fournir un ensemble de classes utiles : Son noyau dispose de chaînes de caractères unicode, de gestion du système de fichiers, hashs, threads, ... @@ -14,23 +13,19 @@ Il propose aussi un ensemble de bibliothèques, comme audio, réseau, physique, Vous pouvez également l'utiliser pour toute application commerciale sans aucune contrainte ([Licence MIT](http://opensource.org/licenses/MIT)). ## Auteurs -------- Jérôme "Lynix" Leclercq - développeur principal () Rémi "overdrivr" Bèges - développeur & aide - module Noise - () ## Installation ------------- Utilisez le système premake pour construire le projet du moteur, dans le dossier build, pour ensuite compiler le moteur pour votre plateforme. ## Utilisation ------------ Vous pouvez lire des tutoriaux sur l'installation, la compilation et l'utilisation sur le [wiki officiel](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) (**\*En cours de rédaction***) ## Contribution ----------- ##### N'hésitez pas à contribuer à Nazara Engine en : - Contribuant au [wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) (**\*Lien brisé***) @@ -41,14 +36,15 @@ Vous pouvez lire des tutoriaux sur l'installation, la compilation et l'utilisati - Faisant n'importe quoi d'autre qui pourrait nous aider ## Liens ----------- -[Website](http://www.digitalpulsesoftware.net) + +[Website](https://nazara.digitalpulsesoftware.net) +[Documentation](https://nazara.digitalpulsesoftware.net/doc) +[Mattermost](https://mattermost.digitalpulsesoftware.net) [Wiki](https://github.com/DigitalPulseSoftware/NazaraEngine/wiki) -[Forum](http://forum.digitalpulsesoftware.net) -[Mattermost](https://mattermost.digitalpulsesoftware.net) +[Forum](https://forum.digitalpulsesoftware.net) ###Remerciements: ----------- + - **RafBill** et **Raakz:** Recherche de bugs et/ou tests - **Fissal "DrFisher" Hannoun**: Aide et conseils lors de la conception de l'architecture du moteur - **Alexandre "Danman" Janniaux**: Aide sur l'implémentation POSIX From c087d916a1c19e9e93c5ea8b4817b1118bb244da Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 25 Sep 2016 03:45:07 +0200 Subject: [PATCH 299/383] Network/SocketPoller: Fix missing documentation Former-commit-id: c6670596bcf9faba08d59c1e90c0596eccbabfd6 [formerly 2a358094943cd9a7971af9ae53c0d1adec34fdf8] [formerly 079909ff9f2cd7bf529eef1537b00f698a880c5f [formerly 989fe6aa5a78ae9c37e7e161ae5895b620cb8d0b]] Former-commit-id: 244c8405aeb61eefdaf47390d059d40a004e48b1 [formerly 7989e0ee5e6fee6b5ecf8e861fcd926c38ced8a2] Former-commit-id: 177e32b55a11dce2936de0e92a4d8a264a30ada4 --- src/Nazara/Network/SocketPoller.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp index 1364cb93d..72ab1a613 100644 --- a/src/Nazara/Network/SocketPoller.cpp +++ b/src/Nazara/Network/SocketPoller.cpp @@ -17,7 +17,13 @@ namespace Nz { /*! - * \brief Constructs a SocketPoller object by default + * \ingroup network + * \class Nz::SocketPoller + * \brief Network class allowing an application to wait on multiples sockets for them to become active (readable) + */ + + /*! + * \brief Constructs an empty SocketPoller object */ inline SocketPoller::SocketPoller() : m_impl(new SocketPollerImpl) @@ -26,6 +32,8 @@ namespace Nz /*! * \brief Destructs the SocketPoller + * + * \remark When the SocketPoller gets destroyed, all sockets are automatically unregistered from it. */ SocketPoller::~SocketPoller() { From 8c7dee81e897e98a423e47230ac821a7edab80de Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 12:35:16 +0200 Subject: [PATCH 300/383] Core/Stream: Fix ReadLine Former-commit-id: 81e89bb4b11264371d7cbcf9cf5275ec0ce3f7ba [formerly 8ac037f30540faebc51efa5953fc01d9659a1f19] [formerly b599cef23b34132171373aee1cca81daf259b65e [formerly 053ef5248717e56f5e943f6dbdddf8092ae9dda2]] Former-commit-id: c14803c0471a6bfa347f0f512886dae2d8cc7871 [formerly dc174bdb2cb49e68b57b85267ac72178d7e202af] Former-commit-id: 815fe25a962845d091de7a02a0c0ff2e62f45b51 --- src/Nazara/Core/Stream.cpp | 45 +++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/Nazara/Core/Stream.cpp b/src/Nazara/Core/Stream.cpp index b36b67d85..f82591fed 100644 --- a/src/Nazara/Core/Stream.cpp +++ b/src/Nazara/Core/Stream.cpp @@ -44,14 +44,19 @@ namespace Nz } /*! - * \brief Reads characters in the stream + * \brief Reads a line from the stream + * + * Reads the stream until a line separator or the end of the stream is found. + * + * If lineSize does not equal zero, it represents the maximum character count to be read from the stream. + * + * \param lineSize Maximum number of characters to read, or zero for no limit + * * \return Line containing characters * - * \param lineSize Number of characters to read, if lineSize is 0, read as much as possible - * - * \remark Produces a NazaraWarning if cursor position could not be reset + * \remark With the text stream option, "\r\n" is treated as "\n" + * \remark The line separator character is not returned as part of the string */ - String Stream::ReadLine(unsigned int lineSize) { String line; @@ -71,19 +76,33 @@ namespace Nz if (ptr) { std::ptrdiff_t pos = ptr - buffer; - - if (m_streamOptions & StreamOption_Text && pos > 0 && buffer[pos - 1] == '\r') - line.Append(buffer, pos - 1); - else - line.Append(buffer, pos); + if (ptr != buffer) + { + if (m_streamOptions & StreamOption_Text && buffer[pos - 1] == '\r') + line.Append(buffer, pos - 1); + else + line.Append(buffer, pos); + } if (!SetCursorPos(GetCursorPos() - readSize + pos + 1)) - NazaraWarning("Failed to reset cursos pos"); + NazaraWarning("Failed to reset cursor pos"); - break; + if (!line.IsEmpty()) + break; } else - line.Append(buffer, readSize); + { + std::size_t length = readSize; + if (m_streamOptions & StreamOption_Text && buffer[length - 1] == '\r') + { + if (!SetCursorPos(GetCursorPos() - 1)) + NazaraWarning("Failed to reset cursor pos"); + + length--; + } + + line.Append(buffer, length); + } } while (readSize == bufferSize); } From d70012470402b80b21da5bf918e8c093e0794b35 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:15:09 +0200 Subject: [PATCH 301/383] Core/Log: Add AbstractLogger inclusion Former-commit-id: 0da715a3ab6b34b3ffe65659a6d46bb542a12897 [formerly c4033c72ac80435a188a50197bc382be9b413c63] [formerly 989f44ed7d63b9f6c3b125694b7855de8e51bacf [formerly a0a4effadc32a802ee2d56429326f1a935bb4d4a]] Former-commit-id: 04addee943f199d59be5cafff05009b191415158 [formerly a787ddc27a06f6b39097b1813235cfe3d33aba30] Former-commit-id: e4f09a35f3dff825c3bafa0f7614526ce01a8e60 --- include/Nazara/Core/Log.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/Nazara/Core/Log.hpp b/include/Nazara/Core/Log.hpp index fa8e9b6d0..fc64c8a49 100644 --- a/include/Nazara/Core/Log.hpp +++ b/include/Nazara/Core/Log.hpp @@ -8,6 +8,7 @@ #define NAZARA_LOG_HPP #include +#include #include #include #include @@ -29,8 +30,6 @@ namespace Nz { - class AbstractLogger; - class NAZARA_CORE_API Log { friend class Core; From bf6425c35f793592738eef5fe371314a0732f9be Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:16:01 +0200 Subject: [PATCH 302/383] Utility/OBJParser: Add Check() method to quickly check if any OBJ token is present at the beginning Former-commit-id: 27f09e4351e6721eab338576075a161f62a4c262 [formerly d2cc64b6b6ec984210fd187adfc0797087ea3a0a] [formerly 58c7a39be0a0fdb8c89c516d5e8d19b18d34ba60 [formerly a9d80e257c27b60319e0d1b03b1534e133e1244e]] Former-commit-id: 9ccaa30b87462af58390478d4d6b956d9b5faa5f [formerly 615171770a9a8c87b37b50940c7342bdeb6876a2] Former-commit-id: c49b38dc42936ba3f696f9436fd9f6b5527244c0 --- include/Nazara/Utility/Formats/OBJParser.hpp | 2 + src/Nazara/Utility/Formats/OBJParser.cpp | 81 +++++++++++++++++++- 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 6c0c35af4..82c1220bf 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -29,6 +29,8 @@ namespace Nz inline void Clear(); + bool Check(Stream& stream); + inline String* GetMaterials(); inline const String* GetMaterials() const; inline UInt32 GetMaterialCount() const; diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index a520d6be1..3b03b7f78 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -13,9 +13,87 @@ namespace Nz { + bool OBJParser::Check(Stream& stream) + { + m_currentStream = &stream; + m_errorCount = 0; + m_keepLastLine = false; + m_lineCount = 0; + + // Force stream in text mode, reset it at the end + Nz::CallOnExit resetTextMode; + if ((stream.GetStreamOptions() & StreamOption_Text) == 0) + { + stream.EnableTextMode(true); + + resetTextMode.Reset([&stream] () + { + stream.EnableTextMode(false); + }); + } + + unsigned int failureCount = 0; + while (Advance(false)) + { + switch (std::tolower(m_currentLine[0])) + { + case '#': //< Comment + failureCount--; + break; + + case 'f': //< Face + case 'g': //< Group (inside a mesh) + case 'o': //< Object (defines a mesh) + case 's': //< Smooth + { + if (m_currentLine.GetSize() > 1 && m_currentLine[1] == ' ') + return true; + + break; + } + + case 'm': //< MTLLib + if (m_currentLine.GetWord(0).ToLower() == "mtllib") + return true; + + break; + + case 'u': //< Usemtl + if (m_currentLine.GetWord(0).ToLower() == "usemtl") + return true; + + break; + + case 'v': //< Position/Normal/Texcoords + { + String word = m_currentLine.GetWord(0).ToLower(); + if (word == 'v') + return true; + else if (word == "vn") + return true; + else if (word == "vt") + return true; + + break; + } + + default: + break; + } + + if (++failureCount > 20U) + return false; + } + + return false; + } + bool OBJParser::Parse(Nz::Stream& stream, UInt32 reservedVertexCount) { m_currentStream = &stream; + m_errorCount = 0; + m_keepLastLine = false; + m_lineCount = 0; // Force stream in text mode, reset it at the end Nz::CallOnExit resetTextMode; @@ -31,9 +109,6 @@ namespace Nz String matName, meshName; matName = meshName = "default"; - m_errorCount = 0; - m_keepLastLine = false; - m_lineCount = 0; m_meshes.clear(); m_mtlLib.Clear(); From 7761b59dd9ab4611ff435ab40930d40c6474085d Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:16:42 +0200 Subject: [PATCH 303/383] Utility/OBJLoader: Check OBJ files before processing them This removes a lot of errors from the logs in some cases Former-commit-id: b540b8b8f942c0e8805e3b3e76295669f5e6764a [formerly c71ce0c21549178438ebcc3c85ca9e9074966410] [formerly 454c698bfa5432f19f238890d303f3641dca7056 [formerly 6e501a315a69b38c11440988bdc5d5f2e7158852]] Former-commit-id: c5bfc674f09100d99a4c853a1dea96fd030fde49 [formerly 6f5190f8ed305b9726ef69d713a20e99d8c476a1] Former-commit-id: a72b009cc519caf76784336b2df8db9d5b2d8628 --- src/Nazara/Utility/Formats/OBJLoader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 11029bada..2a59ba703 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -37,6 +37,10 @@ namespace Nz if (parameters.custom.GetBooleanParameter("SkipNativeOBJLoader", &skip) && skip) return Ternary_False; + OBJParser parser; + if (!parser.Check(stream)) + return Ternary_False; + return Ternary_Unknown; } From dd8f583ddf9565dcd456a2d5c2307cc3c9edadaa Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:17:06 +0200 Subject: [PATCH 304/383] UnitTests: Add SocketPoller test Former-commit-id: b55e068f965f5caa4e4421c34e829522bc48a4cf [formerly c5496d8e4fa3b92bc2b950211de80f6b7e3fc967] [formerly ee508eb538748fd1c23d032fb825a03879a58e67 [formerly e18dff1d01ba1cc6df8351f6ea4b315809843a6c]] Former-commit-id: 307f7d01cfdcc4ec84eed0c36773349922e50a1d [formerly 4098ef95f0950a95b576c95e7a904d986d4c9cc0] Former-commit-id: 1c92830f710e774f575a6bc4ee5151b0c88b6369 --- tests/Engine/Network/SocketPoller.cpp | 81 +++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/Engine/Network/SocketPoller.cpp diff --git a/tests/Engine/Network/SocketPoller.cpp b/tests/Engine/Network/SocketPoller.cpp new file mode 100644 index 000000000..1f9c782d2 --- /dev/null +++ b/tests/Engine/Network/SocketPoller.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include + +#include +#include + +SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]") +{ + GIVEN("A TcpServer and a TcpClient in a selector") + { + Nz::UInt16 port = 64256; + Nz::TcpServer server; + server.EnableBlocking(false); + + REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound); + + Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port); + REQUIRE(serverIP.IsValid()); + + Nz::SocketPoller serverPoller; + Nz::TcpClient clientToServer; + + WHEN("We register the server socket to the poller") + { + REQUIRE(serverPoller.RegisterSocket(server)); + + THEN("The poller should have registered our socket") + { + REQUIRE(serverPoller.IsRegistered(server)); + } + AND_THEN("We connect using a TcpClient") + { + Nz::SocketState state = clientToServer.Connect(serverIP); + + REQUIRE(state != Nz::SocketState_NotConnected); + + AND_THEN("We wait on our selector, it should return true") + { + REQUIRE(serverPoller.Wait(1000)); + + Nz::TcpClient serverToClient; + REQUIRE(server.AcceptClient(&serverToClient)); + + WHEN("We register the client socket to the poller") + { + REQUIRE(serverPoller.RegisterSocket(serverToClient)); + + THEN("The poller should have registered our socket") + { + REQUIRE(serverPoller.IsRegistered(serverToClient)); + } + + AND_WHEN("We test sending data from the client to the server and checking the poller") + { + std::array buffer = {"Data"}; + + std::size_t sent; + REQUIRE(clientToServer.Send(buffer.data(), buffer.size(), &sent)); + REQUIRE(sent == buffer.size()); + + REQUIRE(serverPoller.Wait(1000)); + + REQUIRE(serverPoller.IsReady(serverToClient)); + + REQUIRE(serverToClient.Read(buffer.data(), buffer.size()) == sent); + + AND_THEN("Our selector should report no socket ready") + { + REQUIRE(!serverPoller.Wait(100)); + + REQUIRE(!serverPoller.IsReady(serverToClient)); + } + } + } + } + } + } + } +} From 6d356d2790e224004a1cb620868448b36f716276 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:17:16 +0200 Subject: [PATCH 305/383] Fix all unit tests Former-commit-id: f83290f7d0b5106624a37956edfc0ea623eb61a8 [formerly 7260760404ad152543aaac13fc61861c8f82c15b] [formerly 4cce81216b3f42daab22c52353acc7626d52cdad [formerly c79538e86f953f326636bdacac778d5936988eee]] Former-commit-id: 26b41fdde348870cc75535d80a4bd9a209184668 [formerly e12ae06222e2fb77a6f68c5788f0901485b95218] Former-commit-id: 6f47bc28420ebe23ce378a80324430fe898c1e99 --- tests/Engine/Graphics/Model.cpp | 4 ++-- tests/Engine/Network/RUdpConnection.cpp | 13 ++++++++++--- tests/Engine/Network/TCP.cpp | 12 +++++------- tests/Engine/Network/UdpSocket.cpp | 5 ++++- tests/SDK/NDK/Application.cpp | 17 ++++++++++------- tests/main.cpp | 12 +++++++----- 6 files changed, 38 insertions(+), 25 deletions(-) diff --git a/tests/Engine/Graphics/Model.cpp b/tests/Engine/Graphics/Model.cpp index b363a0be2..270d15a0e 100644 --- a/tests/Engine/Graphics/Model.cpp +++ b/tests/Engine/Graphics/Model.cpp @@ -15,12 +15,12 @@ SCENARIO("Model", "[GRAPHICS][MODEL]") Nz::ModelRef model = Nz::Model::New(); REQUIRE(model->LoadFromFile("resources/Engine/Graphics/dragon_recon/dragon_vrip_res4.obj", params)); - REQUIRE(model->GetMaterialCount() == 2); + REQUIRE(model->GetMaterialCount() == 1); REQUIRE(model->GetSkin() == 0); REQUIRE(model->GetSkinCount() == 1); Nz::Material* material = model->GetMaterial(0); - REQUIRE(material->GetAmbientColor() == Nz::Color(128)); + REQUIRE(material->GetAmbientColor() == Nz::Color::Black); } } } diff --git a/tests/Engine/Network/RUdpConnection.cpp b/tests/Engine/Network/RUdpConnection.cpp index a39100e94..cd30b3e1e 100644 --- a/tests/Engine/Network/RUdpConnection.cpp +++ b/tests/Engine/Network/RUdpConnection.cpp @@ -7,13 +7,18 @@ SCENARIO("RUdpConnection", "[NETWORK][RUDPCONNECTION]") { GIVEN("Two RUdpConnection, one client, one server") { - Nz::UInt16 port = 64266; + // Disabled for now + + /*Nz::UInt16 port = 64266; Nz::RUdpConnection server; REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port)); - Nz::IpAddress serverIP = server.GetBoundAddress(); + + Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port); REQUIRE(serverIP.IsValid()); + Nz::RUdpConnection client; REQUIRE(client.Listen(Nz::NetProtocol_IPv4, port + 1)); + Nz::IpAddress clientIP = client.GetBoundAddress(); REQUIRE(client.Connect(serverIP)); REQUIRE(clientIP.IsValid()); @@ -30,11 +35,13 @@ SCENARIO("RUdpConnection", "[NETWORK][RUDPCONNECTION]") { Nz::RUdpMessage rudpMessage; server.Update(); + REQUIRE(server.PollMessage(&rudpMessage)); + Nz::Vector3f result; rudpMessage.data >> result; REQUIRE(result == vector123); } - } + }*/ } } diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp index a613cf0c6..7ee62cab9 100644 --- a/tests/Engine/Network/TCP.cpp +++ b/tests/Engine/Network/TCP.cpp @@ -11,20 +11,18 @@ SCENARIO("TCP", "[NETWORK][TCP]") { GIVEN("Two TCP, one client, one server") { - // Avoid reusing the same socket - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<> dis(1025, 64245); - - Nz::UInt16 port = dis(gen); + Nz::UInt16 port = 64256; Nz::TcpServer server; server.EnableBlocking(false); REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound); - Nz::IpAddress serverIP = server.GetBoundAddress(); + + Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port); REQUIRE(serverIP.IsValid()); + Nz::TcpClient client; REQUIRE(client.Connect(serverIP) == Nz::SocketState_Connecting); + Nz::IpAddress clientIP = client.GetRemoteAddress(); REQUIRE(clientIP.IsValid()); diff --git a/tests/Engine/Network/UdpSocket.cpp b/tests/Engine/Network/UdpSocket.cpp index 3f199f09e..34ce5a19e 100644 --- a/tests/Engine/Network/UdpSocket.cpp +++ b/tests/Engine/Network/UdpSocket.cpp @@ -11,10 +11,13 @@ SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]") Nz::UInt16 port = 64256; Nz::UdpSocket server(Nz::NetProtocol_IPv4); REQUIRE(server.Bind(port) == Nz::SocketState_Bound); - Nz::IpAddress serverIP = server.GetBoundAddress(); + + Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port); REQUIRE(serverIP.IsValid()); + Nz::UdpSocket client(Nz::NetProtocol_IPv4); REQUIRE(client.Bind(port + 1) == Nz::SocketState_Bound); + Nz::IpAddress clientIP = client.GetBoundAddress(); REQUIRE(clientIP.IsValid()); diff --git a/tests/SDK/NDK/Application.cpp b/tests/SDK/NDK/Application.cpp index 994bd022b..3eab5645e 100644 --- a/tests/SDK/NDK/Application.cpp +++ b/tests/SDK/NDK/Application.cpp @@ -5,17 +5,20 @@ SCENARIO("Application", "[NDK][APPLICATION]") { GIVEN("An application") { - Ndk::Application application; - application.AddWorld(); - Nz::Window& window = application.AddWindow(); + Nz::Window& window = Ndk::Application::Instance()->AddWindow(); - WHEN("We close the open window") + WHEN("We open a window") { - window.Close(); + REQUIRE(window.Create(Nz::VideoMode(800, 600, 32), "Nazara Unit Tests")); - THEN("Application should close") + AND_WHEN("We close the open window") { - REQUIRE(!application.Run()); + window.Close(); + + THEN("Application should close") + { + REQUIRE(!Ndk::Application::Instance()->Run()); + } } } } diff --git a/tests/main.cpp b/tests/main.cpp index 5ba9e8e01..112b7498c 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,14 +1,16 @@ #define CATCH_CONFIG_RUNNER #include -#include -#include -#include +#include +#include #include -int main(int argc, char* const argv[]) +int main(int argc, char* argv[]) { - Nz::Initializer modules; + Ndk::Application application(argc, argv); + Nz::Initializer modules; + + Nz::Log::GetLogger()->EnableStdReplication(false); int result = Catch::Session().run(argc, argv); From bbf9a5337de6f2d6bf281ebfaf4287eea287da13 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:18:21 +0200 Subject: [PATCH 306/383] Core/String: Fix Simplified() method, which was altering the original string size instead of the copy Former-commit-id: ee47e8d0162647c87319345efc1506c41ec4b727 [formerly 02f40858f0e96881607d8e41a7f1ceac9f417a03] [formerly b711d61ffcf49f18afb95def91de1a045f3684dc [formerly b75b19a03b746c0a9f750d7ddf86ddd51f08098d]] Former-commit-id: 120d8b06bdbb658cf67e2a45bdaec4134ce291f2 [formerly ac34669afd7c16f9c2a2dee23dab7f7e09e0f5e5] Former-commit-id: 6b2fc9ec4f3815976a73ca2be3d79ce141597b58 --- src/Nazara/Core/String.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index b1c136eaa..34ddd3dcf 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -3461,7 +3461,7 @@ namespace Nz p--; *p = '\0'; - m_sharedString->size = p - str; + newString->size = p - str; return String(std::move(newString)); } From a7b98c407a89a5219a92d9fa34eefca040b114fb Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:19:03 +0200 Subject: [PATCH 307/383] Core/String: Fix error when using COW on empty string Former-commit-id: 5d4bb54e4d7b9f68ef66ff8f099d9ea854d982b5 [formerly 8c7e15a2f6f5c1978a3e7b2c33f0ce038ca19dc7] [formerly 9b01d29473ca9d3d64333dd1aa79539a3b2dedb2 [formerly 9159fc04b30b7aef18d16ed1887ba637256a8ad8]] Former-commit-id: dcbc45c4fce819a44a47a02439a68276fae5b992 [formerly effba4f1df384c6bc7b87066fe94a93058302b0a] Former-commit-id: 357ad9fa46d773d6066b1b7cc945da663fe004f7 --- src/Nazara/Core/String.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 34ddd3dcf..5019f0885 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -4553,7 +4553,7 @@ namespace Nz String& String::operator=(String&& string) noexcept { - return Set(string); + return Set(std::move(string)); } /*! @@ -5852,7 +5852,7 @@ namespace Nz if (!m_sharedString.unique()) { auto newSharedString = std::make_shared(GetSize(), GetCapacity()); - if (!discardContent) + if (!discardContent && newSharedString->size > 0) std::memcpy(newSharedString->string.get(), GetConstBuffer(), GetSize()+1); m_sharedString = std::move(newSharedString); From e9deac38024f0f040ada2bedcea4d6d9ecaa6307 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 13:19:30 +0200 Subject: [PATCH 308/383] Graphics/ParticleStruct: Add size member to ParticleStruct_Billboard Former-commit-id: c8578baad436d18d609d4cc7cf1d773ba01b8616 [formerly fff8b8fce1a6b0a5330dc983e46676d9de6bc810] [formerly 9d584febdb50e4680d4beb24c5fb65371b838ffa [formerly cdbfc358e3c66ade396353c5d996c6d5c7fba313]] Former-commit-id: 54ab0d22f7e947a2ee01fa9f36bd0e81af40e91d [formerly fc75d5fcd8351f4c9bccfd4c3a57131365d52ea4] Former-commit-id: 79f3c8b08ad0089988e59139baaf87bf2aa5460b --- include/Nazara/Graphics/ParticleStruct.hpp | 1 + src/Nazara/Graphics/ParticleDeclaration.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/Nazara/Graphics/ParticleStruct.hpp b/include/Nazara/Graphics/ParticleStruct.hpp index 72ce961b9..895e8fca2 100644 --- a/include/Nazara/Graphics/ParticleStruct.hpp +++ b/include/Nazara/Graphics/ParticleStruct.hpp @@ -17,6 +17,7 @@ namespace Nz struct ParticleStruct_Billboard { Color color; + Vector2f size; Vector3f normal; Vector3f position; Vector3f velocity; diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index dff382d2c..ebd84e95d 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -291,6 +291,7 @@ namespace Nz declaration->EnableComponent(ParticleComponent_Normal, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Billboard, normal)); declaration->EnableComponent(ParticleComponent_Position, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Billboard, position)); declaration->EnableComponent(ParticleComponent_Rotation, ComponentType_Float1, NazaraOffsetOf(ParticleStruct_Billboard, rotation)); + declaration->EnableComponent(ParticleComponent_Size, ComponentType_Float2, NazaraOffsetOf(ParticleStruct_Billboard, size)); declaration->EnableComponent(ParticleComponent_Velocity, ComponentType_Float3, NazaraOffsetOf(ParticleStruct_Billboard, velocity)); NazaraAssert(declaration->GetStride() == sizeof(ParticleStruct_Billboard), "Invalid stride for declaration ParticleLayout_Billboard"); From 72680be7011756c226b79686469ddf9f5a728227 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 14:10:03 +0200 Subject: [PATCH 309/383] Build/UnitTest: Fix linking Former-commit-id: ea7172090011baea8fda085f8f8d895e5537822b [formerly b00275cc5a01424a1d21d8a03e2022374f2a507c] [formerly 8e05dbc52e4233038ffae8ae6e5e0c0e00780a70 [formerly 798992ad419e11477b62711e249740393b56a01b]] Former-commit-id: 82c971fcfe8baee74e5da16434e82deee1ce0862 [formerly 1cad1379fafea09668d8efbaa8d4558eb3657aec] Former-commit-id: 557d01842da1234ebdd066ee9cd3c2f84f8fd769 --- build/scripts/tools/unittests.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index b423b390f..5dcf6e215 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -19,5 +19,6 @@ TOOL.Files = { } TOOL.Libraries = { + "NazaraNetwork", "NazaraSDK" } From a13b17573e1456653b267140e613a1cfebc69fa3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 18:34:06 +0200 Subject: [PATCH 310/383] Network/SocketPoller: Switch to epoll implementation on Linux Former-commit-id: 1a4b998bff35b5aac411b053fe3dee48f1f6985c [formerly b7a50753347b629f708f21d85efc9e76e4b1bfc6] [formerly 7d59f9ff3d2173657cc5873209753fe64b59e2f2 [formerly 4c38f94a4a366ed290e605870e6f3c87e6decd7f]] Former-commit-id: af5cc261c162ca3eebe5885acd5e2adfbd817984 [formerly 26e7b701e8dcafb7fb9c3537107729b2d0bfe354] Former-commit-id: 00bd2c62ecdb5c493c4ec117dd2033d272f7143a --- build/scripts/modules/network.lua | 5 + src/Nazara/Network/Linux/SocketPollerImpl.cpp | 99 +++++++++++++++++++ src/Nazara/Network/Linux/SocketPollerImpl.hpp | 43 ++++++++ 3 files changed, 147 insertions(+) create mode 100644 src/Nazara/Network/Linux/SocketPollerImpl.cpp create mode 100644 src/Nazara/Network/Linux/SocketPollerImpl.hpp diff --git a/build/scripts/modules/network.lua b/build/scripts/modules/network.lua index 8cf8b068a..987c6a822 100644 --- a/build/scripts/modules/network.lua +++ b/build/scripts/modules/network.lua @@ -14,6 +14,11 @@ MODULE.OsFiles.Posix = { "../src/Nazara/Network/Posix/**.cpp" } +MODULE.OsFiles.Linux = { + "../src/Nazara/Network/Linux/**.hpp", + "../src/Nazara/Network/Linux/**.cpp" +} + MODULE.OsLibraries.Windows = { "ws2_32" } diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.cpp b/src/Nazara/Network/Linux/SocketPollerImpl.cpp new file mode 100644 index 000000000..9a0806d8a --- /dev/null +++ b/src/Nazara/Network/Linux/SocketPollerImpl.cpp @@ -0,0 +1,99 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + SocketPollerImpl::SocketPollerImpl() + { + m_handle = epoll_create1(0); + } + + SocketPollerImpl::~SocketPollerImpl() + { + close(m_handle); + } + + void SocketPollerImpl::Clear() + { + m_activeSockets.clear(); + m_sockets.clear(); + } + + bool SocketPollerImpl::IsReady(SocketHandle socket) const + { + return m_activeSockets.count(socket) != 0; + } + + bool SocketPollerImpl::IsRegistered(SocketHandle socket) const + { + return m_sockets.count(socket) != 0; + } + + bool SocketPollerImpl::RegisterSocket(SocketHandle socket) + { + NazaraAssert(!IsRegistered(socket), "Socket is already registered"); + + epoll_event event; + event.events = EPOLLIN; + event.data.fd = socket; + + if (epoll_ctl(m_handle, EPOLL_CTL_ADD, socket, &event) != 0) + { + NazaraError("Failed to add socket to epoll structure (errno " String::Number(errno) + ": " + Error::GetLastSystemError() + ')'); + return false; + } + + m_sockets.insert(socket); + + return true; + } + + void SocketPollerImpl::UnregisterSocket(SocketHandle socket) + { + NazaraAssert(IsRegistered(socket), "Socket is not registered"); + + m_activeSockets.erase(socket); + m_sockets.erase(socket); + + if (epoll_ctl(m_handle, EPOLL_CTL_DEL, socket, nullptr) != 0) + NazaraWarning("An error occured while removing socket from epoll structure (errno " String::Number(errno) + ": " + Error::GetLastSystemError() + ')'); + } + + int SocketPollerImpl::Wait(UInt64 msTimeout, SocketError* error) + { + int activeSockets; + + // Reset status of sockets + m_events.resize(m_sockets.size()); + std::memset(m_events.data(), 0, m_events.size() * sizeof(epoll_event)); + + activeSockets = epoll_wait(m_handle, m_events.data(), static_cast(m_events.size()), static_cast(msTimeout)); + + m_activeSockets.clear(); + if (activeSockets > 0U) + { + int socketCount = activeSockets; + for (int i = 0; i < socketCount; ++i) + { + if (m_events[i].events & (EPOLLIN | EPOLLHUP | EPOLLERR)) + { + m_activeSockets.insert(m_events[i].data.fd); + if (m_events[i].events & EPOLLERR) + NazaraWarning("Descriptor " + String::Number(m_events[i].data.fd) + " was returned by epoll with EPOLLERR status"); + } + else + { + NazaraWarning("Descriptor " + String::Number(m_events[i].data.fd) + " was returned by epoll without EPOLLIN (events: 0x" + String::Number(m_events[i].events, 16) + ')'); + activeSockets--; + } + } + } + + return activeSockets; + } +} diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.hpp b/src/Nazara/Network/Linux/SocketPollerImpl.hpp new file mode 100644 index 000000000..a6c5ad9f8 --- /dev/null +++ b/src/Nazara/Network/Linux/SocketPollerImpl.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Network module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SOCKETPOLLERIMPL_HPP +#define NAZARA_SOCKETPOLLERIMPL_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class SocketPollerImpl + { + public: + SocketPollerImpl(); + ~SocketPollerImpl(); + + void Clear(); + + bool IsReady(SocketHandle socket) const; + bool IsRegistered(SocketHandle socket) const; + + bool RegisterSocket(SocketHandle socket); + void UnregisterSocket(SocketHandle socket); + + int Wait(UInt64 msTimeout, SocketError* error); + + private: + std::unordered_set m_activeSockets; + std::unordered_set m_sockets; + std::vector m_events; + int m_handle; + }; +} + +#endif // NAZARA_SOCKETPOLLERIMPL_HPP From d8788c8d09063c8e144f978b3f5016382c53dd36 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 19:04:51 +0200 Subject: [PATCH 311/383] Network/SocketPoller: Fix Linux implementation Former-commit-id: f709da3636f60638461910570f8a03bf4acd1723 [formerly 8dd3f494efc40f9c652262903642155941620ac4] [formerly f4aeaca88e75efc00d818046d0a6e63a81db5af3 [formerly b5e70d0536e7d25e363b18e58d47122e3c90ca1e]] Former-commit-id: 2ee713e85407fe7d44d3b1352f197da113cbe041 [formerly 9735f9b849062179207f4453a233a851c49431ea] Former-commit-id: fc5e136d0be6123138623ba3d90b64475b8d81b4 --- build/scripts/modules/network.lua | 5 +++++ src/Nazara/Network/Linux/SocketPollerImpl.cpp | 5 +++-- src/Nazara/Network/SocketPoller.cpp | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build/scripts/modules/network.lua b/build/scripts/modules/network.lua index 987c6a822..9245d72f3 100644 --- a/build/scripts/modules/network.lua +++ b/build/scripts/modules/network.lua @@ -19,6 +19,11 @@ MODULE.OsFiles.Linux = { "../src/Nazara/Network/Linux/**.cpp" } +MODULE.OsFilesExcluded.Linux = { + "../src/Nazara/Network/Posix/SocketPollerImpl.hpp", + "../src/Nazara/Network/Posix/SocketPollerImpl.cpp" +} + MODULE.OsLibraries.Windows = { "ws2_32" } diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.cpp b/src/Nazara/Network/Linux/SocketPollerImpl.cpp index 9a0806d8a..4188ff245 100644 --- a/src/Nazara/Network/Linux/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Linux/SocketPollerImpl.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include @@ -44,7 +45,7 @@ namespace Nz if (epoll_ctl(m_handle, EPOLL_CTL_ADD, socket, &event) != 0) { - NazaraError("Failed to add socket to epoll structure (errno " String::Number(errno) + ": " + Error::GetLastSystemError() + ')'); + NazaraError("Failed to add socket to epoll structure (errno " + String::Number(errno) + ": " + Error::GetLastSystemError() + ')'); return false; } @@ -61,7 +62,7 @@ namespace Nz m_sockets.erase(socket); if (epoll_ctl(m_handle, EPOLL_CTL_DEL, socket, nullptr) != 0) - NazaraWarning("An error occured while removing socket from epoll structure (errno " String::Number(errno) + ": " + Error::GetLastSystemError() + ')'); + NazaraWarning("An error occured while removing socket from epoll structure (errno " + String::Number(errno) + ": " + Error::GetLastSystemError() + ')'); } int SocketPollerImpl::Wait(UInt64 msTimeout, SocketError* error) diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp index 72ab1a613..e9cf40b59 100644 --- a/src/Nazara/Network/SocketPoller.cpp +++ b/src/Nazara/Network/SocketPoller.cpp @@ -6,6 +6,8 @@ #if defined(NAZARA_PLATFORM_WINDOWS) #include +#elif defined(NAZARA_PLATFORM_LINUX) +#include #elif defined(NAZARA_PLATFORM_POSIX) #include #else From 73ca2cd20334a46c93a4326174f478c6652e0832 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 19:21:57 +0200 Subject: [PATCH 312/383] Network/SocketPollerImpl: Fix compilation on Linux Former-commit-id: f73b19423f093e2b61dfa4d6405a31f3727caac8 [formerly 49f4fc0cc3748bbe9d437cbf821b6572f5cce9d0] [formerly e0aba35dcaf14c51b468f3cb7fb0ca11e9fe9858 [formerly d9702db8895beb27659a320065e603e659a0c67a]] Former-commit-id: f519992e9c049bdfff9f27ecdd398a5db2f4c5b2 [formerly 9ddba3042d5ad622d118e3ef9514571323cc0632] Former-commit-id: 9449ba98c71a5d988aa5f619852b32ea3621c97a --- src/Nazara/Network/Linux/SocketPollerImpl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.cpp b/src/Nazara/Network/Linux/SocketPollerImpl.cpp index 4188ff245..fb6321709 100644 --- a/src/Nazara/Network/Linux/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Linux/SocketPollerImpl.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz From 3a8b16f36e07315a48394bd6756cdcb1066ef418 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 26 Sep 2016 19:37:31 +0200 Subject: [PATCH 313/383] Network/SocketPoller: Fix constructor linking Former-commit-id: 618b77421a9ce9d6090789fc45188ce8aa55c166 [formerly fc592c91642c62b2b0d70718dcc6411c7bb089ae] [formerly a53e47653062eff13e08536746bbc4225e366f16 [formerly 82e71fb8b858c0f2ce3ea9141af4920aefb13f61]] Former-commit-id: 27e1799a5c90be2347027cdc9aed33a67cb8ddb3 [formerly 4434c6e8109fb464e87ee7e199680e01de67659e] Former-commit-id: 20011dca33841988e329b74e915848986b2d184c --- src/Nazara/Network/SocketPoller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp index e9cf40b59..049970433 100644 --- a/src/Nazara/Network/SocketPoller.cpp +++ b/src/Nazara/Network/SocketPoller.cpp @@ -27,7 +27,7 @@ namespace Nz /*! * \brief Constructs an empty SocketPoller object */ - inline SocketPoller::SocketPoller() : + SocketPoller::SocketPoller() : m_impl(new SocketPollerImpl) { } From 1403f08d35f267889e7b78d584fbc30d6ba61938 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 12:20:57 +0200 Subject: [PATCH 314/383] Travis: Try to make Travis execute unit tests Former-commit-id: 9e84b2acdfb08155a4e31c6cf29044700c33b216 [formerly 1049c995d1a0d4b67fe2e3abefe9823f66a92142] [formerly 79e2efaff8dd8856e272a6b42a7c314be31b0b8f [formerly a616b93c3baf5236a81b8a591cf756c28a736abe]] Former-commit-id: ae62cf97a5ea86297dabedb7ee6c956e0bd8ccd5 [formerly 5d00bc2bbd73bd1754786960aed26af95588543c] Former-commit-id: 623e1be4f32e802ae245fea03e30ad926d814747 --- .travis.yml | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b3fef862..14970886f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,12 @@ -language: cpp -sudo: required +language: + cpp + +sudo: + required + +notifications: + email: true + services: - docker @@ -7,19 +14,18 @@ before_install: - docker build -t nazara . script: - - docker run -v `pwd`:/NazaraEngine nazara - sh -c "cd build && - ./premake5-linux64 --with-examples gmake && - cd gmake && - make -j4 -f NazaraEngine.make && - cd ../../tests && - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ - " - -notifications: - email: true - -branches: - only: - - master + - docker run --name Nazara -v `pwd`:/NazaraEngine nazara + sh -c " + cd build && + ./premake5-linux64 --with-examples gmake && + cd gmake && + make -j4 -f NazaraEngine.make + " +after_script: + - docker exec Nazara + sh -c " + cd ../../tests && + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && + ./NazaraUnitTests + " From 1ef16a5f3e2b0e4a4e928c8e3f4dc474790df093 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 12:56:07 +0200 Subject: [PATCH 315/383] AppVeyor: Execute unit tests after build Former-commit-id: 8b1650a6c3a68173cfb29d70e23881953902fbf0 [formerly e3ae2470e5d2a3e8dc74fc8a05ddd26c6dced72d] [formerly 3148eee0a49011d0ffbf0ce9eb165ec2754400bd [formerly 36c691428bb590cd6f827a436ac2be82836268e6]] Former-commit-id: 59fbf8a3a1a37f49f8fa824accfea65f0bac8b17 [formerly 5ba5e7b5618f26a9f02fc19edb0827055953d001] Former-commit-id: d4765683b28a0d47c329c88db18ae2f6b1488cab --- appveyor.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 39ff8f7a8..be3abb4aa 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,11 +10,16 @@ environment: - TOOLSET: vs2015 install: - - cd build && "./premake5.exe" %TOOLSET% && cd .. + - cd build + - "./premake5.exe" %TOOLSET% configuration: - DebugDynamic - ReleaseDynamic build: - project: build/$(TOOLSET)/NazaraEngine.sln \ No newline at end of file + project: build/$(TOOLSET)/NazaraEngine.sln + +after_build: + - cd tests + - "./NazaraUnitTests" \ No newline at end of file From a73cab209dd789e48082c21ba353cfa97592da2f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 12:57:10 +0200 Subject: [PATCH 316/383] Fix AppVeyor Former-commit-id: ee228ea9a5e5925c4423e80fb9b6ba54c2e99976 [formerly 51c00f3c2c05986c495e74c615e0d3f1ae35750d] [formerly 184b9efad1b0b555ab85b93f54e676cc574c7b28 [formerly 433ccb4af1f399a2c67eaa63e3334f8d233b75a7]] Former-commit-id: 2e7ac3fa14850b22a04236cbb800732537cd9220 [formerly 671e06d25371c685083adea0abd3501d0109acf1] Former-commit-id: eaf3c71f331e8b4d700399ae8d4cb43a9f153e4d --- appveyor.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index be3abb4aa..a08a06416 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,8 +10,7 @@ environment: - TOOLSET: vs2015 install: - - cd build - - "./premake5.exe" %TOOLSET% + - cd build && "./premake5.exe" %TOOLSET% configuration: - DebugDynamic @@ -21,5 +20,4 @@ build: project: build/$(TOOLSET)/NazaraEngine.sln after_build: - - cd tests - - "./NazaraUnitTests" \ No newline at end of file + - cd tests && "./NazaraUnitTests" \ No newline at end of file From 73af9f801b5ecdd69a23c06d119a6be0d6b02760 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 13:05:41 +0200 Subject: [PATCH 317/383] Fix AppVeyor Former-commit-id: b6f9ea5d9d40318fcbfe46148200edd5e38faf84 [formerly cc835c422f51042efa734c58afa469c72f68e921] [formerly 4222e9b22ed8d168b3c04a115fa7b3fdf42b1d99 [formerly 29f32bff2b0f77149cd44fa19a68c70921aa086f]] Former-commit-id: c7d3d033d1e6b3e93ffa1aff718fd86c4f9fb188 [formerly 43caadd42cfbbb226a4846ae3c9685a15a189454] Former-commit-id: 54987604f1dfdf35aa25013d95f33e2f9328113a --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index a08a06416..3bc1d73c8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,7 @@ environment: - TOOLSET: vs2015 install: - - cd build && "./premake5.exe" %TOOLSET% + - cd build && "./premake5.exe" %TOOLSET% && cd .. configuration: - DebugDynamic From 7529855fc0f8b6a24befd168515863d26c3f984c Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 13:30:49 +0200 Subject: [PATCH 318/383] ContinuousIntegration: Disable UnitTests (servers are not able to execute client unit tests) Former-commit-id: aff932695bc4012b0f22aafb608a3575570cdb3c [formerly d4e4272279e8e089ccccbc2fac245c3a55410519] [formerly 939b2861786fee66b182a3984834ff179e9145db [formerly 607e829a7585d517bc731ef1904b9ad2a2cf0bfd]] Former-commit-id: 3134bf78ce1c77dbf127be6bcf642d5184916f32 [formerly 40a3715aa54ede03bfe3ba5bcb1797cd75dfeb7f] Former-commit-id: 4033b6bf2bca62bd8c955e13439822986809b44f --- .travis.yml | 14 +++++++------- appveyor.yml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14970886f..dc4f5e225 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,10 @@ script: make -j4 -f NazaraEngine.make " -after_script: - - docker exec Nazara - sh -c " - cd ../../tests && - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && - ./NazaraUnitTests - " +#after_script: +# - docker exec Nazara +# sh -c " +# cd ../../tests && +# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && +# ./NazaraUnitTests +# " diff --git a/appveyor.yml b/appveyor.yml index 3bc1d73c8..7688cff07 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,5 +19,5 @@ configuration: build: project: build/$(TOOLSET)/NazaraEngine.sln -after_build: - - cd tests && "./NazaraUnitTests" \ No newline at end of file +#after_build: +# - cd tests && "./NazaraUnitTests" \ No newline at end of file From c61b4598e82c72f3d09972d69d13c829efb62c3f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 13:40:29 +0200 Subject: [PATCH 319/383] Core/Config: Rename WINDOWS_VISTA option to WINDOWS_NT6 Former-commit-id: 9d0c33b7d79521e074aa84684d09d7855956d1df [formerly 7400f0dc41845e0bf275e7a631ec760857db6009] [formerly 9bc38d067febb9723119adf811922642b1f7b782 [formerly e7b9f3e327d422a9ed1e01cdc9439170a67bf7d2]] Former-commit-id: 8614882bef71668ed10cd7fedbf4a058073e6389 [formerly 1bbf4a90092509565475a1709c82dc696f8b8a04] Former-commit-id: 0b6c22973bfa60dca69902388244d4d40fc9b554 --- include/Nazara/Core/Config.hpp | 4 ++-- include/Nazara/Prerequesites.hpp | 4 ++-- src/Nazara/Core/Win32/ConditionVariableImpl.cpp | 10 +++++----- src/Nazara/Core/Win32/ConditionVariableImpl.hpp | 4 ++-- src/Nazara/Network/Win32/IpAddressImpl.cpp | 4 ++-- src/Nazara/Network/Win32/IpAddressImpl.hpp | 2 +- src/Nazara/Network/Win32/SocketImpl.hpp | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/Nazara/Core/Config.hpp b/include/Nazara/Core/Config.hpp index 87848b052..2ad2513ac 100644 --- a/include/Nazara/Core/Config.hpp +++ b/include/Nazara/Core/Config.hpp @@ -72,8 +72,8 @@ // Number of spinlocks to use with the Windows critical sections (0 to disable) #define NAZARA_CORE_WINDOWS_CS_SPINLOCKS 4096 -// Optimize the Windows implementation with technologies of Windows vista (and greater) (Break the compatibility with XP) -#define NAZARA_CORE_WINDOWS_VISTA 0 +// Optimize the Windows implementation with technologies of Windows NT 6.0 (and greater) (Break the compatibility with Windows XP) +#define NAZARA_CORE_WINDOWS_NT6 0 /* diff --git a/include/Nazara/Prerequesites.hpp b/include/Nazara/Prerequesites.hpp index c2c83626a..95af712eb 100644 --- a/include/Nazara/Prerequesites.hpp +++ b/include/Nazara/Prerequesites.hpp @@ -74,7 +74,7 @@ #error Nazara requires a C++11 compliant compiler #endif -// Version du moteur +// Nazara version macro #define NAZARA_VERSION_MAJOR 0 #define NAZARA_VERSION_MINOR 1 @@ -97,7 +97,7 @@ #define NOMINMAX #endif - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 // Version de Windows minimale : Vista #define NAZARA_WINNT 0x0600 #else diff --git a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp index 002a9656a..a387a7638 100644 --- a/src/Nazara/Core/Win32/ConditionVariableImpl.cpp +++ b/src/Nazara/Core/Win32/ConditionVariableImpl.cpp @@ -12,7 +12,7 @@ namespace Nz { ConditionVariableImpl::ConditionVariableImpl() { - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 InitializeConditionVariable(&m_cv); #else m_count = 0; @@ -21,7 +21,7 @@ namespace Nz #endif } - #if !NAZARA_CORE_WINDOWS_VISTA + #if !NAZARA_CORE_WINDOWS_NT6 ConditionVariableImpl::~ConditionVariableImpl() { CloseHandle(m_events[BROADCAST]); @@ -31,7 +31,7 @@ namespace Nz void ConditionVariableImpl::Signal() { - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 WakeConditionVariable(&m_cv); #else if (m_count > 0) @@ -41,7 +41,7 @@ namespace Nz void ConditionVariableImpl::SignalAll() { - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 WakeAllConditionVariable(&m_cv); #else if (m_count > 0) @@ -56,7 +56,7 @@ namespace Nz bool ConditionVariableImpl::Wait(MutexImpl* mutex, UInt32 timeout) { - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 return SleepConditionVariableCS(&m_cv, &mutex->m_criticalSection, timeout) == TRUE; #else m_count++; diff --git a/src/Nazara/Core/Win32/ConditionVariableImpl.hpp b/src/Nazara/Core/Win32/ConditionVariableImpl.hpp index a1bb70deb..469cf6099 100644 --- a/src/Nazara/Core/Win32/ConditionVariableImpl.hpp +++ b/src/Nazara/Core/Win32/ConditionVariableImpl.hpp @@ -21,7 +21,7 @@ namespace Nz { public: ConditionVariableImpl(); - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 ~ConditionVariableImpl() = default; #else ~ConditionVariableImpl(); @@ -34,7 +34,7 @@ namespace Nz bool Wait(MutexImpl* mutex, UInt32 timeout); private: - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 CONDITION_VARIABLE m_cv; #else enum diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 97d7a10e3..2dac156ce 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -13,7 +13,7 @@ namespace Nz { namespace Detail { - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 using addrinfoImpl = addrinfoW; int GetAddressInfo(const String& hostname, const String& service, const addrinfoImpl* hints, addrinfoImpl** results) @@ -105,7 +105,7 @@ namespace Nz return IpAddress::Invalid; } - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 IpAddress IpAddressImpl::FromAddrinfo(const addrinfoW* info) { switch (info->ai_family) diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index 000b407eb..e85dc7411 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -22,7 +22,7 @@ namespace Nz ~IpAddressImpl() = delete; static IpAddress FromAddrinfo(const addrinfo* info); - #if NAZARA_CORE_WINDOWS_VISTA + #if NAZARA_CORE_WINDOWS_NT6 static IpAddress FromAddrinfo(const addrinfoW* info); #endif static IpAddress FromSockAddr(const sockaddr* address); diff --git a/src/Nazara/Network/Win32/SocketImpl.hpp b/src/Nazara/Network/Win32/SocketImpl.hpp index ab93085d9..94e2e9a8c 100644 --- a/src/Nazara/Network/Win32/SocketImpl.hpp +++ b/src/Nazara/Network/Win32/SocketImpl.hpp @@ -12,7 +12,7 @@ #include #include -#define NAZARA_NETWORK_POLL_SUPPORT NAZARA_CORE_WINDOWS_VISTA +#define NAZARA_NETWORK_POLL_SUPPORT NAZARA_CORE_WINDOWS_NT6 namespace Nz { From 4c357a3fa3c300df75734ebee0ee70782ee08d0c Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 13:40:48 +0200 Subject: [PATCH 320/383] Add patch version (currently 0) Former-commit-id: 4a7884684144dd283c5ffede0baa66ef4f54c0f6 [formerly e5f51b59e9803b14d0d36b6db392075e8b9d691e] [formerly c9cc9087ac4b1b5619902f257c3e4a09c5d27a3d [formerly 8e32c976716317c0b46632052e215c7e75fd742c]] Former-commit-id: 0346aa52aea49b3ee0dec1bed0d593e012ba6718 [formerly 64fef1f0211ce68ebfcd3e65d897db954f7471bf] Former-commit-id: 2a6600243f915701d945e08dbda08bcecedb6123 --- include/Nazara/Prerequesites.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Nazara/Prerequesites.hpp b/include/Nazara/Prerequesites.hpp index 95af712eb..6fdbf5d03 100644 --- a/include/Nazara/Prerequesites.hpp +++ b/include/Nazara/Prerequesites.hpp @@ -77,6 +77,7 @@ // Nazara version macro #define NAZARA_VERSION_MAJOR 0 #define NAZARA_VERSION_MINOR 1 +#define NAZARA_VERSION_PATCH 0 #include From 939e28b990ffe98bae016eb463c5b67714e6da35 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 14:04:45 +0200 Subject: [PATCH 321/383] Extlibs/Newton: Compile Newton with /MT This way, using it with MinGW doesn't require any VS Runtime Also removed debug library (they weren't used anyway) Former-commit-id: e08a4da9f48fdfe3960df8e2bff8ba1db9fb34ef [formerly 47a55533f90c5a9bdf747b3f958f8b05b6a15994] [formerly 07f15ca5138d6f2334ea52ab30a6594cd531065d [formerly df5bfc827567e7df0aa5367d6cc85817987b3ce8]] Former-commit-id: 24522fcbc867afd193fad3a0ec875181c018f568 [formerly 6983a21611959a73d99cc916e848e469c1270a98] Former-commit-id: 979cce16b0f2fcf3ca0bf229b8b9f5801b73c929 --- build/scripts/modules/physics.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/modules/physics.lua b/build/scripts/modules/physics.lua index f6d485a67..0796c46fd 100644 --- a/build/scripts/modules/physics.lua +++ b/build/scripts/modules/physics.lua @@ -2,5 +2,5 @@ MODULE.Name = "Physics" MODULE.Libraries = { "NazaraCore", - "Newton" + "Newton" -- Newton Game Dynamics } From 29ac52770ed2a8617b5aadedb3e20c0504b288ba Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 18:09:25 +0200 Subject: [PATCH 322/383] SDK/CameraComponent: Moved virtual functions to source file Former-commit-id: 633046a6f599ce9f8712e11b8195509d9704bfc0 [formerly 080ea253a37d683c72372b406148372f9c1b92d2] [formerly 528dbe2f2c9dcac7b48c11feafb24a12afd43652 [formerly af9843c5eae928fb2f03c0ec1550e7ef95f69108]] Former-commit-id: f17eed57cd271cfc55ef380bde44917ea26deac7 [formerly 30667bf567620cc339c96388303582b8b8601f68] Former-commit-id: 66843984b23bee78fdbcefebbf56febddcdb4bb2 --- .../NDK/Components/CameraComponent.hpp | 20 ++-- .../NDK/Components/CameraComponent.inl | 93 +------------------ SDK/src/NDK/Components/CameraComponent.cpp | 82 +++++++++++++++- 3 files changed, 92 insertions(+), 103 deletions(-) diff --git a/SDK/include/NDK/Components/CameraComponent.hpp b/SDK/include/NDK/Components/CameraComponent.hpp index af2245b11..b26901a79 100644 --- a/SDK/include/NDK/Components/CameraComponent.hpp +++ b/SDK/include/NDK/Components/CameraComponent.hpp @@ -34,21 +34,21 @@ namespace Ndk inline void EnsureViewMatrixUpdate() const; inline void EnsureViewportUpdate() const; - inline float GetAspectRatio() const override; - inline Nz::Vector3f GetEyePosition() const override; - inline Nz::Vector3f GetForward() const override; + float GetAspectRatio() const override; + Nz::Vector3f GetEyePosition() const override; + Nz::Vector3f GetForward() const override; inline float GetFOV() const; - inline const Nz::Frustumf& GetFrustum() const override; + const Nz::Frustumf& GetFrustum() const override; inline unsigned int GetLayer() const; - inline const Nz::Matrix4f& GetProjectionMatrix() const override; + const Nz::Matrix4f& GetProjectionMatrix() const override; inline Nz::ProjectionType GetProjectionType() const; inline const Nz::Vector2f& GetSize() const; - inline const Nz::RenderTarget* GetTarget() const override; + const Nz::RenderTarget* GetTarget() const override; inline const Nz::Rectf& GetTargetRegion() const; - inline const Nz::Matrix4f& GetViewMatrix() const override; - inline const Nz::Recti& GetViewport() const override; - inline float GetZFar() const override; - inline float GetZNear() const override; + const Nz::Matrix4f& GetViewMatrix() const override; + const Nz::Recti& GetViewport() const override; + float GetZFar() const override; + float GetZNear() const override; inline void SetFOV(float fov); inline void SetLayer(unsigned int layer); diff --git a/SDK/include/NDK/Components/CameraComponent.inl b/SDK/include/NDK/Components/CameraComponent.inl index d42d0e152..541096de5 100644 --- a/SDK/include/NDK/Components/CameraComponent.inl +++ b/SDK/include/NDK/Components/CameraComponent.inl @@ -95,40 +95,15 @@ namespace Ndk UpdateViewport(); } - /*! - * \brief Gets the aspect ratio of the camera - * \return Aspect ratio of the camera - */ - - inline float CameraComponent::GetAspectRatio() const - { - EnsureViewportUpdate(); - - return m_aspectRatio; - } - /*! * \brief Gets the field of view of the camera * \return Field of view of the camera */ - - inline float CameraComponent::GetFOV() const + float CameraComponent::GetFOV() const { return m_fov; } - /*! - * \brief Gets the frutum of the camera - * \return A constant reference to the frustum of the camera - */ - - inline const Nz::Frustumf& CameraComponent::GetFrustum() const - { - EnsureFrustumUpdate(); - - return m_frustum; - } - /*! * \brief Gets the layer of the camera * \return Layer of the camera @@ -139,18 +114,6 @@ namespace Ndk return m_layer; } - /*! - * \brief Gets the projection matrix of the camera - * \return A constant reference to the projection matrix of the camera - */ - - inline const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const - { - EnsureProjectionMatrixUpdate(); - - return m_projectionMatrix; - } - /*! * \brief Gets the projection type of the camera * \return Projection type of the camera @@ -171,16 +134,6 @@ namespace Ndk return m_size; } - /*! - * \brief Gets the target of the camera - * \return A constant reference to the render target of the camera - */ - - inline const Nz::RenderTarget* CameraComponent::GetTarget() const - { - return m_target; - } - /*! * \brief Gets the target region of the camera * \return A constant reference to the target region of the camera @@ -191,50 +144,6 @@ namespace Ndk return m_targetRegion; } - /*! - * \brief Gets the view matrix of the camera - * \return A constant reference to the view matrix of the camera - */ - - inline const Nz::Matrix4f& CameraComponent::GetViewMatrix() const - { - EnsureViewMatrixUpdate(); - - return m_viewMatrix; - } - - /*! - * \brief Gets the view port of the camera - * \return A constant reference to the view port of the camera - */ - - inline const Nz::Recti& CameraComponent::GetViewport() const - { - EnsureViewportUpdate(); - - return m_viewport; - } - - /*! - * \brief Gets the Z far distance of the camera - * \return Z far distance of the camera - */ - - inline float CameraComponent::GetZFar() const - { - return m_zFar; - } - - /*! - * \brief Gets the Z near distance of the camera - * \return Z near distance of the camera - */ - - inline float CameraComponent::GetZNear() const - { - return m_zNear; - } - /*! * \brief Sets the field of view of the camera * diff --git a/SDK/src/NDK/Components/CameraComponent.cpp b/SDK/src/NDK/Components/CameraComponent.cpp index 71c653823..28f4e31d5 100644 --- a/SDK/src/NDK/Components/CameraComponent.cpp +++ b/SDK/src/NDK/Components/CameraComponent.cpp @@ -35,6 +35,17 @@ namespace Ndk Nz::Renderer::SetViewport(m_viewport); } + /*! + * \brief Gets the aspect ratio of the camera + * \return Aspect ratio of the camera + */ + float CameraComponent::GetAspectRatio() const + { + EnsureViewportUpdate(); + + return m_aspectRatio; + } + /*! * \brief Gets the eye position of the camera * @@ -53,7 +64,6 @@ namespace Ndk * * \remark Produces a NazaraAssert if entity is invalid or has no NodeComponent */ - Nz::Vector3f CameraComponent::GetForward() const { NazaraAssert(m_entity && m_entity->HasComponent(), "CameraComponent requires NodeComponent"); @@ -61,6 +71,76 @@ namespace Ndk return m_entity->GetComponent().GetForward(); } + /*! + * \brief Gets the frutum of the camera + * \return A constant reference to the frustum of the camera + */ + const Nz::Frustumf& CameraComponent::GetFrustum() const + { + EnsureFrustumUpdate(); + + return m_frustum; + } + + /*! + * \brief Gets the projection matrix of the camera + * \return A constant reference to the projection matrix of the camera + */ + const Nz::Matrix4f& CameraComponent::GetProjectionMatrix() const + { + EnsureProjectionMatrixUpdate(); + + return m_projectionMatrix; + } + + /*! + * \brief Gets the target of the camera + * \return A constant reference to the render target of the camera + */ + const Nz::RenderTarget* CameraComponent::GetTarget() const + { + return m_target; + } + + /*! + * \brief Gets the view matrix of the camera + * \return A constant reference to the view matrix of the camera + */ + const Nz::Matrix4f& CameraComponent::GetViewMatrix() const + { + EnsureViewMatrixUpdate(); + + return m_viewMatrix; + } + + /*! + * \brief Gets the view port of the camera + * \return A constant reference to the view port of the camera + */ + const Nz::Recti& CameraComponent::GetViewport() const + { + EnsureViewportUpdate(); + + return m_viewport; + } + + /*! + * \brief Gets the Z far distance of the camera + * \return Z far distance of the camera + */ + float CameraComponent::GetZFar() const + { + return m_zFar; + } + + /*! + * \brief Gets the Z near distance of the camera + * \return Z near distance of the camera + */ + float CameraComponent::GetZNear() const + { + return m_zNear; + } /*! * \brief Sets the layer of the camera in case of multiples fields * From 3875d2abe2f7f743a961d9b1c4ebfb338f049cd7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 27 Sep 2016 18:10:13 +0200 Subject: [PATCH 323/383] Build: Make some fixes in order to prepare static building Still not linking though Former-commit-id: 3962a663c9368ea78c4703cc860beef8c440bb4b [formerly b9575a870528ef6712500a94c5223a74d5c6dbec] [formerly bf2ab7b17b25479d6a8fda660e8d9055ffce38de [formerly 3db6f9cbf4cedd9f91ef8f7f1bcc99a4e84027a4]] Former-commit-id: 0c292fec84d1963f377d16d5e9a15337bef4620f [formerly 93c016fa10c60bf11e4b0b1e17d8c98a66dfa028] Former-commit-id: 712b1bf14355a82be4cc2c37912f87039b3d9616 --- SDK/include/NDK/Prerequesites.hpp | 4 ++-- build/scripts/common.lua | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Prerequesites.hpp b/SDK/include/NDK/Prerequesites.hpp index f3532c70d..ec40a17d8 100644 --- a/SDK/include/NDK/Prerequesites.hpp +++ b/SDK/include/NDK/Prerequesites.hpp @@ -33,7 +33,7 @@ // Importation/Exportation of the API #if defined(NAZARA_PLATFORM_WINDOWS) - #if !defined(NDK_STATIC) + #if !defined(NAZARA_STATIC) #ifdef NDK_BUILD #define NDK_API NAZARA_EXPORT #else @@ -43,7 +43,7 @@ #define NDK_API #endif #elif defined(NAZARA_PLATFORM_LINUX) - #if !defined(NDK_STATIC) && defined(NAZARA_COMPILER_GCC) + #if !defined(NAZARA_STATIC) && defined(NAZARA_COMPILER_GCC) #define NDK_API NAZARA_EXPORT #else #define NDK_API diff --git a/build/scripts/common.lua b/build/scripts/common.lua index cf6fa6560..e6f231960 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -228,6 +228,7 @@ function NazaraBuild:Execute() targetdir("../lib/xcode/x64") configuration("*Static") + defines("NAZARA_STATIC") kind("StaticLib") configuration("*Dynamic") @@ -357,6 +358,9 @@ function NazaraBuild:Execute() targetdir("../plugins/" .. toolTable.Name .. "/lib/xcode/x64") end + configuration("*Static") + defines("NAZARA_STATIC") + if (toolTable.Kind == "library" or toolTable.Kind == "plugin") then configuration("*Static") kind("StaticLib") @@ -705,7 +709,7 @@ function NazaraBuild:MakeInstallCommands(infoTable) end if (os.is("windows")) then - configuration({}) + configuration("*Dynamic") for k,v in pairs(self.InstallDir) do local destPath = path.translate(path.isabsolute(k) and k or "../../" .. k) From 7e908a52265f414304f1262f346aade9f2937e3c Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 28 Sep 2016 13:06:48 +0200 Subject: [PATCH 324/383] Build/Package: Improve package builder, add unit tests Former-commit-id: 4dd27dd88564a8527dce268c3941f92804a55ade [formerly fdf45e4846285005a6dfccb940756b9d1b092b3a] [formerly 8f0ba428a30ab1716bc93545b7a5eb491176e600 [formerly d4a711f0813706bbd9ef094c4340e7dca2de92fe]] Former-commit-id: 2fbcb21bda1b9660c2dbacd17571adb517342926 [formerly 75446e538072a1fae14aee28b528899be3c217ea] Former-commit-id: e53d8b6e050f5887e86ff7d7825c514b725f936b --- build/scripts/actions/package.lua | 84 +++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index 254bbec26..b62ca3643 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -48,6 +48,18 @@ ACTION.Function = function () Masks = {"**.*"}, Source = "../examples/bin/resources/", Target = "examples/bin/resources/" + }, + -- Unit test sources + { + Masks = {"**.hpp", "**.inl", "**.cpp"}, + Source = "../tests/", + Target = "tests/src/" + }, + -- Unit test resources + { + Masks = {"**.*"}, + Source = "../tests/resources/", + Target = "tests/resources/" } } @@ -76,9 +88,17 @@ ACTION.Function = function () -- Demo executable (Windows) table.insert(copyTargets, { Masks = {"Demo*.exe"}, - Source = "../examples/bin", - Target = "examples/bin" + Source = "../examples/bin/", + Target = "examples/bin/" }) + + -- Unit test (Windows) + table.insert(copyTargets, { + Masks = {"*.exe"}, + Source = "../tests/", + Target = "tests/" + }) + elseif (os.is("macosx")) then -- Engine/SDK binaries table.insert(copyTargets, { @@ -101,13 +121,22 @@ ACTION.Function = function () Target = "bin/" }) - -- Demo executable (Windows) + -- Demo executable (OS X) table.insert(copyTargets, { Masks = {"Demo*"}, Filter = function (path) return path.getextension(path) == "" end, - Source = "../examples/bin", - Target = "examples/bin" + Source = "../examples/bin/", + Target = "examples/bin/" }) + + -- Unit test (OS X) + table.insert(copyTargets, { + Masks = {"*.*"}, + Filter = function (path) return path.getextension(path) == "" end, + Source = "../tests/", + Target = "tests/" + }) + else -- Engine/SDK binaries table.insert(copyTargets, { @@ -130,12 +159,20 @@ ACTION.Function = function () Target = "bin/" }) - -- Demo executable (Windows) + -- Demo executable (Linux) table.insert(copyTargets, { Masks = {"Demo*"}, Filter = function (path) return path.getextension(path) == "" end, - Source = "../examples/bin", - Target = "examples/bin" + Source = "../examples/bin/", + Target = "examples/bin/" + }) + + -- Unit test (Linux) + table.insert(copyTargets, { + Masks = {"*.*"}, + Filter = function (path) return path.getextension(path) == "" end, + Source = "../tests/", + Target = "tests/" }) end @@ -143,24 +180,14 @@ ACTION.Function = function () -- Processing os.mkdir(packageDir) + local size = 0 for k,v in pairs(copyTargets) do local target = packageDir .. v.Target local includePrefix = v.Source - for k,v in pairs(os.matchdirs(includePrefix .. "**")) do - local relPath = v:sub(#includePrefix + 1) - - local targetPath = target .. relPath - - if (not os.isdir(targetPath)) then - local ok, err = os.mkdir(targetPath) - if (not ok) then - print("Failed to create directory \"" .. targetPath .. "\": " .. err) - end - end - end local targetFiles = {} for k, mask in pairs(v.Masks) do + print(includePrefix .. mask .. " => " .. target) local files = os.matchfiles(includePrefix .. mask) if (v.Filter) then for k,path in pairs(files) do @@ -169,7 +196,7 @@ ACTION.Function = function () end end end - + targetFiles = table.join(targetFiles, files) end @@ -177,13 +204,26 @@ ACTION.Function = function () local relPath = v:sub(#includePrefix + 1) local targetPath = target .. relPath + local targetDir = path.getdirectory(targetPath) + if (not os.isdir(targetDir)) then + local ok, err = os.mkdir(targetDir) + if (not ok) then + print("Failed to create directory \"" .. targetDir .. "\": " .. err) + end + end + local ok, err = os.copyfile(v, targetPath) if (not ok) then print("Failed to copy \"" .. v .. "\" to \"" .. targetPath .. "\": " .. err) end + + local stat = os.stat(targetPath) + if (stat) then + size = size + stat.size + end end end - print(string.format("Package successfully created at \"%s\"", packageDir)) + print(string.format("Package successfully created at \"%s\" (%u MB, %s)", packageDir, size / (1024 * 1024), libDir)) end From bd0c99c687f0fbde5edc5a8126713d73f8db3a0b Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 28 Sep 2016 13:55:27 +0200 Subject: [PATCH 325/383] UnitTest: Enable RTTI Former-commit-id: 99410bd952b14a187de04632ae041fd556a66e34 [formerly 85c10d4f7f2251c67cc14f1e7b10bac7092681e7] [formerly 4cd0ef1e6cbe595673dfb71ba82f4620dde4413e [formerly 3b7b24b4cad4e0abd4fb2faf7c9305ca75462028]] Former-commit-id: 4419ea87112eb630430b46e5a8c0a3c155925df3 [formerly 83f3c7cab613c17d504484937fedca9ab09329ea] Former-commit-id: 1455045645ef8e3ca74b49488b3d53adaf7e3d55 --- build/scripts/common.lua | 7 ++++++- build/scripts/tools/unittests.lua | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index e6f231960..b134bf4e3 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -141,7 +141,6 @@ function NazaraBuild:Execute() configuration("Release*") flags("NoFramePointer") optimize("Speed") - rtti("Off") vectorextensions("SSE2") configuration({"Release*", "codeblocks or codelite or gmake or xcode3 or xcode4"}) @@ -243,6 +242,9 @@ function NazaraBuild:Execute() configuration("DebugDynamic") targetsuffix("-d") + configuration("Release*") + rtti(moduleTable.EnableRTTI and "On" or "Off") + configuration({}) files(moduleTable.Files) @@ -361,6 +363,9 @@ function NazaraBuild:Execute() configuration("*Static") defines("NAZARA_STATIC") + configuration("Release*") + rtti(toolTable.EnableRTTI and "On" or "Off") + if (toolTable.Kind == "library" or toolTable.Kind == "plugin") then configuration("*Static") kind("StaticLib") diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index 5dcf6e215..f58b0eee0 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -2,6 +2,7 @@ TOOL.Name = "UnitTests" TOOL.Directory = "../tests" TOOL.EnableConsole = true +TOOL.EnableRTTI = true TOOL.Kind = "Application" TOOL.TargetDirectory = TOOL.Directory From 7849eaf80f2c99bba3f69f952baf9713bade28d6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 28 Sep 2016 17:51:26 +0200 Subject: [PATCH 326/383] Build: Fix package on Linux/OS X Former-commit-id: af859279daff0a3277885a129dbe0a3b64b670ee [formerly 9b5c746de0092b15a3a6b22e7b62c0d786511f74] [formerly c0deb3f2282e65eced2a847bfe96fade40000e0d [formerly 778655003cf7af0d129e08cf1241c0e7062cbc02]] Former-commit-id: 1c43974f748ac73fb001ed826e33e6d65fa6be5a [formerly 860aaa09c8659b40712ecfbde1503098cb18d26f] Former-commit-id: e13892bcca0dac59917554a6236ff53015c7cb2c --- build/scripts/actions/package.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index b62ca3643..8a08b3125 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -124,7 +124,7 @@ ACTION.Function = function () -- Demo executable (OS X) table.insert(copyTargets, { Masks = {"Demo*"}, - Filter = function (path) return path.getextension(path) == "" end, + Filter = function (filePath) return path.getextension(filePath) == "" end, Source = "../examples/bin/", Target = "examples/bin/" }) @@ -132,7 +132,7 @@ ACTION.Function = function () -- Unit test (OS X) table.insert(copyTargets, { Masks = {"*.*"}, - Filter = function (path) return path.getextension(path) == "" end, + Filter = function (filePath) return path.getextension(filePath) == "" end, Source = "../tests/", Target = "tests/" }) @@ -162,7 +162,7 @@ ACTION.Function = function () -- Demo executable (Linux) table.insert(copyTargets, { Masks = {"Demo*"}, - Filter = function (path) return path.getextension(path) == "" end, + Filter = function (filePath) return path.getextension(filePath) == "" end, Source = "../examples/bin/", Target = "examples/bin/" }) @@ -170,7 +170,7 @@ ACTION.Function = function () -- Unit test (Linux) table.insert(copyTargets, { Masks = {"*.*"}, - Filter = function (path) return path.getextension(path) == "" end, + Filter = function (filePath) return path.getextension(filePath) == "" end, Source = "../tests/", Target = "tests/" }) @@ -191,7 +191,7 @@ ACTION.Function = function () local files = os.matchfiles(includePrefix .. mask) if (v.Filter) then for k,path in pairs(files) do - if (not v.Filter(v)) then + if (not v.Filter(path)) then files[k] = nil end end @@ -213,7 +213,14 @@ ACTION.Function = function () end end - local ok, err = os.copyfile(v, targetPath) + local ok, err + if (os.is("windows")) then + ok, err = os.copyfile(v, targetPath) + else + -- Workaround: As premake is translating this to "cp %s %s", it fails if there are space in the paths. + ok, err = os.copyfile(string.format("\"%s\"", v), string.format("\"%s\"", targetPath)) + end + if (not ok) then print("Failed to copy \"" .. v .. "\" to \"" .. targetPath .. "\": " .. err) end From 557aaf3141ed0caa311bf047e2228ebf41b4eafd Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 12:31:49 +0200 Subject: [PATCH 327/383] Enable artifacts with Appveyor Former-commit-id: 5029365ebd21a0449a507beba1a71720fd28ca39 [formerly 799e7d640cd9bfb440e985222b6526c7617f4ae1] [formerly 91f8b637e6b00f6fc536143fa9815a4c9f5bb007 [formerly 39dd7651f8e03f173cdedc5d86df30175c136fc5]] Former-commit-id: 70f3c50046f2674217876f3a069216c10621df72 [formerly 8279b3586b0300b35ae2b7f33128791d69e74a5e] Former-commit-id: bb5af3ca88896f507b863fc493861ea377730c14 --- appveyor.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7688cff07..77edb7377 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,4 +20,12 @@ build: project: build/$(TOOLSET)/NazaraEngine.sln #after_build: -# - cd tests && "./NazaraUnitTests" \ No newline at end of file +# - cd tests && "./NazaraUnitTests" + +after_build: + - cd build && "./premake5.exe" package && cd .. + - 7z a NazaraEngine.7z package\* + +artifacts: + - path: NazaraEngine.7z + name: NazaraEngine From 1ef989871ff8325244830e82a3a72938c2fcc4c3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 13:52:26 +0200 Subject: [PATCH 329/383] Build/Package: Don't package common binaries for not exported binaries Former-commit-id: fb577c02a91d8f016de017390641c0c1e26a5b58 [formerly 8dacd7053117130c72a8eefe98fd617f7193d186] [formerly daf3ea264c0aa476d57130698a35459685cecc4f [formerly d3153049d084af9680181933e3506202061ad98e]] Former-commit-id: da7db81a78c07c060f16ec6cd51fb29137b2efc1 [formerly 215261f061170f3dcb09a843f64fd79d124e316b] Former-commit-id: 69c613201f4d648d0c1f029f0303b23c1715c360 --- build/scripts/actions/package.lua | 99 ++++++++++++++----------------- 1 file changed, 45 insertions(+), 54 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index 8a08b3125..da62d7a71 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -26,6 +26,21 @@ ACTION.Function = function () error(string.format("\"%s\" doesn't seem to be an existing directory", libDir)) end + local archEnabled = { + ["x64"] = false, + ["x86"] = false + } + + for k,v in pairs(os.matchdirs(libDir .. "*")) do + local arch = path.getname(v) + if (archEnabled[arch] ~= nil) then + archEnabled[arch] = true + print(arch .. " arch found") + else + print("Unknown directory " .. v .. " found, ignored") + end + end + local packageDir = "../package/" local copyTargets = { @@ -63,28 +78,48 @@ ACTION.Function = function () } } - if (os.is("windows")) then + local binFileMasks + local libFileMasks + if (os.is("windows")) then + binFileMasks = {"**.dll"} + libFileMasks = {"**.lib", "**.a"} + elseif (os.is("macosx")) then + binFileMasks = {"**.dynlib"} + libFileMasks = {"**.a"} + else + binFileMasks = {"**.so"} + libFileMasks = {"**.a"} + end + + for arch, enabled in pairs(archEnabled) do + local archLibSrc = libDir .. arch .. "/" + local arch3rdPartyBinSrc = "../extlibs/lib/common/" .. arch .. "/" + local archBinDst = "bin/" .. arch .. "/" + local archLibDst = "lib/" .. arch .. "/" + -- Engine/SDK binaries table.insert(copyTargets, { - Masks = {"**.dll"}, - Source = libDir, - Target = "bin/" + Masks = binFileMasks, + Source = archLibSrc, + Target = archBinDst }) -- Engine/SDK libraries table.insert(copyTargets, { - Masks = {"**.lib"}, - Source = libDir, - Target = "lib/" + Masks = libFileMasks, + Source = archLibSrc, + Target = archLibDst }) -- 3rd party binary dep table.insert(copyTargets, { - Masks = {"**.dll"}, - Source = "../extlibs/lib/common/", - Target = "bin/" + Masks = binFileMasks, + Source = arch3rdPartyBinSrc, + Target = archBinDst }) + end + if (os.is("windows")) then -- Demo executable (Windows) table.insert(copyTargets, { Masks = {"Demo*.exe"}, @@ -98,29 +133,7 @@ ACTION.Function = function () Source = "../tests/", Target = "tests/" }) - elseif (os.is("macosx")) then - -- Engine/SDK binaries - table.insert(copyTargets, { - Masks = {"**.dynlib"}, - Source = libDir, - Target = "bin/" - }) - - -- Engine/SDK libraries - table.insert(copyTargets, { - Masks = {"**.a"}, - Source = libDir, - Target = "lib/" - }) - - -- 3rd party binary dep - table.insert(copyTargets, { - Masks = {"**.dynlib"}, - Source = "../extlibs/lib/common/", - Target = "bin/" - }) - -- Demo executable (OS X) table.insert(copyTargets, { Masks = {"Demo*"}, @@ -136,29 +149,7 @@ ACTION.Function = function () Source = "../tests/", Target = "tests/" }) - else - -- Engine/SDK binaries - table.insert(copyTargets, { - Masks = {"**.so"}, - Source = libDir, - Target = "bin/" - }) - - -- Engine/SDK libraries - table.insert(copyTargets, { - Masks = {"**.a"}, - Source = libDir, - Target = "lib/" - }) - - -- 3rd party binary dep - table.insert(copyTargets, { - Masks = {"**.so"}, - Source = "../extlibs/lib/common/", - Target = "bin/" - }) - -- Demo executable (Linux) table.insert(copyTargets, { Masks = {"Demo*"}, From cff7cf418d60a892411cc0c641428465125378db Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 14:03:56 +0200 Subject: [PATCH 330/383] AppVeyor: Enable x64 building Former-commit-id: 936831f0bac5a35695b8624232525d5fa9fea559 [formerly 4912d345b3d4fd67b0ef77684ecae6196f4495bb] [formerly abb747336abe106531946137f69c00c5dd7fed5b [formerly 7cccece4e1b0e9ebe351b3e4e638a1c5ca963351]] Former-commit-id: 5cecb06d2ca88b5273ecce8b3ed5174286fe6df5 [formerly 2b01720f9d6d08a72b11ee68eb902abab5bffaac] Former-commit-id: 06e8c2760b10181a63d19023cebafb3c18bf19de --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 77edb7377..321d2815b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,6 +16,10 @@ configuration: - DebugDynamic - ReleaseDynamic +platform: + - x86 + - x64 + build: project: build/$(TOOLSET)/NazaraEngine.sln From d2a7ac71aca20fe8196f2f86b81391ba40d7fd30 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 16:35:24 +0200 Subject: [PATCH 331/383] Build/Package: Oops Former-commit-id: 1473f3048ba321f5affa32c343b93f9d78ee2494 [formerly f6177c96cd49eebd8be2ea07fd3452b969e8e4fd] [formerly 31c4189bf4b58611ddfe25b8417b3ddd34f8b000 [formerly 114d8b74583d719ce8f43af3d4d8f3afcef99520]] Former-commit-id: 7ec4eda49acc8e8cd4db28a09eff3a76cd75e5fd [formerly fdf8613068f8272875d060261ac31403a17a7130] Former-commit-id: 579005e0c362929583eb81a68d12359f53f980f3 --- build/scripts/actions/package.lua | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index da62d7a71..632462769 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -92,31 +92,33 @@ ACTION.Function = function () end for arch, enabled in pairs(archEnabled) do - local archLibSrc = libDir .. arch .. "/" - local arch3rdPartyBinSrc = "../extlibs/lib/common/" .. arch .. "/" - local archBinDst = "bin/" .. arch .. "/" - local archLibDst = "lib/" .. arch .. "/" + if (enabled) then + local archLibSrc = libDir .. arch .. "/" + local arch3rdPartyBinSrc = "../extlibs/lib/common/" .. arch .. "/" + local archBinDst = "bin/" .. arch .. "/" + local archLibDst = "lib/" .. arch .. "/" + + -- Engine/SDK binaries + table.insert(copyTargets, { + Masks = binFileMasks, + Source = archLibSrc, + Target = archBinDst + }) - -- Engine/SDK binaries - table.insert(copyTargets, { - Masks = binFileMasks, - Source = archLibSrc, - Target = archBinDst - }) - - -- Engine/SDK libraries - table.insert(copyTargets, { - Masks = libFileMasks, - Source = archLibSrc, - Target = archLibDst - }) + -- Engine/SDK libraries + table.insert(copyTargets, { + Masks = libFileMasks, + Source = archLibSrc, + Target = archLibDst + }) - -- 3rd party binary dep - table.insert(copyTargets, { - Masks = binFileMasks, - Source = arch3rdPartyBinSrc, - Target = archBinDst - }) + -- 3rd party binary dep + table.insert(copyTargets, { + Masks = binFileMasks, + Source = arch3rdPartyBinSrc, + Target = archBinDst + }) + end end if (os.is("windows")) then From 2669e9a0e442be335971a50d20e1f21af82d402d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 16:35:42 +0200 Subject: [PATCH 332/383] AppVeyor: Fix x86 compilation Former-commit-id: 303257e1e8ec59dcf5a6de61313c4ee3ba2148c9 [formerly 10d464a82c3d2aa49bf8b850886006ca7464cc86] [formerly 0357f2a49941dab5ba26016cc357e3a307da4dc3 [formerly 469432b0d89a19be3340cfa1e7ca5d80a01318d6]] Former-commit-id: c61db527aeae4b8ad776c42bdea68d5ee4e913fc [formerly 786efeb2b0107cbbd1b65267440abb84084ea1f9] Former-commit-id: 2418137eb0a6c54f37e1fc39d28d699a98557a9f --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 321d2815b..021b56987 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ configuration: - ReleaseDynamic platform: - - x86 + - x32 - x64 build: From 1dd14ec9dba1b4f484a7a48d6782961bb5eadaaf Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 16:36:06 +0200 Subject: [PATCH 333/383] AppVeyor: Add configuration, platform and sha to the artifact name Former-commit-id: b6136dd88307923c48340e77183191b249479637 [formerly 431bbe46e8bbcfe4d03baf53ae6bd3f1fe945490] [formerly 47abf7682120209cef37d72192d29318fcf192b8 [formerly 4137f444cef112d25029537130cc9437a296906e]] Former-commit-id: d5801daf3ae88a6f3701cc7c25497682f62c250f [formerly 87a5aaaae841b3dc42d30128c2f92f33c604c889] Former-commit-id: f2eb4ea36c3bbcf11c35fad4a7f1067a27c46105 --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 021b56987..273e5e6ae 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,5 +31,5 @@ after_build: - 7z a NazaraEngine.7z package\* artifacts: - - path: NazaraEngine.7z - name: NazaraEngine + - path: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z' + name: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT)' From 659b7df1586c9ca3fff6d973b2ffb4a3da64f66b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 16:56:42 +0200 Subject: [PATCH 334/383] Fix Appveyor.yml Former-commit-id: d7892d13742895e29456be7d342de2e7475bc541 [formerly c2123070cfa4afcf93d7199364d871a276fe0903] [formerly 4ad9b9627fcdf18a7aeb7c31f49a61bb94e18b53 [formerly fbbd92794222e48eeeb31917effdaf7b001fae82]] Former-commit-id: 94827be316237e6337007b3b37726159acd8728a [formerly 7f9cd12de6f5261cdb3813506930f0558eafb29e] Former-commit-id: 05f51ea218d683df9a8c930b203b012ad56454e7 --- appveyor.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 273e5e6ae..e21edb10e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,19 +17,20 @@ configuration: - ReleaseDynamic platform: - - x32 + - Win32 - x64 build: + parallel: true project: build/$(TOOLSET)/NazaraEngine.sln #after_build: # - cd tests && "./NazaraUnitTests" after_build: - - cd build && "./premake5.exe" package && cd .. - - 7z a NazaraEngine.7z package\* + - cd build && "./premake5.exe" package && cd ../package + - 7z a NazaraEngine.7z * artifacts: - - path: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z' + - path: package/NazaraEngine.7z name: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT)' From 379d985994438e05fdfb6cb902d9a231e492426a Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 17:07:07 +0200 Subject: [PATCH 335/383] Appveyor: Disable parallel build and try to fix artifact name Former-commit-id: 5716780bd52ad831ab69b3fcea5a71920dd59664 [formerly 79fb5ec5af8b1ef022c1d6b27de26ddb5b0b1e7e] [formerly 03ae2087376e2a98ce2304ff2563125b55bee5b4 [formerly 0bd9976a5849649dade39470314b06206a087a4b]] Former-commit-id: 3c82c3b6d18cc9d4c212195c2c43a86379366dc9 [formerly 2af5d6582d8ef9583b71a47b97f85740a6c66d70] Former-commit-id: f6aa9388ec3a1875ee2b47508ca9c26d93e04932 --- appveyor.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index e21edb10e..ee297487d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,7 +21,6 @@ platform: - x64 build: - parallel: true project: build/$(TOOLSET)/NazaraEngine.sln #after_build: @@ -29,8 +28,8 @@ build: after_build: - cd build && "./premake5.exe" package && cd ../package - - 7z a NazaraEngine.7z * + - 7z a 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z' * artifacts: - - path: package/NazaraEngine.7z - name: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT)' + - path: package/NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z + name: NazaraEngine From 3ba86d0caaee2eba5e6a00fc806250d8c5b834c4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 17:19:54 +0200 Subject: [PATCH 336/383] Appveyor: Damnit Former-commit-id: 3d4db806d140bc0efb51909b79773b8d48739a70 [formerly 35c9f35e88819e44b04b02f4de0f001cc8a222d8] [formerly e85c4e641b0699ea1e2ad82d84d37c3da0de338c [formerly 6f2f5e6244623752115ddf5f323f342a13691201]] Former-commit-id: b3340f769792206e17f7d47910d97b95b389e6c2 [formerly ed237750d552d5f89a97c510ff32f31a5048d730] Former-commit-id: ef426aabcc13c4af5453e445caf40bf28269822b --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ee297487d..e117089c6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,7 +28,7 @@ build: after_build: - cd build && "./premake5.exe" package && cd ../package - - 7z a 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z' * + - 7z a 'NazaraEngine-%CONFIGURATION%-%PLATFORM%-%APPVEYOR_REPO_COMMIT%.7z' * artifacts: - path: package/NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z From 59788a6aab097a5e1265cb2feebf7e91cbab7ac7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 18:00:05 +0200 Subject: [PATCH 337/383] Build/Package: Improve printing Former-commit-id: c0b3bb1c20ed6b0fdcac34bd35e0c9fea6e5a46c [formerly 918686c05b0ac0cacbcd029a8ba95d1250dab731] [formerly fb1bdc4ec327c2b6588cb5fe4977a4fa23728a72 [formerly 9b359f94196467899e015de6107d2dd44c7037c1]] Former-commit-id: a0d6e9386e7970e160655bd1da7e7594754a1635 [formerly f63b6d2e66666389f5fa1c595d5229bcd068b1b4] Former-commit-id: ba34434a83785d2879a365ac324e3230bedec4ac --- build/scripts/actions/package.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index 632462769..6c4f1e677 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -15,15 +15,14 @@ ACTION.Function = function () elseif (#libDirs == 0) then error("No subdirectory was found in the lib directory, have you built the engine yet?") else - libDir = libDirs[1] .. "/" + libDir = path.getname(libDirs[1]) print("No directory was set by the --pack-libdir command, \"" .. libDir .. "\" will be used") end - else - libDir = "../lib/" .. libDir .. "/" end - if (not os.isdir(libDir)) then - error(string.format("\"%s\" doesn't seem to be an existing directory", libDir)) + local realLibDir = "../lib/" .. libDir .. "/" + if (not os.isdir(realLibDir)) then + error(string.format("\"%s\" doesn't seem to be an existing directory", realLibDir)) end local archEnabled = { @@ -31,7 +30,7 @@ ACTION.Function = function () ["x86"] = false } - for k,v in pairs(os.matchdirs(libDir .. "*")) do + for k,v in pairs(os.matchdirs(realLibDir .. "*")) do local arch = path.getname(v) if (archEnabled[arch] ~= nil) then archEnabled[arch] = true @@ -90,10 +89,11 @@ ACTION.Function = function () binFileMasks = {"**.so"} libFileMasks = {"**.a"} end - + + local enabledArchs = {} for arch, enabled in pairs(archEnabled) do if (enabled) then - local archLibSrc = libDir .. arch .. "/" + local archLibSrc = realLibDir .. arch .. "/" local arch3rdPartyBinSrc = "../extlibs/lib/common/" .. arch .. "/" local archBinDst = "bin/" .. arch .. "/" local archLibDst = "lib/" .. arch .. "/" @@ -118,6 +118,8 @@ ACTION.Function = function () Source = arch3rdPartyBinSrc, Target = archBinDst }) + + table.insert(enabledArchs, arch) end end @@ -225,5 +227,6 @@ ACTION.Function = function () end end - print(string.format("Package successfully created at \"%s\" (%u MB, %s)", packageDir, size / (1024 * 1024), libDir)) + local config = libDir .. " - " .. table.concat(enabledArchs, ", ") + print(string.format("Package successfully created at \"%s\" (%u MB, %s)", packageDir, size / (1024 * 1024), config)) end From b029cac3abc75b7b617385599be63974aee9def5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 18:00:13 +0200 Subject: [PATCH 338/383] Try to fix appveyor Former-commit-id: 3ec8b9f0a9dd2db8ee42630b21da75ff3a6b0b0b [formerly f7e7914949a840af474708ee488d885abfd8da7b] [formerly a4ad82b3a5241d94f83623966c5ab9a4a2003842 [formerly 695dea61d4ba1a42a3be0df482c41df080968da3]] Former-commit-id: 40cb0628dc13af904ac6c46361833cf30b55bb99 [formerly c7edbac30d37561c46fc84eb755c117ab30aa5fa] Former-commit-id: af93389c1a2c82385a0937babbb5e4e4285d7451 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index e117089c6..6b918dace 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,5 +31,5 @@ after_build: - 7z a 'NazaraEngine-%CONFIGURATION%-%PLATFORM%-%APPVEYOR_REPO_COMMIT%.7z' * artifacts: - - path: package/NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z + - path: NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z name: NazaraEngine From d88ddf71935ca73cfda3a0010c1e3df520bae47c Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 18:20:12 +0200 Subject: [PATCH 339/383] Fu. Former-commit-id: b6798a519689acd016112db9c2c0c92dba6b1847 [formerly 3a4394c0dbdc68470fbb06ce88cf5165e4d0de9d] [formerly 9b5c8e61f799a5f6df01f08eb69f8a6f3ccef48f [formerly 4db67fbbb4b301e12bc208d4f6714c6dc10e9f4b]] Former-commit-id: 5edc2f60b9efa2c472b9d92af0bfeb09e9202723 [formerly 52c6254586286ac5eaa64b0fd4ff8da62673c6c0] Former-commit-id: 5e255061d6d8a4b0dae764055e6ee59df8890acb --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6b918dace..2ad35736f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,8 +27,8 @@ build: # - cd tests && "./NazaraUnitTests" after_build: - - cd build && "./premake5.exe" package && cd ../package - - 7z a 'NazaraEngine-%CONFIGURATION%-%PLATFORM%-%APPVEYOR_REPO_COMMIT%.7z' * + - cd build && "./premake5.exe" package && cd .. + - 7z a 'NazaraEngine-%CONFIGURATION%-%PLATFORM%-%APPVEYOR_REPO_COMMIT%.7z' package/* artifacts: - path: NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z From 7113a79fc103cc9e1a60512e311eb99656b5309f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 29 Sep 2016 18:29:40 +0200 Subject: [PATCH 340/383] Revert to a working state Former-commit-id: fd3f668245f3c66a628e94181610c7a178737282 [formerly 3ff8141666b3d6f9ea3f6969134513c0f6759de7] [formerly 13ed9a7bf8df2541b70fd47c3938f0cc0650bfd4 [formerly 23e1af3685ea2a62050d2f1971af48437c6cfecf]] Former-commit-id: 185382aee986817032ff0cfc5fee4f8a6228e4a1 [formerly bc99148544c04c52635cfac73ed9d0c15f8f81c6] Former-commit-id: eb289943f34501e896f1e7a4561a65965b600dd0 --- appveyor.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2ad35736f..86eb0a5ad 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -27,9 +27,9 @@ build: # - cd tests && "./NazaraUnitTests" after_build: - - cd build && "./premake5.exe" package && cd .. - - 7z a 'NazaraEngine-%CONFIGURATION%-%PLATFORM%-%APPVEYOR_REPO_COMMIT%.7z' package/* + - cd build && "./premake5.exe" package && cd ../package + - 7z a NazaraEngine.7z * artifacts: - - path: NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT).7z - name: NazaraEngine + - path: package/NazaraEngine.7z + name: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT)' From 2f527091d572a80c755e291e74bba1e86c4a32b6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 30 Sep 2016 14:00:08 +0200 Subject: [PATCH 341/383] Travis: Compile debug and release Former-commit-id: 58c4511e7638f3a9000e34bd186b782733345419 [formerly 2d743d70057cc45d393da47b945b21d8c077e00c] [formerly c110a9ae6db899fcb1452d11d2a927f78321486a [formerly b682c4b65f19ef8aabe7eea9788a60780c56ff0a]] Former-commit-id: e22048857cb83f8dc2474916274999a2d8c410fa [formerly 176d10d1c214761d7823fdc768395b49f1233a7d] Former-commit-id: 21e8e802f0fa2c9858650792e605c72c4dc5ed0e --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dc4f5e225..c4a13c36d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,10 @@ sudo: notifications: email: true +env: + - CONFIG=debug + - CONFIG=release + services: - docker @@ -19,7 +23,7 @@ script: cd build && ./premake5-linux64 --with-examples gmake && cd gmake && - make -j4 -f NazaraEngine.make + make -j4 -f NazaraEngine.make config=$(CONFIG)dynamic_x64 " #after_script: From 3461eb49ca6febd8224118a7e53db85b8fba2929 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 30 Sep 2016 14:15:19 +0200 Subject: [PATCH 342/383] Disable RTTI everywhere and fix Linux compilation Former-commit-id: c8c0f11725d2e5b6c6da6dc3ab11f0eda065094f [formerly c2977e388c70ba7ccdf52f9eb97d7fe71ed6f4cf] [formerly 73c0d0759a6c9cad05dff59bff486f99fde336b6 [formerly 96a6e52ba5c97fd3a107fed5d11738466bd53f7e]] Former-commit-id: c6a193ee5ccb07a40a74719937dbf224ad22081e [formerly 5f275dc02a44bd2ee54f6d926338ddfe388f565b] Former-commit-id: e35640a20ac2269f96b75998e56fcba2fdbf6f00 --- build/scripts/common.lua | 3 +++ build/scripts/tools/unittests.lua | 1 - tests/SDK/NDK/Component.cpp | 16 ++++++++++++++-- tests/SDK/NDK/System.cpp | 14 +++++++++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index b134bf4e3..30272acfd 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -439,6 +439,9 @@ function NazaraBuild:Execute() includedirs(exampleTable.Includes) links(exampleTable.Libraries) + configuration("Release*") + rtti(exampleTable.EnableRTTI and "On" or "Off") + configuration("x32") libdirs(exampleTable.LibraryPaths.x86) diff --git a/build/scripts/tools/unittests.lua b/build/scripts/tools/unittests.lua index f58b0eee0..5dcf6e215 100644 --- a/build/scripts/tools/unittests.lua +++ b/build/scripts/tools/unittests.lua @@ -2,7 +2,6 @@ TOOL.Name = "UnitTests" TOOL.Directory = "../tests" TOOL.EnableConsole = true -TOOL.EnableRTTI = true TOOL.Kind = "Application" TOOL.TargetDirectory = TOOL.Directory diff --git a/tests/SDK/NDK/Component.cpp b/tests/SDK/NDK/Component.cpp index f00bb9006..c41f541be 100644 --- a/tests/SDK/NDK/Component.cpp +++ b/tests/SDK/NDK/Component.cpp @@ -6,6 +6,18 @@ namespace class TestComponent : public Ndk::Component { public: + TestComponent(int value) : + m_value(value) + { + } + + int GetValue() const + { + return m_value; + } + + int m_value; + static Ndk::ComponentIndex componentIndex; }; @@ -16,7 +28,7 @@ SCENARIO("Component", "[NDK][COMPONENT]") { GIVEN("Our TestComponent") { - TestComponent testComponent; + TestComponent testComponent(42); WHEN("We clone it") { @@ -24,7 +36,7 @@ SCENARIO("Component", "[NDK][COMPONENT]") THEN("We should get a copy") { - REQUIRE(dynamic_cast(clone.get()) != nullptr); + REQUIRE(static_cast(clone.get())->GetValue() == 42); } } } diff --git a/tests/SDK/NDK/System.cpp b/tests/SDK/NDK/System.cpp index ca1917124..2948185ae 100644 --- a/tests/SDK/NDK/System.cpp +++ b/tests/SDK/NDK/System.cpp @@ -6,15 +6,23 @@ namespace class TestSystem : public Ndk::System { public: - TestSystem() + TestSystem(int value) : + m_value(value) { } + int GetValue() const + { + return m_value; + } + ~TestSystem() = default; static Ndk::SystemIndex systemIndex; private: + int m_value; + void OnUpdate(float elapsedTime) override { } @@ -27,7 +35,7 @@ SCENARIO("System", "[NDK][SYSTEM]") { GIVEN("Our TestSystem") { - TestSystem testSystem; + TestSystem testSystem(666); WHEN("We clone it") { @@ -35,7 +43,7 @@ SCENARIO("System", "[NDK][SYSTEM]") THEN("We should get a copy") { - REQUIRE(dynamic_cast(clone.get()) != nullptr); + REQUIRE(static_cast(clone.get())->GetValue() == 42); } } } From 1555e4ffd935a86a7980f8018a9b5a7075c4f086 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 30 Sep 2016 14:15:26 +0200 Subject: [PATCH 343/383] Travis: Oops Former-commit-id: 6c934c3198074d9fb8c89236bac5b3e5af1e76c4 [formerly 0f8cd8a21c5e6dfdcd29e271c72d1a7b3582ce01] [formerly 7c35f5317edc5043824ffb9f2ba07738ef715852 [formerly c6151478e2f83b454fab711e6ee7a9e9d7c3a33a]] Former-commit-id: aacc7460fccfabe6a846841074cc394eda916ae6 [formerly 3697655b575c0c6e87647b6ef4955aa1e26f475f] Former-commit-id: bfc48cce38d3e5972d696713620d5fd852710cd0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c4a13c36d..0db1ba26a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ script: cd build && ./premake5-linux64 --with-examples gmake && cd gmake && - make -j4 -f NazaraEngine.make config=$(CONFIG)dynamic_x64 + make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 " #after_script: From 30e07ea2e21bf72c1e405a3381969fe9027c68fd Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 3 Oct 2016 19:05:50 +0200 Subject: [PATCH 344/383] Core: Rewrite CPUID to preserve EBX register (Fix #73) Former-commit-id: 19651c4e8856df2e6a9a208b5dfab1dfdde80978 [formerly d7392176b9b510939aeefaf5c853d023af211379] [formerly 36c14e52fae5966508143704557610247aaf2e22 [formerly 1901b3100ddc4621685375de77dfb7863687d1b4]] Former-commit-id: 53af7fc2cb9ee97f16cc03db53658385dc218b71 [formerly d43f598f33684430ab3a58db1533cb108be6e26a] Former-commit-id: 5d88e9b7ef4bc7e05060ac06678d6c141d9a88a4 --- src/Nazara/Core/Posix/HardwareInfoImpl.cpp | 24 ++++++++++++++++------ src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 24 ++++++++++++++++------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/Nazara/Core/Posix/HardwareInfoImpl.cpp b/src/Nazara/Core/Posix/HardwareInfoImpl.cpp index 0058832a8..20ea4950f 100644 --- a/src/Nazara/Core/Posix/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Posix/HardwareInfoImpl.cpp @@ -11,10 +11,22 @@ namespace Nz void HardwareInfoImpl::Cpuid(UInt32 functionId, UInt32 subFunctionId, UInt32 registers[4]) { #if defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) - // Source: http://stackoverflow.com/questions/1666093/cpuid-implementations-in-c - asm volatile ("cpuid" // Besoin d'être volatile ? - : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]) // output - : "a" (functionId), "c" (subFunctionId)); // input + // https://en.wikipedia.org/wiki/CPUID + asm volatile( + #ifdef NAZARA_PLATFORM_x64 + "pushq %%rbx \n\t" // save %rbx + #else + "pushl %%ebx \n\t" // save %ebx + #endif + "cpuid \n\t" + "movl %%ebx ,%[ebx] \n\t" // write the result into output var + #ifdef NAZARA_PLATFORM_x64 + "popq %%rbx \n\t" + #else + "popl %%ebx \n\t" + #endif + : "=a"(registers[0]), [ebx] "=r"(registers[1]), "=c"(registers[2]), "=d"(registers[3]) + : "a"(functionId), "c" (subFunctionId)); #else NazaraInternalError("Cpuid has been called although it is not supported"); #endif @@ -22,7 +34,7 @@ namespace Nz unsigned int HardwareInfoImpl::GetProcessorCount() { - // Plus simple (et plus portable) que de passer par le CPUID + // Simpler (and more portable) than using CPUID return sysconf(_SC_NPROCESSORS_CONF); } @@ -37,7 +49,7 @@ namespace Nz bool HardwareInfoImpl::IsCpuidSupported() { #ifdef NAZARA_PLATFORM_x64 - return true; // Toujours supporté sur un processeur 64 bits + return true; // cpuid is always supported on x64 arch #else #if defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) int supported; diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index 62b86bf91..542c58d79 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -22,10 +22,22 @@ namespace Nz // Visual propose une fonction intrinsèque pour le cpuid __cpuidex(reinterpret_cast(registers), static_cast(functionId), static_cast(subFunctionId)); #elif defined(NAZARA_COMPILER_CLANG) || defined(NAZARA_COMPILER_GCC) || defined(NAZARA_COMPILER_INTEL) - // Source: http://stackoverflow.com/questions/1666093/cpuid-implementations-in-c - asm volatile ("cpuid" // Besoin d'être volatile ? - : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]) // output - : "a" (functionId), "c" (subFunctionId)); // input + // https://en.wikipedia.org/wiki/CPUID + asm volatile( + #ifdef NAZARA_PLATFORM_x64 + "pushq %%rbx \n\t" // save %rbx + #else + "pushl %%ebx \n\t" // save %ebx + #endif + "cpuid \n\t" + "movl %%ebx ,%[ebx] \n\t" // write the result into output var + #ifdef NAZARA_PLATFORM_x64 + "popq %%rbx \n\t" + #else + "popl %%ebx \n\t" + #endif + : "=a"(registers[0]), [ebx] "=r"(registers[1]), "=c"(registers[2]), "=d"(registers[3]) // output + : "a"(functionId), "c" (subFunctionId)); // input #else NazaraInternalError("Cpuid has been called although it is not supported"); #endif @@ -33,7 +45,7 @@ namespace Nz unsigned int HardwareInfoImpl::GetProcessorCount() { - // Plus simple (et plus portable) que de passer par le CPUID + // Simpler (and more portable) than using CPUID SYSTEM_INFO infos; GetNativeSystemInfo(&infos); @@ -52,7 +64,7 @@ namespace Nz bool HardwareInfoImpl::IsCpuidSupported() { #ifdef NAZARA_PLATFORM_x64 - return true; // Toujours supporté sur un processeur 64 bits + return true; // cpuid is always supported on x64 arch #else #if defined(NAZARA_COMPILER_MSVC) int supported; From d7b7135e27e521586b7d0a3fd8cb31dfcf278f8f Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 3 Oct 2016 19:49:43 +0200 Subject: [PATCH 345/383] Lua/LuaClass: Fix argument count via GetStackTop (Close #75) Former-commit-id: 3a0e60a6e7ec7c85ff5f179cc84a468d8c0682f4 [formerly f0712658e69c7ced1fa46f8878f96776d6b36567] [formerly 3035b072473d17863c3c0f6950451ccf582c107e [formerly fe3cbf8a2cf87cf6cc3d3e8577011159bff04387]] Former-commit-id: df8812d712d28efc2bc83258df53dcb21bbb4b2d [formerly 6d2d8773c96d406690bd5cfc19cef7d1706ff6fc] Former-commit-id: 461fec0cc2dd99690a3de10436730514712beb73 --- SDK/src/NDK/LuaBinding_Audio.cpp | 3 ++- SDK/src/NDK/LuaBinding_Core.cpp | 10 ++++----- SDK/src/NDK/LuaBinding_Graphics.cpp | 4 +++- SDK/src/NDK/LuaBinding_Math.cpp | 32 ++++++++++++++++++----------- SDK/src/NDK/LuaBinding_Network.cpp | 4 ++-- SDK/src/NDK/LuaBinding_Utility.cpp | 4 +++- include/Nazara/Lua/LuaClass.hpp | 2 +- include/Nazara/Lua/LuaClass.inl | 7 +++++-- 8 files changed, 41 insertions(+), 25 deletions(-) diff --git a/SDK/src/NDK/LuaBinding_Audio.cpp b/SDK/src/NDK/LuaBinding_Audio.cpp index b825b1876..ed1538a78 100644 --- a/SDK/src/NDK/LuaBinding_Audio.cpp +++ b/SDK/src/NDK/LuaBinding_Audio.cpp @@ -78,9 +78,10 @@ namespace Ndk }); /*********************************** Nz::SoundBuffer **********************************/ - soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance) + soundBuffer.SetConstructor([] (Nz::LuaInstance& lua, Nz::SoundBufferRef* instance, std::size_t argumentCount) { NazaraUnused(lua); + NazaraUnused(argumentCount); Nz::PlacementNew(instance, Nz::SoundBuffer::New()); return true; diff --git a/SDK/src/NDK/LuaBinding_Core.cpp b/SDK/src/NDK/LuaBinding_Core.cpp index 78c73eea1..d111a0266 100644 --- a/SDK/src/NDK/LuaBinding_Core.cpp +++ b/SDK/src/NDK/LuaBinding_Core.cpp @@ -13,7 +13,7 @@ namespace Ndk void LuaBinding::BindCore() { /*********************************** Nz::Clock **********************************/ - clockClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock) + clockClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Clock* clock, std::size_t argumentCount) { int argIndex = 1; Nz::Int64 startingValue = lua.Check(&argIndex, 0); @@ -44,9 +44,9 @@ namespace Ndk }); /********************************* Nz::Directory ********************************/ - directoryClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* directory) + directoryClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Directory* directory, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 1U); + std::size_t argCount = std::min(argumentCount, 1U); int argIndex = 1; switch (argCount) @@ -138,9 +138,9 @@ namespace Ndk /*********************************** Nz::File ***********************************/ fileClass.Inherit(streamClass); - fileClass.SetConstructor([](Nz::LuaInstance& lua, Nz::File* file) + fileClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::File* file, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 2U); + std::size_t argCount = std::min(argumentCount, 1U); int argIndex = 1; switch (argCount) diff --git a/SDK/src/NDK/LuaBinding_Graphics.cpp b/SDK/src/NDK/LuaBinding_Graphics.cpp index 4c9288428..7505c1d9a 100644 --- a/SDK/src/NDK/LuaBinding_Graphics.cpp +++ b/SDK/src/NDK/LuaBinding_Graphics.cpp @@ -20,8 +20,10 @@ namespace Ndk return reinterpret_cast(model); //TODO: Make a ObjectRefCast }); - modelClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::ModelRef* model) + modelClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::ModelRef* model, std::size_t argumentCount) { + NazaraUnused(argumentCount); + Nz::PlacementNew(model, Nz::Model::New()); return true; }); diff --git a/SDK/src/NDK/LuaBinding_Math.cpp b/SDK/src/NDK/LuaBinding_Math.cpp index 1c53caa69..f65259f50 100644 --- a/SDK/src/NDK/LuaBinding_Math.cpp +++ b/SDK/src/NDK/LuaBinding_Math.cpp @@ -14,9 +14,10 @@ namespace Ndk void LuaBinding::BindMath() { /*********************************** Nz::EulerAngles **********************************/ - eulerAnglesClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* angles) + eulerAnglesClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::EulerAnglesd* angles, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 3U); + std::size_t argCount = std::min(argumentCount, 1U); + switch (argCount) { case 0: @@ -154,9 +155,10 @@ namespace Ndk }); /*********************************** Nz::Rect **********************************/ - rectClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect) + rectClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Rectd* rect, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 4U); + std::size_t argCount = std::min(argumentCount, 4U); + switch (argCount) { case 0: @@ -309,9 +311,10 @@ namespace Ndk }); /*********************************** Nz::Quaternion **********************************/ - quaternionClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion) + quaternionClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Quaterniond* quaternion, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 4U); + std::size_t argCount = std::min(argumentCount, 4U); + switch (argCount) { case 0: @@ -337,6 +340,9 @@ namespace Ndk case 4: Nz::PlacementNew(quaternion, lua.CheckNumber(1), lua.CheckNumber(2), lua.CheckNumber(3), lua.CheckNumber(4)); return true; + + default: + break; } lua.Error("No matching overload for Quaternion constructor"); @@ -411,9 +417,10 @@ namespace Ndk }); /*********************************** Nz::Vector2 **********************************/ - vector2dClass.SetConstructor([](Nz::LuaInstance& lua, Nz::Vector2d* vector) + vector2dClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector2d* vector, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 2U); + std::size_t argCount = std::min(argumentCount, 2U); + switch (argCount) { case 0: @@ -533,9 +540,10 @@ namespace Ndk }); /*********************************** Nz::Vector3 **********************************/ - vector3dClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector) + vector3dClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::Vector3d* vector, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 3U); + std::size_t argCount = std::min(argumentCount, 3U); + switch (argCount) { case 0: @@ -546,7 +554,7 @@ namespace Ndk case 1: { if (lua.IsOfType(1, Nz::LuaType_Number)) - Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(1, "Vector2"))); + Nz::PlacementNew(vector, lua.CheckNumber(1)); else if (lua.IsOfType(1, "Vector2")) Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1))); else if (lua.IsOfType(1, "Vector3")) @@ -560,7 +568,7 @@ namespace Ndk case 2: { if (lua.IsOfType(1, Nz::LuaType_Number)) - Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(1, "Vector2"))); + Nz::PlacementNew(vector, lua.CheckNumber(1), *static_cast(lua.CheckUserdata(2, "Vector2"))); else if (lua.IsOfType(1, "Vector2")) Nz::PlacementNew(vector, *static_cast(lua.ToUserdata(1)), lua.CheckNumber(2)); else diff --git a/SDK/src/NDK/LuaBinding_Network.cpp b/SDK/src/NDK/LuaBinding_Network.cpp index 67f40cb4d..689fc2d1d 100644 --- a/SDK/src/NDK/LuaBinding_Network.cpp +++ b/SDK/src/NDK/LuaBinding_Network.cpp @@ -21,9 +21,9 @@ namespace Ndk abstractSocketClass.BindMethod("QueryAvailableBytes", &Nz::AbstractSocket::QueryAvailableBytes); /*********************************** Nz::IpAddress **********************************/ - ipAddressClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* address) + ipAddressClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::IpAddress* address, std::size_t argumentCount) { - unsigned int argCount = std::min(lua.GetStackTop(), 9U); + std::size_t argCount = std::min(argumentCount, 9U); int argIndex = 1; switch (argCount) diff --git a/SDK/src/NDK/LuaBinding_Utility.cpp b/SDK/src/NDK/LuaBinding_Utility.cpp index 416662b23..3d8dbdc18 100644 --- a/SDK/src/NDK/LuaBinding_Utility.cpp +++ b/SDK/src/NDK/LuaBinding_Utility.cpp @@ -93,8 +93,10 @@ namespace Ndk }); /*********************************** Nz::Font **********************************/ - fontClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::FontRef* font) + fontClass.SetConstructor([] (Nz::LuaInstance& lua, Nz::FontRef* font, std::size_t argumentCount) { + NazaraUnused(argumentCount); + Nz::PlacementNew(font, Nz::Font::New()); return true; }); diff --git a/include/Nazara/Lua/LuaClass.hpp b/include/Nazara/Lua/LuaClass.hpp index b872ad2f7..567c3de7c 100644 --- a/include/Nazara/Lua/LuaClass.hpp +++ b/include/Nazara/Lua/LuaClass.hpp @@ -28,7 +28,7 @@ namespace Nz public: using ClassFunc = std::function; using ClassIndexFunc = std::function; - using ConstructorFunc = std::function; + using ConstructorFunc = std::function; template using ConvertToParent = std::function; using FinalizerFunc = std::function; using StaticIndexFunc = std::function; diff --git a/include/Nazara/Lua/LuaClass.inl b/include/Nazara/Lua/LuaClass.inl index 89487b653..ea53cf0cd 100644 --- a/include/Nazara/Lua/LuaClass.inl +++ b/include/Nazara/Lua/LuaClass.inl @@ -19,9 +19,10 @@ namespace Nz template inline void LuaClass::BindDefaultConstructor() { - SetConstructor([] (Nz::LuaInstance& lua, T* instance) + SetConstructor([] (Nz::LuaInstance& lua, T* instance, std::size_t argumentCount) { NazaraUnused(lua); + NazaraUnused(argumentCount); PlacementNew(instance); return true; @@ -334,9 +335,11 @@ namespace Nz lua.Remove(1); // On enlève l'argument "table" du stack + std::size_t argCount = lua.GetStackTop(); + T* instance = static_cast(lua.PushUserdata(sizeof(T))); - if (!constructor(lua, instance)) + if (!constructor(lua, instance, argCount)) { lua.Error("Constructor failed"); return 0; // Normalement jamais exécuté (l'erreur provoquant une exception) From e234044290f33bc0632bc0e6ea72d1903ba3edb9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 11:26:45 +0200 Subject: [PATCH 346/383] Build/Package: Fix executable binaries not being packaged under Linux (Close #77) Former-commit-id: 5c885f70af44968f33ee1dbd93646293bcea5d2e [formerly 8edfc3654005393c28e27f8c6cbe427a43152f3f] [formerly b66fb4ef5b275e63c649c336170f22bd3155f67b [formerly ac7655fa1c6e2e4d429dca86c5fd78a499481fd6]] Former-commit-id: 0cf284996de8d81ddec55cbabda9d950d45f4d1b [formerly f11faabb2157f8f546a51ed27484b8d5859fbf7e] Former-commit-id: 2a5c0b57a2451980b89c4dbe36e089dd13fabc3a --- build/scripts/actions/package.lua | 83 +++++++++++-------------------- 1 file changed, 29 insertions(+), 54 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index 6c4f1e677..abdb5a4c7 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -29,16 +29,19 @@ ACTION.Function = function () ["x64"] = false, ["x86"] = false } - + + local enabledArchs = {} for k,v in pairs(os.matchdirs(realLibDir .. "*")) do local arch = path.getname(v) if (archEnabled[arch] ~= nil) then archEnabled[arch] = true - print(arch .. " arch found") + table.insert(enabledArchs, arch) else print("Unknown directory " .. v .. " found, ignored") end end + enabledArchs = table.concat(enabledArchs, ", ") + print(enabledArchs .. " arch found") local packageDir = "../package/" @@ -79,18 +82,25 @@ ACTION.Function = function () local binFileMasks local libFileMasks + local exeFileExt + local exeFilterFunc if (os.is("windows")) then binFileMasks = {"**.dll"} libFileMasks = {"**.lib", "**.a"} + exeFileExt = ".exe" + exeFilterFunc = function (filePath) return true end elseif (os.is("macosx")) then binFileMasks = {"**.dynlib"} libFileMasks = {"**.a"} + exeFileExt = "" + exeFilterFunc = function (filePath) return path.getextension(filePath):contains('/') end else binFileMasks = {"**.so"} libFileMasks = {"**.a"} + exeFileExt = "" + exeFilterFunc = function (filePath) return path.getextension(filePath):contains('/') end end - local enabledArchs = {} for arch, enabled in pairs(archEnabled) do if (enabled) then local archLibSrc = realLibDir .. arch .. "/" @@ -118,59 +128,24 @@ ACTION.Function = function () Source = arch3rdPartyBinSrc, Target = archBinDst }) - - table.insert(enabledArchs, arch) end end - if (os.is("windows")) then - -- Demo executable (Windows) - table.insert(copyTargets, { - Masks = {"Demo*.exe"}, - Source = "../examples/bin/", - Target = "examples/bin/" - }) - - -- Unit test (Windows) - table.insert(copyTargets, { - Masks = {"*.exe"}, - Source = "../tests/", - Target = "tests/" - }) - elseif (os.is("macosx")) then - -- Demo executable (OS X) - table.insert(copyTargets, { - Masks = {"Demo*"}, - Filter = function (filePath) return path.getextension(filePath) == "" end, - Source = "../examples/bin/", - Target = "examples/bin/" - }) + -- Demo executable + table.insert(copyTargets, { + Masks = {"Demo*" .. exeFileExt}, + Filter = exeFilterFunc, + Source = "../examples/bin/", + Target = "examples/bin/" + }) - -- Unit test (OS X) - table.insert(copyTargets, { - Masks = {"*.*"}, - Filter = function (filePath) return path.getextension(filePath) == "" end, - Source = "../tests/", - Target = "tests/" - }) - else - -- Demo executable (Linux) - table.insert(copyTargets, { - Masks = {"Demo*"}, - Filter = function (filePath) return path.getextension(filePath) == "" end, - Source = "../examples/bin/", - Target = "examples/bin/" - }) - - -- Unit test (Linux) - table.insert(copyTargets, { - Masks = {"*.*"}, - Filter = function (filePath) return path.getextension(filePath) == "" end, - Source = "../tests/", - Target = "tests/" - }) - end - + -- Unit test + table.insert(copyTargets, { + Masks = {"*" .. exeFileExt}, + Filter = exeFilterFunc, + Source = "../tests/", + Target = "tests/" + }) -- Processing os.mkdir(packageDir) @@ -212,7 +187,7 @@ ACTION.Function = function () if (os.is("windows")) then ok, err = os.copyfile(v, targetPath) else - -- Workaround: As premake is translating this to "cp %s %s", it fails if there are space in the paths. + -- Workaround: As premake is translating this to "cp %s %s", it fails if space are presents in source/destination paths. ok, err = os.copyfile(string.format("\"%s\"", v), string.format("\"%s\"", targetPath)) end @@ -227,6 +202,6 @@ ACTION.Function = function () end end - local config = libDir .. " - " .. table.concat(enabledArchs, ", ") + local config = libDir .. " - " .. enabledArchs print(string.format("Package successfully created at \"%s\" (%u MB, %s)", packageDir, size / (1024 * 1024), config)) end From e7499e2c331bd2ca4d482e307720286a774fcf37 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 11:27:08 +0200 Subject: [PATCH 347/383] Build/Package: Make bat file pause after packaging Former-commit-id: f0b04a4d41a787a2442da7a35681280814380583 [formerly a0af806e47617ccabacad163e1ad7245c707d5cb] [formerly 4ab2f40cb7904394ddc2466fbd3603ee5d7a55e1 [formerly 0f16c04d796543292c22cf92e9d349c2cf3d38be]] Former-commit-id: f6d5a53a6f5f6a7c583c985411ed48ef06d0c8b6 [formerly 96b7e9e96285bdd66c8b86c4925111bc54d20991] Former-commit-id: 7a4cfe131e5b37e67c64d4da18e0fb670626109b --- build/Package_AutoDetect.bat | 2 ++ build/Package_MSVC.bat | 3 ++- build/Package_MinGW.bat | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 build/Package_AutoDetect.bat diff --git a/build/Package_AutoDetect.bat b/build/Package_AutoDetect.bat new file mode 100644 index 000000000..32a52470b --- /dev/null +++ b/build/Package_AutoDetect.bat @@ -0,0 +1,2 @@ +premake5 package +pause \ No newline at end of file diff --git a/build/Package_MSVC.bat b/build/Package_MSVC.bat index 3a5c45bce..0367ff7df 100644 --- a/build/Package_MSVC.bat +++ b/build/Package_MSVC.bat @@ -1 +1,2 @@ -premake5 --pack-libdir=msvc package \ No newline at end of file +premake5 --pack-libdir=msvc package +pause \ No newline at end of file diff --git a/build/Package_MinGW.bat b/build/Package_MinGW.bat index aaa7bbf9a..823c5e4ce 100644 --- a/build/Package_MinGW.bat +++ b/build/Package_MinGW.bat @@ -1 +1,2 @@ -premake5 --pack-libdir=mingw package \ No newline at end of file +premake5 --pack-libdir=mingw package +pause \ No newline at end of file From 02c6144c99510112529088ce4ad30f8efdeaa08f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 11:42:53 +0200 Subject: [PATCH 348/383] Build/Package: Simplify code Former-commit-id: de14600cdf1743f28f309fcc24d1070256901111 [formerly 9a57e456634a478f651c79d7d100af5385c9cb15] [formerly 343131484489da941cdca33470055f0daaffc197 [formerly 668828de25d45c455988ba6e4b8ee834dfdf9cb9]] Former-commit-id: 7141674ad55cdd89ce2e5646b74fc08bff9f5e3b [formerly 5250e79e3fa22eaf3ebc2cae22d8d33a4feb7b30] Former-commit-id: 9d109b01861ed8275fb95c95cd9f5d1b948f117c --- build/scripts/actions/package.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/scripts/actions/package.lua b/build/scripts/actions/package.lua index abdb5a4c7..62d4792b3 100644 --- a/build/scripts/actions/package.lua +++ b/build/scripts/actions/package.lua @@ -89,13 +89,13 @@ ACTION.Function = function () libFileMasks = {"**.lib", "**.a"} exeFileExt = ".exe" exeFilterFunc = function (filePath) return true end - elseif (os.is("macosx")) then - binFileMasks = {"**.dynlib"} - libFileMasks = {"**.a"} - exeFileExt = "" - exeFilterFunc = function (filePath) return path.getextension(filePath):contains('/') end else - binFileMasks = {"**.so"} + if (os.is("macosx")) then + binFileMasks = {"**.dynlib"} + else + binFileMasks = {"**.so"} + end + libFileMasks = {"**.a"} exeFileExt = "" exeFilterFunc = function (filePath) return path.getextension(filePath):contains('/') end From 4dff4f724b5a9298099335ebc561afe42ad579c1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 15:42:42 +0200 Subject: [PATCH 349/383] Utility/X11: Fix xcb_renderutil.h compile error on olders systems (Travis CI for example) Former-commit-id: d244d237356fa61293e8af28654a97df3f127de6 [formerly 348621c8a478a8b2f286b5fcb02b687e10216294] [formerly 25deef8c480e56fe2d2e0f1f8a22b942ace56ef6 [formerly e936f13a7c07985663fc0d35e4d0332a7aad6762]] Former-commit-id: f419ba91ab932b4695632bf2bf6e13cb2d396ffb [formerly 4d66289f24743ce633846a33207a46be5b97f307] Former-commit-id: 38f18e32f5e7154f8bbad8869559279ae268ddee --- src/Nazara/Utility/X11/CursorImpl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Nazara/Utility/X11/CursorImpl.cpp b/src/Nazara/Utility/X11/CursorImpl.cpp index 8cdde5170..ca40b0e64 100644 --- a/src/Nazara/Utility/X11/CursorImpl.cpp +++ b/src/Nazara/Utility/X11/CursorImpl.cpp @@ -9,7 +9,14 @@ #include #include #include + +// Some older versions of xcb/util-renderutil (notably the one available on Travis CI) use `template` as an argument name +// This is a fixed bug (https://cgit.freedesktop.org/xcb/util-renderutil/commit/?id=8d15acc45a47dc4c922eee5b99885db42bc62c17) but until Travis-CI +// has upgraded their Ubuntu version, I'm forced to use this ugly trick. +#define template ptemplate #include +#undef template + #include namespace Nz From 173c3194d0ddbc95a4f0017e8ae222739368b280 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 15:50:32 +0200 Subject: [PATCH 350/383] Travis: Remake script to not use docker Former-commit-id: 7defc544b9eaa9f0490e82092aed1463a08bf35c [formerly a13d1908cd8b640bc4a435f1215c9b54be24e081] [formerly 982b4e0891795af3d299aed2f19a6ef93a29690b [formerly c7fd6461f6dc07fbc7e14a605dccc07b2a54b585]] Former-commit-id: 03a7e2f592e4d394921d3b5e596848c47837dc40 [formerly 7087d97527118834280ff3ace4eb3ac30b99f9d2] Former-commit-id: 49cd6d0273e2a8d1190ca872cdb89cdf53b2ac11 --- .travis.yml | 51 ++++++++++++++++++++++++++++++--------------------- Dockerfile | 11 ----------- 2 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 Dockerfile diff --git a/.travis.yml b/.travis.yml index 0db1ba26a..e6873263c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,29 @@ language: cpp +dist: + trusty + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libassimp-dev + - libfreetype6-dev + - libgl1-mesa-dev + - libopenal-dev + - libsndfile1-dev + - libx11-dev + - libxcb-cursor-dev + - libxcb-ewmh-dev + - libxcb-icccm4-dev + - libxcb-keysyms1-dev + - libxcb-randr0-dev + - mesa-common-dev + sudo: - required + false notifications: email: true @@ -10,26 +31,14 @@ notifications: env: - CONFIG=debug - CONFIG=release - -services: - - docker - -before_install: - - docker build -t nazara . script: - - docker run --name Nazara -v `pwd`:/NazaraEngine nazara - sh -c " - cd build && - ./premake5-linux64 --with-examples gmake && - cd gmake && - make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 - " + - cd build && + ./premake5-linux64 --with-examples gmake && + cd gmake && + make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 -#after_script: -# - docker exec Nazara -# sh -c " -# cd ../../tests && -# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && -# ./NazaraUnitTests -# " +after_script: + - cd ../../tests && + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && + ./NazaraUnitTests diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ac2568e3c..000000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:xenial - -RUN apt-get update && apt-get -y install && \ - apt-get install -y libssl1.0.0 libssl-dev && \ - apt-get install -y libopenal-dev libsndfile1-dev && \ - apt-get install -y libxcb-cursor-dev libxcb-ewmh-dev libxcb-randr0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev && \ - apt-get install -y mesa-common-dev libgl1-mesa-dev && \ - apt-get install -y libassimp-dev - -RUN mkdir /NazaraEngine -WORKDIR /NazaraEngine From f6e52f236e10c4aba560077e178fab89cad4f961 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 15:59:15 +0200 Subject: [PATCH 351/383] Travis: Try to fix Former-commit-id: da0b54910800524239b694d961e63672e7110843 [formerly 2e0603958f3a8404758e131578d961af730982aa] [formerly 418047309f899cc8927343f9f6f23d9078cf377e [formerly 279c19f224c9000002f6e46d278715f55f286108]] Former-commit-id: 8c33464b460a16ddc168d2fb34998107054793c3 [formerly 6549912fe8ff440d18c638335c672159a1d59260] Former-commit-id: 7b17b42dd1814dcb226a3b61eac544c202be7ca2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e6873263c..55865890b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ addons: - mesa-common-dev sudo: - false + required notifications: email: true From be1727bb9379b12146ee9a635163c96c965ae103 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:02:44 +0200 Subject: [PATCH 352/383] Travis: Use Clang Former-commit-id: f43378809346a8b0556fd07d16ded83c573ae2be [formerly c692539c14ec7a405afa58307c46d27e6bfbe78f] [formerly e8764e2de2b8fe8f878c07852f65005018208273 [formerly 39298d784561ba2d690cb0a2b6fcd654e78123bb]] Former-commit-id: f76ef7bf04c4e0e397a6d25d6748ddbd6d3a880e [formerly ba83d857708469c59c1ed973b1d5ba67108ac954] Former-commit-id: 596fd9a7d71d86a92607c508b8c0014a9c1bfec7 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 55865890b..d28f92668 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ addons: sources: - ubuntu-toolchain-r-test packages: + - clang-3.8 - libassimp-dev - libfreetype6-dev - libgl1-mesa-dev @@ -29,6 +30,7 @@ notifications: email: true env: + - COMPILER=clang++-3.8 - CONFIG=debug - CONFIG=release From 01ae1bab4ab1a0137c02836b5b0b82cb9bea3c6b Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:03:53 +0200 Subject: [PATCH 353/383] Travis: Fix typo Former-commit-id: d4e11e224f277d4c831cc848caed7286224805c9 [formerly 3e4b7e1d1d678797a9f019ad2623490297877f05] [formerly 32345f6168304ee3f028da65e7f98bd0f5b40b50 [formerly f6aa14ed799e04ff522c56271ebf1655f71747d7]] Former-commit-id: ca609113d6ce43a58e0a5237a2cf86e127947a15 [formerly f88da3bfe7fd6ed4669bc817110db3890ca47971] Former-commit-id: 98dcb138b03a07963d4a15f556d7d36e67f40401 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d28f92668..275025f0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ addons: sources: - ubuntu-toolchain-r-test packages: - - clang-3.8 + - clang-3.8 - libassimp-dev - libfreetype6-dev - libgl1-mesa-dev From 21d8a54f0957ab81b8af1273725b8be91c0a977b Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:06:23 +0200 Subject: [PATCH 354/383] Travis: Fix mistake Former-commit-id: 9f11c049a2ae8e059c5a5dd23cb3349a2ddeb592 [formerly 74c0956f22e162b28d5ee456f746834b87ffe66d] [formerly 16514d5ff129a4dbfb486b4f2bfa5879ba6e0c81 [formerly 71af6162f4bdb38bd7265634bbef8172dc8873ea]] Former-commit-id: a38a72a124f732c62a0c450a4c330e0e443fd975 [formerly 3908519b7809135544000218b79473af7ca1b0d6] Former-commit-id: 1a0c09f352a5ae5d044f645e29b606fb89277475 --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 275025f0c..dfca6c466 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,8 @@ notifications: email: true env: - - COMPILER=clang++-3.8 - - CONFIG=debug - - CONFIG=release + - COMPILER=clang++-3.8 CONFIG=debug + - COMPILER=clang++-3.8 CONFIG=release script: - cd build && From a1f2662866264f84d49a14853a68ee3cd71ec5b5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:11:46 +0200 Subject: [PATCH 355/383] Travis: I have no idea what I'm doing Former-commit-id: 740fb4396619cf000a39cbf2e47117a756dcbbb8 [formerly 3e5c1fe768b7aac743e18eaeea1c4ba46c01b05d] [formerly ffa51fee6e5b0552fdc72f8403ef254726b53733 [formerly ecf471ac9b15129f94d4e91f67e569aeb675e3df]] Former-commit-id: c8aca56a22e30d84f9d23a2a8632c21283428346 [formerly 6318d4bf81ea42bc76f219a9ebb56ba09640c341] Former-commit-id: 54d5421254ad9d2dccda4297e80b63b0d9e0d456 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dfca6c466..847f1b4fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,8 @@ notifications: email: true env: - - COMPILER=clang++-3.8 CONFIG=debug - - COMPILER=clang++-3.8 CONFIG=release + - CXX=clang++-3.8 CONFIG=debug + - CXX=clang++-3.8 CONFIG=release script: - cd build && From cfd0d255264f8df894a02928e3ed30ccf58430fc Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:21:15 +0200 Subject: [PATCH 356/383] Travis: Black magic Former-commit-id: 1dd7829ae1182d53f27600eb9cc39ac5e31be0b6 [formerly 293806b5cf98dac38a6fbe4ba8e6810e817bea8f] [formerly de75eabf9c19571d794246ac7739a1d26f1115ac [formerly 1aa12f00d439b070be7e5a425c9ac014863dd329]] Former-commit-id: a4f8e0d8fd75cd25da68fcd9377aae9abcf9b903 [formerly 6b89b266ab8f09e8a8166709b8883a38c1f9f8f2] Former-commit-id: a02d37aa4bc157bf55b3b0830f17ffad60c098eb --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 847f1b4fc..8495222b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,13 +30,15 @@ notifications: email: true env: - - CXX=clang++-3.8 CONFIG=debug - - CXX=clang++-3.8 CONFIG=release + - CONFIG=debug + - CONFIG=release script: - cd build && - ./premake5-linux64 --with-examples gmake && + ./premake5-linux64 --cc=clang gmake && cd gmake && + export CC=clang-3.8 && + export CXX=clang++-3.8 && make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 after_script: From a6057294f7262f41ca8d63445f2aaac5e3429f14 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:26:07 +0200 Subject: [PATCH 357/383] Travis: I dare you to work! Former-commit-id: 47423aec8c228315a055477afec8309bf631c144 [formerly 9724e307e2817f95ac59d38b71cf87eba9658bd5] [formerly b6c6129fe5a4e16696240b09d7de190f6fa68635 [formerly 9b0ab2c324bb0c9a813536a5edb83953844891c9]] Former-commit-id: aeda19dbe4a3830edbf34c9af46ff29b8b2647e4 [formerly 0e5815d140826fb9edf6f57101a3abf05fc798e2] Former-commit-id: 331d11a2b587de229d53a6b3fe17814381949b4f --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8495222b7..a9a5c5107 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,14 +34,14 @@ env: - CONFIG=release script: - - cd build && - ./premake5-linux64 --cc=clang gmake && - cd gmake && - export CC=clang-3.8 && - export CXX=clang++-3.8 && - make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 + - export CC=clang-3.8 + - export CXX=clang++-3.8 + - cd build + - ./premake5-linux64 --cc=clang gmake + - cd gmake + - make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 after_script: - - cd ../../tests && - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && - ./NazaraUnitTests + - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ + - cd ../../tests + - ./NazaraUnitTests From 0cb677d92a35ee9d8e1ad05eacf9606ba69284f3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:31:33 +0200 Subject: [PATCH 358/383] AppVeyor: Don't build everytime I update Travis Former-commit-id: 69a0e190a2ae2c9023ed5614517c82cc9768818c [formerly 0d3d76215abb1795110dbf06926f7796d82e92cc] [formerly 0b9ecb1c4223abfb5db435666b1524cb61ba85f0 [formerly eb7005232052463fe7f1411233782c6aeb96f9e7]] Former-commit-id: 74f45a15fa45fcc503e6770cec0bb3a2885a1661 [formerly 3d6b1174adcebb74b27005fd62acc023e7358441] Former-commit-id: a6c02f6f31b3a09c08cd1e0beba7c7b5795158dc --- appveyor.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 86eb0a5ad..1dbe500e9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,20 @@ version: '{branch}-rev{build}' shallow_clone: true +skip_commits: + files: + - .travis.yml + - Doxyfile + - LICENSE + - License-Cabin.txt + - Logo.png + - LogoMini.png + - readme.md + - readme_fr.md + - 'writing style.md' + - doc/* + - NazaraModuleTemplate/* + os: - Visual Studio 2015 From c8db75d7d003a2d00abe2dfe4c80f39b4acab0a9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:34:11 +0200 Subject: [PATCH 359/383] Travis: Burp Former-commit-id: bc9ff70bf389e7086697d1c72eaa1c4d6dafb145 [formerly e8af3d79805eb12ed70a7ee9d919686895e706c7] [formerly a6aec85456c4ef6c59ca5c1fcf0e77ab9ae53bbe [formerly 64232d276ae366d9db47b5f77832722ffd48502f]] Former-commit-id: 4ea77e92cf192cb13466e62b574f2837c15ac2c4 [formerly 9a31fa44a99a7e311877698c41413331c1205b8d] Former-commit-id: 619b8540f208b8a207bd0163cde9769dd075f5f5 --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9a5c5107..b6eb48100 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,14 +34,14 @@ env: - CONFIG=release script: - - export CC=clang-3.8 - - export CXX=clang++-3.8 - - cd build - - ./premake5-linux64 --cc=clang gmake - - cd gmake - - make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 + - cd build && + ./premake5-linux64 --cc=clang gmake + - cd gmake && + export CC=clang-3.8 && + export CXX=clang++-3.8 && + make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 after_script: - - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ - - cd ../../tests - - ./NazaraUnitTests + - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && + cd ../../tests && + ./NazaraUnitTests From 029f830f7f9527278870d3dcce95f41f594ca793 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:40:01 +0200 Subject: [PATCH 360/383] Travis: So two belgian enter a bar... Former-commit-id: 751575ad87c0f3c918291911c53801e8ca169417 [formerly af2091bf40fa7002a7edef539ff74e77909397bd] [formerly 1f204640e175f24574877d8263b0708d251a68e5 [formerly 7efe090c9be1f2317825130eda9023709f06c2be]] Former-commit-id: 9c5def2dc2a6a8bab009db11a032a0e0a863d884 [formerly 4cfbbfec2beee8407ad360eab4eb07380c815592] Former-commit-id: 2adc7edc95186fb61e0f8d4a00ff3bd1e7fa094b --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b6eb48100..7990ed62b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ addons: sources: - ubuntu-toolchain-r-test packages: - - clang-3.8 - libassimp-dev - libfreetype6-dev - libgl1-mesa-dev @@ -29,6 +28,9 @@ sudo: notifications: email: true +compiler: + - clang + env: - CONFIG=debug - CONFIG=release @@ -37,8 +39,6 @@ script: - cd build && ./premake5-linux64 --cc=clang gmake - cd gmake && - export CC=clang-3.8 && - export CXX=clang++-3.8 && make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64 after_script: From 3bf018ad1d3cba30b4ebda66d5a7dc61226be974 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:51:17 +0200 Subject: [PATCH 361/383] Travis: And then the barman says "What do I serve you?" Former-commit-id: dd3f85ff60f29efe74961ae76a9aaa7605db6c51 [formerly da74e62f836eace115c1d373525534b7bedf04e4] [formerly 546fbed596f0a3d2fbe777f64c30b44dd4a5927f [formerly 8729877fc103441cdb9b71395ee5935376243655]] Former-commit-id: 9d1f8276da6759c1e458a3a9b171b5263f5d83f9 [formerly 7d4cbca11648d64e14238a3b9a9d9bed0f439c14] Former-commit-id: 52d3549377515fed138683e53af70575619dcff1 --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7990ed62b..f574e9644 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,10 @@ dist: addons: apt: sources: + - llvm-toolchain-precise-3.7 - ubuntu-toolchain-r-test packages: + - clang-3.7 - libassimp-dev - libfreetype6-dev - libgl1-mesa-dev @@ -32,8 +34,8 @@ compiler: - clang env: - - CONFIG=debug - - CONFIG=release + - COMPILER=clang++-3.7 CONFIG=debug + - COMPILER=clang++-3.7 CONFIG=release script: - cd build && From 993cc9f4f6388a03f73df3385810f6a070ef92e3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 16:52:26 +0200 Subject: [PATCH 362/383] Travis: "Two cola" answer the belgians. Former-commit-id: 2ca5530568e44f13b9a10ee94f351afe28de56c6 [formerly 0db69a9e7f2d050e7d0d58636cdf3285ff062861] [formerly 4536ca1b89091a363cfe169045129185e986cd4d [formerly be93f3f04332d821901e116178f9f7b12b1f968e]] Former-commit-id: 0827701d1cc14f4e770738d0725c1f6446f65dac [formerly 72cc7262a3658efb747365bc9863f5b0e893e8e9] Former-commit-id: 47216ca7323ece972bbcab31c50f424fd3ce36e0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f574e9644..90c64fe4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ dist: addons: apt: sources: - - llvm-toolchain-precise-3.7 + - llvm-toolchain-precise-3.7 - ubuntu-toolchain-r-test packages: - clang-3.7 From 64785dca1788edb12869510d7c8b0ec488193505 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 17:08:45 +0200 Subject: [PATCH 363/383] Lua/LuaInstance: Fix move constructor/operator Former-commit-id: 172608ac5683f594243248017e3abf7f0e2066c9 [formerly d5deec47e4ab121f61ffe7aaea5aa6a7f6774c9e] [formerly 52e490fac2b7003bf64b4eac0cf7e36ce4da46e5 [formerly b64145eecf4cb5c2db1e0e2e780440af8bcb05e7]] Former-commit-id: ad3eec1403fdec906a6495c675dee0407cb75d9b [formerly 3f76ca985a58fcf13c248d438538139e843d05f7] Former-commit-id: 3789b4eb068b2fece669f3a5804d0015ba2e806f --- include/Nazara/Lua/LuaInstance.inl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index e6a4b5482..c5cdc3b6b 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -16,11 +16,11 @@ 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) + m_timeLimit(instance.m_timeLimit), + m_clock(std::move(instance.m_clock)), + m_lastError(std::move(instance.m_lastError)), + m_state(instance.m_state), + m_level(instance.m_level) { instance.m_state = nullptr; } @@ -52,13 +52,13 @@ namespace Nz inline LuaInstance& LuaInstance::operator=(LuaInstance&& instance) noexcept { - m_clock = std::move(m_clock); - m_lastError = std::move(m_lastError); - m_level = m_level; + m_clock = std::move(instance.m_clock); + m_lastError = std::move(instance.m_lastError); + m_level = instance.m_level; m_memoryLimit = instance.m_memoryLimit; m_memoryUsage = instance.m_memoryUsage; - m_state = m_state; - m_timeLimit = m_timeLimit; + m_state = instance.m_state; + m_timeLimit = instance.m_timeLimit; instance.m_state = nullptr; From bdc49b1eb3690fd6cc248ce417a63b627787b33f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 17:57:47 +0200 Subject: [PATCH 364/383] SDK: Fix compilation with Clang Former-commit-id: bbe7ec821304dd13ac6640a1c1c7b654914cbf2e [formerly 67a6dba7a47490a3f39ac6c9c4a0bf853da63f60] [formerly d116a4c3af3782462a1305bd76a1a410a0075027 [formerly 418e3fc7090ada085deb039eb79b9c74df694666]] Former-commit-id: 813f866bfcfd81cff799a2bd7b26ec71ada8e9ca [formerly 5cea6c36cbe5b8a73f1e4aecf86042be331ba424] Former-commit-id: e04eb838630232088ba6f93ad1896228b86f949d --- SDK/include/NDK/Prerequesites.hpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/SDK/include/NDK/Prerequesites.hpp b/SDK/include/NDK/Prerequesites.hpp index ec40a17d8..674bb1070 100644 --- a/SDK/include/NDK/Prerequesites.hpp +++ b/SDK/include/NDK/Prerequesites.hpp @@ -32,27 +32,14 @@ #define NDK_VERSION_MINOR 1 // Importation/Exportation of the API -#if defined(NAZARA_PLATFORM_WINDOWS) - #if !defined(NAZARA_STATIC) - #ifdef NDK_BUILD - #define NDK_API NAZARA_EXPORT - #else - #define NDK_API NAZARA_IMPORT - #endif - #else - #define NDK_API - #endif -#elif defined(NAZARA_PLATFORM_LINUX) - #if !defined(NAZARA_STATIC) && defined(NAZARA_COMPILER_GCC) - #define NDK_API NAZARA_EXPORT - #else - #define NDK_API - #endif +#if defined(NAZARA_STATIC) + #define #define NDK_API #else - // To comment to force a compilation - #error This operating system is not fully supported by the Nazara Development Kit - - #define NDK_API + #ifdef NDK_BUILD + #define NDK_API NAZARA_EXPORT + #else + #define NDK_API NAZARA_IMPORT + #endif #endif namespace Ndk From c653d4c4f2920a49c181a82dac80cb398078723d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 17:58:17 +0200 Subject: [PATCH 365/383] SDK/Prerequesites: Remove version informations Since the SDK has the same version as Nazara for now Former-commit-id: 98a11ff3f51208317502bcf4b66a92402f98b780 [formerly 15a3ec197fe5b709829f267eb66a72f1748ba2bd] [formerly 6568140a3c675568f914035350faf840ee215005 [formerly 76ec756093abdd84d386eee843eb2cc70e206222]] Former-commit-id: 54c6ff374c0e64abbc6e7161ce517ddb568b1972 [formerly 164feb548e2974dcb562f8991f7ded2fa5364fe9] Former-commit-id: 1c03591596f56e7607ae6abd0daacc2c11d6f2bf --- SDK/include/NDK/Prerequesites.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/SDK/include/NDK/Prerequesites.hpp b/SDK/include/NDK/Prerequesites.hpp index 674bb1070..a2305c70f 100644 --- a/SDK/include/NDK/Prerequesites.hpp +++ b/SDK/include/NDK/Prerequesites.hpp @@ -27,10 +27,6 @@ #include -// Version of SDK -#define NDK_VERSION_MAJOR 0 -#define NDK_VERSION_MINOR 1 - // Importation/Exportation of the API #if defined(NAZARA_STATIC) #define #define NDK_API From 7952c1531a17c67855f29d8a3a5bb8117b8104b1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 18:09:15 +0200 Subject: [PATCH 366/383] Utility/X11: Fix compilation on Ubuntu 14.04 Former-commit-id: ec60ac14249ec8373b94adc151689bb296a32eb8 [formerly f133d000ffa0af394ff13f1cdb5c15998e168cb3] [formerly a273e695a23571703a86fb48baf2b3481a880e7f [formerly 16e55866c0bf4159de7ab70f01f10ee8cd85c460]] Former-commit-id: 4119b010eb683593fc1a874a18cd43258a7bb686 [formerly 4f25a87bee75670940a2ad68b61a32342e3ddcf9] Former-commit-id: f811f2c2dbe89bf4a9442b11a2c50b54719c85bd --- src/Nazara/Utility/X11/CursorImpl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Utility/X11/CursorImpl.cpp b/src/Nazara/Utility/X11/CursorImpl.cpp index ca40b0e64..d09f51a1f 100644 --- a/src/Nazara/Utility/X11/CursorImpl.cpp +++ b/src/Nazara/Utility/X11/CursorImpl.cpp @@ -14,7 +14,10 @@ // This is a fixed bug (https://cgit.freedesktop.org/xcb/util-renderutil/commit/?id=8d15acc45a47dc4c922eee5b99885db42bc62c17) but until Travis-CI // has upgraded their Ubuntu version, I'm forced to use this ugly trick. #define template ptemplate -#include +extern "C" +{ + #include +} #undef template #include From e86964936f31b595189fd8ac52f7394ee4783da7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 21:33:56 +0200 Subject: [PATCH 367/383] Add server-side unit tests Former-commit-id: 1db8c846b260cccaa6dc21590554cca469f5ffce [formerly 08a850f788da4d0d8b7c9ce5517fedf096c592d8] [formerly ae83af3d9153471ab88c285a4dd903e50460e1b2 [formerly e744d24dbc26b54a851c4fff0d166ea702fa1c1d]] Former-commit-id: 8b0e0287c6a3f6fb456ff5c4a2f397ee3818d1d4 [formerly 35170cc7321b0bf5dcfe4813cd48b82afdb7ac07] Former-commit-id: 525a0269014feb28795553339ca9d3621a36654a --- .travis.yml | 2 +- appveyor.yml | 6 ++--- build/scripts/tools/ndk_server.lua | 1 - build/scripts/tools/unittests_server.lua | 34 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 build/scripts/tools/unittests_server.lua diff --git a/.travis.yml b/.travis.yml index 90c64fe4a..d1ed3ec6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,4 +46,4 @@ script: after_script: - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ && cd ../../tests && - ./NazaraUnitTests + ./NazaraUnitTestsServer diff --git a/appveyor.yml b/appveyor.yml index 1dbe500e9..f91b3a927 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,13 +36,11 @@ platform: build: project: build/$(TOOLSET)/NazaraEngine.sln - -#after_build: -# - cd tests && "./NazaraUnitTests" after_build: - cd build && "./premake5.exe" package && cd ../package - - 7z a NazaraEngine.7z * + - 7z a NazaraEngine.7z * && cd .. + - cd tests && "./NazaraUnitTestsServer.exe" artifacts: - path: package/NazaraEngine.7z diff --git a/build/scripts/tools/ndk_server.lua b/build/scripts/tools/ndk_server.lua index cebd158c6..b5d258283 100644 --- a/build/scripts/tools/ndk_server.lua +++ b/build/scripts/tools/ndk_server.lua @@ -38,7 +38,6 @@ TOOL.FilesExcluded = { "../SDK/**/LuaBinding_Renderer.*" } - TOOL.Libraries = { "NazaraCore", "NazaraLua", diff --git a/build/scripts/tools/unittests_server.lua b/build/scripts/tools/unittests_server.lua new file mode 100644 index 000000000..b3eab27c0 --- /dev/null +++ b/build/scripts/tools/unittests_server.lua @@ -0,0 +1,34 @@ +TOOL.Name = "UnitTestsServer" + +TOOL.Directory = "../tests" +TOOL.EnableConsole = true +TOOL.Kind = "Application" +TOOL.TargetDirectory = TOOL.Directory + +TOOL.Defines = { + "NDK_SERVER" +} + +TOOL.Includes = { + "../include" +} + +TOOL.Files = { + "../tests/main.cpp", + "../tests/Engine/**.cpp", + "../tests/SDK/**.cpp" +} + +-- Excludes client-only files +TOOL.FilesExcluded = { + "../tests/Engine/Audio/**", + "../tests/Engine/Graphics/**", + "../tests/SDK/NDK/Application.cpp", + "../tests/SDK/NDK/Systems/ListenerSystem.cpp", + "../tests/SDK/NDK/Systems/RenderSystem.cpp" +} + +TOOL.Libraries = { + "NazaraNetwork", + "NazaraSDKServer" +} From 3f9988f75f8b822cc18f1083c10218d3edf0eaf4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 21:47:42 +0200 Subject: [PATCH 368/383] UnitTests: Fix unit tests Former-commit-id: 2ce788e02e887fc77b4e1778ade02e40bd377cd4 [formerly 22a98fbd268679a69754797cf2eeb6c70097fa2d] [formerly 3c6a3e8293b9715cd0b01f7b9d5592e86f65a936 [formerly 14c98743cee9ac56e6cc924ce3004c659dda6439]] Former-commit-id: a7897fb09e78eba5fc055f03a1f5c886d6802a38 [formerly b71928574724e14bdbe74b7a28ea28fc79919d10] Former-commit-id: c1900462b9a5def4daa9c3ca93f1bc00b875135c --- tests/SDK/NDK/System.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/SDK/NDK/System.cpp b/tests/SDK/NDK/System.cpp index 2948185ae..623b4a96f 100644 --- a/tests/SDK/NDK/System.cpp +++ b/tests/SDK/NDK/System.cpp @@ -43,7 +43,7 @@ SCENARIO("System", "[NDK][SYSTEM]") THEN("We should get a copy") { - REQUIRE(static_cast(clone.get())->GetValue() == 42); + REQUIRE(static_cast(clone.get())->GetValue() == 666); } } } From c61ce3a76e3bf8bc07bf996935c9ecdab9363f70 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Oct 2016 21:51:10 +0200 Subject: [PATCH 369/383] AppVeyor: Run tests after packaging Former-commit-id: 2b1be0a95c286f07b925ab241c3fd83fbfbf871e [formerly 908eade0c599976d88bbf887f7c06ae1a9007760] [formerly 9b78ba11a42818e66a1cb00b488ee8b949714492 [formerly 06c16f8b7ea026cb2ec450179ce14b8afd684922]] Former-commit-id: 99470c993d996c73001254e3b236560ec2daab5f [formerly a529bdead5b0e4e966d51b3151c80b49a10978f8] Former-commit-id: b07e86e3104ee3d51a16b9e619b139a7366d75a6 --- appveyor.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f91b3a927..544879a11 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -40,8 +40,10 @@ build: after_build: - cd build && "./premake5.exe" package && cd ../package - 7z a NazaraEngine.7z * && cd .. - - cd tests && "./NazaraUnitTestsServer.exe" - + artifacts: - path: package/NazaraEngine.7z name: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT)' + +test_script: + - cd tests && "./NazaraUnitTestsServer.exe" From fc3fb062e0489746d271bc288321a61b876ec4a6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 5 Oct 2016 00:26:06 +0200 Subject: [PATCH 370/383] Utility: Add Parameters and NoWindowSystem option Temporary fix until Utility module has been split. Former-commit-id: 702929f41c8f1dd4015b64e9b331c150ad6fd953 [formerly f113bd948da6a8c5399aab48f53b6cb5ca272081] [formerly 593365938d7e3a835b94727ec6dc744a7a113822 [formerly e43d02e4e221e5c1d85320d71d1a258db44768d1]] Former-commit-id: 29e2dd7ff9ee608847e3f78a7474e3286343b152 [formerly cf10e1a9dd5ca6df0bdf39730e2b38e9ea0d673a] Former-commit-id: a479d4eb078b30d6e7b34bd53dba6366fad643de --- SDK/src/NDK/Sdk.cpp | 7 +++++++ include/Nazara/Utility/Utility.hpp | 4 ++++ src/Nazara/Utility/Utility.cpp | 16 +++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/SDK/src/NDK/Sdk.cpp b/SDK/src/NDK/Sdk.cpp index bd3bf33e4..326eec502 100644 --- a/SDK/src/NDK/Sdk.cpp +++ b/SDK/src/NDK/Sdk.cpp @@ -59,6 +59,13 @@ namespace Ndk // Initialize the engine first // Shared modules + #ifdef NDK_SERVER + Nz::ParameterList parameters; + parameters.SetParameter("NoWindowSystem", true); + + Nz::Utility::SetParameters(parameters); + #endif + Nz::Lua::Initialize(); Nz::Noise::Initialize(); Nz::Physics::Initialize(); diff --git a/include/Nazara/Utility/Utility.hpp b/include/Nazara/Utility/Utility.hpp index 1beb98bcc..31ec543ee 100644 --- a/include/Nazara/Utility/Utility.hpp +++ b/include/Nazara/Utility/Utility.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -24,12 +25,15 @@ namespace Nz static bool IsInitialized(); + static void SetParameters(const ParameterList& parameters); + static void Uninitialize(); static unsigned int ComponentCount[ComponentType_Max+1]; static std::size_t ComponentStride[ComponentType_Max+1]; private: + static ParameterList s_initializationParameters; static unsigned int s_moduleReferenceCounter; }; } diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 6b2f66353..231a3a93c 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -102,10 +102,14 @@ namespace Nz return false; } - if (!Window::Initialize()) + bool bParam; + if (!s_initializationParameters.GetBooleanParameter("NoWindowSystem", &bParam) || bParam) { - NazaraError("Failed to initialize window's system"); - return false; + if (!Window::Initialize()) + { + NazaraError("Failed to initialize window's system"); + return false; + } } // On enregistre les loaders pour les extensions @@ -147,6 +151,11 @@ namespace Nz return s_moduleReferenceCounter != 0; } + void Utility::SetParameters(const ParameterList& parameters) + { + s_initializationParameters = parameters; + } + void Utility::Uninitialize() { if (s_moduleReferenceCounter != 1) @@ -227,5 +236,6 @@ namespace Nz static_assert(ComponentType_Max+1 == 14, "Component stride array is incomplete"); + ParameterList Utility::s_initializationParameters; unsigned int Utility::s_moduleReferenceCounter = 0; } From 05f7c52378b9efc242108eade24e38c2143d4277 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 5 Oct 2016 00:38:52 +0200 Subject: [PATCH 371/383] Fix some warnings pointed by Clang Former-commit-id: 2e2e0a23d3b4115b584743f100ca05fa404a4e9a [formerly 02f505dd5b7c70682e035ddabaa7731fe09d8452] [formerly bccc66f75a5ad50f88043a502c3cae1395889740 [formerly 294134ecf2220589b85d6950054591ce02e596ec]] Former-commit-id: 9d8d7699eaf4128b3519b3d33b6f5a20bf16f30f [formerly d84e10bdcb4faf5cd48d639bab06544b6fc7bda1] Former-commit-id: d73659592f82b0416b2ca6f2b406f744e68c4d45 --- SDK/include/NDK/Console.hpp | 2 +- SDK/src/NDK/Console.cpp | 5 ++++- SDK/src/NDK/LuaBinding_SDK.cpp | 3 +++ include/Nazara/Noise/Simplex.hpp | 6 +++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SDK/include/NDK/Console.hpp b/SDK/include/NDK/Console.hpp index 78caac3f2..1c007065f 100644 --- a/SDK/include/NDK/Console.hpp +++ b/SDK/include/NDK/Console.hpp @@ -51,7 +51,7 @@ namespace Ndk inline bool IsVisible() const; void SendCharacter(char32_t character); - void SendEvent(Nz::WindowEvent event); + void SendEvent(const Nz::WindowEvent& event); void SetCharacterSize(unsigned int size); void SetSize(const Nz::Vector2f& size); diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 94a80b749..122e2a125 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -168,7 +168,7 @@ namespace Ndk * \param event Event to be takin into consideration by the console */ - void Console::SendEvent(Nz::WindowEvent event) + void Console::SendEvent(const Nz::WindowEvent& event) { switch (event.type) { @@ -204,6 +204,9 @@ namespace Ndk } break; } + + default: + break; } } diff --git a/SDK/src/NDK/LuaBinding_SDK.cpp b/SDK/src/NDK/LuaBinding_SDK.cpp index 1ccd16342..af5cca5a8 100644 --- a/SDK/src/NDK/LuaBinding_SDK.cpp +++ b/SDK/src/NDK/LuaBinding_SDK.cpp @@ -233,6 +233,9 @@ namespace Ndk return &m_componentBinding[it->second]; } + + default: + break; } instance.Error("Invalid component index at #" + Nz::String::Number(argIndex)); diff --git a/include/Nazara/Noise/Simplex.hpp b/include/Nazara/Noise/Simplex.hpp index ae018f7bf..4f33c24ff 100644 --- a/include/Nazara/Noise/Simplex.hpp +++ b/include/Nazara/Noise/Simplex.hpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Engine - Noise module" // For conditions of distribution and use, see copyright notice in Config.hpp -#ifndef SIMPLEX_HPP -#define SIMPLE_HPP +#ifndef NAZARA_SIMPLEX_HPP +#define NAZARA_SIMPLEX_HPP #include #include @@ -25,4 +25,4 @@ namespace Nz }; } -#endif // SIMPLEX_HPP +#endif // NAZARA_SIMPLEX_HPP From d8b7fad5f08ef5614285dc834ab616f25c877595 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 5 Oct 2016 00:41:45 +0200 Subject: [PATCH 372/383] Utility: Fix NoWindowSystem parameter Former-commit-id: e52ac3a387001968fb0e998b788aaad715696a63 [formerly db7e147f903a51ed676f3580ae4e5c14c697ce2a] [formerly 5c467bc943641505761e555b394f1e29201a5680 [formerly 3906b482b0ebfd99d26cc54d7ace3e6d628241e4]] Former-commit-id: 13ac52c4b8fe3e9c73d38387e8fa44690d225a5c [formerly 0554f1fddf0023ccad75f2c946653f052f588e8a] Former-commit-id: d608750b66faf4dae989f7576c268a3ad32854f4 --- src/Nazara/Utility/Utility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 231a3a93c..87b154157 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -103,7 +103,7 @@ namespace Nz } bool bParam; - if (!s_initializationParameters.GetBooleanParameter("NoWindowSystem", &bParam) || bParam) + if (!s_initializationParameters.GetBooleanParameter("NoWindowSystem", &bParam) || !bParam) { if (!Window::Initialize()) { From 7c1680ada7a2203417e9a1855d15e63b3929dd89 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 5 Oct 2016 00:50:27 +0200 Subject: [PATCH 373/383] Network/SocketPoller: Fix Wait not updating error parameter (fixes #79) Former-commit-id: fd04ad1ef0b3c86e02d12251c384c5ee2976460d [formerly 57f72f946a0182c022ad8fc18aea1867914f6552] [formerly bbbadcedac8d46ff33f53a24053d1a9c06d09b8b [formerly f536546d45c326658845c287a1fa6d9d4f8c5a99]] Former-commit-id: 94246df60ecd371a07a57c12586d1d6bc7279076 [formerly b693141c531e6a61a3e8bc703ad7adf0fdb7a12d] Former-commit-id: cbaf3deb146ad0a38f59d890ea99d66d49d9f730 --- src/Nazara/Network/Linux/SocketPollerImpl.cpp | 11 +++++++++++ src/Nazara/Network/Linux/SocketPollerImpl.hpp | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.cpp b/src/Nazara/Network/Linux/SocketPollerImpl.cpp index fb6321709..ec6b8235e 100644 --- a/src/Nazara/Network/Linux/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Linux/SocketPollerImpl.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -75,6 +76,13 @@ namespace Nz std::memset(m_events.data(), 0, m_events.size() * sizeof(epoll_event)); activeSockets = epoll_wait(m_handle, m_events.data(), static_cast(m_events.size()), static_cast(msTimeout)); + if (activeSockets == -1) + { + if (error) + *error = SocketImpl::TranslateErrnoToResolveError(errno); + + return 0; + } m_activeSockets.clear(); if (activeSockets > 0U) @@ -96,6 +104,9 @@ namespace Nz } } + if (error) + *error = SocketError_NoError; + return activeSockets; } } diff --git a/src/Nazara/Network/Linux/SocketPollerImpl.hpp b/src/Nazara/Network/Linux/SocketPollerImpl.hpp index a6c5ad9f8..1c54471fc 100644 --- a/src/Nazara/Network/Linux/SocketPollerImpl.hpp +++ b/src/Nazara/Network/Linux/SocketPollerImpl.hpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include From 254f6fc4f9d2c72a6ab61c1b805374365c51cb77 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 5 Oct 2016 01:12:12 +0200 Subject: [PATCH 374/383] UnitTest: Make each network test use a different port, preventing them to block Former-commit-id: 168b9dbfea12e3729e68e8e3997025e14ced7990 [formerly cdfa45797832584cdb6e89e4619e6d79c893cfdf] [formerly d410f28ace50a77e49e455eae6e5d615a3141fde [formerly c8fc846a743b4bff94c5b25fefba0daf5af4058f]] Former-commit-id: 2c7aabb44d8b870cfa78b04e968cd336fb44369d [formerly 4e832af38d8fcd7e245fe249d6e2ea483a42dd1e] Former-commit-id: d02ca742f02bf62b72c06b78877d65e23972ed21 --- tests/Engine/Network/SocketPoller.cpp | 2 +- tests/Engine/Network/TCP.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Engine/Network/SocketPoller.cpp b/tests/Engine/Network/SocketPoller.cpp index 1f9c782d2..93012d3de 100644 --- a/tests/Engine/Network/SocketPoller.cpp +++ b/tests/Engine/Network/SocketPoller.cpp @@ -10,7 +10,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]") { GIVEN("A TcpServer and a TcpClient in a selector") { - Nz::UInt16 port = 64256; + Nz::UInt16 port = 25664; Nz::TcpServer server; server.EnableBlocking(false); diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp index 7ee62cab9..549742fd7 100644 --- a/tests/Engine/Network/TCP.cpp +++ b/tests/Engine/Network/TCP.cpp @@ -11,7 +11,7 @@ SCENARIO("TCP", "[NETWORK][TCP]") { GIVEN("Two TCP, one client, one server") { - Nz::UInt16 port = 64256; + Nz::UInt16 port = 26456; Nz::TcpServer server; server.EnableBlocking(false); From 03e31af8280bf93908f8b5548172ace0c1e8b1da Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 7 Oct 2016 15:23:08 +0200 Subject: [PATCH 375/383] UnitTests: Choose a random port when testing Former-commit-id: ce4e1c4b2b65327917bd0cf14b91102bfdab6327 [formerly e4390f995cb6ccb2c5e3b81a56acf0563d8d2679] [formerly a813d71a45dc17042129a31a8537b35ffaf93120 [formerly 683e75adf03f84ce2dc2454b4c22c2a20ca31668]] Former-commit-id: 65fe6b63137fc3a55439d3ec777147ab51ed259a [formerly 310169d28ca078fdf76307bbf9f0a653c3c85d42] Former-commit-id: fc03da2c66e08f6d349b5eedae057c5ab371ad9e --- tests/Engine/Network/IpAddress.cpp | 2 +- tests/Engine/Network/SocketPoller.cpp | 11 +++++++---- tests/Engine/Network/TCP.cpp | 5 ++++- tests/Engine/Network/UdpSocket.cpp | 12 ++++++++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/Engine/Network/IpAddress.cpp b/tests/Engine/Network/IpAddress.cpp index 8bb3e7d16..c87880d7b 100644 --- a/tests/Engine/Network/IpAddress.cpp +++ b/tests/Engine/Network/IpAddress.cpp @@ -40,7 +40,7 @@ SCENARIO("IpAddress", "[NETWORK][IPADDRESS]") Nz::IpAddress google(8, 8, 8, 8); THEN("Google (DNS) is 8.8.8.8") { - REQUIRE(Nz::IpAddress::ResolveAddress(google) == "google-public-dns-a.google.com"); + REQUIRE(Nz::IpAddress::ResolveAddress(google) == "google-public-dns-a.google.com"); } } } diff --git a/tests/Engine/Network/SocketPoller.cpp b/tests/Engine/Network/SocketPoller.cpp index 93012d3de..d44c5f65d 100644 --- a/tests/Engine/Network/SocketPoller.cpp +++ b/tests/Engine/Network/SocketPoller.cpp @@ -1,16 +1,19 @@ +#include +#include #include #include #include #include - -#include -#include +#include SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]") { GIVEN("A TcpServer and a TcpClient in a selector") { - Nz::UInt16 port = 25664; + std::random_device rd; + std::uniform_int_distribution dis(1025, 65535); + + Nz::UInt16 port = dis(rd); Nz::TcpServer server; server.EnableBlocking(false); diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp index 549742fd7..4a61e0197 100644 --- a/tests/Engine/Network/TCP.cpp +++ b/tests/Engine/Network/TCP.cpp @@ -11,7 +11,10 @@ SCENARIO("TCP", "[NETWORK][TCP]") { GIVEN("Two TCP, one client, one server") { - Nz::UInt16 port = 26456; + std::random_device rd; + std::uniform_int_distribution dis(1025, 65535); + + Nz::UInt16 port = dis(rd); Nz::TcpServer server; server.EnableBlocking(false); diff --git a/tests/Engine/Network/UdpSocket.cpp b/tests/Engine/Network/UdpSocket.cpp index 34ce5a19e..00d793e7a 100644 --- a/tests/Engine/Network/UdpSocket.cpp +++ b/tests/Engine/Network/UdpSocket.cpp @@ -1,14 +1,17 @@ -#include -#include - #include +#include #include +#include +#include SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]") { GIVEN("Two UdpSocket, one client, one server") { - Nz::UInt16 port = 64256; + std::random_device rd; + std::uniform_int_distribution dis(1025, 65535); + + Nz::UInt16 port = dis(rd); Nz::UdpSocket server(Nz::NetProtocol_IPv4); REQUIRE(server.Bind(port) == Nz::SocketState_Bound); @@ -33,6 +36,7 @@ SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]") Nz::NetPacket resultPacket; Nz::IpAddress fromIp; REQUIRE(server.ReceivePacket(&resultPacket, &fromIp)); + Nz::Vector3f result; resultPacket >> result; REQUIRE(result == vector123); From d99cfa5181cff7ebfc4af03d26b80147fa02ab24 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 7 Oct 2016 16:26:23 +0200 Subject: [PATCH 376/383] AppVeyor: Don't fail if unit test fail [skip ci] Former-commit-id: 6fc41d258de67e7fcfd698d285dae6b9880086cb [formerly 2cc89518336952148ea428d3fbf2274ee06e9a5e] [formerly 9d5486eac5727ff2725a25571befcc2fcd47d0ec [formerly 655b9a3acf9010f61c4ff21fec785fadd1872356]] Former-commit-id: aa2a672863be6251000bdcdd222155ef12a40e06 [formerly bee382ae42a659660d5ad20c8719292e1d32e7ec] Former-commit-id: 082f76abf282a37e7a54aeb60a2df76178e3ee13 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 544879a11..b6f1df78f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -45,5 +45,5 @@ artifacts: - path: package/NazaraEngine.7z name: 'NazaraEngine-$(CONFIGURATION)-$(PLATFORM)-$(APPVEYOR_REPO_COMMIT)' -test_script: +on_success: - cd tests && "./NazaraUnitTestsServer.exe" From 2b28b217d1f6b8c986f3b8ef54618193caf75cfe Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 7 Oct 2016 19:16:25 +0200 Subject: [PATCH 377/383] Core/Bitset: Add bit shifting functions Former-commit-id: a5d9aa0da769a1f5b70e5db8eed5c370e1e9b076 [formerly c8338571cedad83c557ffa9210f8e11a928157f2] [formerly 47e36d22755f77c878f5277a99f61388f096a449 [formerly 12f27f9470c490160deb869f83736c000bb18d93]] Former-commit-id: bc971c681a184ac7d340fa1d5b053f2e4a8cd156 [formerly 2a84c48ec1ab8970fb768dc5d925e7712cb193ea] Former-commit-id: 728cccf49da4bb48416aa91e3687fa7fad8035ef --- include/Nazara/Core/Bitset.hpp | 9 ++ include/Nazara/Core/Bitset.inl | 183 ++++++++++++++++++++++++++++++++- 2 files changed, 191 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index e4e2d8042..5c2746d16 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -64,6 +64,9 @@ namespace Nz void Set(std::size_t bit, bool val = true); void SetBlock(std::size_t i, Block block); + void ShiftLeft(std::size_t pos); + void ShiftRight(std::size_t pos); + void Swap(Bitset& bitset); bool Test(std::size_t bit) const; @@ -88,6 +91,12 @@ namespace Nz template Bitset& operator=(T value); Bitset& operator=(Bitset&& bitset) noexcept = default; + Bitset operator<<(std::size_t pos) const; + Bitset& operator<<=(std::size_t pos); + + Bitset operator>>(std::size_t pos) const; + Bitset& operator>>=(std::size_t pos); + Bitset& operator&=(const Bitset& bitset); Bitset& operator|=(const Bitset& bitset); Bitset& operator^=(const Bitset& bitset); diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index d29315afd..362157d40 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -2,8 +2,10 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include +#include #include #include #include @@ -512,12 +514,117 @@ namespace Nz ResetExtraBits(); } + /*! + * \brief Shift all the bits toward the left + * + * \param pos Bit shifting to be applied + * + * \remark This does not changes the size of the bitset. + * + * \see operator<<= + */ + template + void Bitset::ShiftLeft(std::size_t pos) + { + if (pos == 0) + return; + + if (pos >= m_bitCount) + { + Reset(); + return; + } + + auto div = std::lldiv(pos, bitsPerBlock); + if (div.rem != 0) + { + std::size_t lastIndex = m_blocks.size() - 1; + std::size_t remaining = bitsPerBlock - div.rem; + + for (std::size_t i = lastIndex - div.quot; i > 0; --i) + m_blocks[i + div.quot] = (m_blocks[i] << div.rem) | (m_blocks[i - 1] >> remaining); + + m_blocks[div.quot] = m_blocks[0] << div.rem; + + std::fill_n(m_blocks.begin(), div.quot, Block(0)); + } + else + { + for (auto it = m_blocks.rbegin(); it != m_blocks.rend(); ++it) + { + if (static_cast(std::distance(m_blocks.rbegin(), it) + div.quot) < m_blocks.size()) + { + auto shiftedIt = it; + std::advance(shiftedIt, div.quot); + + *it = *shiftedIt; + } + else + *it = 0U; + } + } + + ResetExtraBits(); + } + + /*! + * \brief Shift all the bits toward the right + * + * \param pos Bit shifting to be applied + * + * \remark This does not changes the size of the bitset. + * + * \see operator>>= + */ + template + void Bitset::ShiftRight(std::size_t pos) + { + if (pos == 0) + return; + + if (pos >= m_bitCount) + { + Reset(); + return; + } + + auto div = std::lldiv(pos, bitsPerBlock); + if (div.rem != 0) + { + std::size_t lastIndex = m_blocks.size() - 1; + std::size_t remaining = bitsPerBlock - div.rem; + + for (std::size_t i = div.quot; i < last; ++i) + m_blocks[i - div.quot] = (m_blocks[i] >> div.rem) | (m_blocks[i + 1] << remaining); + + m_blocks[last - div.quot] = m_blocks[last] >> div.rem; + + std::fill_n(m_blocks.begin() + (m_blocks.size() - div.quot), div.quot, Block(0)); + } + else + { + for (auto it = m_blocks.begin(); it != m_blocks.end(); ++it) + { + if (static_cast(std::distance(m_blocks.begin(), it) + div.quot) < m_blocks.size()) + { + auto shiftedIt = it; + std::advance(shiftedIt, div.quot); + + *it = *shiftedIt; + } + else + *it = 0U; + } + } + + ResetExtraBits(); + } + /*! * \brief Swaps the two bitsets * * \param bitset Other bitset to swap */ - template void Bitset::Swap(Bitset& bitset) { @@ -763,6 +870,80 @@ namespace Nz return *this; } + /*! + * \brief Shift all the bits toward the left + * + * \param pos Bit shifting to be applied + * + * \return A copies of the bitset with shifted bits + * + * \remark This does not changes the size of the bitset. + * + * \see ShiftLeft + */ + template + Bitset Bitset::operator<<(std::size_t pos) const + { + Bitset bitset(*this); + return bitset <<= pos; + } + + /*! + * \brief Shift all the bits toward the left + * + * \param pos Bit shifting to be applied + * + * \return A reference to this + * + * \remark This does not changes the size of the bitset. + * + * \see ShiftLeft + */ + template + Bitset& Bitset::operator<<=(std::size_t pos) + { + ShiftLeft(pos); + + return *this; + } + + /*! + * \brief Shift all the bits toward the right + * + * \param pos Bit shifting to be applied + * + * \return A copies of the bitset with shifted bits + * + * \remark This does not changes the size of the bitset. + * + * \see ShiftRight + */ + template + Bitset Bitset::operator>>(std::size_t pos) const + { + Bitset bitset(*this); + return bitset >>= pos; + } + + /*! + * \brief Shift all the bits toward the right + * + * \param pos Bit shifting to be applied + * + * \return A reference to this + * + * \remark This does not changes the size of the bitset. + * + * \see ShiftRight + */ + template + Bitset& Bitset::operator>>=(std::size_t pos) + { + ShiftRight(pos); + + return *this; + } + /*! * \brief Performs an "AND" with another bitset * \return A reference to this From 42240afb7c7753078ae01d10784f683def5a06b1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 7 Oct 2016 19:17:07 +0200 Subject: [PATCH 378/383] Utility/PixelFormat: Fix RGB32 and RGBA32 formats (Fix #80) Former-commit-id: dceb517cec5aeb1202c9725c62248ca182310528 [formerly 4ac3d4cacf5217c85027f3895a5673c8827cc0c5] [formerly ae697fbfacc90215483a431a3d3377ddf5814a98 [formerly cc43ad0eb6a7793b17e582d4bf9ce2812d47ca2b]] Former-commit-id: 6bd38f6ccb14944d7dcf5b69cda173c1b3c4f02e [formerly c32c42d98d003c181ee0ae1f5e97037d24497a07] Former-commit-id: d87a202835b7929db20c46a05a0dadb0f497c306 --- src/Nazara/Utility/PixelFormat.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index a9b740b8f..77f6bdbb2 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -1284,6 +1284,9 @@ namespace Nz bool PixelFormat::Initialize() { + Bitset<> b32(0xFFFFFFFF); + b32.Resize(128); + // Setup informations about every pixel format s_pixelFormatInfos[PixelFormatType_A8] = PixelFormatInfo("A8", PixelFormatContent_ColorRGBA, 0, 0, 0, 0xFF, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_BGR8] = PixelFormatInfo("BGR8", PixelFormatContent_ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType_Unsigned); @@ -1317,18 +1320,18 @@ namespace Nz s_pixelFormatInfos[PixelFormatType_RGB16F] = PixelFormatInfo("RGB16F", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Half); s_pixelFormatInfos[PixelFormatType_RGB16I] = PixelFormatInfo("RGB16I", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Int); s_pixelFormatInfos[PixelFormatType_RGB16UI] = PixelFormatInfo("RGB16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGB32F] = PixelFormatInfo("RGB32F", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Half); - s_pixelFormatInfos[PixelFormatType_RGB32I] = PixelFormatInfo("RGB32I", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RGB32UI] = PixelFormatInfo("RGB32UI", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGB32F] = PixelFormatInfo("RGB32F", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormatType_RGB32I] = PixelFormatInfo("RGB32I", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RGB32UI] = PixelFormatInfo("RGB32UI", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_RGBA4] = PixelFormatInfo("RGBA4", PixelFormatContent_ColorRGBA, 0xF000, 0x0F00, 0x00F0, 0x000F, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_RGB5A1] = PixelFormatInfo("RGB5A1", PixelFormatContent_ColorRGBA, 0xF800, 0x07C0, 0x003E, 0x0001, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_RGBA8] = PixelFormatInfo("RGBA8", PixelFormatContent_ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_RGBA16F] = PixelFormatInfo("RGBA16F", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Half); s_pixelFormatInfos[PixelFormatType_RGBA16I] = PixelFormatInfo("RGBA16I", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Int); s_pixelFormatInfos[PixelFormatType_RGBA16UI] = PixelFormatInfo("RGBA16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGBA32F] = PixelFormatInfo("RGBA32F", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Half); - s_pixelFormatInfos[PixelFormatType_RGBA32I] = PixelFormatInfo("RGBA32I", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RGBA32UI] = PixelFormatInfo("RGBA32UI", PixelFormatContent_ColorRGBA, 0, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormatType_RGBA32F] = PixelFormatInfo("RGBA32F", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormatType_RGBA32I] = PixelFormatInfo("RGBA32I", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormatType_RGBA32UI] = PixelFormatInfo("RGBA32UI", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_Depth16] = PixelFormatInfo("Depth16", PixelFormatContent_DepthStencil, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_Depth24] = PixelFormatInfo("Depth24", PixelFormatContent_DepthStencil, 0xFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); s_pixelFormatInfos[PixelFormatType_Depth24Stencil8] = PixelFormatInfo("Depth24Stencil8", PixelFormatContent_DepthStencil, 0xFFFFFF00, 0x000000FF, 0, 0, PixelFormatSubType_Unsigned); From 1788cd073536538f3ba9b5ed263af071fc819ef2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 8 Oct 2016 07:19:41 +0200 Subject: [PATCH 379/383] Core/Bitset: Fix compile error Former-commit-id: f9e4fc7547f9b741d9830ca96c552595b49b218d [formerly d8e832f8f8307a5af8c54a073fb7105e956dc91f] [formerly da3ca4c03e8c4f26023530a3150c99fe0bd8f060 [formerly 454daac75baf19c15612509e8505417dd1f194b6]] Former-commit-id: e6c44555476b6b8f2648895493736d6018dd9ce5 [formerly 8e816f8b6a1366583000aa5e35b10b5bd6f82019] Former-commit-id: 8d470b2679af9464001d3239738ab8d5bc7d6d67 --- include/Nazara/Core/Bitset.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index 362157d40..6ddb252e7 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -594,10 +594,10 @@ namespace Nz std::size_t lastIndex = m_blocks.size() - 1; std::size_t remaining = bitsPerBlock - div.rem; - for (std::size_t i = div.quot; i < last; ++i) + for (std::size_t i = div.quot; i < lastIndex; ++i) m_blocks[i - div.quot] = (m_blocks[i] >> div.rem) | (m_blocks[i + 1] << remaining); - m_blocks[last - div.quot] = m_blocks[last] >> div.rem; + m_blocks[lastIndex - div.quot] = m_blocks[lastIndex] >> div.rem; std::fill_n(m_blocks.begin() + (m_blocks.size() - div.quot), div.quot, Block(0)); } From 96a886260e1d5158896ea8b5a44a38a6ab53d64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 8 Oct 2016 20:55:00 +0200 Subject: [PATCH 380/383] Network: Fix compilation on Linux x86 (Fixes #81) Former-commit-id: b9ee4a38914e101751907a0afd5bc4387c4cc595 [formerly fbd619850d74c3264eead6456950549a00445a48] [formerly 38aa0d99632748baef4bdbed948e97d3348fd7c3 [formerly 24dc3d90f246b8a437a6fc1ace1b3091fd0e8df9]] Former-commit-id: 37cfa200c8effe1822e9e2c8dd3224f8d4138c9d [formerly 5a4fdb8f93bcef49702e73d3ca8c7f5a1be56716] Former-commit-id: 3e444884880bb866d4b66b5d4531272a02ac4125 --- src/Nazara/Network/Posix/SocketImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index 92588160c..954ac4f43 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -398,7 +398,7 @@ namespace Nz return IpAddressImpl::FromSockAddr(reinterpret_cast(nameBuffer.data())); } - int SocketImpl::Poll(PollSocket* fdarray, unsigned long nfds, int timeout, SocketError* error) + int SocketImpl::Poll(PollSocket* fdarray, std::size_t nfds, int timeout, SocketError* error) { NazaraAssert(fdarray && nfds > 0, "Invalid fdarray"); From 5c3e29c75028e1059fe2b4c8203751014080618e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 9 Oct 2016 12:56:42 +0200 Subject: [PATCH 381/383] Graphics/ForwardRenderTechnique: Fix sending uniforms when shadows are disabled Former-commit-id: a1c74d1c8e90fb0c9fd00342cd9688b7987c8229 [formerly 30588634d7283d3afa190d45672955631cd275be] [formerly 5f006c4db2f43bf5a167e2c2f02559d5d7c01275 [formerly 43b03cfc6e1255d5ebd86d0af8e49d19087e7ce0]] Former-commit-id: 1717577f8523b12489ad79b4f525a3059d11915d [formerly d0b9210e3c6acf35885b4d22717ce660756ef181] Former-commit-id: f175b9ca43fe11cc11050d7c13f2e8df35e4888a --- .../Graphics/ForwardRenderTechnique.inl | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index 6490513f8..5f7ba181f 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -38,19 +38,25 @@ namespace Nz shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.direction)); - shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + if (uniforms.locations.shadowMapping != -1) + shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + if (light.shadowMap) { Renderer::SetTexture(availableTextureUnit, light.shadowMap); Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); - shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); + if (uniforms.locations.lightViewProjMatrix != -1) + shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); + + if (uniforms.locations.directionalSpotLightShadowMap != -1) + shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); } - else + else if (uniforms.locations.directionalSpotLightShadowMap != -1) shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); + if (uniforms.locations.directionalSpotLightShadowMap != -1) + shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); break; } @@ -63,18 +69,22 @@ namespace Nz shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation)); shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(0.f, 0.f, 0.f, light.invRadius)); - shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + if (uniforms.locations.shadowMapping != -1) + shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + if (light.shadowMap) { Renderer::SetTexture(availableTextureUnit, light.shadowMap); Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, availableTextureUnit); + if (uniforms.locations.pointLightShadowMap != -1) + shader->SendInteger(uniforms.locations.pointLightShadowMap + index, availableTextureUnit); } - else + else if (uniforms.locations.pointLightShadowMap != -1) shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); + if (uniforms.locations.directionalSpotLightShadowMap != -1) + shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); break; } @@ -88,19 +98,25 @@ namespace Nz shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(light.direction, light.invRadius)); shader->SendVector(uniforms.locations.parameters3 + uniformOffset, Vector2f(light.innerAngleCosine, light.outerAngleCosine)); - shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + if (uniforms.locations.shadowMapping != -1) + shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); + if (light.shadowMap) { Renderer::SetTexture(availableTextureUnit, light.shadowMap); Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); - shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); + if (uniforms.locations.lightViewProjMatrix != -1) + shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); + + if (uniforms.locations.directionalSpotLightShadowMap != -1) + shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); } - else + else if (uniforms.locations.directionalSpotLightShadowMap != -1) shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); + if (uniforms.locations.pointLightShadowMap != -1) + shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); break; } @@ -108,9 +124,14 @@ namespace Nz } else { - shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader - shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); - shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); + if (uniforms.locations.type != -1) + shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader + + if (uniforms.locations.directionalSpotLightShadowMap != -1) + shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); + + if (uniforms.locations.pointLightShadowMap != -1) + shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); } } From e0bae16564adb76dbc81956fee48fd227c85d631 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 9 Oct 2016 13:05:27 +0200 Subject: [PATCH 382/383] Bump version to 0.1.1 Former-commit-id: 6a360efed4517a669aff64bd7beb0d3a07c71b88 [formerly 8fecaa13b82bce353b40bba4fb90b8c4a15d3963] [formerly bff0adcb24ddbe3f63109340c04ad44d9831f1e1 [formerly 930549ee2e196d9079908b00726117da477b032a]] Former-commit-id: 5752c3dffc3bb17417c6b5bffb0c3c313dbd8f24 [formerly 693708bd55e361e88189ac3da63c5efafbd7a9e1] Former-commit-id: b6a424e146dc6c43bfec4471f8996df94b8c0c7d --- include/Nazara/Prerequesites.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Prerequesites.hpp b/include/Nazara/Prerequesites.hpp index 6fdbf5d03..bf9d1d75f 100644 --- a/include/Nazara/Prerequesites.hpp +++ b/include/Nazara/Prerequesites.hpp @@ -77,7 +77,7 @@ // Nazara version macro #define NAZARA_VERSION_MAJOR 0 #define NAZARA_VERSION_MINOR 1 -#define NAZARA_VERSION_PATCH 0 +#define NAZARA_VERSION_PATCH 1 #include From d59fd1282415b03a4ce0f4a9065a6978da83c407 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 9 Oct 2016 14:05:07 +0200 Subject: [PATCH 383/383] UnitTests: Try to fix AcceptClient error Former-commit-id: 2545ccc482b0726c23b85e12a3aaa294837676c1 [formerly eda50f108c9d8a4991b59346f47be1850b690f26] [formerly 8b467d645f61cc8b2fcb20318f5c8d792d3fe247 [formerly 287e1abaacb666890183535fc62fa33499f96e83]] Former-commit-id: 40325f685aa612016580d887e8fec111a0845594 [formerly 37695b3f6793e947d79c37b023b9f388b6d888d3] Former-commit-id: 7c6a7d60223733a253d05b52592146ddb51705b8 --- examples/bin/resources/skybox-space.png.REMOVED.git-id | 1 - tests/Engine/Network/TCP.cpp | 9 +++++---- tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id | 1 - .../Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 examples/bin/resources/skybox-space.png.REMOVED.git-id delete mode 100644 tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id delete mode 100644 tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id diff --git a/examples/bin/resources/skybox-space.png.REMOVED.git-id b/examples/bin/resources/skybox-space.png.REMOVED.git-id deleted file mode 100644 index 4bbe2de56..000000000 --- a/examples/bin/resources/skybox-space.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -ca02549e21a494540751b65126dcee5fddfb84db \ No newline at end of file diff --git a/tests/Engine/Network/TCP.cpp b/tests/Engine/Network/TCP.cpp index 4a61e0197..788478c0e 100644 --- a/tests/Engine/Network/TCP.cpp +++ b/tests/Engine/Network/TCP.cpp @@ -1,10 +1,9 @@ +#include +#include +#include #include #include #include - -#include -#include - #include SCENARIO("TCP", "[NETWORK][TCP]") @@ -29,6 +28,8 @@ SCENARIO("TCP", "[NETWORK][TCP]") Nz::IpAddress clientIP = client.GetRemoteAddress(); REQUIRE(clientIP.IsValid()); + Nz::Thread::Sleep(100); + Nz::TcpClient serverToClient; REQUIRE(server.AcceptClient(&serverToClient)); diff --git a/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id b/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id deleted file mode 100644 index a686bc57d..000000000 --- a/tests/resources/Engine/Audio/Cat.flac.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -6993cbcca9ac596667135cb0f30bea4841178d3b \ No newline at end of file diff --git a/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id b/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id deleted file mode 100644 index bfd8dbd70..000000000 --- a/tests/resources/Engine/Audio/The_Brabanconne.ogg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -94b2c47c9143adbac0fb7e81df5cc87f969f7150 \ No newline at end of file