Browse Source

Fixed crash caused by assigning Geometry shared ptr's in multiple threads.

Lasse Öörni 13 years ago
parent
commit
a556679a42

+ 1 - 0
Engine/Engine/APITemplates.h

@@ -28,6 +28,7 @@
 #include "Context.h"
 #include "Drawable.h"
 #include "File.h"
+#include "Node.h"
 #include "Renderer.h"
 #include "Resource.h"
 #include "Script.h"

+ 1 - 0
Engine/Graphics/AnimatedModel.cpp

@@ -30,6 +30,7 @@
 #include "Context.h"
 #include "DebugRenderer.h"
 #include "DrawableEvents.h"
+#include "Geometry.h"
 #include "Graphics.h"
 #include "IndexBuffer.h"
 #include "Log.h"

+ 1 - 0
Engine/Graphics/Batch.cpp

@@ -23,6 +23,7 @@
 
 #include "Precompiled.h"
 #include "Camera.h"
+#include "Geometry.h"
 #include "Graphics.h"
 #include "GraphicsImpl.h"
 #include "Light.h"

+ 3 - 1
Engine/Graphics/BillboardSet.cpp

@@ -26,6 +26,7 @@
 #include "BillboardSet.h"
 #include "Camera.h"
 #include "Context.h"
+#include "Geometry.h"
 #include "Graphics.h"
 #include "GraphicsImpl.h"
 #include "IndexBuffer.h"
@@ -50,6 +51,7 @@ OBJECTTYPESTATIC(BillboardSet);
 
 BillboardSet::BillboardSet(Context* context) :
     Drawable(context),
+    geometry_(new Geometry(context)),
     animationLodBias_(1.0f),
     animationLodTimer_(0.0f),
     relative_(true),
@@ -64,7 +66,7 @@ BillboardSet::BillboardSet(Context* context) :
     drawableFlags_ = DRAWABLE_GEOMETRY;
     
     batches_.Resize(1);
-    batches_[0].geometry_ = new Geometry(context_);
+    batches_[0].geometry_ = geometry_;
     batches_[0].geometryType_ = GEOM_BILLBOARD;
 }
 

+ 3 - 0
Engine/Graphics/BillboardSet.h

@@ -26,6 +26,7 @@
 #include "Color.h"
 #include "Drawable.h"
 #include "Rect.h"
+#include "VectorBuffer.h"
 
 class IndexBuffer;
 class Graphics;
@@ -142,6 +143,8 @@ private:
     /// Rewrite billboard vertex buffer.
     void UpdateVertexBuffer(const FrameInfo& frame);
     
+    /// Geometry.
+    SharedPtr<Geometry> geometry_;
     /// Vertex buffer.
     SharedPtr<VertexBuffer> vertexBuffer_;
     /// Index buffer.

+ 2 - 4
Engine/Graphics/Drawable.h

@@ -25,10 +25,8 @@
 
 #include "BoundingBox.h"
 #include "Component.h"
-#include "Geometry.h"
 #include "GraphicsDefs.h"
 #include "Material.h"
-#include "Node.h"
 
 static const unsigned DRAWABLE_GEOMETRY = 0x1;
 static const unsigned DRAWABLE_LIGHT = 0x2;
@@ -45,7 +43,6 @@ class Camera;
 class DebugRenderer;
 class Geometry;
 class Light;
-class Material;
 class OcclusionBuffer;
 class Octant;
 class RayOctreeQuery;
@@ -80,6 +77,7 @@ struct SourceBatch
     /// Construct with defaults.
     SourceBatch() :
         distance_(0.0f),
+        geometry_(0),
         worldTransform_(&Matrix3x4::IDENTITY),
         shaderData_(0),
         shaderDataSize_(0),
@@ -91,7 +89,7 @@ struct SourceBatch
     /// Distance from camera.
     float distance_;
     /// Geometry.
-    SharedPtr<Geometry> geometry_;
+    Geometry* geometry_;
     /// Material.
     SharedPtr<Material> material_;
     /// %Object's world transform.

+ 1 - 0
Engine/Graphics/StaticModel.cpp

@@ -25,6 +25,7 @@
 #include "Batch.h"
 #include "Camera.h"
 #include "Context.h"
+#include "Geometry.h"
 #include "Log.h"
 #include "Model.h"
 #include "OcclusionBuffer.h"

+ 1 - 0
Engine/Graphics/View.cpp

@@ -24,6 +24,7 @@
 #include "Precompiled.h"
 #include "Camera.h"
 #include "DebugRenderer.h"
+#include "Geometry.h"
 #include "Graphics.h"
 #include "Light.h"
 #include "Log.h"