Fixed bug in CTOR for BulletCylinderShape, and added copy constructor for all shapes.

This commit is contained in:
enn0x 2012-02-08 22:22:20 +00:00
parent 6d630e2cf1
commit 3345f207b8
24 changed files with 273 additions and 12 deletions

View File

@ -24,3 +24,23 @@ INLINE BulletBoxShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletBoxShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletBoxShape::
BulletBoxShape(const BulletBoxShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletBoxShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletBoxShape::
operator = (const BulletBoxShape &copy) {
_shape = copy._shape;
}

View File

@ -32,6 +32,8 @@ class EXPCL_PANDABULLET BulletBoxShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletBoxShape(const LVecBase3 &halfExtents); BulletBoxShape(const LVecBase3 &halfExtents);
INLINE BulletBoxShape(const BulletBoxShape &copy);
INLINE void operator = (const BulletBoxShape &copy);
INLINE ~BulletBoxShape(); INLINE ~BulletBoxShape();
LVecBase3 get_half_extents_without_margin() const; LVecBase3 get_half_extents_without_margin() const;

View File

@ -23,6 +23,26 @@ INLINE BulletCapsuleShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletCapsuleShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletCapsuleShape::
BulletCapsuleShape(const BulletCapsuleShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletCapsuleShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletCapsuleShape::
operator = (const BulletCapsuleShape &copy) {
_shape = copy._shape;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletCapsuleShape::get_radius // Function: BulletCapsuleShape::get_radius
// Access: Published // Access: Published

View File

@ -29,6 +29,8 @@ class EXPCL_PANDABULLET BulletCapsuleShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up);
INLINE BulletCapsuleShape(const BulletCapsuleShape &copy);
INLINE void operator = (const BulletCapsuleShape &copy);
INLINE ~BulletCapsuleShape(); INLINE ~BulletCapsuleShape();
INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_radius() const;

View File

@ -23,6 +23,26 @@ INLINE BulletConeShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletConeShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletConeShape::
BulletConeShape(const BulletConeShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletConeShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletConeShape::
operator = (const BulletConeShape &copy) {
_shape = copy._shape;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletConeShape::get_radius // Function: BulletConeShape::get_radius
// Access: Published // Access: Published

View File

@ -29,6 +29,8 @@ class EXPCL_PANDABULLET BulletConeShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up);
INLINE BulletConeShape(const BulletConeShape &copy);
INLINE void operator = (const BulletConeShape &copy);
INLINE ~BulletConeShape(); INLINE ~BulletConeShape();
INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_radius() const;

View File

@ -23,3 +23,23 @@ INLINE BulletConvexHullShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletConvexHullShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletConvexHullShape::
BulletConvexHullShape(const BulletConvexHullShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletConvexHullShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletConvexHullShape::
operator = (const BulletConvexHullShape &copy) {
_shape = copy._shape;
}

View File

@ -32,6 +32,8 @@ class EXPCL_PANDABULLET BulletConvexHullShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletConvexHullShape(); BulletConvexHullShape();
INLINE BulletConvexHullShape(const BulletConvexHullShape &copy);
INLINE void operator = (const BulletConvexHullShape &copy);
INLINE ~BulletConvexHullShape(); INLINE ~BulletConvexHullShape();
void add_point(const LPoint3 &p); void add_point(const LPoint3 &p);

View File

@ -23,6 +23,26 @@ INLINE BulletConvexPointCloudShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletConvexPointCloudShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletConvexPointCloudShape::
BulletConvexPointCloudShape(const BulletConvexPointCloudShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletConvexPointCloudShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletConvexPointCloudShape::
operator = (const BulletConvexPointCloudShape &copy) {
_shape = copy._shape;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletConvexPointCloudShape::get_num_points // Function: BulletConvexPointCloudShape::get_num_points
// Access: Published // Access: Published

View File

@ -32,6 +32,8 @@ class EXPCL_PANDABULLET BulletConvexPointCloudShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale=LVecBase3(1.)); BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale=LVecBase3(1.));
BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale=LVecBase3(1.)); BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale=LVecBase3(1.));
INLINE BulletConvexPointCloudShape(const BulletConvexPointCloudShape &copy);
INLINE void operator = (const BulletConvexPointCloudShape &copy);
INLINE ~BulletConvexPointCloudShape(); INLINE ~BulletConvexPointCloudShape();
INLINE int get_num_points() const; INLINE int get_num_points() const;

View File

@ -23,6 +23,26 @@ INLINE BulletCylinderShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletCylinderShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletCylinderShape::
BulletCylinderShape(const BulletCylinderShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletCylinderShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletCylinderShape::
operator = (const BulletCylinderShape &copy) {
_shape = copy._shape;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletCylinderShape::get_radius // Function: BulletCylinderShape::get_radius
// Access: Published // Access: Published

View File

@ -54,13 +54,13 @@ BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) {
switch (up) { switch (up) {
case X_up: case X_up:
_shape = new btCylinderShapeX(btVector3(0.5 * height, radius, 0.0f)); _shape = new btCylinderShapeX(btVector3(0.5 * height, radius, radius));
break; break;
case Y_up: case Y_up:
_shape = new btCylinderShape(btVector3(radius, 0.5 * height, 0.0f)); _shape = new btCylinderShape(btVector3(radius, 0.5 * height, radius));
break; break;
case Z_up: case Z_up:
_shape = new btCylinderShapeZ(btVector3(radius, 0.0f, 0.5 * height)); _shape = new btCylinderShapeZ(btVector3(radius, radius, 0.5 * height));
break; break;
default: default:
bullet_cat.error() << "invalid up-axis:" << up << endl; bullet_cat.error() << "invalid up-axis:" << up << endl;

View File

@ -28,8 +28,10 @@
class EXPCL_PANDABULLET BulletCylinderShape : public BulletShape { class EXPCL_PANDABULLET BulletCylinderShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up=Z_up);
BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up);
BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up=Z_up);
INLINE BulletCylinderShape(const BulletCylinderShape &copy);
INLINE void operator = (const BulletCylinderShape &copy);
INLINE ~BulletCylinderShape(); INLINE ~BulletCylinderShape();
INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_radius() const;

View File

@ -24,3 +24,34 @@ INLINE BulletHeightfieldShape::
delete _data; delete _data;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletHeightfieldShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletHeightfieldShape::
BulletHeightfieldShape(const BulletHeightfieldShape &copy) :
_shape(copy._shape),
_num_rows(copy._num_rows),
_num_cols(copy._num_cols) {
_data = new float[_num_rows * _num_cols];
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float));
}
////////////////////////////////////////////////////////////////////
// Function: BulletHeightfieldShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletHeightfieldShape::
operator = (const BulletHeightfieldShape &copy) {
_shape = copy._shape;
_num_rows = copy._num_rows;
_num_cols = copy._num_cols;
_data = new float[_num_rows * _num_cols];
memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float));
}

View File

@ -24,19 +24,20 @@ TypeHandle BulletHeightfieldShape::_type_handle;
BulletHeightfieldShape:: BulletHeightfieldShape::
BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up) { BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up) {
int num_rows = image.get_x_size(); _num_rows = image.get_x_size();
int num_columns = image.get_y_size(); _num_cols = image.get_y_size();
_data = new float[num_rows * num_columns]; _data = new float[_num_rows * _num_cols];
for (int row=0; row < num_rows; row++) { for (int row=0; row < _num_rows; row++) {
for (int column=0; column < num_columns; column++) { for (int column=0; column < _num_cols; column++) {
_data[num_columns * row + column] = _data[_num_cols * row + column] =
max_height * image.get_bright(column, num_columns - row - 1); max_height * image.get_bright(column, _num_cols - row - 1);
} }
} }
_shape = new btHeightfieldTerrainShape(num_rows, num_columns, _shape = new btHeightfieldTerrainShape(_num_rows,
_num_cols,
_data, _data,
max_height, max_height,
up, up,

View File

@ -31,6 +31,8 @@ class EXPCL_PANDABULLET BulletHeightfieldShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up); BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up);
INLINE BulletHeightfieldShape(const BulletHeightfieldShape &copy);
INLINE void operator = (const BulletHeightfieldShape &copy);
INLINE ~BulletHeightfieldShape(); INLINE ~BulletHeightfieldShape();
void set_use_diamond_subdivision(bool flag=true); void set_use_diamond_subdivision(bool flag=true);
@ -39,6 +41,8 @@ public:
virtual btCollisionShape *ptr() const; virtual btCollisionShape *ptr() const;
private: private:
int _num_rows;
int _num_cols;
float *_data; float *_data;
btHeightfieldTerrainShape *_shape; btHeightfieldTerrainShape *_shape;

View File

@ -23,6 +23,26 @@ INLINE BulletMultiSphereShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletMultiSphereShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletMultiSphereShape::
BulletMultiSphereShape(const BulletMultiSphereShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletMultiSphereShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletMultiSphereShape::
operator = (const BulletMultiSphereShape &copy) {
_shape = copy._shape;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletMultiSphereShape::get_sphere_count // Function: BulletMultiSphereShape::get_sphere_count
// Access: Published // Access: Published

View File

@ -31,6 +31,8 @@ class EXPCL_PANDABULLET BulletMultiSphereShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii); BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii);
INLINE BulletMultiSphereShape(const BulletMultiSphereShape &copy);
INLINE void operator = (const BulletMultiSphereShape &copy);
INLINE ~BulletMultiSphereShape(); INLINE ~BulletMultiSphereShape();
INLINE int get_sphere_count() const; INLINE int get_sphere_count() const;

View File

@ -23,6 +23,26 @@ INLINE BulletPlaneShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletPlaneShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletPlaneShape::
BulletPlaneShape(const BulletPlaneShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletPlaneShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletPlaneShape::
operator = (const BulletPlaneShape &copy) {
_shape = copy._shape;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletPlaneShape::get_plane_constant // Function: BulletPlaneShape::get_plane_constant
// Access: Published // Access: Published

View File

@ -32,6 +32,8 @@ class EXPCL_PANDABULLET BulletPlaneShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant);
INLINE BulletPlaneShape(const BulletPlaneShape &copy);
INLINE void operator = (const BulletPlaneShape &copy);
INLINE ~BulletPlaneShape(); INLINE ~BulletPlaneShape();
INLINE LVector3 get_plane_normal() const; INLINE LVector3 get_plane_normal() const;

View File

@ -23,6 +23,26 @@ INLINE BulletSphereShape::
delete _shape; delete _shape;
} }
////////////////////////////////////////////////////////////////////
// Function: BulletSphereShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletSphereShape::
BulletSphereShape(const BulletSphereShape &copy) :
_shape(copy._shape) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletSphereShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletSphereShape::
operator = (const BulletSphereShape &copy) {
_shape = copy._shape;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletSphereShape::get_radius // Function: BulletSphereShape::get_radius
// Access: Published // Access: Published

View File

@ -31,6 +31,8 @@ class EXPCL_PANDABULLET BulletSphereShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletSphereShape(PN_stdfloat radius); BulletSphereShape(PN_stdfloat radius);
INLINE BulletSphereShape(const BulletSphereShape &copy);
INLINE void operator = (const BulletSphereShape &copy);
INLINE ~BulletSphereShape(); INLINE ~BulletSphereShape();
INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_radius() const;

View File

@ -12,6 +12,31 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: BulletTriangleMeshShape::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE BulletTriangleMeshShape::
BulletTriangleMeshShape(const BulletTriangleMeshShape &copy) :
_bvh_shape(copy._bvh_shape),
_gimpact_shape(copy._gimpact_shape),
_mesh(copy._mesh) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletTriangleMeshShape::Copy Assignment Operator
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE void BulletTriangleMeshShape::
operator = (const BulletTriangleMeshShape &copy) {
_bvh_shape = copy._bvh_shape;
_gimpact_shape = copy._gimpact_shape;
_mesh = copy._mesh;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BulletTriangleMeshShape::Destructor // Function: BulletTriangleMeshShape::Destructor
// Access: Published // Access: Published

View File

@ -32,6 +32,8 @@ class EXPCL_PANDABULLET BulletTriangleMeshShape : public BulletShape {
PUBLISHED: PUBLISHED:
BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress=true, bool bvh=true); BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress=true, bool bvh=true);
INLINE BulletTriangleMeshShape(const BulletTriangleMeshShape &copy);
INLINE void operator = (const BulletTriangleMeshShape &copy);
INLINE ~BulletTriangleMeshShape(); INLINE ~BulletTriangleMeshShape();
void refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max); void refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max);