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-12-07 17:45:53 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-12-07 20:55:08 +0300
commitde491abf996281785391b18b3547d1bff305355f (patch)
tree9f6f13c1a48658353f2c4a5ea4885f324daf1b95 /source/blender/modifiers/intern/MOD_mirror.c
parent38ef3d6b91e128c93557991cb8cb9911c9b21f90 (diff)
Fix modifiers evaluation outside of depsgraph/CoW context.
Fix T58237: Exporters: Curve Modifier not applied when "apply modifiers" are selected. Fix T58856: Python: "to_mesh" broken in 2.8. ...And many other cases... ;) Thing is, we need target IDs to always be evaluated ones (at least I cannot see any case where having orig ones is desired effect here). Depsgraph/Cow system ensures us that when modifiers are evaluated by it, but they can also be called outside of this context, e.g. when doing binding, or object conversion... So we need to ensure in modifiers code that we actually are always working with eval data for those targets. Note that I did not touch to physics modifiers, those are a bit touchy and rather not 'fix' something there until proven broken!
Diffstat (limited to 'source/blender/modifiers/intern/MOD_mirror.c')
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 659ac0dee30..d24f32accf8 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -51,6 +51,7 @@
#include "MEM_guardedalloc.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
@@ -85,6 +86,7 @@ static Mesh *doBiscetOnMirrorPlane(
MirrorModifierData *mmd,
Object *ob,
const Mesh *mesh,
+ Object *mirror_ob,
int axis,
float mirrormat[4][4])
{
@@ -114,10 +116,10 @@ static Mesh *doBiscetOnMirrorPlane(
float plane_no[3];
copy_v3_v3(plane_no, mirrormat[axis]);
- if (mmd->mirror_ob) {
+ if (mirror_ob != NULL) {
float tmp[4][4];
invert_m4_m4(tmp, ob->obmat);
- mul_m4_m4m4(tmp, tmp, mmd->mirror_ob->obmat);
+ mul_m4_m4m4(tmp, tmp, mirror_ob->obmat);
copy_v3_v3(plane_no, tmp[axis]);
copy_v3_v3(plane_co, tmp[3]);
@@ -151,6 +153,7 @@ static Mesh *doBiscetOnMirrorPlane(
static Mesh *doMirrorOnAxis(
MirrorModifierData *mmd,
+ const ModifierEvalContext *ctx,
Object *ob,
const Mesh *mesh,
int axis)
@@ -178,13 +181,14 @@ static Mesh *doMirrorOnAxis(
unit_m4(mtx);
mtx[axis][axis] = -1.0f;
- if (mmd->mirror_ob) {
+ Object *mirror_ob = DEG_get_evaluated_object(ctx->depsgraph, mmd->mirror_ob);
+ if (mirror_ob != NULL) {
float tmp[4][4];
float itmp[4][4];
/* tmp is a transform from coords relative to the object's own origin,
* to coords relative to the mirror object origin */
- invert_m4_m4(tmp, mmd->mirror_ob->obmat);
+ invert_m4_m4(tmp, mirror_ob->obmat);
mul_m4_m4m4(tmp, tmp, ob->obmat);
/* itmp is the reverse transform back to origin-relative coordinates */
@@ -200,7 +204,7 @@ static Mesh *doMirrorOnAxis(
Mesh *mesh_bisect = NULL;
if (do_bisect) {
- mesh_bisect = doBiscetOnMirrorPlane(mmd, ob, mesh, axis, mtx);
+ mesh_bisect = doBiscetOnMirrorPlane(mmd, ob, mesh, mirror_ob, axis, mtx);
mesh = mesh_bisect;
}
@@ -382,18 +386,18 @@ static Mesh *doMirrorOnAxis(
}
static Mesh *mirrorModifier__doMirror(
- MirrorModifierData *mmd,
+ MirrorModifierData *mmd, const ModifierEvalContext *ctx,
Object *ob, Mesh *mesh)
{
Mesh *result = mesh;
/* check which axes have been toggled and mirror accordingly */
if (mmd->flag & MOD_MIR_AXIS_X) {
- result = doMirrorOnAxis(mmd, ob, result, 0);
+ result = doMirrorOnAxis(mmd, ctx, ob, result, 0);
}
if (mmd->flag & MOD_MIR_AXIS_Y) {
Mesh *tmp = result;
- result = doMirrorOnAxis(mmd, ob, result, 1);
+ result = doMirrorOnAxis(mmd, ctx, ob, result, 1);
if (tmp != mesh) {
/* free intermediate results */
BKE_id_free(NULL, tmp);
@@ -401,7 +405,7 @@ static Mesh *mirrorModifier__doMirror(
}
if (mmd->flag & MOD_MIR_AXIS_Z) {
Mesh *tmp = result;
- result = doMirrorOnAxis(mmd, ob, result, 2);
+ result = doMirrorOnAxis(mmd, ctx, ob, result, 2);
if (tmp != mesh) {
/* free intermediate results */
BKE_id_free(NULL, tmp);
@@ -418,7 +422,7 @@ static Mesh *applyModifier(
Mesh *result;
MirrorModifierData *mmd = (MirrorModifierData *) md;
- result = mirrorModifier__doMirror(mmd, ctx->object, mesh);
+ result = mirrorModifier__doMirror(mmd, ctx, ctx->object, mesh);
if (result != mesh) {
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;