mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Providing a single method for attaching/removing objects from a world.
This commit is contained in:
parent
a737ebcc90
commit
62ffe69dbc
@ -29,11 +29,7 @@ class BulletWheel;
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : BulletVehicleTuning
|
// Class : BulletVehicleTuning
|
||||||
// Description : Simulates a raycast vehicle which casts a ray per
|
// Description :
|
||||||
// wheel at the ground as a cheap replacement for
|
|
||||||
// complex suspension simulation. The suspension can
|
|
||||||
// be tuned in various ways. It is possible to add a
|
|
||||||
// (probably) arbitrary number of wheels.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class BulletVehicleTuning {
|
class BulletVehicleTuning {
|
||||||
|
|
||||||
@ -60,7 +56,11 @@ private:
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : BulletVehicle
|
// Class : BulletVehicle
|
||||||
// Description :
|
// Description : Simulates a raycast vehicle which casts a ray per
|
||||||
|
// wheel at the ground as a cheap replacement for
|
||||||
|
// complex suspension simulation. The suspension can
|
||||||
|
// be tuned in various ways. It is possible to add a
|
||||||
|
// (probably) arbitrary number of wheels.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDABULLET BulletVehicle : public TypedReferenceCount {
|
class EXPCL_PANDABULLET BulletVehicle : public TypedReferenceCount {
|
||||||
|
|
||||||
|
@ -310,11 +310,74 @@ clear_debug_node() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::attach_rigid_body
|
// Function: BulletWorld::attach
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
|
attach(TypedObject *object) {
|
||||||
|
|
||||||
|
if (object->is_of_type(BulletGhostNode::get_class_type())) {
|
||||||
|
attach_ghost(DCAST(BulletGhostNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletRigidBodyNode::get_class_type())) {
|
||||||
|
attach_rigid_body(DCAST(BulletRigidBodyNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletSoftBodyNode::get_class_type())) {
|
||||||
|
attach_soft_body(DCAST(BulletSoftBodyNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletBaseCharacterControllerNode::get_class_type())) {
|
||||||
|
attach_character(DCAST(BulletBaseCharacterControllerNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletVehicle::get_class_type())) {
|
||||||
|
attach_vehicle(DCAST(BulletVehicle, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletConstraint::get_class_type())) {
|
||||||
|
attach_constraint(DCAST(BulletConstraint, object));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bullet_cat->error() << "not a bullet world object!" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletWorld::remove
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void BulletWorld::
|
||||||
|
remove(TypedObject *object) {
|
||||||
|
|
||||||
|
if (object->is_of_type(BulletGhostNode::get_class_type())) {
|
||||||
|
remove_ghost(DCAST(BulletGhostNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletRigidBodyNode::get_class_type())) {
|
||||||
|
remove_rigid_body(DCAST(BulletRigidBodyNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletSoftBodyNode::get_class_type())) {
|
||||||
|
remove_soft_body(DCAST(BulletSoftBodyNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletBaseCharacterControllerNode::get_class_type())) {
|
||||||
|
remove_character(DCAST(BulletBaseCharacterControllerNode, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletVehicle::get_class_type())) {
|
||||||
|
remove_vehicle(DCAST(BulletVehicle, object));
|
||||||
|
}
|
||||||
|
else if (object->is_of_type(BulletConstraint::get_class_type())) {
|
||||||
|
remove_constraint(DCAST(BulletConstraint, object));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bullet_cat->error() << "not a bullet world object!" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BulletWorld::attach_rigid_body
|
||||||
|
// Access: Published
|
||||||
|
// Description: Deprecated!
|
||||||
|
// Please use BulletWorld::attach
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void BulletWorld::
|
||||||
attach_rigid_body(BulletRigidBodyNode *node) {
|
attach_rigid_body(BulletRigidBodyNode *node) {
|
||||||
|
|
||||||
nassertv(node);
|
nassertv(node);
|
||||||
@ -337,7 +400,8 @@ attach_rigid_body(BulletRigidBodyNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::remove_rigid_body
|
// Function: BulletWorld::remove_rigid_body
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated.!
|
||||||
|
// Please use BulletWorld::remove
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
remove_rigid_body(BulletRigidBodyNode *node) {
|
remove_rigid_body(BulletRigidBodyNode *node) {
|
||||||
@ -362,7 +426,8 @@ remove_rigid_body(BulletRigidBodyNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::attach_soft_body
|
// Function: BulletWorld::attach_soft_body
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated!
|
||||||
|
// Please use BulletWorld::attach
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
attach_soft_body(BulletSoftBodyNode *node) {
|
attach_soft_body(BulletSoftBodyNode *node) {
|
||||||
@ -391,7 +456,8 @@ attach_soft_body(BulletSoftBodyNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::remove_soft_body
|
// Function: BulletWorld::remove_soft_body
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated.!
|
||||||
|
// Please use BulletWorld::remove
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
remove_soft_body(BulletSoftBodyNode *node) {
|
remove_soft_body(BulletSoftBodyNode *node) {
|
||||||
@ -416,7 +482,8 @@ remove_soft_body(BulletSoftBodyNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::attach_ghost
|
// Function: BulletWorld::attach_ghost
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated!
|
||||||
|
// Please use BulletWorld::attach
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
attach_ghost(BulletGhostNode *node) {
|
attach_ghost(BulletGhostNode *node) {
|
||||||
@ -459,7 +526,8 @@ enum CollisionFilterGroups {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::remove_ghost
|
// Function: BulletWorld::remove_ghost
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated.!
|
||||||
|
// Please use BulletWorld::remove
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
remove_ghost(BulletGhostNode *node) {
|
remove_ghost(BulletGhostNode *node) {
|
||||||
@ -484,7 +552,8 @@ remove_ghost(BulletGhostNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::attach_character
|
// Function: BulletWorld::attach_character
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated!
|
||||||
|
// Please use BulletWorld::attach
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
attach_character(BulletBaseCharacterControllerNode *node) {
|
attach_character(BulletBaseCharacterControllerNode *node) {
|
||||||
@ -512,7 +581,8 @@ attach_character(BulletBaseCharacterControllerNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::remove_character
|
// Function: BulletWorld::remove_character
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated.!
|
||||||
|
// Please use BulletWorld::remove
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
remove_character(BulletBaseCharacterControllerNode *node) {
|
remove_character(BulletBaseCharacterControllerNode *node) {
|
||||||
@ -536,7 +606,8 @@ remove_character(BulletBaseCharacterControllerNode *node) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::attach_vehicle
|
// Function: BulletWorld::attach_vehicle
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated!
|
||||||
|
// Please use BulletWorld::attach
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
attach_vehicle(BulletVehicle *vehicle) {
|
attach_vehicle(BulletVehicle *vehicle) {
|
||||||
@ -559,7 +630,8 @@ attach_vehicle(BulletVehicle *vehicle) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::remove_vehicle
|
// Function: BulletWorld::remove_vehicle
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated.!
|
||||||
|
// Please use BulletWorld::remove
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
remove_vehicle(BulletVehicle *vehicle) {
|
remove_vehicle(BulletVehicle *vehicle) {
|
||||||
@ -584,7 +656,8 @@ remove_vehicle(BulletVehicle *vehicle) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::attach_constraint
|
// Function: BulletWorld::attach_constraint
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated!
|
||||||
|
// Please use BulletWorld::attach
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
attach_constraint(BulletConstraint *constraint) {
|
attach_constraint(BulletConstraint *constraint) {
|
||||||
@ -607,7 +680,8 @@ attach_constraint(BulletConstraint *constraint) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletWorld::remove_constraint
|
// Function: BulletWorld::remove_constraint
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: Deprecated.!
|
||||||
|
// Please use BulletWorld::remove
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletWorld::
|
void BulletWorld::
|
||||||
remove_constraint(BulletConstraint *constraint) {
|
remove_constraint(BulletConstraint *constraint) {
|
||||||
|
@ -68,34 +68,26 @@ PUBLISHED:
|
|||||||
|
|
||||||
BulletSoftBodyWorldInfo get_world_info();
|
BulletSoftBodyWorldInfo get_world_info();
|
||||||
|
|
||||||
// Ghost object
|
// Attach/Remove
|
||||||
void attach_ghost(BulletGhostNode *node);
|
void attach(TypedObject *object);
|
||||||
void remove_ghost(BulletGhostNode *node);
|
void remove(TypedObject *object);
|
||||||
|
|
||||||
|
// Ghost object
|
||||||
INLINE int get_num_ghosts() const;
|
INLINE int get_num_ghosts() const;
|
||||||
INLINE BulletGhostNode *get_ghost(int idx) const;
|
INLINE BulletGhostNode *get_ghost(int idx) const;
|
||||||
MAKE_SEQ(get_ghosts, get_num_ghosts, get_ghost);
|
MAKE_SEQ(get_ghosts, get_num_ghosts, get_ghost);
|
||||||
|
|
||||||
// Rigid body
|
// Rigid body
|
||||||
void attach_rigid_body(BulletRigidBodyNode *node);
|
|
||||||
void remove_rigid_body(BulletRigidBodyNode *node);
|
|
||||||
|
|
||||||
INLINE int get_num_rigid_bodies() const;
|
INLINE int get_num_rigid_bodies() const;
|
||||||
INLINE BulletRigidBodyNode *get_rigid_body(int idx) const;
|
INLINE BulletRigidBodyNode *get_rigid_body(int idx) const;
|
||||||
MAKE_SEQ(get_rigid_bodies, get_num_rigid_bodies, get_rigid_body);
|
MAKE_SEQ(get_rigid_bodies, get_num_rigid_bodies, get_rigid_body);
|
||||||
|
|
||||||
// Soft body
|
// Soft body
|
||||||
void attach_soft_body(BulletSoftBodyNode *node);
|
|
||||||
void remove_soft_body(BulletSoftBodyNode *node);
|
|
||||||
|
|
||||||
INLINE int get_num_soft_bodies() const;
|
INLINE int get_num_soft_bodies() const;
|
||||||
INLINE BulletSoftBodyNode *get_soft_body(int idx) const;
|
INLINE BulletSoftBodyNode *get_soft_body(int idx) const;
|
||||||
MAKE_SEQ(get_soft_bodies, get_num_soft_bodies, get_soft_body);
|
MAKE_SEQ(get_soft_bodies, get_num_soft_bodies, get_soft_body);
|
||||||
|
|
||||||
// Character controller
|
// Character controller
|
||||||
void attach_character(BulletBaseCharacterControllerNode *node);
|
|
||||||
void remove_character(BulletBaseCharacterControllerNode *node);
|
|
||||||
|
|
||||||
INLINE int get_num_characters() const;
|
INLINE int get_num_characters() const;
|
||||||
INLINE BulletBaseCharacterControllerNode *get_character(int idx) const;
|
INLINE BulletBaseCharacterControllerNode *get_character(int idx) const;
|
||||||
MAKE_SEQ(get_characters, get_num_characters, get_character);
|
MAKE_SEQ(get_characters, get_num_characters, get_character);
|
||||||
@ -109,9 +101,6 @@ PUBLISHED:
|
|||||||
MAKE_SEQ(get_vehicles, get_num_vehicles, get_vehicle);
|
MAKE_SEQ(get_vehicles, get_num_vehicles, get_vehicle);
|
||||||
|
|
||||||
// Constraint
|
// Constraint
|
||||||
void attach_constraint(BulletConstraint *constraint);
|
|
||||||
void remove_constraint(BulletConstraint *constraint);
|
|
||||||
|
|
||||||
INLINE int get_num_constraints() const;
|
INLINE int get_num_constraints() const;
|
||||||
INLINE BulletConstraint *get_constraint(int idx) const;
|
INLINE BulletConstraint *get_constraint(int idx) const;
|
||||||
MAKE_SEQ(get_constraints, get_num_constraints, get_constraint);
|
MAKE_SEQ(get_constraints, get_num_constraints, get_constraint);
|
||||||
@ -164,6 +153,22 @@ PUBLISHED:
|
|||||||
void set_python_filter_callback(PyObject *callback);
|
void set_python_filter_callback(PyObject *callback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PUBLISHED: // Deprecated methods, will become private soon
|
||||||
|
void attach_ghost(BulletGhostNode *node);
|
||||||
|
void remove_ghost(BulletGhostNode *node);
|
||||||
|
|
||||||
|
void attach_rigid_body(BulletRigidBodyNode *node);
|
||||||
|
void remove_rigid_body(BulletRigidBodyNode *node);
|
||||||
|
|
||||||
|
void attach_soft_body(BulletSoftBodyNode *node);
|
||||||
|
void remove_soft_body(BulletSoftBodyNode *node);
|
||||||
|
|
||||||
|
void attach_character(BulletBaseCharacterControllerNode *node);
|
||||||
|
void remove_character(BulletBaseCharacterControllerNode *node);
|
||||||
|
|
||||||
|
void attach_constraint(BulletConstraint *constraint);
|
||||||
|
void remove_constraint(BulletConstraint *constraint);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static btCollisionObject *get_collision_object(PandaNode *node);
|
static btCollisionObject *get_collision_object(PandaNode *node);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user