diff --git a/panda/src/pgraphnodes/lodNode.I b/panda/src/pgraphnodes/lodNode.I index a56a0c9c72..579808ae22 100644 --- a/panda/src/pgraphnodes/lodNode.I +++ b/panda/src/pgraphnodes/lodNode.I @@ -119,6 +119,30 @@ get_num_switches() const { return cdata->_switch_vector.size(); } +//////////////////////////////////////////////////////////////////// +// Function: LODNode::get_lod_scale +// Access: Published +// Description: Returns the multiplier for lod distances +//////////////////////////////////////////////////////////////////// +INLINE float LODNode:: +get_lod_scale() const { + CDReader cdata(_cycler); + return cdata->_lod_scale; +} + +//////////////////////////////////////////////////////////////////// +// Function: LODNode::set_lod_scale +// Access: Published +// Description: Sets the multiplier for lod distances. A higher +// value means you'll see farther switchs than normal +//////////////////////////////////////////////////////////////////// +INLINE void LODNode:: +set_lod_scale(float value) { + CDWriter cdata(_cycler); + cdata->_lod_scale = value; +} + + //////////////////////////////////////////////////////////////////// // Function: LODNode::get_in // Access: Published @@ -274,7 +298,8 @@ CData() : _highest(0), _got_force_switch(false), _force_switch(0), - _num_shown(0) + _num_shown(0), + _lod_scale(1) { } @@ -292,7 +317,8 @@ CData(const LODNode::CData ©) : _bounds_seq(UpdateSeq::old()), _got_force_switch(copy._got_force_switch), _force_switch(copy._force_switch), - _num_shown(copy._num_shown) + _num_shown(copy._num_shown), + _lod_scale(copy._lod_scale) { } diff --git a/panda/src/pgraphnodes/lodNode.cxx b/panda/src/pgraphnodes/lodNode.cxx index 2d93155286..9162d648e2 100644 --- a/panda/src/pgraphnodes/lodNode.cxx +++ b/panda/src/pgraphnodes/lodNode.cxx @@ -176,7 +176,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (cdata->_got_force_switch) { in_range = (cdata->_force_switch == index); } else { - in_range = sw.in_range_2(dist2); + in_range = sw.in_range_2(dist2*cdata->_lod_scale); } if (in_range) { diff --git a/panda/src/pgraphnodes/lodNode.h b/panda/src/pgraphnodes/lodNode.h index 3516be4f78..044830dc5c 100644 --- a/panda/src/pgraphnodes/lodNode.h +++ b/panda/src/pgraphnodes/lodNode.h @@ -69,6 +69,12 @@ PUBLISHED: INLINE void force_switch(int index); INLINE void clear_force_switch(); + //for performance tuning, increasing this value should improve performance + //at the cost of model quality + INLINE void set_lod_scale(float value); + INLINE float get_lod_scale() const; + + INLINE void set_center(const LPoint3f ¢er); INLINE const LPoint3f &get_center() const; @@ -173,6 +179,7 @@ private: bool _got_force_switch; int _force_switch; int _num_shown; + float _lod_scale; }; PipelineCycler _cycler;