Page 1 of 1

Binding a rotated box.

Posted: Fri Feb 29, 2008 9:15 am
by Falco Girgis
I'm looking into possibilities for checking collision with my physics system. The problem is that everything is a function of time. You're recalculating position every frame based on time, rather than specifically moving the object closer based on its velocity every frame.

I can't make the object stop moving when I detect a collision. Instead, I make it stop when it is INSIDE of a solid, then divide the time that I'm simulating by 2 (binary search) until I've found the frame where it exactly collides and proceed with the collision function.

I really can't just bind things by points like this. I'm going to have to bind boxes against things like rotating boxes. Any suggestions?

Posted: Fri Feb 29, 2008 9:23 am
by Tvspelsfreak
If you need accuracy, representing the box with four line segments is fine.
If you need speed, a circle may do just fine.

Posted: Fri Feb 29, 2008 9:37 am
by Falco Girgis
A circle won't work for something like an odd shaped rectangle. 16x32 or something.

Posted: Fri Feb 29, 2008 9:41 am
by Tvspelsfreak
What do you need it for? If we're talking high speed particles or something you wouldn't really notice any difference with a circle.

Posted: Fri Feb 29, 2008 9:41 am
by Falco Girgis
How do I check collision with line segments? Don't you have to find the slopes of the sides of the rectangle and do some other bullshit?

Posted: Fri Feb 29, 2008 9:42 am
by Falco Girgis
Tvspelsfreak wrote:What do you need it for? If we're talking high speed particles or something you wouldn't really notice any difference with a circle.
It'll make a HUGE difference if there's angular velocity. Something that's longer should be more easily rotated. It'd fuck it up if I were to use a circle.

Posted: Fri Feb 29, 2008 9:44 am
by Tvspelsfreak
True. I'd recommend line segments then. Or multiple circles.

Posted: Fri Feb 29, 2008 9:47 am
by Falco Girgis
Multiple circles may work, yeah. Could you explain how to bind something by line segments?

Posted: Fri Feb 29, 2008 9:48 am
by Falco Girgis
Actually, after some thinking, I'm pretty sure that I know how, but I'd like to hear what you have to say, because it's probably better than what I just thought up.

Posted: Fri Feb 29, 2008 9:52 am
by Tvspelsfreak
By representing each edge of the rectangle by a line segment and then individually checking for collision between them and the map (and other objects). The actual code is messier than box collisions and I don't really feel like looking for my segment vs segment code at the moment.

Posted: Fri Feb 29, 2008 9:59 am
by Falco Girgis
Yeah, it sounds messy. But that's what I'll have to do.

Out of curiosity, the fact that you have segment vs segment means that you've used it. What did you use it for?

Posted: Fri Feb 29, 2008 11:09 am
by Tvspelsfreak
I did some research on collisions for 2D polygonal terrain. Basically swept circles (and points) vs line segments.

Posted: Fri Feb 29, 2008 11:46 am
by Falco Girgis
Ugh. I'll be doing that same research in about 3 hours when I get home. I'm pretty sure that I have everything else figured out.