1
0
Fork 0

Removed all dependencies on <simgear/math/mat3.h> 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.
This commit is contained in:
curt 2000-02-19 14:29:27 +00:00
parent b23d8f9938
commit cc26bb7fe7
26 changed files with 122 additions and 71 deletions

View file

@ -36,17 +36,16 @@
# include <strings.h>
#endif
#include <plib/sg.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/misc/fgstream.hxx>
#include <Objects/materialmgr.hxx>
// #include <gpc/gpc.h>
#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]);

View file

@ -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
INCLUDES += -I$(top_builddir) -I$(top_builddir)/src

View file

@ -39,7 +39,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -45,7 +45,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -48,7 +48,6 @@
#include <deque> // STL double ended queue
#include <simgear/constants.h>
#include <simgear/math/mat3.h>
#include <fg_typedefs.h>
#include <Aircraft/aircraft.hxx>
@ -56,11 +55,15 @@
#include <Controls/controls.hxx>
#include <GUI/gui.h>
#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;

View file

@ -10,7 +10,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -13,7 +13,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

64
src/Cockpit/hud_opts.hxx Normal file
View file

@ -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 <config.h>
#endif
#include <simgear/compiler.h>
#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

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -11,7 +11,6 @@
#include <simgear/constants.h>
#include <simgear/math/fg_random.h>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -67,7 +67,6 @@
#include <simgear/constants.h> // for VERSION
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/fg_random.h>
#include <simgear/misc/fgpath.hxx>

View file

@ -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 <Math/mat3.h>
#include <Include/fg_constants.h>

View file

@ -47,7 +47,6 @@
#include <simgear/logstream.hxx>
#include <simgear/constants.h>
#include <simgear/fg_random.h>
#include <simgear/mat3.h>
#include <simgear/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -46,7 +46,6 @@
#include <simgear/logstream.hxx>
#include <simgear/constants.h>
#include <simgear/fg_random.h>
#include <simgear/mat3.h>
#include <simgear/polar3d.hxx>
#include <Aircraft/aircraft.hxx>

View file

@ -22,7 +22,6 @@
#include <simgear/constants.h>
#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <Scenery/tileentry.hxx>
@ -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;
}

View file

@ -46,7 +46,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/mat3.h>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/fg_random.h>
#include <simgear/math/point3d.hxx>
@ -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;

View file

@ -35,7 +35,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/vector.hxx>
@ -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));
}

View file

@ -52,7 +52,6 @@ FG_USING_STD(string);
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/interpolater.hxx>
#include <simgear/math/mat3.h>
#include <simgear/math/polar3d.hxx>
#include <simgear/misc/fgpath.hxx>

View file

@ -54,7 +54,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/vector.hxx>

View file

@ -53,7 +53,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_geodesy.hxx>
#include <simgear/math/mat3.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/vector.hxx>