From 3a88308f4598d32782117f9b0408d6235de67641 Mon Sep 17 00:00:00 2001 From: deflected Date: Sat, 17 Mar 2018 18:32:52 +0200 Subject: [PATCH] bullet: Cleanup copying of shapes - Fixed copy constructors - Dropped operator= from shapes Signed-off-by: deflected Closes #283 --- panda/src/bullet/bulletBoxShape.cxx | 14 ++----- panda/src/bullet/bulletBoxShape.h | 1 - panda/src/bullet/bulletCapsuleShape.I | 3 +- panda/src/bullet/bulletCapsuleShape.cxx | 42 +++++++++++-------- panda/src/bullet/bulletCapsuleShape.h | 2 +- panda/src/bullet/bulletConeShape.I | 3 +- panda/src/bullet/bulletConeShape.cxx | 39 ++++++++++------- panda/src/bullet/bulletConeShape.h | 2 +- panda/src/bullet/bulletConvexHullShape.cxx | 17 ++++---- panda/src/bullet/bulletConvexHullShape.h | 1 - .../bullet/bulletConvexPointCloudShape.cxx | 15 +++---- .../src/bullet/bulletConvexPointCloudShape.h | 1 - panda/src/bullet/bulletCylinderShape.I | 3 +- panda/src/bullet/bulletCylinderShape.cxx | 41 +++++++++++------- panda/src/bullet/bulletCylinderShape.h | 2 +- panda/src/bullet/bulletHeightfieldShape.cxx | 25 ++++------- panda/src/bullet/bulletHeightfieldShape.h | 1 - panda/src/bullet/bulletMinkowskiSumShape.cxx | 17 +++----- panda/src/bullet/bulletMinkowskiSumShape.h | 1 - panda/src/bullet/bulletPlaneShape.cxx | 14 ++----- panda/src/bullet/bulletPlaneShape.h | 1 - panda/src/bullet/bulletSphereShape.cxx | 13 +----- panda/src/bullet/bulletSphereShape.h | 1 - panda/src/bullet/bulletTriangleMeshShape.cxx | 28 ++++++------- panda/src/bullet/bulletTriangleMeshShape.h | 1 - 25 files changed, 130 insertions(+), 158 deletions(-) diff --git a/panda/src/bullet/bulletBoxShape.cxx b/panda/src/bullet/bulletBoxShape.cxx index 9ae2e16a11..1e18d77899 100644 --- a/panda/src/bullet/bulletBoxShape.cxx +++ b/panda/src/bullet/bulletBoxShape.cxx @@ -35,19 +35,11 @@ BulletBoxShape:: BulletBoxShape(const BulletBoxShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _half_extents = copy._half_extents; -} + btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents); -/** - * - */ -void BulletBoxShape:: -operator = (const BulletBoxShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _half_extents = copy._half_extents; + _shape = new btBoxShape(btHalfExtents); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletBoxShape.h b/panda/src/bullet/bulletBoxShape.h index bfb9207e61..5ac117ac76 100644 --- a/panda/src/bullet/bulletBoxShape.h +++ b/panda/src/bullet/bulletBoxShape.h @@ -34,7 +34,6 @@ private: PUBLISHED: explicit BulletBoxShape(const LVecBase3 &halfExtents); BulletBoxShape(const BulletBoxShape ©); - void operator = (const BulletBoxShape ©); INLINE ~BulletBoxShape(); LVecBase3 get_half_extents_without_margin() const; diff --git a/panda/src/bullet/bulletCapsuleShape.I b/panda/src/bullet/bulletCapsuleShape.I index 2491d55d0d..25caf7b9de 100644 --- a/panda/src/bullet/bulletCapsuleShape.I +++ b/panda/src/bullet/bulletCapsuleShape.I @@ -18,7 +18,8 @@ INLINE BulletCapsuleShape:: BulletCapsuleShape() : _shape(nullptr), _radius(0), - _height(0) { + _height(0), + _up(X_up) { } /** diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 1c396bbdfb..44fbc3e501 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -21,7 +21,8 @@ TypeHandle BulletCapsuleShape::_type_handle; BulletCapsuleShape:: BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _radius(radius), - _height(height) { + _height(height), + _up(up) { switch (up) { case X_up: @@ -49,24 +50,29 @@ BulletCapsuleShape:: BulletCapsuleShape(const BulletCapsuleShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _radius = copy._radius; _height = copy._height; + _up = copy._up; + + switch (_up) { + case X_up: + _shape = new btCapsuleShapeX(_radius, _height); + break; + case Y_up: + _shape = new btCapsuleShape(_radius, _height); + break; + case Z_up: + _shape = new btCapsuleShapeZ(_radius, _height); + break; + default: + bullet_cat.error() << "invalid up-axis:" << _up << endl; + break; + } + + nassertv(_shape); + _shape->setUserPointer(this); } -/** - * - */ -void BulletCapsuleShape:: -operator = (const BulletCapsuleShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _radius = copy._radius; - _height = copy._height; -} - - /** * */ @@ -131,9 +137,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { // parameters to serialize: radius, height, up _radius = scan.get_stdfloat(); _height = scan.get_stdfloat(); - int up = (int) scan.get_int8(); + _up = (BulletUpAxis) scan.get_int8(); - switch (up) { + switch (_up) { case X_up: _shape = new btCapsuleShapeX(_radius, _height); break; @@ -144,7 +150,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btCapsuleShapeZ(_radius, _height); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << endl; break; } diff --git a/panda/src/bullet/bulletCapsuleShape.h b/panda/src/bullet/bulletCapsuleShape.h index e376674976..9994d9f1dc 100644 --- a/panda/src/bullet/bulletCapsuleShape.h +++ b/panda/src/bullet/bulletCapsuleShape.h @@ -31,7 +31,6 @@ private: PUBLISHED: explicit BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); BulletCapsuleShape(const BulletCapsuleShape ©); - void operator = (const BulletCapsuleShape ©); INLINE ~BulletCapsuleShape(); INLINE PN_stdfloat get_radius() const; @@ -50,6 +49,7 @@ private: btCapsuleShape *_shape; PN_stdfloat _radius; PN_stdfloat _height; + BulletUpAxis _up; public: static void register_with_read_factory(); diff --git a/panda/src/bullet/bulletConeShape.I b/panda/src/bullet/bulletConeShape.I index b9c05664b7..debd0900c9 100644 --- a/panda/src/bullet/bulletConeShape.I +++ b/panda/src/bullet/bulletConeShape.I @@ -18,7 +18,8 @@ INLINE BulletConeShape:: BulletConeShape() : _shape(nullptr), _radius(0), - _height(0) { + _height(0), + _up(X_up) { } /** diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index 30b24a5a18..84c1fc4157 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -21,7 +21,8 @@ TypeHandle BulletConeShape::_type_handle; BulletConeShape:: BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _radius(radius), - _height(height) { + _height(height), + _up(up) { switch (up) { case X_up: @@ -49,21 +50,27 @@ BulletConeShape:: BulletConeShape(const BulletConeShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; + _up = copy._up; _radius = copy._radius; _height = copy._height; -} -/** - * - */ -void BulletConeShape:: -operator = (const BulletConeShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + switch (_up) { + case X_up: + _shape = new btConeShapeX((btScalar)_radius, (btScalar)_height); + break; + case Y_up: + _shape = new btConeShape((btScalar)_radius, (btScalar)_height); + break; + case Z_up: + _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); + break; + default: + bullet_cat.error() << "invalid up-axis:" << _up << endl; + break; + } - _shape = copy._shape; - _radius = copy._radius; - _height = copy._height; + nassertv(_shape); + _shape->setUserPointer(this); } /** @@ -95,7 +102,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // parameters to serialize: radius, height, upIndex dg.add_stdfloat(_radius); dg.add_stdfloat(_height); - dg.add_int8((int8_t)_shape->getConeUpIndex()); + dg.add_int8((int8_t)_up); } /** @@ -130,9 +137,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { // parameters to serialize: radius, height, up _radius = scan.get_stdfloat(); _height = scan.get_stdfloat(); + _up = (BulletUpAxis) scan.get_int8(); - int up_index = (int) scan.get_int8(); - switch (up_index) { + switch (_up) { case 0: _shape = new btConeShapeX((btScalar)_radius, (btScalar)_height); break; @@ -143,7 +150,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); break; default: - bullet_cat.error() << "invalid up-axis:" << up_index << endl; + bullet_cat.error() << "invalid up-axis:" << _up << endl; break; } diff --git a/panda/src/bullet/bulletConeShape.h b/panda/src/bullet/bulletConeShape.h index 4d40c61da9..89d085f834 100644 --- a/panda/src/bullet/bulletConeShape.h +++ b/panda/src/bullet/bulletConeShape.h @@ -31,7 +31,6 @@ private: PUBLISHED: explicit BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); BulletConeShape(const BulletConeShape ©); - void operator = (const BulletConeShape ©); INLINE ~BulletConeShape(); INLINE PN_stdfloat get_radius() const; @@ -47,6 +46,7 @@ private: btConeShape *_shape; PN_stdfloat _radius; PN_stdfloat _height; + BulletUpAxis _up; public: static void register_with_read_factory(); diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index c796072b4a..75a3182a34 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -36,17 +36,13 @@ BulletConvexHullShape:: BulletConvexHullShape(const BulletConvexHullShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; -} + _shape = new btConvexHullShape(NULL, 0); + _shape->setUserPointer(this); -/** - * - */ -void BulletConvexHullShape:: -operator = (const BulletConvexHullShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + for(int i = 0; i < copy._shape->getNumPoints(); i++) + _shape->addPoint(copy._shape->getUnscaledPoints()[i], false); - _shape = copy._shape; + _shape->recalcLocalAabb(); } /** @@ -117,6 +113,9 @@ add_geom(const Geom *geom, const TransformState *ts) { points.push_back(m.xform_point(reader.get_data3())); } + if (_shape) + delete _shape; + // Create shape _shape = new btConvexHullShape(NULL, 0); _shape->setUserPointer(this); diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index 653c044952..78485ed12c 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -30,7 +30,6 @@ class EXPCL_PANDABULLET BulletConvexHullShape : public BulletShape { PUBLISHED: BulletConvexHullShape(); BulletConvexHullShape(const BulletConvexHullShape ©); - void operator = (const BulletConvexHullShape ©); INLINE ~BulletConvexHullShape(); void add_point(const LPoint3 &p); diff --git a/panda/src/bullet/bulletConvexPointCloudShape.cxx b/panda/src/bullet/bulletConvexPointCloudShape.cxx index fb7f62287b..1a4cb6e16c 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.cxx +++ b/panda/src/bullet/bulletConvexPointCloudShape.cxx @@ -92,18 +92,13 @@ BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); _scale = copy._scale; - _shape = copy._shape; -} -/** - * - */ -void BulletConvexPointCloudShape:: -operator = (const BulletConvexPointCloudShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + btVector3 *btPoints = copy._shape->getUnscaledPoints(); + int numPoints = copy._shape->getNumPoints(); + btVector3 btScale = LVecBase3_to_btVector3(_scale); - _scale = copy._scale; - _shape = copy._shape; + _shape = new btConvexPointCloudShape(btPoints, numPoints, btScale); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletConvexPointCloudShape.h b/panda/src/bullet/bulletConvexPointCloudShape.h index da403d8794..0bf1d7e427 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.h +++ b/panda/src/bullet/bulletConvexPointCloudShape.h @@ -34,7 +34,6 @@ PUBLISHED: explicit BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale=LVecBase3(1.)); explicit BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale=LVecBase3(1.)); BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©); - void operator = (const BulletConvexPointCloudShape ©); INLINE ~BulletConvexPointCloudShape(); int get_num_points() const; diff --git a/panda/src/bullet/bulletCylinderShape.I b/panda/src/bullet/bulletCylinderShape.I index 54616905f9..bf0ccb40a9 100644 --- a/panda/src/bullet/bulletCylinderShape.I +++ b/panda/src/bullet/bulletCylinderShape.I @@ -17,7 +17,8 @@ INLINE BulletCylinderShape:: BulletCylinderShape() : _half_extents(LVector3::zero()), - _shape(nullptr) { + _shape(nullptr), + _up(X_up) { } /** diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 28ca5d65b4..6d107bff7a 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -20,7 +20,8 @@ TypeHandle BulletCylinderShape::_type_handle; */ BulletCylinderShape:: BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) : - _half_extents(half_extents){ + _half_extents(half_extents), + _up(up) { btVector3 btHalfExtents = LVecBase3_to_btVector3(half_extents); @@ -47,7 +48,8 @@ BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) : * */ BulletCylinderShape:: -BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { +BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : + _up(up) { switch (up) { case X_up: @@ -78,19 +80,28 @@ BulletCylinderShape:: BulletCylinderShape(const BulletCylinderShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; + _up = copy._up; _half_extents = copy._half_extents; -} -/** - * - */ -void BulletCylinderShape:: -operator = (const BulletCylinderShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents); - _shape = copy._shape; - _half_extents = copy._half_extents; + switch (_up) { + case X_up: + _shape = new btCylinderShapeX(btHalfExtents); + break; + case Y_up: + _shape = new btCylinderShape(btHalfExtents); + break; + case Z_up: + _shape = new btCylinderShapeZ(btHalfExtents); + break; + default: + bullet_cat.error() << "invalid up-axis:" << _up << endl; + break; + } + + nassertv(_shape); + _shape->setUserPointer(this); } /** @@ -185,11 +196,11 @@ fillin(DatagramIterator &scan, BamReader *manager) { // parameters to serialize: radius, height, up _half_extents.read_datagram(scan); - int up = (int) scan.get_int8(); + _up = (BulletUpAxis) scan.get_int8(); btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents); - switch (up) { + switch (_up) { case X_up: _shape = new btCylinderShapeX(btHalfExtents); break; @@ -200,7 +211,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btCylinderShapeZ(btHalfExtents); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << endl; break; } diff --git a/panda/src/bullet/bulletCylinderShape.h b/panda/src/bullet/bulletCylinderShape.h index f53962ec6f..901e48b4ff 100644 --- a/panda/src/bullet/bulletCylinderShape.h +++ b/panda/src/bullet/bulletCylinderShape.h @@ -32,7 +32,6 @@ PUBLISHED: explicit BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); explicit BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up=Z_up); BulletCylinderShape(const BulletCylinderShape ©); - void operator = (const BulletCylinderShape ©); INLINE ~BulletCylinderShape(); PN_stdfloat get_radius() const; @@ -49,6 +48,7 @@ public: private: LVector3 _half_extents; btCylinderShape *_shape; + BulletUpAxis _up; public: static void register_with_read_factory(); diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 1a01876401..6f5f0529e3 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -112,7 +112,6 @@ BulletHeightfieldShape:: BulletHeightfieldShape(const BulletHeightfieldShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _num_rows = copy._num_rows; _num_cols = copy._num_cols; _max_height = copy._max_height; @@ -121,24 +120,14 @@ BulletHeightfieldShape(const BulletHeightfieldShape ©) { size_t size = (size_t)_num_rows * (size_t)_num_cols; _data = new btScalar[size]; memcpy(_data, copy._data, size * sizeof(btScalar)); -} -/** - * - */ -void BulletHeightfieldShape:: -operator = (const BulletHeightfieldShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _num_rows = copy._num_rows; - _num_cols = copy._num_cols; - _max_height = copy._max_height; - _up = copy._up; - - size_t size = (size_t)_num_rows * (size_t)_num_cols; - _data = new btScalar[size]; - memcpy(_data, copy._data, size * sizeof(btScalar)); + _shape = new btHeightfieldTerrainShape(_num_rows, + _num_cols, + _data, + _max_height, + _up, + true, false); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletHeightfieldShape.h b/panda/src/bullet/bulletHeightfieldShape.h index 1bfc6c41c3..3631ca1a9d 100644 --- a/panda/src/bullet/bulletHeightfieldShape.h +++ b/panda/src/bullet/bulletHeightfieldShape.h @@ -35,7 +35,6 @@ PUBLISHED: explicit BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up); explicit BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up=Z_up); BulletHeightfieldShape(const BulletHeightfieldShape ©); - void operator = (const BulletHeightfieldShape ©); INLINE ~BulletHeightfieldShape(); void set_use_diamond_subdivision(bool flag=true); diff --git a/panda/src/bullet/bulletMinkowskiSumShape.cxx b/panda/src/bullet/bulletMinkowskiSumShape.cxx index cc56d39884..d750e22244 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.cxx +++ b/panda/src/bullet/bulletMinkowskiSumShape.cxx @@ -40,21 +40,14 @@ BulletMinkowskiSumShape:: BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _shape_a = copy._shape_a; _shape_b = copy._shape_b; -} + + const btConvexShape *ptr_a = (const btConvexShape *)_shape_a->ptr(); + const btConvexShape *ptr_b = (const btConvexShape *)_shape_b->ptr(); -/** - * - */ -void BulletMinkowskiSumShape:: -operator = (const BulletMinkowskiSumShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _shape_a = copy._shape_a; - _shape_b = copy._shape_b; + _shape = new btMinkowskiSumShape(ptr_a, ptr_b); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletMinkowskiSumShape.h b/panda/src/bullet/bulletMinkowskiSumShape.h index c8629f2e33..f8f531ed99 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.h +++ b/panda/src/bullet/bulletMinkowskiSumShape.h @@ -33,7 +33,6 @@ private: PUBLISHED: explicit BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b); BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©); - void operator = (const BulletMinkowskiSumShape ©); INLINE ~BulletMinkowskiSumShape(); void set_transform_a(const TransformState *ts); diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index a7804290cd..0d1a97fd4e 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -34,17 +34,11 @@ BulletPlaneShape:: BulletPlaneShape(const BulletPlaneShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; -} + btVector3 btNormal = copy._shape->getPlaneNormal(); + PN_stdfloat constant = (PN_stdfloat)_shape->getPlaneConstant(); -/** - * - */ -void BulletPlaneShape:: -operator = (const BulletPlaneShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; + _shape = new btStaticPlaneShape(btNormal, constant); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index 610c5d2412..dfee91f12c 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -34,7 +34,6 @@ private: PUBLISHED: explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); BulletPlaneShape(const BulletPlaneShape ©); - void operator = (const BulletPlaneShape ©); INLINE ~BulletPlaneShape(); LVector3 get_plane_normal() const; diff --git a/panda/src/bullet/bulletSphereShape.cxx b/panda/src/bullet/bulletSphereShape.cxx index 7b3fee62a4..b05e09e418 100644 --- a/panda/src/bullet/bulletSphereShape.cxx +++ b/panda/src/bullet/bulletSphereShape.cxx @@ -32,19 +32,10 @@ BulletSphereShape:: BulletSphereShape(const BulletSphereShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _radius = copy._radius; -} -/** - * - */ -void BulletSphereShape:: -operator = (const BulletSphereShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _radius = copy._radius; + _shape = new btSphereShape(_radius); + _shape->setUserPointer(this); } diff --git a/panda/src/bullet/bulletSphereShape.h b/panda/src/bullet/bulletSphereShape.h index b11d1c4a32..aad49a145c 100644 --- a/panda/src/bullet/bulletSphereShape.h +++ b/panda/src/bullet/bulletSphereShape.h @@ -33,7 +33,6 @@ private: PUBLISHED: explicit BulletSphereShape(PN_stdfloat radius); BulletSphereShape(const BulletSphereShape ©); - void operator = (const BulletSphereShape ©); INLINE ~BulletSphereShape(); INLINE PN_stdfloat get_radius() const; diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index 61905a406a..ced374a3fc 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -86,21 +86,21 @@ BulletTriangleMeshShape:: BulletTriangleMeshShape(const BulletTriangleMeshShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _bvh_shape = copy._bvh_shape; - _gimpact_shape = copy._gimpact_shape; - _mesh = copy._mesh; -} - -/** - * - */ -void BulletTriangleMeshShape:: -operator = (const BulletTriangleMeshShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _bvh_shape = copy._bvh_shape; - _gimpact_shape = copy._gimpact_shape; + _dynamic = copy._dynamic; + _compress = copy._compress; + _bvh = copy._bvh; _mesh = copy._mesh; + + if (_dynamic) { + _gimpact_shape = new btGImpactMeshShape(_mesh->ptr()); + _gimpact_shape->updateBound(); + _gimpact_shape->setUserPointer(this); + _bvh_shape = NULL; + } else { + _bvh_shape = new btBvhTriangleMeshShape(_mesh->ptr(), _compress, _bvh); + _bvh_shape->setUserPointer(this); + _gimpact_shape = NULL; + } } /** diff --git a/panda/src/bullet/bulletTriangleMeshShape.h b/panda/src/bullet/bulletTriangleMeshShape.h index 079fb2aeb1..199efb75d1 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.h +++ b/panda/src/bullet/bulletTriangleMeshShape.h @@ -33,7 +33,6 @@ private: PUBLISHED: explicit BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress=true, bool bvh=true); BulletTriangleMeshShape(const BulletTriangleMeshShape ©); - void operator = (const BulletTriangleMeshShape ©); INLINE ~BulletTriangleMeshShape(); void refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max);