15 #include "cullTraverserData.h" 16 #include "cullTraverser.h" 17 #include "config_pgraph.h" 18 #include "pandaNode.h" 19 #include "colorAttrib.h" 20 #include "textureAttrib.h" 21 #include "renderModeAttrib.h" 22 #include "clipPlaneAttrib.h" 23 #include "boundingPlane.h" 24 #include "billboardEffect.h" 25 #include "compassEffect.h" 26 #include "occluderEffect.h" 27 #include "polylightEffect.h" 28 #include "renderState.h" 49 node_state = node_state->compose(camera->get_tag_state(tag_state));
55 _node_reader.get_off_clip_planes());
67 CPT(TransformState) node_transform,
72 node_effects->
cull_callback(trav, *
this, node_transform, node_state);
75 if (!node_transform->is_identity()) {
76 _net_transform = _net_transform->compose(node_transform);
79 (!_cull_planes->is_empty())) {
82 if (node_transform->is_singular()) {
87 _cull_planes = CullPlanes::make_empty();
90 CPT(TransformState) inv_transform =
91 node_transform->invert_compose(TransformState::make_identity());
97 _view_frustum->xform(inv_transform->get_mat());
100 _cull_planes = _cull_planes->xform(inv_transform->get_mat());
105 _state = _state->compose(node_state);
107 if (clip_plane_cull) {
108 _cull_planes = _cull_planes->apply_state(trav,
this,
109 DCAST(
ClipPlaneAttrib, node_state->get_attrib(ClipPlaneAttrib::get_class_slot())),
120 bool CullTraverserData::
125 DCAST_INTO_R(node_gbv, _node_reader.get_bounds(),
false)
127 int result = _view_frustum->contains(node_gbv);
129 if (pgraph_cat.is_spam()) {
131 << _node_path <<
" cull result = " << hex << result << dec <<
"\n";
134 if (result == BoundingVolume::IF_no_intersection) {
139 if (!fake_view_frustum_cull) {
147 CPT(
RenderState) fake_state = get_fake_view_frustum_cull_state();
148 _state = _state->compose(fake_state);
151 }
else if ((result & BoundingVolume::IF_all) != 0) {
159 if (_node_reader.is_final()) {
169 if (!_cull_planes->is_empty()) {
171 DCAST_INTO_R(node_gbv, _node_reader.get_bounds(),
false)
176 _cull_planes = _cull_planes->do_cull(result, _state, node_gbv);
178 if (pgraph_cat.is_spam()) {
180 << _node_path <<
" cull planes cull result = " << hex
181 << result << dec <<
"\n";
182 _cull_planes->write(pgraph_cat.spam(
false));
185 if (_node_reader.is_final()) {
188 _cull_planes = CullPlanes::make_empty();
190 if (pgraph_cat.is_spam()) {
192 << _node_path <<
" is_final, cull planes disabled, state:\n";
193 _state->write(pgraph_cat.spam(
false), 2);
197 if (result == BoundingVolume::IF_no_intersection) {
202 if (!fake_view_frustum_cull) {
205 _cull_planes = CullPlanes::make_empty();
206 CPT(
RenderState) fake_state = get_fake_view_frustum_cull_state();
207 _state = _state->compose(fake_state);
210 }
else if ((result & BoundingVolume::IF_all) != 0) {
214 nassertr(_cull_planes->is_empty(),
true);
229 get_fake_view_frustum_cull_state() {
237 state = RenderState::make
238 (ColorAttrib::make_flat(
LColor(1.0f, 0.0f, 0.0f, 1.0f)),
239 TextureAttrib::make_all_off(),
240 RenderModeAttrib::make(RenderModeAttrib::M_wireframe),
241 RenderState::get_max_priority());
bool has_tag_state_key() const
Returns true if a nonempty tag state key has been specified for the scene's camera, false otherwise.
const RenderEffects * get_effects() const
Returns the complete RenderEffects that will be applied to this node.
const TransformState * get_transform() const
Returns the transform that has been set on this particular node.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
const RenderState * get_state() const
Returns the complete RenderState that will be applied to all nodes at this level and below...
void compose_draw_mask(DrawMask &running_draw_mask) const
Computes the result of applying this node's draw masks to a running draw mask, as during a traversal...
This functions similarly to a LightAttrib.
void cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, CPT(RenderState) &node_state) const
Calls cull_callback() on all effects.
bool has_cull_callback() const
This function is provided as an optimization, to speed up the render-time checking for the existance ...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
const string & get_tag_state_key() const
Returns the tag state key that has been specified for the scene's camera, if any. ...
string get_tag(const string &key) const
Retrieves the user-defined value that was previously set on this node for the particular key...
This functions similarly to a LightAttrib or ClipPlaneAttrib.
Camera * get_camera_node() const
Returns the camera used to render the scene.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
This is the base class for all three-component vectors and points.
void apply_transform_and_state(CullTraverser *trav)
Applies the transform and state from the current node onto the current data.
const RenderEffect * get_effect(int n) const
Returns the nth effect in the state.
SceneSetup * get_scene() const
Returns the SceneSetup object.
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
bool has_tag(const string &key) const
Returns true if a value has been defined on this node for the particular key (even if that value is t...
This represents a unique collection of RenderEffect objects that correspond to a particular renderabl...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...