add clip-plane-cull

This commit is contained in:
David Rose 2007-06-04 22:34:22 +00:00
parent f554899631
commit e5d2c00879
4 changed files with 13 additions and 50 deletions

View File

@ -115,6 +115,12 @@ ConfigVariableBool fake_view_frustum_cull
"object in red wireframe, rather than actually culling it. This "
"helps make culling errors obvious."));
ConfigVariableBool clip_plane_cull
("clip-plane-cull", true,
PRC_DESC("This is normally true; set it false to disable culling of objects "
"that are completely behind one or more clip planes (primarily "
"useful for debugging)."));
ConfigVariableBool allow_portal_cull
("allow-portal-cull", false,

View File

@ -35,6 +35,7 @@ NotifyCategoryDecl(loader, EXPCL_PANDA, EXPTP_PANDA);
NotifyCategoryDecl(portal, EXPCL_PANDA, EXPTP_PANDA);
extern ConfigVariableBool fake_view_frustum_cull;
extern ConfigVariableBool clip_plane_cull;
extern ConfigVariableBool allow_portal_cull;
extern ConfigVariableBool unambiguous_graph;
extern ConfigVariableBool detect_graph_cycles;

View File

@ -117,9 +117,12 @@ apply_transform_and_state(CullTraverser *trav,
}
_state = _state->compose(node_state);
_cull_planes = _cull_planes->apply_state(trav, this,
_state->get_clip_plane(),
DCAST(ClipPlaneAttrib, off_clip_planes));
if (clip_plane_cull) {
_cull_planes = _cull_planes->apply_state(trav, this,
_state->get_clip_plane(),
DCAST(ClipPlaneAttrib, off_clip_planes));
}
}
////////////////////////////////////////////////////////////////////
@ -209,51 +212,6 @@ is_in_view_impl() {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: CullTraverserData::test_within_clip_planes_impl
// Access: Private
// Description: The private implementation of test_within_clip_planes().
////////////////////////////////////////////////////////////////////
int CullTraverserData::
test_within_clip_planes_impl(const CullTraverser *trav,
const ClipPlaneAttrib *cpa) const {
int result = BoundingVolume::IF_all | BoundingVolume::IF_possible | BoundingVolume::IF_some;
const BoundingVolume *node_volume = _node_reader.get_bounds();
nassertr(node_volume->is_of_type(GeometricBoundingVolume::get_class_type()), result);
const GeometricBoundingVolume *node_gbv =
DCAST(GeometricBoundingVolume, node_volume);
CPT(TransformState) net_transform = get_net_transform(trav);
cerr << "considering " << _node_path << ", bv = " << *node_gbv << "\n";
cerr << " net_transform = " << *net_transform << "\n";
int num_planes = cpa->get_num_on_planes();
for (int i = 0;
i < num_planes && result != BoundingVolume::IF_no_intersection;
++i) {
NodePath plane_path = cpa->get_on_plane(i);
PlaneNode *plane_node = DCAST(PlaneNode, plane_path.node());
CPT(TransformState) new_transform =
net_transform->invert_compose(plane_path.get_net_transform());
Planef plane = plane_node->get_plane() * new_transform->get_mat();
BoundingPlane bplane(-plane);
cerr << " " << bplane << " -> " << bplane.contains(node_gbv) << "\n";
result &= bplane.contains(node_gbv);
}
if (pgraph_cat.is_spam()) {
pgraph_cat.spam()
<< _node_path << " test_within_clip_planes result = "
<< hex << result << dec << "\n";
}
return result;
}
////////////////////////////////////////////////////////////////////
// Function: CullTraverserData::get_fake_view_frustum_cull_state
// Access: Private, Static

View File

@ -85,8 +85,6 @@ public:
private:
bool is_in_view_impl();
int test_within_clip_planes_impl(const CullTraverser *trav,
const ClipPlaneAttrib *cpa) const;
static CPT(RenderState) get_fake_view_frustum_cull_state();
};