mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 03:15:07 -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::
|
PandaNode *CollisionNode::
|
||||||
combine_with(PandaNode *other) {
|
combine_with(PandaNode *other) {
|
||||||
if (is_exact_type(get_class_type()) &&
|
if (flatten_collision_nodes) {
|
||||||
other->is_exact_type(get_class_type())) {
|
if (is_exact_type(get_class_type()) &&
|
||||||
// Two CollisionNodes can combine, but only if they have the same
|
other->is_exact_type(get_class_type())) {
|
||||||
// name, because the name is often meaningful, and only if they
|
// Two CollisionNodes can combine, but only if they have the same
|
||||||
// have the same collide masks.
|
// name, because the name is often meaningful, and only if they
|
||||||
CollisionNode *cother = DCAST(CollisionNode, other);
|
// have the same collide masks.
|
||||||
if (get_name() == cother->get_name() &&
|
CollisionNode *cother = DCAST(CollisionNode, other);
|
||||||
get_from_collide_mask() == cother->get_from_collide_mask() &&
|
if (get_name() == cother->get_name() &&
|
||||||
get_into_collide_mask() == cother->get_into_collide_mask()) {
|
get_from_collide_mask() == cother->get_from_collide_mask() &&
|
||||||
const COWPT(CollisionSolid) *solids_begin = &cother->_solids[0];
|
get_into_collide_mask() == cother->get_into_collide_mask()) {
|
||||||
const COWPT(CollisionSolid) *solids_end = solids_begin + cother->_solids.size();
|
const COWPT(CollisionSolid) *solids_begin = &cother->_solids[0];
|
||||||
_solids.insert(_solids.end(), solids_begin, solids_end);
|
const COWPT(CollisionSolid) *solids_end = solids_begin + cother->_solids.size();
|
||||||
mark_internal_bounds_stale();
|
_solids.insert(_solids.end(), solids_begin, solids_end);
|
||||||
return this;
|
mark_internal_bounds_stale();
|
||||||
}
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -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
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user