Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/bvh/bvh.h
| Show All 26 Lines | |||||
| class BVHNode; | class BVHNode; | ||||
| struct BVHStackEntry; | struct BVHStackEntry; | ||||
| class BVHParams; | class BVHParams; | ||||
| class BoundBox; | class BoundBox; | ||||
| class LeafNode; | class LeafNode; | ||||
| class Object; | class Object; | ||||
| class Progress; | class Progress; | ||||
| class Scene; | |||||
| #define BVH_NODE_SIZE 4 | #define BVH_NODE_SIZE 4 | ||||
| #define BVH_NODE_LEAF_SIZE 1 | #define BVH_NODE_LEAF_SIZE 1 | ||||
| #define BVH_QNODE_SIZE 8 | #define BVH_QNODE_SIZE 8 | ||||
| #define BVH_QNODE_LEAF_SIZE 1 | #define BVH_QNODE_LEAF_SIZE 1 | ||||
| #define BVH_ALIGN 4096 | #define BVH_ALIGN 4096 | ||||
| #define TRI_NODE_SIZE 3 | #define TRI_NODE_SIZE 3 | ||||
| Show All 37 Lines | |||||
| /* BVH */ | /* BVH */ | ||||
| class BVH | class BVH | ||||
| { | { | ||||
| public: | public: | ||||
| PackedBVH pack; | PackedBVH pack; | ||||
| BVHParams params; | BVHParams params; | ||||
| const Scene *scene; | |||||
| vector<Object*> objects; | vector<Object*> objects; | ||||
| static BVH *create(const BVHParams& params, const vector<Object*>& objects); | static BVH *create(const BVHParams& params, | ||||
| const Scene *scene, | |||||
| const vector<Object*>& objects); | |||||
| virtual ~BVH() {} | virtual ~BVH() {} | ||||
| void build(Progress& progress); | void build(Progress& progress); | ||||
| void refit(Progress& progress); | void refit(Progress& progress); | ||||
| protected: | protected: | ||||
| BVH(const BVHParams& params, const vector<Object*>& objects); | BVH(const BVHParams& params, | ||||
| const Scene *scene, | |||||
| const vector<Object*>& objects); | |||||
| /* triangles and strands */ | /* triangles and strands */ | ||||
| void pack_primitives(); | void pack_primitives(); | ||||
| void pack_triangle(int idx, float4 storage[3]); | void pack_triangle(int idx, float4 storage[3]); | ||||
| /* merge instance BVH's */ | /* merge instance BVH's */ | ||||
| void pack_instances(size_t nodes_size, size_t leaf_nodes_size); | void pack_instances(size_t nodes_size, size_t leaf_nodes_size); | ||||
| /* for subclasses to implement */ | /* for subclasses to implement */ | ||||
| virtual void pack_nodes(const BVHNode *root) = 0; | virtual void pack_nodes(const BVHNode *root) = 0; | ||||
| virtual void refit_nodes() = 0; | virtual void refit_nodes() = 0; | ||||
| }; | }; | ||||
| /* Regular BVH | /* Regular BVH | ||||
| * | * | ||||
| * Typical BVH with each node having two children. */ | * Typical BVH with each node having two children. */ | ||||
| class RegularBVH : public BVH { | class RegularBVH : public BVH { | ||||
| protected: | protected: | ||||
| /* constructor */ | /* constructor */ | ||||
| friend class BVH; | friend class BVH; | ||||
| RegularBVH(const BVHParams& params, const vector<Object*>& objects); | RegularBVH(const BVHParams& params, | ||||
| const Scene *scene, | |||||
| const vector<Object*>& objects); | |||||
| /* pack */ | /* pack */ | ||||
| void pack_nodes(const BVHNode *root); | void pack_nodes(const BVHNode *root); | ||||
| void pack_leaf(const BVHStackEntry& e, | void pack_leaf(const BVHStackEntry& e, | ||||
| const LeafNode *leaf); | const LeafNode *leaf); | ||||
| void pack_inner(const BVHStackEntry& e, | void pack_inner(const BVHStackEntry& e, | ||||
| const BVHStackEntry& e0, | const BVHStackEntry& e0, | ||||
| Show All 27 Lines | |||||
| /* QBVH | /* QBVH | ||||
| * | * | ||||
| * Quad BVH, with each node having four children, to use with SIMD instructions. */ | * Quad BVH, with each node having four children, to use with SIMD instructions. */ | ||||
| class QBVH : public BVH { | class QBVH : public BVH { | ||||
| protected: | protected: | ||||
| /* constructor */ | /* constructor */ | ||||
| friend class BVH; | friend class BVH; | ||||
| QBVH(const BVHParams& params, const vector<Object*>& objects); | QBVH(const BVHParams& params, | ||||
| const Scene *scene, | |||||
| const vector<Object*>& objects); | |||||
| /* pack */ | /* pack */ | ||||
| void pack_nodes(const BVHNode *root); | void pack_nodes(const BVHNode *root); | ||||
| void pack_leaf(const BVHStackEntry& e, const LeafNode *leaf); | void pack_leaf(const BVHStackEntry& e, const LeafNode *leaf); | ||||
| void pack_inner(const BVHStackEntry& e, const BVHStackEntry *en, int num); | void pack_inner(const BVHStackEntry& e, const BVHStackEntry *en, int num); | ||||
| void pack_aligned_inner(const BVHStackEntry& e, | void pack_aligned_inner(const BVHStackEntry& e, | ||||
| Show All 31 Lines | |||||