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 {
46 for (r
<- testCircleCircle(c1
, c2
, p1
, p2
, v1
* delta
, v2
* delta
)) yield {
47 Collision(r
.t
, Contact(b1
, b2
, r
.normal
, -r
.normal
, r
.contact
))
50 case s2
: LineSegment
=>
55 val vc
= b1
.velocity
* delta
56 val vls
= b2
.velocity
* delta
58 for (r
<- testCircleLineSegment(c
, ls
, pc
, pls
, vc
, vls
)) yield {
59 Collision(r
.t
, Contact(b1
, b2
, r
.normal
, -r
.normal
, r
.contact
))
66 case s1
: LineSegment
=>
73 val vc
= b2
.velocity
* delta
74 val vls
= b1
.velocity
* delta
76 for (r
<- testCircleLineSegment(c
, ls
, pc
, pls
, vc
, vls
)) yield {
77 Collision(r
.t
, Contact(b1
, b2
, r
.normal
, -r
.normal
, r
.contact
))
80 case s2
: LineSegment
=>