From 9557a808147ba593a745c4ca684965cc4fcedab9 Mon Sep 17 00:00:00 2001 From: ousnius Date: Sun, 30 Oct 2016 03:50:21 +0100 Subject: [PATCH] Cleanup - const - Anim class --- src/components/Anim.cpp | 10 +++-- src/components/Anim.h | 49 ++++++++---------------- src/files/NifBlock.cpp | 74 ++++++++++++++++++------------------ src/files/NifBlock.h | 84 ++++++++++++++++++++--------------------- src/files/NifFile.cpp | 20 +++++----- src/files/NifFile.h | 20 +++++----- 6 files changed, 122 insertions(+), 135 deletions(-) diff --git a/src/components/Anim.cpp b/src/components/Anim.cpp index f3a9a471..ac0251b4 100644 --- a/src/components/Anim.cpp +++ b/src/components/Anim.cpp @@ -251,17 +251,21 @@ void AnimInfo::WriteToNif(NifFile* nif, bool synchBoneIDs, const string& shapeEx } bool incomplete = false; - SkinTransform xForm; + bool isFO4 = (nif->GetHeader().GetUserVersion() >= 12 && nif->GetHeader().GetUserVersion2() == 130); + for (auto &shapeBoneList : shapeBones) { if (shapeBoneList.first == shapeException) continue; int stype = nif->GetShapeType(shapeBoneList.first); + if (stype == NIUNKNOWN) + continue; + bool isBSShape = (stype == BSTRISHAPE || stype == BSSUBINDEXTRISHAPE || stype == BSMESHLODTRISHAPE || stype == BSDYNAMICTRISHAPE); - bool isFO4 = (nif->GetHeader().GetUserVersion() >= 12 && nif->GetHeader().GetUserVersion2() == 130); unordered_map vertWeights; for (auto &boneName : shapeBoneList.second) { + SkinTransform xForm; if (AnimSkeleton::getInstance().GetBoneTransform(boneName, xForm)) nif->SetNodeTransform(boneName, xForm, true); @@ -311,7 +315,7 @@ void AnimInfo::WriteToNif(NifFile* nif, bool synchBoneIDs, const string& shapeEx } if (isBSShape) - for (auto vid : vertWeights) + for (auto &vid : vertWeights) nif->SetShapeVertWeights(shapeBoneList.first, vid.first, vid.second.boneIds, vid.second.weights); } diff --git a/src/components/Anim.h b/src/components/Anim.h index 7f1f11ee..6c643c02 100644 --- a/src/components/Anim.h +++ b/src/components/Anim.h @@ -15,24 +15,23 @@ struct VertexBoneWeights { vector boneIds; vector weights; - VertexBoneWeights() { - } + VertexBoneWeights() { } - void Add(byte inboneid, float inweight) { - if (inweight == 0) + void Add(const byte& inBoneId, const float& inWeight) { + if (inWeight == 0.0f) return; for (int i = 0; i < weights.size(); ++i) { - if (inweight < weights[i]) + if (inWeight < weights[i]) continue; - weights.insert(weights.begin() + i, inweight); - boneIds.insert(boneIds.begin() + i, inboneid); + weights.insert(weights.begin() + i, inWeight); + boneIds.insert(boneIds.begin() + i, inBoneId); return; } - weights.push_back(inweight); - boneIds.push_back(inboneid); + weights.push_back(inWeight); + boneIds.push_back(inBoneId); } }; @@ -76,19 +75,11 @@ class AnimWeight { BoundingSphere bounds; AnimWeight() {} - AnimWeight(NifFile* loadFromFile, const string& shape, int index) { + AnimWeight(NifFile* loadFromFile, const string& shape, const int& index) { loadFromFile->GetShapeBoneWeights(shape, index, weights); loadFromFile->GetShapeBoneTransform(shape, index, xform); loadFromFile->GetShapeBoneBounds(shape, index, bounds); } - - bool VertWeight(ushort queryVert, float& weight) { - if (weights.find(queryVert) != weights.end()) { - weight = weights[queryVert]; - return true; - } - return false; - } }; // Bone to weight list association. @@ -113,26 +104,18 @@ class AnimSkin { } } - void VertexBones(ushort queryvert, vector& outbones, vector& outWeights) { - float wresult; - for (auto &bw : boneWeights) { - if (bw.second.VertWeight(queryvert, wresult)) { - outbones.push_back(bw.first); - outWeights.push_back(wresult); - } - } - } - - void RemoveBone(int boneOrder) { - unordered_map bwtemp; + void RemoveBone(const int& boneOrder) { + unordered_map bwTemp; for (auto &bw : boneWeights) { if (bw.first > boneOrder) - bwtemp[bw.first - 1] = move(bw.second); + bwTemp[bw.first - 1] = move(bw.second); else if (bw.first < boneOrder) - bwtemp[bw.first] = move(bw.second); + bwTemp[bw.first] = move(bw.second); } + boneWeights.clear(); - for (auto &bw : bwtemp) + + for (auto &bw : bwTemp) boneWeights[bw.first] = move(bw.second); } }; diff --git a/src/files/NifBlock.cpp b/src/files/NifBlock.cpp index 14f8c309..923a59b4 100644 --- a/src/files/NifBlock.cpp +++ b/src/files/NifBlock.cpp @@ -147,7 +147,7 @@ void NiHeader::SetVersion(const byte& v1, const byte& v2, const byte& v3, const userVersion2 = userVer2; } -bool NiHeader::VerCheck(int v1, int v2, int v3, int v4, bool equal) { +bool NiHeader::VerCheck(const int& v1, const int& v2, const int& v3, const int& v4, const bool& equal) { if (equal) { if (version4 == v1 && version3 == v2 && version2 == v3 && version1 == v4) return true; @@ -560,7 +560,7 @@ string NiObjectNET::GetName() { return name; } -void NiObjectNET::SetName(const string& propertyName, bool renameExisting) { +void NiObjectNET::SetName(const string& propertyName, const bool& renameExisting) { if (renameExisting) header->SetStringById(nameRef, propertyName); else @@ -574,14 +574,14 @@ void NiObjectNET::ClearName() { name.clear(); } -int NiObjectNET::GetExtraDataRef(int id) { +int NiObjectNET::GetExtraDataRef(const int& id) { if (id >= 0 && id < numExtraData) return extraDataRef[id]; return 0xFFFFFFFF; } -void NiObjectNET::AddExtraDataRef(int id) { +void NiObjectNET::AddExtraDataRef(const int& id) { extraDataRef.push_back(id); numExtraData++; } @@ -871,14 +871,14 @@ int NiNode::CalcBlockSize() { return blockSize; } -int NiNode::GetChildRef(int id) { +int NiNode::GetChildRef(const int& id) { if (id >= 0 && id < numChildren) return children[id]; return 0xFFFFFFFF; } -void NiNode::AddChildRef(int id) { +void NiNode::AddChildRef(const int& id) { children.push_back(id); numChildren++; } @@ -888,14 +888,14 @@ void NiNode::ClearChildren() { numChildren = 0; } -int NiNode::GetEffectRef(int id) { +int NiNode::GetEffectRef(const int& id) { if (id >= 0 && id < numEffects) return effects[id]; return 0xFFFFFFFF; } -void NiNode::AddEffectRef(int id) { +void NiNode::AddEffectRef(const int& id) { effects.push_back(id); numEffects++; } @@ -973,7 +973,7 @@ void NiShape::SetAlphaPropertyRef(int alphaPropertyRef) { } int NiShape::GetDataRef() { return 0xFFFFFFFF; } void NiShape::SetDataRef(int dataRef) { } -void NiShape::SetVertices(bool enable) { +void NiShape::SetVertices(const bool& enable) { NiGeometryData* geomData = GetGeomData(); if (geomData) geomData->SetVertices(enable); @@ -987,7 +987,7 @@ bool NiShape::HasVertices() { return false; }; -void NiShape::SetUVs(bool enable) { +void NiShape::SetUVs(const bool& enable) { NiGeometryData* geomData = GetGeomData(); if (geomData) geomData->SetUVs(enable); @@ -1001,7 +1001,7 @@ bool NiShape::HasUVs() { return false; }; -void NiShape::SetNormals(bool enable) { +void NiShape::SetNormals(const bool& enable) { NiGeometryData* geomData = GetGeomData(); if (geomData) geomData->SetNormals(enable); @@ -1015,7 +1015,7 @@ bool NiShape::HasNormals() { return false; }; -void NiShape::SetTangents(bool enable) { +void NiShape::SetTangents(const bool& enable) { NiGeometryData* geomData = GetGeomData(); if (geomData) geomData->SetTangents(enable); @@ -1029,7 +1029,7 @@ bool NiShape::HasTangents() { return false; }; -void NiShape::SetVertexColors(bool enable) { +void NiShape::SetVertexColors(const bool& enable) { NiGeometryData* geomData = GetGeomData(); if (geomData) geomData->SetVertexColors(enable); @@ -1043,7 +1043,7 @@ bool NiShape::HasVertexColors() { return false; }; -void NiShape::SetSkinned(bool enable) { }; +void NiShape::SetSkinned(const bool& enable) { }; bool NiShape::IsSkinned() { return false; }; void NiShape::SetBounds(const BoundingSphere& bounds) { @@ -1623,7 +1623,7 @@ const vector* BSTriShape::GetUVData() { return &rawUvs; } -void BSTriShape::SetVertices(bool enable) { +void BSTriShape::SetVertices(const bool& enable) { if (enable) { vertFlags6 |= 1 << 4; vertData.resize(numVertices); @@ -1641,42 +1641,42 @@ void BSTriShape::SetVertices(bool enable) { } } -void BSTriShape::SetUVs(bool enable) { +void BSTriShape::SetUVs(const bool& enable) { if (enable) vertFlags6 |= 1 << 5; else vertFlags6 &= ~(1 << 5); } -void BSTriShape::SetNormals(bool enable) { +void BSTriShape::SetNormals(const bool& enable) { if (enable) vertFlags6 |= 1 << 7; else vertFlags6 &= ~(1 << 7); } -void BSTriShape::SetTangents(bool enable) { +void BSTriShape::SetTangents(const bool& enable) { if (enable) vertFlags7 |= 1 << 0; else vertFlags7 &= ~(1 << 0); } -void BSTriShape::SetVertexColors(bool enable) { +void BSTriShape::SetVertexColors(const bool& enable) { if (enable) vertFlags7 |= 1 << 1; else vertFlags7 &= ~(1 << 1); } -void BSTriShape::SetSkinned(bool enable) { +void BSTriShape::SetSkinned(const bool& enable) { if (enable) vertFlags7 |= 1 << 2; else vertFlags7 &= ~(1 << 2); } -void BSTriShape::SetFullPrecision(bool enable) { +void BSTriShape::SetFullPrecision(const bool& enable) { if (!CanChangePrecision()) return; @@ -2650,7 +2650,7 @@ void NiGeometryData::Put(fstream& file) { file.write((char*)&additionalData, 4); } -void NiGeometryData::SetVertices(bool enable) { +void NiGeometryData::SetVertices(const bool& enable) { hasVertices = enable; if (enable) { vertices.resize(numVertices); @@ -2666,7 +2666,7 @@ void NiGeometryData::SetVertices(bool enable) { } } -void NiGeometryData::SetNormals(bool enable) { +void NiGeometryData::SetNormals(const bool& enable) { hasNormals = enable; if (enable) normals.resize(numVertices); @@ -2674,7 +2674,7 @@ void NiGeometryData::SetNormals(bool enable) { normals.clear(); } -void NiGeometryData::SetVertexColors(bool enable) { +void NiGeometryData::SetVertexColors(const bool& enable) { hasVertexColors = enable; if (enable) vertexColors.resize(numVertices); @@ -2682,7 +2682,7 @@ void NiGeometryData::SetVertexColors(bool enable) { vertexColors.clear(); } -void NiGeometryData::SetUVs(bool enable) { +void NiGeometryData::SetUVs(const bool& enable) { if (enable) { numUVSets |= 1 << 0; uvSets.resize(numVertices); @@ -2693,7 +2693,7 @@ void NiGeometryData::SetUVs(bool enable) { } } -void NiGeometryData::SetTangents(bool enable) { +void NiGeometryData::SetTangents(const bool& enable) { if (enable) { numUVSets |= 1 << 12; tangents.resize(numVertices); @@ -5060,7 +5060,7 @@ bool NiShader::IsSkinned() { return false; } -void NiShader::SetSkinned(bool enable) { +void NiShader::SetSkinned(const bool& enable) { } bool NiShader::IsDoubleSided() { @@ -5099,7 +5099,7 @@ int NiShader::GetTextureSetRef() { return 0xFFFFFFFF; } -void NiShader::SetTextureSetRef(int texSetRef) { +void NiShader::SetTextureSetRef(const int& texSetRef) { } Color4 NiShader::GetEmissiveColor() { @@ -5478,7 +5478,7 @@ bool BSLightingShaderProperty::IsSkinned() { return (shaderFlags1 & (1 << 1)) != 0; } -void BSLightingShaderProperty::SetSkinned(bool enable) { +void BSLightingShaderProperty::SetSkinned(const bool& enable) { if (enable) shaderFlags1 |= 1 << 1; else @@ -5525,7 +5525,7 @@ int BSLightingShaderProperty::GetTextureSetRef() { return textureSetRef; } -void BSLightingShaderProperty::SetTextureSetRef(int texSetRef) { +void BSLightingShaderProperty::SetTextureSetRef(const int& texSetRef) { textureSetRef = texSetRef; } @@ -5791,7 +5791,7 @@ bool BSEffectShaderProperty::IsSkinned() { return (shaderFlags1 & (1 << 1)) != 0; } -void BSEffectShaderProperty::SetSkinned(bool enable) { +void BSEffectShaderProperty::SetSkinned(const bool& enable) { if (enable) shaderFlags1 |= 1 << 1; else @@ -5981,7 +5981,7 @@ bool BSShaderPPLightingProperty::IsSkinned() { return (shaderFlags & (1 << 1)) != 0; } -void BSShaderPPLightingProperty::SetSkinned(bool enable) { +void BSShaderPPLightingProperty::SetSkinned(const bool& enable) { if (enable) shaderFlags |= 1 << 1; else @@ -5992,7 +5992,7 @@ int BSShaderPPLightingProperty::GetTextureSetRef() { return textureSetRef; } -void BSShaderPPLightingProperty::SetTextureSetRef(int texSetRef) { +void BSShaderPPLightingProperty::SetTextureSetRef(const int& texSetRef) { textureSetRef = texSetRef; } @@ -6717,7 +6717,7 @@ BSClothExtraData::BSClothExtraData() { data.clear(); } -BSClothExtraData::BSClothExtraData(NiHeader& hdr, uint size) { +BSClothExtraData::BSClothExtraData(NiHeader& hdr, const uint& size) { BSExtraData::Init(); header = &hdr; @@ -6930,7 +6930,7 @@ bhkPhysicsSystem::bhkPhysicsSystem() { data.clear(); } -bhkPhysicsSystem::bhkPhysicsSystem(NiHeader& hdr, uint size) { +bhkPhysicsSystem::bhkPhysicsSystem(NiHeader& hdr, const uint& size) { BSExtraData::Init(); header = &hdr; @@ -6995,7 +6995,7 @@ NiUnknown::NiUnknown() { blockType = NIUNKNOWN; } -NiUnknown::NiUnknown(fstream& file, uint size) { +NiUnknown::NiUnknown(fstream& file, const uint& size) { NiObject::Init(); blockType = NIUNKNOWN; @@ -7005,7 +7005,7 @@ NiUnknown::NiUnknown(fstream& file, uint size) { Get(file); } -NiUnknown::NiUnknown(uint size) { +NiUnknown::NiUnknown(const uint& size) { NiObject::Init(); blockType = NIUNKNOWN; diff --git a/src/files/NifBlock.h b/src/files/NifBlock.h index ea511d5e..61d1851d 100644 --- a/src/files/NifBlock.h +++ b/src/files/NifBlock.h @@ -311,7 +311,7 @@ class NiHeader : public NiObject { string GetVersionInfo(); void SetVersion(const byte& v1, const byte& v2, const byte& v3, const byte& v4, const uint& userVer, const uint& userVer2); - bool VerCheck(int v1, int v2, int v3, int v4, bool equal = false); + bool VerCheck(const int& v1, const int& v2, const int& v3, const int& v4, const bool& equal = false); uint GetUserVersion() { return userVersion; }; uint GetUserVersion2() { return userVersion2; }; @@ -378,15 +378,15 @@ class NiObjectNET : public NiObject { void notifyStringDelete(int stringID); string GetName(); - void SetName(const string& propertyName, bool renameExisting = false); + void SetName(const string& propertyName, const bool& renameExisting = false); void ClearName(); int GetControllerRef() { return controllerRef; } void SetControllerRef(int controllerRef) { this->controllerRef = controllerRef; } int GetNumExtraData() { return numExtraData; } - int GetExtraDataRef(int id); - void AddExtraDataRef(int id); + int GetExtraDataRef(const int& id); + void AddExtraDataRef(const int& id); int CalcBlockSize(); }; @@ -473,15 +473,15 @@ class NiNode : public NiAVObject { int CalcBlockSize(); int GetNumChildren() { return numChildren; } - int GetChildRef(int id); - void AddChildRef(int id); + int GetChildRef(const int& id); + void AddChildRef(const int& id); void ClearChildren(); vector::iterator ChildrenBegin() { return children.begin(); } vector::iterator ChildrenEnd() { return children.end(); } int GetNumEffects() { return numEffects; } - int GetEffectRef(int id); - void AddEffectRef(int id); + int GetEffectRef(const int& id); + void AddEffectRef(const int& id); }; class BSFadeNode : public NiNode { @@ -531,19 +531,19 @@ class NiGeometryData : public NiObject { void notifyVerticesDelete(const vector& vertIndices); int CalcBlockSize(); - void SetVertices(bool enable); + void SetVertices(const bool& enable); bool HasVertices() { return hasVertices; } - void SetNormals(bool enable); + void SetNormals(const bool& enable); bool HasNormals() { return hasNormals; } - void SetVertexColors(bool enable); + void SetVertexColors(const bool& enable); bool HasVertexColors() { return hasVertexColors; } - void SetUVs(bool enable); + void SetUVs(const bool& enable); bool HasUVs() { return (numUVSets & (1 << 0)) != 0; } - void SetTangents(bool enable); + void SetTangents(const bool& enable); bool HasTangents() { return (numUVSets & (1 << 12)) != 0; } void SetBounds(const BoundingSphere& bounds) { this->bounds = bounds; } @@ -579,22 +579,22 @@ class NiShape : public NiAVObject { virtual int GetAlphaPropertyRef(); virtual void SetAlphaPropertyRef(int alphaPropertyRef); - virtual void SetVertices(bool enable); + virtual void SetVertices(const bool& enable); virtual bool HasVertices(); - virtual void SetUVs(bool enable); + virtual void SetUVs(const bool& enable); virtual bool HasUVs(); - virtual void SetNormals(bool enable); + virtual void SetNormals(const bool& enable); virtual bool HasNormals(); - virtual void SetTangents(bool enable); + virtual void SetTangents(const bool& enable); virtual bool HasTangents(); - virtual void SetVertexColors(bool enable); + virtual void SetVertexColors(const bool& enable); virtual bool HasVertexColors(); - virtual void SetSkinned(bool enable); + virtual void SetSkinned(const bool& enable); virtual bool IsSkinned(); virtual void SetBounds(const BoundingSphere& bounds); @@ -690,25 +690,25 @@ class BSTriShape : public NiShape { const vector* GetBitangentData(bool xform = true); const vector* GetUVData(); - void SetVertices(bool enable); + void SetVertices(const bool& enable); bool HasVertices() { return (vertFlags6 & (1 << 4)) != 0; } - void SetUVs(bool enable); + void SetUVs(const bool& enable); bool HasUVs() { return (vertFlags6 & (1 << 5)) != 0; } - void SetNormals(bool enable); + void SetNormals(const bool& enable); bool HasNormals() { return (vertFlags6 & (1 << 7)) != 0; } - void SetTangents(bool enable); + void SetTangents(const bool& enable); bool HasTangents() { return (vertFlags7 & (1 << 0)) != 0; } - void SetVertexColors(bool enable); + void SetVertexColors(const bool& enable); bool HasVertexColors() { return (vertFlags7 & (1 << 1)) != 0; } - void SetSkinned(bool enable); + void SetSkinned(const bool& enable); bool IsSkinned() { return (vertFlags7 & (1 << 2)) != 0; } - void SetFullPrecision(bool enable); + void SetFullPrecision(const bool& enable); bool IsFullPrecision() { return (vertFlags7 & (1 << 6)) != 0 || header->GetUserVersion2() == 100; } bool CanChangePrecision() { return (HasVertices() && HasTangents() && HasNormals() && header->GetUserVersion2() != 100); } @@ -993,13 +993,13 @@ class NiSkinInstance : public NiBoneContainer { int CalcBlockSize(); int GetDataRef() { return dataRef; } - void SetDataRef(int dataRef) { this->dataRef = dataRef; } + void SetDataRef(const int& dataRef) { this->dataRef = dataRef; } int GetSkinPartitionRef() { return skinPartitionRef; } - void SetSkinPartitionRef(int skinPartitionRef) { this->skinPartitionRef = skinPartitionRef; } + void SetSkinPartitionRef(const int& skinPartitionRef) { this->skinPartitionRef = skinPartitionRef; } int GetSkeletonRootRef() { return skeletonRootRef; } - void SetSkeletonRootRef(int skeletonRootRef) { this->skeletonRootRef = skeletonRootRef; } + void SetSkeletonRootRef(const int& skeletonRootRef) { this->skeletonRootRef = skeletonRootRef; } }; class BSDismemberSkinInstance : public NiSkinInstance { @@ -1057,10 +1057,10 @@ class BSSkinInstance : public NiBoneContainer { int CalcBlockSize(); int GetTargetRef() { return targetRef; } - void SetTargetRef(int targetRef) { this->targetRef = targetRef; } + void SetTargetRef(const int& targetRef) { this->targetRef = targetRef; } int GetDataRef() { return dataRef; } - void SetDataRef(int dataRef) { this->dataRef = dataRef; } + void SetDataRef(const int& dataRef) { this->dataRef = dataRef; } }; class BSSkinBoneData : public NiObject { @@ -1367,7 +1367,7 @@ class NiShader : public NiProperty { virtual bool IsSkinTint(); virtual bool IsSkinned(); - virtual void SetSkinned(bool enable); + virtual void SetSkinned(const bool& enable); virtual bool IsDoubleSided(); virtual uint GetType(); virtual void SetType(uint type); @@ -1378,7 +1378,7 @@ class NiShader : public NiProperty { virtual float GetGlossiness(); virtual void SetGlossiness(float gloss); virtual int GetTextureSetRef(); - virtual void SetTextureSetRef(int texSetRef); + virtual void SetTextureSetRef(const int& texSetRef); virtual Color4 GetEmissiveColor(); virtual void SetEmissiveColor(Color4 color); virtual float GetEmissiveMultiple(); @@ -1452,7 +1452,7 @@ class BSLightingShaderProperty : public NiShader { bool IsSkinTint(); bool IsSkinned(); - void SetSkinned(bool enable); + void SetSkinned(const bool& enable); bool IsDoubleSided(); uint GetType(); void SetType(uint type); @@ -1463,7 +1463,7 @@ class BSLightingShaderProperty : public NiShader { float GetGlossiness(); void SetGlossiness(float gloss); int GetTextureSetRef(); - void SetTextureSetRef(int texSetRef); + void SetTextureSetRef(const int& texSetRef); Color4 GetEmissiveColor(); void SetEmissiveColor(Color4 color); float GetEmissiveMultiple(); @@ -1526,7 +1526,7 @@ class BSEffectShaderProperty : public NiShader { bool IsSkinTint(); bool IsSkinned(); - void SetSkinned(bool enable); + void SetSkinned(const bool& enable); bool IsDoubleSided(); Color4 GetEmissiveColor(); void SetEmissiveColor(Color4 color); @@ -1568,9 +1568,9 @@ class BSShaderPPLightingProperty : public BSShaderLightingProperty { bool IsSkinTint(); bool IsSkinned(); - void SetSkinned(bool enable); + void SetSkinned(const bool& enable); int GetTextureSetRef(); - void SetTextureSetRef(int texSetRef); + void SetTextureSetRef(const int& texSetRef); }; class BSShaderTextureSet : public NiObject { @@ -1797,7 +1797,7 @@ class BSClothExtraData : public BSExtraData { vector data; BSClothExtraData(); - BSClothExtraData(NiHeader& hdr, uint size = 0); + BSClothExtraData(NiHeader& hdr, const uint& size = 0); BSClothExtraData(fstream& file, NiHeader& hdr); void Get(fstream& file); @@ -1862,7 +1862,7 @@ class bhkPhysicsSystem : public BSExtraData { vector data; bhkPhysicsSystem(); - bhkPhysicsSystem(NiHeader& hdr, uint size = 0); + bhkPhysicsSystem(NiHeader& hdr, const uint& size = 0); bhkPhysicsSystem(fstream& file, NiHeader& hdr); void Get(fstream& file); @@ -1877,8 +1877,8 @@ class NiUnknown : public NiObject { vector data; NiUnknown(); - NiUnknown(fstream& file, uint size); - NiUnknown(uint size); + NiUnknown(fstream& file, const uint& size); + NiUnknown(const uint& size); void Get(fstream& file); void Put(fstream& file); diff --git a/src/files/NifFile.cpp b/src/files/NifFile.cpp index 0fd4b1a2..b82ffe04 100644 --- a/src/files/NifFile.cpp +++ b/src/files/NifFile.cpp @@ -492,7 +492,7 @@ void NifFile::DeleteNode(const string& nodeName) { hdr.DeleteBlock(GetBlockID(FindNodeByName(nodeName))); } -string NifFile::GetNodeName(int blockID) { +string NifFile::GetNodeName(const int& blockID) { string name; auto n = hdr.GetBlock(blockID); @@ -505,7 +505,7 @@ string NifFile::GetNodeName(int blockID) { return name; } -void NifFile::SetNodeName(int blockID, const string& newName) { +void NifFile::SetNodeName(const int& blockID, const string& newName) { auto node = hdr.GetBlock(blockID); if (!node) return; @@ -1325,7 +1325,7 @@ void NifFile::SetShapeBoneIDList(const string& shapeName, vector& inList) { } } -int NifFile::GetShapeBoneWeights(const string& shapeName, int boneIndex, unordered_map& outWeights) { +int NifFile::GetShapeBoneWeights(const string& shapeName, const int& boneIndex, unordered_map& outWeights) { outWeights.clear(); NiShape* shape = FindShapeByName(shapeName); @@ -1376,7 +1376,7 @@ bool NifFile::GetShapeBoneTransform(const string& shapeName, const string& boneN return GetShapeBoneTransform(shapeName, boneIndex, outXform); } -bool NifFile::SetShapeBoneTransform(const string& shapeName, int boneIndex, SkinTransform& inXform) { +bool NifFile::SetShapeBoneTransform(const string& shapeName, const int& boneIndex, SkinTransform& inXform) { NiShape* shape = FindShapeByName(shapeName); if (!shape) return false; @@ -1413,7 +1413,7 @@ bool NifFile::SetShapeBoneTransform(const string& shapeName, int boneIndex, Skin return true; } -bool NifFile::SetShapeBoneBounds(const string& shapeName, int boneIndex, BoundingSphere& inBounds) { +bool NifFile::SetShapeBoneBounds(const string& shapeName, const int& boneIndex, BoundingSphere& inBounds) { NiShape* shape = FindShapeByName(shapeName); if (!shape) return false; @@ -1444,7 +1444,7 @@ bool NifFile::SetShapeBoneBounds(const string& shapeName, int boneIndex, Boundin return true; } -bool NifFile::GetShapeBoneTransform(const string& shapeName, int boneIndex, SkinTransform& outXform) { +bool NifFile::GetShapeBoneTransform(const string& shapeName, const int& boneIndex, SkinTransform& outXform) { NiShape* shape = FindShapeByName(shapeName); if (!shape) return false; @@ -1485,7 +1485,7 @@ bool NifFile::GetShapeBoneTransform(const string& shapeName, int boneIndex, Skin return true; } -bool NifFile::GetShapeBoneBounds(const string& shapeName, int boneIndex, BoundingSphere& outBounds) { +bool NifFile::GetShapeBoneBounds(const string& shapeName, const int& boneIndex, BoundingSphere& outBounds) { NiShape* shape = FindShapeByName(shapeName); if (!shape) return false; @@ -1515,7 +1515,7 @@ bool NifFile::GetShapeBoneBounds(const string& shapeName, int boneIndex, Boundin return true; } -void NifFile::UpdateShapeBoneID(const string& shapeName, int oldID, int newID) { +void NifFile::UpdateShapeBoneID(const string& shapeName, const int& oldID, const int& newID) { NiShape* shape = FindShapeByName(shapeName); if (!shape) return; @@ -1533,7 +1533,7 @@ void NifFile::UpdateShapeBoneID(const string& shapeName, int oldID, int newID) { } // Not implemented for BSTriShape, use SetShapeVertWeights instead -void NifFile::SetShapeBoneWeights(const string& shapeName, int boneIndex, unordered_map& inWeights) { +void NifFile::SetShapeBoneWeights(const string& shapeName, const int& boneIndex, unordered_map& inWeights) { NiShape* shape = FindShapeByName(shapeName); if (!shape) return; @@ -1558,7 +1558,7 @@ void NifFile::SetShapeBoneWeights(const string& shapeName, int boneIndex, unorde bone->numVertices = (ushort)bone->vertexWeights.size(); } -void NifFile::SetShapeVertWeights(const string& shapeName, int vertIndex, vector& boneids, vector& weights) { +void NifFile::SetShapeVertWeights(const string& shapeName, const int& vertIndex, vector& boneids, vector& weights) { NiShape* shape = FindShapeByName(shapeName); if (!shape) return; diff --git a/src/files/NifFile.h b/src/files/NifFile.h index fe69fbac..f1a7cb1d 100644 --- a/src/files/NifFile.h +++ b/src/files/NifFile.h @@ -29,8 +29,8 @@ class NifFile { int AddNode(const string& nodeName, vector& rot, Vector3& trans, float scale); void DeleteNode(const string& nodeName); - string GetNodeName(int blockID); - void SetNodeName(int blockID, const string& newName); + string GetNodeName(const int& blockID); + void SetNodeName(const int& blockID, const string& newName); int AssignExtraData(const string& blockName, const int& extraDataId, bool isNode); int AddStringExtraData(const string& blockName, const string& name, const string& stringData, bool isNode = false); @@ -88,19 +88,19 @@ class NifFile { int GetShapeBoneList(const string& shapeName, vector& outList); int GetShapeBoneIDList(const string& shapeName, vector& outList); void SetShapeBoneIDList(const string& shapeName, vector& inList); - int GetShapeBoneWeights(const string& shapeName, int boneIndex, unordered_map& outWeights); + int GetShapeBoneWeights(const string& shapeName, const int& boneIndex, unordered_map& outWeights); // Empty string for the bone name returns the overall skin transform for the shape. bool GetShapeBoneTransform(const string& shapeName, const string& boneName, SkinTransform& outXform); // 0xFFFFFFFF for the bone index sets the overall skin transform for the shape. - bool SetShapeBoneTransform(const string& shapeName, int boneIndex, SkinTransform& inXform); - bool SetShapeBoneBounds(const string& shapeName, int boneIndex, BoundingSphere& inBounds); + bool SetShapeBoneTransform(const string& shapeName, const int& boneIndex, SkinTransform& inXform); + bool SetShapeBoneBounds(const string& shapeName, const int& boneIndex, BoundingSphere& inBounds); // 0xFFFFFFFF on the bone index returns the overall skin transform for the shape. - bool GetShapeBoneTransform(const string& shapeName, int boneIndex, SkinTransform& outXform); - bool GetShapeBoneBounds(const string& shapeName, int boneIndex, BoundingSphere& outBounds); - void UpdateShapeBoneID(const string& shapeName, int oldID, int newID); - void SetShapeBoneWeights(const string& shapeName, int boneIndex, unordered_map& inWeights); - void SetShapeVertWeights(const string& shapeName, int vertIndex, vector& boneids, vector& weights); + bool GetShapeBoneTransform(const string& shapeName, const int& boneIndex, SkinTransform& outXform); + bool GetShapeBoneBounds(const string& shapeName, const int& boneIndex, BoundingSphere& outBounds); + void UpdateShapeBoneID(const string& shapeName, const int& oldID, const int& newID); + void SetShapeBoneWeights(const string& shapeName, const int& boneIndex, unordered_map& inWeights); + void SetShapeVertWeights(const string& shapeName, const int& vertIndex, vector& boneids, vector& weights); bool GetShapeSegments(const string& shapeName, BSSubIndexTriShape::BSSITSSegmentation& segmentation); void SetShapeSegments(const string& shapeName, const BSSubIndexTriShape::BSSITSSegmentation& segmentation);