mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
+ | Dragon and bvh
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
struct GPUTriangle;
|
||||
struct GPUObject;
|
||||
struct GPUBvh;
|
||||
|
||||
@ -30,13 +31,13 @@ struct AABB
|
||||
class BVH
|
||||
{
|
||||
public:
|
||||
BVH(std::vector<GPUObject> &primitives, int first_primitive, int primitive_count);
|
||||
BVH(std::vector<GPUTriangle> &primitives, int first_primitive, int primitive_count);
|
||||
|
||||
|
||||
void showAABB(Scene *scene);
|
||||
|
||||
void updateBounds(std::vector <GPUObject> &primitives);
|
||||
void subdivide(std::vector<GPUObject> &primitives);
|
||||
void updateBounds(std::vector <GPUTriangle> &primitives);
|
||||
void subdivide(std::vector<GPUTriangle> &primitives);
|
||||
|
||||
int size();
|
||||
|
||||
|
@ -33,6 +33,16 @@ struct GPUObject
|
||||
|
||||
};
|
||||
|
||||
struct GPUTriangle
|
||||
{
|
||||
alignas(16) glm::vec3 position;
|
||||
alignas(16) glm::vec3 vertex1;
|
||||
alignas(16) glm::vec3 vertex2;
|
||||
alignas(16) glm::vec3 normal;
|
||||
|
||||
int mat_index;
|
||||
};
|
||||
|
||||
struct GPUMaterial
|
||||
{
|
||||
alignas(16) glm::vec3 color;
|
||||
@ -86,6 +96,8 @@ class Scene
|
||||
std::set<int> getGPULights();
|
||||
|
||||
const std::vector<GPUObject> &getObjectData() const;
|
||||
const std::vector<GPUTriangle> &getTriangleData() const;
|
||||
|
||||
std::vector<GPUMaterial> &getMaterialData();
|
||||
GPUVolume &getVolume();
|
||||
std::vector<GPUBvh> &getBVH();
|
||||
@ -97,6 +109,8 @@ class Scene
|
||||
std::vector<GPUBvh> _gpu_bvh;
|
||||
|
||||
std::vector<GPUObject> _gpu_objects;
|
||||
std::vector<GPUTriangle> _gpu_triangles;
|
||||
|
||||
std::vector<GPUMaterial> _gpu_materials;
|
||||
|
||||
std::set<int> _gpu_lights;
|
||||
|
@ -45,7 +45,7 @@ class Triangle : public Object
|
||||
// _vertex2 -= _position; //optimization
|
||||
// _vertex3 -= _position; //optimization
|
||||
|
||||
_normal = glm::normalize(glm::cross(_vertex2, _vertex3)); //optimization
|
||||
_normal = glm::normalize(glm::cross(_vertex2 - _position, _vertex3 - _position)); //optimization
|
||||
|
||||
_mat_index = mat_index;
|
||||
}
|
||||
|
Reference in New Issue
Block a user