TWINE: moved methods for reading body data

This commit is contained in:
Martin Gerhardy 2020-12-13 11:44:59 +01:00
parent 4301e49da2
commit e88280ac62
3 changed files with 27 additions and 31 deletions

View File

@ -75,27 +75,6 @@ const uint8* Animations::getKeyFrameData(int32 frameIdx, const uint8 *animPtr) {
return (const uint8 *)((numOfBonesInAnim * 8 + 8) * frameIdx + animPtr + 8);
}
const uint8* Animations::getBonesData(const uint8 *bodyPtr) const {
const uint8 *verticesBase = bodyPtr + 0x1A;
const int16 numVertices = READ_LE_INT16(verticesBase);
const uint8 *bonesBase = verticesBase + 2 + numVertices * 6;
return bonesBase + 2 + 8;
}
uint8* Animations::getBonesData(uint8 *bodyPtr) const {
uint8 *verticesBase = bodyPtr + 0x1A;
const int16 numVertices = READ_LE_INT16(verticesBase);
uint8 *bonesBase = verticesBase + 2 + numVertices * 6;
return bonesBase + 2 + 8;
}
int16 Animations::getNumBones(const uint8 *bodyPtr) const {
const uint8 *verticesBase = bodyPtr + 0x1A;
const int16 numVertices = READ_LE_INT16(verticesBase);
const uint8 *bonesBase = verticesBase + 2 + numVertices * 6;
return READ_LE_INT16(bonesBase);
}
int16 Animations::getNumKeyframes(const uint8 *animPtr) {
return READ_LE_INT16(animPtr + 0);
}
@ -163,8 +142,8 @@ bool Animations::setModelAnimation(int32 keyframeIdx, const uint8 *animPtr, uint
processRotationByAnim = keyFrame->boneframes[0].type;
processLastRotationAngle = ToAngle(keyFrame->boneframes[0].y);
const int16 numBones = getNumBones(bodyPtr);
uint8 *bonesPtr = getBonesData(bodyPtr);
const int16 numBones = Model::getNumBones(bodyPtr);
uint8 *bonesPtr = Model::getBonesData(bodyPtr);
int32 numOfBonesInAnim = animData.getNumBoneframes();
if (numOfBonesInAnim > numBones) {
@ -258,8 +237,8 @@ void Animations::setAnimAtKeyframe(int32 keyframeIdx, const uint8 *animPtr, uint
animTimerDataPtr->ptr = getKeyFrameData(keyframeIdx, animPtr);
animTimerDataPtr->time = _engine->lbaTime;
const int16 numBones = getNumBones(bodyPtr);
uint8 *bonesPtr = getBonesData(bodyPtr);
const int16 numBones = Model::getNumBones(bodyPtr);
uint8 *bonesPtr = Model::getBonesData(bodyPtr);
int16 numOfBonesInAnim = animData.getNumBoneframes();
if (numOfBonesInAnim > numBones) {
@ -286,8 +265,8 @@ void Animations::stockAnimation(const uint8 *bodyPtr, AnimTimerDataStruct *animT
animTimerDataPtr->time = _engine->lbaTime;
animTimerDataPtr->ptr = animBufferPos;
const int32 numBones = getNumBones(bodyPtr);
const uint8 *ptrToData = getBonesData(bodyPtr);
const int32 numBones = Model::getNumBones(bodyPtr);
const uint8 *ptrToData = Model::getBonesData(bodyPtr);
uint8 *bonesPtr = animBufferPos + 8;

View File

@ -38,10 +38,6 @@ private:
void applyAnimStepTranslation(uint8 *ptr, int32 deltaTime, int32 keyFrameLength, const uint8 *keyFramePtr, const uint8 *lastKeyFramePtr);
int32 getAnimMode(uint8 *ptr, const uint8 *keyFramePtr);
const uint8* getBonesData(const uint8 *bodyPtr) const;
uint8* getBonesData(uint8 *bodyPtr) const;
int16 getNumBones(const uint8 *bodyPtr) const;
/**
* Verify animation at keyframe
* @param keyframeIdx Animation key frame index

View File

@ -95,6 +95,27 @@ struct Model {
const int16 bodyHeader = READ_LE_INT16(bodyPtr);
return (bodyHeader & 2) != 0;
}
static const uint8* getBonesData(const uint8 *bodyPtr) {
const uint8 *verticesBase = bodyPtr + 0x1A;
const int16 numVertices = READ_LE_INT16(verticesBase);
const uint8 *bonesBase = verticesBase + 2 + numVertices * 6;
return bonesBase + 2 + 8;
}
static uint8* getBonesData(uint8 *bodyPtr) {
uint8 *verticesBase = bodyPtr + 0x1A;
const int16 numVertices = READ_LE_INT16(verticesBase);
uint8 *bonesBase = verticesBase + 2 + numVertices * 6;
return bonesBase + 2 + 8;
}
static int16 getNumBones(const uint8 *bodyPtr) {
const uint8 *verticesBase = bodyPtr + 0x1A;
const int16 numVertices = READ_LE_INT16(verticesBase);
const uint8 *bonesBase = verticesBase + 2 + numVertices * 6;
return READ_LE_INT16(bonesBase);
}
};
#include "common/pack-start.h"