Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed rounding problem in SimplexProcessor2 #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 217 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'collision'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=collision"
],
"filter": {
"name": "collision",
"kind": "lib"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'serde'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=serde",
"--package=collision"
],
"filter": {
"name": "serde",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'point'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=point",
"--package=collision"
],
"filter": {
"name": "point",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'bound'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=bound",
"--package=collision"
],
"filter": {
"name": "bound",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'dbvt'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=dbvt",
"--package=collision"
],
"filter": {
"name": "dbvt",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'plane'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=plane",
"--package=collision"
],
"filter": {
"name": "plane",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'frustum'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=frustum",
"--package=collision"
],
"filter": {
"name": "frustum",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'sphere'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=sphere",
"--package=collision"
],
"filter": {
"name": "sphere",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug integration test 'aabb'",
"cargo": {
"args": [
"test",
"--no-run",
"--test=aabb",
"--package=collision"
],
"filter": {
"name": "aabb",
"kind": "test"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug benchmark 'dbvt'",
"cargo": {
"args": [
"test",
"--no-run",
"--bench=dbvt",
"--package=collision"
],
"filter": {
"name": "dbvt",
"kind": "bench"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug benchmark 'polyhedron'",
"cargo": {
"args": [
"test",
"--no-run",
"--bench=polyhedron",
"--package=collision"
],
"filter": {
"name": "polyhedron",
"kind": "bench"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "collision"
version = "0.20.1"
version = "0.20.2"
authors = ["Brendan Zabarauskas <[email protected]>",
"Brian Heylin",
"Colin Sherratt",
Expand Down
7 changes: 4 additions & 3 deletions benches/dbvt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ extern crate collision;
extern crate rand;
extern crate test;

use cgmath::{Point2, Vector2};
use cgmath::prelude::*;
use collision::{Aabb2, Ray2};
use cgmath::{Point2, Vector2};
use collision::dbvt::*;
use collision::prelude::*;
use collision::{Aabb2, Ray2};
use rand::Rng;
use test::Bencher;

Expand Down Expand Up @@ -100,7 +100,8 @@ fn benchmark_query(b: &mut Bencher) {
})
.collect();

let mut visitors: Vec<DiscreteVisitor<Ray2<f32>, Value>> = rays.iter()
let mut visitors: Vec<DiscreteVisitor<Ray2<f32>, Value>> = rays
.iter()
.map(|ray| DiscreteVisitor::<Ray2<f32>, Value>::new(ray))
.collect();

Expand Down
10 changes: 6 additions & 4 deletions benches/polyhedron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ extern crate genmesh;
extern crate rand;
extern crate test;

use cgmath::{Decomposed, Point3, Quaternion, Vector3};
use cgmath::prelude::*;
use cgmath::{Decomposed, Point3, Quaternion, Vector3};
use collision::prelude::*;
use collision::primitive::ConvexPolyhedron;
use genmesh::Triangulate;
use genmesh::generators::{IndexedPolygon, SharedVertex, SphereUV};
use genmesh::Triangulate;
use rand::Rng;
use test::{black_box, Bencher};

Expand Down Expand Up @@ -93,12 +93,14 @@ fn dirs(n: usize) -> Vec<Vector3<f32>> {
fn sphere(n: usize, with_faces: bool) -> ConvexPolyhedron<f32> {
let gen = SphereUV::new(n, n);

let vertices = gen.shared_vertex_iter()
let vertices = gen
.shared_vertex_iter()
.map(|v| Point3::from(v.pos))
.collect::<Vec<_>>();

if with_faces {
let faces = gen.indexed_polygon_iter()
let faces = gen
.indexed_polygon_iter()
.triangulate()
.map(|f| (f.x, f.y, f.z))
.collect::<Vec<_>>();
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/broad_phase/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pub use self::dbvt::DbvtBroadPhase;
pub use self::sweep_prune::{SweepAndPrune, SweepAndPrune2, SweepAndPrune3, Variance};

mod brute_force;
mod sweep_prune;
mod dbvt;
mod sweep_prune;
5 changes: 3 additions & 2 deletions src/algorithm/broad_phase/sweep_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ where
}

// compute sweep axis for the next iteration
let (axis, _) = self.variance
let (axis, _) = self
.variance
.compute_axis(NumCast::from(shapes.len()).unwrap());
self.sweep_axis = axis;

Expand All @@ -138,8 +139,8 @@ mod variance {
use std::marker;

use crate::Bound;
use cgmath::{BaseFloat, Point2, Point3, Vector2, Vector3};
use cgmath::prelude::*;
use cgmath::{BaseFloat, Point2, Point3, Vector2, Vector3};

/// Trait for variance calculation in sweep and prune algorithm
pub trait Variance {
Expand Down
Loading