Phase out NIFStream::get[Types]

macos_ci_fix
Alexei Kotov 1 year ago
parent e7bbfed1fd
commit 57144accf6

@ -55,7 +55,7 @@ namespace Nif
nif->skip(2); // Keep flags and compress flags
if (nif->getBoolean())
nif->getVector3s(vertices, verts);
nif->readVector(vertices, verts);
unsigned int dataFlags = 0;
if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0))
@ -67,11 +67,11 @@ namespace Nif
if (nif->getBoolean())
{
nif->getVector3s(normals, verts);
nif->readVector(normals, verts);
if (dataFlags & 0x1000)
{
nif->getVector3s(tangents, verts);
nif->getVector3s(bitangents, verts);
nif->readVector(tangents, verts);
nif->readVector(bitangents, verts);
}
}
@ -79,7 +79,7 @@ namespace Nif
radius = nif->getFloat();
if (nif->getBoolean())
nif->getVector4s(colors, verts);
nif->readVector(colors, verts);
unsigned int numUVs = dataFlags;
if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0))
@ -102,7 +102,7 @@ namespace Nif
uvlist.resize(numUVs);
for (unsigned int i = 0; i < numUVs; i++)
{
nif->getVector2s(uvlist[i], verts);
nif->readVector(uvlist[i], verts);
// flip the texture coordinates to convert them to the OpenGL convention of bottom-left image origin
for (unsigned int uv = 0; uv < uvlist[i].size(); ++uv)
{
@ -135,7 +135,7 @@ namespace Nif
if (nif->getVersion() > NIFFile::NIFVersion::VER_OB_OLD)
hasTriangles = nif->getBoolean();
if (hasTriangles)
nif->getUShorts(triangles, cnt);
nif->readVector(triangles, cnt);
// Read the match list, which lists the vertices that are equal to
// vertices. We don't actually need need this for anything, so
@ -157,7 +157,7 @@ namespace Nif
int numStrips = nif->getUShort();
std::vector<unsigned short> lengths;
nif->getUShorts(lengths, numStrips);
nif->readVector(lengths, numStrips);
// "Has Strips" flag. Exceptionally useful.
bool hasStrips = true;
@ -168,15 +168,15 @@ namespace Nif
strips.resize(numStrips);
for (int i = 0; i < numStrips; i++)
nif->getUShorts(strips[i], lengths[i]);
nif->readVector(strips[i], lengths[i]);
}
void NiLinesData::read(NIFStream* nif)
{
NiGeometryData::read(nif);
size_t num = vertices.size();
std::vector<char> flags;
nif->getChars(flags, num);
std::vector<uint8_t> flags;
nif->readVector(flags, num);
// Can't construct a line from a single vertex.
if (num < 2)
return;
@ -208,21 +208,21 @@ namespace Nif
if (nif->getVersion() <= NIFStream::generateVersion(10, 0, 1, 0))
std::fill(particleRadii.begin(), particleRadii.end(), nif->getFloat());
else if (nif->getBoolean())
nif->getFloats(particleRadii, vertices.size());
nif->readVector(particleRadii, vertices.size());
activeCount = nif->getUShort();
// Particle sizes
if (nif->getBoolean())
nif->getFloats(sizes, vertices.size());
nif->readVector(sizes, vertices.size());
if (nif->getVersion() >= NIFStream::generateVersion(10, 0, 1, 0) && nif->getBoolean())
nif->getQuaternions(rotations, vertices.size());
nif->readVector(rotations, vertices.size());
if (nif->getVersion() >= NIFStream::generateVersion(20, 0, 0, 4))
{
if (nif->getBoolean())
nif->getFloats(rotationAngles, vertices.size());
nif->readVector(rotationAngles, vertices.size());
if (nif->getBoolean())
nif->getVector3s(rotationAxes, vertices.size());
nif->readVector(rotationAxes, vertices.size());
}
}
@ -231,7 +231,7 @@ namespace Nif
NiParticlesData::read(nif);
if (nif->getVersion() <= NIFStream::generateVersion(4, 2, 2, 0) && nif->getBoolean())
nif->getQuaternions(rotations, vertices.size());
nif->readVector(rotations, vertices.size());
}
void NiPosData::read(NIFStream* nif)
@ -301,8 +301,7 @@ namespace Nif
unsigned int numPixels = nif->getUInt();
bool hasFaces = nif->getVersion() >= NIFStream::generateVersion(10, 4, 0, 2);
unsigned int numFaces = hasFaces ? nif->getUInt() : 1;
if (numPixels && numFaces)
nif->getUChars(data, numPixels * numFaces);
nif->readVector(data, numPixels * numFaces);
}
void NiPixelData::post(Reader& nif)
@ -397,24 +396,22 @@ namespace Nif
size_t numBones = nif->getUShort();
size_t numStrips = nif->getUShort();
size_t bonesPerVertex = nif->getUShort();
if (numBones)
nif->getUShorts(bones, numBones);
nif->readVector(bones, numBones);
bool hasVertexMap = true;
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
hasVertexMap = nif->getBoolean();
if (hasVertexMap && numVertices)
nif->getUShorts(vertexMap, numVertices);
if (hasVertexMap)
nif->readVector(vertexMap, numVertices);
bool hasVertexWeights = true;
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
hasVertexWeights = nif->getBoolean();
if (hasVertexWeights && numVertices && bonesPerVertex)
nif->getFloats(weights, numVertices * bonesPerVertex);
if (hasVertexWeights)
nif->readVector(weights, numVertices * bonesPerVertex);
std::vector<unsigned short> stripLengths;
if (numStrips)
nif->getUShorts(stripLengths, numStrips);
nif->readVector(stripLengths, numStrips);
bool hasFaces = true;
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
@ -425,14 +422,14 @@ namespace Nif
{
strips.resize(numStrips);
for (size_t i = 0; i < numStrips; i++)
nif->getUShorts(strips[i], stripLengths[i]);
nif->readVector(strips[i], stripLengths[i]);
}
else if (numTriangles)
nif->getUShorts(triangles, numTriangles * 3);
else
nif->readVector(triangles, numTriangles * 3);
}
bool hasBoneIndices = nif->getChar() != 0;
if (hasBoneIndices && numVertices && bonesPerVertex)
nif->getChars(boneIndices, numVertices * bonesPerVertex);
if (hasBoneIndices)
nif->readVector(boneIndices, numVertices * bonesPerVertex);
if (nif->getBethVersion() > NIFFile::BethVersion::BETHVER_FO3)
{
nif->getChar(); // LOD level
@ -490,7 +487,7 @@ namespace Nif
{
mMorphs[i].mKeyFrames = std::make_shared<FloatKeyMap>();
mMorphs[i].mKeyFrames->read(nif, /*morph*/ true);
nif->getVector3s(mMorphs[i].mVertices, vertCount);
nif->readVector(mMorphs[i].mVertices, vertCount);
}
}

@ -6,8 +6,7 @@ namespace Nif
void NiExtraData::read(NIFStream* nif)
{
Extra::read(nif);
if (recordSize)
nif->getChars(data, recordSize);
nif->readVector(data, recordSize);
}
void NiStringExtraData::read(NIFStream* nif)
@ -47,17 +46,13 @@ namespace Nif
{
Extra::read(nif);
unsigned int num = nif->getUInt();
if (num)
nif->getUInts(data, num);
nif->readVector(data, nif->getUInt());
}
void NiBinaryExtraData::read(NIFStream* nif)
{
Extra::read(nif);
unsigned int size = nif->getUInt();
if (size)
nif->getChars(data, size);
nif->readVector(data, nif->getUInt());
}
void NiBooleanExtraData::read(NIFStream* nif)
@ -82,9 +77,7 @@ namespace Nif
void NiFloatsExtraData::read(NIFStream* nif)
{
Extra::read(nif);
unsigned int num = nif->getUInt();
if (num)
nif->getFloats(data, num);
nif->readVector(data, nif->getUInt());
}
void BSBound::read(NIFStream* nif)

@ -319,28 +319,26 @@ namespace Nif
if (hasRecTypeListings)
{
unsigned short recTypeNum = nif.getUShort();
if (recTypeNum) // Record type list
nif.getSizedStrings(recTypes, recTypeNum);
if (recNum) // Record type mapping for each record
nif.getUShorts(recTypeIndices, recNum);
// Record type list
nif.getSizedStrings(recTypes, recTypeNum);
// Record type mapping for each record
nif.readVector(recTypeIndices, recNum);
if (ver >= NIFStream::generateVersion(5, 0, 0, 6)) // Groups
{
if (ver >= NIFStream::generateVersion(20, 1, 0, 1)) // String table
{
if (ver >= NIFStream::generateVersion(20, 2, 0, 5) && recNum) // Record sizes
if (ver >= NIFStream::generateVersion(20, 2, 0, 5)) // Record sizes
{
std::vector<unsigned int> recSizes; // Currently unused
nif.getUInts(recSizes, recNum);
nif.readVector(recSizes, recNum);
}
const std::size_t stringNum = nif.getUInt();
nif.getUInt(); // Max string length
if (stringNum)
nif.getSizedStrings(strings, stringNum);
nif.getSizedStrings(strings, stringNum);
}
std::vector<unsigned int> groups; // Currently unused
unsigned int groupNum = nif.getUInt();
if (groupNum)
nif.getUInts(groups, groupNum);
nif.readVector(groups, groupNum);
}
}

@ -155,19 +155,6 @@ namespace Nif
Transformation getTrafo() { return get<Transformation>(); }
bool getBoolean() { return get<bool>(); }
std::string getString() { return get<std::string>(); }
/// DEPRECATED: Use readVector()
void getChars(std::vector<char>& vec, size_t size) { readVector(vec, size); }
void getUChars(std::vector<unsigned char>& vec, size_t size) { readVector(vec, size); }
void getUShorts(std::vector<unsigned short>& vec, size_t size) { readVector(vec, size); }
void getFloats(std::vector<float>& vec, size_t size) { readVector(vec, size); }
void getInts(std::vector<int>& vec, size_t size) { readVector(vec, size); }
void getUInts(std::vector<unsigned int>& vec, size_t size) { readVector(vec, size); }
void getVector2s(std::vector<osg::Vec2f>& vec, size_t size) { readVector(vec, size); }
void getVector3s(std::vector<osg::Vec3f>& vec, size_t size) { readVector(vec, size); }
void getVector4s(std::vector<osg::Vec4f>& vec, size_t size) { readVector(vec, size); }
void getQuaternions(std::vector<osg::Quat>& vec, size_t size) { readVector(vec, size); }
void getStrings(std::vector<std::string>& vec, size_t size) { readVector(vec, size); }
};
template <>

@ -157,11 +157,9 @@ namespace Nif
num = nif->getBoolean(); // Has Shader
else if (nif->getVersion() >= NIFStream::generateVersion(20, 2, 0, 5))
num = nif->getUInt();
if (num)
{
nif->getStrings(names, num);
nif->getInts(extra, num);
}
nif->readVector(names, num);
nif->readVector(extra, num);
if (nif->getVersion() >= NIFStream::generateVersion(20, 2, 0, 5))
active = nif->getUInt();
if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS)
@ -377,10 +375,7 @@ namespace Nif
}
if (mDataSize > 0)
{
mTriangles.resize(triNum * 3);
nif->readVector(mTriangles, triNum * 3);
}
if (nif->getBethVersion() == NIFFile::BethVersion::BETHVER_SSE)
{

@ -53,8 +53,7 @@ namespace Nif
mOffset = nif->getVector4();
if (nif->getBethVersion() > NIFFile::BethVersion::BETHVER_FO3)
nif->getChar(); // MOPP data build type
if (size)
nif->getChars(mData, size);
nif->readVector(mData, size);
}
void bhkEntityCInfo::read(NIFStream* nif)
@ -99,18 +98,10 @@ namespace Nif
mMaterialIndex = nif->getUInt();
mReference = nif->getUShort();
mTransformIndex = nif->getUShort();
size_t numVertices = nif->getUInt();
if (numVertices)
nif->getUShorts(mVertices, numVertices);
size_t numIndices = nif->getUInt();
if (numIndices)
nif->getUShorts(mIndices, numIndices);
size_t numStrips = nif->getUInt();
if (numStrips)
nif->getUShorts(mStrips, numStrips);
size_t numInfos = nif->getUInt();
if (numInfos)
nif->getUShorts(mWeldingInfos, numInfos);
nif->readVector(mVertices, nif->getUInt());
nif->readVector(mIndices, nif->getUInt());
nif->readVector(mStrips, nif->getUInt());
nif->readVector(mWeldingInfos, nif->getUInt());
}
void bhkRigidBodyCInfo::read(NIFStream* nif)
@ -395,8 +386,7 @@ namespace Nif
if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
mScale = nif->getVector4();
readRecordList(nif, mData);
unsigned int numFilters = nif->getUInt();
nif->getUInts(mFilters, numFilters);
nif->readVector(mFilters, nif->getUInt());
}
void bhkNiTriStripsShape::post(Reader& nif)
@ -438,7 +428,7 @@ namespace Nif
if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS)
compressed = nif->getBoolean();
if (!compressed)
nif->getVector3s(mVertices, numVertices);
nif->readVector(mVertices, numVertices);
else
nif->skip(6 * numVertices); // Half-precision vectors are not currently supported
if (nif->getVersion() >= NIFFile::NIFVersion::VER_BGS)
@ -465,12 +455,8 @@ namespace Nif
bhkConvexShape::read(nif);
mVerticesProperty.read(nif);
mNormalsProperty.read(nif);
unsigned int numVertices = nif->getUInt();
if (numVertices)
nif->getVector4s(mVertices, numVertices);
unsigned int numNormals = nif->getUInt();
if (numNormals)
nif->getVector4s(mNormals, numNormals);
nif->readVector(mVertices, nif->getUInt());
nif->readVector(mNormals, nif->getUInt());
}
void bhkConvexTransformShape::read(NIFStream* nif)
@ -564,9 +550,7 @@ namespace Nif
for (bhkQsTransform& transform : mChunkTransforms)
transform.read(nif);
size_t numBigVertices = nif->getUInt();
if (numBigVertices)
nif->getVector4s(mBigVerts, numBigVertices);
nif->readVector(mBigVerts, nif->getUInt());
size_t numBigTriangles = nif->getUInt();
mBigTris.resize(numBigTriangles);

Loading…
Cancel
Save