added collision groups, and removed rapierdebugger

This commit is contained in:
Jay Christy
2023-11-07 13:36:05 -05:00
parent a35e7b1330
commit 207766130e
2 changed files with 17 additions and 8 deletions

View File

@@ -52,7 +52,7 @@ fn main() {
.add_plugins(OpenXrDebugRenderer) .add_plugins(OpenXrDebugRenderer)
//rapier goes here //rapier goes here
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default().with_default_system_setup(false)) .add_plugins(RapierPhysicsPlugin::<NoUserData>::default().with_default_system_setup(false))
.add_plugins(RapierDebugRenderPlugin::default()) // .add_plugins(RapierDebugRenderPlugin::default())
//lets setup the starting scene //lets setup the starting scene
.add_systems(Startup, setup_scene) .add_systems(Startup, setup_scene)
.add_systems(Startup, spawn_controllers_example) //you need to spawn controllers or it crashes TODO:: Fix this .add_systems(Startup, spawn_controllers_example) //you need to spawn controllers or it crashes TODO:: Fix this
@@ -277,13 +277,21 @@ fn spawn_physics_hands(mut commands: Commands) {
PhysicsHandBone::LittleDistal, PhysicsHandBone::LittleDistal,
PhysicsHandBone::LittleTip, PhysicsHandBone::LittleTip,
]; ];
//lets just do the Right ThumbMetacarpal for now
//i dont understand the groups yet
let self_group = Group::GROUP_1;
let interaction_group = Group::ALL;
let radius = 0.010; let radius = 0.010;
let left_hand_membership_group = Group::GROUP_1;
let right_hand_membership_group = Group::GROUP_2;
let floor_membership = Group::GROUP_3;
for hand in hands.iter() { for hand in hands.iter() {
let hand_membership = match hand
{
Hand::Left => left_hand_membership_group,
Hand::Right => right_hand_membership_group,
};
let mut hand_filter: Group = Group::ALL;
hand_filter.remove(hand_membership);
hand_filter.remove(floor_membership);
for bone in bones.iter() { for bone in bones.iter() {
//spawn the thing //spawn the thing
commands.spawn(( commands.spawn((
@@ -301,9 +309,9 @@ fn spawn_physics_hands(mut commands: Commands) {
}, },
radius, radius,
), ),
RigidBody::KinematicVelocityBased, RigidBody::Dynamic,
Velocity::default(), Velocity::default(),
// CollisionGroups::new(Group::from_bits(0b1110).unwrap(), Group::from_bits(0b0001).unwrap()), CollisionGroups::new(hand_membership, Group::from_bits(0b0001).unwrap()),
// SolverGroups::new(self_group, interaction_group), // SolverGroups::new(self_group, interaction_group),
bone.clone(), bone.clone(),
BoneInitState::False, BoneInitState::False,

View File

@@ -8,7 +8,7 @@ use bevy::{
}; };
use bevy_openxr::xr_input::interactions::{Touched, XRInteractable, XRInteractableState}; use bevy_openxr::xr_input::interactions::{Touched, XRInteractable, XRInteractableState};
use bevy_rapier3d::{ use bevy_rapier3d::{
prelude::{Collider, RigidBody}, prelude::{Collider, RigidBody, Group, CollisionGroups},
render::ColliderDebugColor, render::ColliderDebugColor,
}; };
@@ -36,6 +36,7 @@ pub fn setup_scene(
}, },
RigidBody::Fixed, RigidBody::Fixed,
Collider::cuboid(ground_size, ground_thickness, ground_size), Collider::cuboid(ground_size, ground_thickness, ground_size),
CollisionGroups::new(Group::GROUP_3, Group::ALL),
)); ));
// cube // cube
commands.spawn(( commands.spawn((