[Bf-blender-cvs] [6142df6] alembic: Nominal support for UVs and Vcols with cached strand data.

Lukas Tönne noreply at git.blender.org
Thu Apr 9 09:06:11 CEST 2015


Commit: 6142df649fbacf89fe9c29187a26bef3e326adae
Author: Lukas Tönne
Date:   Thu Apr 9 09:03:54 2015 +0200
Branches: alembic
https://developer.blender.org/rB6142df649fbacf89fe9c29187a26bef3e326adae

Nominal support for UVs and Vcols with cached strand data.

These are dummy values currently. The UV and vcol values will be stored
in strands directly, unlike particles which evaluate them every time;
this is a much safer and more efficient approach that makes strand data
truely independent from the "emitter" mesh. Such data will be made
available later, primarily for child curves.

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

M	intern/cycles/blender/blender_curves.cpp

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

diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 461cffc..28c11ec 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -37,9 +37,9 @@ void curveinterp_v3_v3v3v3v3(float3 *p, float3 *v1, float3 *v2, float3 *v3, floa
 void interp_weights(float t, float data[4]);
 float shaperadius(float shape, float root, float tip, float time);
 void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData);
-bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num);
-bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num);
-bool ObtainCacheCurves(Mesh *mesh, BL::Scene b_scene, BL::Mesh b_mesh, BL::Object b_parent, BL::DupliObject b_dupli_ob, ParticleCurveData *CData, bool background);
+bool ObtainCacheCurvesUV(Mesh *mesh, BL::Scene b_scene, BL::Mesh b_mesh, BL::Object b_parent, BL::DupliObject b_dupli_ob, ParticleCurveData *CData, bool background, int uv_num);
+bool ObtainCacheCurvesVcol(Mesh *mesh, BL::Scene b_scene, BL::Mesh b_mesh, BL::Object b_parent, BL::DupliObject b_dupli_ob, ParticleCurveData *CData, bool background, int vcol_num);
+bool ObtainCacheCurvesData(Mesh *mesh, BL::Scene b_scene, BL::Mesh b_mesh, BL::Object b_parent, BL::DupliObject b_dupli_ob, ParticleCurveData *CData, bool background);
 void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData);
 void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
                                float3 RotCam, bool is_ortho);
@@ -119,8 +119,8 @@ void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyl
 		curveinterp_v3_v3v3v3v3(keyloc, &ckey_loc1, &ckey_loc2, &ckey_loc3, &ckey_loc4, t);
 }
 
-static void ObtainCacheParticleSystem(Mesh *mesh, BL::Object b_ob, BL::ParticleSystem b_psys, const Transform &itfm,
-                                      ParticleCurveData *CData, bool background, int &keyno, int &curvenum)
+static void ObtainCacheParticleData(Mesh *mesh, BL::Object b_ob, BL::ParticleSystem b_psys, const Transform &itfm,
+                                    ParticleCurveData *CData, bool background, int &keyno, int &curvenum)
 {
 	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 	int mi = clamp(b_part.material()-1, 0, mesh->used_shaders.size()-1);
@@ -194,8 +194,84 @@ static void ObtainCacheParticleSystem(Mesh *mesh, BL::Object b_ob, BL::ParticleS
 	}
 }
 
-static void ObtainCacheStrands(Mesh *mesh, BL::Scene b_scene, BL::Object b_parent, BL::DupliObject b_dupli_ob, BL::ParticleSystem b_psys, const Transform &/*itfm*/,
-                               ParticleCurveData *CData, bool preview, int &keyno, int &curvenum)
+static void ObtainCacheParticleUV(Mesh */*mesh*/, BL::Object /*b_ob*/, BL::Mesh b_mesh, BL::ParticleSystem b_psys, BL::ParticleSystemModifier b_psmd,
+                                  ParticleCurveData *CData, bool background, int uv_num)
+{
+	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
+	int totparts = b_psys.particles.length();
+	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_part.child_type() == 0)
+		totcurves += totparts;
+
+	if(totcurves == 0)
+		return;
+
+	int pa_no = 0;
+	if(!(b_part.child_type() == 0))
+		pa_no = totparts;
+
+	int num_add = (totparts+totchild - pa_no);
+	CData->curve_uv.reserve(CData->curve_uv.size() + num_add);
+
+	BL::ParticleSystem::particles_iterator b_pa;
+	b_psys.particles.begin(b_pa);
+	for(; pa_no < totparts+totchild; pa_no++) {
+		/* Add UVs */
+		BL::Mesh::tessface_uv_textures_iterator l;
+		b_mesh.tessface_uv_textures.begin(l);
+
+		float3 uv = make_float3(0.0f, 0.0f, 0.0f);
+		if(b_mesh.tessface_uv_textures.length())
+			b_psys.uv_on_emitter(b_psmd, *b_pa, pa_no, uv_num, &uv.x);
+		CData->curve_uv.push_back(uv);
+
+		if(pa_no < totparts && b_pa != b_psys.particles.end())
+			++b_pa;
+	}
+}
+
+static void ObtainCacheParticleVcol(Mesh */*mesh*/, BL::Object /*b_ob*/, BL::Mesh b_mesh, BL::ParticleSystem b_psys, BL::ParticleSystemModifier b_psmd,
+                                    ParticleCurveData *CData, bool background, int vcol_num)
+{
+	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
+	int totparts = b_psys.particles.length();
+	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_part.child_type() == 0)
+		totcurves += totparts;
+
+	if(totcurves == 0)
+		return;
+
+	int pa_no = 0;
+	if(!(b_part.child_type() == 0))
+		pa_no = totparts;
+
+	int num_add = (totparts+totchild - pa_no);
+	CData->curve_vcol.reserve(CData->curve_vcol.size() + num_add);
+
+	BL::ParticleSystem::particles_iterator b_pa;
+	b_psys.particles.begin(b_pa);
+	for(; pa_no < totparts+totchild; pa_no++) {
+		/* Add vertex colors */
+		BL::Mesh::tessface_vertex_colors_iterator l;
+		b_mesh.tessface_vertex_colors.begin(l);
+
+		float3 vcol = make_float3(0.0f, 0.0f, 0.0f);
+		if(b_mesh.tessface_vertex_colors.length())
+			b_psys.mcol_on_emitter(b_psmd, *b_pa, pa_no, vcol_num, &vcol.x);
+		CData->curve_vcol.push_back(vcol);
+
+		if(pa_no < totparts && b_pa != b_psys.particles.end())
+			++b_pa;
+	}
+}
+
+static void ObtainCacheStrandsData(Mesh *mesh, BL::Scene b_scene, BL::Object b_parent, BL::DupliObject b_dupli_ob, BL::ParticleSystem b_psys, const Transform &/*itfm*/,
+                                   ParticleCurveData *CData, bool background, int &keyno, int &curvenum)
 {
 	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 	PointerRNA cpsys = RNA_pointer_get(&b_part.ptr, "cycles");
@@ -203,7 +279,7 @@ static void ObtainCacheStrands(Mesh *mesh, BL::Scene b_scene, BL::Object b_paren
 	int mi = clamp(b_part.material()-1, 0, mesh->used_shaders.size()-1);
 	int shader = mesh->used_shaders[mi];
 
-	int settings = preview ? 1 : 2;
+	int settings = background ? 2 : 1;
 	BL::Strands b_strands = b_dupli_ob.strands_new(b_scene, b_parent, b_psys, settings);
 	if (!b_strands)
 		return;
@@ -265,7 +341,60 @@ static void ObtainCacheStrands(Mesh *mesh, BL::Scene b_scene, BL::Object b_paren
 	b_dupli_ob.strands_free(b_strands);
 }
 
-bool ObtainCacheCurves(Mesh *mesh, BL::Scene b_scene, BL::Mesh b_mesh, BL::Object b_parent, BL::DupliObject b_dupli_ob, ParticleCurveData *CData, bool background)
+static void ObtainCacheStrandsUV(Mesh */*mesh*/, BL::Scene b_scene, BL::Object b_parent, BL::DupliObject b_dupli_ob, BL::ParticleSystem b_psys,
+                                 ParticleCurveData *CData, bool background, int /*uv_num*/)
+{
+//	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
+
+	int settings = background ? 2 : 1;
+	BL::Strands b_strands = b_dupli_ob.strands_new(b_scene, b_parent, b_psys, settings);
+	if (!b_strands)
+		return;
+
+	int totcurves = b_strands.curves.length();
+
+	CData->curve_uv.reserve(CData->curve_uv.size() + totcurves);
+
+	int icurve = 0;
+	for(; icurve < totcurves; ++icurve) {
+//		BL::StrandsCurve b_curve = b_strands.curves[icurve];
+		/* XXX for parent strand curves there are no UVs or VCols,
+		 * this is only supported for child curves currently
+		 */
+		CData->curve_uv.push_back(make_float3(0.0f, 0.0f, 0.0f));
+	}
+	
+	b_dupli_ob.strands_free(b_strands);
+}
+
+static void ObtainCacheStrandsVcol(Mesh */*mesh*/, BL::Scene b_scene, BL::Object b_parent, BL::DupliObject b_dupli_ob, BL::ParticleSystem b_psys,
+                                   ParticleCurveData *CData, bool background, int /*vcol_num*/)
+{
+//	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
+	
+	int settings = background ? 2 : 1;
+	BL::Strands b_strands = b_dupli_ob.strands_new(b_scene, b_parent, b_psys, settings);
+	if (!b_strands)
+		return;
+	
+	int totcurves = b_strands.curves.length();
+	
+	CData->curve_vcol.reserve(CData->curve_vcol.size() + totcurves);
+	
+	int icurve = 0;
+	for(; icurve < totcurves; ++icurve) {
+	//	BL::StrandsCurve b_curve = b_strands.curves[icurve];
+		/* XXX for parent strand curves there are no UVs or VCols,
+		 * this is only supported for child curves currently
+		 */
+		CData->curve_vcol.push_back(make_float3(0.0f, 0.0f, 0.0f));
+	}
+	
+	b_dupli_ob.strands_free(b_strands);
+}
+
+bool ObtainCacheCurvesData(Mesh *mesh, BL::Scene b_scene, BL::Mesh b_mesh, BL::Object b_parent, BL::DupliObject b_dupli_ob,
+                           ParticleCurveData *CData, bool background)
 {
 	BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent);
 
@@ -280,15 +409,15 @@ bool ObtainCacheCurves(Mesh *mesh, BL::Scene b_scene, BL::Mesh b_mesh, BL::Objec
 	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::ParticleSystemModifier b_psmd((const PointerRNA)b_mod->ptr);
+			BL::ParticleSystem b_psys((const PointerRNA)b_psmd.particle_system().ptr);
 			BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 
 			if((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && (b_part.type() == BL::ParticleSettings::type_HAIR)) {
 				if (b_dupli_ob && b_parent)
-					ObtainCacheStrands(mesh, b_scene, b_parent, b_dupli_ob, b_psys, itfm, CData, !background, keyno, curvenum);
+					ObtainCacheStrandsData(mesh, b_scene, b_parent, b_dupli_ob, b_psys, itfm, CData, background, keyno, curvenum);
 				else
-					ObtainCacheParticleSystem(mesh, b_ob, b_psys, itfm, CData, background, keyno, curvenum);
+					ObtainCacheParticleData(mesh, b_ob, b_psys, itfm, CData, background, keyno, curvenum);
 			}
 		}
 	}
@@ -296,53 +425,28 @@ bool ObtainCacheCurves(Mesh *mesh, BL::Scene b_scen

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list