From a9dea5cdb3c13e187e314d638d07baec34486a1b Mon Sep 17 00:00:00 2001 From: zhouzihao <1042181618@qq.com> Date: Mon, 18 Sep 2023 17:38:42 +0800 Subject: [PATCH] =?UTF-8?q?fix-=E5=A4=84=E7=90=86server=20headless?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84=E7=89=A9=E7=90=86=E7=A2=B0?= =?UTF-8?q?=E6=92=9E=E4=BD=93=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/sp_physics.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server/sp_physics.rs b/src/server/sp_physics.rs index 20ec315..c778ed3 100644 --- a/src/server/sp_physics.rs +++ b/src/server/sp_physics.rs @@ -230,6 +230,7 @@ fn deal_events( ) { for event in event_reader.iter() { if let Some(entity) = sp_physics_manager.remove(event.chunk_key, event.index) { + // println!("这里销毁了碰撞体"); commands.entity(entity).despawn(); } } @@ -237,7 +238,7 @@ fn deal_events( // 通过mesh生成碰撞体 fn get_collider_by_mesh(mesh: &Mesh) -> Option { - let collider_vertices: Vec = mesh + let mut collider_vertices: Vec = mesh .attribute(Mesh::ATTRIBUTE_POSITION) .unwrap() .as_float3() @@ -251,6 +252,13 @@ fn get_collider_by_mesh(mesh: &Mesh) -> Option { let collider_indices: Vec<[u32; 3]> = indices.chunks(3).map(|i| [i[0], i[1], i[2]]).collect(); // println!("{:?}", collider_vertices); // println!("{:?}", collider_indices); + #[cfg(feature = "headless")] + { + collider_vertices = collider_vertices + .iter() + .map(|x| *x * Vec3::splat(1.0 / 32.0)) + .collect(); + } let collider = Collider::trimesh(collider_vertices, collider_indices); Some(collider) }