GEL
2
GEL is a library for Geometry and Linear Algebra
|
00001 #ifndef __GEOMETRY_BBOX_H__ 00002 #define __GEOMETRY_BBOX_H__ 00003 00004 #include "CGLA/Vec3f.h" 00005 00006 #include "Ray.h" 00007 00008 namespace Geometry 00009 { 00010 struct ISectTri 00011 { 00012 CGLA::Vec3f point0; 00013 CGLA::Vec3f point1; 00014 CGLA::Vec3f point2; 00015 00016 CGLA::Vec3f edge0; // Optimization 00017 CGLA::Vec3f edge1; // Optimization 00018 unsigned int mesh_id; 00019 unsigned int tri_id; // pad to 48 bytes for cache alignment purposes 00020 }; 00021 00022 struct TriAccel 00023 { 00024 // first 16 byte half cache line 00025 // plane: 00026 double n_u; 00027 double n_v; 00028 double n_d; 00029 int k; // projection dimension 00030 00031 // second 16 byte half cache line 00032 // line equation for line ac 00033 double b_nu; 00034 double b_nv; 00035 double b_d; 00036 unsigned int mesh_id; 00037 00038 // third 16 byte half cache line 00039 // line equation for line ab 00040 double c_nu; 00041 double c_nv; 00042 double c_d; 00043 00044 unsigned int tri_id; // pad to 48 bytes for cache alignment purposes 00045 }; 00046 00047 struct BBox 00048 { 00049 CGLA::Vec3f min_corner; 00050 CGLA::Vec3f max_corner; 00051 00052 void intersect_min_max(Ray &ray, double &t_min, double &t_max) const ; 00053 bool intersect(Ray &ray); 00054 bool ray_triangle(CGLA::Vec3f &ray_start, CGLA::Vec3f &ray_end, ISectTri &tri); 00055 bool intersect_edge_box(CGLA::Vec3f &ray_start, CGLA::Vec3f &ray_end); 00056 bool intersect_triangle(ISectTri &tri); 00057 bool in_interval(double min_limit, double test_value, double max_limit); 00058 void compute_bbox(std::vector<ISectTri> &isectmesh); 00059 bool intersect_triangle_left(ISectTri &tri, double plane, int axis); 00060 bool intersect_triangle_right(ISectTri &tri, double plane, int axis); 00061 double area(); 00062 }; 00063 } 00064 00065 #endif