[Scummvm-git-logs] scummvm master -> ba6ebf5b4d1d2c414137e71c78d74df3fbae0e83
mgerhardy
martin.gerhardy at gmail.com
Sat Mar 27 19:32:32 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b8cd7a0dbc TWINE: use members, not operator[]
0430f59454 TWINE: added assignment operator for I16Vec3 to IVec3
ba6ebf5b4d TWINE: fixed header guards
Commit: b8cd7a0dbc88dd8cedbecfe952ef97b062834dfa
https://github.com/scummvm/scummvm/commit/b8cd7a0dbc88dd8cedbecfe952ef97b062834dfa
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-27T20:09:10+01:00
Commit Message:
TWINE: use members, not operator[]
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
engines/twine/shared.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 551cd1b32c..7afe3383e5 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -143,9 +143,9 @@ void Renderer::setOrthoProjection(int32 x, int32 y, int32 z) {
}
void Renderer::baseMatrixTranspose() {
- SWAP(_baseMatrix.row1[1], _baseMatrix.row2[0]);
- SWAP(_baseMatrix.row1[2], _baseMatrix.row3[0]);
- SWAP(_baseMatrix.row2[2], _baseMatrix.row3[1]);
+ SWAP(_baseMatrix.row1.y, _baseMatrix.row2.x);
+ SWAP(_baseMatrix.row1.z, _baseMatrix.row3.x);
+ SWAP(_baseMatrix.row2.z, _baseMatrix.row3.y);
}
void Renderer::setBaseRotation(int32 x, int32 y, int32 z, bool transpose) {
@@ -153,23 +153,23 @@ void Renderer::setBaseRotation(int32 x, int32 y, int32 z, bool transpose) {
const double Yradians = (double)((ANGLE_90 - y) % ANGLE_360) * 2 * M_PI / ANGLE_360;
const double Zradians = (double)((ANGLE_90 - z) % ANGLE_360) * 2 * M_PI / ANGLE_360;
- _baseMatrix.row1[0] = (int32)(sin(Zradians) * sin(Yradians) * SCENE_SIZE_HALFF);
- _baseMatrix.row1[1] = (int32)(-cos(Zradians) * SCENE_SIZE_HALFF);
- _baseMatrix.row1[2] = (int32)(sin(Zradians) * cos(Yradians) * SCENE_SIZE_HALFF);
- _baseMatrix.row2[0] = (int32)(cos(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
- _baseMatrix.row2[1] = (int32)(sin(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
- _baseMatrix.row3[0] = (int32)(cos(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
- _baseMatrix.row3[1] = (int32)(sin(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row1.x = (int32)(sin(Zradians) * sin(Yradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row1.y = (int32)(-cos(Zradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row1.z = (int32)(sin(Zradians) * cos(Yradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row2.x = (int32)(cos(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row2.y = (int32)(sin(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row3.x = (int32)(cos(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row3.y = (int32)(sin(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
- int32 matrixElem = _baseMatrix.row2[0];
+ int32 matrixElem = _baseMatrix.row2.x;
- _baseMatrix.row2[0] = (int32)(sin(Yradians) * matrixElem + SCENE_SIZE_HALFF * cos(Yradians) * cos(Xradians));
- _baseMatrix.row2[2] = (int32)(cos(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Yradians) * cos(Xradians));
+ _baseMatrix.row2.x = (int32)(sin(Yradians) * matrixElem + SCENE_SIZE_HALFF * cos(Yradians) * cos(Xradians));
+ _baseMatrix.row2.z = (int32)(cos(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Yradians) * cos(Xradians));
- matrixElem = _baseMatrix.row3[0];
+ matrixElem = _baseMatrix.row3.x;
- _baseMatrix.row3[0] = (int32)(sin(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Xradians) * cos(Yradians));
- _baseMatrix.row3[2] = (int32)(cos(Yradians) * matrixElem + SCENE_SIZE_HALFF * sin(Xradians) * sin(Yradians));
+ _baseMatrix.row3.x = (int32)(sin(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Xradians) * cos(Yradians));
+ _baseMatrix.row3.z = (int32)(cos(Yradians) * matrixElem + SCENE_SIZE_HALFF * sin(Xradians) * sin(Yradians));
if (transpose) {
baseMatrixTranspose();
@@ -182,20 +182,20 @@ void Renderer::setBaseRotation(int32 x, int32 y, int32 z, bool transpose) {
}
void Renderer::getBaseRotationPosition(int32 x, int32 y, int32 z) {
- destPos.x = (_baseMatrix.row1[0] * x + _baseMatrix.row1[1] * y + _baseMatrix.row1[2] * z) / SCENE_SIZE_HALF;
- destPos.y = (_baseMatrix.row2[0] * x + _baseMatrix.row2[1] * y + _baseMatrix.row2[2] * z) / SCENE_SIZE_HALF;
- destPos.z = (_baseMatrix.row3[0] * x + _baseMatrix.row3[1] * y + _baseMatrix.row3[2] * z) / SCENE_SIZE_HALF;
+ destPos.x = (_baseMatrix.row1.x * x + _baseMatrix.row1.y * y + _baseMatrix.row1.z * z) / SCENE_SIZE_HALF;
+ destPos.y = (_baseMatrix.row2.x * x + _baseMatrix.row2.y * y + _baseMatrix.row2.z * z) / SCENE_SIZE_HALF;
+ destPos.z = (_baseMatrix.row3.x * x + _baseMatrix.row3.y * y + _baseMatrix.row3.z * z) / SCENE_SIZE_HALF;
}
void Renderer::getCameraAnglePositions(int32 x, int32 y, int32 z) {
- destPos.x = (_baseMatrix.row1[0] * x + _baseMatrix.row2[0] * y + _baseMatrix.row3[0] * z) / SCENE_SIZE_HALF;
- destPos.y = (_baseMatrix.row1[1] * x + _baseMatrix.row2[1] * y + _baseMatrix.row3[1] * z) / SCENE_SIZE_HALF;
- destPos.z = (_baseMatrix.row1[2] * x + _baseMatrix.row2[2] * y + _baseMatrix.row3[2] * z) / SCENE_SIZE_HALF;
+ destPos.x = (_baseMatrix.row1.x * x + _baseMatrix.row2.x * y + _baseMatrix.row3.x * z) / SCENE_SIZE_HALF;
+ destPos.y = (_baseMatrix.row1.y * x + _baseMatrix.row2.y * y + _baseMatrix.row3.y * z) / SCENE_SIZE_HALF;
+ destPos.z = (_baseMatrix.row1.z * x + _baseMatrix.row2.z * y + _baseMatrix.row3.z * z) / SCENE_SIZE_HALF;
}
void Renderer::translateGroup(int32 x, int32 y, int32 z) {
- destPos.x = (_shadeMatrix.row1[0] * x + _shadeMatrix.row1[1] * y + _shadeMatrix.row1[2] * z) / SCENE_SIZE_HALF;
- destPos.y = (_shadeMatrix.row2[0] * x + _shadeMatrix.row2[1] * y + _shadeMatrix.row2[2] * z) / SCENE_SIZE_HALF;
+ destPos.x = (_shadeMatrix.row1.x * x + _shadeMatrix.row1.y * y + _shadeMatrix.row1.z * z) / SCENE_SIZE_HALF;
+ destPos.y = (_shadeMatrix.row2.x * x + _shadeMatrix.row2.y * y + _shadeMatrix.row2.z * z) / SCENE_SIZE_HALF;
destPos.z = destPos.y;
}
@@ -232,15 +232,15 @@ IVec3 Renderer::getHolomapRotation(const int32 angleX, const int32 angleY, const
rotX = shadeAngleTable[ClampAngle(angleZ + ANGLE_90)] * rotX / SCENE_SIZE_HALF;
}
- const int32 row1X = _baseMatrix.row1[0] * rotX;
- const int32 row1Y = _baseMatrix.row1[1] * rotY;
- const int32 row1Z = _baseMatrix.row1[2] * rotZ;
- const int32 row2X = _baseMatrix.row2[0] * rotX;
- const int32 row2Y = _baseMatrix.row2[1] * rotY;
- const int32 row2Z = _baseMatrix.row2[2] * rotZ;
- const int32 row3X = _baseMatrix.row3[0] * rotX;
- const int32 row3Y = _baseMatrix.row3[1] * rotY;
- const int32 row3Z = _baseMatrix.row3[2] * rotZ;
+ const int32 row1X = _baseMatrix.row1.x * rotX;
+ const int32 row1Y = _baseMatrix.row1.y * rotY;
+ const int32 row1Z = _baseMatrix.row1.z * rotZ;
+ const int32 row2X = _baseMatrix.row2.x * rotX;
+ const int32 row2Y = _baseMatrix.row2.y * rotY;
+ const int32 row2Z = _baseMatrix.row2.z * rotZ;
+ const int32 row3X = _baseMatrix.row3.x * rotX;
+ const int32 row3Y = _baseMatrix.row3.y * rotY;
+ const int32 row3Z = _baseMatrix.row3.z * rotZ;
IVec3 vec;
vec.x = (row1X + row1Y + row1Z) / SCENE_SIZE_HALF;
vec.y = (row2X + row2Y + row2Z) / SCENE_SIZE_HALF;
@@ -258,16 +258,16 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
- matrix1.row1[0] = currentMatrix->row1[0];
- matrix1.row2[0] = currentMatrix->row2[0];
- matrix1.row3[0] = currentMatrix->row3[0];
+ matrix1.row1.x = currentMatrix->row1.x;
+ matrix1.row2.x = currentMatrix->row2.x;
+ matrix1.row3.x = currentMatrix->row3.x;
- matrix1.row1[1] = (currentMatrix->row1[2] * angleVar2 + currentMatrix->row1[1] * angleVar1) / SCENE_SIZE_HALF;
- matrix1.row1[2] = (currentMatrix->row1[2] * angleVar1 - currentMatrix->row1[1] * angleVar2) / SCENE_SIZE_HALF;
- matrix1.row2[1] = (currentMatrix->row2[2] * angleVar2 + currentMatrix->row2[1] * angleVar1) / SCENE_SIZE_HALF;
- matrix1.row2[2] = (currentMatrix->row2[2] * angleVar1 - currentMatrix->row2[1] * angleVar2) / SCENE_SIZE_HALF;
- matrix1.row3[1] = (currentMatrix->row3[2] * angleVar2 + currentMatrix->row3[1] * angleVar1) / SCENE_SIZE_HALF;
- matrix1.row3[2] = (currentMatrix->row3[2] * angleVar1 - currentMatrix->row3[1] * angleVar2) / SCENE_SIZE_HALF;
+ matrix1.row1.y = (currentMatrix->row1.z * angleVar2 + currentMatrix->row1.y * angleVar1) / SCENE_SIZE_HALF;
+ matrix1.row1.z = (currentMatrix->row1.z * angleVar1 - currentMatrix->row1.y * angleVar2) / SCENE_SIZE_HALF;
+ matrix1.row2.y = (currentMatrix->row2.z * angleVar2 + currentMatrix->row2.y * angleVar1) / SCENE_SIZE_HALF;
+ matrix1.row2.z = (currentMatrix->row2.z * angleVar1 - currentMatrix->row2.y * angleVar2) / SCENE_SIZE_HALF;
+ matrix1.row3.y = (currentMatrix->row3.z * angleVar2 + currentMatrix->row3.y * angleVar1) / SCENE_SIZE_HALF;
+ matrix1.row3.z = (currentMatrix->row3.z * angleVar1 - currentMatrix->row3.y * angleVar2) / SCENE_SIZE_HALF;
} else {
matrix1 = *currentMatrix;
}
@@ -278,16 +278,16 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
- matrix2.row1[2] = matrix1.row1[2];
- matrix2.row2[2] = matrix1.row2[2];
- matrix2.row3[2] = matrix1.row3[2];
+ matrix2.row1.z = matrix1.row1.z;
+ matrix2.row2.z = matrix1.row2.z;
+ matrix2.row3.z = matrix1.row3.z;
- matrix2.row1[0] = (matrix1.row1[1] * angleVar2 + matrix1.row1[0] * angleVar1) / SCENE_SIZE_HALF;
- matrix2.row1[1] = (matrix1.row1[1] * angleVar1 - matrix1.row1[0] * angleVar2) / SCENE_SIZE_HALF;
- matrix2.row2[0] = (matrix1.row2[1] * angleVar2 + matrix1.row2[0] * angleVar1) / SCENE_SIZE_HALF;
- matrix2.row2[1] = (matrix1.row2[1] * angleVar1 - matrix1.row2[0] * angleVar2) / SCENE_SIZE_HALF;
- matrix2.row3[0] = (matrix1.row3[1] * angleVar2 + matrix1.row3[0] * angleVar1) / SCENE_SIZE_HALF;
- matrix2.row3[1] = (matrix1.row3[1] * angleVar1 - matrix1.row3[0] * angleVar2) / SCENE_SIZE_HALF;
+ matrix2.row1.x = (matrix1.row1.y * angleVar2 + matrix1.row1.x * angleVar1) / SCENE_SIZE_HALF;
+ matrix2.row1.y = (matrix1.row1.y * angleVar1 - matrix1.row1.x * angleVar2) / SCENE_SIZE_HALF;
+ matrix2.row2.x = (matrix1.row2.y * angleVar2 + matrix1.row2.x * angleVar1) / SCENE_SIZE_HALF;
+ matrix2.row2.y = (matrix1.row2.y * angleVar1 - matrix1.row2.x * angleVar2) / SCENE_SIZE_HALF;
+ matrix2.row3.x = (matrix1.row3.y * angleVar2 + matrix1.row3.x * angleVar1) / SCENE_SIZE_HALF;
+ matrix2.row3.y = (matrix1.row3.y * angleVar1 - matrix1.row3.x * angleVar2) / SCENE_SIZE_HALF;
} else {
matrix2 = matrix1;
}
@@ -298,17 +298,17 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
- targetMatrix->row1[1] = matrix2.row1[1];
- targetMatrix->row2[1] = matrix2.row2[1];
- targetMatrix->row3[1] = matrix2.row3[1];
+ targetMatrix->row1.y = matrix2.row1.y;
+ targetMatrix->row2.y = matrix2.row2.y;
+ targetMatrix->row3.y = matrix2.row3.y;
- targetMatrix->row1[0] = (matrix2.row1[0] * angleVar1 - matrix2.row1[2] * angleVar2) / SCENE_SIZE_HALF;
- targetMatrix->row1[2] = (matrix2.row1[0] * angleVar2 + matrix2.row1[2] * angleVar1) / SCENE_SIZE_HALF;
- targetMatrix->row2[0] = (matrix2.row2[0] * angleVar1 - matrix2.row2[2] * angleVar2) / SCENE_SIZE_HALF;
- targetMatrix->row2[2] = (matrix2.row2[0] * angleVar2 + matrix2.row2[2] * angleVar1) / SCENE_SIZE_HALF;
+ targetMatrix->row1.x = (matrix2.row1.x * angleVar1 - matrix2.row1.z * angleVar2) / SCENE_SIZE_HALF;
+ targetMatrix->row1.z = (matrix2.row1.x * angleVar2 + matrix2.row1.z * angleVar1) / SCENE_SIZE_HALF;
+ targetMatrix->row2.x = (matrix2.row2.x * angleVar1 - matrix2.row2.z * angleVar2) / SCENE_SIZE_HALF;
+ targetMatrix->row2.z = (matrix2.row2.x * angleVar2 + matrix2.row2.z * angleVar1) / SCENE_SIZE_HALF;
- targetMatrix->row3[0] = (matrix2.row3[0] * angleVar1 - matrix2.row3[2] * angleVar2) / SCENE_SIZE_HALF;
- targetMatrix->row3[2] = (matrix2.row3[0] * angleVar2 + matrix2.row3[2] * angleVar1) / SCENE_SIZE_HALF;
+ targetMatrix->row3.x = (matrix2.row3.x * angleVar1 - matrix2.row3.z * angleVar2) / SCENE_SIZE_HALF;
+ targetMatrix->row3.z = (matrix2.row3.x * angleVar2 + matrix2.row3.z * angleVar1) / SCENE_SIZE_HALF;
} else {
*targetMatrix = matrix2;
}
@@ -317,13 +317,9 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
void Renderer::applyPointsRotation(const Common::Array<BodyVertex> &vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *rotationMatrix) {
for (int32 i = 0; i < numPoints; ++i) {
const BodyVertex &vertex = vertices[i + firstPoint];
- const int32 tmpX = vertex.x;
- const int32 tmpY = vertex.y;
- const int32 tmpZ = vertex.z;
-
- destPoints->x = ((rotationMatrix->row1[0] * tmpX + rotationMatrix->row1[1] * tmpY + rotationMatrix->row1[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.x;
- destPoints->y = ((rotationMatrix->row2[0] * tmpX + rotationMatrix->row2[1] * tmpY + rotationMatrix->row2[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.y;
- destPoints->z = ((rotationMatrix->row3[0] * tmpX + rotationMatrix->row3[1] * tmpY + rotationMatrix->row3[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.z;
+ destPoints->x = ((rotationMatrix->row1.x * vertex.x + rotationMatrix->row1.y * vertex.y + rotationMatrix->row1.z * vertex.z) / SCENE_SIZE_HALF) + destPos.x;
+ destPoints->y = ((rotationMatrix->row2.x * vertex.x + rotationMatrix->row2.y * vertex.y + rotationMatrix->row2.z * vertex.z) / SCENE_SIZE_HALF) + destPos.y;
+ destPoints->z = ((rotationMatrix->row3.x * vertex.x + rotationMatrix->row3.y * vertex.y + rotationMatrix->row3.z * vertex.z) / SCENE_SIZE_HALF) + destPos.z;
destPoints++;
}
@@ -332,11 +328,7 @@ void Renderer::applyPointsRotation(const Common::Array<BodyVertex> &vertices, in
void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const Common::Array<BodyVertex> &vertices, int32 rotX, int32 rotY, int32 rotZ, const BodyBone &bone, ModelData *modelData) {
const int32 firstPoint = bone.firstVertex;
const int32 numOfPoints = bone.numVertices;
-
- IVec3 renderAngle;
- renderAngle.x = rotX;
- renderAngle.y = rotY;
- renderAngle.z = rotZ;
+ const IVec3 renderAngle(rotX, rotY, rotZ);
const IMatrix3x3 *currentMatrix;
// if its the first point
@@ -373,9 +365,9 @@ void Renderer::applyPointsTranslation(const Common::Array<BodyVertex> &vertices,
const int32 tmpY = vertex.y + angleVec.y;
const int32 tmpZ = vertex.z + angleVec.x;
- destPoints->x = ((translationMatrix->row1[0] * tmpX + translationMatrix->row1[1] * tmpY + translationMatrix->row1[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.x;
- destPoints->y = ((translationMatrix->row2[0] * tmpX + translationMatrix->row2[1] * tmpY + translationMatrix->row2[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.y;
- destPoints->z = ((translationMatrix->row3[0] * tmpX + translationMatrix->row3[1] * tmpY + translationMatrix->row3[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.z;
+ destPoints->x = ((translationMatrix->row1.x * tmpX + translationMatrix->row1.y * tmpY + translationMatrix->row1.z * tmpZ) / SCENE_SIZE_HALF) + destPos.x;
+ destPoints->y = ((translationMatrix->row2.x * tmpX + translationMatrix->row2.y * tmpY + translationMatrix->row2.z * tmpZ) / SCENE_SIZE_HALF) + destPos.y;
+ destPoints->z = ((translationMatrix->row3.x * tmpX + translationMatrix->row3.y * tmpY + translationMatrix->row3.z * tmpZ) / SCENE_SIZE_HALF) + destPos.z;
destPoints++;
}
@@ -1411,9 +1403,9 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const BodyData &bodyDat
const int16 col3 = shadePtr.col3;
int32 color = 0;
- color += _shadeMatrix.row1[0] * col1 + _shadeMatrix.row1[1] * col2 + _shadeMatrix.row1[2] * col3;
- color += _shadeMatrix.row2[0] * col1 + _shadeMatrix.row2[1] * col2 + _shadeMatrix.row2[2] * col3;
- color += _shadeMatrix.row3[0] * col1 + _shadeMatrix.row3[1] * col2 + _shadeMatrix.row3[2] * col3;
+ color += _shadeMatrix.row1.x * col1 + _shadeMatrix.row1.y * col2 + _shadeMatrix.row1.z * col3;
+ color += _shadeMatrix.row2.x * col1 + _shadeMatrix.row2.y * col2 + _shadeMatrix.row2.z * col3;
+ color += _shadeMatrix.row3.x * col1 + _shadeMatrix.row3.y * col2 + _shadeMatrix.row3.z * col3;
int32 shade = 0;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 903f6f60a7..f9b863d726 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -71,17 +71,17 @@ struct IMatrix3x3 {
inline IMatrix3x3 operator*(const IMatrix3x3 &matrix, const IVec3 &vec) {
IMatrix3x3 out;
- out.row1[0] = matrix.row1[0] * vec.x;
- out.row1[1] = matrix.row1[1] * vec.x;
- out.row1[2] = matrix.row1[2] * vec.x;
+ out.row1.x = matrix.row1.x * vec.x;
+ out.row1.y = matrix.row1.y * vec.x;
+ out.row1.z = matrix.row1.z * vec.x;
- out.row2[0] = matrix.row2[0] * vec.y;
- out.row2[1] = matrix.row2[1] * vec.y;
- out.row2[2] = matrix.row2[2] * vec.y;
+ out.row2.x = matrix.row2.x * vec.y;
+ out.row2.y = matrix.row2.y * vec.y;
+ out.row2.z = matrix.row2.z * vec.y;
- out.row3[0] = matrix.row3[0] * vec.z;
- out.row3[1] = matrix.row3[1] * vec.z;
- out.row3[2] = matrix.row3[2] * vec.z;
+ out.row3.x = matrix.row3.x * vec.z;
+ out.row3.y = matrix.row3.y * vec.z;
+ out.row3.z = matrix.row3.z * vec.z;
return out;
}
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index a512a20096..d5a8f628d5 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -103,30 +103,6 @@ struct IVec3 {
z -= other.z;
return *this;
}
-
- inline int32 &operator[](size_t idx) {
- switch (idx) {
- default:
- case 0:
- return x;
- case 1:
- return y;
- case 2:
- return z;
- }
- }
-
- inline int32 operator[](size_t idx) const {
- switch (idx) {
- default:
- case 0:
- return x;
- case 1:
- return y;
- case 2:
- return z;
- }
- }
};
inline IVec3 operator+(const IVec3 &lhs, const IVec3 &rhs) {
Commit: 0430f59454efa2c36377e25bef04358bdbced861
https://github.com/scummvm/scummvm/commit/0430f59454efa2c36377e25bef04358bdbced861
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-27T20:28:34+01:00
Commit Message:
TWINE: added assignment operator for I16Vec3 to IVec3
doxygen and removed unused struct
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
engines/twine/shared.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 7afe3383e5..893ba1bcb2 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -344,9 +344,7 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const Common::Arr
assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(_matricesTable));
currentMatrix = &_matricesTable[matrixIndex];
- destPos.x = modelData->computedPoints[pointIdx].x;
- destPos.y = modelData->computedPoints[pointIdx].y;
- destPos.z = modelData->computedPoints[pointIdx].z;
+ destPos = modelData->computedPoints[pointIdx];
}
applyRotation(targetMatrix, currentMatrix, renderAngle);
@@ -387,9 +385,7 @@ void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const Common::
*targetMatrix = _baseMatrix;
} else { // dependent
const int32 pointsIdx = bone.vertex;
- destPos.x = modelData->computedPoints[pointsIdx].x;
- destPos.y = modelData->computedPoints[pointsIdx].y;
- destPos.z = modelData->computedPoints[pointsIdx].z;
+ destPos = modelData->computedPoints[pointsIdx];
const int32 matrixIndex = bone.parent;
assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(_matricesTable));
@@ -405,11 +401,7 @@ void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
_cameraAngleY = angleY;
_cameraAngleZ = angleZ;*/
- IVec3 renderAngle;
- renderAngle.x = angleX;
- renderAngle.y = angleY;
- renderAngle.z = angleZ;
-
+ const IVec3 renderAngle(angleX, angleY, angleZ);
applyRotation(&_shadeMatrix, &_baseMatrix, renderAngle);
translateGroup(0, 0, 59);
@@ -1356,10 +1348,12 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const BodyData &bodyDat
pointPtrDest->y = coY;
- if (pointPtrDest->y < _engine->_redraw->renderRect.top)
+ if (pointPtrDest->y < _engine->_redraw->renderRect.top) {
_engine->_redraw->renderRect.top = pointPtrDest->y;
- if (pointPtrDest->y > _engine->_redraw->renderRect.bottom)
+ }
+ if (pointPtrDest->y > _engine->_redraw->renderRect.bottom) {
_engine->_redraw->renderRect.bottom = pointPtrDest->y;
+ }
}
// Z projection
@@ -1398,9 +1392,9 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const BodyData &bodyDat
do { // for each normal
const BodyShade &shadePtr = bodyData.getShade(shadeIndex);
- const int16 col1 = shadePtr.col1;
- const int16 col2 = shadePtr.col2;
- const int16 col3 = shadePtr.col3;
+ const int32 col1 = (int32)shadePtr.col1;
+ const int32 col2 = (int32)shadePtr.col2;
+ const int32 col3 = (int32)shadePtr.col3;
int32 color = 0;
color += _shadeMatrix.row1.x * col1 + _shadeMatrix.row1.y * col2 + _shadeMatrix.row1.z * col3;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index f9b863d726..cd1ea1e1b0 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -40,10 +40,6 @@
#define POLYGONTYPE_DITHER 8
#define POLYGONTYPE_UNKNOWN 9
-namespace Common {
-class MemoryReadStream;
-}
-
namespace TwinE {
class TwinEEngine;
@@ -95,6 +91,9 @@ private:
/**
* Pointer to the command data
* @sa renderCoordinatesBuffer
+ * @sa CmdRenderLine
+ * @sa CmdRenderSphere
+ * @sa CmdRenderPolygon
*/
uint8 *dataPtr = nullptr;
};
@@ -127,11 +126,6 @@ private:
int16 radius = 0;
};
- struct polyVertexHeader {
- int16 shadeEntry = 0;
- int16 dataOffset = 0;
- };
-
struct ModelData {
I16Vec3 computedPoints[800];
I16Vec3 flattenPoints[800];
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index d5a8f628d5..c97fbb6459 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -90,6 +90,13 @@ struct IVec3 {
int32 y;
int32 z;
+ inline IVec3 &operator=(const I16Vec3& other) {
+ x = other.x;
+ y = other.y;
+ z = other.z;
+ return *this;
+ }
+
inline IVec3& operator+=(const IVec3 &other) {
x += other.x;
y += other.y;
@@ -105,11 +112,11 @@ struct IVec3 {
}
};
-inline IVec3 operator+(const IVec3 &lhs, const IVec3 &rhs) {
+inline constexpr IVec3 operator+(const IVec3 &lhs, const IVec3 &rhs) {
return IVec3{lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z};
}
-inline IVec3 operator-(const IVec3 &lhs, const IVec3 &rhs) {
+inline constexpr IVec3 operator-(const IVec3 &lhs, const IVec3 &rhs) {
return IVec3{lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z};
}
Commit: ba6ebf5b4d1d2c414137e71c78d74df3fbae0e83
https://github.com/scummvm/scummvm/commit/ba6ebf5b4d1d2c414137e71c78d74df3fbae0e83
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-27T20:32:09+01:00
Commit Message:
TWINE: fixed header guards
Changed paths:
engines/twine/renderer/redraw.h
engines/twine/renderer/renderer.h
engines/twine/renderer/screens.h
engines/twine/renderer/shadeangletab.h
engines/twine/resources/hqr.h
engines/twine/resources/lzss.h
engines/twine/resources/resources.h
engines/twine/scene/actor.h
engines/twine/scene/animations.h
engines/twine/scene/collision.h
engines/twine/scene/extra.h
engines/twine/scene/gamestate.h
engines/twine/scene/grid.h
engines/twine/scene/movements.h
engines/twine/scene/scene.h
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index 90aae374b9..9a49718416 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_REDRAW_H
-#define TWINE_REDRAW_H
+#ifndef TWINE_RENDERER_REDRAW_H
+#define TWINE_RENDERER_REDRAW_H
#include "common/scummsys.h"
#include "common/rect.h"
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index cd1ea1e1b0..346c5b7b4d 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_RENDERER_H
-#define TWINE_RENDERER_H
+#ifndef TWINE_RENDERER_RENDERER_H
+#define TWINE_RENDERER_RENDERER_H
#include "common/endian.h"
#include "common/rect.h"
diff --git a/engines/twine/renderer/screens.h b/engines/twine/renderer/screens.h
index 01d38e912e..13dad5a10e 100644
--- a/engines/twine/renderer/screens.h
+++ b/engines/twine/renderer/screens.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_SCREENS_H
-#define TWINE_SCREENS_H
+#ifndef TWINE_RENDERER_SCREENS_H
+#define TWINE_RENDERER_SCREENS_H
#include "common/scummsys.h"
#include "graphics/managed_surface.h"
diff --git a/engines/twine/renderer/shadeangletab.h b/engines/twine/renderer/shadeangletab.h
index 17b3006fe1..1f0b4a4268 100644
--- a/engines/twine/renderer/shadeangletab.h
+++ b/engines/twine/renderer/shadeangletab.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_SHADEANGLETAB_H
-#define TWINE_SHADEANGLETAB_H
+#ifndef TWINE_RENDERER_SHADEANGLETAB_H
+#define TWINE_RENDERER_SHADEANGLETAB_H
#include "common/scummsys.h"
#include "twine/shared.h"
diff --git a/engines/twine/resources/hqr.h b/engines/twine/resources/hqr.h
index c217bd097b..bf75fa894c 100644
--- a/engines/twine/resources/hqr.h
+++ b/engines/twine/resources/hqr.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_HQR_H
-#define TWINE_HQR_H
+#ifndef TWINE_RESOURCES_HQR_H
+#define TWINE_RESOURCES_HQR_H
#include "common/scummsys.h"
#include "common/stream.h"
diff --git a/engines/twine/resources/lzss.h b/engines/twine/resources/lzss.h
index bdabee980d..5536bed579 100644
--- a/engines/twine/resources/lzss.h
+++ b/engines/twine/resources/lzss.h
@@ -20,6 +20,9 @@
*
*/
+#ifndef TWINE_RESOURCES_LZSS_H
+#define TWINE_RESOURCES_LZSS_H
+
#include "common/stream.h"
namespace TwinE {
@@ -48,3 +51,5 @@ public:
};
} // namespace TwinE
+
+#endif
diff --git a/engines/twine/resources/resources.h b/engines/twine/resources/resources.h
index 5785e1fc2e..d0bc368787 100644
--- a/engines/twine/resources/resources.h
+++ b/engines/twine/resources/resources.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_RESOURCES_H
-#define TWINE_RESOURCES_H
+#ifndef TWINE_RESOURCES_RESOURCES_H
+#define TWINE_RESOURCES_RESOURCES_H
#include "common/hashmap.h"
#include "common/scummsys.h"
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index ab0125dc52..1fc5790e7a 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_ACTOR_H
-#define TWINE_ACTOR_H
+#ifndef TWINE_SCENE_ACTOR_H
+#define TWINE_SCENE_ACTOR_H
#include "common/scummsys.h"
#include "twine/parser/anim.h"
diff --git a/engines/twine/scene/animations.h b/engines/twine/scene/animations.h
index 3e98c9d4dc..4a3373f186 100644
--- a/engines/twine/scene/animations.h
+++ b/engines/twine/scene/animations.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_ANIMATIONS_H
-#define TWINE_ANIMATIONS_H
+#ifndef TWINE_SCENE_ANIMATIONS_H
+#define TWINE_SCENE_ANIMATIONS_H
#include "common/scummsys.h"
#include "twine/scene/actor.h"
diff --git a/engines/twine/scene/collision.h b/engines/twine/scene/collision.h
index 09ab8b36cb..280541db17 100644
--- a/engines/twine/scene/collision.h
+++ b/engines/twine/scene/collision.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_COLLISION_H
-#define TWINE_COLLISION_H
+#ifndef TWINE_SCENE_COLLISION_H
+#define TWINE_SCENE_COLLISION_H
#include "common/scummsys.h"
#include "twine/scene/extra.h"
diff --git a/engines/twine/scene/extra.h b/engines/twine/scene/extra.h
index e2d7ccab9b..3dad9f9101 100644
--- a/engines/twine/scene/extra.h
+++ b/engines/twine/scene/extra.h
@@ -20,12 +20,12 @@
*
*/
+#ifndef TWINE_SCENE_EXTRA_H
+#define TWINE_SCENE_EXTRA_H
+
#include "common/scummsys.h"
#include "twine/scene/actor.h"
-#ifndef TWINE_EXTRA_H
-#define TWINE_EXTRA_H
-
namespace TwinE {
#define EXTRA_MAX_ENTRIES 50
diff --git a/engines/twine/scene/gamestate.h b/engines/twine/scene/gamestate.h
index 64451f3f55..5fea87ae88 100644
--- a/engines/twine/scene/gamestate.h
+++ b/engines/twine/scene/gamestate.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_GAMESTATE_H
-#define TWINE_GAMESTATE_H
+#ifndef TWINE_SCENE_GAMESTATE_H
+#define TWINE_SCENE_GAMESTATE_H
#include "common/savefile.h"
#include "common/scummsys.h"
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index 09b6b22fc4..11f17188b2 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_GRID_H
-#define TWINE_GRID_H
+#ifndef TWINE_SCENE_GRID_H
+#define TWINE_SCENE_GRID_H
#include "common/scummsys.h"
#include "twine/parser/sprite.h"
diff --git a/engines/twine/scene/movements.h b/engines/twine/scene/movements.h
index 8c10b58b07..e28cefe440 100644
--- a/engines/twine/scene/movements.h
+++ b/engines/twine/scene/movements.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_MOVEMENTS_H
-#define TWINE_MOVEMENTS_H
+#ifndef TWINE_SCENE_MOVEMENTS_H
+#define TWINE_SCENE_MOVEMENTS_H
#include "common/scummsys.h"
#include "twine/scene/actor.h"
diff --git a/engines/twine/scene/scene.h b/engines/twine/scene/scene.h
index 2b368b3d78..c7db090a92 100644
--- a/engines/twine/scene/scene.h
+++ b/engines/twine/scene/scene.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef TWINE_SCENE_H
-#define TWINE_SCENE_H
+#ifndef TWINE_SCENE_SCENE_H
+#define TWINE_SCENE_SCENE_H
#include "common/scummsys.h"
#include "common/util.h"
More information about the Scummvm-git-logs
mailing list