mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
define flatten-collision-nodes
This commit is contained in:
parent
3971dfc49b
commit
cb1c87d58c
@ -145,27 +145,29 @@ xform(const LMatrix4f &mat) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PandaNode *CollisionNode::
|
||||
combine_with(PandaNode *other) {
|
||||
if (is_exact_type(get_class_type()) &&
|
||||
other->is_exact_type(get_class_type())) {
|
||||
// Two CollisionNodes can combine, but only if they have the same
|
||||
// name, because the name is often meaningful, and only if they
|
||||
// have the same collide masks.
|
||||
CollisionNode *cother = DCAST(CollisionNode, other);
|
||||
if (get_name() == cother->get_name() &&
|
||||
get_from_collide_mask() == cother->get_from_collide_mask() &&
|
||||
get_into_collide_mask() == cother->get_into_collide_mask()) {
|
||||
const COWPT(CollisionSolid) *solids_begin = &cother->_solids[0];
|
||||
const COWPT(CollisionSolid) *solids_end = solids_begin + cother->_solids.size();
|
||||
_solids.insert(_solids.end(), solids_begin, solids_end);
|
||||
mark_internal_bounds_stale();
|
||||
return this;
|
||||
if (flatten_collision_nodes) {
|
||||
if (is_exact_type(get_class_type()) &&
|
||||
other->is_exact_type(get_class_type())) {
|
||||
// Two CollisionNodes can combine, but only if they have the same
|
||||
// name, because the name is often meaningful, and only if they
|
||||
// have the same collide masks.
|
||||
CollisionNode *cother = DCAST(CollisionNode, other);
|
||||
if (get_name() == cother->get_name() &&
|
||||
get_from_collide_mask() == cother->get_from_collide_mask() &&
|
||||
get_into_collide_mask() == cother->get_into_collide_mask()) {
|
||||
const COWPT(CollisionSolid) *solids_begin = &cother->_solids[0];
|
||||
const COWPT(CollisionSolid) *solids_end = solids_begin + cother->_solids.size();
|
||||
_solids.insert(_solids.end(), solids_begin, solids_end);
|
||||
mark_internal_bounds_stale();
|
||||
return this;
|
||||
}
|
||||
|
||||
// Two CollisionNodes with different names or different collide
|
||||
// masks can't combine.
|
||||
}
|
||||
|
||||
// Two CollisionNodes with different names can't combine.
|
||||
return (PandaNode *)NULL;
|
||||
}
|
||||
|
||||
return PandaNode::combine_with(other);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -73,6 +73,17 @@ ConfigVariableBool allow_collider_multiple
|
||||
"false, a one-word BitMask is always used instead, which is faster "
|
||||
"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
|
||||
|
@ -28,6 +28,7 @@ NotifyCategoryDecl(collide, EXPCL_PANDA, EXPTP_PANDA);
|
||||
extern EXPCL_PANDA ConfigVariableBool respect_prev_transform;
|
||||
extern EXPCL_PANDA ConfigVariableBool respect_effective_normal;
|
||||
extern EXPCL_PANDA ConfigVariableBool allow_collider_multiple;
|
||||
extern EXPCL_PANDA ConfigVariableBool flatten_collision_nodes;
|
||||
|
||||
extern EXPCL_PANDA void init_libcollide();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user