mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-11 06:40:34 +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
@ -1659,24 +1659,35 @@ namespace MWRender
|
|||||||
|
|
||||||
osg::BoundingBox RenderingManager::getCullSafeBoundingBox(const MWWorld::Ptr& ptr) const
|
osg::BoundingBox RenderingManager::getCullSafeBoundingBox(const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
const std::string model = ptr.getClass().getCorrectedModel(ptr);
|
if (ptr.isEmpty())
|
||||||
if (model.empty())
|
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> rootNode = new SceneUtil::PositionAttitudeTransform;
|
osg::ref_ptr<SceneUtil::PositionAttitudeTransform> rootNode = ptr.getRefData().getBaseNode();
|
||||||
// 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();
|
// Recalculate bounds on the ptr's template when the object is not loaded or is loaded but paged
|
||||||
rootNode->setScale({ refScale, refScale, refScale });
|
MWWorld::Scene* worldScene = MWBase::Environment::get().getWorldScene();
|
||||||
rootNode->setPosition(osg::Vec3(0, 0, 0));
|
if (!rootNode || worldScene->isPagedRef(ptr))
|
||||||
|
|
||||||
osg::ref_ptr<Animation> animation = nullptr;
|
|
||||||
|
|
||||||
if (ptr.getClass().isNpc())
|
|
||||||
{
|
{
|
||||||
rootNode->setNodeMask(Mask_Actor);
|
const std::string model = ptr.getClass().getCorrectedModel(ptr);
|
||||||
animation = new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(rootNode), mResourceSystem);
|
|
||||||
|
if (model.empty())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
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(ptr.getCellRef().getPosition().asVec3());
|
||||||
|
|
||||||
|
osg::ref_ptr<Animation> animation = nullptr;
|
||||||
|
|
||||||
|
if (ptr.getClass().isNpc())
|
||||||
|
{
|
||||||
|
rootNode->setNodeMask(Mask_Actor);
|
||||||
|
animation = new NpcAnimation(ptr, osg::ref_ptr<osg::Group>(rootNode), mResourceSystem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneUtil::CullSafeBoundsVisitor computeBounds;
|
SceneUtil::CullSafeBoundsVisitor computeBounds;
|
||||||
|
@ -277,7 +277,7 @@
|
|||||||
-- money:split(50):moveInto(types.Container.content(cont))
|
-- 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
|
-- @function [parent=#GameObject] getBoundingBox
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return openmw.util#Box
|
-- @return openmw.util#Box
|
||||||
|
Loading…
x
Reference in New Issue
Block a user