Browse Source

Merge pull request #1612 from eugeneko/master

Minor changes
Lasse Öörni 9 years ago
parent
commit
f89c4e4dfb

+ 20 - 0
Source/Urho3D/Container/Vector.h

@@ -353,6 +353,16 @@ public:
     /// Resize the vector.
     void Resize(unsigned newSize) { Vector<T> tempBuffer; Resize(newSize, 0, tempBuffer); }
 
+    /// Resize the vector and fill new elements with default value.
+    void Resize(unsigned newSize, const T& value)
+    {
+        unsigned oldSize = Size();
+        Vector<T> tempBuffer;
+        Resize(newSize, 0, tempBuffer);
+        for (unsigned i = oldSize; i < newSize; ++i)
+            At(i) = value;
+    }
+
     /// Set new capacity.
     void Reserve(unsigned newCapacity)
     {
@@ -871,6 +881,16 @@ public:
         Resize(newSize, tempBuffer);
     }
 
+    /// Resize the vector and fill new elements with default value.
+    void Resize(unsigned newSize, const T& value)
+    {
+        unsigned oldSize = Size();
+        PODVector<T> tempBuffer;
+        Resize(newSize, tempBuffer);
+        for (unsigned i = oldSize; i < newSize; ++i)
+            At(i) = value;
+    }
+
     /// Set new capacity.
     void Reserve(unsigned newCapacity)
     {

+ 1 - 1
Source/Urho3D/Graphics/StaticModel.cpp

@@ -403,7 +403,7 @@ const ResourceRefList& StaticModel::GetMaterialsAttr() const
 {
     materialsAttr_.names_.Resize(batches_.Size());
     for (unsigned i = 0; i < batches_.Size(); ++i)
-        materialsAttr_.names_[i] = GetResourceName(batches_[i].material_);
+        materialsAttr_.names_[i] = GetResourceName(GetMaterial(i));
 
     return materialsAttr_;
 }

+ 4 - 4
Source/Urho3D/Graphics/StaticModel.h

@@ -63,11 +63,11 @@ public:
     virtual bool DrawOcclusion(OcclusionBuffer* buffer);
 
     /// Set model.
-    void SetModel(Model* model);
+    virtual void SetModel(Model* model);
     /// Set material on all geometries.
-    void SetMaterial(Material* material);
+    virtual void SetMaterial(Material* material);
     /// Set material on one geometry. Return true if successful.
-    bool SetMaterial(unsigned index, Material* material);
+    virtual bool SetMaterial(unsigned index, Material* material);
     /// Set occlusion LOD level. By default (M_MAX_UNSIGNED) same as visible.
     void SetOcclusionLodLevel(unsigned level);
     /// Apply default materials from a material list file. If filename is empty (default), the model's resource name with extension .txt will be used.
@@ -80,7 +80,7 @@ public:
     unsigned GetNumGeometries() const { return geometries_.Size(); }
 
     /// Return material by geometry index.
-    Material* GetMaterial(unsigned index = 0) const;
+    virtual Material* GetMaterial(unsigned index = 0) const;
 
     /// Return occlusion LOD level.
     unsigned GetOcclusionLodLevel() const { return occlusionLodLevel_; }

+ 1 - 1
Source/Urho3D/Scene/Serializable.h

@@ -165,7 +165,7 @@ public:
     {
         assert(ptr);
         const T* classPtr = static_cast<const T*>(ptr);
-        dest = (classPtr->*getFunction_)();
+        dest = (int)(classPtr->*getFunction_)();
     }
 
     /// Invoke setter function.