#collision detection between two meshes

35 messages · Page 1 of 1 (latest)

keen gorge
#

Does raylib have a way to get/detect the collision between two meshes?
If not, what is the general way 3d games in raylib get/detect collision between two meshes?

chrome falcon
#

Like intersections?

keen gorge
#

Yeah

#

Or just to check if there was an collision

chrome falcon
#

I think there are raycasts and collision or if the shape is a sphere you can use distance and the radius of the sphere

keen gorge
#

I am looking if a general why if checking for collisions between any meshes

chrome falcon
#

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

keen gorge
#

You aren’t wrong, but I still need a solution 🙃

chrome falcon
#

Let me see if I can find some reference code in ursina engine

keen gorge
#

One way that I thought to do that with is by checking each triangle in both meshes for collisions

chrome falcon
#

Yeah, intersection is a really slow algorithm

keen gorge
#

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

chrome falcon
#

I couldn't find any references. I will try find them when I get home

keen gorge
#

Ok, thanks

atomic mauve
#

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

lone crow
#

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.

keen gorge
#

Ok

#

Thanks all

chrome falcon
lone crow
#

that's a site that has a matrix of X vs Y intersection articles

chrome falcon
#

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)

lone crow
#

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.

chrome falcon
#

Yes, exactly

grand vault
#

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

chrome falcon
#

Yeah

lone crow
#

yeah, octree, then AABB, maybe sphere, then you go ito the detailed checks