16

Ken's answer notes: The 9 axes are made up of cross products of edges of A and edges of B It's somewhat confusing to refer to the edges, as there are 12 edges compared to 6 normals, when you might as well use the three main normals for the very same output - the edges are all aligned with the normals, so I recommend using them instead! Also note that ...


5

The "velocity vector" is the difference between the velocities of the two objects. When colliding with a static (unmoving) object (such as the level), the "velocity vector" is indeed its current velocity. Normally, the collision surface's direction will be represented by a "normal" -- a vector of length 1 that points in the direction the surface is facing. ...


4

working c# example based on Acegikmo's answer (using some unity api's): using UnityEngine; public class ObbTest : MonoBehaviour { public Transform A; public Transform B; void Start() { Debug.Log(Intersects(ToObb(A), ToObb(B))); } static Obb ToObb(Transform t) { return new Obb(t.position, t.localScale, t.rotation); } class Obb { ...


3

Doing the overlap like that assumes the order of the overlaps. If you instead try to find the smallest min and the biggest max and then compare those it should work; bool overlap(const vec2& b) { double minA; double maxA; double minB; double maxB; if (x < b.x) { minA = x; maxA = y; minB = b.x; maxB ...


3

On line 161 you return too early from FlattenPoints. Move the return statement outside of the for loop and everything appears to work correctly.


3

If you already have SAT working, then you can pretty easily extrude an OBB along its linear velocity for a frame (i.e. create a swept OBB). The result will be a polyhedron, so you can use SAT with it. This only handles linear velocity, though, not rotational velocity. That's quite a bit harder because a rotating OBB sweeps out a volume that isn't a ...


3

I am happy to say that I have squashed the bug. The visualisations really aided me and I strongly recommend anybody struggling with anything to try and get whatever it is your working on onto the screen. Now for how I fixed the bug and what it was. The reason it was not properly setting the min and max projections is due to the ProjectOntoAxes method. For ...


3

The key to any optimisation, is identifying where the bulk of the work is being done. A simple analysis of your problem reveals the following: A cuboid shape has 8 vertices, three perpendicular axes, and a position. The same cuboid can be rotated around any of these axes. At the moment, your algorithm is transforming the vertices, then presumably ...


2

I ended up implementing an AABB/Line Segment collision just to test if it would also have these issues, and i ended up figuring out the problem. It was an issue with my collision resolution. When the AABB was resting on the corner of an OBB or on the top-most point of a line segment, it was resolving the Y resolution amount using the formula for the line, ...


2

Ideally, you don't build your environment out of polygons. You build it out of edges (which perhaps you calculate from a set of polygons). In your first example, for instance, there is a single diagonal edge; in the last example, the box is resting on a single horizontal edge. The fact that your editor or tools use smaller, individual shapes to build a ...


2

When you take two edges on two polyhedra you don't know if they form a face on the Minkowski difference. Only feature pairs that form a face can be a potential axis of separation. Since this information is unknown you must naively test all edges against all edges. This means a supporting point must be computed for each cross product axis since it is not ...


2

Common, easy but ultimately wrong answer Iterate along the vector in very small increments. Eventually they'll de-penetrate at a "reasonable" position, assuming you continue any additional constraints at each iteration. It's brute force, and for something simple, it's good enough. You will almost certainly need to add artificial max/min force limiters to ...


2

Quoting the answer to the linked question, the axes you need to test are: 3 axes from object A (face normals) 3 axes from object B (face normals) 9 axes from all the pairs of edges of A and edges of B (3x3) =15 in total Emphasis added. The black arrow formed in the diagram above is generated by the cross product of a pair of edges: the vertical edge of ...


2

If you seperate along the Minimum Translation Vector, you could be getting some very jerky behaviour. I think you should do your projection backwards along the movement path, which lead to the collision. Then you can resolve your collision physics (change of movement direction ...) and move the object that collided the rest of it's new movement for the ...


2

I forgot to come back to this question when I arrived at an answer, but this has gotten a decent amount of views over time, so better late (even 2 years late) than never! First, prerequisites: Prerequisites: First, one has to be able to calculate the time of collision (TOC) of two circles. Step 3 of this question Small, High-Speed Object Collisions: ...


2

I think I found an answer for my question by using SAT algorithm only. Of course I'm completely ignoring tunneling effects. Let's say we have shapes A and B. Shape B penetrated shape A. We know old position of shape B (before the collision). We already did some collision test (SAT) and we know that the collision between shapes A and B exists. Let's draw an ...


1

Figured it out thanks to @DMGregory 's comment. The slanted axis in the picture shouldn't be there. The axes should be parallel to the normal of each side of both shapes, not perpendicular. This idea goes the same for any 2D convex polygon. grey lines are the separating axes of this triangle and are also normal to the sides of the triangle, as indicated by ...


1

When you know there's a collision, you can just use an arbitary axis (e.g. (0, 1) if you want to separate them upwards), then project the points onto this axis. The distance you need to move the objects to separate them in this direction is the overlap between the projections.


1

Not completely sure if this answer is 100% correct, but i can't comment yet :/ First a question, is it completely necesary to have objects get inside another object and then pushing it out? What i mean is, maybe you can avoid movement in a certain direction in case there is "going to be" a collision. im not sure how modern engines handle collisions, but ...


1

I will assume this question is about 3D SAT which I find has alot less resources than 2D.. I have been struggling with this for the past week. I have face contacts down but not Edge cases. When you are testing your various axes keep track of which has the minimum overlap, that is your contact normal and penetration depth. Contact points are where it gets ...


1

I did some reading on this, and in the book Game Physics Pearls, the following is stated: Edge-Edge (EE) is a degenerate case if the edges are parallel. Degenerate EE is the special case of either Edge-Vertex (EV) or Vertex-Edge (VE), which in turn may be a case of Vertex-Vertex(VV). We can just skip and ignore all special cases for the purposes of ...


1

Why can we immediately say that the projections intersect, when there is a zero vector as projection axis? Intuitively, the zero vector has no direction, and so can't be used to determine a line on which to project your vertices. The zero vector in this case could be thought of as a single point, and obviously the projection of anything on to that single ...


1

I now managed to solve the problem by myself. I changed my data structure, so that the normals are saved separately. When initializing the cuboid, I know what vertices belong to which surface. I then just take three vertices (namely p_1, p_2, p_3) of one surface (for example the surface which faces to positive x). The three vertices form a triangle on the ...


1

My collision detection + reflection works just fine (see here). First you need a boundary box as you will have this already implemented. Boundary boxes are generally vertices having each in 2D an X and Y coordinate which define the outer structure of an object. To generally calculate the angle of a boundary, I use in C++ an atan function, which returns the ...


1

The Minimum Translation Vector is the collision normal most of the time. However, I believe that without velocity information it is impossible to get the collision normal correct all the time. Consider that you have 2 aabbs colliding. One aabb is stationary. In one case, the other aabb moves from the left and hits the first aabb. The correct collision ...


1

Your normals are supposed to be the face normals of a polygon. If your vertices are an oriented array in counter clockwise order, then you can easily compute the normal of a face by a 90 degree rotation. So if we have an edge on a polygon made of the vertices a and b, we know that the edge is oriented from a to b going around the polygon in CCW order. To ...


1

The supporting point is the point that lies at the penetration depth. If you already have working SAT then you've already used the supporting point as otherwise you'd have no way to find penetration depth for OBBs. The supporting point might be buried or abstracted by the specific implementation of SAT you're using, though (if you derive from basics, you'll ...


1

Consistency is crucial for smooth collision detection. I recommend using the bottom center point for rectangular collision as well as slope collision when colliding against the ground. For colliding against walls, you can use points that are in the center left and center right of your sprite. Another way to think of it is as though your sprite has a ...


1

The problem with your image is that the green box is first rotated then stretched. With no rotation, this gives the correct rectangle, but then it fails. Anyway, I don't think you understood clearly how the algorithm works. The algorithm consists to check whether the projection on an axis of the two shapes intersects, for each axis of a nicely selected set ...


1

AFAIK Seperating Axes is only for detecting overlap, it can't be used to determine closest points in non-overlapping cases.


Only top voted, non community-wiki answers of a minimum length are eligible