Fix T44960: Crash with 'Shape Cut' in edit hair mode.
This is only supported for mesh objects so far. Also, abort in case there are no faces in dm (instead of crashing on NULL BVH tree...).
This commit is contained in:
parent
304ee9af8d
commit
d5bca524d5
Notes:
blender-bot
2023-02-14 09:02:41 +01:00
Referenced by issue #44960, Hair crush
|
@ -414,18 +414,18 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void PE_create_shape_tree(PEData *data, Object *shapeob)
|
||||
static bool PE_create_shape_tree(PEData *data, Object *shapeob)
|
||||
{
|
||||
DerivedMesh *dm = shapeob->derivedFinal;
|
||||
|
||||
memset(&data->shape_bvh, 0, sizeof(data->shape_bvh));
|
||||
|
||||
if (!dm) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
DM_ensure_tessface(dm);
|
||||
bvhtree_from_mesh_faces(&data->shape_bvh, dm, 0.0f, 4, 8);
|
||||
return bvhtree_from_mesh_faces(&data->shape_bvh, dm, 0.0f, 4, 8);
|
||||
}
|
||||
|
||||
static void PE_free_shape_tree(PEData *data)
|
||||
|
@ -4059,11 +4059,12 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot)
|
|||
static int shape_cut_poll(bContext *C)
|
||||
{
|
||||
if (PE_hair_poll(C)) {
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ParticleEditSettings *pset= PE_settings(scene);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ParticleEditSettings *pset = PE_settings(scene);
|
||||
|
||||
if (pset->shape_object)
|
||||
if (pset->shape_object && (pset->shape_object->type == OB_MESH)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -4179,7 +4180,10 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
int removed;
|
||||
|
||||
PE_set_data(C, &data);
|
||||
PE_create_shape_tree(&data, shapeob);
|
||||
if (!PE_create_shape_tree(&data, shapeob)) {
|
||||
/* shapeob may not have faces... */
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (selected)
|
||||
foreach_selected_point(&data, shape_cut);
|
||||
|
|
|
@ -871,6 +871,7 @@ static void rna_def_particle_edit(BlenderRNA *brna)
|
|||
prop = RNA_def_property(srna, "shape_object", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Shape Object", "Outer shape to use for tools");
|
||||
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll");
|
||||
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo");
|
||||
|
||||
/* brush */
|
||||
|
|
Loading…
Reference in New Issue