Переглянути джерело

CrowdManager: style, make maxAgents signed

1vanK 3 роки тому
батько
коміт
447aa382fe

+ 10 - 10
Source/Urho3D/AngelScript/Generated_Members.h

@@ -7130,16 +7130,16 @@ template <class T> void RegisterMembers_CrowdObstacleAvoidanceParams(asIScriptEn
     // float CrowdObstacleAvoidanceParams::horizTime
     engine->RegisterObjectProperty(className, "float horizTime", offsetof(T, horizTime));
 
-    // unsigned char CrowdObstacleAvoidanceParams::gridSize
+    // u8 CrowdObstacleAvoidanceParams::gridSize
     engine->RegisterObjectProperty(className, "uint8 gridSize", offsetof(T, gridSize));
 
-    // unsigned char CrowdObstacleAvoidanceParams::adaptiveDivs
+    // u8 CrowdObstacleAvoidanceParams::adaptiveDivs
     engine->RegisterObjectProperty(className, "uint8 adaptiveDivs", offsetof(T, adaptiveDivs));
 
-    // unsigned char CrowdObstacleAvoidanceParams::adaptiveRings
+    // u8 CrowdObstacleAvoidanceParams::adaptiveRings
     engine->RegisterObjectProperty(className, "uint8 adaptiveRings", offsetof(T, adaptiveRings));
 
-    // unsigned char CrowdObstacleAvoidanceParams::adaptiveDepth
+    // u8 CrowdObstacleAvoidanceParams::adaptiveDepth
     engine->RegisterObjectProperty(className, "uint8 adaptiveDepth", offsetof(T, adaptiveDepth));
 
     #ifdef REGISTER_MEMBERS_MANUAL_PART_CrowdObstacleAvoidanceParams
@@ -19851,9 +19851,9 @@ template <class T> void RegisterMembers_CrowdManager(asIScriptEngine* engine, co
     engine->RegisterObjectMethod(className, "float GetMaxAgentRadius() const", AS_METHODPR(T, GetMaxAgentRadius, () const, float), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "float get_maxAgentRadius() const", AS_METHODPR(T, GetMaxAgentRadius, () const, float), AS_CALL_THISCALL);
 
-    // unsigned CrowdManager::GetMaxAgents() const
-    engine->RegisterObjectMethod(className, "uint GetMaxAgents() const", AS_METHODPR(T, GetMaxAgents, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_maxAgents() const", AS_METHODPR(T, GetMaxAgents, () const, unsigned), AS_CALL_THISCALL);
+    // i32 CrowdManager::GetMaxAgents() const
+    engine->RegisterObjectMethod(className, "int GetMaxAgents() const", AS_METHODPR(T, GetMaxAgents, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_maxAgents() const", AS_METHODPR(T, GetMaxAgents, () const, i32), AS_CALL_THISCALL);
 
     // NavigationMesh* CrowdManager::GetNavigationMesh() const
     engine->RegisterObjectMethod(className, "NavigationMesh@+ GetNavigationMesh() const", AS_METHODPR(T, GetNavigationMesh, () const, NavigationMesh*), AS_CALL_THISCALL);
@@ -19899,9 +19899,9 @@ template <class T> void RegisterMembers_CrowdManager(asIScriptEngine* engine, co
     engine->RegisterObjectMethod(className, "void SetMaxAgentRadius(float)", AS_METHODPR(T, SetMaxAgentRadius, (float), void), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_maxAgentRadius(float)", AS_METHODPR(T, SetMaxAgentRadius, (float), void), AS_CALL_THISCALL);
 
-    // void CrowdManager::SetMaxAgents(unsigned maxAgents)
-    engine->RegisterObjectMethod(className, "void SetMaxAgents(uint)", AS_METHODPR(T, SetMaxAgents, (unsigned), void), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void set_maxAgents(uint)", AS_METHODPR(T, SetMaxAgents, (unsigned), void), AS_CALL_THISCALL);
+    // void CrowdManager::SetMaxAgents(i32 maxAgents)
+    engine->RegisterObjectMethod(className, "void SetMaxAgents(int)", AS_METHODPR(T, SetMaxAgents, (i32), void), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void set_maxAgents(int)", AS_METHODPR(T, SetMaxAgents, (i32), void), AS_CALL_THISCALL);
 
     // void CrowdManager::SetNavigationMesh(NavigationMesh* navMesh)
     engine->RegisterObjectMethod(className, "void SetNavigationMesh(NavigationMesh@+)", AS_METHODPR(T, SetNavigationMesh, (NavigationMesh*), void), AS_CALL_THISCALL);

+ 5 - 5
Source/Urho3D/Navigation/CrowdManager.cpp

@@ -24,8 +24,8 @@ namespace Urho3D
 
 extern const char* NAVIGATION_CATEGORY;
 
-static const unsigned DEFAULT_MAX_AGENTS = 512;
-static const float DEFAULT_MAX_AGENT_RADIUS = 0.f;
+static constexpr i32 DEFAULT_MAX_AGENTS = 512;
+static constexpr float DEFAULT_MAX_AGENT_RADIUS = 0.f;
 
 static const StringVector filterTypesStructureElementNames =
 {
@@ -76,7 +76,7 @@ void CrowdManager::RegisterObject(Context* context)
 {
     context->RegisterFactory<CrowdManager>(NAVIGATION_CATEGORY);
 
-    URHO3D_ATTRIBUTE("Max Agents", unsigned, maxAgents_, DEFAULT_MAX_AGENTS, AM_DEFAULT);
+    URHO3D_ATTRIBUTE("Max Agents", i32, maxAgents_, DEFAULT_MAX_AGENTS, AM_DEFAULT);
     URHO3D_ATTRIBUTE("Max Agent Radius", float, maxAgentRadius_, DEFAULT_MAX_AGENT_RADIUS, AM_DEFAULT);
     URHO3D_ATTRIBUTE("Navigation Mesh", unsigned, navigationMeshId_, 0, AM_DEFAULT | AM_COMPONENTID);
     URHO3D_MIXED_ACCESSOR_ATTRIBUTE("Filter Types", GetQueryFilterTypesAttr, SetQueryFilterTypesAttr,
@@ -90,7 +90,7 @@ void CrowdManager::RegisterObject(Context* context)
 void CrowdManager::ApplyAttributes()
 {
     // Values from Editor, saved-file, or network must be checked before applying
-    maxAgents_ = Max(1U, maxAgents_);
+    maxAgents_ = Max(1, maxAgents_);
     maxAgentRadius_ = Max(0.f, maxAgentRadius_);
 
     bool navMeshChange = false;
@@ -214,7 +214,7 @@ void CrowdManager::ResetCrowdTarget(Node* node)
         agents[i]->ResetTarget();
 }
 
-void CrowdManager::SetMaxAgents(unsigned maxAgents)
+void CrowdManager::SetMaxAgents(i32 maxAgents)
 {
     if (maxAgents != maxAgents_ && maxAgents > 0)
     {

+ 7 - 7
Source/Urho3D/Navigation/CrowdManager.h

@@ -31,10 +31,10 @@ struct CrowdObstacleAvoidanceParams
     float weightSide;
     float weightToi;
     float horizTime;
-    unsigned char gridSize;         ///< grid
-    unsigned char adaptiveDivs;     ///< adaptive
-    unsigned char adaptiveRings;    ///< adaptive
-    unsigned char adaptiveDepth;    ///< adaptive
+    u8 gridSize;         ///< grid
+    u8 adaptiveDivs;     ///< adaptive
+    u8 adaptiveRings;    ///< adaptive
+    u8 adaptiveDepth;    ///< adaptive
 };
 
 /// Crowd manager scene component. Should be added only to the root scene node.
@@ -68,7 +68,7 @@ public:
     void ResetCrowdTarget(Node* node = nullptr);
     /// Set the maximum number of agents.
     /// @property
-    void SetMaxAgents(unsigned maxAgents);
+    void SetMaxAgents(i32 maxAgents);
     /// Set the maximum radius of any agent.
     /// @property
     void SetMaxAgentRadius(float maxAgentRadius);
@@ -107,7 +107,7 @@ public:
 
     /// Get the maximum number of agents.
     /// @property
-    unsigned GetMaxAgents() const { return maxAgents_; }
+    i32 GetMaxAgents() const { return maxAgents_; }
 
     /// Get the maximum radius of any agent.
     /// @property
@@ -178,7 +178,7 @@ private:
     /// The NavigationMesh component Id for pending crowd creation.
     unsigned navigationMeshId_{};
     /// The maximum number of agents the crowd can manage.
-    unsigned maxAgents_{};
+    i32 maxAgents_{};
     /// The maximum radius of any agent that will be added to the crowd.
     float maxAgentRadius_{};
     /// Number of query filter types configured in the crowd. Limit to DT_CROWD_MAX_QUERY_FILTER_TYPE.