Changeset 1071 for GTP/trunk/Lib/Geom/shared/GTGeometry/src
- Timestamp:
- 06/30/06 17:40:29 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodManager.cpp
r1069 r1071 18 18 { 19 19 public: 20 lodobj_idpos_node_t(LodObject *o):lodobj(o) {}20 lodobj_idpos_node_t(LodObject *o):lodobj(o),must_recalculate_distance(true),dist2cam(0.0f){} 21 21 LodObject *lodobj; 22 float dist2cam; // used to index the lodobj in the other map 23 bool must_recalculate_distance; 22 24 bool operator < (const lodobj_idpos_node_t &o) const { return (lodobj->GetUniqueID()<o.lodobj->GetUniqueID()); } 23 25 }; … … 45 47 if (camera_changed) 46 48 { 47 // if the camera has changed, recalculate all lodobject distances to it 48 float random_dist = SelectRandomDistance(); 49 49 // if the camera has changed, recalculate all lodobject distances to it 50 lodobj_dists.clear(); 51 for (std::map<Geometry::lodobj_idpos_node_t,Geometry::Vector3>::iterator it = lodobj_pos.begin(); it != lodobj_pos.end(); it++) 52 { 53 const lodobj_idpos_node_t & posnode = it->first; 54 const Vector3 & pos = it->second; 55 float newdist = CalculateDistToCamera(pos); 56 lodobj_dists[newdist] = lodobj_dist_node_t(posnode.lodobj); 57 } 50 58 camera_changed=false; 51 59 } 60 else 61 { 62 // if any of the objects changed its position, the distance must be recalculated 63 for (std::map<Geometry::lodobj_idpos_node_t,Geometry::Vector3>::iterator it = lodobj_pos.begin(); it != lodobj_pos.end(); it++) 64 { 65 const lodobj_idpos_node_t & posnode = it->first; 66 if (posnode.must_recalculate_distance) 67 { 68 const Vector3 & pos = it->second; 69 float newdist = CalculateDistToCamera(pos); 70 lodobj_dists[newdist] = lodobj_dist_node_t(posnode.lodobj); 71 /* lodobj_dists.erase(it);*/ 72 } 73 } 74 } 75 76 // select a tree to change its LOD 77 float random_dist = SelectRandomDistance(); 78 std::map<float,Geometry::lodobj_dist_node_t>::iterator nearest = lodobj_dists.upper_bound(random_dist); 52 79 } 53 80
Note: See TracChangeset
for help on using the changeset viewer.