diff options
Diffstat (limited to 'source/blender/editors/object/object_modifier.c')
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 268 |
1 files changed, 134 insertions, 134 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 34f192fbffa..c79be8ed223 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -97,7 +97,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc { ModifierData *md = NULL, *new_md = NULL; const ModifierTypeInfo *mti = modifierType_getInfo(type); - + /* Check compatibility of modifier [T25291, T50373]. */ if (!BKE_object_support_modifier_type_check(ob, type)) { BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2); @@ -110,23 +110,23 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc return NULL; } } - + if (type == eModifierType_ParticleSystem) { /* don't need to worry about the new modifier's name, since that is set to the number - * of particle systems which shouldn't have too many duplicates + * of particle systems which shouldn't have too many duplicates */ new_md = object_add_particle_system(scene, ob, name); } else { /* get new modifier data to add */ new_md = modifier_new(type); - + if (mti->flags & eModifierTypeFlag_RequiresOriginalData) { md = ob->modifiers.first; - + while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) md = md->next; - + BLI_insertlinkbefore(&ob->modifiers, md, new_md); } else @@ -139,7 +139,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* make sure modifier data has unique name */ modifier_unique_name(&ob->modifiers, new_md); - + /* special cases */ if (type == eModifierType_Softbody) { if (!ob->soft) { @@ -150,7 +150,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc else if (type == eModifierType_Collision) { if (!ob->pd) ob->pd = object_add_collision_fields(0); - + ob->pd->deflect = 1; } else if (type == eModifierType_Surface) { @@ -465,14 +465,14 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * /* add new mesh */ obn = BKE_object_add(bmain, scene, OB_MESH, NULL); me = obn->data; - + me->totvert = totvert; me->totedge = totedge; - + me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); - + mvert = me->mvert; medge = me->medge; @@ -547,18 +547,18 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M Mesh *me = ob->data; Key *key = me->key; KeyBlock *kb; - + if (!modifier_isSameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes"); return 0; } - + dm = mesh_create_derived_for_modifier(scene, ob, md, 0); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply"); return 0; } - + if (key == NULL) { key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; @@ -570,7 +570,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M kb = BKE_keyblock_add(key, md->name); DM_to_meshkey(dm, me, kb); - + dm->release(dm); } else { @@ -656,7 +656,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ParticleSystem *psys = ob->particlesystem.first; for (; psys; psys = psys->next) { - + if (psys->part->type != PART_HAIR) continue; @@ -718,7 +718,7 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierData *md) { ModifierData *nmd; - + nmd = modifier_new(md->type); modifier_copyData(md, nmd); BLI_insertlinkafter(&ob->modifiers, md, nmd); @@ -740,19 +740,19 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } static const EnumPropertyItem *modifier_add_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = ED_object_active_context(C); EnumPropertyItem *item = NULL; const EnumPropertyItem *md_item, *group_item = NULL; const ModifierTypeInfo *mti; int totitem = 0, a; - + if (!ob) return rna_enum_object_modifier_type_items; @@ -797,15 +797,15 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) ot->name = "Add Modifier"; ot->description = "Add a procedural operation/effect to the active object"; ot->idname = "OBJECT_OT_modifier_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = modifier_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "type", rna_enum_object_modifier_type_items, eModifierType_Subsurf, "Type", ""); RNA_def_enum_funcs(prop, modifier_add_itemf); @@ -818,11 +818,11 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); - + if (!ob || ID_IS_LINKED(ob)) return 0; if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) return 0; if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) return 0; - + return 1; } @@ -839,7 +839,7 @@ void edit_modifier_properties(wmOperatorType *ot) int edit_modifier_invoke_properties(bContext *C, wmOperator *op) { ModifierData *md; - + if (RNA_struct_property_is_set(op->ptr, "modifier")) { return true; } @@ -860,9 +860,9 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) char modifier_name[MAX_NAME]; ModifierData *md; RNA_string_get(op->ptr, "modifier", modifier_name); - + md = modifiers_findByName(ob, modifier_name); - + if (md && type != 0 && md->type != type) md = NULL; @@ -878,7 +878,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); int mode_orig = ob->mode; - + if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md)) return OPERATOR_CANCELLED; @@ -889,7 +889,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) if (scene->basact && scene->basact->object == ob) WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); - + return OPERATOR_FINISHED; } @@ -910,7 +910,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->invoke = modifier_remove_invoke; ot->exec = modifier_remove_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -928,7 +928,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -949,7 +949,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->invoke = modifier_move_up_invoke; ot->exec = modifier_move_up_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -967,7 +967,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -988,7 +988,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->invoke = modifier_move_down_invoke; ot->exec = modifier_move_down_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1009,7 +1009,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1036,10 +1036,10 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->invoke = modifier_apply_invoke; ot->exec = modifier_apply_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry"); edit_modifier_properties(ot); } @@ -1052,13 +1052,13 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - + if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1079,7 +1079,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->invoke = modifier_convert_invoke; ot->exec = modifier_convert_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1097,7 +1097,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1118,7 +1118,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->invoke = modifier_copy_invoke; ot->exec = modifier_copy_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1135,18 +1135,18 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_del_levels(mmd, ob, 1); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, &mmd->totlvl); - + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1167,7 +1167,7 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_higher_levels_delete_invoke; ot->exec = multires_higher_levels_delete_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1179,10 +1179,10 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_subdivide(mmd, ob, 0, mmd->simple); ED_object_iter_other(CTX_data_main(C), ob, true, @@ -1196,7 +1196,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) /* ensure that grid paint mask layer is created */ BKE_sculpt_mask_layers_ensure(ob, mmd); } - + return OPERATOR_FINISHED; } @@ -1217,7 +1217,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_subdivide_invoke; ot->exec = multires_subdivide_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1281,14 +1281,14 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_reshape_invoke; ot->exec = multires_reshape_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } - + /****************** multires save external operator *********************/ static int multires_external_save_exec(bContext *C, wmOperator *op) @@ -1304,7 +1304,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; - + RNA_string_get(op->ptr, "filepath", path); if (relative) @@ -1312,7 +1312,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path); CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0); - + return OPERATOR_FINISHED; } @@ -1325,23 +1325,23 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv if (!edit_modifier_invoke_properties(C, op)) return OPERATOR_CANCELLED; - + mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; if (RNA_struct_property_is_set(op->ptr, "filepath")) return multires_external_save_exec(C, op); - + op->customdata = me; BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2); RNA_string_set(op->ptr, "filepath", path); - + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; @@ -1357,7 +1357,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->exec = multires_external_save_exec; ot->invoke = multires_external_save_invoke; ot->poll = multires_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1379,7 +1379,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) /* XXX don't remove.. */ CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - + return OPERATOR_FINISHED; } @@ -1391,7 +1391,7 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) ot->poll = multires_poll; ot->exec = multires_external_pack_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1401,15 +1401,15 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_base_apply(mmd, ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1431,7 +1431,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_base_apply_invoke; ot->exec = multires_base_apply_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1444,7 +1444,7 @@ static void modifier_skin_customdata_delete(Object *ob) { Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; - + if (em) BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN); else @@ -1467,7 +1467,7 @@ static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_sk { BMEdge *bm_edge; BMIter bm_iter; - + BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) { BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert); @@ -1515,7 +1515,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1527,7 +1527,7 @@ void OBJECT_OT_skin_root_mark(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_root_mark_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1570,7 +1570,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1588,7 +1588,7 @@ void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_loose_mark_clear_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1620,7 +1620,7 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1632,7 +1632,7 @@ void OBJECT_OT_skin_radii_equalize(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_radii_equalize_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1676,7 +1676,7 @@ static void skin_armature_bone_create(Object *skin_ob, ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE); ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE); } - + skin_armature_bone_create(skin_ob, mvert, medge, arm, @@ -1709,7 +1709,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * CD_CALLOC, NULL, me->totvert); - + arm_ob = BKE_object_add(bmain, scene, OB_ARMATURE, NULL); BKE_object_transform_copy(arm_ob, skin_ob); arm = arm_ob->data; @@ -1742,7 +1742,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * bone->head[1] = 1.0f; bone->rad_head = bone->rad_tail = 0.25; } - + if (emap[v].count >= 1) { skin_armature_bone_create(skin_ob, mvert, me->medge, @@ -1816,7 +1816,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot) ot->poll = skin_poll; ot->invoke = skin_armature_create_invoke; ot->exec = skin_armature_create_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1901,7 +1901,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform); - + if (!mmd) return OPERATOR_CANCELLED; @@ -1926,7 +1926,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->totvert = 0; mmd->totcagevert = 0; mmd->totinfluence = 0; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); } @@ -1955,7 +1955,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->bindfunc = NULL; mmd->modifier.mode = mode; } - + return OPERATOR_FINISHED; } @@ -1963,7 +1963,7 @@ static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UN { if (edit_modifier_invoke_properties(C, op)) return meshdeform_bind_exec(C, op); - else + else return OPERATOR_CANCELLED; } @@ -1973,12 +1973,12 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) ot->name = "Mesh Deform Bind"; ot->description = "Bind mesh to cage in mesh deform modifier"; ot->idname = "OBJECT_OT_meshdeform_bind"; - + /* api callbacks */ ot->poll = meshdeform_poll; ot->invoke = meshdeform_bind_invoke; ot->exec = meshdeform_bind_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1995,7 +1995,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(op, ob, eModifierType_Explode); - + if (!emd) return OPERATOR_CANCELLED; @@ -2003,7 +2003,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -2025,7 +2025,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) ot->poll = explode_poll; ot->invoke = explode_refresh_invoke; ot->exec = explode_refresh_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -2043,14 +2043,14 @@ static int ocean_bake_poll(bContext *C) static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd) { int do_heightfield, do_chop, do_normals, do_jacobian; - - if (!omd || !oc) return; - + + if (!omd || !oc) return; + do_heightfield = true; do_chop = (omd->chop_amount > 0); do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); - + BKE_ocean_init(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size, omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, omd->depth, omd->time, @@ -2080,8 +2080,8 @@ static int oceanbake_breakjob(void *UNUSED(customdata)) { //OceanBakeJob *ob = (OceanBakeJob *)customdata; //return *(ob->stop); - - /* this is not nice yet, need to make the jobs list template better + + /* this is not nice yet, need to make the jobs list template better * for identifying/acting upon various different jobs */ /* but for now we'll reuse the render break... */ return (G.is_break); @@ -2091,10 +2091,10 @@ static int oceanbake_breakjob(void *UNUSED(customdata)) static void oceanbake_update(void *customdata, float progress, int *cancel) { OceanBakeJob *oj = customdata; - + if (oceanbake_breakjob(oj)) *cancel = 1; - + *(oj->do_update) = true; *(oj->progress) = progress; } @@ -2102,15 +2102,15 @@ static void oceanbake_update(void *customdata, float progress, int *cancel) static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress) { OceanBakeJob *oj = customdata; - + oj->stop = stop; oj->do_update = do_update; oj->progress = progress; - + G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ - + BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj); - + *do_update = true; *stop = 0; } @@ -2118,12 +2118,12 @@ static void oceanbake_startjob(void *customdata, short *stop, short *do_update, static void oceanbake_endjob(void *customdata) { OceanBakeJob *oj = customdata; - + if (oj->ocean) { BKE_ocean_free(oj->ocean); oj->ocean = NULL; } - + oj->omd->oceancache = oj->och; oj->omd->cached = true; } @@ -2138,13 +2138,13 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) struct Ocean *ocean; int f, cfra, i = 0; const bool free = RNA_boolean_get(op->ptr, "free"); - + wmJob *wm_job; OceanBakeJob *oj; - + if (!omd) return OPERATOR_CANCELLED; - + if (free) { omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -2155,11 +2155,11 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(bmain, ob), omd->bakestart, omd->bakeend, omd->wave_scale, omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); - + och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time"); - + cfra = scene->r.cfra; - + /* precalculate time variable before baking */ for (f = omd->bakestart; f <= omd->bakeend; f++) { /* from physics_fluid.c: @@ -2170,41 +2170,41 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) * This doesn't work with drivers: * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL); */ - - /* Modifying the global scene isn't nice, but we can do it in + + /* Modifying the global scene isn't nice, but we can do it in * this part of the process before a threaded job is created */ - + //scene->r.cfra = f; //ED_update_for_newframe(bmain, scene, 1); - - /* ok, this doesn't work with drivers, but is way faster. + + /* ok, this doesn't work with drivers, but is way faster. * let's use this for now and hope nobody wants to drive the time value... */ BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM); - + och->time[i] = omd->time; i++; } - + /* make a copy of ocean to use for baking - threadsafety */ ocean = BKE_ocean_add(); init_ocean_modifier_bake(ocean, omd); - + #if 0 BKE_ocean_bake(ocean, och); - + omd->oceancache = och; omd->cached = true; - + scene->r.cfra = cfra; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); #endif - + /* job stuff */ - + scene->r.cfra = cfra; - + /* setup job */ wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); @@ -2212,15 +2212,15 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) oj->ocean = ocean; oj->och = och; oj->omd = omd; - + WM_jobs_customdata_set(wm_job, oj, oceanbake_free); WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); WM_jobs_callbacks(wm_job, oceanbake_startjob, NULL, NULL, oceanbake_endjob); - + WM_jobs_start(CTX_wm_manager(C), wm_job); - - - + + + return OPERATOR_FINISHED; } @@ -2238,15 +2238,15 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot) ot->name = "Bake Ocean"; ot->description = "Bake an image sequence of ocean data"; ot->idname = "OBJECT_OT_ocean_bake"; - + ot->poll = ocean_bake_poll; ot->invoke = ocean_bake_invoke; ot->exec = ocean_bake_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); - + RNA_def_boolean(ot->srna, "free", false, "Free", "Free the bake, rather than generating it"); } @@ -2279,7 +2279,7 @@ static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEven { if (edit_modifier_invoke_properties(C, op)) return laplaciandeform_bind_exec(C, op); - else + else return OPERATOR_CANCELLED; } @@ -2289,12 +2289,12 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot) ot->name = "Laplacian Deform Bind"; ot->description = "Bind mesh to system in laplacian deform modifier"; ot->idname = "OBJECT_OT_laplaciandeform_bind"; - + /* api callbacks */ ot->poll = laplaciandeform_poll; ot->invoke = laplaciandeform_bind_invoke; ot->exec = laplaciandeform_bind_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); |