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