X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fmeshgen.cc;h=bd9fe534e5fe5e2840dcdfd0019173404be8997b;hb=HEAD;hp=9547ceecc392fe62f13ca9e6483b9d52f1dc9150;hpb=243eb502c5dc70e586a9e81815234069bf623480;p=demo diff --git a/src/meshgen.cc b/src/meshgen.cc index 9547cee..bd9fe53 100644 --- a/src/meshgen.cc +++ b/src/meshgen.cc @@ -119,27 +119,27 @@ void gen_geosphere(Mesh *mesh, float rad, int subdiv, bool hemi) for(int i=0; iindices[i] = i; } - mesh->update_vertex_data(); + mesh->invalidate(); } // ------ heightfield ------ static Vec3 hfield_vertex(float u, float v, float h, float xsz, - float ysz, float height) + float ysz, float 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); } void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub, - int vsub, float (*calc_height)(float u, float v, void *ptr), void *ptr) + int vsub, float (*calc_height)(float u, float v, void *ptr), void *ptr) { - /* + /* usub and vsub is the number of subdivision at each axis - (heightfield = grid) + (heightfield = grid) */ if(usub < 1) usub = 1; @@ -165,21 +165,21 @@ void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub, float dv = 1.0 / (float)num_vvertices; for(int i=0; ivertices[vidx] = vtx; mesh->normals[vidx] = normal; @@ -190,7 +190,7 @@ void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub, } /* - indices: + indices: */ uint16_t *iptr = &mesh->indices[0]; @@ -213,5 +213,5 @@ void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub, *iptr++ = a; } } - mesh->update_vertex_data(); + mesh->invalidate(); }