views:

212

answers:

1

Hi.

As far as I know, using the PhysX API, the only way to obtain an NxActor is from an instance of NxScene using the createActor method. This is really bugging me. I want to keep my code clean, but I feel like there is no choice but to go around passing this scene from constructor to constructor so that classes can make and have references to actors. I suppose that, alternatively, I could make the scene global (eek!), but I don't think global variables are a good idea. One thought I had was to have my classes simply store an NxActorDesc (and have them provide it to the scene to create the actor via message passing), but they really need references to the NxActor so that they can sync their transformations with the actor.

Anyhow, I would like to see what insight others might have. Do you think I am going about this the right way (passing the NxScene all over the place)? It feels kind of icky, but maybe I'm just crazy. If not, how can I sync something such as a Model class with an NxActor in a way that is more elegant? Thanks in advance!

A: 

If you don't want you're objects directly coupled with the Actors I would suggest a different approach. You could come up with a way of registering an object to have physics update it. Then the module that those objects registered with would assign each object to an Actor that would be use to set the information of the objects periodically. This way you have just one module coupled with Actor/PhysX management and the objects just need an interface that allows them to be updated with the physics information.

resolveaswontfix