Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
LatentSpaceExplorer committed Oct 16, 2023
2 parents 1fd1b6a + e9187dd commit 1417dca
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 816 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.3.1 - bevy 0.11 - 2023-10-13

### Fixed

- updated physx-rs to newer version, removed workarounds for now fixed issues there

## 0.3.0 - bevy 0.11 - 2023-08-07

### Added
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_mod_physx"
version = "0.3.0"
version = "0.3.1"
authors = ["Alex Kocharin <[email protected]>"]
description = "PhysX plugin for Bevy"
documentation = "https://docs.rs/bevy_mod_physx"
Expand All @@ -20,12 +20,12 @@ path = "src/lib.rs"
bevy = "0.11.0"
derive_more = "0.99.17"
enumflags2 = "0.7.7"
physx = "0.18.0"
physx-sys = "0.11.3"
physx = "0.19.0"
physx-sys = "0.11.5"
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
bevy-inspector-egui = "0.19.0"
bevy-inspector-egui = "0.20.0"

[features]
serialize = ["dep:serde", "bevy/serialize"]
Binary file removed examples/helloworld.webp
Binary file not shown.
1 change: 0 additions & 1 deletion src/core/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use physx_sys::{
};

use crate::prelude::{self as bpx, *};
use crate::utils::physx_extras::HeightFieldSample;

#[derive(TypeUuid, TypePath, Clone, Deref, DerefMut)]
#[uuid = "db246120-e6af-4ebf-a95a-a6efe1c54d9f"]
Expand Down
45 changes: 7 additions & 38 deletions src/core/shape.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! Defines characteristics of collision shapes (geometry, material).
use std::ptr::drop_in_place;

use bevy::prelude::*;
use derive_more::{Deref, DerefMut};
use physx::prelude::*;
use physx::traits::Class;
use physx_sys::{PxPhysics_createShape_mut, PxShape_release_mut};
use physx_sys::PxPhysics_createShape_mut;

use crate::core::geometry::GeometryInner;
use crate::core::scene::SceneRwLock;
Expand All @@ -30,16 +29,18 @@ impl Default for Shape {
}
}

#[derive(Component)]
#[derive(Component, Deref, DerefMut)]
pub struct ShapeHandle {
handle: Option<SceneRwLock<Owner<PxShape>>>,
#[deref]
#[deref_mut]
handle: SceneRwLock<Owner<PxShape>>,
// we want to specify outward normal for PxPlane specifically, so need to return transform for this
pub custom_xform: Transform,
}

impl ShapeHandle {
pub fn new(px_shape: Owner<PxShape>, custom_xform: Transform) -> Self {
Self { handle: Some(SceneRwLock::new(px_shape)), custom_xform }
Self { handle: SceneRwLock::new(px_shape), custom_xform }
}

pub fn create_shape(
Expand Down Expand Up @@ -102,35 +103,3 @@ impl ShapeHandle {
Self::new(shape, transform)
}
}

impl Drop for ShapeHandle {
fn drop(&mut self) {
// TODO: remove this entire drop when this gets fixed:
// https://github.com/EmbarkStudios/physx-rs/issues/180
let mut shape = self.handle.take().unwrap();
unsafe {
use physx::shape::Shape;
drop_in_place(shape.get_mut_unsafe().get_user_data_mut());
PxShape_release_mut(shape.get_mut_unsafe().as_mut_ptr());
}
std::mem::forget(shape);
}
}

impl std::ops::Deref for ShapeHandle {
type Target = SceneRwLock<Owner<PxShape>>;

fn deref(&self) -> &Self::Target {
// TODO: replace with Deref/DerefMut derive when this gets fixed:
// https://github.com/EmbarkStudios/physx-rs/issues/180
self.handle.as_ref().unwrap()
}
}

impl std::ops::DerefMut for ShapeHandle {
fn deref_mut(&mut self) -> &mut Self::Target {
// TODO: replace with Deref/DerefMut derive when this gets fixed:
// https://github.com/EmbarkStudios/physx-rs/issues/180
self.handle.as_mut().unwrap()
}
}
2 changes: 1 addition & 1 deletion src/plugins/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Plugin for SleepPlugin {

app.world.insert_resource(WakeSleepCallback(OnWakeSleep::new(move |actors, is_waking| {
let entities = actors.iter().map(|actor| {
actor.cast_map_ref(
actor.cast_map(
|articulation| *articulation.get_user_data(),
|rstatic| *rstatic.get_user_data(),
|rdynamic| *rdynamic.get_user_data(),
Expand Down
6 changes: 0 additions & 6 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,5 @@ pub use crate::plugins::velocity::{MaxVelocity, Velocity};
pub use crate::plugins::lock_flags::RigidDynamicLockFlags;

pub use crate::utils::events::AppExtensions;
pub use crate::utils::physx_extras::{
ActorMapExtras,
ConvexMeshExtras,
HeightFieldExtras,
TriangleMeshExtras,
};
pub use crate::utils::raycast::{RaycastHit, SceneQueryExt};
pub use crate::utils::type_bridge::*;
1 change: 0 additions & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Various helpers and extension traits.
pub mod events;
pub mod physx_extras;
pub mod raycast;
pub mod type_bridge;

Expand Down
142 changes: 0 additions & 142 deletions src/utils/physx_extras/actor_map.rs

This file was deleted.

Loading

0 comments on commit 1417dca

Please sign in to comment.