Camera zoom to bounding box fix

This commit is contained in:
sorket 2023-07-15 22:24:53 -04:00
parent 599ff78539
commit 5404460fce
3 changed files with 7 additions and 4 deletions

View File

@ -103,10 +103,11 @@ namespace RNR
this->render_time += ogreRoot->getTimer()->getMilliseconds() / 1000.0;
ogreRoot->getTimer()->reset();
if(!world->getWorkspace()->getBoundingBox().isInfinite())
Ogre::AxisAlignedBox boundingBox = world->getWorkspace()->getBoundingBox();
if(!boundingBox.isNull() && !boundingBox.isInfinite())
{
ogreCamera->getParentSceneNode()->setPosition(world->getWorkspace()->getBoundingBox().getCorner(Ogre::AxisAlignedBox::CornerEnum::NEAR_LEFT_TOP));
ogreCamera->getParentSceneNode()->lookAt(world->getWorkspace()->getBoundingBox().getCenter(), Ogre::Node::TS_WORLD);
ogreCamera->getParentSceneNode()->setPosition(boundingBox.getCorner(Ogre::AxisAlignedBox::CornerEnum::NEAR_LEFT_TOP));
ogreCamera->getParentSceneNode()->lookAt(boundingBox.getCenter(), Ogre::Node::TS_WORLD);
}
ogreRoot->renderOneFrame(this->delta);

View File

@ -83,6 +83,8 @@ void MainWindow::updateTree(RNR::Instance* root_instance)
void MainWindow::loadDatamodel()
{
this->ogreWidget->world->load(QFileDialog::getOpenFileName(this, tr("Open RBXL"), tr(""), tr("RBXLs (*.rbxl)")).toLocal8Bit().data());
updateTree(ogreWidget->world->getDatamodel());
}
void MainWindow::createToolbar()

View File

@ -1,7 +1,7 @@
#pragma once
#include <pugixml.hpp>
#include <OGRE/OgreVector3.h>
#include <OGRE/Ogre.h>
#include <App/CoordinateFrame.hpp>
namespace RNR