mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 10:21:11 +00:00
Separate record list reading from its state
To make it possible to set record list state independently from reading NIF file.
This commit is contained in:
parent
4b760e8846
commit
0688b6de40
@ -19,14 +19,14 @@ namespace Nif
|
|||||||
if (nif->getVersion() < NIFStream::generateVersion(10, 0, 1, 0))
|
if (nif->getVersion() < NIFStream::generateVersion(10, 0, 1, 0))
|
||||||
extra.read(nif);
|
extra.read(nif);
|
||||||
else
|
else
|
||||||
extralist.read(nif);
|
readRecordList(nif, extralist);
|
||||||
controller.read(nif);
|
controller.read(nif);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Named::post(Reader& nif)
|
void Named::post(Reader& nif)
|
||||||
{
|
{
|
||||||
extra.post(nif);
|
extra.post(nif);
|
||||||
extralist.post(nif);
|
postRecordList(nif, extralist);
|
||||||
controller.post(nif);
|
controller.post(nif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ namespace Nif
|
|||||||
void NiMultiTargetTransformController::post(Reader& nif)
|
void NiMultiTargetTransformController::post(Reader& nif)
|
||||||
{
|
{
|
||||||
NiInterpController::post(nif);
|
NiInterpController::post(nif);
|
||||||
mExtraTargets.post(nif);
|
postRecordList(nif, mExtraTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NiAlphaController::read(NIFStream* nif)
|
void NiAlphaController::read(NIFStream* nif)
|
||||||
@ -251,7 +251,7 @@ namespace Nif
|
|||||||
{
|
{
|
||||||
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
|
if (nif->getVersion() <= NIFFile::NIFVersion::VER_OB)
|
||||||
{
|
{
|
||||||
mInterpolators.read(nif);
|
readRecordList(nif, mInterpolators);
|
||||||
if (nif->getVersion() >= NIFStream::generateVersion(10, 2, 0, 0) && nif->getBethVersion() > 9)
|
if (nif->getVersion() >= NIFStream::generateVersion(10, 2, 0, 0) && nif->getBethVersion() > 9)
|
||||||
{
|
{
|
||||||
unsigned int numUnknown = nif->getUInt();
|
unsigned int numUnknown = nif->getUInt();
|
||||||
@ -279,7 +279,7 @@ namespace Nif
|
|||||||
{
|
{
|
||||||
NiInterpController::post(nif);
|
NiInterpController::post(nif);
|
||||||
mData.post(nif);
|
mData.post(nif);
|
||||||
mInterpolators.post(nif);
|
postRecordList(nif, mInterpolators);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NiVisController::read(NIFStream* nif)
|
void NiVisController::read(NIFStream* nif)
|
||||||
@ -304,13 +304,13 @@ namespace Nif
|
|||||||
timeStart = nif->getFloat();
|
timeStart = nif->getFloat();
|
||||||
mDelta = nif->getFloat();
|
mDelta = nif->getFloat();
|
||||||
}
|
}
|
||||||
mSources.read(nif);
|
readRecordList(nif, mSources);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NiFlipController::post(Reader& nif)
|
void NiFlipController::post(Reader& nif)
|
||||||
{
|
{
|
||||||
NiFloatInterpController::post(nif);
|
NiFloatInterpController::post(nif);
|
||||||
mSources.post(nif);
|
postRecordList(nif, mSources);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bhkBlendController::read(NIFStream* nif)
|
void bhkBlendController::read(NIFStream* nif)
|
||||||
|
@ -13,7 +13,7 @@ namespace Nif
|
|||||||
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 101))
|
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 101))
|
||||||
partitions.read(nif);
|
partitions.read(nif);
|
||||||
root.read(nif);
|
root.read(nif);
|
||||||
bones.read(nif);
|
readRecordList(nif, bones);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NiSkinInstance::post(Reader& nif)
|
void NiSkinInstance::post(Reader& nif)
|
||||||
@ -21,20 +21,19 @@ namespace Nif
|
|||||||
data.post(nif);
|
data.post(nif);
|
||||||
partitions.post(nif);
|
partitions.post(nif);
|
||||||
root.post(nif);
|
root.post(nif);
|
||||||
bones.post(nif);
|
postRecordList(nif, bones);
|
||||||
|
|
||||||
if (data.empty() || root.empty())
|
if (data.empty() || root.empty())
|
||||||
throw Nif::Exception("NiSkinInstance missing root or data", nif.getFilename());
|
throw Nif::Exception("NiSkinInstance missing root or data", nif.getFilename());
|
||||||
|
|
||||||
size_t bnum = bones.length();
|
if (bones.size() != data->bones.size())
|
||||||
if (bnum != data->bones.size())
|
|
||||||
throw Nif::Exception("Mismatch in NiSkinData bone count", nif.getFilename());
|
throw Nif::Exception("Mismatch in NiSkinData bone count", nif.getFilename());
|
||||||
|
|
||||||
for (size_t i = 0; i < bnum; i++)
|
for (auto& bone : bones)
|
||||||
{
|
{
|
||||||
if (bones[i].empty())
|
if (bone.empty())
|
||||||
throw Nif::Exception("Oops: Missing bone! Don't know how to handle this.", nif.getFilename());
|
throw Nif::Exception("Oops: Missing bone! Don't know how to handle this.", nif.getFilename());
|
||||||
bones[i]->setBone();
|
bone->setBone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace Nif
|
|||||||
if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0))
|
if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0))
|
||||||
velocity = nif->getVector3();
|
velocity = nif->getVector3();
|
||||||
if (nif->getBethVersion() <= NIFFile::BethVersion::BETHVER_FO3)
|
if (nif->getBethVersion() <= NIFFile::BethVersion::BETHVER_FO3)
|
||||||
props.read(nif);
|
readRecordList(nif, props);
|
||||||
|
|
||||||
if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0))
|
if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0))
|
||||||
hasBounds = nif->getBoolean();
|
hasBounds = nif->getBoolean();
|
||||||
@ -102,7 +102,7 @@ namespace Nif
|
|||||||
void Node::post(Reader& nif)
|
void Node::post(Reader& nif)
|
||||||
{
|
{
|
||||||
Named::post(nif);
|
Named::post(nif);
|
||||||
props.post(nif);
|
postRecordList(nif, props);
|
||||||
collision.post(nif);
|
collision.post(nif);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +114,9 @@ namespace Nif
|
|||||||
void NiNode::read(NIFStream* nif)
|
void NiNode::read(NIFStream* nif)
|
||||||
{
|
{
|
||||||
Node::read(nif);
|
Node::read(nif);
|
||||||
children.read(nif);
|
readRecordList(nif, children);
|
||||||
if (nif->getBethVersion() < NIFFile::BethVersion::BETHVER_FO4)
|
if (nif->getBethVersion() < NIFFile::BethVersion::BETHVER_FO4)
|
||||||
effects.read(nif);
|
readRecordList(nif, effects);
|
||||||
|
|
||||||
// Discard transformations for the root node, otherwise some meshes
|
// Discard transformations for the root node, otherwise some meshes
|
||||||
// occasionally get wrong orientation. Only for NiNode-s for now, but
|
// occasionally get wrong orientation. Only for NiNode-s for now, but
|
||||||
@ -131,14 +131,14 @@ namespace Nif
|
|||||||
void NiNode::post(Reader& nif)
|
void NiNode::post(Reader& nif)
|
||||||
{
|
{
|
||||||
Node::post(nif);
|
Node::post(nif);
|
||||||
children.post(nif);
|
postRecordList(nif, children);
|
||||||
effects.post(nif);
|
postRecordList(nif, effects);
|
||||||
|
|
||||||
for (size_t i = 0; i < children.length(); i++)
|
for (auto& child : children)
|
||||||
{
|
{
|
||||||
// Why would a unique list of children contain empty refs?
|
// Why would a unique list of children contain empty refs?
|
||||||
if (!children[i].empty())
|
if (!child.empty())
|
||||||
children[i]->parents.push_back(this);
|
child->parents.push_back(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,14 +202,14 @@ namespace Nif
|
|||||||
mGrowBy = nif->getUInt();
|
mGrowBy = nif->getUInt();
|
||||||
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
|
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
|
||||||
mScale = nif->getVector4();
|
mScale = nif->getVector4();
|
||||||
mData.read(nif);
|
readRecordList(nif, mData);
|
||||||
unsigned int numFilters = nif->getUInt();
|
unsigned int numFilters = nif->getUInt();
|
||||||
nif->getUInts(mFilters, numFilters);
|
nif->getUInts(mFilters, numFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bhkNiTriStripsShape::post(Reader& nif)
|
void bhkNiTriStripsShape::post(Reader& nif)
|
||||||
{
|
{
|
||||||
mData.post(nif);
|
postRecordList(nif, mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bhkPackedNiTriStripsShape::read(NIFStream* nif)
|
void bhkPackedNiTriStripsShape::read(NIFStream* nif)
|
||||||
@ -301,7 +301,7 @@ namespace Nif
|
|||||||
|
|
||||||
void bhkListShape::read(NIFStream* nif)
|
void bhkListShape::read(NIFStream* nif)
|
||||||
{
|
{
|
||||||
mSubshapes.read(nif);
|
readRecordList(nif, mSubshapes);
|
||||||
mHavokMaterial.read(nif);
|
mHavokMaterial.read(nif);
|
||||||
mChildShapeProperty.read(nif);
|
mChildShapeProperty.read(nif);
|
||||||
mChildFilterProperty.read(nif);
|
mChildFilterProperty.read(nif);
|
||||||
@ -315,7 +315,7 @@ namespace Nif
|
|||||||
{
|
{
|
||||||
bhkEntity::read(nif);
|
bhkEntity::read(nif);
|
||||||
mInfo.read(nif);
|
mInfo.read(nif);
|
||||||
mConstraints.read(nif);
|
readRecordList(nif, mConstraints);
|
||||||
if (nif->getBethVersion() < 76)
|
if (nif->getBethVersion() < 76)
|
||||||
mBodyFlags = nif->getUInt();
|
mBodyFlags = nif->getUInt();
|
||||||
else
|
else
|
||||||
|
@ -85,39 +85,25 @@ namespace Nif
|
|||||||
implementation.
|
implementation.
|
||||||
*/
|
*/
|
||||||
template <class X>
|
template <class X>
|
||||||
class RecordListT
|
using RecordListT = std::vector<RecordPtrT<X>>;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void readRecordList(NIFStream* nif, RecordListT<T>& list)
|
||||||
{
|
{
|
||||||
typedef RecordPtrT<X> Ptr;
|
const int length = nif->getInt();
|
||||||
std::vector<Ptr> list;
|
|
||||||
|
|
||||||
public:
|
list.resize(static_cast<std::size_t>(length));
|
||||||
RecordListT() = default;
|
|
||||||
|
|
||||||
RecordListT(std::vector<Ptr> list)
|
for (auto& value : list)
|
||||||
: list(std::move(list))
|
value.read(nif);
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void read(NIFStream* nif)
|
template <class T>
|
||||||
{
|
void postRecordList(Reader& nif, RecordListT<T>& list)
|
||||||
int len = nif->getInt();
|
{
|
||||||
list.resize(len);
|
for (auto& value : list)
|
||||||
|
value.post(nif);
|
||||||
for (size_t i = 0; i < list.size(); i++)
|
}
|
||||||
list[i].read(nif);
|
|
||||||
}
|
|
||||||
|
|
||||||
void post(Reader& nif)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < list.size(); i++)
|
|
||||||
list[i].post(nif);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Ptr& operator[](size_t index) const { return list.at(index); }
|
|
||||||
Ptr& operator[](size_t index) { return list.at(index); }
|
|
||||||
|
|
||||||
size_t length() const { return list.size(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Node;
|
struct Node;
|
||||||
struct Extra;
|
struct Extra;
|
||||||
|
@ -284,14 +284,9 @@ namespace NifBullet
|
|||||||
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(&node))
|
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(&node))
|
||||||
{
|
{
|
||||||
const Nif::NodeList& list = ninode->children;
|
const Nif::NodeList& list = ninode->children;
|
||||||
for (size_t i = 0; i < list.length(); i++)
|
for (const auto& child : list)
|
||||||
{
|
if (!child.empty() && findBoundingBox(child.get(), filename))
|
||||||
if (!list[i].empty())
|
return true;
|
||||||
{
|
|
||||||
if (findBoundingBox(list[i].get(), filename))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -300,12 +295,11 @@ namespace NifBullet
|
|||||||
{
|
{
|
||||||
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(&rootNode))
|
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(&rootNode))
|
||||||
{
|
{
|
||||||
const Nif::NodeList& list = ninode->children;
|
for (const auto& child : ninode->children)
|
||||||
for (size_t i = 0; i < list.length(); i++)
|
|
||||||
{
|
{
|
||||||
if (list[i].empty())
|
if (child.empty())
|
||||||
continue;
|
continue;
|
||||||
if (list[i].getPtr()->recType == Nif::RC_RootCollisionNode)
|
if (child.getPtr()->recType == Nif::RC_RootCollisionNode)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,17 +310,16 @@ namespace NifBullet
|
|||||||
{
|
{
|
||||||
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(&rootNode))
|
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(&rootNode))
|
||||||
{
|
{
|
||||||
const Nif::NodeList& list = ninode->children;
|
for (const auto& child : ninode->children)
|
||||||
for (size_t i = 0; i < list.length(); i++)
|
|
||||||
{
|
{
|
||||||
if (list[i].empty())
|
if (child.empty())
|
||||||
continue;
|
continue;
|
||||||
const Nif::Node* childNode = list[i].getPtr();
|
const Nif::Node* childNode = child.getPtr();
|
||||||
if (childNode->recType != Nif::RC_RootCollisionNode)
|
if (childNode->recType != Nif::RC_RootCollisionNode)
|
||||||
continue;
|
continue;
|
||||||
const Nif::NiNode* niChildnode
|
const Nif::NiNode* niChildnode
|
||||||
= static_cast<const Nif::NiNode*>(childNode); // RootCollisionNode is always a NiNode
|
= static_cast<const Nif::NiNode*>(childNode); // RootCollisionNode is always a NiNode
|
||||||
if (childNode->hasBounds || niChildnode->children.length() > 0)
|
if (childNode->hasBounds || niChildnode->children.size() > 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,13 +405,13 @@ namespace NifBullet
|
|||||||
{
|
{
|
||||||
const Nif::NodeList& list = ninode->children;
|
const Nif::NodeList& list = ninode->children;
|
||||||
const Nif::Parent currentParent{ *ninode, parent };
|
const Nif::Parent currentParent{ *ninode, parent };
|
||||||
for (size_t i = 0; i < list.length(); i++)
|
for (const auto& child : list)
|
||||||
{
|
{
|
||||||
if (list[i].empty())
|
if (child.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
assert(std::find(list[i]->parents.begin(), list[i]->parents.end(), ninode) != list[i]->parents.end());
|
assert(std::find(child->parents.begin(), child->parents.end(), ninode) != child->parents.end());
|
||||||
handleNode(fileName, list[i].get(), ¤tParent, flags, isCollisionNode, isAnimated, autogenerated,
|
handleNode(fileName, child.get(), ¤tParent, flags, isCollisionNode, isAnimated, autogenerated,
|
||||||
avoid, visualCollisionType);
|
avoid, visualCollisionType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ namespace NifOsg
|
|||||||
|
|
||||||
GeomMorpherController::GeomMorpherController(const Nif::NiGeomMorpherController* ctrl)
|
GeomMorpherController::GeomMorpherController(const Nif::NiGeomMorpherController* ctrl)
|
||||||
{
|
{
|
||||||
if (ctrl->mInterpolators.length() == 0)
|
if (ctrl->mInterpolators.size() == 0)
|
||||||
{
|
{
|
||||||
if (!ctrl->mData.empty())
|
if (!ctrl->mData.empty())
|
||||||
{
|
{
|
||||||
@ -209,10 +209,10 @@ namespace NifOsg
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mKeyFrames.resize(ctrl->mInterpolators.length());
|
mKeyFrames.resize(ctrl->mInterpolators.size());
|
||||||
mWeights = ctrl->mWeights;
|
mWeights = ctrl->mWeights;
|
||||||
|
|
||||||
for (size_t i = 0; i < ctrl->mInterpolators.length(); ++i)
|
for (std::size_t i = 0, n = ctrl->mInterpolators.size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
if (!ctrl->mInterpolators[i].empty() && ctrl->mInterpolators[i]->recType == Nif::RC_NiFloatInterpolator)
|
if (!ctrl->mInterpolators[i].empty() && ctrl->mInterpolators[i]->recType == Nif::RC_NiFloatInterpolator)
|
||||||
{
|
{
|
||||||
|
@ -76,9 +76,9 @@ namespace
|
|||||||
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(node))
|
if (const Nif::NiNode* ninode = dynamic_cast<const Nif::NiNode*>(node))
|
||||||
{
|
{
|
||||||
outIndices.push_back(ninode->recIndex);
|
outIndices.push_back(ninode->recIndex);
|
||||||
for (unsigned int i = 0; i < ninode->children.length(); ++i)
|
for (const auto& child : ninode->children)
|
||||||
if (!ninode->children[i].empty())
|
if (!child.empty())
|
||||||
getAllNiNodes(ninode->children[i].getPtr(), outIndices);
|
getAllNiNodes(child.getPtr(), outIndices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,18 +102,17 @@ namespace
|
|||||||
{
|
{
|
||||||
if (parent != nullptr)
|
if (parent != nullptr)
|
||||||
collectDrawableProperties(&parent->mNiNode, parent->mParent, out);
|
collectDrawableProperties(&parent->mNiNode, parent->mParent, out);
|
||||||
const Nif::PropertyList& props = nifNode->props;
|
for (const auto& property : nifNode->props)
|
||||||
for (size_t i = 0; i < props.length(); ++i)
|
|
||||||
{
|
{
|
||||||
if (!props[i].empty())
|
if (!property.empty())
|
||||||
{
|
{
|
||||||
switch (props[i]->recType)
|
switch (property->recType)
|
||||||
{
|
{
|
||||||
case Nif::RC_NiMaterialProperty:
|
case Nif::RC_NiMaterialProperty:
|
||||||
case Nif::RC_NiVertexColorProperty:
|
case Nif::RC_NiVertexColorProperty:
|
||||||
case Nif::RC_NiSpecularProperty:
|
case Nif::RC_NiSpecularProperty:
|
||||||
case Nif::RC_NiAlphaProperty:
|
case Nif::RC_NiAlphaProperty:
|
||||||
out.push_back(props[i].getPtr());
|
out.push_back(property.getPtr());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -375,19 +374,17 @@ namespace NifOsg
|
|||||||
SceneUtil::CompositeStateSetUpdater* composite, Resource::ImageManager* imageManager,
|
SceneUtil::CompositeStateSetUpdater* composite, Resource::ImageManager* imageManager,
|
||||||
std::vector<unsigned int>& boundTextures, int animflags)
|
std::vector<unsigned int>& boundTextures, int animflags)
|
||||||
{
|
{
|
||||||
const Nif::PropertyList& props = nifNode->props;
|
|
||||||
|
|
||||||
bool hasStencilProperty = false;
|
bool hasStencilProperty = false;
|
||||||
|
|
||||||
for (size_t i = 0; i < props.length(); ++i)
|
for (const auto& property : nifNode->props)
|
||||||
{
|
{
|
||||||
if (props[i].empty())
|
if (property.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (props[i].getPtr()->recType == Nif::RC_NiStencilProperty)
|
if (property.getPtr()->recType == Nif::RC_NiStencilProperty)
|
||||||
{
|
{
|
||||||
const Nif::NiStencilProperty* stencilprop
|
const Nif::NiStencilProperty* stencilprop
|
||||||
= static_cast<const Nif::NiStencilProperty*>(props[i].getPtr());
|
= static_cast<const Nif::NiStencilProperty*>(property.getPtr());
|
||||||
if (stencilprop->data.enabled != 0)
|
if (stencilprop->data.enabled != 0)
|
||||||
{
|
{
|
||||||
hasStencilProperty = true;
|
hasStencilProperty = true;
|
||||||
@ -396,24 +393,24 @@ namespace NifOsg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < props.length(); ++i)
|
for (const auto& property : nifNode->props)
|
||||||
{
|
{
|
||||||
if (!props[i].empty())
|
if (!property.empty())
|
||||||
{
|
{
|
||||||
// Get the lowest numbered recIndex of the NiTexturingProperty root node.
|
// Get the lowest numbered recIndex of the NiTexturingProperty root node.
|
||||||
// This is what is overridden when a spell effect "particle texture" is used.
|
// This is what is overridden when a spell effect "particle texture" is used.
|
||||||
if (nifNode->parents.empty() && !mFoundFirstRootTexturingProperty
|
if (nifNode->parents.empty() && !mFoundFirstRootTexturingProperty
|
||||||
&& props[i].getPtr()->recType == Nif::RC_NiTexturingProperty)
|
&& property.getPtr()->recType == Nif::RC_NiTexturingProperty)
|
||||||
{
|
{
|
||||||
mFirstRootTextureIndex = props[i].getPtr()->recIndex;
|
mFirstRootTextureIndex = property.getPtr()->recIndex;
|
||||||
mFoundFirstRootTexturingProperty = true;
|
mFoundFirstRootTexturingProperty = true;
|
||||||
}
|
}
|
||||||
else if (props[i].getPtr()->recType == Nif::RC_NiTexturingProperty)
|
else if (property.getPtr()->recType == Nif::RC_NiTexturingProperty)
|
||||||
{
|
{
|
||||||
if (props[i].getPtr()->recIndex == mFirstRootTextureIndex)
|
if (property.getPtr()->recIndex == mFirstRootTextureIndex)
|
||||||
applyTo->setUserValue("overrideFx", 1);
|
applyTo->setUserValue("overrideFx", 1);
|
||||||
}
|
}
|
||||||
handleProperty(props[i].getPtr(), applyTo, composite, imageManager, boundTextures, animflags,
|
handleProperty(property.getPtr(), applyTo, composite, imageManager, boundTextures, animflags,
|
||||||
hasStencilProperty);
|
hasStencilProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -463,13 +460,13 @@ namespace NifOsg
|
|||||||
const Nif::NiFltAnimationNode* niFltAnimationNode = static_cast<const Nif::NiFltAnimationNode*>(nifNode);
|
const Nif::NiFltAnimationNode* niFltAnimationNode = static_cast<const Nif::NiFltAnimationNode*>(nifNode);
|
||||||
osg::ref_ptr<osg::Sequence> sequenceNode(new osg::Sequence);
|
osg::ref_ptr<osg::Sequence> sequenceNode(new osg::Sequence);
|
||||||
sequenceNode->setName(niFltAnimationNode->name);
|
sequenceNode->setName(niFltAnimationNode->name);
|
||||||
if (niFltAnimationNode->children.length() != 0)
|
if (!niFltAnimationNode->children.empty())
|
||||||
{
|
{
|
||||||
if (niFltAnimationNode->swing())
|
if (niFltAnimationNode->swing())
|
||||||
sequenceNode->setDefaultTime(
|
sequenceNode->setDefaultTime(
|
||||||
niFltAnimationNode->mDuration / (niFltAnimationNode->children.length() * 2));
|
niFltAnimationNode->mDuration / (niFltAnimationNode->children.size() * 2));
|
||||||
else
|
else
|
||||||
sequenceNode->setDefaultTime(niFltAnimationNode->mDuration / niFltAnimationNode->children.length());
|
sequenceNode->setDefaultTime(niFltAnimationNode->mDuration / niFltAnimationNode->children.size());
|
||||||
}
|
}
|
||||||
return sequenceNode;
|
return sequenceNode;
|
||||||
}
|
}
|
||||||
@ -630,12 +627,9 @@ namespace NifOsg
|
|||||||
for (Nif::ExtraPtr e = nifNode->extra; !e.empty(); e = e->next)
|
for (Nif::ExtraPtr e = nifNode->extra; !e.empty(); e = e->next)
|
||||||
extraCollection.emplace_back(e);
|
extraCollection.emplace_back(e);
|
||||||
|
|
||||||
for (size_t i = 0; i < nifNode->extralist.length(); ++i)
|
for (const auto& extraNode : nifNode->extralist)
|
||||||
{
|
if (!extraNode.empty())
|
||||||
Nif::ExtraPtr e = nifNode->extralist[i];
|
extraCollection.emplace_back(extraNode);
|
||||||
if (!e.empty())
|
|
||||||
extraCollection.emplace_back(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& e : extraCollection)
|
for (const auto& e : extraCollection)
|
||||||
{
|
{
|
||||||
@ -805,20 +799,16 @@ namespace NifOsg
|
|||||||
if (ninode)
|
if (ninode)
|
||||||
{
|
{
|
||||||
const Nif::NodeList& effects = ninode->effects;
|
const Nif::NodeList& effects = ninode->effects;
|
||||||
for (size_t i = 0; i < effects.length(); ++i)
|
for (const auto& effect : effects)
|
||||||
{
|
if (!effect.empty())
|
||||||
if (!effects[i].empty())
|
handleEffect(effect.getPtr(), currentNode, imageManager);
|
||||||
handleEffect(effects[i].getPtr(), currentNode, imageManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Nif::NodeList& children = ninode->children;
|
const Nif::NodeList& children = ninode->children;
|
||||||
const Nif::Parent currentParent{ *ninode, parent };
|
const Nif::Parent currentParent{ *ninode, parent };
|
||||||
for (size_t i = 0; i < children.length(); ++i)
|
for (const auto& child : children)
|
||||||
{
|
if (!child.empty())
|
||||||
if (!children[i].empty())
|
handleNode(child.getPtr(), ¤tParent, currentNode, imageManager, boundTextures, animflags,
|
||||||
handleNode(children[i].getPtr(), ¤tParent, currentNode, imageManager, boundTextures,
|
skipMeshes, hasMarkers, hasAnimatedParents, textKeys, rootNode);
|
||||||
animflags, skipMeshes, hasMarkers, hasAnimatedParents, textKeys, rootNode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nifNode->recType == Nif::RC_NiFltAnimationNode)
|
if (nifNode->recType == Nif::RC_NiFltAnimationNode)
|
||||||
@ -1012,13 +1002,12 @@ namespace NifOsg
|
|||||||
wrapT = inherit->getWrap(osg::Texture2D::WRAP_T);
|
wrapT = inherit->getWrap(osg::Texture2D::WRAP_T);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < flipctrl->mSources.length(); ++i)
|
for (const auto& source : flipctrl->mSources)
|
||||||
{
|
{
|
||||||
Nif::NiSourceTexturePtr st = flipctrl->mSources[i];
|
if (source.empty())
|
||||||
if (st.empty())
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Image> image(handleSourceTexture(st.getPtr(), imageManager));
|
osg::ref_ptr<osg::Image> image(handleSourceTexture(source.getPtr(), imageManager));
|
||||||
osg::ref_ptr<osg::Texture2D> texture(new osg::Texture2D(image));
|
osg::ref_ptr<osg::Texture2D> texture(new osg::Texture2D(image));
|
||||||
if (image)
|
if (image)
|
||||||
texture->setTextureSize(image->s(), image->t());
|
texture->setTextureSize(image->s(), image->t());
|
||||||
@ -1480,7 +1469,7 @@ namespace NifOsg
|
|||||||
const Nif::NiSkinInstance* skin = static_cast<const Nif::NiGeometry*>(nifNode)->skin.getPtr();
|
const Nif::NiSkinInstance* skin = static_cast<const Nif::NiGeometry*>(nifNode)->skin.getPtr();
|
||||||
const Nif::NiSkinData* data = skin->data.getPtr();
|
const Nif::NiSkinData* data = skin->data.getPtr();
|
||||||
const Nif::NodeList& bones = skin->bones;
|
const Nif::NodeList& bones = skin->bones;
|
||||||
for (size_t i = 0; i < bones.length(); i++)
|
for (std::size_t i = 0, n = bones.size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
std::string boneName = Misc::StringUtils::lowerCase(bones[i].getPtr()->name);
|
std::string boneName = Misc::StringUtils::lowerCase(bones[i].getPtr()->name);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user