Skip to content

Commit

Permalink
fix XAE3 delta quats
Browse files Browse the repository at this point in the history
  • Loading branch information
RektInator committed Dec 3, 2020
1 parent 34e3904 commit 8d4e7e3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/IW4/Structs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,7 @@ namespace ZoneTool
__declspec(align(2)) XAnimPartTransData u;
};

#pragma pack(push, 4)
struct XAnimDeltaPartQuatDataFrames2
{
__int16(*frames)[2];
Expand Down Expand Up @@ -2099,13 +2100,13 @@ namespace ZoneTool
union XAnimDeltaPartQuatData
{
XAnimDeltaPartQuatDataFrames frames;
__int16 frame0[2];
__int16 frame0[4];
};

struct XAnimDeltaPartQuat
{
unsigned __int16 size;
__declspec(align(4)) XAnimDeltaPartQuatData u;
XAnimDeltaPartQuatData u;
};

struct XAnimDeltaPart
Expand All @@ -2115,7 +2116,6 @@ namespace ZoneTool
XAnimDeltaPartQuat* quat;
};

#pragma pack(push, 4)
struct XAnimNotifyInfo
{
short name;
Expand Down
30 changes: 20 additions & 10 deletions src/IW5/Assets/XAnimParts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,21 @@ namespace ZoneTool
if (asset->delta->quat2)
{
asset->delta->quat2 = reader.read_raw<XAnimDeltaPartQuat2>();

if (asset->delta->quat2->size && asset->delta->quat2->u.frames.frames)
{
asset->delta->quat2->u.frames.frames = reader.read_raw<short[2]>();
}
}

if (asset->delta->quat)
{
asset->delta->quat = reader.read_raw<XAnimDeltaPartQuat>();

if (asset->delta->quat->size && asset->delta->quat->u.frames.frames)
{
asset->delta->quat->u.frames.frames = reader.read_raw<short[4]>();
}
}
}

Expand Down Expand Up @@ -580,11 +590,6 @@ namespace ZoneTool
{
extra_size += asset->delta->quat2->size + 1;
}

if (asset->delta->quat2->u.frames.frames)
{
extra_size += (asset->delta->quat2->size * 4) + 4;
}
}
else
{
Expand All @@ -593,6 +598,11 @@ namespace ZoneTool
}

dump.dump_raw(asset->delta->quat2, sizeof(XAnimDeltaPartQuat2) + extra_size);

if (asset->delta->quat2->size && asset->delta->quat2->u.frames.frames)
{
dump.dump_raw(asset->delta->quat2->u.frames.frames, (asset->delta->quat2->size * 4) + 4);
}
}

if (asset->delta->quat)
Expand All @@ -609,11 +619,6 @@ namespace ZoneTool
{
extra_size += asset->delta->quat->size + 1;
}

if (asset->delta->quat->u.frames.frames)
{
extra_size += (asset->delta->quat->size * 8) + 8;
}
}
else
{
Expand All @@ -622,6 +627,11 @@ namespace ZoneTool
}

dump.dump_raw(asset->delta->quat, sizeof(XAnimDeltaPartQuat) + extra_size);

if (asset->delta->quat->size && asset->delta->quat->u.frames.frames)
{
dump.dump_raw(asset->delta->quat->u.frames.frames, (asset->delta->quat->size * 8) + 8);
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/IW5/Structs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ namespace ZoneTool
__declspec(align(2)) XAnimPartTransData u;
};

#pragma pack(push, 4)
struct XAnimDeltaPartQuatDataFrames2
{
__int16(*frames)[2];
Expand All @@ -1368,29 +1369,28 @@ namespace ZoneTool
struct XAnimDeltaPartQuatDataFrames
{
__int16(*frames)[4];
XAnimDynamicIndices indices;
XAnimIndices indices;
};

union XAnimDeltaPartQuatData
{
XAnimDeltaPartQuatDataFrames frames;
__int16 frame0[2];
__int16 frame0[4];
};

struct XAnimDeltaPartQuat
{
unsigned __int16 size;
__declspec(align(4)) XAnimDeltaPartQuatData u;
XAnimDeltaPartQuatData u;
};

struct XAnimDeltaPart
{
XAnimPartTrans* trans;
XAnimDeltaPartQuat2* quat2;
XAnimDeltaPartQuat* quat;
};

#pragma pack(push, 4)
struct XAnimNotifyInfo
{
short name;
Expand Down

0 comments on commit 8d4e7e3

Please sign in to comment.