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-01 18:33:04 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-05-01 19:02:17 +0300
commit334b55fd2e89d66023a499e1ce7f867d9789290d (patch)
tree3afcc711d6a9eeda85d9ae069ce1ac9cfc9fcb89 /source/blender/modifiers/intern/MOD_shapekey.c
parent6b9f1ffe6e56ee4d55f4cde5c724c31a3a90292b (diff)
Extract common modifier parameters into ModifierEvalContext struct
The contents of the ModifierEvalContext struct are constant while iterating over the modifier stack. The struct thus should be only created once, outside any loop over the modifiers.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_shapekey.c')
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 7908b42c1f9..8c4664414d5 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -44,28 +44,27 @@
#include "MOD_modifiertypes.h"
-static void deformVerts(ModifierData *UNUSED(md), struct Depsgraph *UNUSED(depsgraph),
- Object *ob, DerivedMesh *UNUSED(derivedData),
+static void deformVerts(ModifierData *UNUSED(md), const ModifierEvalContext *ctx,
+ DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
- int numVerts,
- ModifierApplyFlag UNUSED(flag))
+ int numVerts)
{
- Key *key = BKE_key_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
if (key && key->block.first) {
int deformedVerts_tot;
BKE_key_evaluate_object_ex(
- ob, &deformedVerts_tot,
+ ctx->object, &deformedVerts_tot,
(float *)vertexCos, sizeof(*vertexCos) * numVerts);
}
}
-static void deformMatrices(ModifierData *md, struct Depsgraph *depsgraph, Object *ob, DerivedMesh *derivedData,
+static void deformMatrices(ModifierData *md, const ModifierEvalContext *ctx, DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
{
- Key *key = BKE_key_from_object(ob);
- KeyBlock *kb = BKE_keyblock_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
+ KeyBlock *kb = BKE_keyblock_from_object(ctx->object);
float scale[3][3];
(void)vertexCos; /* unused */
@@ -73,37 +72,37 @@ static void deformMatrices(ModifierData *md, struct Depsgraph *depsgraph, Object
if (kb && kb->totelem == numVerts && kb != key->refkey) {
int a;
- if (ob->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1);
+ if (ctx->object->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1);
else scale_m3_fl(scale, kb->curval);
for (a = 0; a < numVerts; a++)
copy_m3_m3(defMats[a], scale);
}
- deformVerts(md, depsgraph, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, ctx, derivedData, vertexCos, numVerts);
}
-static void deformVertsEM(ModifierData *md, struct Depsgraph *depsgraph, Object *ob,
+static void deformVertsEM(ModifierData *md, const ModifierEvalContext *ctx,
struct BMEditMesh *UNUSED(editData),
DerivedMesh *derivedData,
float (*vertexCos)[3],
int numVerts)
{
- Key *key = BKE_key_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
if (key && key->type == KEY_RELATIVE)
- deformVerts(md, depsgraph, ob, derivedData, vertexCos, numVerts, 0);
+ deformVerts(md, ctx, derivedData, vertexCos, numVerts);
}
-static void deformMatricesEM(ModifierData *UNUSED(md), struct Depsgraph *UNUSED(depsgraph),
- Object *ob, struct BMEditMesh *UNUSED(editData),
+static void deformMatricesEM(ModifierData *UNUSED(md), const ModifierEvalContext *ctx,
+ struct BMEditMesh *UNUSED(editData),
DerivedMesh *UNUSED(derivedData),
float (*vertexCos)[3],
float (*defMats)[3][3],
int numVerts)
{
- Key *key = BKE_key_from_object(ob);
- KeyBlock *kb = BKE_keyblock_from_object(ob);
+ Key *key = BKE_key_from_object(ctx->object);
+ KeyBlock *kb = BKE_keyblock_from_object(ctx->object);
float scale[3][3];
(void)vertexCos; /* unused */