NarrowPhase: Don't pass time delta to inspectCollision.
[scd.git] / src / net / habraun / sd / SimpleBroadPhase.scala
blobad79a7f63bb45a9a9c4488a3a9408de895993af1
1 /*
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
23 /**
24 * SimpleBroadPhase is the simplest possible implementation of a broad phase. It just compiles all possible
25 * pairs of the bodies it is given and returns those.
26 * If any other broad phase implementation is available, it should probably be used in place of this one.
29 class SimpleBroadPhase extends BroadPhase {
31 /**
32 * Returns all possible pairs of the given bodies.
35 def detectPossibleCollisions(bodies: List[Body]) = {
36 def buildPairs(list: List[Body], pairs: List[(Body, Body)]): List[(Body, Body)] = {
37 if (list.isEmpty)
38 pairs
39 else
40 buildPairs(list.tail, pairs:::list.tail.map((list.head, _)))
43 buildPairs(bodies, Nil)