#๐Ÿ”’ Physics calcs: best practices for order-of-operations?

4 messages ยท Page 1 of 1 (latest)

proud wind
#

not a question about a specific bit of code here, but I'm redoing my rough draft of a "billiards" style physics engine and was wondering if there was established convention for these questions;

  1. Starting with the simpler question: per tick, I'm applying any external accelerations (User input), applying friction, resolving collisions, then rendering.
  • Does it matter what order I do that in? Like, should I be applying friction first to the initial reference frame and calculate the rest after? Or should I do all my calculations and then apply friction after?
  1. When resolving collisions, I'm taking these steps;
    -For any moving objects in the queue, "stretch" their hitbox/collider by their velocity vector.
    -For any overlapping colliders, calculate the earliest possible collision time - as a percentage of a "tick", and sort the list of colliders lo->hi.
    -For each collision in colliders:
    -> move both objects forward in time to the point of collision, subtracting the amount moved from their available velocity.
    -> calculate the reflected vectors and update their collider with the remaining velocity.
    -> Check if the new collider(s) overlaps any existing colliders - if so, calc time-of-collide, and return it sorted into to the queue.

this should loop through until all objects have used up all of their velocity or are no longer colliding with anything, and then update their position after.

I guess my question is.... Is that actually a good approach to take? I'm trying to make it so that even objects moving at arbitrarily fast speeds can't clip through each other, but It's a struggle to stop them from being "sticky". Is there a more efficient approach that I'm overlooking?

clever valeBOT
#

@proud wind

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

clever valeBOT
#

@proud wind

Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.