use nightshade::ecs::physics::joints::{
FixedJoint, JointAxisDirection, JointHandle, RevoluteJoint, RopeJoint, SpringJoint,
create_fixed_joint, create_revolute_joint, create_rope_joint, create_spring_joint,
};
use nightshade::prelude::*;
#[inline]
pub fn push(world: &mut World, entity: Entity, impulse: Vec3) {
physics_world_apply_impulse(&mut world.resources.physics, entity, impulse);
}
#[inline]
pub fn set_velocity(world: &mut World, entity: Entity, velocity: Vec3) {
physics_world_set_linear_velocity(&mut world.resources.physics, entity, velocity);
}
#[inline]
pub fn raycast(
world: &World,
origin: Vec3,
direction: Vec3,
max_distance: f32,
) -> Option<RaycastHit> {
physics_world_cast_ray(
&world.resources.physics,
origin,
direction,
max_distance,
None,
)
}
#[inline]
pub fn collisions(world: &World) -> &[CollisionEvent] {
physics_world_collision_events(&world.resources.physics)
}
#[inline]
pub fn attach_fixed(world: &mut World, parent: Entity, child: Entity) -> Option<JointHandle> {
create_fixed_joint(world, parent, child, FixedJoint::new())
}
#[inline]
pub fn attach_hinge(
world: &mut World,
parent: Entity,
child: Entity,
axis: JointAxisDirection,
) -> Option<JointHandle> {
create_revolute_joint(world, parent, child, RevoluteJoint::new(axis))
}
#[inline]
pub fn attach_spring(
world: &mut World,
parent: Entity,
child: Entity,
rest_length: f32,
stiffness: f32,
damping: f32,
) -> Option<JointHandle> {
create_spring_joint(
world,
parent,
child,
SpringJoint::new(rest_length, stiffness, damping),
)
}
#[inline]
pub fn attach_rope(
world: &mut World,
parent: Entity,
child: Entity,
max_distance: f32,
) -> Option<JointHandle> {
create_rope_joint(world, parent, child, RopeJoint::new(max_distance))
}