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:
authorYiming Wu <xp8110@outlook.com>2019-03-08 14:12:37 +0300
committerYiming Wu <xp8110@outlook.com>2019-03-08 14:12:37 +0300
commit26fc7ef55f1584bcf9fd262419f1a3f540c186af (patch)
tree5dc5c93434683a8f211ae5e852ac18c793bc0510 /source/blender/modifiers
parent0ed55524f150003a0121c4e7e5f5c26c52184e00 (diff)
parentcf09a2443cef60cda28c2c2023cb84728e644081 (diff)
Merge branch 'master' into soc-2018-npr
# Conflicts: # release/datafiles/locale # release/scripts/addons # release/scripts/addons_contrib # source/blender/draw/intern/DRW_render.h # source/blender/makesdna/DNA_light_types.h # source/blender/makesdna/DNA_scene_types.h # source/blender/makesrna/intern/rna_scene.c # source/tools
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/CMakeLists.txt8
-rw-r--r--source/blender/modifiers/MOD_modifiertypes.h10
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c30
-rw-r--r--source/blender/modifiers/intern/MOD_array.c32
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c73
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c63
-rw-r--r--source/blender/modifiers/intern/MOD_build.c20
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c34
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c49
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c33
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c28
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c30
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c38
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c40
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c43
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c26
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c37
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c40
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c19
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c31
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.h16
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c40
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c29
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c34
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c30
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c23
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache.c23
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_mdd.c16
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_pc2.c16
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_util.c11
-rw-r--r--source/blender/modifiers/intern/MOD_meshcache_util.h10
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c41
-rw-r--r--source/blender/modifiers/intern/MOD_meshsequencecache.c15
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c84
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c78
-rw-r--r--source/blender/modifiers/intern/MOD_none.c16
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c46
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c47
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c32
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c62
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c14
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c30
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c19
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c43
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c34
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c33
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c31
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c33
-rw-r--r--source/blender/modifiers/intern/MOD_softbody.c19
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c138
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c49
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c59
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c77
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c50
-rw-r--r--source/blender/modifiers/intern/MOD_util.c33
-rw-r--r--source/blender/modifiers/intern/MOD_util.h10
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c36
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c40
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c34
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c38
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c40
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c14
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.h15
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c32
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c35
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c37
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c31
67 files changed, 916 insertions, 1461 deletions
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index a17ea929ef8..89b2114bcb4 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -16,12 +16,6 @@
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain
-# Ben Batt
-#
# ***** END GPL LICENSE BLOCK *****
set(INC
@@ -97,8 +91,8 @@ set(SRC
intern/MOD_surfacedeform.c
intern/MOD_triangulate.c
intern/MOD_util.c
- intern/MOD_uvwarp.c
intern/MOD_uvproject.c
+ intern/MOD_uvwarp.c
intern/MOD_warp.c
intern/MOD_wave.c
intern/MOD_weighted_normal.c
diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h
index 42eb9db3a8f..687bc2c2db6 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,14 +12,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Ben Batt
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file MOD_modifiertypes.h
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#ifndef __MOD_MODIFIERTYPES_H__
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index fcd54639f9f..4a474dde585 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,31 +15,21 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_armature.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
+#include "BLI_utildefines.h"
+
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
-#include "BLI_utildefines.h"
-#include "BLI_string.h"
-
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -77,14 +65,10 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
tamd->prevCos = NULL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = 0;
-
/* ask for vertexgroups */
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -110,7 +94,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_EVAL_POSE, "Armature Modifier");
DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier");
}
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Armature Modifier");
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index d14d8f2288e..56567c79c6a 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,20 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton,
- * Patrice Bertrand
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_array.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*
* Array modifier: duplicates the object multiple times along an axis.
*/
#include "MEM_guardedalloc.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
#include "DNA_curve_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -108,7 +97,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (amd->offset_ob != NULL) {
DEG_add_object_relation(ctx->node, amd->offset_ob, DEG_OB_COMP_TRANSFORM, "Array Modifier Offset");
}
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Array Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Array Modifier");
}
BLI_INLINE float sum_v3(const float v[3])
@@ -372,7 +361,6 @@ static Mesh *arrayModifier_doArray(
int first_chunk_start, first_chunk_nverts, last_chunk_start, last_chunk_nverts;
Mesh *result, *start_cap_mesh = NULL, *end_cap_mesh = NULL;
- bool start_cap_mesh_free, end_cap_mesh_free;
int *vgroup_start_cap_remap = NULL;
int vgroup_start_cap_remap_len = 0;
@@ -391,7 +379,7 @@ static Mesh *arrayModifier_doArray(
vgroup_start_cap_remap = BKE_object_defgroup_index_map_create(
start_cap_ob, ctx->object, &vgroup_start_cap_remap_len);
- start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(start_cap_ob, &start_cap_mesh_free);
+ start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(start_cap_ob, false);
if (start_cap_mesh) {
start_cap_nverts = start_cap_mesh->totvert;
start_cap_nedges = start_cap_mesh->totedge;
@@ -404,7 +392,7 @@ static Mesh *arrayModifier_doArray(
vgroup_end_cap_remap = BKE_object_defgroup_index_map_create(
end_cap_ob, ctx->object, &vgroup_end_cap_remap_len);
- end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(end_cap_ob, &end_cap_mesh_free);
+ end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(end_cap_ob, false);
if (end_cap_mesh) {
end_cap_nverts = end_cap_mesh->totvert;
end_cap_nedges = end_cap_mesh->totedge;
@@ -740,12 +728,6 @@ static Mesh *arrayModifier_doArray(
if (vgroup_end_cap_remap) {
MEM_freeN(vgroup_end_cap_remap);
}
- if (start_cap_mesh != NULL && start_cap_mesh_free) {
- BKE_id_free(NULL, start_cap_mesh);
- }
- if (end_cap_mesh != NULL && end_cap_mesh_free) {
- BKE_id_free(NULL, end_cap_mesh);
- }
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index e63b5407a74..6e1dd9ed45d 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,33 +15,23 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_bevel.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_utildefines.h"
-#include "BLI_linklist_stack.h"
-#include "BLI_math.h"
-#include "BLI_string.h"
-
#include "BKE_deform.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
@@ -67,31 +55,28 @@ static void initData(ModifierData *md)
bmd->e_flags = 0;
bmd->edge_flags = 0;
bmd->face_str_mode = MOD_BEVEL_FACE_STRENGTH_NONE;
+ bmd->miter_inner = MOD_BEVEL_MITER_SHARP;
+ bmd->miter_outer = MOD_BEVEL_MITER_SHARP;
+ bmd->spread = 0.1f;
bmd->mat = -1;
bmd->profile = 0.5f;
bmd->bevel_angle = DEG2RADF(30.0f);
bmd->defgrp_name[0] = '\0';
- bmd->clnordata.faceHash = NULL;
}
-static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int UNUSED(flag))
+static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int flag)
{
- BevelModifierData *bmd_src = (BevelModifierData *)md_src;
- BevelModifierData *bmd_dst = (BevelModifierData *)md_dst;
-
- *bmd_dst = *bmd_src;
- bmd_dst->clnordata.faceHash = NULL;
+ modifier_copyData_generic(md_src, md_dst, flag);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
BevelModifierData *bmd = (BevelModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (bmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (bmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
/*
@@ -112,12 +97,16 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0;
const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK);
const int offset_type = bmd->val_flags;
+ const float value = bmd->value;
const int mat = CLAMPIS(bmd->mat, -1, ctx->object->totcol - 1);
const bool loop_slide = (bmd->flags & MOD_BEVEL_EVEN_WIDTHS) == 0;
const bool mark_seam = (bmd->edge_flags & MOD_BEVEL_MARK_SEAM);
const bool mark_sharp = (bmd->edge_flags & MOD_BEVEL_MARK_SHARP);
- const bool harden_normals = (bmd->flags & MOD_BEVEL_HARDEN_NORMALS);
+ bool harden_normals = (bmd->flags & MOD_BEVEL_HARDEN_NORMALS);
const int face_strength_mode = bmd->face_str_mode;
+ const int miter_outer = bmd->miter_outer;
+ const int miter_inner = bmd->miter_inner;
+ const float spread = bmd->spread;
bm = BKE_mesh_to_bmesh_ex(
mesh,
@@ -125,9 +114,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
&(struct BMeshFromMeshParams){
.calc_face_normal = true,
.add_key_index = false,
- .use_shapekey = true,
- .active_shapekey = ctx->object->shapenr,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .use_shapekey = false,
+ .active_shapekey = 0,
+ /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead (also for other modifiers cases)? */
+ .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX},
});
if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
@@ -187,21 +177,24 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
}
- BM_mesh_bevel(bm, bmd->value, offset_type, bmd->res, bmd->profile,
+ if (harden_normals && !(((Mesh *)ctx->object->data)->flag & ME_AUTOSMOOTH)) {
+ modifier_setError(md, "Enable 'Auto Smooth' option in mesh settings for hardening");
+ harden_normals = false;
+ }
+
+ BM_mesh_bevel(bm, value, offset_type, bmd->res, bmd->profile,
vertex_only, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp,
dvert, vgroup, mat, loop_slide, mark_seam, mark_sharp,
- harden_normals, face_strength_mode);
+ harden_normals, face_strength_mode,
+ miter_outer, miter_inner, spread, mesh->smoothresh);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BLI_assert(bm->vtoolflagpool == NULL &&
bm->etoolflagpool == NULL &&
bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */
BM_mesh_free(bm);
- if (bmd->clnordata.faceHash)
- BLI_ghash_free(bmd->clnordata.faceHash, NULL, NULL);
-
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
return result;
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 840cee6f630..a90ddde7946 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,45 +15,35 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_boolean.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
// #ifdef DEBUG_TIME
#include <stdio.h>
-#include "DNA_object_types.h"
-
#include "BLI_utildefines.h"
-#include "BLI_math_matrix.h"
-
-#include "BKE_library_query.h"
-#include "BKE_modifier.h"
-
-#include "MOD_util.h"
#include "BLI_alloca.h"
#include "BLI_math_geom.h"
+#include "BLI_math_matrix.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "BKE_global.h" /* only to check G.debug */
#include "BKE_library.h"
+#include "BKE_library_query.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
+#include "BKE_modifier.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
+
+#include "MOD_util.h"
#include "DEG_depsgraph_query.h"
@@ -75,6 +63,7 @@ static void initData(ModifierData *md)
BooleanModifierData *bmd = (BooleanModifierData *)md;
bmd->double_threshold = 1e-6f;
+ bmd->operation = eBooleanModifierOp_Difference;
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -101,7 +90,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, bmd->object, DEG_OB_COMP_GEOMETRY, "Boolean Modifier");
}
/* We need own transformation as well. */
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Boolean Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Boolean Modifier");
}
static Mesh *get_quick_mesh(
@@ -122,12 +111,7 @@ static Mesh *get_quick_mesh(
result = mesh_self;
}
else {
- BKE_id_copy_ex(NULL, &mesh_other->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, &mesh_other->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
float imat[4][4];
float omat[4][4];
@@ -174,14 +158,13 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
Mesh *result = mesh;
Mesh *mesh_other;
- bool mesh_other_free;
if (bmd->object == NULL) {
return result;
}
Object *other = DEG_get_evaluated_object(ctx->depsgraph, bmd->object);
- mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(other, &mesh_other_free);
+ mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(other, false);
if (mesh_other) {
Object *object = ctx->object;
@@ -318,7 +301,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
MEM_freeN(looptris);
}
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
@@ -335,20 +318,14 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
modifier_setError(md, "Cannot execute boolean operation");
}
- if (mesh_other != NULL && mesh_other_free) {
- BKE_id_free(NULL, mesh_other);
- }
-
return result;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = CD_MASK_MTFACE | CD_MASK_MEDGE;
-
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->emask |= CD_MASK_MEDGE;
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
}
ModifierTypeInfo modifierType_Boolean = {
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index 77f607d19a2..e46c9aca5ce 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,27 +15,19 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_build.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_rand.h"
-#include "BLI_math_vector.h"
+
#include "BLI_ghash.h"
+#include "BLI_math_vector.h"
+#include "BLI_rand.h"
#include "DNA_meshdata_types.h"
#include "DNA_mesh_types.h"
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 59ffe11d614..f408a22aadf 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,20 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_cast.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
+#include "BLI_utildefines.h"
#include "BLI_math.h"
-#include "BLI_utildefines.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "BKE_deform.h"
#include "BKE_editmesh.h"
@@ -77,15 +66,14 @@ static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool
return false;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
CastModifierData *cmd = (CastModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (cmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (cmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void foreachObjectLink(
@@ -102,7 +90,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
CastModifierData *cmd = (CastModifierData *)md;
if (cmd->object != NULL) {
DEG_add_object_relation(ctx->node, cmd->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Cast Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 636c465d304..41f35faac1b 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,23 +15,18 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_cloth.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
+#include "BLI_utildefines.h"
+
+#include "BLI_listbase.h"
+
#include "DNA_cloth_types.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
@@ -42,9 +35,6 @@
#include "MEM_guardedalloc.h"
-#include "BLI_listbase.h"
-#include "BLI_utildefines.h"
-
#include "BKE_cloth.h"
#include "BKE_effect.h"
#include "BKE_global.h"
@@ -98,13 +88,7 @@ static void deformVerts(
else {
/* Not possible to use get_mesh() in this case as we'll modify its vertices
* and get_mesh() would return 'mesh' directly. */
- BKE_id_copy_ex(
- NULL, (ID *)mesh, (ID **)&mesh_src,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&mesh_src, LIB_ID_COPY_LOCALIZE);
}
/* TODO(sergey): For now it actually duplicates logic from DerivedMesh.c
@@ -140,20 +124,20 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_collision_relations(ctx->node, ctx->object, clmd->coll_parms->group, eModifierType_Collision, NULL, "Cloth Collision");
DEG_add_forcefield_relations(ctx->node, ctx->object, clmd->sim_parms->effector_weights, true, 0, "Cloth Field");
}
+ DEG_add_modifier_to_transform_relation(ctx->node, "Cloth Modifier");
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = 0;
ClothModifierData *clmd = (ClothModifierData *)md;
- if (cloth_uses_vgroup(clmd))
- dataMask |= CD_MASK_MDEFORMVERT;
-
- if (clmd->sim_parms->shapekey_rest != 0)
- dataMask |= CD_MASK_CLOTH_ORCO;
+ if (cloth_uses_vgroup(clmd)) {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
- return dataMask;
+ if (clmd->sim_parms->shapekey_rest != 0) {
+ r_cddata_masks->vmask |= CD_MASK_CLOTH_ORCO;
+ }
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
@@ -201,8 +185,9 @@ static void freeData(ModifierData *md)
ClothModifierData *clmd = (ClothModifierData *) md;
if (clmd) {
- if (G.debug_value > 0)
+ if (G.debug & G_DEBUG_SIMDATA) {
printf("clothModifier_freeData\n");
+ }
cloth_free_modifier_extern(clmd);
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 011635e3012..3e1fa4954fa 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,30 +15,22 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_collision.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "MEM_guardedalloc.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "BKE_collision.h"
#include "BKE_global.h"
#include "BKE_library.h"
@@ -118,13 +108,7 @@ static void deformVerts(
else {
/* Not possible to use get_mesh() in this case as we'll modify its vertices
* and get_mesh() would return 'mesh' directly. */
- BKE_id_copy_ex(
- NULL, (ID *)mesh, (ID **)&mesh_src,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&mesh_src, LIB_ID_COPY_LOCALIZE);
}
if (!ob->pd) {
@@ -141,8 +125,9 @@ static void deformVerts(
current_time = DEG_get_ctime(ctx->depsgraph);
- if (G.debug_value > 0)
+ if (G.debug & G_DEBUG_SIMDATA) {
printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew);
+ }
mvert_num = mesh_src->totvert;
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index 79702517991..cc6177b9bc8 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,28 +15,23 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Jack Simpson,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_correctivesmooth.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*
* Method of smoothing deformation, also known as 'delta-mush'.
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_scene_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "MEM_guardedalloc.h"
#include "BKE_deform.h"
@@ -112,15 +105,14 @@ static void freeData(ModifierData *md)
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
- CustomDataMask dataMask = 0;
+
/* ask for vertex groups if we need them */
- if (csmd->defgrp_name[0]) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ if (csmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
- return dataMask;
}
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index fc33880e922..f3a5e280947 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,20 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_curve.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
+#include "BLI_utildefines.h"
+
#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -61,15 +50,14 @@ static void initData(ModifierData *md)
cmd->defaxis = MOD_CURVE_POSX;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
CurveModifierData *cmd = (CurveModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (cmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (cmd->name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
@@ -103,7 +91,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_special_eval_flag(ctx->node, &cmd->object->id, DAG_EVAL_NEED_CURVE_PATH);
}
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Curve Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Curve Modifier");
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index 6e823a8518a..3e461476eac 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,18 +15,14 @@
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): None yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_datatransfer.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "BLI_utildefines.h"
+
#include "BLI_math.h"
#include "DNA_mesh_types.h"
@@ -81,19 +75,16 @@ static void initData(ModifierData *md)
dtmd->flags = MOD_DATATRANSFER_OBSRC_TRANSFORM;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
- CustomDataMask dataMask = 0;
- if (dtmd->defgrp_name[0]) {
+ if (dtmd->defgrp_name[0] != '\0') {
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
- dataMask |= BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
-
- return dataMask;
+ BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types, r_cddata_masks);
}
static bool dependsOnNormals(ModifierData *md)
@@ -129,14 +120,15 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
if (dtmd->ob_source != NULL) {
- CustomDataMask mask = BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
+ CustomData_MeshMasks cddata_masks = {0};
+ BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types, &cddata_masks);
DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, "DataTransfer Modifier");
- DEG_add_customdata_mask(ctx->node, dtmd->ob_source, mask);
+ DEG_add_customdata_mask(ctx->node, dtmd->ob_source, &cddata_masks);
if (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) {
DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_TRANSFORM, "DataTransfer Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "DataTransfer Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "DataTransfer Modifier");
}
}
}
@@ -184,13 +176,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
{
/* We need to duplicate data here, otherwise setting custom normals, edges' shaprness, etc., could
* modify org mesh, see T43671. */
- BKE_id_copy_ex(
- NULL, &me_mod->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, &me_mod->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
}
BKE_reports_init(&reports, RPT_STORE);
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index fff94e0d836..0ca6111c41a 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,33 +15,24 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_decimate.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "MEM_guardedalloc.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
-#include "BKE_library.h"
#include "DEG_depsgraph_query.h"
@@ -68,17 +57,14 @@ static void initData(ModifierData *md)
dmd->defgrp_factor = 1.0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DecimateModifierData *dmd = (DecimateModifierData *) md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (dmd->defgrp_name[0] && (dmd->defgrp_factor > 0.0f)) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ if (dmd->defgrp_name[0] != '\0' && (dmd->defgrp_factor > 0.0f)) {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
-
- return dataMask;
}
static DecimateModifierData *getOriginalModifierData(
@@ -89,8 +75,10 @@ static DecimateModifierData *getOriginalModifierData(
}
static void updateFaceCount(
- const ModifierEvalContext *ctx, const DecimateModifierData *dmd, int face_count)
+ const ModifierEvalContext *ctx, DecimateModifierData *dmd, int face_count)
{
+ dmd->face_count = face_count;
+
if (DEG_is_active(ctx->depsgraph)) {
/* update for display only */
DecimateModifierData *dmd_orig = getOriginalModifierData(dmd, ctx);
@@ -175,7 +163,7 @@ static Mesh *applyModifier(
&(struct BMeshCreateParams){0},
&(struct BMeshFromMeshParams){
.calc_face_normal = calc_face_normal,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX},
});
switch (dmd->mode) {
@@ -208,7 +196,7 @@ static Mesh *applyModifier(
updateFaceCount(ctx, dmd, bm->totface);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BLI_assert(bm->vtoolflagpool == NULL &&
bm->etoolflagpool == NULL &&
bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 7cad6af6d34..87b25982d81 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,30 +15,22 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_displace.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-
#include "BLI_utildefines.h"
+
#include "BLI_math.h"
#include "BLI_task.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
@@ -75,22 +65,23 @@ static void initData(ModifierData *md)
dmd->space = MOD_DISP_SPACE_LOCAL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DisplaceModifierData *dmd = (DisplaceModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (dmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
+ if (dmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
/* ask for UV coordinates if we need them */
- if (dmd->texmapping == MOD_DISP_MAP_UV) dataMask |= CD_MASK_MTFACE;
+ if (dmd->texmapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
if (dmd->direction == MOD_DISP_DIR_CLNOR) {
- dataMask |= CD_MASK_CUSTOMLOOPNORMAL;
+ r_cddata_masks->lmask |= CD_MASK_CUSTOMLOOPNORMAL;
}
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
@@ -148,14 +139,14 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
DisplaceModifierData *dmd = (DisplaceModifierData *)md;
if (dmd->map_object != NULL && dmd->texmapping == MOD_DISP_MAP_OBJECT) {
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier");
DEG_add_object_relation(ctx->node, dmd->map_object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
}
if (dmd->texmapping == MOD_DISP_MAP_GLOBAL ||
(ELEM(dmd->direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ) &&
dmd->space == MOD_DISP_SPACE_GLOBAL))
{
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Displace Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier");
}
if (dmd->texture != NULL) {
DEG_add_generic_id_relation(ctx->node, &dmd->texture->id, "Displace Modifier");
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index c23a65ec23c..b84e46e145c 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,30 +12,24 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Miika Hämäläinen
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_dynamicpaint.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stddef.h>
+#include "BLI_utildefines.h"
+
#include "DNA_dynamicpaint_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force_types.h"
#include "DNA_scene_types.h"
#include "DNA_mesh_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_dynamicpaint.h"
#include "BKE_layer.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
@@ -72,10 +64,9 @@ static void freeData(ModifierData *md)
dynamicPaint_Modifier_free(pmd);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- CustomDataMask dataMask = 0;
if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
@@ -84,21 +75,20 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ ||
surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE)
{
- dataMask |= CD_MASK_MLOOPUV;
+ r_cddata_masks->lmask |= CD_MASK_MLOOPUV;
}
/* mcol */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT ||
surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR)
{
- dataMask |= CD_MASK_MLOOPCOL;
+ r_cddata_masks->lmask |= CD_MASK_MLOOPCOL;
}
/* CD_MDEFORMVERT */
if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
}
}
- return dataMask;
}
static Mesh *applyModifier(
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 8db8da3fc81..a7b980494b3 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,19 +15,10 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_edgesplit.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*
* EdgeSplit modifier
*
@@ -38,21 +27,21 @@
*/
#include "BLI_utildefines.h"
+
#include "BLI_math.h"
-#include "BKE_library.h"
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "bmesh.h"
#include "bmesh_tools.h"
-#include "DNA_mesh_types.h"
-#include "DNA_object_types.h"
-
#include "MOD_modifiertypes.h"
-static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierEvalContext *ctx)
+static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd)
{
Mesh *result;
BMesh *bm;
@@ -69,9 +58,9 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierE
&(struct BMeshFromMeshParams){
.calc_face_normal = calc_face_normals,
.add_key_index = false,
- .use_shapekey = true,
- .active_shapekey = ctx->object->shapenr,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .use_shapekey = false,
+ .active_shapekey = 0,
+ .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX},
});
if (do_split_angle) {
@@ -111,7 +100,7 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierE
/* BM_mesh_validate(bm); */ /* for troubleshooting */
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
@@ -129,7 +118,7 @@ static void initData(ModifierData *md)
static Mesh *applyModifier(
ModifierData *md,
- const ModifierEvalContext *ctx,
+ const ModifierEvalContext *UNUSED(ctx),
Mesh *mesh)
{
Mesh *result;
@@ -138,7 +127,7 @@ static Mesh *applyModifier(
if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)))
return mesh;
- result = doEdgeSplit(mesh, emd, ctx);
+ result = doEdgeSplit(mesh, emd);
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index f736e44a4cf..3a0449a4e52 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,33 +15,25 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_explode.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_edgehash.h"
+#include "BLI_kdtree.h"
+#include "BLI_math.h"
+#include "BLI_rand.h"
+
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
-#include "BLI_utildefines.h"
-#include "BLI_kdtree.h"
-#include "BLI_rand.h"
-#include "BLI_math.h"
-#include "BLI_edgehash.h"
-
#include "BKE_deform.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -86,15 +76,13 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
{
return true;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ExplodeModifierData *emd = (ExplodeModifierData *) md;
- CustomDataMask dataMask = 0;
-
- if (emd->vgroup)
- dataMask |= CD_MASK_MDEFORMVERT;
- return dataMask;
+ if (emd->vgroup) {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void createFacepa(
@@ -214,7 +202,7 @@ static const short add_faces[24] = {
0,
0, 0, 2, 0, 1, 2, 2, 0, 2, 1,
2, 2, 2, 2, 3, 0, 0, 0, 1, 0,
- 1, 1, 2
+ 1, 1, 2,
};
static MFace *get_dface(Mesh *mesh, Mesh *split, int cur, int i, MFace *mf)
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index 8b6f25ab0ab..d4bac71f677 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,20 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_fluidsim.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
#include "DNA_mesh_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_fluidsim_types.h"
#include "DNA_object_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_layer.h"
#include "BKE_modifier.h"
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 23a62f88f77..f548eb78abd 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,42 +15,35 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_fluidsim_util.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stddef.h>
#include <zlib.h>
+#include "BLI_utildefines.h"
+
+#ifdef WITH_MOD_FLUID
+# include "BLI_blenlib.h"
+# include "BLI_math.h"
+#endif
+
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_fluidsim_types.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "BKE_fluidsim.h" /* ensure definitions here match */
+#include "BKE_mesh.h"
#ifdef WITH_MOD_FLUID
# include "BKE_global.h"
+# include "BKE_library.h"
#endif
-#include "BKE_library.h"
-#include "BKE_main.h"
-#include "BKE_mesh.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.h b/source/blender/modifiers/intern/MOD_fluidsim_util.h
index 4bb745fbd66..7673ec7f6b0 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.h
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.h
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,27 +15,21 @@
*
* The Original Code is Copyright (C) Blender Foundation
* All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_fluidsim_util.h
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#ifndef __MOD_FLUIDSIM_UTIL_H__
#define __MOD_FLUIDSIM_UTIL_H__
-struct Object;
-struct Scene;
struct FluidsimModifierData;
struct Mesh;
struct ModifierEvalContext;
+struct Object;
+struct Scene;
/* new fluid-modifier interface */
void fluidsim_init(struct FluidsimModifierData *fluidmd);
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 24400b5a309..e911dbc4b5a 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,21 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_hook.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "BKE_action.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
@@ -77,16 +67,20 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
thmd->indexar = MEM_dupallocN(hmd->indexar);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
HookModifierData *hmd = (HookModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (hmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
- if (hmd->indexar) dataMask |= CD_MASK_ORIGINDEX;
-
- return dataMask;
+ if (hmd->name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
+ if (hmd->indexar != NULL) {
+ /* TODO check which origindex are actually needed? */
+ r_cddata_masks->vmask |= CD_MASK_ORIGINDEX;
+ r_cddata_masks->emask |= CD_MASK_ORIGINDEX;
+ r_cddata_masks->pmask |= CD_MASK_ORIGINDEX;
+ }
}
static void freeData(ModifierData *md)
@@ -124,7 +118,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, hmd->object, DEG_OB_COMP_TRANSFORM, "Hook Modifier");
}
/* We need own transformation as well. */
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Hook Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Hook Modifier");
}
struct HookData_cb {
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index ba45e6bf848..db76b0fd0c2 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,24 +15,23 @@
*
* The Original Code is Copyright (C) 2013 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Alexander Pinzon Fernandez
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_laplaciandeform.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "BLI_utildefines.h"
-#include "BLI_utildefines_stack.h"
+
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_utildefines_stack.h"
#include "MEM_guardedalloc.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
#include "BKE_deform.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
@@ -42,9 +39,6 @@
#include "BKE_mesh_runtime.h"
#include "BKE_particle.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
#include "MOD_util.h"
#include "eigen_capi.h"
@@ -722,12 +716,13 @@ static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool
return 1;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
- CustomDataMask dataMask = 0;
- if (lmd->anchor_grp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
- return dataMask;
+
+ if (lmd->anchor_grp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index 1acec1d8b7a..a6670f313ce 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,25 +15,21 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Alexander Pinzon
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_laplaciansmooth.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "MEM_guardedalloc.h"
#include "BKE_deform.h"
@@ -48,11 +42,6 @@
#include "eigen_capi.h"
-#if 0
-#define MOD_LAPLACIANSMOOTH_MAX_EDGE_PERCENTAGE 1.8f
-#define MOD_LAPLACIANSMOOTH_MIN_EDGE_PERCENTAGE 0.02f
-#endif
-
struct BLaplacianSystem {
float *eweights; /* Length weights per Edge */
float (*fweights)[3]; /* Cotangent weights per face */
@@ -80,7 +69,7 @@ struct BLaplacianSystem {
};
typedef struct BLaplacianSystem LaplacianSystem;
-static CustomDataMask required_data_mask(Object *ob, ModifierData *md);
+static void required_data_mask(Object *ob, ModifierData *md, CustomData_MeshMasks *r_cddata_masks);
static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, bool useRenderParams);
static float compute_volume(const float center[3], float (*vertexCos)[3], const MPoly *mpoly, int numPolys, const MLoop *mloop);
static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numPolys, int a_numLoops, int a_numVerts);
@@ -487,15 +476,14 @@ static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, boo
return 0;
}
-static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md)
+static void required_data_mask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 9fbd4629629..46a9c4f0a47 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,28 +15,19 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_lattice.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
-#include "DNA_object_types.h"
-
#include "BLI_utildefines.h"
+#include "DNA_object_types.h"
+
#include "BKE_editmesh.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
@@ -58,15 +47,14 @@ static void initData(ModifierData *md)
lmd->strength = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
LatticeModifierData *lmd = (LatticeModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (lmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (lmd->name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
@@ -92,7 +80,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_GEOMETRY, "Lattice Modifier");
DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_TRANSFORM, "Lattice Modifier");
}
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Lattice Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Lattice Modifier");
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 555fe29978f..6d8317ffe77 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,25 +15,17 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_mask.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+
#include "BLI_listbase.h"
#include "BLI_ghash.h"
@@ -47,7 +37,6 @@
#include "BKE_action.h" /* BKE_pose_channel_find_name */
#include "BKE_customdata.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
@@ -60,9 +49,9 @@
#include "BLI_strict_flags.h"
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- return CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
static void foreachObjectLink(
@@ -82,7 +71,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
/* TODO(sergey): Is it a proper relation here? */
DEG_add_object_relation(ctx->node, mmd->ob_arm, DEG_OB_COMP_TRANSFORM, "Mask Modifier");
arm->flag |= ARM_HAS_VIZ_DEPS;
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Mask Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Mask Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c
index e3aa239a713..0ecd56372c7 100644
--- a/source/blender/modifiers/intern/MOD_meshcache.c
+++ b/source/blender/modifiers/intern/MOD_meshcache.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,30 +12,25 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_meshcache.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stdio.h>
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "BLI_utildefines.h"
-#include "BLI_string.h"
-#include "BLI_path_util.h"
-#include "BLI_math.h"
-
-#include "BKE_global.h"
-#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_scene.h"
diff --git a/source/blender/modifiers/intern/MOD_meshcache_mdd.c b/source/blender/modifiers/intern/MOD_meshcache_mdd.c
index f0278c409e5..bd99248eec4 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_mdd.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_mdd.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,22 +12,18 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton, pkowal
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_meshcache_mdd.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
+
#include "BLI_fileops.h"
#include "BLI_math.h"
#ifdef __LITTLE_ENDIAN__
@@ -39,10 +33,10 @@
# include "BLI_winstuff.h"
#endif
-#include "MOD_meshcache_util.h" /* own include */
-
#include "DNA_modifier_types.h"
+#include "MOD_meshcache_util.h" /* own include */
+
typedef struct MDDHead {
int frame_tot;
int verts_tot;
diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
index 3503ce3ef7a..e19a967cca7 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,22 +12,18 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_meshcache_pc2.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
+
#include "BLI_fileops.h"
#ifdef __BIG_ENDIAN__
# include "BLI_endian_switch.h"
@@ -39,10 +33,10 @@
# include "BLI_winstuff.h"
#endif
-#include "MOD_meshcache_util.h" /* own include */
-
#include "DNA_modifier_types.h"
+#include "MOD_meshcache_util.h" /* own include */
+
typedef struct PC2Head {
char header[12]; /* 'POINTCACHE2\0' */
int file_version; /* unused - should be 1 */
diff --git a/source/blender/modifiers/intern/MOD_meshcache_util.c b/source/blender/modifiers/intern/MOD_meshcache_util.c
index f2e12e7749e..2db46af1188 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_util.c
+++ b/source/blender/modifiers/intern/MOD_meshcache_util.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,17 +12,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_meshcache_util.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "BLI_utildefines.h"
+
#include "BLI_math.h"
#include "DNA_modifier_types.h"
diff --git a/source/blender/modifiers/intern/MOD_meshcache_util.h b/source/blender/modifiers/intern/MOD_meshcache_util.h
index 8cf13037d78..a177ea467e7 100644
--- a/source/blender/modifiers/intern/MOD_meshcache_util.h
+++ b/source/blender/modifiers/intern/MOD_meshcache_util.h
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,14 +12,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_meshcache_util.h
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#ifndef __MOD_MESHCACHE_UTIL_H__
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index ae027c64626..e59a6ae9add 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,30 +15,22 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_meshdeform.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+#include "BLI_task.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_math.h"
-#include "BLI_task.h"
-#include "BLI_utildefines.h"
-
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
@@ -99,15 +89,14 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
if (mmd->bindcos) tmmd->bindcos = MEM_dupallocN(mmd->bindcos); /* deprecated */
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (mmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (mmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -291,7 +280,6 @@ static void meshdeformModifier_do(
int a, totvert, totcagevert, defgrp_index;
float (*cagecos)[3] = NULL;
MeshdeformUserdata data;
- bool free_cagemesh = false;
static int recursive_bind_sentinel = 0;
@@ -309,12 +297,12 @@ static void meshdeformModifier_do(
* We'll support this case once granular dependency graph is landed.
*/
Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, mmd->object);
- cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, &free_cagemesh);
+ cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false);
#if 0 /* This shall not be needed if we always get evaluated target object... */
if (cagemesh == NULL && mmd->bindcagecos == NULL && ob == DEG_get_original_object(ob)) {
/* Special case, binding happens outside of depsgraph evaluation, so we can build our own
* target mesh if needed. */
- cagemesh = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), mmd->object, 0);
+ cagemesh = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), mmd->object, &CD_MASK_BAREMESH);
free_cagemesh = cagemesh != NULL;
}
#endif
@@ -411,9 +399,6 @@ static void meshdeformModifier_do(
finally:
MEM_SAFE_FREE(dco);
MEM_SAFE_FREE(cagecos);
- if (cagemesh != NULL && free_cagemesh) {
- BKE_id_free(NULL, cagemesh);
- }
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c
index f0cdd2b2899..d17f343a1ec 100644
--- a/source/blender/modifiers/intern/MOD_meshsequencecache.c
+++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,14 +12,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_meshsequencecache.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "DNA_cachefile_types.h"
@@ -32,7 +26,6 @@
#include "DNA_scene_types.h"
#include "BKE_cachefile.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_scene.h"
@@ -44,6 +37,7 @@
#ifdef WITH_ALEMBIC
# include "ABC_alembic.h"
# include "BKE_global.h"
+# include "BKE_library.h"
#endif
static void initData(ModifierData *md)
@@ -128,8 +122,7 @@ static Mesh *applyModifier(
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ LIB_ID_COPY_NO_PREVIEW);
}
}
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index ae3f28ab764..c46445471df 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,28 +15,19 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_mirror.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_math.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h"
-
#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
@@ -78,24 +67,23 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
MirrorModifierData *mmd = (MirrorModifierData *)md;
if (mmd->mirror_ob != NULL) {
DEG_add_object_relation(ctx->node, mmd->mirror_ob, DEG_OB_COMP_TRANSFORM, "Mirror Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Mirror Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Mirror Modifier");
}
}
static Mesh *doBiscetOnMirrorPlane(
MirrorModifierData *mmd,
- Object *ob,
const Mesh *mesh,
- Object *mirror_ob,
int axis,
- float mirrormat[4][4])
+ float plane_co[3],
+ float plane_no[3])
{
bool do_bisect_flip_axis = (
(axis == 0 && mmd->flag & MOD_MIR_BISECT_FLIP_AXIS_X) ||
(axis == 1 && mmd->flag & MOD_MIR_BISECT_FLIP_AXIS_Y) ||
(axis == 2 && mmd->flag & MOD_MIR_BISECT_FLIP_AXIS_Z));
- const float bisect_distance = 0.001;
+ const float bisect_distance = 0.001f;
Mesh *result;
BMesh *bm;
@@ -103,28 +91,21 @@ static Mesh *doBiscetOnMirrorPlane(
BMVert *v, *v_next;
bm = BKE_mesh_to_bmesh_ex(
- mesh,
- &(struct BMeshCreateParams){0},
- &(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
- });
-
- /* prepare data for bisecting */
+ mesh,
+ &(struct BMeshCreateParams){0},
+ &(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX},
+ });
+
+ /* Define bisecting plane (aka mirror plane). */
float plane[4];
- float plane_co[3] = {0, 0, 0};
- float plane_no[3];
- copy_v3_v3(plane_no, mirrormat[axis]);
-
- if (mirror_ob != NULL) {
- float tmp[4][4];
- invert_m4_m4(tmp, ob->obmat);
- mul_m4_m4m4(tmp, tmp, mirror_ob->obmat);
-
- copy_v3_v3(plane_no, tmp[axis]);
- copy_v3_v3(plane_co, tmp[3]);
+ if (!do_bisect_flip_axis) {
+ /* That reversed condition is a tad weird, but for some reason that's how you keep
+ * the part of the mesh which is on the non-mirrored side when flip option is disabled,
+ * think that that is the expected behavior. */
+ negate_v3(plane_no);
}
-
plane_from_point_normal_v3(plane, plane_co, plane_no);
BM_mesh_bisect_plane(bm, plane, false, false, 0, 0, bisect_distance);
@@ -134,10 +115,6 @@ static Mesh *doBiscetOnMirrorPlane(
copy_v3_v3(plane_offset, plane);
plane_offset[3] = plane[3] - bisect_distance;
- if (do_bisect_flip_axis) {
- negate_v3(plane_offset);
- }
-
/* Delete verts across the mirror plane. */
BM_ITER_MESH_MUTABLE(v, v_next, &viter, bm, BM_VERTS_OF_MESH) {
if (plane_point_side_v3(plane_offset, v->co) > 0.0f) {
@@ -145,7 +122,7 @@ static Mesh *doBiscetOnMirrorPlane(
}
}
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
return result;
@@ -173,6 +150,7 @@ static Mesh *doMirrorOnAxis(
MLoop *ml;
MPoly *mp;
float mtx[4][4];
+ float plane_co[3], plane_no[3];
int i;
int a, totshape;
int *vtargetmap = NULL, *vtmap_a = NULL, *vtmap_b = NULL;
@@ -197,14 +175,22 @@ static Mesh *doMirrorOnAxis(
/* combine matrices to get a single matrix that translates coordinates into
* mirror-object-relative space, does the mirror, and translates back to
* origin-relative space */
- mul_m4_m4m4(mtx, mtx, tmp);
- mul_m4_m4m4(mtx, itmp, mtx);
- }
+ mul_m4_series(mtx, itmp, mtx, tmp);
+ if (do_bisect) {
+ copy_v3_v3(plane_co, itmp[3]);
+ copy_v3_v3(plane_no, itmp[axis]);
+ }
+ }
+ else if (do_bisect) {
+ copy_v3_v3(plane_co, mtx[3]);
+ /* Need to negate here, since that axis is inverted (for mirror transform). */
+ negate_v3_v3(plane_no, mtx[axis]);
+ }
Mesh *mesh_bisect = NULL;
if (do_bisect) {
- mesh_bisect = doBiscetOnMirrorPlane(mmd, ob, mesh, mirror_ob, axis, mtx);
+ mesh_bisect = doBiscetOnMirrorPlane(mmd, mesh, axis, plane_co, plane_no);
mesh = mesh_bisect;
}
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index fc8a376d2d7..7cd9dfa05aa 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,35 +15,26 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_multires.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stddef.h>
+#include "BLI_utildefines.h"
+
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_cdderivedmesh.h"
-#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BKE_modifier.h"
+#include "BKE_paint.h"
#include "BKE_subdiv.h"
#include "BKE_subdiv_ccg.h"
#include "BKE_subdiv_mesh.h"
@@ -67,6 +56,35 @@ static void initData(ModifierData *md)
mmd->quality = 3;
}
+static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int flag)
+{
+ MultiresModifierData *mmd_dst = (MultiresModifierData *)md_dst;
+
+ modifier_copyData_generic(md_src, md_dst, flag);
+
+ mmd_dst->subdiv = NULL;
+}
+
+static void freeData(ModifierData *md)
+{
+ MultiresModifierData *mmd = (MultiresModifierData *) md;
+ if (mmd->subdiv != NULL) {
+ BKE_subdiv_free(mmd->subdiv);
+ }
+}
+
+/* Main goal of this function is to give usable subdivision surface descriptor
+ * which matches settings and topology. */
+static Subdiv *subdiv_descriptor_ensure(MultiresModifierData *mmd,
+ const SubdivSettings *subdiv_settings,
+ const Mesh *mesh)
+{
+ Subdiv *subdiv = BKE_subdiv_update_from_mesh(
+ mmd->subdiv, subdiv_settings, mesh);
+ mmd->subdiv = subdiv;
+ return subdiv;
+}
+
/* Subdivide into fully qualified mesh. */
static Mesh *multires_as_mesh(MultiresModifierData *mmd,
@@ -137,28 +155,40 @@ static Mesh *applyModifier(ModifierData *md,
if (subdiv_settings.level == 0) {
return result;
}
- /* TODO(sergey): Try to re-use subdiv when possible. */
- Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, mesh);
+ BKE_subdiv_settings_validate_for_mesh(&subdiv_settings, mesh);
+ Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh);
if (subdiv == NULL) {
/* Happens on bad topology, ut also on empty input mesh. */
return result;
}
/* NOTE: Orco needs final coordinates on CPU side, which are expected to be
* accessible via MVert. For this reason we do not evaluate multires to
- * grids when orco is requested.
- */
+ * grids when orco is requested. */
const bool for_orco = (ctx->flag & MOD_APPLY_ORCO) != 0;
if ((ctx->object->mode & OB_MODE_SCULPT) && !for_orco) {
/* NOTE: CCG takes ownership over Subdiv. */
result = multires_as_ccg(mmd, ctx, mesh, subdiv);
result->runtime.subdiv_ccg_tot_level = mmd->totlvl;
+ /* TODO(sergey): Usually it is sculpt stroke's update variants which
+ * takes care of this, but is possible that we need this before the
+ * stroke: i.e. when exiting blender right after stroke is done.
+ * Annoying and not so much black-boxed as far as sculpting goes, and
+ * surely there is a better way of solving this. */
+ if (ctx->object->sculpt != NULL) {
+ ctx->object->sculpt->subdiv_ccg = result->runtime.subdiv_ccg;
+ }
+ /* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share
+ * this pointer. Not sure if it's needed, but might have a second look
+ * on the ownership model here. */
+ mmd->subdiv = NULL;
// BKE_subdiv_stats_print(&subdiv->stats);
}
else {
result = multires_as_mesh(mmd, ctx, mesh, subdiv);
- /* TODO(sergey): Cache subdiv somehow. */
// BKE_subdiv_stats_print(&subdiv->stats);
- BKE_subdiv_free(subdiv);
+ if (subdiv != mmd->subdiv) {
+ BKE_subdiv_free(subdiv);
+ }
}
return result;
}
@@ -172,7 +202,7 @@ ModifierTypeInfo modifierType_Multires = {
eModifierTypeFlag_SupportsMapping |
eModifierTypeFlag_RequiresOriginalData,
- /* copyData */ modifier_copyData_generic,
+ /* copyData */ copyData,
/* deformVerts_DM */ NULL,
/* deformMatrices_DM */ NULL,
@@ -188,7 +218,7 @@ ModifierTypeInfo modifierType_Multires = {
/* initData */ initData,
/* requiredDataMask */ NULL,
- /* freeData */ NULL,
+ /* freeData */ freeData,
/* isDisabled */ NULL,
/* updateDepsgraph */ NULL,
/* dependsOnTime */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c
index 3946782b5ef..781e52fc426 100644
--- a/source/blender/modifiers/intern/MOD_none.c
+++ b/source/blender/modifiers/intern/MOD_none.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,20 +15,10 @@
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_none.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stdio.h>
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 5e5621ae717..d838d203ed5 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,29 +12,25 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Bastien Montagne
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_normal_edit.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
+#include "BLI_bitmap.h"
+#include "BLI_math.h"
+
#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_mesh_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-#include "BLI_bitmap.h"
-
#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
@@ -68,8 +62,11 @@ static void generate_vert_coordinates(
/* Get size (i.e. deformation of the spheroid generating normals), either from target object, or own geometry. */
if (r_size != NULL) {
if (ob_center != NULL) {
+ /* Using 'scale' as 'size' here. The input object is typically an empty
+ * who's scale is used to define an ellipsoid instead of a simple sphere. */
+
/* Not we are not interested in signs here - they are even troublesome actually, due to security clamping! */
- abs_v3_v3(r_size, ob_center->size);
+ abs_v3_v3(r_size, ob_center->scale);
}
else {
/* Set size. */
@@ -418,13 +415,7 @@ static Mesh *normalEditModifier_do(
if (mesh->medge == ((Mesh *)ob->data)->medge) {
/* We need to duplicate data here, otherwise setting custom normals (which may also affect sharp edges) could
* modify org mesh, see T43671. */
- BKE_id_copy_ex(
- NULL, &mesh->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
}
else {
result = mesh;
@@ -508,17 +499,16 @@ static void initData(ModifierData *md)
enmd->mix_limit = M_PI;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
NormalEditModifierData *enmd = (NormalEditModifierData *)md;
- CustomDataMask dataMask = CD_MASK_CUSTOMLOOPNORMAL;
+
+ r_cddata_masks->lmask |= CD_MASK_CUSTOMLOOPNORMAL;
/* Ask for vertexgroups if we need them. */
- if (enmd->defgrp_name[0]) {
- dataMask |= (CD_MASK_MDEFORMVERT);
+ if (enmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
-
- return dataMask;
}
static bool dependsOnNormals(ModifierData *UNUSED(md))
@@ -545,7 +535,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
NormalEditModifierData *enmd = (NormalEditModifierData *) md;
if (enmd->target) {
DEG_add_object_relation(ctx->node, enmd->target, DEG_OB_COMP_TRANSFORM, "NormalEdit Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "NormalEdit Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "NormalEdit Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 8231745aa12..50ec32bd605 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,18 +15,18 @@
*
* The Original Code is Copyright (C) Blender Foundation
* All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Matt Ebb
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_ocean.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+#include "BLI_math_inline.h"
+#include "BLI_task.h"
+
#include "DNA_customdata_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
@@ -36,14 +34,7 @@
#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
-#include "BLI_math.h"
-#include "BLI_math_inline.h"
-#include "BLI_task.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_global.h"
#include "BKE_library.h"
-#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_ocean.h"
@@ -159,22 +150,17 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
}
#ifdef WITH_OCEANSIM
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
OceanModifierData *omd = (OceanModifierData *)md;
- CustomDataMask dataMask = 0;
- if (omd->flag & MOD_OCEAN_GENERATE_FOAM)
- dataMask |= CD_MASK_MCOL;
-
- return dataMask;
+ if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
+ r_cddata_masks->fmask |= CD_MASK_MCOL; /* XXX Should be loop cddata I guess? */
+ }
}
#else /* WITH_OCEANSIM */
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *UNUSED(r_cddata_masks))
{
- /* unused */
- (void)md;
- return 0;
}
#endif /* WITH_OCEANSIM */
@@ -394,12 +380,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
BKE_mesh_ensure_normals(result);
}
else if (omd->geometry_mode == MOD_OCEAN_GEOM_DISPLACE) {
- BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
}
cfra_for_cache = cfra_scene;
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index fa305f4c8a7..a9d8db493b8 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,33 +15,25 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_particleinstance.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_rand.h"
#include "BLI_string.h"
-#include "BLI_utildefines.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
#include "BKE_effect.h"
-#include "BKE_global.h"
#include "BKE_lattice.h"
#include "BKE_library_query.h"
#include "BKE_mesh.h"
@@ -73,19 +63,15 @@ static void initData(ModifierData *md)
STRNCPY(pimd->value_layer_name, "");
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
- CustomDataMask dataMask = 0;
if (pimd->index_layer_name[0] != '\0' ||
pimd->value_layer_name[0] != '\0')
{
- dataMask |= CD_MASK_MLOOPCOL;
+ r_cddata_masks->lmask |= CD_MASK_MLOOPCOL;
}
-
- return dataMask;
-
}
static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRenderParams)
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index bc1fb300cac..08a19506694 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,19 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_particlesystem.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stddef.h>
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-
#include "BLI_utildefines.h"
+#include "DNA_material_types.h"
+#include "DNA_mesh_types.h"
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
@@ -93,10 +81,11 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
- return psys_emitter_customdata_mask(psmd->psys);
+
+ psys_emitter_customdata_mask(psmd->psys, r_cddata_masks);
}
/* saves the current emitter state for a particle system and calculates particles */
@@ -127,6 +116,7 @@ static void deformVerts(
}
/* clear old dm */
+ bool had_mesh_final = (psmd->mesh_final != NULL);
if (psmd->mesh_final) {
BKE_id_free(NULL, psmd->mesh_final);
psmd->mesh_final = NULL;
@@ -138,9 +128,12 @@ static void deformVerts(
else if (psmd->flag & eParticleSystemFlag_file_loaded) {
/* in file read mesh just wasn't saved in file so no need to reset everything */
psmd->flag &= ~eParticleSystemFlag_file_loaded;
- }
- else {
- /* no dm before, so recalc particles fully */
+ if (psys->particles == NULL) {
+ psys->recalc |= ID_RECALC_PSYS_RESET;
+ }
+ /* TODO(sergey): This is not how particles were working prior to copy on
+ * write, but now evaluation is similar to case when one duplicates the
+ * object. In that case particles were doing reset here. */
psys->recalc |= ID_RECALC_PSYS_RESET;
}
@@ -158,11 +151,11 @@ static void deformVerts(
Mesh *mesh_original = NULL;
if (ctx->object->type == OB_MESH) {
- BMEditMesh *edit_btmesh = BKE_editmesh_from_object(ctx->object);
+ BMEditMesh *em = BKE_editmesh_from_object(ctx->object);
- if (edit_btmesh) {
+ if (em) {
/* In edit mode get directly from the edit mesh. */
- psmd->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(edit_btmesh->bm, 0);
+ psmd->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
}
else {
/* Otherwise get regular mesh. */
@@ -187,13 +180,16 @@ static void deformVerts(
BKE_id_free(NULL, mesh_src);
}
- /* report change in mesh structure */
- if (psmd->mesh_final->totvert != psmd->totdmvert ||
- psmd->mesh_final->totedge != psmd->totdmedge ||
- psmd->mesh_final->totface != psmd->totdmface)
+ /* Report change in mesh structure.
+ * This is an unreliable check for the topology check, but allows some
+ * handy configuration like emitting particles from inside particle
+ * instance. */
+ if (had_mesh_final &&
+ (psmd->mesh_final->totvert != psmd->totdmvert ||
+ psmd->mesh_final->totedge != psmd->totdmedge ||
+ psmd->mesh_final->totface != psmd->totdmface))
{
psys->recalc |= ID_RECALC_PSYS_RESET;
-
psmd->totdmvert = psmd->mesh_final->totvert;
psmd->totdmedge = psmd->mesh_final->totedge;
psmd->totdmface = psmd->mesh_final->totface;
@@ -205,6 +201,14 @@ static void deformVerts(
particle_system_update(ctx->depsgraph, scene, ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0);
psmd->flag |= eParticleSystemFlag_psys_updated;
}
+
+ if (DEG_is_active(ctx->depsgraph)) {
+ Object *object_orig = DEG_get_original_object(ctx->object);
+ ModifierData *md_orig = modifiers_findByName(object_orig, psmd->modifier.name);
+ BLI_assert(md_orig != NULL);
+ ParticleSystemModifierData *psmd_orig = (ParticleSystemModifierData *) md_orig;
+ psmd_orig->flag = psmd->flag;
+ }
}
/* disabled particles in editmode for now, until support for proper evaluated mesh
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index 6d0f88df492..2ff82d863df 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -16,20 +14,18 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2011 by Nicholas Bishop.
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_remesh.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "MEM_guardedalloc.h"
-#include "BLI_math_base.h"
-#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
+
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
@@ -45,6 +41,8 @@
#include <string.h>
#ifdef WITH_MOD_REMESH
+# include "BLI_math_vector.h"
+
# include "dualcon.h"
#endif
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 2c795a8d9ad..837b4d3d532 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,34 +15,25 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_screw.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
/* Screw modifier: revolves the edges about an axis */
#include <limits.h>
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
+#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_alloca.h"
-#include "BLI_utildefines.h"
-#include "BKE_library.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+
#include "BKE_library_query.h"
#include "BKE_mesh.h"
@@ -231,7 +220,8 @@ static Mesh *applyModifier(
float axis_vec[3] = {0.0f, 0.0f, 0.0f};
float tmp_vec1[3], tmp_vec2[3];
float mat3[3][3];
- float mtx_tx[4][4]; /* transform the coords by an object relative to this objects transformation */
+ /* transform the coords by an object relative to this objects transformation */
+ float mtx_tx[4][4];
float mtx_tx_inv[4][4]; /* inverted */
float mtx_tmp_a[4][4];
@@ -1119,7 +1109,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
ScrewModifierData *ltmd = (ScrewModifierData *)md;
if (ltmd->ob_axis != NULL) {
DEG_add_object_relation(ctx->node, ltmd->ob_axis, DEG_OB_COMP_TRANSFORM, "Screw Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Screw Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Screw Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 764e99866fd..3530ca21d34 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,28 +15,19 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_shapekey.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
#include "BLI_math.h"
#include "DNA_mesh_types.h"
#include "DNA_key_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_key.h"
#include "BKE_particle.h"
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 92cbbaa78ca..7b33df5bf86 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,30 +15,20 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_shrinkwrap.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
+#include "BLI_utildefines.h"
+
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "BKE_editmesh.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
@@ -66,22 +54,20 @@ static void initData(ModifierData *md)
smd->auxTarget = NULL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->vgroup_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
+ if (smd->vgroup_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
if ((smd->shrinkType == MOD_SHRINKWRAP_PROJECT) &&
(smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL))
{
- dataMask |= CD_MASK_MVERT;
+ r_cddata_masks->vmask |= CD_MASK_MVERT; /* XXX Really? These should always be present, always... */
}
-
- return dataMask;
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -148,16 +134,17 @@ static void deformVertsEM(
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
- CustomDataMask mask = 0;
+ CustomData_MeshMasks mask = {0};
if (BKE_shrinkwrap_needs_normals(smd->shrinkType, smd->shrinkMode)) {
- mask |= CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL;
+ mask.vmask |= CD_MASK_NORMAL;
+ mask.lmask |= CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL;
}
if (smd->target != NULL) {
DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, "Shrinkwrap Modifier");
- DEG_add_customdata_mask(ctx->node, smd->target, mask);
+ DEG_add_customdata_mask(ctx->node, smd->target, &mask);
if (smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
DEG_add_special_eval_flag(ctx->node, &smd->target->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
}
@@ -165,12 +152,12 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (smd->auxTarget != NULL) {
DEG_add_object_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
DEG_add_object_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_GEOMETRY, "Shrinkwrap Modifier");
- DEG_add_customdata_mask(ctx->node, smd->auxTarget, mask);
+ DEG_add_customdata_mask(ctx->node, smd->auxTarget, &mask);
if (smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
DEG_add_special_eval_flag(ctx->node, &smd->auxTarget->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
}
}
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Shrinkwrap Modifier");
}
static bool dependsOnNormals(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 33a585e5324..cc36cfbf9eb 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,28 +15,20 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_simpledeform.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
#include "BKE_library.h"
@@ -354,16 +344,14 @@ static void initData(ModifierData *md)
smd->limit[1] = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->vgroup_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->vgroup_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void foreachObjectLink(
@@ -379,7 +367,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
if (smd->origin != NULL) {
DEG_add_object_relation(ctx->node, smd->origin, DEG_OB_COMP_TRANSFORM, "SimpleDeform Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "SimpleDeform Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "SimpleDeform Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 586a0b57350..7ba7882d0d0 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,15 +12,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Nicholas Bishop
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_skin.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
/* Implementation based in part off the paper "B-Mesh: A Fast Modeling
@@ -59,17 +52,18 @@
#include "MEM_guardedalloc.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_modifier_types.h"
-
#include "BLI_utildefines.h"
+
#include "BLI_array.h"
+#include "BLI_bitmap.h"
#include "BLI_heap_simple.h"
#include "BLI_math.h"
#include "BLI_stack.h"
-#include "BLI_bitmap.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_modifier_types.h"
#include "BKE_deform.h"
#include "BKE_library.h"
@@ -92,7 +86,7 @@ typedef enum {
CAP_START = 1,
CAP_END = 2,
SEAM_FRAME = 4,
- ROOT = 8
+ ROOT = 8,
} SkinNodeFlag;
typedef struct Frame {
@@ -1881,7 +1875,7 @@ static Mesh *base_skin(Mesh *origmesh,
if (!bm)
return NULL;
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
@@ -1932,10 +1926,9 @@ static Mesh *applyModifier(ModifierData *md,
return result;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob),
- ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- return CD_MASK_MVERT_SKIN | CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MVERT_SKIN | CD_MASK_MDEFORMVERT;
}
ModifierTypeInfo modifierType_Skin = {
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index d0db852550b..905e8a18e1b 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,19 +15,10 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_smoke.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
@@ -37,6 +26,8 @@
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
#include "DNA_collection_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -44,13 +35,9 @@
#include "DNA_object_force_types.h"
#include "DNA_mesh_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_layer.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
-#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_smoke.h"
@@ -88,22 +75,20 @@ static void freeData(ModifierData *md)
smokeModifier_free(smd);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SmokeModifierData *smd = (SmokeModifierData *)md;
- CustomDataMask dataMask = 0;
if (smd && (smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
if (smd->flow->source == MOD_SMOKE_FLOW_SOURCE_MESH) {
/* vertex groups */
if (smd->flow->vgroup_density)
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* uv layer */
if (smd->flow->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
}
}
- return dataMask;
}
static Mesh *applyModifier(
@@ -201,5 +186,5 @@ ModifierTypeInfo modifierType_Smoke = {
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ foreachIDLink,
- /* foreachTexLink */ NULL
+ /* foreachTexLink */ NULL,
};
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 8b62c2c1d7d..2b9339842fa 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,21 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_smooth.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
+#include "MEM_guardedalloc.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
-#include "MEM_guardedalloc.h"
+#include "BLI_math.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
@@ -74,15 +64,14 @@ static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool
return 0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SmoothModifierData *smd = (SmoothModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void smoothModifier_do(
diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c
index 3f45e37e777..868b42bc241 100644
--- a/source/blender/modifiers/intern/MOD_softbody.c
+++ b/source/blender/modifiers/intern/MOD_softbody.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,20 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_softbody.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stdio.h>
+#include "BLI_utildefines.h"
+
#include "DNA_scene_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_force_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_layer.h"
#include "BKE_particle.h"
#include "BKE_softbody.h"
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 6283b7a250d..e449403eb70 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,29 +15,23 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Campbell Barton
- * Shinsuke Irie
- * Martin Felke
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_solidify.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_bitmap.h"
+#include "BLI_math.h"
+#include "BLI_utildefines_stack.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "MEM_guardedalloc.h"
-#include "BLI_utildefines.h"
-#include "BLI_utildefines_stack.h"
-#include "BLI_bitmap.h"
-#include "BLI_math.h"
-
#include "BKE_mesh.h"
#include "BKE_particle.h"
#include "BKE_deform.h"
@@ -58,13 +50,13 @@
/* could be exposed for other functions to use */
typedef struct EdgeFaceRef {
- int f1; /* init as -1 */
- int f2;
+ int p1; /* init as -1 */
+ int p2;
} EdgeFaceRef;
BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref)
{
- return !((edge_ref->f1 == 0) && (edge_ref->f2 == 0));
+ return !((edge_ref->p1 == 0) && (edge_ref->p2 == 0));
}
/**
@@ -72,9 +64,9 @@ BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref)
* \param face_nors: Precalculated face normals.
* \param r_vert_nors: Return vert normals.
*/
-static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_vert_nors)[3])
+static void mesh_calc_hq_normal(Mesh *mesh, float (*poly_nors)[3], float (*r_vert_nors)[3])
{
- int i, numVerts, numEdges, numFaces;
+ int i, numVerts, numEdges, numPolys;
MPoly *mpoly, *mp;
MLoop *mloop, *ml;
MEdge *medge, *ed;
@@ -82,7 +74,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_ver
numVerts = mesh->totvert;
numEdges = mesh->totedge;
- numFaces = mesh->totface;
+ numPolys = mesh->totpoly;
mpoly = mesh->mpoly;
medge = mesh->medge;
mvert = mesh->mvert;
@@ -105,7 +97,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_ver
float edge_normal[3];
/* Add an edge reference if it's not there, pointing back to the face index. */
- for (i = 0; i < numFaces; i++, mp++) {
+ for (i = 0; i < numPolys; i++, mp++) {
int j;
ml = mloop + mp->loopstart;
@@ -114,15 +106,15 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_ver
/* --- add edge ref to face --- */
edge_ref = &edge_ref_array[ml->e];
if (!edgeref_is_init(edge_ref)) {
- edge_ref->f1 = i;
- edge_ref->f2 = -1;
+ edge_ref->p1 = i;
+ edge_ref->p2 = -1;
}
- else if ((edge_ref->f1 != -1) && (edge_ref->f2 == -1)) {
- edge_ref->f2 = i;
+ else if ((edge_ref->p1 != -1) && (edge_ref->p2 == -1)) {
+ edge_ref->p2 = i;
}
else {
/* 3+ faces using an edge, we can't handle this usefully */
- edge_ref->f1 = edge_ref->f2 = -1;
+ edge_ref->p1 = edge_ref->p2 = -1;
#ifdef USE_NONMANIFOLD_WORKAROUND
medge[ml->e].flag |= ME_EDGE_TMP_TAG;
#endif
@@ -134,8 +126,8 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_ver
for (i = 0, ed = medge, edge_ref = edge_ref_array; i < numEdges; i++, ed++, edge_ref++) {
/* Get the edge vert indices, and edge value (the face indices that use it) */
- if (edgeref_is_init(edge_ref) && (edge_ref->f1 != -1)) {
- if (edge_ref->f2 != -1) {
+ if (edgeref_is_init(edge_ref) && (edge_ref->p1 != -1)) {
+ if (edge_ref->p2 != -1) {
/* We have 2 faces using this edge, calculate the edges normal
* using the angle between the 2 faces as a weighting */
#if 0
@@ -144,13 +136,13 @@ static void mesh_calc_hq_normal(Mesh *mesh, float (*face_nors)[3], float (*r_ver
edge_normal,
angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
#else
- mid_v3_v3v3_angle_weighted(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
+ mid_v3_v3v3_angle_weighted(edge_normal, poly_nors[edge_ref->p1], poly_nors[edge_ref->p2]);
#endif
}
else {
/* only one face attached to that edge */
/* an edge without another attached- the weight on this is undefined */
- copy_v3_v3(edge_normal, face_nors[edge_ref->f1]);
+ copy_v3_v3(edge_normal, poly_nors[edge_ref->p1]);
}
add_v3_v3(r_vert_nors[ed->v1], edge_normal);
add_v3_v3(r_vert_nors[ed->v2], edge_normal);
@@ -175,15 +167,14 @@ static void initData(ModifierData *md)
smd->flag = MOD_SOLIDIFY_RIM;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SolidifyModifierData *smd = (SolidifyModifierData *) md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
/* specific function for solidify - define locally */
@@ -207,9 +198,9 @@ static Mesh *applyModifier(
MPoly *mp, *mpoly, *orig_mpoly;
const unsigned int numVerts = (unsigned int)mesh->totvert;
const unsigned int numEdges = (unsigned int)mesh->totedge;
- const unsigned int numFaces = (unsigned int)mesh->totpoly;
+ const unsigned int numPolys = (unsigned int)mesh->totpoly;
const unsigned int numLoops = (unsigned int)mesh->totloop;
- unsigned int newLoops = 0, newFaces = 0, newEdges = 0, newVerts = 0, rimVerts = 0;
+ unsigned int newLoops = 0, newPolys = 0, newEdges = 0, newVerts = 0, rimVerts = 0;
/* only use material offsets if we have 2 or more materials */
const short mat_nr_max = ctx->object->totcol > 1 ? ctx->object->totcol - 1 : 0;
@@ -230,9 +221,9 @@ static Mesh *applyModifier(
char *edge_order = NULL;
float (*vert_nors)[3] = NULL;
- float (*face_nors)[3] = NULL;
+ float (*poly_nors)[3] = NULL;
- const bool need_face_normals = (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) || (smd->flag & MOD_SOLIDIFY_EVEN);
+ const bool need_poly_normals = (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) || (smd->flag & MOD_SOLIDIFY_EVEN);
const float ofs_orig = -(((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset);
const float ofs_new = smd->offset + ofs_orig;
@@ -257,14 +248,14 @@ static Mesh *applyModifier(
orig_mloop = mesh->mloop;
orig_mpoly = mesh->mpoly;
- if (need_face_normals) {
+ if (need_poly_normals) {
/* calculate only face normals */
- face_nors = MEM_malloc_arrayN(numFaces, sizeof(*face_nors), __func__);
+ poly_nors = MEM_malloc_arrayN(numPolys, sizeof(*poly_nors), __func__);
BKE_mesh_calc_normals_poly(
orig_mvert, NULL, (int)numVerts,
orig_mloop, orig_mpoly,
- (int)numLoops, (int)numFaces,
- face_nors, true);
+ (int)numLoops, (int)numPolys,
+ poly_nors, true);
}
STACK_INIT(new_vert_arr, numVerts * 2);
@@ -294,7 +285,7 @@ static Mesh *applyModifier(
edge_users[eidx] = INVALID_UNUSED;
}
- for (i = 0, mp = orig_mpoly; i < numFaces; i++, mp++) {
+ for (i = 0, mp = orig_mpoly; i < numPolys; i++, mp++) {
MLoop *ml_prev;
int j;
@@ -308,7 +299,7 @@ static Mesh *applyModifier(
ed = orig_medge + eidx;
BLI_assert(ELEM(ml_prev->v, ed->v1, ed->v2) &&
ELEM(ml->v, ed->v1, ed->v2));
- edge_users[eidx] = (ml_prev->v > ml->v) == (ed->v1 < ed->v2) ? i : (i + numFaces);
+ edge_users[eidx] = (ml_prev->v > ml->v) == (ed->v1 < ed->v2) ? i : (i + numPolys);
edge_order[eidx] = j;
}
else {
@@ -323,7 +314,7 @@ static Mesh *applyModifier(
BLI_BITMAP_ENABLE(orig_mvert_tag, ed->v1);
BLI_BITMAP_ENABLE(orig_mvert_tag, ed->v2);
STACK_PUSH(new_edge_arr, eidx);
- newFaces++;
+ newPolys++;
newLoops += 4;
}
}
@@ -346,7 +337,7 @@ static Mesh *applyModifier(
/* only add rim vertices */
newVerts = rimVerts;
/* each extruded face needs an opposite edge */
- newEdges = newFaces;
+ newEdges = newPolys;
}
else {
/* (stride == 2) in this case, so no need to add newVerts/newEdges */
@@ -356,7 +347,7 @@ static Mesh *applyModifier(
if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
vert_nors = MEM_calloc_arrayN(numVerts, 3 * sizeof(float), "mod_solid_vno_hq");
- mesh_calc_hq_normal(mesh, face_nors, vert_nors);
+ mesh_calc_hq_normal(mesh, poly_nors, vert_nors);
}
result = BKE_mesh_new_nomain_from_template(
@@ -364,7 +355,7 @@ static Mesh *applyModifier(
(int)((numVerts * stride) + newVerts),
(int)((numEdges * stride) + newEdges + rimVerts), 0,
(int)((numLoops * stride) + newLoops),
- (int)((numFaces * stride) + newFaces));
+ (int)((numPolys * stride) + newPolys));
mpoly = result->mpoly;
mloop = result->mloop;
@@ -379,10 +370,13 @@ static Mesh *applyModifier(
CustomData_copy_data(&mesh->edata, &result->edata, 0, (int)numEdges, (int)numEdges);
CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)numLoops);
- CustomData_copy_data(&mesh->ldata, &result->ldata, 0, (int)numLoops, (int)numLoops);
+ /* DO NOT copy here the 'copied' part of loop data, we want to reverse loops
+ * (so that winding of copied face get reversed, so that normals get reversed
+ * and point in expected direction...).
+ * If we also copy data here, then this data get overwritten (and allocated memory becomes memleak). */
- CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numFaces);
- CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)numFaces, (int)numFaces);
+ CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys);
+ CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)numPolys, (int)numPolys);
}
else {
int i, j;
@@ -411,7 +405,7 @@ static Mesh *applyModifier(
/* will be created later */
CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)numLoops);
- CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numFaces);
+ CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys);
}
#undef INVALID_UNUSED
@@ -443,7 +437,7 @@ static Mesh *applyModifier(
if (do_shell) {
unsigned int i;
- mp = mpoly + numFaces;
+ mp = mpoly + numPolys;
for (i = 0; i < mesh->totpoly; i++, mp++) {
const int loop_end = mp->totloop - 1;
MLoop *ml2;
@@ -598,7 +592,7 @@ static Mesh *applyModifier(
}
}
- for (i = 0, mp = mpoly; i < numFaces; i++, mp++) {
+ for (i = 0, mp = mpoly; i < numPolys; i++, mp++) {
/* #BKE_mesh_calc_poly_angles logic is inlined here */
float nor_prev[3];
float nor_next[3];
@@ -632,13 +626,13 @@ static Mesh *applyModifier(
LIKELY(((orig_medge[ml[i_curr].e].flag & ME_EDGE_TMP_TAG) == 0) &&
((orig_medge[ml[i_next].e].flag & ME_EDGE_TMP_TAG) == 0)))
{
- vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], face_nors[i]) * angle;
+ vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], poly_nors[i]) * angle;
}
else {
vert_angles[vidx] += angle;
}
#else
- vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], face_nors[i]) * angle;
+ vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], poly_nors[i]) * angle;
#endif
/* --- end non-angle-calc section --- */
@@ -780,7 +774,7 @@ static Mesh *applyModifier(
for (i = 0; i < rimVerts; i++, ed++, orig_ed++) {
ed->v1 = new_vert_arr[i];
ed->v2 = (do_shell ? new_vert_arr[i] : i) + numVerts;
- ed->flag |= ME_EDGEDRAW;
+ ed->flag |= ME_EDGEDRAW | ME_EDGERENDER;
*orig_ed = ORIGINDEX_NONE;
@@ -790,17 +784,17 @@ static Mesh *applyModifier(
}
/* faces */
- mp = mpoly + (numFaces * stride);
+ mp = mpoly + (numPolys * stride);
ml = mloop + (numLoops * stride);
j = 0;
- for (i = 0; i < newFaces; i++, mp++) {
+ for (i = 0; i < newPolys; i++, mp++) {
unsigned int eidx = new_edge_arr[i];
- unsigned int fidx = edge_users[eidx];
+ unsigned int pidx = edge_users[eidx];
int k1, k2;
bool flip;
- if (fidx >= numFaces) {
- fidx -= numFaces;
+ if (pidx >= numPolys) {
+ pidx -= numPolys;
flip = true;
}
else {
@@ -810,15 +804,15 @@ static Mesh *applyModifier(
ed = medge + eidx;
/* copy most of the face settings */
- CustomData_copy_data(&mesh->pdata, &result->pdata, (int)fidx, (int)((numFaces * stride) + i), 1);
+ CustomData_copy_data(&mesh->pdata, &result->pdata, (int)pidx, (int)((numPolys * stride) + i), 1);
mp->loopstart = (int)(j + (numLoops * stride));
- mp->flag = mpoly[fidx].flag;
+ mp->flag = mpoly[pidx].flag;
/* notice we use 'mp->totloop' which is later overwritten,
* we could lookup the original face but there's no point since this is a copy
* and will have the same value, just take care when changing order of assignment */
- k1 = mpoly[fidx].loopstart + (((edge_order[eidx] - 1) + mp->totloop) % mp->totloop); /* prev loop */
- k2 = mpoly[fidx].loopstart + (edge_order[eidx]);
+ k1 = mpoly[pidx].loopstart + (((edge_order[eidx] - 1) + mp->totloop) % mp->totloop); /* prev loop */
+ k2 = mpoly[pidx].loopstart + (edge_order[eidx]);
mp->totloop = 4;
@@ -926,10 +920,10 @@ static Mesh *applyModifier(
if (old_vert_arr)
MEM_freeN(old_vert_arr);
- if (face_nors)
- MEM_freeN(face_nors);
+ if (poly_nors)
+ MEM_freeN(poly_nors);
- if (numFaces == 0 && numEdges != 0) {
+ if (numPolys == 0 && numEdges != 0) {
modifier_setError(md, "Faces needed for useful output");
}
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index e66b3fdbafb..1899faa3583 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,30 +15,21 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_subsurf.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <stddef.h>
+#include "BLI_utildefines.h"
+
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_mesh_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_cdderivedmesh.h"
#include "BKE_scene.h"
#include "BKE_subdiv.h"
@@ -75,6 +64,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
modifier_copyData_generic(md, target, flag);
tsmd->emCache = tsmd->mCache = NULL;
+ tsmd->subdiv = NULL;
}
static void freeData(ModifierData *md)
@@ -89,6 +79,9 @@ static void freeData(ModifierData *md)
ccgSubSurf_free(smd->emCache);
smd->emCache = NULL;
}
+ if (smd->subdiv != NULL) {
+ BKE_subdiv_free(smd->subdiv);
+ }
}
static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParams)
@@ -122,6 +115,18 @@ static void subdiv_settings_init(SubdivSettings *settings,
BKE_subdiv_fvar_interpolation_from_uv_smooth(smd->uv_smooth);
}
+/* Main goal of this function is to give usable subdivision surface descriptor
+ * which matches settings and topology. */
+static Subdiv *subdiv_descriptor_ensure(SubsurfModifierData *smd,
+ const SubdivSettings *subdiv_settings,
+ const Mesh *mesh)
+{
+ Subdiv *subdiv = BKE_subdiv_update_from_mesh(
+ smd->subdiv, subdiv_settings, mesh);
+ smd->subdiv = subdiv;
+ return subdiv;
+}
+
/* Subdivide into fully qualified mesh. */
static void subdiv_mesh_settings_init(SubdivToMeshSettings *settings,
@@ -189,24 +194,24 @@ static Mesh *applyModifier(ModifierData *md,
if (subdiv_settings.level == 0) {
return result;
}
- /* TODO(sergey): Try to re-use subdiv when possible. */
- Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, mesh);
+ BKE_subdiv_settings_validate_for_mesh(&subdiv_settings, mesh);
+ Subdiv *subdiv = subdiv_descriptor_ensure(smd, &subdiv_settings, mesh);
if (subdiv == NULL) {
- /* Happens on bad topology, ut also on empty input mesh. */
+ /* Happens on bad topology, but also on empty input mesh. */
return result;
}
/* TODO(sergey): Decide whether we ever want to use CCG for subsurf,
- * maybe when it is a last modifier in the stack?
- */
+ * maybe when it is a last modifier in the stack? */
if (true) {
result = subdiv_as_mesh(smd, ctx, mesh, subdiv);
}
else {
result = subdiv_as_ccg(smd, ctx, mesh, subdiv);
}
- /* TODO(sergey): Cache subdiv somehow. */
// BKE_subdiv_stats_print(&subdiv->stats);
- BKE_subdiv_free(subdiv);
+ if (subdiv != smd->subdiv) {
+ BKE_subdiv_free(subdiv);
+ }
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index c5fa510f2e0..ee3c99bef85 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,22 +15,17 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_surface.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
@@ -45,9 +38,6 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "MOD_modifiertypes.h"
#include "MOD_util.h"
@@ -59,6 +49,21 @@ static void initData(ModifierData *md)
SurfaceModifierData *surmd = (SurfaceModifierData *) md;
surmd->bvhtree = NULL;
+ surmd->mesh = NULL;
+ surmd->x = NULL;
+ surmd->v = NULL;
+}
+
+static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int flag)
+{
+ SurfaceModifierData *surmd_dst = (SurfaceModifierData *)md_dst;
+
+ modifier_copyData_generic(md_src, md_dst, flag);
+
+ surmd_dst->bvhtree = NULL;
+ surmd_dst->mesh = NULL;
+ surmd_dst->x = NULL;
+ surmd_dst->v = NULL;
}
static void freeData(ModifierData *md)
@@ -96,20 +101,21 @@ static void deformVerts(
SurfaceModifierData *surmd = (SurfaceModifierData *) md;
const int cfra = (int)DEG_get_ctime(ctx->depsgraph);
+ /* Free mesh and BVH cache. */
+ if (surmd->bvhtree) {
+ free_bvhtree_from_mesh(surmd->bvhtree);
+ MEM_SAFE_FREE(surmd->bvhtree);
+ }
+
if (surmd->mesh) {
BKE_id_free(NULL, surmd->mesh);
+ surmd->mesh = NULL;
}
if (mesh) {
/* Not possible to use get_mesh() in this case as we'll modify its vertices
* and get_mesh() would return 'mesh' directly. */
- BKE_id_copy_ex(
- NULL, (ID *)mesh, (ID **)&surmd->mesh,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&surmd->mesh, LIB_ID_COPY_LOCALIZE);
}
else {
surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, numVerts, false, false);
@@ -168,10 +174,7 @@ static void deformVerts(
surmd->cfra = cfra;
- if (surmd->bvhtree)
- free_bvhtree_from_mesh(surmd->bvhtree);
- else
- surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh");
+ surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh");
if (surmd->mesh->totpoly)
BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2);
@@ -190,7 +193,7 @@ ModifierTypeInfo modifierType_Surface = {
eModifierTypeFlag_AcceptsCVs |
eModifierTypeFlag_NoUserAdd,
- /* copyData */ NULL,
+ /* copyData */ copyData,
/* deformVerts_DM */ NULL,
/* deformMatrices_DM */ NULL,
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index d4781e419cf..554545077fa 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1,13 +1,34 @@
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2017, Blender Foundation.
+ */
+
+/** \file
+ * \ingroup modifiers
+ */
-#include "BLI_alloca.h"
#include "BLI_math.h"
#include "BLI_math_geom.h"
#include "BLI_task.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
#include "BKE_bvhutils.h"
#include "BKE_mesh_runtime.h"
#include "BKE_editmesh.h"
@@ -269,7 +290,7 @@ BLI_INLINE void sortPolyVertsTri(unsigned int *indices, const MLoop * const mloo
BLI_INLINE unsigned int nearestVert(SDefBindCalcData * const data, const float point_co[3])
{
- BVHTreeNearest nearest = {.dist_sq = FLT_MAX, .index = -1};
+ BVHTreeNearest nearest = { .dist_sq = FLT_MAX, .index = -1, };
const MPoly *poly;
const MEdge *edge;
const MLoop *loop;
@@ -976,18 +997,20 @@ static bool surfacedeformBind(
smd->numverts = numverts;
smd->numpoly = tnumpoly;
- SDefBindCalcData data = {.treeData = &treeData,
- .vert_edges = vert_edges,
- .edge_polys = edge_polys,
- .mpoly = mpoly,
- .medge = medge,
- .mloop = mloop,
- .looptri = BKE_mesh_runtime_looptri_ensure(target),
- .targetCos = MEM_malloc_arrayN(tnumverts, sizeof(float[3]), "SDefTargetBindVertArray"),
- .bind_verts = smd->verts,
- .vertexCos = vertexCos,
- .falloff = smd->falloff,
- .success = MOD_SDEF_BIND_RESULT_SUCCESS};
+ SDefBindCalcData data = {
+ .treeData = &treeData,
+ .vert_edges = vert_edges,
+ .edge_polys = edge_polys,
+ .mpoly = mpoly,
+ .medge = medge,
+ .mloop = mloop,
+ .looptri = BKE_mesh_runtime_looptri_ensure(target),
+ .targetCos = MEM_malloc_arrayN(tnumverts, sizeof(float[3]), "SDefTargetBindVertArray"),
+ .bind_verts = smd->verts,
+ .vertexCos = vertexCos,
+ .falloff = smd->falloff,
+ .success = MOD_SDEF_BIND_RESULT_SUCCESS,
+ };
if (data.targetCos == NULL) {
modifier_setError((ModifierData *)smd, "Out of memory");
@@ -1105,7 +1128,6 @@ static void surfacedeformModifier_do(
float (*vertexCos)[3], unsigned int numverts, Object *ob)
{
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
- bool free_target;
Mesh *target;
unsigned int tnumverts, tnumpoly;
@@ -1126,12 +1148,12 @@ static void surfacedeformModifier_do(
}
Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, smd->target);
- target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, &free_target);
+ target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false);
#if 0 /* Should not be needed anymore since we always get that mesh from eval object ? */
if (target == NULL && smd->verts == NULL && ob == DEG_get_original_object(ob)) {
/* Special case, binding happens outside of depsgraph evaluation, so we can build our own
* target mesh if needed. */
- target = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), smd->target, 0);
+ target = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), smd->target, CD_MASK_BAREMESH);
free_target = target != NULL;
}
#endif
@@ -1150,7 +1172,7 @@ static void surfacedeformModifier_do(
if (ob != DEG_get_original_object(ob)) {
BLI_assert(!"Trying to bind inside of depsgraph evaluation");
modifier_setError(md, "Trying to bind inside of depsgraph evaluation");
- goto finally;
+ return;
}
float tmp_mat[4][4];
@@ -1161,17 +1183,17 @@ static void surfacedeformModifier_do(
smd->flags &= ~MOD_SDEF_BIND;
}
/* Early abort, this is binding 'call', no need to perform whole evaluation. */
- goto finally;
+ return;
}
/* Poly count checks */
if (smd->numverts != numverts) {
modifier_setError(md, "Verts changed from %u to %u", smd->numverts, numverts);
- goto finally;
+ return;
}
else if (smd->numpoly != tnumpoly) {
modifier_setError(md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly);
- goto finally;
+ return;
}
/* Actual vertex location update starts here */
@@ -1198,11 +1220,6 @@ static void surfacedeformModifier_do(
MEM_freeN(data.targetCos);
}
-
-finally:
- if (target != NULL && free_target) {
- BKE_id_free(NULL, target);
- }
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 0eba535ca9b..802bde21b5c 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,23 +12,20 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Antony Riakiotakis
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_triangulate.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_modifier.h"
#include "BKE_mesh.h"
@@ -39,32 +34,55 @@
#include "MOD_modifiertypes.h"
-static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_method)
+static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_method, const int flag)
{
Mesh *result;
BMesh *bm;
int total_edges, i;
MEdge *me;
+ CustomData_MeshMasks cddata_masks = {.vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX};
+
+ bool keep_clnors = (flag & MOD_TRIANGULATE_KEEP_CUSTOMLOOP_NORMALS) != 0;
+
+ if (keep_clnors) {
+ BKE_mesh_calc_normals_split(mesh);
+ /* We need that one to 'survive' to/from BMesh conversions. */
+ CustomData_clear_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
+ cddata_masks.lmask |= CD_MASK_NORMAL;
+ }
bm = BKE_mesh_to_bmesh_ex(
mesh,
&((struct BMeshCreateParams){0}),
&((struct BMeshFromMeshParams){
.calc_face_normal = true,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .cd_mask_extra = cddata_masks,
}));
BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL, NULL);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, &cddata_masks);
BM_mesh_free(bm);
+
+ if (keep_clnors) {
+ float (*lnors)[3] = CustomData_get_layer(&result->ldata, CD_NORMAL);
+ BLI_assert(lnors != NULL);
+
+ BKE_mesh_set_custom_normals(result, lnors);
+
+ /* Do some cleanup, we do not want those temp data to stay around. */
+ CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
+ CustomData_set_layer_flag(&result->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
+ }
+
total_edges = result->totedge;
me = result->medge;
/* force drawing of all edges (seems to be omitted in CDDM_from_bmesh) */
- for (i = 0; i < total_edges; i++, me++)
+ for (i = 0; i < total_edges; i++, me++) {
me->flag |= ME_EDGEDRAW | ME_EDGERENDER;
+ }
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
@@ -89,7 +107,7 @@ static Mesh *applyModifier(
{
TriangulateModifierData *tmd = (TriangulateModifierData *)md;
Mesh *result;
- if (!(result = triangulate_mesh(mesh, tmd->quad_method, tmd->ngon_method))) {
+ if (!(result = triangulate_mesh(mesh, tmd->quad_method, tmd->ngon_method, tmd->flag))) {
return mesh;
}
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 88fc8048269..941fcf6cf9a 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,21 +15,21 @@
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Ben Batt
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_util.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
+#include "BLI_utildefines.h"
+
+#include "BLI_bitmap.h"
+#include "BLI_math_vector.h"
+#include "BLI_math_matrix.h"
+
#include "DNA_image_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_mesh_types.h"
@@ -39,11 +37,6 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_utildefines.h"
-#include "BLI_bitmap.h"
-#include "BLI_math_vector.h"
-#include "BLI_math_matrix.h"
-
#include "BKE_deform.h"
#include "BKE_editmesh.h"
#include "BKE_image.h"
@@ -186,7 +179,7 @@ Mesh *MOD_deform_mesh_eval_get(
}
else if (ob->type == OB_MESH) {
if (em) {
- mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
+ mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
}
else {
/* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether
@@ -194,12 +187,8 @@ Mesh *MOD_deform_mesh_eval_get(
Mesh *mesh_prior_modifiers = BKE_object_get_pre_modified_mesh(ob);
BKE_id_copy_ex(
NULL, &mesh_prior_modifiers->id, (ID **)&mesh,
- (LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW |
- LIB_ID_COPY_CD_REFERENCE),
- false);
+ (LIB_ID_COPY_LOCALIZE |
+ LIB_ID_COPY_CD_REFERENCE));
mesh->runtime.deformed_only = 1;
}
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index 9a444046bd9..2325f865d6a 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,14 +12,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Ben Batt
- *
- * ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/modifiers/intern/MOD_util.h
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 0da96ba1a38..26c7ec7ed13 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,36 +15,26 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_uvproject.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
/* UV Project modifier: Generates UVs projected from an object */
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_object_types.h"
+#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_uvproject.h"
-#include "BLI_utildefines.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_object_types.h"
#include "BKE_camera.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
@@ -69,14 +57,10 @@ static void initData(ModifierData *md)
umd->scalex = umd->scaley = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = 0;
-
/* ask for UV coordinates */
- dataMask |= CD_MLOOPUV;
-
- return dataMask;
+ r_cddata_masks->lmask |= CD_MLOOPUV;
}
static void foreachObjectLink(
@@ -112,7 +96,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
if (do_add_own_transform) {
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "UV Project Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "UV Project Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index c051f51facc..d4f17b742f1 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,26 +12,22 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Pawel Kowal, Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_uvwarp.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
+#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_task.h"
-#include "BLI_utildefines.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "BKE_action.h" /* BKE_pose_channel_find_name */
#include "BKE_deform.h"
@@ -68,16 +62,14 @@ static void initData(ModifierData *md)
copy_v2_fl(umd->center, 0.5f);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
UVWarpModifierData *umd = (UVWarpModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (umd->vgroup_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (umd->vgroup_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void matrix_from_obj_pchan(float mat[4][4], Object *ob, const char *bonename)
@@ -202,9 +194,11 @@ static Mesh *applyModifier(
mloopuv = CustomData_duplicate_referenced_layer_named(&mesh->ldata, CD_MLOOPUV, uvname, numLoops);
MOD_get_vgroup(ctx->object, mesh, umd->vgroup_name, &dvert, &defgrp_index);
- UVWarpData data = {.mpoly = mpoly, .mloop = mloop, .mloopuv = mloopuv,
- .dvert = dvert, .defgrp_index = defgrp_index,
- .warp_mat = warp_mat, .axis_u = axis_u, .axis_v = axis_v};
+ UVWarpData data = {
+ .mpoly = mpoly, .mloop = mloop, .mloopuv = mloopuv,
+ .dvert = dvert, .defgrp_index = defgrp_index,
+ .warp_mat = warp_mat, .axis_u = axis_u, .axis_v = axis_v,
+ };
ParallelRangeSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (numPolys > 1000);
@@ -247,7 +241,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
uv_warp_deps_object_bone_new(ctx->node, umd->object_src, umd->bone_src);
uv_warp_deps_object_bone_new(ctx->node, umd->object_dst, umd->bone_dst);
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "UVWarp Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "UVWarp Modifier");
}
ModifierTypeInfo modifierType_UVWarp = {
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index cf59c81dcf4..adda5df61ea 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,28 +12,24 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_warp.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include <string.h>
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
#include "BKE_editmesh.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
@@ -75,19 +69,19 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
twmd->curfalloff = curvemapping_copy(wmd->curfalloff);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WarpModifierData *wmd = (WarpModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (wmd->defgrp_name[0]) dataMask |= (CD_MASK_MDEFORMVERT);
- dataMask |= (CD_MASK_MDEFORMVERT);
+ if (wmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
/* ask for UV coordinates if we need them */
- if (wmd->texmapping == MOD_DISP_MAP_UV) dataMask |= (1 << CD_MTFACE);
-
- return dataMask;
+ if (wmd->texmapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
}
static bool dependsOnTime(ModifierData *md)
@@ -143,7 +137,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
WarpModifierData *wmd = (WarpModifierData *) md;
if (wmd->object_from != NULL && wmd->object_to != NULL) {
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Warplace Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Warplace Modifier");
DEG_add_object_relation(ctx->node, wmd->object_from, DEG_OB_COMP_TRANSFORM, "Warp Modifier from");
DEG_add_object_relation(ctx->node, wmd->object_to, DEG_OB_COMP_TRANSFORM, "Warp Modifier to");
}
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index cc3035d3d9b..80ac323c82f 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,22 +15,15 @@
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
- *
- * Contributor(s): Daniel Dunbar
- * Ton Roosendaal,
- * Ben Batt,
- * Brecht Van Lommel,
- * Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_wave.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
#include "BLI_math.h"
#include "DNA_mesh_types.h"
@@ -40,9 +31,6 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_utildefines.h"
-
-
#include "BKE_deform.h"
#include "BKE_editmesh.h"
#include "BKE_library.h"
@@ -124,28 +112,26 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
}
if (wmd->objectcenter != NULL || wmd->map_object != NULL) {
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "Wave Modifier");
}
if (wmd->texture != NULL) {
DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier");
}
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WaveModifierData *wmd = (WaveModifierData *)md;
- CustomDataMask dataMask = 0;
-
/* ask for UV coordinates if we need them */
- if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* ask for vertexgroups if we need them */
- if (wmd->defgrp_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (wmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool dependsOnNormals(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 0e116b2e021..9eda072b7d3 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,17 +12,17 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_weighted_normal.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "MEM_guardedalloc.h"
+#include "BLI_linklist.h"
+#include "BLI_math.h"
+
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -32,12 +30,8 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_deform.h"
#include "BKE_library.h"
-#include "BKE_library_query.h"
#include "BKE_mesh.h"
-#include "BLI_math.h"
-#include "BLI_linklist.h"
-
#include "MOD_modifiertypes.h"
#include "MOD_util.h"
@@ -496,13 +490,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
}
Mesh *result;
- BKE_id_copy_ex(
- NULL, &mesh->id, (ID **)&result,
- LIB_ID_CREATE_NO_MAIN |
- LIB_ID_CREATE_NO_USER_REFCOUNT |
- LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW,
- false);
+ BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
const int numVerts = result->totvert;
const int numEdges = result->totedge;
@@ -535,6 +523,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
float (*polynors)[3] = CustomData_get_layer(pdata, CD_NORMAL);
if (!polynors) {
polynors = CustomData_add_layer(pdata, CD_NORMAL, CD_CALLOC, NULL, numPolys);
+ CustomData_set_layer_flag(pdata, CD_NORMAL, CD_FLAG_TEMPORARY);
}
BKE_mesh_calc_normals_poly(mvert, NULL, numVerts, mloop, mpoly, numLoops, numPolys, polynors, false);
@@ -599,6 +588,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
MEM_SAFE_FREE(wn_data.mode_pair);
MEM_SAFE_FREE(wn_data.items_data);
+ /* Currently Modifier stack assumes there is no poly normal data passed around... */
+ CustomData_free_layers(pdata, CD_NORMAL, numPolys);
return result;
}
@@ -611,20 +602,19 @@ static void initData(ModifierData *md)
wnmd->flag = 0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightedNormalModifierData *wnmd = (WeightedNormalModifierData *)md;
- CustomDataMask dataMask = CD_MASK_CUSTOMLOOPNORMAL;
- if (wnmd->defgrp_name[0]) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->lmask = CD_MASK_CUSTOMLOOPNORMAL;
+
+ if (wnmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
if (wnmd->flag & MOD_WEIGHTEDNORMAL_FACE_INFLUENCE) {
- dataMask |= CD_MASK_PROP_INT;
+ r_cddata_masks->pmask |= CD_MASK_PROP_INT;
}
-
- return dataMask;
}
static bool dependsOnNormals(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 60537e51e22..85cf3102733 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,21 +15,17 @@
*
* The Original Code is Copyright (C) 2011 by Bastien Montagne.
* All rights reserved.
- *
- * Contributor(s): None yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_weightvg_util.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_string.h"
-#include "BLI_utildefines.h"
#include "DNA_color_types.h" /* CurveMapping. */
#include "DNA_mesh_types.h"
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index 93594fd8b29..8bc56eb61f9 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,15 +15,10 @@
*
* The Original Code is Copyright (C) 2011 by Bastien Montagne.
* All rights reserved.
- *
- * Contributor(s): None yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_weightvg_util.h
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#ifndef __MOD_WEIGHTVG_UTIL_H__
@@ -37,9 +30,9 @@ struct MDeformWeight;
struct Mesh;
struct ModifierEvalContext;
struct Object;
-struct Tex;
-struct Scene;
struct RNG;
+struct Scene;
+struct Tex;
/*
* XXX I'd like to make modified weights visible in WeightPaint mode,
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index bf7517ee634..32d058e5659 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,18 +15,14 @@
*
* The Original Code is Copyright (C) 2011 by Bastien Montagne.
* All rights reserved.
- *
- * Contributor(s): None yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_weightvgedit.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "BLI_utildefines.h"
+
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_rand.h"
@@ -41,7 +35,6 @@
#include "BKE_colortools.h" /* CurveMapping. */
#include "BKE_deform.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_modifier.h"
#include "BKE_texture.h" /* Texture masking. */
@@ -91,21 +84,19 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md;
- CustomDataMask dataMask = 0;
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* Ask for UV coordinates if we need them. */
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
@@ -142,10 +133,13 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGEdit Modifier");
}
else if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGEdit Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGEdit Modifier");
+ }
+ if (wmd->mask_texture != NULL) {
+ DEG_add_generic_id_relation(ctx->node, &wmd->mask_texture->id, "WeightVGEdit Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 674ef106737..495d235b406 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,20 +15,16 @@
*
* The Original Code is Copyright (C) 2011 by Bastien Montagne.
* All rights reserved.
- *
- * Contributor(s): None yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_weightvgmix.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "BLI_utildefines.h"
-#include "BLI_math.h"
+
#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -39,7 +33,6 @@
#include "BKE_customdata.h"
#include "BKE_deform.h"
-#include "BKE_library.h"
#include "BKE_library_query.h"
#include "BKE_modifier.h"
#include "BKE_texture.h" /* Texture masking. */
@@ -126,21 +119,19 @@ static void initData(ModifierData *md)
wmd->mask_tex_mapping = MOD_DISP_MAP_LOCAL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md;
- CustomDataMask dataMask = 0;
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* Ask for UV coordinates if we need them. */
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
@@ -179,11 +170,13 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_GEOMETRY, "WeightVGMix Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGMix Modifier");
}
else if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) {
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGMix Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_GEOMETRY, "WeightVGMix Modifier");
+ DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGMix Modifier");
+ }
+ if (wmd->mask_texture != NULL) {
+ DEG_add_generic_id_relation(ctx->node, &wmd->mask_texture->id, "WeightVGMix Modifier");
}
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index cee5c266e59..2e2e4fe963d 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -17,18 +15,14 @@
*
* The Original Code is Copyright (C) 2011 by Bastien Montagne.
* All rights reserved.
- *
- * Contributor(s): None yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_weightvgproximity.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
#include "BLI_utildefines.h"
+
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -294,21 +288,19 @@ static void initData(ModifierData *md)
wmd->max_dist = 1.0f; /* vert arbitrary distance, but don't use 0 */
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md;
- CustomDataMask dataMask = 0;
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* Ask for UV coordinates if we need them. */
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
@@ -352,8 +344,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
}
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
- DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
+ if (wmd->mask_texture != NULL) {
+ DEG_add_generic_id_relation(ctx->node, &wmd->mask_texture->id, "WeightVGProximity Modifier");
+ }
+ DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGProximity Modifier");
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -489,8 +483,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const bool use_trgt_faces = (wmd->proximity_flags & MOD_WVG_PROXIMITY_GEOM_FACES) != 0;
if (use_trgt_verts || use_trgt_edges || use_trgt_faces) {
- bool target_mesh_free;
- Mesh *target_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(obr, &target_mesh_free);
+ Mesh *target_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(obr, false);
/* We must check that we do have a valid target_mesh! */
if (target_mesh != NULL) {
@@ -513,10 +506,6 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
MEM_SAFE_FREE(dists_v);
MEM_SAFE_FREE(dists_e);
MEM_SAFE_FREE(dists_f);
-
- if (target_mesh_free) {
- BKE_id_free(NULL, target_mesh);
- }
}
/* Else, fall back to default obj2vert behavior. */
else {
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index a47be7b5244..2f70ab16cf8 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -1,6 +1,4 @@
/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -14,20 +12,17 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- *
*/
-/** \file blender/modifiers/intern/MOD_wireframe.c
- * \ingroup modifiers
+/** \file
+ * \ingroup modifiers
*/
+#include "BLI_utildefines.h"
+
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
-#include "BLI_utildefines.h"
-
#include "BKE_deform.h"
#include "BKE_mesh.h"
@@ -44,16 +39,14 @@ static void initData(ModifierData *md)
wmd->crease_weight = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WireframeModifierData *wmd = (WireframeModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (wmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
-
+ if (wmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool dependsOnNormals(ModifierData *UNUSED(md))
@@ -74,9 +67,9 @@ static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh *
&(struct BMeshFromMeshParams){
.calc_face_normal = true,
.add_key_index = false,
- .use_shapekey = true,
- .active_shapekey = ob->shapenr,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .use_shapekey = false,
+ .active_shapekey = 0,
+ .cd_mask_extra = {.vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX},
});
BM_mesh_wireframe(
@@ -94,7 +87,7 @@ static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh *
MAX2(ob->totcol - 1, 0),
false);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;