just create a raycaster
This commit is contained in:
parent
b54e0a637f
commit
b34d771d65
1 changed files with 16 additions and 35 deletions
51
src/bike.rs
51
src/bike.rs
|
@ -146,16 +146,16 @@ fn spawn_children(
|
||||||
let rear_rake = Vec3::new(0.0, -1.0, 0.9).normalize();
|
let rear_rake = Vec3::new(0.0, -1.0, 0.9).normalize();
|
||||||
let rear_wheel_pos = REAR_ATTACH + (rear_rake * REST_DISTANCE);
|
let rear_wheel_pos = REAR_ATTACH + (rear_rake * REST_DISTANCE);
|
||||||
|
|
||||||
children!(
|
children![
|
||||||
body,
|
body,
|
||||||
wheel_caster(
|
(
|
||||||
parent,
|
RayCaster::new(FRONT_ATTACH, Dir3::new_unchecked(front_rake))
|
||||||
FRONT_ATTACH,
|
.with_max_hits(1)
|
||||||
Dir3::new_unchecked(front_rake),
|
.with_max_distance(REST_DISTANCE)
|
||||||
REST_DISTANCE,
|
.with_query_filter(SpatialQueryFilter::from_excluded_entities([parent])),
|
||||||
CyberWheel::Front,
|
CyberWheel::Front
|
||||||
),
|
),
|
||||||
wheel_mesh(
|
wheel_bundle(
|
||||||
mesh.clone(),
|
mesh.clone(),
|
||||||
material.clone(),
|
material.clone(),
|
||||||
front_wheel_pos,
|
front_wheel_pos,
|
||||||
|
@ -169,14 +169,14 @@ fn spawn_children(
|
||||||
),
|
),
|
||||||
CyberWheel::Front,
|
CyberWheel::Front,
|
||||||
),
|
),
|
||||||
wheel_caster(
|
(
|
||||||
parent,
|
RayCaster::new(REAR_ATTACH, Dir3::new_unchecked(rear_rake))
|
||||||
REAR_ATTACH,
|
.with_max_hits(1)
|
||||||
Dir3::new_unchecked(rear_rake),
|
.with_max_distance(REST_DISTANCE)
|
||||||
REST_DISTANCE,
|
.with_query_filter(SpatialQueryFilter::from_excluded_entities([parent])),
|
||||||
CyberWheel::Rear,
|
CyberWheel::Rear,
|
||||||
),
|
),
|
||||||
wheel_mesh(
|
wheel_bundle(
|
||||||
mesh,
|
mesh,
|
||||||
material,
|
material,
|
||||||
rear_wheel_pos,
|
rear_wheel_pos,
|
||||||
|
@ -190,29 +190,10 @@ fn spawn_children(
|
||||||
),
|
),
|
||||||
CyberWheel::Rear,
|
CyberWheel::Rear,
|
||||||
),
|
),
|
||||||
)
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
//-************************************************************************
|
fn wheel_bundle(
|
||||||
// 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(
|
|
||||||
mesh: Handle<Mesh>,
|
mesh: Handle<Mesh>,
|
||||||
material: Handle<StandardMaterial>,
|
material: Handle<StandardMaterial>,
|
||||||
position: Vec3,
|
position: Vec3,
|
||||||
|
|
Loading…
Reference in a new issue