Revert "components/nif/base.hpp now uses the templated get() function"

This reverts commit ad609bff78.

Revert "Made incorrect nif get error message more informative."

This reverts commit 9909c4abad.

Revert "Build the nif file tester by default"

This reverts commit c1315ed90c.

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

This reverts commit 2619d57bb6.

Revert "Add a templated option for getting vectors to NIFStream"

This reverts commit f318ee0b8c.

Revert "Made NIFStream getters templated"

This reverts commit 4edc4142f3.
openmw-35
scrawl 10 years ago
parent 31f6ccdf4d
commit c6c7d102d0

@ -82,7 +82,7 @@ option(BUILD_OPENCS "build OpenMW Construction Set" ON)
option(BUILD_WIZARD "build Installation Wizard" ON) option(BUILD_WIZARD "build Installation Wizard" ON)
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF) option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest and GMock frameworks" OFF) option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest and GMock frameworks" OFF)
option(BUILD_NIFTEST "build nif file tester" ON) option(BUILD_NIFTEST "build nif file tester" OFF)
option(BUILD_MYGUI_PLUGIN "build MyGUI plugin for OpenMW resources, to use with MyGUI tools" ON) option(BUILD_MYGUI_PLUGIN "build MyGUI plugin for OpenMW resources, to use with MyGUI tools" ON)
# OS X deployment # OS X deployment

@ -36,12 +36,12 @@ public:
{ {
next.read(nif); next.read(nif);
flags = nif->get<unsigned short>(); flags = nif->getUShort();
frequency = nif->get<float>(); frequency = nif->getFloat();
phase = nif->get<float>(); phase = nif->getFloat();
timeStart = nif->get<float>(); timeStart = nif->getFloat();
timeStop = nif->get<float>(); timeStop = nif->getFloat();
target.read(nif); target.read(nif);
} }
@ -81,7 +81,7 @@ public:
void read(NIFStream *nif) void read(NIFStream *nif)
{ {
name = nif->get<std::string>(); name = nif->getString();
Controlled::read(nif); Controlled::read(nif);
} }
}; };

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

@ -106,33 +106,41 @@ std::string NIFStream::getVersionString()
return inp->getLine(); return inp->getLine();
} }
template <> void NIFStream::getShorts(std::vector<short> &vec, size_t size)
char NIFStream::get<char>(){ return getChar(); } {
template <> vec.resize(size);
short NIFStream::get<short>(){ return getShort(); } for(size_t i = 0;i < vec.size();i++)
template <> vec[i] = getShort();
unsigned short NIFStream::get<unsigned short>(){ return getUShort(); } }
template <> void NIFStream::getFloats(std::vector<float> &vec, size_t size)
int NIFStream::get<int>(){ return getInt(); } {
template <> vec.resize(size);
unsigned int NIFStream::get<unsigned int>(){ return getUInt(); } for(size_t i = 0;i < vec.size();i++)
template <> vec[i] = getFloat();
float NIFStream::get<float>(){ return getFloat(); } }
void NIFStream::getVector2s(std::vector<Ogre::Vector2> &vec, size_t size)
template <> {
Ogre::Vector2 NIFStream::get<Ogre::Vector2>(){ return getVector2(); } vec.resize(size);
template <> for(size_t i = 0;i < vec.size();i++)
Ogre::Vector3 NIFStream::get<Ogre::Vector3>(){ return getVector3(); } vec[i] = getVector2();
template <> }
Ogre::Vector4 NIFStream::get<Ogre::Vector4>(){ return getVector4(); } void NIFStream::getVector3s(std::vector<Ogre::Vector3> &vec, size_t size)
template <> {
Ogre::Matrix3 NIFStream::get<Ogre::Matrix3>(){ return getMatrix3(); } vec.resize(size);
template <> for(size_t i = 0;i < vec.size();i++)
Ogre::Quaternion NIFStream::get<Ogre::Quaternion>(){ return getQuaternion(); } vec[i] = getVector3();
template <> }
Transformation NIFStream::get<Transformation>(){ return getTrafo(); } void NIFStream::getVector4s(std::vector<Ogre::Vector4> &vec, size_t size)
{
template <> vec.resize(size);
std::string NIFStream::get<std::string>(){ return getString(); } 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();
}
} }

@ -5,8 +5,6 @@
#include <stdint.h> #include <stdint.h>
#include <stdexcept> #include <stdexcept>
#include <typeinfo>
#include <string>
#include <OgreDataStream.h> #include <OgreDataStream.h>
#include <OgreVector2.h> #include <OgreVector2.h>
@ -86,23 +84,12 @@ public:
///This is special since the version string doesn't start with a number, and ends with "\n" ///This is special since the version string doesn't start with a number, and ends with "\n"
std::string getVersionString(); std::string getVersionString();
//Templated functions to handle reads void getShorts(std::vector<short> &vec, size_t size);
template <typename T> void getFloats(std::vector<float> &vec, size_t size);
T get(){throw std::runtime_error("Can not read a <"+std::string(typeid(T).name())+"> from a NIF File! The get() function was called with the wrong template!");} void getVector2s(std::vector<Ogre::Vector2> &vec, size_t size);
void getVector3s(std::vector<Ogre::Vector3> &vec, size_t size);
///Return a vector of whatever object is needed void getVector4s(std::vector<Ogre::Vector4> &vec, size_t size);
template <typename T> void getQuaternions(std::vector<Ogre::Quaternion> &quat, size_t size);
std::vector<T> getItems(size_t number_of_items)
{
std::vector<T> items;
items.reserve(number_of_items);
for(size_t i=0; i < number_of_items; ++i)
{
items.push_back(get<T>());
}
return items;
}
}; };
} }

@ -9,7 +9,7 @@ find "$DATAFILESDIR" -iname *nif >> nifs.txt
sed -e 's/.*/\"&\"/' nifs.txt > quoted_nifs.txt sed -e 's/.*/\"&\"/' nifs.txt > quoted_nifs.txt
nice -n 10 xargs --arg-file=quoted_nifs.txt ../../../niftest xargs --arg-file=quoted_nifs.txt ../../../niftest
rm nifs.txt rm nifs.txt
rm quoted_nifs.txt rm quoted_nifs.txt

Loading…
Cancel
Save