cse 872 dr. charles b. owen advanced computer graphics1 basic 3d collision detection we want to know...

19
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics 1 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!!!

Upload: dominic-morgan

Post on 18-Dec-2015

216 views

Category:

Documents


3 download

TRANSCRIPT

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!!!

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

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

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

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?

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics6

Overlap test

b1 e1 b2 e2 b3 e3b4 e4b5 e5 b6 e6

Any ideas now?

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

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

CSE 872 Dr. Charles B. OwenAdvanced Computer Graphics9

Can we do better than O(nlogn)?

• Algorithmically we can’t– Lower bound

• But…

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!!

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?

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

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

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?

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

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

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?

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?

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?