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:
Diffstat (limited to 'source/blender/editors/object/object_modifier.c')
-rw-r--r--source/blender/editors/object/object_modifier.c275
1 files changed, 138 insertions, 137 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 96d82d51e3f..1b9af3725ca 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -63,6 +63,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_modifier.h"
#include "BKE_multires.h"
#include "BKE_report.h"
@@ -100,7 +101,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);
@@ -113,23 +114,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
@@ -142,7 +143,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) {
@@ -153,7 +154,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) {
@@ -468,14 +469,14 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
/* add new mesh */
obn = BKE_object_add(bmain, scene, view_layer, 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;
@@ -550,18 +551,18 @@ static int modifier_apply_shape(ReportList *reports, Depsgraph *depsgraph, Scene
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;
}
-
+
mesh_applied = BKE_mesh_create_derived_for_modifier(depsgraph, scene, ob, md, 0);
if (!mesh_applied) {
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;
@@ -572,8 +573,8 @@ static int modifier_apply_shape(ReportList *reports, Depsgraph *depsgraph, Scene
}
kb = BKE_keyblock_add(key, md->name);
- BKE_nomain_mesh_to_meshkey(mesh_applied, me, kb);
-
+ BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb);
+
BKE_id_free(NULL, mesh_applied);
}
else {
@@ -621,7 +622,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
return 0;
}
- BKE_nomain_mesh_to_mesh(mesh_applied, me, ob, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, CD_MASK_MESH, true);
if (md->type == eModifierType_Multires)
multires_customdata_delete(me);
@@ -660,7 +661,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
ParticleSystem *psys = ob->particlesystem.first;
for (; psys; psys = psys->next) {
-
+
if (psys->part->type != PART_HAIR)
continue;
@@ -724,7 +725,7 @@ int ED_object_modifier_apply(
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);
@@ -746,19 +747,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;
@@ -803,15 +804,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);
@@ -824,7 +825,7 @@ 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 (!ptr.data) {
CTX_wm_operator_poll_msg_set(C, "Context missing 'modifier'");
return 0;
@@ -838,7 +839,7 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers comming from static override");
return (((ModifierData *)ptr.data)->flag & eModifierFlag_StaticOverride_Local) != 0;
}
-
+
return 1;
}
@@ -855,7 +856,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;
}
@@ -876,9 +877,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;
@@ -894,7 +895,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;
@@ -928,7 +929,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);
@@ -946,7 +947,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -967,7 +968,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);
@@ -985,7 +986,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1006,7 +1007,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);
@@ -1028,7 +1029,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1055,10 +1056,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);
}
@@ -1072,13 +1073,13 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(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, view_layer, ob, md))
return OPERATOR_CANCELLED;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1099,7 +1100,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);
@@ -1117,7 +1118,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1138,7 +1139,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);
@@ -1155,18 +1156,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;
}
@@ -1187,7 +1188,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);
@@ -1199,10 +1200,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,
@@ -1216,7 +1217,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;
}
@@ -1237,7 +1238,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);
@@ -1302,14 +1303,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)
@@ -1325,15 +1326,15 @@ 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)
- BLI_path_rel(path, bmain->name);
+ BLI_path_rel(path, BKE_main_blendfile_path(bmain));
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;
}
@@ -1346,23 +1347,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;
@@ -1378,7 +1379,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;
@@ -1400,7 +1401,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;
}
@@ -1412,7 +1413,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;
}
@@ -1422,15 +1423,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);
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1452,7 +1453,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);
@@ -1465,7 +1466,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
@@ -1488,7 +1489,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);
@@ -1536,7 +1537,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1548,7 +1549,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;
}
@@ -1591,7 +1592,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1609,7 +1610,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;
@@ -1641,7 +1642,7 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1653,7 +1654,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;
}
@@ -1697,7 +1698,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,
@@ -1730,7 +1731,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
CD_CALLOC,
NULL,
me->totvert);
-
+
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, NULL);
BKE_object_transform_copy(arm_ob, skin_ob);
@@ -1764,7 +1765,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
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,
@@ -1781,7 +1782,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
MEM_freeN(emap);
MEM_freeN(emap_mem);
- ED_armature_from_edit(arm);
+ ED_armature_from_edit(bmain, arm);
ED_armature_edit_free(arm);
return arm_ob;
@@ -1839,7 +1840,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);
@@ -1925,7 +1926,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform);
-
+
if (!mmd)
return OPERATOR_CANCELLED;
@@ -1950,7 +1951,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
mmd->totvert = 0;
mmd->totcagevert = 0;
mmd->totinfluence = 0;
-
+
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
}
@@ -1979,7 +1980,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
mmd->bindfunc = NULL;
mmd->modifier.mode = mode;
}
-
+
return OPERATOR_FINISHED;
}
@@ -1987,7 +1988,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;
}
@@ -1997,12 +1998,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);
@@ -2019,7 +2020,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;
@@ -2027,7 +2028,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -2049,7 +2050,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);
@@ -2067,14 +2068,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,
@@ -2104,8 +2105,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);
@@ -2115,10 +2116,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;
}
@@ -2126,15 +2127,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;
}
@@ -2142,12 +2143,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;
}
@@ -2162,13 +2163,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;
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -2179,11 +2180,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:
@@ -2194,41 +2195,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);
-
- /* 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(CTX_data_depsgraph(C), 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;
-
+
DEG_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);
@@ -2236,15 +2237,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;
}
@@ -2262,15 +2263,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");
}
@@ -2329,7 +2330,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;
}
@@ -2339,12 +2340,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);