r/GraphicsProgramming • u/DeltaSucksAtMC • 3d ago
Collision
hey guys ive made a collision detection method, its a cpu intesive method but i got a sense of idea how collisions work
I just get every vertice and get the area then i make 3 triangles from the collision point and get the area of all them then add it, and if the area is equal to the original triangle its colliding, then i get the distance from the triangle's normal and make a if statement if distance is less then 0.001f.
Im getting a lot better, so if yall have any collision method that could be better for smaller concave models that would be great, ive know about aabb for the longest time so i have check that off

If you are giving a method, could you link like anything that could be good to learn it.
2
u/CodyDuncan1260 3d ago
I need a picture drawn to understand what you mean. I suspect this method is equivalent to Minkowski difference.
1
u/DeltaSucksAtMC 3d ago edited 3d ago
Kinda but not really, I use three triangles, both triangle has a point connected to the point where it collides with, so i just get the sum area of them three combine and then I get the actual vertex and get the area of that, do and if statement if the three area is less bigger then 0.001f. But that artical you gave me was very useful and i was actually making it in ms paint earlier lmao, weird how Im way better then before. Also i edited the post so it ives a visual guide to how it works.
1
u/keelanstuart 3d ago
I understand what you are describing... how are you computing the height of the triangles for your area calculations?
1
u/DeltaSucksAtMC 3d ago
Vector3 edge1 = p2 - p1; Vector3 edge2 = p3 - p1; // 1. Unit normal vector Vector3 normal = edge1.Cross(edge2).Normalized(); if (normal == Vector3.Zero) return false; // 2. Signed and absolute distance from 'p' to the triangle's plane float signedDistance = (p - p1).Dot(normal); float distance = Mathf.Abs(signedDistance); Vector3 edge1 = p2 - p1; Vector3 edge2 = p3 - p1; // 1. Unit normal vector Vector3 normal = edge1.Cross(edge2).Normalized(); if (normal == Vector3.Zero) return false; // 2. Signed and absolute distance from 'p' to the triangle's plane float signedDistance = (p - p1).Dot(normal); float distance = Mathf.Abs(signedDistance);ok so i did use a LLM for one part and its lik confusing math but im pretty sure it can be used for other stuff but here it is, this is how i get the normal or distance between the triangle and point, mainly used for 3D, 2D dosent need it, i I did watch a tutorial on how this works but he didnt describe how to make it so I tried and tried but the math formula was too much, im not the best at math. So I ask an LLM to give me a better explanation.
1
u/keelanstuart 2d ago
Well, you obviously didn't post all of it there, but that's the beginning of "traditional" ray/triangle intersection tests... make sure the triangle isn't degenerate, get the triangle normal, get the edge normals, compute dot products of edge normals and vertex-to-planar-intersection-point and look at their signs.
1
•
u/AutoModerator 3d ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
No showcases.
Disclose AI usage in post or project.
Present a topic to talk about, e.g. how something works.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.