TWINE: removed ScenePoint and added actor debug rendering

This commit is contained in:
Martin Gerhardy 2021-03-15 22:11:15 +01:00
parent bacdce7328
commit 70fd4f428d
11 changed files with 227 additions and 144 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
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;
}
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;
}
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;
}
for (int z = 0; z < _engine->_scene->sceneNumZones; z++) {
const ZoneStruct *zonePtr = &_engine->_scene->sceneZones[z];
return state;
}
// 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];
}
#endif
return false;
}
bool DebugScene::displayZones() {
bool state = false;
for (int i = 0; i < _engine->_scene->sceneNumZones; i++) {
const ZoneStruct *zonePtr = &_engine->_scene->sceneZones[i];
if (!checkZoneType(zonePtr->type)) {
continue;
}
ScenePoint frontBottomLeftPoint;
ScenePoint frontBottomRightPoint;
ScenePoint frontTopLeftPoint;
ScenePoint frontTopRightPoint;
const ScenePositionsProjected &positions = calculateBoxPositions(zonePtr->bottomLeft, zonePtr->topRight);
const uint8 color = 15 * 3 + zonePtr->type * 16;
if (!drawBox(positions, color)) {
continue;
}
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);
// draw all lines
uint8 color = 15 * 3 + zonePtr->type * 16;
// 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);
// 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);
// 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);
// 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

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;