[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40281] trunk/blender/source/blender/ editors/space_view3d/drawobject.c: use less confusing array syntax for circle drawing, no functional changes.

Campbell Barton ideasman42 at gmail.com
Sat Sep 17 07:35:56 CEST 2011


Revision: 40281
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40281
Author:   campbellbarton
Date:     2011-09-17 05:35:55 +0000 (Sat, 17 Sep 2011)
Log Message:
-----------
use less confusing array syntax for circle drawing, no functional changes.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-09-17 04:59:14 UTC (rev 40280)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-09-17 05:35:55 UTC (rev 40281)
@@ -257,7 +257,9 @@
 
 /* ----------------- OpenGL Circle Drawing - Tables for Optimised Drawing Speed ------------------ */
 /* 32 values of sin function (still same result!) */
-static float sinval[32] = {
+#define CIRCLE_RESOL 32
+
+static float sinval[CIRCLE_RESOL] = {
 	0.00000000,
 	0.20129852,
 	0.39435585,
@@ -293,7 +295,7 @@
 };
 
 /* 32 values of cos function (still same result!) */
-static float cosval[32] ={
+static float cosval[CIRCLE_RESOL] = {
 	1.00000000,
 	0.97952994,
 	0.91895781,
@@ -614,16 +616,16 @@
 void drawcircball(int mode, const float cent[3], float rad, float tmat[][4])
 {
 	float vec[3], vx[3], vy[3];
-	int a, tot=32;
+	int a;
 
 	mul_v3_v3fl(vx, tmat[0], rad);
 	mul_v3_v3fl(vy, tmat[1], rad);
 
 	glBegin(mode);
-	for(a=0; a<tot; a++) {
-		vec[0]= cent[0] + *(sinval+a) * vx[0] + *(cosval+a) * vy[0];
-		vec[1]= cent[1] + *(sinval+a) * vx[1] + *(cosval+a) * vy[1];
-		vec[2]= cent[2] + *(sinval+a) * vx[2] + *(cosval+a) * vy[2];
+	for(a=0; a < CIRCLE_RESOL; a++) {
+		vec[0]= cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
+		vec[1]= cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
+		vec[2]= cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
 		glVertex3fv(vec);
 	}
 	glEnd();
@@ -5039,8 +5041,7 @@
 static void drawspiral(const float cent[3], float rad, float tmat[][4], int start)
 {
 	float vec[3], vx[3], vy[3];
-	const int tot=32;
-	const float tot_inv= (1.0f / 32.0f);
+	const float tot_inv= (1.0f / (float)CIRCLE_RESOL);
 	int a;
 	char inverse= FALSE;
 
@@ -5055,31 +5056,31 @@
 	copy_v3_v3(vec, cent);
 
 	if (inverse==0) {
-		for(a=0; a<tot; a++) {
+		for(a=0; a<CIRCLE_RESOL; a++) {
 			if (a+start>31)
 				start=-a + 1;
 			glBegin(GL_LINES);							
 			glVertex3fv(vec);
-			vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)a * tot_inv) + *(cosval+a+start) * (vy[0] * (float)a * tot_inv);
-			vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)a * tot_inv) + *(cosval+a+start) * (vy[1] * (float)a * tot_inv);
-			vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)a * tot_inv) + *(cosval+a+start) * (vy[2] * (float)a * tot_inv);
+			vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)a * tot_inv) + cosval[a+start] * (vy[0] * (float)a * tot_inv);
+			vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)a * tot_inv) + cosval[a+start] * (vy[1] * (float)a * tot_inv);
+			vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)a * tot_inv) + cosval[a+start] * (vy[2] * (float)a * tot_inv);
 			glVertex3fv(vec);
 			glEnd();
 		}
 	}
 	else {
 		a=0;
-		vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[0] * (float)(-a+31) * tot_inv);
-		vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[1] * (float)(-a+31) * tot_inv);
-		vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[2] * (float)(-a+31) * tot_inv);
-		for(a=0; a<tot; a++) {
+		vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv);
+		vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv);
+		vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv);
+		for(a=0; a<CIRCLE_RESOL; a++) {
 			if (a+start>31)
 				start=-a + 1;
 			glBegin(GL_LINES);							
 			glVertex3fv(vec);
-			vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[0] * (float)(-a+31) * tot_inv);
-			vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[1] * (float)(-a+31) * tot_inv);
-			vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31) * tot_inv) + *(cosval+a+start) * (vy[2] * (float)(-a+31) * tot_inv);
+			vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv);
+			vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv);
+			vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv);
 			glVertex3fv(vec);
 			glEnd();
 		}
@@ -5097,9 +5098,9 @@
 	glBegin(GL_LINE_LOOP);
 
 	/* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */
-	for (degrees=0; degrees<32; degrees++) {
-		x= *(cosval + degrees);
-		y= *(sinval + degrees);
+	for (degrees=0; degrees<CIRCLE_RESOL; degrees++) {
+		x= cosval[degrees];
+		y= sinval[degrees];
 		
 		glVertex3f(x*size, 0.0f, y*size);
 	}




More information about the Bf-blender-cvs mailing list