[Scummvm-git-logs] scummvm master -> dda215f5e6875b471f8283f629b7dc306c4dfe13
mgerhardy
martin.gerhardy at gmail.com
Fri Dec 11 16:11:52 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ff30023e43 TWINE: cleanup bone index setup
ab8aab37c0 TWINE: only load the entity data once
dda215f5e6 TWINE: made prepareIsoModel static
Commit: ff30023e43bf231e7a3e6c922f1645dc28412f48
https://github.com/scummvm/scummvm/commit/ff30023e43bf231e7a3e6c922f1645dc28412f48
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-11T17:10:24+01:00
Commit Message:
TWINE: cleanup bone index setup
Changed paths:
engines/twine/renderer.cpp
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 030e8c75f6..aa1249666c 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -259,8 +259,7 @@ void Renderer::processRotatedElement(Matrix *targetMatrix, const pointTab *point
destZ = 0;
} else {
const int32 pointIdx = elemPtr->basePoint / sizeof(pointTab);
- assert(elemPtr->baseElement % 36 == 0);
- const int32 matrixIndex = elemPtr->baseElement / 36;
+ const int32 matrixIndex = elemPtr->baseElement;
assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(matricesTable));
currentMatrix = &matricesTable[matrixIndex];
@@ -312,8 +311,7 @@ void Renderer::processTranslatedElement(Matrix *targetMatrix, const pointTab *po
destY = modelData->computedPoints[pointsIdx].y;
destZ = modelData->computedPoints[pointsIdx].z;
- assert(elemPtr->baseElement % 36 == 0);
- const int32 matrixIndex = elemPtr->baseElement / 36;
+ const int32 matrixIndex = elemPtr->baseElement;
assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(matricesTable));
*targetMatrix = matricesTable[matrixIndex];
}
@@ -1457,9 +1455,6 @@ int32 Renderer::renderAnimatedModel(ModelData *modelData, uint8 *bodyPtr, Render
}
void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
- int32 bp = 36;
- int32 bx = sizeof(elementEntry);
-
Model *bodyHeader = (Model *)bodyPtr;
// This function should only be called ONCE, otherwise it corrupts the model data.
@@ -1474,20 +1469,20 @@ void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
return;
}
- int16 offsetToData = bodyHeader->offsetToData;
-
- uint8 *bodyDataPtr = bodyPtr + offsetToData + 16; // headersize
+ uint8 *bodyDataPtr = bodyPtr + 0x1A;
- int16 numOfElement1 = *((const int16 *)bodyDataPtr);
- uint8 *ptr2 = bodyDataPtr + 2 + numOfElement1 * sizeof(pointTab);
+ int16 numVertices = *((const int16 *)bodyDataPtr);
+ uint8 *bonesBase = bodyDataPtr + 2 + numVertices * sizeof(pointTab);
- int16 numOfPoint = *((const int16 *)ptr2);
+ int16 numBones = *((const int16 *)bonesBase);
- uint8 *ptrToKeyData = ptr2 + 2;
+ uint8 *elementEntryBasePointer = bonesBase + 2;
- for (int32 i = 0; i < numOfPoint; i++) {
- ptrToKeyData += sizeof(elementEntry);
- *((int16 *)(ptrToKeyData + 6)) = (*((const int16 *)(ptrToKeyData + 6)) * bp) / bx;
+ // set up bone indices
+ for (int32 i = 0; i < numBones; i++) {
+ elementEntryBasePointer += sizeof(elementEntry);
+ elementEntry *ee = (elementEntry*)elementEntryBasePointer;
+ ee->baseElement = ee->baseElement / sizeof(elementEntry);
}
}
@@ -1517,7 +1512,7 @@ int32 Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 an
Model *bodyHeader = (Model *)bodyPtr;
if (bodyHeader->bodyFlag.animated) {
// jump after the header
- uint8 *ptr = bodyPtr + 16 + *((const uint16 *)(bodyPtr + 14));
+ uint8 *ptr = bodyPtr + 0x1A;
// the mostly used renderer code
// restart at the beginning of the renderTable
return renderAnimatedModel(&_modelData, ptr, _renderCmds);
Commit: ab8aab37c0c2afc3a066e53006b7fbce48a5a354
https://github.com/scummvm/scummvm/commit/ab8aab37c0c2afc3a066e53006b7fbce48a5a354
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-11T17:10:24+01:00
Commit Message:
TWINE: only load the entity data once
Changed paths:
engines/twine/actor.cpp
engines/twine/actor.h
engines/twine/animations.cpp
engines/twine/entity.cpp
diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 6613e06ad5..3e8dde46d3 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -89,6 +89,7 @@ void Actor::loadHeroEntities() {
}
sceneHero->entityDataPtr = heroEntityATHLETIC;
sceneHero->entityDataSize = heroEntityATHLETICSize;
+ sceneHero->entityData.loadFromBuffer(sceneHero->entityDataPtr, sceneHero->entityDataSize);
heroAnimIdxATHLETIC = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
if (heroAnimIdxATHLETIC == -1) {
error("Could not find athletic animation data");
@@ -100,6 +101,7 @@ void Actor::loadHeroEntities() {
}
sceneHero->entityDataPtr = heroEntityAGGRESSIVE;
sceneHero->entityDataSize = heroEntityAGGRESSIVESize;
+ sceneHero->entityData.loadFromBuffer(sceneHero->entityDataPtr, sceneHero->entityDataSize);
heroAnimIdxAGGRESSIVE = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
if (heroAnimIdxAGGRESSIVE == -1) {
error("Could not find aggressive animation data");
@@ -111,6 +113,7 @@ void Actor::loadHeroEntities() {
}
sceneHero->entityDataPtr = heroEntityDISCRETE;
sceneHero->entityDataSize = heroEntityDISCRETESize;
+ sceneHero->entityData.loadFromBuffer(sceneHero->entityDataPtr, sceneHero->entityDataSize);
heroAnimIdxDISCRETE = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
if (heroAnimIdxDISCRETE == -1) {
error("Could not find discrete animation data");
@@ -122,6 +125,7 @@ void Actor::loadHeroEntities() {
}
sceneHero->entityDataPtr = heroEntityPROTOPACK;
sceneHero->entityDataSize = heroEntityPROTOPACKSize;
+ sceneHero->entityData.loadFromBuffer(sceneHero->entityDataPtr, sceneHero->entityDataSize);
heroAnimIdxPROTOPACK = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
if (heroAnimIdxPROTOPACK == -1) {
error("Could not find protopack animation data");
@@ -133,6 +137,7 @@ void Actor::loadHeroEntities() {
}
sceneHero->entityDataPtr = heroEntityNORMAL;
sceneHero->entityDataSize = heroEntityNORMALSize;
+ sceneHero->entityData.loadFromBuffer(sceneHero->entityDataPtr, sceneHero->entityDataSize);
heroAnimIdxNORMAL = _engine->_animations->getBodyAnimIndex(AnimationTypes::kStanding);
if (heroAnimIdxNORMAL == -1) {
error("Could not find normal animation data");
@@ -529,6 +534,7 @@ void ActorStruct::loadModel(int32 modelIndex) {
if (!staticFlags.bIsSpriteActor) {
debug("Init actor with model %i", modelIndex);
entityDataSize = HQR::getAllocEntry(&entityDataPtr, Resources::HQR_FILE3D_FILE, modelIndex);
+ entityData.loadFromBuffer(entityDataPtr, entityDataSize);
} else {
entityDataSize = 0;
free(entityDataPtr);
diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index 583b1e0bb4..ec0f0c636c 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -24,6 +24,7 @@
#define TWINE_ACTOR_H
#include "common/scummsys.h"
+#include "twine/entity.h"
#include "twine/shared.h"
namespace TwinE {
@@ -149,6 +150,8 @@ private:
public:
~ActorStruct();
+ EntityData entityData;
+
StaticFlagsStruct staticFlags;
DynamicFlagsStruct dynamicFlags;
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index c8ddabe3cb..4f50fc9f3a 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -283,9 +283,7 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
- EntityData entityData;
- entityData.loadFromBuffer(actor->entityDataPtr, actor->entityDataSize);
- const int32 bodyAnimIndex = entityData.getAnimIndex(animIdx);
+ const int32 bodyAnimIndex = actor->entityData.getAnimIndex(animIdx);
if (bodyAnimIndex != -1) {
currentActorAnimExtraPtr = animIdx;
}
@@ -380,13 +378,11 @@ bool Animations::verifyAnimAtKeyframe(int32 animIdx, const uint8 *animPtr, AnimT
void Animations::processAnimActions(int32 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
- if (actor->entityDataPtr == nullptr || actor->animExtraPtr == AnimationTypes::kAnimNone) {
+ if (actor->animExtraPtr == AnimationTypes::kAnimNone) {
return;
}
- EntityData entityData;
- entityData.loadFromBuffer(actor->entityDataPtr, actor->entityDataSize);
- const Common::Array<EntityAnim::Action> *actions = entityData.getActions(actor->animExtraPtr);
+ const Common::Array<EntityAnim::Action> *actions = actor->entityData.getActions(actor->animExtraPtr);
if (actions == nullptr) {
return;
}
diff --git a/engines/twine/entity.cpp b/engines/twine/entity.cpp
index af5beab502..7afec2f428 100644
--- a/engines/twine/entity.cpp
+++ b/engines/twine/entity.cpp
@@ -147,6 +147,8 @@ bool EntityData::loadAnim(Common::SeekableReadStream &stream) {
}
bool EntityData::loadFromStream(Common::SeekableReadStream &stream) {
+ _bodies.clear();
+ _animations.clear();
do {
const uint8 opcode = stream.readByte();
if (opcode == 1) {
Commit: dda215f5e6875b471f8283f629b7dc306c4dfe13
https://github.com/scummvm/scummvm/commit/dda215f5e6875b471f8283f629b7dc306c4dfe13
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-11T17:10:24+01:00
Commit Message:
TWINE: made prepareIsoModel static
Changed paths:
engines/twine/actor.cpp
engines/twine/gamestate.cpp
engines/twine/holomap.cpp
engines/twine/menu.cpp
engines/twine/redraw.cpp
engines/twine/renderer.h
diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 3e8dde46d3..c5f4d9f9ad 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -245,7 +245,7 @@ int32 Actor::initBody(int32 bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoun
if (bodyTableSize[index] == 0) {
error("HQR ERROR: Loading body entities");
}
- _engine->_renderer->prepareIsoModel(bodyTable[index]);
+ Renderer::prepareIsoModel(bodyTable[index]);
stream.seek(stream.pos() - sizeof(uint16));
stream.writeUint16LE(index + 0x8000);
} else {
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 4f4e93bee7..5f7f746961 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -328,7 +328,7 @@ void GameState::processFoundItem(int32 item) {
int32 currentAnimState = 0;
- _engine->_renderer->prepareIsoModel(_engine->_resources->inventoryTable[item]);
+ Renderer::prepareIsoModel(_engine->_resources->inventoryTable[item]);
_engine->_redraw->numOfRedrawBox = 0;
while (!quitItem) {
@@ -452,7 +452,7 @@ void GameState::processGameoverAnimation() {
const int32 right = 519;
const int32 bottom = 359;
const Common::Rect rect(left, top, right, bottom);
- _engine->_renderer->prepareIsoModel(gameOverPtr);
+ Renderer::prepareIsoModel(gameOverPtr);
_engine->_sound->stopSamples();
_engine->_music->stopMidiMusic(); // stop fade music
_engine->_renderer->setCameraPosition(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 128, 200, 200);
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index cc83b007f6..46afaa3b50 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -93,10 +93,10 @@ void Holomap::loadHolomapGFX() {
uint8 *videoPtr7 = videoPtr6 + HQR::getEntry(videoPtr6, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWMDL);
uint8 *videoPtr8 = videoPtr7 + HQR::getEntry(videoPtr7, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINARROWMDL);
- _engine->_renderer->prepareIsoModel(videoPtr5);
- _engine->_renderer->prepareIsoModel(videoPtr6);
- _engine->_renderer->prepareIsoModel(videoPtr7);
- _engine->_renderer->prepareIsoModel(videoPtr8);
+ Renderer::prepareIsoModel(videoPtr5);
+ Renderer::prepareIsoModel(videoPtr6);
+ Renderer::prepareIsoModel(videoPtr7);
+ Renderer::prepareIsoModel(videoPtr8);
// TODO:
// uint8 *videoPtr1 = (uint8 *)_engine->workVideoBuffer.getPixels();
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 644983e241..f37707855e 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -1057,7 +1057,7 @@ void Menu::drawItem(int32 item) {
_engine->_interface->drawSplittedBox(rect, inventorySelectedItem == item ? inventorySelectedColor : 0);
if (item < NUM_INVENTORY_ITEMS && _engine->_gameState->hasItem((InventoryItems)item) && !_engine->_gameState->inventoryDisabled()) {
- _engine->_renderer->prepareIsoModel(_engine->_resources->inventoryTable[item]);
+ Renderer::prepareIsoModel(_engine->_resources->inventoryTable[item]);
itemAngle[item] += 8;
_engine->_renderer->renderInventoryItem(itemX, itemY, _engine->_resources->inventoryTable[item], itemAngle[item], 15000);
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 6333df73c1..f6dd1cfeb0 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -653,7 +653,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
_engine->_interface->drawSplittedBox(rect, 0);
_engine->_interface->setClip(rect);
- _engine->_renderer->prepareIsoModel(_engine->_resources->inventoryTable[item]);
+ Renderer::prepareIsoModel(_engine->_resources->inventoryTable[item]);
_engine->_renderer->setCameraPosition(40, 40, 128, 200, 200);
_engine->_renderer->setCameraAngle(0, 0, 0, 60, 0, 0, 16000);
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index ea565ce1b2..70b6304c3a 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -272,7 +272,7 @@ public:
void setLightVector(int32 angleX, int32 angleY, int32 angleZ);
- void prepareIsoModel(uint8 *bodyPtr); // loadGfxSub
+ static void prepareIsoModel(uint8 *bodyPtr);
void renderPolygons(const CmdRenderPolygon &polygon, Vertex *vertices);
int32 projectPositionOnScreen(int32 cX, int32 cY, int32 cZ);
More information about the Scummvm-git-logs
mailing list