Revision: 47403 http://brlcad.svn.sourceforge.net/brlcad/?rev=47403&view=rev Author: abhi2011 Date: 2011-11-02 21:27:38 +0000 (Wed, 02 Nov 2011) Log Message: ----------- Need to keep track of normals encountered so far, for a ray passing through rigid_body B, otherwise the same normals added twice will skew the resultant normal direction.
Modified Paths: -------------- brlcad/trunk/src/libged/simulate/simrt.c brlcad/trunk/src/libged/simulate/simrt.h brlcad/trunk/src/libged/simulate/simutils.c Modified: brlcad/trunk/src/libged/simulate/simrt.c =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.c 2011-11-02 21:23:58 UTC (rev 47402) +++ brlcad/trunk/src/libged/simulate/simrt.c 2011-11-02 21:27:38 UTC (rev 47403) @@ -388,8 +388,8 @@ VMOVE(ap.a_ray.r_dir, dir); /* Simple debug printing */ - bu_log("Pnt (%f,%f,%f)", V3ARGS(ap.a_ray.r_pt)); - VPRINT("Dir", ap.a_ray.r_dir); + /*bu_log("Pnt (%f,%f,%f)", V3ARGS(ap.a_ray.r_pt)); + VPRINT("Dir", ap.a_ray.r_dir);*/ /* Shoot the ray. */ (void)rt_shootray(&ap); @@ -460,6 +460,21 @@ int +exists_normal(vect_t n) +{ + int i; + vect_t a; + for(i=0; i<rt_result.num_normals; i++){ + VMOVE(a, rt_result.normals[i]); + if(VEQUAL(a, n)) + return 1; + } + + return 0; +} + + +int traverse_xray_lists( struct sim_manifold *current_manifold, struct simulation_params *sim_params, @@ -473,9 +488,6 @@ struct rt_db_internal intern; struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL; - /* quellage */ - bu_log("traverse_xray_lists : From : (%f,%f,%f), towards(%f,%f,%f)", V3ARGS(pt), V3ARGS(dir)); - /* Draw all the overlap regions : lines are added for overlap segments * to help visual debugging */ @@ -494,7 +506,7 @@ overlap_list[i].out_point, 0, 210, 0); - bu_log("traverse_xray_lists: %s", bu_vls_addr(®_vls)); + /*bu_log("traverse_xray_lists: %s", bu_vls_addr(®_vls));*/ add_to_comb(sim_params->gedp, sim_params->sim_comb_name, bu_vls_addr(®_vls)); @@ -607,9 +619,8 @@ struct rt_db_internal intern; struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL; - /* quellage */ - bu_log("traverse_yray_lists : From : (%f,%f,%f), towards(%f,%f,%f)", V3ARGS(pt), V3ARGS(dir)); + /* Draw all the overlap regions : lines are added for overlap segments * to help visual debugging */ @@ -740,8 +751,6 @@ struct rt_db_internal intern; struct rt_comb_internal *comb =(struct rt_comb_internal *)NULL; - /* quellage */ - bu_log("traverse_zray_lists : From : (%f,%f,%f), towards(%f,%f,%f)", V3ARGS(pt), V3ARGS(dir)); /* Draw all the overlap regions : lines are added for overlap segments * to help visual debugging @@ -873,7 +882,7 @@ VSET(r_dir, 1.0, 0.0, 0.0); - bu_log("Querying overlap between %s & %s", + bu_log("Querying overlap between A: %s & B: %s", current_manifold->rbA->rb_namep, current_manifold->rbB->rb_namep); @@ -928,11 +937,11 @@ /* Cleanup the overlap and hit lists and free memory */ cleanup_lists(); - bu_log("Last y ray fired from y = %f, overlap_max[Y]=%f", y, overlap_max[Y]); + /*bu_log("Last y ray fired from y = %f, overlap_max[Y]=%f", y, overlap_max[Y]);*/ } - bu_log("Last z ray fired from z = %f, overlap_max[Z]=%f", z, overlap_max[Z]); + /*bu_log("Last z ray fired from z = %f, overlap_max[Z]=%f", z, overlap_max[Z]);*/ } @@ -955,7 +964,7 @@ VSET(r_dir, 0.0, 1.0, 0.0); - bu_log("Querying overlap between %s & %s", + bu_log("Querying overlap between A:%s & B:%s", current_manifold->rbA->rb_namep, current_manifold->rbB->rb_namep); @@ -1010,11 +1019,11 @@ /* Cleanup the overlap and hit lists and free memory */ cleanup_lists(); - bu_log("Last x ray fired from x = %f, overlap_max[X]=%f", x, overlap_max[X]); + /*bu_log("Last x ray fired from x = %f, overlap_max[X]=%f", x, overlap_max[X]);*/ } - bu_log("Last z ray fired from z = %f, overlap_max[Z]=%f", z, overlap_max[Z]); + /*bu_log("Last z ray fired from z = %f, overlap_max[Z]=%f", z, overlap_max[Z]);*/ } @@ -1037,7 +1046,7 @@ VSET(r_dir, 0.0, 0.0, 1.0); - bu_log("Querying overlap between %s & %s", + bu_log("Querying overlap between A:%s & B:%s", current_manifold->rbA->rb_namep, current_manifold->rbB->rb_namep); @@ -1092,11 +1101,11 @@ /* Cleanup the overlap and hit lists and free memory */ cleanup_lists(); - bu_log("Last x ray fired from x = %f, overlap_max[X]=%f", x, overlap_max[X]); + /*bu_log("Last x ray fired from x = %f, overlap_max[X]=%f", x, overlap_max[X]);*/ } - bu_log("Last y ray fired from y = %f, overlap_max[Y]=%f", y, overlap_max[Y]); + /*bu_log("Last y ray fired from y = %f, overlap_max[Y]=%f", y, overlap_max[Y]);*/ } Modified: brlcad/trunk/src/libged/simulate/simrt.h =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.h 2011-11-02 21:23:58 UTC (rev 47402) +++ brlcad/trunk/src/libged/simulate/simrt.h 2011-11-02 21:27:38 UTC (rev 47403) @@ -60,7 +60,12 @@ */ #define TOL 0.04 +/* + * Maximum normals allowed to be detected by ray shots + */ +#define MAX_NORMALS 10 + /* * This structure is a single node of a circularly linked list * of overlap regions: similar to the one in nirt/usrfrmt.h @@ -117,6 +122,10 @@ vect_t resultant_normal_A; vect_t resultant_normal_B; + /* List of normals added to a resultant so far, used to prevent adding a normal again */ + vect_t normals[MAX_NORMALS]; + int num_normals; + /* Results of shooting rays towards -ve x-axis : xr means x rays */ 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*/ @@ -252,6 +261,28 @@ /** + * Traverse the hit list and overlap list, drawing the ray segments + * for y-rays + */ +int +traverse_yray_lists( + struct sim_manifold *current_manifold, + struct simulation_params *sim_params, + point_t pt, point_t dir); + + +/** + * Traverse the hit list and overlap list, drawing the ray segments + * for z-rays + */ +int +traverse_zray_lists( + struct sim_manifold *current_manifold, + struct simulation_params *sim_params, + point_t pt, point_t dir); + + +/** * Initializes the simulation scene for raytracing */ int Modified: brlcad/trunk/src/libged/simulate/simutils.c =================================================================== --- brlcad/trunk/src/libged/simulate/simutils.c 2011-11-02 21:23:58 UTC (rev 47402) +++ brlcad/trunk/src/libged/simulate/simutils.c 2011-11-02 21:27:38 UTC (rev 47403) @@ -182,17 +182,17 @@ /* Check if the duplicate already exists, and kill it if so */ if (db_lookup(gedp->ged_wdbp->dbip, name, LOOKUP_QUIET) != RT_DIR_NULL) { - bu_log("kill: WARNING \"%s\" exists, deleting it\n", name); - cmd_args[0] = bu_strdup("kill"); - cmd_args[1] = bu_strdup(name); - cmd_args[2] = (char *)0; + /* bu_log("kill: WARNING \"%s\" exists, deleting it\n", name); */ + cmd_args[0] = bu_strdup("kill"); + cmd_args[1] = bu_strdup(name); + cmd_args[2] = (char *)0; - if (ged_kill(gedp, argc, (const char **)cmd_args) != GED_OK) { - bu_log("kill: ERROR Could not delete existing \"%s\"\n", name); - return GED_ERROR; - } + if (ged_kill(gedp, argc, (const char **)cmd_args) != GED_OK) { + bu_log("kill: ERROR Could not delete existing \"%s\"\n", name); + return GED_ERROR; + } - bu_free_array(argc, cmd_args, "kill: free cmd_args"); + bu_free_array(argc, cmd_args, "kill: free cmd_args"); } return GED_OK; @@ -303,7 +303,7 @@ cmd_args[19] = (char *)0; - print_command(cmd_args, 19); + /* print_command(cmd_args, 19); */ rv = ged_in(gedp, argc, (const char **)cmd_args); if (rv != GED_OK) { 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