Different from other physics, we want the player to slide along the wall as it walks at an angle towards the wall.
Sliding along the wall
We also want the players to be able to move up stairs:
every frame when player walk, tries to increase player y (maybe decrease player height to prevent player cannot walk into a door because the player is too tall)
do physics simulation
Walking on stairs
We also want the player to move up slopes, but slide down for steep slopes.
When walking on slopes, a real human's walking behavior is drastically different from normal walking. The animation system should take care of that.
Character Volume Update
Sometimes we need to resize character capsule. We need to do a overlap test before update to avoid insertion inside objects.
For moving platform, we can't use physics engine. We need to do a ray cast to detect which platform the character is standing on.
Not just for character, potentially every moving objects. Objects in elevator will look shaky because there is always a 1-frame difference for object to fall down and push up by elevators.
Ragdoll
Ragdoll: use physics simulation at the end of animation. (usually when character dies)
Joints for Ragdoll
A character might have more joints than we need for physics simulation. We only pick about 10 joints for ragdoll. Since physics simulation is done on about 10 joints, we need to calculate the rest of joint positions for animation to play. (Animation Re-targeting)
Animation Re-targeting in Ragdoll
Active Joints: position provided by physics simulation.
Leaf Joints: endpoint, controlled solely by animation
Intermediate Joints: calculate and interpolated by animation re-targeting.
Lifetime of Ragdoll
Ragdoll need to satisfy joint's constraints (since human joints do not have al degrees of freedom) in order to provide satisfying animation.
Joint's constraints vs no constraints
Ragdoll can interleave with animation, providing more realistic looking transitions. (e.g. when a conscious human hang on a dynamic object)
Blending in Ragdoll
Cloth Simulation
Old Methods
Traditional: animated bone
Rigid Body-based Cloth Simulation: bones of cloth are bounded with rigid bodies and constraints solved by physics engine
Pros: cheap, interactive
Cons: undetermined quality, not robust, need good physics engine
Mesh-Based
Mesh-based Approach
We separate render mesh with physical mesh for reducing computation complexity.
Render Mesh vs. Physical Mesh
We set different amount of constaints for each vertex: to prevent penetration to attached body (human characters)
Different weights on constraints
To simulate cloth, we use spring force and dampling on vertices
spring force: elasticity
dampling:
to take account of friction of cloth's face with air
to avoid floating point error causing explosion of momentum
In cloth simulation, Verlet integration provides more stability and better computational complexity than Euler's Semi-implicit.
Verlet Integration
Position-based Dynamics
Position-based Dynamics
Position-based Dynamics is now commonly used.
Self Collision
Self-collision: when cloth collide with itself or other cloths
Make Cloth Thicker
Use substeps: trade computation with accuracy
Set maximum velocity: so you don't penetrate too far
Contact Constaints and Friction Constraints: apply a force with negative direction
Self-collision Methods (1)
Self-collision Methods (2)
Destruction
Creating Hierarchy Tree
Creating Connectivity Graph
When a projectile hit a surface
we create chunk hierarchy assigned by the artist (or automatically generated during compilation by Voronoi Diagram)
we use the assigned "hardness" between connectivity graph
if damage (calculated below) is higher than a threshold, break the connection
generate new triangle mesh by Delaunay Triangulation with new texture and texture coordinate
generate new rigid body for collision
For texture coordinate, we can:
offline generate 3D volume texture and sample from it when things break
online generate 3D volume texture and sample from it when things break
Usually the new rigid body does not collide with other rigid bodies other than the children of original body. This is because for consistency issue, physics simulation might diverge. (e.g. you can't shoot down a wall to hit a player)
\text{Damage } = \frac{\text{Impulse by Collision}}{\text{Material Hardness}}
Damage Distribution
The current solution is not at all physics based
Common Breaking Patterns:
uniform
clustered
radial
Uniform Random Pattern
Clustered Pattern
Radial Pattern
The entire pipeline
Besides the pipeline, we need to add many callback function for realistic side effects
sound effect
particle effect
nevigation logic update
shader effect
Destruction can consume 10x to 100x computational power than we currently have.