summaryrefslogtreecommitdiffstats
path: root/src/animation/AnimBlendSequence.cpp
diff options
context:
space:
mode:
authorFire_Head <Fire-Head@users.noreply.github.com>2019-06-12 00:57:49 +0200
committerGitHub <noreply@github.com>2019-06-12 00:57:49 +0200
commit0f402c97ea94c3980aa7aa0305a35db1a3f59c2b (patch)
tree1d9bb0ba737fcd4ba0189c72ecd651eddbe04ac4 /src/animation/AnimBlendSequence.cpp
parenttmp (diff)
parentadded animation system (with skin support for now) (diff)
downloadre3-0f402c97ea94c3980aa7aa0305a35db1a3f59c2b.tar
re3-0f402c97ea94c3980aa7aa0305a35db1a3f59c2b.tar.gz
re3-0f402c97ea94c3980aa7aa0305a35db1a3f59c2b.tar.bz2
re3-0f402c97ea94c3980aa7aa0305a35db1a3f59c2b.tar.lz
re3-0f402c97ea94c3980aa7aa0305a35db1a3f59c2b.tar.xz
re3-0f402c97ea94c3980aa7aa0305a35db1a3f59c2b.tar.zst
re3-0f402c97ea94c3980aa7aa0305a35db1a3f59c2b.zip
Diffstat (limited to 'src/animation/AnimBlendSequence.cpp')
-rw-r--r--src/animation/AnimBlendSequence.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/animation/AnimBlendSequence.cpp b/src/animation/AnimBlendSequence.cpp
new file mode 100644
index 00000000..4b675774
--- /dev/null
+++ b/src/animation/AnimBlendSequence.cpp
@@ -0,0 +1,68 @@
+#include "common.h"
+#include "patcher.h"
+#include "AnimBlendSequence.h"
+
+CAnimBlendSequence::CAnimBlendSequence(void)
+{
+ type = 0;
+ numFrames = 0;
+ keyFrames = nil;
+ keyFramesCompressed = nil;
+#ifdef PED_SKIN
+ boneTag = -1;
+#endif
+}
+
+CAnimBlendSequence::~CAnimBlendSequence(void)
+{
+ if(keyFrames)
+ RwFree(keyFrames);
+}
+
+void
+CAnimBlendSequence::SetName(char *name)
+{
+ strncpy(this->name, name, 24);
+}
+
+void
+CAnimBlendSequence::SetNumFrames(int numFrames, bool translation)
+{
+ int sz;
+
+ if(translation){
+ sz = sizeof(KeyFrameTrans);
+ type |= KF_ROT | KF_TRANS;
+ }else{
+ sz = sizeof(KeyFrame);
+ type |= KF_ROT;
+ }
+ keyFrames = RwMalloc(sz * numFrames);
+ this->numFrames = numFrames;
+}
+
+void
+CAnimBlendSequence::RemoveQuaternionFlips(void)
+{
+ int i;
+ CQuaternion last;
+ KeyFrame *frame;
+
+ if(numFrames < 2)
+ return;
+
+ frame = GetKeyFrame(0);
+ last = frame->rotation;
+ for(i = 1; i < numFrames; i++){
+ frame = GetKeyFrame(i);
+ if(DotProduct(last, frame->rotation) < 0.0f)
+ frame->rotation = -frame->rotation;
+ last = frame->rotation;
+ }
+}
+
+STARTPATCHES
+ InjectHook(0x402330, &CAnimBlendSequence::SetName, PATCH_JUMP);
+ InjectHook(0x402350, &CAnimBlendSequence::SetNumFrames, PATCH_JUMP);
+ InjectHook(0x4023A0, &CAnimBlendSequence::RemoveQuaternionFlips, PATCH_JUMP);
+ENDPATCHES