# Lecture 011

## Physics Application

### Character Controller

Kinematic Actor: usually player

• not affected by physics rules

• push other objects

• Shapes: capsule, box, convex

Different from other physics, we want the player to slide along the wall as it walks at an angle towards the wall.

We also want the players to be able to move up stairs:

1. 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)
2. do physics simulation

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.

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)

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)

Active Joints: position provided by physics simulation.

Leaf Joints: endpoint, controlled solely by animation

Intermediate Joints: calculate and interpolated by animation re-targeting.

Ragdoll need to satisfy joint's constraints (since human joints do not have al degrees of freedom) in order to provide satisfying animation.

Ragdoll can interleave with animation, providing more realistic looking transitions. (e.g. when a conscious human hang on a dynamic object)

### Cloth Simulation

#### Old Methods

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

We separate render mesh with physical mesh for reducing computation complexity.

We set different amount of constaints for each vertex: to prevent penetration to attached body (human characters)

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

\vec{F}_{\text{net}}^{vertex}(t) = M\vec{g}_{\text{gravity}} + \vec{F}_{\text{wind}} + \vec{F}_{\text{air resistance}}(t) + \sum_{\text{springs } \in v} \left( k_{\text{spring}} \Delta\vec{x}(t) - k_{\text{dampling}}\vec{v}(t) \right) = M\vec{a}(t)

In cloth simulation, Verlet integration provides more stability and better computational complexity than Euler's Semi-implicit.

#### 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

#### Destruction

When a projectile hit a surface

1. we create chunk hierarchy assigned by the artist (or automatically generated during compilation by Voronoi Diagram)
2. we use the assigned "hardness" between connectivity graph
3. if damage (calculated below) is higher than a threshold, break the connection
4. generate new triangle mesh by Delaunay Triangulation with new texture and texture coordinate
5. 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}}

The current solution is not at all physics based

Common Breaking Patterns:

• uniform

• clustered

Besides the pipeline, we need to add many callback function for realistic side effects

• sound effect

• particle effect

• nevigation logic update

Destruction can consume 10x to 100x computational power than we currently have.

Popular Destruction Implementation

• NVIDIA APEX (UE4, PhysX Lab), deprecated in 2017

• NVIDIA Blast in Omniverse

• Havok (Unity) with high license fee

• Chaos Destruction (Epic Games, beta in UE5)

// TODO

Table of Content