mardi 24 juillet 2018

Physics Object Double Buffering

I've been working on a little game in python using a (very) basic physics engine I wrote. The original physics code was rushed, and so I've been cleaning it up and trying to make it less terrible. Here's the problem:

I wanted to make the collision detection (using SAT algorithm) decoupled from the collision response by having physics objects store their collision response function in a variable, which allows for different objects to behave as triggers, solid objects, force fields, etc. In doing this I had to make the response consist of two method calls (one for each object in a collision) which means that one call happens after the other. This causes problems because the changes to one object have an impact on the other object's response to the collision.

I've read about double buffering being used in displaying images and thought that it might be able to be used to solve this by buffering all changes to each object somehow and applying them after they have all been calculated. I've been having trouble coming up with a clean and flexible way of doing this. Does anyone know of a good way to deal with this non-simultaneous collision response?

(sorry if this is a wordy question, I felt that the background was required to make it clear what I was trying to do)

Aucun commentaire:

Enregistrer un commentaire