Rajveer 250 Report post Posted March 8, 2008 Which is generally quicker to sweep test against a triangle, an OBB or an ellipse? Looking at the ellipse article http://www.gamedev.net/reference/articles/article2426.asp, there seems to be alot of computation, so are OBBs generally quicker? (For some reason I can't find any continuous OBB vs static triangle resources) [Edited by - Rajveer on March 8, 2008 8:00:39 PM] 0 Share this post Link to post Share on other sites
Rajveer 250 Report post Posted March 9, 2008 Ok, I'm going to try to implement a continuous OBB-Triangle test. I know how to use the SAT for static OBBs vs tris but what about swept ones? Sweeping an OBB creates another shape of at most 12-sides, am I supposed to use the SAT with this shape or am I thinking about it wrong? 0 Share this post Link to post Share on other sites
Rajveer 250 Report post Posted March 9, 2008 I think I know what to do, for each possible separating axis I would project the triangle as usual, and then project the obb both before and after movement and combine its 2 ranges, then continue as usual right. But what if I want the deepest intersection depth so I can move the OBB that amount along the triangle's normal? 0 Share this post Link to post Share on other sites
jyk 2094 Report post Posted March 9, 2008 Quote:Original post by RajveerI think I know what to do, for each possible separating axis I would project the triangle as usual, and then project the obb both before and after movement and combine its 2 ranges, then continue as usual right. But what if I want the deepest intersection depth so I can move the OBB that amount along the triangle's normal?The typical way to do this is to use the same axes and projections as in the static test, but perform swept rather than static interval-interval tests. Each interval test yields a 'first' and 'last' time of intersection. As you perform the tests, you track the greatest of the 'first times' and the least of the 'last times'; the interval you're left with tells you if and when an intersection occurred.It's a bit complicated to explain in a forum post (it's also a bit tricky to implement correctly). I'd recommend checking out Dave Eberly's articles and code at geometrictools.com, or taking a look at oliii's tutorials. (You might also consider whether it would be easier just to use a preexisting collision detection or physics package.) 0 Share this post Link to post Share on other sites
Rajveer 250 Report post Posted March 9, 2008 When you say sweeping the interval test, do you mean projecting the OBB's current and future positions onto whichever axis I'm testing and combining their ranges?Also, how is time calculated? For example say I'm testing in the triangle's plane:- Project the triangle onto the normal, store triRange.min and triRange.max- Project the current OBB onto the normal- Project the future OBB onto the normal- Find min and max of both OBB ranges, store as OBBRange.min and OBBRange.max- Compare triRange and OBBRange, if no overlap then intersectedwhere would time of collision come in? 0 Share this post Link to post Share on other sites
Rajveer 250 Report post Posted March 10, 2008 I think I've nearly nailed the algorithm, all I'm having trouble with is calculating the time to first collision so I can actually position the OBB next to the triangle (time to last isn't important to me, unless I need to use it somehow without realising it!)I think I also may have misunderstood you, can you explain how to calculate the intersection time/distance? I've drawn a (crappy) diagram showing what I'm doing, this shows the projection onto the triangle's normal axis. In this projection, the time to collision would be the initial OBBs minimum range - the maximum (or minimum, either in this case) range of the triangle. However this isn't always the case for other axes, so what am I doing wrong? What about the case where the range of the triangle is larger than both OBB ranges?<br/>[Edited by - Rajveer on March 11, 2008 9:18:08 AM] 0 Share this post Link to post Share on other sites