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:
authorSybren A. Stüvel <sybren@stuvel.eu>2018-05-17 17:21:04 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-05-17 17:21:13 +0300
commit3b6a0f5fe0f26d15927c67e7ef4083fd722c9015 (patch)
treee44a2692a07af243496fd53b62a0b58569f2d169 /source/blender/modifiers/intern/MOD_surface.c
parentedf6676a77b30290918e60547544bc1a6f7a8838 (diff)
Modifiers: ported Surface DerivedMesh → Mesh
Diffstat (limited to 'source/blender/modifiers/intern/MOD_surface.c')
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index c05d021a845..7f3fa125cd9 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -35,14 +35,16 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "BKE_bvhutils.h"
+#include "BKE_library.h"
+#include "BKE_mesh.h"
+
#include "BLI_math.h"
#include "BLI_utildefines.h"
-
-#include "BKE_cdderivedmesh.h"
-
#include "MOD_modifiertypes.h"
#include "MOD_util.h"
@@ -66,9 +68,9 @@ static void freeData(ModifierData *md)
MEM_SAFE_FREE(surmd->bvhtree);
}
- if (surmd->dm) {
- surmd->dm->release(surmd->dm);
- surmd->dm = NULL;
+ if (surmd->mesh) {
+ BKE_id_free(NULL, surmd->mesh);
+ surmd->mesh = NULL;
}
MEM_SAFE_FREE(surmd->x);
@@ -84,34 +86,44 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
static void deformVerts(
ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *derivedData,
+ Mesh *mesh,
float (*vertexCos)[3],
int UNUSED(numVerts))
{
SurfaceModifierData *surmd = (SurfaceModifierData *) md;
- if (surmd->dm)
- surmd->dm->release(surmd->dm);
+ if (surmd->mesh) {
+ BKE_id_free(NULL, surmd->mesh);
+ }
- /* if possible use/create DerivedMesh */
- if (derivedData) surmd->dm = CDDM_copy(derivedData);
- else surmd->dm = get_dm(ctx->object, NULL, NULL, NULL, false, false);
+ 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);
+ }
+ else surmd->mesh = get_mesh(ctx->object, NULL, NULL, NULL, false, false);
if (!ctx->object->pd) {
printf("SurfaceModifier deformVerts: Should not happen!\n");
return;
}
- if (surmd->dm) {
+ if (surmd->mesh) {
unsigned int numverts = 0, i = 0;
int init = 0;
float *vec;
MVert *x, *v;
- CDDM_apply_vert_coords(surmd->dm, vertexCos);
- CDDM_calc_normals(surmd->dm);
+ BKE_mesh_apply_vert_coords(surmd->mesh, vertexCos);
+ BKE_mesh_calc_normals(surmd->mesh);
- numverts = surmd->dm->getNumVerts(surmd->dm);
+ numverts = surmd->mesh->totvert;
if (numverts != surmd->numverts ||
surmd->x == NULL ||
@@ -137,7 +149,7 @@ static void deformVerts(
/* convert to global coordinates and calculate velocity */
for (i = 0, x = surmd->x, v = surmd->v; i < numverts; i++, x++, v++) {
- vec = CDDM_get_vert(surmd->dm, i)->co;
+ vec = surmd->mesh->mvert[i].co;
mul_m4_v3(ctx->object->obmat, vec);
if (init)
@@ -155,10 +167,10 @@ static void deformVerts(
else
surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh");
- if (surmd->dm->getNumPolys(surmd->dm))
- bvhtree_from_mesh_get(surmd->bvhtree, surmd->dm, BVHTREE_FROM_LOOPTRI, 2);
+ if (surmd->mesh->totpoly)
+ BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2);
else
- bvhtree_from_mesh_get(surmd->bvhtree, surmd->dm, BVHTREE_FROM_EDGES, 2);
+ BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_EDGES, 2);
}
}
@@ -174,14 +186,14 @@ ModifierTypeInfo modifierType_Surface = {
/* copyData */ NULL,
- /* deformVerts_DM */ deformVerts,
+ /* deformVerts_DM */ NULL,
/* deformMatrices_DM */ NULL,
/* deformVertsEM_DM */ NULL,
/* deformMatricesEM_DM*/NULL,
/* applyModifier_DM */ NULL,
/* applyModifierEM_DM */NULL,
- /* deformVerts */ NULL,
+ /* deformVerts */ deformVerts,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,