High-perf wireframe for planet.
This commit is contained in:
parent
212d9daac9
commit
373fc30d56
7 changed files with 70 additions and 52 deletions
46
Cargo.lock
generated
46
Cargo.lock
generated
|
@ -73,9 +73,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.53"
|
||||
version = "1.0.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
|
||||
checksum = "7a99269dff3bc004caa411f38845c20303f1e393ca2bd6581576fa3a7f59577d"
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
|
@ -152,9 +152,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
|||
|
||||
[[package]]
|
||||
name = "bevy"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b77ad2987710ed960746c43813ad8c103db5c4c090f5cbc9c32c0a90a91bc599"
|
||||
checksum = "97342ea2f3bad36be2ded1d1fbd569ff83147b70697f12f1579e87a7480afa36"
|
||||
dependencies = [
|
||||
"bevy_internal",
|
||||
]
|
||||
|
@ -523,7 +523,7 @@ dependencies = [
|
|||
"downcast-rs",
|
||||
"futures-lite",
|
||||
"hex",
|
||||
"hexasphere",
|
||||
"hexasphere 6.1.0",
|
||||
"image",
|
||||
"naga",
|
||||
"once_cell",
|
||||
|
@ -784,9 +784,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.72"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
|
@ -1066,7 +1066,7 @@ dependencies = [
|
|||
"bevy",
|
||||
"bevy_polyline",
|
||||
"bevy_rapier3d",
|
||||
"hexasphere",
|
||||
"hexasphere 7.0.0",
|
||||
"noise",
|
||||
"rand 0.8.5",
|
||||
"wgpu",
|
||||
|
@ -1460,9 +1460,19 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
|||
|
||||
[[package]]
|
||||
name = "hexasphere"
|
||||
version = "6.0.0"
|
||||
version = "6.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9dc62dcfd68ec810c4707804556f2e88655012b1a373b0e0bbbe88a9db366627"
|
||||
checksum = "2b219bdb56b14905fa5429636bfc4df0043626642d4586d069a82019130846f5"
|
||||
dependencies = [
|
||||
"glam",
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hexasphere"
|
||||
version = "7.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04ab9d20ba513ff1582a7d885e91839f62cf28bef7c56b1b0428ca787315979b"
|
||||
dependencies = [
|
||||
"glam",
|
||||
"lazy_static",
|
||||
|
@ -1579,9 +1589,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.118"
|
||||
version = "0.2.119"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94"
|
||||
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
|
@ -2130,9 +2140,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.1.0"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83"
|
||||
checksum = "9dada8c9981fcf32929c3c0f0cd796a9284aca335565227ed88c83babb1d43dc"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"toml",
|
||||
|
@ -2674,9 +2684,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.30"
|
||||
version = "0.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d8d93354fe2a8e50d5953f5ae2e47a3fc2ef03292e7ea46e3cc38f549525fb9"
|
||||
checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"pin-project-lite",
|
||||
|
@ -2718,9 +2728,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74786ce43333fcf51efe947aed9718fbe46d5c7328ec3f1029e818083966d9aa"
|
||||
checksum = "9e0ab7bdc962035a87fba73f3acca9b8a8d0034c2e6f60b84aeaaddddc155dce"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"lazy_static",
|
||||
|
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||
rand = "0.8"
|
||||
bevy_polyline = "0.1"
|
||||
noise = { git = "https://github.com/Razaekel/noise-rs" }
|
||||
hexasphere = "6.0.0"
|
||||
hexasphere = "7"
|
||||
wgpu = "0.12.0"
|
||||
|
||||
[dependencies.bevy]
|
||||
|
@ -33,4 +33,3 @@ opt-level = 1
|
|||
# Enable optimizations for dependencies (incl. Bevy), but not for our code:
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ fn setup_colliders(
|
|||
let pcollide = ColliderBundle {
|
||||
shape: ColliderShape::ball(PLANET_RADIUS).into(),
|
||||
material: ColliderMaterial {
|
||||
friction: 0.1,
|
||||
restitution: 0.05,
|
||||
friction: 0.05,
|
||||
restitution: 0.01,
|
||||
..Default::default()
|
||||
}
|
||||
.into(),
|
||||
|
@ -53,7 +53,7 @@ fn setup_colliders(
|
|||
|
||||
fn setup_bike(bike: Entity, xform: &Transform, commands: &mut Commands) {
|
||||
let mut bbody = RigidBodyBundle::default();
|
||||
bbody.damping.angular_damping = 0.5;
|
||||
bbody.damping.angular_damping = 0.7;
|
||||
bbody.damping.linear_damping = 0.3;
|
||||
bbody.forces = RigidBodyForces {
|
||||
torque: Vec3::ZERO.into(),
|
||||
|
@ -65,8 +65,8 @@ fn setup_bike(bike: Entity, xform: &Transform, commands: &mut Commands) {
|
|||
..Default::default()
|
||||
}
|
||||
.into();
|
||||
bbody.mass_properties =
|
||||
MassProperties::new(Vec3::ZERO.into(), 0.5, Vec3::new(0.0, 0.01, 0.0).into()).into();
|
||||
// bbody.mass_properties = MassProperties::new(Vec3::ZERO.into(), 0.5,
|
||||
// Vec3::new(0.0, 0.01, 0.0).into()).into();
|
||||
let isometry = Isometry::from_parts(xform.translation.into(), xform.rotation.into());
|
||||
bbody.position = isometry.into();
|
||||
// collider
|
||||
|
@ -77,7 +77,7 @@ fn setup_bike(bike: Entity, xform: &Transform, commands: &mut Commands) {
|
|||
);
|
||||
let bcollide = ColliderBundle {
|
||||
shape: shape.into(),
|
||||
mass_properties: ColliderMassProps::Density(0.3).into(),
|
||||
mass_properties: ColliderMassProps::Density(0.2).into(),
|
||||
material: ColliderMaterial {
|
||||
friction: 0.0,
|
||||
restitution: 0.05,
|
||||
|
@ -94,7 +94,7 @@ fn setup_bike(bike: Entity, xform: &Transform, commands: &mut Commands) {
|
|||
}
|
||||
|
||||
fn gravity(xform: Query<&Transform, With<CyberBike>>, mut config: ResMut<RapierConfiguration>) {
|
||||
let gravity = xform.single().translation.normalize() * -8.0;
|
||||
let gravity = xform.single().translation.normalize() * -6.0;
|
||||
config.gravity = gravity.into();
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ fn falling_cat(
|
|||
let cos = up.dot(cam_up);
|
||||
|
||||
let theta = cos.acos();
|
||||
let force_mag = if !theta.is_normal() { 0.0 } else { theta * 5.0 };
|
||||
let force_mag = if !theta.is_normal() { 0.0 } else { theta * 2.0 };
|
||||
let torque = cam_up.cross(up).normalize() * force_mag;
|
||||
|
||||
forces.torque = torque.into();
|
||||
|
|
|
@ -22,9 +22,7 @@ fn spawn_giant_sphere(
|
|||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
let mut color = Color::DARK_GRAY;
|
||||
color.set_a(0.92);
|
||||
|
||||
let color = Color::DARK_GRAY;
|
||||
let isphere = shape::Icosphere {
|
||||
radius: PLANET_RADIUS,
|
||||
subdivisions: 26,
|
||||
|
@ -37,7 +35,7 @@ fn spawn_giant_sphere(
|
|||
mesh: meshes.add(pmesh),
|
||||
material: materials.add(StandardMaterial {
|
||||
base_color: color,
|
||||
metallic: 0.65,
|
||||
metallic: 0.1,
|
||||
perceptual_roughness: 0.3,
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
..Default::default()
|
||||
|
@ -92,17 +90,20 @@ fn gen_planet(sphere: Icosphere) -> Mesh {
|
|||
// TODO: use displaced points for normals by replacing raw_points with
|
||||
// noise-displaced points.
|
||||
let noise = HybridMulti::<Perlin>::default();
|
||||
let raw_points = generated.raw_points();
|
||||
|
||||
let raw_points = generated
|
||||
.raw_points()
|
||||
.iter()
|
||||
.map(|&p| {
|
||||
let disp = noise.get(p.as_dvec3().into()) as f32 * 0.07;
|
||||
let pt = p + disp;
|
||||
pt.into()
|
||||
})
|
||||
.collect::<Vec<[f32; 3]>>();
|
||||
|
||||
let points = raw_points
|
||||
.iter()
|
||||
.map(|&p| {
|
||||
let pt = p * sphere.radius;
|
||||
let disp = noise.get(pt.as_dvec3().into()) as f32;
|
||||
let disp = p * disp * 20.0;
|
||||
let pt = pt + disp;
|
||||
pt.into()
|
||||
})
|
||||
.map(|&p| (Vec3::from_slice(&p) * sphere.radius).into())
|
||||
.collect::<Vec<[f32; 3]>>();
|
||||
|
||||
let normals = raw_points
|
||||
|
|
|
@ -38,9 +38,16 @@ fn wireframe_planet(
|
|||
}
|
||||
}
|
||||
|
||||
if !pts.is_empty() {
|
||||
let mut verts = Vec::with_capacity((pts.len() as f32 * 1.4) as usize);
|
||||
for pts in pts.chunks(3) {
|
||||
if pts.len() > 1 {
|
||||
verts.extend_from_slice(pts);
|
||||
verts.push(Vec3::NAN);
|
||||
}
|
||||
}
|
||||
|
||||
commands.spawn_bundle(PolylineBundle {
|
||||
polyline: polylines.add(Polyline { vertices: pts }),
|
||||
polyline: polylines.add(Polyline { vertices: verts }),
|
||||
material: polymats.add(PolylineMaterial {
|
||||
width: 101.0,
|
||||
color: BISEXY_COLOR,
|
||||
|
@ -49,7 +56,6 @@ fn wireframe_planet(
|
|||
..Default::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn wireframify_lights(
|
||||
mut commands: Commands,
|
||||
|
|
|
@ -113,7 +113,7 @@ fn spawn_static_lights(
|
|||
|
||||
commands.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 0.1,
|
||||
brightness: 0.2,
|
||||
});
|
||||
|
||||
// up light
|
||||
|
|
|
@ -12,7 +12,7 @@ use cyber_rider::{
|
|||
|
||||
const MOVEMENT_SETTINGS: MovementSettings = MovementSettings {
|
||||
sensitivity: 10.0, // default: 1.0
|
||||
accel: 20.0, // default: 40.0
|
||||
accel: 10.0, // default: 40.0
|
||||
};
|
||||
|
||||
fn main() {
|
||||
|
@ -20,6 +20,8 @@ fn main() {
|
|||
app.insert_resource(Msaa { samples: 4 })
|
||||
.insert_resource(ClearColor(Color::rgb(0.07, 0.001, 0.02)))
|
||||
.add_plugins(DefaultPlugins)
|
||||
//.add_plugin(LogDiagnosticsPlugin::default())
|
||||
//.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.add_plugin(CyberGeomPlugin)
|
||||
.add_plugin(CyberGlamorPlugin)
|
||||
.add_plugin(CyberInputPlugin)
|
||||
|
|
Loading…
Reference in a new issue