Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scale spirals out of control when using the delta matrix #73

Open
charlesboudousquie opened this issue Feb 28, 2019 · 8 comments
Open

Comments

@charlesboudousquie
Copy link

charlesboudousquie commented Feb 28, 2019

bandicam20190227210558832

When using the scale gizmo it somehow moves the object along with scaling it. This causes it to thrash until it jumps off screen.

@CedricGuillemet
Copy link
Owner

That's a serious issue! Can you please try to reproduce it with the sample app?

@twaritwaikar
Copy link

twaritwaikar commented Apr 27, 2020

I can reproduce this issue on a recent build. All my transforms are stored locally and every frame I calculate the absolute transform. Because of this, I used the delta matrix. Translation and rotation work properly but the scale in the delta matrix goes out of control

@CedricGuillemet
Copy link
Owner

I'll take a look very soon! Thanks

@twaritwaikar
Copy link

I have a workaround for this one now.

ImGuizmo::Manipulate(
	&view.m[0][0],
	&proj.m[0][0],
	gizmoOperation,
	gizmoMode,
	&matrix.m[0][0],
	&deltaMatrix.m[0][0],
	currentSnap,
	&transform->getBoundsMutable().m_LowerBounds.x);
				
matrix *= transform->getParentAbsoluteTransform().Invert();

transform->setTransform(matrix);

The basic idea is that the matrix parameter is always having the absolute transform, which is indeed correct. So I convert matrix from world position to local coordinates by multiplying it by the inverse of the world transform of the object.

@peter1745
Copy link

peter1745 commented Nov 16, 2022

@CedricGuillemet Any update on this? Having a similar issue on one of more recent builds (5a3afc9).

Haven't really investigated the code, but what seems to be happening is that the delta matrix always contains a non-zero scale value, regardless of the scale gizmo being used or not. In my testing it returned a [1, 1, 1] scale despite me using the translation gizmo.

I also made sure to check that it doesn't simply return the original scale, it still returned a [1, 1, 1] delta scale even when my transform matrix contained a [2, 2, 2] scale. So it always returns a [1, 1, 1] scale

@peter1745
Copy link

In fact it seems like the entire delta scale is very broken. Firstly the delta matrix will always have a scale of [1, 1, 1] when doing translation and rotation.

Secondly when actually using the scale gizmo the delta matrix always contains a positive scale value, meaning the delta matrix can't be used for scaling down a transform, which seems strange to me, although it may be intended behaviour (if it is intended may I ask why?)

@peter1745
Copy link

peter1745 commented Nov 16, 2022

Alright so now that I've investigated the code it's pretty obvious why the delta matrix always has a scale of [1, 1, 1] when doing translation or rotation.
It's because e.g the deltaMatrixTranslation matrix is set to an identity matrix. This may require a separate issue, let me know and I can open a separate one!

One potential solution to this could be for ImGuizmo to not copy the entire deltaMatrixTranslation into deltaMatrix, but rather only copy the translation part.

Unsure if that would work for rotation though so a better solution might be good.

@peter1745
Copy link

@CedricGuillemet So I realized that I was handling the delta scale incorrectly. Apparently the correct way of doing the delta scale is to multiply my original scale with the delta scale.
Personally I think the delta scale should either be an actual delta, or it should be made very clear that the delta scale should be multiplied with the current scale.
It is slightly confusing considering that both translation and rotation is additive, not multiplicative. But this really should be a separate issue where we can discuss it so I'll stop spamming this issue 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants