forked from mirrors/0ad
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of mostly equivalent types we had in use (int, uint, unsigned, unsigned int, i32, u32, ulong, uintN). it is more efficient to use 64-bit types in 64-bit mode, so the preferred default is size_t (for anything remotely resembling a size or index). tile coordinates are ssize_t to allow more efficient conversion to/from floating point. flags are int because we almost never need more than 15 distinct bits, bit test/set is not slower and int is fastest to type. finally, some data that is pretty much directly passed to OpenGL is now typed accordingly. after several hours, the code now requires fewer casts and less guesswork. other changes: - unit and player IDs now have an "invalid id" constant in the respective class to avoid casting and -1 - fix some endian/64-bit bugs in the map (un)packing. added a convenience function to write/read a size_t. - ia32: change CPUID interface to allow passing in ecx (required for cache topology detection, which I need at work). remove some unneeded functions from asm, replace with intrinsics where possible. This was SVN commit r5942.
This commit is contained in:
@@ -32,12 +32,12 @@ CSkeletonAnimDef::~CSkeletonAnimDef()
|
||||
void CSkeletonAnimDef::BuildBoneMatrices(float time, CMatrix3D* matrices, bool loop) const
|
||||
{
|
||||
float fstartframe = time/m_FrameTime;
|
||||
u32 startframe = u32(time/m_FrameTime);
|
||||
size_t startframe = (size_t)(int)(time/m_FrameTime);
|
||||
float deltatime = fstartframe-startframe;
|
||||
|
||||
startframe %= m_NumFrames;
|
||||
|
||||
u32 endframe = startframe + 1;
|
||||
size_t endframe = startframe + 1;
|
||||
endframe %= m_NumFrames;
|
||||
|
||||
if (!loop && endframe == 0)
|
||||
@@ -46,7 +46,7 @@ void CSkeletonAnimDef::BuildBoneMatrices(float time, CMatrix3D* matrices, bool l
|
||||
// between the final frame and the initial frame is wrong, because they're
|
||||
// totally different. So if we've looped around to endframe==0, just display
|
||||
// the animation's final frame with no interpolation.
|
||||
for (u32 i = 0; i < m_NumKeys; i++)
|
||||
for (size_t i = 0; i < m_NumKeys; i++)
|
||||
{
|
||||
const Key& key = GetKey(startframe, i);
|
||||
matrices[i].SetIdentity();
|
||||
@@ -56,7 +56,7 @@ void CSkeletonAnimDef::BuildBoneMatrices(float time, CMatrix3D* matrices, bool l
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u32 i = 0; i < m_NumKeys; i++)
|
||||
for (size_t i = 0; i < m_NumKeys; i++)
|
||||
{
|
||||
const Key& startkey = GetKey(startframe, i);
|
||||
const Key& endkey = GetKey(endframe, i);
|
||||
@@ -90,8 +90,8 @@ CSkeletonAnimDef* CSkeletonAnimDef::Load(const VfsPath& filename)
|
||||
CStr name; // unused - just here to maintain compatibility with the animation files
|
||||
unpacker.UnpackString(name);
|
||||
unpacker.UnpackRaw(&anim->m_FrameTime,sizeof(anim->m_FrameTime));
|
||||
unpacker.UnpackRaw(&anim->m_NumKeys,sizeof(anim->m_NumKeys));
|
||||
unpacker.UnpackRaw(&anim->m_NumFrames,sizeof(anim->m_NumFrames));
|
||||
anim->m_NumKeys = unpacker.UnpackSize();
|
||||
anim->m_NumFrames = unpacker.UnpackSize();
|
||||
anim->m_Keys=new Key[anim->m_NumKeys*anim->m_NumFrames];
|
||||
unpacker.UnpackRaw(anim->m_Keys,anim->m_NumKeys*anim->m_NumFrames*sizeof(Key));
|
||||
} catch (PSERROR_File&) {
|
||||
@@ -111,12 +111,12 @@ void CSkeletonAnimDef::Save(const char* filename,const CSkeletonAnimDef* anim)
|
||||
// pack up all the data
|
||||
packer.PackString("");
|
||||
packer.PackRaw(&anim->m_FrameTime,sizeof(anim->m_FrameTime));
|
||||
packer.PackRaw(&anim->m_NumKeys,sizeof(anim->m_NumKeys));
|
||||
packer.PackRaw(&anim->m_NumFrames,sizeof(anim->m_NumFrames));
|
||||
packer.PackRaw(anim->m_Keys,anim->m_NumKeys*anim->m_NumFrames*sizeof(Key));
|
||||
const size_t numKeys = anim->m_NumKeys;
|
||||
packer.PackSize(numKeys);
|
||||
const size_t numFrames = anim->m_NumFrames;
|
||||
packer.PackSize(numFrames);
|
||||
packer.PackRaw(anim->m_Keys,numKeys*numFrames*sizeof(Key));
|
||||
|
||||
// now write it
|
||||
packer.Write(filename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user