From: curt Date: Sat, 19 Feb 2000 14:29:27 +0000 (+0000) Subject: Removed all dependencies on and friends. These are X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cc26bb7fe73be1fa23b5e1c3b88f71e0d361a4c2;p=flightgear.git Removed all dependencies on and friends. These are old routines from SRGP. Steve's plib/sg.h does a nice job of completely replacing this (and since plib is already around) and is a nice clean design so it just makes sense. --- diff --git a/src/Airports/genapt.cxx b/src/Airports/genapt.cxx index af70ddf0d..6ad0b2089 100644 --- a/src/Airports/genapt.cxx +++ b/src/Airports/genapt.cxx @@ -36,17 +36,16 @@ # include #endif +#include + #include #include -#include #include #include #include #include -// #include - #include "genapt.hxx" FG_USING_STD(string); @@ -90,8 +89,8 @@ gen_base( const Point3D& average, const container& perimeter, FGTileEntry *t) { GLint display_list; Point3D cart, cart_trans, tex; - MAT3vec normal; - double dist, max_dist, temp; + sgVec3 normal; + double dist, max_dist; int center_num, i; fgFRAGMENT fragment; @@ -119,10 +118,8 @@ gen_base( const Point3D& average, const container& perimeter, FGTileEntry *t) << average.x() << " " << average.y() << " " << average.z() ); fragment.center = average; - normal[0] = average.x(); - normal[1] = average.y(); - normal[2] = average.z(); - MAT3_NORMALIZE_VEC(normal, temp); + sgSetVec3( normal, average.x(), average.y(), average.z() ); + sgNormalizeVec3( normal ); display_list = xglGenLists(1); xglNewList(display_list, GL_COMPILE); @@ -138,7 +135,7 @@ gen_base( const Point3D& average, const container& perimeter, FGTileEntry *t) tex = calc_tex_coords( t->nodes[t->ncount-1], t->center ); xglTexCoord2f(tex.x(), tex.y()); - xglNormal3dv(normal); + xglNormal3fv(normal); xglVertex3d(t->nodes[t->ncount-1][0], t->nodes[t->ncount-1][1], t->nodes[t->ncount-1][2]); diff --git a/src/Cockpit/Makefile.am b/src/Cockpit/Makefile.am index 5aac8271f..9c1948027 100644 --- a/src/Cockpit/Makefile.am +++ b/src/Cockpit/Makefile.am @@ -2,11 +2,11 @@ noinst_LIBRARIES = libCockpit.a libCockpit_a_SOURCES = \ cockpit.cxx cockpit.hxx \ - hud.cxx hud.hxx \ + hud.cxx hud.hxx hud_opts.hxx \ hud_card.cxx hud_dnst.cxx hud_guag.cxx hud_inst.cxx \ hud_labl.cxx hud_ladr.cxx \ hud_lat.cxx hud_lon.cxx \ hud_scal.cxx hud_tbi.cxx \ panel.cxx panel.hxx -INCLUDES += -I$(top_builddir) -I$(top_builddir)/src \ No newline at end of file +INCLUDES += -I$(top_builddir) -I$(top_builddir)/src diff --git a/src/Cockpit/cockpit.cxx b/src/Cockpit/cockpit.cxx index 840f0f47b..f0ad116dd 100644 --- a/src/Cockpit/cockpit.cxx +++ b/src/Cockpit/cockpit.cxx @@ -39,7 +39,6 @@ #include #include #include -#include #include #include diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index b9a543e47..0d773c8c9 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -45,7 +45,6 @@ #include #include #include -#include #include #include diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx index b2fedeaee..f060bd69b 100644 --- a/src/Cockpit/hud.hxx +++ b/src/Cockpit/hud.hxx @@ -48,7 +48,6 @@ #include // STL double ended queue #include -#include #include #include @@ -56,11 +55,15 @@ #include #include +#include "hud_opts.hxx" + FG_USING_STD(deque); FG_USING_STD(vector); FG_USING_NAMESPACE(std); +// some of Norman's crazy optimizations. :-) + #ifndef WIN32 typedef struct { int x, y; diff --git a/src/Cockpit/hud_card.cxx b/src/Cockpit/hud_card.cxx index 1278f631c..f0761cdca 100644 --- a/src/Cockpit/hud_card.cxx +++ b/src/Cockpit/hud_card.cxx @@ -10,7 +10,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_dnst.cxx b/src/Cockpit/hud_dnst.cxx index 6bbc61bf6..0314be094 100644 --- a/src/Cockpit/hud_dnst.cxx +++ b/src/Cockpit/hud_dnst.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_guag.cxx b/src/Cockpit/hud_guag.cxx index fe8d8f61b..7bbf2f155 100644 --- a/src/Cockpit/hud_guag.cxx +++ b/src/Cockpit/hud_guag.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_inst.cxx b/src/Cockpit/hud_inst.cxx index fdd2934f5..25b0f0380 100644 --- a/src/Cockpit/hud_inst.cxx +++ b/src/Cockpit/hud_inst.cxx @@ -13,7 +13,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_labl.cxx b/src/Cockpit/hud_labl.cxx index 048394e0c..09d18b269 100644 --- a/src/Cockpit/hud_labl.cxx +++ b/src/Cockpit/hud_labl.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_ladr.cxx b/src/Cockpit/hud_ladr.cxx index 13fb5df3c..e3143cee6 100644 --- a/src/Cockpit/hud_ladr.cxx +++ b/src/Cockpit/hud_ladr.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_lat.cxx b/src/Cockpit/hud_lat.cxx index 39c6e1397..ea9e61f71 100644 --- a/src/Cockpit/hud_lat.cxx +++ b/src/Cockpit/hud_lat.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_lon.cxx b/src/Cockpit/hud_lon.cxx index d46cf01cc..8cdb8363e 100644 --- a/src/Cockpit/hud_lon.cxx +++ b/src/Cockpit/hud_lon.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_opts.hxx b/src/Cockpit/hud_opts.hxx new file mode 100644 index 000000000..fa12848c6 --- /dev/null +++ b/src/Cockpit/hud_opts.hxx @@ -0,0 +1,64 @@ +// hud_opts.hxx -- hud optimization tools +// +// Probably written by Norman Vine, started sometime in 1998 or 1999. +// +// Copyright (C) 1999 FlightGear Project +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +// $Id$ + + +#ifndef _HUD_OPTS_HXX +#define _HUD_OPTS_HXX + +#ifndef __cplusplus +# error This library requires C++ +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + + +#if defined(i386) +#define USE_X86_ASM +#endif + +#if defined(USE_X86_ASM) +static __inline__ int FloatToInt(float f) +{ + int r; + __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st"); + return r; +} +#elif defined(__MSC__) && defined(__WIN32__) +static __inline int FloatToInt(float f) +{ + int r; + _asm { + fld f + fistp r + } + return r; +} +#else +#define FloatToInt(F) ((int) ((F) < 0.0f ? (F)-0.5f : (F)+0.5f)) +#endif + + +#endif // _HUD_OPTS_H diff --git a/src/Cockpit/hud_scal.cxx b/src/Cockpit/hud_scal.cxx index 46d5ec951..6dcb1d30b 100644 --- a/src/Cockpit/hud_scal.cxx +++ b/src/Cockpit/hud_scal.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Cockpit/hud_tbi.cxx b/src/Cockpit/hud_tbi.cxx index 307cb59a4..bd8e0d9b7 100644 --- a/src/Cockpit/hud_tbi.cxx +++ b/src/Cockpit/hud_tbi.cxx @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/src/Main/main.cxx b/src/Main/main.cxx index ac570225d..2af1f3e9c 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -67,7 +67,6 @@ #include // for VERSION #include #include -#include #include #include #include diff --git a/src/Main/ttest.cxx b/src/Main/ttest.cxx index ff4ed676f..7dc778b30 100644 --- a/src/Main/ttest.cxx +++ b/src/Main/ttest.cxx @@ -1,3 +1,6 @@ +// This should be ported to plib/sg before you try to compile it. If +// you do the port please send it to me. :-) + #include #include diff --git a/src/NetworkOLK/net_hud.cxx b/src/NetworkOLK/net_hud.cxx index 33880216d..d5dfeef79 100644 --- a/src/NetworkOLK/net_hud.cxx +++ b/src/NetworkOLK/net_hud.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include diff --git a/src/NetworkOLK/network.cxx b/src/NetworkOLK/network.cxx index 64dec6c9d..6e9ca43e1 100644 --- a/src/NetworkOLK/network.cxx +++ b/src/NetworkOLK/network.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/src/Objects/fragment.cxx b/src/Objects/fragment.cxx index 0edbf5e02..48c41d7a5 100644 --- a/src/Objects/fragment.cxx +++ b/src/Objects/fragment.cxx @@ -22,7 +22,6 @@ #include -#include #include #include @@ -98,8 +97,9 @@ int fgFRAGMENT::intersect( const Point3D& end0, Point3D& result) const { FGTileEntry *t; - MAT3vec v1, v2, n, center; - double p1[3], p2[3], p3[3]; + sgVec3 v1, v2, n, center; + sgVec3 p1, p2, p3; + sgVec3 temp; double x, y, z; // temporary holding spot for result double a, b, c, d; double x0, y0, z0, x1, y1, z1, a1, b1, c1; @@ -120,22 +120,28 @@ int fgFRAGMENT::intersect( const Point3D& end0, // printf("."); // get face vertex coordinates - center[0] = t->center.x(); - center[1] = t->center.y(); - center[2] = t->center.z(); + sgSetVec3( center, t->center.x(), t->center.y(), t->center.z() ); - MAT3_ADD_VEC(p1, t->nodes[(*current).n1], center); - MAT3_ADD_VEC(p2, t->nodes[(*current).n2], center); - MAT3_ADD_VEC(p3, t->nodes[(*current).n3], center); + sgSetVec3( temp, t->nodes[(*current).n1].x(), + t->nodes[(*current).n1].y(), t->nodes[(*current).n1].z() ); + sgAddVec3( p1, temp, center ); + + sgSetVec3( temp, t->nodes[(*current).n2].x(), + t->nodes[(*current).n2].y(), t->nodes[(*current).n2].z() ); + sgAddVec3( p2, temp, center ); + + sgSetVec3( temp, t->nodes[(*current).n3].x(), + t->nodes[(*current).n3].y(), t->nodes[(*current).n3].z() ); + sgAddVec3( p3, temp, center ); // printf("point 1 = %.2f %.2f %.2f\n", p1[0], p1[1], p1[2]); // printf("point 2 = %.2f %.2f %.2f\n", p2[0], p2[1], p2[2]); // printf("point 3 = %.2f %.2f %.2f\n", p3[0], p3[1], p3[2]); // calculate two edge vectors, and the face normal - MAT3_SUB_VEC(v1, p2, p1); - MAT3_SUB_VEC(v2, p3, p1); - MAT3cross_product(n, v1, v2); + sgSubVec3( v1, p2, p1 ); + sgSubVec3( v2, p3, p1 ); + sgVectorProductVec3( n, v1, v2 ); // calculate the plane coefficients for the plane defined by // this face. If n is the normal vector, n = (a, b, c) and p1 @@ -282,7 +288,7 @@ int fgFRAGMENT::intersect( const Point3D& end0, // all dimensions are really small so lets call it close // enough and return a successful match result = Point3D(x, y, z); - return(1); + return 1; } // check if intersection point is on the same side of p1 <-> p2 as p3 @@ -314,11 +320,11 @@ int fgFRAGMENT::intersect( const Point3D& end0, // printf( "intersection point = %.2f %.2f %.2f\n", x, y, z); result = Point3D(x, y, z); - return(1); + return 1; } // printf("\n"); - return(0); + return 0; } diff --git a/src/Objects/obj.cxx b/src/Objects/obj.cxx index 56a590b51..4bd5b21a9 100644 --- a/src/Objects/obj.cxx +++ b/src/Objects/obj.cxx @@ -46,7 +46,6 @@ #include #include -#include #include #include #include @@ -76,16 +75,15 @@ static double tex_coords[FG_MAX_NODES*3][3]; // given three points defining a triangle, calculate the normal static void calc_normal(Point3D p1, Point3D p2, - Point3D p3, double normal[3]) + Point3D p3, sgVec3 normal) { - double v1[3], v2[3]; - double temp; + sgVec3 v1, v2; v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; v1[2] = p2[2] - p1[2]; v2[0] = p3[0] - p1[0]; v2[1] = p3[1] - p1[1]; v2[2] = p3[2] - p1[2]; - MAT3cross_product(normal, v1, v2); - MAT3_NORMALIZE_VEC(normal,temp); + sgVectorProductVec3( normal, v1, v2 ); + sgNormalizeVec3( normal ); // fgPrintf( FG_TERRAIN, FG_DEBUG, " Normal = %.2f %.2f %.2f\n", // normal[0], normal[1], normal[2]); @@ -152,7 +150,7 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) { // material FGMaterial m = fragment.material_ptr->get_m(); double tex_width = m.get_xsize(); - double tex_height = m.get_ysize(); + // double tex_height = m.get_ysize(); // set ssgState state = fragment.material_ptr->get_state(); @@ -273,7 +271,8 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) { ssgBranch *fgObjLoad( const string& path, FGTileEntry *t, const bool is_base) { fgFRAGMENT fragment; Point3D pp; - double approx_normal[3] /*, normal[3], scale = 0.0 */; + sgVec3 approx_normal; + // double normal[3], scale = 0.0; // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin; // GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 }; // GLint display_list = 0; diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index f151c7d0f..6c1c0d63b 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -152,14 +151,14 @@ void FGTileMgr::load_tile( const FGBucket& b, int cache_index) { // Calculate shortest distance from point to line static double point_line_dist_squared( const Point3D& tc, const Point3D& vp, - MAT3vec d ) + sgVec3 d ) { - MAT3vec p, p0; + sgVec3 p, p0; - p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z(); - p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z(); + sgSetVec3( p, tc.x(), tc.y(), tc.z() ); + sgSetVec3( p0, vp.x(), vp.y(), vp.z() ); - return fgPointLineSquared(p, p0, d); + return sgPointLineDistSquared(p, p0, d); } @@ -174,13 +173,11 @@ FGTileMgr::current_elev_new( const FGBucket& p ) { Point3D abs_view_pos = current_view.get_abs_view_pos(); Point3D earth_center(0.0); Point3D result; - MAT3vec local_up; + sgVec3 local_up; double dist, lat_geod, alt, sea_level_r; int index; - local_up[0] = abs_view_pos.x(); - local_up[1] = abs_view_pos.y(); - local_up[2] = abs_view_pos.z(); + sgSetVec3( local_up, abs_view_pos.x(), abs_view_pos.y(), abs_view_pos.z() ); // Find current translation offset // fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p); @@ -272,7 +269,7 @@ FGTileMgr::current_elev( double lon, double lat, const Point3D& abs_view_pos ) { fgFRAGMENT *frag_ptr; Point3D earth_center(0.0); Point3D result; - MAT3vec local_up; + sgVec3 local_up; double dist, lat_geod, alt, sea_level_r; int index; @@ -985,9 +982,9 @@ int FGTileMgr::update( void ) { static int inrange( const double radius, const Point3D& center, const Point3D& vp, - const MAT3vec up) + const sgVec3 up) { - MAT3vec u, u1, v; + sgVec3 u, u1, v; // double tmp; // u = p - p0 @@ -998,14 +995,14 @@ inrange( const double radius, const Point3D& center, const Point3D& vp, // calculate the projection, u1, of u along d. // u1 = ( dot_prod(u, d) / dot_prod(d, d) ) * d; - MAT3_SCALE_VEC(u1, up, - (MAT3_DOT_PRODUCT(u, up) / MAT3_DOT_PRODUCT(up, up)) ); + sgScaleVec3( u1, up, + (sgScalarProductVec3(u, up) / sgScalarProductVec3(up, up)) ); // v = u - u1 = vector from closest point on line, p1, to the // original point, p. - MAT3_SUB_VEC(v, u, u1); + sgSubVec3( v, u, u1 ); - return( FG_SQUARE(radius) >= MAT3_DOT_PRODUCT(v, v)); + return( FG_SQUARE(radius) >= sgScalarProductVec3(v, v)); } diff --git a/src/Time/light.cxx b/src/Time/light.cxx index 875eb4347..d8a23e1ea 100644 --- a/src/Time/light.cxx +++ b/src/Time/light.cxx @@ -52,7 +52,6 @@ FG_USING_STD(string); #include #include #include -#include #include #include diff --git a/src/Time/moonpos.cxx b/src/Time/moonpos.cxx index 5d1648e67..2c64927c9 100644 --- a/src/Time/moonpos.cxx +++ b/src/Time/moonpos.cxx @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Time/sunpos.cxx b/src/Time/sunpos.cxx index 3ae598ca2..07d943ca8 100644 --- a/src/Time/sunpos.cxx +++ b/src/Time/sunpos.cxx @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include