turned on CCD
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3287,6 +3287,7 @@ dependencies = [
|
|||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"parry3d",
|
"parry3d",
|
||||||
|
"rayon",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"simba",
|
"simba",
|
||||||
"vec_map",
|
"vec_map",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use crate::{hex_utils::*, prelude::*};
|
|||||||
|
|
||||||
const CHUNK_TOTAL: usize = Chunk::SIZE * Chunk::SIZE;
|
const CHUNK_TOTAL: usize = Chunk::SIZE * Chunk::SIZE;
|
||||||
|
|
||||||
|
|
||||||
pub fn generate_chunk_collider(chunk: &Chunk, map: &Map) -> (Vec<Vec3>, Vec<[u32; 3]>) {
|
pub fn generate_chunk_collider(chunk: &Chunk, map: &Map) -> (Vec<Vec3>, Vec<[u32; 3]>) {
|
||||||
let vertex_count: usize = CHUNK_TOTAL * 6;
|
let vertex_count: usize = CHUNK_TOTAL * 6;
|
||||||
let mut verts = Vec::with_capacity(vertex_count);
|
let mut verts = Vec::with_capacity(vertex_count);
|
||||||
@@ -35,12 +34,18 @@ fn create_tile_collider(
|
|||||||
let p = pos + HEX_CORNERS[i];
|
let p = pos + HEX_CORNERS[i];
|
||||||
verts.push(p);
|
verts.push(p);
|
||||||
}
|
}
|
||||||
for i in 0..3 {
|
// for i in 0..3 {
|
||||||
let off = i * 2;
|
// let off = i * 2;
|
||||||
indices.push([off + idx, ((off + 1) % 6) + idx, ((off + 2) % 6) + idx]);
|
// indices.push([off + idx, ((off + 1) % 6) + idx, ((off + 2) % 6) + idx]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
indices.push([idx, idx + 2, idx + 4]);
|
// indices.push([idx, idx + 2, idx + 4]);
|
||||||
|
|
||||||
|
//Top Surfave
|
||||||
|
indices.push([idx, idx + 1, idx + 5]);
|
||||||
|
indices.push([idx + 1, idx + 2, idx + 5]);
|
||||||
|
indices.push([idx + 2, idx + 4, idx + 5]);
|
||||||
|
indices.push([idx + 2, idx + 3, idx + 4]);
|
||||||
|
|
||||||
for i in 0..neighbors.len() {
|
for i in 0..neighbors.len() {
|
||||||
let cur_n = neighbors[i];
|
let cur_n = neighbors[i];
|
||||||
@@ -49,7 +54,7 @@ fn create_tile_collider(
|
|||||||
if n_height < pos.y {
|
if n_height < pos.y {
|
||||||
create_tile_wall_collider(
|
create_tile_wall_collider(
|
||||||
idx,
|
idx,
|
||||||
Vec3::new(pos.x, n_height, pos.z),
|
Vec3::new(pos.x, n_height.min(pos.y - 0.5), pos.z),
|
||||||
i,
|
i,
|
||||||
verts,
|
verts,
|
||||||
indices,
|
indices,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use crate::prelude::PhosCamera;
|
use crate::prelude::PhosCamera;
|
||||||
use bevy::input::mouse::MouseMotion;
|
use bevy::input::mouse::MouseMotion;
|
||||||
|
use bevy::pbr::ScreenSpaceAmbientOcclusionBundle;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::window::CursorGrabMode;
|
use bevy::window::CursorGrabMode;
|
||||||
|
|
||||||
@@ -26,7 +27,8 @@ impl Plugin for PhosCameraPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands) {
|
fn setup(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands
|
||||||
|
.spawn((
|
||||||
Camera3dBundle {
|
Camera3dBundle {
|
||||||
transform: Transform::from_xyz(0., 30., 0.)
|
transform: Transform::from_xyz(0., 30., 0.)
|
||||||
.looking_at(Vec3::new(1000., 0., 1000.), Vec3::Y),
|
.looking_at(Vec3::new(1000., 0., 1000.), Vec3::Y),
|
||||||
@@ -36,7 +38,8 @@ fn setup(mut commands: Commands) {
|
|||||||
speed: 100.,
|
speed: 100.,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
));
|
))
|
||||||
|
.insert(ScreenSpaceAmbientOcclusionBundle::default());
|
||||||
}
|
}
|
||||||
fn update_camera(
|
fn update_camera(
|
||||||
mut cam_query: Query<(&PhosCamera, &mut Transform)>,
|
mut cam_query: Query<(&PhosCamera, &mut Transform)>,
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ iyes_perf_ui = "0.2.3"
|
|||||||
noise = "0.8.2"
|
noise = "0.8.2"
|
||||||
world_generation ={path="../../engine/world_generation"}
|
world_generation ={path="../../engine/world_generation"}
|
||||||
camera_system={path = "../camera_system"}
|
camera_system={path = "../camera_system"}
|
||||||
bevy_rapier3d = { version = "0.25.0", features = [ "simd-stable", "debug-render-3d" ] }
|
bevy_rapier3d = { version = "0.25.0", features = [ "simd-stable", "debug-render-3d","parallel" ] }
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ use bevy::{
|
|||||||
pbr::{wireframe::WireframeConfig, CascadeShadowConfig},
|
pbr::{wireframe::WireframeConfig, CascadeShadowConfig},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use bevy_rapier3d::dynamics::{RigidBody, Velocity};
|
use bevy_rapier3d::dynamics::{Ccd, RigidBody, Velocity};
|
||||||
use bevy_rapier3d::geometry::Collider;
|
use bevy_rapier3d::geometry::Collider;
|
||||||
use bevy_rapier3d::plugin::{NoUserData, RapierPhysicsPlugin};
|
use bevy_rapier3d::plugin::{NoUserData, RapierPhysicsPlugin};
|
||||||
|
use bevy_rapier3d::render::RapierDebugRenderPlugin;
|
||||||
use camera_system::prelude::PhosCamera;
|
use camera_system::prelude::PhosCamera;
|
||||||
use camera_system::PhosCameraPlugin;
|
use camera_system::PhosCameraPlugin;
|
||||||
use iyes_perf_ui::prelude::*;
|
use iyes_perf_ui::prelude::*;
|
||||||
@@ -21,11 +22,11 @@ pub struct PhosGamePlugin;
|
|||||||
|
|
||||||
impl Plugin for PhosGamePlugin {
|
impl Plugin for PhosGamePlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugins(PhosCameraPlugin)
|
app.add_plugins((
|
||||||
.add_plugins(MapInitPlugin)
|
PhosCameraPlugin,
|
||||||
.add_plugins(MaterialPlugin::<
|
MapInitPlugin,
|
||||||
ExtendedMaterial<StandardMaterial, ChunkMaterial>,
|
MaterialPlugin::<ExtendedMaterial<StandardMaterial, ChunkMaterial>>::default(),
|
||||||
>::default());
|
));
|
||||||
|
|
||||||
//Systems - Startup
|
//Systems - Startup
|
||||||
app.add_systems(Startup, init_game);
|
app.add_systems(Startup, init_game);
|
||||||
@@ -105,6 +106,7 @@ fn spawn_sphere(
|
|||||||
},
|
},
|
||||||
Collider::ball(0.3),
|
Collider::ball(0.3),
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
|
Ccd::enabled(),
|
||||||
Velocity::linear(cam_transform.forward() * 50.),
|
Velocity::linear(cam_transform.forward() * 50.),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user