define flatten-collision-nodes

This commit is contained in:
David Rose 2007-06-08 23:38:27 +00:00
parent 3971dfc49b
commit cb1c87d58c
3 changed files with 32 additions and 18 deletions

View File

@ -145,6 +145,7 @@ xform(const LMatrix4f &mat) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
PandaNode *CollisionNode:: PandaNode *CollisionNode::
combine_with(PandaNode *other) { combine_with(PandaNode *other) {
if (flatten_collision_nodes) {
if (is_exact_type(get_class_type()) && if (is_exact_type(get_class_type()) &&
other->is_exact_type(get_class_type())) { other->is_exact_type(get_class_type())) {
// Two CollisionNodes can combine, but only if they have the same // Two CollisionNodes can combine, but only if they have the same
@ -161,11 +162,12 @@ combine_with(PandaNode *other) {
return this; return this;
} }
// Two CollisionNodes with different names can't combine. // Two CollisionNodes with different names or different collide
return (PandaNode *)NULL; // masks can't combine.
}
} }
return PandaNode::combine_with(other); return NULL;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -73,6 +73,17 @@ ConfigVariableBool allow_collider_multiple
"false, a one-word BitMask is always used instead, which is faster " "false, a one-word BitMask is always used instead, which is faster "
"per pass, but may require more passes.")); "per pass, but may require more passes."));
ConfigVariableBool flatten_collision_nodes
("flatten-collision-nodes", false,
PRC_DESC("Set this true to allow NodePath::flatten_medium() and "
"flatten_strong() to combine multiple CollisionNodes "
"into a single CollisionNode--but only if they share the "
"same name and collide masks. When false, CollisionNodes "
"are never combined. This is false by default, since "
"collision tests rely heavily on bounding volume tests "
"to be efficient, and combining CollisionNodes is likely "
"to merge bounding volumes inappropriately."));
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: init_libcollide // Function: init_libcollide

View File

@ -28,6 +28,7 @@ NotifyCategoryDecl(collide, EXPCL_PANDA, EXPTP_PANDA);
extern EXPCL_PANDA ConfigVariableBool respect_prev_transform; extern EXPCL_PANDA ConfigVariableBool respect_prev_transform;
extern EXPCL_PANDA ConfigVariableBool respect_effective_normal; extern EXPCL_PANDA ConfigVariableBool respect_effective_normal;
extern EXPCL_PANDA ConfigVariableBool allow_collider_multiple; extern EXPCL_PANDA ConfigVariableBool allow_collider_multiple;
extern EXPCL_PANDA ConfigVariableBool flatten_collision_nodes;
extern EXPCL_PANDA void init_libcollide(); extern EXPCL_PANDA void init_libcollide();