[info-performer] RayCast bug in Performer 2.2 and 3.1.1 on IRIX

Date view Thread view Subject view Author view

From: Damien Gerhardy (damien.gerhardy++at++sydac.com.au)
Date: 04/21/2005 22:04:26


I've run in to a problem with some ray casting code on
Irix that works fine on Windows.

After pfNode->isect returns a hit I call ->query(PFQHIT_POINT, pnt.vec)
on the hit and get pnt.vec set to (nan, nan, nan).

Many other points *near* the point I am testing seem to work but the
same points seem to fail the raycast each time.

Here is the code I am using below. If anyone knows of a workaround, or
how to fix this it would be of great help.

*Just to reiterate, this code works fine on several projects on the Windows
platform but does not work on Irix (tested with performer 2.2 and 3.1.1).

    int PerformerEngine::RayCast(const Vision::Ray &ray, Vision::RayHit
&rayhit)
    {
        // Make a performer line segment for testing
        // Need a segment set to do the testing
        ::pfSegSet segset;

        // set up intersection segment, pointing down
        // for "terrain" following
        segset.activeMask = 1;
        segset.isectMask = 0x0000FFFF; // Set high masks on m_objects to
skip isector hit
        segset.discFunc = NULL;
        segset.bound = NULL;
        segset.mode = PFTRAV_IS_PRIM;
        segset.segs[0].pos.set(ray.x, ray.y, ray.z);
        segset.segs[0].dir.set(ray.dx, ray.dy, ray.dz);
        segset.segs[0].length = (ray.distance <= 0.0 ? 999.0 :
ray.distance);

        // Cast from the scene node - we are testing against the whole
scene!

        // Prepare a list for hits - but we only realy care about the first
one.
        // All the examples on the web use [32] here. Not sure why.
        ::pfHit **hits[32];
        int numhits;
        numhits = g_scene->m_pnode->isect(&segset, hits);
        if (numhits <= 0)
        {
            return 0;
        }

        // get the hit point
        ::pfVec3 pnt;
        (*hits[0])->query(PFQHIT_POINT, pnt.vec);

#ifdef IRIX
        // we need to sanity check the hit point on IRIX
        if (isnan(pnt.vec[PF_Z]))
        {
            LOG_ERROR << "RayCast point is invalid" << ENDLOG; // THIS
ERROR COMES UP OFTEN!!
            return 0;
        }
#endif

        // transform object point into scene coordinates
        ::pfMatrix xmat;
        (*hits[0])->query(PFQHIT_XFORM, (float*)xmat.mat);

        ::pfVec3 xpnt;
        xpnt.xformPt(pnt, xmat);

        // copy into rayhits
        rayhit.x = xpnt[PF_X];
        rayhit.y = xpnt[PF_Y];
        rayhit.z = xpnt[PF_Z];

        return 1;
    }

Thanks.
-Damien

Damien Gerhardy
SYDAC Pty Ltd
Simulating a Better Reality
113-115 King William Street
Adelaide, SA, 5000
Australia
tel: +61 8 8239 3600
fax: +61 8 8212 0334
damien.gerhardy++at++sydac.com.au
Caution - This e-mail and its contents contain privileged information that
is intended solely for the recipient. If you are not the intended recipient
you are hereby notified that any use, dissemination, distribution or
reproduction of this e-mail is prohibited. If you have received this e-mail
in error please notify the Postmaster at sydac++at++sydac.com.au immediately. Any
views expressed in this e-mail are of the sender and may not necessarily
reflect the views of Sydac Pty Ltd.


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Apr 21 2005 - 22:00:58 PDT