diff --git a/CHANGELOG.md b/CHANGELOG.md index d55452e42..deb7abd44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -183,6 +183,7 @@ Bug #5220: GetLOS crashes when actor isn't loaded Bug #5222: Empty cell name subrecords are not saved Bug #5226: Reputation should be capped + Bug #5229: Crash if mesh controller node has no data node Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 509877381..f1dd63def 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -661,6 +661,8 @@ namespace NifOsg if (ctrl->recType == Nif::RC_NiUVController) { const Nif::NiUVController *niuvctrl = static_cast(ctrl.getPtr()); + if (niuvctrl->data.empty()) + continue; const unsigned int uvSet = niuvctrl->uvSet; std::set texUnits; // UVController should work only for textures which use a given UV Set, usually 0. @@ -728,6 +730,8 @@ namespace NifOsg void handleVisController(const Nif::NiVisController* visctrl, osg::Node* node, int animflags) { + if (visctrl->data.empty()) + return; osg::ref_ptr callback(new VisController(visctrl->data.getPtr())); setupController(visctrl, callback, animflags); node->addUpdateCallback(callback); @@ -735,6 +739,8 @@ namespace NifOsg void handleRollController(const Nif::NiRollController* rollctrl, osg::Node* node, int animflags) { + if (rollctrl->data.empty()) + return; osg::ref_ptr callback(new RollController(rollctrl->data.getPtr())); setupController(rollctrl, callback, animflags); node->addUpdateCallback(callback); @@ -749,6 +755,8 @@ namespace NifOsg if (ctrl->recType == Nif::RC_NiAlphaController) { const Nif::NiAlphaController* alphactrl = static_cast(ctrl.getPtr()); + if (alphactrl->data.empty()) + continue; osg::ref_ptr osgctrl(new AlphaController(alphactrl->data.getPtr())); setupController(alphactrl, osgctrl, animflags); composite->addController(osgctrl); @@ -756,6 +764,8 @@ namespace NifOsg else if (ctrl->recType == Nif::RC_NiMaterialColorController) { const Nif::NiMaterialColorController* matctrl = static_cast(ctrl.getPtr()); + if (matctrl->data.empty()) + continue; // Two bits that correspond to the controlled material color. // 00: Ambient // 01: Diffuse @@ -1142,10 +1152,12 @@ namespace NifOsg continue; if(ctrl->recType == Nif::RC_NiGeomMorpherController) { - drawable = handleMorphGeometry(static_cast(ctrl.getPtr()), geom, parentNode, composite, boundTextures, animflags); + const Nif::NiGeomMorpherController* nimorphctrl = static_cast(ctrl.getPtr()); + if (nimorphctrl->data.empty()) + continue; + drawable = handleMorphGeometry(nimorphctrl, geom, parentNode, composite, boundTextures, animflags); - osg::ref_ptr morphctrl = new GeomMorpherController( - static_cast(ctrl.getPtr())->data.getPtr()); + osg::ref_ptr morphctrl = new GeomMorpherController(nimorphctrl->data.getPtr()); setupController(ctrl.getPtr(), morphctrl, animflags); drawable->setUpdateCallback(morphctrl); break;