ID:1893123
 
(See the best response by Ter13.)
Hello!

I was just trying things out in dream maker, trying to learn new things, and I've gotten stuck in this one problem:
- Rotating and creating dynamic bounds

I've gotten the icons to rotate around well with the matrix, but... the boundary was a difficult question for me.

For example, if I have a box (upright box (32x32)) and rotate it at a 45 degree angle, the icon itself rotates, but the boundary still remains as the upright box instead of the 45-tilted box.

Is there a built-in process to accomplish this task? If not, could you guys give me a general direction on how to approach this?

Thanks!
Best response
Nope. BYOND only supports AABBs (Axis-Aligned Bounding Boxes). If you want OBB (Oriented Bounding Boxes), you gotta do it yourself.
At present all bounding boxes are rectangular and axis-aligned as Ter said. When we implemented bounds, a little bit of wiggle room was introduced so we could support more formats in the future (e.g. circular bounds), but right now they're still limited to their original form.

atom.transform is visual-only.
The most solid method of OBB square collision is basically just taking two opposite corners of the box, getting the angular spread of each corner, testing that against the relative angle to whatever object you're looking for a collision in and seeing if any of the corners of that bounding box cross into the area. If so, collision happens. The downside to this is that you need to do the test both ways, because it's possible for one object to not detect a collision this way, but for the other one to.

Not sure if that description was specific enough to get the picture, but that's my visualization.
There's a technique that I like a little more, Kats.

Basically, what you do is you test for AABB collision. If you have AABB collision, you then go into a second test which projects parallel vertices from both objects onto a single line perpendicular to the direction of motion. If any of the vertices of the two objects are inside of each other, you have a potential collision. You then take and project the perpendicular vertices onto a single line parallel to the direction of motion. If you have any vertices inside of one another in this approach, you have a definite collision.

I like this method because there's a lot of chances for early ejection and it's pretty accurate for convex hulls.
In response to Ter13
Vector collisions were always the bane of my existence. The angular testing I was able to figure out on a piece of scratch paper at work one day, lol, still trying to be a smarter person.
So what Kats is saying... If I understood it correctly,
First take the angle of the opposing vertice of the hurtbox that I want to use. Then take the angle between center of the two. Then compare it to see if the angle we found between center is within the angle of the vertice? Then I guess I can check the distance between two centers to adjust the hurtbox's length...

I'm not sure if I got it right, though.

I'm still trying to understand what Ter has written.

Am I correct on this:

Take parallel vertices frm both objects, and put them on a parallel/perpendicular line of motion. Then compare the sets with another to see if any of them lie within another.

Ugh, I'm not too bright with numbers... More of humanities guy, haha.
Probably best to ignore what I wrote. It's... A bit dwarven.
I think Kats is describing the method used by Hobnob in his Spacewar demo, explained at the end of his article, Pointing the Way to Vectors.

I think Ter is describing the Separating Axis Theorem, which you can find plenty of info about through Google.
Not sure, this is an example of the method I like to use:


The black angles are the angles of the corners and the red angles are the absolute vector angles of each corner, note the compass in the lower corner for reference. We'll call this angular spread for each corner the FoV.

The red dots are the corners that test each vertex to check for collision. All vertices are tested against, though, not just the red ones.

Basically I just test if any of the vertices of a hitbox are within the FoV's of both corners of the other. If the tested vertex is not within both FoV's at the same time, no collision is possible, if it is, then you have a collision. As soon as one vertex returns with a collision, you don't really have to do any more tests.

I just use vector angles because those are easier to calculate by for me. It was a bit of a quick example, but I hope it was a little clearer.

EDIT: OR, if your project works the same without it, you can always do circular hitbox calculations. That's always less of a headache than rotated bounding box collisions.
In response to Kats
Yeah, that's the method Hobnob uses, but his is generalized for convex polygons with any number of vertices. Your angular spreads are the angles between the two adjacent vertices. And rather than using like, atan2 to get relative angles, you can use a vector dot and/or cross product.