浏览代码

Clang-Tidy - google-default-arguments.
Refactor StaticMode::GetMaterial() virtual method.

Yao Wei Tjong 姚伟忠 8 年之前
父节点
当前提交
f82ea40480

+ 2 - 1
Source/Urho3D/AngelScript/APITemplates.h

@@ -985,7 +985,8 @@ template <class T> void RegisterStaticModel(asIScriptEngine* engine, const char*
     engine->RegisterObjectMethod(className, "Model@+ get_model() const", asMETHOD(T, GetModel), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_material(Material@+)", asMETHODPR(T, SetMaterial, (Material*), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool set_materials(uint, Material@+)", asMETHODPR(T, SetMaterial, (unsigned, Material*), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "Material@+ get_materials(uint) const", asMETHOD(T, GetMaterial), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Material@+ get_material() const", asMETHODPR(T, GetMaterial, () const, Material*), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Material@+ get_materials(uint) const", asMETHODPR(T, GetMaterial, (unsigned) const, Material*), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_numGeometries() const", asMETHOD(T, GetNumGeometries), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Zone@+ get_zone() const", asMETHOD(T, GetZone), asCALL_THISCALL);
 }

+ 2 - 1
Source/Urho3D/AngelScript/GraphicsAPI.cpp

@@ -1318,7 +1318,8 @@ static void RegisterStaticModel(asIScriptEngine* engine)
     engine->RegisterObjectMethod("StaticModel", "Model@+ get_model() const", asMETHOD(StaticModel, GetModel), asCALL_THISCALL);
     engine->RegisterObjectMethod("StaticModel", "void set_material(Material@+)", asMETHODPR(StaticModel, SetMaterial, (Material*), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("StaticModel", "bool set_materials(uint, Material@+)", asMETHODPR(StaticModel, SetMaterial, (unsigned, Material*), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("StaticModel", "Material@+ get_materials(uint) const", asMETHOD(StaticModel, GetMaterial), asCALL_THISCALL);
+    engine->RegisterObjectMethod("StaticModel", "Material@+ get_material() const", asMETHODPR(StaticModel, GetMaterial, () const, Material*), asCALL_THISCALL);
+    engine->RegisterObjectMethod("StaticModel", "Material@+ get_materials(uint) const", asMETHODPR(StaticModel, GetMaterial, (unsigned) const, Material*), asCALL_THISCALL);
     engine->RegisterObjectMethod("StaticModel", "uint get_numGeometries() const", asMETHOD(StaticModel, GetNumGeometries), asCALL_THISCALL);
     engine->RegisterObjectMethod("StaticModel", "void set_occlusionLodLevel(uint) const", asMETHOD(StaticModel, SetOcclusionLodLevel), asCALL_THISCALL);
     engine->RegisterObjectMethod("StaticModel", "uint get_occlusionLodLevel() const", asMETHOD(StaticModel, GetOcclusionLodLevel), asCALL_THISCALL);

+ 3 - 1
Source/Urho3D/Graphics/StaticModel.h

@@ -79,8 +79,10 @@ public:
     /// Return number of geometries.
     unsigned GetNumGeometries() const { return geometries_.Size(); }
 
+    /// Return material from the first geometry, assuming all the geometries use the same material.
+    virtual Material* GetMaterial() const { return GetMaterial(0); }
     /// Return material by geometry index.
-    virtual Material* GetMaterial(unsigned index = 0) const;
+    virtual Material* GetMaterial(unsigned index) const;
 
     /// Return occlusion LOD level.
     unsigned GetOcclusionLodLevel() const { return occlusionLodLevel_; }

+ 3 - 2
Source/Urho3D/LuaScript/pkgs/Graphics/StaticModel.pkg

@@ -9,11 +9,12 @@ class StaticModel : public Drawable
     void ApplyMaterialList(const String fileName = String::EMPTY);
     Model* GetModel() const;
     unsigned GetNumGeometries() const;
-    Material* GetMaterial(unsigned index = 0) const;
+    Material* GetMaterial() const;
+    Material* GetMaterial(unsigned index) const;
     unsigned GetOcclusionLodLevel() const;
     bool IsInside(const Vector3& point) const;
     bool IsInsideLocal(const Vector3& point) const;
-    
+
     tolua_property__get_set Model* model;
     tolua_property__get_set Material* material;
     tolua_readonly tolua_property__get_set BoundingBox& boundingBox;