[Bf-blender-cvs] [489c015e706] master: Fix T62891: particle even distribution is not even.
Brecht Van Lommel
noreply at git.blender.org
Mon Mar 25 14:30:48 CET 2019
Commit: 489c015e706cf3bcfd246a2a081664d290ec7096
Author: Brecht Van Lommel
Date: Mon Mar 25 13:55:03 2019 +0100
Branches: master
https://developer.blender.org/rB489c015e706cf3bcfd246a2a081664d290ec7096
Fix T62891: particle even distribution is not even.
CD_ORCO coordinates are stored normalized by convention, this code path did
not store them correctly.
===================================================================
M source/blender/blenkernel/intern/particle_distribute.c
M source/blender/makesdna/DNA_customdata_types.h
===================================================================
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,
More information about the Bf-blender-cvs
mailing list