Revision: 47285 http://brlcad.svn.sourceforge.net/brlcad/?rev=47285&view=rev Author: abhi2011 Date: 2011-10-18 15:17:58 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Moving towards tighter integration of raytracing with the Bullet pipeline to ensure the contact pairs are injected at the right point during the simulation, added some extern C linkage code to allow this integration
Modified Paths: -------------- brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp brlcad/trunk/src/libged/simulate/simcollisionalgo.h brlcad/trunk/src/libged/simulate/simphysics.cpp 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.h Modified: brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp 2011-10-18 14:43:19 UTC (rev 47284) +++ brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp 2011-10-18 15:17:58 UTC (rev 47285) @@ -39,7 +39,7 @@ #define USE_PERSISTENT_CONTACTS 1 -#define DEBUG_MF 1 +//#define DEBUG_MF 1 btRTCollisionAlgorithm::btRTCollisionAlgorithm(btPersistentManifold* mf, @@ -105,7 +105,7 @@ //------------------- DEBUG --------------------------- int i; - struct sim_manifold *bt_mf, *rt_mf; + struct sim_manifold *bt_mf; //Get the user pointers to struct rigid_body, for printing the body name struct rigid_body *rbA = (struct rigid_body *)col0->getUserPointer(); @@ -170,6 +170,8 @@ //Scan all RT manifolds of rbB looking for a rbA-rbB manifold---------------------- #ifdef DEBUG_MF + struct sim_manifold *rt_mf; + for (rt_mf = rbB->head_rt_manifold; rt_mf != NULL; rt_mf = rt_mf->next) { Modified: brlcad/trunk/src/libged/simulate/simcollisionalgo.h =================================================================== --- brlcad/trunk/src/libged/simulate/simcollisionalgo.h 2011-10-18 14:43:19 UTC (rev 47284) +++ brlcad/trunk/src/libged/simulate/simcollisionalgo.h 2011-10-18 15:17:58 UTC (rev 47285) @@ -46,7 +46,6 @@ /* private headers */ #include "./simulate.h" - class btPersistentManifold; ///Raytrace based collision detection Modified: brlcad/trunk/src/libged/simulate/simphysics.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/simphysics.cpp 2011-10-18 14:43:19 UTC (rev 47284) +++ brlcad/trunk/src/libged/simulate/simphysics.cpp 2011-10-18 15:17:58 UTC (rev 47285) @@ -29,15 +29,20 @@ #include <iostream> #include <btBulletDynamicsCommon.h> -/* public headers */ -#include "db.h" -#include "vmath.h" +extern "C" { -/* private headers */ -#include "./simulate.h" -#include "./simcollisionalgo.h" + /* public headers */ + #include "db.h" + /* private headers */ + #include "simulate.h" + #include "simcollisionalgo.h" + #include "simrt.h" +} + +struct simulation_params *sim_params; + /** * Prints the 16 by 16 transform matrices for debugging * @@ -81,8 +86,7 @@ */ int add_rigid_bodies(btDiscreteDynamicsWorld* dynamicsWorld, - struct simulation_params *sim_params, - btAlignedObjectArray<btCollisionShape*> collision_shapes) + btAlignedObjectArray<btCollisionShape*> collision_shapes) { struct rigid_body *current_node; fastf_t volume; @@ -183,7 +187,7 @@ * */ int -step_physics(btDiscreteDynamicsWorld* dynamicsWorld, struct simulation_params *sim_params) +step_physics(btDiscreteDynamicsWorld* dynamicsWorld) { bu_vls_printf(sim_params->result_str, "Simulation will run for %d steps.\n", sim_params->duration); bu_vls_printf(sim_params->result_str, "----- Starting simulation -----\n"); @@ -201,7 +205,7 @@ * */ int -get_transforms(btDiscreteDynamicsWorld* dynamicsWorld, struct simulation_params *sim_params) +get_transforms(btDiscreteDynamicsWorld* dynamicsWorld) { int i; btScalar m[16]; @@ -351,7 +355,7 @@ btDispatcherInfo& dispatchInfo) { - int i, j, numContacts; + int i, j, numContacts, rv; int numManifolds = dispatcher.getNumManifolds(); /* First iterate through the number of manifolds for the whole dynamics world @@ -399,6 +403,12 @@ } } + /* Generate manifolds using rt */ + rv = generate_manifolds(sim_params->gedp, sim_params); + if (rv != GED_OK) { + bu_log("nearphase_callback: ERROR while calculating manifolds\n"); + } + //Can un-comment this line, and then all points are removed //contactManifold->clearManifold(); } @@ -471,10 +481,12 @@ * */ extern "C" int -run_simulation(struct simulation_params *sim_params) +run_simulation(struct simulation_params *sp) { //int i; + sim_params = sp; + //for (i=0 ; i < sim_params->duration ; i++) { // Initialize the physics world @@ -503,7 +515,7 @@ dynamicsWorld->setGravity(btVector3(0, 0, -10)); //Add the rigid bodies to the world, including the ground plane - add_rigid_bodies(dynamicsWorld, sim_params, collision_shapes); + add_rigid_bodies(dynamicsWorld, collision_shapes); //Add a broadphase callback to hook to the AABB detection algos btOverlapFilterCallback * filterCallback = new broadphase_callback(); @@ -518,10 +530,10 @@ gContactDestroyedCallback = contact_destroyed; //Step the physics the required number of times - step_physics(dynamicsWorld, sim_params); + step_physics(dynamicsWorld); //Get the world transforms back into the simulation params struct - get_transforms(dynamicsWorld, sim_params); + get_transforms(dynamicsWorld); //Clean and free memory used by physics objects cleanup(dynamicsWorld, collision_shapes); Modified: brlcad/trunk/src/libged/simulate/simrt.h =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.h 2011-10-18 14:43:19 UTC (rev 47284) +++ brlcad/trunk/src/libged/simulate/simrt.h 2011-10-18 15:17:58 UTC (rev 47285) @@ -27,6 +27,13 @@ #ifndef SIMRT_H_ #define SIMRT_H_ +#if defined __cplusplus + + /* If the functions in this header have C linkage, this + * will specify linkage for all C++ language compilers */ + extern "C" { +#endif + /* System Headers */ #include <stdlib.h> #include <ctype.h> @@ -235,7 +242,11 @@ int init_rayshot_results(void); +#if defined __cplusplus + } /* matches the linkage specification at the beginning. */ +#endif + #endif /* SIMRT_H_ */ /* Modified: brlcad/trunk/src/libged/simulate/simulate.c =================================================================== --- brlcad/trunk/src/libged/simulate/simulate.c 2011-10-18 14:43:19 UTC (rev 47284) +++ brlcad/trunk/src/libged/simulate/simulate.c 2011-10-18 15:17:58 UTC (rev 47285) @@ -45,7 +45,7 @@ #include "../ged_private.h" #include "simulate.h" #include "simutils.h" -#include "simrt.h" +/*#include "simrt.h"*/ /* The C++ simulation function */ @@ -465,11 +465,11 @@ } /* Generate manifolds using rt */ - rv = generate_manifolds(gedp, &sim_params); +/* rv = generate_manifolds(gedp, &sim_params); if (rv != GED_OK) { bu_vls_printf(gedp->ged_result_str, "%s: ERROR while calculating manifolds\n", argv[0]); return GED_ERROR; - } + }*/ free_bt_manifold_lists(&sim_params); Modified: brlcad/trunk/src/libged/simulate/simulate.h =================================================================== --- brlcad/trunk/src/libged/simulate/simulate.h 2011-10-18 14:43:19 UTC (rev 47284) +++ brlcad/trunk/src/libged/simulate/simulate.h 2011-10-18 15:17:58 UTC (rev 47285) @@ -28,8 +28,16 @@ #ifndef SIMULATE_H_ #define SIMULATE_H_ +#if defined __cplusplus + + /* If the functions in this header have C linkage, this + * will specify linkage for all C++ language compilers */ + extern "C" { +#endif + /* interface headers */ #include "vmath.h" +#include "../ged_private.h" //Copy of the rigid body state tags from btCollisionObject.h @@ -111,10 +119,15 @@ char *ground_plane_name; /**< @brief name of the ground plane region */ struct rigid_body *head_node; /**< @brief link to first rigid body node */ + struct ged *gedp; /**< @brief pass the gfx context to allow lines to be drawn by rt */ + /* Debugging */ int iter; }; +#if defined __cplusplus + } /* matches the linkage specification at the beginning. */ +#endif #endif /* SIMULATE_H_ */ Modified: brlcad/trunk/src/libged/simulate/simutils.h =================================================================== --- brlcad/trunk/src/libged/simulate/simutils.h 2011-10-18 14:43:19 UTC (rev 47284) +++ brlcad/trunk/src/libged/simulate/simutils.h 2011-10-18 15:17:58 UTC (rev 47285) @@ -26,6 +26,13 @@ #ifndef SIMUTILS_H_ #define SIMUTILS_H_ +#if defined __cplusplus + + /* If the functions in this header have C linkage, this + * will specify linkage for all C++ language compilers */ + extern "C" { +#endif + /* System Headers */ #include <stdlib.h> #include <ctype.h> @@ -173,9 +180,6 @@ insert_manifolds(struct ged *gedp, struct simulation_params *sim_params, struct rigid_body *rb); -#endif /* SIMUTILS_H_ */ - - /** * This function creates and inserts a RPP * Used to show AABB overlap volume @@ -185,6 +189,14 @@ int make_rpp(struct ged *gedp, vect_t max, vect_t min, char* name); + +#if defined __cplusplus + } /* matches the linkage specification at the beginning. */ +#endif + + +#endif /* SIMUTILS_H_ */ + /* * Local Variables: * tab-width: 8 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