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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-10-16 13:48:35 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-16 14:16:53 +0300
commit4475c49e2f901ba034b086ca856848ee2071af34 (patch)
tree330532f16392ffc11c22a7bf97c40311f170609e /source
parent3b84dce96967e7a9fe568e2518ee774843d48733 (diff)
Fix T81591: Align view to active is not working in sculpt mode
Remove sculpt/paint checks in getTransformOrientation_ex This code goes back a long time (early 2.5x). I couldn't find any reason why sculpt/paint checks were being made. This makes the following changes: - When in object mode, the object must be selected. Since this function typically operates on the selected items. - When in paint/particle modes, the objects matrix is always used regardless of selection, since object selection can't be controlled in these modes. - When there is no active object, the first selected object is no longer used as it's quite an arbitrary decision & not something done elsewhere with objects in Blender.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/transform/transform_orientations.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 3cd4c12980c..8ad61288461 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -744,7 +744,6 @@ int getTransformOrientation_ex(const bContext *C,
{
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C);
- Base *base;
int result = ORIENTATION_NONE;
const bool activeOnly = (around == V3D_AROUND_ACTIVE);
@@ -1236,30 +1235,30 @@ int getTransformOrientation_ex(const bContext *C,
result = ORIENTATION_EDGE;
}
}
- else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
- /* pass */
- }
else {
/* we need the one selected object, if its not active */
- base = BASACT(view_layer);
- ob = OBACT(view_layer);
- if (base && ((base->flag & BASE_SELECTED) != 0)) {
- /* pass */
- }
- else {
- /* first selected */
- ob = NULL;
- for (base = view_layer->object_bases.first; base; base = base->next) {
- if (BASE_SELECTED_EDITABLE(v3d, base)) {
- ob = base->object;
- break;
+ if (ob != NULL) {
+ bool ok = false;
+ if (activeOnly || (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
+ /* Ignore selection state. */
+ ok = true;
+ }
+ else {
+ Base *base = BKE_view_layer_base_find(view_layer, ob);
+ if (UNLIKELY(base == NULL)) {
+ /* This is very unlikely, if it happens allow the value to be set since the caller
+ * may have taken the object from outside this view-layer. */
+ ok = true;
+ }
+ else if (BASE_SELECTED(v3d, base)) {
+ ok = true;
}
}
- }
- if (ob) {
- copy_v3_v3(normal, ob->obmat[2]);
- copy_v3_v3(plane, ob->obmat[1]);
+ if (ok) {
+ copy_v3_v3(normal, ob->obmat[2]);
+ copy_v3_v3(plane, ob->obmat[1]);
+ }
}
result = ORIENTATION_NORMAL;
}