From 489c015e706cf3bcfd246a2a081664d290ec7096 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 25 Mar 2019 13:55:03 +0100 Subject: Fix T62891: particle even distribution is not even. CD_ORCO coordinates are stored normalized by convention, this code path did not store them correctly. --- source/blender/blenkernel/intern/particle_distribute.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern/particle_distribute.c') 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]); -- cgit v1.2.3