X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fmeshgen.cc;h=bd9fe534e5fe5e2840dcdfd0019173404be8997b;hb=9922a7c30b64d74b424cb5783b08497396d2365c;hp=c6a4f48784082604b68054249c8e1c9f24ccca95;hpb=47982b199010496e34eefb95044275fb231cba18;p=demo diff --git a/src/meshgen.cc b/src/meshgen.cc index c6a4f48..bd9fe53 100644 --- a/src/meshgen.cc +++ b/src/meshgen.cc @@ -125,7 +125,7 @@ void gen_geosphere(Mesh *mesh, float rad, int subdiv, bool hemi) // ------ 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; @@ -135,11 +135,11 @@ static Vec3 hfield_vertex(float u, float v, float h, float xsz, } 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; @@ -174,12 +174,12 @@ void gen_heightfield(Mesh *mesh, float xsz, float ysz, float height, int usub, slopes in x, z, axis */ Vec3 tangent = hfield_vertex(u + du, v, calc_height(u + du, v, ptr), - xsz, ysz, height) - vtx; + xsz, ysz, height) - vtx; Vec3 bitangent = hfield_vertex(u, v + dv, calc_height(u, v + dv, ptr), - xsz, ysz, height) - vtx; + xsz, ysz, height) - vtx; - Vec3 normal = normalize(cross(tangent, bitangent)); + Vec3 normal = normalize(cross(bitangent, tangent)); mesh->vertices[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];