Continuous Collision Detection for Wires with Adaptive Resolution
Total Page:16
File Type:pdf, Size:1020Kb
Continuous Collision Detection for Wires with Adaptive Resolution Michael Brandl Friday 31st March, 2017 Master’s Thesis in Computing Science, 30 ECTS credits Supervisor at CS-UmU: Martin Berggren Examiner: Eddie Wadbro Umeå University Department of Computing Science SE-901 87 UMEÅ SWEDEN Abstract For interactive simulations using a physics engine, a fixed time step is often necessary in order to maintain real-time performance. Furthermore, collisions between the simulated geo- metric objects have to be detected by solving a computational problem called collision detection. In its discrete formulation, the geometric configurations of the bodies are evaluated at each sim- ulation time step, whereas its continuous variant also considers the bodies’ motion in between the time steps. A fixed simulation time step can lead to missed collisions if only discrete colli- sion detection is performed. This problem arises especially when simulating thin objects such as wires, chains, or ropes for applications like heavy lifting or anchor handling. In order to be able to simulate wires interacting with each other in real-time simulations, continuous collision detection is therefore necessary. An existing simulation model for wires, chains, and ropes using adaptive wire resolution has been augmented using continuous collision detection. This addition has been integrated into the physics engine AGX Dynamics. Issues in existing methods for continuous collision detection of moving line segments caused by co-linearity and co-planarity have been identified, classified and addressed. Using this augmented approach to continuous collision detection allows for a larger fixed simulation step size compared to discrete collision detection, and thus decreases the total run time by up to 58.22% in relevant scenarios. Sammanfattning För interaktiva simuleringar med en fysikmotor är det ofta nödvändigt att använda ett fast tids- steg för att bibehålla realtidsprestanda. Dessutom måste kollisioner mellan de simulerade geo- metriska objekt upptäckas genom att lösa ett beräkningsproblem som kallas för kollisionsde- tektering. I dess diskreta formulering utvärderas kropparnas geometriska konfiguration i varje simuleringstidssteg, medan den kontinuerliga varianten även tar hänsyn till kropparnas rörelse under tidssteget. Ett fast tidssteg kan leda till att kollisioner missas om bara diskret kollisionsde- tektering används. Detta problem uppstår speciellt när tunna objekt såsom vajrar, kättingar eller rep simuleras i tillämpningar som tunga lyft eller ankarhantering. För att kunna simulera vajrar som interagerar med varandra i realtidssimuleringar behövs därför kontinuerlig kollisionsdetek- tering. En existerande simuleringsmodell för vajrar, kättingar och rep som använder sig av adaptiv vajerupplösning har utökats med kontinuerlig kollisionsdetektering. Utökningen har integrerats i fysikmotorn AGX Dynamics. Problem inom existerande metoder för kontinuerlig kollisions- detektering av rörliga linjesegment som orsakas av kolinjäritet och koplanaritet har identifierats, klassificerats och behandlats. Användningen av denna variant av kontinuerlig kollisionsdetek- tering tillåter ett större fast simuleringstidssteg jämfört med diskret kollisionsdetektering, och minskar därmed den totala exekveringstiden med upp till 58.22% i relevanta scenarion. ii Contents Contents iii List of Figures vii List of Tables xi List of Algorithms xiii 1 Introduction 1 2 Theory 5 2.1 Physics Engine .................................. 5 2.1.1 Multibody Simulation .......................... 5 2.1.2 General Design .............................. 5 2.1.3 Simulation Step Pipeline ......................... 6 2.1.4 Real-Time Simulation .......................... 6 2.2 Collision Detection in a Physics Engine ..................... 6 2.2.1 Output of Discrete Collision Detection .................. 8 2.2.2 Output of Continuous Collision Detection ................ 9 2.3 Collision Detection Pipeline ........................... 10 2.3.1 Broad Phase ............................... 11 2.3.1.1 Bounding Volumes ...................... 11 2.3.1.2 Sweep and Prune ....................... 12 2.3.1.3 Hierarchical Grid ....................... 13 2.3.2 Middle Phase ............................... 14 2.3.3 Narrow Phase ............................... 16 2.3.3.1 Sphere-Sphere Collision Detection .............. 16 2.3.3.2 Separating Axis Test ...................... 17 2.3.3.3 GJK with EPA ......................... 18 2.3.3.4 Non-Convex Objects ..................... 20 2.4 Overview of Continuous Collision Detection ................... 20 2.4.1 General Approaches ........................... 20 iii iv CONTENTS 2.4.2 In-Between Motion ............................ 22 2.4.3 Continuous Broad Phase and Middle Phase ............... 23 2.5 Continuous Collision Detection of Triangle-Triangle Pairs ........... 24 2.5.1 Original Approach by Moore ....................... 24 2.5.2 Solving Polynomials Numerically .................... 26 2.5.3 Provot’s Method ............................. 28 2.5.4 Issues with Co-Planarity and Co-Linearity ................ 29 2.6 Wire Simulation .................................. 29 2.6.1 Recent Approaches ............................ 30 2.6.2 Hybrid, Multi-Resolution Wires with Massless Frictional Contacts ... 30 2.7 AGX Dynamics .................................. 32 2.7.1 Spook Stepper .............................. 33 2.7.2 Collision Detection ............................ 33 2.7.3 Constraints ................................ 33 2.7.4 Wires ................................... 34 3 Method 35 3.1 Continuous Collision Detection Edge-Edge ................... 35 3.1.1 Detection of Co-Planarity and Co-Linearity ............... 35 3.1.1.1 Detection of Case 1: Line Segments Degenerate ....... 38 3.1.1.2 Detection of Case 2: Line Segment Starting Points Identical . 38 3.1.1.3 Detection of Case 3: Parallel Case .............. 38 3.1.1.4 Detection of Case 4: 2D-Case ................. 39 3.1.2 The Parallel Case ............................. 41 3.1.2.1 Detection of the Parallel Co-Linear Case ........... 42 3.1.2.2 Handling the Parallel Co-Linear Case ............. 43 3.1.2.3 Handling the Parallel Non-Degenerate Case ......... 45 3.1.3 The 2D-Case ............................... 46 3.1.3.1 Testing for Initial Overlap ................... 46 3.1.3.2 The Permanent Point-On-Line Case .............. 49 3.1.3.3 The General 2D Case ..................... 49 3.1.4 The General Case ............................. 49 3.1.5 A Note on Thresholds .......................... 49 3.2 Implementation .................................. 50 3.2.1 Libraries ................................. 50 3.2.2 WireShape-Class ............................. 51 3.2.3 Broad Phase ............................... 51 3.2.4 Narrow Phase ............................... 52 3.2.5 Hardware ................................. 52 CONTENTS v 4 Results and Discussions 59 4.1 WireShape Collision Cases ............................ 59 4.1.1 Explanation of Visualization ....................... 59 4.1.2 The Non-Degenerate Case ........................ 60 4.1.3 Case 2: Line Segment Starting Points Identical ............. 60 4.1.4 Case 3: The Parallel Case ........................ 60 4.1.5 Case 4: The 2D-Case ........................... 62 4.2 Wire Collision Scenarios ............................. 67 4.2.1 Scenario Descriptions .......................... 67 4.2.1.1 Scenario 1: Basic Collision .................. 67 4.2.1.2 Scenario 2: Wire Pulling Anchor ............... 67 4.2.1.3 Scenario 3: Twisting under Load ............... 67 4.2.1.4 Scenario 4: Chains on Deck ................. 71 4.2.2 Occurrence of Degenerate Cases ..................... 71 4.2.3 Computation Time ............................ 71 5 Conclusion 77 5.1 Achievements ................................... 77 5.2 Shortcomings ................................... 77 5.3 Future Work .................................... 78 6 Acknowledgments 79 References 81 vi CONTENTS List of Figures 1.1 Real-time simulation of cranes with wires. .................... 1 1.2 Objects s1 and s2 tunneling through each other within the time step from time t0 to t1. ....................................... 2 1.3 Two wires tunneling through each other. ..................... 2 2.1 Typical pipeline for a physics engine. ...................... 7 2.2 Contact points at beginning of time step, time of impact, and end of time step. 8 2.3 Intersection depth and corresponding normal nd not equal to contact normal from movement of bodies nv. ........................... 9 2.4 Non-convex contact of capsule in triangle mesh-torus, using contacts with dif- ferent normals. The orange spheres indicate the contact points, and the orange arrows the contact normals. Visualized in AGX Dynamics. ........... 10 2.5 Typical pipeline for collision detection. ..................... 11 2.6 Different bounding volumes. ........................... 12 2.7 Bounding volume for moving object in continuous collision detection. ..... 12 2.8 Sweep and Prune on objects in 2D. ........................ 13 2.9 Objects in a uniform grid (2D). .......................... 13 2.10 Objects in a hierarchical grid (2D). ........................ 14 2.11 An AABB-tree in 2D. The edges of the arrow-shaped geometry with red bound- aries are surrounded by black AABBs, which are the leaf-nodes of the tree. The tree’s root is the green AABB covering the whole geometry. Its children are the two blue AABBs covering part of it, each enclosing two black AABBs. The tree node structure is shown in Figure 2.12.