18 LODNode(
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();
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();
97 get_num_switches()
const {
98 CDReader cdata(_cycler);
99 return cdata->_switch_vector.size();
105 INLINE PN_stdfloat LODNode::
106 get_lod_scale()
const {
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();
150 get_lowest_switch()
const {
151 CDReader cdata(_cycler);
152 return cdata->_lowest;
161 get_highest_switch()
const {
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();
207 INLINE
const LPoint3 &LODNode::
209 CDReader cdata(_cycler);
210 return cdata->_center;
220 return (cdata->_num_shown != 0);
228 INLINE
void LODNode::
232 do_auto_verify_lods(trav, data);
240 INLINE LODNode::CData::
242 _center(0.0f, 0.0f, 0.0f),
245 _got_force_switch(false),
255 INLINE LODNode::CData::
256 CData(
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)
272 INLINE LODNode::Switch::
273 Switch(PN_stdfloat in, PN_stdfloat out) :
284 INLINE PN_stdfloat LODNode::Switch::
292 INLINE PN_stdfloat LODNode::Switch::
300 INLINE
void LODNode::Switch::
301 set_range(PN_stdfloat in, PN_stdfloat out) {
310 INLINE
bool LODNode::Switch::
311 in_range(PN_stdfloat dist)
const {
312 return (dist >= _out && dist < _in);
320 INLINE
bool LODNode::Switch::
321 in_range_2(PN_stdfloat dist2)
const {
322 return (dist2 >= _out * _out && dist2 < _in * _in);
328 INLINE
void LODNode::Switch::
329 rescale(PN_stdfloat factor) {
338 INLINE
bool LODNode::Switch::
346 INLINE
void LODNode::Switch::
347 show(
const LColor &color) {
355 INLINE
void LODNode::Switch::
365 get_ring_viz()
const {
366 if (_ring_viz.is_null()) {
367 ((Switch *)
this)->compute_ring_viz();
378 get_spindle_viz()
const {
379 if (_spindle_viz.is_null()) {
380 ((Switch *)
this)->compute_spindle_viz();
391 get_viz_model_state()
const {
392 if (_viz_model_state.is_null()) {
393 ((Switch *)
this)->compute_viz_model_state();
396 return _viz_model_state;
403 INLINE
void LODNode::Switch::
404 write_datagram(
Datagram &destination)
const {
413 INLINE
void LODNode::Switch::
423 INLINE
void LODNode::Switch::
426 _spindle_viz.clear();
427 _viz_model_state.clear();
428 _bounds_seq = UpdateSeq::old();
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...
This collects together the pieces of data that are accumulated for each node while walking the scene ...
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...
void add_switch(PN_stdfloat in, PN_stdfloat out)
Adds a switch range to the LODNode.
set_lod_scale
Sets the multiplier for lod distances.
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...
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...
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,...
set_center
Specifies the center of the LOD.
get_out
Returns the "out" distance of the indicated switch range.