[Scummvm-git-logs] scummvm master -> 2e77b6eaf6aef2c7a04bff3c05811822e8ae9908
moralrecordings
code at moral.net.au
Tue Nov 9 14:29:10 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:
2e77b6eaf6 DIRECTOR: Fix position of film loop subchannels
Commit: 2e77b6eaf6aef2c7a04bff3c05811822e8ae9908
https://github.com/scummvm/scummvm/commit/2e77b6eaf6aef2c7a04bff3c05811822e8ae9908
Author: Scott Percival (code at moral.net.au)
Date: 2021-11-09T21:46:44+08:00
Commit Message:
DIRECTOR: Fix position of film loop subchannels
Sprites stored in frames are referenced by position (minus the
registration offset), width and height. Film loops are the same. As
such, fix the bounding box calculation for the film loop to use the
correct sprite positions (e.g. center for bitmaps), then fix the
subchannel generator to take these into account.
Changed paths:
engines/director/castmember.cpp
engines/director/channel.cpp
engines/director/sprite.cpp
engines/director/sprite.h
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index 40af6e9cac..0b95c74a54 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -610,7 +610,6 @@ Common::Array<Channel> *FilmLoopCastMember::getSubChannels(Common::Rect &bbox, C
chan._currentPoint = Common::Point(absX, absY);
chan._width = width;
chan._height = height;
- chan.addRegistrationOffset(chan._currentPoint, true);
_subchannels.push_back(chan);
_subchannels[_subchannels.size() - 1].replaceWidget();
@@ -725,13 +724,21 @@ void FilmLoopCastMember::loadFilmLoopData(Common::SeekableReadStreamEndian &stre
frameSize -= msgWidth;
+ newFrame.sprites.setVal(channel, sprite);
+ }
+
+ for (Common::HashMap<int, Sprite>::iterator s = newFrame.sprites.begin(); s != newFrame.sprites.end(); ++s) {
+ debugC(5, kDebugLoading, "Sprite: channel %d, castId %s, bbox %d %d %d %d", s->_key,
+ s->_value._castId.asString().c_str(), s->_value._startPoint.x, s->_value._startPoint.y,
+ s->_value._width, s->_value._height);
+
+ Common::Point topLeft = s->_value._startPoint + s->_value.getRegistrationOffset();
Common::Rect spriteBbox(
- sprite._startPoint.x,
- sprite._startPoint.y,
- sprite._startPoint.x + sprite._width,
- sprite._startPoint.y + sprite._height
+ topLeft.x,
+ topLeft.y,
+ topLeft.x + s->_value._width,
+ topLeft.y + s->_value._height
);
- newFrame.sprites.setVal(channel, sprite);
if (!((spriteBbox.width() == 0) && (spriteBbox.height() == 0))) {
if ((_initialRect.width() == 0) && (_initialRect.height() == 0)) {
_initialRect = spriteBbox;
@@ -739,15 +746,8 @@ void FilmLoopCastMember::loadFilmLoopData(Common::SeekableReadStreamEndian &stre
_initialRect.extend(spriteBbox);
}
}
- }
-
- if (debugChannelSet(5, kDebugLoading)) {
- for (Common::HashMap<int, Sprite>::iterator s = newFrame.sprites.begin(); s != newFrame.sprites.end(); ++s) {
- debugC(5, kDebugLoading, "Sprite: channel %d, castId %s, bbox %d %d %d %d", s->_key,
- s->_value._castId.asString().c_str(), s->_value._startPoint.x, s->_value._startPoint.y,
- s->_value._width, s->_value._height);
+ debugC(8, kDebugLoading, "New bounding box: %d %d %d %d", _initialRect.left, _initialRect.top, _initialRect.width(), _initialRect.height());
- }
}
_frames.push_back(newFrame);
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 18ac1f33fb..ba09e44f51 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -619,30 +619,21 @@ void Channel::addRegistrationOffset(Common::Point &pos, bool subtract) {
return;
switch (_sprite->_cast->_type) {
- case kCastBitmap: {
- BitmapCastMember *bc = (BitmapCastMember *)(_sprite->_cast);
-
- Common::Point point(0, 0);
- // stretch the offset
- if (!_sprite->_stretch && (_width != bc->_initialRect.width() || _height != bc->_initialRect.height())) {
- point.x = (bc->_initialRect.left - bc->_regX) * _width / bc->_initialRect.width();
- point.y = (bc->_initialRect.top - bc->_regY) * _height / bc->_initialRect.height();
- } else {
- point.x = bc->_initialRect.left - bc->_regX;
- point.y = bc->_initialRect.top - bc->_regY;
+ case kCastBitmap:
+ {
+ if (subtract)
+ pos -= _sprite->getRegistrationOffset();
+ else
+ pos += _sprite->getRegistrationOffset();
}
- if (subtract)
- pos -= point;
- else
- pos += point;
- } break;
+ break;
case kCastDigitalVideo:
case kCastFilmLoop:
- pos -= Common::Point(_sprite->_cast->_initialRect.width() >> 1, _sprite->_cast->_initialRect.height() >> 1);
- break;
+ pos -= _sprite->getRegistrationOffset();
default:
break;
}
+ return;
}
void Channel::addDelta(Common::Point pos) {
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index 2b2149e3eb..a3ffd7af99 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -283,6 +283,38 @@ uint32 Sprite::getForeColor() {
}
}
+Common::Point Sprite::getRegistrationOffset() {
+ Common::Point result(0, 0);
+ if (!_cast)
+ return result;
+
+ switch (_cast->_type) {
+ case kCastBitmap:
+ {
+ BitmapCastMember *bc = (BitmapCastMember *)(_cast);
+
+ Common::Point point(0, 0);
+ // stretch the offset
+ if (!_stretch && (_width != bc->_initialRect.width() || _height != bc->_initialRect.height())) {
+ result.x = (bc->_initialRect.left - bc->_regX) * _width / bc->_initialRect.width();
+ result.y = (bc->_initialRect.top - bc->_regY) * _height / bc->_initialRect.height();
+ } else {
+ result.x = bc->_initialRect.left - bc->_regX;
+ result.y = bc->_initialRect.top - bc->_regY;
+ }
+ }
+ break;
+ case kCastDigitalVideo:
+ case kCastFilmLoop:
+ result.x = _cast->_initialRect.width() >> 1;
+ result.y = _cast->_initialRect.height() >> 1;
+ break;
+ default:
+ break;
+ }
+ return result;
+}
+
void Sprite::updateEditable() {
if (!_cast)
return;
@@ -442,18 +474,26 @@ void Sprite::setCast(CastMemberID memberID) {
// them properly.
Common::Rect dims = _cast->getInitialRect();
// strange logic here, need to be fixed
- if (_cast->_type == kCastBitmap) {
+ switch (_cast->_type) {
+ case kCastBitmap:
// for the stretched sprites, we need the original size to get the correct bbox offset.
// there are two stretch situation here.
// 1. stretch happened when creating the widget, there is no lingo participated. we will use the original sprite size to create widget. check copyStretchImg
// 2. stretch set by lingo. this time we need to store the original dims because we will create the original sprite and stretch it when bliting. check inkBlitStretchSurface
- if (!(_inkData & 0x80) || _stretch) {
- _width = dims.width();
- _height = dims.height();
+ {
+ if (!(_inkData & 0x80) || _stretch) {
+ _width = dims.width();
+ _height = dims.height();
+ }
}
- } else if (_cast->_type != kCastShape && _cast->_type != kCastText) {
+ break;
+ case kCastShape:
+ case kCastText: // fall-through
+ break;
+ default:
_width = dims.width();
_height = dims.height();
+ break;
}
} else {
diff --git a/engines/director/sprite.h b/engines/director/sprite.h
index dbc967545e..84d004a985 100644
--- a/engines/director/sprite.h
+++ b/engines/director/sprite.h
@@ -84,6 +84,7 @@ public:
MacShape *getShape();
uint32 getForeColor();
uint32 getBackColor();
+ Common::Point getRegistrationOffset();
Frame *_frame;
Score *_score;
More information about the Scummvm-git-logs
mailing list