Converted most nifstream "get multiple" functions to the templated version

moveref
Arthur Moore 10 years ago
parent f318ee0b8c
commit 2619d57bb6

@ -44,16 +44,16 @@ public:
int verts = nif->getUShort();
if(nif->getInt())
nif->getVector3s(vertices, verts);
vertices = nif->getItems<Ogre::Vector3>(verts);
if(nif->getInt())
nif->getVector3s(normals, verts);
normals = nif->getItems<Ogre::Vector3>(verts);
center = nif->getVector3();
radius = nif->getFloat();
if(nif->getInt())
nif->getVector4s(colors, verts);
colors = nif->getItems<Ogre::Vector4>(verts);
// Only the first 6 bits are used as a count. I think the rest are
// flags of some sort.
@ -64,7 +64,7 @@ public:
{
uvlist.resize(uvs);
for(int i = 0;i < uvs;i++)
nif->getVector2s(uvlist[i], verts);
uvlist[i] = nif->getItems<Ogre::Vector2>(verts);
}
}
};
@ -84,7 +84,7 @@ public:
// We have three times as many vertices as triangles, so this
// is always equal to tris*3.
int cnt = nif->getInt();
nif->getShorts(triangles, cnt);
triangles = nif->getItems<short>(cnt);
// Read the match list, which lists the vertices that are equal to
// vertices. We don't actually need need this for anything, so
@ -123,7 +123,7 @@ public:
if(nif->getInt())
{
// Particle sizes
nif->getFloats(sizes, vertices.size());
sizes = nif->getItems<float>(vertices.size());
}
}
};
@ -140,7 +140,7 @@ public:
if(nif->getInt())
{
// Rotation quaternions.
nif->getQuaternions(rotations, vertices.size());
rotations = nif->getItems<Ogre::Quaternion>(vertices.size());
}
}
};
@ -341,7 +341,7 @@ struct NiMorphData : public Record
for(int i = 0;i < morphCount;i++)
{
mMorphs[i].mData.read(nif, true);
nif->getVector3s(mMorphs[i].mVertices, vertCount);
mMorphs[i].mVertices = nif->getItems<Ogre::Vector3>(vertCount);
}
}
};

@ -106,43 +106,6 @@ std::string NIFStream::getVersionString()
return inp->getLine();
}
void NIFStream::getShorts(std::vector<short> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getShort();
}
void NIFStream::getFloats(std::vector<float> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getFloat();
}
void NIFStream::getVector2s(std::vector<Ogre::Vector2> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector2();
}
void NIFStream::getVector3s(std::vector<Ogre::Vector3> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector3();
}
void NIFStream::getVector4s(std::vector<Ogre::Vector4> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector4();
}
void NIFStream::getQuaternions(std::vector<Ogre::Quaternion> &quat, size_t size)
{
quat.resize(size);
for(size_t i = 0;i < quat.size();i++)
quat[i] = getQuaternion();
}
template <>
char NIFStream::get<char>(){ return getChar(); }
template <>

@ -88,13 +88,6 @@ public:
template <typename T>
T get(){throw std::runtime_error("Can not get this type of data from a NIF File!");}
void getShorts(std::vector<short> &vec, size_t size);
void getFloats(std::vector<float> &vec, size_t size);
void getVector2s(std::vector<Ogre::Vector2> &vec, size_t size);
void getVector3s(std::vector<Ogre::Vector3> &vec, size_t size);
void getVector4s(std::vector<Ogre::Vector4> &vec, size_t size);
void getQuaternions(std::vector<Ogre::Quaternion> &quat, size_t size);
///Return a vector of whatever object is needed
template <typename T>
std::vector<T> getItems(size_t number_of_items)

Loading…
Cancel
Save