fix indentation,style
authorEleni Maria Stea <estea@igalia.com>
Sat, 16 Sep 2017 17:51:29 +0000 (20:51 +0300)
committerEleni Maria Stea <estea@igalia.com>
Sat, 16 Sep 2017 17:51:29 +0000 (20:51 +0300)
src/image.cc
src/main.cc
src/meshgen.cc
src/meshgen.h
src/morph_renderer.cc
src/opengl/mesh-gl.cc
src/terrain.cc
src/terrain.h

index 82d8cd1..818b686 100644 (file)
@@ -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);
index 491dd9c..69721c1 100644 (file)
@@ -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<Vec2> &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<Vec2> &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; j<points.size(); j++) {
                        if(length_sq(points[j] - p) < min_dist * min_dist) {
                                valid = false;
index ddcd571..bd9fe53 100644 (file)
@@ -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,10 +174,10 @@ 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(bitangent, tangent));
 
@@ -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];
 
index 81880f6..1db98f9 100644 (file)
@@ -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_
index 7535171..d076114 100644 (file)
@@ -66,7 +66,7 @@ void MorphRenderer::draw() const
 
        for(size_t i=0; i<scene->objects.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)
index dd73bf3..6175aae 100644 (file)
@@ -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)
index 0f10074..89caa6e 100644 (file)
@@ -58,8 +58,8 @@ bool Terrain::generate(const TerrainParams &params)
                        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 &params)
 
                        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;
index db9464d..337a03b 100644 (file)
@@ -35,7 +35,7 @@ private:
        mutable Scene *vis_scene; /* set of visible tiles returned by get_visible */
 
        std::vector<TerrainTile> tiles;
-       
+
 public:
        Material material;
 
@@ -48,8 +48,8 @@ public:
        bool generate(const TerrainParams &params);
        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