From 5683f076331d2831eb4720b65bb53e8d01ca33ee Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 18:19:07 +0200 Subject: WINTERMUTE: Rename CamelCased filenames to prefixed_under_score-filenames This is mostly a lead-up to namespacing the Ad/Base folders, and then possibly removing the prefixes from the files, it also has the added benefit of getting rid of the odd case-typos that makes for issues on platforms that don't ignore case. --- engines/wintermute/math/MathUtil.cpp | 48 ------------------- engines/wintermute/math/MathUtil.h | 42 ----------------- engines/wintermute/math/Matrix4.cpp | 86 ----------------------------------- engines/wintermute/math/Matrix4.h | 59 ------------------------ engines/wintermute/math/Rect32.h | 86 ----------------------------------- engines/wintermute/math/Vector2.cpp | 55 ---------------------- engines/wintermute/math/Vector2.h | 75 ------------------------------ engines/wintermute/math/math_util.cpp | 48 +++++++++++++++++++ engines/wintermute/math/math_util.h | 42 +++++++++++++++++ engines/wintermute/math/matrix4.cpp | 86 +++++++++++++++++++++++++++++++++++ engines/wintermute/math/matrix4.h | 59 ++++++++++++++++++++++++ engines/wintermute/math/rect32.h | 86 +++++++++++++++++++++++++++++++++++ engines/wintermute/math/vector2.cpp | 55 ++++++++++++++++++++++ engines/wintermute/math/vector2.h | 75 ++++++++++++++++++++++++++++++ 14 files changed, 451 insertions(+), 451 deletions(-) delete mode 100644 engines/wintermute/math/MathUtil.cpp delete mode 100644 engines/wintermute/math/MathUtil.h delete mode 100644 engines/wintermute/math/Matrix4.cpp delete mode 100644 engines/wintermute/math/Matrix4.h delete mode 100644 engines/wintermute/math/Rect32.h delete mode 100644 engines/wintermute/math/Vector2.cpp delete mode 100644 engines/wintermute/math/Vector2.h create mode 100644 engines/wintermute/math/math_util.cpp create mode 100644 engines/wintermute/math/math_util.h create mode 100644 engines/wintermute/math/matrix4.cpp create mode 100644 engines/wintermute/math/matrix4.h create mode 100644 engines/wintermute/math/rect32.h create mode 100644 engines/wintermute/math/vector2.cpp create mode 100644 engines/wintermute/math/vector2.h (limited to 'engines/wintermute/math') diff --git a/engines/wintermute/math/MathUtil.cpp b/engines/wintermute/math/MathUtil.cpp deleted file mode 100644 index 47b472d9cf..0000000000 --- a/engines/wintermute/math/MathUtil.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "MathUtil.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -float MathUtil::round(float val) { - float result = floor(val); - if (val - result >= 0.5) result += 1.0; - return result; -} - -////////////////////////////////////////////////////////////////////////// -float MathUtil::roundUp(float val) { - float result = floor(val); - if (val - result > 0) result += 1.0; - return result; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/math/MathUtil.h b/engines/wintermute/math/MathUtil.h deleted file mode 100644 index db814a59ac..0000000000 --- a/engines/wintermute/math/MathUtil.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_MATHUTIL_H -#define WINTERMUTE_MATHUTIL_H - -namespace WinterMute { - -class MathUtil { -public: - static float round(float val); - static float roundUp(float val); -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/math/Matrix4.cpp b/engines/wintermute/math/Matrix4.cpp deleted file mode 100644 index 557f0d5c9a..0000000000 --- a/engines/wintermute/math/Matrix4.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/math/Matrix4.h" -#include "engines/wintermute/math/Vector2.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -Matrix4::Matrix4() { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - m[i][j] = 0.0f; - } - } -} - -////////////////////////////////////////////////////////////////////////// -Matrix4::~Matrix4() { -} - - -////////////////////////////////////////////////////////////////////////// -void Matrix4::identity() { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - m[i][j] = 0.0f; - } - } - m[0][0] = 1.0f; - m[1][1] = 1.0f; - m[2][2] = 1.0f; - m[3][3] = 1.0f; - -} - -////////////////////////////////////////////////////////////////////////// -void Matrix4::rotationZ(float angle) { - identity(); - - m[0][0] = cos(angle); - m[1][1] = cos(angle); - m[0][1] = sin(angle); - m[1][0] = -sin(angle); -} - -////////////////////////////////////////////////////////////////////////// -void Matrix4::transformVector2(Vector2 &vec) { - float norm; - - norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; - - float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm; - float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm; - - vec.x = x; - vec.y = y; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/math/Matrix4.h b/engines/wintermute/math/Matrix4.h deleted file mode 100644 index 5def8dfe97..0000000000 --- a/engines/wintermute/math/Matrix4.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_MATRIX4_H -#define WINTERMUTE_MATRIX4_H - -namespace WinterMute { - -class Vector2; - -class Matrix4 { -public: - Matrix4(); - ~Matrix4(); - - void identity(); - void rotationZ(float angle); - void transformVector2(Vector2 &vec); - - /* union { - struct { - float _11, _12, _13, _14; - float _21, _22, _23, _24; - float _31, _32, _33, _34; - float _41, _42, _43, _44; - };*/ - float m[4][4]; - //}; - -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/math/Rect32.h b/engines/wintermute/math/Rect32.h deleted file mode 100644 index e0babcbbb9..0000000000 --- a/engines/wintermute/math/Rect32.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef WINTERMUTE_RECT32_H -#define WINTERMUTE_RECT32_H - -#include "common/system.h" - -namespace WinterMute { - -struct Point32 { - int32 x; - int32 y; -}; - -struct Rect32 { - int32 top, left; ///< The point at the top left of the rectangle (part of the rect). - int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). - - Rect32() : top(0), left(0), bottom(0), right(0) {} - Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} - Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { - assert(isValidRect()); - } - bool operator==(const Rect32 &rhs) const { return equals(rhs); } - bool operator!=(const Rect32 &rhs) const { return !equals(rhs); } - - int16 width() const { return right - left; } - int16 height() const { return bottom - top; } - - void setWidth(int16 aWidth) { - right = left + aWidth; - } - - void setHeight(int16 aHeight) { - bottom = top + aHeight; - } - - void setEmpty() { - left = right = top = bottom = 0; - } - - void offsetRect(int dx, int dy) { - left += dx; - top += dy; - right += dx; - bottom += dy; - } - /** - * Check if the given rect is equal to this one. - * - * @param r The rectangle to check - * - * @return true if the given rect is equal, false otherwise - */ - bool equals(const Rect32 &r) const { - return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom); - } - - bool isValidRect() const { - return (left <= right && top <= bottom); - } -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_RECT32_H diff --git a/engines/wintermute/math/Vector2.cpp b/engines/wintermute/math/Vector2.cpp deleted file mode 100644 index 8bd10320a8..0000000000 --- a/engines/wintermute/math/Vector2.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "Vector2.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -Vector2::Vector2() { - x = y = 0.0f; -} - -////////////////////////////////////////////////////////////////////////// -Vector2::Vector2(float xVal, float yVal) { - this->x = xVal; - this->y = yVal; -} - -////////////////////////////////////////////////////////////////////////// -Vector2::~Vector2() { -} - - -////////////////////////////////////////////////////////////////////////// -float Vector2::length() const { - return (float)sqrt(x * x + y * y); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/math/Vector2.h b/engines/wintermute/math/Vector2.h deleted file mode 100644 index 96d3a3827d..0000000000 --- a/engines/wintermute/math/Vector2.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_VECTOR2_H -#define WINTERMUTE_VECTOR2_H - -namespace WinterMute { - -class Vector2 { -public: - Vector2(); - Vector2(float x, float y); - ~Vector2(); - - float length() const; - - inline Vector2 &operator= (const Vector2 &other) { - x = other.x; - y = other.y; - - return *this; - } - - inline Vector2 operator+ (const Vector2 &other) const { - return Vector2(x + other.x, y + other.y); - } - - inline Vector2 operator- (const Vector2 &other) const { - return Vector2(x - other.x, y - other.y); - } - - inline Vector2 operator* (const float scalar) const { - return Vector2(x * scalar, y * scalar); - } - - inline Vector2 &operator+= (const Vector2 &other) { - x += other.x; - y += other.y; - - return *this; - } - - - float x; - float y; -}; - -} // end of namespace WinterMute - -#endif // WINTERMUTE_VECTOR2_H diff --git a/engines/wintermute/math/math_util.cpp b/engines/wintermute/math/math_util.cpp new file mode 100644 index 0000000000..d9449294fb --- /dev/null +++ b/engines/wintermute/math/math_util.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/math/math_util.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +float MathUtil::round(float val) { + float result = floor(val); + if (val - result >= 0.5) result += 1.0; + return result; +} + +////////////////////////////////////////////////////////////////////////// +float MathUtil::roundUp(float val) { + float result = floor(val); + if (val - result > 0) result += 1.0; + return result; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/math_util.h b/engines/wintermute/math/math_util.h new file mode 100644 index 0000000000..db814a59ac --- /dev/null +++ b/engines/wintermute/math/math_util.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_MATHUTIL_H +#define WINTERMUTE_MATHUTIL_H + +namespace WinterMute { + +class MathUtil { +public: + static float round(float val); + static float roundUp(float val); +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_MATHUTIL_H diff --git a/engines/wintermute/math/matrix4.cpp b/engines/wintermute/math/matrix4.cpp new file mode 100644 index 0000000000..a716e937f4 --- /dev/null +++ b/engines/wintermute/math/matrix4.cpp @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/math/matrix4.h" +#include "engines/wintermute/math/vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Matrix4::Matrix4() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } +} + +////////////////////////////////////////////////////////////////////////// +Matrix4::~Matrix4() { +} + + +////////////////////////////////////////////////////////////////////////// +void Matrix4::identity() { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + m[i][j] = 0.0f; + } + } + m[0][0] = 1.0f; + m[1][1] = 1.0f; + m[2][2] = 1.0f; + m[3][3] = 1.0f; + +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::rotationZ(float angle) { + identity(); + + m[0][0] = cos(angle); + m[1][1] = cos(angle); + m[0][1] = sin(angle); + m[1][0] = -sin(angle); +} + +////////////////////////////////////////////////////////////////////////// +void Matrix4::transformVector2(Vector2 &vec) { + float norm; + + norm = m[0][3] * vec.x + m[1][3] * vec.y + m[3][3]; + + float x = (m[0][0] * vec.x + m[1][0] * vec.y + m[3][0]) / norm; + float y = (m[0][1] * vec.x + m[1][1] * vec.y + m[3][1]) / norm; + + vec.x = x; + vec.y = y; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/matrix4.h b/engines/wintermute/math/matrix4.h new file mode 100644 index 0000000000..5def8dfe97 --- /dev/null +++ b/engines/wintermute/math/matrix4.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_MATRIX4_H +#define WINTERMUTE_MATRIX4_H + +namespace WinterMute { + +class Vector2; + +class Matrix4 { +public: + Matrix4(); + ~Matrix4(); + + void identity(); + void rotationZ(float angle); + void transformVector2(Vector2 &vec); + + /* union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + };*/ + float m[4][4]; + //}; + +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_MATRIX4_H diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h new file mode 100644 index 0000000000..e0babcbbb9 --- /dev/null +++ b/engines/wintermute/math/rect32.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef WINTERMUTE_RECT32_H +#define WINTERMUTE_RECT32_H + +#include "common/system.h" + +namespace WinterMute { + +struct Point32 { + int32 x; + int32 y; +}; + +struct Rect32 { + int32 top, left; ///< The point at the top left of the rectangle (part of the rect). + int32 bottom, right; ///< The point at the bottom right of the rectangle (not part of the rect). + + Rect32() : top(0), left(0), bottom(0), right(0) {} + Rect32(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {} + Rect32(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) { + assert(isValidRect()); + } + bool operator==(const Rect32 &rhs) const { return equals(rhs); } + bool operator!=(const Rect32 &rhs) const { return !equals(rhs); } + + int16 width() const { return right - left; } + int16 height() const { return bottom - top; } + + void setWidth(int16 aWidth) { + right = left + aWidth; + } + + void setHeight(int16 aHeight) { + bottom = top + aHeight; + } + + void setEmpty() { + left = right = top = bottom = 0; + } + + void offsetRect(int dx, int dy) { + left += dx; + top += dy; + right += dx; + bottom += dy; + } + /** + * Check if the given rect is equal to this one. + * + * @param r The rectangle to check + * + * @return true if the given rect is equal, false otherwise + */ + bool equals(const Rect32 &r) const { + return (left == r.left) && (right == r.right) && (top == r.top) && (bottom == r.bottom); + } + + bool isValidRect() const { + return (left <= right && top <= bottom); + } +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_RECT32_H diff --git a/engines/wintermute/math/vector2.cpp b/engines/wintermute/math/vector2.cpp new file mode 100644 index 0000000000..9906a59429 --- /dev/null +++ b/engines/wintermute/math/vector2.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/math/vector2.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2() { + x = y = 0.0f; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::Vector2(float xVal, float yVal) { + this->x = xVal; + this->y = yVal; +} + +////////////////////////////////////////////////////////////////////////// +Vector2::~Vector2() { +} + + +////////////////////////////////////////////////////////////////////////// +float Vector2::length() const { + return (float)sqrt(x * x + y * y); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/math/vector2.h b/engines/wintermute/math/vector2.h new file mode 100644 index 0000000000..96d3a3827d --- /dev/null +++ b/engines/wintermute/math/vector2.h @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VECTOR2_H +#define WINTERMUTE_VECTOR2_H + +namespace WinterMute { + +class Vector2 { +public: + Vector2(); + Vector2(float x, float y); + ~Vector2(); + + float length() const; + + inline Vector2 &operator= (const Vector2 &other) { + x = other.x; + y = other.y; + + return *this; + } + + inline Vector2 operator+ (const Vector2 &other) const { + return Vector2(x + other.x, y + other.y); + } + + inline Vector2 operator- (const Vector2 &other) const { + return Vector2(x - other.x, y - other.y); + } + + inline Vector2 operator* (const float scalar) const { + return Vector2(x * scalar, y * scalar); + } + + inline Vector2 &operator+= (const Vector2 &other) { + x += other.x; + y += other.y; + + return *this; + } + + + float x; + float y; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_VECTOR2_H -- cgit v1.2.3