[Bf-blender-cvs] [a72de91] compositor-2016: Fix broken Cycles curve motion radius after recent refactor, and fix warnings.

Brecht Van Lommel noreply at git.blender.org
Wed Jun 8 21:51:35 CEST 2016


Commit: a72de9116e0a4f760ed5c59b7f500d641c5369d4
Author: Brecht Van Lommel
Date:   Mon May 30 22:44:17 2016 +0200
Branches: compositor-2016
https://developer.blender.org/rBa72de9116e0a4f760ed5c59b7f500d641c5369d4

Fix broken Cycles curve motion radius after recent refactor, and fix warnings.

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

M	intern/cycles/blender/blender_curves.cpp
M	intern/cycles/render/mesh.cpp
M	intern/cycles/render/mesh.h
M	intern/cycles/subd/subd_dice.cpp
M	intern/cycles/subd/subd_dice.h

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

diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index a1e2617..378ae67 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -604,7 +604,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
 				num_curve_keys++;
 			}
 
-			mesh->add_curve(num_keys, num_curve_keys, CData->psys_shader[sys]);
+			mesh->add_curve(num_keys, CData->psys_shader[sys]);
 			num_keys += num_curve_keys;
 			num_curves++;
 		}
@@ -635,7 +635,7 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
 
 	/* export motion vectors for curve keys */
 	size_t numkeys = mesh->curve_keys.size();
-	float3 *mP = attr_mP->data_float3() + time_index*numkeys;
+	float4 *mP = attr_mP->data_float4() + time_index*numkeys;
 	bool have_motion = false;
 	int i = 0;
 
@@ -656,13 +656,16 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
 					if(CData->psys_closetip[sys] && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1))
 						radius = 0.0f;
 
-					mP[i] = ickey_loc;
-					(void)radius;
+					/* curve motion keys store both position and radius in float4 */
+					mP[i] = float3_to_float4(ickey_loc);
+					mP[i].w = radius;
 
 					/* unlike mesh coordinates, these tend to be slightly different
 					 * between frames due to particle transforms into/out of object
 					 * space, so we use an epsilon to detect actual changes */
-					if(len_squared(mP[i] - mesh->curve_keys[i]) > 1e-5f*1e-5f)
+					float4 curve_key = float3_to_float4(mesh->curve_keys[i]);
+					curve_key.w = mesh->curve_radius[i];
+					if(len_squared(mP[i] - curve_key) > 1e-5f*1e-5f)
 						have_motion = true;
 				}
 
@@ -684,10 +687,12 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
 			/* motion, fill up previous steps that we might have skipped because
 			 * they had no motion, but we need them anyway now */
 			for(int step = 0; step < time_index; step++) {
-				float3 *mP = attr_mP->data_float3() + step*numkeys;
+				float4 *mP = attr_mP->data_float4() + step*numkeys;
 
-				for(int key = 0; key < numkeys; key++)
-					mP[key] = mesh->curve_keys[key];
+				for(int key = 0; key < numkeys; key++) {
+					mP[key] = float3_to_float4(mesh->curve_keys[key]);
+					mP[key].w = mesh->curve_radius[key];
+				}
 			}
 		}
 	}
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 00b8e02..d92226d 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -240,7 +240,7 @@ void Mesh::add_curve_key(float3 co, float radius)
 	curve_radius.push_back_reserved(radius);
 }
 
-void Mesh::add_curve(int first_key, int num_keys, int shader)
+void Mesh::add_curve(int first_key, int shader)
 {
 	curve_first_key.push_back_reserved(first_key);
 	curve_shader.push_back_reserved(shader);
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index 7556b7c..5c788fc 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -158,7 +158,7 @@ public:
 	void add_vertex(float3 P);
 	void add_triangle(int v0, int v1, int v2, int shader, bool smooth, bool forms_quad = false);
 	void add_curve_key(float3 loc, float radius);
-	void add_curve(int first_key, int num_keys, int shader);
+	void add_curve(int first_key, int shader);
 	int split_vertex(int vertex);
 
 	void compute_bounds();
diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp
index 9542ac4..8dba137 100644
--- a/intern/cycles/subd/subd_dice.cpp
+++ b/intern/cycles/subd/subd_dice.cpp
@@ -41,7 +41,7 @@ EdgeDice::EdgeDice(const SubdParams& params_)
 	}
 }
 
-void EdgeDice::reserve(int num_verts, int num_tris)
+void EdgeDice::reserve(int num_verts)
 {
 	Mesh *mesh = params.mesh;
 
@@ -147,8 +147,7 @@ void QuadDice::reserve(EdgeFactors& ef, int Mu, int Mv)
 {
 	/* XXX need to make this also work for edge factor 0 and 1 */
 	int num_verts = (ef.tu0 + ef.tu1 + ef.tv0 + ef.tv1) + (Mu - 1)*(Mv - 1);
-	int num_tris = 0;
-	EdgeDice::reserve(num_verts, num_tris);
+	EdgeDice::reserve(num_verts);
 }
 
 float2 QuadDice::map_uv(SubPatch& sub, float u, float v)
@@ -358,7 +357,7 @@ void TriangleDice::reserve(EdgeFactors& ef, int M)
 	if(!(M & 1))
 		num_verts++;
 	
-	EdgeDice::reserve(num_verts, 0);
+	EdgeDice::reserve(num_verts);
 }
 
 float2 TriangleDice::map_uv(SubPatch& sub, float2 uv)
diff --git a/intern/cycles/subd/subd_dice.h b/intern/cycles/subd/subd_dice.h
index 49f786e..85bd0ea 100644
--- a/intern/cycles/subd/subd_dice.h
+++ b/intern/cycles/subd/subd_dice.h
@@ -72,7 +72,7 @@ public:
 
 	explicit EdgeDice(const SubdParams& params);
 
-	void reserve(int num_verts, int num_tris);
+	void reserve(int num_verts);
 
 	int add_vert(Patch *patch, float2 uv);
 	void add_triangle(Patch *patch, int v0, int v1, int v2);




More information about the Bf-blender-cvs mailing list