public DContactGeomBuffer getGeomBuffer() { return new DContactGeomBuffer(this); }
/** * * @return The first contact. */ public DContactGeom get() { return get(0); }
static void space_geom_collider (Object data, DxGeom o1, DxGeom o2) { SpaceGeomColliderData d = (SpaceGeomColliderData) data; if ((d.flags & DxGeom.NUMC_MASK) != 0) { // int n = dCollide (o1,o2,d.flags,d.contact,d.skip); // d.contact = CONTACT (d.contact,d.skip*n); // int n = DxGeom.dCollide (o1,o2,d.flags,d._contacts, d.skip); //d.contact = CONTACT (d.contact,d.skip*n); //d.contact = ((SpaceGeomColliderData)data).contact[n]; d._contacts = ((SpaceGeomColliderData)data)._contacts.createView(n); d.flags -= n; } }
private void nearCallback (Object data, DGeom o1, DGeom o2) { int n; final int N = 100; //dContactGeom contact[N]; DContactGeomBuffer contacts = new DContactGeomBuffer(N); if (o2 instanceof DRay) { n = OdeHelper.collide (o2,o1,N,contacts);//,sizeof(dContactGeom)); } else { n = OdeHelper.collide (o1,o2,N,contacts);//,sizeof(dContactGeom)); } if (n > 0) { DMatrix3 RI = new DMatrix3(); RI.setIdentity(); DVector3 ss = new DVector3(0.01,0.01,0.01); for (int i=0; i<n; i++) { DContactGeom contact = contacts.get(i); contact.pos.add2( Z_OFFSET ); dsDrawBox (contact.pos,RI,ss); DVector3 n2 = new DVector3(); //for (j=0; j<3; j++) n[j] = contact[i].pos[j] + 0.1*contact[i].normal[j]; n2.eqSum(contact.pos, contact.normal, 0.1); dsDrawLine (contact.pos,n2); } } }
contacts.get(0).g1 = cyl1; contacts.get(0).g2 = cyl2; contacts.get(0).side1 = -1; contacts.get(0).side2 = -1; DContactGeomBuffer c2 = contacts.createView(skip); int n2 = DxCollisionUtil.dCollideSpheres (sphere1,cyl1._radius, sphere2,cyl2._radius, c2); if (n2!=0) { c2.get().g1 = cyl1; c2.get().g2 = cyl2; c2.get().side1 = -1; c2.get().side2 = -1; return 2;
private int TestCollisionForSingleTriangle(int ctContacts0, int Triint, DVector3 dv[], RefBoolean bOutFinishSearching) { // test this triangle _cldTestOneTriangle(dv[0],dv[1],dv[2],Triint); // fill-in tri index for generated contacts for (; ctContacts0 < m_ctContacts.i; ctContacts0++) { //DContactGeom pContact = SAFECONTACT(m_iFlags, m_ContactGeoms, ctContacts0, m_iStride); DContactGeom pContact = m_ContactGeoms.getSafe(m_iFlags, ctContacts0); pContact.side1 = Triint; pContact.side2 = -1; } /* NOTE by Oleh_Derevenko: The function continues checking triangles after maximal number of contacts is reached because it selects maximal penetration depths. See also comments in GenerateContact() */ bOutFinishSearching.b = ((m_ctContacts.i | CONTACTS_UNIMPORTANT) == (m_iFlags & (DxGeom.NUMC_MASK | CONTACTS_UNIMPORTANT))); return ctContacts0; }
private void nearCallback (Object data, DGeom o1, DGeom o2) { int i,n; final int N = 100; //dContactGeom contact[N]; DContactGeomBuffer contacts = new DContactGeomBuffer(N); if (o2 instanceof DRay) { n = dCollide (o2,o1,N,contacts);//,sizeof(dContactGeom)); } else { n = dCollide (o1,o2,N,contacts);//,sizeof(dContactGeom)); } if (n > 0) { DMatrix3 RI = new DMatrix3(); RI.setIdentity();//dRSetIdentity (RI); DVector3 ss = new DVector3(0.01,0.01,0.01); for (i=0; i<n; i++) { DContactGeom contact = contacts.get(i); contact.pos.add(2, Z_OFFSET ); dsDrawBox (contact.pos,RI,ss); DVector3 n2 = new DVector3(); //for (j=0; j<3; j++) n[j] = contact[i].pos[j] + 0.1*contact[i].normal[j]; n2.eqSum(contact.pos, contact.normal, 0.1); dsDrawLine (contact.pos,n2); } } }
contacts.get(0).g1 = cyl1; contacts.get(0).g2 = cyl2; contacts.get(0).side1 = -1; contacts.get(0).side2 = -1; DContactGeomBuffer c2 = contacts.createView(skip); int n2 = DxCollisionUtil.dCollideSpheres (sphere1,cyl1._radius, sphere2,cyl2._radius, c2); if (n2!=0) { c2.get().g1 = cyl1; c2.get().g2 = cyl2; c2.get().side1 = -1; c2.get().side2 = -1; return 2;
private int TestCollisionForSingleTriangle(int ctContacts0, int Triint, DVector3 dv[], RefBoolean bOutFinishSearching) { // test this triangle _cldTestOneTriangle(dv[0],dv[1],dv[2],Triint); // fill-in tri index for generated contacts for (; ctContacts0 < m_ctContacts.i; ctContacts0++) { //DContactGeom pContact = SAFECONTACT(m_iFlags, m_ContactGeoms, ctContacts0, m_iStride); DContactGeom pContact = m_ContactGeoms.getSafe(m_iFlags, ctContacts0); pContact.side1 = Triint; pContact.side2 = -1; } /* NOTE by Oleh_Derevenko: The function continues checking triangles after maximal number of contacts is reached because it selects maximal penetration depths. See also comments in GenerateContact() */ bOutFinishSearching.b = ((m_ctContacts.i | CONTACTS_UNIMPORTANT) == (m_iFlags & (DxGeom.NUMC_MASK | CONTACTS_UNIMPORTANT))); return ctContacts0; }
final DVector3[] triangle = new DVector3[] { new DVector3(), new DVector3(), new DVector3() }; int contactcount = 0; DContactGeomBuffer tempContacts = new DContactGeomBuffer(1); for (int i : triindices) { ((DxTriMesh) o2).FetchTransformedTriangle(i, triangle); if (ccdCollide(o1, o2, flags, tempContacts, c1, ccdSupportConvex, ccdCenter, c2, ccdSupportTriangle, ccdCenter) == 1) { DContactGeom tempContact = tempContacts.get(); tempContact.side2 = i; if (correctContactNormal(c2, tempContact, triangle, o2, triindices)) { DContactGeom contact = contacts.get(0); ((DxTriMesh) o2).FetchTransformedTriangle(contact.side2, triangle); contactcount = addPerturbedContacts(o1, o2, flags, c1, c2, contacts, triangle, contact, contactcount, contact = contacts.get(i); contact.normal.safeNormalize();
/** * * @return The first contact. */ public DContactGeom get() { return get(0); }
flags, contacts.createView(numTerrainContacts*skip), skip ); dIASSERT( numTerrainContacts <= numMaxTerrainContacts ); pContact = contacts.get(i*skip);//CONTACT(contact,i*skip); pContact.g1 = o1; pContact.g2 = o2; pContact = contacts.get(i*skip);//CONTACT(contact,i*skip); for ( i = 0; i < numTerrainContacts; ++i ) pContact = contacts.get(i*skip);//CONTACT(contact,i*skip); pContact.pos.add( 0, -terrain.m_p_data.m_fHalfWidth ); pContact.pos.add( 2, -terrain.m_p_data.m_fHalfDepth );
public DContactGeomBuffer createView(int skip) { return new DContactGeomBuffer(this, skip); }
Contact = contacts.getSafe(m_iFlags, nFinalContact); Contact.depth = m_gLocalContacts[iContact].fDepth;
static void space_geom_collider (Object data, DxGeom o1, DxGeom o2) { SpaceGeomColliderData d = (SpaceGeomColliderData) data; if ((d.flags & DxGeom.NUMC_MASK) != 0) { // int n = dCollide (o1,o2,d.flags,d.contact,d.skip); // d.contact = CONTACT (d.contact,d.skip*n); // int n = DxGeom.dCollide (o1,o2,d.flags,d._contacts, d.skip); //d.contact = CONTACT (d.contact,d.skip*n); //d.contact = ((SpaceGeomColliderData)data).contact[n]; d._contacts = ((SpaceGeomColliderData)data)._contacts.createView(n); d.flags -= n; } }
final DVector3[] triangle = new DVector3[] { new DVector3(), new DVector3(), new DVector3() }; int contactcount = 0; DContactGeomBuffer tempContacts = new DContactGeomBuffer(1); for (int i : triindices) { ((DxTriMesh) o2).FetchTransformedTriangle(i, triangle); if (ccdCollide(o1, o2, flags, tempContacts, c1, ccdSupportConvex, ccdCenter, c2, ccdSupportTriangle, ccdCenter) == 1) { DContactGeom tempContact = tempContacts.get(); tempContact.side2 = i; if (correctContactNormal(c2, tempContact, triangle, o2, triindices)) { DContactGeom contact = contacts.get(0); ((DxTriMesh) o2).FetchTransformedTriangle(contact.side2, triangle); contactcount = addPerturbedContacts(o1, o2, flags, c1, c2, contacts, triangle, contact, contactcount, contact = contacts.get(i); contact.normal.safeNormalize();
public DContactGeom getSafe(int flags, int index) { if (!(index >= 0 && index < (flags & DxGeom.NUMC_MASK))) { throw new IllegalStateException("Index="+index + "; flags="+flags); } return get(index); }
flags, contacts.createView(numTerrainContacts*skip), skip ); dIASSERT( numTerrainContacts <= numMaxTerrainContacts ); pContact = contacts.get(i*skip);//CONTACT(contact,i*skip); pContact.g1 = o1; pContact.g2 = o2; pContact = contacts.get(i*skip);//CONTACT(contact,i*skip); for ( i = 0; i < numTerrainContacts; ++i ) pContact = contacts.get(i*skip);//CONTACT(contact,i*skip); pContact.pos.add( 0, -terrain.m_p_data.m_fHalfWidth ); pContact.pos.add( 2, -terrain.m_p_data.m_fHalfDepth );
public DContactGeomBuffer getGeomBuffer() { return new DContactGeomBuffer(this); }
Contact = contacts.getSafe(m_iFlags, nFinalContact); Contact.depth = m_gLocalContacts[iContact].fDepth;