Space Partitioning for Broad Sweep Collision Detection Part 1 - Grids Game Design Experience Professor Jim Whitehead February 11, 2009 Creative Commons.

Slides:



Advertisements
Similar presentations
© 2012 Common Core, Inc. All rights reserved. commoncore.org NYS COMMON CORE MATHEMATICS CURRICULUM A Story of Units Grade 2 – Module 6.
Advertisements

Nearest Neighbor Search
Solving Verbal Problems Kitty Jay © 2002 Tomball College LAC.
Searching on Multi-Dimensional Data
Stacks, Queues, and Deques. 2 A stack is a last in, first out (LIFO) data structure Items are removed from a stack in the reverse order from the way they.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
CSE 380 – Computer Game Programming Collision Detection & Response Erin Catto’s Box2D.
Space Partitioning for Broad Sweep Collision Detection Part 2 - Quadtrees Game Design Experience Professor Jim Whitehead February 13, 2009 Creative Commons.
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience Gforge SVN Collision Detection and Resolution.
Trees II Kruse and Ryba Ch 10.1,10.2,10.4 and 11.3.
Particle Systems Final Exam Study Guide Game Design Experience Professor Jim Whitehead March 16, 2009 Creative Commons Attribution 3.0 (Except copyrighted.
Inheritance, Method Overloading, Interfaces, Abstract Classes Game Design Experience Professor Jim Whitehead January 28, 2009 Creative Commons Attribution.
CS 280 Data Structures Professor John Peterson. Invariants Back to Invariants! Recall the insertion sort invariant – how can we turn this into debugging.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
Efficient Parallelization for AMR MHD Multiphysics Calculations Implementation in AstroBEAR.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
Exam Questions Chain of Responsibility & Singleton Patterns Game Design Experience Professor Jim Whitehead February 4, 2009 Creative Commons Attribution.
Introduction to Collision Detection Lecture based on Real Time Collision Detection, Christer Ericson, Morgan Kauffman, 2005 Game Design Experience Professor.
PowerPoint: Tables Computer Information Technology Section 5-11 Some text and examples used with permission from: Note: We are.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
CS 8532: Adv. Software Eng. – Spring 2007 Dr. Hisham Haddad Tuesday Class will start momentarily. Please Stand By … CS 8532: Advanced Software.
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Identifying Reversible Functions From an ROBDD Adam MacDonald.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
CSE 381 – Advanced Game Programming Quickhull and GJK.
Course Solving Multiplication Equations Course 1 Warm Up Warm Up Lesson Presentation Lesson Presentation Problem of the Day Problem of the Day.
1 CO Games Concepts Week 20 Matrices continued Gareth Bellaby.
User Input and Collisions COSC 315 Fall 2014 Bridget M. Blodgett.
Hashing Chapter 20. Hash Table A hash table is a data structure that allows fast find, insert, and delete operations (most of the time). The simplest.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
GPU Broad Phase Collision Detection GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from GPU Gems III.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
CMPS 3130/6130 Computational Geometry Spring 2015
Salman Marvasti Sharif University of Technology Winter 2015.
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
Ratios, Proportions and Similar Figures Ratios, proportions and scale drawings.
Graphs A graphs is an abstract representation of a set of objects, called vertices or nodes, where some pairs of the objects are connected by links, called.
Understanding General Software Development Lesson 3.
(c) University of Washington02-1 CSC 143 Java Object and Class Relationships: Interfaces Reading: Ch. 9 (on Java interfaces)
Copyright © Curt Hill Sorting Ordering an array.
Entity Relationship Diagram (ERD). Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship.
Arrays.
What is GIS? “A powerful set of tools for collecting, storing, retrieving, transforming and displaying spatial data”
1 Chapter 4 Unordered List. 2 Learning Objectives ● Describe the properties of an unordered list. ● Study sequential search and analyze its worst- case.
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
Understanding General Software Development Lesson 3.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CPS120: Introduction to Computer Science Sorting.
Lesson Objectives Aims Key Words Paging, Segmentation, Virtual Memory
Introduction to Collision Detection
Microsoft Office 2007-Illustrated
PowerPoint: Tables and Charts
CMPS 3130/6130 Computational Geometry Spring 2017
Multiplication Equations
Multiplication Equations
CS 8532: Advanced Software Engineering
Introduction to Data Structures
Collision Detection.
Animation Translation.
Presentation transcript:

Space Partitioning for Broad Sweep Collision Detection Part 1 - Grids Game Design Experience Professor Jim Whitehead February 11, 2009 Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0

Technical Design Document Create a UML structure diagram for your game ► Map out your design on paper, before writing code ► Allows you to think about design decisions early ► Due this Friday, February 13 In one or more UML diagrams, describe all of the classes and interfaces you will create for your project ► For each class and interface, give Class properties, methods, and variables ► Show inheritance and containment relationships

Technical Design Document (cont’d) Items that should be in your design ► input handling ► representation of game levels, if present ► player class ► enemy classes, including a container holding active enemies ► game object classes, including a container to hold them ► collision detection ► classes for drawing player, enemies, other game objects ► classes for handling audio ► menu system classes Make sure TDD is consistent with game design ► Are you missing anything? Strongly recommend using a UML modeling tool ► StarUML is free, has good set of features ► (see link on Tools page) Demonstration of use of StarUML

Broad vs Narrow Sweep With many small objects in large playfield ► Each object only has the potential to collide with nearby objects Broad sweep ► Perform a quick pass over n objects to determine which pairs have potential to intersect, p Narrow sweep ► Perform p x p check of object pairs that have potential to intersect Dramatically reduces # of checks Mushihimesama

Broad sweep approaches Grid ► Divide playfield into a grid of squares ► Place each object in its square ► Only need to check contents of square against itself and neighboring squares ► See for example Space partitioning tree ► Subdivide space as needed into rectangles ► Use tree data structure to point to objects in space ► Only need to check tree leaves ► Quadtree, Binary Space Partition (BSP) tree Application-specific ► 2D-shooter: only need to check for collision against ship ► Do quick y check for broad sweep Point Quadtree (Wikipedia)

Space Partition Grid Subdivide space into a grid ► Each cell in the grid holds a list of the objects contained in the cell ► Objects that overlap cells are placed in multiple cells ► One approach: class Grid { // The collision grid // Grid is a 2D array, where each element holds a list of IGameObject List [,] grid; int grid_cols; // # of grid columns int grid_rows; // # of grid rows int cell_x; // x width of each grid cell int cell_y; // y width of each grid cell … This is a relatively memory intensive approach.

Grid Cell Size Issues Grid too fine ► Cell size similar to object size ► Many objects will overlap cells ► Slows update and collision checks Grid too large ► Few overlaps (good) ► Larger number of n x n checks within a cell Grid too coarse with respect to object complexity ► Complexity of object geometry makes pairwise comparison too hard ► Solution: make grid size smaller, objects broken up into smaller pieces Grid too large and too fine ► Can happen if object sizes vary widely Grid too coarse (complexity) Grid too fine

Grid Collision Test Within each cell ► Compare each object in cell with every other object in cell ► Pairwise comparison, but only within cells // Simple cell compare – does twice as many compares as necessary void cell_collide(int row, int col) { foreach (IGameObject g in grid[row,col]) { foreach (IGameObject h in grid[row,col]) { if (g == h ) continue; if (object_test(g,h) == true) { g.collided = true; h.collided = true; }

Object Update When an object moves, it may change cell location Need to compute cell(s) holding object at new location ► May be more than one due to overlap If new cell, add object to cell ► This is O(1), since only adding to end of list If leaving existing cell, need to remove from list ► Naïve approach: O(# elems in cell), since need to traverse lists to find object to remove A problem, since fast moving objects may mean large fraction of objects need to update each tick. Approaches O(n 2 ) ► Better approach: have each game object maintain pointer back to its location in list in each cell But, requires you to write your own linked list class