From: curt Date: Fri, 24 Jul 1998 21:42:06 +0000 (+0000) Subject: material.cxx: whups, double method declaration with no definition. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a7cf4f0a53c59de237c0c6cd5ca519c7d2fb769c;p=flightgear.git material.cxx: whups, double method declaration with no definition. obj.cxx: tweaks to avoid errors in SGI's CC. tile.cxx: optimizations by Norman Vine. tilemgr.cxx: optimizations by Norman Vine. --- diff --git a/Scenery/material.cxx b/Scenery/material.cxx index f52bff036..c8d8d917d 100644 --- a/Scenery/material.cxx +++ b/Scenery/material.cxx @@ -52,10 +52,13 @@ fgMATERIAL::fgMATERIAL ( void ) { // Sorting routines -void fgMATERIAL::init_sort_list( void ); +void fgMATERIAL::init_sort_list( void ) { +} -int fgMATERIAL::append_sort_list( fgFRAGMENT *object ); +int fgMATERIAL::append_sort_list( fgFRAGMENT *object ) { + return(0); +} // Destructor @@ -294,6 +297,12 @@ fgMATERIAL_MGR::~fgMATERIAL_MGR ( void ) { // $Log$ +// Revision 1.10 1998/07/24 21:42:06 curt +// material.cxx: whups, double method declaration with no definition. +// obj.cxx: tweaks to avoid errors in SGI's CC. +// tile.cxx: optimizations by Norman Vine. +// tilemgr.cxx: optimizations by Norman Vine. +// // Revision 1.9 1998/07/13 21:01:57 curt // Wrote access functions for current fgOPTIONS. // diff --git a/Scenery/material.hxx b/Scenery/material.hxx index a4254dce6..7efcc391f 100644 --- a/Scenery/material.hxx +++ b/Scenery/material.hxx @@ -41,13 +41,14 @@ #include #include -#ifdef __sun__ +#if defined ( __sun__ ) extern "C" void *memmove(void *, const void *, size_t); extern "C" void *memset(void *, int, size_t); #endif -#include // Standard C++ string library -#include // STL associative "array" +#include // Standard C++ string library +#include // STL associative "array" + #ifdef NEEDNAMESPACESTD using namespace std; #endif @@ -119,6 +120,12 @@ extern fgMATERIAL_MGR material_mgr; // $Log$ +// Revision 1.10 1998/07/24 21:42:06 curt +// material.cxx: whups, double method declaration with no definition. +// obj.cxx: tweaks to avoid errors in SGI's CC. +// tile.cxx: optimizations by Norman Vine. +// tilemgr.cxx: optimizations by Norman Vine. +// // Revision 1.9 1998/07/06 21:34:33 curt // Added using namespace std for compilers that support this. // diff --git a/Scenery/obj.cxx b/Scenery/obj.cxx index dc544b33f..43664a291 100644 --- a/Scenery/obj.cxx +++ b/Scenery/obj.cxx @@ -35,13 +35,14 @@ #include #include -#ifdef __sun__ +#if defined ( __sun__ ) extern "C" void *memmove(void *, const void *, size_t); extern "C" void *memset(void *, int, size_t); #endif -#include // Standard C++ library -#include // STL +#include // Standard C++ library +#include // STL + #ifdef NEEDNAMESPACESTD using namespace std; #endif @@ -216,7 +217,7 @@ int fgObjLoad(char *path, fgTILE *t) { sscanf(line, "usemtl %s\n", material); // give the fragment a pointer back to the tile - (fgTILE *)fragment.tile_ptr = t; + (fgTILE *)(fragment.tile_ptr) = t; // find this material in the properties list map < string, fgMATERIAL, less > :: iterator myfind = @@ -226,7 +227,7 @@ int fgObjLoad(char *path, fgTILE *t) { "Ack! unknown usemtl name = %s in %s\n", material, path); } else { - (fgMATERIAL *)fragment.material_ptr = &(*myfind).second; + fragment.material_ptr = (void *)(&(*myfind).second); } // initialize the fragment transformation matrix @@ -466,6 +467,12 @@ int fgObjLoad(char *path, fgTILE *t) { // $Log$ +// Revision 1.20 1998/07/24 21:42:07 curt +// material.cxx: whups, double method declaration with no definition. +// obj.cxx: tweaks to avoid errors in SGI's CC. +// tile.cxx: optimizations by Norman Vine. +// tilemgr.cxx: optimizations by Norman Vine. +// // Revision 1.19 1998/07/13 21:01:58 curt // Wrote access functions for current fgOPTIONS. // diff --git a/Scenery/tile.cxx b/Scenery/tile.cxx index a0a6078cf..d6903134e 100644 --- a/Scenery/tile.cxx +++ b/Scenery/tile.cxx @@ -256,16 +256,24 @@ int fgFRAGMENT::intersect( fgPoint3d *end0, fgPoint3d *end1, int side_flag, // check to see if end0 and end1 are on opposite sides of // plane if ( (x - x0) > FG_EPSILON ) { - t1 = x; t2 = x0; t3 = x1; + t1 = x; + t2 = x0; + t3 = x1; } else if ( (y - y0) > FG_EPSILON ) { - t1 = y; t2 = y0; t3 = y1; + t1 = y; + t2 = y0; + t3 = y1; } else if ( (z - z0) > FG_EPSILON ) { - t1 = z; t2 = z0; t3 = z1; + t1 = z; + t2 = z0; + t3 = z1; } else { // everything is too close together to tell the difference // so the current intersection point should work as good // as any - result->x = x; result->y = y; result->z = z; + result->x = x; + result->y = y; + result->z = z; return(1); } side1 = FG_SIGN (t1 - t2); @@ -287,17 +295,17 @@ int fgFRAGMENT::intersect( fgPoint3d *end0, fgPoint3d *end1, int side_flag, // printf("bounding cube = %.2f,%.2f,%.2f %.2f,%.2f,%.2f\n", // xmin, ymin, zmin, xmax, ymax, zmax); // punt if outside bouding cube - if ( x < xmin ) { + if ( x < (xmin = fg_min3 (p1[0], p2[0], p3[0])) ) { continue; - } else if ( x > xmax ) { + } else if ( x > (xmax = fg_max3 (p1[0], p2[0], p3[0])) ) { continue; - } else if ( y < ymin ) { + } else if ( y < (ymin = fg_min3 (p1[1], p2[1], p3[1])) ) { continue; - } else if ( y > ymax ) { + } else if ( y > (ymax = fg_max3 (p1[1], p2[1], p3[1])) ) { continue; - } else if ( z < zmin ) { + } else if ( z < (zmin = fg_min3 (p1[2], p2[2], p3[2])) ) { continue; - } else if ( z > zmax ) { + } else if ( z > (zmax = fg_max3 (p1[2], p2[2], p3[2])) ) { continue; } @@ -312,55 +320,74 @@ int fgFRAGMENT::intersect( fgPoint3d *end0, fgPoint3d *end1, int side_flag, min_dim = fg_min3 (dx, dy, dz); if ( fabs(min_dim - dx) <= FG_EPSILON ) { // x is the smallest dimension - x1 = p1[1]; y1 = p1[2]; - x2 = p2[1]; y2 = p2[2]; - x3 = p3[1]; y3 = p3[2]; - rx = y; ry = z; + x1 = p1[1]; + y1 = p1[2]; + x2 = p2[1]; + y2 = p2[2]; + x3 = p3[1]; + y3 = p3[2]; + rx = y; + ry = z; } else if ( fabs(min_dim - dy) <= FG_EPSILON ) { // y is the smallest dimension - x1 = p1[0]; y1 = p1[2]; - x2 = p2[0]; y2 = p2[2]; - x3 = p3[0]; y3 = p3[2]; - rx = x; ry = z; + x1 = p1[0]; + y1 = p1[2]; + x2 = p2[0]; + y2 = p2[2]; + x3 = p3[0]; + y3 = p3[2]; + rx = x; + ry = z; } else if ( fabs(min_dim - dz) <= FG_EPSILON ) { // z is the smallest dimension - x1 = p1[0]; y1 = p1[1]; - x2 = p2[0]; y2 = p2[1]; - x3 = p3[0]; y3 = p3[1]; - rx = x; ry = y; + x1 = p1[0]; + y1 = p1[1]; + x2 = p2[0]; + y2 = p2[1]; + x3 = p3[0]; + y3 = p3[1]; + rx = x; + ry = y; } else { // all dimensions are really small so lets call it close // enough and return a successful match - result->x = x; result->y = y; result->z = z; + result->x = x; + result->y = y; + result->z = z; return(1); } // check if intersection point is on the same side of p1 <-> p2 as p3 - side1 = FG_SIGN ((y1 - y2) * ((x3) - x2) / (x1 - x2) + y2 - (y3)); - side2 = FG_SIGN ((y1 - y2) * ((rx) - x2) / (x1 - x2) + y2 - (ry)); + t1 = (y1 - y2) / (x1 - x2); + side1 = FG_SIGN (t1 * ((x3) - x2) + y2 - (y3)); + side2 = FG_SIGN (t1 * ((rx) - x2) + y2 - (ry)); if ( side1 != side2 ) { // printf("failed side 1 check\n"); continue; } // check if intersection point is on correct side of p2 <-> p3 as p1 - side1 = FG_SIGN ((y2 - y3) * ((x1) - x3) / (x2 - x3) + y3 - (y1)); - side2 = FG_SIGN ((y2 - y3) * ((rx) - x3) / (x2 - x3) + y3 - (ry)); + t1 = (y2 - y3) / (x2 - x3); + side1 = FG_SIGN (t1 * ((x1) - x3) + y3 - (y1)); + side2 = FG_SIGN (t1 * ((rx) - x3) + y3 - (ry)); if ( side1 != side2 ) { // printf("failed side 2 check\n"); continue; } // check if intersection point is on correct side of p1 <-> p3 as p2 - side1 = FG_SIGN ((y1 - y3) * ((x2) - x3) / (x1 - x3) + y3 - (y2)); - side2 = FG_SIGN ((y1 - y3) * ((rx) - x3) / (x1 - x3) + y3 - (ry)); + t1 = (y1 - y3) / (x1 - x3); + side1 = FG_SIGN (t1 * ((x2) - x3) + y3 - (y2)); + side2 = FG_SIGN (t1 * ((rx) - x3) + y3 - (ry)); if ( side1 != side2 ) { // printf("failed side 3 check\n"); continue; } // printf( "intersection point = %.2f %.2f %.2f\n", x, y, z); - result->x = x; result->y = y; result->z = z; + result->x = x; + result->y = y; + result->z = z; return(1); } @@ -419,6 +446,12 @@ fgTILE::~fgTILE ( void ) { // $Log$ +// Revision 1.5 1998/07/24 21:42:08 curt +// material.cxx: whups, double method declaration with no definition. +// obj.cxx: tweaks to avoid errors in SGI's CC. +// tile.cxx: optimizations by Norman Vine. +// tilemgr.cxx: optimizations by Norman Vine. +// // Revision 1.4 1998/07/22 21:41:42 curt // Add basic fgFACE methods contributed by Charlie Hotchkiss. // intersect optimization from Norman Vine. diff --git a/Scenery/tile.hxx b/Scenery/tile.hxx index 2143a7750..c676741e6 100644 --- a/Scenery/tile.hxx +++ b/Scenery/tile.hxx @@ -41,7 +41,7 @@ #include #include -#ifdef __sun__ +#if defined ( __sun__ ) extern "C" void *memmove(void *, const void *, size_t); extern "C" void *memset(void *, int, size_t); #endif @@ -163,6 +163,12 @@ public: // $Log$ +// Revision 1.13 1998/07/24 21:42:08 curt +// material.cxx: whups, double method declaration with no definition. +// obj.cxx: tweaks to avoid errors in SGI's CC. +// tile.cxx: optimizations by Norman Vine. +// tilemgr.cxx: optimizations by Norman Vine. +// // Revision 1.12 1998/07/22 21:41:42 curt // Add basic fgFACE methods contributed by Charlie Hotchkiss. // intersect optimization from Norman Vine. diff --git a/Scenery/tilemgr.cxx b/Scenery/tilemgr.cxx index bbf176769..118d75fef 100644 --- a/Scenery/tilemgr.cxx +++ b/Scenery/tilemgr.cxx @@ -55,6 +55,8 @@ #define FG_LOCAL_X_Y 81 // max(o->tile_diameter) ** 2 +#define FG_SQUARE(X) ((X) * (X)) + // closest (potentially viewable) tiles, centered on current tile. // This is an array of pointers to cache indexes. @@ -216,14 +218,16 @@ int fgTileMgrUpdate( void ) { // Calculate shortest distance from point to line -static double point_line_dist( fgPoint3d *tc, fgPoint3d *vp, MAT3vec d) { +static double point_line_dist_squared( fgPoint3d *tc, fgPoint3d *vp, + MAT3vec d ) +{ MAT3vec p, p0; double dist; p[0] = tc->x; p[1] = tc->y; p[2] = tc->z; p0[0] = vp->x; p0[1] = vp->y; p0[2] = vp->z; - dist = fgPointLine(p, p0, d); + dist = fgPointLineSquared(p, p0, d); // printf("dist = %.2f\n", dist); @@ -397,12 +401,13 @@ void fgTileMgrRender( void ) { // calculate distance from vertical tangent line at // current position to center of tile. - /* printf("distance = %.2f, bounding radius = %.2f\n", - point_line_dist(&(t->offset), &(v->view_pos), v->local_up), - t->bounding_radius); */ + /* printf("distance squared = %.2f, bounding radius = %.2f\n", + point_line_dist_squared(&(t->offset), &(v->view_pos), + v->local_up), t->bounding_radius); */ - dist = point_line_dist(&(t->center), &(v->abs_view_pos), v->local_up); - if ( dist < t->bounding_radius ) { + dist = point_line_dist_squared( &(t->center), &(v->abs_view_pos), + v->local_up ); + if ( dist < FG_SQUARE(t->bounding_radius) ) { // traverse fragment list for tile current = t->fragment_list.begin(); @@ -411,14 +416,14 @@ void fgTileMgrRender( void ) { while ( current != last ) { frag_ptr = &(*current); current++; - /* printf("distance = %.2f, bounding radius = %.2f\n", - point_line_dist( &(frag_ptr->center), + /* printf("distance squared = %.2f, bounding radius = %.2f\n", + point_line_dist_squared( &(frag_ptr->center), &(v->abs_view_pos), v->local_up), frag_ptr->bounding_radius); */ - dist = point_line_dist( &(frag_ptr->center), + dist = point_line_dist_squared( &(frag_ptr->center), &(v->abs_view_pos), v->local_up); - if ( dist <= frag_ptr->bounding_radius ) { + if ( dist <= FG_SQUARE(frag_ptr->bounding_radius) ) { if ( frag_ptr->intersect( &(v->abs_view_pos), &earth_center, 0, &result ) ) { // compute geocentric coordinates of tile center @@ -559,6 +564,12 @@ void fgTileMgrRender( void ) { // $Log$ +// Revision 1.27 1998/07/24 21:42:09 curt +// material.cxx: whups, double method declaration with no definition. +// obj.cxx: tweaks to avoid errors in SGI's CC. +// tile.cxx: optimizations by Norman Vine. +// tilemgr.cxx: optimizations by Norman Vine. +// // Revision 1.26 1998/07/20 12:51:26 curt // Added far clip plane to fragment clipping calculations and tie this to // weather->visibility. This way you can increase framerates by increasing