Browse Source

Make PIXEL_SIZE inline | Don't use URHO3D_API in cpp files (#2919)

1vanK 3 years ago
parent
commit
6a2a44a2d9

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

@@ -714,7 +714,7 @@ void ASRegisterGeneratedGlobalVariables(asIScriptEngine* engine)
     // static const unsigned FLIP_VERTICAL | File: ../Urho2D/TileMapDefs2D.h
     engine->RegisterGlobalProperty("const uint FLIP_VERTICAL", (void*)&FLIP_VERTICAL);
 
-    // const float PIXEL_SIZE | File: ../Urho2D/Drawable2D.h
+    // constexpr float PIXEL_SIZE | File: ../Urho2D/Urho2D.h
     engine->RegisterGlobalProperty("const float PIXEL_SIZE", (void*)&PIXEL_SIZE);
 #endif
 }

+ 2 - 1
Source/Urho3D/Core/MiniDump.cpp

@@ -24,6 +24,7 @@
 
 #include "../Precompiled.h"
 
+#include "../Core/MiniDump.h"
 #include "../Core/ProcessUtils.h"
 
 #include <cstdio>
@@ -36,7 +37,7 @@
 namespace Urho3D
 {
 
-URHO3D_API int WriteMiniDump(const char* applicationName, void* exceptionPointers)
+int WriteMiniDump(const char* applicationName, void* exceptionPointers)
 {
     static bool miniDumpWritten = false;
 

+ 6 - 0
Source/Urho3D/Core/MiniDump.h

@@ -22,6 +22,12 @@
 
 #pragma once
 
+#ifdef URHO3D_IS_BUILDING
+#include "Urho3D.h"
+#else
+#include <Urho3D/Urho3D.h>
+#endif
+
 namespace Urho3D
 {
 

+ 1 - 1
Source/Urho3D/Urho2D/AnimationSet2D.cpp

@@ -270,7 +270,7 @@ bool AnimationSet2D::EndLoadSpine()
         return false;
     }
 
-    skeletonJson->scale = 0.01f; // PIXEL_SIZE;
+    skeletonJson->scale = PIXEL_SIZE;
     skeletonData_ = spSkeletonJson_readSkeletonData(skeletonJson, &jsonData_[0]);
 
     spSkeletonJson_dispose(skeletonJson);

+ 0 - 2
Source/Urho3D/Urho2D/Drawable2D.cpp

@@ -35,8 +35,6 @@
 namespace Urho3D
 {
 
-const float PIXEL_SIZE = 0.01f;
-
 SourceBatch2D::SourceBatch2D() :
     distance_(0.0f),
     drawOrder_(0)

+ 1 - 3
Source/Urho3D/Urho2D/Drawable2D.h

@@ -24,6 +24,7 @@
 
 #include "../Graphics/Drawable.h"
 #include "../Graphics/GraphicsDefs.h"
+#include "../Urho2D/Urho2D.h"
 
 namespace Urho3D
 {
@@ -62,9 +63,6 @@ struct SourceBatch2D
     Vector<Vertex2D> vertices_;
 };
 
-/// Pixel size (equal 0.01f).
-extern URHO3D_API const float PIXEL_SIZE;
-
 /// Base class for 2D visible components.
 class URHO3D_API Drawable2D : public Drawable
 {

+ 1 - 0
Source/Urho3D/Urho2D/Sprite2D.h

@@ -23,6 +23,7 @@
 #pragma once
 
 #include "../Resource/Resource.h"
+#include "../Urho2D/Urho2D.h"
 
 namespace Urho3D
 {

+ 0 - 1
Source/Urho3D/Urho2D/TileMap2D.cpp

@@ -36,7 +36,6 @@
 namespace Urho3D
 {
 
-extern const float PIXEL_SIZE;
 extern const char* URHO2D_CATEGORY;
 
 TileMap2D::TileMap2D(Context* context) :

+ 0 - 1
Source/Urho3D/Urho2D/TileMapDefs2D.cpp

@@ -30,7 +30,6 @@
 
 namespace Urho3D
 {
-extern URHO3D_API const float PIXEL_SIZE;
 
 float TileMapInfo2D::GetMapWidth() const
 {

+ 0 - 2
Source/Urho3D/Urho2D/TmxFile2D.cpp

@@ -39,8 +39,6 @@
 namespace Urho3D
 {
 
-extern const float PIXEL_SIZE;
-
 TmxLayer2D::TmxLayer2D(TmxFile2D* tmxFile, TileMapLayerType2D type) :
     tmxFile_(tmxFile),
     type_(type)

+ 3 - 0
Source/Urho3D/Urho2D/Urho2D.h

@@ -25,6 +25,9 @@
 namespace Urho3D
 {
 
+/// Pixel size.
+inline constexpr float PIXEL_SIZE = 0.01f;
+
 /// Register Urho2D library objects.
 /// @nobind
 void URHO3D_API RegisterUrho2DLibrary(Context* context);