clray

diff src/rt.cc @ 24:13091c00d7ca

- moved create_face_buffer to Scene::get_face_buffer and did a few reorganizations. - starting work on the kdtree creation
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Aug 2010 03:02:52 +0100
parents 6c44e4b1726d
children 8b2f2ad14ae7
line diff
     1.1 --- a/src/rt.cc	Fri Aug 13 18:20:45 2010 +0100
     1.2 +++ b/src/rt.cc	Sat Aug 14 03:02:52 2010 +0100
     1.3 @@ -36,7 +36,6 @@
     1.4  };
     1.5  
     1.6  static Ray get_primary_ray(int x, int y, int w, int h, float vfov_deg);
     1.7 -static Face *create_face_buffer(Mesh **meshes, int num_meshes);
     1.8  
     1.9  static Face *faces;
    1.10  static Ray *prim_rays;
    1.11 @@ -78,8 +77,7 @@
    1.12  		return false;
    1.13  	}
    1.14  
    1.15 -	/*Face **/faces = create_face_buffer(&scn->meshes[0], scn->meshes.size());
    1.16 -	if(!faces) {
    1.17 +	if(!(faces = (Face*)scn->get_face_buffer())) {
    1.18  		fprintf(stderr, "failed to create face buffer\n");
    1.19  		return false;
    1.20  	}
    1.21 @@ -234,23 +232,3 @@
    1.22  	Ray ray = {{0, 0, 0, 1}, {px, py, -pz, 1}};
    1.23  	return ray;
    1.24  }
    1.25 -
    1.26 -static Face *create_face_buffer(Mesh **meshes, int num_meshes)
    1.27 -{
    1.28 -	int num_faces = 0;
    1.29 -	for(int i=0; i<num_meshes; i++) {
    1.30 -		num_faces += meshes[i]->faces.size();
    1.31 -	}
    1.32 -	printf("constructing face buffer with %d faces (out of %d meshes)\n", num_faces, num_meshes);
    1.33 -
    1.34 -	Face *faces = new Face[num_faces];
    1.35 -	memset(faces, 0, num_faces * sizeof *faces);
    1.36 -	Face *fptr = faces;
    1.37 -
    1.38 -	for(int i=0; i<num_meshes; i++) {
    1.39 -		for(size_t j=0; j<meshes[i]->faces.size(); j++) {
    1.40 -			*fptr++ = meshes[i]->faces[j];
    1.41 -		}
    1.42 -	}
    1.43 -	return faces;
    1.44 -}