A Different Approach for Continuous Physics Vincent ROBERT - - PowerPoint PPT Presentation

a different approach for continuous physics
SMART_READER_LITE
LIVE PREVIEW

A Different Approach for Continuous Physics Vincent ROBERT - - PowerPoint PPT Presentation

A Different Approach for Continuous Physics Vincent ROBERT vincent.robert@ubisoft.com Physics Programmer at Ubisoft A Different Approach for Continuous Physics Existing approaches Our method Limitations Performances Conclusion A


slide-1
SLIDE 1

A Different Approach for Continuous Physics

Vincent ROBERT

vincent.robert@ubisoft.com

Physics Programmer at Ubisoft

slide-2
SLIDE 2

A Different Approach for Continuous Physics

Existing approaches Our method Limitations Performances Conclusion

slide-3
SLIDE 3

A Different Approach for Continuous Physics

Existing approaches Our method Limitations Performances Conclusion

slide-4
SLIDE 4

Linear convex cast

TOI Compute the Time of Impact (TOI) between two convex shapes

Trajectory TOI

slide-5
SLIDE 5

An issue can still occur

With the Linear cast, a future collision can be detected. Detecting the collision != handling it.

Static mesh Dynamic box

slide-6
SLIDE 6

Existing Continuous Physics method

while (TOI found)

 Move at earliest time of impact  Compute collision  Solve

This method costs a lot of CPU. Does not always prevent tunnelling of fast rotating bodies.

slide-7
SLIDE 7

Speculative contact points

Bounding volume Dynamic sphere Static mesh Trajectory Contact point

  • Contact point with

a positive distance

  • Cheap and

efficient solution

  • Handles various

impacts in one frame

slide-8
SLIDE 8

Speculative contact points: Ghost bug

Bounding volume Dynamic sphere Static mesh Trajectory Contact point

Stops the dynamic rigid body even if it shouldn’t.

slide-9
SLIDE 9

Speculative contact

  • This solution doesn’t

always prevent tunnelling issues.

  • This issue can occur

with ragdoll.

slide-10
SLIDE 10

A Different Approach for Continuous Physics

Existing approaches Our method Limitations Performances Conclusion

slide-11
SLIDE 11

Objective: No tunnelling issues

  • No iterative algorithm that costs a lot of CPU:
  • Iteration of all the pipeline
  • Robust:
  • Few solver iterations
  • Handling variable frame rate
  • Handling fast rotating bodies
slide-12
SLIDE 12

Our method

Our approach involves some modifications at different stages of the physics pipeline:

 Broad phase  Narrow phase  Constraint creation  Solver

slide-13
SLIDE 13

Our method

Broad phase Narrow phase Constraint creation Solver

slide-14
SLIDE 14

Moving body in the broad phase

Body’s linear velocity is used to compute the trajectory: Segment = velocity * deltaTime The segment is used to detect the potential collisions.

slide-15
SLIDE 15

Detecting the potential colliding bodies

  • Consider the

trajectory.

  • Use the bodies’

Axis Aligned Bounding Box (AABB).

slide-16
SLIDE 16

Transfer volume and compute a segment intersection

  • Add AABB of the

moving body to the other AABB

  • Compute

intersection between segment and AABB

  • Generate the

expected body pairs

slide-17
SLIDE 17

Our method

Broad phase Narrow phase Constraint creation Solver

slide-18
SLIDE 18

Incremental Manifold

Incremental manifold provides

  • ne new contact

point at each frame. Frame 1 2

Static mesh Dynamic box Contact point

slide-19
SLIDE 19

Full Manifold

Full manifold provides all contact points in one frame. Frame 1

Static mesh Dynamic box Contact point

slide-20
SLIDE 20

Distance-based full manifold

Potential contact points in full manifold

Static mesh Dynamic box Contact point

slide-21
SLIDE 21

Supported shapes

Shapes supported on all rigid bodies:

  • Sphere (point + radius)
  • Capsule (segment + radius)
  • Box
  • Convex

Shapes only supported on static rigid bodies:

  • Mesh / Height map (collision with triangles)
slide-22
SLIDE 22

Distance-based full manifold with a sphere

  • One contact point = full manifold.
  • Gilbert Johnson Keerthi (GJK) is a well known

algorithm to compute the minimum distance between two convex shapes.

  • Use GJK against any other shapes.
slide-23
SLIDE 23

Distance-based full manifold with a sphere

Contact point

slide-24
SLIDE 24

Distance-based full manifold with a capsule

  • Full manifold is required for a capsule.
  • But, how do we calculate it?
slide-25
SLIDE 25

Distance-based full manifold between a capsule and a box

Static box Dynamic capsule Trajectory

slide-26
SLIDE 26

Find the box’s reference plane

Static box Dynamic capsule Normal plane

slide-27
SLIDE 27

Project capsule extremities

  • n the plane

Static box Dynamic capsule Contact point Plane

slide-28
SLIDE 28

Find clipping planes: orthogonal to the

reference plane with an edge in common

Static box Dynamic capsule Plane Normal plane

slide-29
SLIDE 29

Clip contact points

Static box Dynamic capsule Plane Normal plane Contact point

slide-30
SLIDE 30

Compute contact points, considering the capsule radius

Static box Contact point Dynamic capsule

slide-31
SLIDE 31

If the capsule is in the Voronoï edge region, use GJK

Voronoï edge region Voronoï edge region Voronoï edge region Voronoï edge region Static box Contact point Dynamic capsule

slide-32
SLIDE 32

Distance-based full manifold between a capsule and a triangle

Static mesh Plane Normal plane Contact point Dynamic capsule

slide-33
SLIDE 33

Generalizing the computation to convex

Static convex Plane Normal plane Contact point Dynamic capsule

slide-34
SLIDE 34

Distance-based full manifold with a box

  • Full manifold is required for a box.
  • Same technique:

 Clip edges instead of segment.

  • Don’t clip all edges:

Select the right ones.

slide-35
SLIDE 35

Use edges that face the reference plane

Dynamic box Normal plane Static mesh Selected edge

slide-36
SLIDE 36

Distance-based full manifold between a box and a triangle

Dynamic box Static mesh Selected edge Contact point Clipping plane

slide-37
SLIDE 37

Distance-based full manifold: Generalization between two convexes

Dynamic convex Static mesh Selected edge Contact point Clipping plane

slide-38
SLIDE 38

Handle potential and real contact points

Real contact points Potential contact points

Contact point Static mesh Dynamic box

slide-39
SLIDE 39

Handle potential and real contact points at the same time

  • Same frame:
  • Real contact points can generate fast

rotation.

  • Potential ones avoid tunnelling issue

in the same frame.

  • Same part of the code:
  • Reuse geometry information.
  • Maximize cache access.

Contact point Static mesh Dynamic box

slide-40
SLIDE 40

Our method

Broad phase Narrow phase Constraint creation Solver

slide-41
SLIDE 41

Constraint creation for real contact points and potential ones

Real contact

  • Restitution is computed.
  • Friction is added.

Potential Contact

  • No restitution.
  • No friction.
  • Cheaper: no need to solve

the friction.

slide-42
SLIDE 42

Restitution

  • Potential contact points reduce the velocities to

reach the point of impact on the obstacle.

  • At the next frame the body reaches the obstacle

with reduced velocities.

  • Don’t use the current velocities to compute the

restitution.

slide-43
SLIDE 43

Restitution example using the current velocities

Dynamic sphere Trajectory Static mesh

slide-44
SLIDE 44

Handling restitution

Using current velocities results in a false

  • restitution. Therefore, we must:
  • Store the previous velocities; and
  • Use them to compute restitution.
slide-45
SLIDE 45

Restitution example using the previous velocities

Dynamic sphere Trajectory Static mesh

slide-46
SLIDE 46

Restitution

Pro

 Restitution is correct, with no loss of energy.

Con

 Still a loss of distance during the frame of impact. This

small loss is not visible in a video game.

slide-47
SLIDE 47
slide-48
SLIDE 48

Our method

Broad phase Narrow phase Constraint creation Solver

slide-49
SLIDE 49

Organize constraints in the solver

With a Gauss Seidel solver, each constraint changes the velocities of bodies. The latest solved constraints have more importance. Group the constraints by type. Sort them by importance.

slide-50
SLIDE 50

Hinge vs. Contact: hinge solved first avoids tunnelling issues

Dynamic box Hinge Static mesh

slide-51
SLIDE 51
slide-52
SLIDE 52

A Different Approach for Continuous Physics

Existing approaches Our method Limitations Performances Conclusion

slide-53
SLIDE 53

Limitation on the second impact

Bounding volume Dynamic sphere Static mesh Trajectory

slide-54
SLIDE 54

Limitation on the second impact

This issue will happen if the second obstacle is right after a first obstacle. Solution wouldn’t be suitable for some video games.

slide-55
SLIDE 55
slide-56
SLIDE 56

Handling several fast bodies

slide-57
SLIDE 57

Handling several fast bodies

  • We decided not to manage this case because it

was not an issue for most of the games.

  • If one body moves really fast and the other one

moves slowly, the collision will be handled correctly.

slide-58
SLIDE 58
slide-59
SLIDE 59

Remove these limitations

  • To handle these limitations, only a modification
  • n the broad phase is needed.
  • Use a bigger bounding volume, but this method:
  • Can generate unnecessary body pairs
  • Can increase CPU costs
  • Causes the ghost bug
slide-60
SLIDE 60

A Different Approach for Continuous Physics

Existing approaches Our method Limitations Performances Conclusion

slide-61
SLIDE 61

Continuous physics cost

Comparison between the discrete collision pipeline and the continuous physics pipeline. Broad phase

  • Segment intersection with an AABB:

addition, min, max, cross product, select...

  • More body pairs are generated.

Narrow Phase

  • Distance-based full manifold collision algorithms cost about

the same as traditional collision algorithms.

  • More contact points are generated.
  • Additional memory is used to store the contact points.
slide-62
SLIDE 62

Continuous physics cost

Constraint creation

 Additional data to store: previous velocities.

(For managing the restitution only.)

Solver

 No additional process.  It takes more time because there are more contact

point constraints to solve.

slide-63
SLIDE 63

Profiling in Ghost Recon Future Soldier on Xbox 360

  • Showing the profiling scene using Continuous

physics

  • CPU benchmark
  • Memory consumption
slide-64
SLIDE 64
slide-65
SLIDE 65

CPU benchmark

200 400 600 800 1000 1200 1400 1600 1800 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Time in micro seconds Frames

CPU Benchmark

Total Physics Step Cost Discrete Physics Cost Continuous Physics Cost

slide-66
SLIDE 66

Average cost: 11.4% Average only falling: 15.4% Max cost: 24.5% Min cost: 0.7% Dynamic rigid bodies: 11 All using continuous physics

CPU benchmark

10 20 30 40 50 60 70 80 90 100 1 3 5 7 9 11 13 15 17 19 % CPU cost Frames

Additional cost to the discrete pipeline

Additional cost to the discrete pipeline

slide-67
SLIDE 67

Memory consumption: compare to physics data

99% 1%

Memory consumption

Other usage Continuous Physics

Other usage: 14.2 MB Continuous Physics: 107 KB

slide-68
SLIDE 68

Memory consumption: Mesh as most important data

17% 1% 82%

Memory consumption

Other usage Continuous Physics Mesh

Other usage excluding meshes: 2.5 MB Continuous Physics: 107 KB Mesh data : 11.7 MB

slide-69
SLIDE 69

Memory consumption: Comparison without mesh data

96% 4%

Titre du graphique

Other usage without mesh Continuous Physics

Other usage excluding meshes: 2.5 MB Continuous Physics: 107 KB

slide-70
SLIDE 70

A Different approach for Continuous Physics

Existing approaches Our method Limitations Performances Conclusion

slide-71
SLIDE 71
slide-72
SLIDE 72

Conclusion

Low additional cost for the CPU

  • No big additional process.
  • Potential contact points less expensive than real

contact points: no friction.

  • The number of body pairs generated is more

significant, so the cost increases in the entire pipeline.

Restitution is handled correctly

slide-73
SLIDE 73

Conclusion

Robust: No tunnelling issues with fast rotating bodies

  • Variable frame rate
  • Few solver iterations

Limitations:

  • Several fast bodies
  • Second impact
  • Solution can be improved
slide-74
SLIDE 74
slide-75
SLIDE 75

References

Erin Catto

Iterative Dynamics with Temporal Coherence Box2D

Russell Smith

Constraints in Rigid Body Dynamics Open Dynamics Engine (ODE) Erwin Coumans Continuous Collision Detection and Physics

Bullet

slide-76
SLIDE 76

References

Gino van den Bergen

Ray Casting against General Convex Objects with Application to Continuous Collision

Dirk Gregorius

Game Physics Pearls (Gino van den Bergen)

Paul Firth

Speculative Contacts - A continuous collision engine approach

slide-77
SLIDE 77

Special Thanks

slide-78
SLIDE 78