Handle NiGeomMorpherController interpolator list

pull/593/head
Alexei Dobrohotov 4 years ago
parent f3f5dcb016
commit a46699fb1e

@ -216,6 +216,7 @@ namespace Nif
}
else
{
// TODO: handle weighted interpolators
unsigned int numInterps = nif->getUInt();
nif->skip(8 * numInterps);
}

@ -197,10 +197,25 @@ GeomMorpherController::GeomMorpherController(const GeomMorpherController &copy,
{
}
GeomMorpherController::GeomMorpherController(const Nif::NiMorphData *data)
GeomMorpherController::GeomMorpherController(const Nif::NiGeomMorpherController* ctrl)
{
for (unsigned int i=0; i<data->mMorphs.size(); ++i)
mKeyFrames.emplace_back(data->mMorphs[i].mKeyFrames);
if (ctrl->interpolators.length() == 0)
{
if (ctrl->data.empty())
return;
for (const auto& morph : ctrl->data->mMorphs)
mKeyFrames.emplace_back(morph.mKeyFrames);
}
else
{
for (size_t i = 0; i < ctrl->interpolators.length(); ++i)
{
if (!ctrl->interpolators[i].empty())
mKeyFrames.emplace_back(ctrl->interpolators[i].getPtr());
else
mKeyFrames.emplace_back();
}
}
}
void GeomMorpherController::update(osg::NodeVisitor *nv, osg::Drawable *drawable)

@ -218,7 +218,7 @@ namespace NifOsg
class GeomMorpherController : public osg::Drawable::UpdateCallback, public SceneUtil::Controller
{
public:
GeomMorpherController(const Nif::NiMorphData* data);
GeomMorpherController(const Nif::NiGeomMorpherController* ctrl);
GeomMorpherController();
GeomMorpherController(const GeomMorpherController& copy, const osg::CopyOp& copyop);

@ -1244,7 +1244,7 @@ namespace NifOsg
continue;
drawable = handleMorphGeometry(nimorphctrl, geom, parentNode, composite, boundTextures, animflags);
osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController(nimorphctrl->data.getPtr());
osg::ref_ptr<GeomMorpherController> morphctrl = new GeomMorpherController(nimorphctrl);
setupController(ctrl.getPtr(), morphctrl, animflags);
drawable->setUpdateCallback(morphctrl);
break;

Loading…
Cancel
Save