Revision: 47267 http://brlcad.svn.sourceforge.net/brlcad/?rev=47267&view=rev Author: abhi2011 Date: 2011-10-15 21:41:16 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Bullet seems to be deleting the contact pairs, added some more callbacks to investigate
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/simulate.c Modified: brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp 2011-10-15 20:27:56 UTC (rev 47266) +++ brlcad/trunk/src/libged/simulate/simcollisionalgo.cpp 2011-10-15 21:41:16 UTC (rev 47267) @@ -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,8 +93,8 @@ 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 --------------------------- Modified: brlcad/trunk/src/libged/simulate/simphysics.cpp =================================================================== --- brlcad/trunk/src/libged/simulate/simphysics.cpp 2011-10-15 20:27:56 UTC (rev 47266) +++ brlcad/trunk/src/libged/simulate/simphysics.cpp 2011-10-15 21:41:16 UTC (rev 47267) @@ -407,6 +407,64 @@ /** + * Called whenever a contact pair is added to a manifold + */ +bool contact_added( + btManifoldPoint& pt, + const btCollisionObject* col0, + int partId0, + int index0, + const btCollisionObject* col1, + int partId1, + int index1) +{ + //Get the user pointers to struct rigid_body, for printing the body name + struct rigid_body *rbA = (struct rigid_body *)col0->getUserPointer(); + struct rigid_body *rbB = (struct rigid_body *)col1->getUserPointer(); + + btVector3 ptA = pt.getPositionWorldOnA(); + btVector3 ptB = pt.getPositionWorldOnB(); + + bu_log("Contact added between %s(%f, %f, %f):%d,%d & %s(%f, %f, %f):%d,%d!", + rbA->rb_namep, V3ARGS(ptA), partId0, index0, + rbB->rb_namep, V3ARGS(ptB), partId1, index1); + + return true; +} + + +/** + * Called whenever a contact pair is finished processing by the constraint + * solver + */ +bool contact_processed(btManifoldPoint& pt, void* col0, void* col1) +{ + //Get the user pointers to struct rigid_body, for printing the body name + struct rigid_body *rbA = (struct rigid_body *)((btCollisionObject*)col0)->getUserPointer(); + struct rigid_body *rbB = (struct rigid_body *)((btCollisionObject*)col1)->getUserPointer(); + + btVector3 ptA = pt.getPositionWorldOnA(); + btVector3 ptB = pt.getPositionWorldOnB(); + + bu_log("Contact processed between %s(%f, %f, %f) & %s(%f, %f, %f)!", + rbA->rb_namep, V3ARGS(ptA), + rbB->rb_namep, V3ARGS(ptB)); + + + return true; +} + + +/** + * Called when a contact pair's lifetime has expired and it's deleted + */ +bool contact_destroyed(void* userPersistentData) +{ + bu_log("CONTACT DESTROYED! %s", (char*)userPersistentData); + return true; +} + +/** * C++ wrapper for doing physics using bullet * */ @@ -452,6 +510,11 @@ //Add a nearphase callback to hook to the contact points generation algos dispatcher->setNearCallback((btNearCallback)nearphase_callback); + //Investigating the contact pairs used between 2 rigid bodies + gContactAddedCallback = contact_added; + gContactProcessedCallback = contact_processed; + gContactDestroyedCallback = contact_destroyed; + //Step the physics the required number of times step_physics(dynamicsWorld, sim_params); Modified: brlcad/trunk/src/libged/simulate/simrt.c =================================================================== --- brlcad/trunk/src/libged/simulate/simrt.c 2011-10-15 20:27:56 UTC (rev 47266) +++ brlcad/trunk/src/libged/simulate/simrt.c 2011-10-15 21:41:16 UTC (rev 47267) @@ -542,13 +542,13 @@ VSUB2(diff, overlap_max, overlap_min); /* Is it thinner than TOLerance ? */ - if(diff[Z] < TOL){ + /*if(diff[Z] < TOL){*/ /* Yep , so shoot rays only in a single plane in the middle of the overlap region*/ startz = overlap_min[Z] + diff[Z]*0.5; /* The overlap region is too thin for generating 4 contacts points, 2 will do */ - for(z=startz; z<(overlap_max[Z]+TOL); z += TOL){ + for(z=startz; z<overlap_max[Z]; z += TOL){ for(y=starty; y<(overlap_max[Y]+TOL); y += TOL){ /* Shooting towards lower x, so start from max x outside of overlap box */ @@ -574,7 +574,7 @@ bu_log("Last y ray fired from z=%f, y=%f , overlap_max[Z]=%f, overlap_max[Y]=%f", z, y, overlap_max[Z], overlap_max[Y]); } - } + /*}*/ return GED_OK; Modified: brlcad/trunk/src/libged/simulate/simulate.c =================================================================== --- brlcad/trunk/src/libged/simulate/simulate.c 2011-10-15 20:27:56 UTC (rev 47266) +++ brlcad/trunk/src/libged/simulate/simulate.c 2011-10-15 21:41:16 UTC (rev 47267) @@ -446,6 +446,13 @@ /* Recreate sim.c to clear AABBs and manifold regions from previous iteration */ recreate_sim_comb(gedp, &sim_params); + /* Generate manifolds using rt */ + 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; + } + /* Run the physics simulation */ rv = run_simulation(&sim_params); if (rv != GED_OK) { @@ -460,13 +467,6 @@ return GED_ERROR; } - /* Generate manifolds using rt */ - 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_manifold_lists(&sim_params); } 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