Browse Source

Use inline for global consts in MathDefs.h & GraphicsDefs.h (#2918)

1vanK 3 years ago
parent
commit
78bbe5022c

+ 28 - 28
Source/Urho3D/AngelScript/Generated_Enums.cpp

@@ -21,10 +21,10 @@ static const unsigned char BoneCollisionShape_BONECOLLISION_NONE = BONECOLLISION
 static const unsigned char BoneCollisionShape_BONECOLLISION_SPHERE = BONECOLLISION_SPHERE;
 static const unsigned char BoneCollisionShape_BONECOLLISION_BOX = BONECOLLISION_BOX;
 
-// enum ClearTarget : unsigned | File: ../Graphics/GraphicsDefs.h
-static const unsigned ClearTarget_CLEAR_COLOR = CLEAR_COLOR;
-static const unsigned ClearTarget_CLEAR_DEPTH = CLEAR_DEPTH;
-static const unsigned ClearTarget_CLEAR_STENCIL = CLEAR_STENCIL;
+// enum ClearTarget : u32 | File: ../Graphics/GraphicsDefs.h
+static const u32 ClearTarget_CLEAR_COLOR = CLEAR_COLOR;
+static const u32 ClearTarget_CLEAR_DEPTH = CLEAR_DEPTH;
+static const u32 ClearTarget_CLEAR_STENCIL = CLEAR_STENCIL;
 
 // enum ControllerAxis : unsigned | File: ../Input/InputConstants.h
 static const unsigned ControllerAxis_CONTROLLER_AXIS_LEFTX = CONTROLLER_AXIS_LEFTX;
@@ -305,11 +305,11 @@ static const unsigned Key_KEY_VOLUMEDOWN = KEY_VOLUMEDOWN;
 static const unsigned Key_KEY_VOLUMEUP = KEY_VOLUMEUP;
 static const unsigned Key_KEY_WWW = KEY_WWW;
 
-// enum MaterialQuality : unsigned | File: ../Graphics/GraphicsDefs.h
-static const unsigned MaterialQuality_QUALITY_LOW = QUALITY_LOW;
-static const unsigned MaterialQuality_QUALITY_MEDIUM = QUALITY_MEDIUM;
-static const unsigned MaterialQuality_QUALITY_HIGH = QUALITY_HIGH;
-static const unsigned MaterialQuality_QUALITY_MAX = QUALITY_MAX;
+// enum MaterialQuality : u32 | File: ../Graphics/GraphicsDefs.h
+static const u32 MaterialQuality_QUALITY_LOW = QUALITY_LOW;
+static const u32 MaterialQuality_QUALITY_MEDIUM = QUALITY_MEDIUM;
+static const u32 MaterialQuality_QUALITY_HIGH = QUALITY_HIGH;
+static const u32 MaterialQuality_QUALITY_MAX = QUALITY_MAX;
 
 // enum MouseButton : unsigned | File: ../Input/InputConstants.h
 static const unsigned MouseButton_MOUSEB_NONE = MOUSEB_NONE;
@@ -586,22 +586,22 @@ static const unsigned UpdateEvent_USE_POSTUPDATE = USE_POSTUPDATE;
 static const unsigned UpdateEvent_USE_FIXEDUPDATE = USE_FIXEDUPDATE;
 static const unsigned UpdateEvent_USE_FIXEDPOSTUPDATE = USE_FIXEDPOSTUPDATE;
 
-// enum VertexMask : unsigned | File: ../Graphics/GraphicsDefs.h
-static const unsigned VertexMask_MASK_NONE = MASK_NONE;
-static const unsigned VertexMask_MASK_POSITION = MASK_POSITION;
-static const unsigned VertexMask_MASK_NORMAL = MASK_NORMAL;
-static const unsigned VertexMask_MASK_COLOR = MASK_COLOR;
-static const unsigned VertexMask_MASK_TEXCOORD1 = MASK_TEXCOORD1;
-static const unsigned VertexMask_MASK_TEXCOORD2 = MASK_TEXCOORD2;
-static const unsigned VertexMask_MASK_CUBETEXCOORD1 = MASK_CUBETEXCOORD1;
-static const unsigned VertexMask_MASK_CUBETEXCOORD2 = MASK_CUBETEXCOORD2;
-static const unsigned VertexMask_MASK_TANGENT = MASK_TANGENT;
-static const unsigned VertexMask_MASK_BLENDWEIGHTS = MASK_BLENDWEIGHTS;
-static const unsigned VertexMask_MASK_BLENDINDICES = MASK_BLENDINDICES;
-static const unsigned VertexMask_MASK_INSTANCEMATRIX1 = MASK_INSTANCEMATRIX1;
-static const unsigned VertexMask_MASK_INSTANCEMATRIX2 = MASK_INSTANCEMATRIX2;
-static const unsigned VertexMask_MASK_INSTANCEMATRIX3 = MASK_INSTANCEMATRIX3;
-static const unsigned VertexMask_MASK_OBJECTINDEX = MASK_OBJECTINDEX;
+// enum VertexMask : u32 | File: ../Graphics/GraphicsDefs.h
+static const u32 VertexMask_MASK_NONE = MASK_NONE;
+static const u32 VertexMask_MASK_POSITION = MASK_POSITION;
+static const u32 VertexMask_MASK_NORMAL = MASK_NORMAL;
+static const u32 VertexMask_MASK_COLOR = MASK_COLOR;
+static const u32 VertexMask_MASK_TEXCOORD1 = MASK_TEXCOORD1;
+static const u32 VertexMask_MASK_TEXCOORD2 = MASK_TEXCOORD2;
+static const u32 VertexMask_MASK_CUBETEXCOORD1 = MASK_CUBETEXCOORD1;
+static const u32 VertexMask_MASK_CUBETEXCOORD2 = MASK_CUBETEXCOORD2;
+static const u32 VertexMask_MASK_TANGENT = MASK_TANGENT;
+static const u32 VertexMask_MASK_BLENDWEIGHTS = MASK_BLENDWEIGHTS;
+static const u32 VertexMask_MASK_BLENDINDICES = MASK_BLENDINDICES;
+static const u32 VertexMask_MASK_INSTANCEMATRIX1 = MASK_INSTANCEMATRIX1;
+static const u32 VertexMask_MASK_INSTANCEMATRIX2 = MASK_INSTANCEMATRIX2;
+static const u32 VertexMask_MASK_INSTANCEMATRIX3 = MASK_INSTANCEMATRIX3;
+static const u32 VertexMask_MASK_OBJECTINDEX = MASK_OBJECTINDEX;
 
 // enum ViewOverride : unsigned | File: ../Graphics/Camera.h
 static const unsigned ViewOverride_VO_NONE = VO_NONE;
@@ -678,7 +678,7 @@ void ASRegisterGeneratedEnums(asIScriptEngine* engine)
     // URHO3D_FLAGSET(BoneCollisionShape, BoneCollisionShapeFlags) | File: ../Graphics/Skeleton.h
     engine->RegisterTypedef("BoneCollisionShapeFlags", "uint8");
 
-    // enum ClearTarget : unsigned | File: ../Graphics/GraphicsDefs.h
+    // enum ClearTarget : u32 | File: ../Graphics/GraphicsDefs.h
     engine->RegisterTypedef("ClearTarget", "uint");
     engine->RegisterGlobalProperty("const uint CLEAR_COLOR", (void*)&ClearTarget_CLEAR_COLOR);
     engine->RegisterGlobalProperty("const uint CLEAR_DEPTH", (void*)&ClearTarget_CLEAR_DEPTH);
@@ -1316,7 +1316,7 @@ void ASRegisterGeneratedEnums(asIScriptEngine* engine)
     engine->RegisterEnumValue("LockState", "LOCK_SHADOW", LOCK_SHADOW);
     engine->RegisterEnumValue("LockState", "LOCK_SCRATCH", LOCK_SCRATCH);
 
-    // enum MaterialQuality : unsigned | File: ../Graphics/GraphicsDefs.h
+    // enum MaterialQuality : u32 | File: ../Graphics/GraphicsDefs.h
     engine->RegisterTypedef("MaterialQuality", "uint");
     engine->RegisterGlobalProperty("const uint QUALITY_LOW", (void*)&MaterialQuality_QUALITY_LOW);
     engine->RegisterGlobalProperty("const uint QUALITY_MEDIUM", (void*)&MaterialQuality_QUALITY_MEDIUM);
@@ -1845,7 +1845,7 @@ void ASRegisterGeneratedEnums(asIScriptEngine* engine)
     engine->RegisterEnumValue("VertexLightVSVariation", "VLVS_4LIGHTS", VLVS_4LIGHTS);
     engine->RegisterEnumValue("VertexLightVSVariation", "MAX_VERTEXLIGHT_VS_VARIATIONS", MAX_VERTEXLIGHT_VS_VARIATIONS);
 
-    // enum VertexMask : unsigned | File: ../Graphics/GraphicsDefs.h
+    // enum VertexMask : u32 | File: ../Graphics/GraphicsDefs.h
     engine->RegisterTypedef("VertexMask", "uint");
     engine->RegisterGlobalProperty("const uint MASK_NONE", (void*)&VertexMask_MASK_NONE);
     engine->RegisterGlobalProperty("const uint MASK_POSITION", (void*)&VertexMask_MASK_POSITION);

+ 20 - 20
Source/Urho3D/AngelScript/Generated_GlobalVariables.cpp

@@ -16,7 +16,7 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // static const float ANIMATION_LOD_BASESCALE | File: ../Graphics/Drawable.h
     engine->RegisterGlobalProperty("const float ANIMATION_LOD_BASESCALE", (void*)&ANIMATION_LOD_BASESCALE);
 
-    // static const int BITS_PER_COMPONENT | File: ../Graphics/GraphicsDefs.h
+    // constexpr i32 BITS_PER_COMPONENT | File: ../Graphics/GraphicsDefs.h
     engine->RegisterGlobalProperty("const int BITS_PER_COMPONENT", (void*)&BITS_PER_COMPONENT);
 
     // static const int COLOR_LUT_SIZE | File: ../Resource/Image.h
@@ -100,7 +100,7 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // static const unsigned DRAWABLE_ZONE | File: ../Graphics/Drawable.h
     engine->RegisterGlobalProperty("const uint DRAWABLE_ZONE", (void*)&DRAWABLE_ZONE);
 
-    // const unsigned ELEMENT_TYPESIZES[] | File: ../Graphics/GraphicsDefs.h
+    // const u32 ELEMENT_TYPESIZES[] | File: ../Graphics/GraphicsDefs.h
     // Not registered because array
 
     // static const String EP_AUTOLOAD_PATHS | File: ../Engine/EngineDefs.h
@@ -304,7 +304,7 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // static const unsigned MAX_CASCADE_SPLITS | File: ../Graphics/Light.h
     engine->RegisterGlobalProperty("const uint MAX_CASCADE_SPLITS", (void*)&MAX_CASCADE_SPLITS);
 
-    // static const int MAX_CONSTANT_REGISTERS | File: ../Graphics/GraphicsDefs.h
+    // constexpr i32 MAX_CONSTANT_REGISTERS | File: ../Graphics/GraphicsDefs.h
     engine->RegisterGlobalProperty("const int MAX_CONSTANT_REGISTERS", (void*)&MAX_CONSTANT_REGISTERS);
 
     // static const int MAX_LIGHT_SPLITS | File: ../Graphics/Light.h
@@ -313,7 +313,7 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // static const unsigned MAX_NETWORK_ATTRIBUTES | File: ../Scene/ReplicationState.h
     engine->RegisterGlobalProperty("const uint MAX_NETWORK_ATTRIBUTES", (void*)&MAX_NETWORK_ATTRIBUTES);
 
-    // static const int MAX_RENDERTARGETS | File: ../Graphics/GraphicsDefs.h
+    // constexpr i32 MAX_RENDERTARGETS | File: ../Graphics/GraphicsDefs.h
     engine->RegisterGlobalProperty("const int MAX_RENDERTARGETS", (void*)&MAX_RENDERTARGETS);
 
     // static const int MAX_TEXTURE_QUALITY_LEVELS | File: ../Graphics/Texture.h
@@ -322,7 +322,7 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // static const int MAX_VERTEX_LIGHTS | File: ../Graphics/Drawable.h
     engine->RegisterGlobalProperty("const int MAX_VERTEX_LIGHTS", (void*)&MAX_VERTEX_LIGHTS);
 
-    // static const int MAX_VERTEX_STREAMS | File: ../Graphics/GraphicsDefs.h
+    // constexpr i32 MAX_VERTEX_STREAMS | File: ../Graphics/GraphicsDefs.h
     engine->RegisterGlobalProperty("const int MAX_VERTEX_STREAMS", (void*)&MAX_VERTEX_STREAMS);
 
     // static const unsigned MAX_VIEWPORT_TEXTURES | File: ../Graphics/View.h
@@ -331,49 +331,49 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // const IntVector2 MOUSE_POSITION_OFFSCREEN | File: ../Input/Input.h
     engine->RegisterGlobalProperty("const IntVector2 MOUSE_POSITION_OFFSCREEN", (void*)&MOUSE_POSITION_OFFSCREEN);
 
-    // static const float M_DEGTORAD | File: ../Math/MathDefs.h
+    // constexpr float M_DEGTORAD | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_DEGTORAD", (void*)&M_DEGTORAD);
 
-    // static const float M_DEGTORAD_2 | File: ../Math/MathDefs.h
+    // constexpr float M_DEGTORAD_2 | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_DEGTORAD_2", (void*)&M_DEGTORAD_2);
 
-    // static const float M_EPSILON | File: ../Math/MathDefs.h
+    // constexpr float M_EPSILON | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_EPSILON", (void*)&M_EPSILON);
 
-    // static const float M_HALF_PI | File: ../Math/MathDefs.h
+    // constexpr float M_HALF_PI | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_HALF_PI", (void*)&M_HALF_PI);
 
-    // static const float M_INFINITY | File: ../Math/MathDefs.h
+    // constexpr float M_INFINITY | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_INFINITY", (void*)&M_INFINITY);
 
-    // static const float M_LARGE_EPSILON | File: ../Math/MathDefs.h
+    // constexpr float M_LARGE_EPSILON | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_LARGE_EPSILON", (void*)&M_LARGE_EPSILON);
 
-    // static const float M_LARGE_VALUE | File: ../Math/MathDefs.h
+    // constexpr float M_LARGE_VALUE | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_LARGE_VALUE", (void*)&M_LARGE_VALUE);
 
-    // static const float M_MAX_FOV | File: ../Math/MathDefs.h
+    // constexpr float M_MAX_FOV | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_MAX_FOV", (void*)&M_MAX_FOV);
 
-    // static const int M_MAX_INT | File: ../Math/MathDefs.h
+    // constexpr i32 M_MAX_INT | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const int M_MAX_INT", (void*)&M_MAX_INT);
 
-    // static const unsigned M_MAX_UNSIGNED | File: ../Math/MathDefs.h
+    // constexpr u32 M_MAX_UNSIGNED | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const uint M_MAX_UNSIGNED", (void*)&M_MAX_UNSIGNED);
 
-    // static const int M_MIN_INT | File: ../Math/MathDefs.h
+    // constexpr i32 M_MIN_INT | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const int M_MIN_INT", (void*)&M_MIN_INT);
 
-    // static const float M_MIN_NEARCLIP | File: ../Math/MathDefs.h
+    // constexpr float M_MIN_NEARCLIP | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_MIN_NEARCLIP", (void*)&M_MIN_NEARCLIP);
 
-    // static const unsigned M_MIN_UNSIGNED | File: ../Math/MathDefs.h
+    // constexpr u32 M_MIN_UNSIGNED | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const uint M_MIN_UNSIGNED", (void*)&M_MIN_UNSIGNED);
 
-    // static const float M_PI | File: ../Math/MathDefs.h
+    // constexpr float M_PI | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_PI", (void*)&M_PI);
 
-    // static const float M_RADTODEG | File: ../Math/MathDefs.h
+    // constexpr float M_RADTODEG | File: ../Math/MathDefs.h
     engine->RegisterGlobalProperty("const float M_RADTODEG", (void*)&M_RADTODEG);
 
     // static const unsigned NUM_FRUSTUM_PLANES | File: ../Math/Frustum.h

+ 61 - 125
Source/Urho3D/Graphics/GraphicsDefs.cpp

@@ -1,125 +1,61 @@
-//
-// Copyright (c) 2008-2022 the Urho3D project.
-//
-// 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.
-//
-
-#include "../Precompiled.h"
-
-#include "../Graphics/GraphicsDefs.h"
-#include "../Math/Vector3.h"
-
-#include "../DebugNew.h"
-
-namespace Urho3D
-{
-
-// The extern keyword is required when building Urho3D.dll for Windows platform
-// The keyword is not required for other platforms but it does no harm, aside from warning from static analyzer
-
-extern URHO3D_API const StringHash VSP_AMBIENTSTARTCOLOR("AmbientStartColor");
-extern URHO3D_API const StringHash VSP_AMBIENTENDCOLOR("AmbientEndColor");
-extern URHO3D_API const StringHash VSP_BILLBOARDROT("BillboardRot");
-extern URHO3D_API const StringHash VSP_CAMERAPOS("CameraPos");
-extern URHO3D_API const StringHash VSP_CLIPPLANE("ClipPlane");
-extern URHO3D_API const StringHash VSP_NEARCLIP("NearClip");
-extern URHO3D_API const StringHash VSP_FARCLIP("FarClip");
-extern URHO3D_API const StringHash VSP_DEPTHMODE("DepthMode");
-extern URHO3D_API const StringHash VSP_DELTATIME("DeltaTime");
-extern URHO3D_API const StringHash VSP_ELAPSEDTIME("ElapsedTime");
-extern URHO3D_API const StringHash VSP_FRUSTUMSIZE("FrustumSize");
-extern URHO3D_API const StringHash VSP_GBUFFEROFFSETS("GBufferOffsets");
-extern URHO3D_API const StringHash VSP_LIGHTDIR("LightDir");
-extern URHO3D_API const StringHash VSP_LIGHTPOS("LightPos");
-extern URHO3D_API const StringHash VSP_NORMALOFFSETSCALE("NormalOffsetScale");
-extern URHO3D_API const StringHash VSP_MODEL("Model");
-extern URHO3D_API const StringHash VSP_VIEW("View");
-extern URHO3D_API const StringHash VSP_VIEWINV("ViewInv");
-extern URHO3D_API const StringHash VSP_VIEWPROJ("ViewProj");
-extern URHO3D_API const StringHash VSP_UOFFSET("UOffset");
-extern URHO3D_API const StringHash VSP_VOFFSET("VOffset");
-extern URHO3D_API const StringHash VSP_ZONE("Zone");
-extern URHO3D_API const StringHash VSP_LIGHTMATRICES("LightMatrices");
-extern URHO3D_API const StringHash VSP_SKINMATRICES("SkinMatrices");
-extern URHO3D_API const StringHash VSP_VERTEXLIGHTS("VertexLights");
-extern URHO3D_API const StringHash PSP_AMBIENTCOLOR("AmbientColor");
-extern URHO3D_API const StringHash PSP_CAMERAPOS("CameraPosPS");
-extern URHO3D_API const StringHash PSP_DELTATIME("DeltaTimePS");
-extern URHO3D_API const StringHash PSP_DEPTHRECONSTRUCT("DepthReconstruct");
-extern URHO3D_API const StringHash PSP_ELAPSEDTIME("ElapsedTimePS");
-extern URHO3D_API const StringHash PSP_FOGCOLOR("FogColor");
-extern URHO3D_API const StringHash PSP_FOGPARAMS("FogParams");
-extern URHO3D_API const StringHash PSP_GBUFFERINVSIZE("GBufferInvSize");
-extern URHO3D_API const StringHash PSP_LIGHTCOLOR("LightColor");
-extern URHO3D_API const StringHash PSP_LIGHTDIR("LightDirPS");
-extern URHO3D_API const StringHash PSP_LIGHTPOS("LightPosPS");
-extern URHO3D_API const StringHash PSP_NORMALOFFSETSCALE("NormalOffsetScalePS");
-extern URHO3D_API const StringHash PSP_MATDIFFCOLOR("MatDiffColor");
-extern URHO3D_API const StringHash PSP_MATEMISSIVECOLOR("MatEmissiveColor");
-extern URHO3D_API const StringHash PSP_MATENVMAPCOLOR("MatEnvMapColor");
-extern URHO3D_API const StringHash PSP_MATSPECCOLOR("MatSpecColor");
-extern URHO3D_API const StringHash PSP_NEARCLIP("NearClipPS");
-extern URHO3D_API const StringHash PSP_FARCLIP("FarClipPS");
-extern URHO3D_API const StringHash PSP_SHADOWCUBEADJUST("ShadowCubeAdjust");
-extern URHO3D_API const StringHash PSP_SHADOWDEPTHFADE("ShadowDepthFade");
-extern URHO3D_API const StringHash PSP_SHADOWINTENSITY("ShadowIntensity");
-extern URHO3D_API const StringHash PSP_SHADOWMAPINVSIZE("ShadowMapInvSize");
-extern URHO3D_API const StringHash PSP_SHADOWSPLITS("ShadowSplits");
-extern URHO3D_API const StringHash PSP_LIGHTMATRICES("LightMatricesPS");
-extern URHO3D_API const StringHash PSP_VSMSHADOWPARAMS("VSMShadowParams");
-extern URHO3D_API const StringHash PSP_ROUGHNESS("Roughness");
-extern URHO3D_API const StringHash PSP_METALLIC("Metallic");
-extern URHO3D_API const StringHash PSP_LIGHTRAD("LightRad");
-extern URHO3D_API const StringHash PSP_LIGHTLENGTH("LightLength");
-extern URHO3D_API const StringHash PSP_ZONEMIN("ZoneMin");
-extern URHO3D_API const StringHash PSP_ZONEMAX("ZoneMax");
-
-extern URHO3D_API const Vector3 DOT_SCALE(1 / 3.0f, 1 / 3.0f, 1 / 3.0f);
-
-extern URHO3D_API const VertexElement LEGACY_VERTEXELEMENTS[] =
-{
-    VertexElement(TYPE_VECTOR3, SEM_POSITION, 0, false),     // Position
-    VertexElement(TYPE_VECTOR3, SEM_NORMAL, 0, false),       // Normal
-    VertexElement(TYPE_UBYTE4_NORM, SEM_COLOR, 0, false),    // Color
-    VertexElement(TYPE_VECTOR2, SEM_TEXCOORD, 0, false),     // Texcoord1
-    VertexElement(TYPE_VECTOR2, SEM_TEXCOORD, 1, false),     // Texcoord2
-    VertexElement(TYPE_VECTOR3, SEM_TEXCOORD, 0, false),     // Cubetexcoord1
-    VertexElement(TYPE_VECTOR3, SEM_TEXCOORD, 1, false),     // Cubetexcoord2
-    VertexElement(TYPE_VECTOR4, SEM_TANGENT, 0, false),      // Tangent
-    VertexElement(TYPE_VECTOR4, SEM_BLENDWEIGHTS, 0, false), // Blendweights
-    VertexElement(TYPE_UBYTE4, SEM_BLENDINDICES, 0, false),  // Blendindices
-    VertexElement(TYPE_VECTOR4, SEM_TEXCOORD, 4, true),      // Instancematrix1
-    VertexElement(TYPE_VECTOR4, SEM_TEXCOORD, 5, true),      // Instancematrix2
-    VertexElement(TYPE_VECTOR4, SEM_TEXCOORD, 6, true),      // Instancematrix3
-    VertexElement(TYPE_INT, SEM_OBJECTINDEX, 0, false)       // Objectindex
-};
-
-extern URHO3D_API const unsigned ELEMENT_TYPESIZES[] =
-{
-    sizeof(int),
-    sizeof(float),
-    2 * sizeof(float),
-    3 * sizeof(float),
-    4 * sizeof(float),
-    sizeof(unsigned),
-    sizeof(unsigned)
-};
-
-
-}
+//
+// Copyright (c) 2008-2022 the Urho3D project.
+//
+// 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.
+//
+
+#include "../Precompiled.h"
+
+#include "../Graphics/GraphicsDefs.h"
+
+#include "../DebugNew.h"
+
+namespace Urho3D
+{
+
+const VertexElement LEGACY_VERTEXELEMENTS[] =
+{
+    VertexElement(TYPE_VECTOR3, SEM_POSITION, 0, false),     // Position
+    VertexElement(TYPE_VECTOR3, SEM_NORMAL, 0, false),       // Normal
+    VertexElement(TYPE_UBYTE4_NORM, SEM_COLOR, 0, false),    // Color
+    VertexElement(TYPE_VECTOR2, SEM_TEXCOORD, 0, false),     // Texcoord1
+    VertexElement(TYPE_VECTOR2, SEM_TEXCOORD, 1, false),     // Texcoord2
+    VertexElement(TYPE_VECTOR3, SEM_TEXCOORD, 0, false),     // Cubetexcoord1
+    VertexElement(TYPE_VECTOR3, SEM_TEXCOORD, 1, false),     // Cubetexcoord2
+    VertexElement(TYPE_VECTOR4, SEM_TANGENT, 0, false),      // Tangent
+    VertexElement(TYPE_VECTOR4, SEM_BLENDWEIGHTS, 0, false), // Blendweights
+    VertexElement(TYPE_UBYTE4, SEM_BLENDINDICES, 0, false),  // Blendindices
+    VertexElement(TYPE_VECTOR4, SEM_TEXCOORD, 4, true),      // Instancematrix1
+    VertexElement(TYPE_VECTOR4, SEM_TEXCOORD, 5, true),      // Instancematrix2
+    VertexElement(TYPE_VECTOR4, SEM_TEXCOORD, 6, true),      // Instancematrix3
+    VertexElement(TYPE_INT, SEM_OBJECTINDEX, 0, false)       // Objectindex
+};
+
+const u32 ELEMENT_TYPESIZES[] =
+{
+    sizeof(int),
+    sizeof(float),
+    2 * sizeof(float),
+    3 * sizeof(float),
+    4 * sizeof(float),
+    sizeof(unsigned),
+    sizeof(unsigned)
+};
+
+} // namespace Urho3D

+ 77 - 66
Source/Urho3D/Graphics/GraphicsDefs.h

@@ -27,6 +27,7 @@
 #include "../Container/FlagSet.h"
 #include "../Container/HashBase.h"
 #include "../Math/StringHash.h"
+#include "../Math/Vector3.h"
 
 namespace Urho3D
 {
@@ -229,7 +230,7 @@ struct URHO3D_API VertexElement
 };
 
 /// Sizes of vertex element types.
-extern URHO3D_API const unsigned ELEMENT_TYPESIZES[];
+extern URHO3D_API const u32 ELEMENT_TYPESIZES[];
 
 /// Vertex element definitions for the legacy elements.
 extern URHO3D_API const VertexElement LEGACY_VERTEXELEMENTS[];
@@ -382,67 +383,76 @@ enum ShadowQuality
 };
 
 // Inbuilt shader parameters.
-extern URHO3D_API const StringHash VSP_AMBIENTSTARTCOLOR;
-extern URHO3D_API const StringHash VSP_AMBIENTENDCOLOR;
-extern URHO3D_API const StringHash VSP_BILLBOARDROT;
-extern URHO3D_API const StringHash VSP_CAMERAPOS;
-extern URHO3D_API const StringHash VSP_CLIPPLANE;
-extern URHO3D_API const StringHash VSP_NEARCLIP;
-extern URHO3D_API const StringHash VSP_FARCLIP;
-extern URHO3D_API const StringHash VSP_DEPTHMODE;
-extern URHO3D_API const StringHash VSP_DELTATIME;
-extern URHO3D_API const StringHash VSP_ELAPSEDTIME;
-extern URHO3D_API const StringHash VSP_FRUSTUMSIZE;
-extern URHO3D_API const StringHash VSP_GBUFFEROFFSETS;
-extern URHO3D_API const StringHash VSP_LIGHTDIR;
-extern URHO3D_API const StringHash VSP_LIGHTPOS;
-extern URHO3D_API const StringHash VSP_NORMALOFFSETSCALE;
-extern URHO3D_API const StringHash VSP_MODEL;
-extern URHO3D_API const StringHash VSP_VIEW;
-extern URHO3D_API const StringHash VSP_VIEWINV;
-extern URHO3D_API const StringHash VSP_VIEWPROJ;
-extern URHO3D_API const StringHash VSP_UOFFSET;
-extern URHO3D_API const StringHash VSP_VOFFSET;
-extern URHO3D_API const StringHash VSP_ZONE;
-extern URHO3D_API const StringHash VSP_LIGHTMATRICES;
-extern URHO3D_API const StringHash VSP_SKINMATRICES;
-extern URHO3D_API const StringHash VSP_VERTEXLIGHTS;
-extern URHO3D_API const StringHash PSP_AMBIENTCOLOR;
-extern URHO3D_API const StringHash PSP_CAMERAPOS;
-extern URHO3D_API const StringHash PSP_DELTATIME;
-extern URHO3D_API const StringHash PSP_DEPTHRECONSTRUCT;
-extern URHO3D_API const StringHash PSP_ELAPSEDTIME;
-extern URHO3D_API const StringHash PSP_FOGCOLOR;
-extern URHO3D_API const StringHash PSP_FOGPARAMS;
-extern URHO3D_API const StringHash PSP_GBUFFERINVSIZE;
-extern URHO3D_API const StringHash PSP_LIGHTCOLOR;
-extern URHO3D_API const StringHash PSP_LIGHTDIR;
-extern URHO3D_API const StringHash PSP_LIGHTPOS;
-extern URHO3D_API const StringHash PSP_NORMALOFFSETSCALE;
-extern URHO3D_API const StringHash PSP_MATDIFFCOLOR;
-extern URHO3D_API const StringHash PSP_MATEMISSIVECOLOR;
-extern URHO3D_API const StringHash PSP_MATENVMAPCOLOR;
-extern URHO3D_API const StringHash PSP_MATSPECCOLOR;
-extern URHO3D_API const StringHash PSP_NEARCLIP;
-extern URHO3D_API const StringHash PSP_FARCLIP;
-extern URHO3D_API const StringHash PSP_SHADOWCUBEADJUST;
-extern URHO3D_API const StringHash PSP_SHADOWDEPTHFADE;
-extern URHO3D_API const StringHash PSP_SHADOWINTENSITY;
-extern URHO3D_API const StringHash PSP_SHADOWMAPINVSIZE;
-extern URHO3D_API const StringHash PSP_SHADOWSPLITS;
-extern URHO3D_API const StringHash PSP_LIGHTMATRICES;
-extern URHO3D_API const StringHash PSP_VSMSHADOWPARAMS;
-extern URHO3D_API const StringHash PSP_ROUGHNESS;
-extern URHO3D_API const StringHash PSP_METALLIC;
-extern URHO3D_API const StringHash PSP_LIGHTRAD;
-extern URHO3D_API const StringHash PSP_LIGHTLENGTH;
-extern URHO3D_API const StringHash PSP_ZONEMIN;
-extern URHO3D_API const StringHash PSP_ZONEMAX;
+inline const StringHash VSP_AMBIENTENDCOLOR{"AmbientEndColor"};
+inline const StringHash VSP_AMBIENTSTARTCOLOR{"AmbientStartColor"};
+inline const StringHash VSP_BILLBOARDROT{"BillboardRot"};
+inline const StringHash VSP_CLIPPLANE{"ClipPlane"};
+inline const StringHash VSP_DEPTHMODE{"DepthMode"};
+inline const StringHash VSP_FRUSTUMSIZE{"FrustumSize"};
+inline const StringHash VSP_GBUFFEROFFSETS{"GBufferOffsets"};
+inline const StringHash VSP_MODEL{"Model"};
+inline const StringHash VSP_SKINMATRICES{"SkinMatrices"};
+inline const StringHash VSP_UOFFSET{"UOffset"};
+inline const StringHash VSP_VERTEXLIGHTS{"VertexLights"};
+inline const StringHash VSP_VIEW{"View"};
+inline const StringHash VSP_VIEWINV{"ViewInv"};
+inline const StringHash VSP_VIEWPROJ{"ViewProj"};
+inline const StringHash VSP_VOFFSET{"VOffset"};
+inline const StringHash VSP_ZONE{"Zone"};
+inline const StringHash PSP_AMBIENTCOLOR{"AmbientColor"};
+inline const StringHash PSP_DEPTHRECONSTRUCT{"DepthReconstruct"};
+inline const StringHash PSP_FOGCOLOR{"FogColor"};
+inline const StringHash PSP_FOGPARAMS{"FogParams"};
+inline const StringHash PSP_GBUFFERINVSIZE{"GBufferInvSize"};
+inline const StringHash PSP_LIGHTCOLOR{"LightColor"};
+inline const StringHash PSP_LIGHTLENGTH{"LightLength"};
+inline const StringHash PSP_LIGHTRAD{"LightRad"};
+inline const StringHash PSP_MATDIFFCOLOR{"MatDiffColor"};
+inline const StringHash PSP_MATEMISSIVECOLOR{"MatEmissiveColor"};
+inline const StringHash PSP_MATENVMAPCOLOR{"MatEnvMapColor"};
+inline const StringHash PSP_MATSPECCOLOR{"MatSpecColor"};
+inline const StringHash PSP_METALLIC{"Metallic"};
+inline const StringHash PSP_ROUGHNESS{"Roughness"};
+inline const StringHash PSP_SHADOWCUBEADJUST{"ShadowCubeAdjust"};
+inline const StringHash PSP_SHADOWDEPTHFADE{"ShadowDepthFade"};
+inline const StringHash PSP_SHADOWINTENSITY{"ShadowIntensity"};
+inline const StringHash PSP_SHADOWMAPINVSIZE{"ShadowMapInvSize"};
+inline const StringHash PSP_SHADOWSPLITS{"ShadowSplits"};
+inline const StringHash PSP_VSMSHADOWPARAMS{"VSMShadowParams"};
+inline const StringHash PSP_ZONEMAX{"ZoneMax"};
+inline const StringHash PSP_ZONEMIN{"ZoneMin"};
+
+inline const StringHash VSP_CAMERAPOS{"CameraPos"};
+inline const StringHash PSP_CAMERAPOS{"CameraPosPS"};
+
+inline const StringHash VSP_DELTATIME{"DeltaTime"};
+inline const StringHash PSP_DELTATIME{"DeltaTimePS"};
+
+inline const StringHash VSP_ELAPSEDTIME{"ElapsedTime"};
+inline const StringHash PSP_ELAPSEDTIME{"ElapsedTimePS"};
+
+inline const StringHash VSP_FARCLIP{"FarClip"};
+inline const StringHash PSP_FARCLIP{"FarClipPS"};
+
+inline const StringHash VSP_LIGHTDIR{"LightDir"};
+inline const StringHash PSP_LIGHTDIR{"LightDirPS"};
+
+inline const StringHash VSP_LIGHTMATRICES{"LightMatrices"};
+inline const StringHash PSP_LIGHTMATRICES{"LightMatricesPS"};
+
+inline const StringHash VSP_LIGHTPOS{"LightPos"};
+inline const StringHash PSP_LIGHTPOS{"LightPosPS"};
+
+inline const StringHash VSP_NEARCLIP{"NearClip"};
+inline const StringHash PSP_NEARCLIP{"NearClipPS"};
+
+inline const StringHash VSP_NORMALOFFSETSCALE{"NormalOffsetScale"};
+inline const StringHash PSP_NORMALOFFSETSCALE{"NormalOffsetScalePS"};
 
 // Scale calculation from bounding box diagonal.
-extern URHO3D_API const Vector3 DOT_SCALE;
+inline const Vector3 DOT_SCALE{1 / 3.0f, 1 / 3.0f, 1 / 3.0f};
 
-enum MaterialQuality : unsigned
+enum MaterialQuality : u32
 {
     QUALITY_LOW = 0,
     QUALITY_MEDIUM = 1,
@@ -450,7 +460,7 @@ enum MaterialQuality : unsigned
     QUALITY_MAX = 15,
 };
 
-enum ClearTarget : unsigned
+enum ClearTarget : u32
 {
     CLEAR_COLOR = 0x1,
     CLEAR_DEPTH = 0x2,
@@ -459,7 +469,7 @@ enum ClearTarget : unsigned
 URHO3D_FLAGSET(ClearTarget, ClearTargetFlags);
 
 // Legacy vertex element bitmasks.
-enum VertexMask : unsigned
+enum VertexMask : u32
 {
     MASK_NONE = 0x0,
     MASK_POSITION = 0x1,
@@ -479,9 +489,10 @@ enum VertexMask : unsigned
 };
 URHO3D_FLAGSET(VertexMask, VertexMaskFlags);
 
-static const int MAX_RENDERTARGETS = 4;
-static const int MAX_VERTEX_STREAMS = 4;
-static const int MAX_CONSTANT_REGISTERS = 256;
+inline constexpr i32 MAX_RENDERTARGETS = 4;
+inline constexpr i32 MAX_VERTEX_STREAMS = 4;
+inline constexpr i32 MAX_CONSTANT_REGISTERS = 256;
 
-static const int BITS_PER_COMPONENT = 8;
-}
+inline constexpr i32 BITS_PER_COMPONENT = 8;
+
+} // namespace Urho3D

+ 16 - 16
Source/Urho3D/Math/MathDefs.h

@@ -41,22 +41,22 @@ namespace Urho3D
 {
 
 #undef M_PI
-static const float M_PI = 3.14159265358979323846264338327950288f;
-static const float M_HALF_PI = M_PI * 0.5f;
-static const int M_MIN_INT = 0x80000000;
-static const int M_MAX_INT = 0x7fffffff;
-static const unsigned M_MIN_UNSIGNED = 0x00000000;
-static const unsigned M_MAX_UNSIGNED = 0xffffffff;
-
-static const float M_EPSILON = 0.000001f;
-static const float M_LARGE_EPSILON = 0.00005f;
-static const float M_MIN_NEARCLIP = 0.01f;
-static const float M_MAX_FOV = 160.0f;
-static const float M_LARGE_VALUE = 100000000.0f;
-static const float M_INFINITY = (float)HUGE_VAL;
-static const float M_DEGTORAD = M_PI / 180.0f;
-static const float M_DEGTORAD_2 = M_PI / 360.0f;    // M_DEGTORAD / 2.f
-static const float M_RADTODEG = 1.0f / M_DEGTORAD;
+inline constexpr float M_PI = 3.14159265358979323846264338327950288f;
+inline constexpr float M_HALF_PI = M_PI * 0.5f;
+inline constexpr i32 M_MIN_INT = 0x80000000;
+inline constexpr i32 M_MAX_INT = 0x7fffffff;
+inline constexpr u32 M_MIN_UNSIGNED = 0x00000000;
+inline constexpr u32 M_MAX_UNSIGNED = 0xffffffff;
+
+inline constexpr float M_EPSILON = 0.000001f;
+inline constexpr float M_LARGE_EPSILON = 0.00005f;
+inline constexpr float M_MIN_NEARCLIP = 0.01f;
+inline constexpr float M_MAX_FOV = 160.0f;
+inline constexpr float M_LARGE_VALUE = 100000000.0f;
+inline constexpr float M_INFINITY = std::numeric_limits<float>::infinity();
+inline constexpr float M_DEGTORAD = M_PI / 180.0f;
+inline constexpr float M_DEGTORAD_2 = M_PI / 360.0f;    // M_DEGTORAD / 2.f
+inline constexpr float M_RADTODEG = 1.0f / M_DEGTORAD;
 
 /// Intersection test result.
 enum Intersection

+ 2 - 0
Source/Urho3D/Math/Random.h

@@ -28,6 +28,8 @@
 #include <Urho3D/Urho3D.h>
 #endif
 
+#include "../Base/PrimitiveTypes.h"
+
 namespace Urho3D
 {