[SOLVED] [2.12-beta2] getWorldBoundBox


photo

Recommended Posts

Hello,

The function "getWorldBoundBox" always returns Vec3(0,0,0) in 2.12.

The following code works in 2.10.2 but always returns 0,0,0 after upgrading my project to 2.12-beta2

 

    PlayerDummyPtr player = PlayerDummy::create();

    Game::setPlayer(player);
    float znear = 0.1f;
    float zfar = 10000.0f;
    player->setFov(60.0f);
    player->setZNear(znear);
    player->setZFar(zfar);

    player->setWorldPosition(Vec3(0, -3., 1));
    player->worldLookAt(Vec3(0., 0., 0.));

    NodePtr testNode = World::loadNode("/home/ganoufa/unigine_projects/tmptest/data/models/mymodel.fbx");
    testNode->setEnabled(true);
    testNode->setWorldPosition(Vec3(0., 0., 0.));
    WorldBoundBox bbox3D = testNode->getWorldBoundBox();
    Vec3 bmin = bbox3D.getMin();
    Vec3 bmax = bbox3D.getMax();
    std::cout << "bmin = " << bmin.x << ", " << bmin.y << ", " << bmin.z << '\n';
    std::cout << "bmax = " << bmax.x << ", " << bmax.y << ", " << bmax.z << '\n';

 

Link to post

Hi Damien,

Bounding box calculations changed in 2.11 release: https://developer.unigine.com/en/docs/2.11/upgrade/migration_api?rlang=cpp#bounds_changes

Now getWorldBoundBox will return bounds for the selected object without it's children (in case of NodeDummy it will return all zeroes). More likely in your case you need to call getHierarchyBoundBox to get the resulting bounding box.

Similar issue: https://developer.unigine.com/forum/topic/6179-solved-cannot-access-boundbox-of-created-nodes-in-custom-consolecommand/

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to post

Thanks,

It works with getHierarchyWorldBoundBox instead of getWorldBoundBox.

 

Link to post
  • morbid changed the title to [SOLVED] [2.12-beta2] getWorldBoundBox