DxGeom g0 = buffer.get(i); DAABB aabb0 = g0._aabb; final double idx0ax0max = aabb0.getMax(ax0id);//(ax0idx+1); for (int j = i+1; j < size; j++) { DxGeom g1 = buffer.get(j); if (g1._aabb.getMin(ax0id) > idx0ax0max) { if ( aabb0.getMax(ax1id) >= g1._aabb.getMin(ax1id)) if (g1._aabb.getMax(ax1id) >= aabb0.getMin(ax1id) ) if ( aabb0.getMax(ax2id) >= g1._aabb.getMin(ax2id)) if (g1._aabb.getMax(ax2id) >= aabb0.getMin(ax2id) ) collideGeomsNoAABBs(g0, g1, data, callback);
if (bounds[i] == null) bounds[i] = new DAABB(); bounds[i].setMin0( dRandReal()*2-1 ); bounds[i].setMax0( bounds[i].getMin0() + dRandReal()*scale ); bounds[i].setMin1( dRandReal()*2-1 ); bounds[i].setMax1( bounds[i].getMin1() + dRandReal()*scale ); bounds[i].setMin2( dRandReal()*2 ); bounds[i].setMax2( bounds[i].getMin2() + dRandReal()*scale ); bounds[i].len0(), bounds[i].len1(), bounds[i].len2()); geom[i].setPosition (bounds[i].getCenter()); if (bounds[i].isDisjoint(bounds[j])) continue; good_matrix[i][j] = true; good_matrix[j][i] = true;
DAABB aabbbak = new DAABB(); int gflagsbak = 0; DVector3 pos0 = new DVector3(), pos1 = new DVector3(); aabbbak.set(o2._aabb);//memcpy( aabbbak, o2.aabb, sizeof( double ) * 6 ); if ( o2._aabb.getMin0() > terrain.m_p_data.m_fWidth //MinX || o2._aabb.getMin2() > terrain.m_p_data.m_fDepth) { //MinZ if ( o2._aabb.getMax0() < 0 //MaxX || o2._aabb.getMax2() < 0) { //MaxZ int nMinX = (int)dFloor(Common.dNextAfter(o2._aabb.getMin0() * fInvSampleWidth, -dInfinity)); int nMaxX = (int)dCeil(Common.dNextAfter(o2._aabb.getMax0() * fInvSampleWidth, dInfinity)); final double fInvSampleDepth = terrain.m_p_data.m_fInvSampleDepth; int nMinZ = (int)dFloor(Common.dNextAfter(o2._aabb.getMin2() * fInvSampleDepth, -dInfinity)); int nMaxZ = (int)dCeil(Common.dNextAfter(o2._aabb.getMax2() * fInvSampleDepth, dInfinity)); o2._aabb.set(aabbbak);
DAABB aabb = new DAABB(); dGeomGetAABB (g,aabb); DVector3 bbpos = new DVector3(); for (i=0; i<3; i++) bbpos.set(i, 0.5*(aabb.getMin(i) + aabb.getMax(i)) ); DVector3 bbsides = new DVector3(); for (i=0; i<3; i++) bbsides.set(i, aabb.getMax(i) - aabb.getMin(i) ); DMatrix3 RI = new DMatrix3(); RI.setIdentity();
private static int findLevel (DAABB boundsV) //[6]) { //double[] bounds = boundsV.v; // if (bounds[0] <= -dInfinity || bounds[1] >= dInfinity || // bounds[2] <= -dInfinity || bounds[3] >= dInfinity || // bounds[4] <= -dInfinity || bounds[5] >= dInfinity) { // return MAXINT; // } if (!boundsV.isValid()) { return MAXINT; } // compute q double q,q2; q = boundsV.len0();//bounds[1] - bounds[0]; // x bounds q2 = boundsV.len1();//bounds[3] - bounds[2]; // y bounds if (q2 > q) q = q2; q2 = boundsV.len2();//bounds[5] - bounds[4]; // z bounds if (q2 > q) q = q2; // find level such that 0.5 * 2^level < q <= 2^level RefInt level = new RefInt(); frexp (q,level); // q = (0.5 .. 1.0) * 2^level (definition of frexp) return level.i; } // find a virtual memory address for a cell at the given level and x,y,z
@Override void computeAABB() { if (_first != null) { // int i; // double[] a = new double[6]; DAABB aabb = new DAABB(); aabb.set( dInfinity, -dInfinity, dInfinity, -dInfinity, dInfinity, -dInfinity); // a[0] = dInfinity; // a[1] = -dInfinity; // a[2] = dInfinity; // a[3] = -dInfinity; // a[4] = dInfinity; // a[5] = -dInfinity; for (DxGeom g=_first; g != null; g=g.getNext()) { g.recomputeAABB(); // for (i=0; i<6; i += 2) if (g._aabb.get(i) < a[i]) a[i] = g._aabb.get(i); // for (i=1; i<6; i += 2) if (g._aabb.get(i) > a[i]) a[i] = g._aabb.get(i); aabb.expand(g.getAABB()); } //memcpy(aabb,a,6*sizeof(double)); _aabb.set(aabb); } else { _aabb.setZero(); } }
DAABB aabb = new DAABB(); dGeomGetAABB( g,aabb ); DVector3 bbpos = aabb.getCenter(); DVector3 bbsides = aabb.getLengths();
private void simLoop (boolean pause) { int i,j; for (i=0; i < NUM; i++) { for (j=0; j < NUM; j++) test_matrix[i][j] = false; } OdeHelper.spaceCollide (space,0,nearCallback); for (i=0; i < NUM; i++) { for (j=i+1; j < NUM; j++) { if (good_matrix[i][j] && !test_matrix[i][j]) { System.out.println ("failed to report collision ("+i+","+j+") (seed="+seed+")"); } } } seed++; init_test(); for (i=0; i<NUM; i++) { DMatrix3 R = new DMatrix3(); R.setIdentity(); DVector3 pos = bounds[i].getCenter(); DVector3 side = bounds[i].getLengths(); if (hits[i] > 0) dsSetColor (1,0,0); else dsSetColor (1,1,0); dsDrawBox (pos,R,side); } }
@Override public void cleanGeoms() { // compute the AABBs of all dirty geoms, clear the dirty flags, // remove from dirty list lock_count++; if (dirtyGeoms) { for (DxGeom g : dirty) { if (g instanceof DSpace) { ((DSpace) g).cleanGeoms(); } g.recomputeAABB(); g.unsetFlagDirtyAndBad(); } for (Iterator<DxGeom> iter = infGeomList.iterator(); iter.hasNext();) { DxGeom g = iter.next(); if (g._aabb.getMax(ax0id) != dInfinity) { iter.remove(); normGeomList.add(g); } } Collections.sort(normGeomList, new GeomComparator()); dirty.clear(); dirtyGeoms = false; bvhNodes.clear(); } lock_count--; }
while (i < size) { BVHNode node = bvhNodes.get(i); boolean overlap = !node.aabb.isDisjoint(aabb); boolean isLeafNode = node.escape >= 0; if (isLeafNode && overlap) {
DAABB aabbbak = new DAABB(); int gflagsbak = 0; DVector3 pos0 = new DVector3(), pos1 = new DVector3(); aabbbak.set(o2._aabb);//memcpy( aabbbak, o2.aabb, sizeof( double ) * 6 ); if ( o2._aabb.getMin0() > terrain.m_p_data.m_fWidth //MinX || o2._aabb.getMin2() > terrain.m_p_data.m_fDepth) { //MinZ if ( o2._aabb.getMax0() < 0 //MaxX || o2._aabb.getMax2() < 0) { //MaxZ int nMinX = (int)dFloor(Common.dNextAfter(o2._aabb.getMin0() * fInvSampleWidth, -dInfinity)); int nMaxX = (int)dCeil(Common.dNextAfter(o2._aabb.getMax0() * fInvSampleWidth, dInfinity)); final double fInvSampleDepth = terrain.m_p_data.m_fInvSampleDepth; int nMinZ = (int)dFloor(Common.dNextAfter(o2._aabb.getMin2() * fInvSampleDepth, -dInfinity)); int nMaxZ = (int)dCeil(Common.dNextAfter(o2._aabb.getMax2() * fInvSampleDepth, dInfinity)); o2._aabb.set(aabbbak);
DAABB aabb = new DAABB(); dGeomGetAABB (g,aabb); DVector3 bbpos = new DVector3(); for (int i=0; i<3; i++) bbpos.set(i, 0.5*(aabb.getMin(i) + aabb.getMax(i)) ); DVector3 bbsides = new DVector3(); for (int j=0; j<3; j++) bbsides.set(j, aabb.getMax(j) - aabb.getMin(j) ); DMatrix3 RI = new DMatrix3(); dRSetIdentity (RI);
private static int findLevel (DAABB boundsV) //[6]) { //double[] bounds = boundsV.v; // if (bounds[0] <= -dInfinity || bounds[1] >= dInfinity || // bounds[2] <= -dInfinity || bounds[3] >= dInfinity || // bounds[4] <= -dInfinity || bounds[5] >= dInfinity) { // return MAXINT; // } if (!boundsV.isValid()) { return MAXINT; } // compute q double q,q2; q = boundsV.len0();//bounds[1] - bounds[0]; // x bounds q2 = boundsV.len1();//bounds[3] - bounds[2]; // y bounds if (q2 > q) q = q2; q2 = boundsV.len2();//bounds[5] - bounds[4]; // z bounds if (q2 > q) q = q2; // find level such that 0.5 * 2^level < q <= 2^level RefInt level = new RefInt(); frexp (q,level); // q = (0.5 .. 1.0) * 2^level (definition of frexp) return level.i; } // find a virtual memory address for a cell at the given level and x,y,z