[Bf-blender-cvs] [6d1fecc] alembic: Support for UV and vertex color attributes of cached strands data.

Lukas Tönne noreply at git.blender.org
Mon Apr 27 15:18:38 CEST 2015


Commit: 6d1fecc15254381420fdb1290eb611ed14cddaae
Author: Lukas Tönne
Date:   Mon Apr 27 15:14:48 2015 +0200
Branches: alembic
https://developer.blender.org/rB6d1fecc15254381420fdb1290eb611ed14cddaae

Support for UV and vertex color attributes of cached strands data.

Unlike particles, the Strands data stores UV coordinates and vertex
colors explicitly as a per-strand (const) property. This means Cycles
does not have to know the details of how particles map themselves to
a changing mesh surfaces (which is very complicated and fraught with
broken use cases and bugs). The UVs and colors are stored once for each
strand, since they are not expected to change over time (strands being
fixed to the mesh surface).

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

M	intern/cycles/blender/blender_curves.cpp
M	source/blender/blenkernel/BKE_strands.h
M	source/blender/blenkernel/intern/strands.c
M	source/blender/makesdna/DNA_strands_types.h
M	source/blender/makesrna/intern/rna_strands.c
M	source/blender/pointcache/alembic/abc_customdata.cpp
M	source/blender/pointcache/alembic/abc_customdata.h
M	source/blender/pointcache/alembic/abc_mesh.cpp
M	source/blender/pointcache/alembic/abc_particles.cpp
M	source/blender/pointcache/alembic/abc_particles.h

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

diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index f75d487..005747e 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -37,15 +37,14 @@ 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 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);
 void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution);
 void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata);
+void ExportCurveUV(Mesh *mesh, ParticleCurveData *CData, ustring name, bool active_render, int primitive, int vert_offset, int resol);
 void ExportCurveTriangleVcol(ParticleCurveData *CData, int vert_offset, int resol, uchar4 *cdata);
+void ExportCurveVcol(Mesh *mesh, ParticleCurveData *CData, ustring name, int primitive, int vert_offset, int resol);
 
 ParticleCurveData::ParticleCurveData()
 {
@@ -120,7 +119,7 @@ void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyl
 }
 
 static void ObtainCacheParticleData(Mesh *mesh, BL::Object b_ob, BL::ParticleSystem b_psys, const Transform &itfm,
-                                    ParticleCurveData *CData, bool background, int &keyno, int &curvenum)
+                                    ParticleCurveData *CData, bool background)
 {
 	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 	int mi = clamp(b_part.material()-1, 0, mesh->used_shaders.size()-1);
@@ -141,6 +140,9 @@ static void ObtainCacheParticleData(Mesh *mesh, BL::Object b_ob, BL::ParticleSys
 		ren_step += b_part.kink_extra_steps();
 
 	PointerRNA cpsys = RNA_pointer_get(&b_part.ptr, "cycles");
+	
+	int keyno = CData->curvekey_co.size();
+	int curvenum = CData->curve_keynum.size();
 
 	CData->psys_firstcurve.push_back(curvenum);
 	CData->psys_curvenum.push_back(totcurves);
@@ -283,16 +285,6 @@ struct StrandsTraits<BL::Strands>
 	typedef BL::StrandsCurve curve_t;
 	typedef BL::StrandsVertex vertex_t;
 	
-	static BL::Strands make_strands(BL::Scene b_scene, BL::Object b_parent, BL::DupliObject b_dupli_ob, BL::ParticleSystem b_psys, bool background)
-	{
-		int settings = background ? 2 : 1;
-		return b_dupli_ob.strands_new(b_scene, b_parent, b_psys, settings);
-	}
-	static void free_strands(BL::DupliObject b_dupli_ob, BL::Strands b_strands)
-	{
-		b_dupli_ob.strands_free(b_strands);
-	}
-	
 	static float3 get_location(BL::Strands b_strands, int index)
 	{
 		float *co = (b_strands.has_motion_state())? b_strands.motion_state[index].location() : b_strands.vertices[index].location();
@@ -314,42 +306,40 @@ struct StrandsTraits<BL::StrandsChildren>
 	typedef BL::StrandsChildCurve curve_t;
 	typedef BL::StrandsChildVertex vertex_t;
 	
-	static BL::StrandsChildren make_strands(BL::Scene b_scene, BL::Object b_parent, BL::DupliObject b_dupli_ob, BL::ParticleSystem b_psys, bool background)
-	{
-		int settings = background ? 2 : 1;
-		return b_dupli_ob.strands_children_new(b_scene, b_parent, b_psys, settings);
-	}
-	static void free_strands(BL::DupliObject b_dupli_ob, BL::StrandsChildren b_strands)
-	{
-		b_dupli_ob.strands_children_free(b_strands);
-	}
-	
 	static float3 get_location(BL::StrandsChildren b_strands, int index)
 	{
 		float *co = b_strands.vertices[index].location();
 		return make_float3(co[0], co[1], co[2]);
 	}
-	static float3 get_uv(BL::StrandsChildren /*b_strands*/, int /*index*/, int /*uv_num*/)
+	static float3 get_uv(BL::StrandsChildren b_strands, int index, int uv_num)
 	{
-		return make_float3(0.0f, 0.0f, 0.0f);
+		if (uv_num < b_strands.num_curve_uv_layers()) {
+			size_t offset = uv_num * b_strands.curves.length();
+			float *uv = b_strands.curve_uvs[offset + index].uv();
+			return make_float3(uv[0], uv[1], 0.0f);
+		}
+		else
+			return make_float3(0.0f, 0.0f, 0.0f);
 	}
-	static float3 get_vcol(BL::StrandsChildren /*b_strands*/, int /*index*/, int /*vcol_num*/)
+	static float3 get_vcol(BL::StrandsChildren b_strands, int index, int vcol_num)
 	{
-		return make_float3(0.0f, 0.0f, 0.0f);
+		if (vcol_num < b_strands.num_curve_vcol_layers()) {
+			size_t offset = vcol_num * b_strands.curves.length();
+			float *vcol = b_strands.curve_vcols[offset + index].vcol();
+			return make_float3(vcol[0], vcol[1], vcol[2]);
+		}
+		else
+			return make_float3(0.0f, 0.0f, 0.0f);
 	}
 };
 
 template <typename StrandsT>
-static bool 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)
+static bool ObtainCacheStrandsData(Mesh *mesh, BL::Scene /*b_scene*/, BL::Object /*b_parent*/, BL::DupliObject /*b_dupli_ob*/, BL::ParticleSystem b_psys, StrandsT b_strands, const Transform &/*itfm*/,
+                                   ParticleCurveData *CData, bool /*background*/)
 {
 	typedef StrandsTraits<StrandsT> traits;
 	typedef typename traits::curve_t CurveT;
 	
-	StrandsT b_strands = traits::make_strands(b_scene, b_parent, b_dupli_ob, b_psys, background);
-	if (!b_strands)
-		return false;
-	
 	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 	PointerRNA cpsys = RNA_pointer_get(&b_part.ptr, "cycles");
 	
@@ -359,6 +349,9 @@ static bool ObtainCacheStrandsData(Mesh *mesh, BL::Scene b_scene, BL::Object b_p
 	int totcurves = b_strands.curves.length();
 	int totvert = b_strands.vertices.length();
 
+	int keyno = CData->curvekey_co.size();
+	int curvenum = CData->curve_keynum.size();
+
 	CData->psys_firstcurve.push_back(curvenum);
 	CData->psys_curvenum.push_back(totcurves);
 	CData->psys_shader.push_back(shader);
@@ -407,20 +400,15 @@ static bool ObtainCacheStrandsData(Mesh *mesh, BL::Scene b_scene, BL::Object b_p
 		curvenum++;
 	}
 	
-	traits::free_strands(b_dupli_ob, b_strands);
 	return true;
 }
 
 template <typename StrandsT>
-static bool 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)
+static bool ObtainCacheStrandsUV(Mesh * /*mesh*/, BL::Scene /*b_scene*/, BL::Object /*b_parent*/, BL::DupliObject /*b_dupli_ob*/, BL::ParticleSystem /*b_psys*/, StrandsT b_strands,
+                                 ParticleCurveData *CData, bool /*background*/, int uv_num)
 {
 	typedef StrandsTraits<StrandsT> traits;
 	
-	StrandsT b_strands = traits::make_strands(b_scene, b_parent, b_dupli_ob, b_psys, background);
-	if (!b_strands)
-		return false;
-	
 //	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 
 	int totcurves = b_strands.curves.length();
@@ -432,20 +420,15 @@ static bool ObtainCacheStrandsUV(Mesh * /*mesh*/, BL::Scene b_scene, BL::Object
 		CData->curve_uv.push_back(traits::get_uv(b_strands, icurve, uv_num));
 	}
 	
-	traits::free_strands(b_dupli_ob, b_strands);
 	return true;
 }
 
 template <typename StrandsT>
-static bool 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)
+static bool ObtainCacheStrandsVcol(Mesh * /*mesh*/, BL::Scene /*b_scene*/, BL::Object /*b_parent*/, BL::DupliObject /*b_dupli_ob*/, BL::ParticleSystem /*b_psys*/, StrandsT b_strands,
+                                   ParticleCurveData *CData, bool /*background*/, int vcol_num)
 {
 	typedef StrandsTraits<StrandsT> traits;
 	
-	StrandsT b_strands = traits::make_strands(b_scene, b_parent, b_dupli_ob, b_psys, background);
-	if (!b_strands)
-		return false;
-	
 //	BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);
 	
 	int totcurves = b_strands.curves.length();
@@ -457,119 +440,6 @@ static bool ObtainCacheStrandsVcol(Mesh * /*mesh*/, BL::Scene b_scene, BL::Objec
 		CData->curve_vcol.push_back(traits::get_vcol(b_strands, icurve, vcol_num));
 	}
 	
-	traits::free_strands(b_dupli_ob, b_strands);
-	return true;
-}
-
-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);
-
-	if(!(mesh && b_mesh && b_ob && CData))
-		return false;
-
-	Transform tfm = get_transform(b_ob.matrix_world());
-	Transform itfm = transform_quick_inverse(tfm);
-
-	int curvenum = 0;
-	int keyno = 0;
-	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 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) {
-					if (ObtainCacheStrandsData<BL::StrandsChildren>(mesh, b_scene, b_parent, b_dupli_ob,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list