-
Notifications
You must be signed in to change notification settings - Fork 250
Fast intersection queries #1590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fast intersection queries #1590
Conversation
Basically creates an addon with an acceleration structure with a bounding volume hierarchy so only a subset of triangles need to undergo intersection testing.
It turns out that modern C++ compilers really don't want to vectorise this loop like a shader compiler would. vsg::vec3 being a struct apparently upsets them, even when it's only used within the function, so an array of vec3s could be rearranged to three arrays of components.
Switching to float makes things a bit faster, but made some intersections go undetected with my test data, so I'm not switching.
A lot of time during intersector traversal is spent doing allocations and deallocations. This can be avoided by just reusing the existing allocations. The easiest way to do that is to reuse the thing that owns the allocations. Helpfully, just resizing a vector doesn't throw away its existing allocation, as usually a vector is used for things about the same size as the last time they were used. This doesn't totally remove all allocations - the array state stack has vectors of matrices in each element, so when elements are removed, those are destroyed and reallocated the next frame, and the intersection vector also has node paths etc. in each element. Eliminating these would be more challenging. With the test data I've tried, and using the accelerated IntersectionOptimizedVertexDraw class, reusing the same LineSegmentIntersector instance with this change knocks about 15% off the time to do a lot of intersection queries. 20% of the time is still spent doing allocations and deallocations, though.
@AnyOldName3 I'm back to work now so working through my inbox. I've generated a test PR from your repo's fast-intersection-queries branch but the automated build is failing on the Install VulkanSDK step. I presume this means github have changed what SDK is available. Have you come across discussion & resolution of this issue? |
I think it's going to want pretty much exactly the same fix as a year ago: https://github.com/vsg-dev/VulkanSceneGraph/pull/1306/files. We can switch to the 1.2 release of humbletim/install-vulkan-sdk now that the commit we need for MacOS has made it to a tagged release, so it's slightly tidier than last time. As LunarG/Kronos are going to keep removing the download links for obsolete VulkanSDK versions, it might make sense just to not pass a specific version number for the VulkanSDK and let the script install whatever's the latest available when it runs. |
No description provided.