CullVisitor::apply(Geode&) detected NaN,

668 Views Asked by At

I have the following message when I run my OSG application:

CullVisitor::apply(Geode&) detected NaN, 
    depth=nan, center=(1.79588 1.50488 1.42179), 
    matrix={ 
        nan nan -nan -nan 
        nan nan -nan -nan 
        nan nan -nan -nan 
        nan nan -nan -nan 
}

What this kind of warning/error means?

Thanks in advance,

Rômulo

2

There are 2 best solutions below

1
On

from the http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/src/osgUtil/CullVisitor.cpp?rev=12829

It is a problem due to depth, I think.

    RefMatrix& matrix = *getModelViewMatrix();
...
    float depth = bb.valid() ? distance(bb.center(),matrix) : 0.0f;

enter image description here

0
On

I found and solved the problem!

When I grab the osg scene at first time, my view matrix is NaN; from the second time, this matrix is correctly filled.

Then I perform a check: if the view matrix is invalid, I will replace it by the identity matrix, as follows:

   // if the view matrix is invalid (NaN), use the identity
    osg::ref_ptr<osg::Camera> camera = _viewer->getCamera();
    if (camera->getViewMatrix().isNaN())
        camera->setViewMatrix(osg::Matrix::identity());