commit 64dd79c2ea3d705d508eaa38f53ae9ca5c9b352a parent 6c1c2b12d4480fbc860a95ccb8681a9679e67c49 Author: Michael Savage <mikejsavage@gmail.com> Date: Mon Oct 31 21:05:48 +0200 Remove Heightmap::point_normal Diffstat:
heightmap.cc | | | 67 | ------------------------------------------------------------------- |
heightmap.h | | | 1 | - |
diff --git a/heightmap.cc b/heightmap.cc @@ -57,73 +57,6 @@ glm::vec3 Heightmap::point( u32 x, u32 y ) const { return glm::vec3( x, y, pixels[ y * width + x ] ); } -glm::vec3 Heightmap::point_normal( u32 x, u32 y ) const { - glm::vec3 bent_normal = glm::vec3( 0 ); - - /* - * A vertex looks like this: - * - * +y - * \ 6 | - * \ | - * 5 \ | 1 - * \| - * ------X------ +x - * |\ - * 2 | \ 4 - * | \ - * | 3 \ - * - * We consider up to six triangles for the bent normal - */ - - if( x > 0 ) { - if( y > 0 ) { // bottom left - const glm::vec3 tri2a = point( x, y ); - const glm::vec3 tri2b = point( x - 1, y ); - const glm::vec3 tri2c = point( x, y - 1 ); - - bent_normal += triangle_normal_ccw( tri2a, tri2b, tri2c ); - } - if( y < height - 1 ) { // top left - const glm::vec3 tri5a = point( x, y ); - const glm::vec3 tri5b = point( x - 1, y + 1 ); - const glm::vec3 tri5c = point( x - 1, y ); - - const glm::vec3 tri6a = point( x, y ); - const glm::vec3 tri6b = point( x, y + 1 ); - const glm::vec3 tri6c = point( x - 1, y + 1 ); - - bent_normal += triangle_normal_ccw( tri5a, tri5b, tri5c ); - bent_normal += triangle_normal_ccw( tri6a, tri6b, tri6c ); - } - } - - if( x < width - 1 ) { - if( y > 0 ) { // bottom right - const glm::vec3 tri3a = point( x, y ); - const glm::vec3 tri3b = point( x, y - 1 ); - const glm::vec3 tri3c = point( x + 1, y - 1 ); - - const glm::vec3 tri4a = point( x, y ); - const glm::vec3 tri4b = point( x + 1, y - 1 ); - const glm::vec3 tri4c = point( x + 1, y ); - - bent_normal += triangle_normal_ccw( tri3a, tri3b, tri3c ); - bent_normal += triangle_normal_ccw( tri4a, tri4b, tri4c ); - } - if( y < height - 1 ) { // top right - const glm::vec3 tri1a = point( x, y ); - const glm::vec3 tri1b = point( x + 1, y ); - const glm::vec3 tri1c = point( x, y + 1 ); - - bent_normal += triangle_normal_ccw( tri1a, tri1b, tri1c ); - } - } - - return glm::normalize( bent_normal ); -} - float Heightmap::bilerp_height( const float x, const float y ) const { const float ix = floorf( x ); const float iy = floorf( y ); diff --git a/heightmap.h b/heightmap.h @@ -15,7 +15,6 @@ public: u32 width, height; glm::vec3 point( u32 x, u32 y ) const; - glm::vec3 point_normal( u32 x, u32 y ) const; float bilerp_height( const float x, const float y ) const; };