Hooking into the Render Loop to update objects?

Hey all,



I’m using jMonkey to render my results from some PhysX calculations I am doing. I am wondering if I can get more speed out of my technique by hooking into the render loop and updating my render objects as I render them.



My current update loop looks something like this:

  1. Have PhysX update all it’s objects
  2. Go through all the objects and update the corresponding jMonkey objects for rendering
  3. Render all objects



    It seems to me like I am wasting time by going through all the objects in PhysX (done by PhysX), then going through all of them to update their transform, then finally going through them all again to render them.



    I am wondering if there is a way to update and render at the same time, so I only need to loop through them once?

The update loop is in fact the only place you should move your objects in. You have two options for “multithreading”: either do the physx update in parallel to rendering or do it completely detached and only synchronize the single objects. The latter method ofc doesn’t guarantee that all objects rendered are from one physics update. Look at BulletAppState for an implementation of a physics system in jME3.

I see. I suppose I could multithread it, that might speed things up.



My end goal is simply to improve the performance. Right now I’m getting around 400fps without rendering, 20fps with rendering (just a series of quads to represent particles), so I was looking for ways to improve it.



Thanks

A series of quads is not a good idea, separate geometries I guess? Look at the ParticleEmitter class and how its done.

Thanks for the emitter pointer normen.



I’ve now jumped up to 400+fps using the same technique :slight_smile:

1 Like

Cool, good to hear.