Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3dxIntersect speed

Started by Mescalito Jan 27, 2003 at 8:30 AM 2 replies 400+ views
Original Post
Mescalito
Mescalito
I was wondering what you think about D3dxIntersect speed. I use this many times in my application and it fucks my fps (3 times for some collisions stuffs and 2 times for camera collision detection) Is there another way of doing this ray casting faster ?
L_dot_N
L_dot_N
Use the Intersect Tri function out of the dx8-dx9 sample. In most cases you need not all the math.
Make a box test first.
Hold the mesh in your own system memory.
If you check only by hit return by the first hit.
Use lod meshes for the test or dummy collison objs.
Make a behind the ray function, to test only in the ray direction.
JoeyBlow2
JoeyBlow2
I had no problems using Ray Intersect Triangle Logic (my own version not the D3D one) and I've had no problems. I assume the one I have and the D3D is the same or very similiar.

Typically, you want to test Intersects in a tree structure "Am I within this area... If so, lets scan only the objects within this area" That way you aren't testing every object/face/box/sphere in the entire level every frame. Try to cut out half the available objects every call. If you have 500 objects in the level, if you can cut out half each iteration, you will save a ton of time... Cut 250 to 128 to 64 to 32 to 16 to 8 to 4 to 2 to 1... You are making 9 intersect calls per frame instead of 500...

Of course it requires you to partition the levels into trees or portals or whatever you use, which can make things more tricky but the payoff is good.

When I did this in my first engine I doubled the FPS. It sounds kinda hard, but when you do it you will find out its much easier than it sounds, and I was like "wow! Cool! This is how the pros do it" and I felt good.

[edited by - JoeyBlow2 on January 27, 2003 9:58:54 PM]
EvilDecl81
EvilDecl81
D3DXIntersect is about as fast as you can make an intersection function for a triangle, however it does not use any spatial data structure. Thus, all intersections are (roughly) on the order of magnitude o(n).

You''ll need to write a spatial data structure system of your own to get good collision speed.
EvilDecl81

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.