dkavolis / Ferram-Aerospace-Research

Aerodynamics model for Kerbal Space Program
Other
81 stars 32 forks source link

Animated wings #21

Open alex-dev opened 5 years ago

alex-dev commented 5 years ago

Allow a wing with an animation to have multiple wing model.

dkavolis commented 5 years ago

I think this can be done by each model having its own FAR config and allowing FAR to switch between them. However, there would be a delay of few frames in flight mode as the voxelization is redone. But what happens in the transition between the models? This is the main issue with animated parts. Currently, voxelization cannot be done in real time and I would need to check that recomputing wing interactions each frame does not slow down the game significantly during the transition (or run it in a different thread but that would introduce a physics delay).

At the moment I am not sure how this can be implemented. How would the config look like, each part having a list of FAR modules one for each model or each model having a FAR module?

alex-dev commented 5 years ago

I feel like a close enough answer is acceptable here. If voxelization is not to slow.... a delay of a few frames up to maybe .3 or .4 seconds before aerodynamics kicks in could be acceptable.

And you don't want to recompute each frame. You just want to check if the animation changed state and is in one of two state. Then you use this to trigger voxelization. At least... it depends on where stuff happens. And it could also be as simple as putting a few modules inside the animated module itself and letting far calculate itself which to chose... or for simple cases, just bounds and a curve for the whole animation. This also depends on where stuff is calculated...

dkavolis commented 5 years ago

I'll have to consult someone on how best to implement this. For long animations, I could add trigger points or time it every X seconds for voxelization, maybe run voxelization one after another in the off-threads.

Code-Grump commented 5 years ago

Perhaps tweening between voxelized key states would be an acceptable solution?

dkavolis commented 5 years ago

Perhaps tweening between voxelized key states would be an acceptable solution?

That and computing voxelization per part and then combining instead of voxelizing the entire vehicle

dkavolis commented 5 years ago

For now, GeometryPartModule has a new node rebuildOnAnimation which forces rebuilding of the part's mesh and vehicle voxelization every 30 FixedUpdate ticks if animations were found playing. Previously only transforms were updated which could have resulted in wrong voxelization. InflatableHeatShield is such an example - using colliders for voxelization worked ok-ish since their meshes did not change on animation but voxelizing based on meshes would result in voxelization having the old shape. Currently, animation state names are found from all part modules in the part that have fields animationName, animationStateName, animName and deployAnimationName unless they are disabled in FARAnimOverride. I'm sure this can be improved like allowing mesh rebuild only for specific animations