vm6502q / OpenRelativity

An open source framework to add the effects of traveling at relativistic speeds to visualizations or games
17 stars 2 forks source link

PhysX tangent space mechanics #56

Closed WrathfulSpatula closed 3 years ago

WrathfulSpatula commented 3 years ago

I'm sure the original OpenRelativity team would recognize that this this fork has had some significant success with co-opting PhysX collision solving, for supporting relativistic collision. The basic assumption is that PhysX already satisfies "rapidity" based mechanics in the local "tangent space."

(By "rapidity," I mean linear integral of proper acceleration, rather than hyperbolic, such that rapidity approaching infinite magnitude limits to a speed-of-light velocity: https://en.wikipedia.org/wiki/Rapidity)

PhysX' assumptions, if "classically mechanical," are those of "rapidity mechanics" "tangent spaces." We should offload "mechanics" simulation to PhysX under this assumption, by a cycle of loading a Rigidbody with quantities transformed to the local tangent space, and transforming back after physics update.

WrathfulSpatula commented 3 years ago

I think all it takes to add this is 50b9c14. (We've been unconsciously driving towards it for a long time.)

This doesn't immediately fully work with RindlerGravity, or maybe very hyper-relativistic scenarios, but it's better than anything we can reinvent redundantly in RelativisticObject, for now.

On FixedUpdate(), a RelativisticObject loads its Rigidbody with appropriately transformed velocity and angular velocity. FixedUpdate() also sets a flag to let the downstream lifecycle know that it expects an immediate internal physics update, by PhysX.

The next available opportunity to (inverse) transform the "rapidity" "tangent space" physics update into RelativisticObject state, downstream in the lifecycle immediately after internal physics update, is in Update(). If Update() sees that FixedUpdate() has set the update flag, (meaning that an internal physics updates has definitely just happened, by the time we've arrived at Update() with the flag set,) then it inversely transforms the PhysX Rigidbody state update back into RelativisticObject state.

If a collision happens, in the meantime, this will happen before Update() in the same cycle; we inverse transform the quantities on collision and clear the physics update flag from FixedUpdate() before we reach Update().

(That's it!)

WrathfulSpatula commented 3 years ago

We still need handling for piw updates via PhysX.