[Bf-blender-cvs] [9bd3a22] master: Cleanup: Code and style cleanup for Cycles curve export code.

Thomas Dinges noreply at git.blender.org
Sat Dec 21 00:20:27 CET 2013


Commit: 9bd3a226aec3404c05c4d92eeb669b358a901fba
Author: Thomas Dinges
Date:   Sat Dec 21 00:20:16 2013 +0100
http://developer.blender.org/rB9bd3a226aec3404c05c4d92eeb669b358a901fba

Cleanup: Code and style cleanup for Cycles curve export code.

===================================================================

M	intern/cycles/blender/blender_curves.cpp

===================================================================

diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 393effe..ed348e6 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -137,7 +137,6 @@ void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyl
 	if(key < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2)
 		ckey_loc4 = CData->curvekey_co[key + 2];
 
-
 	float time1 = CData->curvekey_time[key]/CData->curve_length[curve];
 	float time2 = CData->curvekey_time[key + 1]/CData->curve_length[curve];
 
@@ -156,7 +155,6 @@ void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyl
 
 bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background)
 {
-
 	int curvenum = 0;
 	int keyno = 0;
 
@@ -170,22 +168,19 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
 	for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
 		if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && (background ? b_mod->show_render() : b_mod->show_viewport())) {
 			BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
-
 			BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
-
 			BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 
-			if((b_psys.settings().render_type()==BL::ParticleSettings::render_type_PATH)&&(b_psys.settings().type()==BL::ParticleSettings::type_HAIR)) {
-
-				int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
+			if((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && (b_part.type() == BL::ParticleSettings::type_HAIR)) {
+				int mi = clamp(b_part.material()-1, 0, mesh->used_shaders.size()-1);
 				int shader = mesh->used_shaders[mi];
-				int draw_step = background ? b_psys.settings().render_step() : b_psys.settings().draw_step();
+				int draw_step = background ? b_part.render_step() : b_part.draw_step();
 				int ren_step = (int)powf(2.0f, (float)draw_step);
 				int totparts = b_psys.particles.length();
-				int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
+				int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f);
 				int totcurves = totchild;
 				
-				if(b_psys.settings().child_type() == 0)
+				if(b_part.child_type() == 0)
 					totcurves += totparts;
 
 				if(totcurves == 0)
@@ -205,11 +200,10 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
 				CData->psys_closetip.push_back(get_boolean(cpsys, "use_closetip"));
 
 				int pa_no = 0;
-				if(!(b_psys.settings().child_type() == 0))
+				if(!(b_part.child_type() == 0))
 					pa_no = totparts;
 
 				for(; pa_no < totparts+totchild; pa_no++) {
-
 					CData->curve_firstkey.push_back(keyno);
 					CData->curve_keynum.push_back(ren_step+1);
 					
@@ -227,70 +221,50 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
 						pcKey = cKey;
 						keyno++;
 					}
-					CData->curve_length.push_back(curve_length);
 
+					CData->curve_length.push_back(curve_length);
 					curvenum++;
-
 				}
 			}
-
 		}
 	}
 
 	return true;
-
 }
 
 bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num)
 {
-#if 0
-	int keyno = 0;
-#endif
-
 	if(!(mesh && b_mesh && b_ob && CData))
 		return false;
 
-#if 0
-	Transform tfm = get_transform(b_ob->matrix_world());
-	Transform itfm = transform_quick_inverse(tfm);
-#endif
-
 	CData->curve_uv.clear();
 
 	BL::Object::modifiers_iterator b_mod;
 	for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
 		if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && (background ? b_mod->show_render() : b_mod->show_viewport())) {
 			BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
-
 			BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
-
 			BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 
-			if((b_psys.settings().render_type()==BL::ParticleSettings::render_type_PATH)&&(b_psys.settings().type()==BL::ParticleSettings::type_HAIR)) {
-#if 0
-				int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
-				int shader = mesh->used_shaders[mi];
-#endif
-
+			if((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && (b_part.type() == BL::ParticleSettings::type_HAIR)) {
 				int totparts = b_psys.particles.length();
-				int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
+				int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f);
 				int totcurves = totchild;
 				
-				if (b_psys.settings().child_type() == 0)
+				if (b_part.child_type() == 0)
 					totcurves += totparts;
 
 				if (totcurves == 0)
 					continue;
 
 				int pa_no = 0;
-				if(!(b_psys.settings().child_type() == 0))
+				if(!(b_part.child_type() == 0))
 					pa_no = totparts;
 
 				BL::ParticleSystem::particles_iterator b_pa;
 				b_psys.particles.begin(b_pa);
 				for(; pa_no < totparts+totchild; pa_no++) {
-
-					/*add uvs*/
+					/* Add UVs */
 					BL::Mesh::tessface_uv_textures_iterator l;
 					b_mesh->tessface_uv_textures.begin(l);
 
@@ -301,65 +275,47 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti
 
 					if(pa_no < totparts && b_pa != b_psys.particles.end())
 						++b_pa;
-
 				}
 			}
-
 		}
 	}
 
 	return true;
-
 }
 
 bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num)
 {
-#if 0
-	int keyno = 0;
-#endif
 	if(!(mesh && b_mesh && b_ob && CData))
 		return false;
 
-#if 0
-	Transform tfm = get_transform(b_ob->matrix_world());
-	Transform itfm = transform_quick_inverse(tfm);
-#endif
-
 	CData->curve_vcol.clear();
 
 	BL::Object::modifiers_iterator b_mod;
 	for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
 		if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && (background ? b_mod->show_render() : b_mod->show_viewport())) {
 			BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
-
 			BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
-
 			BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 
-			if((b_psys.settings().render_type()==BL::ParticleSettings::render_type_PATH)&&(b_psys.settings().type()==BL::ParticleSettings::type_HAIR)) {
-#if 0
-				int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
-				int shader = mesh->used_shaders[mi];
-#endif
+			if((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && (b_part.type() == BL::ParticleSettings::type_HAIR)) {
 				int totparts = b_psys.particles.length();
-				int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
+				int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f);
 				int totcurves = totchild;
 				
-				if (b_psys.settings().child_type() == 0)
+				if (b_part.child_type() == 0)
 					totcurves += totparts;
 
 				if (totcurves == 0)
 					continue;
 
 				int pa_no = 0;
-				if(!(b_psys.settings().child_type() == 0))
+				if(!(b_part.child_type() == 0))
 					pa_no = totparts;
 
 				BL::ParticleSystem::particles_iterator b_pa;
 				b_psys.particles.begin(b_pa);
 				for(; pa_no < totparts+totchild; pa_no++) {
-
-					/*add uvs*/
+					/* Add vertex colors */
 					BL::Mesh::tessface_vertex_colors_iterator l;
 					b_mesh->tessface_vertex_colors.begin(l);
 
@@ -370,15 +326,12 @@ bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
 
 					if(pa_no < totparts && b_pa != b_psys.particles.end())
 						++b_pa;
-
 				}
 			}
-
 		}
 	}
 
 	return true;
-
 }
 
 static void set_resolution(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, BL::Scene *scene, bool render)
@@ -398,8 +351,8 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, float3 RotC
 	int vertexno = mesh->verts.size();
 	int vertexindex = vertexno;
 
-	for( int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-		for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+	for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
+		for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
 			if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
 				continue;
 
@@ -416,7 +369,7 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, float3 RotC
 			mesh->verts.push_back(ickey_loc_shfr);
 			vertexindex += 2;
 
-			for( int curvekey = CData->curve_firstkey[curve] + 1; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) {
+			for(int curvekey = CData->curve_firstkey[curve] + 1; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve]; curvekey++) {
 				ickey_loc = CData->curvekey_co[curvekey];
 
 				if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)
@@ -460,8 +413,8 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol
 	int vertexno = mesh->verts.size();
 	int vertexindex = vertexno;
 
-	for( int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-		for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+	for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
+		for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
 			

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list