How can auto stop the AnimControl if the model not in camera area

many model need play stand anim or idle anim! so how can auto stop the AnimControl if the model not in camera area?

To test whether the model is “in camera”, you might use the Spatial.checkCulling() method.

To disable the control, you might use AnimControl.setEnabled(false);

To perform the test on every update, you might create an AppState or add it to SimpleApplication.simpleUpdate().

2 Likes

One question is why you want to do this.

The mesh itself is only updated when the object is on screen (controlRender()) even if the ‘animation’ and bones, etc. are updated when the character is off-screen. And sometimes it’s important for those bones to be updated even when they aren’t in view.

Do you have like several thousand animated characters or something? If so, I don’t think animating the bones is going to be your bottleneck.

2 Likes

yes i have 5 thousand anim ! so i need auto stop the anim while the model not in camera area

The work that animations are doing when not in view is not very much.

You can implement what you want as already described but it is unlikely to help much. That’s probably just too many animated characters at once. Off the shelf systems are unlikely to work well in that case.

…which is why you don’t see many video games with 5000 animated characters at once.

yes, even M&B Bannerlord that is known for big battles using detailed models have limits. i belive it was 1000.

well, you can do own control and check if is in view and disable anim control, but im also not sure if this will help.