bullet: Implement make_copy() for BulletGhostNode

This commit is contained in:
rdb 2021-02-05 23:48:41 +01:00
parent cc4701d299
commit 642f4a4e55
2 changed files with 35 additions and 0 deletions

View File

@ -41,6 +41,39 @@ BulletGhostNode(const char *name) : BulletBodyNode(name) {
_ghost->setCollisionShape(_shape);
}
/**
* Do not call the copy constructor directly; instead, use make_copy() or
* copy_subgraph() to make a copy of a node.
*/
BulletGhostNode::
BulletGhostNode(const BulletGhostNode &copy) :
BulletBodyNode(copy),
_sync(TransformState::make_identity()),
_sync_disable(false),
_sync_local(false)
{
// Initial transform - the node has no parent yet, so this is the local one
btTransform trans = TransformState_to_btTrans(get_transform());
// Ghost object
_ghost = new btPairCachingGhostObject();
_ghost->setUserPointer(this);
_ghost->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
_ghost->setWorldTransform(trans);
_ghost->setInterpolationWorldTransform(trans);
_ghost->setCollisionShape(_shape);
}
/**
* 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 *BulletGhostNode::
make_copy() const {
return new BulletGhostNode(*this);
}
/**
*
*/

View File

@ -61,8 +61,10 @@ private:
public:
static void register_with_read_factory();
virtual PandaNode *make_copy() const;
protected:
BulletGhostNode(const BulletGhostNode &copy);
static TypedWritable *make_from_bam(const FactoryParams &params);
public: