clray

diff src/scene.h @ 28:97cfd9675310

trying to pass the kdtree to the kernel
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Aug 2010 03:42:49 +0100
parents 8b2f2ad14ae7
children 353d80127627
line diff
     1.1 --- a/src/scene.h	Tue Aug 17 20:35:00 2010 +0100
     1.2 +++ b/src/scene.h	Sat Aug 21 03:42:49 2010 +0100
     1.3 @@ -46,12 +46,6 @@
     1.4  	KDAXIS_Z
     1.5  };
     1.6  
     1.7 -#define KDCLEAR(node)	((node)->axis = -1)
     1.8 -#define KDUSED(node)	((node)->axis >= 0)
     1.9 -#define KDPARENT(x)		((x) >> 1)
    1.10 -#define KDLEFT(x)		((x) << 1)
    1.11 -#define KDRIGHT(x)		(((x) << 1) + 1)
    1.12 -
    1.13  struct KDNode {
    1.14  	int axis;
    1.15  	float pt;
    1.16 @@ -66,8 +60,10 @@
    1.17  };
    1.18  
    1.19  struct KDNodeGPU {
    1.20 -	int axis;
    1.21 -	float pt;
    1.22 +	AABBox aabb;
    1.23 +	int face_idx[32];
    1.24 +	int num_faces;
    1.25 +	int padding[3];
    1.26  };
    1.27  
    1.28  
    1.29 @@ -76,12 +72,13 @@
    1.30  	mutable Face *facebuf;
    1.31  	mutable int num_faces;
    1.32  
    1.33 +	mutable KDNodeGPU *kdbuf;
    1.34 +	mutable int num_kdnodes;
    1.35 +
    1.36  public:
    1.37  	std::vector<Mesh*> meshes;
    1.38  	std::vector<Material> matlib;
    1.39 -
    1.40  	KDNode *kdtree;
    1.41 -	std::vector<KDNode> kdtree_gpu;
    1.42  
    1.43  	Scene();
    1.44  	~Scene();
    1.45 @@ -98,6 +95,8 @@
    1.46  	bool load(FILE *fp);
    1.47  
    1.48  	const Face *get_face_buffer() const;
    1.49 +	const KDNodeGPU *get_kdtree_buffer() const;
    1.50 +	int get_num_kdnodes() const;
    1.51  
    1.52  	void draw_kdtree() const;
    1.53  	bool build_kdtree();
    1.54 @@ -114,4 +113,7 @@
    1.55  
    1.56  void set_accel_param(int p, int v);
    1.57  
    1.58 +int kdtree_depth(const KDNode *tree);
    1.59 +int kdtree_nodes(const KDNode *tree);
    1.60 +
    1.61  #endif	/* MESH_H_ */