phys_raycast/
lib.rs

1// Copyright (C) 2020-2025 phys-raycast authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! # Phys Raycast Library
16//!
17//! A lightweight ray casting library for 3D physics shapes built on top of the phys-geom library.
18//!
19//! This library provides ray casting functionality for basic geometric shapes commonly used in
20//! physics simulations. It's designed to be minimal and focused, depending only on the core
21//! geometry library without requiring the full collision detection system.
22//!
23//! ## Features
24//!
25//! - **Basic Shapes**: Ray casting support for sphere, cuboid, capsule, cylinder, triangle, and
26//!   infinite plane
27//! - **Minimal Dependencies**: Only depends on phys-geom for geometry types
28//! - **Simple API**: Clean and intuitive ray casting interface
29//! - **Type Safe**: Leverages Rust's type system for safe geometric operations
30//!
31//! ## Usage
32//!
33//! ```rust
34//! use phys_raycast::{Raycast, RaycastHitResult};
35//! use phys_geom::{Ray, shape::Sphere, math::{Point3, Vec3}};
36//!
37//! let sphere = Sphere::new(1.0);
38//! let ray = Ray::new(Point3::new(-2.0, 0.0, 0.0), Vec3::x_axis());
39//!
40//! if let Some(hit) = sphere.raycast(ray, 10.0, false) {
41//!     println!("Hit at distance: {}, normal: {:?}", hit.distance, hit.normal);
42//! }
43//! ```
44
45pub extern crate phys_geom as geom;
46mod shapes;
47mod traits;
48
49// Re-export commonly used types
50pub use geom::math::Real;
51pub use geom::Ray;
52pub use traits::{Raycast, RaycastHitResult};