[Scummvm-git-logs] scummvm master -> 63b8b0bf535a5ad1b2559d42fa479fbd030ce444
neuromancer
noreply at scummvm.org
Sat Aug 12 10:47:39 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b4fc39a01b FREESCAPE: preliminary implementation of startanim opcode
63b8b0bf53 FREESCAPE: move execution and rendering code code inside group
Commit: b4fc39a01b103900567810ea2777034bfc020954
https://github.com/scummvm/scummvm/commit/b4fc39a01b103900567810ea2777034bfc020954
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-08-12T08:19:31+02:00
Commit Message:
FREESCAPE: preliminary implementation of startanim opcode
Changed paths:
engines/freescape/language/instruction.cpp
engines/freescape/objects/geometricobject.h
engines/freescape/objects/group.cpp
engines/freescape/objects/object.h
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index c17331353f7..a2b0517f7a4 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -651,11 +651,13 @@ void FreescapeEngine::executeSwapJet(FCLInstruction &instruction) {
}
void FreescapeEngine::executeStartAnim(FCLInstruction &instruction) {
- uint16 groupID = instruction._source + 1;
- debugC(1, kFreescapeDebugCode, "Staring animation of group %d", groupID);
- Group *group = (Group *)_currentArea->objectWithID(groupID);
- assert(group);
- assert(group->getType() == kGroupType);
+ uint16 objID = instruction._source;
+ debugC(1, kFreescapeDebugCode, "Staring animation of object %d", objID);
+ Object *obj = _currentArea->objectWithID(objID);
+ assert(obj);
+ assert(obj->_partOfGroup);
+ Group *group = (Group *)obj->_partOfGroup;
+ debugC(1, kFreescapeDebugCode, "From group %d", group->getObjectID());
group->_active = true;
}
diff --git a/engines/freescape/objects/geometricobject.h b/engines/freescape/objects/geometricobject.h
index 2c320241b88..99c9ad6fa47 100644
--- a/engines/freescape/objects/geometricobject.h
+++ b/engines/freescape/objects/geometricobject.h
@@ -26,6 +26,7 @@
#define FREESCAPE_GEOMETRICOBJECT_H
#include "freescape/language/instruction.h"
+#include "freescape/objects/group.h"
#include "freescape/objects/object.h"
namespace Freescape {
diff --git a/engines/freescape/objects/group.cpp b/engines/freescape/objects/group.cpp
index a9218ed99cd..6744a5a12b6 100644
--- a/engines/freescape/objects/group.cpp
+++ b/engines/freescape/objects/group.cpp
@@ -92,6 +92,7 @@ void Group::linkObject(Object *obj) {
_origins.push_back(obj->getOrigin());
obj->makeInitiallyVisible();
obj->makeVisible();
+ obj->_partOfGroup = this;
_objects.push_back(obj);
}
diff --git a/engines/freescape/objects/object.h b/engines/freescape/objects/object.h
index b03de78a649..0fced4e8009 100644
--- a/engines/freescape/objects/object.h
+++ b/engines/freescape/objects/object.h
@@ -88,6 +88,7 @@ public:
uint16 _objectID;
Math::Vector3d _origin, _size, _rotation;
Math::AABB _boundingBox;
+ Object *_partOfGroup = nullptr;
};
} // End of namespace Freescape
Commit: 63b8b0bf535a5ad1b2559d42fa479fbd030ce444
https://github.com/scummvm/scummvm/commit/63b8b0bf535a5ad1b2559d42fa479fbd030ce444
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-08-12T12:49:33+02:00
Commit Message:
FREESCAPE: move execution and rendering code code inside group
Changed paths:
engines/freescape/area.cpp
engines/freescape/objects/geometricobject.cpp
engines/freescape/objects/group.cpp
engines/freescape/objects/group.h
diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 6947e6ff256..ee525cecb56 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -235,16 +235,12 @@ void Area::draw(Freescape::Renderer *gfx, uint32 ticks) {
}
void Area::drawGroup(Freescape::Renderer *gfx, Group* group, uint32 ticks) {
- if (group->_objectOperations[0] == 0x10)
- if (!group->_active)
- return;
-
- uint32 groupSize = group->_objects.size();
- uint32 frameSize = group->_objectPositions.size();
- for (uint32 i = 0; i < groupSize ; i++) {
- group->assemble((ticks / 10) % frameSize, i);
- group->_objects[i]->draw(gfx);
- }
+ if ((ticks % 10) != 0)
+ return;
+
+ group->run();
+ group->draw(gfx);
+ group->step();
}
Object *Area::shootRay(const Math::Ray &ray) {
diff --git a/engines/freescape/objects/geometricobject.cpp b/engines/freescape/objects/geometricobject.cpp
index 2f0071aed86..d29667d61c2 100644
--- a/engines/freescape/objects/geometricobject.cpp
+++ b/engines/freescape/objects/geometricobject.cpp
@@ -384,7 +384,7 @@ bool GeometricObject::collides(const Math::AABB &boundingBox_) {
return _boundingBox.collides(boundingBox_);
}
-void GeometricObject::draw(Freescape::Renderer *gfx) {
+void GeometricObject::draw(Renderer *gfx) {
if (this->getType() == kCubeType) {
gfx->renderCube(_origin, _size, _colours);
} else if (this->getType() == kRectangleType) {
diff --git a/engines/freescape/objects/group.cpp b/engines/freescape/objects/group.cpp
index 6744a5a12b6..8e4e46595f2 100644
--- a/engines/freescape/objects/group.cpp
+++ b/engines/freescape/objects/group.cpp
@@ -30,6 +30,8 @@ Group::Group(uint16 objectID_, uint16 flags_, const Common::Array<byte> data_) {
_flags = flags_;
_scale = 0;
_active = false;
+ _finished = false;
+ _step = 0;
int i;
for (i = 0; i < 5; i++) {
@@ -42,10 +44,12 @@ Group::Group(uint16 objectID_, uint16 flags_, const Common::Array<byte> data_) {
i = 9;
while (i < int(data_.size())) {
int operation = data_[i];
+ _objectOperations.push_back(operation);
debugC(1, kFreescapeDebugParser, "group data[%d] = %d (operation)", i, operation);
- if (operation == 0x80)
+ if (operation == 0x80) {
i++;
- else if (operation == 0x01) {
+ _objectPositions.push_back(Math::Vector3d());
+ } else if (operation == 0x01) {
i++;
int scriptSize = data_[i];
assert(scriptSize > 0);
@@ -56,16 +60,17 @@ Group::Group(uint16 objectID_, uint16 flags_, const Common::Array<byte> data_) {
}
Common::String conditionStr = detokenise8bitCondition(conditionData, instructions, false);
debugC(1, kFreescapeDebugParser, "group condition:\n%s", conditionStr.c_str());
+ _objectPositions.push_back(Math::Vector3d());
i = i + 1 + scriptSize;
} else {
- _objectOperations.push_back(operation);
if (i < int(data_.size() - 4)) {
debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 1, data_[i + 1]);
debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 2, data_[i + 2]);
debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 3, data_[i + 3]);
Math::Vector3d position(data_[i + 1], data_[i + 2], data_[i + 3]);
_objectPositions.push_back(position);
- }
+ } else
+ _objectOperations.pop_back();
i = i + 4;
}
}
@@ -96,9 +101,9 @@ void Group::linkObject(Object *obj) {
_objects.push_back(obj);
}
-void Group::assemble(int frame, int index) {
+void Group::assemble(int index) {
GeometricObject *gobj = (GeometricObject *)_objects[index];
- Math::Vector3d position = _objectPositions[frame];
+ Math::Vector3d position = _objectPositions[_step];
if (!GeometricObject::isPolygon(gobj->getType()))
position = 32 * position / _scale;
@@ -107,4 +112,50 @@ void Group::assemble(int frame, int index) {
gobj->offsetOrigin(position);
}
+
+void Group::run() {
+ if (_finished)
+ return;
+
+ uint32 groupSize = _objects.size();
+ for (uint32 i = 0; i < groupSize ; i++) {
+ run(i);
+ }
+}
+
+void Group::run(int index) {
+ if (_objectOperations[_step] == 0x80) {
+ _step = -1;
+ _active = false;
+ _finished = false;
+ } else if (_objectOperations[_step] == 0x01) {
+ // TODO
+ } else {
+ if (_objectOperations[_step] == 0x10)
+ if (!_active) {
+ _step = -1;
+ return;
+ }
+ assemble(index);
+ }
+}
+
+void Group::draw(Renderer *gfx) {
+ uint32 groupSize = _objects.size();
+ for (uint32 i = 0; i < groupSize ; i++) {
+ _objects[i]->draw(gfx);
+ }
+}
+
+void Group::step() {
+ if (_finished)
+ return;
+
+ if (_step < int(_objectOperations.size() - 1))
+ _step++;
+ else {
+ _finished = true;
+ }
+}
+
} // End of namespace Freescape
\ No newline at end of file
diff --git a/engines/freescape/objects/group.h b/engines/freescape/objects/group.h
index c001a2b00c9..2f2b07975b6 100644
--- a/engines/freescape/objects/group.h
+++ b/engines/freescape/objects/group.h
@@ -22,6 +22,7 @@
#ifndef FREESCAPE_GROUP_H
#define FREESCAPE_GROUP_H
+#include "freescape/gfx.h"
#include "freescape/objects/object.h"
namespace Freescape {
@@ -30,7 +31,10 @@ class Group : public Object {
public:
Group(uint16 objectID_, uint16 flags_, const Common::Array<byte> data_);
void linkObject(Object *obj);
- void assemble(int frame, int index);
+ void assemble(int index);
+ void step();
+ void run();
+ void run(int index);
Common::Array<Object *> _objects;
Common::Array<Math::Vector3d> _origins;
@@ -38,11 +42,13 @@ public:
Common::Array<int16> _objectOperations;
Common::Array<int16> _objectIds;
int _scale;
+ int _step;
bool _active;
+ bool _finished;
ObjectType getType() override { return ObjectType::kGroupType; };
bool isDrawable() override { return true; }
- void draw(Freescape::Renderer *gfx) override { error("cannot render Group"); };
+ void draw(Renderer *gfx) override;
void scale(int scale_) override { _scale = scale_; };
Object *duplicate() override { error("cannot duplicate Group"); };
};
More information about the Scummvm-git-logs
mailing list