Revision: 47270
          http://brlcad.svn.sourceforge.net/brlcad/?rev=47270&view=rev
Author:   abhi2011
Date:     2011-10-16 20:11:13 +0000 (Sun, 16 Oct 2011)
Log Message:
-----------
Separated the list of manifolds generated by bullet and that generated by rt, 
as they are required at different times during the simulation iterations

Modified Paths:
--------------
    brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp
    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
    brlcad/trunk/src/libged/simulate/simulate.h
    brlcad/trunk/src/libged/simulate/simutils.c

Modified: brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp
===================================================================
--- brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp       2011-10-16 
10:02:42 UTC (rev 47269)
+++ brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp       2011-10-16 
20:11:13 UTC (rev 47270)
@@ -75,8 +75,8 @@
 
     btCollisionObject* col0 = body0;
     btCollisionObject* col1 = body1;
-    btBoxShape* box0 = (btBoxShape*)col0->getCollisionShape();
-    btBoxShape* box1 = (btBoxShape*)col1->getCollisionShape();
+ /*   btBoxShape* box0 = (btBoxShape*)col0->getCollisionShape();
+    btBoxShape* box1 = (btBoxShape*)col1->getCollisionShape();*/
 
     //quellage
     bu_log("%d", dispatchInfo.m_stepCount);
@@ -93,15 +93,14 @@
     input.m_transformB = body1->getWorldTransform();
 
     //This part will get replaced with a call to rt
-   //btBoxBoxDetector detector(box0, box1);
-   //detector.getClosestPoints(input, *resultOut, dispatchInfo.m_debugDraw);
+  //  btBoxBoxDetector detector(box0, box1);
+   // detector.getClosestPoints(input, *resultOut, dispatchInfo.m_debugDraw);
 
 
     //------------------- DEBUG ---------------------------
 
     int i;
-    int num_contacts;
-    struct sim_manifold *current_manifold;
+    struct sim_manifold *bt_mf, *rt_mf;
 
     //Get the user pointers to struct rigid_body, for printing the body name
     struct rigid_body *rbA = (struct rigid_body *)col0->getUserPointer();
@@ -109,89 +108,108 @@
 
     if (rbA != NULL && rbB != NULL) {
 
-               btPersistentManifold* contactManifold = 
resultOut->getPersistentManifold();
 
-               current_manifold =
-                       (struct sim_manifold *)bu_malloc(sizeof(struct 
sim_manifold), "sim_manifold: current_manifold");
-               current_manifold->next = NULL;
-               current_manifold->rbA = rbA;
-               current_manifold->rbB = rbB;
+       //Iterate over the points for the BT 
manifold----------------------------------
 
+       btPersistentManifold* contactManifold = 
resultOut->getPersistentManifold();
+
+               bt_mf = (struct sim_manifold *)bu_malloc(sizeof(struct 
sim_manifold),
+                                                                               
                                "sim_manifold: bt_mf");
+               bt_mf->next = NULL;
+               bt_mf->rbA = rbA;
+               bt_mf->rbB = rbB;
+
                //Add manifold to rbB
-               if (rbB->head_manifold == NULL) {
-                       rbB->head_manifold = current_manifold;
+               if (rbB->head_bt_manifold == NULL) {
+                       rbB->head_bt_manifold = bt_mf;
                } else{
                        //Go upto the last manifold, keeping a ptr 1 node behind
-                       struct sim_manifold *p1 = rbB->head_manifold, *p2;
+                       struct sim_manifold *p1 = rbB->head_bt_manifold, *p2;
                        while (p1 != NULL) {
                        p2 = p1;
                        p1 = p1->next;
                        }
 
-                       p2->next = current_manifold;
+                       p2->next = bt_mf;
                        //print_manifold_list(rb->head_manifold);
                }
-               rbB->num_manifolds++;
+               rbB->num_bt_manifolds++;
 
                bu_log("processCollision(box/box): %s & %s \n", rbA->rb_namep, 
rbB->rb_namep);
 
                //Get the number of points in this manifold
-               num_contacts = contactManifold->getNumContacts();
-               current_manifold->num_bt_contacts = num_contacts;
+               bt_mf->num_contacts = contactManifold->getNumContacts();
 
+               bu_log("processCollision : Manifold contacts : %d\n", 
bt_mf->num_contacts);
 
-               bu_log("processCollision : Manifold contacts : %d\n", 
num_contacts);
 
-               //Iterate over the points for this manifold
-               for (i=0; i<num_contacts; i++) {
+               for (i=0; i<bt_mf->num_contacts; i++) {
                        btManifoldPoint& pt = 
contactManifold->getContactPoint(i);
 
                        btVector3 ptA = pt.getPositionWorldOnA();
                        btVector3 ptB = pt.getPositionWorldOnB();
 
-                       VMOVE(current_manifold->bt_contacts[i].ptA, ptA);
-                       VMOVE(current_manifold->bt_contacts[i].ptB, ptB);
-                       VMOVE(current_manifold->bt_contacts[i].normalWorldOnB, 
pt.m_normalWorldOnB);
+                       VMOVE(bt_mf->contacts[i].ptA, ptA);
+                       VMOVE(bt_mf->contacts[i].ptB, ptB);
+                       VMOVE(bt_mf->contacts[i].normalWorldOnB, 
pt.m_normalWorldOnB);
 
-                       bu_log("%d, %s(%f, %f, %f) , %s(%f, %f, %f), n(%f, %f, 
%f)\n",
+                       bu_log("processCollision: Got BT contact %d, %s(%f, %f, 
%f) , \
+                                       %s(%f, %f, %f), n(%f, %f, %f)\n",
                           i+1,
                           rbA->rb_namep, ptA[0], ptA[1], ptA[2],
                           rbB->rb_namep, ptB[0], ptB[1], ptB[2],
                           pt.m_normalWorldOnB[0], pt.m_normalWorldOnB[1], 
pt.m_normalWorldOnB[2]);
 
                }
-    }
 
 
-   //Scan all manifolds of rbB looking for a rbA-rbB manifold
-   for (current_manifold = rbB->head_manifold; current_manifold != NULL;
-            current_manifold = current_manifold->next) {
+           //Scan all RT manifolds of rbB looking for a rbA-rbB 
manifold----------------------
 
-          //Find the manifold in rbB's list which connects rbB and rbA
-          if( bu_strcmp(current_manifold->rbA->rb_namep, rbA->rb_namep) &&
-                          bu_strcmp(current_manifold->rbB->rb_namep, 
rbB->rb_namep) ){
+               for (rt_mf = rbB->head_rt_manifold; rt_mf != NULL;
+                        rt_mf = rt_mf->next) {
 
-                  // Now add the rt contact pairs
-                  for (i=0; i<current_manifold->num_rt_contacts; i++){
+                  //Find the manifold in rbB's list which connects rbB and rbA
+                  if( bu_strcmp(rt_mf->rbA->rb_namep, rbA->rb_namep) &&
+                                  bu_strcmp(rt_mf->rbB->rb_namep, 
rbB->rb_namep) ){
 
-                          btVector3 ptB, normalWorldOnB;
-                          VMOVE(ptB, current_manifold->rt_contacts[i].ptB);
-                          VMOVE(normalWorldOnB, 
current_manifold->rt_contacts[i].normalWorldOnB);
+                          // Now add the RT contact pairs
+                          for (i=0; i<rt_mf->num_contacts; i++){
 
-                          //Negative depth for penetration
-                          resultOut->addContactPoint(ptB, normalWorldOnB,
-                                          
-(current_manifold->rt_contacts[i].depth));
-                  }
+                                  btVector3 ptA, ptB;
+                                  btVector3 normalWorldOnB(0.000000,0.000000, 
-1.000000);
+                                  rt_mf->contacts[i].depth = rbA->iter * 0.02f;
 
-          }
+                                  VMOVE(ptA, rt_mf->contacts[i].ptA);
+                                  VMOVE(ptB, rt_mf->contacts[i].ptB);
+                                  VMOVE(normalWorldOnB, 
rt_mf->contacts[i].normalWorldOnB);
 
-   }
+                                  //Positive depth for penetration
+                                  resultOut->addContactPoint(normalWorldOnB, 
ptB, rt_mf->contacts[i].depth);
 
+                                  bu_log("processCollision: Added RT contact 
%d, %s(%f, %f, %f) , \
+                                                  %s(%f, %f, %f), n(%f, %f, 
%f), %f\n",
+                                                          i+1,
+                                                       rt_mf->rbA->rb_namep, 
V3ARGS(ptA),
+                                                       rt_mf->rbB->rb_namep, 
V3ARGS(ptB),
+                                                       V3ARGS(normalWorldOnB),
+                                                       
(rt_mf->contacts[i].depth));
+                          }
 
+                  }//end- if( bu_strcmp...
+
+          }//end- for (rt_mf = rbB->head_rt_manifold...
+
+    } //end-if
+
+
+
+
+
     //------------------------------------------------------
 
 #ifdef USE_PERSISTENT_CONTACTS
-    //  refreshContactPoints is only necessary when using persistent contact 
points. otherwise all points are newly added
+    // refreshContactPoints is only necessary when using persistent contact 
points.
+    // otherwise all points are newly added
     if (m_ownManifold) {
        resultOut->refreshContactPoints();
     }

Modified: brlcad/trunk/src/libged/simulate/simphysics.cpp
===================================================================
--- brlcad/trunk/src/libged/simulate/simphysics.cpp     2011-10-16 10:02:42 UTC 
(rev 47269)
+++ brlcad/trunk/src/libged/simulate/simphysics.cpp     2011-10-16 20:11:13 UTC 
(rev 47270)
@@ -93,6 +93,8 @@
 
     for (current_node = sim_params->head_node; current_node != NULL; 
current_node = current_node->next) {
 
+       current_node->iter = sim_params->iter;
+
        // Check if we should add a ground plane
        if (strcmp(current_node->rb_namep, sim_params->ground_plane_name) == 0) 
{
            // Add a static ground plane : should be controlled by an option : 
TODO

Modified: brlcad/trunk/src/libged/simulate/simrt.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simrt.c    2011-10-16 10:02:42 UTC (rev 
47269)
+++ brlcad/trunk/src/libged/simulate/simrt.c    2011-10-16 20:11:13 UTC (rev 
47270)
@@ -593,24 +593,23 @@
           mf->rbA->rb_namep, mf->rbB->rb_namep);
 
 
-
     /* Determine if an arb4 needs to be generated using x/y/z diff. */
-    mf->num_rt_contacts = 2;
+    mf->num_contacts = 2;
 
-    VMOVE(mf->rt_contacts[0].ptA, rt_result.xr_min_y_in);
-    VMOVE(mf->rt_contacts[1].ptA, rt_result.xr_min_y_out);
+    VMOVE(mf->contacts[0].ptA, rt_result.xr_min_y_in);
+    VMOVE(mf->contacts[1].ptA, rt_result.xr_min_y_out);
 
-    VMOVE(mf->rt_contacts[1].ptB, rt_result.xr_max_y_in);
-    VMOVE(mf->rt_contacts[0].ptB, rt_result.xr_max_y_out);
+    VMOVE(mf->contacts[1].ptB, rt_result.xr_max_y_in);
+    VMOVE(mf->contacts[0].ptB, rt_result.xr_max_y_out);
 
-    for(i=0; i< mf->num_rt_contacts; i++){
+    for(i=0; i< mf->num_contacts; i++){
        bu_log("create_contact_pairs : %d, %s(%f, %f, %f) -- %s(%f, %f, %f)",
-         i, mf->rbA->rb_namep, V3ARGS(mf->rt_contacts[i].ptA),
-                mf->rbB->rb_namep, V3ARGS(mf->rt_contacts[i].ptB));
+         i, mf->rbA->rb_namep, V3ARGS(mf->contacts[i].ptA),
+                mf->rbB->rb_namep, V3ARGS(mf->contacts[i].ptB));
     }
 
-    VSUB2(a, mf->rt_contacts[1].ptB, mf->rt_contacts[1].ptA);
-    VSUB2(b, mf->rt_contacts[0].ptA, mf->rt_contacts[1].ptB);
+    VSUB2(a, mf->contacts[1].ptB, mf->contacts[1].ptA);
+    VSUB2(b, mf->contacts[0].ptA, mf->contacts[1].ptB);
 
     /* Get the normals */
     VCROSS(c, a, b);
@@ -618,30 +617,70 @@
     bu_log("create_contact_pairs : Normal got as %f,%f, %f",
          V3ARGS(c));
 
-    VMOVE(mf->rt_contacts[0].normalWorldOnB, c);
-    VMOVE(mf->rt_contacts[1].normalWorldOnB, c);
+    VMOVE(mf->contacts[0].normalWorldOnB, c);
+    VMOVE(mf->contacts[1].normalWorldOnB, c);
 
     /* Get penetration depth */
     VSUB2(c, overlap_max, overlap_min);
-    mf->rt_contacts[0].depth = c[Z];
-    mf->rt_contacts[1].depth = c[Z];
+    mf->contacts[0].depth = c[Z];
+    mf->contacts[1].depth = c[Z];
     bu_log("create_contact_pairs : Penetration depth set to %f", c[Z]);
 
+  /*  VSET(mf->contacts[0].ptA, 0.000000, 0.000000, -0.001389);
+       VSET(mf->contacts[1].ptA, 1.000000, 0.000000, -0.001389);
 
+       VSET(mf->contacts[1].ptB, 0.000000, 0.960000, -0.001389);
+       VSET(mf->contacts[0].ptB, 1.000000, 0.960000, -0.001389);*/
 
+       VSET(mf->contacts[0].ptB, 1.000000, 1.000000, 0.000000);
+       VSET(mf->contacts[1].ptB, 1.000000, 0.000000, 0.000000);
+       VSET(mf->contacts[2].ptB, 0.000000, 0.000000, 0.000000);
+       VSET(mf->contacts[3].ptB, 0.000000, 1.000000, 0.000000);
+
+
+
     return GED_OK;
 }
 
 
 int
+free_rt_manifold_lists(struct simulation_params *sim_params)
+{
+    /* Free memory in manifold list */
+    struct sim_manifold *current_manifold, *next_manifold;
+    struct rigid_body *current_node;
+
+    for (current_node = sim_params->head_node; current_node != NULL;
+               current_node = current_node->next) {
+
+               for (current_manifold = current_node->head_rt_manifold; 
current_manifold != NULL;) {
+
+                       next_manifold = current_manifold->next;
+                       bu_free(current_manifold, "simulate : 
head_rt_manifold");
+                       current_manifold = next_manifold;
+                       current_node->num_rt_manifolds--;
+               }
+
+               current_node->num_rt_manifolds = 0;
+               current_node->head_rt_manifold = NULL;
+    }
+
+    return GED_OK;
+}
+
+
+int
 generate_manifolds(struct ged *gedp, struct simulation_params *sim_params)
 {
-    struct sim_manifold *current_manifold;
+    struct sim_manifold *bt_mf, *rt_mf;
     struct rigid_body *rb;
     vect_t overlap_min, overlap_max;
     char *prefix_overlap = "overlap_";
     struct bu_vls overlap_name = BU_VLS_INIT_ZERO;
 
+    /* Free all the manifolds generated in the previous iteration */
+    free_rt_manifold_lists(sim_params);
+
     /* Raytrace related stuff */
     struct rt_i *rtip;
 
@@ -652,55 +691,64 @@
     }
     rtip->useair = 1;
 
+    /* Initialize the raytrace */
     init_raytrace(sim_params, rtip);
 
 
-    /* Check all rigid bodies for overlaps using their manifold lists */
+    /* Check all rigid bodies for overlaps using their BT manifold list */
     for (rb = sim_params->head_node; rb != NULL; rb = rb->next) {
 
        bu_log("generate_manifolds: Analyzing manifolds of %s", rb->rb_namep);
 
-       for (current_manifold = rb->head_manifold; current_manifold != NULL;
-            current_manifold = current_manifold->next) {
+               for (bt_mf = rb->head_bt_manifold; bt_mf != NULL;
+                        bt_mf = bt_mf->next) {
 
-           /* Get the overlap region */
-           get_overlap(current_manifold->rbA, current_manifold->rbB,
-                       overlap_min,
-                       overlap_max);
+                       /* Get the overlap region */
+                       get_overlap(bt_mf->rbA, bt_mf->rbB,
+                               overlap_min,
+                               overlap_max);
 
-           /* Prepare the overlap prim name */
-           bu_vls_sprintf(&overlap_name, "%s%s_%s",
-                          prefix_overlap,
-                          current_manifold->rbA->rb_namep,
-                          current_manifold->rbB->rb_namep);
+                       /* Prepare the overlap prim name */
+                       bu_vls_sprintf(&overlap_name, "%s%s_%s",
+                                  prefix_overlap,
+                                  bt_mf->rbA->rb_namep,
+                                  bt_mf->rbB->rb_namep);
 
-           /* Make the overlap volume RPP */
-           make_rpp(gedp, overlap_min, overlap_max, 
bu_vls_addr(&overlap_name));
+                       /* Make the overlap volume RPP */
+                       make_rpp(gedp, overlap_min, overlap_max, 
bu_vls_addr(&overlap_name));
 
-           /* Add the region to the result of the sim so it will be drawn too 
*/
-           add_to_comb(gedp, sim_params->sim_comb_name, 
bu_vls_addr(&overlap_name));
+                       /* Add the region to the result of the sim so it will 
be drawn too */
+                       add_to_comb(gedp, sim_params->sim_comb_name, 
bu_vls_addr(&overlap_name));
 
-           /* Initialize the rayshot results structure, has to be done for 
each manifold  */
-           init_rayshot_results();
+                       /* Initialize the rayshot results structure, has to be 
done for each manifold  */
+                       init_rayshot_results();
 
-           /* Shoot rays right here as the pair of rigid_body ptrs are known,
-            * todo: ignore volumes already shot
-            */
-           shoot_x_rays(gedp, current_manifold, sim_params, rtip, overlap_min, 
overlap_max);
+                       /* Allocate memory for a new RT manifold */
+                       rt_mf = (struct sim_manifold *)
+                                                                       
bu_malloc(sizeof(struct sim_manifold), "sim_manifold: rt_mf");
+                   rt_mf->rbA = bt_mf->rbA;
+                       rt_mf->rbB = bt_mf->rbB;
+                       rt_mf->num_contacts = 0;
+                       rt_mf->next = NULL;
 
+                       /* Shoot rays right here as the pair of rigid_body ptrs 
are known,
+                        * TODO: ignore volumes already shot
+                        */
+                       shoot_x_rays(gedp, rt_mf, sim_params, rtip, 
overlap_min, overlap_max);
 
-           /* shoot_y_rays(); */
 
+                       /* shoot_y_rays(); */
 
-           /* shoot_z_rays(); */
 
-           /* Note down this volume as already covered, so no need to shoot 
rays through it again */
+                       /* shoot_z_rays(); */
 
-           /* Create the contact pairs and normals */
-           create_contact_pairs(current_manifold, overlap_min, overlap_max);
 
 
-       }
+                       /* Create the contact pairs and normals */
+                       create_contact_pairs(rt_mf, overlap_min, overlap_max);
+
+
+               }
     }
 
 

Modified: brlcad/trunk/src/libged/simulate/simrt.h
===================================================================
--- brlcad/trunk/src/libged/simulate/simrt.h    2011-10-16 10:02:42 UTC (rev 
47269)
+++ brlcad/trunk/src/libged/simulate/simrt.h    2011-10-16 20:11:13 UTC (rev 
47270)
@@ -117,8 +117,12 @@
 
 
 /**
- * Creates the contact pairs from the raytracing results
- *
+ * Creates the contact pairs from the raytracing results.
+ * This is the core logic of the simulation and the manifold points
+ * have to satisfy certain constraints(max area within overlap region etc)
+ * to have a successful simulation. The normals and penetration depth is also
+ * generated here for each point in the contact pairs. There can be upto 4
+ * contact pairs.
  */
 int
 create_contact_pairs(struct sim_manifold *mf, vect_t overlap_min, vect_t 
overlap_max);
@@ -126,7 +130,13 @@
 
 /**
  * Shoots rays within the AABB overlap regions only, to allow more rays to be 
shot
- * in a grid of finer granularity and to increase performance.
+ * in a grid of finer granularity and to increase performance. The bodies to 
be targeted
+ * are got from the list of manifolds returned by Bullet which carries out AABB
+ * intersection checks. These manifolds are stored in the corresponding 
rigid_body
+ * structures of each body participating in the simulation. The manifolds are 
then used
+ * to generate manifolds based on raytracing and stored in a separate list for 
the body B
+ * of that particular manifold. The list is freed in the next iteration in 
this function
+ * as well, to prevent memory leaks, before a new set manifolds are created.
  */
 int
 generate_manifolds(struct ged *gedp, struct simulation_params *sim_params);
@@ -204,6 +214,14 @@
 
 
 /**
+ * Frees the list of manifolds as generated by RT for all rigid
+ * bodies in the simulation.
+ */
+int
+free_rt_manifold_lists(struct simulation_params *sim_params);
+
+
+/**
  * Initializes the simulation scene for raytracing
  */
 int

Modified: brlcad/trunk/src/libged/simulate/simulate.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simulate.c 2011-10-16 10:02:42 UTC (rev 
47269)
+++ brlcad/trunk/src/libged/simulate/simulate.c 2011-10-16 20:11:13 UTC (rev 
47270)
@@ -62,9 +62,12 @@
     VSETALL(current_node->linear_velocity, 0.0f);
     VSETALL(current_node->angular_velocity, 0.0f);
 
-    current_node->num_manifolds = 0;
-    current_node->head_manifold = NULL;
+    current_node->num_bt_manifolds = 0;
+    current_node->head_bt_manifold = NULL;
 
+    current_node->num_rt_manifolds = 0;
+    current_node->head_rt_manifold = NULL;
+
     return GED_OK;
 }
 
@@ -340,7 +343,7 @@
  * used to compare with rt generated manifold for accuracy
  */
 int
-free_manifold_lists(struct simulation_params *sim_params)
+free_bt_manifold_lists(struct simulation_params *sim_params)
 {
     /* Free memory in manifold list */
     struct sim_manifold *current_manifold, *next_manifold;
@@ -349,16 +352,16 @@
     for (current_node = sim_params->head_node; current_node != NULL;
         current_node = current_node->next) {
 
-       for (current_manifold = current_node->head_manifold; current_manifold 
!= NULL;) {
+       for (current_manifold = current_node->head_bt_manifold; 
current_manifold != NULL;) {
 
            next_manifold = current_manifold->next;
-           bu_free(current_manifold, "simulate : current_manifold");
+           bu_free(current_manifold, "simulate : head_bt_manifold");
            current_manifold = next_manifold;
-           current_node->num_manifolds--;
+           current_node->num_bt_manifolds--;
        }
 
-       current_node->num_manifolds = 0;
-       current_node->head_manifold = NULL;
+       current_node->num_bt_manifolds = 0;
+       current_node->head_bt_manifold = NULL;
     }
 
     return GED_OK;
@@ -447,6 +450,7 @@
        recreate_sim_comb(gedp, &sim_params);
 
        /* Run the physics simulation */
+       sim_params.iter = i;
        rv = run_simulation(&sim_params);
        if (rv != GED_OK) {
            bu_vls_printf(gedp->ged_result_str, "%s: ERROR while running the 
simulation\n", argv[0]);
@@ -467,7 +471,7 @@
            return GED_ERROR;
        }
 
-       free_manifold_lists(&sim_params);
+       free_bt_manifold_lists(&sim_params);
 
     }
 

Modified: brlcad/trunk/src/libged/simulate/simulate.h
===================================================================
--- brlcad/trunk/src/libged/simulate/simulate.h 2011-10-16 10:02:42 UTC (rev 
47269)
+++ brlcad/trunk/src/libged/simulate/simulate.h 2011-10-16 20:11:13 UTC (rev 
47270)
@@ -51,12 +51,9 @@
 
 struct sim_manifold {
     struct rigid_body *rbA, *rbB;
-    int num_bt_contacts;
-    struct sim_contact bt_contacts[MAX_CONTACTS_PER_MANIFOLD];
+    int num_contacts;
+    struct sim_contact contacts[MAX_CONTACTS_PER_MANIFOLD];
 
-    int num_rt_contacts;
-    struct sim_contact rt_contacts[MAX_CONTACTS_PER_MANIFOLD];
-
     struct sim_manifold *next;
 };
 
@@ -90,8 +87,15 @@
     vect_t angular_velocity;        /**< @brief angular velocity components */
 
     /* Manifold generated, where this body is B, only body B has manifold info 
*/
-    int num_manifolds;                            /**< @brief number of 
manifolds for this body */
-    struct sim_manifold *head_manifold;/**< @brief head of the manifolds 
linked list */
+    int num_bt_manifolds;                                 /**< @brief number 
of manifolds for this body */
+    struct sim_manifold *head_bt_manifold;/**< @brief head of the manifolds 
linked list */
+
+    /* Manifold generated, where this body is B, only body B has manifold info 
*/
+    int num_rt_manifolds;                                 /**< @brief number 
of manifolds for this body */
+    struct sim_manifold *head_rt_manifold;/**< @brief head of the manifolds 
linked list */
+
+    /* Debugging */
+    int iter;
 };
 
 
@@ -106,6 +110,9 @@
     char *sim_comb_name;           /**< @brief name of the group which 
contains all sim regions*/
     char *ground_plane_name;       /**< @brief name of the ground plane region 
*/
     struct rigid_body *head_node;  /**< @brief link to first rigid body node */
+
+    /* Debugging */
+    int iter;
 };
 
 

Modified: brlcad/trunk/src/libged/simulate/simutils.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simutils.c 2011-10-16 10:02:42 UTC (rev 
47269)
+++ brlcad/trunk/src/libged/simulate/simutils.c 2011-10-16 20:11:13 UTC (rev 
47270)
@@ -83,20 +83,20 @@
 
     bu_log("print_manifold_list: %s\n", rb->rb_namep);
 
-    for (current_manifold = rb->head_manifold; current_manifold != NULL;
+    for (current_manifold = rb->head_bt_manifold; current_manifold != NULL;
         current_manifold = current_manifold->next) {
 
        bu_log("--Manifold between %s & %s has %d contacts--\n",
               current_manifold->rbA->rb_namep,
               current_manifold->rbB->rb_namep,
-              current_manifold->num_bt_contacts);
+              current_manifold->num_contacts);
 
-       for (i=0; i<current_manifold->num_bt_contacts; i++) {
+       for (i=0; i<current_manifold->num_contacts; i++) {
            bu_log("%d, (%f, %f, %f):(%f, %f, %f), n(%f, %f, %f)\n",
                   i+1,
-                  V3ARGS(current_manifold->bt_contacts[i].ptA),
-                  V3ARGS(current_manifold->bt_contacts[i].ptB),
-                  V3ARGS(current_manifold->bt_contacts[i].normalWorldOnB));
+                  V3ARGS(current_manifold->contacts[i].ptA),
+                  V3ARGS(current_manifold->contacts[i].ptB),
+                  V3ARGS(current_manifold->contacts[i].normalWorldOnB));
        }
     }
 }
@@ -656,11 +656,11 @@
     struct sim_manifold *current_manifold;
     int i;
 
-    for (current_manifold = rb->head_manifold; current_manifold != NULL;
+    for (current_manifold = rb->head_bt_manifold; current_manifold != NULL;
         current_manifold = current_manifold->next) {
 
 
-       if(current_manifold->num_bt_contacts > 0){
+       if(current_manifold->num_contacts > 0){
 
            /* Prepare prefixed bounding box primitive name */
            bu_vls_sprintf(&name, "%s_%s", current_manifold->rbA->rb_namep, 
current_manifold->rbB->rb_namep);
@@ -695,46 +695,46 @@
            cmd_args[2] = (char *)0;
            argc = 2;
 
-           switch(current_manifold->num_bt_contacts) {
+           switch(current_manifold->num_contacts) {
                case 1:
                    bu_log("1 contact got, no manifold drawn");
                    break;
 
                case 2:
                    cmd_args[2] = bu_strdup("arb4");
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[0].ptA[0]);
+                   sprintf(buffer, "%f", current_manifold->contacts[0].ptA[0]);
                    cmd_args[3] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[0].ptA[1]);
+                   sprintf(buffer, "%f", current_manifold->contacts[0].ptA[1]);
                    cmd_args[4] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[0].ptA[2]);
+                   sprintf(buffer, "%f", current_manifold->contacts[0].ptA[2]);
                    cmd_args[5] = bu_strdup(buffer);
 
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[1].ptA[0]);
+                   sprintf(buffer, "%f", current_manifold->contacts[1].ptA[0]);
                    cmd_args[6] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[1].ptA[1]);
+                   sprintf(buffer, "%f", current_manifold->contacts[1].ptA[1]);
                    cmd_args[7] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[1].ptA[2]);
+                   sprintf(buffer, "%f", current_manifold->contacts[1].ptA[2]);
                    cmd_args[8] = bu_strdup(buffer);
 
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[1].ptB[0]);
+                   sprintf(buffer, "%f", current_manifold->contacts[1].ptB[0]);
                    cmd_args[9] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[1].ptB[1]);
+                   sprintf(buffer, "%f", current_manifold->contacts[1].ptB[1]);
                    cmd_args[10] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[1].ptB[2]);
+                   sprintf(buffer, "%f", current_manifold->contacts[1].ptB[2]);
                    cmd_args[11] = bu_strdup(buffer);
 
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[0].ptB[0]);
+                   sprintf(buffer, "%f", current_manifold->contacts[0].ptB[0]);
                    cmd_args[12] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[0].ptB[1]);
+                   sprintf(buffer, "%f", current_manifold->contacts[0].ptB[1]);
                    cmd_args[13] = bu_strdup(buffer);
-                   sprintf(buffer, "%f", 
current_manifold->bt_contacts[0].ptB[2]);
+                   sprintf(buffer, "%f", current_manifold->contacts[0].ptB[2]);
                    cmd_args[14] = bu_strdup(buffer);
 
                    cmd_args[15] = (char *)0;
                    argc = 15;
 
-                   VADD2SCALE(from, current_manifold->bt_contacts[0].ptA,
-                              current_manifold->bt_contacts[1].ptB, 0.5);
+                   VADD2SCALE(from, current_manifold->contacts[0].ptA,
+                              current_manifold->contacts[1].ptB, 0.5);
                    break;
 
                case 3:
@@ -744,39 +744,39 @@
                case 4:
                    cmd_args[2] = bu_strdup("arb8");
                    for (i=0; i<4; i++) {
-                       sprintf(buffer, "%f", 
current_manifold->bt_contacts[i].ptA[0]);
+                       sprintf(buffer, "%f", 
current_manifold->contacts[i].ptA[0]);
                        cmd_args[3+i*3] = bu_strdup(buffer);
-                       sprintf(buffer, "%f", 
current_manifold->bt_contacts[i].ptA[1]);
+                       sprintf(buffer, "%f", 
current_manifold->contacts[i].ptA[1]);
                        cmd_args[4+i*3] = bu_strdup(buffer);
-                       sprintf(buffer, "%f", 
current_manifold->bt_contacts[i].ptA[2]);
+                       sprintf(buffer, "%f", 
current_manifold->contacts[i].ptA[2]);
                        cmd_args[5+i*3] = bu_strdup(buffer);
 
-                       sprintf(buffer, "%f", 
current_manifold->bt_contacts[i].ptB[0]);
+                       sprintf(buffer, "%f", 
current_manifold->contacts[i].ptB[0]);
                        cmd_args[15+i*3] = bu_strdup(buffer);
-                       sprintf(buffer, "%f", 
current_manifold->bt_contacts[i].ptB[1]);
+                       sprintf(buffer, "%f", 
current_manifold->contacts[i].ptB[1]);
                        cmd_args[16+i*3] = bu_strdup(buffer);
-                       sprintf(buffer, "%f", 
current_manifold->bt_contacts[i].ptB[2]);
+                       sprintf(buffer, "%f", 
current_manifold->contacts[i].ptB[2]);
                        cmd_args[17+i*3] = bu_strdup(buffer);
 
-                       /* current_manifold->bt_contacts[i].ptA[0],
-                          current_manifold->bt_contacts[i].ptA[1],
-                          current_manifold->bt_contacts[i].ptA[2],
-                          current_manifold->bt_contacts[i].ptB[0],
-                          current_manifold->bt_contacts[i].ptB[1],
-                          current_manifold->bt_contacts[i].ptB[2],
-                          current_manifold->bt_contacts[i].normalWorldOnB[0],
-                          current_manifold->bt_contacts[i].normalWorldOnB[1],
-                          current 
cmd_argsrent_manifold->bt_contacts[i].normalWorldOnB[2]);*/
+                       /* current_manifold->contacts[i].ptA[0],
+                          current_manifold->contacts[i].ptA[1],
+                          current_manifold->contacts[i].ptA[2],
+                          current_manifold->contacts[i].ptB[0],
+                          current_manifold->contacts[i].ptB[1],
+                          current_manifold->contacts[i].ptB[2],
+                          current_manifold->contacts[i].normalWorldOnB[0],
+                          current_manifold->contacts[i].normalWorldOnB[1],
+                          current 
cmd_argsrent_manifold->contacts[i].normalWorldOnB[2]);*/
                    }
                    cmd_args[27] = (char *)0;
                    argc = 27;
 
-                   VADD2SCALE(from, current_manifold->bt_contacts[0].ptA,
-                              current_manifold->bt_contacts[2].ptB, 0.5);
+                   VADD2SCALE(from, current_manifold->contacts[0].ptA,
+                              current_manifold->contacts[2].ptB, 0.5);
                    break;
 
                default:
-                   bu_log("%d contacts got, no manifold drawn", 
current_manifold->num_bt_contacts);
+                   bu_log("%d contacts got, no manifold drawn", 
current_manifold->num_contacts);
                    cmd_args[2] = (char *)0;
                    argc = 2;
                    break;
@@ -803,11 +803,11 @@
                add_to_comb(gedp, sim_params->sim_comb_name, 
bu_vls_addr(&prefixed_reg_name));
 
                /* Finally draw the normal */
-               VSCALE(scaled_normal, 
current_manifold->bt_contacts[0].normalWorldOnB, NORMAL_SCALE_FACTOR);
+               VSCALE(scaled_normal, 
current_manifold->contacts[0].normalWorldOnB, NORMAL_SCALE_FACTOR);
                VADD2(to, scaled_normal, from);
 
                bu_log("insert_manifolds: line (%f,%f,%f)-> (%f,%f,%f)-> 
(%f,%f,%f) \n",
-                      V3ARGS(current_manifold->bt_contacts[0].normalWorldOnB),
+                      V3ARGS(current_manifold->contacts[0].normalWorldOnB),
                       V3ARGS(to),
                       V3ARGS(scaled_normal));
 

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


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to