avian testing
is slow
This commit is contained in:
@@ -12,7 +12,6 @@ bevy-inspector-egui = "0.25.0"
|
||||
iyes_perf_ui = "0.3.0"
|
||||
noise = "0.8.2"
|
||||
world_generation = { path = "../../engine/world_generation" }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["simd-stable", "parallel"] }
|
||||
rayon = "1.10.0"
|
||||
buildings = { path = "../buildings" }
|
||||
shared = { path = "../shared" }
|
||||
@@ -21,6 +20,7 @@ bevy_asset_loader = { version = "0.21.0", features = [
|
||||
"3d",
|
||||
] }
|
||||
ron = "0.8.1"
|
||||
avian3d = { version = "0.1.1" }
|
||||
|
||||
[features]
|
||||
tracing = ["bevy/trace_tracy", "world_generation/tracing", "buildings/tracing"]
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use avian3d::prelude::*;
|
||||
use bevy::ecs::world::CommandQueue;
|
||||
use bevy::prelude::*;
|
||||
use bevy::tasks::*;
|
||||
use bevy::utils::futures;
|
||||
use bevy_rapier3d::geometry::Collider;
|
||||
use bevy_rapier3d::geometry::TriMeshFlags;
|
||||
use world_generation::prelude::Map;
|
||||
use world_generation::states::GeneratorState;
|
||||
|
||||
@@ -17,18 +16,12 @@ pub struct ChunkRebuildPlugin;
|
||||
|
||||
impl Plugin for ChunkRebuildPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.insert_resource(ChunkRebuildQueue::default());
|
||||
app.init_resource::<PhosChunkRegistry>();
|
||||
app.add_systems(PreUpdate, chunk_rebuilder.run_if(in_state(GeneratorState::SpawnMap)));
|
||||
app.add_systems(PostUpdate, collider_task_resolver);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct ChunkRebuildQueue {
|
||||
pub queue: Vec<usize>,
|
||||
}
|
||||
|
||||
fn chunk_rebuilder(
|
||||
mut commands: Commands,
|
||||
chunk_query: Query<(Entity, &PhosChunk), (With<RebuildChunk>, Without<ChunkRebuildTask>)>,
|
||||
@@ -51,11 +44,7 @@ fn chunk_rebuilder(
|
||||
let (mesh, collider_data, _, _) = prepare_chunk_mesh(&chunk_data, chunk_offset, chunk_index);
|
||||
#[cfg(feature = "tracing")]
|
||||
let trimesh_span = info_span!("Chunk Trimesh").entered();
|
||||
let c = Collider::trimesh_with_flags(
|
||||
collider_data.0,
|
||||
collider_data.1,
|
||||
TriMeshFlags::DELETE_DUPLICATE_TRIANGLES,
|
||||
);
|
||||
let c = Collider::trimesh(collider_data.0, collider_data.1);
|
||||
#[cfg(feature = "tracing")]
|
||||
drop(trimesh_span);
|
||||
queue.push(move |world: &mut World| {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use avian3d::prelude::*;
|
||||
use bevy::{prelude::*, window::PrimaryWindow};
|
||||
use bevy_rapier3d::{pipeline::QueryFilter, plugin::RapierContext};
|
||||
use world_generation::{hex_utils::HexCoord, prelude::Map, states::GeneratorState};
|
||||
|
||||
use crate::{
|
||||
@@ -20,7 +20,7 @@ fn deform(
|
||||
mut commands: Commands,
|
||||
window: Query<&Window, With<PrimaryWindow>>,
|
||||
mouse: Res<ButtonInput<MouseButton>>,
|
||||
rapier_context: Res<RapierContext>,
|
||||
spatial_query: SpatialQuery,
|
||||
mut heightmap: ResMut<Map>,
|
||||
chunks: Res<PhosChunkRegistry>,
|
||||
) {
|
||||
@@ -45,17 +45,20 @@ fn deform(
|
||||
return;
|
||||
};
|
||||
|
||||
let collision = rapier_context.cast_ray(
|
||||
let collision = spatial_query.cast_ray(
|
||||
cam_ray.origin,
|
||||
cam_ray.direction.into(),
|
||||
500.,
|
||||
true,
|
||||
QueryFilter::only_fixed(),
|
||||
SpatialQueryFilter::default(),
|
||||
);
|
||||
|
||||
if let Some((e, dist)) = collision {
|
||||
if let Some(hit) = collision {
|
||||
#[cfg(feature = "tracing")]
|
||||
let span = info_span!("Deform Mesh").entered();
|
||||
|
||||
let e = hit.entity;
|
||||
let dist = hit.time_of_impact;
|
||||
let contact_point = cam_ray.get_point(dist);
|
||||
let contact_coord = HexCoord::from_world_pos(contact_point);
|
||||
let modified_chunks = heightmap.create_crater(&contact_coord, 5, 5. * multi);
|
||||
|
||||
@@ -2,14 +2,13 @@ use crate::camera_system::camera_plugin::PhosCameraPlugin;
|
||||
use crate::camera_system::components::PhosCamera;
|
||||
use crate::map_rendering::map_init::MapInitPlugin;
|
||||
use crate::utlis::render_distance_system::RenderDistancePlugin;
|
||||
use avian3d::prelude::*;
|
||||
use avian3d::PhysicsPlugins;
|
||||
use bevy::{
|
||||
pbr::{wireframe::WireframeConfig, CascadeShadowConfig},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy_asset_loader::prelude::*;
|
||||
use bevy_rapier3d::dynamics::{Ccd, RigidBody, Velocity};
|
||||
use bevy_rapier3d::geometry::Collider;
|
||||
use bevy_rapier3d::plugin::{NoUserData, RapierPhysicsPlugin};
|
||||
use buildings::BuildingPugin;
|
||||
use iyes_perf_ui::prelude::*;
|
||||
use shared::states::{GameplayState, MenuState};
|
||||
@@ -31,7 +30,7 @@ impl Plugin for PhosGamePlugin {
|
||||
PhosCameraPlugin,
|
||||
MapInitPlugin,
|
||||
RenderDistancePlugin,
|
||||
// BuildingPugin,
|
||||
//BuildingPugin,
|
||||
DespawnPuglin,
|
||||
));
|
||||
|
||||
@@ -48,7 +47,7 @@ impl Plugin for PhosGamePlugin {
|
||||
.add_plugins(PerfUiPlugin);
|
||||
|
||||
//Physics
|
||||
app.add_plugins(RapierPhysicsPlugin::<NoUserData>::default());
|
||||
app.add_plugins(PhysicsPlugins::default());
|
||||
// app.add_plugins(RapierDebugRenderPlugin::default());
|
||||
|
||||
app.insert_resource(WireframeConfig {
|
||||
@@ -107,10 +106,9 @@ fn spawn_sphere(
|
||||
transform: Transform::from_translation(cam_transform.translation),
|
||||
..default()
|
||||
},
|
||||
Collider::ball(0.3),
|
||||
Collider::sphere(0.3),
|
||||
RigidBody::Dynamic,
|
||||
Ccd::enabled(),
|
||||
Velocity::linear(cam_transform.forward() * 50.),
|
||||
LinearVelocity(cam_transform.forward() * 50.),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use avian3d::prelude::*;
|
||||
#[cfg(feature = "tracing")]
|
||||
use bevy::log::*;
|
||||
use bevy::{
|
||||
@@ -6,7 +7,6 @@ use bevy::{
|
||||
math::{IVec2, Vec3},
|
||||
render::mesh::Mesh,
|
||||
};
|
||||
use bevy_rapier3d::geometry::{Collider, TriMeshFlags};
|
||||
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
|
||||
use world_generation::{
|
||||
biome_painter::BiomePainter,
|
||||
@@ -76,7 +76,7 @@ pub fn prepare_chunk_mesh_with_collider(
|
||||
{
|
||||
#[cfg(feature = "tracing")]
|
||||
let _collider_span = info_span!("Create Collider Trimesh").entered();
|
||||
collider = Collider::trimesh_with_flags(col_verts, col_indicies, TriMeshFlags::DELETE_DUPLICATE_TRIANGLES);
|
||||
collider = Collider::trimesh(col_verts, col_indicies);
|
||||
}
|
||||
return (mesh, collider, pos, index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user