use crate::core::{get_length_units_per_meter, SECRET_COOKIE};
use crate::debug_draw::{CreateDebugShapeCallback, DestroyDebugShapeCallback};
use crate::math_functions::Vec3;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Capacity {
pub static_shape_count: i32,
pub dynamic_shape_count: i32,
pub static_body_count: i32,
pub dynamic_body_count: i32,
pub contact_count: i32,
}
pub type FrictionCallback = fn(f32, u64, f32, u64) -> f32;
pub type RestitutionCallback = fn(f32, u64, f32, u64) -> f32;
#[derive(Debug, Clone)]
pub struct WorldDef {
pub gravity: Vec3,
pub restitution_threshold: f32,
pub hit_event_threshold: f32,
pub contact_hertz: f32,
pub contact_damping_ratio: f32,
pub contact_speed: f32,
pub maximum_linear_speed: f32,
pub friction_callback: Option<FrictionCallback>,
pub restitution_callback: Option<RestitutionCallback>,
pub enable_sleep: bool,
pub enable_continuous: bool,
pub user_data: u64,
pub capacity: Capacity,
pub create_debug_shape: Option<CreateDebugShapeCallback>,
pub destroy_debug_shape: Option<DestroyDebugShapeCallback>,
pub user_debug_shape_context: u64,
pub internal_value: i32,
}
pub fn default_world_def() -> WorldDef {
let length_units = get_length_units_per_meter();
WorldDef {
gravity: Vec3 {
x: 0.0,
y: -10.0,
z: 0.0,
},
restitution_threshold: 1.0 * length_units,
hit_event_threshold: 1.0 * length_units,
contact_hertz: 30.0,
contact_damping_ratio: 10.0,
contact_speed: 3.0 * length_units,
maximum_linear_speed: 400.0 * length_units,
friction_callback: None,
restitution_callback: None,
enable_sleep: true,
enable_continuous: true,
user_data: 0,
capacity: Capacity::default(),
create_debug_shape: None,
destroy_debug_shape: None,
user_debug_shape_context: 0,
internal_value: SECRET_COOKIE,
}
}
impl Default for WorldDef {
fn default() -> Self {
default_world_def()
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct WorldCastOutput {
pub normal: Vec3,
pub point: crate::math_functions::Pos,
pub fraction: f32,
pub iterations: i32,
pub triangle_index: i32,
pub child_index: i32,
pub material_index: i32,
pub hit: bool,
}
impl Default for WorldCastOutput {
fn default() -> Self {
WorldCastOutput {
normal: crate::math_functions::VEC3_ZERO,
point: crate::math_functions::POS_ZERO,
fraction: 0.0,
iterations: 0,
triangle_index: crate::core::NULL_INDEX,
child_index: 0,
material_index: 0,
hit: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RayResult {
pub shape_id: crate::id::ShapeId,
pub point: crate::math_functions::Pos,
pub normal: Vec3,
pub user_material_id: u64,
pub fraction: f32,
pub triangle_index: i32,
pub child_index: i32,
pub node_visits: i32,
pub leaf_visits: i32,
pub hit: bool,
}
impl Default for RayResult {
fn default() -> Self {
RayResult {
shape_id: crate::id::ShapeId::default(),
point: crate::math_functions::POS_ZERO,
normal: crate::math_functions::VEC3_ZERO,
user_material_id: 0,
fraction: 0.0,
triangle_index: 0,
child_index: 0,
node_visits: 0,
leaf_visits: 0,
hit: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Counters {
pub body_count: i32,
pub shape_count: i32,
pub contact_count: i32,
pub joint_count: i32,
pub island_count: i32,
pub stack_used: i32,
pub arena_capacity: i32,
pub static_tree_height: i32,
pub tree_height: i32,
pub sat_call_count: i32,
pub sat_cache_hit_count: i32,
pub byte_count: i32,
pub task_count: i32,
pub color_counts: [i32; crate::constants::GRAPH_COLOR_COUNT as usize],
pub manifold_counts: [i32; crate::constants::CONTACT_MANIFOLD_COUNT_BUCKETS],
pub awake_contact_count: i32,
pub recycled_contact_count: i32,
pub distance_iterations: i32,
pub push_back_iterations: i32,
pub root_iterations: i32,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ExplosionDef {
pub mask_bits: u64,
pub position: crate::math_functions::Pos,
pub radius: f32,
pub falloff: f32,
pub impulse_per_area: f32,
}
pub fn default_explosion_def() -> ExplosionDef {
ExplosionDef {
mask_bits: crate::dynamic_tree::DEFAULT_MASK_BITS,
position: crate::math_functions::POS_ZERO,
radius: 0.0,
falloff: 0.0,
impulse_per_area: 0.0,
}
}
impl Default for ExplosionDef {
fn default() -> Self {
default_explosion_def()
}
}