Page MenuHome
Paste P946

T55494 snippet
ActivePublic

Authored by Philipp Oeser (lichtwerk) on Apr 2 2019, 9:53 AM.
possible fix for T55494
note: ignore the (commented out) stuff about applying to object data [not needed afaict]
but object matrix, scale etc. on the evaluated object needs to be up to date...
This would go in line with the fixes for T62601/ T60623 where we prepare the evaluated object as best as we can as well.
(in order for immediate calls to 'BKE_object_workob_calc_parent()' to work - before depsgraph did its magic...)
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index f7a49f3fcb7..c7480e49d2b 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -57,6 +57,7 @@
#include "BKE_gpencil.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_define.h"
#include "RNA_access.h"
@@ -532,6 +533,8 @@ static int apply_objects_internal(
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+
/* calculate rotation/scale matrix */
if (apply_scale && apply_rot)
BKE_object_to_mat3(ob, rsmat);
@@ -571,35 +574,45 @@ static int apply_objects_internal(
/* apply to object data */
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
+ //Mesh *me_eval = ob_eval->data;
if (apply_scale)
multiresModifier_scale_disp(depsgraph, scene, ob);
/* adjust data */
BKE_mesh_transform(me, mat, true);
+ //BKE_mesh_transform(me_eval, mat, true);
/* update normals */
BKE_mesh_calc_normals(me);
+ //BKE_mesh_calc_normals(me_eval);
}
else if (ob->type == OB_ARMATURE) {
ED_armature_transform_apply(bmain, ob, mat, do_props);
+ //ED_armature_transform_apply(bmain, ob_eval, mat, do_props);
}
else if (ob->type == OB_LATTICE) {
Lattice *lt = ob->data;
-
+ //Lattice *lt_eval = ob_eval->data;
BKE_lattice_transform(lt, mat, true);
+ //BKE_lattice_transform(lt_eval, mat, true);
}
else if (ob->type == OB_MBALL) {
MetaBall *mb = ob->data;
+ //MetaBall *mb_eval = ob_eval->data;
BKE_mball_transform(mb, mat, do_props);
+ //BKE_mball_transform(mb_eval, mat, do_props);
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = ob->data;
+ //Curve *cu_eval = ob_eval->data;
scale = mat3_to_scale(rsmat);
BKE_curve_transform_ex(cu, mat, true, do_props, scale);
+ //BKE_curve_transform_ex(cu_eval, mat, true, do_props, scale);
}
else if (ob->type == OB_FONT) {
Curve *cu = ob->data;
+ //Curve *cu_eval = ob_eval->data;
int i;
scale = mat3_to_scale(rsmat);
@@ -610,15 +623,24 @@ static int apply_objects_internal(
tb->y *= scale;
tb->w *= scale;
tb->h *= scale;
+
+ //TextBox *tb_eval = &cu_eval->tb[i];
+ //tb_eval->x *= scale;
+ //tb_eval->y *= scale;
+ //tb_eval->w *= scale;
+ //tb_eval->h *= scale;
}
if (do_props) {
cu->fsize *= scale;
+ //cu_eval->fsize *= scale;
}
}
else if (ob->type == OB_GPENCIL) {
bGPdata *gpd = ob->data;
+ //bGPdata *gpd_eval = ob_eval->data;
BKE_gpencil_transform(gpd, mat);
+ //BKE_gpencil_transform(gpd_eval, mat);
}
else if (ob->type == OB_CAMERA) {
MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
@@ -651,10 +673,13 @@ static int apply_objects_internal(
{
float max_scale = max_fff(fabsf(ob->scale[0]), fabsf(ob->scale[1]), fabsf(ob->scale[2]));
ob->empty_drawsize *= max_scale;
+ //float max_scale_eval = max_fff(fabsf(ob_eval->scale[0]), fabsf(ob_eval->scale[1]), fabsf(ob_eval->scale[2]));
+ //ob_eval->empty_drawsize *= max_scale_eval;
}
}
else if (ob->type == OB_LAMP) {
Light *la = ob->data;
+ //Light *la_eval = ob_eval->data;
if (la->type != LA_AREA) {
continue;
}
@@ -663,36 +688,54 @@ static int apply_objects_internal(
if ((la->area_shape == LA_AREA_SQUARE) && !keeps_aspect_ratio) {
la->area_shape = LA_AREA_RECT;
la->area_sizey = la->area_size;
+ //la_eval->area_shape = LA_AREA_RECT;
+ //la_eval->area_sizey = la->area_size;
}
else if ((la->area_shape == LA_AREA_DISK) && !keeps_aspect_ratio) {
la->area_shape = LA_AREA_ELLIPSE;
la->area_sizey = la->area_size;
+ //la_eval->area_shape = LA_AREA_ELLIPSE;
+ //la_eval->area_sizey = la->area_size;
}
la->area_size *= rsmat[0][0];
la->area_sizey *= rsmat[1][1];
la->area_sizez *= rsmat[2][2];
+ //la_eval->area_size *= rsmat[0][0];
+ //la_eval->area_sizey *= rsmat[1][1];
+ //la_eval->area_sizez *= rsmat[2][2];
}
else {
continue;
}
- if (apply_loc)
+ if (apply_loc) {
zero_v3(ob->loc);
- if (apply_scale)
+ zero_v3(ob_eval->loc);
+ }
+ if (apply_scale) {
ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f;
+ ob_eval->scale[0] = ob_eval->scale[1] = ob_eval->scale[2] = 1.0f;
+ }
if (apply_rot) {
zero_v3(ob->rot);
unit_qt(ob->quat);
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
+ zero_v3(ob_eval->rot);
+ unit_qt(ob_eval->quat);
+ unit_axis_angle(ob_eval->rotAxis, &ob_eval->rotAngle);
}
BKE_object_where_is_calc(depsgraph, scene, ob);
+ BKE_object_where_is_calc(depsgraph, scene, ob_eval);
+
if (ob->type == OB_ARMATURE) {
BKE_pose_where_is(depsgraph, scene, ob); /* needed for bone parents */
+ BKE_pose_where_is(depsgraph, scene, ob_eval); /* needed for bone parents */
}
ignore_parent_tx(C, bmain, scene, ob);
+ ignore_parent_tx(C, bmain, scene, ob_eval);
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);