This commit is contained in:
Joe Ardent 2023-01-20 14:40:51 -08:00
parent bd96c52f3a
commit ca59748849
13 changed files with 588 additions and 628 deletions

1122
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,17 +5,17 @@ edition = "2021"
[dependencies]
rand = "0.8"
bevy_polyline = "0.3"
bevy_polyline = "0.4"
noise = { git = "https://github.com/Razaekel/noise-rs" }
hexasphere = "7"
wgpu = "0.13"
wgpu = "0.14"
# wgpu = "0.12"
[features]
debug_render = []
[dependencies.bevy]
version = "0.8"
version = "0.9"
default-features = false
features = [
"bevy_gilrs",
@ -28,7 +28,7 @@ features = [
[dependencies.bevy_rapier3d]
features = ["simd-nightly"]
version = "0.16"
version = "0.20"
# Maybe also enable only a small amount of optimization for our code:
[profile.dev]

BIN
assets/cb-no-y_up.glb Normal file

Binary file not shown.

View file

@ -1,6 +1,4 @@
use bevy::prelude::{
App, ParallelSystemDescriptorCoercion, Plugin, Query, Res, ResMut, Transform, Vec3, With,
};
use bevy::prelude::*;
use bevy_rapier3d::prelude::{
ExternalForce, Friction, NoUserData, RapierConfiguration, RapierPhysicsPlugin, Velocity,
};
@ -10,6 +8,7 @@ use crate::{
input::InputState,
};
#[derive(Resource)]
pub struct MovementSettings {
pub accel: f32,
pub gravity: f32,

View file

@ -1,5 +1,5 @@
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
use bevy_rapier3d::{geometry::Group, prelude::*};
use crate::planet::PLANET_RADIUS;
@ -22,8 +22,8 @@ pub struct CyberBikeControl {
pub prev_pitch_error: f32,
}
const BIKE_BODY_COLLISION_GROUP: (u32, u32) = (0b01, 0b01);
const BIKE_WHEEL_COLLISION_GROUP: (u32, u32) = (0b10, 0b10);
const BIKE_BODY_COLLISION_GROUP: (Group, Group) = (Group::GROUP_1, Group::GROUP_1);
const BIKE_WHEEL_COLLISION_GROUP: (Group, Group) = (Group::GROUP_10, Group::GROUP_10);
fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
let xform = Transform::from_translation(Vec3::X * SPAWN_ALTITUDE)
@ -53,13 +53,13 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
let mass_properties = ColliderMassProperties::Density(0.2);
let (membership, filter) = BIKE_BODY_COLLISION_GROUP;
let bike_collision_group = CollisionGroups::new(membership, filter);
let bike_collision_group = CollisionGroups::new(membership.into(), filter.into());
let bike = commands
.spawn()
.spawn_empty()
.insert(RigidBody::Dynamic)
.insert_bundle((xform, GlobalTransform::default()))
.insert_bundle((
.insert((xform, GlobalTransform::default()))
.insert((
bcollider_shape,
bike_collision_group,
mass_properties,
@ -77,8 +77,8 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
.insert(ExternalForce::default())
.insert(CyberBikeCollider)
.with_children(|rider| {
rider.spawn_bundle(SceneBundle {
scene: asset_server.load("cyber-bike_no_y_up.glb#Scene0"),
rider.spawn(SceneBundle {
scene: asset_server.load("cb-no-y_up.glb#Scene0"),
..Default::default()
});
})
@ -119,10 +119,10 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
let joint = ImpulseJoint::new(bike, prismatic);
let _wheel_rb = commands
.spawn()
.spawn_empty()
.insert(RigidBody::Dynamic)
.insert_bundle((wheel_pos_in_world, GlobalTransform::default()))
.insert_bundle((
.insert((wheel_pos_in_world, GlobalTransform::default()))
.insert((
wheel_collider,
mass_props,
wheel_damping,

View file

@ -1,7 +1,4 @@
use bevy::prelude::{
info, Camera, Camera3dBundle, Commands, Component, Input, KeyCode, ParamSet,
PerspectiveProjection, Plugin, Quat, Query, Res, ResMut, State, Transform, With,
};
use bevy::prelude::*;
use crate::{bike::CyberBikeModel, input::InputState};
@ -29,14 +26,14 @@ fn setup_cybercams(mut commands: Commands) {
..Default::default()
};
commands
.spawn_bundle(Camera3dBundle {
.spawn(Camera3dBundle {
projection: bevy::render::camera::Projection::Perspective(hero_projection),
..Default::default()
})
.insert(CyberCameras::Hero);
commands
.spawn_bundle(Camera3dBundle::default())
.spawn(Camera3dBundle::default())
.insert(CyberCameras::Debug);
}

View file

@ -45,7 +45,7 @@ fn wireframe_planet(
mesh.duplicate_vertices();
mesh.compute_flat_normals();
commands.spawn_bundle(PolylineBundle {
commands.spawn(PolylineBundle {
polyline: polylines.add(Polyline { vertices: verts }),
material: polymats.add(PolylineMaterial {
width: 101.0,

View file

@ -1,9 +1,5 @@
use bevy::prelude::{
info, App, EventReader, GamepadAxisType, GamepadButtonType, GamepadEvent, GamepadEventType,
Plugin, ResMut,
};
#[derive(Default, Debug)]
use bevy::prelude::*;
#[derive(Default, Debug, Resource)]
pub(crate) struct InputState {
pub yaw: f32,
pub throttle: f32,

View file

@ -22,7 +22,7 @@ pub enum Label {
pub fn disable_mouse_trap(mut windows: ResMut<Windows>) {
let window = windows.get_primary_mut().unwrap();
window.set_cursor_lock_mode(false);
window.set_cursor_grab_mode(bevy::window::CursorGrabMode::None);
window.set_cursor_visibility(true);
}

View file

@ -55,7 +55,7 @@ fn spawn_moving_lights(
commands
// first, spawn an entity with a transform we can rotate
.spawn_bundle((
.spawn((
AnimatedCyberLight { axis, rate },
Transform::from_rotation(rotation),
GlobalTransform::default(),
@ -64,7 +64,7 @@ fn spawn_moving_lights(
parent
// now spawn a child entity with a pointlight, and a relative transform that's
// just translation from the parent
.spawn_bundle(PointLightBundle {
.spawn(PointLightBundle {
transform,
point_light,
..Default::default()
@ -72,7 +72,7 @@ fn spawn_moving_lights(
.with_children(|builder| {
builder
// now a simple mesh to show a wireframe.
.spawn_bundle(PbrBundle {
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Icosphere {
radius,
subdivisions: 1,
@ -120,13 +120,13 @@ fn spawn_static_lights(
// up light
commands
.spawn_bundle(PointLightBundle {
.spawn(PointLightBundle {
transform: Transform::from_xyz(0.0, PLANET_RADIUS + 30.0, 0.0),
point_light: pink_light,
..Default::default()
})
.with_children(|builder| {
builder.spawn_bundle(PbrBundle {
builder.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Icosphere {
radius: 10.0,
subdivisions: 2,
@ -141,13 +141,13 @@ fn spawn_static_lights(
});
// down light
commands
.spawn_bundle(PointLightBundle {
.spawn(PointLightBundle {
transform: Transform::from_xyz(0.0, -PLANET_RADIUS - 30.0, 0.0),
point_light: blue_light,
..Default::default()
})
.with_children(|builder| {
builder.spawn_bundle(PbrBundle {
builder.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Icosphere {
radius: 10.0,
subdivisions: 2,

View file

@ -21,13 +21,15 @@ fn main() {
let mut app = App::new();
app.insert_resource(Msaa { samples: 4 })
.insert_resource(ClearColor(Color::rgb(0.07, 0.001, 0.02)))
.insert_resource(WindowDescriptor {
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
width: 2560.0,
height: 1440.0,
..Default::default()
})
},
..Default::default()
}))
.insert_resource(MOVEMENT_SETTINGS)
.add_plugins(DefaultPlugins)
.add_plugin(CyberPlanetPlugin)
.add_plugin(CyberGlamorPlugin)
.add_plugin(CyberInputPlugin)

View file

@ -39,7 +39,7 @@ fn spawn_planet(
);
commands
.spawn_bundle(PbrBundle {
.spawn(PbrBundle {
mesh: meshes.add(mesh),
material: materials.add(StandardMaterial {
base_color: color,
@ -51,8 +51,8 @@ fn spawn_planet(
..Default::default()
})
.insert_bundle(pbody)
.insert_bundle(pcollide)
.insert(pbody)
.insert(pcollide)
.insert(CyberPlanet);
}

View file

@ -7,10 +7,10 @@ use crate::bike::CyberBikeBody;
struct UpText;
fn setup_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
//commands.spawn_bundle(UiCameraBundle::default());
//commands.spawn(UiCameraBundle::default());
commands
.spawn_bundle(TextBundle {
.spawn(TextBundle {
style: Style {
align_self: AlignSelf::FlexEnd,
..Default::default()