X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fbsptree.c;h=cd8e356e4b31aad667a56dbace820aad69acec1e;hp=30f67eff08fb3d87eca861a91a10bb1ab60fdddd;hb=77e0a84543a31aecceabc0e4b18a0d37ad92c89b;hpb=45f6f46fe758d15aafccdb69ae837fc7d84ee466 diff --git a/src/bsptree.c b/src/bsptree.c index 30f67ef..cd8e356 100644 --- a/src/bsptree.c +++ b/src/bsptree.c @@ -2,11 +2,17 @@ #include #include #include +#if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__DJGPP__) +#include +#else +#include +#endif #include "bsptree.h" #include "dynarr.h" #include "inttypes.h" #include "polyclip.h" #include "vmath.h" +#include "util.h" struct bspfile_header { char magic[4]; @@ -239,6 +245,26 @@ static struct bspnode *add_poly_tree(struct bspnode *n, struct g3d_vertex *v, in return n; } +#undef DRAW_NGONS + +#ifndef DRAW_NGONS +static void debug_draw_poly(struct g3d_vertex *varr, int vcount) +{ + int i, nfaces = vcount - 2; + int vbuf_size = nfaces * 3; + struct g3d_vertex *vbuf = alloca(vbuf_size * sizeof *vbuf); + struct g3d_vertex *vptr = varr + 1; + + for(i=0; ix * n->plane.nx + vdir->y * n->plane.ny + vdir->z * n->plane.nz; if(dot >= 0.0f) { draw_bsp_tree(n->front, vdir); +#ifdef DRAW_NGONS g3d_draw_indexed(n->vcount, n->verts, n->vcount, 0, 0); +#else + debug_draw_poly(n->verts, n->vcount); +#endif draw_bsp_tree(n->back, vdir); } else { draw_bsp_tree(n->back, vdir); +#ifdef DRAW_NGONS g3d_draw_indexed(n->vcount, n->verts, n->vcount, 0, 0); +#else + debug_draw_poly(n->verts, n->vcount); +#endif draw_bsp_tree(n->front, vdir); } }