-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not manually free materials for shapes (#215)
* Do not manually free materials for shapes * remove unnecessary junk
- Loading branch information
Showing
4 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["physx", "physx-sys", "physx-sys/pxbind"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use physx::{base::RefCounted, prelude::*}; | ||
|
||
type PxMaterial = physx::material::PxMaterial<()>; | ||
type PxShape = physx::shape::PxShape<(), PxMaterial>; | ||
|
||
#[test] | ||
fn test_double_free() { | ||
let mut physics = PhysicsFoundation::<_, PxShape>::default(); | ||
|
||
let mut material = physics.create_material(0.5, 0.5, 0.6, ()).unwrap(); | ||
let geometry = PxBoxGeometry::new(1., 1., 1.); | ||
let flags = | ||
ShapeFlags::SceneQueryShape | ShapeFlags::SimulationShape | ShapeFlags::Visualization; | ||
|
||
let shape = physics | ||
.create_shape(&geometry, &mut [&mut material], false, flags, ()) | ||
.unwrap(); | ||
|
||
assert_eq!(material.get_reference_count(), 2); | ||
drop(shape); | ||
|
||
assert_eq!(material.get_reference_count(), 1); | ||
drop(material); | ||
} |