clray

diff src/scene.cc @ 58:3d13924b22e6

implementing polygon split
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 12 Sep 2010 00:19:04 +0100
parents 6a30f27fa1e6
children eb97f9c92e1d
line diff
     1.1 --- a/src/scene.cc	Sat Sep 11 03:01:20 2010 +0100
     1.2 +++ b/src/scene.cc	Sun Sep 12 00:19:04 2010 +0100
     1.3 @@ -20,6 +20,7 @@
     1.4  static float eval_cost(const Face *faces, const int *face_idx, int num_faces, const AABBox &aabb, int axis);
     1.5  static void free_kdtree(KDNode *node);
     1.6  static void print_item_counts(const KDNode *node, int level);
     1.7 +static int split_face(const Face *inface, int axis, Face *face1, Face *face2);
     1.8  
     1.9  
    1.10  static int accel_param[NUM_ACCEL_PARAMS] = {
    1.11 @@ -589,3 +590,31 @@
    1.12  	print_item_counts(node->left, level + 1);
    1.13  	print_item_counts(node->right, level + 1);
    1.14  }
    1.15 +/*
    1.16 +#define SWAP(a, b, type)	\
    1.17 +	do { \
    1.18 +		type tmp = a; \
    1.19 +		a = b; \
    1.20 +		b = tmp; \
    1.21 +	} while(0)
    1.22 +
    1.23 +static bool clip_face(const Face *inface, float splitpos, int axis, Face *face1, Face *face2)
    1.24 +{
    1.25 +	assert(inface && face1 && face2);
    1.26 +	assert(inface != face1 && inface != face2);
    1.27 +	assert(axis >= 0 && axis < 3);
    1.28 +
    1.29 +	std::vector<Vertex> verts;
    1.30 +
    1.31 +	// find the edges that must be split
    1.32 +	for(int i=0; i<3; i++) {
    1.33 +		verts.push_back(inface->v[i]);
    1.34 +
    1.35 +		float start = inface->v[i].pos[axis];
    1.36 +		float end = inface->v[(i + 1) % 3].pos[axis];
    1.37 +
    1.38 +		if((splitpos >= start && splitpos < end) || (splitpos >= end && splitpos < start)) {
    1.39 +
    1.40 +		}
    1.41 +	}
    1.42 +}*/