inline void _collisonInstrumentTissue( //Input parameters: const bool hastopologychange, //Topology change? const double &cur_time, //current time, in mili-sec CSceneGraph &tissue, //The scene graph with tissue objects in CSceneGraph &instrument, //instruments const Vector3d*fortDeformedVert,//the deformed vertices, in fortran array (starting at 1, 0 is for omit the adding 1) const int BUFFERLIMIT, //Output buffer size limit int &nBufferLength, // int indexbuffer[], // Vector3d dispbuffer[]) // { int nTotalFace; if (objs.m_nObjects==0){ const bool updateonly = false; const int ntool = addInstrumentObjects(instrument, objs, updateonly); if (ntool<=0) return; const int ntissue = addTissueObjects(fortDeformedVert, tissue, objs, hastopologychange, updateonly, nTotalFace); if (ntissue<=0) return; } else{ const bool updateonly = true; addInstrumentObjects(instrument, objs, updateonly); addTissueObjects(fortDeformedVert, tissue, objs, hastopologychange, updateonly, nTotalFace); } //do collsion detection if (nTotalFace==0){//If there is no object boundary surface in the scene, no need printf("SCENE EMPTY! HALT!\n"); exit(0); nBufferLength = 0; } else{ printf("Total %d triangles for CD!\n", nTotalFace); runCollisionDetection(objs); parseCollisionResults(objs, fortDeformedVert, BUFFERLIMIT, nBufferLength, indexbuffer, dispbuffer); } //----report buffer info. //printf("Collision buffer size %d.\n", nBufferLength); for (int i=0; i<nBufferLength; i++){ const int vv = indexbuffer[i]; const double x = dispbuffer[i].x; const double y = dispbuffer[i].y; const double z = dispbuffer[i].z; printf("VID %d, %lg %lg %lg\n", vv, x, y, z); } //nBufferLength = 0; if (USE_INTERNAL_SIMULATOR){ const int nv=nBufferLength; const int *pVertexID = indexbuffer; const Vector3d *pVertexPos = dispbuffer; CSimuEngine *peng = CSimuEngine::getInstance(); const double inputTimeInterval=200.00; //33 milisec (30hz) impluse contraint peng->updateCollisionConstraint(pVertexPos, pVertexID, nv, cur_time, inputTimeInterval); } }
void display ( void ) { if ( debugOpt != DRAW_WITHOUT_SHADERS && debugOpt != DRAW_WITHOUT_PHYSICS ) { runCollisionDetection () ; runPhysics () ; } /* Now render the scene using the results */ glViewport ( 0, 0, win_width, win_height ) ; drawCubes () ; /* All done! */ glutSwapBuffers () ; glutPostRedisplay () ; }