kenny wrote:I read the paper, nice work:-) I do have a few questions/remarks:
Using an event driven scheme, would the usage of sequential collision response (I got the impression when reading the paper, that this is what you use) cause problems when configurations with infinite sequences are encountered?
Well, our broad phase allows interleaving sequential collision response with broad phase events. The result is that configurations with such infinite sequences wouldn't hurt Kinetic Sweep and Prune per se. I think the bottleneck in these situations is in the pair-wise testing and response. I'll make no claims that our method for collision response is great; our focus was on the broad phase.
kenny wrote:
Have you done any testing with dense structured stacks or random piles? All your test configuration appears to be very dynamic (everything is moving around).
Yeah it seems to be a popular description for scenes to test broad phases. I am interested in hearing of other possibly better scenes which push the bounds of broad phase methods. By definition this requires many objects to be moving on their own paths. A scene with mostly static objects is simple to prune after initial steps, as it probably won't incur worst-case behavior in any scheme.
kenny wrote:
In the paper you did mention something about bounds to handle ``noise'', I think this is similar, perhaps you could elaborate a bit about this?
Certainly. Lets imagine an object infinitely bouncing between two other very close objects, quickly enough that it occurs over 1000 times/second. At least from the broad phase's perspective, this object's motion can be bounded pretty well. For resolving all of the intersection tests and responses I'm afraid all I can suggest is to search through the other literature on it. For the broad phase, however, consider first a case with the other two objects immobile (e.g., walls). The motion of the object in between has a hard bound. If one wall ends at 3.0 and the other starts at 3.5, and the object is a ball with radius 0.4, it only has room to move back and forth by 0.1. In such a tight case it'd be wise to set the bounds of the motion to 3.0 and 3.5. If these walls were moving along instead of static, again keeping the ball bouncing infinitely between them, then on average, the ball's velocity would share the walls' velocities. To hopefully wrap up this long-winded response, the traditional way for sweep and prune to absorb noise is to just expand bounding volumes. The approach more suited to KSP is that when a pair of values in the lists keep swapping too frequently, then a compromise needs to be made: a shared motion that reduces the frequency of the swapping, acknowledging that a particular pair of boxes will frequently start and stop overlapping so just let them stay overlapped. In essence this is maintaining a contact. These are suggestions for handling noise, but perhaps the subject for further study.
kenny wrote:
If you did not use the spherical-AABB approximation, but used tight AABBs taking the rotational motion into account, how would you then determine the velocities of the extrema?
Take a look at this image from wikipedia, noting the sine and triangle waveforms:

In 1D, rotations turn into functions of sine and/or cosine. With rotation and velocity, an extrema's 1D motion x(t) with rotation would be:
x(t) = x_0 + v_x * t + sin(theta(t)),
where theta(t) is the object's angle also as a function of time.
Frankly, there is no closed form solution to intersecting two such x(t) functions, so (relatively slow) numerical solvers are usually used. Instead, imagine if you will, placing the triangle wave above the sine wave so that it intersects tangentially only but always stays above the sine wave.
Replacing the sine wave, we get:
x(t) = x_0 + v_x * t + tri_wave(theta(t)),
Since the tri_wave is piece-wise linear, now we have a closed form solution that we can apply. The triangle wave is just one of many possible wave forms you could use to 'cap' the sine wave, each with its own trade-off in tightness vs cost of finding intersections.
kenny wrote:
Also in a multiplayer setting I would imagine that every object in the configuration would constantly change acceleration/velocities, requiring updates of the kinetic sorted lists, I was wondering what kind of impact this has on performance?
Each time an element's motion in a kinetic sorted list changes there can be O(log n) cost, depending on the data structure you use for scheduling. This cost is a trade-off. Instead of an O(n) update cost (updating all moving objects' positions every time-step), we have an O(log n) cost for each time an object changes its "motion". When would this theoretically be worse? Well, constant factors aside, if less than O(n / log n) objects changed their motion within a given time period, our method would be asymptotically faster. For example, a ballistic object, just following physics laws like gravity, the motion changes are infrequent. Once in air, its affected by a constant acceleration. Even though its velocity changes continuously, its "motion" can be described as a function of time. It is when this function is changed arbitrarily that we incur the motion change cost. However, users are less predictable, but in most cases more limited in quantity than predictable objects. Of course, if acceleration were to change continuously for the scene, say... gravity were in the process of reversing(?), then you could just use an even higher order of motion and account for the continuous change in acceleration.
kenny wrote:
I have used priority queues to in the past for making an event-driven approach, what I found to be the downside was the constant heapify operations that need to be performed. These were way to expensive (for my usage:-). Do you have some magical workaround for this issue?
Nothing magical about it, but the choice of data structure is Critical! We use auxiliary two-pass pairing heaps. They're a bit tricky, but very cheap and have great amortized costs.
kenny wrote:
You do mention that you need O(n^2) storage for keeping track of axis overlaps (close counters). I am curious about what data structure you decided to use for this?
I wouldn't say "need". Technically any sweep and prune method can get away without storing any axis overlaps, by testing for overlaps on other axes whenever a new overlap occurs on one axis. This is expensive so the trade-off of extra memory is worthwhile. We use a lower-triangular matrix M of integers, such that if M[i,j] = 0 then the bounding volumes of objects i and j overlap. M[i,j] = 1,2,3 means that 1,2,3 axes do not overlap, respectively. We use this method since it easily scales to more than 3 axes as would be nice for k-DOPs.
kenny wrote:
As a side-note I would like to mention that I gave up on the ordinary sweep and prune years ago. It was too slow! I usually have 1000 primitive objects, which means the pair-testing is cheap and broad-phase is the bottleneck.
The studies I've read comparing S&P to other broad phase methods have shown that S&P is relatively more expensive but performs superior in terms of pruning. Whether the broad-phase expense is justified depends on how complex the objects are and how expensive each pair-wise test is.
kenny wrote:
Today I use optimized spatial hashing with a few tweaks of my own. Although this is a ``pseudo-dynamic'' approach I have very low constants compared to sweep and prune, and I do not need the O(n^2) storage for close counters. In my case a query with 1000 objects in dense configuration usually takes less than 0.01 seconds using optimized spatial hashing. It is a bit unclear to me if kinetic sweep and prune would be more expensive or more efficient for my usage?
Again, it depends on your objects' complexities and how expensive pair-wise tests are. I will say that one problem with spatial hashing (I presume this is space partitioning into cells) is the issue of cell-sizes. Also, there are costs associated with entering and leaving cells in such a way that I find S&P usually handles scenes with fast-moving objects better, where spatial subdivision works great for scenes with slow-movers. I'm also aware that there are differences in terms of scene density (how spaced objects are). S&P seems to gracefully handle density changes too. I've only seen one adaptive spatial subdivision scheme that changed cell sizes, but it was an expensive operation.