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

This commit is contained in:
Jérôme Leclercq 2017-05-29 19:55:50 +02:00
commit 421dbf54f2
6 changed files with 53 additions and 56 deletions

View File

@ -105,7 +105,7 @@ namespace Nz
{
ParameterType_Boolean,
ParameterType_Color,
ParameterType_Float,
ParameterType_Double,
ParameterType_Integer,
ParameterType_None,
ParameterType_Pointer,

View File

@ -32,8 +32,8 @@ namespace Nz
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 GetDoubleParameter(const String& name, double* value) const;
bool GetIntegerParameter(const String& name, long long* value) const;
bool GetParameterType(const String& name, ParameterType* type) const;
bool GetPointerParameter(const String& name, void** value) const;
bool GetStringParameter(const String& name, String* value) const;
@ -48,8 +48,8 @@ namespace Nz
void SetParameter(const String& name, const String& value);
void SetParameter(const String& name, const char* value);
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, double value);
void SetParameter(const String& name, long long value);
void SetParameter(const String& name, void* value);
void SetParameter(const String& name, void* value, Destructor destructor);
@ -84,8 +84,8 @@ namespace Nz
~Value() {}
bool boolVal;
float floatVal;
int intVal;
double doubleVal;
long long intVal;
void* ptrVal;
Color colorVal;
String stringVal;

View File

@ -95,7 +95,7 @@ namespace Nz
}
case ParameterType_Color:
case ParameterType_Float:
case ParameterType_Double:
case ParameterType_None:
case ParameterType_Pointer:
case ParameterType_Userdata:
@ -137,9 +137,9 @@ namespace Nz
return true;
case ParameterType_Boolean:
case ParameterType_Double:
case ParameterType_Integer:
case ParameterType_String:
case ParameterType_Float:
case ParameterType_None:
case ParameterType_Pointer:
case ParameterType_Userdata:
@ -151,19 +151,19 @@ namespace Nz
}
/*!
* \brief Gets a parameter as a float
* \return true if the parameter could be represented as a float
* \brief Gets a parameter as a double
* \return true if the parameter could be represented as a double
*
* \param name Name of the parameter
* \param value Pointer to a float to hold the retrieved value
* \param value Pointer to a double 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
* \remark If the parameter is not a double, a conversion will be performed, compatibles types are:
Integer: The integer value is converted to its double representation
String: Conversion obeys the rule as described by String::ToDouble
*/
bool ParameterList::GetFloatParameter(const String& name, float* value) const
bool ParameterList::GetDoubleParameter(const String& name, double* value) const
{
NazaraAssert(value, "Invalid pointer");
@ -178,12 +178,12 @@ namespace Nz
switch (it->second.type)
{
case ParameterType_Float:
*value = it->second.value.floatVal;
case ParameterType_Double:
*value = it->second.value.doubleVal;
return true;
case ParameterType_Integer:
*value = static_cast<float>(it->second.value.intVal);
*value = static_cast<double>(it->second.value.intVal);
return true;
case ParameterType_String:
@ -191,7 +191,7 @@ namespace Nz
double converted;
if (it->second.value.stringVal.ToDouble(&converted))
{
*value = static_cast<float>(converted);
*value = converted;
return true;
}
@ -206,7 +206,7 @@ namespace Nz
break;
}
NazaraError("Parameter value is not representable as a float");
NazaraError("Parameter value is not representable as a double");
return false;
}
@ -219,12 +219,12 @@ namespace Nz
*
* \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:
* \remark If the parameter is not an integer, 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
Double: The floating-point value is truncated and converted to a integer
String: Conversion obeys the rule as described by String::ToInteger
*/
bool ParameterList::GetIntegerParameter(const String& name, int* value) const
bool ParameterList::GetIntegerParameter(const String& name, long long* value) const
{
NazaraAssert(value, "Invalid pointer");
@ -243,8 +243,8 @@ namespace Nz
*value = (it->second.value.boolVal) ? 1 : 0;
return true;
case ParameterType_Float:
*value = static_cast<int>(it->second.value.floatVal);
case ParameterType_Double:
*value = static_cast<long long>(it->second.value.doubleVal);
return true;
case ParameterType_Integer:
@ -256,11 +256,8 @@ namespace Nz
long long converted;
if (it->second.value.stringVal.ToInteger(&converted))
{
if (converted <= std::numeric_limits<int>::max() && converted >= std::numeric_limits<int>::min())
{
*value = static_cast<int>(converted);
return true;
}
*value = converted;
return true;
}
break;
}
@ -335,7 +332,7 @@ namespace Nz
case ParameterType_Boolean:
case ParameterType_Color:
case ParameterType_Float:
case ParameterType_Double:
case ParameterType_Integer:
case ParameterType_None:
case ParameterType_String:
@ -358,7 +355,7 @@ namespace Nz
* \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
Double: 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
@ -387,8 +384,8 @@ namespace Nz
*value = it->second.value.colorVal.ToString();
return true;
case ParameterType_Float:
*value = String::Number(it->second.value.floatVal);
case ParameterType_Double:
*value = String::Number(it->second.value.doubleVal);
return true;
case ParameterType_Integer:
@ -560,18 +557,18 @@ namespace Nz
}
/*!
* \brief Sets a float parameter named `name`
* \brief Sets a double 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 float value
* \param value The double value
*/
void ParameterList::SetParameter(const String& name, float value)
void ParameterList::SetParameter(const String& name, double value)
{
Parameter& parameter = CreateValue(name);
parameter.type = ParameterType_Float;
parameter.value.floatVal = value;
parameter.type = ParameterType_Double;
parameter.value.doubleVal = value;
}
/*!
@ -582,7 +579,7 @@ namespace Nz
* \param name Name of the parameter
* \param value The integer value
*/
void ParameterList::SetParameter(const String& name, int value)
void ParameterList::SetParameter(const String& name, long long value)
{
Parameter& parameter = CreateValue(name);
parameter.type = ParameterType_Integer;
@ -627,8 +624,8 @@ namespace Nz
case ParameterType_Color:
ss << "Color(" << it->second.value.colorVal.ToString() << ")";
break;
case ParameterType_Float:
ss << "Float(" << it->second.value.floatVal << ")";
case ParameterType_Double:
ss << "Double(" << it->second.value.doubleVal << ")";
break;
case ParameterType_Integer:
ss << "Integer(" << it->second.value.intVal << ")";
@ -692,7 +689,7 @@ namespace Nz
{
case ParameterType_Boolean:
case ParameterType_Color:
case ParameterType_Float:
case ParameterType_Double:
case ParameterType_Integer:
case ParameterType_Pointer:
std::memcpy(&parameter, &it->second, sizeof(Parameter));
@ -764,7 +761,7 @@ namespace Nz
case ParameterType_Boolean:
case ParameterType_Color:
case ParameterType_Float:
case ParameterType_Double:
case ParameterType_Integer:
case ParameterType_None:
case ParameterType_Pointer:

View File

@ -124,8 +124,8 @@ namespace Nz
// Some default settings
data.SetParameter(MaterialData::Blending, true);
data.SetParameter(MaterialData::DepthWrite, true);
data.SetParameter(MaterialData::DstBlend, static_cast<int>(BlendFunc_InvSrcAlpha));
data.SetParameter(MaterialData::SrcBlend, static_cast<int>(BlendFunc_SrcAlpha));
data.SetParameter(MaterialData::DstBlend, static_cast<long long>(BlendFunc_InvSrcAlpha));
data.SetParameter(MaterialData::SrcBlend, static_cast<long long>(BlendFunc_SrcAlpha));
}
it = materialCache.emplace(matName, std::move(data)).first;
@ -139,7 +139,7 @@ namespace Nz
bool Load(Mesh* mesh, Stream& stream, const MeshParams& parameters)
{
int reservedVertexCount;
long long reservedVertexCount;
if (!parameters.custom.GetIntegerParameter("NativeOBJLoader_VertexCount", &reservedVertexCount))
reservedVertexCount = 100;

View File

@ -128,7 +128,7 @@ namespace Nz
else
{
Color colorVal;
float fValue;
double dValue;
if (matData.GetColorParameter(MaterialData::AmbientColor, &colorVal))
material->ambient = colorVal;
@ -139,8 +139,8 @@ namespace Nz
if (matData.GetColorParameter(MaterialData::SpecularColor, &colorVal))
material->specular = colorVal;
if (matData.GetFloatParameter(MaterialData::Shininess, &fValue))
material->shininess = fValue;
if (matData.GetDoubleParameter(MaterialData::Shininess, &dValue))
material->shininess = float(dValue);
if (matData.GetStringParameter(MaterialData::AlphaTexturePath, &strVal))
material->alphaMap = strVal;
@ -176,7 +176,7 @@ namespace Nz
UInt32 faceIndex = 0;
TriangleIterator triangle(staticMesh);
do
do
{
OBJParser::Face& face = meshes[i].faces[faceIndex];
face.firstVertex = faceIndex * 3;

View File

@ -24,13 +24,13 @@ SCENARIO("ParameterList", "[CORE][PARAMETERLIST]")
WHEN("We add Float '3.f'")
{
float fl = 3.f;
parameterList.SetParameter("float", fl);
double fl = 3.f;
parameterList.SetParameter("double", fl);
THEN("We can get it back")
{
float newFl;
REQUIRE(parameterList.GetFloatParameter("float", &newFl));
double newFl;
REQUIRE(parameterList.GetDoubleParameter("double", &newFl));
REQUIRE(newFl == fl);
}
}