That's fine, now i don't need to set Sleep State manually to zero anymore

I had no luck making the boxes example work like expected, and i have doupts modifying contat acc is the right (or only) way to do it.
What i've done:
Calculate scaling velocity: (contact point - scaleBodyCom) * (newscale / oldscale - 1.0) / timestep
Either use this or make a relative velocity with the other body's velocity at contact point (I'm unsure if NewtonMaterialSetAcceleration expects relative or world values)
Rotate tangents to match scaling velocity direction.
NewtonMaterialSetAcceleration (scaleVel.Dot(normal btw. tangent) * some_constant), optionally subtract NewtonMaterialGetContactSpeed
To get reasonable results, some_constant needs to be 2-3 for tangent, and 500000 (!) for normal.
Small Boxes move in the right directions then and interpenetration is avoided, but simulation is not smooth, it's pretty jumpy.
Do you think it should be possible and i do something wrong?
There are the other solutions i see:
1. Before Scaling, create custom joints at contact position, they should successfully avoid penetration and do tangential motion with least friction as possible.
Delete the joints when scaling is done. I assume nonrealistic sideffects from this and also difficult to implement / slow, but my best bet so far.
2. Because realtime scaling might happen slowly and smoothly, it might suffice to temproary raise your 'penetration recovery speed' for affected bodies. Is that possible?
I mean the slow non-phsical motion you use to seperate interpenetrating bodies. This would not handle tangential motion, but it might be acceptable, pretty robust and easy to do.
3. You add the scaling velocity to your engine. (Lots of work? Performance drop?)
Even if you would do, there is another problem left:
Imagine there is a static rooftop above the scene. To use realtime scaling in games we would need to detect such a case, so that you can not further upscale objects to prevent penetration.
I assume this can be done by convex casting the small boxes on top in contact normal direction, and for the scaled box itself a temporary prescaled body might be tested somehow...
Sounds like "it will never work 100 %", but to be safe, upsacling of bodies in an island where one body has penetration > constant could be prohibited.
What do you think?
Here some Ascii-art to illustrate what i want:
- Code: Select all
_O_O_
xxxxx
x x
upscale table (small bodies (O) move up and sideways):
__O___O__
xxxxxxxxx
x x
x x
upscale table (small bodies move up only):
___O_O___
xxxxxxxxx
x x
x x