]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/hitlist.cxx
Added static port system and a new altimeter model connected to it.
[flightgear.git] / src / Scenery / hitlist.cxx
index 21ef767fd171b38349bc91de4366861981dcdcb4..856b175a2184cafee67cf1ad480b38a53cb6fb44 100644 (file)
 
 #include <Main/globals.hxx>
 #include <Main/viewer.hxx>
+#include <Scenery/scenery.hxx>
 
 #include "hitlist.hxx"
 
-extern ssgBranch *terrain_branch;
-
 // forward declaration of our helper/convenience functions
 static void sgMultMat4(sgdMat4 dst, sgdMat4 m1, sgMat4 m2);
 static void ssgGetEntityTransform(ssgEntity *entity, sgMat4 m );
@@ -214,6 +213,7 @@ int FGHitList::IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
             if( fgdPointInTriangle( point, tri ) ) {
                 // transform point into passed into desired coordinate frame
                 sgdXformPnt3( point, point, m );
+               sgdXformPnt4(plane,plane,m);
                 add(leaf,i,point,plane);
                 num_hits++;
             }
@@ -292,7 +292,7 @@ int FGHitList::IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
         sgdVec4 plane;
         sgdMakePlane( plane, tri[0], tri[1], tri[2] );
 
-        sgdVec3 point, test;
+        sgdVec3 point;
 
         // find point of intersection of line from point org
         // in direction dir with triangle's plane
@@ -317,6 +317,7 @@ int FGHitList::IntersectLeaf( ssgLeaf *leaf, sgdMat4 m,
         if( fgdPointInTriangle( point, tri ) ) {
             // transform point into passed coordinate frame
             sgdXformPnt3( point, point, m );
+           sgdXformPnt4(plane,plane,m);
             add(leaf,n,point,plane);
             test_dist = tmp_dist;
             num_hits++;
@@ -509,8 +510,8 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
     sgdCopyVec3(orig, view_pos );
     sgdCopyVec3(dir, abs_view_pos );
 
-    // !! why is terrain not globals->get_terrain()
-    hit_list->Intersect( terrain_branch, orig, dir );
+    hit_list->Intersect( globals->get_scenery()->get_terrain_branch(),
+                         orig, dir );
 
     int this_hit=0;
     Point3D geoc;
@@ -536,14 +537,11 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
         *terrain_elev = result;
         *radius = geoc.radius();
         sgVec3 tmp;
-        sgMat4 TMP;
         sgSetVec3(tmp, hit_list->get_normal(this_hit));
-        // cout << "cur_normal: " << tmp[0] << " " << tmp[1] << " "
-        //      << tmp[2] << endl;
-        sgTransposeNegateMat4 ( TMP, globals->get_current_view()->get_UP() ) ;
-        sgXformVec3(tmp, tmp, TMP);
-        // cout << "NED: " << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
-        sgdSetVec3( normal, tmp[2], tmp[1], tmp[0] );
+        // cout << "cur_normal: " << tmp[0] << " " << tmp[1] << " "  << tmp[2] << endl;
+        sgdSetVec3( normal, tmp );
+        // float *up = globals->get_current_view()->get_world_up();
+       // cout << "world_up  : " << up[0] << " " << up[1] << " " << up[2] << endl;
         /* ssgState *IntersectedLeafState =
               ((ssgLeaf*)hit_list->get_entity(this_hit))->getState(); */
         return true;
@@ -603,11 +601,11 @@ bool fgCurrentElev( sgdVec3 abs_view_pos, sgdVec3 scenery_center,
         *terrain_elev = result;
         *radius = geoc.radius();
         sgVec3 tmp;
-        sgMat4 TMP;
         sgSetVec3(tmp, hit_list->get_normal(this_hit));
-        sgTransposeNegateMat4 ( TMP, globals->get_current_view()->get_UP() ) ;
-        sgXformVec3(tmp, tmp, TMP);
-        sgdSetVec3( normal, tmp[2], tmp[1], tmp[0] );
+        // cout << "cur_normal: " << tmp[0] << " " << tmp[1] << " "  << tmp[2] << endl;
+        sgdSetVec3( normal, tmp );
+        // float *up = globals->get_current_view()->get_world_up();
+       // cout << "world_up  : " << up[0] << " " << up[1] << " " << up[2] << endl;
         /* ssgState *IntersectedLeafState =
               ((ssgLeaf*)hit_list->get_entity(this_hit))->getState(); */
         return true;