removed bsp test
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 26 Aug 2018 01:22:25 +0000 (04:22 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 26 Aug 2018 01:22:25 +0000 (04:22 +0300)
src/parts/rtxonoff.c

index 0f44854..14edf1c 100644 (file)
@@ -9,7 +9,6 @@
 #include "imago2.h"
 #include "gfxutil.h"
 #include "mesh.h"
 #include "imago2.h"
 #include "gfxutil.h"
 #include "mesh.h"
-#include "bsptree.h"
 
 static int init(void);
 static void destroy(void);
 
 static int init(void);
 static void destroy(void);
@@ -29,13 +28,10 @@ static struct screen scr = {
 static float cam_theta = -29, cam_phi = 35;
 static float cam_dist = 10;
 
 static float cam_theta = -29, cam_phi = 35;
 static float cam_dist = 10;
 
-static int use_bsp = 1;
-
 static const char *car_fname[2] = {"data/ldiablo.obj", 0};
 static const char *cartex_fname[2] = {"data/ldiablo.png", 0};
 static struct g3d_mesh mesh_car[2];
 static struct pimage tex_car[2];
 static const char *car_fname[2] = {"data/ldiablo.obj", 0};
 static const char *cartex_fname[2] = {"data/ldiablo.png", 0};
 static struct g3d_mesh mesh_car[2];
 static struct pimage tex_car[2];
-static struct bsptree bsp_car[2];
 
 struct screen *rtxonoff_screen(void)
 {
 
 struct screen *rtxonoff_screen(void)
 {
@@ -60,13 +56,6 @@ static int init(void)
                        if(load_mesh(&mesh_car[i], car_fname[i]) == -1) {
                                return -1;
                        }
                        if(load_mesh(&mesh_car[i], car_fname[i]) == -1) {
                                return -1;
                        }
-
-                       init_bsp(&bsp_car[i]);
-                       if(bsp_add_mesh(&bsp_car[i], &mesh_car[i]) == -1) {
-                               fprintf(stderr, "failed to construct BSP tree %d\n", i);
-                               return -1;
-                       }
-                       bsp_build(&bsp_car[i]);
                }
        }
        return 0;
                }
        }
        return 0;
@@ -79,7 +68,6 @@ static void destroy(void)
        for(i=0; i<2; i++) {
                free(mesh_car[i].varr);
                free(mesh_car[i].iarr);
        for(i=0; i<2; i++) {
                free(mesh_car[i].varr);
                free(mesh_car[i].iarr);
-               destroy_bsp(&bsp_car[i]);
        }
 }
 
        }
 }
 
@@ -115,26 +103,14 @@ static void draw(void)
        g3d_rotate(cam_phi, 1, 0, 0);
        g3d_rotate(cam_theta, 0, 1, 0);
 
        g3d_rotate(cam_phi, 1, 0, 0);
        g3d_rotate(cam_theta, 0, 1, 0);
 
-       if(use_bsp) {
-               const float *mat = g3d_get_matrix(G3D_MODELVIEW, 0);
-               /* transform (0, 0, -1) with transpose(mat3x3) */
-               vdir[0] = -mat[2];
-               vdir[1] = -mat[6];
-               vdir[2] = -mat[10];
-       }
-
        g3d_polygon_mode(G3D_TEX_GOURAUD);
 
        for(i=0; i<sizeof mesh_car / sizeof mesh_car[0]; i++) {
                if(mesh_car[i].varr) {
                        g3d_set_texture(tex_car[i].width, tex_car[i].height, tex_car[i].pixels);
 
        g3d_polygon_mode(G3D_TEX_GOURAUD);
 
        for(i=0; i<sizeof mesh_car / sizeof mesh_car[0]; i++) {
                if(mesh_car[i].varr) {
                        g3d_set_texture(tex_car[i].width, tex_car[i].height, tex_car[i].pixels);
 
-                       if(use_bsp) {
-                               draw_bsp(&bsp_car[i], vdir[0], vdir[1], vdir[2]);
-                       } else {
-                               zsort_mesh(&mesh_car[i]);
-                               draw_mesh(&mesh_car[i]);
-                       }
+                       zsort_mesh(&mesh_car[i]);
+                       draw_mesh(&mesh_car[i]);
                }
        }
 
                }
        }
 
@@ -143,10 +119,4 @@ static void draw(void)
 
 static void keypress(int key)
 {
 
 static void keypress(int key)
 {
-       switch(key) {
-       case 'b':
-               use_bsp = !use_bsp;
-               printf("drawing with %s\n", use_bsp ? "BSP tree" : "z-sorting");
-               break;
-       }
 }
 }