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:
authorBastien Montagne <montagne29@wanadoo.fr>2018-05-08 17:42:01 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-05-08 17:42:01 +0300
commit5b3559576de5d9896ca2a7f200e1e51ee0fc8af5 (patch)
treea1b9df85d23fcea6e4b729b47bffa22e9397b7ac /source/blender/modifiers/intern/MOD_smooth.c
parent43be4343107b1dc2a05353a6ff41360cce27d629 (diff)
Modifier stack: Port Smooth to new Mesh-based system.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_smooth.c')
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c55
1 files changed, 34 insertions, 21 deletions
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index ace5a95cd22..fdf1e9da6bc 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -33,6 +33,7 @@
*/
+#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_math.h"
@@ -40,7 +41,9 @@
#include "MEM_guardedalloc.h"
-#include "BKE_cdderivedmesh.h"
+#include "BKE_editmesh.h"
+#include "BKE_library.h"
+#include "BKE_mesh.h"
#include "BKE_particle.h"
#include "BKE_deform.h"
@@ -83,7 +86,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
static void smoothModifier_do(
- SmoothModifierData *smd, Object *ob, DerivedMesh *dm,
+ SmoothModifierData *smd, Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
MDeformVert *dvert = NULL;
@@ -106,16 +109,16 @@ static void smoothModifier_do(
fac = smd->fac;
facm = 1 - fac;
- if (dm->getNumVerts(dm) == numVerts) {
- medges = dm->getEdgeArray(dm);
- numDMEdges = dm->getNumEdges(dm);
+ if (mesh->totvert == numVerts) {
+ medges = mesh->medge;
+ numDMEdges = mesh->totedge;
}
else {
medges = NULL;
numDMEdges = 0;
}
- modifier_get_vgroup(ob, dm, smd->defgrp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup_mesh(ob, mesh, smd->defgrp_name, &dvert, &defgrp_index);
/* NOTICE: this can be optimized a little bit by moving the
* if (dvert) out of the loop, if needed */
@@ -206,29 +209,39 @@ static void smoothModifier_do(
MEM_freeN(uctmp);
}
-static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
+ Mesh *mesh_src = mesh;
- smoothModifier_do((SmoothModifierData *)md, ctx->object, dm,
- vertexCos, numVerts);
+ if (mesh_src == NULL) {
+ mesh_src = ctx->object->data;
+ }
- if (dm != derivedData)
- dm->release(dm);
+ BLI_assert(mesh_src->totvert == numVerts);
+
+ smoothModifier_do((SmoothModifierData *)md, ctx->object, mesh_src,
+ vertexCos, numVerts);
}
static void deformVertsEM(
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *editData,
- DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
+ Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- DerivedMesh *dm = get_dm(ctx->object, editData, derivedData, NULL, false, false);
+ Mesh *mesh_src = mesh;
- smoothModifier_do((SmoothModifierData *)md, ctx->object, dm,
+ if (mesh_src == NULL) {
+ mesh_src = BKE_bmesh_to_mesh_nomain(editData->bm, &(struct BMeshToMeshParams){0});
+ }
+
+ BLI_assert(mesh_src->totvert == numVerts);
+
+ smoothModifier_do((SmoothModifierData *)md, ctx->object, mesh_src,
vertexCos, numVerts);
- if (dm != derivedData)
- dm->release(dm);
+ if (!mesh) {
+ BKE_id_free(NULL, mesh_src);
+ }
}
@@ -243,16 +256,16 @@ ModifierTypeInfo modifierType_Smooth = {
/* copyData */ modifier_copyData_generic,
- /* deformVerts_DM */ deformVerts,
+ /* deformVerts_DM */ NULL,
/* deformMatrices_DM */ NULL,
- /* deformVertsEM_DM */ deformVertsEM,
+ /* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
/* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
- /* deformVerts */ NULL,
+ /* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
- /* deformVertsEM */ NULL,
+ /* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ NULL,
/* applyModifier */ NULL,
/* applyModifierEM */ NULL,