Norman Vine wrote:
>
>>On Tue, 2002-04-16 at 08:49, Norman Vine wrote:
>>> These are available for the current FDM in the global Scenery
>>> instantiation  see Scenery / scenery.hxx

>--scenery.hxx
>inline double get_cur_radius() const { return cur_radius; }
>inline const double * get_cur_normal() { return cur_normal; }

Yikes  --
Looks like I broke the scenery.current_normal when I last
reworked the hitlist code.

I guess this is proof that no one has been using it.

A quick fix is

hitlist.cxx

int FGHitList::IntersectLeaf( ssgLeaf *leaf, const sgdMat4 m,
                              sgdVec3 orig, sgdVec3 dir )
{
.......
        if( fgdIsectLinesegPlane( point, orig, dir, plane ) ) {
            if( fgdPointInTriangle( point, tri ) ) {
                // transform point and plane into the passed frame
                sgdXformPnt3( point, point, m );
+               sgdXformPnt4(plane,plane,m);

                add(leaf,i,point,plane);
                num_hits++;
            }


int FGHitList::IntersectLeaf( ssgLeaf *leaf, const sgdMat4 m,
                              sgdVec3 orig, sgdVec3 dir,
                              const GLenum primType )
{
......
        if( fgdPointInTriangle( point, tri ) ) {
        // transform point and plane into the passed frame
        sgdXformPnt3( point, point, m );
+       sgdXformPnt4(plane,plane,m);

            add(leaf,n,point,plane);
            if( tmp_dist >= 0 )
                                test_dist = tmp_dist;
            num_hits++;
        }


then in both fgCurrentElev(...)
{
......

    if ( result > -9000 ) {
        *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;
        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;

You verify  that the code is working by removing the
commented out 'cout's above in fgCurrentElev()

or by adding something like this to cockpit / hud.cxx

sgVec3 up;
sgSetVec3(up,scenery.get_cur_normal()[0],
          scenery.get_cur_normal()[1],
          scenery.get_cur_normal()[2]);
sprintf(fpsbuf,"%7.4f",
        sgAngleBetweenVec3(up,globals->get_current_view()->get_world_up()) );
HUD_TextList.add( fgText( int(640 - guiFnt.getStringWidth(fpsbuf) - 10),
       468 - 10 - guiFnt.getStringHeight(fpsbuf),   fpsbuf) );


Cheers

Norman


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to