Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2014-12-16 20:37:15 +0000
committerStijn Buys <ingar@osirion.org>2014-12-16 20:37:15 +0000
commitbebb67e03d378a084367cc05c3d9bbb76f1d8e73 (patch)
treecd79f728276a9e5805ce29163f055c5103e3577e /src/model
parenta18281d42e8b4e9b3cf9d987ff980bcfc14344ad (diff)
Project::OSiRiON can now be built with Clang, use -Wno-overloaded-virtual.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/asefile.cc2
-rw-r--r--src/model/mapfile.cc59
2 files changed, 54 insertions, 7 deletions
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 T> 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<math::Vector3f> patchvertices(rows, columns);
+ Matrix<math::Vector2f> 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<math::Vector3f> mesh(subdivide_max + 1, subdivide_max +1);
+ Matrix<math::Vector3f> meshnormals(subdivide_max + 1, subdivide_max +1);
+ Matrix<math::Vector2f> 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) {