Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/modifiers/intern/MOD_laplaciandeform.c')
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c89
1 files changed, 51 insertions, 38 deletions
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 81cfa980135..6ece9fb1f1b 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -35,10 +35,15 @@
#include "MEM_guardedalloc.h"
+#include "BKE_deform.h"
+#include "BKE_editmesh.h"
+#include "BKE_library.h"
#include "BKE_mesh_mapping.h"
-#include "BKE_cdderivedmesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_particle.h"
-#include "BKE_deform.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
#include "MOD_util.h"
@@ -499,18 +504,18 @@ static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3])
}
}
-static bool isValidVertexGroup(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm)
+static bool isValidVertexGroup(LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh)
{
int defgrp_index;
MDeformVert *dvert = NULL;
- modifier_get_vgroup(ob, dm, lmd->anchor_grp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup_mesh(ob, mesh, lmd->anchor_grp_name, &dvert, &defgrp_index);
return (dvert != NULL);
}
static void initSystem(
- LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm,
+ LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
int i;
@@ -521,7 +526,7 @@ static void initSystem(
MDeformVert *dv = NULL;
LaplacianSystem *sys;
- if (isValidVertexGroup(lmd, ob, dm)) {
+ if (isValidVertexGroup(lmd, ob, mesh)) {
int *index_anchors = MEM_malloc_arrayN(numVerts, sizeof(int), __func__); /* over-alloc */
const MLoopTri *mlooptri;
const MLoop *mloop;
@@ -530,7 +535,7 @@ static void initSystem(
STACK_INIT(index_anchors, numVerts);
- modifier_get_vgroup(ob, dm, lmd->anchor_grp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup_mesh(ob, mesh, lmd->anchor_grp_name, &dvert, &defgrp_index);
BLI_assert(dvert != NULL);
dv = dvert;
for (i = 0; i < numVerts; i++) {
@@ -542,8 +547,8 @@ static void initSystem(
}
total_anchors = STACK_SIZE(index_anchors);
- lmd->cache_system = initLaplacianSystem(numVerts, dm->getNumEdges(dm), dm->getNumLoopTri(dm),
- total_anchors, lmd->anchor_grp_name, lmd->repeat);
+ lmd->cache_system = initLaplacianSystem(numVerts, mesh->totedge, BKE_mesh_runtime_looptri_len(mesh),
+ total_anchors, lmd->anchor_grp_name, lmd->repeat);
sys = (LaplacianSystem *)lmd->cache_system;
memcpy(sys->index_anchors, index_anchors, sizeof(int) * total_anchors);
memcpy(sys->co, vertexCos, sizeof(float[3]) * numVerts);
@@ -553,15 +558,15 @@ static void initSystem(
lmd->total_verts = numVerts;
createFaceRingMap(
- dm->getNumVerts(dm), dm->getLoopTriArray(dm), dm->getNumLoopTri(dm),
- dm->getLoopArray(dm), &sys->ringf_map, &sys->ringf_indices);
+ mesh->totvert, BKE_mesh_runtime_looptri_ensure(mesh), BKE_mesh_runtime_looptri_len(mesh),
+ mesh->mloop, &sys->ringf_map, &sys->ringf_indices);
createVertRingMap(
- dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm),
+ mesh->totvert, mesh->medge, mesh->totedge,
&sys->ringv_map, &sys->ringv_indices);
- mlooptri = dm->getLoopTriArray(dm);
- mloop = dm->getLoopArray(dm);
+ mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
+ mloop = mesh->mloop;;
for (i = 0; i < sys->total_tris; i++) {
sys->tris[i][0] = mloop[mlooptri[i].tri[0]].v;
@@ -571,7 +576,7 @@ static void initSystem(
}
}
-static int isSystemDifferent(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm, int numVerts)
+static int isSystemDifferent(LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, int numVerts)
{
int i;
int defgrp_index;
@@ -584,13 +589,13 @@ static int isSystemDifferent(LaplacianDeformModifierData *lmd, Object *ob, Deriv
if (sys->total_verts != numVerts) {
return LAPDEFORM_SYSTEM_CHANGE_VERTEXES;
}
- if (sys->total_edges != dm->getNumEdges(dm)) {
+ if (sys->total_edges != mesh->totedge) {
return LAPDEFORM_SYSTEM_CHANGE_EDGES;
}
if (!STREQ(lmd->anchor_grp_name, sys->anchor_grp_name)) {
return LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP;
}
- modifier_get_vgroup(ob, dm, lmd->anchor_grp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup_mesh(ob, mesh, lmd->anchor_grp_name, &dvert, &defgrp_index);
if (!dvert) {
return LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP;
}
@@ -610,7 +615,7 @@ static int isSystemDifferent(LaplacianDeformModifierData *lmd, Object *ob, Deriv
}
static void LaplacianDeformModifier_do(
- LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh *dm,
+ LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
float (*filevertexCos)[3];
@@ -628,7 +633,7 @@ static void LaplacianDeformModifier_do(
return;
}
if (lmd->cache_system) {
- sysdif = isSystemDifferent(lmd, ob, dm, numVerts);
+ sysdif = isSystemDifferent(lmd, ob, mesh, numVerts);
sys = lmd->cache_system;
if (sysdif) {
if (sysdif == LAPDEFORM_SYSTEM_ONLY_CHANGE_ANCHORS || sysdif == LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP) {
@@ -638,7 +643,7 @@ static void LaplacianDeformModifier_do(
lmd->total_verts = 0;
deleteLaplacianSystem(sys);
lmd->cache_system = NULL;
- initSystem(lmd, ob, dm, filevertexCos, numVerts);
+ initSystem(lmd, ob, mesh, filevertexCos, numVerts);
sys = lmd->cache_system; /* may have been reallocated */
MEM_SAFE_FREE(filevertexCos);
if (sys) {
@@ -650,7 +655,7 @@ static void LaplacianDeformModifier_do(
modifier_setError(&lmd->modifier, "Vertices changed from %d to %d", lmd->total_verts, numVerts);
}
else if (sysdif == LAPDEFORM_SYSTEM_CHANGE_EDGES) {
- modifier_setError(&lmd->modifier, "Edges changed from %d to %d", sys->total_edges, dm->getNumEdges(dm));
+ modifier_setError(&lmd->modifier, "Edges changed from %d to %d", sys->total_edges, mesh->totedge);
}
else if (sysdif == LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP) {
modifier_setError(&lmd->modifier, "Vertex group '%s' is not valid", sys->anchor_grp_name);
@@ -663,7 +668,7 @@ static void LaplacianDeformModifier_do(
}
}
else {
- if (!isValidVertexGroup(lmd, ob, dm)) {
+ if (!isValidVertexGroup(lmd, ob, mesh)) {
modifier_setError(&lmd->modifier, "Vertex group '%s' is not valid", lmd->anchor_grp_name);
lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND;
}
@@ -672,13 +677,13 @@ static void LaplacianDeformModifier_do(
memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * numVerts);
MEM_SAFE_FREE(lmd->vertexco);
lmd->total_verts = 0;
- initSystem(lmd, ob, dm, filevertexCos, numVerts);
+ initSystem(lmd, ob, mesh, filevertexCos, numVerts);
sys = lmd->cache_system;
MEM_SAFE_FREE(filevertexCos);
laplacianDeformPreview(sys, vertexCos);
}
else {
- initSystem(lmd, ob, dm, vertexCos, numVerts);
+ initSystem(lmd, ob, mesh, vertexCos, numVerts);
sys = lmd->cache_system;
laplacianDeformPreview(sys, vertexCos);
}
@@ -710,7 +715,7 @@ static void copyData(const ModifierData *md, ModifierData *target)
tlmd->cache_system = NULL;
}
-static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
+static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, int UNUSED(useRenderParams))
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
if (lmd->anchor_grp_name[0]) return 0;
@@ -726,26 +731,26 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
static void deformVerts(
- ModifierData *md, Object *ob, DerivedMesh *derivedData,
- float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag))
+ ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
+ float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, false, false);
+ Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false);
- LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ob, dm, vertexCos, numVerts);
- if (dm != derivedData) {
- dm->release(dm);
+ LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts);
+ if (mesh_src != mesh) {
+ BKE_id_free(NULL, mesh_src);
}
}
static void deformVertsEM(
- ModifierData *md, Object *ob, struct BMEditMesh *editData,
- DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
+ ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
+ Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, false, false);
- LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ob, dm,
+ Mesh *mesh_src = get_mesh(ctx->object, editData, mesh, NULL, false, false);
+ LaplacianDeformModifier_do((LaplacianDeformModifierData *)md, ctx->object, mesh_src,
vertexCos, numVerts);
- if (dm != derivedData) {
- dm->release(dm);
+ if (mesh_src != mesh) {
+ BKE_id_free(NULL, mesh_src);
}
}
@@ -767,17 +772,25 @@ ModifierTypeInfo modifierType_LaplacianDeform = {
/* type */ eModifierTypeType_OnlyDeform,
/* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
+
+ /* deformVerts_DM */ NULL,
+ /* deformMatrices_DM */ NULL,
+ /* deformVertsEM_DM */ NULL,
+ /* deformMatricesEM_DM*/NULL,
+ /* applyModifier_DM */ NULL,
+ /* applyModifierEM_DM */NULL,
+
/* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ NULL,
/* applyModifier */ NULL,
/* applyModifierEM */ NULL,
+
/* initData */ initData,
/* requiredDataMask */ requiredDataMask,
/* freeData */ freeData,
/* isDisabled */ isDisabled,
- /* updateDepgraph */ NULL,
/* updateDepsgraph */ NULL,
/* dependsOnTime */ NULL,
/* dependsOnNormals */ NULL,