[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45146] trunk/blender/source/blender: style cleanup: dont use 'else for' for extended blocks of code ( quite confusing)

Campbell Barton ideasman42 at gmail.com
Mon Mar 26 01:12:49 CEST 2012


Revision: 45146
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45146
Author:   campbellbarton
Date:     2012-03-25 23:12:42 +0000 (Sun, 25 Mar 2012)
Log Message:
-----------
style cleanup: dont use 'else for' for extended blocks of code (quite confusing)

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

Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c	2012-03-25 22:35:18 UTC (rev 45145)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c	2012-03-25 23:12:42 UTC (rev 45146)
@@ -2839,40 +2839,44 @@
 			cache->flag &= ~PTCACHE_BAKED;
 		}
 	}
-	else for (SETLOOPER(scene, sce_iter, base)) {
-		/* cache/bake everything in the scene */
-		BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
+	else {
+		for (SETLOOPER(scene, sce_iter, base)) {
+			/* cache/bake everything in the scene */
+			BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
-		for (pid=pidlist.first; pid; pid=pid->next) {
-			cache = pid->cache;
-			if ((cache->flag & PTCACHE_BAKED)==0) {
-				if (pid->type==PTCACHE_TYPE_PARTICLES) {
-					ParticleSystem *psys = (ParticleSystem*)pid->calldata;
-					/* skip hair & keyed particles */
-					if (psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED)
-						continue;
+			for (pid=pidlist.first; pid; pid=pid->next) {
+				cache = pid->cache;
+				if ((cache->flag & PTCACHE_BAKED)==0) {
+					if (pid->type==PTCACHE_TYPE_PARTICLES) {
+						ParticleSystem *psys = (ParticleSystem*)pid->calldata;
+						/* skip hair & keyed particles */
+						if (psys->part->type == PART_HAIR || psys->part->phystype == PART_PHYS_KEYED)
+							continue;
 
-					psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
-				}
+						psys_get_pointcache_start_end(scene, pid->calldata, &cache->startframe, &cache->endframe);
+					}
 
-				if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0)
-					&& ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake))
-					BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+					if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) &&
+					    ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake))
+					{
+						BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+					}
 
-				startframe = MIN2(startframe, cache->startframe);
+					startframe = MIN2(startframe, cache->startframe);
 
-				if (bake || render) {
-					cache->flag |= PTCACHE_BAKING;
+					if (bake || render) {
+						cache->flag |= PTCACHE_BAKING;
 
-					if (bake)
-						thread_data.endframe = MAX2(thread_data.endframe, cache->endframe);
-				}
+						if (bake)
+							thread_data.endframe = MAX2(thread_data.endframe, cache->endframe);
+					}
 
-				cache->flag &= ~PTCACHE_BAKED;
+					cache->flag &= ~PTCACHE_BAKED;
 
+				}
 			}
+			BLI_freelistN(&pidlist);
 		}
-		BLI_freelistN(&pidlist);
 	}
 
 	CFRA = startframe;
@@ -2928,30 +2932,32 @@
 				BKE_ptcache_write(pid, 0);
 		}
 	}
-	else for (SETLOOPER(scene, sce_iter, base)) {
-		BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
+	else {
+		for (SETLOOPER(scene, sce_iter, base)) {
+			BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
 
-		for (pid=pidlist.first; pid; pid=pid->next) {
-			/* skip hair particles */
-			if (pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR)
-				continue;
-		
-			cache = pid->cache;
+			for (pid=pidlist.first; pid; pid=pid->next) {
+				/* skip hair particles */
+				if (pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->calldata)->part->type == PART_HAIR)
+					continue;
 
-			if (thread_data.step > 1)
-				cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
-			else
-				cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
+				cache = pid->cache;
 
-			cache->flag |= PTCACHE_SIMULATION_VALID;
+				if (thread_data.step > 1)
+					cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
+				else
+					cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
 
-			if (bake) {
-				cache->flag |= PTCACHE_BAKED;
-				if (cache->flag & PTCACHE_DISK_CACHE)
-					BKE_ptcache_write(pid, 0);
+				cache->flag |= PTCACHE_SIMULATION_VALID;
+
+				if (bake) {
+					cache->flag |= PTCACHE_BAKED;
+					if (cache->flag & PTCACHE_DISK_CACHE)
+						BKE_ptcache_write(pid, 0);
+				}
 			}
+			BLI_freelistN(&pidlist);
 		}
-		BLI_freelistN(&pidlist);
 	}
 
 	scene->r.framelen = frameleno;

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-03-25 22:35:18 UTC (rev 45145)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-03-25 23:12:42 UTC (rev 45146)
@@ -4412,192 +4412,194 @@
 
 	/* circles don't use drawdata, so have to add a special case here */
 	if ((pdd || draw_as==PART_DRAW_CIRC) && draw_as!=PART_DRAW_PATH) {
-/* 5. */
+		/* 5. */
 		if (pdd && (pdd->flag & PARTICLE_DRAW_DATA_UPDATED) &&
 		    (pdd->vedata || part->draw & (PART_DRAW_SIZE|PART_DRAW_NUM|PART_DRAW_HEALTH))==0)
 		{
 			totpoint = pdd->totpoint; /* draw data is up to date */
 		}
-		else for (a=0,pa=pars; a<totpart+totchild; a++, pa++) {
-			/* setup per particle individual stuff */
-			if (a<totpart) {
-				if (totchild && (part->draw&PART_DRAW_PARENT)==0) continue;
-				if (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue;
+		else {
+			for (a=0,pa=pars; a<totpart+totchild; a++, pa++) {
+				/* setup per particle individual stuff */
+				if (a<totpart) {
+					if (totchild && (part->draw&PART_DRAW_PARENT)==0) continue;
+					if (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue;
 
-				pa_time=(cfra-pa->time)/pa->lifetime;
-				pa_birthtime=pa->time;
-				pa_dietime = pa->dietime;
-				pa_size=pa->size;
-				if (part->phystype==PART_PHYS_BOIDS)
-					pa_health = pa->boid->data.health;
-				else
-					pa_health = -1.0;
+					pa_time=(cfra-pa->time)/pa->lifetime;
+					pa_birthtime=pa->time;
+					pa_dietime = pa->dietime;
+					pa_size=pa->size;
+					if (part->phystype==PART_PHYS_BOIDS)
+						pa_health = pa->boid->data.health;
+					else
+						pa_health = -1.0;
 
-				r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f);
-				r_length = PSYS_FRAND(a + 22);
+					r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f);
+					r_length = PSYS_FRAND(a + 22);
 
-				if (part->draw_col > PART_DRAW_COL_MAT) {
-					switch(part->draw_col) {
-						case PART_DRAW_COL_VEL:
-							intensity = len_v3(pa->state.vel)/part->color_vec_max;
-							break;
-						case PART_DRAW_COL_ACC:
-							intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max);
-							break;
-						default:
-							intensity= 1.0f; /* should never happen */
+					if (part->draw_col > PART_DRAW_COL_MAT) {
+						switch(part->draw_col) {
+							case PART_DRAW_COL_VEL:
+								intensity = len_v3(pa->state.vel)/part->color_vec_max;
+								break;
+							case PART_DRAW_COL_ACC:
+								intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max);
+								break;
+							default:
+								intensity= 1.0f; /* should never happen */
+						}
+						CLAMP(intensity, 0.f, 1.f);
+						weight_to_rgb(ma_col, intensity);
 					}
-					CLAMP(intensity, 0.f, 1.f);
-					weight_to_rgb(ma_col, intensity);
 				}
-			}
-			else {
-				ChildParticle *cpa= &psys->child[a-totpart];
+				else {
+					ChildParticle *cpa= &psys->child[a-totpart];
 
-				pa_time=psys_get_child_time(psys,cpa,cfra,&pa_birthtime,&pa_dietime);
-				pa_size=psys_get_child_size(psys,cpa,cfra,NULL);
+					pa_time=psys_get_child_time(psys,cpa,cfra,&pa_birthtime,&pa_dietime);
+					pa_size=psys_get_child_size(psys,cpa,cfra,NULL);
 
-				pa_health = -1.0;
+					pa_health = -1.0;
 
-				r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f);
-				r_length = PSYS_FRAND(a + 22);
-			}
+					r_tilt = 2.0f*(PSYS_FRAND(a + 21) - 0.5f);
+					r_length = PSYS_FRAND(a + 22);
+				}
 
-			drawn = 0;
-			if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
-				float length = part->path_end * (1.0f - part->randlength * r_length);
-				int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
-				float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
-				float dt = length / (trail_count ? (float)trail_count : 1.0f);
-				int i=0;
+				drawn = 0;
+				if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
+					float length = part->path_end * (1.0f - part->randlength * r_length);
+					int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
+					float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
+					float dt = length / (trail_count ? (float)trail_count : 1.0f);
+					int i=0;
 
-				ct+=dt;
-				for (i=0; i < trail_count; i++, ct += dt) {
-					float pixsize;
+					ct+=dt;
+					for (i=0; i < trail_count; i++, ct += dt) {
+						float pixsize;
 
-					if (part->draw & PART_ABS_PATH_TIME) {
-						if (ct < pa_birthtime || ct > pa_dietime)
+						if (part->draw & PART_ABS_PATH_TIME) {
+							if (ct < pa_birthtime || ct > pa_dietime)
+								continue;
+						}
+						else if (ct < 0.0f || ct > 1.0f)
 							continue;
-					}
-					else if (ct < 0.0f || ct > 1.0f)
-						continue;
 
-					state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime));
-					psys_get_particle_on_path(&sim,a,&state,need_v);
-					
-					if (psys->parent)
-						mul_m4_v3(psys->parent->obmat, state.co);
+						state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime));
+						psys_get_particle_on_path(&sim,a,&state,need_v);
 
-					/* create actiual particle data */
-					if (draw_as == PART_DRAW_BB) {
-						bb.offset[0] = part->bb_offset[0];
-						bb.offset[1] = part->bb_offset[1];
-						bb.size[0] = part->bb_size[0] * pa_size;
-						if (part->bb_align==PART_BB_VEL) {
-							float pa_vel = len_v3(state.vel);
-							float head = part->bb_vel_head*pa_vel;
-							float tail = part->bb_vel_tail*pa_vel;
-							bb.size[1] = part->bb_size[1]*pa_size + head + tail;
-							/* use offset to adjust the particle center. this is relative to size, so need to divide! */
-							if (bb.size[1] > 0.0f)
-								bb.offset[1] += (head-tail) / bb.size[1];
+						if (psys->parent)
+							mul_m4_v3(psys->parent->obmat, state.co);
+
+						/* create actiual particle data */
+						if (draw_as == PART_DRAW_BB) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list