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:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 45284c1805a..0ae69debf18 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -244,22 +244,21 @@ void view3d_orbit_apply_dyn_ofs(
static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
{
static float lastofs[3] = {0, 0, 0};
- const WorkSpace *workspace = CTX_wm_workspace(C);
bool is_set = false;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob_act = OBACT(view_layer);
- if (ob_act && (workspace->object_mode & OB_MODE_ALL_PAINT) &&
+ if (ob_act && (ob_act->mode & OB_MODE_ALL_PAINT) &&
/* with weight-paint + pose-mode, fall through to using calculateTransformCenter */
- ((workspace->object_mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0)
+ ((ob_act->mode & OB_MODE_WEIGHT_PAINT) && BKE_object_pose_armature_get(ob_act)) == 0)
{
/* in case of sculpting use last average stroke position as a rotation
* center, in other cases it's not clear what rotation center shall be
* so just rotate around object origin
*/
- if (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
+ if (ob_act->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) {
float stroke[3];
BKE_paint_stroke_get_average(scene, ob_act, stroke);
copy_v3_v3(lastofs, stroke);
@@ -269,7 +268,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
}
is_set = true;
}
- else if (ob_act && (workspace->object_mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
+ else if (ob_act && (ob_act->mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) {
Curve *cu = ob_act->data;
EditFont *ef = cu->editfont;
int i;
@@ -284,7 +283,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
is_set = true;
}
- else if (ob_act == NULL || workspace->object_mode == OB_MODE_OBJECT) {
+ else if (ob_act == NULL || ob_act->mode == OB_MODE_OBJECT) {
/* object mode use boundbox centers */
Base *base;
unsigned int tot = 0;
@@ -2793,7 +2792,6 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
/* like a localview without local!, was centerview() in 2.4x */
static int viewselected_exec(bContext *C, wmOperator *op)
{
- const WorkSpace *workspace = CTX_wm_workspace(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
@@ -2817,10 +2815,16 @@ static int viewselected_exec(bContext *C, wmOperator *op)
ob = NULL;
}
- if (ob && (workspace->object_mode & OB_MODE_WEIGHT_PAINT)) {
- Object *ob_armature = BKE_object_pose_armature_get_visible(ob, view_layer);
- if (ob_armature) {
- ob = ob_armature;
+ if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT)) {
+ /* hard-coded exception, we look for the one selected armature */
+ /* this is weak code this way, we should make a generic active/selection callback interface once... */
+ Base *base;
+ for (base = view_layer->object_bases.first; base; base = base->next) {
+ if (TESTBASELIB(base)) {
+ if (base->object->type == OB_ARMATURE)
+ if (base->object->mode & OB_MODE_POSE)
+ break;
+ }
}
}
@@ -2842,17 +2846,17 @@ static int viewselected_exec(bContext *C, wmOperator *op)
else if (obedit) {
ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */
}
- else if (ob && (workspace->object_mode & OB_MODE_POSE)) {
+ else if (ob && (ob->mode & OB_MODE_POSE)) {
ok = BKE_pose_minmax(ob, min, max, true, true);
}
- else if (BKE_paint_select_face_test(ob, workspace->object_mode)) {
+ else if (BKE_paint_select_face_test(ob)) {
ok = paintface_minmax(ob, min, max);
}
- else if (ob && (workspace->object_mode & OB_MODE_PARTICLE_EDIT)) {
+ else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
ok = PE_minmax(scene, view_layer, min, max);
}
else if (ob &&
- (workspace->object_mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)))
+ (ob->mode & (OB_MODE_SCULPT | OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)))
{
BKE_paint_stroke_get_average(scene, ob, min);
copy_v3_v3(max, min);
@@ -2964,8 +2968,7 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op))
v3d->ob_centre = obact; /* can be NULL */
if (obact && obact->type == OB_ARMATURE) {
- const WorkSpace *workspace = CTX_wm_workspace(C);
- if (workspace->object_mode & OB_MODE_POSE) {
+ if (obact->mode & OB_MODE_POSE) {
bPoseChannel *pcham_act = BKE_pose_channel_active(obact);
if (pcham_act) {
BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone));