stilldesign / PhysX.Net

A .NET wrapper for NVIDIA PhysX 4.1.2 written using C++/CLI.
MIT License
206 stars 55 forks source link

Release/detach of actor shapes #4

Closed kpko closed 9 years ago

kpko commented 10 years ago

Hi,

we need a better mechanism to support the release of shapes from actors. PhysX has its own reference counting mechanism and I think it kind of collides with the Disposing of shapes and actors how it is currently implemented.

We talked about it a few weeks ago on codeplex: https://physxdotnet.codeplex.com/workitem/35077

We have no method yet to detach a shape from an actor. This for example seems to happen automatically if we use Actor::CreateShape (see the first paragraphs of https://developer.nvidia.com/sites/default/files/akamai/physx/Docs/Shapes.html).

At one point we have to remote the object from ObjectTable too. We need a way to detect, when PhysX decides to delete the shape.

stilldesign commented 10 years ago

Definitely need to add the ability to remove shapes from certain actors. I can't quite remember whether there were any particular problems with doing this, or whether it's a simple case of adding RigidActor.DetachShape(Shape s).

As you say, we'll need to remove it from the ObjectTable at some point, I can't quite find a suitable method to help with this, we'd need something that returns the referenceCount of the PxShape, as once this equals 0, the shape is deleted by PhysX and then we'd remove it from the ObjectTable.

I'll try find some time to take a look at this one. Should be able to write tests for this case as well :)

stilldesign commented 9 years ago

Done some work regarding attaching/detaching shapes - will close this thread and move over to: https://github.com/stilldesign/PhysX.Net/issues/10