Edit Simulation algorithm to allow separate simulation for an actor (Networking feature)

I’m using Unreal Engine, and I need to add a PhysX function to advance the simulation only for an actor. So I need simulate its movement separately from the scene.

My idea
My idea is to add a boolean parameter to PxRigidDynamic that indicate if this actor must be moved or not with the scene simulation.

Then my new function that acept the pointer of PxRigidDynamic and a DeltaTime can simulate only the movement for this actor.

What I done
To do this I’ve checked the code to find out where the simulation algorithm is.
I’ve discovered that the class responsible for the simulation is NpScene with function simulateOrCollide, this function initialize all dispatchers that are managing the execution process, then is called the function executeScene by one of dispatcher init before.
At this point is called the function Scb::Scene::simulate that calls the function Sc::Scene::simulate.

The problem is that the function “Sc::Scene::simulate” call “Sc::Scene::advanceStep” that starts other dispatchers, but where is the real algorithm that perform the movement?

I know the existence of instant API but I prefer to use the scene that UE already created instead of create a new to add this feature.

Have you considered making actors that you don’t want to step kinematic? I’m not sure what the implications of rapidly changing actors between dynamic and kinematic are but I believe in principle it should work.

Yes I’ve thought it, but the problem with it is that all forces applied will be lost, and I want to preserve all forces for when this actor is simulated.

I found in the class Sc::Scene there are some Task classes that are responsible for simulation, now I’m trying understand them because I’ve not found any documentation.

I’m not sure what you’re asking for makes sense. When body X collides with body Y the resulting velocity of body X is going to depend on how much Y moves as a result. If Y can move then X could keep going in the direction it was going but at a lower speed. If Y refuses to move (i.e. is kinematic) then X has to stop or bounce off (depending on restitution). In order to solve the new velocity of X you need to simultaneously solve the velocity of Y. You can assume that Y does not move, as I’ve suggested but this would mean that in general the force your bodies experience would be exaggerated (a property of my original suggestion). You could find out what the force on body X was and apply an equal and opposite force to body Y but I believe the net separating velocity would be more than had you simulated the two bodies together. Fundamentally I think it causes problems having two different dynamics simulations interact because one needs to know a lot about what the other one is doing (or is going to do). If however, one of your simulations is not a physics simulation but rather involves some more oblivious movement (say an animation or external user control) then you don’t have this limitation because effectively body X gets all the force and body Y ignores any force it would experience (due to having effectively infinite mass).

Yes this is true, for this reason I’ve changed the approach and now I’m simulating all scene’s bodies.