From e935f85366ba1e83fdd1cea3712959edee1f6270 Mon Sep 17 00:00:00 2001 From: johndoe123 Date: Wed, 17 Apr 2013 19:54:39 +0200 Subject: SWORD25: Change absolute Z calculation to match that of absolute x/y; remove old comment --- engines/sword25/gfx/dynamicbitmap.cpp | 2 -- engines/sword25/gfx/renderobject.cpp | 23 +++++++++++++---------- engines/sword25/gfx/renderobject.h | 12 +++++++++--- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'engines/sword25/gfx') diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp index aef04fe1ef..242508bf85 100644 --- a/engines/sword25/gfx/dynamicbitmap.cpp +++ b/engines/sword25/gfx/dynamicbitmap.cpp @@ -78,8 +78,6 @@ bool DynamicBitmap::doRender(RectangleList *updateRects) { GraphicEngine *pGfx = Kernel::getInstance()->getGfx(); assert(pGfx); - //return true;//DEBUG - // Draw the bitmap bool result; if (_scaleFactorX == 1.0f && _scaleFactorY == 1.0f) { diff --git a/engines/sword25/gfx/renderobject.cpp b/engines/sword25/gfx/renderobject.cpp index f2d25771a9..d1381513fd 100644 --- a/engines/sword25/gfx/renderobject.cpp +++ b/engines/sword25/gfx/renderobject.cpp @@ -219,9 +219,10 @@ Common::Rect RenderObject::calcBoundingBox() const { return bbox; } -void RenderObject::calcAbsolutePos(int &x, int &y) const { +void RenderObject::calcAbsolutePos(int &x, int &y, int &z) const { x = calcAbsoluteX(); y = calcAbsoluteY(); + z = calcAbsoluteZ(); } int RenderObject::calcAbsoluteX() const { @@ -238,6 +239,13 @@ int RenderObject::calcAbsoluteY() const { return _y; } +int RenderObject::calcAbsoluteZ() const { + if (_parentPtr.isValid()) + return _parentPtr->getAbsoluteZ() + _z; + else + return _z; +} + void RenderObject::deleteAllChildren() { // Es ist nicht notwendig die Liste zu iterieren, da jedes Kind für sich DetatchChildren an diesem Objekt aufruft und sich somit // selber entfernt. Daher muss immer nur ein beliebiges Element (hier das letzte) gelöscht werden, bis die Liste leer ist. @@ -281,7 +289,7 @@ void RenderObject::sortRenderObjects() { } void RenderObject::updateAbsolutePos() { - calcAbsolutePos(_absoluteX, _absoluteY); + calcAbsolutePos(_absoluteX, _absoluteY, _absoluteZ); RENDEROBJECT_ITER it = _children.begin(); for (; it != _children.end(); ++it) @@ -313,15 +321,10 @@ void RenderObject::setY(int y) { void RenderObject::setZ(int z) { if (z < 0) error("Tried to set a negative Z value (%d).", z); - else + else { _z = z; -} - -int RenderObject::getAbsoluteZ() const { - if (_parentPtr.isValid()) - return _parentPtr->getAbsoluteZ() + _z; - else - return _z; + updateAbsolutePos(); + } } void RenderObject::setVisible(bool visible) { diff --git a/engines/sword25/gfx/renderobject.h b/engines/sword25/gfx/renderobject.h index a22893a69e..48cbf8ea65 100644 --- a/engines/sword25/gfx/renderobject.h +++ b/engines/sword25/gfx/renderobject.h @@ -305,7 +305,9 @@ public: return _z; } - int getAbsoluteZ() const; + int getAbsoluteZ() const { + return _absoluteZ; + } /** @brief Gibt die Breite des Objektes zurück. @@ -387,9 +389,10 @@ protected: int _x; ///< Die X-Position des Objektes relativ zum Eltern-Objekt int _y; ///< Die Y-Position des Objektes relativ zum Eltern-Objekt + int _z; ///< Der Z-Wert des Objektes relativ zum Eltern-Objekt int _absoluteX; ///< Die absolute X-Position des Objektes int _absoluteY; ///< Die absolute Y-Position des Objektes - int _z; ///< Der Z-Wert des Objektes relativ zum Eltern-Objekt + int _absoluteZ; int _width; ///< Die Breite des Objektes int _height; ///< Die Höhe des Objektes bool _visible; ///< Ist true, wenn das Objekt sichtbar ist @@ -496,7 +499,7 @@ private: /** @brief Berechnet die absolute Position des Objektes. */ - void calcAbsolutePos(int &x, int &y) const; + void calcAbsolutePos(int &x, int &y, int &z) const; /** @brief Berechnet die absolute Position des Objektes auf der X-Achse. */ @@ -505,6 +508,9 @@ private: @brief Berechnet die absolute Position des Objektes. */ int calcAbsoluteY() const; + + int calcAbsoluteZ() const; + /** @brief Sortiert alle Kinderobjekte nach ihrem Renderang. */ -- cgit v1.2.3