mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 07:39:47 +00:00
Use the initial pose of a MorphGeometry for object placement (Fixes #3136)
This commit is contained in:
parent
aa9905b0eb
commit
06ed20abf8
1 changed files with 11 additions and 4 deletions
|
@ -999,7 +999,7 @@ namespace NifOsg
|
||||||
continue;
|
continue;
|
||||||
if(ctrl->recType == Nif::RC_NiGeomMorpherController)
|
if(ctrl->recType == Nif::RC_NiGeomMorpherController)
|
||||||
{
|
{
|
||||||
geometry = handleMorphGeometry(static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr()));
|
geometry = handleMorphGeometry(static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr()), triShape, parentNode, composite, boundTextures, animflags);
|
||||||
|
|
||||||
osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController(
|
osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController(
|
||||||
static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr())->data.getPtr());
|
static_cast<const Nif::NiGeomMorpherController*>(ctrl.getPtr())->data.getPtr());
|
||||||
|
@ -1010,9 +1010,10 @@ namespace NifOsg
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!geometry.get())
|
if (!geometry.get())
|
||||||
|
{
|
||||||
geometry = new osg::Geometry;
|
geometry = new osg::Geometry;
|
||||||
|
|
||||||
triShapeToGeometry(triShape, geometry, parentNode, composite, boundTextures, animflags);
|
triShapeToGeometry(triShape, geometry, parentNode, composite, boundTextures, animflags);
|
||||||
|
}
|
||||||
|
|
||||||
#if OSG_VERSION_LESS_THAN(3,3,3)
|
#if OSG_VERSION_LESS_THAN(3,3,3)
|
||||||
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
||||||
|
@ -1046,7 +1047,7 @@ namespace NifOsg
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> handleMorphGeometry(const Nif::NiGeomMorpherController* morpher)
|
osg::ref_ptr<osg::Geometry> handleMorphGeometry(const Nif::NiGeomMorpherController* morpher, const Nif::NiTriShape *triShape, osg::Node* parentNode, SceneUtil::CompositeStateSetUpdater* composite, const std::vector<int>& boundTextures, int animflags)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osgAnimation::MorphGeometry> morphGeom = new osgAnimation::MorphGeometry;
|
osg::ref_ptr<osgAnimation::MorphGeometry> morphGeom = new osgAnimation::MorphGeometry;
|
||||||
morphGeom->setMethod(osgAnimation::MorphGeometry::RELATIVE);
|
morphGeom->setMethod(osgAnimation::MorphGeometry::RELATIVE);
|
||||||
|
@ -1056,6 +1057,8 @@ namespace NifOsg
|
||||||
morphGeom->setUpdateCallback(NULL);
|
morphGeom->setUpdateCallback(NULL);
|
||||||
morphGeom->setCullCallback(new UpdateMorphGeometry);
|
morphGeom->setCullCallback(new UpdateMorphGeometry);
|
||||||
|
|
||||||
|
triShapeToGeometry(triShape, morphGeom, parentNode, composite, boundTextures, animflags);
|
||||||
|
|
||||||
const std::vector<Nif::NiMorphData::MorphData>& morphs = morpher->data.getPtr()->mMorphs;
|
const std::vector<Nif::NiMorphData::MorphData>& morphs = morpher->data.getPtr()->mMorphs;
|
||||||
if (!morphs.size())
|
if (!morphs.size())
|
||||||
return morphGeom;
|
return morphGeom;
|
||||||
|
@ -1096,6 +1099,10 @@ namespace NifOsg
|
||||||
box.expandBy(vertBounds[i]);
|
box.expandBy(vertBounds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For the initial bounding box (used for object placement) use the default pose, fire off a bounding compute to set this initial box
|
||||||
|
morphGeom->getBoundingBox();
|
||||||
|
|
||||||
|
// Now set up the callback so that we get properly enlarged bounds if/when the mesh starts animating
|
||||||
morphGeom->setComputeBoundingBoxCallback(new StaticBoundingBoxCallback(box));
|
morphGeom->setComputeBoundingBoxCallback(new StaticBoundingBoxCallback(box));
|
||||||
|
|
||||||
return morphGeom;
|
return morphGeom;
|
||||||
|
|
Loading…
Reference in a new issue