From 1e8963fc3f8191e328bbecd04cfbcba31d7d0bdf Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Sat, 16 Sep 2017 20:51:29 +0300 Subject: [PATCH] fix indentation,style --- src/image.cc | 6 +++--- src/main.cc | 9 ++++----- src/meshgen.cc | 14 +++++++------- src/meshgen.h | 2 +- src/morph_renderer.cc | 2 +- src/opengl/mesh-gl.cc | 12 ++++++------ src/terrain.cc | 14 +++++++------- src/terrain.h | 6 +++--- 8 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/image.cc b/src/image.cc index 82d8cd1..818b686 100644 --- a/src/image.cc +++ b/src/image.cc @@ -124,11 +124,11 @@ bool Image::load(const char *fname) Vec4 Image::get_pixel(int x, int y) const { if(is_float) { - return ((Vec4*)pixels)[y * w + x]; + return ((Vec4 *)pixels)[y * w + x]; } Vec4 color; - unsigned char *pptr = ((unsigned char*)pixels) + (y * w + x) * 4; + unsigned char *pptr = ((unsigned char *)pixels) + (y * w + x) * 4; color.x = pptr[0] / 255.0; color.y = pptr[1] / 255.0; color.z = pptr[2] / 255.0; @@ -165,7 +165,7 @@ Vec4 Image::lookup_linear(float u, float v, float du, float dv) const Vec4 p00 = get_pixel(x0, y0); Vec4 p01 = get_pixel(x0, y1); Vec4 p11 = get_pixel(x1, y1); - Vec4 p10 = get_pixel(x1, y0); + Vec4 p10 = get_pixel(x1, y0); Vec4 ptop = lerp(p01, p11, tu); Vec4 pbot = lerp(p00, p10, tu); diff --git a/src/main.cc b/src/main.cc index 491dd9c..69721c1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -211,7 +211,7 @@ static bool init(Gfx_API api) Object *cow = new Object; *cow = *cow0; - if (!gen_poisson(cow_pos, cow_gap, disk_radius)) + if(!gen_poisson(cow_pos, cow_gap, disk_radius)) goto cowgen_end; Vec2 pos = cow_pos.back(); float y = terrain.get_height(Vec3(pos.x, 1, pos.y)); @@ -305,7 +305,7 @@ static void clbk_motion(GLFWwindow *win, double x, double y) cam_dist = 0.0; } } - } +} static void clbk_mouse(GLFWwindow *win, int bn, int action, int mods) { @@ -364,8 +364,7 @@ static void display() static bool gen_poisson(std::vector &points, float min_dist, float radius) { /* poisson radius */ - for (int i = 0; i < 1000; i++) - { + for(int i = 0; i < 1000; i++) { float angle = (float)rand() / (float)RAND_MAX * 2 * M_PI; float r = sqrt((float)rand() / (float)RAND_MAX) * radius; @@ -373,7 +372,7 @@ static bool gen_poisson(std::vector &points, float min_dist, float radius) p.x = cos(angle) * r; p.y = sin(angle) * r; - bool valid = true; + bool valid = true; for(size_t j=0; jindices[0]; diff --git a/src/meshgen.h b/src/meshgen.h index 81880f6..1db98f9 100644 --- a/src/meshgen.h +++ b/src/meshgen.h @@ -8,6 +8,6 @@ class Mesh; /* generates geodesic sphere: if hemi is true we only gen the hemisphere */ void gen_geosphere(Mesh *mesh, float rad, int subdiv, bool hemi = false); 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); #endif // MESHGEN_H_ diff --git a/src/morph_renderer.cc b/src/morph_renderer.cc index 7535171..d076114 100644 --- a/src/morph_renderer.cc +++ b/src/morph_renderer.cc @@ -66,7 +66,7 @@ void MorphRenderer::draw() const for(size_t i=0; iobjects.size(); i++) { float t = (sin(time_sec + 7.3 * noise(i * M_PI)) + 1) * 0.5; - if (t_loc != -1) + if(t_loc != -1) sprog->set_uniformf(t_loc, t); if(mmod_loc != -1) diff --git a/src/opengl/mesh-gl.cc b/src/opengl/mesh-gl.cc index dd73bf3..6175aae 100644 --- a/src/opengl/mesh-gl.cc +++ b/src/opengl/mesh-gl.cc @@ -74,7 +74,7 @@ MeshGL::~MeshGL() void MeshGL::draw() const { if(!vdata_valid) { - ((MeshGL*)this)->update_vertex_data(); + ((MeshGL *)this)->update_vertex_data(); } glBindVertexArray(vao); @@ -93,12 +93,11 @@ void MeshGL::draw_normals(float scale) const glGenBuffers(1, &nvbo); glBindBuffer(GL_ARRAY_BUFFER, nvbo); - + glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(Vec3) * 2, 0, GL_STATIC_DRAW); Vec3 *data = (Vec3 *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - for (size_t i = 0; i < normals.size(); i++) - { + for(size_t i = 0; i < normals.size(); i++) { *data++ = vertices[i]; *data++ = vertices[i] + normals[i] * scale; } @@ -107,7 +106,8 @@ void MeshGL::draw_normals(float scale) const glVertexAttribPointer(MESH_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vec3), 0); glEnableVertexAttribArray(MESH_VERTEX); glBindBuffer(GL_ARRAY_BUFFER, 0); - } else { + } + else { glBindVertexArray(nvao); } @@ -204,7 +204,7 @@ void MeshGL::destroy_vbo() glDeleteBuffers(1, &vbo_tex_coords); if(ibo) glDeleteBuffers(1, &ibo); - if (vao) + if(vao) glDeleteVertexArrays(1, &vao); if(nvbo) diff --git a/src/terrain.cc b/src/terrain.cc index 0f10074..89caa6e 100644 --- a/src/terrain.cc +++ b/src/terrain.cc @@ -58,8 +58,8 @@ bool Terrain::generate(const TerrainParams ¶ms) data.yoffs = (float)i / (float)params.ytiles; gen_heightfield(tile.mesh, txsz, tysz, params.max_height, - params.tile_usub, params.tile_vsub, calc_height, - (void*)&data); + params.tile_usub, params.tile_vsub, calc_height, + (void *)&data); float xoffs = j * txsz - params.xsz / 2.0 + txsz / 2.0; float yoffs = i * tysz - params.ysz / 2.0 + tysz / 2.0; @@ -70,10 +70,10 @@ bool Terrain::generate(const TerrainParams ¶ms) tiles.push_back(tile); -/* - the terrain scene stores objects only - no need to fill the mat, mesh std::vectors -*/ + /* + the terrain scene stores objects only + no need to fill the mat, mesh std::vectors + */ Object *o = new Object; o->mesh = tile.mesh; o->material = &material; @@ -123,7 +123,7 @@ float Terrain::get_height(float u, float v) const static float calc_height(float u, float v, void *ptr) { - GenData *data = (GenData*)ptr; + GenData *data = (GenData *)ptr; const TerrainParams *tp = data->tp; u = u / tp->xtiles + data->xoffs; diff --git a/src/terrain.h b/src/terrain.h index db9464d..337a03b 100644 --- a/src/terrain.h +++ b/src/terrain.h @@ -35,7 +35,7 @@ private: mutable Scene *vis_scene; /* set of visible tiles returned by get_visible */ std::vector tiles; - + public: Material material; @@ -48,8 +48,8 @@ public: bool generate(const TerrainParams ¶ms); Scene *get_visible(const Camera *camera) const; - float get_height(float u, float v) const; - float get_height(const Vec3 &pos) const; /* world coordinates */ + float get_height(float u, float v) const; + float get_height(const Vec3 &pos) const; /* world coordinates */ }; #endif // TERRAIN_H_ \ No newline at end of file -- 1.7.10.4