ad-hoc exhibits created by the manager and described with the same file
[laserbrain_demo] / src / app.cc
index 8865012..620ec52 100644 (file)
@@ -20,6 +20,7 @@
 #include "exman.h"
 #include "blob_exhibit.h"
 #include "dbg_gui.h"
+#include "geomdraw.h"
 
 #define NEAR_CLIP      5.0
 #define FAR_CLIP       10000.0
@@ -70,7 +71,6 @@ static unsigned int sdr_post_gamma;
 static long prev_msec;
 
 static ExhibitManager *exman;
-static BlobExhibit *blobs;
 static bool show_blobs;
 
 ExSelection exsel_active, exsel_hover;
@@ -171,15 +171,6 @@ bool app_init(int argc, char **argv)
        }
        */
 
-       blobs = new BlobExhibit;
-       blobs->node = new SceneNode;
-       blobs->init();
-       blobs->node->set_position(Vec3(-680, 160, -100));
-       blobs->node->set_scaling(Vec3(28, 28, 28));
-       blobs->node->update(0);
-
-       exman->add(blobs);
-
        if(!(sdr_ltmap_notex = create_program_load("sdr/lightmap.v.glsl", "sdr/lightmap-notex.p.glsl"))) {
                return false;
        }
@@ -483,6 +474,11 @@ static void draw_scene()
        }
        */
 
+       if(debug_gui && dbg_sel_node) {
+               AABox bvol = dbg_sel_node->get_bounds();
+               draw_geom_object(&bvol);
+       }
+
        if(show_walk_mesh && mscn->walk_mesh) {
                glPushAttrib(GL_ENABLE_BIT);
                glEnable(GL_BLEND);
@@ -648,17 +644,19 @@ void app_mouse_button(int bn, bool pressed, int x, int y)
                } else {
                        if(exsel_grab_mouse) {
                                // cancel grab on mouse release
-                               debug_log("releasing...\n");
                                Exhibit *ex = exsel_grab_mouse.ex;
                                Vec3 pos = exslot_mouse.node.get_position();
-                               debug_log("release location: %g %g %g\n", pos.x, pos.y, pos.z);
 
-                               ExhibitSlot *slot = exman->nearest_empty_slot(pos);
+                               debug_log("releasing at %g %g %g ...\n", pos.x, pos.y, pos.z);
+
+                               exslot_mouse.detach_exhibit();
+
+                               ExhibitSlot *slot = exman->nearest_empty_slot(pos, 100);
                                if(!slot) {
-                                       debug_log("no nearby slot\n");
+                                       debug_log("no empty slot nearby\n");
                                        if(ex->prev_slot && ex->prev_slot->empty()) {
                                                slot = ex->prev_slot;
-                                               debug_log("previous slot available though\n");
+                                               debug_log("using previous slot");
                                        }
                                }