mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-06 09:39:49 +00:00
Merge branch 'bounding_box' into 'master'
lua - use loaded node when possible when calculating bounding box (#7580) Closes #7580 See merge request OpenMW/openmw!4073
This commit is contained in:
commit
376e8a6e1f
@ -1658,18 +1658,28 @@ namespace MWRender
|
||||
}
|
||||
|
||||
osg::BoundingBox RenderingManager::getCullSafeBoundingBox(const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if (ptr.isEmpty())
|
||||
return {};
|
||||
|
||||
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> rootNode = ptr.getRefData().getBaseNode();
|
||||
|
||||
// Recalculate bounds on the ptr's template when the object is not loaded or is loaded but paged
|
||||
MWWorld::Scene* worldScene = MWBase::Environment::get().getWorldScene();
|
||||
if (!rootNode || worldScene->isPagedRef(ptr))
|
||||
{
|
||||
const std::string model = ptr.getClass().getCorrectedModel(ptr);
|
||||
|
||||
if (model.empty())
|
||||
return {};
|
||||
|
||||
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> rootNode = new SceneUtil::PositionAttitudeTransform;
|
||||
rootNode = new SceneUtil::PositionAttitudeTransform;
|
||||
// Hack even used by osg internally, osg's NodeVisitor won't accept const qualified nodes
|
||||
rootNode->addChild(const_cast<osg::Node*>(mResourceSystem->getSceneManager()->getTemplate(model).get()));
|
||||
|
||||
const float refScale = ptr.getCellRef().getScale();
|
||||
rootNode->setScale({ refScale, refScale, refScale });
|
||||
rootNode->setPosition(osg::Vec3(0, 0, 0));
|
||||
rootNode->setPosition(ptr.getCellRef().getPosition().asVec3());
|
||||
|
||||
osg::ref_ptr<Animation> animation = nullptr;
|
||||
|
||||
@ -1678,6 +1688,7 @@ namespace MWRender
|
||||
rootNode->setNodeMask(Mask_Actor);
|
||||
animation = new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(rootNode), mResourceSystem);
|
||||
}
|
||||
}
|
||||
|
||||
SceneUtil::CullSafeBoundsVisitor computeBounds;
|
||||
computeBounds.setTraversalMask(~(MWRender::Mask_ParticleSystem | MWRender::Mask_Effect));
|
||||
|
@ -277,7 +277,7 @@
|
||||
-- money:split(50):moveInto(types.Container.content(cont))
|
||||
|
||||
---
|
||||
-- The axis aligned bounding box in local coordinates.
|
||||
-- The axis aligned bounding box in world coordinates.
|
||||
-- @function [parent=#GameObject] getBoundingBox
|
||||
-- @param self
|
||||
-- @return openmw.util#Box
|
||||
|
Loading…
x
Reference in New Issue
Block a user