mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Add NiBlendInterpolator
This commit is contained in:
parent
76dfb1b1b4
commit
7ecf018743
@ -502,4 +502,97 @@ namespace Nif
|
||||
data.post(nif);
|
||||
}
|
||||
|
||||
void NiBlendInterpolator::read(NIFStream* nif)
|
||||
{
|
||||
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 112))
|
||||
mManagerControlled = nif->getChar() & 1;
|
||||
size_t numInterps = 0;
|
||||
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 109))
|
||||
{
|
||||
numInterps = nif->getUShort();
|
||||
mArrayGrowBy = nif->getUShort();
|
||||
}
|
||||
else
|
||||
{
|
||||
numInterps = nif->getChar();
|
||||
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 112))
|
||||
{
|
||||
mWeightThreshold = nif->getFloat();
|
||||
if (!mManagerControlled)
|
||||
{
|
||||
mInterpCount = nif->getChar();
|
||||
mSingleIndex = nif->getChar();
|
||||
mHighPriority = nif->getChar();
|
||||
mNextHighPriority = nif->getChar();
|
||||
mSingleTime = nif->getFloat();
|
||||
mHighWeightsSum = nif->getFloat();
|
||||
mNextHighWeightsSum = nif->getFloat();
|
||||
mHighEaseSpinner = nif->getFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mManagerControlled)
|
||||
{
|
||||
mItems.resize(numInterps);
|
||||
for (Item& item : mItems)
|
||||
item.read(nif);
|
||||
}
|
||||
|
||||
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 111))
|
||||
{
|
||||
mManagerControlled = nif->getBoolean();
|
||||
mWeightThreshold = nif->getFloat();
|
||||
mOnlyUseHighestWeight = nif->getBoolean();
|
||||
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 109))
|
||||
{
|
||||
mInterpCount = nif->getUShort();
|
||||
mSingleIndex = nif->getUShort();
|
||||
}
|
||||
else
|
||||
{
|
||||
mInterpCount = nif->getChar();
|
||||
mSingleIndex = nif->getChar();
|
||||
}
|
||||
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 108))
|
||||
{
|
||||
mSingleInterpolator.read(nif);
|
||||
mSingleTime = nif->getFloat();
|
||||
}
|
||||
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 109))
|
||||
{
|
||||
mHighPriority = nif->getInt();
|
||||
mNextHighPriority = nif->getInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
mHighPriority = nif->getChar();
|
||||
mNextHighPriority = nif->getChar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NiBlendInterpolator::post(Reader& nif)
|
||||
{
|
||||
for (Item& item : mItems)
|
||||
item.post(nif);
|
||||
mSingleInterpolator.post(nif);
|
||||
}
|
||||
|
||||
void NiBlendInterpolator::Item::read(NIFStream* nif)
|
||||
{
|
||||
mInterpolator.read(nif);
|
||||
mWeight = nif->getFloat();
|
||||
mNormalizedWeight = nif->getFloat();
|
||||
if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 109))
|
||||
mPriority = nif->getInt();
|
||||
else
|
||||
mPriority = nif->getChar();
|
||||
mEaseSpinner = nif->getFloat();
|
||||
}
|
||||
|
||||
void NiBlendInterpolator::Item::post(Reader& nif)
|
||||
{
|
||||
mInterpolator.post(nif);
|
||||
}
|
||||
}
|
||||
|
@ -345,5 +345,36 @@ namespace Nif
|
||||
void post(Reader& nif) override;
|
||||
};
|
||||
|
||||
// Abstract
|
||||
struct NiBlendInterpolator : public NiInterpolator
|
||||
{
|
||||
struct Item
|
||||
{
|
||||
NiInterpolatorPtr mInterpolator;
|
||||
float mWeight, mNormalizedWeight;
|
||||
int mPriority;
|
||||
float mEaseSpinner;
|
||||
|
||||
void read(NIFStream* nif);
|
||||
void post(Reader& nif);
|
||||
};
|
||||
|
||||
bool mManagerControlled{ false };
|
||||
bool mOnlyUseHighestWeight{ false };
|
||||
unsigned short mArrayGrowBy{ 0 };
|
||||
float mWeightThreshold;
|
||||
unsigned short mInterpCount;
|
||||
unsigned short mSingleIndex;
|
||||
int mHighPriority, mNextHighPriority;
|
||||
float mSingleTime;
|
||||
float mHighWeightsSum, mNextHighWeightsSum;
|
||||
float mHighEaseSpinner;
|
||||
std::vector<Item> mItems;
|
||||
NiInterpolatorPtr mSingleInterpolator;
|
||||
|
||||
void read(NIFStream* nif) override;
|
||||
void post(Reader& nif) override;
|
||||
};
|
||||
|
||||
} // Namespace
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user