From 255fd5338292afd5ba77f1a43f280c464fd1320e Mon Sep 17 00:00:00 2001
From: isucan <isucan@253336fb-580f-4252-a368-f3cef5a2a82b>
Date: Fri, 6 Jan 2012 20:13:41 +0000
Subject: [PATCH] the collision object should not enforce ownership of the
 geometry (this way every object would require creating a new geometry
 instance for every object instance)

git-svn-id: https://kforge.ros.org/fcl/fcl_ros@58 253336fb-580f-4252-a368-f3cef5a2a82b
---
 trunk/fcl/include/fcl/collision_object.h | 15 ++++-----------
 trunk/fcl/test/test_core_broad_phase.cpp |  6 +++---
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/trunk/fcl/include/fcl/collision_object.h b/trunk/fcl/include/fcl/collision_object.h
index 77f603bd..e8a6ee9b 100644
--- a/trunk/fcl/include/fcl/collision_object.h
+++ b/trunk/fcl/include/fcl/collision_object.h
@@ -84,24 +84,17 @@ public:
 class CollisionObject
 {
 public:
-  CollisionObject(CollisionGeometry* cgeom_)
+  CollisionObject(const boost::shared_ptr<CollisionGeometry> &cgeom_) : cgeom(cgeom_)
   {
-    cgeom.reset(cgeom_);
-    computeAABB();
   }
 
-  CollisionObject(CollisionGeometry* cgeom_, const SimpleTransform& tf)
+  CollisionObject(const boost::shared_ptr<CollisionGeometry> &cgeom_, const SimpleTransform& tf) : cgeom(cgeom_), t(tf)
   {
-    cgeom.reset(cgeom_);
-    t = tf;
-    computeAABB();
   }
 
-  CollisionObject(CollisionGeometry* cgeom_, const Matrix3f& R, const Vec3f& T)
+  CollisionObject(const boost::shared_ptr<CollisionGeometry> &cgeom_, const Matrix3f& R, const Vec3f& T):
+      cgeom(cgeom_), t(SimpleTransform(R, T))
   {
-    cgeom.reset(cgeom_);
-    t = SimpleTransform(R, T);
-    computeAABB();
   }
 
   CollisionObject()
diff --git a/trunk/fcl/test/test_core_broad_phase.cpp b/trunk/fcl/test/test_core_broad_phase.cpp
index 63d33f7c..ae196f99 100644
--- a/trunk/fcl/test/test_core_broad_phase.cpp
+++ b/trunk/fcl/test/test_core_broad_phase.cpp
@@ -222,7 +222,7 @@ void generateEnvironments(std::vector<CollisionObject*>& env, int n)
     BVHModel<OBB>* model = new BVHModel<OBB>();
     box.setLocalTransform(transforms[i].R, transforms[i].T);
     generateBVHModel(*model, box, SimpleTransform());
-    env.push_back(new CollisionObject(model));
+    env.push_back(new CollisionObject(boost::shared_ptr<CollisionGeometry>(model)));
   }
 
   generateRandomTransform(extents, transforms, transforms2, delta_trans, 0.005 * 2 * 3.1415, n);
@@ -232,7 +232,7 @@ void generateEnvironments(std::vector<CollisionObject*>& env, int n)
     BVHModel<OBB>* model = new BVHModel<OBB>();
     sphere.setLocalTransform(transforms[i].R, transforms[i].T);
     generateBVHModel(*model, sphere, SimpleTransform());
-    env.push_back(new CollisionObject(model));
+    env.push_back(new CollisionObject(boost::shared_ptr<CollisionGeometry>(model)));
   }
 
   generateRandomTransform(extents, transforms, transforms2, delta_trans, 0.005 * 2 * 3.1415, n);
@@ -242,6 +242,6 @@ void generateEnvironments(std::vector<CollisionObject*>& env, int n)
     BVHModel<OBB>* model = new BVHModel<OBB>();
     cylinder.setLocalTransform(transforms[i].R, transforms[i].T);
     generateBVHModel(*model, cylinder, SimpleTransform());
-    env.push_back(new CollisionObject(model));
+    env.push_back(new CollisionObject(boost::shared_ptr<CollisionGeometry>(model)));
   }
 }
-- 
GitLab