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_screw.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_screw.c')
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 1de2a976fca..2c795a8d9ad 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -49,6 +49,7 @@
#include "BKE_mesh.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
#include "MEM_guardedalloc.h"
@@ -245,6 +246,8 @@ static Mesh *applyModifier(
MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new;
MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base;
+ Object *ob_axis = DEG_get_evaluated_object(ctx->depsgraph, ltmd->ob_axis);
+
ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL;
const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0;
@@ -270,10 +273,10 @@ static Mesh *applyModifier(
axis_vec[ltmd->axis] = 1.0f;
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
/* calc the matrix relative to the axis object */
invert_m4_m4(mtx_tmp_a, ctx->object->obmat);
- copy_m4_m4(mtx_tx_inv, ltmd->ob_axis->obmat);
+ copy_m4_m4(mtx_tx_inv, ob_axis->obmat);
mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv);
/* calc the axis vec */
@@ -508,7 +511,7 @@ static Mesh *applyModifier(
med_new = medge_new;
mv_new = mvert_new;
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
/*mtx_tx is initialized early on */
for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) {
vc->co[0] = mv_new->co[0] = mv_orig->co[0];
@@ -839,7 +842,7 @@ static Mesh *applyModifier(
/* Rotation Matrix */
step_angle = (angle / (float)(step_tot - (!close))) * (float)step;
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle);
}
else {
@@ -871,7 +874,7 @@ static Mesh *applyModifier(
/* only need to set these if using non cleared memory */
/*mv_new->mat_nr = mv_new->flag = 0;*/
- if (ltmd->ob_axis) {
+ if (ob_axis != NULL) {
sub_v3_v3(mv_new->co, mtx_tx[3]);
mul_m4_v3(mat, mv_new->co);
@@ -1098,7 +1101,7 @@ static Mesh *applyModifier(
Mesh *result_prev = result;
result = mesh_remove_doubles_on_axis(
result, mvert_new, totvert, step_tot,
- axis_vec, ltmd->ob_axis ? mtx_tx[3] : NULL, ltmd->merge_dist);
+ axis_vec, ob_axis != NULL ? mtx_tx[3] : NULL, ltmd->merge_dist);
if (result != result_prev) {
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
}