From 2619d57bb6afc5c31bf1a90b8c033d66f29a9a58 Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Tue, 28 Oct 2014 04:50:28 -0400 Subject: [PATCH] Converted most nifstream "get multiple" functions to the templated version --- components/nif/data.hpp | 16 ++++++++-------- components/nif/nifstream.cpp | 37 ------------------------------------ components/nif/nifstream.hpp | 7 ------- 3 files changed, 8 insertions(+), 52 deletions(-) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index d9de12fb5..e6d3370be 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -44,16 +44,16 @@ public: int verts = nif->getUShort(); if(nif->getInt()) - nif->getVector3s(vertices, verts); + vertices = nif->getItems(verts); if(nif->getInt()) - nif->getVector3s(normals, verts); + normals = nif->getItems(verts); center = nif->getVector3(); radius = nif->getFloat(); if(nif->getInt()) - nif->getVector4s(colors, verts); + colors = nif->getItems(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(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(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(vertices.size()); } } }; @@ -140,7 +140,7 @@ public: if(nif->getInt()) { // Rotation quaternions. - nif->getQuaternions(rotations, vertices.size()); + rotations = nif->getItems(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(vertCount); } } }; diff --git a/components/nif/nifstream.cpp b/components/nif/nifstream.cpp index 4464c8af5..9eeee6a12 100644 --- a/components/nif/nifstream.cpp +++ b/components/nif/nifstream.cpp @@ -106,43 +106,6 @@ std::string NIFStream::getVersionString() return inp->getLine(); } -void NIFStream::getShorts(std::vector &vec, size_t size) -{ - vec.resize(size); - for(size_t i = 0;i < vec.size();i++) - vec[i] = getShort(); -} -void NIFStream::getFloats(std::vector &vec, size_t size) -{ - vec.resize(size); - for(size_t i = 0;i < vec.size();i++) - vec[i] = getFloat(); -} -void NIFStream::getVector2s(std::vector &vec, size_t size) -{ - vec.resize(size); - for(size_t i = 0;i < vec.size();i++) - vec[i] = getVector2(); -} -void NIFStream::getVector3s(std::vector &vec, size_t size) -{ - vec.resize(size); - for(size_t i = 0;i < vec.size();i++) - vec[i] = getVector3(); -} -void NIFStream::getVector4s(std::vector &vec, size_t size) -{ - vec.resize(size); - for(size_t i = 0;i < vec.size();i++) - vec[i] = getVector4(); -} -void NIFStream::getQuaternions(std::vector &quat, size_t size) -{ - quat.resize(size); - for(size_t i = 0;i < quat.size();i++) - quat[i] = getQuaternion(); -} - template <> char NIFStream::get(){ return getChar(); } template <> diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index 083147867..b9caa1536 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -88,13 +88,6 @@ public: template T get(){throw std::runtime_error("Can not get this type of data from a NIF File!");} - void getShorts(std::vector &vec, size_t size); - void getFloats(std::vector &vec, size_t size); - void getVector2s(std::vector &vec, size_t size); - void getVector3s(std::vector &vec, size_t size); - void getVector4s(std::vector &vec, size_t size); - void getQuaternions(std::vector &quat, size_t size); - ///Return a vector of whatever object is needed template std::vector getItems(size_t number_of_items)