diff options
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_boolean.c | 56 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshdeform.c | 37 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_multires.c | 15 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_particlesystem.c | 2 |
5 files changed, 68 insertions, 46 deletions
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index cf87e3598b6..d2ac9dc85de 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -171,6 +171,10 @@ if(WITH_CYCLES) add_definitions(-DWITH_CYCLES) endif() +if(WITH_GMP) + add_definitions(-DWITH_GMP) +endif() + # So we can have special tricks in modifier system. add_definitions(${GL_DEFINITIONS}) diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 08fd7fb229d..37c3f32f529 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -62,6 +62,7 @@ #include "bmesh.h" #include "bmesh_tools.h" +#include "tools/bmesh_boolean.h" #include "tools/bmesh_intersect.h" #ifdef DEBUG_TIME @@ -75,6 +76,11 @@ static void initData(ModifierData *md) bmd->double_threshold = 1e-6f; bmd->operation = eBooleanModifierOp_Difference; +#ifdef WITH_GMP + bmd->solver = eBooleanModifierSolver_Exact; +#else + bmd->solver = eBooleanModifierSolver_Fast; +#endif } static bool isDisabled(const struct Scene *UNUSED(scene), @@ -315,19 +321,33 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * 0; } - BM_mesh_intersect(bm, - looptris, - tottri, - bm_face_isect_pair, - NULL, - false, - use_separate, - use_dissolve, - use_island_connect, - false, - false, - bmd->operation, - bmd->double_threshold); +#ifdef WITH_GMP + bool use_exact = bmd->solver == eBooleanModifierSolver_Exact; +#else + if (bmd->solver == eBooleanModifierSolver_Exact) { + BKE_modifier_set_error(md, "Compiled without GMP, using fast solver"); + } + bool use_exact = false; +#endif + + if (use_exact) { + BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, false, bmd->operation); + } + else { + BM_mesh_intersect(bm, + looptris, + tottri, + bm_face_isect_pair, + NULL, + false, + use_separate, + use_dissolve, + use_island_connect, + false, + false, + bmd->operation, + bmd->double_threshold); + } MEM_freeN(looptris); } @@ -373,8 +393,14 @@ static void panel_draw(const bContext *C, Panel *panel) uiLayoutSetPropSep(layout, true); + const bool use_exact = RNA_enum_get(&ptr, "solver") == eBooleanModifierSolver_Exact; + uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE); - uiItemR(layout, &ptr, "double_threshold", 0, NULL, ICON_NONE); + uiItemR(layout, &ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + + if (!use_exact) { + uiItemR(layout, &ptr, "double_threshold", 0, NULL, ICON_NONE); + } if (G.debug) { uiLayout *col = uiLayoutColumn(layout, true); @@ -394,7 +420,7 @@ ModifierTypeInfo modifierType_Boolean = { /* structName */ "BooleanModifierData", /* structSize */ sizeof(BooleanModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh, + /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode, /* copyData */ BKE_modifier_copydata_generic, diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index ae031bffb04..4dee70608f8 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -37,7 +37,6 @@ #include "BKE_context.h" #include "BKE_deform.h" #include "BKE_editmesh.h" -#include "BKE_global.h" #include "BKE_lib_id.h" #include "BKE_lib_query.h" #include "BKE_mesh.h" @@ -332,12 +331,7 @@ static void meshdeform_vert_task(void *__restrict userdata, if (totweight > 0.0f) { mul_v3_fl(co, fac / totweight); mul_m3_v3(data->icagemat, co); - if (G.debug_value != 527) { - add_v3_v3(vertexCos[iter], co); - } - else { - copy_v3_v3(vertexCos[iter], co); - } + add_v3_v3(vertexCos[iter], co); } } @@ -353,9 +347,8 @@ static void meshdeformModifier_do(ModifierData *md, Mesh *cagemesh; MDeformVert *dvert = NULL; float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; - float co[3], (*dco)[3] = NULL, (*bindcagecos)[3]; + float(*dco)[3] = NULL, (*bindcagecos)[3]; int a, totvert, totcagevert, defgrp_index; - float(*cagecos)[3] = NULL; MeshdeformUserdata data; static int recursive_bind_sentinel = 0; @@ -406,7 +399,7 @@ static void meshdeformModifier_do(ModifierData *md, /* verify we have compatible weights */ totvert = numVerts; - totcagevert = cagemesh->totvert; + totcagevert = BKE_mesh_wrapper_vert_len(cagemesh); if (mmd->totvert != totvert) { BKE_modifier_set_error(md, "Vertices changed from %d to %d", mmd->totvert, totvert); @@ -422,27 +415,22 @@ static void meshdeformModifier_do(ModifierData *md, goto finally; } - /* setup deformation data */ - cagecos = BKE_mesh_vert_coords_alloc(cagemesh, NULL); - bindcagecos = (float(*)[3])mmd->bindcagecos; - /* We allocate 1 element extra to make it possible to * load the values to SSE registers, which are float4. */ dco = MEM_calloc_arrayN((totcagevert + 1), sizeof(*dco), "MDefDco"); zero_v3(dco[totcagevert]); + + /* setup deformation data */ + BKE_mesh_wrapper_vert_coords_copy(cagemesh, dco, totcagevert); + bindcagecos = (float(*)[3])mmd->bindcagecos; + for (a = 0; a < totcagevert; a++) { /* get cage vertex in world space with binding transform */ - copy_v3_v3(co, cagecos[a]); - - if (G.debug_value != 527) { - mul_m4_v3(mmd->bindmat, co); - /* compute difference with world space bind coord */ - sub_v3_v3v3(dco[a], co, bindcagecos[a]); - } - else { - copy_v3_v3(dco[a], co); - } + float co[3]; + mul_v3_m4v3(co, mmd->bindmat, dco[a]); + /* compute difference with world space bind coord */ + sub_v3_v3v3(dco[a], co, bindcagecos[a]); } MOD_get_vgroup(ob, mesh, mmd->defgrp_name, &dvert, &defgrp_index); @@ -464,7 +452,6 @@ static void meshdeformModifier_do(ModifierData *md, finally: MEM_SAFE_FREE(dco); - MEM_SAFE_FREE(cagecos); } static void deformVerts(ModifierData *md, diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 98a348bfbfc..9ced297bb48 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -238,7 +238,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Needed when rendering or baking will in sculpt mode. */ const bool for_render = (ctx->flag & MOD_APPLY_RENDER) != 0; - if ((ctx->object->mode & OB_MODE_SCULPT) && !for_orco && !for_render) { + const bool sculpt_base_mesh = mmd->flags & eMultiresModifierFlag_UseSculptBaseMesh; + + if ((ctx->object->mode & OB_MODE_SCULPT) && !for_orco && !for_render && !sculpt_base_mesh) { /* NOTE: CCG takes ownership over Subdiv. */ result = multires_as_ccg(mmd, ctx, mesh, subdiv); result->runtime.subdiv_ccg_tot_level = mmd->totlvl; @@ -341,6 +343,12 @@ static void panel_draw(const bContext *C, Panel *panel) uiItemR(col, &ptr, "sculpt_levels", 0, IFACE_("Sculpt"), ICON_NONE); uiItemR(col, &ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE); + const bool is_sculpt_mode = CTX_data_active_object(C)->mode & OB_MODE_SCULPT; + uiBlock *block = uiLayoutGetBlock(panel->layout); + UI_block_lock_set(block, !is_sculpt_mode, IFACE_("Sculpt Base Mesh")); + uiItemR(col, &ptr, "use_sculpt_base_mesh", 0, IFACE_("Sculpt Base Mesh"), ICON_NONE); + UI_block_lock_clear(block); + uiItemR(layout, &ptr, "show_only_control_edges", 0, NULL, ICON_NONE); modifier_panel_end(layout, &ptr); @@ -407,10 +415,7 @@ static void subdivisions_panel_draw(const bContext *C, Panel *panel) uiItemS(layout); uiItemO(layout, IFACE_("Unsubdivide"), ICON_NONE, "OBJECT_OT_multires_unsubdivide"); - - row = uiLayoutRow(layout, false); - uiItemL(row, "", ICON_NONE); - uiItemO(row, IFACE_("Delete Higher"), ICON_NONE, "OBJECT_OT_multires_higher_levels_delete"); + uiItemO(layout, IFACE_("Delete Higher"), ICON_NONE, "OBJECT_OT_multires_higher_levels_delete"); } static void shape_panel_draw(const bContext *C, Panel *panel) diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index ea0c63da1b0..4ef1b19dc64 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -219,7 +219,7 @@ static void deformVerts(ModifierData *md, psmd->totdmedge = psmd->mesh_final->totedge; psmd->totdmface = psmd->mesh_final->totface; - if (!(ctx->object->transflag & OB_NO_PSYS_UPDATE)) { + { struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); psmd->flag &= ~eParticleSystemFlag_psys_updated; particle_system_update( |