[Scummvm-git-logs] scummvm master -> aaf47ea195c302ba003b18f70bef5a85e130e352
mgerhardy
noreply at scummvm.org
Thu Aug 18 15:08:55 UTC 2022
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c39ea9499b TWINE: depth sorting issue for doors
5dddc23714 TWINE: fixed giving kashes as replacements where it should have been life points
26cce38137 TWINE: extract to local variables
d1be8e523e TWINE: todo comment
aaf47ea195 TWINE: Items/pickups start flashing the moment they pop out.
Commit: c39ea9499bdc600aba16f81898fc298d0eec72f6
https://github.com/scummvm/scummvm/commit/c39ea9499bdc600aba16f81898fc298d0eec72f6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2022-08-18T17:08:43+02:00
Commit Message:
TWINE: depth sorting issue for doors
https://bugs.scummvm.org/ticket/12085
Changed paths:
engines/twine/renderer/redraw.cpp
engines/twine/renderer/redraw.h
engines/twine/renderer/renderer.h
engines/twine/scene/actor.h
engines/twine/scene/extra.cpp
engines/twine/scene/scene.h
engines/twine/shared.h
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index abfc830e5af..ef8d1e4c878 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -199,7 +199,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool bgRedraw) {
// get actor position on screen
const IVec3 &projPos = _engine->_renderer->projectPositionOnScreen(actor->pos() - _engine->_grid->_camera);
// check if actor is visible on screen, otherwise don't display it
- if (projPos.x > -50 && projPos.x < _engine->width() + 40 && projPos.y > -30 && projPos.y < _engine->height() + 100) {
+ if (projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine)) {
actor->_dynamicFlags.bIsDrawn = 1;
}
continue;
@@ -212,9 +212,9 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool bgRedraw) {
const IVec3 &projPos = _engine->_renderer->projectPositionOnScreen(actor->pos() - _engine->_grid->_camera);
if ((actor->_staticFlags.bUsesClipping && projPos.x > -112 && projPos.x < _engine->width() + 112 && projPos.y > -50 && projPos.y < _engine->height() + 171) ||
- ((!actor->_staticFlags.bUsesClipping) && projPos.x > -50 && projPos.x < _engine->width() + 40 && projPos.y > -30 && projPos.y < _engine->height() + 100)) {
+ ((!actor->_staticFlags.bUsesClipping) && projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine))) {
- int32 ztri = actor->_pos.z + actor->_pos.x - _engine->_grid->_camera.x - _engine->_grid->_camera.z;
+ int32 ztri = actor->_pos.x - _engine->_grid->_camera.x + actor->_pos.z - _engine->_grid->_camera.z;
// if actor is above another actor
if (actor->_carryBy != -1) {
@@ -229,7 +229,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool bgRedraw) {
ztri = actor->_animStep.x - _engine->_grid->_camera.x + actor->_animStep.z - _engine->_grid->_camera.z;
}
} else {
- drawList[drawListPos].type = 0;
+ drawList[drawListPos].type = DrawListType::DrawObject3D;
drawList[drawListPos].actorIdx = a;
}
@@ -265,7 +265,7 @@ int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool bgRedraw) {
return drawListPos;
}
-int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos) {
+int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos) { // part of AffScene
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &_engine->_extra->_extraList[i];
if (extra->sprite == -1) {
@@ -279,10 +279,10 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
}
continue;
}
- if ((extra->type & ExtraType::TIME_OUT) || (extra->type & ExtraType::FLASH) || (extra->payload.lifeTime + extra->spawnTime - 150 < _engine->_lbaTime) || (!((_engine->_lbaTime + extra->spawnTime) & 8))) {
+ if ((extra->type & ExtraType::TIME_OUT) || (extra->type & ExtraType::FLASH) || (extra->payload.lifeTime + extra->spawnTime - TO_SECONDS(3) < _engine->_lbaTime) || (!((_engine->_lbaTime + extra->spawnTime) & 8))) {
const IVec3 &projPos = _engine->_renderer->projectPositionOnScreen(extra->pos - _engine->_grid->_camera);
- if (projPos.x > -50 && projPos.x < _engine->width() + 40 && projPos.y > -30 && projPos.y < _engine->height() + 100) {
+ if (projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine)) {
const int16 tmpVal = extra->pos.x - _engine->_grid->_camera.x + extra->pos.z - _engine->_grid->_camera.z;
drawList[drawListPos].posValue = tmpVal;
drawList[drawListPos].actorIdx = i;
@@ -481,6 +481,123 @@ void Redraw::processDrawListExtras(const DrawListStruct &drawCmd) {
}
}
+void Redraw::correctZLevels(DrawListStruct *drawList, int32 drawListPos) {
+ ActorStruct *ptrobj = _engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX);
+ if (ptrobj->_staticFlags.bIsHidden || ptrobj->_body == -1) {
+ return;
+ }
+
+ IVec3 tmin = ptrobj->pos() + ptrobj->_boundingBox.mins;
+ IVec3 tmax = ptrobj->pos() + ptrobj->_boundingBox.maxs;
+ int32 twinsenpos = -1;
+ int32 twinsenz = -1;
+ for (int32 pos = 0; pos < drawListPos; ++pos) {
+ DrawListStruct &drawCmd = drawList[pos];
+ if (drawCmd.type == DrawListType::DrawObject3D && drawCmd.actorIdx == OWN_ACTOR_SCENE_INDEX) {
+ twinsenpos = pos;
+ twinsenz = drawCmd.posValue;
+ break;
+ }
+ }
+
+ if (twinsenpos == -1) {
+ return;
+ }
+
+ for (int32 n = 0; n < drawListPos; ++n) {
+ DrawListStruct &ptrtri = drawList[n];
+ uint32 typeobj = ptrtri.type;
+ int32 numobj = ptrtri.actorIdx;
+ ptrobj = _engine->_scene->getActor(numobj);
+ switch (typeobj) {
+ default:
+ break;
+ case DrawListType::DrawActorSprites:
+ if (ptrobj->_staticFlags.bUsesClipping) {
+ IVec3 pmin = ptrobj->_animStep + ptrobj->_boundingBox.mins;
+ IVec3 pmax = ptrobj->_animStep + ptrobj->_boundingBox.maxs;
+
+ if (pmax.x > tmin.x && pmin.x < tmax.x) {
+ if (pmax.z <= tmin.z) {
+ // twinsen after
+ if (twinsenz < ptrtri.posValue) {
+ // correct the error
+ drawList[twinsenpos].posValue = ptrtri.posValue;
+ drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
+ drawList[twinsenpos].type = ptrtri.type;
+
+ ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+ ptrtri.type = DrawListType::DrawObject3D;
+ ptrtri.posValue = (int16)twinsenz;
+
+ twinsenpos = n;
+ numobj = -1;
+ break;
+ }
+ }
+ if (pmin.z >= tmax.z) {
+ // twinsen before
+ if (twinsenz > ptrtri.posValue) {
+ // correct the error
+ drawList[twinsenpos].posValue = ptrtri.posValue;
+ drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
+ drawList[twinsenpos].type = ptrtri.type;
+
+ ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+ ptrtri.type = DrawListType::DrawObject3D;
+ ptrtri.posValue = (int16)twinsenz;
+
+ twinsenpos = n;
+ numobj = -1;
+ break;
+ }
+ }
+ }
+
+ if (pmax.z > tmin.z && pmin.z < tmax.z) {
+ if (pmax.x <= tmin.x) {
+ // twinsen after
+ if (twinsenz < ptrtri.posValue) {
+ // correct the error
+ drawList[twinsenpos].posValue = ptrtri.posValue;
+ drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
+ drawList[twinsenpos].type = ptrtri.type;
+
+ ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+ ptrtri.type = DrawListType::DrawObject3D;
+ ptrtri.posValue = (int16)twinsenz;
+
+ twinsenpos = n;
+ numobj = -1;
+ break;
+ }
+ } else {
+ // twinsen before
+ if (twinsenz > ptrtri.posValue) {
+ // correct the error
+ drawList[twinsenpos].posValue = ptrtri.posValue;
+ drawList[twinsenpos].actorIdx = ptrtri.actorIdx;
+ drawList[twinsenpos].type = ptrtri.type;
+
+ ptrtri.actorIdx = OWN_ACTOR_SCENE_INDEX;
+ ptrtri.type = DrawListType::DrawObject3D;
+ ptrtri.posValue = (int16)twinsenz;
+
+ twinsenpos = n;
+ numobj = -1;
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+ if (numobj == -1) {
+ break;
+ }
+ }
+}
+
void Redraw::processDrawList(DrawListStruct *drawList, int32 drawListPos, bool bgRedraw) {
for (int32 pos = 0; pos < drawListPos; ++pos) {
const DrawListStruct &drawCmd = drawList[pos];
@@ -698,12 +815,13 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // AffScene
blitBackgroundAreas();
}
- DrawListStruct drawList[150];
+ DrawListStruct drawList[NUM_MAX_ACTORS + EXTRA_MAX_ENTRIES]; // ListTri[MAX_OBJECTS + MAX_EXTRAS]
int32 drawListPos = fillActorDrawingList(drawList, bgRedraw);
drawListPos = fillExtraDrawingList(drawList, drawListPos);
sortDrawingList(drawList, drawListPos);
_currNumOfRedrawBox = 0;
+ correctZLevels(drawList, drawListPos);
processDrawList(drawList, drawListPos, bgRedraw);
if (_engine->_cfgfile.Debug) {
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index 43f39d3b365..1f4292d16d0 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -128,6 +128,7 @@ private:
int32 fillActorDrawingList(DrawListStruct *drawList, bool bgRedraw);
int32 fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos);
+ void correctZLevels(DrawListStruct *drawList, int32 drawListPos);
void processDrawList(DrawListStruct *drawList, int32 drawListPos, bool bgRedraw);
void renderOverlays();
void renderText();
@@ -135,7 +136,7 @@ private:
public:
Redraw(TwinEEngine *engine);
- bool _inSceneryView = false;
+ bool _inSceneryView = false; // FlagMCGA
/** Request background redraw */
bool _firstTime = false;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index da37363a4e6..ed9f65ae2dc 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -239,7 +239,7 @@ public:
void fillVertices(int vtop, int32 vsize, uint8 renderType, uint16 color);
void renderPolygons(const CmdRenderPolygon &polygon, Vertex *vertices, int vtop, int vbottom);
- inline IVec3 &projectPositionOnScreen(const IVec3& pos) {
+ inline IVec3 &projectPositionOnScreen(const IVec3& pos) { // ProjettePoint
return projectPositionOnScreen(pos.x, pos.y, pos.z);
}
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 78d330f26a7..95bf9ff4885 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -176,7 +176,7 @@ public:
EntityData *_entityDataPtr = nullptr;
int16 _actorIdx = 0; // own actor index
- IVec3 _pos;
+ IVec3 _pos; // PosObjX, PosObjY, PosObjZ
int32 _strengthOfHit = 0;
int32 _hitBy = -1;
BonusParameter _bonusParameter;
@@ -231,7 +231,7 @@ public:
int32 _spriteActorRotation = 0;
uint8 _brickSound = 0U; // CodeJeu
- BoundingBox _boundingBox;
+ BoundingBox _boundingBox; // Xmin, YMin, Zmin, Xmax, Ymax, Zmax
ActorMoveStruct _move;
AnimTimerDataStruct _animTimerData;
};
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index f44316f3830..73a9f6392b1 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -231,7 +231,7 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle
extra->type = ExtraType::STOP_COL | ExtraType::TAKABLE | ExtraType::WAIT_SOME_TIME;
if (type != SPRITEHQR_KEY) {
- extra->type = ExtraType::TIME_OUT | ExtraType::TAKABLE | ExtraType::FLASH | ExtraType::STOP_COL | ExtraType::WAIT_SOME_TIME;
+ extra->type |= ExtraType::TIME_OUT | ExtraType::FLASH;
}
extra->pos.x = x;
diff --git a/engines/twine/scene/scene.h b/engines/twine/scene/scene.h
index 9b870f9ccd1..86669e1e780 100644
--- a/engines/twine/scene/scene.h
+++ b/engines/twine/scene/scene.h
@@ -125,7 +125,7 @@ private:
void resetScene();
// the first actor is the own hero
- ActorStruct _sceneActors[NUM_MAX_ACTORS];
+ ActorStruct _sceneActors[NUM_MAX_ACTORS]; // ListObjet
int32 _currentSceneSize = 0;
bool _isOutsideScene = false; // lba2
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 126b4bafcaf..50eee6cf987 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -617,6 +617,11 @@ struct TwineImage {
#define ANGLE_1 5 // 1.75
#define ANGLE_0 0
+#define VIEW_X0 (-50)
+#define VIEW_Y0 (-30)
+#define VIEW_X1(engine) ((engine)->width() - 40)
+#define VIEW_Y1(engine) ((engine)->height() + 100)
+
inline int32 NormalizeAngle(int32 angle) {
if (angle < -ANGLE_180) {
angle += ANGLE_360;
Commit: 5dddc23714a72e1485017ba37fc2f215c8f5a953
https://github.com/scummvm/scummvm/commit/5dddc23714a72e1485017ba37fc2f215c8f5a953
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2022-08-18T17:08:43+02:00
Commit Message:
TWINE: fixed giving kashes as replacements where it should have been life points
Changed paths:
engines/twine/scene/extra.cpp
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index 73a9f6392b1..f23fbb85899 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -215,7 +215,7 @@ int Extra::getBonusSprite(BonusParameter bonusParameter) const {
int8 bonusSprite = bonusSprites[bonusIndex];
// if bonus is magic an no magic level yet, then give life points
if (!_engine->_gameState->_magicLevelIdx && bonusSprite == SPRITEHQR_MAGICPOINTS) {
- bonusSprite = SPRITEHQR_KASHES;
+ bonusSprite = SPRITEHQR_LIFEPOINTS;
}
return bonusSprite;
@@ -241,7 +241,7 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle
throwExtra(extra, xAngle, yAngle, 40, ToAngle(15));
extra->strengthOfHit = 0;
- extra->payload.lifeTime = 1000;
+ extra->payload.lifeTime = TO_SECONDS(20);
extra->info1 = bonusAmount;
return i;
}
Commit: 26cce38137295c97dd849d9a66e628e2dbb82acb
https://github.com/scummvm/scummvm/commit/26cce38137295c97dd849d9a66e628e2dbb82acb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2022-08-18T17:08:43+02:00
Commit Message:
TWINE: extract to local variables
Changed paths:
engines/twine/scene/scene.cpp
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 6edeba496d6..c0bfba6701e 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -685,8 +685,10 @@ void Scene::processZoneExtraBonus(ZoneStruct *zone) {
}
const int32 amount = zone->infoData.Bonus.amount;
- const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(ABS(zone->maxs.x + zone->mins.x) / 2, ABS(zone->maxs.z + zone->mins.z) / 2, _sceneHero->_pos.x, _sceneHero->_pos.z);
- const int32 index = _engine->_extra->addExtraBonus(ABS(zone->maxs.x + zone->mins.x) / 2, zone->maxs.y, ABS(zone->maxs.z + zone->mins.z) / 2, ANGLE_63, angle, bonusSprite, amount);
+ const int32 x = (zone->maxs.x + zone->mins.x) / 2;
+ const int32 z = (zone->maxs.z + zone->mins.z) / 2;
+ const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, _sceneHero->_pos.x, _sceneHero->_pos.z);
+ const int32 index = _engine->_extra->addExtraBonus(x, zone->maxs.y, z, ANGLE_63, angle, bonusSprite, amount);
if (index != -1) {
_engine->_extra->_extraList[index].type |= ExtraType::TIME_IN;
Commit: d1be8e523e9dbf20c0864a73f7e63728a47a075d
https://github.com/scummvm/scummvm/commit/d1be8e523e9dbf20c0864a73f7e63728a47a075d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2022-08-18T17:08:43+02:00
Commit Message:
TWINE: todo comment
Changed paths:
engines/twine/scene/actor.h
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 95bf9ff4885..90c249f96d0 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -292,7 +292,7 @@ public:
/** Previous Hero angle */
int16 _previousHeroAngle = 0;
- int16 _cropBottomScreen = 0;
+ int16 _cropBottomScreen = 0; // TODO: usage differ in original sources
/** Hero current anim for normal behaviour */
int16 _heroAnimIdxNORMAL = 0;
Commit: aaf47ea195c302ba003b18f70bef5a85e130e352
https://github.com/scummvm/scummvm/commit/aaf47ea195c302ba003b18f70bef5a85e130e352
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2022-08-18T17:08:43+02:00
Commit Message:
TWINE: Items/pickups start flashing the moment they pop out.
Changed paths:
engines/twine/renderer/redraw.cpp
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index ef8d1e4c878..1aafddebab2 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -279,28 +279,33 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
}
continue;
}
- if ((extra->type & ExtraType::TIME_OUT) || (extra->type & ExtraType::FLASH) || (extra->payload.lifeTime + extra->spawnTime - TO_SECONDS(3) < _engine->_lbaTime) || (!((_engine->_lbaTime + extra->spawnTime) & 8))) {
- const IVec3 &projPos = _engine->_renderer->projectPositionOnScreen(extra->pos - _engine->_grid->_camera);
+ if ((extra->type & ExtraType::TIME_OUT) && (extra->type & ExtraType::FLASH)) {
+ if (_engine->_lbaTime >= extra->spawnTime + extra->payload.lifeTime - TO_SECONDS(3)) {
+ if ((_engine->_lbaTime + extra->spawnTime) & 8) {
+ continue;
+ }
+ }
+ }
+ const IVec3 &projPos = _engine->_renderer->projectPositionOnScreen(extra->pos - _engine->_grid->_camera);
- if (projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine)) {
- const int16 tmpVal = extra->pos.x - _engine->_grid->_camera.x + extra->pos.z - _engine->_grid->_camera.z;
- drawList[drawListPos].posValue = tmpVal;
- drawList[drawListPos].actorIdx = i;
- drawList[drawListPos].type = DrawListType::DrawExtras;
- drawListPos++;
+ if (projPos.x > VIEW_X0 && projPos.x < VIEW_X1(_engine) && projPos.y > VIEW_Y0 && projPos.y < VIEW_Y1(_engine)) {
+ const int16 tmpVal = extra->pos.x - _engine->_grid->_camera.x + extra->pos.z - _engine->_grid->_camera.z;
+ drawList[drawListPos].posValue = tmpVal;
+ drawList[drawListPos].actorIdx = i;
+ drawList[drawListPos].type = DrawListType::DrawExtras;
+ drawListPos++;
- if (_engine->_cfgfile.ShadowMode == 2 && !(extra->sprite & EXTRA_SPECIAL_MASK)) {
- const IVec3 &shadowCoord = _engine->_movements->getShadowPosition(extra->pos);
+ if (_engine->_cfgfile.ShadowMode == 2 && !(extra->sprite & EXTRA_SPECIAL_MASK)) {
+ const IVec3 &shadowCoord = _engine->_movements->getShadowPosition(extra->pos);
- drawList[drawListPos].posValue = tmpVal - 1;
- drawList[drawListPos].actorIdx = 0;
- drawList[drawListPos].type = DrawListType::DrawShadows;
- drawList[drawListPos].x = shadowCoord.x;
- drawList[drawListPos].y = shadowCoord.y;
- drawList[drawListPos].z = shadowCoord.z;
- drawList[drawListPos].offset = 0;
- drawListPos++;
- }
+ drawList[drawListPos].posValue = tmpVal - 1;
+ drawList[drawListPos].actorIdx = 0;
+ drawList[drawListPos].type = DrawListType::DrawShadows;
+ drawList[drawListPos].x = shadowCoord.x;
+ drawList[drawListPos].y = shadowCoord.y;
+ drawList[drawListPos].z = shadowCoord.z;
+ drawList[drawListPos].offset = 0;
+ drawListPos++;
}
}
}
More information about the Scummvm-git-logs
mailing list