[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51052] branches/ge_harmony/source/ gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp: Fixing the artifacts when rendering point lights with the inferred lighting option enabled .

Daniel Stokes kupomail at gmail.com
Thu Oct 4 22:01:27 CEST 2012


Revision: 51052
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51052
Author:   kupoman
Date:     2012-10-04 20:01:25 +0000 (Thu, 04 Oct 2012)
Log Message:
-----------
Fixing the artifacts when rendering point lights with the inferred lighting option enabled.

Modified Paths:
--------------
    branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

Modified: branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
===================================================================
--- branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp	2012-10-04 18:53:17 UTC (rev 51051)
+++ branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp	2012-10-04 20:01:25 UTC (rev 51052)
@@ -186,32 +186,57 @@
 
 void RAS_OpenGLRasterizer::init_sphere()
 {
-	//radius == 1
-	int rings = 16;
-	int sectors = 16;
+	float t = (1.0 + sqrt(5.0))/2.0;
+	float l = 1.5;
+	float i = 1.0/l, j = t/l;
+	m_sphere_size = 60;
 
-	float R = 1./(rings-1);
-	float S = 1./(sectors-1);
-	int r, s;
-
-	m_sphere_vertices = new float[rings * sectors * 3];
-	m_sphere_indices = new unsigned short[rings * sectors * 4];
-	m_sphere_size = rings*sectors*4;
-
-	int v=0, i=0;
-	for (r = 0; r < rings; r++) {
-		for (s = 0; s < sectors; s++) {
-			m_sphere_vertices[v++] = cos(2*M_PI * s * S) * sin(M_PI * r * R);
-			m_sphere_vertices[v++] = sin(-M_PI/2 + M_PI * r * R);
-			m_sphere_vertices[v++] = sin(2*M_PI * s * S) * sin(M_PI * r * R);
-
-			m_sphere_indices[i++] = r * sectors + s;
-			m_sphere_indices[i++] = r * sectors + (s+1);
-			m_sphere_indices[i++] = (r+1) * sectors + (s+1);
-			m_sphere_indices[i++] = (r+1) * sectors + s;
-		}
-	}
-
+	m_sphere_vertices = new float[12 * 3];
+	float v_tmp[36] = {
+				-i, j, 0.0,
+				i, j, 0.0,
+				-i, -j, 0.0,
+				i, -j, 0.0,
+				
+				0.0, -i, j,
+				0.0, i, j,
+				0.0, -i, -j,
+				0.0, i, -j,
+				
+				j, 0.0, -i,
+				j, 0.0, i,
+				-j, 0.0, -i,
+				-j, 0.0, i,
+	};
+	std::copy(v_tmp, v_tmp+36, &m_sphere_vertices[0]);
+	
+	m_sphere_indices = new unsigned short[20 * 3];
+	unsigned short i_tmp[60] = {
+				0, 11, 5,
+				0, 5, 1,
+				0, 1, 7,
+				0, 7, 10,
+				0, 10, 11,
+				
+				1, 5, 9,
+				5, 11, 4,
+				11, 10, 2,
+				10, 7, 6,
+				7, 1, 8,
+				
+				3, 9, 4,
+				3, 4, 2,
+				3, 2, 6,
+				3, 6, 8,
+				3, 8, 9,
+				
+				4, 9, 5,
+				2, 4, 11,
+				6, 2, 10,
+				8, 6, 7,
+				9, 8, 1,
+	};
+	std::copy(i_tmp, i_tmp+60, &m_sphere_indices[0]);
 }
 
 
@@ -1565,7 +1590,7 @@
 		glScalef(light->m_distance, light->m_distance, light->m_distance);
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glVertexPointer(3, GL_FLOAT, 0, m_sphere_vertices);
-		glDrawElements(GL_QUADS, m_sphere_size, GL_UNSIGNED_SHORT, m_sphere_indices);
+		glDrawElements(GL_TRIANGLES, m_sphere_size, GL_UNSIGNED_SHORT, m_sphere_indices);
 
 		glPopMatrix();
 	}




More information about the Bf-blender-cvs mailing list