Commit Camera::set_lod_scale patch by Josh Enes

This commit is contained in:
rdb 2012-10-19 15:25:48 +00:00
parent 0d7773d30a
commit 19cb1e5230
4 changed files with 31 additions and 2 deletions

View File

@ -250,3 +250,24 @@ INLINE const string &Camera::
get_tag_state_key() const { get_tag_state_key() const {
return _tag_state_key; return _tag_state_key;
} }
////////////////////////////////////////////////////////////////////
// Function: Camera::get_lod_scale
// Access: Published
// Description: Returns the multiplier for LOD distances.
////////////////////////////////////////////////////////////////////
INLINE PN_stdfloat Camera::
get_lod_scale() const {
return _lod_scale;
}
////////////////////////////////////////////////////////////////////
// Function: Camera::set_lod_scale
// Access: Published
// Description: Sets the multiplier for LOD distances. This value
// is multiplied with the LOD scale set on LodNodes.
////////////////////////////////////////////////////////////////////
INLINE void Camera::
set_lod_scale(PN_stdfloat value) {
_lod_scale = value;
}

View File

@ -31,6 +31,7 @@ Camera(const string &name, Lens *lens) :
_camera_mask(~PandaNode::get_overall_bit()), _camera_mask(~PandaNode::get_overall_bit()),
_initial_state(RenderState::make_empty()) _initial_state(RenderState::make_empty())
{ {
set_lod_scale(1.0);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -45,6 +46,7 @@ Camera(const Camera &copy) :
_scene(copy._scene), _scene(copy._scene),
_camera_mask(copy._camera_mask), _camera_mask(copy._camera_mask),
_initial_state(copy._initial_state), _initial_state(copy._initial_state),
_lod_scale(copy._lod_scale),
_tag_state_key(copy._tag_state_key), _tag_state_key(copy._tag_state_key),
_tag_states(copy._tag_states) _tag_states(copy._tag_states)
{ {

View File

@ -75,6 +75,9 @@ PUBLISHED:
INLINE void set_tag_state_key(const string &tag_state_key); INLINE void set_tag_state_key(const string &tag_state_key);
INLINE const string &get_tag_state_key() const; INLINE const string &get_tag_state_key() const;
INLINE void set_lod_scale(PN_stdfloat value);
INLINE PN_stdfloat get_lod_scale() const;
void set_tag_state(const string &tag_state, const RenderState *state); void set_tag_state(const string &tag_state, const RenderState *state);
void clear_tag_state(const string &tag_state); void clear_tag_state(const string &tag_state);
bool has_tag_state(const string &tag_state) const; bool has_tag_state(const string &tag_state) const;
@ -97,6 +100,7 @@ private:
NodePath _lod_center; NodePath _lod_center;
DrawMask _camera_mask; DrawMask _camera_mask;
PN_stdfloat _lod_scale;
typedef pvector<DisplayRegionBase *> DisplayRegions; typedef pvector<DisplayRegionBase *> DisplayRegions;
DisplayRegions _display_regions; DisplayRegions _display_regions;

View File

@ -177,7 +177,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) {
if (cdata->_got_force_switch) { if (cdata->_got_force_switch) {
in_range = (cdata->_force_switch == index); in_range = (cdata->_force_switch == index);
} else { } else {
in_range = sw.in_range_2(dist2*cdata->_lod_scale); in_range = sw.in_range_2(dist2 * cdata->_lod_scale
* trav->get_scene()->get_camera_node()->get_lod_scale());
} }
if (in_range) { if (in_range) {
@ -376,7 +377,8 @@ compute_child(CullTraverser *trav, CullTraverserData &data) {
PN_stdfloat dist2 = center.dot(center); PN_stdfloat dist2 = center.dot(center);
for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) {
if (cdata->_switch_vector[index].in_range_2(dist2*cdata->_lod_scale)) { if (cdata->_switch_vector[index].in_range_2(dist2 * cdata->_lod_scale
* trav->get_scene()->get_camera_node()->get_lod_scale())) {
if (pgraph_cat.is_debug()) { if (pgraph_cat.is_debug()) {
pgraph_cat.debug() pgraph_cat.debug()
<< data._node_path << " at distance " << sqrt(dist2) << data._node_path << " at distance " << sqrt(dist2)