18LODNode(
const std::string &name) :
47 cdata->_switch_vector.push_back(Switch(in, out));
48 cdata->check_limits();
50 if (cdata->_num_shown != 0) {
51 mark_internal_bounds_stale();
60set_switch(
int index, PN_stdfloat in, PN_stdfloat out) {
61 nassertr(in >= out,
false);
64 nassertr(index >= 0 && index < (
int)cdata->_switch_vector.size(),
false);
65 cdata->_switch_vector[index].set_range(in, out);
66 cdata->check_limits();
68 if (cdata->_num_shown != 0) {
69 mark_internal_bounds_stale();
82 cdata->_switch_vector.clear();
86 if (cdata->_num_shown != 0) {
87 mark_internal_bounds_stale();
98 CDReader cdata(_cycler);
99 return cdata->_switch_vector.size();
107 CDReader cdata(_cycler);
108 return cdata->_lod_scale;
117 CDWriter cdata(_cycler);
118 cdata->_lod_scale = value;
128 CDReader cdata(_cycler);
129 nassertr(index >= 0 && index < (
int)cdata->_switch_vector.size(), 0.0);
130 return cdata->_switch_vector[index].get_in();
139 CDReader cdata(_cycler);
140 nassertr(index >= 0 && index < (
int)cdata->_switch_vector.size(), 0.0);
141 return cdata->_switch_vector[index].get_out();
151 CDReader cdata(_cycler);
152 return cdata->_lowest;
162 CDReader cdata(_cycler);
163 return cdata->_highest;
173 cdata->_force_switch = index;
174 cdata->_got_force_switch =
true;
184 cdata->_got_force_switch =
false;
194 CDWriter cdata(_cycler);
195 cdata->_center = center;
197 if (cdata->_num_shown != 0) {
198 mark_internal_bounds_stale();
209 CDReader cdata(_cycler);
210 return cdata->_center;
220 return (cdata->_num_shown != 0);
232 do_auto_verify_lods(trav, data);
240INLINE LODNode::CData::
242 _center(0.0f, 0.0f, 0.0f),
245 _got_force_switch(false),
255INLINE LODNode::CData::
256CData(
const LODNode::CData ©) :
257 _center(copy._center),
258 _switch_vector(copy._switch_vector),
259 _lowest(copy._lowest),
260 _highest(copy._highest),
262 _got_force_switch(copy._got_force_switch),
263 _force_switch(copy._force_switch),
264 _num_shown(copy._num_shown),
265 _lod_scale(copy._lod_scale)
272INLINE LODNode::Switch::
273Switch(PN_stdfloat in, PN_stdfloat out) :
284INLINE PN_stdfloat LODNode::Switch::
292INLINE PN_stdfloat LODNode::Switch::
300INLINE
void LODNode::Switch::
301set_range(PN_stdfloat in, PN_stdfloat out) {
310INLINE
bool LODNode::Switch::
311in_range(PN_stdfloat dist)
const {
312 return (dist >= _out && dist < _in);
320INLINE
bool LODNode::Switch::
321in_range_2(PN_stdfloat dist2)
const {
322 return (dist2 >= _out * _out && dist2 < _in * _in);
328INLINE
void LODNode::Switch::
329rescale(PN_stdfloat factor) {
338INLINE
bool LODNode::Switch::
346INLINE
void LODNode::Switch::
347show(
const LColor &color) {
355INLINE
void LODNode::Switch::
365get_ring_viz()
const {
366 if (_ring_viz.is_null()) {
367 ((Switch *)
this)->compute_ring_viz();
378get_spindle_viz()
const {
379 if (_spindle_viz.is_null()) {
380 ((Switch *)
this)->compute_spindle_viz();
391get_viz_model_state()
const {
392 if (_viz_model_state.is_null()) {
393 ((Switch *)
this)->compute_viz_model_state();
396 return _viz_model_state;
403INLINE
void LODNode::Switch::
404write_datagram(
Datagram &destination)
const {
413INLINE
void LODNode::Switch::
423INLINE
void LODNode::Switch::
426 _spindle_viz.clear();
427 _viz_model_state.clear();
428 _bounds_seq = UpdateSeq::old();
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
get_lowest_switch
Returns the index number of the child with the lowest level of detail; that is, the one that is desig...
get_out
Returns the "out" distance of the indicated switch range.
bool set_switch(int index, PN_stdfloat in, PN_stdfloat out)
Changes the switching range of a particular child of the LODNode.
get_in
Returns the "in" distance of the indicated switch range.
bool is_any_shown() const
Returns true if any switch has been shown with show_switch(), indicating the LODNode is in debug show...
set_center
Specifies the center of the LOD.
get_center
Returns the center of the LOD.
void add_switch(PN_stdfloat in, PN_stdfloat out)
Adds a switch range to the LODNode.
void clear_force_switch()
Undoes the effect of a previous call to force_switch() and releases the LODNode to once again display...
get_highest_switch
Returns the index number of the child with the highest level of detail; that is, the one that is desi...
get_lod_scale
Returns the multiplier for lod distances.
get_num_switches
Returns the number of switch ranges added to the LODNode.
void clear_switches()
Removes the set of switching ranges for the LODNode, presumably in conjunction with removing all of i...
void force_switch(int index)
Forces the LODNode to show the indicated level instead of the level that would normally be shown base...
set_lod_scale
Sets the multiplier for lod distances.
A basic node of the scene graph or data graph.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
This is a sequence number that increments monotonically.