From bebb67e03d378a084367cc05c3d9bbb76f1d8e73 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 16 Dec 2014 20:37:15 +0000 Subject: Project::OSiRiON can now be built with Clang, use -Wno-overloaded-virtual. --- src/model/asefile.cc | 2 +- src/model/mapfile.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 7 deletions(-) (limited to 'src/model') diff --git a/src/model/asefile.cc b/src/model/asefile.cc index 90bd6f2..ce43cd0 100644 --- a/src/model/asefile.cc +++ b/src/model/asefile.cc @@ -83,7 +83,7 @@ bool ASEFile::read_header(std::istream &is) std::string word; line >> word; - if (!word.compare("*3DSMAX_ASCIIEXPORT") == 0) { + if (word.compare("*3DSMAX_ASCIIEXPORT") != 0) { return false; } diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index 3a8aa40..9cdb23e 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -21,6 +21,52 @@ namespace model { +/** + * @brief a two-dimensional array class + * */ +template class Matrix { +public: + Matrix(size_t rows, size_t columns) + { + matrix_rows = rows; + matrix_columns = columns; + + matrix_values = new T *[matrix_rows]; + + for (size_t i = 0; i < matrix_rows; ++i) + { + matrix_values[i] = new T[columns]; + } + } + + ~Matrix() + { + for (size_t i = 0; i < matrix_rows; ++i) + { + delete[] matrix_values[i]; + } + + delete matrix_values; + } + + T * operator[](size_t row) + { + return matrix_values[row]; + } + + const T * operator[](size_t row) const + { + return matrix_values[row]; + } + + +private: + size_t matrix_rows; + size_t matrix_columns; + + T **matrix_values; +}; + // max geometry bounds const float MAX_BOUNDS = 16384; @@ -295,9 +341,10 @@ bool MapFile::read_patchdef() if ((columns < 2) || (rows < 2) || (columns >= 1024) || (rows >= 1024)) { return false; } - - math::Vector3f patchvertices[rows][columns]; - math::Vector2f patchtexcoords[rows][columns]; + + // clang doesn't like multidimensional arrays + Matrix patchvertices(rows, columns); + Matrix patchtexcoords(rows, columns); // read rows for (size_t r = 0; r < rows; r++) { @@ -417,9 +464,9 @@ bool MapFile::read_patchdef() size_t subdivide_u = 0; size_t subdivide_v = 0; - math::Vector3f mesh[subdivide_max + 1][subdivide_max +1]; - math::Vector3f meshnormals[subdivide_max + 1][subdivide_max +1]; - math::Vector2f meshtexcoords[subdivide_max + 1][subdivide_max +1]; + Matrix mesh(subdivide_max + 1, subdivide_max +1); + Matrix meshnormals(subdivide_max + 1, subdivide_max +1); + Matrix meshtexcoords(subdivide_max + 1, subdivide_max +1); for (size_t r = 0; r < rows-2; r +=2 ) { for (size_t c = 0; c < columns -2; c += 2) { -- cgit v1.2.3