mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
Implement make_copy() for BulletRigidBodyNode
This appears to be the last piece needed to load BulletRigidBodyNodes from BAM files.
This commit is contained in:
parent
758cd523e2
commit
81dd4d97ad
@ -36,6 +36,25 @@ BulletBodyNode(const char *name) : PandaNode(name) {
|
|||||||
set_into_collide_mask(CollideMask::all_on());
|
set_into_collide_mask(CollideMask::all_on());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
BulletBodyNode::
|
||||||
|
BulletBodyNode(const BulletBodyNode ©) :
|
||||||
|
PandaNode(copy),
|
||||||
|
_shapes(copy._shapes)
|
||||||
|
{
|
||||||
|
if (copy._shape && copy._shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) {
|
||||||
|
_shape = new btCompoundShape(copy._shape);
|
||||||
|
}
|
||||||
|
else if (copy._shape && copy._shape->getShapeType() == EMPTY_SHAPE_PROXYTYPE) {
|
||||||
|
_shape = new btEmptyShape();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_shape = copy._shape;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the subset of CollideMask bits that may be set for this particular
|
* Returns the subset of CollideMask bits that may be set for this particular
|
||||||
* type of PandaNode. For BodyNodes this returns all bits on.
|
* type of PandaNode. For BodyNodes this returns all bits on.
|
||||||
|
@ -33,6 +33,7 @@ class BulletShape;
|
|||||||
class EXPCL_PANDABULLET BulletBodyNode : public PandaNode {
|
class EXPCL_PANDABULLET BulletBodyNode : public PandaNode {
|
||||||
protected:
|
protected:
|
||||||
BulletBodyNode(const char *name);
|
BulletBodyNode(const char *name);
|
||||||
|
BulletBodyNode(const BulletBodyNode ©);
|
||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
INLINE ~BulletBodyNode();
|
INLINE ~BulletBodyNode();
|
||||||
|
@ -46,6 +46,31 @@ BulletRigidBodyNode(const char *name) : BulletBodyNode(name) {
|
|||||||
_rigid->setUserPointer(this);
|
_rigid->setUserPointer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not call the copy constructor directly; instead, use make_copy() or
|
||||||
|
* copy_subgraph() to make a copy of a node.
|
||||||
|
*/
|
||||||
|
BulletRigidBodyNode::
|
||||||
|
BulletRigidBodyNode(const BulletRigidBodyNode ©) :
|
||||||
|
BulletBodyNode(copy)
|
||||||
|
{
|
||||||
|
_motion = new MotionState(*copy._motion);
|
||||||
|
_rigid = new btRigidBody(*copy._rigid);
|
||||||
|
_rigid->setUserPointer(this);
|
||||||
|
_rigid->setCollisionShape(_shape);
|
||||||
|
_rigid->setMotionState(_motion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a newly-allocated PandaNode that is a shallow copy of this one. It
|
||||||
|
* will be a different pointer, but its internal data may or may not be shared
|
||||||
|
* with that of the original PandaNode. No children will be copied.
|
||||||
|
*/
|
||||||
|
PandaNode *BulletRigidBodyNode::
|
||||||
|
make_copy() const {
|
||||||
|
return new BulletRigidBodyNode(*this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -130,8 +130,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
static void register_with_read_factory();
|
static void register_with_read_factory();
|
||||||
virtual void write_datagram(BamWriter *manager, Datagram &dg);
|
virtual void write_datagram(BamWriter *manager, Datagram &dg);
|
||||||
|
virtual PandaNode *make_copy() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
BulletRigidBodyNode(const BulletRigidBodyNode ©);
|
||||||
static TypedWritable *make_from_bam(const FactoryParams ¶ms);
|
static TypedWritable *make_from_bam(const FactoryParams ¶ms);
|
||||||
void fillin(DatagramIterator &scan, BamReader *manager);
|
void fillin(DatagramIterator &scan, BamReader *manager);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user