Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling getWorldPosition after calling setTransform returns previous value #7827

Open
hannojg opened this issue May 6, 2024 · 2 comments
Open
Assignees

Comments

@hannojg
Copy link
Contributor

hannojg commented May 6, 2024

Describe the bug

In our code we try to change the position of an entity continuously by a game-pad input.
First, we call getWorldTransform to get the current position, and then update it using setTransform. Visually we can tell that the entity is correctly updated and its position is changed.
Then, on the next frame, we call the same code again, but this time getWorldTransform doesn't return the value we updated, but the previous one.

To Reproduce

Add an asset / entity to the scene (ie. it has no parent, and the entity you're changing is a direct child of the scene / world)

auto rootEntity = asset.getRoot();
auto rootInstance = transformManager.getInstance(rootEntity);

auto prev = transformManager.getWorldTransform(rootInstance) // [0, 0, 0]
transformManager.setTransform([0,1,0]) // (simplified)
auto updated = transformManager.getWorldTransform(rootInstance) // ⚠️ this is still [0, 0, 0]

Note: this behaviour is also true between frames. So when calling

auto prev = transformManager.getWorldTransform(...) // [0, 0, 0]
transformManager.setTransform([0,1,0])

engine->render(...)

auto updated = transformManager.getWorldTransform(...) // ⚠️ this is still [0, 0, 0]

Expected behavior

The world position be updated after calling setTransform

Screenshots
n/a

Logs
n/a

Desktop (please complete the following information):

  • OS: iOS
  • GPU: Apple GPU
  • Backend: Metal

Smartphone (please complete the following information):

  • Device: iPhone 13 Pro
  • OS: iOS 17.4

Additional context
n/a

@pixelflinger pixelflinger self-assigned this May 8, 2024
@pixelflinger
Copy link
Collaborator

I wrote this simple test, which passes:

TEST(FilamentTest, TransformManagerSimple) {
    filament::FTransformManager tcm;
    EntityManager& em = EntityManager::get();
    Entity root = em.create();
    tcm.create(root);

    auto ti = tcm.getInstance(root);

    auto t = mat4f::translation(float3{ 1, 2, 3 });
    auto prev = tcm.getWorldTransform(ti);
    tcm.setTransform(ti, t);
    auto updated = tcm.getWorldTransform(ti);

    EXPECT_NE(prev, t);
    EXPECT_EQ(updated, t);
}

Are you sure you have not called openLocalTransformTransaction() ?

pixelflinger added a commit that referenced this issue May 9, 2024
pixelflinger added a commit that referenced this issue May 9, 2024
@hannojg
Copy link
Contributor Author

hannojg commented May 10, 2024

Actually we don't (thanks for checking!).
Let me try to build a reproduction in the filament samples - then it must be because of something else we are doing in our code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants