Disable CCD, embiggen world, increase FoV.
This commit is contained in:
parent
d36452569b
commit
83af546e63
4 changed files with 37 additions and 27 deletions
|
@ -2,7 +2,8 @@ use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::mesh::{Indices, VertexAttributeValues},
|
render::mesh::{Indices, VertexAttributeValues},
|
||||||
};
|
};
|
||||||
use bevy_rapier3d::{na::Vector3, prelude::*};
|
#[allow(unused_imports)]
|
||||||
|
use bevy_rapier3d::{na::Vector3, physics::PhysicsSystems::StepWorld, prelude::*};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{CyberBike, CyberSphere, PLANET_RADIUS},
|
geometry::{CyberBike, CyberSphere, PLANET_RADIUS},
|
||||||
|
@ -39,8 +40,6 @@ fn setup_colliders(
|
||||||
let vertices = mesh.attribute(Mesh::ATTRIBUTE_POSITION).unwrap();
|
let vertices = mesh.attribute(Mesh::ATTRIBUTE_POSITION).unwrap();
|
||||||
if let VertexAttributeValues::Float32x3(verts) = vertices {
|
if let VertexAttributeValues::Float32x3(verts) = vertices {
|
||||||
if let Some(Indices::U32(indices)) = mesh.indices() {
|
if let Some(Indices::U32(indices)) = mesh.indices() {
|
||||||
//let vertices: Vec<Vec3> = verts.iter().map(|v|
|
|
||||||
// Vec3::from_slice(v)).collect();
|
|
||||||
let mut idxs = Vec::new();
|
let mut idxs = Vec::new();
|
||||||
for idx in indices.chunks_exact(3) {
|
for idx in indices.chunks_exact(3) {
|
||||||
idxs.push([idx[0], idx[1], idx[2]]);
|
idxs.push([idx[0], idx[1], idx[2]]);
|
||||||
|
@ -50,20 +49,19 @@ fn setup_colliders(
|
||||||
.map(|p| Point::from_slice(p))
|
.map(|p| Point::from_slice(p))
|
||||||
.collect::<Vec<Point<_>>>();
|
.collect::<Vec<Point<_>>>();
|
||||||
|
|
||||||
shape = ColliderShape::convex_decomposition(&vertices, &idxs);
|
shape = ColliderShape::trimesh(vertices, idxs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, now attach shit
|
|
||||||
let pbody = RigidBodyBundle {
|
let pbody = RigidBodyBundle {
|
||||||
body_type: RigidBodyType::Static.into(),
|
body_type: RigidBodyType::Static.into(),
|
||||||
ccd: RigidBodyCcd {
|
// ccd: RigidBodyCcd {
|
||||||
ccd_enabled: true,
|
// ccd_enabled: true,
|
||||||
ccd_max_dist: PLANET_RADIUS * 1.1,
|
// ccd_max_dist: PLANET_RADIUS * 1.1,
|
||||||
ccd_thickness: 0.4,
|
// ccd_thickness: 0.1,
|
||||||
..Default::default()
|
// ..Default::default()
|
||||||
}
|
// }
|
||||||
.into(),
|
// .into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let pcollide = ColliderBundle {
|
let pcollide = ColliderBundle {
|
||||||
|
@ -90,18 +88,20 @@ fn setup_colliders(
|
||||||
fn setup_bike_collider(bike: Entity, xform: &Transform, commands: &mut Commands) {
|
fn setup_bike_collider(bike: Entity, xform: &Transform, commands: &mut Commands) {
|
||||||
let mut bbody = RigidBodyBundle::default();
|
let mut bbody = RigidBodyBundle::default();
|
||||||
bbody.damping.angular_damping = 0.8;
|
bbody.damping.angular_damping = 0.8;
|
||||||
bbody.damping.linear_damping = 0.5;
|
bbody.damping.linear_damping = 0.4;
|
||||||
bbody.forces = RigidBodyForces {
|
bbody.forces = RigidBodyForces {
|
||||||
torque: Vec3::ZERO.into(),
|
torque: Vec3::ZERO.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.into();
|
.into();
|
||||||
bbody.ccd = RigidBodyCcd {
|
|
||||||
ccd_enabled: true,
|
// bbody.ccd = RigidBodyCcd {
|
||||||
ccd_max_dist: 2.4,
|
// ccd_enabled: false,
|
||||||
..Default::default()
|
// ccd_max_dist: 2.4,
|
||||||
}
|
// ..Default::default()
|
||||||
.into();
|
// }
|
||||||
|
// .into();
|
||||||
|
|
||||||
let isometry = Isometry::from_parts(xform.translation.into(), xform.rotation.into());
|
let isometry = Isometry::from_parts(xform.translation.into(), xform.rotation.into());
|
||||||
bbody.position = isometry.into();
|
bbody.position = isometry.into();
|
||||||
// collider
|
// collider
|
||||||
|
@ -112,10 +112,10 @@ fn setup_bike_collider(bike: Entity, xform: &Transform, commands: &mut Commands)
|
||||||
);
|
);
|
||||||
let bcollide = ColliderBundle {
|
let bcollide = ColliderBundle {
|
||||||
shape: shape.into(),
|
shape: shape.into(),
|
||||||
mass_properties: ColliderMassProps::Density(0.4).into(),
|
mass_properties: ColliderMassProps::Density(0.6).into(),
|
||||||
material: ColliderMaterial {
|
material: ColliderMaterial {
|
||||||
friction: 0.0,
|
friction: 0.0,
|
||||||
restitution: 0.01,
|
restitution: 0.0,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -129,7 +129,7 @@ fn setup_bike_collider(bike: Entity, xform: &Transform, commands: &mut Commands)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gravity(xform: Query<&Transform, With<CyberBike>>, mut config: ResMut<RapierConfiguration>) {
|
fn gravity(xform: Query<&Transform, With<CyberBike>>, mut config: ResMut<RapierConfiguration>) {
|
||||||
let gravity = xform.single().translation.normalize() * -6.0;
|
let gravity = xform.single().translation.normalize() * -7.80;
|
||||||
config.gravity = gravity.into();
|
config.gravity = gravity.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,15 @@ const MAX_PITCH: f32 = 1.48353;
|
||||||
pub struct CyberCam;
|
pub struct CyberCam;
|
||||||
|
|
||||||
fn setup_cybercam(mut commands: Commands) {
|
fn setup_cybercam(mut commands: Commands) {
|
||||||
|
let projection = PerspectiveProjection {
|
||||||
|
fov: std::f32::consts::FRAC_PI_3,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(PerspectiveCameraBundle {
|
.spawn_bundle(PerspectiveCameraBundle {
|
||||||
transform: Transform::from_xyz(SPAWN_ALTITUDE + CAM_DIST, 0.0, 0.0)
|
transform: Transform::from_xyz(SPAWN_ALTITUDE + CAM_DIST, 0.0, 0.0)
|
||||||
.looking_at(Vec3::ZERO, Vec3::Y),
|
.looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
|
perspective_projection: projection,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(CyberCam);
|
.insert(CyberCam);
|
||||||
|
|
|
@ -8,7 +8,7 @@ use wgpu::PrimitiveTopology;
|
||||||
|
|
||||||
use crate::Label;
|
use crate::Label;
|
||||||
|
|
||||||
pub const PLANET_RADIUS: f32 = 1200.0;
|
pub const PLANET_RADIUS: f32 = 5000.0;
|
||||||
pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS * 1.095;
|
pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS * 1.095;
|
||||||
|
|
||||||
#[derive(Component, Debug)]
|
#[derive(Component, Debug)]
|
||||||
|
@ -25,7 +25,7 @@ fn spawn_giant_sphere(
|
||||||
let color = Color::DARK_GRAY;
|
let color = Color::DARK_GRAY;
|
||||||
let isphere = shape::Icosphere {
|
let isphere = shape::Icosphere {
|
||||||
radius: PLANET_RADIUS,
|
radius: PLANET_RADIUS,
|
||||||
subdivisions: 26,
|
subdivisions: 40,
|
||||||
};
|
};
|
||||||
|
|
||||||
let pmesh = gen_planet(isphere);
|
let pmesh = gen_planet(isphere);
|
||||||
|
@ -37,7 +37,7 @@ fn spawn_giant_sphere(
|
||||||
base_color: color,
|
base_color: color,
|
||||||
metallic: 0.1,
|
metallic: 0.1,
|
||||||
perceptual_roughness: 0.3,
|
perceptual_roughness: 0.3,
|
||||||
alpha_mode: AlphaMode::Blend,
|
alpha_mode: AlphaMode::Opaque,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ fn gen_planet(sphere: Icosphere) -> Mesh {
|
||||||
.raw_points()
|
.raw_points()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&p| {
|
.map(|&p| {
|
||||||
let disp = noise.get(p.as_dvec3().into()) as f32 * 0.09;
|
let disp = noise.get(p.as_dvec3().into()) as f32 * 0.05;
|
||||||
let pt = p + disp;
|
let pt = p + disp;
|
||||||
pt.into()
|
pt.into()
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,13 +12,18 @@ use cyber_rider::{
|
||||||
|
|
||||||
const MOVEMENT_SETTINGS: MovementSettings = MovementSettings {
|
const MOVEMENT_SETTINGS: MovementSettings = MovementSettings {
|
||||||
sensitivity: 10.0, // default: 1.0
|
sensitivity: 10.0, // default: 1.0
|
||||||
accel: 10.0, // default: 40.0
|
accel: 30.0, // default: 40.0
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.insert_resource(Msaa { samples: 4 })
|
app.insert_resource(Msaa { samples: 4 })
|
||||||
.insert_resource(ClearColor(Color::rgb(0.07, 0.001, 0.02)))
|
.insert_resource(ClearColor(Color::rgb(0.07, 0.001, 0.02)))
|
||||||
|
.insert_resource(WindowDescriptor {
|
||||||
|
width: 2560.0,
|
||||||
|
height: 1440.0,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
.insert_resource(MOVEMENT_SETTINGS)
|
.insert_resource(MOVEMENT_SETTINGS)
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_plugin(CyberGeomPlugin)
|
.add_plugin(CyberGeomPlugin)
|
||||||
|
|
Loading…
Reference in a new issue