Stop my Constraints from Blowing Up! Oliver Strunk (Havok)

Similar documents
Modeling and Solving Constraints. Erin Catto Blizzard Entertainment

Principles of Computer Game Design and Implementation. Lecture 17

the gamedesigninitiative at cornell university Lecture 18 Box2D Physics

Physic 602 Conservation of Momentum. (Read objectives on screen.)

Newton s Wagon. Materials. friends rocks wagon balloon fishing line tape stopwatch measuring tape. Lab Time Part 1

The Story of Energy. Forms and Functions

the gamedesigninitiative at cornell university Lecture 17 Physics and Motion

UNIT 2G. Momentum & It s Conservation

1 Forces. 2 Energy & Work. GS 104, Exam II Review

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

Elementary Mechanics Using Matlab

CHAPTER 7 NEWTON'S THIRD LAW OF MOTION MOMENTUM & CONSERVATION OF MOMENTUM ACTIVITY LESSON DESCRIPTION POINTS

SUPERCHARGED SCIENCE. Unit 2: Motion.

You know the drill: Turn in hw Pick up graded hw Name tags up Grab white boards and markers for your group

Physics 100. Today. Finish Chapter 4: Newton s Second Law. Start Chapter 5: Newton s Third Law

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

What is a Force? Free-Body diagrams. Contact vs. At-a-Distance 11/28/2016. Forces and Newton s Laws of Motion

Rotational Dynamics, Moment of Inertia and Angular Momentum

SPS8. STUDENTS WILL DETERMINE RELATIONSHIPS AMONG FORCE, MASS, AND MOTION.

Physics 101. Today Chapter 5: Newton s Third Law

Σp before ± I = Σp after

Forces and Motion Chapter Problems

LECTURE 22 EQUILIBRIUM. Instructor: Kazumi Tolich

CS-184: Computer Graphics

r r Sample Final questions for PS 150

Lecture PowerPoints. Chapter 4 Physics: for Scientists & Engineers, with Modern Physics, 4th edition Giancoli

Phys 111 Final Exam December 16, 2015

Newton s Laws of Motion

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Driveway Races Acceleration

NEWTON S LAWS OF MOTION. Review

Chapter 9 Momentum and Its Conservation

Physics 8 Wednesday, October 14, 2015

Welcome back to Physics 211

If there is nothing pushing on an object, it will not move. If there is nothing pushing on an object, it will not stop. The List:

particle p = m v F ext = d P = M d v cm dt

This Week. 7/29/2010 Physics 214 Fall

MITOCW MIT8_01F16_w02s05v06_360p

Impulse (J) J = FΔ t Momentum Δp = mδv Impulse and Momentum j = (F)( p = ( )(v) F)(Δ ) = ( )(Δv)

Big Idea 4: Interactions between systems can result in changes in those systems. Essential Knowledge 4.D.1: Torque, angular velocity, angular

Physics Knowledge Organiser P8 - Forces in balance

Newton s Laws of Motion. Steve Case NMGK-8 University of Mississippi October 2005

Most people said that they understand force and acceleration. GOOD!

Lecture Presentation Chapter 9 Momentum

Chapter 10: Dynamics of Rotational Motion

Physics 121, Sections 1 and 2, Winter 2011 Instructor: Scott Bergeson Exam #3 April 16 April 21, 2011 RULES FOR THIS TEST:

Physics 11 (Fall 2012) Chapter 9: Momentum. Problem Solving

Momentum. Slide 2 / 69. Slide 1 / 69. Slide 4 / 69. Slide 3 / 69. Slide 5 / 69. Slide 6 / 69. Conservation of Momentum. Conservation of Momentum

6 th week Lectures Feb. 12. Feb

Problem Solving Day and Movie Project Introduction

PHYSICS 220. Lecture 15. Textbook Sections Lecture 15 Purdue University, Physics 220 1

A B = AB cos θ = 100. = 6t. a(t) = d2 r(t) a(t = 2) = 12 ĵ

ET3-7: Modelling I(V) Introduction and Objectives. Electrical, Mechanical and Thermal Systems

Momentum. Physics 1425 Lecture 15. Michael Fowler, UVa

Newton s Laws Student Success Sheets (SSS)

Mechanics 5 Dynamics of a rigid body. Basic phenomena

Section 4: Newton s Laws and Momentum

Forces are impossible to see! We can only see the effects! Essentially forces are pushes or pulls.

Chapter 8: Momentum, Impulse, & Collisions. Newton s second law in terms of momentum:

Physics 8 Monday, October 12, 2015

Newton's 1 st Law. Newton s Laws. Newton's 2 nd Law of Motion. Newton's Second Law (cont.) Newton's Second Law (cont.)

TEST REPORT. Question file: P Copyright:

This Week. 9/5/2018 Physics 214 Fall

TEACHER BACKGROUND INFORMATION FORCE

Physics 201, Practice Midterm Exam 3, Fall 2006

PHY218 SPRING 2016 Review for Final Exam: Week 14 Final Review: Chapters 1-11, 13-14

Modal Analysis: What it is and is not Gerrit Visser

Physics Tutorial 6: Collision Response

Laws of Motion. What is force? What happens when you push or pull objects? Some examples of pushing and pulling. Definition Force:

Kinematic Physics for Simulation and Game Programming

5.2 Infinite Series Brian E. Veitch

Physics 111. Tuesday, November 2, Rotational Dynamics Torque Angular Momentum Rotational Kinetic Energy

Preparing for Six Flags Physics Concepts

GRADE 7: Physical processes 4. UNIT 7P.4 9 hours. The effects of forces. Resources. About this unit. Previous learning

Save My Exams! The Home of Revision For more awesome GCSE and A level resources, visit us at

Test Wed, Feb 8 th 7pm, G20 MING HSIEH Bring your calculator and #2 pencil with a good eraser! 20 Multiple choice questions from:

Comments about HW #1 Sunset observations: Pick a convenient spot (your dorm?) Try to get 1 data point per week Keep a lab notebook with date, time,

ω avg [between t 1 and t 2 ] = ω(t 1) + ω(t 2 ) 2

Final (3.4)(2.54) = ( )( ) = x = max+ mv 2. + at 2 d. mv = xma t. Name: Class: Date:

Semester 1 Final Exam Review Answers

Announcements Oct 16, 2014

Math-2 Lesson 2-4. Radicals

Chapter 9: Rotational Dynamics Tuesday, September 17, 2013

Exam 1--PHYS 151--Chapter 1

Work, Power, & Machines

Moving Bodies---The Marble Luge Run

Momentum. Physics 211 Syracuse University, Physics 211 Spring 2017 Walter Freeman. February 28, W. Freeman Momentum February 28, / 15

The English physicist Isaac Newton ( ) was one of the greatest physicists of all time. His conception of the universe, which he formulated at

1. The first thing you need to find is the mass of piece three. In order to find it you need to realize that the masses of the three pieces must be

Homework #19 (due Friday 5/6)

Final Exam Review Topics/Problems

Here s a typical flow chart for game physics.

Momentum. Inertia in Motion

Momentum ~ Learning Guide Name:

GIANCOLI READING ACTIVITY Lesson 8-4

PROJECTILE MOTION: CONSERVATION OF MOMENTUM 19 FEBRUARY 2013

Semester 1 Final Exam Review Answers

CHAPTER 7 NEWTON'S THIRD LAW OF MOTION MOMENTUM & CONSERVATION OF MOMENTUM ACTIVITY LESSON DESCRIPTION POINTS

Torque rotational force which causes a change in rotational motion. This force is defined by linear force multiplied by a radius.

Rotation and Angles. By torque and energy

Transcription:

Stop my Constraints from Blowing Up! Oliver Strunk (Havok) 1

Overview Just understanding a rigid-body solver algorithm is not enough. (google for ragdoll glitch and enjoy) Solver Algorithm 2

Chapter I: How does a solver work? 198 kg 2 kg 198 kg 2 meter 3

Position only Solver Each Bavarian moves the mug to his boat every other second. The center of mass of Bavarian + Beer must stay constant: the mass ratio mug : Bavarian = 1:99 -> the mug will move 198cm and the Bavarian 2cm. In the end the mug and the Bavarian moved and all velocities are 0. In the next second the other Bavarian will do the same. Repeat 4

1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97 Lets iterate Step Distance 1 2.00 2 1.98 3 1.96 4 1.94 5 1.92 10 1.83 100.74 ~2/e 2.50 2.00 1.50 1.00 0.50 0.00 5

Now use velocities 198 kg 2 kg 198 kg 2 meter 6

Position and Velocity Solver Each Bavarian now pulls the rope every other second such that the mug arrives at his boat after one second. Mass * velocity (moment) must stay constant: -> If the beer is accelerated to 1.98 meters/second, the Bavarian will be accelerated to 2.0cm/second. After one second: the mug reaches the boat and both mug and Bavarian have some velocity. In the next second the other Bavarian will pull the rope and reverse the velocity of the mug. 7

Let s iterate Relative Step Distance Velocity Distance Prev. Solver 1 2 0.020 2.00 2 1.98 0.060 1.98 3 1.92 0.098 1.96 4 1.82 0.134 1.94 5 1.69 0.168 1.92 6 1.52 0.199 1.90 7 1.32 0.225 1.88 8 1.10 0.247 1.86 9 0.85 0.264 1.85 10 0.59 0.276 1.83 11 0.31 0.282 1.81 12 0.03 0.282 1.79 2.50 2.00 1.50 1.00 0.50 0.00 1 2 3 4 5 6 7 8 9 10 11 12 8

Lessons Learned 2 constraints fighting each other iteratively solves the global problem (=bringing the boats together). We saw 2 types of iterative solvers: Strength ~ num iterations (convergence) Strength ~ num iterations 2, but this adds energy 9

Can We Pull an Ocean-Liner Using a Mug? 100 000 000 kg 100 000 000 kg 2 kg 2 meter 10

7000 iterations of our beer-mug solver will move this ship by 1 meter.

Lets look into details. Solver strength depends on: Solver type (e.g. linear/quadratic) We want fast convergence without the risk of instability. Number of solver iterations (per second) We want as few as possible to save CPU. Mass ratio of the objects involved Needs to be as small as possible to allow for small number of iterations. 12

Solver Type Statement: All quadratic/linear convergence solvers have similar strength. Solver variants found in the literature: Position/velocity based solver. Error correction by post-projection, split impulse or Baumgarte-stabilization. 13

Number of Solver Iterations Say n=iterations/sec, d=distance > we accelerate the body n-times per second to d*n velocity -> acceleration = n 2 *d n [Hz] d [meter] acceleration acc/gravity 30 0.05 45 4.5 120 0.05 720 72 240 0.01 576 57.6 1000 0.10 100000 10000 14

Number of Solver Iterations Observations: Running one solver iteration per frame (30Hz) is not good enough. Running a pure quadratic convergent solver higher than frame frequency can lead to instability. Most game physics engine solvers use quadratic convergence using frame frequency (30Hz) and use linear convergence using subiterations (4-10). 15

Mass Ratio: High mass ratios require lots of solver iterations, so keep mass ratio low! Avoid calculating the mass from density automatically: Guessing density is tricky: What is the density of a car / a 747? Problem: solid vs. hollow objects -> So let your artist set the mass not the density. A tank driving either over a 10cm metal or a wooden box makes no difference: Increase your masses on small debris objects Exceptions: bullets and rockets Advice: Don t tweak mass if you don t have a problem yet. 16

Mass-Ratio in a 3d-World In a 1d-universe, the mass ratio just depends on the mass of the objects. But games are not 1d, so 2d/3d rigid bodies can rotate. As a result the mass ratio depends on mass and inertia (= angular mass ). 17

Typical Bad Example Clavicle bone arm torso Lets assume: All joints are limited. All joints have reached their limit. Shoulder bone is 4x smaller than arm. Mass is calculated from density. 18

Let s simplify Lets move the pivot to the mass center of the combined arm. (in a fixed constraint we can do this without changing behavior). We see: We virtually apply a force at the shoulder bone way outside its shape. Is this bad? Yes, it results in very poor solver strength because the effective mass ratio gets extremely high (1 : 3000) 19

Effective Mass impulse Velocity = impulse/mass 20

Effective Mass Impulse Point vel. Angular vel. Linear vel. d Center of Mass 21 velocity at = linearvel + d*angularvel = impulse/mass + d*impulse/angularmass(d) angularmass(d) = inertia/d velocity = impulse / effmass effmass = 1 / (1/mass + d 2 /inertia)

Effective Mass Example Dimensions: 1meter * 20cm * 20cm Mass: 100kg (= density: 2.5kg/litre) Distance: =.5 meter. Inertia: 100/12* (1*1 +.2*.2) = 8.6 kg m 2 Effmass at = 1/(1/100 +.5 2 /8.6 ) = 25kg 22

Lets make the cube 4x smaller Dimensions:.25meter * 5cm * 5cm Mass: 1.56kg (= density: 2.5kg/litre) Distance: =.5 meter. Inertia: 1/12*1.56*(.25*.25 +.05*.05) = 8.46e-5 Total effmass at = 33.13g cube 4 times smaller -> eff.mass drops by 750!!! 23

Summary Chapter 1 Solver strength mainly depends on: Number of solver iterations Mass ratio Rotations are bad! Angular movement reduces our effective mass and therefore our solver strength. 24

Chapter 2: Angular Effects Angular movement not only reduces effective mass but also leads to instability! Demo 25

Angular Effects We have 2 distance constraints (distance d) between a ball and 2 fixed walls. d d 26

Angular Effects If we move the walls apart, we ll have to move the ball to satisfy the constraints: d d d d 27

Angular Effects How will a perfect algorithm solve this? d d 28

Angular Effects We are forced to linearize the equations of motion. d d 29

Angular Effects Lets move the walls a little bit further: d d 30

Angular Effects A solver will gain energy if it overshoots too much. The likelihood of overshoots increases if the solver misspredicts the angular movement: Because of linearization, the force direction (=Jacobian) is not optimally chosen, especially when running building the jacobian - algorithm at low frequency. Angular velocity is high compared to linear velocity. Effective angular mass is much less than the body mass and high forces are applied: inertia/d 2 / mass << 1.0 31

Lessons Learned Low inertias are the main problem for bad solver behavior!!! They increase the effective mass ratios between bodies They lead to high angular velocities, which lead to explosions /jitter Solution: Increase inertias 32

Increasing Inertia Demo 33

Increasing Inertia Lessons learned: We can increase inertia of selected single objects easily by factor of 2-4 before users spot serious artifacts. 34

Inertia Visualizations We can visualize the inertia by drawing a box which would have the same inertia. Object Object with increased inertia Inertia Inertia 35

36 Combining Inertias

37 Combining Inertias

Demo Of Ragdoll With Increased Inertia Demo 38

Lessons Learned Increasing inertia matrix is very often quite acceptable in a game environment and artifacts are hardly noticeable. Especially true for small bodies inside a chain of constraint bodies (like shoulder bone). 39

How to Increase the Inertia Matrix Multiply by a factor (single bodies) Add a constant to the diagonal (bodies in a constraint chain) 40

Summary Chapter 2 To improve solver stability and strength : Increase inertia Increase simulation frequency Decrease mass ratio Advice: Don t try to damp rigid bodies or the solver 41

Chapter 3: Reducing Rigidity Our physics engine uses rigid bodies. Rigid means 100% rigid. Bodies never deform. Bodies never break. Impulses and friction forces have no limit: -> Physics engine can feel cute and bouncy 42

Implementing Soft Contact Reduce the maximum contact impulse to allow for some penetration. E.g. clip the impulse. Ensure that the penetration recovery happens slowly to avoid springy behavior. E.g. reduce the Baumgarte stabilization for this contact. 43

Soft Contact Demo: 44

Destruction Idea: destroy bodies if impulses get too high. 45

Destruction Solution 1: Estimate the contact impulse and destruct the object before running the solver: Impulse = relativevelocity * effectivemass This works pretty well, except if the breakable object is blocked by an unbreakable object. Fast bullet Unbreakable Box Destructible wall 46

Destruction Solution 2: After running the solver: If the contact impulse exceeds a limit, break the object If implemented naively, breakable fixed objects will stop any moving object. 1 st frame: 2 nd frame: Fast bullet Destructible wall Stopped bullet Destroyed wall 47

Destruction Solution 2b: Extend solution 2 with the following modifications: The solver also clips the impulses to the breaking limit. If an object breaks, move the two objects involved to the previous position. 1 st frame: 2 nd frame Just after solve: 2 nd frame after destruct and position move: 48

Destruction Demo 49

Summary Chapter 3 Impulse clipping in the solver allows to emulate soft, deformable or breakable materials. 50

The End Thanks for listening, questions welcome Solver Algorithm 51