fabmax / physx-jni

Java JNI bindings for Nvidia PhysX
MIT License
89 stars 9 forks source link

Active Actors support #25

Closed haubna closed 3 years ago

haubna commented 3 years ago

Maybe I am unable to find the proper function but I think this one is missing: https://gameworksdocs.nvidia.com/PhysX/4.0/documentation/PhysXGuide/Manual/RigidBodyDynamics.html#active-actors

It would probably improve performance for sleeping objects quite a bit by avoiding to update them.

fabmax commented 3 years ago

You are right, I skipped the getActiveActors function becauso both the returned raw pointer / array and the primitive int passed in by reference and used as an output parameter don't map well to Java.

However, it should be possible to write a small wrapper function which maps that to something that can be used from Java.

fabmax commented 3 years ago

Was indeed not too hard, it's in the dev branch now. Here is how it works:

    Vector_PxActorPtr activeActors = SupportFunctions.PxScene_getActiveActors(scene);
    int nbActiveActors = activeActors.size();
    for (int i = 0; i < nbActiveActors; i++) {
        PxActor actor = activeActors.at(i);
    }

I will wait a bit longer until I publish a new lib version in case more stuff comes up...

haubna commented 3 years ago

Perfect, thanks! :)