RadicalCSG / Chisel.Prototype

Work in progress prototype for the Chisel Level Editor, for Unity
MIT License
466 stars 34 forks source link

Moving pivot of generator should not move child objects of that generator #257

Open LogicalError opened 3 years ago

LogicalError commented 3 years ago

The move pivot tool (ChiselMovePivotTool.cs) calls SetPivot (ChiselNode.cs) on each generator, which modifies the transform.position, but doesn't check if there are any child gameObjects that need to be moved in the opposite direction.

Note 1: It's probably better to do all this in ChiselMovePivotTool, where we could remember the original position of all involved transforms, and move them to their desired position, relative to the STARTING position. If we don't, and we move everything bit by bit, moving a pivot quickly back and forth (while not releasing the mouse button in between) would accumulate floating point errors during that move, and things would slowly drift into unpredictable directions.

Note 2: The brush meshes of the generators are not modified, instead an additional offset is stored (PivotOffset) relatively to the transform position. This avoids having to move all the vertices in a brush mesh, which would cause the vertices to drift due to floating point inaccuracies