Transform: revert use of evaluated objects

This is no longer needed.
This commit is contained in:
Campbell Barton 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 */
static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
{
Depsgraph *depsgraph = t->depsgraph;
Scene *scene = t->scene;
bool constinv;
bool skip_invert = false;
if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
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 */
// XXX: This needs fixing for COW. May need rigidbody_world from scene
if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) {
/* save original object transform */
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);
/* disable constraints inversion for dummy pass */
// XXX: Should this use ob or ob_eval?! It's not clear!
if (t->mode == TFM_DUMMY)
skip_invert = true;
Scene *scene_eval = DEG_get_evaluated_scene(t->depsgraph);
if (skip_invert == false && constinv == false) {
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ob_eval->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
BKE_object_where_is_calc(t->depsgraph, scene_eval, ob_eval);
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);
ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */
BKE_object_where_is_calc(t->depsgraph, t->scene, ob);
ob->transflag &= ~OB_NO_CONSTRAINTS;
}
else
BKE_object_where_is_calc(t->depsgraph, t->scene, ob);
td->ob = ob;
td->loc = ob->loc;
copy_v3_v3(td->iloc, ob->loc);
copy_v3_v3(td->iloc, td->loc);
if (ob->rotmode > 0) {
td->ext->rot = ob->rot;

View File

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

View File

@ -56,8 +56,6 @@
#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "DEG_depsgraph_query.h"
#include "BLT_translation.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)) {
const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bArmature *arm = ob_eval->data;
bArmature *arm = ob->data;
bPoseChannel *pchan;
float imat[3][3], mat[3][3];
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(plane, pchan->pose_mat[1]);
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);
if (totsel) {
/* 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) {
add_v3_v3(normal, pchan->pose_mat[2]);
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 */
if (ok) {
/* 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);
transpose_m3(mat);