mkey, I've gotten the first version of the clipped decal code in it's first revision, it of corse does not work, but here it is, anyone who can find the many many bugs in it befor me will have the great honor of beeing 13373|2 than me
int decal_create(object * obj, decal_point *point, int subobject, int texture){
	mprintf(("a decal is about to be made at %0.2f, %0.2f, %0.2f\n", point->pnt.xyz.x, point->pnt.xyz.y, point->pnt.xyz.z));
	if(obj->type != OBJ_SHIP){
		return 0;
	}
	vector center = point->pnt;
	float rad = point->radius * 2;
	if(rad <=0) rad = 10;
	mprintf(("radius %f\n",rad));
	vector plain_point[4];
	vector cube_point[8];
//define the decals dimentions
	plain_point[0] = point->orient.vec.uvec;
	plain_point[1] = plain_point[0];
		vm_vec_negate(&plain_point[1]);
	plain_point[2] = point->orient.vec.rvec;
	plain_point[3] = plain_point[2];
		vm_vec_negate(&plain_point[3]);
	vector topcenter;
	vector bvec = point->orient.vec.fvec;
	vm_vec_negate(&bvec);
	vm_vec_scale_add(&topcenter, ¢er, &bvec, rad);
	for(int i = 0; i < 4; i++){
		vm_vec_scale_add( &cube_point[i], &topcenter, &plain_point[i], rad );
		vm_vec_scale_add( &cube_point[i+4], &cube_point[i], &point->orient.vec.fvec, rad*2);
	}
	float max_rad = vm_vec_dist(¢er, &cube_point[0]);	//the cube points are all equidistant, right?
mprintf(("decal defined\n"));
//define the decals dimentions
	
//set up the decal model
	ship *shipp = &Ships[obj->instance];
	decal *sdec = &shipp->decals[0];
	polymodel *pm = model_get(shipp->modelnum);
	bsp_info * sm;
	sm = &pm->submodel[subobject];
	decal_model dmod = sm->dec_model;
	decal_model tdec;	//temporary decal model for holding the culled down part of the decal
//end set up the decal model
mprintf(("decal model set up\n"));
//cull out all polys you are defanantly not going to be useing
	tdec.n_polys = 0;
	for(i=0; i<1200; i++) tdec.vert[i] = dmod.vert[i];//make sure they have the same def points
	for(i = 0; i < dmod.n_polys; i++){
		if(vm_vec_dist(¢er, &dmod.poly[i].center) <= (dmod.poly[i].radius + max_rad)){
			tdec.poly[tdec.n_polys++] = dmod.poly[i];
		}
	}
mprintf(("culled unwanted poleis\n"));
//end cull out all polys you are defanantly not going to be useing
//the good part, find what part of wich poly you are going to be useing and copy that to a ship decal
	sdec->n_poly = 0;
//	find defpoints
	int dec_vert = 0;
	int decal_vert_index[1200];
	for(int j = 0; j < 3; j ++){	//if this def point is inside the box, copy it
		vector test_point, temp;
		vm_vec_sub(&test_point, &tdec.vert[tdec.poly[i].point[j]], &point->pnt);	//make it relitive to the decal point
		vm_vec_unrotate(&temp, &test_point, &point->orient);	//unrotate it
		test_point = temp;
		if(
			test_point.xyz.x < (center.xyz.x + rad) &&
			test_point.xyz.x > (center.xyz.x - rad) &&
			test_point.xyz.y < (center.xyz.y + rad) &&
			test_point.xyz.y > (center.xyz.y - rad) &&
			test_point.xyz.z < (center.xyz.z + rad) &&
			test_point.xyz.z > (center.xyz.z - rad)
			)
		{
			decal_vert_index[j] = dec_vert;	//this says wich index in the ship decal relates to the decal model
			sdec->vert[dec_vert++] = tdec.vert[j];
			mprintf(("defpoint %d copied\n", j));
		}else{
			decal_vert_index[j] = -1;	//if it isn't in the box then there is no vert to relate to
			mprintf(("defpoint %d isn't in the cube\n", j));
		}
	}
mprintf(("defpoints copied\n"));
	for(i = 0; i < tdec.n_polys; i++){
mprintf(("procesing tdec poly %d, there are currently %d polys in the decal\n",tdec.n_polys, sdec->n_poly));
		int verts_in_cube = 0;
//find how many of the verts of this poly are in the cube
		for( int k = 0; k< 3; k++){
			if(decal_vert_index[tdec.poly[i].point[k]] != -1){
				verts_in_cube++;
			}
		}
mprintf(("%d of it's verts are in the cube\n",verts_in_cube));
		
			int n_point = 0;
			int poly_point[6];
int l, r, p, v, newpnt;
vector poly_pnts[3];
		switch(verts_in_cube){
		case 3:
//if all verts are in the box just copy it
			for(l = 0; l < 3; l++){
				sdec->poly[sdec->n_poly].point[i] = decal_vert_index[tdec.poly[i].point[l]];
			}
			sdec->n_poly++;
			break;
		case 2:
//if two of the verts are in make a (posably up to five-pointed, no less than four) poly 
			n_point = 0;
			r=0;
			for( l = 0; l < 3; l++){
				if(decal_vert_index[tdec.poly[i].point[l]] != -1){
				//if the point is in the cube just copy it
					poly_point[r++] = decal_vert_index[tdec.poly[i].point[l]];
				}else{
				//else find one somewere between
					//this one and the previus
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l-1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
					//posably one from a cube intersection
					for(v = 0; v<3; v++)poly_pnts[v]= tdec.vert[tdec.poly[i].point[v]];
					if(decal_intersect_poly_with_cube(&sdec->vert[dec_vert], poly_pnts, cube_point, 0) == 1){
						poly_point[r++] = dec_vert++;
					}
					//this one and the next
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l+1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
				}
			}
//then copy the triangulated version to the ship decal
			for(p = 1; p<(r-1); p++){
				sdec->poly[sdec->n_poly].point[0] = poly_point[0];
				sdec->poly[sdec->n_poly].point[p] = poly_point[p];
				sdec->poly[sdec->n_poly].point[p+1] = poly_point[p+1];
				sdec->n_poly++;
			}
			break;
		case 1:
//if one of the verts are in make a (posably up to 5-pointed, at least 3) poly 
			n_point = 0;
			r=0;
			for( l = 0; l < 3; l++){
				if(decal_vert_index[tdec.poly[i].point[l]] != -1){
				//if the point is in the cube just copy it
					poly_point[r++] = decal_vert_index[tdec.poly[i].point[l]];
				}else{
				//else find one somewere between
					//this one and the previus
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l-1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
					//posably one from a cube intersection
					vector poly_pnts[3];
					vector temppnt1;
					vector temppnt2;
					newpnt = 0;
					for(v = 0; v<3; v++)poly_pnts[v]= tdec.vert[tdec.poly[i].point[v]];
					if(decal_intersect_poly_with_cube(&temppnt1, poly_pnts, cube_point, 0) == 1){
						newpnt = 1;
					}
					//posably another one from a cube intersection
					for(v = 0; v<3; v++)poly_pnts[v]= tdec.vert[tdec.poly[i].point[v]];
					if(decal_intersect_poly_with_cube(&temppnt2, poly_pnts, cube_point, 1) == 1){
						newpnt = 2;
					}
					//that function doesn't generate points in any particular order so if the first one is closer to the last point make it the naext one
					if(newpnt == 1){
						sdec->vert[dec_vert] = temppnt1;
						poly_point[r++] = dec_vert++;
					}else if(newpnt == 2){
						if(vm_vec_dist(&sdec->vert[dec_vert - 1], &temppnt1) < vm_vec_dist(&sdec->vert[dec_vert - 1], &temppnt2)){
							sdec->vert[dec_vert] = temppnt1;
							poly_point[r++] = dec_vert++;
							sdec->vert[dec_vert] = temppnt2;
							poly_point[r++] = dec_vert++;
						}else{
							sdec->vert[dec_vert] = temppnt2;
							poly_point[r++] = dec_vert++;
							sdec->vert[dec_vert] = temppnt1;
							poly_point[r++] = dec_vert++;
						}
						
						poly_point[r++] = dec_vert++;
					}
					//this one and the next
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l+1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
				}
			}
//then copy the triangulated version to the ship decal
			for(p = 1; p<(r-1); p++){
				sdec->poly[sdec->n_poly].point[0] = poly_point[0];
				sdec->poly[sdec->n_poly].point[p] = poly_point[p];
				sdec->poly[sdec->n_poly].point[p+1] = poly_point[p+1];
				sdec->n_poly++;
			}
			break;
		case 0:
//if none of the verts are in make a (posably up to 6-pointed) poly 
			n_point = 0;
			r=0;
			newpnt = 0;
			vector newpoint[4];
			for(v = 0; v<3; v++)poly_pnts[v]= tdec.vert[tdec.poly[i].point[v]];
			for(k = 0; k<4; k++){
				if( decal_intersect_poly_with_cube(&newpoint[k], poly_pnts, cube_point, k) == 1){
					newpnt = k;
				}
			}
			float dist;
			switch(newpnt){
//four cube intersections
			case 4:
				for(v = 0; v<4; v++){
					sdec->vert[dec_vert+v] = newpoint[v];
					poly_point[r++] = dec_vert++;
				}
				r=4;
				break;
//tree cube intersections
			case 3:
				for(l=0; l<3; l++){
					//this one and the next
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l+1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
					//this one and the previus
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l-1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
				}
				for(l = 0; l<3; l++){
					dist = vm_vec_dist(&sdec->vert[poly_point[r-1]], &newpoint[l%3]);
					//if this intersection point is closer than the other two, use it as the next point
					if((dist < vm_vec_dist(&sdec->vert[poly_point[r-1]], &newpoint[(l+1)%3])) && (dist < vm_vec_dist(&sdec->vert[poly_point[r-1]], &newpoint[(l+2)%3])) ){
						sdec->vert[dec_vert] = newpoint[l];
						k = l;
					}
				}
				poly_point[r++] = dec_vert++;
				//of the remaining two points wich one is the farthest from the first point is next
				dist = vm_vec_dist(&sdec->vert[poly_point[0]], &newpoint[(k + 1)%3]);
				if(dist > vm_vec_dist(&sdec->vert[poly_point[0]], &newpoint[(k+2)%3]) ){
					sdec->vert[dec_vert] = newpoint[(k + 1)%3];
					poly_point[r++] = dec_vert++;
					sdec->vert[dec_vert] = newpoint[(k + 2)%3];
					poly_point[r++] = dec_vert++;
				}else{
					sdec->vert[dec_vert] = newpoint[(k + 2)%3];
					poly_point[r++] = dec_vert++;
					sdec->vert[dec_vert] = newpoint[(k + 1)%3];
					poly_point[r++] = dec_vert++;
				}
				break;
//two cube intersections
			case 2:
				//get the two poly points
				for(l=0; l<3; l++){
					//this one and the next
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l+1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
					//this one and the previus
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l-1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
				}
				//get the two cube intersections
				for(l = 0; l<3; l++){
					dist = vm_vec_dist(&sdec->vert[poly_point[r-1]], &newpoint[l%3]);
					//if this intersection point is closer than the other, use it as the next point
					if((dist < vm_vec_dist(&sdec->vert[poly_point[r-1]], &newpoint[(l+1)%3])) ){
						sdec->vert[dec_vert] = newpoint[l];
						k = l;
					}
				}
				poly_point[r++] = dec_vert++;
				//the remaining point is next
					sdec->vert[dec_vert] = newpoint[(k + 2)%3];
					poly_point[r++] = dec_vert++;
				break;
//one cube intersection
			case 1:
				for(l=0; l<3; l++){
					//this one and the next
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l+1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
					//this one and the previus
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l-1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
				}
	
				sdec->vert[dec_vert] = newpoint[0];
				poly_point[r++] = dec_vert++;
				break;
//no cube intersections
			case 0:
				for(l=0; l<3; l++){
					//this one and the next
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l+1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
					//this one and the previus
					if(decal_intersect_seg_with_cube(&sdec->vert[dec_vert], tdec.vert[tdec.poly[i].point[l]], tdec.vert[tdec.poly[i].point[(l-1)%3]], cube_point, point->orient)){
						poly_point[r++] = dec_vert++;
					}
				}
				break;
			}
//then copy the triangulated version to the ship decal
//IT IS POSABLE THAT THERE IS NO INTERSECTION AT ALL
			for(p = 1; p<(r-1); p++){
				sdec->poly[sdec->n_poly].point[0] = poly_point[0];
				sdec->poly[sdec->n_poly].point[p] = poly_point[p];
				sdec->poly[sdec->n_poly].point[p+1] = poly_point[p+1];
				sdec->n_poly++;
			}
			break;
		}
	}
	for(i=0; in_poly; i++){
		for(int k=0; k<3; k++){
			sdec->poly[i].uv[k].u = 0.5f;
			sdec->poly[i].uv[k].v = 0.5f;
		}
	}
	sdec->texture = texture;
	sdec->is_valid = 1;
	sdec->timestamp = timestamp();
	mprintf(("a decal should have been made with %d polys\n",sdec->n_poly));
	return 1;
}
these are two subrouteens used by that
int decal_intersect_seg_with_cube(vector * poly_point, vector start, vector end, vector cube_point[8], matrix orient){
mprintf(("entering decal_intersect_seg_with_cube\n"));
	//for each four sided face of the cube
	vector *pointlist[4];
	vector plnorm = orient.vec.fvec;
	pointlist[0] = &cube_point[4];
	pointlist[1] = &cube_point[6];
	pointlist[2] = &cube_point[5];
	pointlist[3] = &cube_point[7];
	if(fvi_segment_plane(poly_point, &cube_point[5], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vm_vec_negate(&plnorm);
	pointlist[0] = &cube_point[0];
	pointlist[1] = &cube_point[3];
	pointlist[2] = &cube_point[1];
	pointlist[3] = &cube_point[2];
	if(fvi_segment_plane(poly_point, &cube_point[0], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vector veca;
	vector vecb;
	veca = orient.vec.uvec;
	vecb = orient.vec.rvec;
	vm_vec_negate(&veca);
	vm_vec_avg(&plnorm, &veca, &vecb);
	vm_vec_normalize(&plnorm);
	pointlist[0] = &cube_point[2];
	pointlist[1] = &cube_point[1];
	pointlist[2] = &cube_point[5];
	pointlist[3] = &cube_point[6];
	if(fvi_segment_plane(poly_point, &cube_point[5], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vm_vec_negate(&plnorm);
	pointlist[0] = &cube_point[3];
	pointlist[1] = &cube_point[0];
	pointlist[2] = &cube_point[4];
	pointlist[3] = &cube_point[7];
	if(fvi_segment_plane(poly_point, &cube_point[0], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	
	veca = orient.vec.uvec;
	vecb = orient.vec.rvec;
	vm_vec_avg(&plnorm, &veca, &vecb);
	vm_vec_normalize(&plnorm);
	pointlist[0] = &cube_point[2];
	pointlist[1] = &cube_point[0];
	pointlist[2] = &cube_point[4];
	pointlist[3] = &cube_point[6];
	if(fvi_segment_plane(poly_point, &cube_point[0], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vm_vec_negate(&plnorm);
	pointlist[0] = &cube_point[3];
	pointlist[1] = &cube_point[1];
	pointlist[2] = &cube_point[5];
	pointlist[3] = &cube_point[7];
	if(fvi_segment_plane(poly_point, &cube_point[5], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
mprintf(("leaveing decal_intersect_seg_with_cube\n"));
return 0;//it couldn't find any
	
}
int decal_intersect_poly_with_cube(vector * poly_point, vector point[3], vector cube_point[8], int ints){
mprintf(("entering decal_intersect_poly_with_cube\n"));
	vector plnorm;
	vector *pointlist[3];
	for(int i = 0; i<3; i++)pointlist[i] = &point[i];
	vm_vec_perp(&plnorm, &point[0], &point[1], &point[2]);
	vector pnt1 = cube_point[0];
	vector pnt2 = cube_point[2];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face, and this isn't the last one
				return 1;//and if it is, then get out
	pnt1 = cube_point[2];
	pnt2 = cube_point[1];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[1];
	pnt2 = cube_point[3];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[3];
	pnt2 = cube_point[0];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[0];
	pnt2 = cube_point[4];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[2];
	pnt2 = cube_point[6];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[1];
	pnt2 = cube_point[5];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[3];
	pnt2 = cube_point[7];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[4];
	pnt2 = cube_point[6];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[6];
	pnt2 = cube_point[5];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[5];
	pnt2 = cube_point[7];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[7];
	pnt2 = cube_point[4];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
mprintf(("leaveing decal_intersect_poly_with_cube\n"));
	return 0;
}
now this is the object interpeter I made, that sets a trianglulated version of all submodels into a specal polymodel format I have incerted into the submodel data type
int decal_intersect_seg_with_cube(vector * poly_point, vector start, vector end, vector cube_point[8], matrix orient){
mprintf(("entering decal_intersect_seg_with_cube\n"));
	//for each four sided face of the cube
	vector *pointlist[4];
	vector plnorm = orient.vec.fvec;
	pointlist[0] = &cube_point[4];
	pointlist[1] = &cube_point[6];
	pointlist[2] = &cube_point[5];
	pointlist[3] = &cube_point[7];
	if(fvi_segment_plane(poly_point, &cube_point[5], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vm_vec_negate(&plnorm);
	pointlist[0] = &cube_point[0];
	pointlist[1] = &cube_point[3];
	pointlist[2] = &cube_point[1];
	pointlist[3] = &cube_point[2];
	if(fvi_segment_plane(poly_point, &cube_point[0], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vector veca;
	vector vecb;
	veca = orient.vec.uvec;
	vecb = orient.vec.rvec;
	vm_vec_negate(&veca);
	vm_vec_avg(&plnorm, &veca, &vecb);
	vm_vec_normalize(&plnorm);
	pointlist[0] = &cube_point[2];
	pointlist[1] = &cube_point[1];
	pointlist[2] = &cube_point[5];
	pointlist[3] = &cube_point[6];
	if(fvi_segment_plane(poly_point, &cube_point[5], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vm_vec_negate(&plnorm);
	pointlist[0] = &cube_point[3];
	pointlist[1] = &cube_point[0];
	pointlist[2] = &cube_point[4];
	pointlist[3] = &cube_point[7];
	if(fvi_segment_plane(poly_point, &cube_point[0], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	
	veca = orient.vec.uvec;
	vecb = orient.vec.rvec;
	vm_vec_avg(&plnorm, &veca, &vecb);
	vm_vec_normalize(&plnorm);
	pointlist[0] = &cube_point[2];
	pointlist[1] = &cube_point[0];
	pointlist[2] = &cube_point[4];
	pointlist[3] = &cube_point[6];
	if(fvi_segment_plane(poly_point, &cube_point[0], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
	vm_vec_negate(&plnorm);
	pointlist[0] = &cube_point[3];
	pointlist[1] = &cube_point[1];
	pointlist[2] = &cube_point[5];
	pointlist[3] = &cube_point[7];
	if(fvi_segment_plane(poly_point, &cube_point[5], &plnorm, &start, &end, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 4, pointlist, &plnorm, NULL, NULL, NULL))//then see if it is on the face
				return 1;//and if it is, then get out
mprintf(("leaveing decal_intersect_seg_with_cube\n"));
return 0;//it couldn't find any
	
}
int decal_intersect_poly_with_cube(vector * poly_point, vector point[3], vector cube_point[8], int ints){
mprintf(("entering decal_intersect_poly_with_cube\n"));
	vector plnorm;
	vector *pointlist[3];
	for(int i = 0; i<3; i++)pointlist[i] = &point[i];
	vm_vec_perp(&plnorm, &point[0], &point[1], &point[2]);
	vector pnt1 = cube_point[0];
	vector pnt2 = cube_point[2];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face, and this isn't the last one
				return 1;//and if it is, then get out
	pnt1 = cube_point[2];
	pnt2 = cube_point[1];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[1];
	pnt2 = cube_point[3];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[3];
	pnt2 = cube_point[0];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[0];
	pnt2 = cube_point[4];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[2];
	pnt2 = cube_point[6];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[1];
	pnt2 = cube_point[5];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[3];
	pnt2 = cube_point[7];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[4];
	pnt2 = cube_point[6];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[6];
	pnt2 = cube_point[5];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[5];
	pnt2 = cube_point[7];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
	pnt1 = cube_point[7];
	pnt2 = cube_point[4];
	if(fvi_segment_plane(poly_point, &point[0], &plnorm, &pnt1, &pnt2, 0.0) == 1)//see if the segment intersecs the plane
			if(fvi_point_face(poly_point, 3, pointlist, &plnorm, NULL, NULL, NULL) && (0 != ints--))//then see if it is on the face
				return 1;//and if it is, then get out
mprintf(("leaveing decal_intersect_poly_with_cube\n"));
	return 0;
}
and these are the current versions of the data types
typedef struct decal_model{	//this will store a triangulated version of the ships polygons
	struct{
		int point[3];		//an index to the vert list-Bobboau
		vector center;		//the center of the poly
		float radius;		//the max radius of the poly
	}poly[800];
	vector vert[1200];	//the defpoints-Bobboau
	int n_polys;
}decal_model;
//extern decal_model d_model;
typedef struct decal{
	struct{
		uv_pair uv[3];
		int point[3];		//an index to the vert list-Bobboau
	}poly[MAX_DECAL_POLY];
	vector vert[MAX_DECAL_POLY * 3];	//the defpoints-Bobboau
	int texture;
	int is_valid;		//this means it is a good decal that should be rendered-Bobboau
	int n_poly;
	int timestamp;	//is to start fadeing away-Bobboau
}decal;
typedef struct decal_point{
vector pnt;
matrix orient;
float radius;
}decal_point;