bevyengine / bevyengine/bevy

Lock values of transforms.

Open
#3,025 1 comment 0 reactions 0 assignees View on GitHub
A-Transform C-Feature
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Imagine adding a child entity to a parent, and you want the child to have the position updated but don't want it to update rotation. I would like a way to do, by locking certain parts of the transform.

## What solution would you like?

I propose a bitmask for disabling updates to translation, rotation and scale. Constants can be added to `Transform` like `MASK_TRANSLATION_X` to turn on/off flags. Whenever the system that updates transforms is called, it can check the mask before updating it. I'm not sure about the performance impact, how it would add up for large numbers of entities.

## What alternative(s) have you considered?

A byte is the smallest value we can use to store this. However, it can be given a generic name like `mask` and be used in the future for adding any other features. `if` statements aren't necessary for the update code, a simple AND statement and you can multiply the result by the updated field, effectively canceling it, like so: `transform.x = update.x * (transform.mask & MASK_TRANSLATION_X)` though, I don't actually know if this is what is happening.

## Additional context

I am using this for bevy_atmosphere. I wanted to attach a child entity for the skybox (to make it more flexible for cases such as local split-screen multiplayer) but since the rotation keeps moving, I would have to cancel it out with a system. This would improve performance in those cases.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.