Multi-Button Drag: not working properly for Object Dimensions #38587

Open
opened 2014-02-11 02:32:35 +01:00 by CodeManX · 65 comments
Member

System Information
Windows 7

Blender Version
Broken: 2014-02-11

Short description of error
Multi-Button Drag - https://developer.blender.org/D270 - doesn't work properly in N panel for Dimensions

If you drag over all 3, only X and Z change, Y remains unchanged. As mouse button is released, the first selected property will reset, only the last hovered is kept (and scale changed)

**System Information** Windows 7 **Blender Version** Broken: 2014-02-11 **Short description of error** Multi-Button Drag - https://developer.blender.org/D270 - doesn't work properly in N panel for Dimensions If you drag over all 3, only X and Z change, Y remains unchanged. As mouse button is released, the first selected property will reset, only the last hovered is kept (and scale changed)
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @CodeManX

Added subscriber: @CodeManX

#64496 was marked as duplicate of this issue

#64496 was marked as duplicate of this issue

#55225 was marked as duplicate of this issue

#55225 was marked as duplicate of this issue

#47977 was marked as duplicate of this issue

#47977 was marked as duplicate of this issue

#46025 was marked as duplicate of this issue

#46025 was marked as duplicate of this issue

#44340 was marked as duplicate of this issue

#44340 was marked as duplicate of this issue

#42657 was marked as duplicate of this issue

#42657 was marked as duplicate of this issue

#41347 was marked as duplicate of this issue

#41347 was marked as duplicate of this issue

#42759 was marked as duplicate of this issue

#42759 was marked as duplicate of this issue

#42433 was marked as duplicate of this issue

#42433 was marked as duplicate of this issue

#40511 was marked as duplicate of this issue

#40511 was marked as duplicate of this issue

#38760 was marked as duplicate of this issue

#38760 was marked as duplicate of this issue

#39019 was marked as duplicate of this issue

#39019 was marked as duplicate of this issue

#39227 was marked as duplicate of this issue

#39227 was marked as duplicate of this issue

#39665 was marked as duplicate of this issue

#39665 was marked as duplicate of this issue

#38820 was marked as duplicate of this issue

#38820 was marked as duplicate of this issue

#50043 was marked as duplicate of this issue

#50043 was marked as duplicate of this issue

#49638 was marked as duplicate of this issue

#49638 was marked as duplicate of this issue
CodeManX changed title from Multi-Button Drag: Only X and Z work for Object Dimensions to Multi-Button Drag: not working properly for Object Dimensions 2014-02-11 02:36:06 +01:00
Member

Added subscriber: @JoshuaLeung

Added subscriber: @JoshuaLeung
Campbell Barton was assigned by Sergey Sharybin 2014-02-12 10:43:26 +01:00

Added subscriber: @Sergey

Added subscriber: @Sergey

Object dimensions are broken and an abuse of RNA, IMHO - the same problem happens from Python and we had it reported too.

Basically they rely on one axis being set, then updating - before the other values are set.

This is in fact the same bug:

However since this is so user visible, it really should be addressed somehow, leaving open.

Object dimensions are broken and an abuse of RNA, IMHO - the same problem happens from Python and we had it reported too. Basically they rely on one axis being set, then updating - before the other values are set. This is in fact the same bug: - https://developer.blender.org/T31760 - https://developer.blender.org/T36958 However since this is so user visible, it really should be addressed somehow, leaving open.

Added subscriber: @lucacustom

Added subscriber: @lucacustom

◀ Merged tasks: #38760.

◀ Merged tasks: #38760.

Added subscribers: @candreacchio, @dfelinto

Added subscribers: @candreacchio, @dfelinto

◀ Merged tasks: #38820.

◀ Merged tasks: #38820.

Added subscriber: @AngelPat

Added subscriber: @AngelPat

Added subscribers: @PabloGilFernandez, @mont29, @DuarteRamos

Added subscribers: @PabloGilFernandez, @mont29, @DuarteRamos

◀ Merged tasks: #39019.

◀ Merged tasks: #39019.

Uh, well, decided to have a quick look at this one, and I realized BKE_object_dimensions_set() was quite broken (just add two objects, parent one to the other, scale parent e.g. 0.5, and try setting dimension of child…). So I wrote this patch, and to my surprise it seems to also fix that bug!

P24: Fix "Dimension" issues?

diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 0970af4..cbb29d4 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2529,13 +2529,13 @@ void BKE_object_dimensions_set(Object *ob, const float *value)
                
                mat4_to_size(scale, ob->obmat);
                
-               len- [x] = bb->vec- [x]- [x] - bb->vec- [x][0];
-               len- [x] = bb->vec- [x]- [x] - bb->vec- [x][1];
-               len- [x] = bb->vec- [x]- [x] - bb->vec- [x][2];
+               len- [x] = fabsf(scale- [x]) * (bb->vec- [x]- [x] - bb->vec- [x][0]);
+               len- [x] = fabsf(scale- [x]) * (bb->vec- [x]- [x] - bb->vec- [x][1]);
+               len- [x] = fabsf(scale- [x]) * (bb->vec- [x]- [x] - bb->vec- [x][2]);
                
-               if (len- [x] > 0.f) ob->size- [x] = value- [x] / len[0];
-               if (len- [x] > 0.f) ob->size- [x] = value- [x] / len[1];
-               if (len- [x] > 0.f) ob->size- [x] = value- [x] / len[2];
+               if (len- [x] > 0.f) ob->size- [x] *= value- [x] / len[0];
+               if (len- [x] > 0.f) ob->size- [x] *= value- [x] / len[1];
+               if (len- [x] > 0.f) ob->size- [x] *= value- [x] / len[2];
        }
 }
 

Not sure this covers all possible situation (as already said in another related report, dimension can become rather involved in complex setups), but think it makes it at least less broken. ;)

Uh, well, decided to have a quick look at this one, and I realized BKE_object_dimensions_set() was quite broken (just add two objects, parent one to the other, scale parent e.g. 0.5, and try setting dimension of child…). So I wrote this patch, and to my surprise it seems to also fix that bug! [P24: Fix "Dimension" issues?](https://archive.blender.org/developer/P24.txt) ```diff diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0970af4..cbb29d4 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2529,13 +2529,13 @@ void BKE_object_dimensions_set(Object *ob, const float *value) mat4_to_size(scale, ob->obmat); - len- [x] = bb->vec- [x]- [x] - bb->vec- [x][0]; - len- [x] = bb->vec- [x]- [x] - bb->vec- [x][1]; - len- [x] = bb->vec- [x]- [x] - bb->vec- [x][2]; + len- [x] = fabsf(scale- [x]) * (bb->vec- [x]- [x] - bb->vec- [x][0]); + len- [x] = fabsf(scale- [x]) * (bb->vec- [x]- [x] - bb->vec- [x][1]); + len- [x] = fabsf(scale- [x]) * (bb->vec- [x]- [x] - bb->vec- [x][2]); - if (len- [x] > 0.f) ob->size- [x] = value- [x] / len[0]; - if (len- [x] > 0.f) ob->size- [x] = value- [x] / len[1]; - if (len- [x] > 0.f) ob->size- [x] = value- [x] / len[2]; + if (len- [x] > 0.f) ob->size- [x] *= value- [x] / len[0]; + if (len- [x] > 0.f) ob->size- [x] *= value- [x] / len[1]; + if (len- [x] > 0.f) ob->size- [x] *= value- [x] / len[2]; } } ``` Not sure this covers all possible situation (as already said in another related report, dimension can become rather involved in complex setups), but think it makes it at least less broken. ;)

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Ok, so @ideasman42 noticed previous patch failed when reaching zero value… Here is a new one, there are still some glitches around 0 in case of "grouped drag", but it’s still better (do not have yet idea to fix completely the zero-issue):

void BKE_object_dimensions_set(Object *ob, const float *value)
{
	BoundBox *bb = NULL;

	bb = BKE_object_boundbox_get(ob);
	if (bb) {
		float scale[3], len[3];
		int i = 3;

		mat4_to_size(scale, ob->obmat);

		len[0] = bb->vec[4][0] - bb->vec[0][0];
		len[1] = bb->vec[2][1] - bb->vec[0][1];
		len[2] = bb->vec[1][2] - bb->vec[0][2];

		while (i--) {
			float l = len[i], s = scale[i], v = value[i];

			if (l > 0.0f) {
				if (ELEM(0.0f, s, ob->size[i])) {
					ob->size[i] = v / l;
				}
				else {
					ob->size[i] *= v / (l * fabsf(s));
				}
			}
		}
	}
}
Ok, so @ideasman42 noticed previous patch failed when reaching zero value… Here is a new one, there are still some glitches around 0 in case of "grouped drag", but it’s still better (do not have yet idea to fix completely the zero-issue): ``` void BKE_object_dimensions_set(Object *ob, const float *value) { BoundBox *bb = NULL; bb = BKE_object_boundbox_get(ob); if (bb) { float scale[3], len[3]; int i = 3; mat4_to_size(scale, ob->obmat); len[0] = bb->vec[4][0] - bb->vec[0][0]; len[1] = bb->vec[2][1] - bb->vec[0][1]; len[2] = bb->vec[1][2] - bb->vec[0][2]; while (i--) { float l = len[i], s = scale[i], v = value[i]; if (l > 0.0f) { if (ELEM(0.0f, s, ob->size[i])) { ob->size[i] = v / l; } else { ob->size[i] *= v / (l * fabsf(s)); } } } } }

Added subscriber: @EvandroFerreiradaCosta

Added subscriber: @EvandroFerreiradaCosta

◀ Merged tasks: #39227.

◀ Merged tasks: #39227.

Added subscriber: @bliblubli

Added subscriber: @bliblubli

◀ Merged tasks: #39665.

◀ Merged tasks: #39665.

@mont29, the patch mostly works well, but it has one strange behavior I noticed.

Pasting values into the buttons now fails.

  • Default cube
  • Set X scale to 2.0 (so X dimension is 4.0)
  • Copy the Y scale (1.0) and paste into the Y dimension (2.0) (Ctrl+C, Ctrl+V).
  • Keep pressing Ctrl+V
  • Y dimension cycles between 2.0 and 0.5 but never reaches 1.0.

I really think how this button works is broken, probably it shouldn't be using RNA at all and we could instead use callbacks so each situation can be handled better.

@mont29, the patch mostly works well, but it has one strange behavior I noticed. Pasting values into the buttons now fails. - Default cube - Set X scale to 2.0 (so X dimension is 4.0) - Copy the Y scale (1.0) and paste into the Y dimension (2.0) (Ctrl+C, Ctrl+V). - Keep pressing Ctrl+V - Y dimension cycles between 2.0 and 0.5 but never reaches 1.0. I really think how this button works is broken, probably it shouldn't be using RNA at all and we could instead use callbacks so each situation can be handled better.

@ideasman42 imho, it’s not RNA the issue here, it’s that (to handle correctly things like parent-related scaling), we need to use ob->obmat to get current object's scale, and yet we set ob->size. The problem is that in some cases (like e.g. pasting values), BKE_object_dimensions_set() is called twice or more without any object update in between, so ob->obmat becomes obsolete.

This quick (and dirty, obviously not a good solution as is, just could not find a nice way to get current scene here) hack “fixes” it:

P35: #38587 related

void BKE_object_dimensions_set(Object *ob, const float value[3])
{
	BoundBox *bb = NULL;

	bb = BKE_object_boundbox_get(ob);
	if (bb) {
		float obmat- [x][4];
		float scale- [x], len[3];
		int i = 3;

		mat4_to_size(scale, ob->obmat);

		len- [x] = bb->vec- [x]- [x] - bb->vec- [x][0];
		len- [x] = bb->vec- [x]- [x] - bb->vec- [x][1];
		len- [x] = bb->vec- [x]- [x] - bb->vec- [x][2];

		print_v3("value", value);
		print_v3("scale", scale);
		print_v3("ob->size", ob->size);
		print_v3("len", len);
		printf("\n");

		while (i--) {
			float l = len- [x], s = scale- [x], v = value[i];

			if (l > 0.0f) {
				if (ELEM(0.0f, s, ob->size[i])) {
					ob->size- [x] = v / l;
				}
				else {
					ob->size- [x] *= v / (l * fabsf(s));
				}
			}
		}
		BKE_object_where_is_calc_mat4(G.main->scene.first, ob, ob->obmat);
	}
}

Now how to do this properly, I do not know really. Is it possible to get a valid scene from on object pointer? Or, probably better, to flush tagged updates in RNA update func?

@ideasman42 imho, it’s not RNA the issue here, it’s that (to handle correctly things like parent-related scaling), we need to use `ob->obmat` to get current object's scale, and yet we set `ob->size`. The problem is that in some cases (like e.g. pasting values), `BKE_object_dimensions_set()` is called twice or more without any object update in between, so `ob->obmat` becomes obsolete. This quick (and dirty, obviously not a good solution as is, just could not find a nice way to get current scene here) hack “fixes” it: [P35: #38587 related](https://archive.blender.org/developer/P35.txt) ```c void BKE_object_dimensions_set(Object *ob, const float value[3]) { BoundBox *bb = NULL; bb = BKE_object_boundbox_get(ob); if (bb) { float obmat- [x][4]; float scale- [x], len[3]; int i = 3; mat4_to_size(scale, ob->obmat); len- [x] = bb->vec- [x]- [x] - bb->vec- [x][0]; len- [x] = bb->vec- [x]- [x] - bb->vec- [x][1]; len- [x] = bb->vec- [x]- [x] - bb->vec- [x][2]; print_v3("value", value); print_v3("scale", scale); print_v3("ob->size", ob->size); print_v3("len", len); printf("\n"); while (i--) { float l = len- [x], s = scale- [x], v = value[i]; if (l > 0.0f) { if (ELEM(0.0f, s, ob->size[i])) { ob->size- [x] = v / l; } else { ob->size- [x] *= v / (l * fabsf(s)); } } } BKE_object_where_is_calc_mat4(G.main->scene.first, ob, ob->obmat); } } ``` Now how to do this properly, I do not know really. Is it possible to get a valid scene from on object pointer? Or, probably better, to flush tagged updates in RNA update func?

@mont29. the hack you propose could be made to work, but I would rather investigate some way to apply all buttons at once.

Or, redo the dimensions in C/ui.
dont use RNA for it, and have whatever hacks that are needed as callback functions for the C defined buttons.

@mont29. the hack you propose could be made to work, but I would rather investigate some way to apply all buttons at once. Or, redo the dimensions in C/ui. dont use RNA for it, and have whatever hacks that are needed as callback functions for the C defined buttons.

Added subscriber: @gandalf3

Added subscriber: @gandalf3

◀ Merged tasks: #40511.

◀ Merged tasks: #40511.

Added subscriber: @Druban

Added subscriber: @Druban

◀ Merged tasks: #41347.

◀ Merged tasks: #41347.

Added subscriber: @MikhailRachinskiy

Added subscriber: @MikhailRachinskiy

Added subscribers: @ZhangYu, @ThomasDinges

Added subscribers: @ZhangYu, @ThomasDinges

Added subscriber: @FilipMond

Added subscriber: @FilipMond

This comment was removed by @FilipMond

*This comment was removed by @FilipMond*

@FilipMond, please only add useful information in posts.

@FilipMond, please only add useful information in posts.

Setting as TODO because this is an error in the way the RNA attribute works and its not some mistake to correct, The rna code has to work differently to support this for Python and the UI.

http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/UserInterface#UI_Widgets

Setting as TODO because this is an error in the way the RNA attribute works and its not some mistake to correct, The rna code has to work differently to support this for Python and the UI. http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/UserInterface#UI_Widgets

Removed subscriber: @candreacchio

Removed subscriber: @candreacchio
Member

Added subscriber: @AdamPreisler

Added subscriber: @AdamPreisler
Member

Added subscriber: @Traverso

Added subscriber: @Traverso

Added subscriber: @quantumanomaly

Added subscriber: @quantumanomaly

Added subscriber: @YegorSmirnov

Added subscriber: @YegorSmirnov

Added subscriber: @chrisoffner3d

Added subscriber: @chrisoffner3d
Campbell Barton removed their assignment 2016-08-11 06:35:00 +02:00
Member

Added subscriber: @GeorgesDahdouh

Added subscriber: @GeorgesDahdouh

Closed as duplicate of #50043

Closed as duplicate of #50043

Changed status from 'Duplicate' to: 'Open'

Changed status from 'Duplicate' to: 'Open'

Sorry, merged them the wrong way.

Sorry, merged them the wrong way.

Added subscriber: @Leroy-Xie

Added subscriber: @Leroy-Xie
Member

Added subscribers: @Baeronius, @lichtwerk

Added subscribers: @Baeronius, @lichtwerk
Member

Added subscriber: @infrabread

Added subscriber: @infrabread

Added subscriber: @capnm

Added subscriber: @capnm

If you drag over all 3, only X and Z change, Y remains unchanged. As mouse button is released, the first selected property will reset, only the last hovered is kept (and scale changed)

Update (ca58936f2f)
Works in the sidebar for some time, but is now broken in the object properties widget clone created in D5577.

> If you drag over all 3, only X and Z change, Y remains unchanged. As mouse button is released, the first selected property will reset, only the last hovered is kept (and scale changed) Update (ca58936f2f) Works in the sidebar for some time, but is now broken in the object properties widget clone created in [D5577](https://archive.blender.org/developer/D5577).

Works in a glance under OSX, at least from 2.81a

Works in a glance under OSX, at least from 2.81a
Philipp Oeser removed the
Interest
User Interface
label 2023-02-10 09:26:33 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
17 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#38587
No description provided.