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);
47 btCollisionObject *BulletGhostNode::
56 void BulletGhostNode::
61 for (
size_t i = 0; i < parents.get_num_parents(); ++i) {
65 if (BulletRigidBodyNode::get_class_type() == type ||
66 BulletSoftBodyNode::get_class_type() == type ||
67 BulletGhostNode::get_class_type() == type ||
68 type.
is_derived_from(BulletBaseCharacterControllerNode::get_class_type())) {
81 void BulletGhostNode::
82 do_transform_changed() {
84 if (_sync_disable)
return;
89 LMatrix4 m_sync = _sync->
get_mat();
90 LMatrix4 m_ts = ts->get_mat();
92 if (!m_sync.almost_equal(m_ts)) {
95 btTransform trans = TransformState_to_btTrans(ts);
96 _ghost->setWorldTransform(trans);
97 _ghost->setInterpolationWorldTransform(trans);
99 if (ts->has_scale()) {
100 LVecBase3 scale = ts->get_scale();
101 if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) {
103 shape->do_set_local_scale(scale);
110 void BulletGhostNode::
111 transform_changed() {
113 if (_sync_disable)
return;
117 do_transform_changed();
123 int BulletGhostNode::
124 get_num_overlapping_nodes()
const {
127 return _ghost->getNumOverlappingObjects();
134 get_overlapping_node(
int idx)
const {
137 nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(),
nullptr);
139 btCollisionObject *
object = _ghost->getOverlappingObject(idx);
140 return (
object) ? (
PandaNode *)object->getUserPointer() :
nullptr;
149 do_transform_changed();
159 LVecBase3 scale = np.get_net_transform()->
get_scale();
161 btTransform trans = _ghost->getWorldTransform();
164 LMatrix4 m_sync = _sync->get_mat();
165 LMatrix4 m_ts = ts->get_mat();
167 if (!m_sync.almost_equal(m_ts)) {
169 _sync_disable =
true;
171 _sync_disable =
false;
void do_sync_p2b()
Assumes the lock(bullet global lock) is held by the caller.
A basic node of the scene graph or data graph.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void do_sync_b2p()
Assumes the lock(bullet global lock) is held by the caller.
bool is_derived_from(TypeHandle parent, TypedObject *object=nullptr) const
Returns true if this type is derived from the indicated type, false otherwise.
void set_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Changes the complete transform object on this node.
get_parents
Returns an object that can be used to walk through the list of parents of the node,...
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.
Similar to MutexHolder, but for a light mutex.
get_parent
Returns the nth parent node of this node.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
LVecBase3 get_scale() const
Retrieves the scale component of the transform.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const LMatrix4 & get_mat() const
Returns the transform matrix that has been applied to the referenced node, or the identity matrix if ...
TypeHandle is the identifier used to differentiate C++ class types.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...