-
Notifications
You must be signed in to change notification settings - Fork 1
henrixh/intersector-gadget
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a small, simple and somewhat decent ray/mesh intersection library for C++14. If something more production worthy is needed, look somewhere else. The goal is not to be correct, not to be fast. The goal is to be easy to use when writing toy raytracers, pathtracers or other things where some ray/mesh intersection is needed. Just throw your triangles and rays at it. Usage: Move all .cpp and .h files to your project and add to your build system. If you are building on x86-64, you should add '-march=native' to your compiler flags for some extra speed. Compiles with '$ g++ -pedantic -Wall -Wextra -Werror -std=gnu++14' API: namespace gadget { typedef vec3 position_t; typedef vec3 direction_t; typedef vec3 normal_t; typedef vec3 uv_t; typedef size_t id_t; typedef float fp; class ray { public: position_t origin; direction_t dir; ray(position_t o, direction_t d); }; struct intersection { normal_t hit_normal; position_t hit_position; ray incoming_ray; uv_t uv; id_t id; bool hit; }; class triangle { public: position_t v0, v1, v2; normal_t n0, n1, n2; uv_t t0, t1, t2; id_t id; }; class intersector { public: intersector(std::vector<triangle> triangles); intersection intersect(const ray & r) const; }; } Smallvec: 'smallvec.h' is also available at https://github.com/henrixh/smallvec as a separate project Written by: Mattias Hammar <mahavilan@gmail.com> Henrik Henriksson <hx@hx.ax>
About
Small crappy ray/mesh intersection library
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published