Random 1.#QNAN, 1.#IND, 1.#INF asserts

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Random 1.#QNAN, 1.#IND, 1.#INF asserts

Postby PJani » Sun May 10, 2009 7:58 pm

Hy.

Im having bit of problem. Im using OgreNewt for Newton 1.53. And Ogre 1.6. And i dont have time to change to newton 2.0.

When im testing my game i get random Assert AABB errors from Ogre. After few hours of investigation i foundout that the pyhisic engine in this case newton 1.53 passes this 1.#QNAN, 1.#IND, 1.#INF three "errors" to OgreNewt. What things could couse this things to happen i dont know, becouse my application was working fine before.

Here is my error info about object, before ogre graphic refresh. It happends at random positions. It happends to vehicles and other stuff too.

Moment of inertia is calculated with NewtonConvexCollisionCalculateInertialMatrix and its multiplied by mass of objects.

This missle initial velocity is 600m/s i tried to change to other velocites or mass but no luck.
Code: Select all
....
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
        Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
        Vector3(-1127.88, 356.634, -842.74)
...other objects
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
        Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
        Vector3(-1129.37, 356.969, -843.85)

...Other objects
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
        Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
        Vector3(-1.#IND, -1.#IND, -1.#IND)

....Other objects
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
        Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
        Vector3(1.#QNAN, 1.#QNAN, 1.#QNAN)


Here is code for building physic object.
Code: Select all
PhysicObject::PhysicObject( OgreNewt::World* w,
                            std::string meshid,
                            bool overrideCOF,
                            Ogre::Vector3 offsetCenterOfMass,
                            Ogre::Real mass,
                            bool isNullCollison){
    mWorld = w;

    SceneNodeClass* snc = SceneNodeManager::getSingletonPtr()->GetMesh(meshid);
    Ogre::SceneNode* osn = snc->getSceneNode();

    std::vector<OgreNewt::Collision*> colarry;
    //build sub node collisions
    int c = osn->numChildren();
    while(c){
        Ogre::SceneNode* object = (Ogre::SceneNode*)osn->getChild(--c);

        //set setscale
        Ogre::Vector3 gs = object->getScale();object->setScale(osn->getScale());
        OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::ConvexHull(mWorld, object, Ogre::Quaternion::IDENTITY, object->getPosition()*osn->getScale());
        object->setScale(gs);

        colarry.push_back(col);
    }
    //build compound collison...
    OgreNewt::Collision* cmp = new OgreNewt::CollisionPrimitives::CompoundCollision(mWorld,colarry);

    //Destroy collisons
    while(!colarry.empty()){
        delete colarry.back();
        colarry.pop_back();
    }


    //cast collison for inertia and center of mass calculation...
    OgreNewt::ConvexCollision* cccol = (OgreNewt::ConvexCollision*)cmp;

    //calculate inertia and center of mass
    Ogre::Vector3 inertia; Ogre::Vector3 offsetCOF;
    cccol->calculateInertialMatrix(inertia,offsetCOF);

    //Create Body
    bdy = new OgreNewt::Body(mWorld, cmp);
    //Delete collison
    delete cmp;

    bdy->setMassMatrix(mass,mass * inertia);

    //Set center of mass
    Ogre::Vector3 off = (!overrideCOF)? offsetCOF : offsetCenterOfMass;
    bdy->setCenterOfMass(off);


    bdy->setPositionOrientation(osn->getPosition(), osn->getOrientation());



    //Attach body to scenenode
    bdy->attachToNode(osn);

    //reset vars
    mTorque = Ogre::Vector3::ZERO; //reset torque
    mForce = Ogre::Vector3::ZERO;mTouchpoint = Ogre::Vector3::ZERO; //reset local force
    mGlbForce = Ogre::Vector3::ZERO;mGlbTouchpoint = Ogre::Vector3::ZERO; //reset global force
    mImpulse = Ogre::Vector3::ZERO;mImpulsePos = Ogre::Vector3::ZERO; //reset impulse

    //setCustomForceAndTorqueCallback
    bdy->setCustomForceAndTorqueCallback<PhysicObject>(&PhysicObject::forceCallBack, this);
}

void PhysicObject::forceCallBack(OgreNewt::Body* m_pBody){


    m_pBody->addTorque(mTorque);
    m_pBody->addLocalForce(mForce,mTouchpoint);
    m_pBody->addGlobalForce(mGlbForce,mGlbTouchpoint);
    m_pBody->addImpulse(mImpulse,mImpulsePos);
    //reset vars
    mTorque = Ogre::Vector3::ZERO; //reset torque
    mForce = Ogre::Vector3::ZERO;mTouchpoint = Ogre::Vector3::ZERO; //reset local force
    mGlbForce = Ogre::Vector3::ZERO;mGlbTouchpoint = Ogre::Vector3::ZERO; //reset global force
    mImpulse = Ogre::Vector3::ZERO;mImpulsePos = Ogre::Vector3::ZERO; //reset impulse

    //!GRAVITY
    //!///////////////////////////////////////////////
    //!Fg = m * g
    Ogre::Real mass;Ogre::Vector3 inertia;
    m_pBody->getMassMatrix(mass,inertia);
    m_pBody->addForce(Ogre::Vector3(0,(mass*-9.803),0));


}

PhysicObject::~PhysicObject(){
    delete bdy;
}

OgreNewt::Body* PhysicObject::getOgreNewtBody(){
    return bdy;
}


I just dont get it...please help...im in hurry...thanyou for your help in advance.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Random 1.#QNAN, 1.#IND, 1.#INF asserts

Postby PJani » Mon May 11, 2009 6:11 am

i found out if i call addImpulse everytime the callback happends and impulse is zero unexpected behaviour happends. So i modified that part of code in forceCallback. And now it works fine.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests

cron