diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-25 15:55:03 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-25 16:28:29 +0300 |
commit | 489c015e706cf3bcfd246a2a081664d290ec7096 (patch) | |
tree | 2fc1ad494d7172419c60a8d16c9f8f103fa53651 | |
parent | a6f9e0d6441c3741280bda998e179f2a2da8efe2 (diff) |
Fix T62891: particle even distribution is not even.
CD_ORCO coordinates are stored normalized by convention, this code path did
not store them correctly.
-rw-r--r-- | source/blender/blenkernel/intern/particle_distribute.c | 9 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_customdata_types.h | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index dd0a4a24d7b..fc3c998ca1c 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -909,8 +909,12 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti BKE_mesh_tessface_ensure(mesh); /* we need orco for consistent distributions */ - if (!CustomData_has_layer(&mesh->vdata, CD_ORCO)) - CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob), mesh->totvert); + if (!CustomData_has_layer(&mesh->vdata, CD_ORCO)) { + /* Orcos are stored in normalized 0..1 range by convention. */ + float (*orcodata)[3] = BKE_mesh_orco_verts_get(ob); + BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->totvert, false); + CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, orcodata, mesh->totvert); + } if (from == PART_FROM_VERT) { MVert *mv = mesh->mvert; @@ -966,6 +970,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti MFace *mf = &mesh->mface[i]; if (orcodata) { + /* Transform orcos from normalized 0..1 to object space. */ copy_v3_v3(co1, orcodata[mf->v1]); copy_v3_v3(co2, orcodata[mf->v2]); copy_v3_v3(co3, orcodata[mf->v3]); diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 91412044e0e..10d18684413 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -108,7 +108,7 @@ typedef enum CustomDataType { CD_PROP_INT = 11, CD_PROP_STR = 12, CD_ORIGSPACE = 13, /* for modifier stack face location mapping */ - CD_ORCO = 14, + CD_ORCO = 14, /* undeformed vertex coordinates, normalized to 0..1 range */ /* CD_MTEXPOLY = 15, */ /* deprecated */ CD_MLOOPUV = 16, CD_MLOOPCOL = 17, |