28 _sync = TransformState::make_identity();
29 _sync_disable =
false;
33 btTransform trans = btTransform::getIdentity();
36 _ghost =
new btPairCachingGhostObject();
37 _ghost->setUserPointer(
this);
38 _ghost->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
39 _ghost->setWorldTransform(trans);
40 _ghost->setInterpolationWorldTransform(trans);
41 _ghost->setCollisionShape(_shape);
56 btTransform trans = TransformState_to_btTrans(get_transform());
59 _ghost =
new btPairCachingGhostObject();
60 _ghost->setUserPointer(
this);
61 _ghost->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
62 _ghost->setWorldTransform(trans);
63 _ghost->setInterpolationWorldTransform(trans);
64 _ghost->setCollisionShape(_shape);
80btCollisionObject *BulletGhostNode::
94 for (
size_t i = 0; i < parents.get_num_parents(); ++i) {
98 if (BulletRigidBodyNode::get_class_type() == type ||
99 BulletSoftBodyNode::get_class_type() == type ||
100 BulletGhostNode::get_class_type() == type ||
101 type.
is_derived_from(BulletBaseCharacterControllerNode::get_class_type())) {
114void BulletGhostNode::
115do_transform_changed() {
117 if (_sync_disable)
return;
122 LMatrix4 m_sync = _sync->
get_mat();
123 LMatrix4 m_ts = ts->get_mat();
125 if (!m_sync.almost_equal(m_ts)) {
128 btTransform trans = TransformState_to_btTrans(ts);
129 _ghost->setWorldTransform(trans);
130 _ghost->setInterpolationWorldTransform(trans);
132 if (ts->has_scale()) {
133 LVecBase3 scale = ts->get_scale();
134 if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) {
136 shape->do_set_local_scale(scale);
143void BulletGhostNode::
146 if (_sync_disable)
return;
150 do_transform_changed();
157get_num_overlapping_nodes()
const {
160 return _ghost->getNumOverlappingObjects();
167get_overlapping_node(
int idx)
const {
170 nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(),
nullptr);
172 btCollisionObject *
object = _ghost->getOverlappingObject(idx);
173 return (
object) ? (
PandaNode *)object->getUserPointer() :
nullptr;
182 do_transform_changed();
192 LVecBase3 scale = np.get_net_transform()->
get_scale();
194 btTransform trans = _ghost->getWorldTransform();
197 LMatrix4 m_sync = _sync->get_mat();
198 LMatrix4 m_ts = ts->get_mat();
200 if (!m_sync.almost_equal(m_ts)) {
202 _sync_disable =
true;
204 _sync_disable =
false;
227 param->fillin(scan, manager);
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void do_sync_p2b()
Assumes the lock(bullet global lock) is held by the caller.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
void do_sync_b2p()
Assumes the lock(bullet global lock) is held by the caller.
static void register_with_read_factory()
Tells the BamReader how to create objects of type BulletGhostNode.
A class to retrieve the individual data elements previously stored in a Datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Similar to MutexHolder, but for a light mutex.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
static NodePath any_path(PandaNode *node, Thread *current_thread=Thread::get_current_thread())
Returns a new NodePath that represents any arbitrary path from the root to the indicated node.
LVecBase3 get_scale() const
Retrieves the scale component of the transform.
const LMatrix4 & get_mat() const
Returns the transform matrix that has been applied to the referenced node, or the identity matrix if ...
void set_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Changes the complete transform object on this node.
A basic node of the scene graph or data graph.
get_parents
Returns an object that can be used to walk through the list of parents of the node,...
get_parent
Returns the nth parent node of this node.
TypeHandle is the identifier used to differentiate C++ class types.
bool is_derived_from(TypeHandle parent, TypedObject *object=nullptr) const
Returns true if this type is derived from the indicated type, false otherwise.
Base class for objects that can be written to and read from Bam files.