viromedia / virocore

ViroCore cross-platform AR/VR renderer
MIT License
370 stars 108 forks source link

Node's transforms too slow (i.e. setPosition, setRotation) #322

Open fzaiatz opened 4 years ago

fzaiatz commented 4 years ago

Hi there! We're trying to generate a new Node animation model (AnimationTransaction's does not fit 100% our needs).

The approach so far is:

  1. Set ViroView's setFrameListener
  2. On each frame, update each Node's position, rotation, scale and opacity

For this we've created a component-oriented approach. From a design point of view everything is working as expected.

The problem we're having is when we call each Node's native setPosition/setRotation/setScale methods. Each call takes around 300ms (on a Samsung Galaxy S8).

Taking a look a bit further at Node's setPosition (for example):

public void setPosition(Vector position) {
    this.nativeSetPosition(this.mNativeRef, position.x, position.y, position.z);
    this.updateWorldTransforms();
    this.updateAllUmbrellaBounds();
}

Where nativeSetPosition calls setPositionAtomic (Node_JNI.cpp). Is there any way this could be changed, in order to update Node's props immediately?

Thanks!

dthian commented 4 years ago

Hey @fzaiatz, could you explain what you are trying to do? Are you trying to call setPosition and then getPositionRealtime immediately? (Which is why you ran into this case)

fzaiatz commented 4 years ago

Hi @dthian :) Well, not exactly. I need a way to animate a Node’s position frame by frame, and by calling setPosition we can’t make it work (around 300ms each call)