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;
}
////////////////////////////////////////////////////////////////////
// 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:
BulletBoxShape(const LVecBase3 &halfExtents);
INLINE BulletBoxShape(const BulletBoxShape &copy);
INLINE void operator = (const BulletBoxShape &copy);
INLINE ~BulletBoxShape();
LVecBase3 get_half_extents_without_margin() const;

View File

@ -23,6 +23,26 @@ INLINE BulletCapsuleShape::
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
// Access: Published

View File

@ -29,6 +29,8 @@ class EXPCL_PANDABULLET BulletCapsuleShape : public BulletShape {
PUBLISHED:
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 PN_stdfloat get_radius() const;

View File

@ -23,6 +23,26 @@ INLINE BulletConeShape::
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
// Access: Published

View File

@ -29,6 +29,8 @@ class EXPCL_PANDABULLET BulletConeShape : public BulletShape {
PUBLISHED:
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 PN_stdfloat get_radius() const;

View File

@ -23,3 +23,23 @@ INLINE BulletConvexHullShape::
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:
BulletConvexHullShape();
INLINE BulletConvexHullShape(const BulletConvexHullShape &copy);
INLINE void operator = (const BulletConvexHullShape &copy);
INLINE ~BulletConvexHullShape();
void add_point(const LPoint3 &p);

View File

@ -23,6 +23,26 @@ INLINE BulletConvexPointCloudShape::
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
// Access: Published

View File

@ -32,6 +32,8 @@ class EXPCL_PANDABULLET BulletConvexPointCloudShape : public BulletShape {
PUBLISHED:
BulletConvexPointCloudShape(const PTA_LVecBase3 &points, 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 int get_num_points() const;

View File

@ -23,6 +23,26 @@ INLINE BulletCylinderShape::
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
// Access: Published

View File

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

View File

@ -28,8 +28,10 @@
class EXPCL_PANDABULLET BulletCylinderShape : public BulletShape {
PUBLISHED:
BulletCylinderShape(const LVector3 &half_extents, 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 PN_stdfloat get_radius() const;

View File

@ -24,3 +24,34 @@ INLINE BulletHeightfieldShape::
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(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up) {
int num_rows = image.get_x_size();
int num_columns = image.get_y_size();
_num_rows = image.get_x_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 column=0; column < num_columns; column++) {
_data[num_columns * row + column] =
max_height * image.get_bright(column, num_columns - row - 1);
for (int row=0; row < _num_rows; row++) {
for (int column=0; column < _num_cols; column++) {
_data[_num_cols * row + column] =
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,
max_height,
up,

View File

@ -31,6 +31,8 @@ class EXPCL_PANDABULLET BulletHeightfieldShape : public BulletShape {
PUBLISHED:
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();
void set_use_diamond_subdivision(bool flag=true);
@ -39,6 +41,8 @@ public:
virtual btCollisionShape *ptr() const;
private:
int _num_rows;
int _num_cols;
float *_data;
btHeightfieldTerrainShape *_shape;

View File

@ -23,6 +23,26 @@ INLINE BulletMultiSphereShape::
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
// Access: Published

View File

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

View File

@ -23,6 +23,26 @@ INLINE BulletPlaneShape::
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
// Access: Published

View File

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

View File

@ -23,6 +23,26 @@ INLINE BulletSphereShape::
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
// Access: Published

View File

@ -31,6 +31,8 @@ class EXPCL_PANDABULLET BulletSphereShape : public BulletShape {
PUBLISHED:
BulletSphereShape(PN_stdfloat radius);
INLINE BulletSphereShape(const BulletSphereShape &copy);
INLINE void operator = (const BulletSphereShape &copy);
INLINE ~BulletSphereShape();
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
// Access: Published

View File

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