[Bf-blender-cvs] [eee7918] gooseberry: Disabled the child hair hull drawing feature.

Lukas Tönne noreply at git.blender.org
Thu Jan 29 17:01:00 CET 2015


Commit: eee7918c377806ea9ad17d7d7142c3ee9aaa222a
Author: Lukas Tönne
Date:   Thu Jan 29 16:55:36 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBeee7918c377806ea9ad17d7d7142c3ee9aaa222a

Disabled the child hair hull drawing feature.

This is incompatible with particle data structures in their current form.
Hull drawing requires sorting child particles based on the distance from
their primary parent. However, this changes the order of children, which
is the main method of generating random numbers for them. In the
viewport this is not a problem, but when rendering the children are
constantly recreated, using the respective deformed emitter mesh each
time. This leads to changing child orders when using the convex hull
sorting, and therefore different randomisation values.

To properly implement child hull drawing we would have to generate a
stable parent-child offset metric as well as avoiding any resorting in
the actual data arrays. This in turn requires terribly inefficient
drawing iteration, which could become a bottleneck by itself even before
taking cache coherence or OpenGL optimization requirements into account
(collecting child data into a dedicated buffer for drawing).

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

M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/particle_distribute.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/makesrna/intern/rna_particle.c

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

diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index e5f9c79..481043a 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -69,6 +69,11 @@ struct EdgeHash;
 
 /* XXX disabled for now due to stability issues and limited usefulness */
 //#define USE_PARTICLE_PREVIEW
+/* XXX disabled because this requires sorting of children,
+ * but during render children are constantly recreated based on the deformed mesh,
+ * which leads to different indices every time and therefore different randomization values.
+ */
+//#define USE_PARTICLE_HULL_DRAWING
 
 #define PARTICLE_P              ParticleData * pa; int p
 #define LOOP_PARTICLES  for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++)
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 41a8ec2..5ce1aea 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -1156,6 +1156,7 @@ static void distribute_particles_on_shape(ParticleSimulationData *sim, int UNUSE
 	fprintf(stderr,"Shape emission not yet possible!\n");
 }
 
+#ifdef USE_PARTICLE_HULL_DRAWING
 /* placeholder for child particle sorting, storing emitter hair-space offset */
 typedef struct ChildParticleSort {
 	int index;
@@ -1330,6 +1331,7 @@ static void psys_sort_children(ParticleSimulationData *sim)
 	
 	MEM_freeN(sort);
 }
+#endif
 
 void distribute_particles(ParticleSimulationData *sim, int from)
 {
@@ -1345,8 +1347,10 @@ void distribute_particles(ParticleSimulationData *sim, int from)
 	else
 		distribute_particles_on_shape(sim, from);
 
+#ifdef USE_PARTICLE_HULL_DRAWING
 	if (from == PART_FROM_CHILD)
 		psys_sort_children(sim);
+#endif
 
 	if (distr_error) {
 		distribute_invalid(sim->scene, sim->psys, from);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 0e2f7d8..ade2437 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4482,6 +4482,43 @@ static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *ba
 
 /* *********** drawing for particles ************* */
 
+BLI_INLINE unsigned int hash_int_2d(unsigned int kx, unsigned int ky)
+{
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
+
+	unsigned int a, b, c;
+
+	a = b = c = 0xdeadbeef + (2 << 2) + 13;
+	a += kx;
+	b += ky;
+
+	c ^= b; c -= rot(b,14);
+	a ^= c; a -= rot(c,11);
+	b ^= a; b -= rot(a,25);
+	c ^= b; c -= rot(b,16);
+	a ^= c; a -= rot(c,4);
+	b ^= a; b -= rot(a,14);
+	c ^= b; c -= rot(b,24);
+
+	return c;
+
+#undef rot
+}
+
+BLI_INLINE unsigned int hash_int(unsigned int k)
+{
+	return hash_int_2d(k, 0);
+}
+
+static void particle_path_color(int index, float col[3])
+{
+	unsigned seed = hash_int(index);
+	
+	BLI_srandom(seed);
+	hsv_to_rgb(BLI_frand(), 1.0f, 1.0f, col+0, col+1, col+2);
+}
+
+#ifdef USE_PARTICLE_HULL_DRAWING
 static void draw_particle_hull_section(ParticleCacheKey *path, ParticleCacheKey *npath)
 {
 	int segments = max_ii(path->segments, npath->segments);
@@ -4638,42 +4675,6 @@ BLI_INLINE int particle_path_prev(ParticleCacheKey **cache, int pmin, int p)
 	return p;
 }
 
-BLI_INLINE unsigned int hash_int_2d(unsigned int kx, unsigned int ky)
-{
-#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
-
-	unsigned int a, b, c;
-
-	a = b = c = 0xdeadbeef + (2 << 2) + 13;
-	a += kx;
-	b += ky;
-
-	c ^= b; c -= rot(b,14);
-	a ^= c; a -= rot(c,11);
-	b ^= a; b -= rot(a,25);
-	c ^= b; c -= rot(b,16);
-	a ^= c; a -= rot(c,4);
-	b ^= a; b -= rot(a,14);
-	c ^= b; c -= rot(b,24);
-
-	return c;
-
-#undef rot
-}
-
-BLI_INLINE unsigned int hash_int(unsigned int k)
-{
-	return hash_int_2d(k, 0);
-}
-
-static void particle_path_color(int index, float col[3])
-{
-	unsigned seed = hash_int(index);
-	
-	BLI_srandom(seed);
-	hsv_to_rgb(BLI_frand(), 1.0f, 1.0f, col+0, col+1, col+2);
-}
-
 static void draw_particle_hair_hull(Scene *UNUSED(scene), View3D *v3d, RegionView3D *rv3d,
                                     Base *base, ParticleSystem *psys,
                                     const char UNUSED(ob_dt), const short dflag)
@@ -4848,10 +4849,8 @@ static void draw_particle_hair_hull(Scene *UNUSED(scene), View3D *v3d, RegionVie
 	if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
 		glLoadMatrixf(rv3d->viewmat);
 	}
-	
-#undef FOREACH_PATH_PAIR_BEGIN
-#undef FOREACH_PATH_PAIR_END
 }
+#endif
 
 static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select)
 {
@@ -5116,7 +5115,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 		return;
 	}
 	else if (draw_as == PART_DRAW_HULL) {
+#ifdef USE_PARTICLE_HULL_DRAWING
 		draw_particle_hair_hull(scene, v3d, rv3d, base, psys, ob_dt, dflag);
+#endif
 		return;
 	}
 
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index f792d38..99981ee 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -101,7 +101,9 @@ static EnumPropertyItem part_hair_draw_as_items[] = {
 	{PART_DRAW_NOT, "NONE", 0, "None", "No hair drawing"},
 	{PART_DRAW_REND, "RENDER", 0, "Rendered", "Approximate render result in the viewport"},
 	{PART_DRAW_PATH, "PATH", 0, "Path", "Show path of hair particles"},
+#ifdef USE_PARTICLE_HULL_DRAWING
 	{PART_DRAW_HULL, "HULL", 0, "Hull", "Show convex hull of child particle paths"},
+#endif
 	{0, NULL, 0, NULL, NULL}
 };
 #endif
@@ -2101,7 +2103,9 @@ static void rna_def_particle_settings(BlenderRNA *brna)
 		{PART_DRAW_COL_MAT, "MATERIAL", 0, "Material", ""},
 		{PART_DRAW_COL_VEL, "VELOCITY", 0, "Velocity", ""},
 		{PART_DRAW_COL_ACC, "ACCELERATION", 0, "Acceleration", ""},
+#ifdef USE_PARTICLE_HULL_DRAWING
 		{PART_DRAW_COL_PARENT, "PARENT", 0, "Parent", ""},
+#endif
 		{0, NULL, 0, NULL, NULL}
 	};




More information about the Bf-blender-cvs mailing list