If you’re using regular positions (ie
node->setPosition()), the conversions work well, but if the original’s parent is using a normalized position, and the destination is not normalized, the conversions don’t work.
If the node who’s position I’m trying to into,
touch_to_close_overlay_layout, is non-normalized to the center of the map with anchor 0.5, 0.5, (its size is 9999x9999), it looks like this, which is as intended:
but if I change the touch_to_close_layout to normalized position,
setPositionNormalized(0.5, 0.5), it’ll get out of place. notice the two bright buttons are missing on the right:
so if I change the size of the grey see-through layout from 9999 to 1000, you’ll see how it changes. again, non-normalized and positioned wherever on screen, it doesn’t matter, it works as intended:
but if I keep the size at 1000, and instead normalize the position of the overlay to 0.5 again, the buttons are gone:
Alright so thats roughly what the issue looks like. But if I use the map->converToWorldSpace then touch_to_close_layout->convertToNodeSpaceAR, it gets close, but it seems to be scaling out, rather than absolute positioning:
If I shrink the layout from 1000 to 500, the positions get even further out of whack, so it does seem to be some sort of scaling issue
touch_to_close_overlay_layout is the grey see through layout,
location_btn_origin is the bottom left corner of the bounding box of the ‘Add Forest’ button, added to the map. The
dropdown_listview is a child of the touch_to_close_overlay_layout, and contains two buttons within it, the second ‘Add Forest’ and ‘Gather’ buttons. I’ve tried using all of these as the position of the
dropdown_listview, but nothing seemed to position it correctly, like it did when the touch_to_close_overlay_layout is non-normalized positioned.
Both the first Add Forest button and
touch_to_close_overlay are added to the same parent.
auto btn_world_space = location_btn_parent->convertToWorldSpace(location_btn_origin); auto btn_world_space_AR = location_btn_parent->convertToWorldSpaceAR(location_btn_origin); auto btn_local_overlay_pos = touch_to_close_overlay_layout->convertToNodeSpace(btn_world_space); auto btn_local_overlay_pos_AR_AR = touch_to_close_overlay_layout->convertToNodeSpaceAR(btn_world_space_AR); auto btn_local_overlay_pos_AR = touch_to_close_overlay_layout->convertToNodeSpaceAR(btn_world_space); dropdown_listview->setPosition( btn_local_overlay_pos );
tl;dr if I’m scaling the position of one of the nodes involved here, how can I easily convert the positions of one of the nodes to another? Is the problem that I’m mixing and matching normalized and non-normalized positions?
edit: looking through
Node::getNodeToParentTransform, it looks at
_position a few times, and setting setPositionNormalized doesnt seem to update
_position directly, so maybe that’s it. Mixing is the problem? But in
processParentFlags is called, which should update
_position, so I’m not sure still.
If I create the node and immediately use it, before visit is called, that would mean that the _position isn’t updated. I’ll try that.