Skip to content

When attaching Transform, behavior is as if keep is always set #4

@superlou

Description

@superlou

This might be a misunderstanding on my part, but from the comments in Transform.attach, it seems like local positions (and maybe rotation) are always transformed so that the PositionWorld is kept. In the following example, I make a simple tree, where I expect the PositionWorld of device to be (3, 3, 3):

base = Transform("base")
room = Transform("room", position=(1, 1, 1))
device = Transform("device", position=(2, 2, 2))

base.attach(room)
room.attach(device)

base.printTree()
for item, index, depth in base.layout():
    print(f"{item.Position} {item.PositionWorld} {item.Name}")

However, the Position of device has changed and now its PositionWorld is (2, 2, 2):

base
+- room
   +- device
vec3(            0,            0,            0 ) vec3(            0,            0,            0 ) base
vec3(            1,            1,            1 ) vec3(            1,            1,            1 ) room
vec3(            1,            1,            1 ) vec3(            2,            2,            2 ) device

This seems to be related to attaching, even without keep set, because if I set Position after attaching, the result is as expected:

...
base.attach(room)
room.attach(device)

device.Position = (2, 2, 2)
...
+- room
   +- device
vec3(            0,            0,            0 ) vec3(            0,            0,            0 ) base
vec3(            1,            1,            1 ) vec3(            1,            1,            1 ) room
vec3(            2,            2,            2 ) vec3(            3,            3,            3 ) device

Is this the expected behavior? The logic in attach makes sense, so I'm not quite sure why this happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions