Transcript
Page 1: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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!!!

Page 2: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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

Page 3: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics3

Two stage process

• Bounding boxes– Only test if bounding boxes intersect

• Witness test– See if we can stick a plane between them

Page 4: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics4

Bounding box tests

• We will not even consider O(N2). – Even for something as easy as bounding boxes

Page 5: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics5

Suppose…

• You have a set of line segments– [bi,ei] beginning to end

– Bounding boxes in 1D– How could we determine if any overlap?– How fast could I do it?

Page 6: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics6

Overlap test

b1 e1 b2 e2 b3 e3b4 e4b5 e5 b6 e6

Any ideas now?

Page 7: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics7

Overlap test (1D)

b1 e1 b2 e2 b3 e3b4 e4b5 e5 b6 e6

E sort(endpoints) O(nlogn)c 0for each endpoint eE do O(n) if e is a begin endpoint c c + 1 else c c - 1if c > 1 then output overlapping segments O(k)

O(nlogn + k) algorithm

Sort and sweep

Page 8: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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 2nd dimension only for overlaps

• Sweep 3rd dimension only for overlaps

• Algorithm remains O(nlogn + k)• Lots of careful “bookkeeping” required.• Sometimes called sweep and prune

Page 9: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics9

Can we do better than O(nlogn)?

• Algorithmically we can’t– Lower bound

• But…

Page 10: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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!!

Page 11: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics11

So, we have two intersecting bounding boxes, what now?

• We compare the enclosed polyhedra• What defines intersecting polyhedra?

Page 12: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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

Page 13: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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

Page 14: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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?

Page 15: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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

Page 16: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics16

Contact determination

• Can be vertex to plane or edge to edge. We have to again test all pairs

Page 17: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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?

Page 18: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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?

Page 19: Basic 3D collision detection

CSE 872 Dr. Charles B. OwenAdvanced 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?


Top Related