Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/model/mapfile.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 7020d47..94a2642 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -411,8 +411,14 @@ bool MapFile::read_patchdef()
// binomial coefficient
const float binom[3] = {1.0f, 2.0f, 1.0f};
+ const size_t subdivide_max = 4;
+
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];
for (size_t r = 0; r < rows-2; r +=2 ) {
for (size_t c = 0; c < columns -2; c += 2) {
@@ -425,7 +431,7 @@ bool MapFile::read_patchdef()
) {
subdivide_u = 1;
} else {
- subdivide_u = 4;
+ subdivide_u = subdivide_max;
}
@@ -437,12 +443,10 @@ bool MapFile::read_patchdef()
) {
subdivide_v = 1;
} else {
- subdivide_v = 4;
+ subdivide_v = subdivide_max;
}
- math::Vector3f mesh[subdivide_u + 1][subdivide_v +1];
- math::Vector3f meshnormals[subdivide_u + 1][subdivide_v +1];
- math::Vector2f meshtexcoords[subdivide_u + 1][subdivide_v +1];
+
for (size_t i = 0; i <= subdivide_u; i++) {
const float u = (float) i / (float) subdivide_u;
@@ -461,6 +465,8 @@ bool MapFile::read_patchdef()
vn = (v - 0.5f) * 0.95f + 0.5f;
}
+ mesh[i][j].clear();
+
for (size_t mi = 0; mi < 3; mi++) {
for (size_t mj = 0; mj < 3; mj++) {
mesh[i][j] +=
@@ -633,7 +639,7 @@ bool MapFile::getline()
value_current.clear();
- } else if ((parse_level == 1)) {
+ } else if (parse_level == 1) {
// end-of-class
last_read_was_classend = true;
}