Transform: revert use of evaluated objects

This is no longer needed.
This commit is contained in:
2018-06-05 09:48:38 +02:00
parent 1df228a416
commit 83db7a0070
3 changed files with 27 additions and 46 deletions

View File

@@ -5619,18 +5619,17 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
/* transcribe given object into TransData for Transforming */ /* transcribe given object into TransData for Transforming */
static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
{ {
Depsgraph *depsgraph = t->depsgraph;
Scene *scene = t->scene; Scene *scene = t->scene;
bool constinv; bool constinv;
bool skip_invert = false; bool skip_invert = false;
if (t->mode != TFM_DUMMY && ob->rigidbody_object) { if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
float rot[3][3], scale[3]; float rot[3][3], scale[3];
float ctime = DEG_get_ctime(depsgraph); float ctime = BKE_scene_frame_get(scene);
/* only use rigid body transform if simulation is running, avoids problems with initial setup of rigid bodies */ /* only use rigid body transform if simulation is running, avoids problems with initial setup of rigid bodies */
// XXX: This needs fixing for COW. May need rigidbody_world from scene
if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) { if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) {
/* save original object transform */ /* save original object transform */
copy_v3_v3(td->ext->oloc, ob->loc); copy_v3_v3(td->ext->oloc, ob->loc);
@@ -5665,26 +5664,21 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
constinv = constraints_list_needinv(t, &ob->constraints); constinv = constraints_list_needinv(t, &ob->constraints);
/* disable constraints inversion for dummy pass */ /* disable constraints inversion for dummy pass */
// XXX: Should this use ob or ob_eval?! It's not clear!
if (t->mode == TFM_DUMMY) if (t->mode == TFM_DUMMY)
skip_invert = true; skip_invert = true;
Scene *scene_eval = DEG_get_evaluated_scene(t->depsgraph);
if (skip_invert == false && constinv == false) { if (skip_invert == false && constinv == false) {
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
ob_eval->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */ BKE_object_where_is_calc(t->depsgraph, t->scene, ob);
BKE_object_where_is_calc(t->depsgraph, scene_eval, ob_eval); ob->transflag &= ~OB_NO_CONSTRAINTS;
ob_eval->transflag &= ~OB_NO_CONSTRAINTS;
}
else {
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_where_is_calc(t->depsgraph, scene_eval, ob_eval);
} }
else
BKE_object_where_is_calc(t->depsgraph, t->scene, ob);
td->ob = ob; td->ob = ob;
td->loc = ob->loc; td->loc = ob->loc;
copy_v3_v3(td->iloc, ob->loc); copy_v3_v3(td->iloc, td->loc);
if (ob->rotmode > 0) { if (ob->rotmode > 0) {
td->ext->rot = ob->rot; td->ext->rot = ob->rot;

View File

@@ -586,7 +586,6 @@ int ED_transform_calc_manipulator_stats(
const struct TransformCalcParams *params, const struct TransformCalcParams *params,
struct TransformBounds *tbounds) struct TransformBounds *tbounds)
{ {
const Depsgraph *depsgraph = CTX_data_depsgraph(C);
ScrArea *sa = CTX_wm_area(C); ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C); ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
@@ -596,8 +595,6 @@ int ED_transform_calc_manipulator_stats(
RegionView3D *rv3d = ar->regiondata; RegionView3D *rv3d = ar->regiondata;
Base *base; Base *base;
Object *ob = OBACT(view_layer); Object *ob = OBACT(view_layer);
Object *ob_eval = NULL;
Object *obedit_eval = NULL;
bGPdata *gpd = CTX_data_gpencil_data(C); bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
int a, totsel = 0; int a, totsel = 0;
@@ -612,9 +609,6 @@ int ED_transform_calc_manipulator_stats(
rv3d->twdrawflag = 0xFFFF; rv3d->twdrawflag = 0xFFFF;
ob_eval = DEG_get_evaluated_object(depsgraph, ob);
obedit_eval = DEG_get_evaluated_object(depsgraph, obedit);
/* global, local or normal orientation? /* global, local or normal orientation?
* if we could check 'totsel' now, this should be skipped with no selection. */ * if we could check 'totsel' now, this should be skipped with no selection. */
if (ob && !is_gp_edit) { if (ob && !is_gp_edit) {
@@ -629,7 +623,7 @@ int ED_transform_calc_manipulator_stats(
case V3D_MANIP_GIMBAL: case V3D_MANIP_GIMBAL:
{ {
float mat[3][3]; float mat[3][3];
if (gimbal_axis(ob_eval, mat)) { if (gimbal_axis(ob, mat)) {
copy_m4_m3(rv3d->twmat, mat); copy_m4_m3(rv3d->twmat, mat);
break; break;
} }
@@ -659,7 +653,7 @@ int ED_transform_calc_manipulator_stats(
copy_m4_m3(rv3d->twmat, mat); copy_m4_m3(rv3d->twmat, mat);
break; break;
} }
copy_m4_m4(rv3d->twmat, ob_eval->obmat); copy_m4_m4(rv3d->twmat, ob->obmat);
normalize_m4(rv3d->twmat); normalize_m4(rv3d->twmat);
break; break;
} }
@@ -699,7 +693,7 @@ int ED_transform_calc_manipulator_stats(
copy_m3_m4(tbounds->axis, rv3d->twmat); copy_m3_m4(tbounds->axis, rv3d->twmat);
if (params->use_local_axis && (ob && ob->mode & OB_MODE_EDIT)) { if (params->use_local_axis && (ob && ob->mode & OB_MODE_EDIT)) {
float diff_mat[3][3]; float diff_mat[3][3];
copy_m3_m4(diff_mat, ob_eval->obmat); copy_m3_m4(diff_mat, ob->obmat);
normalize_m3(diff_mat); normalize_m3(diff_mat);
invert_m3(diff_mat); invert_m3(diff_mat);
mul_m3_m3m3(tbounds->axis, tbounds->axis, diff_mat); mul_m3_m3m3(tbounds->axis, tbounds->axis, diff_mat);
@@ -762,7 +756,6 @@ int ED_transform_calc_manipulator_stats(
} }
else if (obedit) { else if (obedit) {
ob = obedit; ob = obedit;
ob_eval = obedit_eval;
if (obedit->type == OB_MESH) { if (obedit->type == OB_MESH) {
BMEditMesh *em = BKE_editmesh_from_object(obedit); BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMEditSelection ese; BMEditSelection ese;
@@ -937,9 +930,9 @@ int ED_transform_calc_manipulator_stats(
/* selection center */ /* selection center */
if (totsel) { if (totsel) {
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
mul_m4_v3(obedit_eval->obmat, tbounds->center); mul_m4_v3(obedit->obmat, tbounds->center);
mul_m4_v3(obedit_eval->obmat, tbounds->min); mul_m4_v3(obedit->obmat, tbounds->min);
mul_m4_v3(obedit_eval->obmat, tbounds->max); mul_m4_v3(obedit->obmat, tbounds->max);
} }
} }
else if (ob && (ob->mode & OB_MODE_POSE)) { else if (ob && (ob->mode & OB_MODE_POSE)) {
@@ -947,7 +940,7 @@ int ED_transform_calc_manipulator_stats(
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
bool ok = false; bool ok = false;
if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob_eval))) { if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) {
/* doesn't check selection or visibility intentionally */ /* doesn't check selection or visibility intentionally */
Bone *bone = pchan->bone; Bone *bone = pchan->bone;
if (bone) { if (bone) {
@@ -958,11 +951,11 @@ int ED_transform_calc_manipulator_stats(
} }
} }
else { else {
totsel = count_set_pose_transflags(&mode, 0, ob_eval); totsel = count_set_pose_transflags(&mode, 0, ob);
if (totsel) { if (totsel) {
/* use channels to get stats */ /* use channels to get stats */
for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) { for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
Bone *bone = pchan->bone; Bone *bone = pchan->bone;
if (bone && (bone->flag & BONE_TRANSFORM)) { if (bone && (bone->flag & BONE_TRANSFORM)) {
calc_tw_center(tbounds, pchan->pose_head); calc_tw_center(tbounds, pchan->pose_head);
@@ -975,9 +968,9 @@ int ED_transform_calc_manipulator_stats(
if (ok) { if (ok) {
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
mul_m4_v3(ob_eval->obmat, tbounds->center); mul_m4_v3(ob->obmat, tbounds->center);
mul_m4_v3(ob_eval->obmat, tbounds->min); mul_m4_v3(ob->obmat, tbounds->min);
mul_m4_v3(ob_eval->obmat, tbounds->max); mul_m4_v3(ob->obmat, tbounds->max);
} }
} }
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
@@ -1018,18 +1011,16 @@ int ED_transform_calc_manipulator_stats(
if (!TESTBASELIB(base)) { if (!TESTBASELIB(base)) {
continue; continue;
} }
Object *base_object_eval = DEG_get_evaluated_object(depsgraph, base->object);
if (ob == NULL) { if (ob == NULL) {
ob = base->object; ob = base->object;
ob_eval = base_object_eval;
} }
if (params->use_only_center || base_object_eval->bb == NULL) { if (params->use_only_center || base->object->bb == NULL) {
calc_tw_center(tbounds, base_object_eval->obmat[3]); calc_tw_center(tbounds, base->object->obmat[3]);
} }
else { else {
for (uint j = 0; j < 8; j++) { for (uint j = 0; j < 8; j++) {
float co[3]; float co[3];
mul_v3_m4v3(co, base_object_eval->obmat, base_object_eval->bb->vec[j]); mul_v3_m4v3(co, base->object->obmat, base->object->bb->vec[j]);
calc_tw_center(tbounds, co); calc_tw_center(tbounds, co);
} }
} }

View File

@@ -56,8 +56,6 @@
#include "BKE_scene.h" #include "BKE_scene.h"
#include "BKE_workspace.h" #include "BKE_workspace.h"
#include "DEG_depsgraph_query.h"
#include "BLT_translation.h" #include "BLT_translation.h"
#include "ED_armature.h" #include "ED_armature.h"
@@ -1016,14 +1014,12 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
} }
} }
else if (ob && (ob->mode & OB_MODE_POSE)) { else if (ob && (ob->mode & OB_MODE_POSE)) {
const Depsgraph *depsgraph = CTX_data_depsgraph(C); bArmature *arm = ob->data;
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bArmature *arm = ob_eval->data;
bPoseChannel *pchan; bPoseChannel *pchan;
float imat[3][3], mat[3][3]; float imat[3][3], mat[3][3];
bool ok = false; bool ok = false;
if (activeOnly && (pchan = BKE_pose_channel_active(ob_eval))) { if (activeOnly && (pchan = BKE_pose_channel_active(ob))) {
add_v3_v3(normal, pchan->pose_mat[2]); add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]); add_v3_v3(plane, pchan->pose_mat[1]);
ok = true; ok = true;
@@ -1034,7 +1030,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
totsel = count_bone_select(arm, &arm->bonebase, true); totsel = count_bone_select(arm, &arm->bonebase, true);
if (totsel) { if (totsel) {
/* use channels to get stats */ /* use channels to get stats */
for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) { for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) { if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
add_v3_v3(normal, pchan->pose_mat[2]); add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]); add_v3_v3(plane, pchan->pose_mat[1]);
@@ -1047,7 +1043,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
/* use for both active & all */ /* use for both active & all */
if (ok) { if (ok) {
/* we need the transpose of the inverse for a normal... */ /* we need the transpose of the inverse for a normal... */
copy_m3_m4(imat, ob_eval->obmat); copy_m3_m4(imat, ob->obmat);
invert_m3_m3(mat, imat); invert_m3_m3(mat, imat);
transpose_m3(mat); transpose_m3(mat);