-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add ability to play animations on a separate instance #7919
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,30 @@ | |
*/ | ||
public class Animator { | ||
private long mNativeObject; | ||
private Boolean mIsOwner = false; | ||
|
||
Animator(long nativeObject) { | ||
mNativeObject = nativeObject; | ||
} | ||
|
||
public Animator(FilamentAsset asset, FilamentInstance instance) { | ||
mNativeObject = nCreateAnimatorFromAssetAndInstance(asset.getNativeObject(), instance.getNativeObject()); | ||
mIsOwner = true; | ||
} | ||
|
||
@Override | ||
public void finalize() { | ||
try { | ||
super.finalize(); | ||
} catch (Throwable t) { // Ignore | ||
} finally { | ||
if (mIsOwner) { | ||
nDestroyAnimator(mNativeObject); | ||
mNativeObject = 0; | ||
} | ||
} | ||
} | ||
Comment on lines
+51
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this -- I think we can't rely on finalizers from being called. I'm not sure what the correct pattern would be here. @romainguy what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finalizers are unfortunately not reliable (and at best take a lot of time to be invoked). We did use them in a couple of places but it's better to have a manual destroy(). |
||
|
||
/** | ||
* Applies rotation, translation, and scale to entities that have been targeted by the given | ||
* animation definition. Uses <code>TransformManager</code>. | ||
|
@@ -137,6 +156,8 @@ void clearNativeObject() { | |
mNativeObject = 0; | ||
} | ||
|
||
private static native long nCreateAnimatorFromAssetAndInstance(long nativeAsset, long nativeInstance); | ||
private static native void nDestroyAnimator(long nativeAnimator); | ||
private static native void nApplyAnimation(long nativeAnimator, int index, float time); | ||
private static native void nUpdateBoneMatrices(long nativeAnimator); | ||
private static native void nApplyCrossFade(long nativeAnimator, int animIndex, float animTime, float alpha); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be lower case
boolean
, otherwise it's an object.