Skip to main content

A small bounding volume hierarchy implementation

Project description

LBVH

An implementation of the LBVH algorithm for performing fast bounding-box intersections. NVIDIA has a great series of blog posts that describes, in detail, the algorithm for LBVH construction/traversal:

  1. https://developer.nvidia.com/blog/thinking-parallel-part-i-collision-detection-gpu/
  2. https://developer.nvidia.com/blog/thinking-parallel-part-ii-tree-traversal-gpu/
  3. https://developer.nvidia.com/blog/thinking-parallel-part-iii-tree-construction-gpu/

This repo's implementation is CPU-only for now, but it does include python and Mathematica bindings.

Python

Precompiled binaries are available for many versions of python on mac, linux and windows. To install python bindings for use with jax or numpy, do

pip3 install lbvh

The python bindings expect arrays of bounding boxes to be specified in one of the following formats:

# list of 2D bounding boxes, as arrays with shape (*, 4)
[[min_x, min_y, max_x, max_y], ... ]

# list of 2D bounding boxes, as arrays with shape (*, 2, 2)
[[[min_x, min_y], [max_x, max_y]], ... ]

# list of 3D bounding boxes, as arrays with shape (*, 6)
[[min_x, min_y, min_z, max_x, max_y, max_z], ... ]

# list of 3D bounding boxes, as arrays with shape (*, 2, 3)
[[[min_x, min_y, min_z], [max_x, max_y, max_z]], ... ]

See https://github.com/samuelpmish/LBVH/tree/main/python for some basic examples of bounding box queries.

C++

To build from source:

1. clone the repo

git clone git@github.com:samuelpmish/LBVH.git

2. configure CMake

cd LBVH
cmake . -Bbuild -DCMAKE_BUILD_TYPE=Release 

This project has a few (off by default) configure arguments that control which targets get built, including

  • LBVH_ENABLE_PYTHON_BINDINGS
  • LBVH_ENABLE_MATHEMATICA_BINDINGS
  • LBVH_ENABLE_TESTS

3. build

cmake --build build

To use LBVH in another CMake project, you can use FetchContent to automatically build it along with the parent CMake project

...

# fetch and build LBVH
include(FetchContent)
FetchContent_Declare(
  LBVH
  GIT_REPOSITORY https://github.com/samuelpmish/LBVH.git
  GIT_TAG main
)
set(LBVH_ENABLE_PYTHON_BINDINGS OFF CACHE INTERNAL "")
set(LBVH_ENABLE_MATHEMATICA_BINDINGS OFF CACHE INTERNAL "")
set(LBVH_ENABLE_TESTING OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(LBVH)

...

# link it against any targets in the parent project
target_link_libraries(my_project PUBLIC LBVH)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lbvh-0.0.13.tar.gz (45.6 kB view hashes)

Uploaded Source

Built Distributions

lbvh-0.0.13-cp311-cp311-win_amd64.whl (52.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

lbvh-0.0.13-cp311-cp311-musllinux_1_1_x86_64.whl (380.5 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

lbvh-0.0.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (68.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

lbvh-0.0.13-cp311-cp311-macosx_11_0_arm64.whl (44.8 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

lbvh-0.0.13-cp311-cp311-macosx_10_14_x86_64.whl (47.8 kB view hashes)

Uploaded CPython 3.11 macOS 10.14+ x86-64

lbvh-0.0.13-cp310-cp310-win_amd64.whl (52.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

lbvh-0.0.13-cp310-cp310-musllinux_1_1_x86_64.whl (380.6 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

lbvh-0.0.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

lbvh-0.0.13-cp310-cp310-macosx_11_0_arm64.whl (44.9 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

lbvh-0.0.13-cp310-cp310-macosx_10_14_x86_64.whl (47.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.14+ x86-64

lbvh-0.0.13-cp39-cp39-win_amd64.whl (52.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

lbvh-0.0.13-cp39-cp39-musllinux_1_1_x86_64.whl (380.6 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

lbvh-0.0.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

lbvh-0.0.13-cp39-cp39-macosx_11_0_arm64.whl (44.9 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

lbvh-0.0.13-cp39-cp39-macosx_10_14_x86_64.whl (47.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

lbvh-0.0.13-cp38-cp38-win_amd64.whl (52.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

lbvh-0.0.13-cp38-cp38-musllinux_1_1_x86_64.whl (380.5 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

lbvh-0.0.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (68.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

lbvh-0.0.13-cp38-cp38-macosx_11_0_arm64.whl (44.8 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

lbvh-0.0.13-cp38-cp38-macosx_10_14_x86_64.whl (48.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page