projects
/
demo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed terrain tiles generation
[demo]
/
src
/
meshgen.cc
diff --git
a/src/meshgen.cc
b/src/meshgen.cc
index
9547cee
..
c6a4f48
100644
(file)
--- a/
src/meshgen.cc
+++ b/
src/meshgen.cc
@@
-119,7
+119,7
@@
void gen_geosphere(Mesh *mesh, float rad, int subdiv, bool hemi)
for(int i=0; i<num_verts; i++) {
mesh->indices[i] = i;
}
for(int i=0; i<num_verts; i++) {
mesh->indices[i] = i;
}
- mesh->update_vertex_data();
+ mesh->invalidate();
}
// ------ heightfield ------
}
// ------ heightfield ------
@@
-129,7
+129,7
@@
static Vec3 hfield_vertex(float u, float v, float h, float xsz,
{
float x = u * xsz - xsz / 2.0;
float y = h * height;
{
float x = u * xsz - xsz / 2.0;
float y = h * height;
- float z = -(v * ysz - ysz / 2.0);
+ float z = v * ysz - ysz / 2.0;
return Vec3(x, y, z);
}
return Vec3(x, y, z);
}
@@
-165,9
+165,9
@@
void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub,
float dv = 1.0 / (float)num_vvertices;
for(int i=0; i<num_vvertices; i++) {
float dv = 1.0 / (float)num_vvertices;
for(int i=0; i<num_vvertices; i++) {
- float v = (float)i / (float)num_vvertices;
+ float v = 1 - (float)i / (float)(num_vvertices - 1);
for(int j=0; j<num_uvertices; j++) {
for(int j=0; j<num_uvertices; j++) {
- float u = (float)j / (float)num_uvertices;
+ float u = (float)j / (float)(num_uvertices - 1);
Vec3 vtx = hfield_vertex(u, v, calc_height(u, v, ptr), xsz, ysz, height);
/* calculating normal with forward differences:
Vec3 vtx = hfield_vertex(u, v, calc_height(u, v, ptr), xsz, ysz, height);
/* calculating normal with forward differences:
@@
-213,5
+213,5
@@
void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub,
*iptr++ = a;
}
}
*iptr++ = a;
}
}
- mesh->update_vertex_data();
+ mesh->invalidate();
}
}