Hi, I've been running my soft-body physics engine on top of Orx for a while, and my integration so far could be regarded at best as a proof-of-concept. You can see a screenshot of that integration here:
Now that the concept has been proven, I would like to sink my teeth deeper into Orx
Right now, the physics simulation is handled completely detached from Orx; In my main update function, I check the system time, and simulate my world for the duration that has passed since the last update. Additionally, it has no integration with Box2D whatsoever. As far as Orx is concerned, my entire soft-body physics world is an object that does some special rendering through the orxRender_DrawMesh function.
Now, one of the first things I want to do, is to get my soft bodies to play nicely with Box2D bodies. I want them to physically interact, and the two simulation worlds should be in sync (They're out of sync now, since I use the system time to determine how long to simulate). By sync, I also mean that if the simulation can't keep up with real time, the slow-down should be in-sync with the rest of the engine.
As I've said, right now, I'm doing my calculations on the main update function, and I should obviously move them to some kind of physics update handler. I can see that the [Physics] main config section has an entry called "IterationsPerStep". Ideally, I should move my calculations right before each of these iterations, so that I can calculate a force for each Box2D body to be applied during that iteration.
Digging through the source code I could find that the physics update function is registered to this clock:
pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE);
I don't understand which clock this function call returns exactly. Do I have any control over which one that is?
I can see that the orxPhysics_Box2D_Update is registered to this clock with priority orxCLOCK_PRIORITY_LOWER, does that mean I can register my physics update to the same clock with priority LOWEST (or NORMAL) to make sure that it gets called before orxPhysics_Box2D_Update?
I can also see in the source code that the simulation step is called this way:
sstPhysics.poWorld->Step(orxPhysics::sfMaxDT, sstPhysics.u32Iterations, sstPhysics.u32Iterations >> 1);
That means the iterations take place inside Box2D, and that I can't really run anything between them. I can think of two solutions to this:
1. Increase the physics clock frequency 10 folds, so that I can get away with an "IterationsPerStep" value of 1.
2. Find a way to bypass Orx and register a callback to Box2D itself.
What do you think? Am I on the right track? I'd really be glad if you could point me in the right direction.