# HG changeset patch # User John Tsiombikas # Date 1284247144 -3600 # Node ID 3d13924b22e693d9fadec53b4da6d858ff31b488 # Parent 14c8ebe8f1222348489d5b24eb4f260dff86b3f1 implementing polygon split diff -r 14c8ebe8f122 -r 3d13924b22e6 src/clray.cc --- a/src/clray.cc Sat Sep 11 03:01:20 2010 +0100 +++ b/src/clray.cc Sun Sep 12 00:19:04 2010 +0100 @@ -203,6 +203,11 @@ if(!render()) { exit(1); } + + if(dbg_frame_time) { + const RenderStats *rstat = get_render_stats(); + printf("render time (msec): %lu\n", rstat->render_time); + } } need_update = false; } @@ -242,10 +247,7 @@ { glViewport(0, 0, x, y); - /* reallocate the framebuffer */ - /*delete [] fb; - fb = new float[x * y * 4]; - set_framebuffer(fb, x, y);*/ + /* TODO reallocate the framebuffer to fit the window */ } void idle() diff -r 14c8ebe8f122 -r 3d13924b22e6 src/rt.cc --- a/src/rt.cc Sat Sep 11 03:01:20 2010 +0100 +++ b/src/rt.cc Sun Sep 12 00:19:04 2010 +0100 @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "rt.h" #include "ogl.h" @@ -41,8 +42,6 @@ static long timing_sample_sum; static long num_timing_samples; -extern bool dbg_frame_time; - bool init_renderer(int xsz, int ysz, Scene *scn, unsigned int tex) { @@ -137,9 +136,12 @@ bool render() { - // XXX do we need to call glFinish ? + long tm0 = get_msec(); - long tm0 = get_msec(); + // initialize render-stats + memset(&rstat, 0, sizeof rstat); + rstat.min_aabb_tests = rstat.min_triangle_tests = INT_MAX; + rstat.max_aabb_tests = rstat.max_triangle_tests = 0; #ifdef CLGL_INTEROP cl_event ev; @@ -180,13 +182,11 @@ unmap_mem_buffer(mbuf); #endif - long msec = get_msec() - tm0; - timing_sample_sum += msec; + rstat.render_time = get_msec() - tm0; + + timing_sample_sum += rstat.render_time; num_timing_samples++; - if(dbg_frame_time) { - printf("rendered in %ld msec\n", msec); - } return true; } diff -r 14c8ebe8f122 -r 3d13924b22e6 src/scene.cc --- a/src/scene.cc Sat Sep 11 03:01:20 2010 +0100 +++ b/src/scene.cc Sun Sep 12 00:19:04 2010 +0100 @@ -20,6 +20,7 @@ static float eval_cost(const Face *faces, const int *face_idx, int num_faces, const AABBox &aabb, int axis); static void free_kdtree(KDNode *node); static void print_item_counts(const KDNode *node, int level); +static int split_face(const Face *inface, int axis, Face *face1, Face *face2); static int accel_param[NUM_ACCEL_PARAMS] = { @@ -589,3 +590,31 @@ print_item_counts(node->left, level + 1); print_item_counts(node->right, level + 1); } +/* +#define SWAP(a, b, type) \ + do { \ + type tmp = a; \ + a = b; \ + b = tmp; \ + } while(0) + +static bool clip_face(const Face *inface, float splitpos, int axis, Face *face1, Face *face2) +{ + assert(inface && face1 && face2); + assert(inface != face1 && inface != face2); + assert(axis >= 0 && axis < 3); + + std::vector verts; + + // find the edges that must be split + for(int i=0; i<3; i++) { + verts.push_back(inface->v[i]); + + float start = inface->v[i].pos[axis]; + float end = inface->v[(i + 1) % 3].pos[axis]; + + if((splitpos >= start && splitpos < end) || (splitpos >= end && splitpos < start)) { + + } + } +}*/