Revision: 47447
          http://brlcad.svn.sourceforge.net/brlcad/?rev=47447&view=rev
Author:   abhi2011
Date:     2011-11-08 04:12:07 +0000 (Tue, 08 Nov 2011)
Log Message:
-----------
Changed the location of raytrace initialization to the main simulate file in an 
attempt to eliminate as many function calls as possible and get to the bottom 
of why objects appear to be in a different location in the rt_i as compared to 
the one shown by mged.

Modified Paths:
--------------
    brlcad/trunk/src/libged/simulate/simphysics.cpp
    brlcad/trunk/src/libged/simulate/simrt.c
    brlcad/trunk/src/libged/simulate/simrt.h
    brlcad/trunk/src/libged/simulate/simulate.c

Modified: brlcad/trunk/src/libged/simulate/simphysics.cpp
===================================================================
--- brlcad/trunk/src/libged/simulate/simphysics.cpp     2011-11-07 22:05:41 UTC 
(rev 47446)
+++ brlcad/trunk/src/libged/simulate/simphysics.cpp     2011-11-08 04:12:07 UTC 
(rev 47447)
@@ -503,17 +503,6 @@
 
        //for (i=0 ; i < sim_params->duration ; i++) {
 
-    //Make a new rt_i instance from the existing db_i structure
-    if ((sim_params->rtip=rt_new_rti(sim_params->gedp->ged_wdbp->dbip)) == 
RTI_NULL) {
-       bu_log("run_simulation: rt_new_rti failed while getting new rt 
instance\n");
-       return 1;
-    }
-    sim_params->rtip->useair = 1;
-
-    //Initialize the raytrace world
-    init_raytrace(sim_params);
-
-
     //Initialize the physics world
     btDiscreteDynamicsWorld* dynamicsWorld;
 
@@ -573,9 +562,6 @@
     delete collisionConfiguration;
     delete broadphase;
 
-    //Free the raytrace instance
-    rt_free_rti(sim_params->rtip);
-
     //}
 
 

Modified: brlcad/trunk/src/libged/simulate/simrt.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simrt.c    2011-11-07 22:05:41 UTC (rev 
47446)
+++ brlcad/trunk/src/libged/simulate/simrt.c    2011-11-08 04:12:07 UTC (rev 
47447)
@@ -376,37 +376,6 @@
 
 
 int
-init_raytrace(struct simulation_params *sim_params)
-{
-    struct rigid_body *rb;
-
-    /* Add all sim objects to raytrace instance */
-
-    /* Add all the sim objects to the rt_i */
-    for (rb = sim_params->head_node; rb != NULL; rb = rb->next) {
-               if (rt_gettree(sim_params->rtip, rb->rb_namep) < 0)
-                       bu_log("generate_manifolds: Failed to load geometry for 
[%s]\n",
-                          rb->rb_namep);
-               else
-                       bu_log("generate_manifolds: Added [%s] to raytracer\n", 
rb->rb_namep);
-    }
-
-    /* This next call causes some values to be pre-computed, sets up space
-     * partitioning, computes bounding volumes, etc.
-     */
-    rt_prep_parallel(sim_params->rtip, 1);
-
-    bu_log("Simulation objects bounding box (%f, %f, %f):(%f,%f,%f)",
-          V3ARGS(sim_params->rtip->mdl_min), 
V3ARGS(sim_params->rtip->mdl_max));
-
-    num_hits = 0;
-    num_overlaps = 0;
-
-    return GED_OK;
-}
-
-
-int
 init_rayshot_results(void)
 {
     VSETALL(rt_result.resultant_normal_A, SMALL_FASTF);
@@ -1221,6 +1190,9 @@
        /* Add the region to the result of the sim so it will be drawn too */
        add_to_comb(sim_params->gedp, sim_params->sim_comb_name, 
bu_vls_addr(&overlap_name));
 
+    /* Clear ray visualization primitives */
+    kill(sim_params->gedp, "ray_*");
+
        /* Initialize the rayshot results structure, has to be done for each 
manifold  */
        init_rayshot_results();
 

Modified: brlcad/trunk/src/libged/simulate/simrt.h
===================================================================
--- brlcad/trunk/src/libged/simulate/simrt.h    2011-11-07 22:05:41 UTC (rev 
47446)
+++ brlcad/trunk/src/libged/simulate/simrt.h    2011-11-08 04:12:07 UTC (rev 
47447)
@@ -302,13 +302,6 @@
 
 
 /**
- * Initializes the simulation scene for raytracing
- */
-int
-init_raytrace(struct simulation_params *sim_params);
-
-
-/**
  * Initializes the rayshot results structure, called before analyzing
  * each manifold through rays shot in x, y & z directions
  */

Modified: brlcad/trunk/src/libged/simulate/simulate.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simulate.c 2011-11-07 22:05:41 UTC (rev 
47446)
+++ brlcad/trunk/src/libged/simulate/simulate.c 2011-11-08 04:12:07 UTC (rev 
47447)
@@ -366,6 +366,38 @@
 
 
 /**
+ * Initializes the simulation scene for raytracing
+ */
+int
+init_raytrace(struct simulation_params *sim_params)
+{
+    struct rigid_body *rb;
+
+    /* Add all sim objects to raytrace instance */
+
+    /* Add all the sim objects to the rt_i */
+    for (rb = sim_params->head_node; rb != NULL; rb = rb->next) {
+               if (rt_gettree(sim_params->rtip, rb->rb_namep) < 0)
+                       bu_log("init_raytrace: Failed to load geometry for 
[%s]\n",
+                          rb->rb_namep);
+               else
+                       bu_log("init_raytrace: Added [%s] to raytracer\n", 
rb->rb_namep);
+    }
+
+    /* This next call causes some values to be pre-computed, sets up space
+     * partitioning, computes bounding volumes, etc.
+     */
+    rt_prep_parallel(sim_params->rtip, 1);
+
+    bu_log("init_raytrace: Simulation objects bounding box (%f, %f, 
%f):(%f,%f,%f)",
+          V3ARGS(sim_params->rtip->mdl_min), 
V3ARGS(sim_params->rtip->mdl_max));
+
+
+    return GED_OK;
+}
+
+
+/**
  * The libged physics simulation function.
  *
  * Check flags, adds regions to simulation parameters, runs the
@@ -388,13 +420,13 @@
 
     /* Must be wanting help */
     if (argc == 1) {
-       print_usage(gedp->ged_result_str);
-       return GED_HELP;
+               print_usage(gedp->ged_result_str);
+               return GED_HELP;
     }
 
     if (argc < 2) {
-       bu_vls_printf(gedp->ged_result_str, "Usage: %s <steps>", argv[0]);
-       return GED_ERROR;
+               bu_vls_printf(gedp->ged_result_str, "Usage: %s <steps>", 
argv[0]);
+               return GED_ERROR;
     }
 
     /* Make a list containing the bb and existing transforms of all the 
objects in the model
@@ -408,20 +440,33 @@
 
     rv = add_regions(gedp, &sim_params);
     if (rv != GED_OK) {
-       bu_vls_printf(gedp->ged_result_str, "%s: ERROR while adding objects and 
sim attributes\n", argv[0]);
-       return GED_ERROR;
+               bu_vls_printf(gedp->ged_result_str, "%s: ERROR while adding 
objects and sim attributes\n", argv[0]);
+               return GED_ERROR;
     }
 
     rv = get_bb(gedp, &sim_params);
     if (rv != GED_OK) {
-       bu_vls_printf(gedp->ged_result_str, "%s: ERROR while getting bounding 
boxes\n", argv[0]);
-       return GED_ERROR;
+               bu_vls_printf(gedp->ged_result_str, "%s: ERROR while getting 
bounding boxes\n", argv[0]);
+               return GED_ERROR;
     }
 
     for (i=0 ; i < sim_params.duration ; i++) {
 
                bu_log("%s: ------------------------- Iteration %d 
-----------------------\n", argv[0], i+1);
 
+
+               /* Make a new rt_i instance from the existing db_i structure */
+               if 
((sim_params.rtip=rt_new_rti(sim_params.gedp->ged_wdbp->dbip)) == RTI_NULL) {
+                       bu_log("run_simulation: rt_new_rti failed while getting 
new rt instance\n");
+                       return 1;
+               }
+               sim_params.rtip->useair = 1;
+
+               /* Initialize the raytrace world */
+               init_raytrace(&sim_params);
+
+
+
                /* Recreate sim.c to clear AABBs and manifold regions from 
previous iteration */
                recreate_sim_comb(gedp, &sim_params);
 
@@ -440,6 +485,9 @@
                        return GED_ERROR;
                }
 
+               //Free the raytrace instance
+               rt_free_rti(sim_params.rtip);
+
     }
 
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to