Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Basic 3D collision detection We want to know if objects have touched Objects are considered to.

Similar presentations


Presentation on theme: "CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Basic 3D collision detection We want to know if objects have touched Objects are considered to."— Presentation transcript:

1 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Basic 3D collision detection We want to know if objects have touched Objects are considered to be in continuous motion (vertices are changing) We want to do this stuff FAST!!!

2 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics2 We’ll only do… Convex polyhedra – Objects will be broken into convex polyhedra or we’ll use an enclosing polyhedron Definition – A line segment joining any two points in the polyhedron is contained in the polyhedron

3 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics3 Two stage process Bounding boxes – Only test if bounding boxes intersect Witness test – See if we can stick a plane between them

4 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics4 Bounding box tests We will not even consider O(N 2 ). – Even for something as easy as bounding boxes

5 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics5 Suppose… You have a set of line segments – [b i,e i ] beginning to end – Bounding boxes in 1D – How could we determine if any overlap? – How fast could I do it?

6 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics6 Overlap test b1b1 e1e1 b2b2 e2e2 b3b3 e3e3 b4b4 e4e4 b5b5 e5e5 b6b6 e6e6 Any ideas now?

7 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics7 Overlap test (1D) b1b1 e1e1 b2b2 e2e2 b3b3 e3e3 b4b4 e4e4 b5b5 e5e5 b6b6 e6e6 E  sort(endpoints) O(nlogn) c  0 for each endpoint e  E do O(n) if e is a begin endpoint c  c + 1 else c  c - 1 if c > 1 then output overlapping segments O(k) O(nlogn + k) algorithm Sort and sweep

8 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics8 Overlap test (3D) We have begin/end combinations for each of 3 dimensions We build three sorted lists – Each dimension Sweep 1 dimension – Sweep 2 nd dimension only for overlaps Sweep 3 rd dimension only for overlaps Algorithm remains O(nlogn + k) Lots of careful “bookkeeping” required. Sometimes called sweep and prune

9 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics9 Can we do better than O(nlogn)? Algorithmically we can’t – Lower bound But…

10 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics10 Coherence What will make this work is that things do move very far from frame to frame – Coherence When we update a bounding box, we change the ends – But, usually not be much – Just move it in the list – Expected time: O(n) bingo!!

11 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics11 So, we have two intersecting bounding boxes, what now? We compare the enclosed polyhedra What defines intersecting polyhedra?

12 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics12 Intersection definition Two polyhedra A and B do NOT intersect if there exists a plane P such that A and B are on different sides of P – We call this plane a separating plane – It indicates there’s no intersection – Only works for convex polyhedra

13 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics13 Separating planes Separating planes will either – Contain a face of one of the polyhedra – - or - – Contain the edge of one polyhedra and are parallel to an edge in the other polyhedra

14 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics14 Determining intersection For every face and every pair of edges – Is this is a separating plane? How do we test for space partitioning?

15 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics15 Test Let p be any point on P and N be normal to P Dot product of v-p and N will be: – >= 0 for someone on one side – <= 0 for someone on the other side

16 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics16 Contact determination Can be vertex to plane or edge to edge. We have to again test all pairs

17 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics17 Fast enough to be any use? Lots of all pairs stuff here. Can this be fast enough to be any use at all? – How often do we call collision detection?

18 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics18 Witness A witness is some cached value from a previous computation that we can reuse – Keep track of – Previous separating plane Previous collision pair – Why does this make this so fast we’re really impressed?

19 CSE 872 Dr. Charles B. Owen Advanced Computer Graphics19 Use of witnesses Change from one call to another is very tiny – Separating plane usually does not change Can it? – We are often searching for the collision time – Colliding edges or face/vertex usually do not change Can they?


Download ppt "CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Basic 3D collision detection We want to know if objects have touched Objects are considered to."

Similar presentations


Ads by Google