Selaa lähdekoodia

bullet: Clean up BulletContact/BulletManifoldPoint reference handling a bit

Still looks kinda sketchy though

Related to #1192
rdb 3 vuotta sitten
vanhempi
sitoutus
f64dcbd3df

+ 1 - 1
panda/src/bullet/bulletContactResult.I

@@ -32,7 +32,7 @@ get_node1() const {
 /**
  *
  */
-INLINE BulletManifoldPoint &BulletContact::
+INLINE BulletManifoldPoint BulletContact::
 get_manifold_point() {
 
   return _mp;

+ 8 - 8
panda/src/bullet/bulletContactResult.cxx

@@ -21,9 +21,13 @@ BulletContact BulletContactResult::_empty;
  */
 BulletContact::
 BulletContact() : _mp(_empty) {
+}
 
-  _node0 = nullptr;
-  _node1 = nullptr;
+/**
+ *
+ */
+BulletContact::
+BulletContact(btManifoldPoint &mp) : _mp(mp) {
 }
 
 /**
@@ -93,9 +97,7 @@ addSingleResult(btManifoldPoint &mp,
   const btCollisionObject *obj0 = wrap0->getCollisionObject();
   const btCollisionObject *obj1 = wrap1->getCollisionObject();
 
-  BulletContact contact;
-
-  contact._mp = BulletManifoldPoint(mp);
+  BulletContact contact(mp);
   contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr;
   contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr;
   contact._part_id0 = part_id0;
@@ -116,9 +118,7 @@ addSingleResult(btManifoldPoint &mp,
                 const btCollisionObject *obj0, int part_id0, int idx0,
                 const btCollisionObject *obj1, int part_id1, int idx1) {
 
-  BulletContact contact;
-
-  contact._mp = BulletManifoldPoint(mp);
+  BulletContact contact(mp);
   contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr;
   contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr;
   contact._part_id0 = part_id0;

+ 2 - 1
panda/src/bullet/bulletContactResult.h

@@ -28,10 +28,11 @@ struct EXPCL_PANDABULLET BulletContact {
 
 public:
   BulletContact();
+  BulletContact(btManifoldPoint &mp);
   BulletContact(const BulletContact &other);
 
 PUBLISHED:
-  INLINE BulletManifoldPoint &get_manifold_point();
+  INLINE BulletManifoldPoint get_manifold_point();
   INLINE PandaNode *get_node0() const;
   INLINE PandaNode *get_node1() const;
   INLINE int get_idx0() const;

+ 0 - 8
panda/src/bullet/bulletManifoldPoint.I

@@ -10,11 +10,3 @@
  * @author enn0x
  * @date 2010-03-07
  */
-
-/**
- *
- */
-INLINE BulletManifoldPoint::
-~BulletManifoldPoint() {
-
-}

+ 0 - 19
panda/src/bullet/bulletManifoldPoint.cxx

@@ -24,25 +24,6 @@ BulletManifoldPoint(btManifoldPoint &pt)
 
 }
 
-/**
- *
- */
-BulletManifoldPoint::
-BulletManifoldPoint(const BulletManifoldPoint &other)
- : _pt(other._pt) {
-
-}
-
-/**
- *
- */
-BulletManifoldPoint& BulletManifoldPoint::
-operator=(const BulletManifoldPoint& other) {
-
-  this->_pt = other._pt;
-  return *this;
-}
-
 /**
  *
  */

+ 3 - 3
panda/src/bullet/bulletManifoldPoint.h

@@ -27,7 +27,7 @@
 class EXPCL_PANDABULLET BulletManifoldPoint {
 
 PUBLISHED:
-  INLINE ~BulletManifoldPoint();
+  ~BulletManifoldPoint() = default;
 
   int get_life_time() const;
   PN_stdfloat get_distance() const;
@@ -95,8 +95,8 @@ PUBLISHED:
 public:
   BulletManifoldPoint(btManifoldPoint &pt);
 
-  BulletManifoldPoint(const BulletManifoldPoint &other);
-  BulletManifoldPoint& operator=(const BulletManifoldPoint& other);
+  BulletManifoldPoint(const BulletManifoldPoint &other) = default;
+  BulletManifoldPoint& operator=(const BulletManifoldPoint& other) = delete;
 
 private:
   btManifoldPoint &_pt;