[Bf-blender-cvs] [f5c0ef52cf2] master: Fix T84588: Cache access in rna_Particle_uv_on_emitter
Robert Guetzkow
noreply at git.blender.org
Tue Jan 12 12:18:33 CET 2021
Commit: f5c0ef52cf2f4ae333269eec33e5bd7a89a00a23
Author: Robert Guetzkow
Date: Tue Jan 12 12:12:33 2021 +0100
Branches: master
https://developer.blender.org/rBf5c0ef52cf2f4ae333269eec33e5bd7a89a00a23
Fix T84588: Cache access in rna_Particle_uv_on_emitter
The function `rna_Particle_uv_on_emitter` did not handle the case where
`particle->num_dmcache` was `DMCACHE_ISCHILD`. This resulted in an
incorrect offset for the `mtface` pointer. The commit checks for the
case and sets the offset accordingly, similar to existing code in
e.g. `particle_calculate_parent_uvs`.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10072
===================================================================
M source/blender/makesdna/DNA_particle_types.h
M source/blender/makesrna/intern/rna_particle.c
===================================================================
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index d48144f90e8..5310ec56b26 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -132,7 +132,10 @@ typedef struct ParticleData {
*/
/** Index to vert/edge/face. */
int num;
- /** Index to derived mesh data (face) to avoid slow lookups. */
+ /**
+ * Index to derived mesh data (face) to avoid slow lookups. It can also have negative
+ * values DMCACHE_NOTFOUND and DMCACHE_ISCHILD.
+ */
int num_dmcache;
/** Coordinates on face/edge number "num" and depth along. */
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 057f48c498c..bc9eda3cb5f 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -403,16 +403,15 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle,
}
BKE_mesh_tessface_ensure(modifier->mesh_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
- if (num == DMCACHE_NOTFOUND) {
+ if (ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
if (particle->num < modifier->mesh_final->totface) {
num = particle->num;
}
}
/* get uvco */
- if (r_uv && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
-
- if (num != DMCACHE_NOTFOUND) {
+ if (r_uv && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME) &&
+ !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
MFace *mface;
MTFace *mtface;
@@ -424,7 +423,6 @@ static void rna_Particle_uv_on_emitter(ParticleData *particle,
psys_interpolate_uvs(mtface, mface->v4, particle->fuv, r_uv);
return;
}
- }
}
r_uv[0] = 0.0f;
More information about the Bf-blender-cvs
mailing list