TWINE: implemented missing function copyInterAnim

This commit is contained in:
Martin Gerhardy 2023-05-30 21:55:32 +02:00
parent 70b794cbb9
commit b29f0a0ef9
3 changed files with 22 additions and 6 deletions

View File

@ -186,10 +186,10 @@ bool BodyData::loadFromStream(Common::SeekableReadStream &stream, bool lba1) {
bbox.maxs.y = stream.readSint16LE();
bbox.mins.z = stream.readSint16LE();
bbox.maxs.z = stream.readSint16LE();
offsetToData = stream.readSint16LE();
// using this value as the offset crashes the demo of lba1 - see https://bugs.scummvm.org/ticket/14294
// const uint16 offset = stream.readUint16LE();
// stream.skip(offset);
// stream.seek(offsetToData);
stream.seek(0x1A);
loadVertices(stream);

View File

@ -189,6 +189,7 @@ void Actor::initBody(BodyType bodyIdx, int16 actorIdx) {
return;
}
const int32 oldBody = localActor->_body;
localActor->_body = newBody;
localActor->_genBody = bodyIdx;
@ -217,11 +218,22 @@ void Actor::initBody(BodyType bodyIdx, int16 actorIdx) {
localActor->_boundingBox.mins.z = -size;
localActor->_boundingBox.maxs.z = size;
}
#if 0
if (oldbody != -1 && localActor->_anim != -1) {
copyInterAnim(_engine->_resources->_bodyData[oldbody], _engine->_resources->_bodyData[localActor->_body]);
if (oldBody != -1 && localActor->_anim != -1) {
copyInterAnim(_engine->_resources->_bodyData[oldBody], _engine->_resources->_bodyData[localActor->_body]);
}
}
void Actor::copyInterAnim(const BodyData &src, BodyData &dest) {
if (!src.isAnimated() || !dest.isAnimated()) {
return;
}
const int16 numBones = MIN<int16>((int16)src.getNumBones(), (int16)dest.getNumBones());
for (int16 i = 0; i < numBones; ++i) {
const BoneFrame *srcBoneFrame = src.getBoneState(i);
BoneFrame *destBoneFrame = dest.getBoneState(i);
*destBoneFrame = *srcBoneFrame;
}
#endif
}
void Actor::initActor(int16 actorIdx) {

View File

@ -24,6 +24,7 @@
#include "common/scummsys.h"
#include "twine/parser/anim.h"
#include "twine/parser/body.h"
#include "twine/parser/entity.h"
#include "twine/shared.h"
@ -139,6 +140,7 @@ private:
bool _brickCausesDamage = false;
EntityData _entityData;
public:
StaticFlagsStruct _staticFlags;
DynamicFlagsStruct _dynamicFlags;
@ -272,6 +274,8 @@ private:
void loadBehaviourEntity(ActorStruct *actor, EntityData &entityData, int16 &bodyAnimIndex, int32 index);
void copyInterAnim(const BodyData &src, BodyData &dest);
public:
Actor(TwinEEngine *engine);