[Scummvm-git-logs] scummvm master -> 70fd4f428d9ed5ba1f71bb02f35b8fae7fccb410
mgerhardy
martin.gerhardy at gmail.com
Mon Mar 15 22:11:44 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
bacdce7328 TWINE: improved scene debug rendering and added script patches found in the enhanced edition
70fd4f428d TWINE: removed ScenePoint and added actor debug rendering
Commit: bacdce73287d0dc0e3a51fcba1d64339499a7eef
https://github.com/scummvm/scummvm/commit/bacdce73287d0dc0e3a51fcba1d64339499a7eef
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-15T23:08:57+01:00
Commit Message:
TWINE: improved scene debug rendering and added script patches found in the enhanced edition
Changed paths:
engines/twine/debugger/console.cpp
engines/twine/debugger/console.h
engines/twine/debugger/debug_scene.cpp
engines/twine/debugger/debug_scene.h
engines/twine/scene/scene.cpp
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index 0608da5f69..b46370bcec 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -62,6 +62,7 @@ TwinEConsole::TwinEConsole(TwinEEngine *engine) : _engine(engine), GUI::Debugger
registerCmd("set_holomap_flag", WRAP_METHOD(TwinEConsole, doSetHolomapFlag));
registerCmd("set_holomap_trajectory", WRAP_METHOD(TwinEConsole, doSetHolomapTrajectory));
registerCmd("show_holomap_flag", WRAP_METHOD(TwinEConsole, doPrintGameFlag));
+ registerCmd("toggle_scene_patches", WRAP_METHOD(TwinEConsole, doToggleScenePatches));
}
TwinEConsole::~TwinEConsole() {
@@ -84,6 +85,11 @@ bool TwinEConsole::doToggleZoneRendering(int argc, const char **argv) {
return true;
}
+bool TwinEConsole::doToggleScenePatches(int argc, const char **argv) {
+ TOGGLE_DEBUG(_engine->_debugScene->useScenePatches, "use scene patches\n")
+ return true;
+}
+
bool TwinEConsole::doToggleClipRendering(int argc, const char **argv) {
TOGGLE_DEBUG(_engine->_debugScene->showingClips, "clip rendering\n")
return true;
diff --git a/engines/twine/debugger/console.h b/engines/twine/debugger/console.h
index c42c98c300..685e6ae2aa 100644
--- a/engines/twine/debugger/console.h
+++ b/engines/twine/debugger/console.h
@@ -51,6 +51,7 @@ private:
bool doGiveKashes(int argc, const char **argv);
bool doToggleZoneRendering(int argc, const char **argv);
bool doToggleClipRendering(int argc, const char **argv);
+ bool doToggleScenePatches(int argc, const char **argv);
bool doToggleFreeCamera(int argc, const char **argv);
bool doToggleSceneChanges(int argc, const char **argv);
bool doSkipSceneActorsBut(int argc, const char **argv);
diff --git a/engines/twine/debugger/debug_scene.cpp b/engines/twine/debugger/debug_scene.cpp
index 7dfadbdd6a..880441f431 100644
--- a/engines/twine/debugger/debug_scene.cpp
+++ b/engines/twine/debugger/debug_scene.cpp
@@ -31,6 +31,9 @@
namespace TwinE {
+// TODO: render scene tracks
+// TODO: render actors and their bounding boxes
+
DebugScene::DebugScene(TwinEEngine *engine) : _engine(engine) {}
void DebugScene::drawClip(const Common::Rect& rect) {
@@ -95,7 +98,7 @@ int32 DebugScene::checkZoneType(int32 type) {
return 1;
break;
default:
- break;
+ return 1;
}
return 0;
@@ -207,6 +210,14 @@ void DebugScene::displayZones() {
_engine->_interface->drawLine(backBottomLeftPoint2D.x, backBottomLeftPoint2D.y, backBottomRightPoint2D.x, backBottomRightPoint2D.y, color);
_engine->_interface->drawLine(backBottomRightPoint2D.x, backBottomRightPoint2D.y, frontBottomRightPoint2D.x, frontBottomRightPoint2D.y, color);
_engine->_interface->drawLine(frontBottomRightPoint2D.x, frontBottomRightPoint2D.y, frontBottomLeftPoint2D.x, frontBottomLeftPoint2D.y, color);
+ const int boxwidth = 150;
+ const int lineHeight = 14;
+ const int boxheight = 2 * lineHeight;
+ const Common::Rect filledRect(frontTopRightPoint2D.x, frontTopRightPoint2D.y, frontTopRightPoint2D.x + boxwidth, frontTopRightPoint2D.y + boxheight);
+ _engine->_interface->drawFilledRect(filledRect, COLOR_WHITE);
+ _engine->_menu->drawBox(filledRect);
+ _engine->drawText(frontTopRightPoint2D.x, frontTopRightPoint2D.y, Common::String::format("Type: %i (%i)", zonePtr->type, z), true, false, boxwidth);
+ _engine->drawText(frontTopRightPoint2D.x, frontTopRightPoint2D.y + lineHeight, Common::String::format("pos: %i:%i:%i", frontTopRightPoint.x, frontTopRightPoint.y, frontTopRightPoint.z), true, false, boxwidth);
}
_engine->flip();
}
diff --git a/engines/twine/debugger/debug_scene.h b/engines/twine/debugger/debug_scene.h
index b0cd9b7e79..25e3f22e20 100644
--- a/engines/twine/debugger/debug_scene.h
+++ b/engines/twine/debugger/debug_scene.h
@@ -41,6 +41,7 @@ public:
DebugScene(TwinEEngine *engine);
bool showingZones = false;
bool showingClips = false;
+ bool useScenePatches = false;
int32 typeZones = 127; // all zones on as default
int16 onlyLoadActor = -1;
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index f3be95f7cb..25bcfd20a8 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -393,26 +393,40 @@ bool Scene::loadSceneLBA1() {
point->z = stream.readUint16LE();
}
-#if 0
- // TODO: these were found in the disassembly and might be some script fixes - check me and activate me
- switch (currentSceneIdx) {
- case LBA1SceneId::Hamalayi_Mountains_landing_place:
- assert(sceneNumActors >= 22);
- _sceneActors[21].x = _sceneActors[21].collisionX = 0x1b00;
- _sceneActors[21].z = _sceneActors[21].collisionZ = 0x300;
- break;
- case Principal_Island_outside_the_fortress:
- assert(sceneNumActors >= 30);
- _sceneActors[29].z = _sceneActors[29].collisionZ = 0x703;
- break;
- case Tippet_Island_Secret_passage_scene_1:
- (ushort*)puVar4[78] = 0xe20;
- break;
- case Principal_Island_inside_the_fortress:
- (ushort*)puVar4[140] = 0x32;
- break;
- }
-#endif
+ if (_engine->_debugScene->useScenePatches) {
+ switch (currentSceneIdx) {
+ case LBA1SceneId::Hamalayi_Mountains_landing_place:
+ assert(sceneNumActors >= 22);
+ _sceneActors[21].pos.x = _sceneActors[21].collisionPos.x = 0x1b00;
+ _sceneActors[21].pos.z = _sceneActors[21].collisionPos.z = 0x300;
+ break;
+ case LBA1SceneId::Principal_Island_outside_the_fortress:
+ assert(sceneNumActors >= 30);
+ _sceneActors[29].pos.z = _sceneActors[29].collisionPos.z = 0x703;
+ assert(sceneNumZones >= 23);
+ // each scene zone entry has 24 bytes
+ sceneZones[15].bottomLeft.y = 0x450; // [zone:15] 362 (mod:2) offset relative to sceneNumZones
+ sceneZones[15].type = 0x2ce0; // [zone:15] 372 (mod:12) offset relative to sceneNumZones
+ sceneZones[16].bottomLeft.y = 0x5270; // [zone:16] 386 (mod:2) offset relative to sceneNumZones
+ sceneZones[16].type = 0x1f90; // [zone:16] 396 (mod:12) offset relative to sceneNumZones
+ sceneZones[22].bottomLeft.y = 0x1800; // [zone:22] 530 (mod:2) offset relative to sceneNumZones
+ sceneZones[15].topRight.x = 0x10f0;
+ sceneZones[15].topRight.y = 0x2100; // [zone:15] 366 (mod:6) offset relative to sceneNumZones (4 bytes)
+ sceneZones[16].topRight.x = 0x5d10;
+ sceneZones[16].topRight.y = 0x1200; // [zone:16] 390 (mod:6) offset relative to sceneNumZones (4 bytes)
+ sceneZones[22].topRight.x = 0x22a1;
+ sceneZones[22].topRight.y = 0x1800; // [zone:22] 534 (mod:6) offset relative to sceneNumZones (4 bytes)
+ sceneZones[22].type = 0x1ae1; // [zone:22] 540 (mod:12) offset relative to sceneNumZones
+ break;
+ case LBA1SceneId::Tippet_Island_Secret_passage_scene_1:
+ // puVar4 is the position of sceneNumZones
+ //(ushort*)puVar4[78] = 0xe20;
+ break;
+ case LBA1SceneId::Principal_Island_inside_the_fortress:
+ //(ushort*)puVar4[140] = 0x32;
+ break;
+ }
+ }
return true;
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index e0670c5b57..1d3b25203c 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -1128,17 +1128,15 @@ void TwinEEngine::readKeys() {
_input->readKeys();
}
-void TwinEEngine::drawText(int32 x, int32 y, const char *string, int32 center) {
- const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+void TwinEEngine::drawText(int32 x, int32 y, const Common::String &text, bool center, bool bigFont, int width) {
+ const Graphics::Font *font = FontMan.getFontByUsage(bigFont ? Graphics::FontManager::kBigGUIFont : Graphics::FontManager::kGUIFont);
if (!font) {
return;
}
- int width = 180;
- const Common::String text(string);
font->drawString(&frontVideoBuffer, text,
x, y, width,
frontVideoBuffer.format.RGBToColor(255, 255, 255),
- center ? Graphics::kTextAlignCenter : Graphics::kTextAlignLeft, 0, false);
+ center ? Graphics::kTextAlignCenter : Graphics::kTextAlignLeft, 0, true);
}
const char *TwinEEngine::getGameId() const {
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 690ac686dc..0c075f0a72 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -357,10 +357,10 @@ public:
* Display text in screen
* @param x X coordinate in screen
* @param y Y coordinate in screen
- * @param string text to display
+ * @param text text to display
* @param center if the text should be centered accoding with the giving positions
*/
- void drawText(int32 x, int32 y, const char *string, int32 center);
+ void drawText(int32 x, int32 y, const Common::String &text, bool center = false, bool bigFont = false, int width = 100);
};
inline int TwinEEngine::width() const {
Commit: 70fd4f428d9ed5ba1f71bb02f35b8fae7fccb410
https://github.com/scummvm/scummvm/commit/70fd4f428d9ed5ba1f71bb02f35b8fae7fccb410
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-15T23:11:21+01:00
Commit Message:
TWINE: removed ScenePoint and added actor debug rendering
Changed paths:
engines/twine/debugger/console.cpp
engines/twine/debugger/console.h
engines/twine/debugger/debug_scene.cpp
engines/twine/debugger/debug_scene.h
engines/twine/menu/interface.cpp
engines/twine/menu/interface.h
engines/twine/renderer/redraw.cpp
engines/twine/scene/scene.cpp
engines/twine/scene/scene.h
engines/twine/script/script_life_v1.cpp
engines/twine/script/script_move_v1.cpp
diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index b46370bcec..7eb5bb52b3 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -49,6 +49,8 @@ TwinEConsole::TwinEConsole(TwinEEngine *engine) : _engine(engine), GUI::Debugger
registerCmd("list_menutext", WRAP_METHOD(TwinEConsole, doListMenuText));
registerCmd("toggle_debug", WRAP_METHOD(TwinEConsole, doToggleDebug));
registerCmd("toggle_zones", WRAP_METHOD(TwinEConsole, doToggleZoneRendering));
+ registerCmd("toggle_tracks", WRAP_METHOD(TwinEConsole, doToggleTrackRendering));
+ registerCmd("toggle_actors", WRAP_METHOD(TwinEConsole, doToggleActorRendering));
registerCmd("toggle_clips", WRAP_METHOD(TwinEConsole, doToggleClipRendering));
registerCmd("toggle_freecamera", WRAP_METHOD(TwinEConsole, doToggleFreeCamera));
registerCmd("toggle_scenechanges", WRAP_METHOD(TwinEConsole, doToggleSceneChanges));
@@ -85,6 +87,16 @@ bool TwinEConsole::doToggleZoneRendering(int argc, const char **argv) {
return true;
}
+bool TwinEConsole::doToggleActorRendering(int argc, const char **argv) {
+ TOGGLE_DEBUG(_engine->_debugScene->showingActors, "actor rendering\n")
+ return true;
+}
+
+bool TwinEConsole::doToggleTrackRendering(int argc, const char **argv) {
+ TOGGLE_DEBUG(_engine->_debugScene->showingTracks, "tracks rendering\n")
+ return true;
+}
+
bool TwinEConsole::doToggleScenePatches(int argc, const char **argv) {
TOGGLE_DEBUG(_engine->_debugScene->useScenePatches, "use scene patches\n")
return true;
diff --git a/engines/twine/debugger/console.h b/engines/twine/debugger/console.h
index 685e6ae2aa..a72aa1760f 100644
--- a/engines/twine/debugger/console.h
+++ b/engines/twine/debugger/console.h
@@ -51,6 +51,8 @@ private:
bool doGiveKashes(int argc, const char **argv);
bool doToggleZoneRendering(int argc, const char **argv);
bool doToggleClipRendering(int argc, const char **argv);
+ bool doToggleActorRendering(int argc, const char **argv);
+ bool doToggleTrackRendering(int argc, const char **argv);
bool doToggleScenePatches(int argc, const char **argv);
bool doToggleFreeCamera(int argc, const char **argv);
bool doToggleSceneChanges(int argc, const char **argv);
diff --git a/engines/twine/debugger/debug_scene.cpp b/engines/twine/debugger/debug_scene.cpp
index 880441f431..af8d9bfb73 100644
--- a/engines/twine/debugger/debug_scene.cpp
+++ b/engines/twine/debugger/debug_scene.cpp
@@ -27,23 +27,21 @@
#include "twine/renderer/renderer.h"
#include "twine/scene/grid.h"
#include "twine/scene/scene.h"
+#include "twine/text.h"
#include "twine/twine.h"
namespace TwinE {
-// TODO: render scene tracks
-// TODO: render actors and their bounding boxes
-
DebugScene::DebugScene(TwinEEngine *engine) : _engine(engine) {}
-void DebugScene::drawClip(const Common::Rect& rect) {
+void DebugScene::drawClip(const Common::Rect &rect) {
if (!showingClips) {
return;
}
_engine->_menu->drawBox(rect);
}
-void DebugScene::drawBoundingBoxProjectPoints(ScenePoint *pPoint3d, ScenePoint *pPoint3dProjected) {
+void DebugScene::drawBoundingBoxProjectPoints(Vec3 *pPoint3d, Vec3 *pPoint3dProjected) {
_engine->_renderer->projectPositionOnScreen(pPoint3d->x, pPoint3d->y, pPoint3d->z);
pPoint3dProjected->x = _engine->_renderer->projPos.x;
@@ -67,33 +65,33 @@ void DebugScene::drawBoundingBoxProjectPoints(ScenePoint *pPoint3d, ScenePoint *
}
}
-int32 DebugScene::checkZoneType(int32 type) {
+int32 DebugScene::checkZoneType(int32 type) const {
switch (type) {
- case 0:
+ case ZoneType::kCube:
if (typeZones & 0x01)
return 1;
break;
- case 1:
+ case ZoneType::kCamera:
if (typeZones & 0x02)
return 1;
break;
- case 2:
+ case ZoneType::kSceneric:
if (typeZones & 0x04)
return 1;
break;
- case 3:
+ case ZoneType::kGrid:
if (typeZones & 0x08)
return 1;
break;
- case 4:
+ case ZoneType::kObject:
if (typeZones & 0x10)
return 1;
break;
- case 5:
+ case ZoneType::kText:
if (typeZones & 0x20)
return 1;
break;
- case 6:
+ case ZoneType::kLadder:
if (typeZones & 0x40)
return 1;
break;
@@ -104,122 +102,163 @@ int32 DebugScene::checkZoneType(int32 type) {
return 0;
}
-void DebugScene::displayZones() {
- if (!showingZones) {
- return;
- }
- for (int z = 0; z < _engine->_scene->sceneNumZones; z++) {
- const ZoneStruct *zonePtr = &_engine->_scene->sceneZones[z];
+DebugScene::ScenePositionsProjected DebugScene::calculateBoxPositions(const Vec3 &bottomLeft, const Vec3 &topRight) {
+ ScenePositionsProjected positions;
+ // compute the points in 3D
+ positions.frontBottomLeftPoint.x = bottomLeft.x - _engine->_grid->camera.x;
+ positions.frontBottomLeftPoint.y = bottomLeft.y - _engine->_grid->camera.y;
+ positions.frontBottomLeftPoint.z = topRight.z - _engine->_grid->camera.z;
+
+ positions.frontBottomRightPoint.x = topRight.x - _engine->_grid->camera.x;
+ positions.frontBottomRightPoint.y = bottomLeft.y - _engine->_grid->camera.y;
+ positions.frontBottomRightPoint.z = topRight.z - _engine->_grid->camera.z;
+
+ positions.frontTopLeftPoint.x = bottomLeft.x - _engine->_grid->camera.x;
+ positions.frontTopLeftPoint.y = topRight.y - _engine->_grid->camera.y;
+ positions.frontTopLeftPoint.z = topRight.z - _engine->_grid->camera.z;
+
+ positions.frontTopRightPoint.x = topRight.x - _engine->_grid->camera.x;
+ positions.frontTopRightPoint.y = topRight.y - _engine->_grid->camera.y;
+ positions.frontTopRightPoint.z = topRight.z - _engine->_grid->camera.z;
+
+ positions.backBottomLeftPoint.x = bottomLeft.x - _engine->_grid->camera.x;
+ positions.backBottomLeftPoint.y = bottomLeft.y - _engine->_grid->camera.y;
+ positions.backBottomLeftPoint.z = bottomLeft.z - _engine->_grid->camera.z;
+
+ positions.backBottomRightPoint.x = topRight.x - _engine->_grid->camera.x;
+ positions.backBottomRightPoint.y = bottomLeft.y - _engine->_grid->camera.y;
+ positions.backBottomRightPoint.z = bottomLeft.z - _engine->_grid->camera.z;
+
+ positions.backTopLeftPoint.x = bottomLeft.x - _engine->_grid->camera.x;
+ positions.backTopLeftPoint.y = topRight.y - _engine->_grid->camera.y;
+ positions.backTopLeftPoint.z = bottomLeft.z - _engine->_grid->camera.z;
+
+ positions.backTopRightPoint.x = topRight.x - _engine->_grid->camera.x;
+ positions.backTopRightPoint.y = topRight.y - _engine->_grid->camera.y;
+ positions.backTopRightPoint.z = bottomLeft.z - _engine->_grid->camera.z;
+
+ // project all points
+
+ drawBoundingBoxProjectPoints(&positions.frontBottomLeftPoint, &positions.frontBottomLeftPoint2D);
+ drawBoundingBoxProjectPoints(&positions.frontBottomRightPoint, &positions.frontBottomRightPoint2D);
+ drawBoundingBoxProjectPoints(&positions.frontTopLeftPoint, &positions.frontTopLeftPoint2D);
+ drawBoundingBoxProjectPoints(&positions.frontTopRightPoint, &positions.frontTopRightPoint2D);
+ drawBoundingBoxProjectPoints(&positions.backBottomLeftPoint, &positions.backBottomLeftPoint2D);
+ drawBoundingBoxProjectPoints(&positions.backBottomRightPoint, &positions.backBottomRightPoint2D);
+ drawBoundingBoxProjectPoints(&positions.backTopLeftPoint, &positions.backTopLeftPoint2D);
+ drawBoundingBoxProjectPoints(&positions.backTopRightPoint, &positions.backTopRightPoint2D);
+
+ return positions;
+}
- if (!checkZoneType(zonePtr->type)) {
+bool DebugScene::drawBox(const ScenePositionsProjected &positions, uint8 color) {
+ bool state = false;
+ // draw front part
+ state |= _engine->_interface->drawLine(positions.frontBottomLeftPoint2D.x, positions.frontBottomLeftPoint2D.y, positions.frontTopLeftPoint2D.x, positions.frontTopLeftPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.frontTopLeftPoint2D.x, positions.frontTopLeftPoint2D.y, positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, positions.frontBottomRightPoint2D.x, positions.frontBottomRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.frontBottomRightPoint2D.x, positions.frontBottomRightPoint2D.y, positions.frontBottomLeftPoint2D.x, positions.frontBottomLeftPoint2D.y, color);
+
+ // draw top part
+ state |= _engine->_interface->drawLine(positions.frontTopLeftPoint2D.x, positions.frontTopLeftPoint2D.y, positions.backTopLeftPoint2D.x, positions.backTopLeftPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.backTopLeftPoint2D.x, positions.backTopLeftPoint2D.y, positions.backTopRightPoint2D.x, positions.backTopRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.backTopRightPoint2D.x, positions.backTopRightPoint2D.y, positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, positions.frontTopLeftPoint2D.x, positions.frontTopLeftPoint2D.y, color);
+
+ // draw back part
+ state |= _engine->_interface->drawLine(positions.backBottomLeftPoint2D.x, positions.backBottomLeftPoint2D.y, positions.backTopLeftPoint2D.x, positions.backTopLeftPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.backTopLeftPoint2D.x, positions.backTopLeftPoint2D.y, positions.backTopRightPoint2D.x, positions.backTopRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.backTopRightPoint2D.x, positions.backTopRightPoint2D.y, positions.backBottomRightPoint2D.x, positions.backBottomRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.backBottomRightPoint2D.x, positions.backBottomRightPoint2D.y, positions.backBottomLeftPoint2D.x, positions.backBottomLeftPoint2D.y, color);
+
+ // draw bottom part
+ state |= _engine->_interface->drawLine(positions.frontBottomLeftPoint2D.x, positions.frontBottomLeftPoint2D.y, positions.backBottomLeftPoint2D.x, positions.backBottomLeftPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.backBottomLeftPoint2D.x, positions.backBottomLeftPoint2D.y, positions.backBottomRightPoint2D.x, positions.backBottomRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.backBottomRightPoint2D.x, positions.backBottomRightPoint2D.y, positions.frontBottomRightPoint2D.x, positions.frontBottomRightPoint2D.y, color);
+ state |= _engine->_interface->drawLine(positions.frontBottomRightPoint2D.x, positions.frontBottomRightPoint2D.y, positions.frontBottomLeftPoint2D.x, positions.frontBottomLeftPoint2D.y, color);
+
+ return state;
+}
+
+// TODO: redrawing doesn't work properly yet for moving actors
+bool DebugScene::displayActors() {
+ bool state = false;
+ for (int i = 0; i < _engine->_scene->sceneNumActors; i++) {
+ const ActorStruct *actorPtr = _engine->_scene->getActor(i);
+ const Vec3 &pos = actorPtr->pos;
+ const ZVBox &bbox = actorPtr->boudingBox;
+ const Vec3 mins(bbox.x.bottomLeft, bbox.y.bottomLeft, bbox.z.bottomLeft);
+ const Vec3 maxs(bbox.x.topRight, bbox.y.topRight, bbox.z.topRight);
+ const ScenePositionsProjected &positions = calculateBoxPositions(pos + mins, pos + maxs);
+ if (!drawBox(positions, COLOR_WHITE)) {
continue;
}
- ScenePoint frontBottomLeftPoint;
- ScenePoint frontBottomRightPoint;
-
- ScenePoint frontTopLeftPoint;
- ScenePoint frontTopRightPoint;
-
- ScenePoint backBottomLeftPoint;
- ScenePoint backBottomRightPoint;
-
- ScenePoint backTopLeftPoint;
- ScenePoint backTopRightPoint;
-
- ScenePoint frontBottomLeftPoint2D;
- ScenePoint frontBottomRightPoint2D;
-
- ScenePoint frontTopLeftPoint2D;
- ScenePoint frontTopRightPoint2D;
-
- ScenePoint backBottomLeftPoint2D;
- ScenePoint backBottomRightPoint2D;
-
- ScenePoint backTopLeftPoint2D;
- ScenePoint backTopRightPoint2D;
-
- // compute the points in 3D
-
- frontBottomLeftPoint.x = zonePtr->bottomLeft.x - _engine->_grid->camera.x;
- frontBottomLeftPoint.y = zonePtr->bottomLeft.y - _engine->_grid->camera.y;
- frontBottomLeftPoint.z = zonePtr->topRight.z - _engine->_grid->camera.z;
-
- frontBottomRightPoint.x = zonePtr->topRight.x - _engine->_grid->camera.x;
- frontBottomRightPoint.y = zonePtr->bottomLeft.y - _engine->_grid->camera.y;
- frontBottomRightPoint.z = zonePtr->topRight.z - _engine->_grid->camera.z;
-
- frontTopLeftPoint.x = zonePtr->bottomLeft.x - _engine->_grid->camera.x;
- frontTopLeftPoint.y = zonePtr->topRight.y - _engine->_grid->camera.y;
- frontTopLeftPoint.z = zonePtr->topRight.z - _engine->_grid->camera.z;
-
- frontTopRightPoint.x = zonePtr->topRight.x - _engine->_grid->camera.x;
- frontTopRightPoint.y = zonePtr->topRight.y - _engine->_grid->camera.y;
- frontTopRightPoint.z = zonePtr->topRight.z - _engine->_grid->camera.z;
-
- backBottomLeftPoint.x = zonePtr->bottomLeft.x - _engine->_grid->camera.x;
- backBottomLeftPoint.y = zonePtr->bottomLeft.y - _engine->_grid->camera.y;
- backBottomLeftPoint.z = zonePtr->bottomLeft.z - _engine->_grid->camera.z;
-
- backBottomRightPoint.x = zonePtr->topRight.x - _engine->_grid->camera.x;
- backBottomRightPoint.y = zonePtr->bottomLeft.y - _engine->_grid->camera.y;
- backBottomRightPoint.z = zonePtr->bottomLeft.z - _engine->_grid->camera.z;
-
- backTopLeftPoint.x = zonePtr->bottomLeft.x - _engine->_grid->camera.x;
- backTopLeftPoint.y = zonePtr->topRight.y - _engine->_grid->camera.y;
- backTopLeftPoint.z = zonePtr->bottomLeft.z - _engine->_grid->camera.z;
-
- backTopRightPoint.x = zonePtr->topRight.x - _engine->_grid->camera.x;
- backTopRightPoint.y = zonePtr->topRight.y - _engine->_grid->camera.y;
- backTopRightPoint.z = zonePtr->bottomLeft.z - _engine->_grid->camera.z;
-
- // project all points
-
- drawBoundingBoxProjectPoints(&frontBottomLeftPoint, &frontBottomLeftPoint2D);
- drawBoundingBoxProjectPoints(&frontBottomRightPoint, &frontBottomRightPoint2D);
- drawBoundingBoxProjectPoints(&frontTopLeftPoint, &frontTopLeftPoint2D);
- drawBoundingBoxProjectPoints(&frontTopRightPoint, &frontTopRightPoint2D);
- drawBoundingBoxProjectPoints(&backBottomLeftPoint, &backBottomLeftPoint2D);
- drawBoundingBoxProjectPoints(&backBottomRightPoint, &backBottomRightPoint2D);
- drawBoundingBoxProjectPoints(&backTopLeftPoint, &backTopLeftPoint2D);
- drawBoundingBoxProjectPoints(&backTopRightPoint, &backTopRightPoint2D);
+ const int boxwidth = 150;
+ const int lineHeight = 14;
+ const int boxheight = 2 * lineHeight;
+ const Common::Rect filledRect(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, positions.frontTopRightPoint2D.x + boxwidth, positions.frontTopRightPoint2D.y + boxheight);
+ _engine->_interface->drawFilledRect(filledRect, COLOR_WHITE);
+ _engine->_menu->drawBox(filledRect);
+ _engine->drawText(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, Common::String::format("Actor: %i", i), true, false, boxwidth);
+ _engine->drawText(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y + lineHeight, Common::String::format("pos: %i:%i:%i", positions.frontTopRightPoint.x, positions.frontTopRightPoint.y, positions.frontTopRightPoint.z), true, false, boxwidth);
+ state = true;
+ }
+ return state;
+}
- // draw all lines
+// TODO: implement the rendering points of all tracks as a dot with the id
+bool DebugScene::displayTracks() {
+#if 0
+ for (int i = 0; i < _engine->_scene->sceneNumTracks; i++) {
+ const Vec3 *trackPoint = &_engine->_scene->sceneTracks[i];
- uint8 color = 15 * 3 + zonePtr->type * 16;
+ }
+#endif
+ return false;
+}
- // draw front part
- _engine->_interface->drawLine(frontBottomLeftPoint2D.x, frontBottomLeftPoint2D.y, frontTopLeftPoint2D.x, frontTopLeftPoint2D.y, color);
- _engine->_interface->drawLine(frontTopLeftPoint2D.x, frontTopLeftPoint2D.y, frontTopRightPoint2D.x, frontTopRightPoint2D.y, color);
- _engine->_interface->drawLine(frontTopRightPoint2D.x, frontTopRightPoint2D.y, frontBottomRightPoint2D.x, frontBottomRightPoint2D.y, color);
- _engine->_interface->drawLine(frontBottomRightPoint2D.x, frontBottomRightPoint2D.y, frontBottomLeftPoint2D.x, frontBottomLeftPoint2D.y, color);
+bool DebugScene::displayZones() {
+ bool state = false;
+ for (int i = 0; i < _engine->_scene->sceneNumZones; i++) {
+ const ZoneStruct *zonePtr = &_engine->_scene->sceneZones[i];
- // draw top part
- _engine->_interface->drawLine(frontTopLeftPoint2D.x, frontTopLeftPoint2D.y, backTopLeftPoint2D.x, backTopLeftPoint2D.y, color);
- _engine->_interface->drawLine(backTopLeftPoint2D.x, backTopLeftPoint2D.y, backTopRightPoint2D.x, backTopRightPoint2D.y, color);
- _engine->_interface->drawLine(backTopRightPoint2D.x, backTopRightPoint2D.y, frontTopRightPoint2D.x, frontTopRightPoint2D.y, color);
- _engine->_interface->drawLine(frontTopRightPoint2D.x, frontTopRightPoint2D.y, frontTopLeftPoint2D.x, frontTopLeftPoint2D.y, color);
+ if (!checkZoneType(zonePtr->type)) {
+ continue;
+ }
- // draw back part
- _engine->_interface->drawLine(backBottomLeftPoint2D.x, backBottomLeftPoint2D.y, backTopLeftPoint2D.x, backTopLeftPoint2D.y, color);
- _engine->_interface->drawLine(backTopLeftPoint2D.x, backTopLeftPoint2D.y, backTopRightPoint2D.x, backTopRightPoint2D.y, color);
- _engine->_interface->drawLine(backTopRightPoint2D.x, backTopRightPoint2D.y, backBottomRightPoint2D.x, backBottomRightPoint2D.y, color);
- _engine->_interface->drawLine(backBottomRightPoint2D.x, backBottomRightPoint2D.y, backBottomLeftPoint2D.x, backBottomLeftPoint2D.y, color);
+ const ScenePositionsProjected &positions = calculateBoxPositions(zonePtr->bottomLeft, zonePtr->topRight);
+ const uint8 color = 15 * 3 + zonePtr->type * 16;
+ if (!drawBox(positions, color)) {
+ continue;
+ }
- // draw bottom part
- _engine->_interface->drawLine(frontBottomLeftPoint2D.x, frontBottomLeftPoint2D.y, backBottomLeftPoint2D.x, backBottomLeftPoint2D.y, color);
- _engine->_interface->drawLine(backBottomLeftPoint2D.x, backBottomLeftPoint2D.y, backBottomRightPoint2D.x, backBottomRightPoint2D.y, color);
- _engine->_interface->drawLine(backBottomRightPoint2D.x, backBottomRightPoint2D.y, frontBottomRightPoint2D.x, frontBottomRightPoint2D.y, color);
- _engine->_interface->drawLine(frontBottomRightPoint2D.x, frontBottomRightPoint2D.y, frontBottomLeftPoint2D.x, frontBottomLeftPoint2D.y, color);
const int boxwidth = 150;
const int lineHeight = 14;
const int boxheight = 2 * lineHeight;
- const Common::Rect filledRect(frontTopRightPoint2D.x, frontTopRightPoint2D.y, frontTopRightPoint2D.x + boxwidth, frontTopRightPoint2D.y + boxheight);
+ const Common::Rect filledRect(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, positions.frontTopRightPoint2D.x + boxwidth, positions.frontTopRightPoint2D.y + boxheight);
_engine->_interface->drawFilledRect(filledRect, COLOR_WHITE);
_engine->_menu->drawBox(filledRect);
- _engine->drawText(frontTopRightPoint2D.x, frontTopRightPoint2D.y, Common::String::format("Type: %i (%i)", zonePtr->type, z), true, false, boxwidth);
- _engine->drawText(frontTopRightPoint2D.x, frontTopRightPoint2D.y + lineHeight, Common::String::format("pos: %i:%i:%i", frontTopRightPoint.x, frontTopRightPoint.y, frontTopRightPoint.z), true, false, boxwidth);
+ _engine->drawText(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y, Common::String::format("Type: %i (%i)", zonePtr->type, i), true, false, boxwidth);
+ _engine->drawText(positions.frontTopRightPoint2D.x, positions.frontTopRightPoint2D.y + lineHeight, Common::String::format("pos: %i:%i:%i", positions.frontTopRightPoint.x, positions.frontTopRightPoint.y, positions.frontTopRightPoint.z), true, false, boxwidth);
+ state = true;
+ }
+ return state;
+}
+
+void DebugScene::renderDebugView() {
+ bool dirty = false;
+ if (showingZones) {
+ dirty |= displayZones();
+ }
+ if (showingActors) {
+ dirty |= displayActors();
+ }
+ if (showingTracks) {
+ dirty |= displayTracks();
+ }
+ if (dirty) {
+ _engine->flip();
}
- _engine->flip();
}
} // namespace TwinE
diff --git a/engines/twine/debugger/debug_scene.h b/engines/twine/debugger/debug_scene.h
index 25e3f22e20..e7e75093fa 100644
--- a/engines/twine/debugger/debug_scene.h
+++ b/engines/twine/debugger/debug_scene.h
@@ -25,29 +25,63 @@
#include "common/rect.h"
#include "common/scummsys.h"
+#include "twine/shared.h"
namespace TwinE {
class TwinEEngine;
-struct ScenePoint;
class DebugScene {
private:
TwinEEngine *_engine;
- void drawBoundingBoxProjectPoints(ScenePoint *point3d, ScenePoint *point3dProjected);
- int32 checkZoneType(int32 type);
+ void drawBoundingBoxProjectPoints(Vec3 *point3d, Vec3 *point3dProjected);
+ int32 checkZoneType(int32 type) const;
+ bool displayZones();
+ bool displayActors();
+ bool displayTracks();
+
+ struct ScenePositionsProjected {
+ Vec3 frontBottomLeftPoint;
+ Vec3 frontBottomRightPoint;
+
+ Vec3 frontTopLeftPoint;
+ Vec3 frontTopRightPoint;
+
+ Vec3 backBottomLeftPoint;
+ Vec3 backBottomRightPoint;
+
+ Vec3 backTopLeftPoint;
+ Vec3 backTopRightPoint;
+
+ Vec3 frontBottomLeftPoint2D;
+ Vec3 frontBottomRightPoint2D;
+
+ Vec3 frontTopLeftPoint2D;
+ Vec3 frontTopRightPoint2D;
+
+ Vec3 backBottomLeftPoint2D;
+ Vec3 backBottomRightPoint2D;
+
+ Vec3 backTopLeftPoint2D;
+ Vec3 backTopRightPoint2D;
+ };
+
+ ScenePositionsProjected calculateBoxPositions(const Vec3 &bottomLeft, const Vec3 &topRight);
+ bool drawBox(const ScenePositionsProjected &positions, uint8 color);
public:
DebugScene(TwinEEngine *engine);
bool showingZones = false;
+ bool showingActors = false;
+ bool showingTracks = false;
bool showingClips = false;
bool useScenePatches = false;
int32 typeZones = 127; // all zones on as default
int16 onlyLoadActor = -1;
- void displayZones();
+ void renderDebugView();
- void drawClip(const Common::Rect& rect);
+ void drawClip(const Common::Rect &rect);
};
} // namespace TwinE
diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index cca553247c..158c12260a 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -50,7 +50,7 @@ int32 Interface::checkClipping(int32 x, int32 y) const {
}
// TODO: check if Graphics::drawLine() works here
-void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, uint8 lineColor) {
+bool Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, uint8 lineColor) {
// draw line from left to right
if (startWidth > endWidth) {
SWAP(endWidth, startWidth);
@@ -63,7 +63,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
while ((outcode0 | outcode1) != INSIDE) {
if ((outcode0 & outcode1) != INSIDE && outcode0 != INSIDE) {
- return; // Reject lines which are behind one clipping plane
+ return false; // Reject lines which are behind one clipping plane
}
// At least one endpoint is outside the clip rectangle; pick it.
@@ -137,6 +137,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
}
} while (--endWidth);
}
+ return true;
}
void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface &source, Graphics::ManagedSurface &dest) {
diff --git a/engines/twine/menu/interface.h b/engines/twine/menu/interface.h
index 242dfd3cc6..f557c90721 100644
--- a/engines/twine/menu/interface.h
+++ b/engines/twine/menu/interface.h
@@ -52,7 +52,7 @@ public:
* @param endHeight height value where the line ends
* @param lineColor line color in the current palette
*/
- void drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, uint8 lineColor);
+ bool drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, uint8 lineColor);
/**
* Blit button box from working buffer to front buffer
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 2532133c0d..1022cbd3dc 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -220,8 +220,8 @@ int32 Redraw::fillActorDrawingList(bool bgRedraw) {
// if actor is above another actor
if (actor->standOn != -1) {
- const ActorStruct *standOnActor = _engine->_scene->getActor(actor->standOn);
- tmpVal = standOnActor->pos.x - _engine->_grid->camera.x + standOnActor->pos.z - _engine->_grid->camera.z + 2;
+ //const ActorStruct *standOnActor = _engine->_scene->getActor(actor->standOn);
+ //tmpVal = standOnActor->pos.x - _engine->_grid->camera.x + standOnActor->pos.z - _engine->_grid->camera.z + 2;
}
if (actor->staticFlags.bIsSpriteActor) {
@@ -453,7 +453,7 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
}
// show clipping area
- //drawBox(renderRect.left, renderRect.top, renderRect.right, renderRect.bottom);
+ //_engine->_debugScene->drawClip(renderRect);
}
}
@@ -707,7 +707,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) {
processDrawList(drawListPos, bgRedraw);
if (_engine->cfgfile.Debug) {
- _engine->_debugScene->displayZones();
+ _engine->_debugScene->renderDebugView();
}
renderOverlays();
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 25bcfd20a8..ff8aa9e1ba 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -262,7 +262,7 @@ bool Scene::loadSceneLBA2() {
sceneNumTracks = stream.readUint16LE();
for (int32 i = 0; i < sceneNumTracks; i++) {
- ScenePoint *point = &sceneTracks[i];
+ Vec3 *point = &sceneTracks[i];
point->x = stream.readSint32LE();
point->y = stream.readSint32LE();
point->z = stream.readSint32LE();
@@ -387,13 +387,14 @@ bool Scene::loadSceneLBA1() {
sceneNumTracks = stream.readUint16LE();
for (int32 i = 0; i < sceneNumTracks; i++) {
- ScenePoint *point = &sceneTracks[i];
+ Vec3 *point = &sceneTracks[i];
point->x = stream.readUint16LE();
point->y = stream.readUint16LE();
point->z = stream.readUint16LE();
}
if (_engine->_debugScene->useScenePatches) {
+ // TODO: these were found in the disassembly and might be some script fixes - check me and activate me
switch (currentSceneIdx) {
case LBA1SceneId::Hamalayi_Mountains_landing_place:
assert(sceneNumActors >= 22);
diff --git a/engines/twine/scene/scene.h b/engines/twine/scene/scene.h
index 474e5da02e..48c7ead233 100644
--- a/engines/twine/scene/scene.h
+++ b/engines/twine/scene/scene.h
@@ -45,18 +45,12 @@ enum class ScenePositionType {
// ZONES
-struct ScenePoint {
- int16 x = 0;
- int16 y = 0;
- int16 z = 0;
-};
-
/**
* Special actions, like change scene, climbing a ladder, ...
*/
struct ZoneStruct {
- ScenePoint bottomLeft;
- ScenePoint topRight;
+ Vec3 bottomLeft;
+ Vec3 topRight;
int16 type = 0;
int16 snap = 0;
union {
@@ -351,7 +345,7 @@ public:
// TRACKS Tell the actor where to go
int32 sceneNumTracks = 0;
- ScenePoint sceneTracks[NUM_MAX_TRACKS];
+ Vec3 sceneTracks[NUM_MAX_TRACKS];
bool enableGridTileRendering = true;
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index 6dcc1f37fd..f6b41b1b41 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -1115,7 +1115,7 @@ static int32 lZOOM(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lPOS_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
int32 trackIdx = ctx.stream.readByte();
- const ScenePoint &sp = engine->_scene->sceneTracks[trackIdx];
+ const Vec3 &sp = engine->_scene->sceneTracks[trackIdx];
engine->_renderer->destPos.x = sp.x;
engine->_renderer->destPos.y = sp.y;
engine->_renderer->destPos.z = sp.z;
diff --git a/engines/twine/script/script_move_v1.cpp b/engines/twine/script/script_move_v1.cpp
index 977149b8d6..44d3baaced 100644
--- a/engines/twine/script/script_move_v1.cpp
+++ b/engines/twine/script/script_move_v1.cpp
@@ -116,7 +116,7 @@ static int32 mANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
static int32 mGOTO_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
engine->_scene->currentScriptValue = ctx.stream.readByte();
- const ScenePoint &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
+ const Vec3 &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
engine->_renderer->destPos.x = sp.x;
engine->_renderer->destPos.y = sp.y;
engine->_renderer->destPos.z = sp.z;
@@ -188,7 +188,7 @@ static int32 mANGLE(TwinEEngine *engine, MoveScriptContext &ctx) {
static int32 mPOS_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
engine->_scene->currentScriptValue = ctx.stream.readByte();
- const ScenePoint &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
+ const Vec3 &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
engine->_renderer->destPos.x = sp.x;
engine->_renderer->destPos.y = sp.y;
engine->_renderer->destPos.z = sp.z;
@@ -248,7 +248,7 @@ static int32 mSTOP(TwinEEngine *engine, MoveScriptContext &ctx) {
static int32 mGOTO_SYM_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
engine->_scene->currentScriptValue = ctx.stream.readByte();
- const ScenePoint &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
+ const Vec3 &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
engine->_renderer->destPos.x = sp.x;
engine->_renderer->destPos.y = sp.y;
engine->_renderer->destPos.z = sp.z;
@@ -321,7 +321,7 @@ static int32 mGOTO_POINT_3D(TwinEEngine *engine, MoveScriptContext &ctx) {
engine->_scene->currentScriptValue = trackId;
- const ScenePoint &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
+ const Vec3 &sp = engine->_scene->sceneTracks[engine->_scene->currentScriptValue];
engine->_renderer->destPos.x = sp.x;
engine->_renderer->destPos.y = sp.y;
engine->_renderer->destPos.z = sp.z;
More information about the Scummvm-git-logs
mailing list