sketchpunklabs / ossos

Webbased Character Animation System
MIT License
423 stars 46 forks source link

Spring bone clamping? #16

Open alankent opened 1 year ago

alankent commented 1 year ago

I was wondering if your spring bone implementation should have a maximum stretch clamp from looking at your demo... ;-)

image

Unless of course you left that in just for amusement. This is when the walk animation resets to the original position causing the bust spring bone to snap back due to the super-fast movement back to the origin. (I have had the same problem with hair in other spring bone solutions - moving the character in an animation sequence to a new position causes the hair to think the body moved at 100,000 miles per hour in one tick, which then caused the hair to take a while to settle back down again.)

sketchpunk commented 1 year ago

When I implemented the spring bones, I only tested it with root motion disabled, so those things didn't happen. Its a simple implementation too, without limits or constraints.

This year I'm focusing on rewriting the library with a focus of having a character controller to animate characters doing basic movements like walking, running and jumping. So these issues will be address in the next version.

When it comes to spring bones I have a few ideas I'd like the experiment with.

  1. In my original version I had cascading settings for chains but in ossos I have 1 set of settings that applies to all bones. The original way of doing it was a lil more work to setup but I feel like things animated better. So I want to work out a way to handle both ways of setting up a spring chains

  2. I use a single spring algorithm, so the next one I'd like to work out have at least 3 or 4 different types of springs to choose from as some tends to be more springy then others. The one I currently use does not even take mass into account for how fast something should move.

  3. To solve the problem of springs going out of control when position gets reset, I'd like to see if I can convert all that into "modelspace". Where all the points i'm using are saved in relation to the root bone of the skeleton. This will be helpful if I want to keep the velocity going when a character teleports around which you can see with your image doesn't work well when the points are all done in world space.

  4. I also want to build in some basic constraints like hinges and ball, that should help around various issues especially when dealing with iterative ik solvers. Ideally it should also work with spring bones too.

Those are some of my plans. Only issue its a slow process & this sort of stuff is hard to do. A good amount of the work is trial & error to see what works and what doesn't.