Revision: 47262
          http://brlcad.svn.sourceforge.net/brlcad/?rev=47262&view=rev
Author:   abhi2011
Date:     2011-10-15 02:27:22 +0000 (Sat, 15 Oct 2011)
Log Message:
-----------
Added logic to generate contact pairs, need to still find a way to properly 
generalize it to all cases

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

Modified: brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp
===================================================================
--- brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp       2011-10-14 
21:54:38 UTC (rev 47261)
+++ brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp       2011-10-15 
02:27:22 UTC (rev 47262)
@@ -154,7 +154,10 @@
        }
     }
 
+    /* Now add the rt contact pairs */
 
+
+
     //------------------------------------------------------
 
 #ifdef USE_PERSISTENT_CONTACTS

Modified: brlcad/trunk/src/libged/simulate/simrt.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simrt.c    2011-10-14 21:54:38 UTC (rev 
47261)
+++ brlcad/trunk/src/libged/simulate/simrt.c    2011-10-15 02:27:22 UTC (rev 
47262)
@@ -43,26 +43,18 @@
 
     bu_log("print_rayshot_results: -------\n");
 
-    bu_log("X bounds xr_min_x_x:%f, xr_min_x_y:%f, xr_min_x_z:%f \n",
-          rt_result.xr_min_x_x,
-          rt_result.xr_min_x_y,
-          rt_result.xr_min_x_z);
-    bu_log("X bounds xr_max_x_x:%f, xr_max_x_y:%f, xr_max_x_z:%f \n",
-          rt_result.xr_max_x_x,
-          rt_result.xr_max_x_y,
-          rt_result.xr_max_x_z);
-    bu_log("Y bounds xr_min_y:%f, xr_min_y_z:%f\n",
-          rt_result.xr_min_y,
-          rt_result.xr_min_y_z);
-    bu_log("Y bounds xr_max_y:%f, xr_max_y_z:%f\n",
-          rt_result.xr_max_y,
-          rt_result.xr_max_y_z);
-    bu_log("Z bounds xr_min_z:%f, xr_min_z_y:%f\n",
-          rt_result.xr_min_z,
-          rt_result.xr_min_z_y);
-    bu_log("Z bounds xr_max_z:%f, xr_max_z_y:%f\n",
-          rt_result.xr_max_z,
-          rt_result.xr_max_z_y);
+    bu_log("X bounds xr_min_x :%f, %f, %f \n",
+               V3ARGS(rt_result.xr_min_x));
+    bu_log("X bounds xr_max_x :%f, %f, %f \n",
+               V3ARGS(rt_result.xr_max_x));
+    bu_log("Y bounds xr_min_y :%f, %f, %f  >>> (%f, %f, %f)\n",
+               V3ARGS(rt_result.xr_min_y_in), V3ARGS(rt_result.xr_min_y_out));
+    bu_log("Y bounds xr_max_y :%f, %f, %f >>> (%f, %f, %f)\n",
+               V3ARGS(rt_result.xr_max_y_in), V3ARGS(rt_result.xr_max_y_out));
+    bu_log("Z bounds xr_min_z :%f, %f, %f\n",
+               V3ARGS(rt_result.xr_min_z_in));
+    bu_log("Z bounds xr_max_z :%f, %f, %f\n",
+               V3ARGS(rt_result.xr_max_z_in));
 
 
 }
@@ -409,11 +401,12 @@
 init_rayshot_results(void)
 {
         /* Initialize the result structure */
-       rt_result.xr_min_y = MAX_FASTF;
-       rt_result.xr_max_y = -MAX_FASTF;
-       rt_result.xr_min_x_x  = MAX_FASTF;
-       rt_result.xr_max_x_x  = -MAX_FASTF;
+       rt_result.xr_min_x[X]  = MAX_FASTF;
+       rt_result.xr_max_x[X]  = -MAX_FASTF;
+       rt_result.xr_min_y_in[Y] = MAX_FASTF;
+       rt_result.xr_max_y_in[Y] = -MAX_FASTF;
 
+
        return GED_OK;
 }
 
@@ -422,7 +415,7 @@
  * Traverse the hit list and overlap list, drawing the ray segments
  */
 int
-traverse_lists(struct ged *gedp, struct simulation_params *sim_params,
+traverse_xray_lists(struct ged *gedp, struct simulation_params *sim_params,
               point_t pt, point_t dir)
 {
     struct overlap *ovp;
@@ -457,40 +450,36 @@
            /* Fill up the result structure */
 
            /* The min x in the direction of the ray where it hit an overlap */
-           if(ovp->in_point[X] < rt_result.xr_min_x_x){
-               rt_result.xr_min_x_x = ovp->in_point[X];
-               rt_result.xr_min_x_y = ovp->in_point[Y];
-               rt_result.xr_min_x_z = ovp->in_point[Z];
+           if(ovp->in_point[X] < rt_result.xr_min_x[X]){
+               VMOVE(rt_result.xr_min_x, ovp->in_point);
            }
 
            /* The max x in the direction of the ray where it hit an overlap,
             * could be on a different ray from above
             */
-           if(ovp->out_point[X] > rt_result.xr_max_x_x){
-               rt_result.xr_max_x_x = ovp->out_point[X];
-               rt_result.xr_max_x_y = ovp->out_point[Y];
-               rt_result.xr_max_x_z = ovp->out_point[Z];
+           if((ovp->out_point[X] > rt_result.xr_max_x[X])){
+               VMOVE(rt_result.xr_max_x, ovp->out_point);
            }
 
            /* The min y where the x rays encountered overlap */
-           if(ovp->in_point[Y] < rt_result.xr_min_y){
-               rt_result.xr_min_y   = ovp->in_point[Y];
-               rt_result.xr_min_y_z = ovp->in_point[Z];
+           if(ovp->in_point[Y] < rt_result.xr_min_y_in[Y]){
+               VMOVE(rt_result.xr_min_y_in, ovp->in_point);
+               VMOVE(rt_result.xr_min_y_out, ovp->out_point);
            }
 
            /* The max y for the same */
-           if(ovp->in_point[Y] > rt_result.xr_max_y){
-               rt_result.xr_max_y   = ovp->in_point[Y];
-               rt_result.xr_max_y_z = ovp->in_point[Z];
+           if(ovp->in_point[Y] > rt_result.xr_max_y_in[Y]){
+               VMOVE(rt_result.xr_max_y_in, ovp->in_point);
+               VMOVE(rt_result.xr_max_y_out, ovp->out_point);
            }
 
            /* The min z where the x rays encountered overlap */
-           if(ovp->in_point[Y] < rt_result.xr_min_z){
+           if(ovp->in_point[Y] < rt_result.xr_min_z_in[Z]){
                /* Not need currently, may be removed when z-rays are shot */
            }
 
            /* The max z for the same */
-           if(ovp->in_point[Y] > rt_result.xr_max_z){
+           if(ovp->in_point[Y] > rt_result.xr_max_z_in[Z]){
                /* Not need currently, may be removed when z-rays are shot */
            }
 
@@ -573,7 +562,7 @@
                /* Traverse the hit list and overlap list, drawing the ray 
segments
                 * for the current ray
                 */
-               traverse_lists(gedp, sim_params, r_pt, r_dir);
+               traverse_xray_lists(gedp, sim_params, r_pt, r_dir);
 
                print_rayshot_results();
 
@@ -590,16 +579,46 @@
 
 
 int
-create_contact_pairs(struct sim_manifold *mf)
+create_contact_pairs(struct sim_manifold *mf, vect_t overlap_min, vect_t 
overlap_max)
 {
-    /* Prepare the overlap prim name */
+    vect_t a, b, c;
+
+
+       /* Prepare the overlap prim name */
     bu_log("create_contact_pairs : between %s & %s",
           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;
 
+    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->rt_contacts[1].ptB, rt_result.xr_max_y_in);
+    VMOVE(mf->rt_contacts[0].ptB, rt_result.xr_max_y_out);
+
+    VSUB2(a, mf->rt_contacts[1].ptB, mf->rt_contacts[1].ptA);
+    VSUB2(b, mf->rt_contacts[0].ptA, mf->rt_contacts[1].ptB);
+
+    /* Get the normals */
+    VCROSS(c, a, b);
+    VUNITIZE(c);
+    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);
+
+    /* Get penetration depth */
+    VSUB2(c, overlap_max, overlap_min);
+    mf->rt_contacts[0].depth = c[Z];
+    mf->rt_contacts[1].depth = c[Z];
+    bu_log("create_contact_pairs : Penetration depth set to %f", c[Z]);
+
+
+
     return GED_OK;
 }
 
@@ -666,7 +685,7 @@
            /* Note down this volume as already covered, so no need to shoot 
rays through it again */
 
            /* Create the contact pairs and normals */
-           create_contact_pairs(current_manifold);
+           create_contact_pairs(current_manifold, overlap_min, overlap_max);
 
 
        }

Modified: brlcad/trunk/src/libged/simulate/simrt.h
===================================================================
--- brlcad/trunk/src/libged/simulate/simrt.h    2011-10-14 21:54:38 UTC (rev 
47261)
+++ brlcad/trunk/src/libged/simulate/simrt.h    2011-10-15 02:27:22 UTC (rev 
47262)
@@ -95,14 +95,18 @@
 };
 
 
+/**
+ * This structure contains the results of analyzing an overlap volume(among 2
+ * regions), through shooting rays
+ */
 struct rayshot_results{
     /* Results of shooting rays towards -ve x-axis : xr means x rays */
-    fastf_t xr_min_x_x, xr_min_x_y, xr_min_x_z;  /* the min X found while 
shooting x rays & rltd y,z*/
-    fastf_t xr_max_x_x, xr_max_x_y, xr_max_x_z;  /* the max X found while 
shooting x rays & rltd y,z*/
-    fastf_t xr_min_y, xr_min_y_z; /* the min y where overlap was found & the z 
co-ord for it*/
-    fastf_t xr_max_y, xr_max_y_z; /* the max y where overlap was still found */
-    fastf_t xr_min_z, xr_min_z_y; /* the min z where overlap was found & the y 
co-ord for it*/
-    fastf_t xr_max_z, xr_max_z_y; /* the max z where overlap was still found */
+       point_t xr_min_x;  /* the min X found while shooting x rays & rltd y,z*/
+       point_t xr_max_x;  /* the max X found while shooting x rays & rltd y,z*/
+       point_t xr_min_y_in, xr_min_y_out;  /* the min y where overlap was 
found & the z co-ord for it*/
+       point_t xr_max_y_in, xr_max_y_out;  /* the max y where overlap was 
still found */
+       point_t xr_min_z_in;  /* the min z where overlap was found & the y 
co-ord for it*/
+       point_t xr_max_z_in;  /* the max z where overlap was still found */
 
     /* Results of shooting rays down y axis */
 
@@ -117,7 +121,7 @@
  *
  */
 int
-create_contact_pairs(struct sim_manifold *mf);
+create_contact_pairs(struct sim_manifold *mf, vect_t overlap_min, vect_t 
overlap_max);
 
 
 /**
@@ -191,6 +195,15 @@
 
 
 /**
+ * Traverse the hit list and overlap list, drawing the ray segments
+ * for x-rays
+ */
+int
+traverse_xray_lists(struct ged *gedp, struct simulation_params *sim_params,
+              point_t pt, point_t dir);
+
+
+/**
  * Initializes the simulation scene for raytracing
  */
 int

Modified: brlcad/trunk/src/libged/simulate/simulate.h
===================================================================
--- brlcad/trunk/src/libged/simulate/simulate.h 2011-10-14 21:54:38 UTC (rev 
47261)
+++ brlcad/trunk/src/libged/simulate/simulate.h 2011-10-15 02:27:22 UTC (rev 
47262)
@@ -45,6 +45,7 @@
     vect_t ptA;
     vect_t ptB;
     vect_t normalWorldOnB;
+    fastf_t depth;
 };
 
 

Modified: brlcad/trunk/src/libged/simulate/simutils.h
===================================================================
--- brlcad/trunk/src/libged/simulate/simutils.h 2011-10-14 21:54:38 UTC (rev 
47261)
+++ brlcad/trunk/src/libged/simulate/simutils.h 2011-10-15 02:27:22 UTC (rev 
47262)
@@ -117,7 +117,7 @@
 /**
  * Draws an arrow from, to using the BOT primitive & TRC
  * Used to draw manifold normals
- * TODO: surely there is a simpler way!
+ * TODO: find a simpler way
  */
 int
 arrow(struct ged *gedp, char* name, point_t from, point_t to);
@@ -167,7 +167,7 @@
  * This function inserts a manifold comb as reported by Bullet.
  *
  * TODO: this should be used with a debugging flag
- * TODO: this function will be lowered to librt
+ * TODO: this function should be lowered to librt
  */
 int
 insert_manifolds(struct ged *gedp, struct simulation_params *sim_params, 
struct rigid_body *rb);
@@ -180,7 +180,7 @@
  * This function creates and inserts a RPP
  * Used to show AABB overlap volume
  *
- * TODO: this function will be lowered to librt
+ * TODO: this function should be lowered to librt
  */
 int
 make_rpp(struct ged *gedp, vect_t max, vect_t min, char* name);

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