[Scummvm-git-logs] scummvm master -> 5639b0e7f6e46a2c9f2d160bec005e15f368986b
npjg
nathanael.gentrydb8 at gmail.com
Wed Jun 17 16:09:32 UTC 2020
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:
5639b0e7f6 DIRECTOR: Improve sprite position calculations
Commit: 5639b0e7f6e46a2c9f2d160bec005e15f368986b
https://github.com/scummvm/scummvm/commit/5639b0e7f6e46a2c9f2d160bec005e15f368986b
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-06-17T12:08:54-04:00
Commit Message:
DIRECTOR: Improve sprite position calculations
Changed paths:
engines/director/lingo/lingo-the.cpp
engines/director/score.cpp
engines/director/score.h
engines/director/sprite.cpp
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index c8f262808a..a5aace3e5f 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -706,7 +706,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_blend;
break;
case kTheBottom:
- d.u.i = sprite->getDims().bottom + channel->_currentPoint.y;
+ d.u.i = channel->getBbox().bottom;
break;
case kTheCastNum:
d.u.i = sprite->_castId;
@@ -730,7 +730,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_ink;
break;
case kTheLeft:
- d.u.i = sprite->getDims().left + channel->_currentPoint.x;
+ d.u.i = channel->getBbox().left;
break;
case kTheLineSize:
d.u.i = sprite->_thickness & 0x3;
@@ -757,7 +757,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_puppet;
break;
case kTheRight:
- d.u.i = sprite->getDims().right + channel->_currentPoint.x;
+ d.u.i = channel->getBbox().right;
break;
case kTheStartTime:
d.u.i = sprite->_startTime;
@@ -769,7 +769,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_stretch;
break;
case kTheTop:
- d.u.i = sprite->getDims().top + channel->_currentPoint.y;
+ d.u.i = channel->getBbox().top;
break;
case kTheTrails:
d.u.i = sprite->_trails;
@@ -856,7 +856,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
channel->addDelta(Common::Point(d.asInt() - channel->_currentPoint.x, 0));
break;
case kTheLocV:
- channel->addDelta(Common::Point(0, d.asInt() - channel->_currentPoint.y));
+ channel->addDelta(Common::Point(d.asInt() - channel->_currentPoint.y, 0));
break;
case kTheMoveableSprite:
sprite->_moveable = d.asInt();
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 39394c1f24..e1e67bac80 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -47,13 +47,12 @@ Channel::Channel(Sprite *sp) {
if (_sprite && _sprite->_castType != kCastTypeNull) {
_sprite->updateCast();
- updateLocation();
}
}
Common::Rect Channel::getBbox() {
Common::Rect bbox = _sprite->getDims();
- bbox.moveTo(_currentPoint);
+ bbox.moveTo(getPosition());
return bbox;
}
@@ -71,6 +70,19 @@ void Channel::addDelta(Common::Point pos) {
_delta += pos;
}
+Common::Point Channel::getPosition() {
+ Common::Point res = _currentPoint;
+
+ if (_sprite->_castType == kCastBitmap) {
+ BitmapCast *bc = (BitmapCast *)(_sprite->_cast);
+
+ res += Common::Point(bc->_initialRect.left - bc->_regX,
+ bc->_initialRect.top - bc->_regY);
+ }
+
+ return res;
+}
+
void Channel::resetPosition() {
_delta = _sprite->_startPoint;
}
@@ -371,7 +383,7 @@ void Score::startLoop() {
}
// All frames in the same movie have the same number of channels
- for (int i = _frames[1]->_sprites.size() - 1; i >= 0; i--) {
+ for (uint i = 0; i < _frames[1]->_sprites.size(); i++) {
_channels.push_back(new Channel(_frames[1]->_sprites[i]));
}
diff --git a/engines/director/score.h b/engines/director/score.h
index 08fb1a5a68..3047d47a3d 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -95,6 +95,7 @@ struct Channel {
Channel(Sprite *sp);
Common::Rect getBbox();
+ Common::Point getPosition();
void updateLocation();
void addDelta(Common::Point pos);
void resetPosition();
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index dcdcb6a951..7e53b20f9c 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -227,12 +227,6 @@ void Sprite::setCast(uint16 castId) {
}
}
- if (_castType == kCastBitmap && _cast) {
- BitmapCast *bc = (BitmapCast *)_cast;
-
- _startPoint += Common::Point(bc->_initialRect.left - bc->_regX, bc->_initialRect.top - bc->_regY);
- }
-
_dirty = true;
}
@@ -248,13 +242,6 @@ Common::Rect Sprite::getDims() {
} else {
if (_cast && _cast->_widget) {
result = Common::Rect(_cast->_widget->_dims.width(), _cast->_widget->_dims.height());
-
- if (_castType == kCastBitmap) {
- BitmapCast *bc = (BitmapCast *)_cast;
- int offsety = bc->_initialRect.top - bc->_regY;
- int offsetx = bc->_initialRect.left - bc->_regX;
- result.translate(offsetx, offsety);
- }
}
}
More information about the Scummvm-git-logs
mailing list