[Scummvm-git-logs] scummvm master -> e1868bfd7082d76e5f0608b5d1f606081e047c23

bluegr bluegr at gmail.com
Wed Jun 16 19:41:57 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e1868bfd70 TRECISION: Use Common::Rect for the actor rect


Commit: e1868bfd7082d76e5f0608b5d1f606081e047c23
    https://github.com/scummvm/scummvm/commit/e1868bfd7082d76e5f0608b5d1f606081e047c23
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2021-06-16T22:41:33+03:00

Commit Message:
TRECISION: Use Common::Rect for the actor rect

Changed paths:
    engines/trecision/actor.cpp
    engines/trecision/actor.h
    engines/trecision/graphics.cpp
    engines/trecision/renderer3d.cpp
    engines/trecision/renderer3d.h


diff --git a/engines/trecision/actor.cpp b/engines/trecision/actor.cpp
index a851c4ad87..f80189d0c5 100644
--- a/engines/trecision/actor.cpp
+++ b/engines/trecision/actor.cpp
@@ -471,4 +471,12 @@ float Actor::frameCenter(SVertex *v) {
 	return (-v[86]._z - v[164]._z) / 2.0;
 }
 
+bool Actor::actorRectIsValid() const {
+	return _lim[0] < _lim[1] && _lim[2] < _lim[3];
+}
+
+Common::Rect Actor::getActorRect() const {
+	return Common::Rect(_lim[0], _lim[2], _lim[1], _lim[3]);
+}
+
 } // End of namespace Trecision
diff --git a/engines/trecision/actor.h b/engines/trecision/actor.h
index 8d0167f110..b671cf69fe 100644
--- a/engines/trecision/actor.h
+++ b/engines/trecision/actor.h
@@ -78,6 +78,8 @@ public:
 	void read3D(Common::SeekableReadStreamEndian *ff);
 	float frameCenter(SVertex *v);
 	void updateStepSound();
+	bool actorRectIsValid() const;
+	Common::Rect getActorRect() const;
 };
 
 } // End of namespace Trecision
diff --git a/engines/trecision/graphics.cpp b/engines/trecision/graphics.cpp
index 99aa2d719b..90c1991610 100644
--- a/engines/trecision/graphics.cpp
+++ b/engines/trecision/graphics.cpp
@@ -496,14 +496,11 @@ void GraphicsManager::paintScreen(bool flag) {
 	_dirtyRects.clear();
 	_vm->_flagPaintCharacter = true; // always redraws the character
 
-	int x1 = _vm->_actor->_lim[0];
-	int y1 = _vm->_actor->_lim[2] - TOP;
-	int x2 = _vm->_actor->_lim[1];
-	int y2 = _vm->_actor->_lim[3] - TOP;
-
 	// erase character
-	if (_vm->_flagShowCharacter && x2 > x1 && y2 > y1) { // if a description exists
-		drawObj(-1, false, Common::Rect(0, TOP, MAXX, AREA + TOP), Common::Rect(x1, y1, x2, y2));
+	if (_vm->_flagShowCharacter && _vm->_actor->actorRectIsValid()) { // if a description exists
+		Common::Rect actorRect = _vm->_actor->getActorRect();
+		actorRect.translate(0, -TOP);
+		drawObj(-1, false, Common::Rect(0, TOP, MAXX, AREA + TOP), actorRect);
 	} else if (_vm->_animMgr->_animRect.left != MAXX) {
 		drawObj(-1, false, Common::Rect(0, TOP, MAXX, AREA + TOP), _vm->_animMgr->_animRect);
 	}
@@ -629,18 +626,13 @@ void GraphicsManager::paintObjAnm(uint16 curBox) {
 	if (_vm->_pathFind->getActorPos() == curBox && _vm->_flagShowCharacter) {
 		_vm->_renderer->drawCharacter(CALCPOINTS);
 
-		int x1 = _vm->_actor->_lim[0];
-		int y1 = _vm->_actor->_lim[2];
-		int x2 = _vm->_actor->_lim[1];
-		int y2 = _vm->_actor->_lim[3];
-
-		if (x2 > x1 && y2 > y1) {
+		if (_vm->_actor->actorRectIsValid()) {
+			const Common::Rect actorRect = _vm->_actor->getActorRect();
 			// enlarge the last dirty rectangle with the actor's rectangle
-			Common::Rect l(x1, y1, x2, y2);
 			if (!_dirtyRects.empty())
-				_dirtyRects.back().extend(l);
+				_dirtyRects.back().extend(actorRect);
 
-			_vm->_renderer->resetZBuffer(x1, y1, x2, y2);
+			_vm->_renderer->resetZBuffer(actorRect);
 		}
 
 		_vm->_renderer->drawCharacter(DRAWFACES);
diff --git a/engines/trecision/renderer3d.cpp b/engines/trecision/renderer3d.cpp
index dbb88924ef..c6fb0eade6 100644
--- a/engines/trecision/renderer3d.cpp
+++ b/engines/trecision/renderer3d.cpp
@@ -390,11 +390,11 @@ void Renderer3D::init3DRoom() {
 		_zBuffer[c] = 0x7FFF;
 }
 
-void Renderer3D::resetZBuffer(int x1, int y1, int x2, int y2) {
-	if (x1 > x2 || y1 > y2)
+void Renderer3D::resetZBuffer(Common::Rect area) {
+	if (!area.isValidRect())
 		return;
 
-	int size = (x2 - x1) * (y2 - y1);
+	int size = area.width() * area.height();
 	if (size * 2 > ZBUFFERSIZE)
 		warning("Warning: _zBuffer size %d!\n", size * 2);
 
diff --git a/engines/trecision/renderer3d.h b/engines/trecision/renderer3d.h
index 16b99ca511..a1ec492223 100644
--- a/engines/trecision/renderer3d.h
+++ b/engines/trecision/renderer3d.h
@@ -86,7 +86,7 @@ public:
 	~Renderer3D();
 
 	void init3DRoom();
-	void resetZBuffer(int x1, int y1, int x2, int y2);
+	void resetZBuffer(Common::Rect area);
 	void setClipping(int16 x1, int16 y1, int16 x2, int16 y2);
 	void drawCharacter(uint8 flag);
 };




More information about the Scummvm-git-logs mailing list