Revision: 47011
          http://brlcad.svn.sourceforge.net/brlcad/?rev=47011&view=rev
Author:   abhi2011
Date:     2011-10-01 20:48:21 +0000 (Sat, 01 Oct 2011)
Log Message:
-----------
Fixed some memory bugs

Modified Paths:
--------------
    brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp
    brlcad/trunk/src/libged/simulate/simulate.c

Modified: brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp
===================================================================
--- brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp       2011-10-01 
19:47:23 UTC (rev 47010)
+++ brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp       2011-10-01 
20:48:21 UTC (rev 47011)
@@ -106,7 +106,7 @@
 
                btPersistentManifold* contactManifold = 
resultOut->getPersistentManifold();
 
-               struct sim_manifold *current_manifold =
+/*             struct sim_manifold *current_manifold =
                        (struct sim_manifold *)bu_malloc(sizeof(struct 
sim_manifold), "sim_manifold: current_manifold");
                current_manifold->next = NULL;
 
@@ -125,29 +125,29 @@
                        //print_manifold_list(rb->first_manifold);
                }
                rbB->num_manifolds++;
-
+*/
                bu_log("processCollision(box/box): %s & %s \n", rbA->rb_namep, 
rbB->rb_namep);
 
                //Get the number of points in this manifold
-               current_manifold->num_contacts = 
contactManifold->getNumContacts();
+               int num_contacts = contactManifold->getNumContacts();
+/*             current_manifold->num_contacts = num_contacts;*/
                int i;
 
-               bu_log("processCollision : Manifold contacts : %d\n", 
current_manifold->num_contacts);
+               bu_log("processCollision : Manifold contacts : %d\n", 
num_contacts);
 
                //Iterate over the points for this manifold
-               for (i=0; i<current_manifold->num_contacts; i++){
+               for (i=0; i<num_contacts; i++){
                        btManifoldPoint& pt = 
contactManifold->getContactPoint(i);
 
                        btVector3 ptA = pt.getPositionWorldOnA();
                        btVector3 ptB = pt.getPositionWorldOnB();
 
-                       VMOVE(ptA, current_manifold->rb_contacts[i].ptA);
+/*                     VMOVE(ptA, current_manifold->rb_contacts[i].ptA);
                        VMOVE(ptB, current_manifold->rb_contacts[i].ptB);
-                       VMOVE(pt.m_normalWorldOnB, 
current_manifold->rb_contacts[i].normalWorldOnB);
+                       VMOVE(pt.m_normalWorldOnB, 
current_manifold->rb_contacts[i].normalWorldOnB);*/
 
-                       bu_log("processCollision: contact %d of %d, %s(%f, %f, 
%f) , %s(%f, %f, %f) \
-                                       n(%f, %f, %f)\n",
-                                       i+1, current_manifold->num_contacts,
+                       bu_log("contact %d of %d, %s(%f, %f, %f) , %s(%f, %f, 
%f), n(%f, %f, %f)\n",
+                                       i+1, num_contacts,
                                        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]);

Modified: brlcad/trunk/src/libged/simulate/simulate.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simulate.c 2011-10-01 19:47:23 UTC (rev 
47010)
+++ brlcad/trunk/src/libged/simulate/simulate.c 2011-10-01 20:48:21 UTC (rev 
47011)
@@ -100,11 +100,12 @@
     struct sim_manifold *current_manifold;
     int i;
 
+    bu_log("print_manifold_list: %s\n", rb->rb_namep);
+
        for (current_manifold = rb->first_manifold; current_manifold != NULL;
                        current_manifold = current_manifold->next) {
                for (i=0; i<current_manifold->num_contacts; i++) {
-                       bu_log("print_manifold_list: contact %d of %d, (%f, %f, 
%f) , (%f, %f, %f) \
-                                       n(%f, %f, %f)\n",
+                       bu_log("contact %d of %d, (%f, %f, %f):(%f, %f, %f), 
n(%f, %f, %f)\n",
                                        i+1, current_manifold->num_contacts,
                                        current_manifold->rb_contacts[i].ptA[0],
                                        current_manifold->rb_contacts[i].ptA[1],
@@ -207,6 +208,7 @@
 
        current_node->num_manifolds = 0;
        current_node->first_manifold = NULL;
+
        return GED_OK;
 }
 
@@ -570,8 +572,8 @@
 
        for (current_node = sim_params->head_node; current_node != NULL; 
current_node = current_node->next) {
 
-               if(strcmp(current_node->rb_namep, 
sim_params->ground_plane_name) == 0)
-                       continue;
+               /*if(strcmp(current_node->rb_namep, 
sim_params->ground_plane_name) == 0)
+                       continue;*/
 
                /* Get the internal representation of the object */
                GED_DB_GET_INTERNAL(gedp, &intern, current_node->dp, 
bn_mat_identity, &rt_uniresource, GED_ERROR);
@@ -648,11 +650,15 @@
                current_node = current_node->next) {
 
                for (current_manifold = current_node->first_manifold; 
current_manifold != NULL; ) {
+
                        next_manifold = current_manifold->next;
                        bu_free(current_manifold, "simulate : 
current_manifold");
                        current_manifold = next_manifold;
                        current_node->num_manifolds--;
                }
+
+               current_node->num_manifolds = 0;
+               current_node->first_manifold = NULL;
        }
 
     return GED_OK;
@@ -715,6 +721,8 @@
                return GED_ERROR;
        }
 
+       /* */
+
        /* Run the physics simulation  */
                rv = run_simulation(&sim_params);
                if (rv != GED_OK){
@@ -729,7 +737,7 @@
                        return GED_ERROR;
                }
 
-               free_manifold_lists(&sim_params);
+               /*free_manifold_lists(&sim_params);*/
     }
 
 

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


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to