Browse Source

Fixed cloned geometries (for morphing) missing raw data.
Removed unused member variables from Model.

Lasse Öörni 14 years ago
parent
commit
ce5a45d10f
3 changed files with 8 additions and 11 deletions
  1. 4 3
      Engine/Graphics/AnimatedModel.cpp
  2. 4 0
      Engine/Graphics/Geometry.h
  3. 0 8
      Engine/Graphics/Model.h

+ 4 - 3
Engine/Graphics/AnimatedModel.cpp

@@ -812,7 +812,7 @@ void AnimatedModel::CloneGeometries()
         {
             SharedPtr<VertexBuffer> clone(new VertexBuffer(context_));
             clone->SetSize(original->GetVertexCount(), original->GetElementMask(), true);
-            void* originalData = original->Lock(0, original->GetVertexCount(), LOCK_NORMAL);
+            void* originalData = original->Lock(0, original->GetVertexCount(), LOCK_READONLY);
             if (originalData)
             {
                 clone->SetData(originalData);
@@ -837,8 +837,8 @@ void AnimatedModel::CloneGeometries()
             const Vector<SharedPtr<VertexBuffer> >& originalBuffers = original->GetVertexBuffers();
             
             SharedPtr<Geometry> clone(new Geometry(context_));
-            clone->SetNumVertexBuffers(originalVertexBuffers.Size());
-            for (unsigned k = 0; k < originalVertexBuffers.Size(); ++k)
+            clone->SetNumVertexBuffers(originalBuffers.Size());
+            for (unsigned k = 0; k < originalBuffers.Size(); ++k)
             {
                 VertexBuffer* originalBuffer = originalBuffers[k];
                 if (clonedVertexBuffers.Contains(originalBuffer))
@@ -850,6 +850,7 @@ void AnimatedModel::CloneGeometries()
             clone->SetIndexBuffer(original->GetIndexBuffer());
             clone->SetDrawRange(original->GetPrimitiveType(), original->GetIndexStart(), original->GetIndexCount());
             clone->SetLodDistance(original->GetLodDistance());
+            clone->SetRawData(original->GetRawVertexData(), original->GetRawIndexData());
             
             geometries_[i][j] = clone;
         }

+ 4 - 0
Engine/Graphics/Geometry.h

@@ -88,6 +88,10 @@ public:
     unsigned short GetBufferHash() const;
     /// Return raw vertex and index data for CPU operations, or null pointers if not available.
     void GetRawData(const unsigned char*& vertexData, unsigned& vertexSize, const unsigned char*& indexData, unsigned& indexSize);
+    /// Return the raw vertex data array.
+    const SharedArrayPtr<unsigned char>& GetRawVertexData() const { return rawVertexData_; }
+    /// Return the raw index data array.
+    const SharedArrayPtr<unsigned char>& GetRawIndexData() const { return rawIndexData_; }
     /// Return ray hit distance or infinity if no hit. Requires raw data to be set.
     float GetDistance(const Ray& ray);
     

+ 0 - 8
Engine/Graphics/Model.h

@@ -119,10 +119,6 @@ public:
     const ModelMorph* GetMorph(const String& name) const;
     /// Return vertex morph by name hash.
     const ModelMorph* GetMorph(StringHash nameHash) const;
-    /// Return CPU copy of vertices.
-    const PODVector<Vector3>& GetVertices() const { return vertices_; }
-    /// Return CPU copy of indices.
-    const PODVector<unsigned>& GetIndices() const { return indices_; }
     
 private:
     /// Bounding box.
@@ -139,8 +135,4 @@ private:
     Vector<PODVector<unsigned> > geometryBoneMappings_;
     /// Vertex morphs.
     Vector<ModelMorph> morphs_;
-    /// CPU copy of vertex positions.
-    PODVector<Vector3> vertices_;
-    /// CPU copy of indices.
-    PODVector<unsigned> indices_;
 };