1
0
Fork 0

cleaned up my fragment.num_faces hack :-) to use the STL (no need in

duplicating work.)
Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
removed some unneeded stuff from fgTileMgrCurElev()
This commit is contained in:
curt 1998-09-15 01:35:03 +00:00
parent f4f6397877
commit b4abef6ab8
5 changed files with 69 additions and 29 deletions

View file

@ -68,8 +68,7 @@ fgFRAGMENT::fgFRAGMENT ( const fgFRAGMENT & rhs ) :
material_ptr ( rhs.material_ptr ),
tile_ptr ( rhs.tile_ptr ),
display_list ( rhs.display_list ),
faces ( rhs.faces ),
num_faces ( rhs.num_faces )
faces ( rhs.faces )
{
}
@ -330,6 +329,12 @@ int fgFRAGMENT::intersect( const fgPoint3d *end0,
}
// $Log$
// Revision 1.4 1998/09/15 01:35:03 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
// Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
// removed some unneeded stuff from fgTileMgrCurElev()
//
// Revision 1.3 1998/09/08 21:40:42 curt
// Updates from Bernie Bright.
//

View file

@ -114,12 +114,13 @@ public:
container faces;
// number of faces in this fragment
int num_faces;
int num_faces() {
return faces.size();
}
// Add a face to the face list
void add_face(int n1, int n2, int n3) {
faces.push_back( fgFACE(n1,n2,n3) );
num_faces++;
}
// test if line intesects with this fragment. p0 and p1 are the
@ -133,7 +134,7 @@ public:
fgPoint3d *result) const;
// Constructors
fgFRAGMENT () : num_faces(0) { /*faces.reserve(512);*/}
fgFRAGMENT () { /*faces.reserve(512);*/}
fgFRAGMENT ( const fgFRAGMENT &image );
// Destructor
@ -149,7 +150,6 @@ public:
void init() {
faces.erase( faces.begin(), faces.end() );
num_faces = 0;
}
int deleteDisplayList() {
@ -176,6 +176,12 @@ operator == ( const fgFRAGMENT & lhs, const fgFRAGMENT & rhs ) {
// $Log$
// Revision 1.5 1998/09/15 01:35:04 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
// Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
// removed some unneeded stuff from fgTileMgrCurElev()
//
// Revision 1.4 1998/09/10 19:07:09 curt
// /Simulator/Objects/fragment.hxx
// Nested fgFACE inside fgFRAGMENT since its not used anywhere else.

View file

@ -34,6 +34,7 @@
#include <XGL/xgl.h>
#include <string.h>
#include <string>
#include "Include/fg_stl_config.h"
#include <Debug/fg_debug.h>
@ -231,6 +232,8 @@ fgMATERIAL_MGR::fgMATERIAL_MGR ( void ) {
void
fgMATERIAL::render_fragments()
{
// cout << "rendering " + texture_name + " = " << list_size << "\n";
if ( empty() )
return;
@ -252,17 +255,17 @@ fgMATERIAL::render_fragments()
for ( size_t i = 0; i < list_size; ++i )
{
fgFRAGMENT* frag_ptr = list[i];
current_view.tris_rendered += frag_ptr->num_faces;
current_view.tris_rendered += frag_ptr->num_faces();
if ( frag_ptr->tile_ptr != last_tile_ptr )
{
// new tile, new translate
last_tile_ptr = frag_ptr->tile_ptr;
xglLoadMatrixd( frag_ptr->tile_ptr->model_view );
}
// Woohoo!!! We finally get to draw something!
// printf(" display_list = %d\n", frag_ptr->display_list);
xglCallList( frag_ptr->display_list );
last_tile_ptr = frag_ptr->tile_ptr;
}
}
@ -348,6 +351,12 @@ fgMATERIAL_MGR::render_fragments()
// $Log$
// Revision 1.6 1998/09/15 01:35:05 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
// Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
// removed some unneeded stuff from fgTileMgrCurElev()
//
// Revision 1.5 1998/09/10 19:07:11 curt
// /Simulator/Objects/fragment.hxx
// Nested fgFACE inside fgFRAGMENT since its not used anywhere else.

View file

@ -101,6 +101,14 @@ fgPoint3d calc_tex_coords(double *node, fgPoint3d *ref) {
pp.lon = fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.lon, 25.0);
pp.lat = fmod(RAD_TO_DEG * FG_TEX_CONSTANT * pp.lat, 25.0);
if ( pp.lon < 0.0 ) {
pp.lon += 25.0;
}
if ( pp.lat < 0.0 ) {
pp.lat += 25.0;
}
return(pp);
}
@ -538,6 +546,12 @@ int fgObjLoad( const string& path, fgTILE *t) {
// $Log$
// Revision 1.4 1998/09/15 01:35:07 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
// Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
// removed some unneeded stuff from fgTileMgrCurElev()
//
// Revision 1.3 1998/09/03 21:27:03 curt
// Fixed a serious bug caused by not-quite-correct comment/white space eating
// which resulted in mismatched glBegin() glEnd() pairs, incorrect display lists,

View file

@ -416,7 +416,7 @@ double fgTileMgrCurElev( double lon, double lat, fgPoint3d *abs_view_pos ) {
list < fgFRAGMENT > :: iterator current;
list < fgFRAGMENT > :: iterator last;
double dist, min_dist, lat_geod, alt, sea_level_r;
double x, y, z;
// double x, y, z;
int index, tile_diameter, i;
c = &global_tile_cache;
@ -431,10 +431,10 @@ double fgTileMgrCurElev( double lon, double lat, fgPoint3d *abs_view_pos ) {
index = c->exists(&p);
t = c->get_tile(index);
scenery.next_center.x = t->center.x;
scenery.next_center.y = t->center.y;
scenery.next_center.z = t->center.z;
// scenery.next_center.x = t->center.x;
// scenery.next_center.y = t->center.y;
// scenery.next_center.z = t->center.z;
earth_center.x = 0.0;
earth_center.y = 0.0;
earth_center.z = 0.0;
@ -445,10 +445,10 @@ double fgTileMgrCurElev( double lon, double lat, fgPoint3d *abs_view_pos ) {
p.lon, p.lat, p.x, p.y, fgBucketGenIndex(&p) );
// calculate tile offset
x = (t->offset.x = t->center.x - scenery.center.x);
y = (t->offset.y = t->center.y - scenery.center.y);
z = (t->offset.z = t->center.z - scenery.center.z);
// x = (t->offset.x = t->center.x - scenery.center.x);
// y = (t->offset.y = t->center.y - scenery.center.y);
// z = (t->offset.z = t->center.z - scenery.center.z);
// calc current terrain elevation calculate distance from
// vertical tangent line at current position to center of
// tile.
@ -592,18 +592,6 @@ void fgTileMgrRender( void ) {
y = (t->offset.y = t->center.y - scenery.center.y);
z = (t->offset.z = t->center.z - scenery.center.z);
m = t->model_view;
for ( j = 0; j < 16; j++ ) {
m[j] = v->MODEL_VIEW[j];
}
// Calculate the model_view transformation matrix for this tile
// This is equivalent to doing a glTranslatef(x, y, z);
m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
#if defined( TEST_FOV_CLIP )
if( viewable(&(t->offset), t->bounding_radius) !=
viewable2(&(t->offset), t->bounding_radius) )
@ -617,6 +605,18 @@ void fgTileMgrRender( void ) {
if ( viewable(&(t->offset), t->bounding_radius) ) {
// at least a portion of this tile could be viewable
m = t->model_view;
for ( j = 0; j < 16; j++ ) {
m[j] = v->MODEL_VIEW[j];
}
// Calculate the model_view transformation matrix for this tile
// This is equivalent to doing a glTranslatef(x, y, z);
m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
// xglPushMatrix();
// xglTranslatef(t->offset.x, t->offset.y, t->offset.z);
@ -690,6 +690,12 @@ void fgTileMgrRender( void ) {
// $Log$
// Revision 1.37 1998/09/15 01:36:45 curt
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
// duplicating work.)
// Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
// removed some unneeded stuff from fgTileMgrCurElev()
//
// Revision 1.36 1998/09/14 12:45:26 curt
// minor tweaks.
//