diff --git a/panda/src/gobj/LOD.cxx b/panda/src/gobj/LOD.cxx index 072ecbace1..e9813451ae 100644 --- a/panda/src/gobj/LOD.cxx +++ b/panda/src/gobj/LOD.cxx @@ -85,6 +85,9 @@ xform(const LMatrix4f &mat) { } } +//const int minimum_LOD_number = config_gobj.GetInt("minimum-LOD-number", 0); +//extern EXPCL_PANDA const int minimum_LOD_number; + //////////////////////////////////////////////////////////////////// // Function: LOD::compute_child // Access: Public @@ -94,6 +97,7 @@ xform(const LMatrix4f &mat) { //////////////////////////////////////////////////////////////////// int LOD:: compute_child(const LPoint3f &cam_pos, const LPoint3f ¢er) const { + LVector3f v = cam_pos - center; float dist = dot(v, v); LODSwitchVector::const_iterator i; @@ -103,6 +107,15 @@ compute_child(const LPoint3f &cam_pos, const LPoint3f ¢er) const { if ((*i).in_range(dist)) break; } + + // since lowest level LOD is lev 0, must invert the meaning of + // so minimum_LOD_number 0 will screen out no LODs, and increasing it + // will screen out successively higher levels + int max_allowed_LOD_number = (_switch_vector.size()-1) - minimum_LOD_number; + if(child > max_allowed_LOD_number) { + child = max_allowed_LOD_number; + } + return child; } diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index 4231611e69..9e64673ab0 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -93,6 +93,11 @@ BamTextureMode bam_texture_mode; // texture file, which will presumably only be loaded once. const string fake_texture_image = config_gobj.GetString("fake-texture-image", ""); +// this controls the LOD child number returned by compute_child +// use it to force the LOD alg to not select the highest level(s) of LOD +// minimum_LOD_number=0 will screen out no LODs, and increasing it +// will screen out successively higher levels +const int minimum_LOD_number = config_gobj.GetInt("minimum-LOD-number", 0); static BamTextureMode parse_texture_mode(const string &mode) { diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index 0f332d6559..1e5c679b35 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -40,6 +40,8 @@ enum BamTextureMode { extern EXPCL_PANDA BamTextureMode bam_texture_mode; extern EXPCL_PANDA const string fake_texture_image; +extern EXPCL_PANDA const int minimum_LOD_number; + #endif diff --git a/panda/src/gobj/gobj_composite1.cxx b/panda/src/gobj/gobj_composite1.cxx index 387a0eb530..d93ef6cd00 100644 --- a/panda/src/gobj/gobj_composite1.cxx +++ b/panda/src/gobj/gobj_composite1.cxx @@ -1,5 +1,4 @@ -#include "LOD.cxx" #include "geom.cxx" #include "geomLine.cxx" #include "geomLinestrip.cxx" @@ -11,4 +10,5 @@ #include "geomTri.cxx" #include "geomTrifan.cxx" #include "geomTristrip.cxx" +#include "fog.cxx" diff --git a/panda/src/gobj/gobj_composite2.cxx b/panda/src/gobj/gobj_composite2.cxx index 43d8ec91e5..3f6a70348d 100644 --- a/panda/src/gobj/gobj_composite2.cxx +++ b/panda/src/gobj/gobj_composite2.cxx @@ -1,7 +1,7 @@ #include "config_gobj.cxx" +#include "LOD.cxx" #include "drawable.cxx" -#include "fog.cxx" #include "imageBuffer.cxx" #include "material.cxx" #include "materialPool.cxx"