diff --git a/doomsday/libdeng2/include/de/vector.h b/doomsday/libdeng2/include/de/vector.h index 85929e82bc..269b3bc70a 100644 --- a/doomsday/libdeng2/include/de/vector.h +++ b/doomsday/libdeng2/include/de/vector.h @@ -55,9 +55,6 @@ namespace de operator Vector2 () const { return Vector2(ddouble(x), ddouble(y)); } - operator String () const { - return asText(); - } Vector2 operator + (const Vector2& other) const { return Vector2(x + other.x, y + other.y); } @@ -158,9 +155,6 @@ namespace de operator Vector3 () const { return Vector3(Vector2::x, Vector2::y, z); } - operator String () const { - return asText(); - } Vector3 operator + (const Vector3& other) const { return Vector3(Vector2::x + other.x, Vector2::y + other.y, z + other.z); } @@ -266,9 +260,6 @@ namespace de operator Vector4 () const { return Vector4(Vector3::x, Vector3::y, Vector3::z, w); } - operator String () const { - return asText(); - } Vector4 operator + (const Vector4& other) const { return Vector4(Vector3::x + other.x, Vector3::y + other.y, Vector3::z + other.z, w + other.w); diff --git a/doomsday/tests/tests.pro b/doomsday/tests/tests.pro index e50bb29fa6..b0aa1c8964 100644 --- a/doomsday/tests/tests.pro +++ b/doomsday/tests/tests.pro @@ -4,6 +4,6 @@ SUBDIRS = \ #basiclink \ #record \ script \ - #vectors + vectors #OTHER_FILES += testapp.de diff --git a/doomsday/tests/vectors/main.cpp b/doomsday/tests/vectors/main.cpp new file mode 100644 index 0000000000..7f43aa41e3 --- /dev/null +++ b/doomsday/tests/vectors/main.cpp @@ -0,0 +1,84 @@ +/* + * The Doomsday Engine Project + * + * Copyright (c) 2009-2012 Jaakko Keränen + * + * 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, see . + */ + +#include +#include + +using namespace de; + +int main(int, char**) +{ + try + { + Vector2f a(1, 2.5); + Vector3f b(3, 5, 6); + + // Note: Using QDebug because no de::App (and therefore no log message + // buffer) is available. + + qDebug() << "Sizeof Vector2f:" << sizeof(a); + qDebug() << "Sizeof Vector3f:" << sizeof(b); + + qDebug() << "Direct access to members:"; + qDebug() << a.x << a.y; + qDebug() << b.x << b.y << b.z; + + qDebug() << "First operand defines type of result:"; + + qDebug() << "Vector2f + Vector3f:" << (a + b).asText(); + qDebug() << "Vector3f + Vector2f:" << (b + a).asText(); + + Vector2i c(6, 5); + + // This would downgrade the latter to int; won't do it. + //qDebug() << "Vector2i + Vector2f (converted to int!): " << (c + a).asText(); + + qDebug() << "Vector2i:" << c.asText(); + qDebug() << "Vector2f + Vector2i:" << (a + c).asText(); + + a += b; + b += a; + qDebug() << "After sum:" ; + qDebug() << "a:" << a.asText() << "b:" << b.asText(); + + qDebug() << "a > b: " << (a > b); + qDebug() << "b > a: " << (b > a); + + Vector2f s(1, 1); + Vector3f t(2, 2, 2); + qDebug() << "s: " << s.asText() << " t:" << t.asText(); + qDebug() << "s > t: " << (s > t); + qDebug() << "t > s: " << (t > s); + qDebug() << "s < t: " << (s < t); + qDebug() << "t < s: " << (t < s); + t.z = -100; + qDebug() << "t is now: " << t.asText(); + qDebug() << "s > t: " << (s > t); + qDebug() << "t > s: " << (t > s); + qDebug() << "s < t: " << (s < t) << " <- first operand causes conversion to Vector2"; + qDebug() << "t < s: " << (t < s); + } + catch(const Error& err) + { + qWarning() << err.asText() << "\n"; + } + + qDebug() << "Exiting main()...\n"; + return 0; +} diff --git a/doomsday/tests/vectors/vectors.pro b/doomsday/tests/vectors/vectors.pro new file mode 100644 index 0000000000..42a7370af2 --- /dev/null +++ b/doomsday/tests/vectors/vectors.pro @@ -0,0 +1,15 @@ +include(../config_test.pri) + +TEMPLATE = app +TARGET = test_vectors + +SOURCES += main.cpp + +macx { + cfg.files = $$DENG_CONFIG_DIR/deng.de + cfg.path = Contents/Resources/config + + QMAKE_BUNDLE_DATA += cfg + + macDeployTest($$TARGET) +}