Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-12-21 13:27:39 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-12-21 13:27:39 +0400
commitb28c055508bb694aab6c67f716b0e5a70cd73291 (patch)
tree8cd28d79f7bbe4910286cc2b24b19210d0ff71fa /source/blender/editors/physics/particle_object.c
parent99433a34667ea3c9fd10be6214e905288304e95f (diff)
Fix #33640: Blender crashes when I click on "Connect Hair" in "Particles" pannel
Issue was caused by disabled particle system modifier, now connect hair will check on that and give an error message if modifier is disabled.
Diffstat (limited to 'source/blender/editors/physics/particle_object.c')
-rw-r--r--source/blender/editors/physics/particle_object.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 221aad2161c..23069ab8a08 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -49,6 +49,7 @@
#include "BKE_main.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
+#include "BKE_report.h"
#include "RNA_access.h"
@@ -625,7 +626,7 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "all", 0, "All hair", "Disconnect all hair systems from the emitter mesh");
}
-static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
+static int connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
ParticleData *pa;
@@ -642,8 +643,8 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
float hairmat[4][4], imat[4][4];
float v[4][3], vec[3];
- if (!psys || !psys->part || psys->part->type != PART_HAIR)
- return;
+ if (!psys || !psys->part || psys->part->type != PART_HAIR || !psmd->dm)
+ return FALSE;
edit= psys->edit;
point= edit ? edit->points : NULL;
@@ -724,6 +725,8 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
psys->flag &= ~PSYS_GLOBAL_HAIR;
PE_update_object(scene, ob, 0);
+
+ return TRUE;
}
static int connect_hair_exec(bContext *C, wmOperator *op)
@@ -733,18 +736,24 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys= NULL;
int all = RNA_boolean_get(op->ptr, "all");
+ int any_connected = FALSE;
if (!ob)
return OPERATOR_CANCELLED;
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
- connect_hair(scene, ob, psys);
+ any_connected |= connect_hair(scene, ob, psys);
}
}
else {
psys = ptr.data;
- connect_hair(scene, ob, psys);
+ any_connected |= connect_hair(scene, ob, psys);
+ }
+
+ if (!any_connected) {
+ BKE_report(op->reports, RPT_ERROR, "Can't disconnect hair if particle system modifier is disabled");
+ return OPERATOR_CANCELLED;
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);