Strange behavior with getSceneNodeFromRayBB()

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
TheUber
Posts: 1
Joined: Fri Mar 06, 2015 7:06 am

Strange behavior with getSceneNodeFromRayBB()

Post by TheUber »

Hello all, I am working on a portfolio piece and have run into problems with the getSceneNodeFromRayBB function.
I am drawing a very small line that follows my player for the purposes of these raycast collisions against specific objects.
No matter the distance from the player (and therefore the line) the object I am checking against is the getSceneNodeFromRayBB function is returning it when it passes the projected path of the ray.
Debug values from the ray and box themselves show there is no collision, and checking the returned scenenode's transformed bounding box against the same line return false for intersect.
The object I am checking for does have a triangle selector that is created from its own bounding box. I get the feeling the getSceneNodeFromRayBB call isn't taking the object's transformation into account, although I have done raycast checks on other objects in the world that work properly.

For now I am able to use the aforementioned intersect check to continue, but it would be appreciated if anyone had insight to this issue.

Some code snippets:

Collision manager check

Code: Select all

 
void CollisionManager::SendRaycastCollision(line3df ray, GameObject* gameObj)
{
    ISceneNode* sceneNode = nullptr;
    GameObject* go = nullptr;
 
    u32 t = 0xfffffff;
    u32 bits = gameObj->GetType() ^ t; // To avoid colliding with itself
 
    sceneNode = mpSceneCollisionManager->getSceneNodeFromRayBB(ray, bits); // this returns the object
    bool collided = sceneNode->getTransformedBoundingBox().intersectsWithLine(ray); // this returns false
    if(sceneNode)
    {
        go = mpObjectManager->GetObjectFromSceneNode(sceneNode);
    }
    if (go)  
    {
        go->OnCollision(gameObj);
        gameObj->OnCollision(go);
    }
}
 
Load function for the object I am unintentionally colliding with

Code: Select all

 
void Powerup::Load(ISceneNode* node, eGameObjects type, EventManager* eventMan, ISceneManager* sceneMan, 
    ObjectManager* objMan, CollisionManager* colMan,
    vector3df pos, vector3df rot, vector3df scl)
{
    GameObject::Load(node, type, eventMan, sceneMan, objMan, colMan, pos, rot, scl);
    
    mSceneNode->setName("Powerup");
 
    ITriangleSelector* selector = mpSceneManager->createTriangleSelectorFromBoundingBox(mSceneNode);
    mSceneNode->setTriangleSelector(selector);
    mSelector = selector;
}
 
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Strange behavior with getSceneNodeFromRayBB()

Post by CuteAlien »

Took me a while to get to this. From what I can see from the code the node-transformation is regarded by getSceneNodeFromRayBB. I would need a concrete example which I can debug to dig deeper what's going on in your case.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply