[Bf-blender-cvs] [b0386628872] master: Fix T103559: Check for no-face object for particle baking
Sibo Van Gool
noreply at git.blender.org
Mon Jan 16 01:16:15 CET 2023
Commit: b03866288728823d74352ba2ba91ade8d08e1d2e
Author: Sibo Van Gool
Date: Mon Jan 16 11:06:01 2023 +1100
Branches: master
https://developer.blender.org/rBb03866288728823d74352ba2ba91ade8d08e1d2e
Fix T103559: Check for no-face object for particle baking
Meshes spawning particles from faces with with UV's/Vertex-colors but no
faces would crash de-referencing a NULL pointer.
Resolve by adding a check for this case and an assertion if CD_MFACE is
NULL when the mesh has polygons.
Ref D16947
===================================================================
M source/blender/draw/intern/draw_cache_impl_particles.c
===================================================================
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 5b45fa38704..cba06eec76c 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -311,6 +311,11 @@ static void particle_calculate_parent_uvs(ParticleSystem *psys,
}
if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
const MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE);
+ if (UNLIKELY(mfaces == NULL)) {
+ BLI_assert_msg(psmd->mesh_final->totpoly == 0,
+ "A mesh with polygons should always have a generated 'CD_MFACE' layer!");
+ return;
+ }
const MFace *mface = &mfaces[num];
for (int j = 0; j < num_uv_layers; j++) {
psys_interpolate_uvs(mtfaces[j] + num, mface->v4, particle->fuv, r_uv[j]);
@@ -341,6 +346,11 @@ static void particle_calculate_parent_mcol(ParticleSystem *psys,
}
if (!ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
const MFace *mfaces = CustomData_get_layer(&psmd->mesh_final->fdata, CD_MFACE);
+ if (UNLIKELY(mfaces == NULL)) {
+ BLI_assert_msg(psmd->mesh_final->totpoly == 0,
+ "A mesh with polygons should always have a generated 'CD_MFACE' layer!");
+ return;
+ }
const MFace *mface = &mfaces[num];
for (int j = 0; j < num_col_layers; j++) {
/* CustomDataLayer CD_MCOL has 4 structs per face. */
More information about the Bf-blender-cvs
mailing list