#collision detection between two meshes
35 messages · Page 1 of 1 (latest)
Like intersections?
I think there are raycasts and collision or if the shape is a sphere you can use distance and the radius of the sphere
I am looking if a general why if checking for collisions between any meshes
Ok, I haven't made a deep search because I am not at home but for what I know, raylib does not have intersections detection, you will have to implement that on your own.
A quick search gave me this: https://stackoverflow.com/questions/4831216/set-of-efficient-3d-intersection-algorithms
Correct me if I am wrong
You aren’t wrong, but I still need a solution 🙃
Let me see if I can find some reference code in ursina engine
One way that I thought to do that with is by checking each triangle in both meshes for collisions
Yeah, intersection is a really slow algorithm
Well, it seems that the new unreal engine is able to preform interactions between 8 million triangles in real time
p.s. I know that raylib isn’t a game engine neither does unreal is open source
I couldn't find any references. I will try find them when I get home
Ok, thanks
For the mesh you have the GetMeshBoundingBox function, and then you have the function for boundingbox intersection
but for complex mesh and if you want pretty accurate collisions it won't work
then you have GetRayCollisionMesh, or GetRayCollisionTriangle
but as Lixt said it's pretty heavy
mesh mesh intersections are slow and complicated
in general games try not to use meshes when possible, but simpler mathamatical volumes, boxes, cylinders, and capsules.
Yeah, that is true
For example, in a game I made I had trees with thousands of polygons and I wanted to add a collider so I can use raycasts, the true was my game droped from 60fps to 5, so I used a cube as the collider and my game got back to 60 fps (I had ~100 trees)
yeah, for like a tree, I'd use a cylinder
cylinders are easy to test against
and smoother for collisions, since you can slide arround them.
Yes, exactly
On top of that, games don't immediately go for the complicated collision checks, they'll usually have a broad phase check first (eg. Aabb) to see if a collision is even possible
Well that and using things like quad trees to only check stuff that's near the object
Yeah
yeah, octree, then AABB, maybe sphere, then you go ito the detailed checks