From b34d771d653c768f82c9aac773ac9c5392b7bceb Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Sat, 26 Apr 2025 16:52:46 -0700 Subject: [PATCH] just create a raycaster --- src/bike.rs | 51 ++++++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/src/bike.rs b/src/bike.rs index 9def5f6..0a38311 100644 --- a/src/bike.rs +++ b/src/bike.rs @@ -146,16 +146,16 @@ fn spawn_children( let rear_rake = Vec3::new(0.0, -1.0, 0.9).normalize(); let rear_wheel_pos = REAR_ATTACH + (rear_rake * REST_DISTANCE); - children!( + children![ body, - wheel_caster( - parent, - FRONT_ATTACH, - Dir3::new_unchecked(front_rake), - REST_DISTANCE, - CyberWheel::Front, + ( + RayCaster::new(FRONT_ATTACH, Dir3::new_unchecked(front_rake)) + .with_max_hits(1) + .with_max_distance(REST_DISTANCE) + .with_query_filter(SpatialQueryFilter::from_excluded_entities([parent])), + CyberWheel::Front ), - wheel_mesh( + wheel_bundle( mesh.clone(), material.clone(), front_wheel_pos, @@ -169,14 +169,14 @@ fn spawn_children( ), CyberWheel::Front, ), - wheel_caster( - parent, - REAR_ATTACH, - Dir3::new_unchecked(rear_rake), - REST_DISTANCE, + ( + RayCaster::new(REAR_ATTACH, Dir3::new_unchecked(rear_rake)) + .with_max_hits(1) + .with_max_distance(REST_DISTANCE) + .with_query_filter(SpatialQueryFilter::from_excluded_entities([parent])), CyberWheel::Rear, ), - wheel_mesh( + wheel_bundle( mesh, material, rear_wheel_pos, @@ -190,29 +190,10 @@ fn spawn_children( ), CyberWheel::Rear, ), - ) + ] } -//-************************************************************************ -// helper fns for the wheels -//-************************************************************************ - -fn wheel_caster( - parent: Entity, - origin: Vec3, - direction: Dir3, - rest_dist: Scalar, - wheel: CyberWheel, -) -> impl Bundle { - let caster = RayCaster::new(origin, direction) - .with_max_distance(rest_dist) - .with_max_hits(1) - .with_query_filter(SpatialQueryFilter::from_excluded_entities([parent])); - - (caster, wheel) -} - -fn wheel_mesh( +fn wheel_bundle( mesh: Handle, material: Handle, position: Vec3,