KSPWheel icon indicating copy to clipboard operation
KSPWheel copied to clipboard

TODO - Integration has room for improvement

Open shadowmage45 opened this issue 8 years ago • 1 comments

  • Currently using basic euler integration. Need to swap to some derivative based integration.
    • Pass in the vessel mass and COM into the integration code, use that to extrapolate positions for derivatives/substeps
      • treat entire craft as a single rigidbody for interpolated/extrapolated states, it should be at least close enough to correct for the duration being simulated, especially with the improvements to the base integration code
    • --how to handle changes in suspension compression from attitude changes or terrain changes that would happen in the substeps?
      • assume a single plane exists with surface-normal of the base raycast hit normal, use that plane for suspension interpolation data
    • -- how to accomodate changes to integration across multiple wheels on the same craft?
      • have the integrator simulate at the vessel level as for as rigidbody sub-integration
      • requires the wheel-collider integration code be aware of 'wheel body groups' and have customizable rigidbody com, mass, and ternsor data
      • could result in a fairly accurate simulation if handled properly, with potentially very little overhead cost (and would be much more efficient than if done on a per-wheel basis even at the worst case)

shadowmage45 avatar Jan 14 '17 23:01 shadowmage45

Even without the ability to rework the physics, it seems that the current setup could still benefit from some form of multi-step integration for the spring and friction calculations.

  • Given two states, at distinct points in time (A, B),
    • Two measurable values at each point - compression distance, surface position
    • Two deduced values - compression velocity, surface velocity
  • The spring/damper and friction forces should represent the sum of forces across the interval in time as if it were not quantized, not the forces at a single point in time.
  • Unsure on how to implement.
    • A simple 50/50 interpolation might be slightly more accurate, but seems like it would only add 1/2 frame of delay to everything; this could easily be accomplished by caching the last frames output data, combining with current frames calculations.
      • The 'delay' might actually be a good thing as it may smooth out acceleration/grip problems.

shadowmage45 avatar Sep 01 '17 01:09 shadowmage45