2 Copyright (c) 2009 Hanno Braun <hanno@habraun.net>
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
19 package net
.habraun
.sd
28 class SimpleNarrowPhase
extends NarrowPhase
{
30 var testCircleCircle
: CircleCircleTest
= new ContinuousCircleCircleTest
31 var testCircleLineSegment
: CircleLineSegmentTest
= new ContinuousCircleLineSegmentTest
35 def inspectCollision(delta
: Double
, b1
: Body
, b2
: Body
) = b1
.shape
match {
39 for (r
<- testCircleCircle(s1
, s2
, b1
.position
, b2
.position
, b1
.velocity
* delta
,
40 b2
.velocity
* delta
)) yield {
41 Collision(r
.t
, Contact(b1
, r
.contact
, r
.normal
, b2
),
42 Contact(b2
, r
.contact
, -r
.normal
, b1
))
45 case s2
: LineSegment
=>
46 for (r
<- testCircleLineSegment(s1
, s2
, b1
.position
, b2
.position
, b1
.velocity
* delta
,
47 b2
.velocity
* delta
)) yield {
48 Collision(r
.t
, Contact(b1
, r
.contact
, r
.normal
, b2
),
49 Contact(b2
, r
.contact
, -r
.normal
, b1
))
56 case s1
: LineSegment
=>
59 for (r
<- testCircleLineSegment(s2
, s1
, b2
.position
, b1
.position
, b2
.velocity
* delta
,
60 b1
.velocity
* delta
)) yield {
61 Collision(r
.t
, Contact(b1
, r
.contact
, r
.normal
, b2
),
65 case s2
: LineSegment
=>