A Different Approach for Continuous Physics. Vincent ROBERT Physics Programmer at Ubisoft

Similar documents
Continuous Collision Detection and Physics

Introduction to Collision Detection

Anatomy of a Physics Engine. Erwin Coumans

Rigid Body Simulation. Jeremy Ulrich Advised by David Mount Fall 2013

Physics Parallelization. Erwin Coumans SCEA

What is a Rigid Body?

CPSC / Sonny Chan - University of Calgary. Collision Detection II

Collision Detection between Dynamic Rigid Objects and Static Displacement Mapped Surfaces in Computer Games

Collision detection in Chrono

References. Additional lecture notes for 2/18/02.

Occluder Simplification using Planar Sections

Cylinder Collision. Reddy Sambavaram 9/07/2007

Simulation (last lecture and this one)

Dynamic Bounding Volume Hierarchies. Erin Catto, Blizzard Entertainment

Convex Hull Generation with Quick Hull. Randy Gaul Special thanks to Stan Melax and Dirk Gregorius for contributions on this topic

Using Bounding Volume Hierarchies Efficient Collision Detection for Several Hundreds of Objects

Joshua Newth CS297 Professor Pollett 5/14/2012. Rigid Body Physics Simulation

Lesson 05. Mid Phase. Collision Detection

Geometry proxies (in 2D): a Convex Polygon

Web Physics: A Hardware Accelerated Physics Engine for Web- Based Applications

Direct Rendering of Trimmed NURBS Surfaces

08: CONTACT MODELLING 15/02/2016

CS535 Fall Department of Computer Science Purdue University

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Collision Detection. Pu Jiantao.

Collision Detection II. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Collision handling: detection and response

Cloth Animation with Collision Detection

Collision Detection with Bounding Volume Hierarchies

IFC-based clash detection for the open-source BIMserver

Collision Detection. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

Collision and Proximity Queries

Separating Axis Test (SAT) and Support Points in 2D. Randy Gaul Special thanks to Dirk Gregorius for his GDC 2013 lecture and slides

Principles of Computer Game Design and Implementation. Lecture 11

Real-Time Physics Simulation. Alan Hazelden.

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

Specialized Acceleration Structures for Ray-Tracing. Warren Hunt

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

Game AI: The set of algorithms, representations, tools, and tricks that support the creation and management of real-time digital experiences

Volumetric Particle Separating Planes for Collision Detection

ReactPhysics3D library User Manual

Overview. Collision detection. Collision detection. Brute force collision detection. Brute force collision detection. Motivation

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

Rotational Joint Limits in Quaternion Space. Gino van den Bergen Dtecta

Collision detection. Piotr Fulma«ski. 1 grudnia

Integrating Physics into a Modern Game Engine. Object Collision. Various types of collision for an object:

Physically-Based Laser Simulation

l Without collision detection (CD), it is practically impossible to construct e.g., games, movie production tools (e.g., Avatar)

ACOMPUTATIONALLY efficient, straightforward and robust

Overview. Collision Detection. A Simple Collision Detection Algorithm. Collision Detection in a Dynamic Environment. Query Types.

Collision detection. Piotr Fulma«ski. 19 pa¹dziernika Wydziaª Matematyki i Informatyki, Uniwersytet Šódzki, Polska

Tutorial: Using the UUCS Crowd Simulation Plug-in for Unity

Math for Gameplay / AI. John O Brien Senior Gameplay Programmer Insomniac Games, Inc

Technical Game Development II. [using materials provided by Mark Claypool] IMGD 4000 (D 08) 1. What is game physics and why is it important?

Lecture VI: Constraints and Controllers. Parts Based on Erin Catto s Box2D Tutorial

Kinetic BV Hierarchies and Collision Detection

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Game Design Unity Workshop

Computer Graphics Ray Casting. Matthias Teschner

Real-time Continuous Collision Detection and Penetration Depth Computation

improving raytracing speed

Spatial Data Structures

PolyDepth: Real-Time Penetration Depth Computation Using Iterative Contact-Space Projection

Intersecting Simple Surfaces. Dr. Scott Schaefer

Self-Collision Detection and Prevention for Humanoid Robots. Talk Overview

Physics Tutorial 4: Collision Detection

Enhancing Traditional Rasterization Graphics with Ray Tracing. October 2015

(Sparse) Linear Solvers

Technical Game Development II. [some material provided by Mark Claypool] IMGD 4000 (D 10) 1. computing motion of objects in virtual scene

Self-Collision Detection. Planning for Humanoid Robots. Digital Human Research Center. Talk Overview

Collision Experimental Data

Virtual Environments

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Collision Detection based on Spatial Partitioning

Chapter 19- Object Physics

Ray Genealogy. Raytracing: Performance. Bounding Volumes. Bounding Volume. Acceleration Classification. Acceleration Classification

QP-Collide: A New Approach to Collision Treatment

Tracking Minimum Distances between Curved Objects with Parametric Surfaces in Real Time

Technical Game Development II. [some material provided by Mark Claypool] IMGD 4000 (D 11) 1. computing motion of objects in virtual scene

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

NVIDIA GameWorks Animation Technologies in Unreal Engine 4

Critique for CS 448B: Topics in Modeling The Voronoi-clip Collision Detection Algorithm

IMGD 4000 Technical Game Development II Basic Physics

Objects DO overlap. Objects DO NOT overlap. No calculations needed.

Sign up for crits! Announcments

Accelerating Shadow Rays Using Volumetric Occluders and Modified kd-tree Traversal

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

15-494/694: Cognitive Robotics

Flowmap Generator Reference

Robot Motion Control Matteo Matteucci

igmobybspheres jonathan garrett 3/7/08

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

Physics based animations. Julien Vulliet (Vux) Natan Sinigaglia (Dottore)

ECE276B: Planning & Learning in Robotics Lecture 5: Configuration Space

Collision Detection of Triangle Meshes using GPU

Bounding Volume Hierarchies

LECTURE 7. Announcements

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

Transcription:

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 Different Approach for Continuous Physics Existing approaches Our method Limitations Performances Conclusion

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

An issue can still occur With the Linear cast, a future collision can be detected. Detecting the collision!= handling it. Static mesh Dynamic box

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.

Speculative contact points Contact point with a positive distance Cheap and efficient solution Handles various impacts in one frame Contact point Bounding volume Dynamic sphere Static mesh Trajectory

Speculative contact points: Ghost bug Stops the dynamic rigid body even if it shouldn t. Contact point Bounding volume Dynamic sphere Static mesh Trajectory

Speculative contact This solution doesn t always prevent tunnelling issues. This issue can occur with ragdoll.

A Different Approach for Continuous Physics Existing approaches Our method Limitations Performances Conclusion

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

Our method Our approach involves some modifications at different stages of the physics pipeline: Broad phase Narrow phase Constraint creation Solver

Our method Broad phase Narrow phase Constraint creation Solver

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.

Detecting the potential colliding bodies Consider the trajectory. Use the bodies Axis Aligned Bounding Box (AABB).

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

Our method Broad phase Narrow phase Constraint creation Solver

Incremental Manifold Frame 012 Incremental manifold provides one new contact point at each frame. Static mesh Dynamic box Contact point

Full Manifold Frame 01 Full manifold provides all contact points in one frame. Static mesh Dynamic box Contact point

Distance-based full manifold Potential contact points in full manifold Static mesh Dynamic box Contact point

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)

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.

Distance-based full manifold with a sphere Contact point

Distance-based full manifold with a capsule Full manifold is required for a capsule. But, how do we calculate it?

Distance-based full manifold between a capsule and a box Trajectory Dynamic capsule Static box

Find the box s reference plane Normal plane Dynamic capsule Static box

Project capsule extremities on the plane Plane Contact point Dynamic capsule Static box

Find clipping planes: orthogonal to the reference plane with an edge in common Plane Normal plane Dynamic capsule Static box

Clip contact points Contact point Plane Normal plane Dynamic capsule Static box

Compute contact points, considering the capsule radius Contact point Dynamic capsule Static box

If the capsule is in the Voronoï edge region, use GJK Voronoï edge region Voronoï edge region Voronoï edge region Voronoï edge region Contact point Dynamic capsule Static box

Distance-based full manifold between a capsule and a triangle Contact point Plane Normal plane Dynamic capsule Static mesh

Generalizing the computation to convex Contact point Plane Normal plane Dynamic capsule Static convex

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.

Use edges that face the reference plane Selected edge Normal plane Dynamic box Static mesh

Distance-based full manifold between a box and a triangle Clipping plane Selected edge Contact point Dynamic box Static mesh

Distance-based full manifold: Generalization between two convexes Clipping plane Selected edge Contact point Dynamic convex Static mesh

Handle potential and real contact points Real contact points Potential contact points Static mesh Contact point Dynamic box

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. Static mesh Maximize cache access. Contact point Dynamic box

Our method Broad phase Narrow phase Constraint creation Solver

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.

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.

Restitution example using the current velocities Dynamic sphere Trajectory Static mesh

Handling restitution Using current velocities results in a false restitution. Therefore, we must: Store the previous velocities; and Use them to compute restitution.

Restitution example using the previous velocities Dynamic sphere Trajectory Static mesh

Restitution Pro Con Restitution is correct, with no loss of energy. Still a loss of distance during the frame of impact. This small loss is not visible in a video game.

Our method Broad phase Narrow phase Constraint creation Solver

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.

Hinge vs. Contact: hinge solved first avoids tunnelling issues Dynamic box Hinge Static mesh

A Different Approach for Continuous Physics Existing approaches Our method Limitations Performances Conclusion

Limitation on the second impact Bounding volume Dynamic sphere Static mesh Trajectory

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.

Handling several fast bodies

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.

Remove these limitations To handle these limitations, only a modification on 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

A Different Approach for Continuous Physics Existing approaches Our method Limitations Performances Conclusion

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.

Continuous physics cost Constraint creation Additional data to store: previous velocities. Solver (For managing the restitution only.) No additional process. It takes more time because there are more contact point constraints to solve.

Profiling in Ghost Recon Future Soldier on Xbox 360 Showing the profiling scene using Continuous physics CPU benchmark Memory consumption

Time in micro seconds CPU benchmark 1800 1600 1400 1200 1000 800 600 400 200 0 CPU Benchmark 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Frames Total Physics Step Cost Discrete Physics Cost Continuous Physics Cost

% CPU cost CPU benchmark Additional cost to the discrete pipeline 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 100 90 80 70 60 50 40 30 20 Additional cost to the discrete pipeline 10 0 1 3 5 7 9 11 13 15 17 19 Frames

Memory consumption: compare to physics data Memory consumption Other usage Continuous Physics 1% Other usage: 14.2 MB Continuous Physics: 107 KB 99%

Memory consumption: Mesh as most important data Memory consumption Other usage Continuous Physics Mesh 17% 1% Other usage excluding meshes: 2.5 MB Continuous Physics: 107 KB Mesh data : 11.7 MB 82%

Memory consumption: Comparison without mesh data Titre du graphique Other usage without mesh Continuous Physics 4% Other usage excluding meshes: 2.5 MB Continuous Physics: 107 KB 96%

A Different approach for Continuous Physics Existing approaches Our method Limitations Performances Conclusion

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

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

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

References Gino van den Bergen Ray Casting against General Convex Objects with Application to Continuous Collision Dirk Gregorius Paul Firth Game Physics Pearls (Gino van den Bergen) Speculative Contacts - A continuous collision engine approach

Special Thanks