Does anybody know how optimized D3DXIntersect method is? Is there any sense to create own intersection test algorithm?
#2 Members - Reputation: 1989
Posted 28 December 2012 - 06:55 AM
The actual functionality of the intersection calculation is fairly well optimized, though.
If you can make assumptions about the spatial partitioning of the mesh, you can probably write a better function yourself. The basic logic (assuming nothing about the geometry) is as follows:
Let "intersections" be an empty list of triangle indices and distances from the origin of the probe ray
Let "mindist" be a float that is initialized to maximum value of float
Let "mintri" be an index of the nearest found triangle so far
For each triangle in mesh
Check for intersection between ray and current triangle
If (ray intersects triangle)
{
store current triangle index and intersection distance to "intersections" collection
if (mindist is larger than current intersection distance)
{
set mindist = current intersection distance
set mintri = current triangle
}
}
return interections, mindist and mintri; each are potentially empty or unchanged, if intesections were not found
Edited by Nik02, 28 December 2012 - 06:57 AM.
Software developer
#3 Crossbones+ - Reputation: 5155
Posted 28 December 2012 - 06:57 AM
Is there any sense to create own intersection test algorithm?Yes. By creating your own you are not tied to the D3DX library.
Reason enough for me.
L. Spiro
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums
#4 Members - Reputation: 1989
Posted 28 December 2012 - 07:02 AM
Edited by Nik02, 28 December 2012 - 07:04 AM.
Software developer
#5 Members - Reputation: 131
Posted 28 December 2012 - 02:12 PM
Is there any sense to create own intersection test algorithm?Yes. By creating your own you are not tied to the D3DX library.
Reason enough for me.
L. Spiro
Yes, but sometimes using time to unnecessary optimization is bad considering the project schedule. Or if I'm very smart, I could say bad for the ROI ;)
I try to find reasons why to do or not to do my own test algorithm. If common opinion is, that the DX algorithm suxs, then it's probably smart to create own at very beginning because you have to do it anyway. If the common opinion is, that weel it's ok, then I think I'll stick with it and perhaps create it, if the algorithm seems to be bottle neck.
#6 Members - Reputation: 131
Posted 28 December 2012 - 02:14 PM
Nice answers Nik02. I'll have to consider those options.






