Compare commits
No commits in common. "e358830c5f66db66a3fa129a825a529d75ff1910" and "ff9b1671b15ef0a94fff057d9841864891f41129" have entirely different histories.
e358830c5f
...
ff9b1671b1
5 changed files with 34 additions and 16 deletions
|
@ -38,7 +38,7 @@ impl Plugin for CyberActionPlugin {
|
||||||
reset_wheel_forces,
|
reset_wheel_forces,
|
||||||
cyber_lean,
|
cyber_lean,
|
||||||
falling_cat,
|
falling_cat,
|
||||||
wheel_forces,
|
input_forces,
|
||||||
drag,
|
drag,
|
||||||
)
|
)
|
||||||
.chain(),
|
.chain(),
|
||||||
|
|
|
@ -137,7 +137,7 @@ pub(super) fn wheel_forces(
|
||||||
&mut PreviousVelocity,
|
&mut PreviousVelocity,
|
||||||
Option<&CyberSteering>,
|
Option<&CyberSteering>,
|
||||||
),
|
),
|
||||||
(With<CyberWheel>, Without<CyberBikeBody>),
|
With<CyberWheel>,
|
||||||
>,
|
>,
|
||||||
mut body_query: Query<
|
mut body_query: Query<
|
||||||
(
|
(
|
||||||
|
@ -146,7 +146,7 @@ pub(super) fn wheel_forces(
|
||||||
&mut PreviousVelocity,
|
&mut PreviousVelocity,
|
||||||
&ReadMassProperties,
|
&ReadMassProperties,
|
||||||
),
|
),
|
||||||
(With<CyberBikeBody>, Without<CyberWheel>),
|
With<CyberBikeBody>,
|
||||||
>,
|
>,
|
||||||
wheel_config: Res<WheelConfig>,
|
wheel_config: Res<WheelConfig>,
|
||||||
rapier_config: Res<RapierConfiguration>,
|
rapier_config: Res<RapierConfiguration>,
|
||||||
|
|
|
@ -8,10 +8,7 @@ use bevy_rapier3d::prelude::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{spawn_wheels, CyberBikeBody, Meshterial, WheelConfig, BIKE_BODY_COLLISION_GROUP};
|
use super::{spawn_wheels, CyberBikeBody, Meshterial, WheelConfig, BIKE_BODY_COLLISION_GROUP};
|
||||||
use crate::{
|
use crate::{action::CatControllerState, planet::PLANET_RADIUS};
|
||||||
action::{CatControllerState, PreviousVelocity},
|
|
||||||
planet::PLANET_RADIUS,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(super) fn spawn_cyberbike(
|
pub(super) fn spawn_cyberbike(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
@ -66,7 +63,6 @@ pub(super) fn spawn_cyberbike(
|
||||||
Sleeping::disabled(),
|
Sleeping::disabled(),
|
||||||
Ccd { enabled: true },
|
Ccd { enabled: true },
|
||||||
ReadMassProperties::default(),
|
ReadMassProperties::default(),
|
||||||
PreviousVelocity::default(),
|
|
||||||
))
|
))
|
||||||
.insert(TransformInterpolation {
|
.insert(TransformInterpolation {
|
||||||
start: None,
|
start: None,
|
||||||
|
|
|
@ -2,12 +2,13 @@ use bevy::prelude::*;
|
||||||
use bevy_rapier3d::{
|
use bevy_rapier3d::{
|
||||||
dynamics::{FixedJointBuilder, Velocity},
|
dynamics::{FixedJointBuilder, Velocity},
|
||||||
prelude::{
|
prelude::{
|
||||||
ColliderMassProperties, ExternalForce, MultibodyJoint, PrismaticJointBuilder, RigidBody,
|
Ccd, CoefficientCombineRule, Collider, ColliderMassProperties, CollisionGroups, Damping,
|
||||||
Sleeping, TransformInterpolation,
|
ExternalForce, Friction, MultibodyJoint, PrismaticJointBuilder, Restitution,
|
||||||
|
RevoluteJointBuilder, RigidBody, Sleeping, TransformInterpolation,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{CyberSteering, CyberWheel, Meshterial, WheelConfig};
|
use super::{CyberSteering, CyberWheel, Meshterial, WheelConfig, BIKE_WHEEL_COLLISION_GROUP};
|
||||||
use crate::action::PreviousVelocity;
|
use crate::action::PreviousVelocity;
|
||||||
|
|
||||||
pub(crate) fn spawn_wheels(
|
pub(crate) fn spawn_wheels(
|
||||||
|
@ -16,13 +17,21 @@ pub(crate) fn spawn_wheels(
|
||||||
conf: &WheelConfig,
|
conf: &WheelConfig,
|
||||||
meshterials: &mut Meshterial,
|
meshterials: &mut Meshterial,
|
||||||
) {
|
) {
|
||||||
|
let (membership, filter) = BIKE_WHEEL_COLLISION_GROUP;
|
||||||
|
let wheels_collision_group = CollisionGroups::new(membership, filter);
|
||||||
let wheel_y = conf.y;
|
let wheel_y = conf.y;
|
||||||
let stiffness = conf.stiffness;
|
let stiffness = conf.stiffness;
|
||||||
let not_sleeping = Sleeping::disabled();
|
let not_sleeping = Sleeping::disabled();
|
||||||
|
let ccd = Ccd { enabled: true };
|
||||||
let limits = conf.limits;
|
let limits = conf.limits;
|
||||||
let (meshes, materials) = meshterials;
|
let (meshes, materials) = meshterials;
|
||||||
let rake_vec: Vec3 = Vec3::new(0.0, 1.0, 0.57).normalize(); // about 30 degrees of rake
|
let rake_vec: Vec3 = Vec3::new(0.0, 1.0, 0.57).normalize(); // about 30 degrees of rake
|
||||||
|
|
||||||
|
let friction = Friction {
|
||||||
|
coefficient: conf.friction,
|
||||||
|
combine_rule: CoefficientCombineRule::Min,
|
||||||
|
};
|
||||||
|
|
||||||
let mut wheel_poses = Vec::with_capacity(2);
|
let mut wheel_poses = Vec::with_capacity(2);
|
||||||
|
|
||||||
// front
|
// front
|
||||||
|
@ -42,7 +51,7 @@ pub(crate) fn spawn_wheels(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (offset, steering) in wheel_poses {
|
for (offset, steering) in wheel_poses {
|
||||||
let mesh = gen_tires(conf);
|
let (mesh, collider) = gen_tires(conf);
|
||||||
|
|
||||||
let material = StandardMaterial {
|
let material = StandardMaterial {
|
||||||
base_color: Color::YELLOW,
|
base_color: Color::YELLOW,
|
||||||
|
@ -84,6 +93,7 @@ pub(crate) fn spawn_wheels(
|
||||||
.spawn(RigidBody::Dynamic)
|
.spawn(RigidBody::Dynamic)
|
||||||
.insert(neck_joint)
|
.insert(neck_joint)
|
||||||
.insert(steering)
|
.insert(steering)
|
||||||
|
.insert(not_sleeping)
|
||||||
.id();
|
.id();
|
||||||
neck
|
neck
|
||||||
} else {
|
} else {
|
||||||
|
@ -94,11 +104,15 @@ pub(crate) fn spawn_wheels(
|
||||||
let axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
|
let axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
|
||||||
|
|
||||||
commands.spawn(pbr_bundle).insert((
|
commands.spawn(pbr_bundle).insert((
|
||||||
|
collider,
|
||||||
mass_props,
|
mass_props,
|
||||||
//wheel_damping,
|
//wheel_damping,
|
||||||
axel_joint,
|
ccd,
|
||||||
CyberWheel,
|
|
||||||
not_sleeping,
|
not_sleeping,
|
||||||
|
axel_joint,
|
||||||
|
wheels_collision_group,
|
||||||
|
friction,
|
||||||
|
CyberWheel,
|
||||||
Velocity::default(),
|
Velocity::default(),
|
||||||
PreviousVelocity::default(),
|
PreviousVelocity::default(),
|
||||||
ExternalForce::default(),
|
ExternalForce::default(),
|
||||||
|
@ -110,8 +124,11 @@ pub(crate) fn spawn_wheels(
|
||||||
}
|
}
|
||||||
|
|
||||||
// do mesh shit
|
// do mesh shit
|
||||||
fn gen_tires(conf: &WheelConfig) -> Mesh {
|
fn gen_tires(conf: &WheelConfig) -> (Mesh, Collider) {
|
||||||
let wheel_rad = conf.radius;
|
let wheel_rad = conf.radius;
|
||||||
let tire = Sphere::new(wheel_rad);
|
let tire = Sphere::new(wheel_rad);
|
||||||
Mesh::from(tire)
|
let mesh = Mesh::from(tire);
|
||||||
|
let wheel_collider = Collider::ball(wheel_rad);
|
||||||
|
|
||||||
|
(mesh, wheel_collider)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ use bevy::{
|
||||||
TextBundle, TextSection, TextStyle, Transform, With,
|
TextBundle, TextSection, TextStyle, Transform, With,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
//#[cfg(feature = "inspector")]
|
||||||
|
//use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||||
use bevy_rapier3d::prelude::Velocity;
|
use bevy_rapier3d::prelude::Velocity;
|
||||||
|
|
||||||
use crate::bike::CyberBikeBody;
|
use crate::bike::CyberBikeBody;
|
||||||
|
@ -51,6 +53,9 @@ pub struct CyberUIPlugin;
|
||||||
|
|
||||||
impl Plugin for CyberUIPlugin {
|
impl Plugin for CyberUIPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
|
#[cfg(feature = "inspector")]
|
||||||
|
//app.add_plugins(WorldInspectorPlugin::new());
|
||||||
|
|
||||||
//
|
//
|
||||||
app.add_systems(Startup, setup_ui)
|
app.add_systems(Startup, setup_ui)
|
||||||
.add_systems(Update, update_ui);
|
.add_systems(Update, update_ui);
|
||||||
|
|
Loading…
Reference in a new issue