playcanvas / editor

Issue tracker for the PlayCanvas Editor
https://playcanvas.com/
159 stars 28 forks source link

Have an option to preserve world scale, position and rotation when reparenting #150

Open yaustar opened 4 years ago

yaustar commented 4 years ago

Forum thread here: https://forum.playcanvas.com/t/entities-resize-when-re-parenting-in-editor-how-do-i-get-them-to-stop/14838/2

It would be useful for world scale in particular to be preserved when reparenting.

Maksims commented 4 years ago

I don't think it is actually possible. Scale can affect model by axes, and ancestors with different rotations, will lead to all sorts of skews and scaling by different axes (non parallel to local space). This cannot be replicated by own "scale", as there are so many different options, not like with position and rotation. There is also no "world scale".

yaustar commented 4 years ago

I appreciate that there is no 'world scale', it was the easiest way to communicate the feature.

Would it be possible to work out what the new local scale would be based on the hierarchy transforms? It's something that we are missing that other engines are able to do :(

Maksims commented 4 years ago

Actually, none of the engines can preserve non-uniform scaling when reparenting. This is mathematical problem, not engine one. There are 2 paths that can "solve" it:

  1. Make scale completely independent of hierarchy, so no inheritance of scale, which of course is not good.
  2. Restoring scale when reparenting, is possible but only if all ancestors of old and new parent scaled uniformly (same value for each axes, no skewing).