diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index dd3068ac89..f08f28612e 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -10,6 +10,7 @@ #include #include +#include #include @@ -58,8 +59,38 @@ namespace NifOsg using ValueT = typename MapT::ValueType; ValueInterpolator() = default; - ValueInterpolator(const Nif::NiFloatInterpolator* interpolator) = delete; - ValueInterpolator(const Nif::NiPoint3Interpolator* interpolator) = delete; + + template + inline ValueInterpolator(typename std::enable_if< + std::is_same::value, + const Nif::NiFloatInterpolator + >::type * interpolator) : mDefaultVal(interpolator->defaultVal) + { + if (interpolator->data.empty()) + return; + mKeys = interpolator->data->mKeyList; + if (mKeys) + { + mLastLowKey = mKeys->mKeys.end(); + mLastHighKey = mKeys->mKeys.end(); + } + }; + + template + inline ValueInterpolator(typename std::enable_if< + std::is_same::value, + const Nif::NiPoint3Interpolator + >::type * interpolator) : mDefaultVal(interpolator->defaultVal) + { + if (interpolator->data.empty()) + return; + mKeys = interpolator->data->mKeyList; + if (mKeys) + { + mLastLowKey = mKeys->mKeys.end(); + mLastHighKey = mKeys->mKeys.end(); + } + } ValueInterpolator(std::shared_ptr keys, ValueT defaultVal = ValueT()) : mKeys(keys) @@ -163,34 +194,6 @@ namespace NifOsg using Vec3Interpolator = ValueInterpolator; using Vec4Interpolator = ValueInterpolator; - template<> - inline FloatInterpolator::ValueInterpolator(const Nif::NiFloatInterpolator* interpolator) - : mDefaultVal(interpolator->defaultVal) - { - if (interpolator->data.empty()) - return; - mKeys = interpolator->data->mKeyList; - if (mKeys) - { - mLastLowKey = mKeys->mKeys.end(); - mLastHighKey = mKeys->mKeys.end(); - } - } - - template<> - inline Vec3Interpolator::ValueInterpolator(const Nif::NiPoint3Interpolator* interpolator) - : mDefaultVal(interpolator->defaultVal) - { - if (interpolator->data.empty()) - return; - mKeys = interpolator->data->mKeyList; - if (mKeys) - { - mLastLowKey = mKeys->mKeys.end(); - mLastHighKey = mKeys->mKeys.end(); - } - } - class ControllerFunction : public SceneUtil::ControllerFunction { private: