[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54054] trunk/blender/source/blender/ editors/physics/particle_edit.c: Fix #33896: particle add brush with radius 1 would give duplicated and NaN hairs.
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed Jan 23 20:40:53 CET 2013
Revision: 54054
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54054
Author: blendix
Date: 2013-01-23 19:40:52 +0000 (Wed, 23 Jan 2013)
Log Message:
-----------
Fix #33896: particle add brush with radius 1 would give duplicated and NaN hairs.
Modified Paths:
--------------
trunk/blender/source/blender/editors/physics/particle_edit.c
Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c 2013-01-23 17:15:45 UTC (rev 54053)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c 2013-01-23 19:40:52 UTC (rev 54054)
@@ -3254,7 +3254,7 @@
ParticleEditSettings *pset= PE_settings(scene);
int i, k, n= 0, totpart= psys->totpart;
float mco[2];
- short dmx= 0, dmy= 0;
+ float dmx, dmy;
float co1[3], co2[3], min_d, imat[4][4];
float framestep, timestep;
short size= pset->brush[PE_BRUSH_ADD].size;
@@ -3282,12 +3282,19 @@
for (i=0; i<number; i++) {
if (number>1) {
- dmx=dmy=size;
- while (dmx*dmx+dmy*dmy>size2) {
- dmx=(short)((2.0f*BLI_frand()-1.0f)*size);
- dmy=(short)((2.0f*BLI_frand()-1.0f)*size);
+ dmx = size;
+ dmy = size;
+
+ /* rejection sampling to get points in circle */
+ while (dmx*dmx + dmy*dmy > size2) {
+ dmx= (2.0f*BLI_frand() - 1.0f)*size;
+ dmy= (2.0f*BLI_frand() - 1.0f)*size;
}
}
+ else {
+ dmx = 0.0f;
+ dmy = 0.0f;
+ }
mco[0] = data->mval[0] + dmx;
mco[1] = data->mval[1] + dmy;
@@ -3390,8 +3397,14 @@
weight[w] = 0.0f;
}
- for (w=0; w<maxw; w++)
- weight[w] /= totw;
+ if(totw > 0.0f) {
+ for (w=0; w<maxw; w++)
+ weight[w] /= totw;
+ }
+ else {
+ for (w=0; w<maxw; w++)
+ weight[w] = 1.0f/maxw;
+ }
ppa= psys->particles+ptn[0].index;
@@ -3403,7 +3416,7 @@
psys_get_particle_on_path(&sim, ptn[0].index, key3, 0);
mul_v3_fl(key3[0].co, weight[0]);
- /* TODO: interpolatint the weight would be nicer */
+ /* TODO: interpolating the weight would be nicer */
thkey->weight= (ppa->hair+MIN2(k, ppa->totkey-1))->weight;
if (maxw>1) {
More information about the Bf-blender-cvs
mailing list