Skip to content

Commit

Permalink
bump version to 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
flomonster committed Jan 29, 2023
1 parent 132b0a9 commit afdf656
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kdtree-ray"
version = "1.1.0"
version = "1.2.0"
authors = ["Florian Amsallem <[email protected]>"]
description = "Fast Kdtree implementation for raytracer"
documentation = "https://docs.rs/kdtree-ray"
Expand Down
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,45 @@ To install it, just add the dependency in your `Cargo.toml`.

```toml
[dependencies]
kdtree-ray="1.1.0"
kdtree-ray="1.2.0"
```

### Usage

Examples of use:
```rust
use cgmath::*;
use kdtree_ray::{AABB, Bounded, KDTree};

struct Triangle(Vector3<f32>, Vector3<f32>, Vector3<f32>);

// To use the KDTree on an object you need first to implement the BoundingBox trait.
impl Bounded for Triangle {
fn bound(&self) -> AABB {
let min = Vector3::new(
self.0.x.min(self.1.x).min(self.2.x),
self.0.y.min(self.1.y).min(self.2.y),
self.0.z.min(self.1.z).min(self.2.z),
);
let max = Vector3::new(
self.0.x.max(self.1.x).max(self.2.x),
self.0.y.max(self.1.y).max(self.2.y),
self.0.z.max(self.1.z).max(self.2.z),
);
AABB::new(min, max)
}
}

// Kdtree creation
let triangle = Triangle(Vector3::zero(), Vector3::zero(), Vector3::zero());
let triangles: Vec<Triangle> = vec![triangle, /* ... */];
let kdtree = KDTree::build(&triangles);

// Get a reduced list of triangles that a ray could intersect
let ray_origin = Vector3::zero();
let ray_direction = Vector3::new(1., 0., 0.);
let candidates_triangles = kdtree.intersect(&ray_origin, &ray_direction);
```

Examples of projects using this crate:

- [Path Tracer](https://github.com/flomonster/path-tracer)
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//!
//! ```toml
//! [dependencies]
//! kdtree-ray="1.1.0"
//! kdtree-ray="1.2.0"
//! ```
//!
//! # Usage & Tips
Expand Down

0 comments on commit afdf656

Please sign in to comment.