Currently near the work I do for Island at the evening mostly, I m working with the pascal based engine called “CGE” and im trying to port critical render and physics code over to oxygene and write them as modules I can import to fpc (sadly the entire thing has to much LoC and is to heavy to refactor to oxygene and thus I need to make a bridge between fpc and oxygene here (maybe I can use hydra for this?) however, I have encournted that the main dev of CGE uses alot of custom types which are used inconjunction with defered execution which changes rendering and physics state and hence decides what shall be drawn in which state, so he has some code for instance:
TRenderCycle = 0..FrameCount;; //mostly 60FPS
and his code is cluttered (in respective proceudres) with if-else to check if a specific renderCycleCount has been reached (think it was 30 or so…)in asynchronous code, so the physicsengine can kick in and do its part and give controlback to the main-render update loop and so on, and this could be much much easier made with the suggestion @Theo69 gave in that case, since you define only one time in the
TRenderer class that
renderCycleCount <= countToCallIntoPhysicsCycle so this is actually a very neat Idea here. As always, would love to hear from you !
And based on the async state of the physic-engine, it will notify the renderengine when its done to give controlback and there are no other things which shall occur at that time so there is flawless rendering happening as i could see, so the phyiscsengine must get the state_flag from the render() call for it to proceed right after and before, so a flawless rrythmic can occur between render() and collision/mesh checking stuff, and his code kinda uglifies those checks over and over to gurantee a flawless sync between render and collisions and stuff, so I could definitely see a big benefit of this feature