Skip to content

Commit 0ddf67b

Browse files
committed
WIP collision-rs integration
1 parent 034d941 commit 0ddf67b

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ default = ["opengl"]
2020

2121
[dependencies]
2222
cgmath = "0.14"
23-
collision = "0.10"
23+
collision = {path = "../collision"}
2424
froggy = "0.3"
2525
genmesh = "0.5"
2626
gfx = "0.16"

src/factory.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use std::io::BufReader;
44
use std::fs::File;
55
use std::path::Path;
66

7-
use cgmath::Transform as Transform_;
7+
use cgmath::{Point3, Transform as Transform_};
8+
use collision::Aabb3;
89
use genmesh::{Polygon, EmitTriangles, Triangulate, Vertex as GenVertex};
910
use genmesh::generators::{self, IndexedPolygon, SharedVertex};
1011
use gfx;
@@ -15,7 +16,6 @@ use image;
1516
use mint;
1617
use obj;
1718

18-
use bound::BoundingBox;
1919
use camera::{Orthographic, Perspective};
2020
use render::{BackendFactory, BackendResources, GpuData, Vertex, ShadowFormat};
2121
use scene::{Color, Background, Group, Mesh, Sprite, Material,
@@ -49,6 +49,11 @@ const QUAD: [Vertex; 4] = [
4949
},
5050
];
5151

52+
const EMPTY_AABB3: Aabb3<f32> = Aabb3 {
53+
min: Point3 { x:0.0, y: 0.0, z: 0.0 },
54+
max: Point3 { x:0.0, y: 0.0, z: 0.0 },
55+
};
56+
5257

5358
impl From<SubNode> for Node {
5459
fn from(sub: SubNode) -> Self {
@@ -57,8 +62,8 @@ impl From<SubNode> for Node {
5762
world_visible: false,
5863
transform: Transform_::one(),
5964
world_transform: Transform_::one(),
60-
bounds: BoundingBox::empty(),
61-
world_bounds: BoundingBox::empty(),
65+
bounds: EMPTY_AABB3,
66+
world_bounds: EMPTY_AABB3,
6267
parent: None,
6368
scene_id: None,
6469
sub_node: sub,

src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub use glutin::VirtualKeyCode as Key;
4747
use std::sync::{mpsc, Arc, Mutex};
4848

4949
use cgmath::Transform as Transform_;
50-
use bound::BoundingBox;
50+
use collision::Aabb;
5151
use factory::SceneId;
5252
use render::GpuData;
5353

@@ -213,11 +213,12 @@ impl Hub {
213213
Some(ref parent_ptr) => {
214214
let parent = item.look_back(parent_ptr).unwrap();
215215
let transform = parent.world_transform.concat(&item.transform);
216-
let bounds = if parent_world_visible {
216+
let bounds = if parent.world_visible {
217217
let bounds = item.bounds.transform(&transform);
218218
parent.world_bounds = parent.world_bounds.union(&bounds);
219+
bounds
219220
} else {
220-
Aabb3::empty()
221+
item.bounds
221222
};
222223
(parent.world_visible, parent.scene_id, transform, bounds)
223224
},

0 commit comments

Comments
 (0)