Upgrade Rapier.
This commit is contained in:
parent
65067412af
commit
bff40340a8
|
@ -25,7 +25,7 @@ features = [
|
||||||
[dependencies]
|
[dependencies]
|
||||||
backtrace = "0.3"
|
backtrace = "0.3"
|
||||||
bevy_input_actionmap = { git = "https://github.com/lightsoutgames/bevy_input_actionmap" }
|
bevy_input_actionmap = { git = "https://github.com/lightsoutgames/bevy_input_actionmap" }
|
||||||
bevy_rapier2d = { version = "0.14", features = ["enhanced-determinism", "serde-serialize"] }
|
bevy_rapier2d = { version = "0.15", features = ["serde-serialize"] }
|
||||||
bevy_synthizer = { git = "https://labs.lightsout.games/projects/bevy_synthizer" }
|
bevy_synthizer = { git = "https://labs.lightsout.games/projects/bevy_synthizer" }
|
||||||
bevy_tts = { git = "https://github.com/lightsoutgames/bevy_tts", default-features = false, features = ["tolk"] }
|
bevy_tts = { git = "https://github.com/lightsoutgames/bevy_tts", default-features = false, features = ["tolk"] }
|
||||||
coord_2d = "0.3"
|
coord_2d = "0.3"
|
||||||
|
|
|
@ -351,8 +351,7 @@ fn exploration_changed_announcement<D: 'static + Clone + Default + Send + Sync>(
|
||||||
exploring,
|
exploring,
|
||||||
0.,
|
0.,
|
||||||
&shape,
|
&shape,
|
||||||
InteractionGroups::all(),
|
QueryFilter::new().predicate(&|v| explorable.get(v).is_ok()),
|
||||||
Some(&|v| explorable.get(v).is_ok()),
|
|
||||||
|entity| {
|
|entity| {
|
||||||
commands.entity(entity).insert(ExplorationFocused);
|
commands.entity(entity).insert(ExplorationFocused);
|
||||||
if visible || mappables.get(entity).is_ok() {
|
if visible || mappables.get(entity).is_ok() {
|
||||||
|
|
|
@ -247,7 +247,7 @@ fn spawn_colliders<D: 'static + Clone + Default + Send + Sync>(
|
||||||
let id = commands
|
let id = commands
|
||||||
.spawn()
|
.spawn()
|
||||||
.insert(shape)
|
.insert(shape)
|
||||||
.insert(Sensor(true))
|
.insert(Sensor)
|
||||||
.insert(ActiveEvents::COLLISION_EVENTS)
|
.insert(ActiveEvents::COLLISION_EVENTS)
|
||||||
.insert(Transform::from_xyz(
|
.insert(Transform::from_xyz(
|
||||||
position.translation.x,
|
position.translation.x,
|
||||||
|
@ -317,17 +317,18 @@ fn spawn_portals<D: 'static + Clone + Default + Send + Sync>(
|
||||||
|
|
||||||
fn spawn_portal_colliders<D: 'static + Clone + Default + Send + Sync>(
|
fn spawn_portal_colliders<D: 'static + Clone + Default + Send + Sync>(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
map: Query<&SpawnColliders, With<Map<D>>>,
|
map: Query<(Entity, &SpawnColliders), With<Map<D>>>,
|
||||||
portals: Query<Entity, (With<Portal>, Without<Collider>)>,
|
portals: Query<Entity, (With<Portal>, Without<Collider>)>,
|
||||||
) {
|
) {
|
||||||
for spawn_colliders in map.iter() {
|
for (entity, spawn_colliders) in map.iter() {
|
||||||
if **spawn_colliders {
|
if **spawn_colliders {
|
||||||
for portal_entity in portals.iter() {
|
for portal_entity in portals.iter() {
|
||||||
commands
|
commands
|
||||||
.entity(portal_entity)
|
.entity(portal_entity)
|
||||||
.insert(Collider::cuboid(0.5, 0.5))
|
.insert(Collider::cuboid(0.5, 0.5))
|
||||||
.insert(Sensor(true));
|
.insert(Sensor);
|
||||||
}
|
}
|
||||||
|
commands.entity(entity).remove::<SpawnColliders>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use bevy::{
|
||||||
use bevy_rapier2d::{
|
use bevy_rapier2d::{
|
||||||
na::{Isometry2, Vector2},
|
na::{Isometry2, Vector2},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
rapier::prelude::{ColliderHandle, ColliderSet, QueryPipeline},
|
rapier::prelude::{ColliderHandle, ColliderSet, QueryPipeline, RigidBodySet},
|
||||||
};
|
};
|
||||||
use futures_lite::future;
|
use futures_lite::future;
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ fn find_path_for_shape<D: 'static + Clone + Default + Send + Sync>(
|
||||||
map: Map<D>,
|
map: Map<D>,
|
||||||
query_pipeline: QueryPipeline,
|
query_pipeline: QueryPipeline,
|
||||||
collider_set: ColliderSet,
|
collider_set: ColliderSet,
|
||||||
|
rigid_body_set: RigidBodySet,
|
||||||
shape: Collider,
|
shape: Collider,
|
||||||
) -> Option<Path> {
|
) -> Option<Path> {
|
||||||
let path = astar(
|
let path = astar(
|
||||||
|
@ -78,11 +79,12 @@ fn find_path_for_shape<D: 'static + Clone + Default + Send + Sync>(
|
||||||
let shape_pos =
|
let shape_pos =
|
||||||
Isometry2::new(Vector2::new(tile.0 as f32 + 0.5, tile.1 as f32 + 0.5), 0.);
|
Isometry2::new(Vector2::new(tile.0 as f32 + 0.5, tile.1 as f32 + 0.5), 0.);
|
||||||
query_pipeline.intersections_with_shape(
|
query_pipeline.intersections_with_shape(
|
||||||
|
&rigid_body_set,
|
||||||
&collider_set,
|
&collider_set,
|
||||||
&shape_pos,
|
&shape_pos,
|
||||||
&*shape.raw,
|
&*shape.raw,
|
||||||
InteractionGroups::all(),
|
bevy_rapier2d::rapier::pipeline::QueryFilter::new()
|
||||||
Some(&|v| v != initiator),
|
.predicate(&|h, _c| h != initiator),
|
||||||
|_handle| {
|
|_handle| {
|
||||||
should_push = false;
|
should_push = false;
|
||||||
false
|
false
|
||||||
|
@ -146,9 +148,9 @@ fn calculate_path<D: 'static + Clone + Default + Send + Sync>(
|
||||||
to_remove.push(handle.0);
|
to_remove.push(handle.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let mut bodies = rapier_context.bodies.clone();
|
||||||
if !to_remove.is_empty() {
|
if !to_remove.is_empty() {
|
||||||
let mut islands = rapier_context.islands.clone();
|
let mut islands = rapier_context.islands.clone();
|
||||||
let mut bodies = rapier_context.bodies.clone();
|
|
||||||
for handle in to_remove {
|
for handle in to_remove {
|
||||||
collider_set.remove(handle, &mut islands, &mut bodies, false);
|
collider_set.remove(handle, &mut islands, &mut bodies, false);
|
||||||
}
|
}
|
||||||
|
@ -162,6 +164,7 @@ fn calculate_path<D: 'static + Clone + Default + Send + Sync>(
|
||||||
map_clone,
|
map_clone,
|
||||||
query_pipeline,
|
query_pipeline,
|
||||||
collider_set,
|
collider_set,
|
||||||
|
bodies,
|
||||||
shape_clone,
|
shape_clone,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
@ -89,8 +89,7 @@ impl Viewshed {
|
||||||
shape_pos,
|
shape_pos,
|
||||||
0.,
|
0.,
|
||||||
&shape,
|
&shape,
|
||||||
InteractionGroups::all(),
|
QueryFilter::new().predicate(&|v| visible_query.get(v).is_ok()),
|
||||||
Some(&|v| visible_query.get(v).is_ok()),
|
|
||||||
|entity| {
|
|entity| {
|
||||||
let obstruction = obstructions_query.get(entity).is_ok();
|
let obstruction = obstructions_query.get(entity).is_ok();
|
||||||
if obstruction {
|
if obstruction {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user