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 18:52:24 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-05-08 18:52:53 +0300
commit5f2a2e048da911e0a16acdf07d4914c60ebe1444 (patch)
tree16ce25b64f876af88bc869aa1bd85d620cfc3d2b /source/blender/modifiers/intern/MOD_cast.c
parente6d11c6ce66f94549d1fe896c59b67564ae19d68 (diff)
Modifier stack: Port Caqst to new Mesh-based system.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_cast.c')
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 18c64a24392..a2283fd66e9 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -33,6 +33,7 @@
*/
+#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -41,8 +42,10 @@
#include "BKE_deform.h"
-#include "BKE_DerivedMesh.h"
+#include "BKE_editmesh.h"
+#include "BKE_library.h"
#include "BKE_library_query.h"
+#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "MOD_util.h"
@@ -102,7 +105,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
static void sphere_do(
- CastModifierData *cmd, Object *ob, DerivedMesh *dm,
+ CastModifierData *cmd, Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
MDeformVert *dvert = NULL;
@@ -150,7 +153,7 @@ static void sphere_do(
/* 3) if we were given a vertex group name,
* only those vertices should be affected */
- modifier_get_vgroup(ob, dm, cmd->defgrp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup_mesh(ob, mesh, cmd->defgrp_name, &dvert, &defgrp_index);
if (flag & MOD_CAST_SIZE_FROM_RADIUS) {
len = cmd->radius;
@@ -223,7 +226,7 @@ static void sphere_do(
}
static void cuboid_do(
- CastModifierData *cmd, Object *ob, DerivedMesh *dm,
+ CastModifierData *cmd, Object *ob, Mesh *mesh,
float (*vertexCos)[3], int numVerts)
{
MDeformVert *dvert = NULL;
@@ -252,7 +255,7 @@ static void cuboid_do(
/* 3) if we were given a vertex group name,
* only those vertices should be affected */
- modifier_get_vgroup(ob, dm, cmd->defgrp_name, &dvert, &defgrp_index);
+ modifier_get_vgroup_mesh(ob, mesh, cmd->defgrp_name, &dvert, &defgrp_index);
if (ctrl_ob) {
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
@@ -420,43 +423,53 @@ static void cuboid_do(
}
static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
- DerivedMesh *derivedData,
+ Mesh *mesh,
float (*vertexCos)[3],
int numVerts)
{
- DerivedMesh *dm = NULL;
CastModifierData *cmd = (CastModifierData *)md;
- dm = get_dm(ctx->object, NULL, derivedData, NULL, false, false);
+ Mesh *mesh_src = mesh;
+
+ if (mesh_src == NULL) {
+ mesh_src = ctx->object->data;
+ }
+
+ BLI_assert(mesh_src->totvert == numVerts);
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
- cuboid_do(cmd, ctx->object, dm, vertexCos, numVerts);
+ cuboid_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
}
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
- sphere_do(cmd, ctx->object, dm, vertexCos, numVerts);
+ sphere_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
}
-
- if (dm != derivedData)
- dm->release(dm);
}
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);
CastModifierData *cmd = (CastModifierData *)md;
+ Mesh *mesh_src = mesh;
+
+ if (mesh_src == NULL) {
+ mesh_src = BKE_bmesh_to_mesh_nomain(editData->bm, &(struct BMeshToMeshParams){0});
+ }
+
+ BLI_assert(mesh_src->totvert == numVerts);
+
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
- cuboid_do(cmd, ctx->object, dm, vertexCos, numVerts);
+ cuboid_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
}
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
- sphere_do(cmd, ctx->object, dm, vertexCos, numVerts);
+ sphere_do(cmd, ctx->object, mesh_src, vertexCos, numVerts);
}
- if (dm != derivedData)
- dm->release(dm);
+ if (!mesh) {
+ BKE_id_free(NULL, mesh_src);
+ }
}
@@ -471,16 +484,16 @@ ModifierTypeInfo modifierType_Cast = {
/* 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,