23 LODNode(
const string &name) :
59 cdata->_switch_vector.push_back(Switch(in, out));
60 cdata->check_limits();
62 if (cdata->_num_shown != 0) {
75 nassertr(in >= out,
false);
78 nassertr(index >= 0 && index < (
int)cdata->_switch_vector.size(),
false);
79 cdata->_switch_vector[index].set_range(in, out);
80 cdata->check_limits();
82 if (cdata->_num_shown != 0) {
99 cdata->_switch_vector.clear();
103 if (cdata->_num_shown != 0) {
119 return cdata->_switch_vector.size();
130 return cdata->_lod_scale;
142 cdata->_lod_scale = value;
156 nassertr(index >= 0 && index < (
int)cdata->_switch_vector.size(), 0.0);
157 return cdata->_switch_vector[index].get_in();
170 nassertr(index >= 0 && index < (
int)cdata->_switch_vector.size(), 0.0);
171 return cdata->_switch_vector[index].get_out();
185 return cdata->_lowest;
199 return cdata->_highest;
212 cdata->_force_switch = index;
213 cdata->_got_force_switch =
true;
226 cdata->_got_force_switch =
false;
239 cdata->_center = center;
241 if (cdata->_num_shown != 0) {
256 return cdata->_center;
269 return (cdata->_num_shown != 0);
280 INLINE
void LODNode::
284 do_auto_verify_lods(trav, data);
294 INLINE LODNode::CData::
296 _center(0.0f, 0.0f, 0.0f),
299 _got_force_switch(false),
311 INLINE LODNode::CData::
312 CData(
const LODNode::CData ©) :
313 _center(copy._center),
314 _switch_vector(copy._switch_vector),
315 _lowest(copy._lowest),
316 _highest(copy._highest),
318 _got_force_switch(copy._got_force_switch),
319 _force_switch(copy._force_switch),
320 _num_shown(copy._num_shown),
321 _lod_scale(copy._lod_scale)
330 INLINE LODNode::Switch::
331 Switch(PN_stdfloat in, PN_stdfloat out) :
344 INLINE PN_stdfloat LODNode::Switch::
354 INLINE PN_stdfloat LODNode::Switch::
364 INLINE
void LODNode::Switch::
365 set_range(PN_stdfloat in, PN_stdfloat out) {
377 INLINE
bool LODNode::Switch::
378 in_range(PN_stdfloat dist)
const {
379 return (dist >= _out && dist < _in);
390 INLINE
bool LODNode::Switch::
391 in_range_2(PN_stdfloat dist2)
const {
392 return (dist2 >= _out * _out && dist2 < _in * _in);
400 INLINE
void LODNode::Switch::
401 rescale(PN_stdfloat factor) {
412 INLINE
bool LODNode::Switch::
423 INLINE
void LODNode::Switch::
434 INLINE
void LODNode::Switch::
446 get_ring_viz()
const {
447 if (_ring_viz.is_null()) {
448 ((Switch *)
this)->compute_ring_viz();
461 get_spindle_viz()
const {
462 if (_spindle_viz.is_null()) {
463 ((Switch *)
this)->compute_spindle_viz();
477 get_viz_model_state()
const {
478 if (_viz_model_state.is_null()) {
479 ((Switch *)
this)->compute_viz_model_state();
482 return _viz_model_state;
492 INLINE
void LODNode::Switch::
493 write_datagram(
Datagram &destination)
const {
504 INLINE
void LODNode::Switch::
517 INLINE
void LODNode::Switch::
520 _spindle_viz.clear();
521 _viz_model_state.clear();
PN_stdfloat get_lod_scale() const
Returns the multiplier for lod distances.
const LPoint3 & get_center() const
Returns the center of the LOD.
A basic node of the scene graph or data graph.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
PN_stdfloat get_in(int index) const
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...
void set_lod_scale(PN_stdfloat value)
Sets the multiplier for lod distances.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
void clear_switches()
Removes the set of switching ranges for the LODNode, presumably in conjunction with removing all of i...
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void force_switch(int index)
Forces the LODNode to show the indicated level instead of the level that would normally be shown base...
int get_num_switches() const
Returns the number of switch ranges added to the LODNode.
PN_stdfloat get_out(int index) const
Returns the "out" distance of the indicated switch range.
void add_switch(PN_stdfloat in, PN_stdfloat out)
Adds a switch range to the LODNode.
void mark_internal_bounds_stale(Thread *current_thread=Thread::get_current_thread())
Should be called by a derived class to mark the internal bounding volume stale, so that compute_inter...
int get_lowest_switch() const
Returns the index number of the child with the lowest level of detail; that is, the one that is desig...
bool set_switch(int index, PN_stdfloat in, PN_stdfloat out)
Changes the switching range of a particular child of the LODNode.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
static UpdateSeq old()
Returns an UpdateSeq in the 'old' state.
This is the base class for all three-component vectors and points.
A class to retrieve the individual data elements previously stored in a Datagram. ...
This is a sequence number that increments monotonically.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void clear_force_switch()
Undoes the effect of a previous call to force_switch() and releases the LODNode to once again display...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
int get_highest_switch() const
Returns the index number of the child with the highest level of detail; that is, the one that is desi...
void set_center(const LPoint3 ¢er)
Specifies the center of the LOD.