static int connect_hair_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob= ED_object_context(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= NULL; const bool all = RNA_boolean_get(op->ptr, "all"); bool any_connected = false; if (!ob) return OPERATOR_CANCELLED; if (all) { for (psys=ob->particlesystem.first; psys; psys=psys->next) { any_connected |= connect_hair(scene, ob, psys); } } else { psys = ptr.data; 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); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); return OPERATOR_FINISHED; }
static int connect_hair_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= NULL; int all = RNA_boolean_get(op->ptr, "all"); if(!ob) return OPERATOR_CANCELLED; if(all) { for(psys=ob->particlesystem.first; psys; psys=psys->next) { connect_hair(scene, ob, psys); } } else { psys = ptr.data; connect_hair(scene, ob, psys); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); return OPERATOR_FINISHED; }