You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(18) |
Apr
(29) |
May
(32) |
Jun
(17) |
Jul
(34) |
Aug
(12) |
Sep
(39) |
Oct
(9) |
Nov
(20) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(13) |
Feb
(9) |
Mar
(1) |
Apr
(17) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(9) |
Sep
(65) |
Oct
(22) |
Nov
(23) |
Dec
(28) |
2008 |
Jan
(18) |
Feb
(4) |
Mar
(69) |
Apr
(33) |
May
(11) |
Jun
(39) |
Jul
(22) |
Aug
(13) |
Sep
(1) |
Oct
(43) |
Nov
(5) |
Dec
(13) |
2009 |
Jan
(31) |
Feb
(12) |
Mar
(6) |
Apr
(6) |
May
(9) |
Jun
(9) |
Jul
(1) |
Aug
(5) |
Sep
(5) |
Oct
(11) |
Nov
(4) |
Dec
(6) |
2010 |
Jan
(8) |
Feb
(3) |
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(5) |
Aug
(17) |
Sep
(6) |
Oct
(5) |
Nov
(6) |
Dec
(5) |
2011 |
Jan
(13) |
Feb
(2) |
Mar
(4) |
Apr
(12) |
May
(16) |
Jun
(4) |
Jul
(3) |
Aug
|
Sep
(4) |
Oct
(8) |
Nov
(5) |
Dec
(12) |
2012 |
Jan
(2) |
Feb
(8) |
Mar
(13) |
Apr
(6) |
May
(4) |
Jun
(3) |
Jul
(9) |
Aug
(1) |
Sep
|
Oct
|
Nov
(3) |
Dec
(16) |
2013 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <br...@us...> - 2013-03-06 05:09:51
|
Revision: 1929 http://opende.svn.sourceforge.net/opende/?rev=1929&view=rev Author: bram Date: 2013-03-06 05:09:43 +0000 (Wed, 06 Mar 2013) Log Message: ----------- Applied JC's patch for bug #87 cyl-ray collisions missing. Modified Paths: -------------- trunk/ode/demo/demo_collision.cpp trunk/ode/src/ray.cpp Modified: trunk/ode/demo/demo_collision.cpp =================================================================== --- trunk/ode/demo/demo_collision.cpp 2013-03-03 17:08:44 UTC (rev 1928) +++ trunk/ode/demo/demo_collision.cpp 2013-03-06 05:09:43 UTC (rev 1929) @@ -44,6 +44,7 @@ #define dsDrawBox dsDrawBoxD #define dsDrawLine dsDrawLineD #define dsDrawCapsule dsDrawCapsuleD +#define dsDrawCylinder dsDrawCylinderD #endif //**************************************************************************** @@ -190,6 +191,13 @@ dsDrawCapsule (pos,dGeomGetRotation(g),length,radius); break; } + case dCylinderClass: { + dsSetColorAlpha (0,1,0,0.8); + dReal radius,length; + dGeomCylinderGetParams (g,&radius,&length); + dsDrawCylinder (pos,dGeomGetRotation(g),length,radius); + break; + } case dPlaneClass: { dVector4 n; @@ -846,7 +854,69 @@ PASSED(); } +/* + Test rays within the cylinder + -completely inside + -exiting through side + -exiting through cap + -exiting through corner + Test rays outside the cylinder +*/ +int test_ray_and_cylinder() +{ + int j; + dContactGeom contact; + dVector3 p,a,b,n; + dMatrix3 R; + dReal r,l,k,x,y; + const int positions = 5; + const int slices = 13; + const int pitch = 11; + dSimpleSpace space(0); + dGeomID ray = dCreateRay(space,4); + dGeomID cyl = dCreateCylinder(space,0.5,1); + + // The first thing that happens is the ray is + // rotated into cylinder coordinates. We'll trust that's + // done right. The major axis is in the z-dir. + + + // Random tests + /*b[0]=4*dRandReal()-2; + b[1]=4*dRandReal()-2; + b[2]=4*dRandReal()-2; + a[0]=2*dRandReal()-1; + a[1]=2*dRandReal()-1; + a[2]=2*dRandReal()-1;*/ + + // Inside out + b[0]=dRandReal()-0.5; + b[1]=dRandReal()-0.5; + b[2]=dRandReal()-0.5; + a[0]=2*dRandReal()-1; + a[1]=2*dRandReal()-1; + a[2]=2*dRandReal()-1; + + // Outside in + /*b[0]=4*dRandReal()-2; + b[1]=4*dRandReal()-2; + b[2]=4*dRandReal()-2; + a[0]=-b[0]; + a[1]=-b[1]; + a[2]=-b[2];*/ + + + dGeomRaySet (ray,b[0],b[1],b[2],a[0],a[1],a[2]); + // This is just for visual inspection right now. + //if (dCollide (ray,cyl,1,&contact,sizeof(dContactGeom)) != 1) FAILED(); + + draw_all_objects (space); + + PASSED(); +} + + int test_ray_and_plane() { int j; @@ -1364,6 +1434,7 @@ MAKE_TEST(11,test_ray_and_box); MAKE_TEST(12,test_ray_and_ccylinder); MAKE_TEST(13,test_ray_and_plane); + MAKE_TEST(14,test_ray_and_cylinder); MAKE_TEST(100,test_dBoxTouchesBox); MAKE_TEST(101,test_dBoxBox); Modified: trunk/ode/src/ray.cpp =================================================================== --- trunk/ode/src/ray.cpp 2013-03-03 17:08:44 UTC (rev 1928) +++ trunk/ode/src/ray.cpp 2013-03-06 05:09:43 UTC (rev 1929) @@ -496,7 +496,7 @@ return 1; } -// Ray - Cylinder collider by David Walters (June 2006) +// Ray-Cylinder collider by Joseph Cooper (2011) int dCollideRayCylinder( dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, int skip ) { dIASSERT( skip >= (int)sizeof( dContactGeom ) ); @@ -515,184 +515,182 @@ const dReal half_length = cyl->lz * REAL( 0.5 ); - // - // Compute some useful info - // - dVector3 q, r; - dReal d, C, k; - - // Vector 'r', line segment from C to R (ray start) ( r = R - C ) - r[ 0 ] = ray->final_posr->pos[0] - cyl->final_posr->pos[0]; - r[ 1 ] = ray->final_posr->pos[1] - cyl->final_posr->pos[1]; - r[ 2 ] = ray->final_posr->pos[2] - cyl->final_posr->pos[2]; - - // Distance that ray start is along cyl axis ( Z-axis direction ) - d = dCalcVectorDot3_41( cyl->final_posr->R + 2, r ); - + // Possible collision cases: + // Ray origin between/outside caps + // Ray origin within/outside radius + // Ray direction left/right/perpendicular + // Ray direction parallel/perpendicular/other + // + // Ray origin cases (ignoring origin on surface) // - // Compute vector 'q' representing the shortest line from R to the cylinder z-axis (Cz). + // A B + // /-\-----------\ + // C ( ) D ) + // \_/___________/ // - // Point on axis ( in world space ): cp = ( d * Cz ) + C - // - // Line 'q' from R to cp: q = cp - R - // q = ( d * Cz ) + C - R - // q = ( d * Cz ) - ( R - C ) + // Cases A and D can collide with caps or cylinder + // Case C can only collide with the caps + // Case B can only collide with the cylinder + // Case D will produce inverted normals + // If the ray is perpendicular, only check the cylinder + // If the ray is parallel to cylinder axis, + // we can only check caps + // If the ray points right, + // Case A,C Check left cap + // Case D Check right cap + // If the ray points left + // Case A,C Check right cap + // Case D Check left cap + // Case B, check only first possible cylinder collision + // Case D, check only second possible cylinder collision - q[ 0 ] = ( d * cyl->final_posr->R[0*4+2] ) - r[ 0 ]; - q[ 1 ] = ( d * cyl->final_posr->R[1*4+2] ) - r[ 1 ]; - q[ 2 ] = ( d * cyl->final_posr->R[2*4+2] ) - r[ 2 ]; + // Find the ray in the cylinder coordinate frame: + dVector3 tmp; + dVector3 pos; // Ray origin in cylinder frame + dVector3 dir; // Ray direction in cylinder frame + // Translate ray start by inverse cyl + dSubtractVectors3(tmp,ray->final_posr->pos,cyl->final_posr->pos); + // Rotate ray start by inverse cyl + dMultiply1_331(pos,cyl->final_posr->R,tmp); + // Get the ray's direction + tmp[0] = ray->final_posr->R[2]; + tmp[1] = ray->final_posr->R[6]; + tmp[2] = ray->final_posr->R[10]; + // Rotate the ray direction by inverse cyl + dMultiply1_331(dir,cyl->final_posr->R,tmp); - // Compute square length of 'q'. Subtract from radius squared to - // get square distance 'C' between the line q and the radius. + // Is the ray origin inside of the (extended) cylinder? + dReal r2 = cyl->radius*cyl->radius; + dReal C = pos[0]*pos[0] + pos[1]*pos[1] - r2; - // if C < 0 then ray start position is within infinite extension of cylinder + // Find the different cases + // Is ray parallel to the cylinder length? + int parallel = (dir[0]==0 && dir[1]==0); + // Is ray perpendicular to the cylinder length? + int perpendicular = (dir[2]==0); + // Is ray origin within the radius of the caps? + int inRadius = (C<=0); + // Is ray origin between the top and bottom caps? + int inCaps = (dFabs(pos[2])<=half_length); - C = dCalcVectorDot3( q, q ) - ( cyl->radius * cyl->radius ); + int checkCaps = (!perpendicular && (!inCaps || inRadius)); + int checkCyl = (!parallel && (!inRadius || inCaps)); + int flipNormals = (inCaps&&inRadius); - // Compute the projection of ray direction normal onto cylinder direction normal. - dReal uv = dCalcVectorDot3_44( cyl->final_posr->R+2, ray->final_posr->R+2 ); + dReal tt=-dInfinity; // Depth to intersection + dVector3 tmpNorm; - - - // - // Find ray collision with infinite cylinder - // - - // Compute vector from end of ray direction normal to projection on cylinder direction normal. - r[ 0 ] = ( uv * cyl->final_posr->R[0*4+2] ) - ray->final_posr->R[0*4+2]; - r[ 1 ] = ( uv * cyl->final_posr->R[1*4+2] ) - ray->final_posr->R[1*4+2]; - r[ 2 ] = ( uv * cyl->final_posr->R[2*4+2] ) - ray->final_posr->R[2*4+2]; - - - // Quadratic Formula Magic - // Compute discriminant 'k': - - // k < 0 : No intersection - // k = 0 : Tangent - // k > 0 : Intersection - - dReal A = dCalcVectorDot3( r, r ); - dReal B = 2 * dCalcVectorDot3( q, r ); - - k = B*B - 4*A*C; - - - - - // - // Collision with Flat Caps ? - // - - // No collision with cylinder edge. ( Use epsilon here or we miss some obvious cases ) - if ( k < dEpsilon && C <= 0 ) - { - // The ray does not intersect the edge of the infinite cylinder, - // but the ray start is inside and so must run parallel to the axis. - // It may yet intersect an end cap. The following cases are valid: - - // -ve-cap , -half centre +half , +ve-cap - // <<================|-------------------|------------->>>---|================>> - // | | - // | d-------------------> 1. - // 2. d------------------> | - // 3. <------------------d | - // | <-------------------d 4. - // | | - // <<================|-------------------|------------->>>---|===============>> - - // Negative if the ray and cylinder axes point in opposite directions. - const dReal uvsign = ( uv < 0 ) ? REAL( -1.0 ) : REAL( 1.0 ); - - // Negative if the ray start is inside the cylinder - const dReal internal = ( d >= -half_length && d <= +half_length ) ? REAL( -1.0 ) : REAL( 1.0 ); - - // Ray and Cylinder axes run in the same direction ( cases 1, 2 ) - // Ray and Cylinder axes run in opposite directions ( cases 3, 4 ) - if ( ( ( uv > 0 ) && ( d + ( uvsign * ray->length ) < half_length * internal ) ) || - ( ( uv < 0 ) && ( d + ( uvsign * ray->length ) > half_length * internal ) ) ) - { - return 0; // No intersection with caps or curved surface. + if (checkCaps) { + // Make it so we only need to check one cap + int flipDir = 0; + // Wish c had logical xor... + if ((dir[2]<0 && flipNormals) || (dir[2]>0 && !flipNormals)) { + flipDir = 1; + dir[2]=-dir[2]; + pos[2]=-pos[2]; } - - // Compute depth (distance from ray to cylinder) - contact->depth = ( ( -uvsign * d ) - ( internal * half_length ) ); - - // Compute contact point. - contact->pos[0] = ray->final_posr->pos[0] + ( contact->depth * ray->final_posr->R[0*4+2] ); - contact->pos[1] = ray->final_posr->pos[1] + ( contact->depth * ray->final_posr->R[1*4+2] ); - contact->pos[2] = ray->final_posr->pos[2] + ( contact->depth * ray->final_posr->R[2*4+2] ); - - // Compute reflected contact normal. - contact->normal[0] = uvsign * ( cyl->final_posr->R[0*4+2] ); - contact->normal[1] = uvsign * ( cyl->final_posr->R[1*4+2] ); - contact->normal[2] = uvsign * ( cyl->final_posr->R[2*4+2] ); - - // Contact! - return 1; + // The cap is half the cylinder's length + // from the cylinder's origin + // We only checkCaps if dir[2]!=0 + tt = (half_length-pos[2])/dir[2]; + if (tt>=0 && tt<=ray->length) { + tmp[0] = pos[0] + tt*dir[0]; + tmp[1] = pos[1] + tt*dir[1]; + // Ensure collision point is within cap circle + if (tmp[0]*tmp[0] + tmp[1]*tmp[1] <= r2) { + // Successful collision + tmp[2] = (flipDir)?-half_length:half_length; + tmpNorm[0]=0; + tmpNorm[1]=0; + tmpNorm[2]=(flipDir!=flipNormals)?-1:1; + checkCyl = 0; // Short circuit cylinder check + } else { + // Ray hits cap plane outside of cap circle + tt=-dInfinity; // No collision yet + } + } else { + // The cap plane is beyond (or behind) the ray length + tt=-dInfinity; // No collision yet + } + if (flipDir) { + // Flip back + dir[2]=-dir[2]; + pos[2]=-pos[2]; + } } + if (checkCyl) { + // Compute quadratic formula for parametric ray equation + dReal A = dir[0]*dir[0] + dir[1]*dir[1]; + dReal B = 2*(pos[0]*dir[0] + pos[1]*dir[1]); + // Already computed C - - - // - // Collision with Curved Edge ? - // - - if ( k > 0 ) - { - // Finish off quadratic formula to get intersection co-efficient - k = dSqrt( k ); - A = dRecip( 2 * A ); - - // Compute distance along line to contact point. - dReal alpha = ( -B - k ) * A; - if ( alpha < 0 ) - { - // Flip in the other direction. - alpha = ( -B + k ) * A; - } - - // Intersection point is within ray length? - if ( alpha >= 0 && alpha <= ray->length ) - { - // The ray intersects the infinite cylinder! - - // Compute contact point. - contact->pos[0] = ray->final_posr->pos[0] + ( alpha * ray->final_posr->R[0*4+2] ); - contact->pos[1] = ray->final_posr->pos[1] + ( alpha * ray->final_posr->R[1*4+2] ); - contact->pos[2] = ray->final_posr->pos[2] + ( alpha * ray->final_posr->R[2*4+2] ); - - // q is the vector from the cylinder centre to the contact point. - q[0] = contact->pos[0] - cyl->final_posr->pos[0]; - q[1] = contact->pos[1] - cyl->final_posr->pos[1]; - q[2] = contact->pos[2] - cyl->final_posr->pos[2]; - - // Compute the distance along the cylinder axis of this contact point. - d = dCalcVectorDot3_14( q, cyl->final_posr->R+2 ); - - // Check to see if the intersection point is between the flat end caps - if ( d >= -half_length && d <= +half_length ) - { - // Flip the normal if the start point is inside the cylinder. - const dReal nsign = ( C < 0 ) ? REAL( -1.0 ) : REAL( 1.0 ); - - // Compute contact normal. - contact->normal[0] = nsign * (contact->pos[0] - (cyl->final_posr->pos[0] + d*cyl->final_posr->R[0*4+2])); - contact->normal[1] = nsign * (contact->pos[1] - (cyl->final_posr->pos[1] + d*cyl->final_posr->R[1*4+2])); - contact->normal[2] = nsign * (contact->pos[2] - (cyl->final_posr->pos[2] + d*cyl->final_posr->R[2*4+2])); - dNormalize3( contact->normal ); - - // Store depth. - contact->depth = alpha; - - // Contact! - return 1; + dReal k = B*B - 4*A*C; + // Check collision with infinite cylinder + // k<0 means the ray passes outside the cylinder + // k==0 means ray is tangent to cylinder (or parallel) + // + // Our quadratic formula: tt = (-B +- sqrt(k))/(2*A) + // + // A must be positive (otherwise we wouldn't be checking + // cylinder because ray is parallel) + // if (k<0) ray doesn't collide with sphere + // if (B > sqrt(k)) then both times are negative + // -- don't calculate + // if (B<-sqrt(k)) then both times are positive (Case A or B) + // -- only calculate first, if first isn't valid + // -- second can't be without first going through a cap + // otherwise (fabs(B)<=sqrt(k)) then C<=0 (ray-origin inside/on cylinder) + // -- only calculate second collision + if (k>=0 && (B<0 || B*B<=k)) { + k = dSqrt(k); + A = dRecip(2*A); + if (dFabs(B)<=k) { + tt = (-B + k)*A; // Second solution + // If ray origin is on surface and pointed out, we + // can get a tt=0 solution... + } else { + tt = (-B - k)*A; // First solution } + if (tt<=ray->length) { + tmp[2] = pos[2] + tt*dir[2]; + if (dFabs(tmp[2])<=half_length) { + // Valid solution + tmp[0] = pos[0] + tt*dir[0]; + tmp[1] = pos[1] + tt*dir[1]; + tmpNorm[0] = tmp[0]/cyl->radius; + tmpNorm[1] = tmp[1]/cyl->radius; + tmpNorm[2] = 0; + if (flipNormals) { + // Ray origin was inside cylinder + tmpNorm[0] = -tmpNorm[0]; + tmpNorm[1] = -tmpNorm[1]; + } + } else { + // Ray hits cylinder outside of caps + tt=-dInfinity; + } + } else { + // Ray doesn't reach the cylinder + tt=-dInfinity; + } } } + if (tt>0) { + contact->depth = tt; + // Transform the point back to world coordinates + tmpNorm[3]=0; + tmp[3] = 0; + dMultiply0_331(contact->normal,cyl->final_posr->R,tmpNorm); + dMultiply0_331(contact->pos,cyl->final_posr->R,tmp); + contact->pos[0]+=cyl->final_posr->pos[0]; + contact->pos[1]+=cyl->final_posr->pos[1]; + contact->pos[2]+=cyl->final_posr->pos[2]; + + return 1; + } // No contact with anything. return 0; } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2013-03-03 17:08:51
|
Revision: 1928 http://opende.svn.sourceforge.net/opende/?rev=1928&view=rev Author: oleh_derevenko Date: 2013-03-03 17:08:44 +0000 (Sun, 03 Mar 2013) Log Message: ----------- Fixed: Fixed issue with "findex==-1" constraints being intermixed with "findex!=-1" ones during constraints random reordering in QuickStep Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/quickstep.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2013-02-09 08:50:21 UTC (rev 1927) +++ trunk/CHANGELOG.txt 2013-03-03 17:08:44 UTC (rev 1928) @@ -8,14 +8,18 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ -02/03/13 Oleh_derevenko - * [u]int[8/16/32] renamed to contain "d" prefix so that global namespace - was not polluted with these names unconditionally. - If your project depended on these types other than just for passing - parameters to ODE calls, add similar typedefs for yourself in some - of your project's global headers. +03/03/13 Oleh_Derevenko + * Fixed issue with "findex==-1" constraints being intermixed with + "findex!=-1" ones during constraints random reordering in QuickStep. -01/02/13 Oleh_derevenko +02/03/13 Oleh_Derevenko + * [u]int[8/16/32] renamed to contain "d" prefix so that global namespace + was not polluted with these names unconditionally. + If your project depended on these types other than just for passing + parameters to ODE calls, add similar typedefs for yourself in some + of your project's global headers. + +01/02/13 Oleh_Derevenko * Applied patch #183 by Joseph Cooper (complementary matrix calculation fix). Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2013-02-09 08:50:21 UTC (rev 1927) +++ trunk/ode/src/quickstep.cpp 2013-03-03 17:08:44 UTC (rev 1928) @@ -589,6 +589,7 @@ // order to solve constraint rows in IndexError *order = memarena->AllocateArray<IndexError>(m); + unsigned int head_size; #ifndef REORDER_CONSTRAINTS { @@ -605,6 +606,7 @@ --ordertail; } } + head_size = (unsigned int)(orderhead - order); dIASSERT (orderhead-ordertail==1); } #endif @@ -623,11 +625,14 @@ if (iteration < 2) { // for the first two iterations, solve the constraints in // the given order + head_size = 0; IndexError *ordercurr = order; for (unsigned int i = 0; i != m; ordercurr++, i++) { + int findex_i = findex[i]; ordercurr->error = i; - ordercurr->findex = findex[i]; + ordercurr->findex = findex_i; ordercurr->index = i; + if (findex_i == -1) { ++head_size; } } } else { @@ -644,8 +649,10 @@ else { order[i].error = dInfinity; } - order[i].findex = findex[i]; + int findex_i = findex[i]; + order[i].findex = findex_i; order[i].index = i; + if (findex_i == -1) { ++head_size; } } } qsort (order,m,sizeof(IndexError),&compare_index_error); @@ -657,12 +664,19 @@ #endif #ifdef RANDOMLY_REORDER_CONSTRAINTS if ((iteration & 7) == 0) { - for (unsigned int i=1; i<m; i++) { + for (unsigned int i=1; i<head_size; i++) { int swapi = dRandInt(i+1); IndexError tmp = order[i]; order[i] = order[swapi]; order[swapi] = tmp; } + unsigned int tail_size = m - head_size; + for (unsigned int j=1; j<tail_size; j++) { + int swapj = dRandInt(j+1); + IndexError tmp = order[head_size + j]; + order[head_size + j] = order[head_size + swapj]; + order[head_size + swapj] = tmp; + } } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2013-02-09 08:50:27
|
Revision: 1927 http://opende.svn.sourceforge.net/opende/?rev=1927&view=rev Author: oleh_derevenko Date: 2013-02-09 08:50:21 +0000 (Sat, 09 Feb 2013) Log Message: ----------- Cosmetic: Explicit cast of INFINITY to double added for configuration with doubles to solve compile error Modified Paths: -------------- trunk/include/ode/odeconfig.h Modified: trunk/include/ode/odeconfig.h =================================================================== --- trunk/include/ode/odeconfig.h 2013-02-03 17:07:25 UTC (rev 1926) +++ trunk/include/ode/odeconfig.h 2013-02-09 08:50:21 UTC (rev 1927) @@ -95,7 +95,7 @@ #ifdef dSINGLE #define dInfinity ((float)INFINITY) #else - #define dInfinity INFINITY + #define dInfinity ((double)INFINITY) #endif #elif defined(HUGE_VAL) #ifdef dSINGLE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2013-02-03 17:07:34
|
Revision: 1926 http://opende.svn.sourceforge.net/opende/?rev=1926&view=rev Author: oleh_derevenko Date: 2013-02-03 17:07:25 +0000 (Sun, 03 Feb 2013) Log Message: ----------- Changed: [u]int[8/16/32] renamed to contain "d" prefix so that global namespace was not polluted with these names unconditionally. Fixed: Compilation errors fixed in 'tests' Modified Paths: -------------- trunk/CHANGELOG.txt trunk/build/config-default.h trunk/configure.ac trunk/include/ode/common.h trunk/include/ode/odeconfig.h trunk/ode/src/Makefile.am trunk/ode/src/obstack.cpp trunk/tests/friction.cpp trunk/tests/joint.cpp trunk/tests/joints/ball.cpp trunk/tests/joints/fixed.cpp trunk/tests/joints/hinge.cpp trunk/tests/joints/hinge2.cpp trunk/tests/joints/piston.cpp trunk/tests/joints/pr.cpp trunk/tests/joints/pu.cpp trunk/tests/joints/slider.cpp trunk/tests/joints/universal.cpp trunk/tests/odemath.cpp Added Paths: ----------- trunk/ode/src/typedefs.h Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/CHANGELOG.txt 2013-02-03 17:07:25 UTC (rev 1926) @@ -8,6 +8,13 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +02/03/13 Oleh_derevenko + * [u]int[8/16/32] renamed to contain "d" prefix so that global namespace + was not polluted with these names unconditionally. + If your project depended on these types other than just for passing + parameters to ODE calls, add similar typedefs for yourself in some + of your project's global headers. + 01/02/13 Oleh_derevenko * Applied patch #183 by Joseph Cooper (complementary matrix calculation fix). Modified: trunk/build/config-default.h =================================================================== --- trunk/build/config-default.h 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/build/config-default.h 2013-02-03 17:07:25 UTC (rev 1926) @@ -126,4 +126,7 @@ #endif +#include "typedefs.h" + + #endif Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/configure.ac 2013-02-03 17:07:25 UTC (rev 1926) @@ -493,6 +493,9 @@ #endif +#include "typedefs.h" + + #endif /* #define ODE_CONFIG_H */ ]) Modified: trunk/include/ode/common.h =================================================================== --- trunk/include/ode/common.h 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/include/ode/common.h 2013-02-03 17:07:25 UTC (rev 1926) @@ -74,12 +74,12 @@ */ #if dTRIMESH_16BIT_INDICES #if dTRIMESH_GIMPACT -typedef uint32 dTriIndex; +typedef duint32 dTriIndex; #else /* dTRIMESH_GIMPACT */ -typedef uint16 dTriIndex; +typedef duint16 dTriIndex; #endif /* dTRIMESH_GIMPACT */ #else /* dTRIMESH_16BIT_INDICES */ -typedef uint32 dTriIndex; +typedef duint32 dTriIndex; #endif /* dTRIMESH_16BIT_INDICES */ /* round an integer up to a multiple of 4, except that 0 and 1 are unmodified Modified: trunk/include/ode/odeconfig.h =================================================================== --- trunk/include/ode/odeconfig.h 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/include/ode/odeconfig.h 2013-02-03 17:07:25 UTC (rev 1926) @@ -74,19 +74,19 @@ /* Well-defined common data types...need to define for 64 bit systems */ #if defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__) #define X86_64_SYSTEM 1 - typedef int int32; - typedef unsigned int uint32; - typedef short int16; - typedef unsigned short uint16; - typedef signed char int8; - typedef unsigned char uint8; + typedef int dint32; + typedef unsigned int duint32; + typedef short dint16; + typedef unsigned short duint16; + typedef signed char dint8; + typedef unsigned char duint8; #else - typedef int int32; - typedef unsigned int uint32; - typedef short int16; - typedef unsigned short uint16; - typedef signed char int8; - typedef unsigned char uint8; + typedef int dint32; + typedef unsigned int duint32; + typedef short dint16; + typedef unsigned short duint16; + typedef signed char dint8; + typedef unsigned char duint8; #endif Modified: trunk/ode/src/Makefile.am =================================================================== --- trunk/ode/src/Makefile.am 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/ode/src/Makefile.am 2013-02-03 17:07:25 UTC (rev 1926) @@ -61,16 +61,17 @@ step.cpp step.h \ timer.cpp \ threading_atomics_provs.h \ + threading_base.cpp threading_base.h \ threading_fake_sync.h \ + threading_impl.cpp threading_impl.h \ + threading_impl_posix.h \ threading_impl_templates.h \ - threading_impl_posix.h \ threading_impl_win.h \ - threading_impl.cpp threading_impl.h \ threading_pool_posix.cpp \ threading_pool_win.cpp \ - threading_base.cpp threading_base.h \ - util.cpp util.h \ - threadingutils.h + threadingutils.h \ + typedefs.h \ + util.cpp util.h ################################### Modified: trunk/ode/src/obstack.cpp =================================================================== --- trunk/ode/src/obstack.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/ode/src/obstack.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -31,7 +31,7 @@ // macros and constants #define ROUND_UP_OFFSET_TO_EFFICIENT_SIZE(arena,ofs) \ - ofs = (size_t) (dEFFICIENT_SIZE( ((intP)(arena)) + ofs ) - ((intP)(arena)) ) + ofs = (size_t) (dEFFICIENT_SIZE( ((size_t)(arena)) + ofs ) - ((size_t)(arena)) ) #define MAX_ALLOC_SIZE \ ((size_t)(dOBSTACK_ARENA_SIZE - sizeof (Arena) - EFFICIENT_ALIGNMENT + 1)) Added: trunk/ode/src/typedefs.h =================================================================== --- trunk/ode/src/typedefs.h (rev 0) +++ trunk/ode/src/typedefs.h 2013-02-03 17:07:25 UTC (rev 1926) @@ -0,0 +1,40 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * + * All rights reserved. Email: ru...@q1... Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_TYPEDEFS_H_ +#define _ODE_TYPEDEFS_H_ + + +/* + * Internal typedefs to map public types into more convenient private types + */ + + +typedef dint32 int32; +typedef duint32 uint32; +typedef dint16 int16; +typedef duint16 uint16; +typedef dint8 int8; +typedef duint8 uint8; + + +#endif Modified: trunk/tests/friction.cpp =================================================================== --- trunk/tests/friction.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/friction.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -31,6 +31,7 @@ #include <algorithm> #include <UnitTest++.h> #include <ode/ode.h> +#include "../ode/src/config.h" #include "../ode/src/joints/joints.h" @@ -69,7 +70,7 @@ test_ZeroMu) { dxJoint::Info1 info1; - dxJoint::Info2 info2; + dxJoint::Info2Descr info2; dReal dummy_J[3][12] = {{0}}; dReal dummy_c[3]; dReal dummy_cfm[3]; @@ -77,8 +78,8 @@ dReal dummy_hi[3]; int dummy_findex[3]; - info2.fps = 100; - info2.erp = 0; + dReal info2_fps = 100; + dReal info2_erp = 0; info2.J1l = dummy_J[0]; info2.J1a = dummy_J[0] + 3; info2.J2l = dummy_J[0] + 6; @@ -137,7 +138,7 @@ joint->getInfo1(&info1); CHECK_EQUAL(2, (int)info1.m); ZERO_ALL; - joint->getInfo2(&info2); + joint->getInfo2(info2_fps, info2_erp, &info2); CHECK_CLOSE(0, dummy_J[1][0], 1e-6); CHECK_CLOSE(0, dummy_J[1][1], 1e-6); CHECK_CLOSE(-1, dummy_J[1][2], 1e-6); @@ -166,7 +167,7 @@ joint->getInfo1(&info1); CHECK_EQUAL(2, (int)info1.m); ZERO_ALL; - joint->getInfo2(&info2); + joint->getInfo2(info2_fps, info2_erp, &info2); CHECK_CLOSE(0, dummy_J[1][0], 1e-6); CHECK_CLOSE(1, dummy_J[1][1], 1e-6); CHECK_CLOSE(0, dummy_J[1][2], 1e-6); Modified: trunk/tests/joint.cpp =================================================================== --- trunk/tests/joint.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joint.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -30,6 +30,7 @@ //////////////////////////////////////////////////////////////////////////////// #include <UnitTest++.h> #include <ode/ode.h> +#include "../ode/src/config.h" #include "../ode/src/joints/joints.h" Modified: trunk/tests/joints/ball.cpp =================================================================== --- trunk/tests/joints/ball.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/ball.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/ball.h" Modified: trunk/tests/joints/fixed.cpp =================================================================== --- trunk/tests/joints/fixed.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/fixed.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/fixed.h" SUITE (TestdxJointFixed) Modified: trunk/tests/joints/hinge.cpp =================================================================== --- trunk/tests/joints/hinge.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/hinge.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/hinge.h" SUITE (TestdxJointHinge) Modified: trunk/tests/joints/hinge2.cpp =================================================================== --- trunk/tests/joints/hinge2.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/hinge2.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/hinge2.h" Modified: trunk/tests/joints/piston.cpp =================================================================== --- trunk/tests/joints/piston.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/piston.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/piston.h" SUITE (TestdxJointPiston) Modified: trunk/tests/joints/pr.cpp =================================================================== --- trunk/tests/joints/pr.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/pr.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/pr.h" SUITE (TestdxJointPR) Modified: trunk/tests/joints/pu.cpp =================================================================== --- trunk/tests/joints/pu.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/pu.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/pu.h" SUITE (TestdxJointPU) Modified: trunk/tests/joints/slider.cpp =================================================================== --- trunk/tests/joints/slider.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/slider.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -33,6 +33,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/slider.h" SUITE (TestdxJointSlider) Modified: trunk/tests/joints/universal.cpp =================================================================== --- trunk/tests/joints/universal.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/joints/universal.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -32,6 +32,7 @@ #include <UnitTest++.h> #include <ode/ode.h> +#include "../../ode/src/config.h" #include "../../ode/src/joints/universal.h" dReal d2r(dReal degree) Modified: trunk/tests/odemath.cpp =================================================================== --- trunk/tests/odemath.cpp 2013-01-21 20:19:04 UTC (rev 1925) +++ trunk/tests/odemath.cpp 2013-02-03 17:07:25 UTC (rev 1926) @@ -24,7 +24,7 @@ #include <UnitTest++.h> #include <ode/ode.h> -#include "ode/odemath.h" +#include <ode/odemath.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2013-01-21 20:19:11
|
Revision: 1925 http://opende.svn.sourceforge.net/opende/?rev=1925&view=rev Author: oleh_derevenko Date: 2013-01-21 20:19:04 +0000 (Mon, 21 Jan 2013) Log Message: ----------- Cosmetic: Header inclusion fixed (might cause linking errors) Modified Paths: -------------- trunk/ode/src/fastdot.c trunk/ode/src/fastldlt.c trunk/ode/src/fastlsolve.c trunk/ode/src/fastltsolve.c Modified: trunk/ode/src/fastdot.c =================================================================== --- trunk/ode/src/fastdot.c 2013-01-02 22:15:09 UTC (rev 1924) +++ trunk/ode/src/fastdot.c 2013-01-21 20:19:04 UTC (rev 1925) @@ -22,8 +22,9 @@ /* generated code, do not edit. */ -#include "ode/matrix.h" +#include <ode/common.h> #include "config.h" +#include "matrix.h" dReal _dDot (const dReal *a, const dReal *b, int n) Modified: trunk/ode/src/fastldlt.c =================================================================== --- trunk/ode/src/fastldlt.c 2013-01-02 22:15:09 UTC (rev 1924) +++ trunk/ode/src/fastldlt.c 2013-01-21 20:19:04 UTC (rev 1925) @@ -22,8 +22,9 @@ /* generated code, do not edit. */ -#include "ode/matrix.h" +#include <ode/common.h> #include "config.h" +#include "matrix.h" /* solve L*X=B, with B containing 1 right hand sides. * L is an n*n lower triangular matrix with ones on the diagonal. Modified: trunk/ode/src/fastlsolve.c =================================================================== --- trunk/ode/src/fastlsolve.c 2013-01-02 22:15:09 UTC (rev 1924) +++ trunk/ode/src/fastlsolve.c 2013-01-21 20:19:04 UTC (rev 1925) @@ -22,8 +22,9 @@ /* generated code, do not edit. */ -#include "ode/matrix.h" +#include <ode/common.h> #include "config.h" +#include "matrix.h" /* solve L*X=B, with B containing 1 right hand sides. * L is an n*n lower triangular matrix with ones on the diagonal. Modified: trunk/ode/src/fastltsolve.c =================================================================== --- trunk/ode/src/fastltsolve.c 2013-01-02 22:15:09 UTC (rev 1924) +++ trunk/ode/src/fastltsolve.c 2013-01-21 20:19:04 UTC (rev 1925) @@ -22,8 +22,9 @@ /* generated code, do not edit. */ -#include "ode/matrix.h" +#include <ode/common.h> #include "config.h" +#include "matrix.h" /* solve L^T * x=b, with b containing 1 right hand side. * L is an n*n lower triangular matrix with ones on the diagonal. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2013-01-02 22:15:15
|
Revision: 1924 http://opende.svn.sourceforge.net/opende/?rev=1924&view=rev Author: oleh_derevenko Date: 2013-01-02 22:15:09 +0000 (Wed, 02 Jan 2013) Log Message: ----------- Applied patch #183 by Joseph Cooper (complementary matrix calculation fix) Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/collision_util.h Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-12-30 15:55:01 UTC (rev 1923) +++ trunk/CHANGELOG.txt 2013-01-02 22:15:09 UTC (rev 1924) @@ -8,6 +8,10 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +01/02/13 Oleh_derevenko + * Applied patch #183 by Joseph Cooper (complementary matrix + calculation fix). + 12/28/12 Oleh_Derevenko * A bug with heightfield data assigned to a wrong field in dGeomHeightfieldSetHeightfieldData fixed (bug report #88 by Luc). Modified: trunk/ode/src/collision_util.h =================================================================== --- trunk/ode/src/collision_util.h 2012-12-30 15:55:01 UTC (rev 1923) +++ trunk/ode/src/collision_util.h 2013-01-02 22:15:09 UTC (rev 1924) @@ -199,17 +199,19 @@ return; } - dst[0] = ma[5]*ma[10] - ma[6]*ma[9] / det; - dst[1] = -( ma[1]*ma[10] - ma[9]*ma[2] ) / det; - dst[2] = ma[1]*ma[6] - ma[5]*ma[2] / det; + double detRecip = REAL(1.0) / det; - dst[4] = -( ma[4]*ma[10] - ma[6]*ma[8] ) / det; - dst[5] = ma[0]*ma[10] - ma[8]*ma[2] / det; - dst[6] = -( ma[0]*ma[6] - ma[4]*ma[2] ) / det; + dst[0] = ( ma[5]*ma[10] - ma[6]*ma[9] ) * detRecip; + dst[1] = ( ma[9]*ma[2] - ma[1]*ma[10] ) * detRecip; + dst[2] = ( ma[1]*ma[6] - ma[5]*ma[2] ) * detRecip; - dst[8] = ma[4]*ma[9] - ma[8]*ma[5] / det; - dst[9] = -( ma[0]*ma[9] - ma[8]*ma[1] ) / det; - dst[10] = ma[0]*ma[5] - ma[1]*ma[4] / det; + dst[4] = ( ma[6]*ma[8] - ma[4]*ma[10] ) * detRecip; + dst[5] = ( ma[0]*ma[10] - ma[8]*ma[2] ) * detRecip; + dst[6] = ( ma[4]*ma[2] - ma[0]*ma[6] ) * detRecip; + + dst[8] = ( ma[4]*ma[9] - ma[8]*ma[5] ) * detRecip; + dst[9] = ( ma[8]*ma[1] - ma[0]*ma[9] ) * detRecip; + dst[10] = ( ma[0]*ma[5] - ma[1]*ma[4] ) * detRecip; } inline void dQuatTransform(const dQuaternion& quat,const dVector3& source,dVector3& dest) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-30 15:55:09
|
Revision: 1923 http://opende.svn.sourceforge.net/opende/?rev=1923&view=rev Author: oleh_derevenko Date: 2012-12-30 15:55:01 +0000 (Sun, 30 Dec 2012) Log Message: ----------- Cosmetic: Minor code improvements to allow better optimizations by compiler Modified Paths: -------------- trunk/ode/src/joints/contact.cpp trunk/ode/src/joints/fixed.cpp trunk/ode/src/joints/joint.cpp Modified: trunk/ode/src/joints/contact.cpp =================================================================== --- trunk/ode/src/joints/contact.cpp 2012-12-29 11:46:13 UTC (rev 1922) +++ trunk/ode/src/joints/contact.cpp 2012-12-30 15:55:01 UTC (rev 1923) @@ -98,20 +98,24 @@ // c1,c2 = contact points with respect to body PORs dVector3 c1, c2 = {0,0,0}; - c1[0] = contact.geom.pos[0] - node[0].body->posr.pos[0]; - c1[1] = contact.geom.pos[1] - node[0].body->posr.pos[1]; - c1[2] = contact.geom.pos[2] - node[0].body->posr.pos[2]; + dxBody *b0 = node[0].body; + c1[0] = contact.geom.pos[0] - b0->posr.pos[0]; + c1[1] = contact.geom.pos[1] - b0->posr.pos[1]; + c1[2] = contact.geom.pos[2] - b0->posr.pos[2]; + // set jacobian for normal info->J1l[0] = normal[0]; info->J1l[1] = normal[1]; info->J1l[2] = normal[2]; dCalcVectorCross3( info->J1a, c1, normal ); - if ( node[1].body ) + + dxBody *b1 = node[1].body; + if ( b1 ) { - c2[0] = contact.geom.pos[0] - node[1].body->posr.pos[0]; - c2[1] = contact.geom.pos[1] - node[1].body->posr.pos[1]; - c2[2] = contact.geom.pos[2] - node[1].body->posr.pos[2]; + c2[0] = contact.geom.pos[0] - b1->posr.pos[0]; + c2[1] = contact.geom.pos[1] - b1->posr.pos[1]; + c2[2] = contact.geom.pos[2] - b1->posr.pos[2]; info->J2l[0] = -normal[0]; info->J2l[1] = -normal[1]; info->J2l[2] = -normal[2]; @@ -195,6 +199,7 @@ info->J1l[s+1] = t1[1]; info->J1l[s+2] = t1[2]; dCalcVectorCross3( info->J1a + s, c1, t1 ); + if ( node[1].body ) { info->J2l[s+0] = -t1[0]; @@ -204,6 +209,7 @@ dCalcVectorCross3( J2a_plus_s, c2, t1 ); dNegateVector3( J2a_plus_s ); } + // set right hand side if ( contact.surface.mode & dContactMotion1 ) { @@ -235,6 +241,7 @@ info->J1l[s2+1] = t2[1]; info->J1l[s2+2] = t2[2]; dCalcVectorCross3( info->J1a + s2, c1, t2 ); + if ( node[1].body ) { info->J2l[s2+0] = -t2[0]; @@ -244,11 +251,13 @@ dCalcVectorCross3( J2a_plus_s2, c2, t2 ); dNegateVector3( J2a_plus_s2 ); } + // set right hand side if ( contact.surface.mode & dContactMotion2 ) { info->c[rowFriction2] = contact.surface.motion2; } + // set LCP bounds and friction index. this depends on the approximation // mode info->lo[rowFriction2] = -mu2; Modified: trunk/ode/src/joints/fixed.cpp =================================================================== --- trunk/ode/src/joints/fixed.cpp 2012-12-29 11:46:13 UTC (rev 1922) +++ trunk/ode/src/joints/fixed.cpp 2012-12-30 15:55:01 UTC (rev 1923) @@ -74,9 +74,12 @@ info->cfm[1] = this->cfm; info->cfm[2] = this->cfm; + dxBody *b0 = node[0].body, *b1 = node[1].body; + dVector3 ofs; - dMultiply0_331 ( ofs, node[0].body->posr.R, offset ); - if ( node[1].body ) + dMultiply0_331 ( ofs, b0->posr.R, offset ); + + if ( b1 ) { dSetCrossMatrixPlus( info->J1a, ofs, s ); info->J2l[0] = -1; @@ -86,17 +89,21 @@ // set right hand side for the first three rows (linear) dReal k = worldFPS * this->erp; - if ( node[1].body ) + if ( b1 ) { for ( int j = 0; j < 3; j++ ) - info->c[j] = k * ( node[1].body->posr.pos[j] - - node[0].body->posr.pos[j] + { + info->c[j] = k * ( b1->posr.pos[j] + - b0->posr.pos[j] + ofs[j] ); + } } else { for ( int j = 0; j < 3; j++ ) - info->c[j] = k * ( offset[j] - node[0].body->posr.pos[j] ); + { + info->c[j] = k * ( offset[j] - b0->posr.pos[j] ); + } } } Modified: trunk/ode/src/joints/joint.cpp =================================================================== --- trunk/ode/src/joints/joint.cpp 2012-12-29 11:46:13 UTC (rev 1922) +++ trunk/ode/src/joints/joint.cpp 2012-12-30 15:55:01 UTC (rev 1923) @@ -116,23 +116,26 @@ info->J1l[2*s+2] = 1; dMultiply0_331( a1, joint->node[0].body->posr.R, anchor1 ); dSetCrossMatrixMinus( info->J1a, a1, s ); - if ( joint->node[1].body ) + + dxBody *b1 = joint->node[1].body; + if ( b1 ) { info->J2l[0] = -1; info->J2l[s+1] = -1; info->J2l[2*s+2] = -1; - dMultiply0_331( a2, joint->node[1].body->posr.R, anchor2 ); + dMultiply0_331( a2, b1->posr.R, anchor2 ); dSetCrossMatrixPlus( info->J2a, a2, s ); } // set right hand side dReal k = fps * erp; - if ( joint->node[1].body ) + dxBody *b0 = joint->node[0].body; + if ( b1 ) { for ( int j = 0; j < 3; j++ ) { - info->c[j] = k * ( a2[j] + joint->node[1].body->posr.pos[j] - - a1[j] - joint->node[0].body->posr.pos[j] ); + info->c[j] = k * ( a2[j] + b1->posr.pos[j] - + a1[j] - b0->posr.pos[j] ); } } else @@ -140,7 +143,7 @@ for ( int j = 0; j < 3; j++ ) { info->c[j] = k * ( anchor2[j] - a1[j] - - joint->node[0].body->posr.pos[j] ); + b0->posr.pos[j] ); } } } @@ -173,12 +176,14 @@ dCalcVectorCross3( info->J1a, a1, axis ); dCalcVectorCross3( info->J1a + s, a1, q1 ); dCalcVectorCross3( info->J1a + 2*s, a1, q2 ); - if ( joint->node[1].body ) + + dxBody *b1 = joint->node[1].body; + if ( b1 ) { for ( i = 0; i < 3; i++ ) info->J2l[i] = -axis[i]; for ( i = 0; i < 3; i++ ) info->J2l[s+i] = -q1[i]; for ( i = 0; i < 3; i++ ) info->J2l[2*s+i] = -q2[i]; - dMultiply0_331( a2, joint->node[1].body->posr.R, anchor2 ); + dMultiply0_331( a2, b1->posr.R, anchor2 ); dReal *J2a = info->J2a; dCalcVectorCross3( J2a, a2, axis ); dNegateVector3( J2a ); @@ -194,11 +199,19 @@ dReal k1 = fps * erp1; dReal k = fps * erp; - for ( i = 0; i < 3; i++ ) a1[i] += joint->node[0].body->posr.pos[i]; - if ( joint->node[1].body ) + dxBody *b0 = joint->node[0].body; + for ( i = 0; i < 3; i++ ) { - for ( i = 0; i < 3; i++ ) a2[i] += joint->node[1].body->posr.pos[i]; + a1[i] += b0->posr.pos[i]; + } + if ( b1 ) + { + for ( i = 0; i < 3; i++ ) + { + a2[i] += b1->posr.pos[i]; + } + dVector3 a2_minus_a1; dSubtractVectors3(a2_minus_a1, a2, a1); info->c[0] = k1 * dCalcVectorDot3( axis, a2_minus_a1 ); @@ -228,7 +241,9 @@ info->J1a[start_index] = 1; info->J1a[start_index + s + 1] = 1; info->J1a[start_index + s*2+2] = 1; - if ( joint->node[1].body ) + + dxBody *b1 = joint->node[1].body; + if ( b1 ) { info->J2a[start_index] = -1; info->J2a[start_index + s+1] = -1; @@ -251,15 +266,16 @@ // get qerr = relative rotation (rotation error) between two bodies dQuaternion qerr, e; - if ( joint->node[1].body ) + dxBody *b0 = joint->node[0].body; + if ( b1 ) { dQuaternion qq; - dQMultiply1( qq, joint->node[0].body->q, joint->node[1].body->q ); + dQMultiply1( qq, b0->q, b1->q ); dQMultiply2( qerr, qq, qrel ); } else { - dQMultiply3( qerr, joint->node[0].body->q, qrel ); + dQMultiply3( qerr, b0->q, qrel ); } if ( qerr[0] < 0 ) { @@ -267,7 +283,7 @@ qerr[2] = -qerr[2]; qerr[3] = -qerr[3]; } - dMultiply0_331( e, joint->node[0].body->posr.R, qerr + 1 ); // @@@ bad SIMD padding! + dMultiply0_331( e, b0->posr.R, qerr + 1 ); // @@@ bad SIMD padding! dReal k = fps * erp; info->c[start_row] = 2 * k * e[0]; info->c[start_row+1] = 2 * k * e[1]; @@ -280,21 +296,24 @@ void setAnchors( dxJoint *j, dReal x, dReal y, dReal z, dVector3 anchor1, dVector3 anchor2 ) { - if ( j->node[0].body ) + dxBody *b0 = j->node[0].body; + if ( b0 ) { dReal q[4]; - q[0] = x - j->node[0].body->posr.pos[0]; - q[1] = y - j->node[0].body->posr.pos[1]; - q[2] = z - j->node[0].body->posr.pos[2]; + q[0] = x - b0->posr.pos[0]; + q[1] = y - b0->posr.pos[1]; + q[2] = z - b0->posr.pos[2]; q[3] = 0; - dMultiply1_331( anchor1, j->node[0].body->posr.R, q ); - if ( j->node[1].body ) + dMultiply1_331( anchor1, b0->posr.R, q ); + + dxBody *b1 = j->node[1].body; + if ( b1 ) { - q[0] = x - j->node[1].body->posr.pos[0]; - q[1] = y - j->node[1].body->posr.pos[1]; - q[2] = z - j->node[1].body->posr.pos[2]; + q[0] = x - b1->posr.pos[0]; + q[1] = y - b1->posr.pos[1]; + q[2] = z - b1->posr.pos[2]; q[3] = 0; - dMultiply1_331( anchor2, j->node[1].body->posr.R, q ); + dMultiply1_331( anchor2, b1->posr.R, q ); } else { @@ -313,7 +332,8 @@ void setAxes( dxJoint *j, dReal x, dReal y, dReal z, dVector3 axis1, dVector3 axis2 ) { - if ( j->node[0].body ) + dxBody *b0 = j->node[0].body; + if ( b0 ) { dReal q[4]; q[0] = x; @@ -321,16 +341,19 @@ q[2] = z; q[3] = 0; dNormalize3( q ); + if ( axis1 ) { - dMultiply1_331( axis1, j->node[0].body->posr.R, q ); + dMultiply1_331( axis1, b0->posr.R, q ); axis1[3] = 0; } + if ( axis2 ) { - if ( j->node[1].body ) + dxBody *b1 = j->node[1].body; + if ( b1 ) { - dMultiply1_331( axis2, j->node[1].body->posr.R, q ); + dMultiply1_331( axis2, b1->posr.R, q ); } else { @@ -346,24 +369,26 @@ void getAnchor( dxJoint *j, dVector3 result, dVector3 anchor1 ) { - if ( j->node[0].body ) + dxBody *b0 = j->node[0].body; + if ( b0 ) { - dMultiply0_331( result, j->node[0].body->posr.R, anchor1 ); - result[0] += j->node[0].body->posr.pos[0]; - result[1] += j->node[0].body->posr.pos[1]; - result[2] += j->node[0].body->posr.pos[2]; + dMultiply0_331( result, b0->posr.R, anchor1 ); + result[0] += b0->posr.pos[0]; + result[1] += b0->posr.pos[1]; + result[2] += b0->posr.pos[2]; } } void getAnchor2( dxJoint *j, dVector3 result, dVector3 anchor2 ) { - if ( j->node[1].body ) + dxBody *b1 = j->node[1].body; + if ( b1 ) { - dMultiply0_331( result, j->node[1].body->posr.R, anchor2 ); - result[0] += j->node[1].body->posr.pos[0]; - result[1] += j->node[1].body->posr.pos[1]; - result[2] += j->node[1].body->posr.pos[2]; + dMultiply0_331( result, b1->posr.R, anchor2 ); + result[0] += b1->posr.pos[0]; + result[1] += b1->posr.pos[1]; + result[2] += b1->posr.pos[2]; } else { @@ -376,18 +401,20 @@ void getAxis( dxJoint *j, dVector3 result, dVector3 axis1 ) { - if ( j->node[0].body ) + dxBody *b0 = j->node[0].body; + if ( b0 ) { - dMultiply0_331( result, j->node[0].body->posr.R, axis1 ); + dMultiply0_331( result, b0->posr.R, axis1 ); } } void getAxis2( dxJoint *j, dVector3 result, dVector3 axis2 ) { - if ( j->node[1].body ) + dxBody *b1 = j->node[1].body; + if ( b1 ) { - dMultiply0_331( result, j->node[1].body->posr.R, axis2 ); + dMultiply0_331( result, b1->posr.R, axis2 ); } else { @@ -589,7 +616,9 @@ J1[srow+0] = ax1[0]; J1[srow+1] = ax1[1]; J1[srow+2] = ax1[2]; - if ( joint->node[1].body ) + + dxBody *b1 = joint->node[1].body; + if ( b1 ) { J2[srow+0] = -ax1[0]; J2[srow+1] = -ax1[1]; @@ -610,12 +639,13 @@ // only need to do this if the constraint connects two bodies. dVector3 ltd = {0,0,0}; // Linear Torque Decoupling vector (a torque) - if ( !rotational && joint->node[1].body ) + if ( !rotational && b1 ) { + dxBody *b0 = joint->node[0].body; dVector3 c; - c[0] = REAL( 0.5 ) * ( joint->node[1].body->posr.pos[0] - joint->node[0].body->posr.pos[0] ); - c[1] = REAL( 0.5 ) * ( joint->node[1].body->posr.pos[1] - joint->node[0].body->posr.pos[1] ); - c[2] = REAL( 0.5 ) * ( joint->node[1].body->posr.pos[2] - joint->node[0].body->posr.pos[2] ); + c[0] = REAL( 0.5 ) * ( b1->posr.pos[0] - b0->posr.pos[0] ); + c[1] = REAL( 0.5 ) * ( b1->posr.pos[1] - b0->posr.pos[1] ); + c[2] = REAL( 0.5 ) * ( b1->posr.pos[2] - b0->posr.pos[2] ); dCalcVectorCross3( ltd, c, ax1 ); info->J1a[srow+0] = ltd[0]; info->J1a[srow+1] = ltd[1]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-29 11:46:19
|
Revision: 1922 http://opende.svn.sourceforge.net/opende/?rev=1922&view=rev Author: oleh_derevenko Date: 2012-12-29 11:46:13 +0000 (Sat, 29 Dec 2012) Log Message: ----------- Fixed: Extra DLL exports removed for MinGW builds on Windows Modified Paths: -------------- trunk/include/ode/odeconfig.h Modified: trunk/include/ode/odeconfig.h =================================================================== --- trunk/include/ode/odeconfig.h 2012-12-28 09:57:39 UTC (rev 1921) +++ trunk/include/ode/odeconfig.h 2012-12-29 11:46:13 UTC (rev 1922) @@ -42,7 +42,7 @@ #endif /* Define a DLL export symbol for those platforms that need it */ -#if defined(_MSC_VER) +#if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32)) #if defined(ODE_DLL) #define ODE_API __declspec(dllexport) #elif !defined(ODE_LIB) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-28 09:57:50
|
Revision: 1921 http://opende.svn.sourceforge.net/opende/?rev=1921&view=rev Author: oleh_derevenko Date: 2012-12-28 09:57:39 +0000 (Fri, 28 Dec 2012) Log Message: ----------- Fixed: A bug with heightfield data assigned to a wrong field in dGeomHeightfieldSetHeightfieldData fixed (bug report #88 by Luc). Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/heightfield.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-12-26 10:17:08 UTC (rev 1920) +++ trunk/CHANGELOG.txt 2012-12-28 09:57:39 UTC (rev 1921) @@ -8,11 +8,16 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +12/28/12 Oleh_Derevenko + * A bug with heightfield data assigned to a wrong field in + dGeomHeightfieldSetHeightfieldData fixed (bug report #88 by Luc). + 12/18/12 Oleh_Derevenko * Fixed issue with some kinds of joints (Ball, DBall, DHinge, Fixed) might overwrite world ERP value with their custom ERP during getInfo2() call and that inappropriate value would then be passed to subsequent joints in solver instead of world ERP. + 12/01/12 Oleh_Derevenko * Fixed issues reported in patches #151 and #22 (collisions with SAPSpace and QuadTreeSpace might not work because geometries list Modified: trunk/ode/src/heightfield.cpp =================================================================== --- trunk/ode/src/heightfield.cpp 2012-12-26 10:17:08 UTC (rev 1920) +++ trunk/ode/src/heightfield.cpp 2012-12-28 09:57:39 UTC (rev 1921) @@ -892,7 +892,7 @@ void dGeomHeightfieldSetHeightfieldData( dGeomID g, dHeightfieldDataID d ) { dxHeightfield* geom = (dxHeightfield*) g; - geom->data = d; + geom->m_p_data = d; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-26 10:17:15
|
Revision: 1920 http://opende.svn.sourceforge.net/opende/?rev=1920&view=rev Author: oleh_derevenko Date: 2012-12-26 10:17:08 +0000 (Wed, 26 Dec 2012) Log Message: ----------- Fixed: Inclusion of <ode/precision.h> moved to proper header (was causing compile errors in dSINGLE mode) Modified Paths: -------------- trunk/include/ode/common.h trunk/include/ode/odeconfig.h Modified: trunk/include/ode/common.h =================================================================== --- trunk/include/ode/common.h 2012-12-25 23:31:06 UTC (rev 1919) +++ trunk/include/ode/common.h 2012-12-26 10:17:08 UTC (rev 1920) @@ -23,8 +23,6 @@ #ifndef _ODE_COMMON_H_ #define _ODE_COMMON_H_ -#include <ode/precision.h> - #include <ode/odeconfig.h> #include <ode/error.h> Modified: trunk/include/ode/odeconfig.h =================================================================== --- trunk/include/ode/odeconfig.h 2012-12-25 23:31:06 UTC (rev 1919) +++ trunk/include/ode/odeconfig.h 2012-12-26 10:17:08 UTC (rev 1920) @@ -34,6 +34,9 @@ #include <float.h> +#include <ode/precision.h> + + #if defined(ODE_DLL) || defined(ODE_LIB) #define __ODE__ #endif @@ -89,7 +92,11 @@ /* Define the dInfinity macro */ #ifdef INFINITY - #define dInfinity INFINITY + #ifdef dSINGLE + #define dInfinity ((float)INFINITY) + #else + #define dInfinity INFINITY + #endif #elif defined(HUGE_VAL) #ifdef dSINGLE #ifdef HUGE_VALF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-25 23:31:16
|
Revision: 1919 http://opende.svn.sourceforge.net/opende/?rev=1919&view=rev Author: oleh_derevenko Date: 2012-12-25 23:31:06 +0000 (Tue, 25 Dec 2012) Log Message: ----------- Changed: Second part of changes towards threading steppers. Steppers implementation optimizations. Modified Paths: -------------- trunk/ode/src/joints/joint.cpp trunk/ode/src/quickstep.cpp trunk/ode/src/quickstep.h trunk/ode/src/step.cpp trunk/ode/src/step.h trunk/ode/src/util.cpp trunk/ode/src/util.h Modified: trunk/ode/src/joints/joint.cpp =================================================================== --- trunk/ode/src/joints/joint.cpp 2012-12-25 23:24:39 UTC (rev 1918) +++ trunk/ode/src/joints/joint.cpp 2012-12-25 23:31:06 UTC (rev 1919) @@ -36,6 +36,7 @@ #include "odemath.h" #include "joint.h" #include "joint_internal.h" +#include "util.h" extern void addObjectToList( dObject *obj, dObject **first ); @@ -654,27 +655,41 @@ // if we're powering away from the limit, apply the fudge factor if (( limit == 1 && vel > 0 ) || ( limit == 2 && vel < 0 ) ) fm *= fudge_factor; + + dReal fm_ax1_0 = fm*ax1[0], fm_ax1_1 = fm*ax1[1], fm_ax1_2 = fm*ax1[2]; + + dxBody *b0 = joint->node[0].body; + dxWorldProcessContext *world_process_context = b0->world->UnsafeGetWorldProcessingContext(); + + world_process_context->LockForAddLimotSerialization(); + if ( rotational ) { - dBodyAddTorque( joint->node[0].body, -fm*ax1[0], -fm*ax1[1], - -fm*ax1[2] ); - if ( joint->node[1].body ) - dBodyAddTorque( joint->node[1].body, fm*ax1[0], fm*ax1[1], fm*ax1[2] ); + dxBody *b1 = joint->node[1].body; + if ( b1 != NULL ) + { + dBodyAddTorque( b1, fm_ax1_0, fm_ax1_1, fm_ax1_2 ); + } + + dBodyAddTorque( b0, -fm_ax1_0, -fm_ax1_1, -fm_ax1_2 ); } else { - dBodyAddForce( joint->node[0].body, -fm*ax1[0], -fm*ax1[1], -fm*ax1[2] ); - if ( joint->node[1].body ) + dxBody *b1 = joint->node[1].body; + if ( b1 != NULL ) { - dBodyAddForce( joint->node[1].body, fm*ax1[0], fm*ax1[1], fm*ax1[2] ); + // linear limot torque decoupling step: refer to above discussion + dReal neg_fm_ltd_0 = -fm*ltd[0], neg_fm_ltd_1 = -fm*ltd[1], neg_fm_ltd_2 = -fm*ltd[2]; + dBodyAddTorque( b0, neg_fm_ltd_0, neg_fm_ltd_1, neg_fm_ltd_2 ); + dBodyAddTorque( b1, neg_fm_ltd_0, neg_fm_ltd_1, neg_fm_ltd_2 ); - // linear limot torque decoupling step: refer to above discussion - dBodyAddTorque( joint->node[0].body, -fm*ltd[0], -fm*ltd[1], - -fm*ltd[2] ); - dBodyAddTorque( joint->node[1].body, -fm*ltd[0], -fm*ltd[1], - -fm*ltd[2] ); + dBodyAddForce( b1, fm_ax1_0, fm_ax1_1, fm_ax1_2 ); } + + dBodyAddForce( b0, -fm_ax1_0, -fm_ax1_1, -fm_ax1_2 ); } + + world_process_context->UnlockForAddLimotSerialization(); } } Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2012-12-25 23:24:39 UTC (rev 1918) +++ trunk/ode/src/quickstep.cpp 2012-12-25 23:31:06 UTC (rev 1919) @@ -41,9 +41,6 @@ #define dMAX(A,B) ((B)>(A) ? (B) : (A)) -typedef const dReal *dRealPtr; -typedef dReal *dRealMutablePtr; - //*************************************************************************** // configuration @@ -126,20 +123,22 @@ struct dxQuickStepperStage0Outputs { - size_t nj; + unsigned int nj; unsigned int m; unsigned int mfb; }; struct dxQuickStepperStage1CallContext { - dxQuickStepperStage1CallContext(dxStepperProcessingCallContext *stepperCallContext, void *stageMemArenaState, dReal *invI, dJointWithInfo1 *jointinfos): - m_stepperCallContext(stepperCallContext), m_stageMemArenaState(stageMemArenaState), - m_invI(invI), m_jointinfos(jointinfos) + void Initialize(const dxStepperProcessingCallContext *stepperCallContext, void *stageMemArenaState, dReal *invI, dJointWithInfo1 *jointinfos) { + m_stepperCallContext = stepperCallContext; + m_stageMemArenaState = stageMemArenaState; + m_invI = invI; + m_jointinfos = jointinfos; } - dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperProcessingCallContext *m_stepperCallContext; void *m_stageMemArenaState; dReal *m_invI; dJointWithInfo1 *m_jointinfos; @@ -148,13 +147,16 @@ struct dxQuickStepperStage0BodiesCallContext { - dxQuickStepperStage0BodiesCallContext(dxStepperProcessingCallContext *stepperCallContext, dReal *invI): - m_stepperCallContext(stepperCallContext), m_invI(invI), - m_tagsTaken(0), m_gravityTaken(0), m_inertiaBodyIndex(0) + void Initialize(const dxStepperProcessingCallContext *stepperCallContext, dReal *invI) { + m_stepperCallContext = stepperCallContext; + m_invI = invI; + m_tagsTaken = 0; + m_gravityTaken = 0; + m_inertiaBodyIndex = 0; } - dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperProcessingCallContext *m_stepperCallContext; dReal *m_invI; atomicord32 m_tagsTaken; atomicord32 m_gravityTaken; @@ -163,12 +165,14 @@ struct dxQuickStepperStage0JointsCallContext { - dxQuickStepperStage0JointsCallContext(dxStepperProcessingCallContext *stepperCallContext, dJointWithInfo1 *jointinfos, dxQuickStepperStage0Outputs *stage0Outputs): - m_stepperCallContext(stepperCallContext), m_jointinfos(jointinfos), m_stage0Outputs(stage0Outputs) + void Initialize(const dxStepperProcessingCallContext *stepperCallContext, dJointWithInfo1 *jointinfos, dxQuickStepperStage0Outputs *stage0Outputs) { + m_stepperCallContext = stepperCallContext; + m_jointinfos = jointinfos; + m_stage0Outputs = stage0Outputs; } - dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperProcessingCallContext *m_stepperCallContext; dJointWithInfo1 *m_jointinfos; dxQuickStepperStage0Outputs *m_stage0Outputs; }; @@ -181,16 +185,106 @@ static void dxQuickStepIsland_Stage0_Joints(dxQuickStepperStage0JointsCallContext *callContext); static void dxQuickStepIsland_Stage1(dxQuickStepperStage1CallContext *callContext); + +struct dxQuickStepperLocalContext +{ + void Initialize(dReal *invI, dJointWithInfo1 *jointinfos, unsigned int nj, + unsigned int m, unsigned int mfb, const unsigned int *mindex, int *findex, + dReal *J, dReal *cfm, dReal *lo, dReal *hi, int *jb, dReal *rhs, dReal *Jcopy) + { + m_invI = invI; + m_jointinfos = jointinfos; + m_nj = nj; + m_m = m; + m_mfb = mfb; + m_mindex = mindex; + m_findex = findex; + m_J = J; + m_cfm = cfm; + m_lo = lo; + m_hi = hi; + m_jb = jb; + m_rhs = rhs; + m_Jcopy = Jcopy; + } + + dReal *m_invI; + dJointWithInfo1 *m_jointinfos; + unsigned int m_nj; + unsigned int m_m; + unsigned int m_mfb; + const unsigned int *m_mindex; + int *m_findex; + dReal *m_J; + dReal *m_cfm; + dReal *m_lo; + dReal *m_hi; + int *m_jb; + dReal *m_rhs; + dReal *m_Jcopy; +}; + +struct dxQuickStepperStage3CallContext +{ + void Initialize(const dxStepperProcessingCallContext *callContext, const dxQuickStepperLocalContext *localContext, + void *stage1MemArenaState) + { + m_stepperCallContext = callContext; + m_localContext = localContext; + m_stage1MemArenaState = stage1MemArenaState; + } + + const dxStepperProcessingCallContext *m_stepperCallContext; + const dxQuickStepperLocalContext *m_localContext; + void *m_stage1MemArenaState; +}; + +struct dxQuickStepperStage2CallContext +{ + void Initialize(const dxStepperProcessingCallContext *callContext, const dxQuickStepperLocalContext *localContext, + dReal *rhs_tmp) + { + m_stepperCallContext = callContext; + m_localContext = localContext; + m_rhs_tmp = rhs_tmp; + m_ji_J = 0; + m_ji_jb = 0; + m_bi = 0; + m_Jrhsi = 0; + } + + const dxStepperProcessingCallContext *m_stepperCallContext; + const dxQuickStepperLocalContext *m_localContext; + dReal *m_rhs_tmp; + volatile unsigned int m_ji_J; + volatile unsigned int m_ji_jb; + volatile unsigned int m_bi; + volatile unsigned int m_Jrhsi; +}; + +static int dxQuickStepIsland_Stage2a_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxQuickStepIsland_Stage2aSync_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxQuickStepIsland_Stage2b_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxQuickStepIsland_Stage2bSync_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxQuickStepIsland_Stage2c_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxQuickStepIsland_Stage3_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); + +static void dxQuickStepIsland_Stage2a(dxQuickStepperStage2CallContext *callContext); +static void dxQuickStepIsland_Stage2b(dxQuickStepperStage2CallContext *callContext); +static void dxQuickStepIsland_Stage2c(dxQuickStepperStage2CallContext *callContext); +static void dxQuickStepIsland_Stage3(dxQuickStepperStage3CallContext *callContext); + + //*************************************************************************** // various common computations involving the matrix J // compute iMJ = inv(M)*J' -static void compute_invM_JT (unsigned int m, dRealPtr J, dRealMutablePtr iMJ, int *jb, - dxBody * const *body, dRealPtr invI) +static void compute_invM_JT (unsigned int m, const dReal *J, dReal *iMJ, int *jb, + dxBody * const *body, const dReal *invI) { - dRealMutablePtr iMJ_ptr = iMJ; - dRealPtr J_ptr = J; + dReal *iMJ_ptr = iMJ; + const dReal *J_ptr = J; for (unsigned int i=0; i<m; J_ptr += 12, iMJ_ptr += 12, i++) { int b1 = jb[(size_t)i*2]; int b2 = jb[(size_t)i*2+1]; @@ -209,16 +303,16 @@ // compute out = inv(M)*J'*in. #ifdef WARM_STARTING -static void multiply_invM_JT (unsigned int m, unsigned int nb, dRealMutablePtr iMJ, int *jb, - dRealPtr in, dRealMutablePtr out) +static void multiply_invM_JT (unsigned int m, unsigned int nb, dReal *iMJ, int *jb, + const dReal *in, dReal *out) { dSetZero (out,6*(size_t)nb); - dRealPtr iMJ_ptr = iMJ; + const dReal *iMJ_ptr = iMJ; for (unsigned int i=0; i<m; i++) { int b1 = jb[(size_t)i*2]; int b2 = jb[(size_t)i*2+1]; const dReal in_i = in[i]; - dRealMutablePtr out_ptr = out + (size_t)(unsigned)b1*6; + dReal *out_ptr = out + (size_t)(unsigned)b1*6; for (unsigned int j=0; j<6; j++) out_ptr[j] += iMJ_ptr[j] * in_i; iMJ_ptr += 6; if (b2 != -1) { @@ -231,16 +325,35 @@ #endif // compute out = J*in. +static void multiplyAdd_J (volatile unsigned *mi_storage, + unsigned int m, const dReal *J, const int *jb, const dReal *in, dReal *out) +{ + unsigned int mi; + while ((mi = ThrsafeIncrementIntUpToLimit(mi_storage, m)) != m) { + int b1 = jb[(size_t)mi*2]; + int b2 = jb[(size_t)mi*2+1]; + const dReal *J_ptr = J + (size_t)mi * 12; + dReal sum = REAL(0.0); + const dReal *in_ptr = in + (size_t)(unsigned)b1*6; + for (unsigned int j = 0; j < 6; ++j) sum += J_ptr[j] * in_ptr[j]; + if (b2 != -1) { + in_ptr = in + (size_t)(unsigned)b2*6; + for (unsigned int j=0; j<6; j++) sum += J_ptr[6 + j] * in_ptr[j]; + } + out[mi] += sum; + } +} -static void multiply_J (unsigned int m, dRealPtr J, int *jb, - dRealPtr in, dRealMutablePtr out) +// Single threaded versionto be removed later +static void _multiply_J (unsigned int m, const dReal* J, int *jb, + const dReal* in, dReal* out) { - dRealPtr J_ptr = J; + const dReal* J_ptr = J; for (unsigned int i=0; i<m; i++) { int b1 = jb[(size_t)i*2]; int b2 = jb[(size_t)i*2+1]; dReal sum = 0; - dRealPtr in_ptr = in + (size_t)(unsigned)b1*6; + const dReal* in_ptr = in + (size_t)(unsigned)b1*6; for (unsigned int j=0; j<6; j++) sum += J_ptr[j] * in_ptr[j]; J_ptr += 6; if (b2 != -1) { @@ -256,11 +369,11 @@ // compute out = (J*inv(M)*J' + cfm)*in. // use z as an nb*6 temporary. #ifdef WARM_STARTING -static void multiply_J_invM_JT (unsigned int m, unsigned int nb, dRealMutablePtr J, dRealMutablePtr iMJ, int *jb, - dRealPtr cfm, dRealMutablePtr z, dRealMutablePtr in, dRealMutablePtr out) +static void multiply_J_invM_JT (unsigned int m, unsigned int nb, dReal *J, dReal *iMJ, int *jb, + const dReal *cfm, dReal *z, dReal *in, dReal *out) { multiply_invM_JT (m,nb,iMJ,jb,in,z); - multiply_J (m,J,jb,z,out); + _multiply_J (m,J,jb,z,out); // add cfm for (unsigned int i=0; i<m; i++) out[i] += cfm[i] * in[i]; @@ -275,7 +388,7 @@ #ifdef USE_CG_LCP -static inline dReal dot (unsigned int n, dRealPtr x, dRealPtr y) +static inline dReal dot (unsigned int n, const dReal *x, const dReal *y) { dReal sum=0; for (unsigned int i=0; i<n; i++) sum += x[i]*y[i]; @@ -285,15 +398,15 @@ // x = y + z*alpha -static inline void add (unsigned int n, dRealMutablePtr x, dRealPtr y, dRealPtr z, dReal alpha) +static inline void add (unsigned int n, dReal *x, const dReal *y, const dReal *z, dReal alpha) { for (unsigned int i=0; i<n; i++) x[i] = y[i] + z[i]*alpha; } static void CG_LCP (dxWorldProcessMemArena *memarena, - unsigned int m, unsigned int nb, dRealMutablePtr J, int *jb, dxBody * const *body, - dRealPtr invI, dRealMutablePtr lambda, dRealMutablePtr fc, dRealMutablePtr b, - dRealMutablePtr lo, dRealMutablePtr hi, dRealPtr cfm, int *findex, + unsigned int m, unsigned int nb, dReal *J, int *jb, dxBody * const *body, + const dReal *invI, dReal *lambda, dReal *fc, dReal *b, + dReal *lo, dReal *hi, const dReal *cfm, int *findex, dxQuickStepParameters *qs) { const unsigned int num_iterations = qs->num_iterations; @@ -303,15 +416,15 @@ compute_invM_JT (m,J,iMJ,jb,body,invI); dReal last_rho = 0; - dReal *r = memarena->AllocateArray<dReal> (m); - dReal *z = memarena->AllocateArray<dReal> (m); - dReal *p = memarena->AllocateArray<dReal> (m); - dReal *q = memarena->AllocateArray<dReal> (m); + dReal *r = memarena->AllocateArray<dReal>(m); + dReal *z = memarena->AllocateArray<dReal>(m); + dReal *p = memarena->AllocateArray<dReal>(m); + dReal *q = memarena->AllocateArray<dReal>(m); // precompute 1 / diagonals of A - dReal *Ad = memarena->AllocateArray<dReal> (m); - dRealPtr iMJ_ptr = iMJ; - dRealPtr J_ptr = J; + dReal *Ad = memarena->AllocateArray<dReal>(m); + const dReal *iMJ_ptr = iMJ; + const dReal *J_ptr = J; for (unsigned int i=0; i<m; i++) { dReal sum = 0; for (unsigned int j=0; j<6; j++) sum += iMJ_ptr[j] * J_ptr[j]; @@ -412,9 +525,9 @@ #endif static void SOR_LCP (dxWorldProcessMemArena *memarena, - const unsigned int m, const unsigned int nb, dRealMutablePtr J, int *jb, dxBody * const *body, - dRealPtr invI, dRealMutablePtr lambda, dRealMutablePtr fc, dRealMutablePtr b, - dRealPtr lo, dRealPtr hi, dRealPtr cfm, const int *findex, + const unsigned int m, const unsigned int nb, dReal *J, int *jb, dxBody * const *body, + const dReal *invI, dReal *lambda, dReal *fc, dReal *b, + const dReal *lo, const dReal *hi, const dReal *cfm, const int *findex, const dxQuickStepParameters *qs) { #ifdef WARM_STARTING @@ -428,7 +541,7 @@ #endif // precompute iMJ = inv(M)*J' - dReal *iMJ = memarena->AllocateArray<dReal> ((size_t)m*12); + dReal *iMJ = memarena->AllocateArray<dReal>((size_t)m*12); compute_invM_JT (m,J,iMJ,jb,body,invI); // compute fc=(inv(M)*J')*lambda. we will incrementally maintain fc @@ -439,13 +552,13 @@ dSetZero (fc,(size_t)nb*6); #endif - dReal *Ad = memarena->AllocateArray<dReal> (m); + dReal *Ad = memarena->AllocateArray<dReal>(m); { const dReal sor_w = qs->w; // SOR over-relaxation parameter // precompute 1 / diagonals of A - dRealPtr iMJ_ptr = iMJ; - dRealPtr J_ptr = J; + const dReal *iMJ_ptr = iMJ; + const dReal *J_ptr = J; for (unsigned int i=0; i<m; J_ptr += 12, iMJ_ptr += 12, i++) { dReal sum = 0; for (unsigned int j=0; j<6; j++) sum += iMJ_ptr[j] * J_ptr[j]; @@ -461,7 +574,7 @@ // to move multiplication by Ad[i] and cfm[i] out of iteration loop. // scale J and b by Ad - dRealMutablePtr J_ptr = J; + dReal *J_ptr = J; for (unsigned int i=0; i<m; J_ptr += 12, i++) { dReal Ad_i = Ad[i]; for (unsigned int j=0; j<12; j++) { @@ -475,7 +588,7 @@ // order to solve constraint rows in - IndexError *order = memarena->AllocateArray<IndexError> (m); + IndexError *order = memarena->AllocateArray<IndexError>(m); #ifndef REORDER_CONSTRAINTS { @@ -499,7 +612,7 @@ #ifdef REORDER_CONSTRAINTS // the lambda computed at the previous iteration. // this is used to measure error for when we are reordering the indexes. - dReal *last_lambda = memarena->AllocateArray<dReal> (m); + dReal *last_lambda = memarena->AllocateArray<dReal>(m); #endif const unsigned int num_iterations = qs->num_iterations; @@ -561,8 +674,8 @@ unsigned int index = order[i].index; - dRealMutablePtr fc_ptr1; - dRealMutablePtr fc_ptr2; + dReal *fc_ptr1; + dReal *fc_ptr2; dReal delta; { @@ -577,7 +690,7 @@ { delta = b[index] - old_lambda*Ad[index]; - dRealPtr J_ptr = J + (size_t)index*12; + const dReal *J_ptr = J + (size_t)index*12; // @@@ potential optimization: SIMD-ize this and the b2 >= 0 case delta -=fc_ptr1[0] * J_ptr[0] + fc_ptr1[1] * J_ptr[1] + fc_ptr1[2] * J_ptr[2] + fc_ptr1[3] * J_ptr[3] + @@ -631,7 +744,7 @@ //delta *= ramp; { - dRealPtr iMJ_ptr = iMJ + (size_t)index*12; + const dReal *iMJ_ptr = iMJ + (size_t)index*12; // update fc. // @@@ potential optimization: SIMD for this and the b2 >= 0 case fc_ptr1[0] += delta * iMJ_ptr[0]; @@ -656,7 +769,7 @@ } /*extern */ -void dxQuickStepIsland(dxStepperProcessingCallContext *callContext) +void dxQuickStepIsland(const dxStepperProcessingCallContext *callContext) { IFTIMING(dTimerStart("preprocessing")); @@ -665,8 +778,8 @@ unsigned int nb = callContext->m_islandBodiesCount; unsigned int _nj = callContext->m_islandJointsCount; - dReal *invI = memarena->AllocateArray<dReal> (3*4*(size_t)nb); - dJointWithInfo1 *const jointinfos = memarena->AllocateArray<dJointWithInfo1> (_nj); + dReal *invI = memarena->AllocateArray<dReal>(3 * 4 * (size_t)nb); + dJointWithInfo1 *const jointinfos = memarena->AllocateArray<dJointWithInfo1>(_nj); const unsigned allowedThreads = callContext->m_stepperAllowedThreads; dIASSERT(allowedThreads != 0); @@ -674,13 +787,13 @@ void *stagesMemArenaState = memarena->SaveState(); dxQuickStepperStage1CallContext *stage1CallContext = (dxQuickStepperStage1CallContext *)memarena->AllocateBlock(sizeof(dxQuickStepperStage1CallContext)); - new(stage1CallContext) dxQuickStepperStage1CallContext(callContext, stagesMemArenaState, invI, jointinfos); + stage1CallContext->Initialize(callContext, stagesMemArenaState, invI, jointinfos); dxQuickStepperStage0BodiesCallContext *stage0BodiesCallContext = (dxQuickStepperStage0BodiesCallContext *)memarena->AllocateBlock(sizeof(dxQuickStepperStage0BodiesCallContext)); - new(stage0BodiesCallContext) dxQuickStepperStage0BodiesCallContext(callContext, invI); - + stage0BodiesCallContext->Initialize(callContext, invI); + dxQuickStepperStage0JointsCallContext *stage0JointsCallContext = (dxQuickStepperStage0JointsCallContext *)memarena->AllocateBlock(sizeof(dxQuickStepperStage0JointsCallContext)); - new(stage0JointsCallContext) dxQuickStepperStage0JointsCallContext(callContext, jointinfos, &stage1CallContext->m_stage0Outputs); + stage0JointsCallContext->Initialize(callContext, jointinfos, &stage1CallContext->m_stage0Outputs); if (allowedThreads == 1) { @@ -846,27 +959,19 @@ static void dxQuickStepIsland_Stage1(dxQuickStepperStage1CallContext *stage1CallContext) { - dxStepperProcessingCallContext *callContext; - dReal *invI; - dJointWithInfo1 *jointinfos; - size_t nj; - unsigned int m; - unsigned int mfb; - { - callContext = stage1CallContext->m_stepperCallContext; - invI = stage1CallContext->m_invI; - jointinfos = stage1CallContext->m_jointinfos; - nj = stage1CallContext->m_stage0Outputs.nj; - m = stage1CallContext->m_stage0Outputs.m; - mfb = stage1CallContext->m_stage0Outputs.mfb; - } + const dxStepperProcessingCallContext *callContext = stage1CallContext->m_stepperCallContext; + dReal *invI = stage1CallContext->m_invI; + dJointWithInfo1 *jointinfos = stage1CallContext->m_jointinfos; + unsigned int nj = stage1CallContext->m_stage0Outputs.nj; + unsigned int m = stage1CallContext->m_stage0Outputs.m; + unsigned int mfb = stage1CallContext->m_stage0Outputs.mfb; dxWorldProcessMemArena *memarena = callContext->m_stepperArena; + memarena->RestoreState(stage1CallContext->m_stageMemArenaState); + stage1CallContext = NULL; // WARNING! _stage1CallContext is not valid after this point! + dIVERIFY(stage1CallContext == NULL); // To suppress unused variable assignment warnings + { - memarena->RestoreState(stage1CallContext->m_stageMemArenaState); - stage1CallContext = NULL; // WARNING! _stage1CallContext is not valid after this point! - dIVERIFY(stage1CallContext == NULL); // To suppress unused variable assignment warnings - unsigned int _nj = callContext->m_islandJointsCount; memarena->ShrinkArray<dJointWithInfo1>(jointinfos, _nj, nj); } @@ -875,161 +980,357 @@ dxBody * const *body = callContext->m_islandBodiesStart; unsigned int nb = callContext->m_islandBodiesCount; + unsigned int *mindex = NULL; + dReal *J = NULL, *cfm = NULL, *lo = NULL, *hi = NULL, *rhs = NULL, *Jcopy = NULL; + int *jb = NULL, *findex = NULL; + // if there are constraints, compute the constraint force - dReal *J = NULL; - int *jb = NULL; if (m > 0) { - dReal *cfm, *lo, *hi, *rhs, *Jcopy; - int *findex; - + mindex = memarena->AllocateArray<unsigned int>(2 * (size_t)(nj + 1)); { - unsigned int mlocal = m; + unsigned int *mcurr = mindex; + unsigned int moffs = 0, mfboffs = 0; + mcurr[0] = moffs; + mcurr[1] = mfboffs; + mcurr += 2; - const size_t jelements = (size_t)mlocal*12; - J = memarena->AllocateArray<dReal> (jelements); - dSetZero (J,jelements); + const dJointWithInfo1 *const jiend = jointinfos + nj; + for (const dJointWithInfo1 *jicurr = jointinfos; jicurr != jiend; ++jicurr) { + dxJoint *joint = jicurr->joint; + moffs += jicurr->info.m; + if (joint->feedback) { mfboffs += jicurr->info.m; } + mcurr[0] = moffs; + mcurr[1] = mfboffs; + mcurr += 2; + } + } - // create a constraint equation right hand side vector `c', a constraint - // force mixing vector `cfm', and LCP low and high bound vectors, and an - // 'findex' vector. - cfm = memarena->AllocateArray<dReal> (mlocal); - dSetValue (cfm,mlocal,world->global_cfm); + findex = memarena->AllocateArray<int>(m); + J = memarena->AllocateArray<dReal>((size_t)m*12); + cfm = memarena->AllocateArray<dReal>(m); + lo = memarena->AllocateArray<dReal>(m); + hi = memarena->AllocateArray<dReal>(m); + jb = memarena->AllocateArray<int>((size_t)m*2); + rhs = memarena->AllocateArray<dReal>(m); + Jcopy = memarena->AllocateArray<dReal>((size_t)mfb*12); + } - lo = memarena->AllocateArray<dReal> (mlocal); - dSetValue (lo,mlocal,-dInfinity); + dxQuickStepperLocalContext *localContext = (dxQuickStepperLocalContext *)memarena->AllocateBlock(sizeof(dxQuickStepperLocalContext)); + localContext->Initialize(invI, jointinfos, nj, m, mfb, mindex, findex, J, cfm, lo, hi, jb, rhs, Jcopy); - hi = memarena->AllocateArray<dReal> (mlocal); - dSetValue (hi,mlocal, dInfinity); + void *stage1MemarenaState = memarena->SaveState(); + dxQuickStepperStage3CallContext *stage3CallContext = (dxQuickStepperStage3CallContext*)memarena->AllocateBlock(sizeof(dxQuickStepperStage3CallContext)); + stage3CallContext->Initialize(callContext, localContext, stage1MemarenaState); - findex = memarena->AllocateArray<int> (mlocal); - for (unsigned int i=0; i<mlocal; i++) findex[i] = -1; + if (m > 0) { + // create a constraint equation right hand side vector `rhs', a constraint + // force mixing vector `cfm', and LCP low and high bound vectors, and an + // 'findex' vector. + dReal *rhs_tmp = memarena->AllocateArray<dReal>((size_t)nb*6); - const size_t jbelements = (size_t)mlocal*2; - jb = memarena->AllocateArray<int> (jbelements); + dxQuickStepperStage2CallContext *stage2CallContext = (dxQuickStepperStage2CallContext*)memarena->AllocateBlock(sizeof(dxQuickStepperStage2CallContext)); + stage2CallContext->Initialize(callContext, localContext, rhs_tmp); - rhs = memarena->AllocateArray<dReal> (mlocal); + const unsigned allowedThreads = callContext->m_stepperAllowedThreads; + dIASSERT(allowedThreads != 0); - Jcopy = memarena->AllocateArray<dReal> ((size_t)mfb*12); + if (allowedThreads == 1) + { + dxQuickStepIsland_Stage2a(stage2CallContext); + dxQuickStepIsland_Stage2b(stage2CallContext); + dxQuickStepIsland_Stage2c(stage2CallContext); + dxQuickStepIsland_Stage3(stage3CallContext); } + else + { + dCallReleaseeID stage3CallReleasee; + world->PostThreadedCallForUnawareReleasee(NULL, &stage3CallReleasee, 1, callContext->m_finalReleasee, + NULL, &dxQuickStepIsland_Stage3_Callback, stage3CallContext, 0, "QuickStepIsland Stage3"); - BEGIN_STATE_SAVE(memarena, cstate) { - dReal *c = memarena->AllocateArray<dReal> (m); - dSetZero (c, m); + dCallReleaseeID stage2bSyncReleasee; + world->PostThreadedCall(NULL, &stage2bSyncReleasee, 1, stage3CallReleasee, + NULL, &dxQuickStepIsland_Stage2bSync_Callback, stage2CallContext, 0, "QuickStepIsland Stage2b Sync"); - const dReal stepsizeRecip = dRecip(callContext->m_stepSize); + dCallReleaseeID stage2aSyncReleasee; + world->PostThreadedCall(NULL, &stage2aSyncReleasee, allowedThreads, stage2bSyncReleasee, + NULL, &dxQuickStepIsland_Stage2aSync_Callback, stage2CallContext, 0, "QuickStepIsland Stage2a Sync"); - { - IFTIMING (dTimerNow ("create J")); - // get jacobian data from constraints. an m*12 matrix will be created - // to store the two jacobian blocks from each constraint. it has this - // format: - // - // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 \ . - // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 }-- jacobian for joint 0, body 1 and body 2 (3 rows) - // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 / - // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 }--- jacobian for joint 1, body 1 and body 2 (3 rows) - // etc... - // - // (lll) = linear jacobian data - // (aaa) = angular jacobian data - // - dxJoint::Info2Descr Jinfo; - Jinfo.rowskip = 12; + world->PostThreadedCallsGroup(NULL, allowedThreads, stage2aSyncReleasee, &dxQuickStepIsland_Stage2a_Callback, stage2CallContext, "QuickStepIsland Stage2a"); + } + } + else { + dxQuickStepIsland_Stage3(stage3CallContext); + } +} - dReal *Jcopyrow = Jcopy; - unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointinfos; - const dJointWithInfo1 *const jiend = jicurr + nj; - for (; jicurr != jiend; jicurr++) { - dReal *const Jrow = J + (size_t)ofsi * 12; - Jinfo.J1l = Jrow; - Jinfo.J1a = Jrow + 3; - Jinfo.J2l = Jrow + 6; - Jinfo.J2a = Jrow + 9; - Jinfo.c = c + ofsi; - Jinfo.cfm = cfm + ofsi; - Jinfo.lo = lo + ofsi; - Jinfo.hi = hi + ofsi; - Jinfo.findex = findex + ofsi; - dxJoint *joint = jicurr->joint; - joint->getInfo2 (stepsizeRecip, world->global_erp, &Jinfo); +static +int dxQuickStepIsland_Stage2a_Callback(void *_stage2CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage2CallContext *stage2CallContext = (dxQuickStepperStage2CallContext *)_stage2CallContext; + dxQuickStepIsland_Stage2a(stage2CallContext); + return 1; +} - const unsigned int infom = jicurr->info.m; +static +void dxQuickStepIsland_Stage2a(dxQuickStepperStage2CallContext *stage2CallContext) +{ + const dxStepperProcessingCallContext *callContext = stage2CallContext->m_stepperCallContext; + const dxQuickStepperLocalContext *localContext = stage2CallContext->m_localContext; + dJointWithInfo1 *jointinfos = localContext->m_jointinfos; + unsigned int nj = localContext->m_nj; + const unsigned int *mindex = localContext->m_mindex; - // we need a copy of Jacobian for joint feedbacks - // because it gets destroyed by SOR solver - // instead of saving all Jacobian, we can save just rows - // for joints, that requested feedback (which is normally much less) - if (joint->feedback) { - const size_t rowels = (size_t)infom * 12; - memcpy(Jcopyrow, Jrow, (size_t)rowels * sizeof(dReal)); - Jcopyrow += rowels; - } + dxWorld *world = callContext->m_world; + const dReal stepsizeRecip = dRecip(callContext->m_stepSize); + { + int *findex = localContext->m_findex; + dReal *J = localContext->m_J; + dReal *cfm = localContext->m_cfm; + dReal *lo = localContext->m_lo; + dReal *hi = localContext->m_hi; + dReal *Jcopy = localContext->m_Jcopy; + dReal *rhs = localContext->m_rhs; - // adjust returned findex values for global index numbering - int *findex_ofsi = findex + ofsi; - for (unsigned int j=0; j<infom; j++) { - int fival = findex_ofsi[j]; - if (fival != -1) - findex_ofsi[j] = fival + ofsi; - } + IFTIMING (dTimerNow ("create J")); + // get jacobian data from constraints. an m*12 matrix will be created + // to store the two jacobian blocks from each constraint. it has this + // format: + // + // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 \ . + // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 }-- jacobian for joint 0, body 1 and body 2 (3 rows) + // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 / + // l1 l1 l1 a1 a1 a1 l2 l2 l2 a2 a2 a2 }--- jacobian for joint 1, body 1 and body 2 (3 rows) + // etc... + // + // (lll) = linear jacobian data + // (aaa) = angular jacobian data + // + const dReal worldERP = world->global_erp; - ofsi += infom; - } + dxJoint::Info2Descr Jinfo; + Jinfo.rowskip = 12; + + unsigned ji; + while ((ji = ThrsafeIncrementIntUpToLimit(&stage2CallContext->m_ji_J, nj)) != nj) { + const unsigned ofsi = mindex[ji * 2 + 0]; + const unsigned int infom = mindex[ji * 2 + 2] - ofsi; + + dReal *const Jrow = J + (size_t)ofsi * 12; + Jinfo.J1l = Jrow; + Jinfo.J1a = Jrow + 3; + Jinfo.J2l = Jrow + 6; + Jinfo.J2a = Jrow + 9; + dSetZero (Jrow, infom*12); + Jinfo.c = rhs + ofsi; + dSetZero (Jinfo.c, infom); + Jinfo.cfm = cfm + ofsi; + dSetValue (Jinfo.cfm, infom, world->global_cfm); + Jinfo.lo = lo + ofsi; + dSetValue (Jinfo.lo, infom, -dInfinity); + Jinfo.hi = hi + ofsi; + dSetValue (Jinfo.hi, infom, dInfinity); + Jinfo.findex = findex + ofsi; + dSetValue(Jinfo.findex, infom, -1); + + dxJoint *joint = jointinfos[ji].joint; + joint->getInfo2(stepsizeRecip, worldERP, &Jinfo); + + dReal *rhs_row = Jinfo.c; + dReal *cfm_row = Jinfo.cfm; + for (unsigned int i = 0; i != infom; ++i) { + rhs_row[i] *= stepsizeRecip; + cfm_row[i] *= stepsizeRecip; } - { - // create an array of body numbers for each joint row - int *jb_ptr = jb; - const dJointWithInfo1 *jicurr = jointinfos; - const dJointWithInfo1 *const jiend = jicurr + nj; - for (; jicurr != jiend; jicurr++) { - dxJoint *joint = jicurr->joint; - const unsigned int infom = jicurr->info.m; + // adjust returned findex values for global index numbering + int *findex_row = Jinfo.findex; + for (unsigned int j = infom; j != 0; ) { + --j; + int fival = findex_row[j]; + if (fival != -1) + findex_row[j] = fival + ofsi; + } - int b1 = (joint->node[0].body) ? (joint->node[0].body->tag) : -1; - int b2 = (joint->node[1].body) ? (joint->node[1].body->tag) : -1; - for (unsigned int j=0; j<infom; j++) { - jb_ptr[0] = b1; - jb_ptr[1] = b2; - jb_ptr += 2; - } - } - dIASSERT (jb_ptr == jb+2*(size_t)m); + // we need a copy of Jacobian for joint feedbacks + // because it gets destroyed by SOR solver + // instead of saving all Jacobian, we can save just rows + // for joints, that requested feedback (which is normally much less) + unsigned mfbcurr = mindex[ji * 2 + 1], mfbnext = mindex[ji * 2 + 3]; + if (mfbcurr != mfbnext) { + dReal *Jcopyrow = Jcopy + mfbcurr; + memcpy(Jcopyrow, Jrow, (mfbnext - mfbcurr) * 12 * sizeof(dReal)); } + } + } - BEGIN_STATE_SAVE(memarena, tmp1state) { - IFTIMING (dTimerNow ("compute rhs")); - // compute the right hand side `rhs' - dReal *tmp1 = memarena->AllocateArray<dReal> ((size_t)nb*6); - // put v/h + invM*fe into tmp1 - dReal *tmp1curr = tmp1; - const dReal *invIrow = invI; - dxBody *const *const bodyend = body + nb; - for (dxBody *const *bodycurr = body; bodycurr != bodyend; tmp1curr+=6, invIrow+=12, bodycurr++) { - dxBody *b = *bodycurr; - dReal body_invMass = b->invMass; - for (unsigned int j=0; j<3; j++) tmp1curr[j] = b->facc[j] * body_invMass + b->lvel[j] * stepsizeRecip; - dMultiply0_331 (tmp1curr + 3,invIrow,b->tacc); - for (unsigned int k=0; k<3; k++) tmp1curr[3+k] += b->avel[k] * stepsizeRecip; - } + { + int *jb = localContext->m_jb; - // put J*tmp1 into rhs - multiply_J (m,J,jb,tmp1,rhs); + // create an array of body numbers for each joint row + unsigned ji; + while ((ji = ThrsafeIncrementIntUpToLimit(&stage2CallContext->m_ji_jb, nj)) != nj) { + dxJoint *joint = jointinfos[ji].joint; + int b1 = (joint->node[0].body) ? (joint->node[0].body->tag) : -1; + int b2 = (joint->node[1].body) ? (joint->node[1].body->tag) : -1; - } END_STATE_SAVE(memarena, tmp1state); + int *const jb_end = jb + 2 * (size_t)mindex[ji * 2 + 2]; + int *jb_ptr = jb + 2 * (size_t)mindex[ji * 2 + 0]; + for (; jb_ptr != jb_end; jb_ptr += 2) { + jb_ptr[0] = b1; + jb_ptr[1] = b2; + } + } + } +} - // complete rhs - for (unsigned int i=0; i<m; i++) rhs[i] = c[i]*stepsizeRecip - rhs[i]; +static +int dxQuickStepIsland_Stage2aSync_Callback(void *_stage2CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage2CallContext *stage2CallContext = (dxQuickStepperStage2CallContext *)_stage2CallContext; + const dxStepperProcessingCallContext *callContext = stage2CallContext->m_stepperCallContext; + dxWorld *world = callContext->m_world; + const unsigned allowedThreads = callContext->m_stepperAllowedThreads; - // scale CFM - for (unsigned int j=0; j<m; j++) cfm[j] *= stepsizeRecip; + world->AlterThreadedCallDependenciesCount(callThisReleasee, allowedThreads); + world->PostThreadedCallsGroup(NULL, allowedThreads, callThisReleasee, &dxQuickStepIsland_Stage2b_Callback, stage2CallContext, "QuickStepIsland Stage2b"); - } END_STATE_SAVE(memarena, cstate); + return 1; +} +static +int dxQuickStepIsland_Stage2b_Callback(void *_stage2CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage2CallContext *stage2CallContext = (dxQuickStepperStage2CallContext *)_stage2CallContext; + dxQuickStepIsland_Stage2b(stage2CallContext); + return 1; +} + +static +void dxQuickStepIsland_Stage2b(dxQuickStepperStage2CallContext *stage2CallContext) +{ + const dxStepperProcessingCallContext *callContext = stage2CallContext->m_stepperCallContext; + const dxQuickStepperLocalContext *localContext = stage2CallContext->m_localContext; + + const dReal stepsizeRecip = dRecip(callContext->m_stepSize); + { + // Warning!!! + // This code reads facc/tacc fields of body objects which (the fields) + // may be modified by dxJoint::getInfo2(). Therefore the code must be + // in different sub-stage from Jacobian construction in Stage2a + // to ensure proper synchronization and avoid accessing numbers being modified. + // Warning!!! + dxBody * const *const body = callContext->m_islandBodiesStart; + const unsigned int nb = callContext->m_islandBodiesCount; + const dReal *invI = localContext->m_invI; + dReal *rhs_tmp = stage2CallContext->m_rhs_tmp; + + // compute the right hand side `rhs' + IFTIMING (dTimerNow ("compute rhs_tmp")); + + // put -(v/h + invM*fe) into rhs_tmp + unsigned bi; + while ((bi = ThrsafeIncrementIntUpToLimit(&stage2CallContext->m_bi, nb)) != nb) { + dReal *tmp1curr = rhs_tmp + (size_t)bi * 6; + const dReal *invIrow = invI + (size_t)bi * (6 * 2); + dxBody *b = body[bi]; + dReal body_invMass = b->invMass; + for (unsigned int j=0; j<3; ++j) tmp1curr[j] = -(b->facc[j] * body_invMass + b->lvel[j] * stepsizeRecip); + dMultiply0_331 (tmp1curr + 3, invIrow, b->tacc); + for (unsigned int k=0; k<3; ++k) tmp1curr[3+k] = -(b->avel[k] * stepsizeRecip) - tmp1curr[3+k]; + } + } +} + +static +int dxQuickStepIsland_Stage2bSync_Callback(void *_stage2CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage2CallContext *stage2CallContext = (dxQuickStepperStage2CallContext *)_stage2CallContext; + const dxStepperProcessingCallContext *callContext = stage2CallContext->m_stepperCallContext; + dxWorld *world = callContext->m_world; + const unsigned allowedThreads = callContext->m_stepperAllowedThreads; + + world->AlterThreadedCallDependenciesCount(callThisReleasee, allowedThreads); + world->PostThreadedCallsGroup(NULL, allowedThreads, callThisReleasee, &dxQuickStepIsland_Stage2c_Callback, stage2CallContext, "QuickStepIsland Stage2c"); + + return 1; +} + + +static +int dxQuickStepIsland_Stage2c_Callback(void *_stage2CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage2CallContext *stage2CallContext = (dxQuickStepperStage2CallContext *)_stage2CallContext; + dxQuickStepIsland_Stage2c(stage2CallContext); + return 1; +} + +static +void dxQuickStepIsland_Stage2c(dxQuickStepperStage2CallContext *stage2CallContext) +{ + const dxStepperProcessingCallContext *callContext = stage2CallContext->m_stepperCallContext; + const dxQuickStepperLocalContext *localContext = stage2CallContext->m_localContext; + + const dReal stepsizeRecip = dRecip(callContext->m_stepSize); + { + // Warning!!! + // This code depends on rhs_tmp and therefore must be in different sub-stage + // from rhs_tmp calculation in Stage2b to ensure proper synchronization + // and avoid accessing numbers being modified. + // Warning!!! + dReal *rhs = localContext->m_rhs; + const dReal *J = localContext->m_J; + const int *jb = localContext->m_jb; + const dReal *rhs_tmp = stage2CallContext->m_rhs_tmp; + const unsigned int m = localContext->m_m; + + // add J*rhs_tmp to rhs + multiplyAdd_J(&stage2CallContext->m_Jrhsi, m, J, jb, rhs_tmp, rhs); + } +} + + +static +int dxQuickStepIsland_Stage3_Callback(void *_stage3CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage3CallContext *stage3CallContext = (dxQuickStepperStage3CallContext *)_stage3CallContext; + dxQuickStepIsland_Stage3(stage3CallContext); + return 1; +} + +static +void dxQuickStepIsland_Stage3(dxQuickStepperStage3CallContext *stage3CallContext) +{ + const dxStepperProcessingCallContext *callContext = stage3CallContext->m_stepperCallContext; + const dxQuickStepperLocalContext *localContext = stage3CallContext->m_localContext; + + dxWorldProcessMemArena *memarena = callContext->m_stepperArena; + memarena->RestoreState(stage3CallContext->m_stage1MemArenaState); + stage3CallContext = NULL; // WARNING! stage3CallContext is not valid after this point! + dIVERIFY(stage3CallContext == NULL); // To suppress unused variable assignment warnings + + dReal *invI = localContext->m_invI; + dJointWithInfo1 *jointinfos = localContext->m_jointinfos; + unsigned int nj = localContext->m_nj; + unsigned int m = localContext->m_m; + unsigned int mfb = localContext->m_mfb; + const unsigned int *mindex = localContext->m_mindex; + const int *findex = localContext->m_findex; + dReal *J = localContext->m_J; + dReal *cfm = localContext->m_cfm; + dReal *lo = localContext->m_lo; + dReal *hi = localContext->m_hi; + int *jb = localContext->m_jb; + dReal *rhs = localContext->m_rhs; + dReal *Jcopy = localContext->m_Jcopy; + + dxWorld *world = callContext->m_world; + dxBody * const *body = callContext->m_islandBodiesStart; + unsigned int nb = callContext->m_islandBodiesCount; + + if (m > 0) { // load lambda from the value saved on the previous iteration - dReal *lambda = memarena->AllocateArray<dReal> (m); + dReal *lambda = memarena->AllocateArray<dReal>(m); #ifdef WARM_STARTING { @@ -1038,13 +1339,13 @@ const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; jicurr++) { unsigned int infom = jicurr->info.m; - memcpy (lambdscurr, jicurr->joint->lambda, (size_t)infom * sizeof(dReal)); + memcpy (lambdscurr, jicurr->joint->lambda, infom * sizeof(dReal)); lambdscurr += infom; } } #endif - dReal *cforce = memarena->AllocateArray<dReal> ((size_t)nb*6); + dReal *cforce = memarena->AllocateArray<dReal>((size_t)nb*6); BEGIN_STATE_SAVE(memarena, lcpstate) { IFTIMING (dTimerNow ("solving LCP problem")); @@ -1063,7 +1364,7 @@ const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; jicurr++) { unsigned int infom = jicurr->info.m; - memcpy (jicurr->joint->lambda, lambdacurr, (size_t)infom * sizeof(dReal)); + memcpy (jicurr->joint->lambda, lambdacurr, infom * sizeof(dReal)); lambdacurr += infom; } } @@ -1120,7 +1421,7 @@ fb->t2[2] = data[5]; } - Jcopyrow += (size_t)infom * 12; + Jcopyrow += infom * 12; } lambdacurr += infom; @@ -1160,8 +1461,8 @@ velcurr[3+j] = bodycurr->avel[j]; } } - dReal *tmp = memarena->AllocateArray<dReal> (m); - multiply_J (m,J,jb,vel,tmp); + dReal *tmp = memarena->AllocateArray<dReal>(m); + _multiply_J (m,J,jb,vel,tmp); dReal error = 0; for (unsigned int i=0; i<m; i++) error += dFabs(tmp[i]); printf ("velocity error = %10.6e\n",error); @@ -1245,38 +1546,35 @@ size_t res = 0; - res += dEFFICIENT_SIZE(sizeof(dReal) * 3 * 4 * (size_t)nb); // for invI + res += dEFFICIENT_SIZE(sizeof(dReal) * 3 * 4 * nb); // for invI { - size_t sub1_res1 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * (size_t)_nj); // for initial jointinfos + size_t sub1_res1 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * _nj); // for initial jointinfos - size_t sub1_res2 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * (size_t)nj); // for shrunk jointinfos + size_t sub1_res2 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * nj); // for shrunk jointinfos + sub1_res2 += dEFFICIENT_SIZE(sizeof(dxQuickStepperLocalContext)); // for dxQuickStepLocalContext if (m > 0) { - sub1_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 12 * (size_t)m); // for J - sub1_res2 += dEFFICIENT_SIZE(sizeof(int) * 12 * (size_t)m); // for jb - sub1_res2 += 4 * dEFFICIENT_SIZE(sizeof(dReal) * (size_t)m); // for cfm, lo, hi, rhs - sub1_res2 += dEFFICIENT_SIZE(sizeof(int) * (size_t)m); // for findex - sub1_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 12 * (size_t)mfb); // for Jcopy + sub1_res2 += dEFFICIENT_SIZE(sizeof(unsigned int) * 2 * (nj + 1)); // for mindex + sub1_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 12 * m); // for J + sub1_res2 += dEFFICIENT_SIZE(sizeof(int) * 12 * m); // for jb + sub1_res2 += 4 * dEFFICIENT_SIZE(sizeof(dReal) * m); // for cfm, lo, hi, rhs + sub1_res2 += dEFFICIENT_SIZE(sizeof(int) * m); // for findex + sub1_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 12 * mfb); // for Jcopy { - size_t sub2_res1 = dEFFICIENT_SIZE(sizeof(dReal) * (size_t)m); // for c - { - size_t sub3_res1 = dEFFICIENT_SIZE(sizeof(dReal) * 6 * (size_t)nb); // for tmp1 + size_t sub2_res1 = dEFFICIENT_SIZE(sizeof(dxQuickStepperStage3CallContext)); // for dxQuickStepperStage3CallContext + sub2_res1 += dEFFICIENT_SIZE(sizeof(dReal) * 6 * nb); // for rhs_tmp + sub2_res1 += dEFFICIENT_SIZE(sizeof(dxQuickStepperStage2CallContext)); // for dxQuickStepperStage2CallContext - size_t sub3_res2 = 0; - - sub2_res1 += dMAX(sub3_res1, sub3_res2); - } - - size_t sub2_res2 = dEFFICIENT_SIZE(sizeof(dReal) * (size_t)m); // for lambda - sub2_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 6 * (size_t)nb); // for cforce + size_t sub2_res2 = dEFFICIENT_SIZE(sizeof(dReal) * m); // for lambda + sub2_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 6 * nb); // for cforce { size_t sub3_res1 = EstimateSOR_LCPMemoryRequirements(m); // for SOR_LCP size_t sub3_res2 = 0; #ifdef CHECK_VELOCITY_OBEYS_CONSTRAINT { - size_t sub4_res1 = dEFFICIENT_SIZE(sizeof(dReal) * 6 * (size_t)nb); // for vel - sub4_res1 += dEFFICIENT_SIZE(sizeof(dReal) * (size_t)m); // for tmp + size_t sub4_res1 = dEFFICIENT_SIZE(sizeof(dReal) * 6 * nb); // for vel + sub4_res1 += dEFFICIENT_SIZE(sizeof(dReal) * m); // for tmp size_t sub4_res2 = 0; @@ -1289,6 +1587,9 @@ sub1_res2 += dMAX(sub2_res1, sub2_res2); } } + else { + sub1_res2 += dEFFICIENT_SIZE(sizeof(dxQuickStepperStage3CallContext)); // for dxQuickStepperStage3CallContext + } size_t sub1_res12_max = dMAX(sub1_res1, sub1_res2); size_t stage01_contexts = dEFFICIENT_SIZE(sizeof(dxQuickStepperStage0BodiesCallContext)) @@ -1305,8 +1606,8 @@ unsigned activeThreadCount, unsigned allowedThreadCount) { unsigned result = 1 // dxQuickStepIsland itself - + (allowedThreadCount + 1) // allowedThreadCount * dxQuickStepIsland_Stage0_Bodies + dxQuickStepIsland_Stage0_Joints - + 1; // dxQuickStepIsland_Stage1 + + (2 * allowedThreadCount + 2) // (dxQuickStepIsland_Stage2a + dxQuickStepIsland_Stage2b) * allowedThreadCount + 2 * dxStepIsland_Stage2?_Sync + + 1; // dxStepIsland_Stage3 return result; } Modified: trunk/ode/src/quickstep.h =================================================================== --- trunk/ode/src/quickstep.h 2012-12-25 23:24:39 UTC (rev 1918) +++ trunk/ode/src/quickstep.h 2012-12-25 23:31:06 UTC (rev 1919) @@ -33,7 +33,7 @@ unsigned dxEstimateQuickStepMaxCallCount( unsigned activeThreadCount, unsigned allowedThreadCount); -void dxQuickStepIsland(dxStepperProcessingCallContext *callContext); +void dxQuickStepIsland(const dxStepperProcessingCallContext *callContext); #endif Modified: trunk/ode/src/step.cpp =================================================================== --- trunk/ode/src/step.cpp 2012-12-25 23:24:39 UTC (rev 1918) +++ trunk/ode/src/step.cpp 2012-12-25 23:31:06 UTC (rev 1919) @@ -39,7 +39,6 @@ #define dMIN(A,B) ((A)>(B) ? (B) : (A)) #define dMAX(A,B) ((B)>(A) ? (B) : (A)) - //**************************************************************************** // misc defines @@ -69,13 +68,13 @@ struct dxStepperStage1CallContext { - dxStepperStage1CallContext(dxStepperProcessingCallContext *stepperCallContext, void *stageMemArenaState, dReal *invI, dJointWithInfo1 *jointinfos): + dxStepperStage1CallContext(const dxStepperProcessingCallContext *stepperCallContext, void *stageMemArenaState, dReal *invI, dJointWithInfo1 *jointinfos): m_stepperCallContext(stepperCallContext), m_stageMemArenaState(stageMemArenaState), m_invI(invI), m_jointinfos(jointinfos) { } - dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperProcessingCallContext *m_stepperCallContext; void *m_stageMemArenaState; dReal *m_invI; dJointWithInfo1 *m_jointinfos; @@ -84,13 +83,13 @@ struct dxStepperStage0BodiesCallContext { - dxStepperStage0BodiesCallContext(dxStepperProcessingCallContext *stepperCallContext, dReal *invI): + dxStepperStage0BodiesCallContext(const dxStepperProcessingCallContext *stepperCallContext, dReal *invI): m_stepperCallContext(stepperCallContext), m_invI(invI), m_tagsTaken(0), m_gravityTaken(0), m_inertiaBodyIndex(0) { } - dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperProcessingCallContext *m_stepperCallContext; dReal *m_invI; atomicord32 m_tagsTaken; atomicord32 m_gravityTaken; @@ -99,12 +98,12 @@ struct dxStepperStage0JointsCallContext { - dxStepperStage0JointsCallContext(dxStepperProcessingCallContext *stepperCallContext, dJointWithInfo1 *jointinfos, dxStepperStage0Outputs *stage0Outputs): + dxStepperStage0JointsCallContext(const dxStepperProcessingCallContext *stepperCallContext, dJointWithInfo1 *jointinfos, dxStepperStage0Outputs *stage0Outputs): m_stepperCallContext(stepperCallContext), m_jointinfos(jointinfos), m_stage0Outputs(stage0Outputs) { } - dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperProcessingCallContext *m_stepperCallContext; dJointWithInfo1 *m_jointinfos; dxStepperStage0Outputs *m_stage0Outputs; }; @@ -118,6 +117,97 @@ static void dxStepIsland_Stage1(dxStepperStage1CallContext *callContext); +struct dxStepperLocalContext +{ + void Initialize(dReal *invI, dJointWithInfo1 *jointinfos, unsigned int nj, + unsigned int m, unsigned int nub, const unsigned int *mindex, int *findex, + dReal *lo, dReal *hi, dReal *J, dReal *A, dReal *rhs) + { + m_invI = invI; + m_jointinfos = jointinfos; + m_nj = nj; + m_m = m; + m_nub = nub; + m_mindex = mindex; + m_findex = findex; + m_lo = lo; + m_hi = hi; + m_J = J; + m_A = A; + m_rhs = rhs; + } + + dReal *m_invI; + dJointWithInfo1 *m_jointinfos; + unsigned int m_nj; + unsigned int m_m; + unsigned int m_nub; + const unsigned int *m_mindex; + int *m_findex; + dReal *m_lo; + dReal *m_hi; + dReal *m_J; + dReal *m_A; + dReal *m_rhs; +}; + +struct dxStepperStage3CallContext +{ + void Initialize(const dxStepperProcessingCallContext *callContext, const dxStepperLocalContext *localContext, + void *stage1MemArenaState) + { + m_stepperCallContext = callContext; + m_localContext = localContext; + m_stage1MemArenaState = stage1MemArenaState; + } + + const dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperLocalContext *m_localContext; + void *m_stage1MemArenaState; +}; + +struct dxStepperStage2CallContext +{ + void Initialize(const dxStepperProcessingCallContext *callContext, const dxStepperLocalContext *localContext, + dReal *JinvM, dReal *rhs_tmp_or_cfm) + { + m_stepperCallContext = callContext; + m_localContext = localContext; + m_JinvM = JinvM; + m_rhs_tmp_or_cfm = rhs_tmp_or_cfm; + m_ji_J = 0; + m_ji_Ainit = 0; + m_ji_JinvM = 0; + m_ji_Aaddjb = 0; + m_bi_rhs_tmp = 0; + m_ji_rhs = 0; + } + + const dxStepperProcessingCallContext *m_stepperCallContext; + const dxStepperLocalContext *m_localContext; + dReal *m_JinvM; + dReal *m_rhs_tmp_or_cfm; + volatile unsigned m_ji_J; + volatile unsigned m_ji_Ainit; + volatile unsigned m_ji_JinvM; + volatile unsigned m_ji_Aaddjb; + volatile unsigned m_bi_rhs_tmp; + volatile unsigned m_ji_rhs; +}; + +static int dxStepIsland_Stage2a_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxStepIsland_Stage2aSync_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxStepIsland_Stage2b_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxStepIsland_Stage2bSync_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxStepIsland_Stage2c_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxStepIsland_Stage3_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); + +static void dxStepIsland_Stage2a(dxStepperStage2CallContext *callContext); +static void dxStepIsland_Stage2b(dxStepperStage2CallContext *callContext); +static void dxStepIsland_Stage2c(dxStepperStage2CallContext *callContext); +static void dxStepIsland_Stage3(dxStepperStage3CallContext *callContext); + + //**************************************************************************** // special matrix multipliers @@ -185,14 +275,15 @@ dIASSERT (p>0 && A && B && C); dReal *aa = A; const dReal *bb = B; + const dReal C_0 = C[0], C_1 = C[1], C_2 = C[2], C_4 = C[4], C_5 = C[5], C_6 = C[6]; for (unsigned int i = p; i != 0; --i) { dReal sum; - sum = bb[0]*C[0]; - sum += bb[1]*C[1]; - sum += bb[2]*C[2]; - sum += bb[4]*C[4]; - sum += bb[5]*C[5]; - sum += bb[6]*C[6]; + sum = bb[0]*C_0; + sum += bb[1]*C_1; + sum += bb[2]*C_2; + sum += bb[4]*C_4; + sum += bb[5]*C_5; + sum += bb[6]*C_6; *(aa++) -= sum; bb += 8; } @@ -252,7 +34... [truncated message content] |
From: <ole...@us...> - 2012-12-25 23:24:46
|
Revision: 1918 http://opende.svn.sourceforge.net/opende/?rev=1918&view=rev Author: oleh_derevenko Date: 2012-12-25 23:24:39 +0000 (Tue, 25 Dec 2012) Log Message: ----------- Changed: Threading usage option added to demo_crash. Modified Paths: -------------- trunk/ode/demo/demo_crash.cpp Modified: trunk/ode/demo/demo_crash.cpp =================================================================== --- trunk/ode/demo/demo_crash.cpp 2012-12-25 22:45:30 UTC (rev 1917) +++ trunk/ode/demo/demo_crash.cpp 2012-12-25 23:24:39 UTC (rev 1918) @@ -81,6 +81,8 @@ static dWorldID world; static dSpaceID space; +static dThreadingImplementationID threading; +static dThreadingThreadPoolID pool; static dBodyID body[10000]; static int bodies; static dJointID joint[100000]; @@ -229,19 +231,29 @@ sphereI += 4; } +static +void shutdownSimulation() +{ + // destroy world if it exists + if (bodies) + { + dThreadingImplementationShutdownProcessing(threading); + dThreadingFreeThreadPool(pool); + dWorldSetStepThreadingImplementation(world, NULL, NULL); + dThreadingFreeImplementation(threading); -void resetSimulation() + dJointGroupDestroy (contactgroup); + dSpaceDestroy (space); + dWorldDestroy (world); + + bodies = 0; + } +} + +static +void setupSimulation() { int i; - i = 0; - // destroy world if it exists - if (bodies) - { - dJointGroupDestroy (contactgroup); - dSpaceDestroy (space); - dWorldDestroy (world); - } - for (i = 0; i < 1000; i++) wb_stepsdis[i] = 0; @@ -258,6 +270,14 @@ dWorldSetCFM (world, 1e-5); dWorldSetERP (world, 0.8); dWorldSetQuickStepNumIterations (world,ITERS); + + threading = dThreadingAllocateMultiThreadedImplementation(); + pool = dThreadingAllocateThreadPool(4, 0, dAllocateFlagBasicData, NULL); + dThreadingThreadPoolServeMultiThreadedImplementation(pool, threading); + // dWorldSetStepIslandsProcessingMaxThreadCount(world, 1); + dWorldSetStepThreadingImplementation(world, dThreadingImplementationGetFunctions(threading), threading); + + ground = dCreatePlane (space,0,0,1,0); bodies = 0; @@ -447,7 +467,8 @@ doFast = !doFast; break; case 'r': case 'R': - resetSimulation(); + shutdownSimulation(); + setupSimulation(); break; case '[': cannon_angle += 0.1; @@ -610,14 +631,12 @@ boxes = 0; spheres = 0; - resetSimulation(); + setupSimulation(); // run simulation dsSimulationLoop (argc,argv,352,288,&fn); - dJointGroupDestroy (contactgroup); - dSpaceDestroy (space); - dWorldDestroy (world); + shutdownSimulation(); dCloseODE(); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-25 22:45:38
|
Revision: 1917 http://opende.svn.sourceforge.net/opende/?rev=1917&view=rev Author: oleh_derevenko Date: 2012-12-25 22:45:30 +0000 (Tue, 25 Dec 2012) Log Message: ----------- Changed: Private definitions moved from public <ode/matrix.h> into internal header "matrix.h" Modified Paths: -------------- trunk/include/ode/matrix.h trunk/include/ode/odeconfig.h trunk/ode/src/Makefile.am trunk/ode/src/box.cpp trunk/ode/src/capsule.cpp trunk/ode/src/collision_cylinder_box.cpp trunk/ode/src/collision_cylinder_plane.cpp trunk/ode/src/collision_cylinder_sphere.cpp trunk/ode/src/collision_cylinder_trimesh.cpp trunk/ode/src/collision_kernel.cpp trunk/ode/src/collision_quadtreespace.cpp trunk/ode/src/collision_sapspace.cpp trunk/ode/src/collision_space.cpp trunk/ode/src/collision_transform.cpp trunk/ode/src/collision_trimesh_box.cpp trunk/ode/src/collision_trimesh_ccylinder.cpp trunk/ode/src/collision_trimesh_disabled.cpp trunk/ode/src/collision_trimesh_gimpact.cpp trunk/ode/src/collision_trimesh_opcode.cpp trunk/ode/src/collision_trimesh_plane.cpp trunk/ode/src/collision_trimesh_ray.cpp trunk/ode/src/collision_trimesh_sphere.cpp trunk/ode/src/collision_trimesh_trimesh.cpp trunk/ode/src/collision_trimesh_trimesh_new.cpp trunk/ode/src/convex.cpp trunk/ode/src/cylinder.cpp trunk/ode/src/heightfield.cpp trunk/ode/src/joints/joint.cpp trunk/ode/src/joints/joint_internal.h trunk/ode/src/lcp.cpp trunk/ode/src/mass.cpp trunk/ode/src/mat.cpp trunk/ode/src/matrix.cpp trunk/ode/src/misc.cpp trunk/ode/src/objects.cpp trunk/ode/src/ode.cpp trunk/ode/src/plane.cpp trunk/ode/src/quickstep.cpp trunk/ode/src/ray.cpp trunk/ode/src/sphere.cpp trunk/ode/src/step.cpp Added Paths: ----------- trunk/ode/src/matrix.h Modified: trunk/include/ode/matrix.h =================================================================== --- trunk/include/ode/matrix.h 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/include/ode/matrix.h 2012-12-25 22:45:30 UTC (rev 1917) @@ -186,113 +186,9 @@ */ ODE_API void dRemoveRowCol (dReal *A, int n, int nskip, int r); - -#if defined(__ODE__) - -ODE_PURE_INLINE -void _dSetZero (dReal *a, size_t n) -{ - dReal *acurr = a; - dReal *const aend = a + n; - while (acurr != aend) { - *(acurr++) = 0; - } -} - -ODE_PURE_INLINE -void _dSetValue (dReal *a, size_t n, dReal value) -{ - dReal *acurr = a; - dReal *const aend = a + n; - while (acurr != aend) { - *(acurr++) = value; - } -} - -dReal _dDot (const dReal *a, const dReal *b, int n); -void _dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); -void _dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); -void _dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); -int _dFactorCholesky (dReal *A, int n, void *tmpbuf); -void _dSolveCholesky (const dReal *L, dReal *b, int n, void *tmpbuf); -int _dInvertPDMatrix (const dReal *A, dReal *Ainv, int n, void *tmpbuf); -int _dIsPositiveDefinite (const dReal *A, int n, void *tmpbuf); -void _dFactorLDLT (dReal *A, dReal *d, int n, int nskip); -void _dSolveL1 (const dReal *L, dReal *b, int n, int nskip); -void _dSolveL1T (const dReal *L, dReal *b, int n, int nskip); -void _dVectorScale (dReal *a, const dReal *d, int n); -void _dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip); -void _dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip, void *tmpbuf); -void _dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, int n1, int n2, int r, int nskip, void *tmpbuf); -void _dRemoveRowCol (dReal *A, int n, int nskip, int r); - -ODE_PURE_INLINE size_t _dEstimateFactorCholeskyTmpbufSize(int n) -{ - return dPAD(n) * sizeof(dReal); -} - -ODE_PURE_INLINE size_t _dEstimateSolveCholeskyTmpbufSize(int n) -{ - return dPAD(n) * sizeof(dReal); -} - -ODE_PURE_INLINE size_t _dEstimateInvertPDMatrixTmpbufSize(int n) -{ - size_t FactorCholesky_size = _dEstimateFactorCholeskyTmpbufSize(n); - size_t SolveCholesky_size = _dEstimateSolveCholeskyTmpbufSize(n); - size_t MaxCholesky_size = FactorCholesky_size > SolveCholesky_size ? FactorCholesky_size : SolveCholesky_size; - return dPAD(n) * (n + 1) * sizeof(dReal) + MaxCholesky_size; -} - -ODE_PURE_INLINE size_t _dEstimateIsPositiveDefiniteTmpbufSize(int n) -{ - return dPAD(n) * n * sizeof(dReal) + _dEstimateFactorCholeskyTmpbufSize(n); -} - -ODE_PURE_INLINE size_t _dEstimateLDLTAddTLTmpbufSize(int nskip) -{ - return nskip * 2 * sizeof(dReal); -} - -ODE_PURE_INLINE size_t _dEstimateLDLTRemoveTmpbufSize(int n2, int nskip) -{ - return n2 * sizeof(dReal) + _dEstimateLDLTAddTLTmpbufSize(nskip); -} - -/* For internal use */ -#define dSetZero(a, n) _dSetZero(a, n) -#define dSetValue(a, n, value) _dSetValue(a, n, value) -#define dDot(a, b, n) _dDot(a, b, n) -#define dMultiply0(A, B, C, p, q, r) _dMultiply0(A, B, C, p, q, r) -#define dMultiply1(A, B, C, p, q, r) _dMultiply1(A, B, C, p, q, r) -#define dMultiply2(A, B, C, p, q, r) _dMultiply2(A, B, C, p, q, r) -#define dFactorCholesky(A, n, tmpbuf) _dFactorCholesky(A, n, tmpbuf) -#define dSolveCholesky(L, b, n, tmpbuf) _dSolveCholesky(L, b, n, tmpbuf) -#define dInvertPDMatrix(A, Ainv, n, tmpbuf) _dInvertPDMatrix(A, Ainv, n, tmpbuf) -#define dIsPositiveDefinite(A, n, tmpbuf) _dIsPositiveDefinite(A, n, tmpbuf) -#define dFactorLDLT(A, d, n, nskip) _dFactorLDLT(A, d, n, nskip) -#define dSolveL1(L, b, n, nskip) _dSolveL1(L, b, n, nskip) -#define dSolveL1T(L, b, n, nskip) _dSolveL1T(L, b, n, nskip) -#define dVectorScale(a, d, n) _dVectorScale(a, d, n) -#define dSolveLDLT(L, d, b, n, nskip) _dSolveLDLT(L, d, b, n, nskip) -#define dLDLTAddTL(L, d, a, n, nskip, tmpbuf) _dLDLTAddTL(L, d, a, n, nskip, tmpbuf) -#define dLDLTRemove(A, p, L, d, n1, n2, r, nskip, tmpbuf) _dLDLTRemove(A, p, L, d, n1, n2, r, nskip, tmpbuf) -#define dRemoveRowCol(A, n, nskip, r) _dRemoveRowCol(A, n, nskip, r) - - -#define dEstimateFactorCholeskyTmpbufSize(n) _dEstimateFactorCholeskyTmpbufSize(n) -#define dEstimateSolveCholeskyTmpbufSize(n) _dEstimateSolveCholeskyTmpbufSize(n) -#define dEstimateInvertPDMatrixTmpbufSize(n) _dEstimateInvertPDMatrixTmpbufSize(n) -#define dEstimateIsPositiveDefiniteTmpbufSize(n) _dEstimateIsPositiveDefiniteTmpbufSize(n) -#define dEstimateLDLTAddTLTmpbufSize(nskip) _dEstimateLDLTAddTLTmpbufSize(nskip) -#define dEstimateLDLTRemoveTmpbufSize(n2, nskip) _dEstimateLDLTRemoveTmpbufSize(n2, nskip) - - -#endif /* defined(__ODE__) */ - - #ifdef __cplusplus } #endif + #endif Modified: trunk/include/ode/odeconfig.h =================================================================== --- trunk/include/ode/odeconfig.h 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/include/ode/odeconfig.h 2012-12-25 22:45:30 UTC (rev 1917) @@ -60,6 +60,7 @@ #endif #define ODE_PURE_INLINE static __inline +#define ODE_INLINE __inline #if defined(__cplusplus) #define ODE_EXTERN_C extern "C" Modified: trunk/ode/src/Makefile.am =================================================================== --- trunk/ode/src/Makefile.am 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/Makefile.am 2012-12-25 22:45:30 UTC (rev 1917) @@ -43,7 +43,7 @@ lcp.cpp lcp.h \ mass.cpp \ mat.cpp mat.h \ - matrix.cpp \ + matrix.cpp matrix.h \ memory.cpp \ misc.cpp \ objects.cpp objects.h \ Modified: trunk/ode/src/box.cpp =================================================================== --- trunk/ode/src/box.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/box.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -31,9 +31,9 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/capsule.cpp =================================================================== --- trunk/ode/src/capsule.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/capsule.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -31,9 +31,9 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/collision_cylinder_box.cpp =================================================================== --- trunk/ode/src/collision_cylinder_box.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_cylinder_box.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -26,9 +26,9 @@ */ #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_util.h" Modified: trunk/ode/src/collision_cylinder_plane.cpp =================================================================== --- trunk/ode/src/collision_cylinder_plane.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_cylinder_plane.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -30,10 +30,10 @@ */ #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include <ode/objects.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" // for dxGeom #include "collision_util.h" Modified: trunk/ode/src/collision_cylinder_sphere.cpp =================================================================== --- trunk/ode/src/collision_cylinder_sphere.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_cylinder_sphere.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -41,10 +41,10 @@ *******************************************************************/ #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include <ode/objects.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" // for dxGeom #include "collision_util.h" Modified: trunk/ode/src/collision_cylinder_trimesh.cpp =================================================================== --- trunk/ode/src/collision_cylinder_trimesh.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_cylinder_trimesh.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -27,9 +27,9 @@ #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_util.h" #include "collision_trimesh_internal.h" Modified: trunk/ode/src/collision_kernel.cpp =================================================================== --- trunk/ode/src/collision_kernel.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_kernel.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -28,10 +28,10 @@ */ #include <ode/common.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include <ode/objects.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_util.h" Modified: trunk/ode/src/collision_quadtreespace.cpp =================================================================== --- trunk/ode/src/collision_quadtreespace.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_quadtreespace.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -24,10 +24,10 @@ // With math corrections by Oleh Derevenko. ;) #include <ode/common.h> -#include <ode/matrix.h> #include <ode/collision_space.h> #include <ode/collision.h> #include "config.h" +#include "matrix.h" #include "collision_kernel.h" #include "collision_space_internal.h" Modified: trunk/ode/src/collision_sapspace.cpp =================================================================== --- trunk/ode/src/collision_sapspace.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_sapspace.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -34,11 +34,11 @@ */ #include <ode/common.h> -#include <ode/matrix.h> #include <ode/collision_space.h> #include <ode/collision.h> #include "config.h" +#include "matrix.h" #include "collision_kernel.h" #include "collision_space_internal.h" Modified: trunk/ode/src/collision_space.cpp =================================================================== --- trunk/ode/src/collision_space.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_space.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -27,10 +27,10 @@ */ #include <ode/common.h> -#include <ode/matrix.h> #include <ode/collision_space.h> #include <ode/collision.h> #include "config.h" +#include "matrix.h" #include "collision_kernel.h" #include "collision_space_internal.h" #include "util.h" Modified: trunk/ode/src/collision_transform.cpp =================================================================== --- trunk/ode/src/collision_transform.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_transform.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -27,9 +27,9 @@ */ #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_transform.h" #include "collision_util.h" Modified: trunk/ode/src/collision_trimesh_box.cpp =================================================================== --- trunk/ode/src/collision_trimesh_box.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_box.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -30,9 +30,9 @@ #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_util.h" #include "collision_trimesh_internal.h" Modified: trunk/ode/src/collision_trimesh_ccylinder.cpp =================================================================== --- trunk/ode/src/collision_trimesh_ccylinder.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_ccylinder.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -51,9 +51,9 @@ //problem we are looking forward to address soon. #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_util.h" #include "collision_trimesh_internal.h" Modified: trunk/ode/src/collision_trimesh_disabled.cpp =================================================================== --- trunk/ode/src/collision_trimesh_disabled.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_disabled.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -21,8 +21,8 @@ *************************************************************************/ #include <ode/collision.h> -#include <ode/matrix.h> #include "config.h" +#include "matrix.h" #if !dTRIMESH_ENABLED Modified: trunk/ode/src/collision_trimesh_gimpact.cpp =================================================================== --- trunk/ode/src/collision_trimesh_gimpact.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_gimpact.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -21,9 +21,9 @@ *************************************************************************/ #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #if dTRIMESH_ENABLED Modified: trunk/ode/src/collision_trimesh_opcode.cpp =================================================================== --- trunk/ode/src/collision_trimesh_opcode.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_opcode.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -23,9 +23,9 @@ // TriMesh code by Erwin de Vries. #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_util.h" #include "collision_trimesh_internal.h" Modified: trunk/ode/src/collision_trimesh_plane.cpp =================================================================== --- trunk/ode/src/collision_trimesh_plane.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_plane.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -23,9 +23,9 @@ // TriMesh - Plane collider by David Walters, July 2006 #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #if dTRIMESH_ENABLED Modified: trunk/ode/src/collision_trimesh_ray.cpp =================================================================== --- trunk/ode/src/collision_trimesh_ray.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_ray.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -23,9 +23,9 @@ // TriMesh code by Erwin de Vries. #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #if dTRIMESH_ENABLED Modified: trunk/ode/src/collision_trimesh_sphere.cpp =================================================================== --- trunk/ode/src/collision_trimesh_sphere.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_sphere.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -23,9 +23,9 @@ // TriMesh code by Erwin de Vries. #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_util.h" Modified: trunk/ode/src/collision_trimesh_trimesh.cpp =================================================================== --- trunk/ode/src/collision_trimesh_trimesh.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_trimesh.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -27,9 +27,9 @@ #endif #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" Modified: trunk/ode/src/collision_trimesh_trimesh_new.cpp =================================================================== --- trunk/ode/src/collision_trimesh_trimesh_new.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/collision_trimesh_trimesh_new.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -28,9 +28,9 @@ #endif #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" Modified: trunk/ode/src/convex.cpp =================================================================== --- trunk/ode/src/convex.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/convex.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -25,9 +25,9 @@ */ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/cylinder.cpp =================================================================== --- trunk/ode/src/cylinder.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/cylinder.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -31,9 +31,9 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/heightfield.cpp =================================================================== --- trunk/ode/src/heightfield.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/heightfield.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -30,9 +30,9 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/joints/joint.cpp =================================================================== --- trunk/ode/src/joints/joint.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/joints/joint.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -31,8 +31,8 @@ #include <ode/ode.h> #include <ode/rotation.h> -#include <ode/matrix.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "joint.h" #include "joint_internal.h" Modified: trunk/ode/src/joints/joint_internal.h =================================================================== --- trunk/ode/src/joints/joint_internal.h 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/joints/joint_internal.h 2012-12-25 22:45:30 UTC (rev 1917) @@ -25,9 +25,9 @@ #define _ODE_JOINT_INTERNAL_H_ -#include <ode/matrix.h> #include <ode/rotation.h> #include <ode/objects.h> +#include "matrix.h" #include "odemath.h" Modified: trunk/ode/src/lcp.cpp =================================================================== --- trunk/ode/src/lcp.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/lcp.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -109,10 +109,10 @@ */ #include <ode/common.h> -#include <ode/matrix.h> #include <ode/misc.h> #include <ode/timer.h> // for testing #include "config.h" +#include "matrix.h" #include "lcp.h" #include "mat.h" // for testing #include "util.h" Modified: trunk/ode/src/mass.cpp =================================================================== --- trunk/ode/src/mass.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/mass.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -22,8 +22,8 @@ #include <ode/odeconfig.h> #include <ode/mass.h> -#include <ode/matrix.h> #include "config.h" +#include "matrix.h" #include "odemath.h" // Local dependencies Modified: trunk/ode/src/mat.cpp =================================================================== --- trunk/ode/src/mat.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/mat.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -22,10 +22,10 @@ #include <ode/odeconfig.h> #include <ode/misc.h> -#include <ode/matrix.h> #include <ode/error.h> #include <ode/memory.h> #include "config.h" +#include "matrix.h" #include "mat.h" Modified: trunk/ode/src/matrix.cpp =================================================================== --- trunk/ode/src/matrix.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/matrix.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -21,8 +21,8 @@ *************************************************************************/ #include <ode/common.h> -#include <ode/matrix.h> #include "config.h" +#include "matrix.h" #include "util.h" // misc defines Added: trunk/ode/src/matrix.h =================================================================== --- trunk/ode/src/matrix.h (rev 0) +++ trunk/ode/src/matrix.h 2012-12-25 22:45:30 UTC (rev 1917) @@ -0,0 +1,174 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: ru...@q1... Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +/* + * optimized and unoptimized vector and matrix functions + * (inlined private versions) + */ + +#ifndef _ODE__PRIVATE_MATRIX_H_ +#define _ODE__PRIVATE_MATRIX_H_ + + +#include <ode/matrix.h> + + +#ifdef __cplusplus + +template <typename element_type> +ODE_INLINE +void _dSetZero (element_type *a, size_t n) +{ + element_type *acurr = a; + element_type *const aend = a + n; + while (acurr != aend) { + *(acurr++) = 0; + } +} + +template <typename element_type> +ODE_INLINE +void _dSetValue (element_type *a, size_t n, element_type value) +{ + element_type *acurr = a; + element_type *const aend = a + n; + while (acurr != aend) { + *(acurr++) = value; + } +} + + +#else // #ifndef __cplusplus + +ODE_PURE_INLINE +void _dSetZero (dReal *a, size_t n) +{ + dReal *acurr = a; + dReal *const aend = a + n; + while (acurr != aend) { + *(acurr++) = 0; + } +} + +ODE_PURE_INLINE +void _dSetValue (dReal *a, size_t n, dReal value) +{ + dReal *acurr = a; + dReal *const aend = a + n; + while (acurr != aend) { + *(acurr++) = value; + } +} + + +#endif // #ifdef __cplusplus + + +#ifdef __cplusplus +extern "C" { +#endif + +dReal _dDot (const dReal *a, const dReal *b, int n); +void _dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); +void _dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); +void _dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); +int _dFactorCholesky (dReal *A, int n, void *tmpbuf); +void _dSolveCholesky (const dReal *L, dReal *b, int n, void *tmpbuf); +int _dInvertPDMatrix (const dReal *A, dReal *Ainv, int n, void *tmpbuf); +int _dIsPositiveDefinite (const dReal *A, int n, void *tmpbuf); +void _dFactorLDLT (dReal *A, dReal *d, int n, int nskip); +void _dSolveL1 (const dReal *L, dReal *b, int n, int nskip); +void _dSolveL1T (const dReal *L, dReal *b, int n, int nskip); +void _dVectorScale (dReal *a, const dReal *d, int n); +void _dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip); +void _dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip, void *tmpbuf); +void _dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, int n1, int n2, int r, int nskip, void *tmpbuf); +void _dRemoveRowCol (dReal *A, int n, int nskip, int r); + +ODE_PURE_INLINE size_t _dEstimateFactorCholeskyTmpbufSize(int n) +{ + return dPAD(n) * sizeof(dReal); +} + +ODE_PURE_INLINE size_t _dEstimateSolveCholeskyTmpbufSize(int n) +{ + return dPAD(n) * sizeof(dReal); +} + +ODE_PURE_INLINE size_t _dEstimateInvertPDMatrixTmpbufSize(int n) +{ + size_t FactorCholesky_size = _dEstimateFactorCholeskyTmpbufSize(n); + size_t SolveCholesky_size = _dEstimateSolveCholeskyTmpbufSize(n); + size_t MaxCholesky_size = FactorCholesky_size > SolveCholesky_size ? FactorCholesky_size : SolveCholesky_size; + return dPAD(n) * (n + 1) * sizeof(dReal) + MaxCholesky_size; +} + +ODE_PURE_INLINE size_t _dEstimateIsPositiveDefiniteTmpbufSize(int n) +{ + return dPAD(n) * n * sizeof(dReal) + _dEstimateFactorCholeskyTmpbufSize(n); +} + +ODE_PURE_INLINE size_t _dEstimateLDLTAddTLTmpbufSize(int nskip) +{ + return nskip * 2 * sizeof(dReal); +} + +ODE_PURE_INLINE size_t _dEstimateLDLTRemoveTmpbufSize(int n2, int nskip) +{ + return n2 * sizeof(dReal) + _dEstimateLDLTAddTLTmpbufSize(nskip); +} + +/* For internal use */ +#define dSetZero(a, n) _dSetZero(a, n) +#define dSetValue(a, n, value) _dSetValue(a, n, value) +#define dDot(a, b, n) _dDot(a, b, n) +#define dMultiply0(A, B, C, p, q, r) _dMultiply0(A, B, C, p, q, r) +#define dMultiply1(A, B, C, p, q, r) _dMultiply1(A, B, C, p, q, r) +#define dMultiply2(A, B, C, p, q, r) _dMultiply2(A, B, C, p, q, r) +#define dFactorCholesky(A, n, tmpbuf) _dFactorCholesky(A, n, tmpbuf) +#define dSolveCholesky(L, b, n, tmpbuf) _dSolveCholesky(L, b, n, tmpbuf) +#define dInvertPDMatrix(A, Ainv, n, tmpbuf) _dInvertPDMatrix(A, Ainv, n, tmpbuf) +#define dIsPositiveDefinite(A, n, tmpbuf) _dIsPositiveDefinite(A, n, tmpbuf) +#define dFactorLDLT(A, d, n, nskip) _dFactorLDLT(A, d, n, nskip) +#define dSolveL1(L, b, n, nskip) _dSolveL1(L, b, n, nskip) +#define dSolveL1T(L, b, n, nskip) _dSolveL1T(L, b, n, nskip) +#define dVectorScale(a, d, n) _dVectorScale(a, d, n) +#define dSolveLDLT(L, d, b, n, nskip) _dSolveLDLT(L, d, b, n, nskip) +#define dLDLTAddTL(L, d, a, n, nskip, tmpbuf) _dLDLTAddTL(L, d, a, n, nskip, tmpbuf) +#define dLDLTRemove(A, p, L, d, n1, n2, r, nskip, tmpbuf) _dLDLTRemove(A, p, L, d, n1, n2, r, nskip, tmpbuf) +#define dRemoveRowCol(A, n, nskip, r) _dRemoveRowCol(A, n, nskip, r) + + +#define dEstimateFactorCholeskyTmpbufSize(n) _dEstimateFactorCholeskyTmpbufSize(n) +#define dEstimateSolveCholeskyTmpbufSize(n) _dEstimateSolveCholeskyTmpbufSize(n) +#define dEstimateInvertPDMatrixTmpbufSize(n) _dEstimateInvertPDMatrixTmpbufSize(n) +#define dEstimateIsPositiveDefiniteTmpbufSize(n) _dEstimateIsPositiveDefiniteTmpbufSize(n) +#define dEstimateLDLTAddTLTmpbufSize(nskip) _dEstimateLDLTAddTLTmpbufSize(nskip) +#define dEstimateLDLTRemoveTmpbufSize(n2, nskip) _dEstimateLDLTRemoveTmpbufSize(n2, nskip) + + +#ifdef __cplusplus +} +#endif + + +#endif // #ifndef _ODE__PRIVATE_MATRIX_H_ Modified: trunk/ode/src/misc.cpp =================================================================== --- trunk/ode/src/misc.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/misc.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -22,8 +22,8 @@ #include <ode/odeconfig.h> #include <ode/misc.h> -#include <ode/matrix.h> #include "config.h" +#include "matrix.h" //**************************************************************************** // random numbers Modified: trunk/ode/src/objects.cpp =================================================================== --- trunk/ode/src/objects.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/objects.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -26,9 +26,8 @@ #include <ode/common.h> #include <ode/threading_impl.h> #include <ode/objects.h> -#include <ode/matrix.h> #include "config.h" - +#include "matrix.h" #include "objects.h" #include "util.h" #include "threading_impl.h" Modified: trunk/ode/src/ode.cpp =================================================================== --- trunk/ode/src/ode.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/ode.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -28,10 +28,10 @@ // numerics. #include <ode/ode.h> -#include <ode/matrix.h> #include <ode/memory.h> #include <ode/error.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "objects.h" #include "joints/joints.h" Modified: trunk/ode/src/plane.cpp =================================================================== --- trunk/ode/src/plane.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/plane.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -31,9 +31,9 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/quickstep.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -24,9 +24,9 @@ #include <ode/rotation.h> #include <ode/timer.h> #include <ode/error.h> -#include <ode/matrix.h> #include <ode/misc.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "objects.h" #include "joints/joint.h" Modified: trunk/ode/src/ray.cpp =================================================================== --- trunk/ode/src/ray.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/ray.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -31,9 +31,9 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/sphere.cpp =================================================================== --- trunk/ode/src/sphere.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/sphere.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -31,9 +31,9 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/matrix.h> #include <ode/rotation.h> #include "config.h" +#include "matrix.h" #include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" Modified: trunk/ode/src/step.cpp =================================================================== --- trunk/ode/src/step.cpp 2012-12-18 22:34:05 UTC (rev 1916) +++ trunk/ode/src/step.cpp 2012-12-25 22:45:30 UTC (rev 1917) @@ -24,9 +24,9 @@ #include <ode/rotation.h> #include <ode/timer.h> #include <ode/error.h> -#include <ode/matrix.h> #include "config.h" #include "odemath.h" +#include "matrix.h" #include "objects.h" #include "joints/joint.h" #include "lcp.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-18 22:34:13
|
Revision: 1916 http://opende.svn.sourceforge.net/opende/?rev=1916&view=rev Author: oleh_derevenko Date: 2012-12-18 22:34:05 +0000 (Tue, 18 Dec 2012) Log Message: ----------- Fixed issue with some kinds of joints (Ball, DBall, DHinge, Fixed) might overwrite world ERP value with their custom ERP during getInfo2() call and that inappropriate value would then be passed to subsequent joints in solver instead of world ERP. Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/joints/amotor.cpp trunk/ode/src/joints/amotor.h trunk/ode/src/joints/ball.cpp trunk/ode/src/joints/ball.h trunk/ode/src/joints/contact.cpp trunk/ode/src/joints/contact.h trunk/ode/src/joints/dball.cpp trunk/ode/src/joints/dball.h trunk/ode/src/joints/dhinge.cpp trunk/ode/src/joints/dhinge.h trunk/ode/src/joints/fixed.cpp trunk/ode/src/joints/fixed.h trunk/ode/src/joints/hinge.cpp trunk/ode/src/joints/hinge.h trunk/ode/src/joints/hinge2.cpp trunk/ode/src/joints/hinge2.h trunk/ode/src/joints/joint.cpp trunk/ode/src/joints/joint.h trunk/ode/src/joints/joint_internal.h trunk/ode/src/joints/lmotor.cpp trunk/ode/src/joints/lmotor.h trunk/ode/src/joints/null.cpp trunk/ode/src/joints/null.h trunk/ode/src/joints/piston.cpp trunk/ode/src/joints/piston.h trunk/ode/src/joints/plane2d.cpp trunk/ode/src/joints/plane2d.h trunk/ode/src/joints/pr.cpp trunk/ode/src/joints/pr.h trunk/ode/src/joints/pu.cpp trunk/ode/src/joints/pu.h trunk/ode/src/joints/slider.cpp trunk/ode/src/joints/slider.h trunk/ode/src/joints/universal.cpp trunk/ode/src/joints/universal.h trunk/ode/src/quickstep.cpp trunk/ode/src/step.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/CHANGELOG.txt 2012-12-18 22:34:05 UTC (rev 1916) @@ -8,6 +8,11 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +12/18/12 Oleh_Derevenko + * Fixed issue with some kinds of joints (Ball, DBall, DHinge, Fixed) + might overwrite world ERP value with their custom ERP during + getInfo2() call and that inappropriate value would then be passed + to subsequent joints in solver instead of world ERP. 12/01/12 Oleh_Derevenko * Fixed issues reported in patches #151 and #22 (collisions with SAPSpace and QuadTreeSpace might not work because geometries list Modified: trunk/ode/src/joints/amotor.cpp =================================================================== --- trunk/ode/src/joints/amotor.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/amotor.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -215,7 +215,7 @@ void -dxJointAMotor::getInfo2( dxJoint::Info2 *info ) +dxJointAMotor::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ) { int i; @@ -256,7 +256,7 @@ int row = 0; for ( i = 0; i < num; i++ ) { - row += limot[i].addLimot( this, info, row, *( axptr[i] ), 1 ); + row += limot[i].addLimot( this, worldFPS, info, row, *( axptr[i] ), 1 ); } } Modified: trunk/ode/src/joints/amotor.h =================================================================== --- trunk/ode/src/joints/amotor.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/amotor.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -49,7 +49,7 @@ dxJointAMotor( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; }; Modified: trunk/ode/src/joints/ball.cpp =================================================================== --- trunk/ode/src/joints/ball.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/ball.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -55,13 +55,12 @@ void -dxJointBall::getInfo2( dxJoint::Info2 *info ) +dxJointBall::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ) { - info->erp = erp; info->cfm[0] = cfm; info->cfm[1] = cfm; info->cfm[2] = cfm; - setBall( this, info, anchor1, anchor2 ); + setBall( this, worldFPS, this->erp, info, anchor1, anchor2 ); } Modified: trunk/ode/src/joints/ball.h =================================================================== --- trunk/ode/src/joints/ball.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/ball.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -39,7 +39,7 @@ dxJointBall( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/contact.cpp =================================================================== --- trunk/ode/src/joints/contact.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/contact.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -72,7 +72,7 @@ void -dxJointContact::getInfo2( dxJoint::Info2 *info ) +dxJointContact::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { int s = info->rowskip; int s2 = 2 * s; @@ -120,10 +120,10 @@ } // set right hand side and cfm value for normal - dReal erp = info->erp; + dReal erp = worldERP; if ( contact.surface.mode & dContactSoftERP ) erp = contact.surface.soft_erp; - dReal k = info->fps * erp; + dReal k = worldFPS * erp; dReal depth = contact.geom.depth - world->contactp.min_depth; if ( depth < 0 ) depth = 0; Modified: trunk/ode/src/joints/contact.h =================================================================== --- trunk/ode/src/joints/contact.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/contact.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -35,7 +35,7 @@ dxJointContact( dxWorld* w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; }; Modified: trunk/ode/src/joints/dball.cpp =================================================================== --- trunk/ode/src/joints/dball.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/dball.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -54,10 +54,9 @@ } void -dxJointDBall::getInfo2( dxJoint::Info2 *info ) +dxJointDBall::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { - info->erp = erp; - info->cfm[0] = cfm; + info->cfm[0] = this->cfm; dVector3 globalA1, globalA2; dBodyGetRelPointPos(node[0].body, anchor1[0], anchor1[1], anchor1[2], globalA1); @@ -125,9 +124,8 @@ dMultiply1_331(info->J2a, a2m, q); } - const dReal k = info->fps * info->erp; + const dReal k = worldFPS * this->erp; info->c[0] = k * (targetDistance - dCalcPointsDistance3(globalA1, globalA2)); - } Modified: trunk/ode/src/joints/dball.h =================================================================== --- trunk/ode/src/joints/dball.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/dball.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -43,7 +43,7 @@ dxJointDBall( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/dhinge.cpp =================================================================== --- trunk/ode/src/joints/dhinge.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/dhinge.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -54,9 +54,9 @@ void -dxJointDHinge::getInfo2( dxJoint::Info2* info ) +dxJointDHinge::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ) { - dxJointDBall::getInfo2( info ); // sets row0 + dxJointDBall::getInfo2( worldFPS, worldERP, info ); // sets row0 const int skip = info->rowskip; const int row1 = skip; @@ -94,7 +94,7 @@ // similar to the hinge joint dVector3 u; dCalcVectorCross3(u, globalAxis1, globalAxis2); - const dReal k = info->fps * info->erp; + const dReal k = worldFPS * this->erp; info->c[1] = k * dCalcVectorDot3( u, p ); info->c[2] = k * dCalcVectorDot3( u, q ); Modified: trunk/ode/src/joints/dhinge.h =================================================================== --- trunk/ode/src/joints/dhinge.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/dhinge.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -33,7 +33,7 @@ virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/fixed.cpp =================================================================== --- trunk/ode/src/joints/fixed.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/fixed.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -57,12 +57,12 @@ void -dxJointFixed::getInfo2 ( dxJoint::Info2 *info ) +dxJointFixed::getInfo2 ( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { int s = info->rowskip; // Three rows for orientation - setFixedOrientation ( this, info, qrel, 3 ); + setFixedOrientation ( this, worldFPS, worldERP, info, qrel, 3 ); // Three rows for position. // set jacobian @@ -70,10 +70,9 @@ info->J1l[s+1] = 1; info->J1l[2*s+2] = 1; - info->erp = erp; - info->cfm[0] = cfm; - info->cfm[1] = cfm; - info->cfm[2] = cfm; + info->cfm[0] = this->cfm; + info->cfm[1] = this->cfm; + info->cfm[2] = this->cfm; dVector3 ofs; dMultiply0_331 ( ofs, node[0].body->posr.R, offset ); @@ -86,7 +85,7 @@ } // set right hand side for the first three rows (linear) - dReal k = info->fps * info->erp; + dReal k = worldFPS * this->erp; if ( node[1].body ) { for ( int j = 0; j < 3; j++ ) Modified: trunk/ode/src/joints/fixed.h =================================================================== --- trunk/ode/src/joints/fixed.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/fixed.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -40,7 +40,7 @@ dxJointFixed ( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1 ( Info1* info ); - virtual void getInfo2 ( Info2* info ); + virtual void getInfo2 ( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/hinge.cpp =================================================================== --- trunk/ode/src/joints/hinge.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/hinge.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -74,11 +74,10 @@ } -void -dxJointHinge::getInfo2( dxJoint::Info2 *info ) +void dxJointHinge::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ) { // set the three ball-and-socket rows - setBall( this, info, anchor1, anchor2 ); + setBall( this, worldFPS, worldERP, info, anchor1, anchor2 ); // set the two hinge rows. the hinge axis should be the only unconstrained // rotational axis, the angular velocity of the two bodies perpendicular to @@ -141,12 +140,12 @@ ax2[2] = axis2[2]; } dCalcVectorCross3( b, ax1, ax2 ); - dReal k = info->fps * info->erp; + dReal k = worldFPS * worldERP; info->c[3] = k * dCalcVectorDot3( b, p ); info->c[4] = k * dCalcVectorDot3( b, q ); // if the hinge is powered, or has joint limits, add in the stuff - limot.addLimot( this, info, 5, ax1, 1 ); + limot.addLimot( this, worldFPS, info, 5, ax1, 1 ); } Modified: trunk/ode/src/joints/hinge.h =================================================================== --- trunk/ode/src/joints/hinge.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/hinge.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -40,7 +40,7 @@ dxJointHinge( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/hinge2.cpp =================================================================== --- trunk/ode/src/joints/hinge2.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/hinge2.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -126,7 +126,7 @@ void -dxJointHinge2::getInfo2( dxJoint::Info2 *info ) +dxJointHinge2::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { // get information we need to set the hinge row dReal s, c; @@ -138,7 +138,7 @@ dNormalize3( q ); // @@@ quicker: divide q by s ? // set the three ball-and-socket rows (aligned to the suspension axis ax1) - setBall2( this, info, anchor1, anchor2, ax1, susp_erp ); + setBall2( this, worldFPS, worldERP, info, anchor1, anchor2, ax1, susp_erp ); // set the hinge row int s3 = 3 * info->rowskip; @@ -167,14 +167,14 @@ // where c = cos(theta), s = sin(theta) // c0 = cos(theta0), s0 = sin(theta0) - dReal k = info->fps * info->erp; + dReal k = worldFPS * worldERP; info->c[3] = k * ( c0 * s - joint->s0 * c ); // if the axis1 hinge is powered, or has joint limits, add in more stuff - int row = 4 + limot1.addLimot( this, info, 4, ax1, 1 ); + int row = 4 + limot1.addLimot( this, worldFPS, info, 4, ax1, 1 ); // if the axis2 hinge is powered, add in more stuff - limot2.addLimot( this, info, row, ax2, 1 ); + limot2.addLimot( this, worldFPS, info, row, ax2, 1 ); // set parameter for the suspension info->cfm[0] = susp_cfm; Modified: trunk/ode/src/joints/hinge2.h =================================================================== --- trunk/ode/src/joints/hinge2.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/hinge2.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -52,7 +52,7 @@ virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/joint.cpp =================================================================== --- trunk/ode/src/joints/joint.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/joint.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -101,7 +101,7 @@ // set three "ball-and-socket" rows in the constraint equation, and the // corresponding right hand side. -void setBall( dxJoint *joint, dxJoint::Info2 *info, +void setBall( dxJoint *joint, dReal fps, dReal erp, const dxJoint::Info2Descr *info, dVector3 anchor1, dVector3 anchor2 ) { // anchor points in global coordinates with respect to body PORs. @@ -125,7 +125,7 @@ } // set right hand side - dReal k = info->fps * info->erp; + dReal k = fps * erp; if ( joint->node[1].body ) { for ( int j = 0; j < 3; j++ ) @@ -150,7 +150,7 @@ // position row (the other two row vectors will be derived from this). // `erp1' is the erp value to use along the axis. -void setBall2( dxJoint *joint, dxJoint::Info2 *info, +void setBall2( dxJoint *joint, dReal fps, dReal erp, const dxJoint::Info2Descr *info, dVector3 anchor1, dVector3 anchor2, dVector3 axis, dReal erp1 ) { @@ -190,8 +190,8 @@ } // set right hand side - measure error along (axis,q1,q2) - dReal k1 = info->fps * erp1; - dReal k = info->fps * info->erp; + dReal k1 = fps * erp1; + dReal k = fps * erp; for ( i = 0; i < 3; i++ ) a1[i] += joint->node[0].body->posr.pos[i]; if ( joint->node[1].body ) @@ -218,7 +218,7 @@ // set three orientation rows in the constraint equation, and the // corresponding right hand side. -void setFixedOrientation( dxJoint *joint, dxJoint::Info2 *info, dQuaternion qrel, int start_row ) +void setFixedOrientation( dxJoint *joint, dReal fps, dReal erp, const dxJoint::Info2Descr *info, dQuaternion qrel, int start_row ) { int s = info->rowskip; int start_index = start_row * s; @@ -267,7 +267,7 @@ qerr[3] = -qerr[3]; } dMultiply0_331( e, joint->node[0].body->posr.R, qerr + 1 ); // @@@ bad SIMD padding! - dReal k = info->fps * info->erp; + dReal k = fps * erp; info->c[start_row] = 2 * k * e[0]; info->c[start_row+1] = 2 * k * e[1]; info->c[start_row+2] = 2 * k * e[2]; @@ -573,8 +573,8 @@ int dxJointLimitMotor::addLimot( dxJoint *joint, - dxJoint::Info2 *info, int row, - const dVector3 ax1, int rotational ) + dReal fps, const dxJoint::Info2Descr *info, int row, + const dVector3 ax1, int rotational ) { int srow = row * info->rowskip; @@ -680,7 +680,7 @@ if ( limit ) { - dReal k = info->fps * stop_erp; + dReal k = fps * stop_erp; info->c[row] = -k * limit_err; info->cfm[row] = stop_cfm; Modified: trunk/ode/src/joints/joint.h =================================================================== --- trunk/ode/src/joints/joint.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/joint.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -82,12 +82,8 @@ // info returned by getInfo2 function - struct Info2 + struct Info2Descr { - // integrator parameters: frames per second (1/stepsize), default error - // reduction parameter (0..1). - dReal fps, erp; - // for the first and second body, pointers to two (linear and angular) // n*3 jacobian sub matrices, stored by rows. these matrices will have // been initialized to 0 on entry. if the second body is zero then the @@ -141,7 +137,9 @@ virtual ~dxJoint(); virtual void getInfo1( Info1* info ) = 0; - virtual void getInfo2( Info2* info ) = 0; + + // integrator parameters: fps=frames per second (1/stepsize), erp=default error reduction parameter (0..1). + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ) = 0; // This call quickly!!! estimates maximum value of "m" that could be returned by getInfo1() // See comments at definition of SureMaxInfo for defails. virtual void getSureMaxInfo( SureMaxInfo* info ) = 0; @@ -207,7 +205,7 @@ void set( int num, dReal value ); dReal get( int num ); int testRotationalLimit( dReal angle ); - int addLimot( dxJoint *joint, dxJoint::Info2 *info, int row, + int addLimot( dxJoint *joint, dReal fps, const dxJoint::Info2Descr *info, int row, const dVector3 ax1, int rotational ); }; Modified: trunk/ode/src/joints/joint_internal.h =================================================================== --- trunk/ode/src/joints/joint_internal.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/joint_internal.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -35,9 +35,9 @@ "joint type is not " #t) -void setBall( dxJoint *joint, dxJoint::Info2 *info, +void setBall( dxJoint *joint, dReal fps, dReal erp, const dxJoint::Info2Descr *info, dVector3 anchor1, dVector3 anchor2 ); -void setBall2( dxJoint *joint, dxJoint::Info2 *info, +void setBall2( dxJoint *joint, dReal fps, dReal erp, const dxJoint::Info2Descr *info, dVector3 anchor1, dVector3 anchor2, dVector3 axis, dReal erp1 ); @@ -57,7 +57,7 @@ dReal getHingeAngle( dxBody *body1, dxBody *body2, dVector3 axis, dQuaternion q_initial ); dReal getHingeAngleFromRelativeQuat( dQuaternion qrel, dVector3 axis ); -void setFixedOrientation( dxJoint *joint, dxJoint::Info2 *info, dQuaternion qrel, int start_row ); +void setFixedOrientation( dxJoint *joint, dReal fps, dReal erp, const dxJoint::Info2Descr *info, dQuaternion qrel, int start_row ); #endif Modified: trunk/ode/src/joints/lmotor.cpp =================================================================== --- trunk/ode/src/joints/lmotor.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/lmotor.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -87,7 +87,7 @@ } void -dxJointLMotor::getInfo2( dxJoint::Info2 *info ) +dxJointLMotor::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { int row = 0; dVector3 ax[3]; @@ -95,7 +95,7 @@ for ( int i = 0;i < num;i++ ) { - row += limot[i].addLimot( this, info, row, ax[i], 0 ); + row += limot[i].addLimot( this, worldFPS, info, row, ax[i], 0 ); } } Modified: trunk/ode/src/joints/lmotor.h =================================================================== --- trunk/ode/src/joints/lmotor.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/lmotor.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -38,7 +38,7 @@ dxJointLMotor( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; }; Modified: trunk/ode/src/joints/null.cpp =================================================================== --- trunk/ode/src/joints/null.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/null.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -51,7 +51,7 @@ void -dxJointNull::getInfo2( dxJoint::Info2 *info ) +dxJointNull::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { dDebug( 0, "this should never get called" ); } Modified: trunk/ode/src/joints/null.h =================================================================== --- trunk/ode/src/joints/null.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/null.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -34,7 +34,7 @@ dxJointNull( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; }; Modified: trunk/ode/src/joints/piston.cpp =================================================================== --- trunk/ode/src/joints/piston.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/piston.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -219,13 +219,13 @@ void -dxJointPiston::getInfo2 ( dxJoint::Info2 *info ) +dxJointPiston::getInfo2 ( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { const int s0 = 0; const int s1 = info->rowskip; const int s2 = 2 * s1, s3 = 3 * s1 /*, s4=4*s1*/; - const dReal k = info->fps * info->erp; + const dReal k = worldFPS * worldERP; // Pull out pos and R for both bodies. also get the `connection' @@ -406,7 +406,7 @@ int row = 4; if ( node[1].body ) { - row += limotP.addLimot ( this, info, 4, ax1, 0 ); + row += limotP.addLimot ( this, worldFPS, info, 4, ax1, 0 ); } else if (flags & dJOINT_REVERSE ) { @@ -414,12 +414,12 @@ rAx1[0] = -ax1[0]; rAx1[1] = -ax1[1]; rAx1[2] = -ax1[2]; - row += limotP.addLimot ( this, info, 4, rAx1, 0 ); + row += limotP.addLimot ( this, worldFPS, info, 4, rAx1, 0 ); } else - row += limotP.addLimot ( this, info, 4, ax1, 0 ); + row += limotP.addLimot ( this, worldFPS, info, 4, ax1, 0 ); - limotR.addLimot ( this, info, row, ax1, 1 ); + limotR.addLimot ( this, worldFPS, info, row, ax1, 1 ); } void dJointSetPistonAnchor ( dJointID j, dReal x, dReal y, dReal z ) Modified: trunk/ode/src/joints/piston.h =================================================================== --- trunk/ode/src/joints/piston.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/piston.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -94,7 +94,7 @@ dxJointPiston( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/plane2d.cpp =================================================================== --- trunk/ode/src/joints/plane2d.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/plane2d.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -93,12 +93,12 @@ void -dxJointPlane2D::getInfo2( dxJoint::Info2 *info ) +dxJointPlane2D::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { int r0 = 0; int r1 = info->rowskip; int r2 = 2 * r1; - dReal eps = info->fps * info->erp; + dReal eps = worldFPS * worldERP; /* v = v1, w = omega1 @@ -140,13 +140,13 @@ // if the slider is powered, or has joint limits, add in the extra row: if ( row_motor_x > 0 ) - motor_x.addLimot( this, info, row_motor_x, Midentity[0], 0 ); + motor_x.addLimot( this, worldFPS, info, row_motor_x, Midentity[0], 0 ); if ( row_motor_y > 0 ) - motor_y.addLimot( this, info, row_motor_y, Midentity[1], 0 ); + motor_y.addLimot( this, worldFPS, info, row_motor_y, Midentity[1], 0 ); if ( row_motor_angle > 0 ) - motor_angle.addLimot( this, info, row_motor_angle, Midentity[2], 1 ); + motor_angle.addLimot( this, worldFPS, info, row_motor_angle, Midentity[2], 1 ); } Modified: trunk/ode/src/joints/plane2d.h =================================================================== --- trunk/ode/src/joints/plane2d.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/plane2d.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -41,7 +41,7 @@ dxJointPlane2D( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; }; Modified: trunk/ode/src/joints/pr.cpp =================================================================== --- trunk/ode/src/joints/pr.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/pr.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -225,14 +225,14 @@ void -dxJointPR::getInfo2( dxJoint::Info2 *info ) +dxJointPR::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { int s = info->rowskip; int s2 = 2 * s; int s3 = 3 * s; //int s4= 4*s; - dReal k = info->fps * info->erp; + dReal k = worldFPS * worldERP; dVector3 q; // plane space of axP and after that axR @@ -430,7 +430,7 @@ int row = 4; if ( node[1].body || !(flags & dJOINT_REVERSE) ) { - row += limotP.addLimot ( this, info, 4, axP, 0 ); + row += limotP.addLimot ( this, worldFPS, info, 4, axP, 0 ); } else { @@ -438,10 +438,10 @@ rAxP[0] = -axP[0]; rAxP[1] = -axP[1]; rAxP[2] = -axP[2]; - row += limotP.addLimot ( this, info, 4, rAxP, 0 ); + row += limotP.addLimot ( this, worldFPS, info, 4, rAxP, 0 ); } - limotR.addLimot ( this, info, row, ax1, 1 ); + limotR.addLimot ( this, worldFPS, info, row, ax1, 1 ); } Modified: trunk/ode/src/joints/pr.h =================================================================== --- trunk/ode/src/joints/pr.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/pr.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -84,7 +84,7 @@ dxJointPR( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/pu.cpp =================================================================== --- trunk/ode/src/joints/pu.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/pu.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -261,13 +261,13 @@ void -dxJointPU::getInfo2( dxJoint::Info2 *info ) +dxJointPU::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { const int s0 = 0; const int s1 = info->rowskip; const int s2 = 2 * s1; - const dReal k = info->fps * info->erp; + const dReal k = worldFPS * worldERP; // pull out pos and R for both bodies. also get the `connection' // vector pos2-pos1. @@ -434,17 +434,17 @@ info->c[1] = k * dCalcVectorDot3( ax1, err ); info->c[2] = k * dCalcVectorDot3( q, err ); - int row = 3 + limot1.addLimot( this, info, 3, ax1, 1 ); - row += limot2.addLimot( this, info, row, ax2, 1 ); + int row = 3 + limot1.addLimot( this, worldFPS, info, 3, ax1, 1 ); + row += limot2.addLimot( this, worldFPS, info, row, ax2, 1 ); if ( node[1].body || !(flags & dJOINT_REVERSE) ) - limotP.addLimot( this, info, row, axP, 0 ); + limotP.addLimot( this, worldFPS, info, row, axP, 0 ); else { axP[0] = -axP[0]; axP[1] = -axP[1]; axP[2] = -axP[2]; - limotP.addLimot ( this, info, row, axP, 0 ); + limotP.addLimot ( this, worldFPS, info, row, axP, 0 ); } } Modified: trunk/ode/src/joints/pu.h =================================================================== --- trunk/ode/src/joints/pu.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/pu.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -72,7 +72,7 @@ dxJointPU( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/slider.cpp =================================================================== --- trunk/ode/src/joints/slider.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/slider.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -147,7 +147,7 @@ void -dxJointSlider::getInfo2 ( dxJoint::Info2 *info ) +dxJointSlider::getInfo2 ( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { int i, s = info->rowskip; int s3 = 3 * s, s4 = 4 * s; @@ -173,7 +173,7 @@ } // 3 rows to make body rotations equal - setFixedOrientation ( this, info, qrel, 0 ); + setFixedOrientation ( this, worldFPS, worldERP, info, qrel, 0 ); // remaining two rows. we want: vel2 = vel1 + w1 x c ... but this would // result in three equations, so we project along the planespace vectors @@ -203,7 +203,7 @@ // compute last two elements of right hand side. we want to align the offset // point (in body 2's frame) with the center of body 1. - dReal k = info->fps * info->erp; + dReal k = worldFPS * worldERP; if ( node[1].body ) { dVector3 ofs; // offset point in global coordinates @@ -224,7 +224,7 @@ } // if the slider is powered, or has joint limits, add in the extra row - limot.addLimot ( this, info, 5, ax1, 0 ); + limot.addLimot ( this, worldFPS, info, 5, ax1, 0 ); } Modified: trunk/ode/src/joints/slider.h =================================================================== --- trunk/ode/src/joints/slider.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/slider.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -40,7 +40,7 @@ dxJointSlider ( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1 ( Info1* info ); - virtual void getInfo2 ( Info2* info ); + virtual void getInfo2 ( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/joints/universal.cpp =================================================================== --- trunk/ode/src/joints/universal.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/universal.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -294,10 +294,10 @@ void -dxJointUniversal::getInfo2( dxJoint::Info2 *info ) +dxJointUniversal::getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr *info ) { // set the three ball-and-socket rows - setBall( this, info, anchor1, anchor2 ); + setBall( this, worldFPS, worldERP, info, anchor1, anchor2 ); // set the universal joint row. the angular velocity about an axis // perpendicular to both joint axes should be equal. thus the constraint @@ -352,13 +352,13 @@ // theta - Pi/2 ~= cos(theta), so // |angular_velocity| ~= (erp*fps) * (ax1 dot ax2) - info->c[3] = info->fps * info->erp * - k; + info->c[3] = worldFPS * worldERP * - k; // if the first angle is powered, or has joint limits, add in the stuff - int row = 4 + limot1.addLimot( this, info, 4, ax1, 1 ); + int row = 4 + limot1.addLimot( this, worldFPS, info, 4, ax1, 1 ); // if the second angle is powered, or has joint limits, add in more stuff - limot2.addLimot( this, info, row, ax2, 1 ); + limot2.addLimot( this, worldFPS, info, row, ax2, 1 ); } Modified: trunk/ode/src/joints/universal.h =================================================================== --- trunk/ode/src/joints/universal.h 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/joints/universal.h 2012-12-18 22:34:05 UTC (rev 1916) @@ -49,7 +49,7 @@ dxJointUniversal( dxWorld *w ); virtual void getSureMaxInfo( SureMaxInfo* info ); virtual void getInfo1( Info1* info ); - virtual void getInfo2( Info2* info ); + virtual void getInfo2( dReal worldFPS, dReal worldERP, const Info2Descr* info ); virtual dJointType type() const; virtual size_t size() const; Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/quickstep.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -933,10 +933,8 @@ // (lll) = linear jacobian data // (aaa) = angular jacobian data // - dxJoint::Info2 Jinfo; + dxJoint::Info2Descr Jinfo; Jinfo.rowskip = 12; - Jinfo.fps = stepsizeRecip; - Jinfo.erp = world->global_erp; dReal *Jcopyrow = Jcopy; unsigned ofsi = 0; @@ -955,7 +953,7 @@ Jinfo.findex = findex + ofsi; dxJoint *joint = jicurr->joint; - joint->getInfo2 (&Jinfo); + joint->getInfo2 (stepsizeRecip, world->global_erp, &Jinfo); const unsigned int infom = jicurr->info.m; Modified: trunk/ode/src/step.cpp =================================================================== --- trunk/ode/src/step.cpp 2012-12-16 09:55:39 UTC (rev 1915) +++ trunk/ode/src/step.cpp 2012-12-18 22:34:05 UTC (rev 1916) @@ -669,10 +669,8 @@ // (aaa) = angular jacobian data // - dxJoint::Info2 Jinfo; + dxJoint::Info2Descr Jinfo; Jinfo.rowskip = 8; - Jinfo.fps = stepsizeRecip; - Jinfo.erp = world->global_erp; unsigned ofsi = 0; const dJointWithInfo1 *jicurr = jointinfos; @@ -692,7 +690,7 @@ Jinfo.findex = findex + ofsi; dxJoint *joint = jicurr->joint; - joint->getInfo2 (&Jinfo); + joint->getInfo2 (stepsizeRecip, world->global_erp, &Jinfo); // adjust returned findex values for global index numbering int *findex_ofsi = findex + ofsi; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-16 09:55:45
|
Revision: 1915 http://opende.svn.sourceforge.net/opende/?rev=1915&view=rev Author: oleh_derevenko Date: 2012-12-16 09:55:39 +0000 (Sun, 16 Dec 2012) Log Message: ----------- Cosmetic: NDEBUG and dNODEBUG defined added to release configurations generated by Premake Modified Paths: -------------- trunk/build/premake4.lua Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-12-16 09:23:02 UTC (rev 1914) +++ trunk/build/premake4.lua 2012-12-16 09:55:39 UTC (rev 1915) @@ -214,6 +214,7 @@ flags { "Symbols" } configuration { "Release*" } + defines { "NDEBUG", "dNODEBUG" } flags { "OptimizeSpeed", "NoFramePointer" } configuration { "*Single*" } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-16 09:23:09
|
Revision: 1914 http://opende.svn.sourceforge.net/opende/?rev=1914&view=rev Author: oleh_derevenko Date: 2012-12-16 09:23:02 +0000 (Sun, 16 Dec 2012) Log Message: ----------- Cosmetic: _dSetZero and _dSetValue functions made inlined Modified Paths: -------------- trunk/include/ode/matrix.h trunk/ode/src/matrix.cpp Modified: trunk/include/ode/matrix.h =================================================================== --- trunk/include/ode/matrix.h 2012-12-16 08:51:59 UTC (rev 1913) +++ trunk/include/ode/matrix.h 2012-12-16 09:23:02 UTC (rev 1914) @@ -189,8 +189,26 @@ #if defined(__ODE__) -void _dSetZero (dReal *a, size_t n); -void _dSetValue (dReal *a, size_t n, dReal value); +ODE_PURE_INLINE +void _dSetZero (dReal *a, size_t n) +{ + dReal *acurr = a; + dReal *const aend = a + n; + while (acurr != aend) { + *(acurr++) = 0; + } +} + +ODE_PURE_INLINE +void _dSetValue (dReal *a, size_t n, dReal value) +{ + dReal *acurr = a; + dReal *const aend = a + n; + while (acurr != aend) { + *(acurr++) = value; + } +} + dReal _dDot (const dReal *a, const dReal *b, int n); void _dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); void _dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); Modified: trunk/ode/src/matrix.cpp =================================================================== --- trunk/ode/src/matrix.cpp 2012-12-16 08:51:59 UTC (rev 1913) +++ trunk/ode/src/matrix.cpp 2012-12-16 09:23:02 UTC (rev 1914) @@ -29,31 +29,6 @@ #define ALLOCA dALLOCA16 - -void _dSetZero (dReal *a, size_t n) -{ - dAASSERT (a && n >= 0); - dReal *acurr = a; - size_t ncurr = n; - while (ncurr > 0) { - *(acurr++) = 0; - --ncurr; - } -} - - -void _dSetValue (dReal *a, size_t n, dReal value) -{ - dAASSERT (a && n >= 0); - dReal *acurr = a; - size_t ncurr = n; - while (ncurr > 0) { - *(acurr++) = value; - --ncurr; - } -} - - void _dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p, int q, int r) { dAASSERT (A && B && C && p>0 && q>0 && r>0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-16 08:52:05
|
Revision: 1913 http://opende.svn.sourceforge.net/opende/?rev=1913&view=rev Author: oleh_derevenko Date: 2012-12-16 08:51:59 +0000 (Sun, 16 Dec 2012) Log Message: ----------- Cosmetic: A compile error fixed Modified Paths: -------------- trunk/ode/src/threadingutils.h Modified: trunk/ode/src/threadingutils.h =================================================================== --- trunk/ode/src/threadingutils.h 2012-12-13 22:56:22 UTC (rev 1912) +++ trunk/ode/src/threadingutils.h 2012-12-16 08:51:59 UTC (rev 1913) @@ -32,7 +32,7 @@ static inline bool ThrsafeCompareExchange(volatile atomicord32 *paoDestination, atomicord32 aoComparand, atomicord32 aoExchange) { - return AtomicCompareExchange(paoDestination, aoComparand, aoExchange) + return AtomicCompareExchange(paoDestination, aoComparand, aoExchange); } static inline This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-13 22:56:28
|
Revision: 1912 http://opende.svn.sourceforge.net/opende/?rev=1912&view=rev Author: oleh_derevenko Date: 2012-12-13 22:56:22 +0000 (Thu, 13 Dec 2012) Log Message: ----------- A file missing from previous commit added Added Paths: ----------- trunk/ode/src/threadingutils.h Added: trunk/ode/src/threadingutils.h =================================================================== --- trunk/ode/src/threadingutils.h (rev 0) +++ trunk/ode/src/threadingutils.h 2012-12-13 22:56:22 UTC (rev 1912) @@ -0,0 +1,125 @@ +/************************************************************************* + * * + * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * + * All rights reserved. Email: ru...@q1... Web: www.q12.org * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of EITHER: * + * (1) The GNU Lesser General Public License as published by the Free * + * Software Foundation; either version 2.1 of the License, or (at * + * your option) any later version. The text of the GNU Lesser * + * General Public License is included with this library in the * + * file LICENSE.TXT. * + * (2) The BSD-style license that is included with this library in * + * the file LICENSE-BSD.TXT. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * + * LICENSE.TXT and LICENSE-BSD.TXT for more details. * + * * + *************************************************************************/ + +#ifndef _ODE_THREADINGUTILS_H_ +#define _ODE_THREADINGUTILS_H_ + + +#include "odeou.h" + + +#if !dTHREADING_INTF_DISABLED + +static inline +bool ThrsafeCompareExchange(volatile atomicord32 *paoDestination, atomicord32 aoComparand, atomicord32 aoExchange) +{ + return AtomicCompareExchange(paoDestination, aoComparand, aoExchange) +} + +static inline +atomicord32 ThrsafeExchange(volatile atomicord32 *paoDestination, atomicord32 aoExchange) +{ + return AtomicExchange(paoDestination, aoExchange); +} + +static inline +bool ThrsafeCompareExchangePointer(volatile atomicptr *papDestination, atomicptr apComparand, atomicptr apExchange) +{ + return AtomicCompareExchangePointer(papDestination, apComparand, apExchange); +} + +static inline +atomicptr ThrsafeExchangePointer(volatile atomicptr *papDestination, atomicptr apExchange) +{ + return AtomicExchangePointer(papDestination, apExchange); +} + + +#else // #if dTHREADING_INTF_DISABLED + +static inline +bool ThrsafeCompareExchange(volatile atomicord32 *paoDestination, atomicord32 aoComparand, atomicord32 aoExchange) +{ + return (*paoDestination == aoComparand) ? ((*paoDestination = aoExchange), true) : false; +} + +static inline +atomicord32 ThrsafeExchange(volatile atomicord32 *paoDestination, atomicord32 aoExchange) +{ + atomicord32 aoDestinationValue = *paoDestination; + *paoDestination = aoExchange; + return aoDestinationValue; +} + +static inline +bool ThrsafeCompareExchangePointer(volatile atomicptr *papDestination, atomicptr apComparand, atomicptr apExchange) +{ + return (*papDestination == apComparand) ? ((*papDestination = apExchange), true) : false; +} + +static inline +atomicptr ThrsafeExchangePointer(volatile atomicptr *papDestination, atomicptr apExchange) +{ + atomicptr apDestinationValue = *papDestination; + *papDestination = apExchange; + return apDestinationValue; +} + + +#endif // #if dTHREADING_INTF_DISABLED + + +static inline +unsigned int ThrsafeIncrementIntUpToLimit(volatile unsigned int *storagePointer, unsigned int limitValue) +{ + unsigned int resultValue; + while (true) { + resultValue = *storagePointer; + if (resultValue == limitValue) { + break; + } + if (ThrsafeCompareExchange((volatile atomicord32 *)storagePointer, (atomicord32)resultValue, (atomicord32)(resultValue + 1))) { + break; + } + } + return resultValue; +} + +static inline +size_t ThrsafeIncrementSizeUpToLimit(volatile size_t *storagePointer, size_t limitValue) +{ + size_t resultValue; + while (true) { + resultValue = *storagePointer; + if (resultValue == limitValue) { + break; + } + if (ThrsafeCompareExchangePointer((volatile atomicptr *)storagePointer, (atomicptr)resultValue, (atomicptr)(resultValue + 1))) { + break; + } + } + return resultValue; +} + + + +#endif // _ODE_THREADINGUTILS_H_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-13 22:55:17
|
Revision: 1911 http://opende.svn.sourceforge.net/opende/?rev=1911&view=rev Author: oleh_derevenko Date: 2012-12-13 22:55:10 +0000 (Thu, 13 Dec 2012) Log Message: ----------- Fixed: Changes to prevent use of atomics in stepper functions with threading interface disabled even if OU usage is enabled for other purposes (for collisions). Modified Paths: -------------- trunk/ode/src/Makefile.am trunk/ode/src/odeou.h trunk/ode/src/quickstep.cpp trunk/ode/src/step.cpp trunk/ode/src/util.cpp Modified: trunk/ode/src/Makefile.am =================================================================== --- trunk/ode/src/Makefile.am 2012-12-01 21:56:10 UTC (rev 1910) +++ trunk/ode/src/Makefile.am 2012-12-13 22:55:10 UTC (rev 1911) @@ -69,7 +69,8 @@ threading_pool_posix.cpp \ threading_pool_win.cpp \ threading_base.cpp threading_base.h \ - util.cpp util.h + util.cpp util.h \ + threadingutils.h ################################### Modified: trunk/ode/src/odeou.h =================================================================== --- trunk/ode/src/odeou.h 2012-12-01 21:56:10 UTC (rev 1910) +++ trunk/ode/src/odeou.h 2012-12-13 22:55:10 UTC (rev 1911) @@ -92,70 +92,5 @@ #endif // dOU_ENABLED -#if !dATOMICS_ENABLED -static inline -bool AtomicCompareExchange(volatile atomicord32 *paoDestination, atomicord32 aoComparand, atomicord32 aoExchange) -{ - return (*paoDestination == aoComparand) ? ((*paoDestination = aoExchange), true) : false; -} - -static inline -atomicord32 AtomicExchange(volatile atomicord32 *paoDestination, atomicord32 aoExchange) -{ - atomicord32 aoDestinationValue = *paoDestination; - *paoDestination = aoExchange; - return aoDestinationValue; -} - -static inline -bool AtomicCompareExchangePointer(volatile atomicptr *papDestination, atomicptr apComparand, atomicptr apExchange) -{ - return (*papDestination == apComparand) ? ((*papDestination = apExchange), true) : false; -} - -static inline -atomicptr AtomicExchangePointer(volatile atomicptr *papDestination, atomicptr apExchange) -{ - atomicptr apDestinationValue = *papDestination; - *papDestination = apExchange; - return apDestinationValue; -} - -#endif // #if !dATOMICS_ENABLED - - -static inline -unsigned int AtomicIncrementIntUpToLimit(volatile unsigned int *storagePointer, unsigned int limitValue) -{ - unsigned int resultValue; - while (true) { - resultValue = *storagePointer; - if (resultValue == limitValue) { - break; - } - if (AtomicCompareExchange((volatile atomicord32 *)storagePointer, (atomicord32)resultValue, (atomicord32)(resultValue + 1))) { - break; - } - } - return resultValue; -} - -static inline -size_t AtomicIncrementSizeUpToLimit(volatile size_t *storagePointer, size_t limitValue) -{ - size_t resultValue; - while (true) { - resultValue = *storagePointer; - if (resultValue == limitValue) { - break; - } - if (AtomicCompareExchangePointer((volatile atomicptr *)storagePointer, (atomicptr)resultValue, (atomicptr)(resultValue + 1))) { - break; - } - } - return resultValue; -} - - #endif // _ODE_ODEOU_H_ Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2012-12-01 21:56:10 UTC (rev 1910) +++ trunk/ode/src/quickstep.cpp 2012-12-13 22:55:10 UTC (rev 1911) @@ -32,7 +32,7 @@ #include "joints/joint.h" #include "lcp.h" #include "util.h" -#include "odeou.h" +#include "threadingutils.h" #include <new> @@ -718,13 +718,13 @@ dxBody * const *body = callContext->m_stepperCallContext->m_islandBodiesStart; unsigned int nb = callContext->m_stepperCallContext->m_islandBodiesCount; - if (AtomicExchange(&callContext->m_tagsTaken, 1) == 0) + if (ThrsafeExchange(&callContext->m_tagsTaken, 1) == 0) { // number all bodies in the body list - set their tag values for (unsigned int i=0; i<nb; i++) body[i]->tag = i; } - if (AtomicExchange(&callContext->m_gravityTaken, 1) == 0) + if (ThrsafeExchange(&callContext->m_gravityTaken, 1) == 0) { dxWorld *world = callContext->m_stepperCallContext->m_world; @@ -766,7 +766,7 @@ // accumulator. I and invI are a vertical stack of 3x4 matrices, one per body. { dReal *invIrow = callContext->m_invI; - unsigned int bodyIndex = AtomicIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); + unsigned int bodyIndex = ThrsafeIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); for (unsigned int i = 0; i != nb; invIrow += 12, ++i) { if (i == bodyIndex) { @@ -787,7 +787,7 @@ dSubtractVectorCross3(b->tacc,b->avel,tmp); } - bodyIndex = AtomicIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); + bodyIndex = ThrsafeIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); } } } Modified: trunk/ode/src/step.cpp =================================================================== --- trunk/ode/src/step.cpp 2012-12-01 21:56:10 UTC (rev 1910) +++ trunk/ode/src/step.cpp 2012-12-13 22:55:10 UTC (rev 1911) @@ -31,7 +31,7 @@ #include "joints/joint.h" #include "lcp.h" #include "util.h" -#include "odeou.h" +#include "threadingutils.h" #include <new> @@ -317,13 +317,13 @@ dxBody * const *body = callContext->m_stepperCallContext->m_islandBodiesStart; unsigned int nb = callContext->m_stepperCallContext->m_islandBodiesCount; - if (AtomicExchange(&callContext->m_tagsTaken, 1) == 0) + if (ThrsafeExchange(&callContext->m_tagsTaken, 1) == 0) { // number all bodies in the body list - set their tag values for (unsigned int i=0; i<nb; i++) body[i]->tag = i; } - if (AtomicExchange(&callContext->m_gravityTaken, 1) == 0) + if (ThrsafeExchange(&callContext->m_gravityTaken, 1) == 0) { dxWorld *world = callContext->m_stepperCallContext->m_world; @@ -365,7 +365,7 @@ // accumulator. I and invI are a vertical stack of 3x4 matrices, one per body. { dReal *invIrow = callContext->m_invI; - unsigned int bodyIndex = AtomicIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); + unsigned int bodyIndex = ThrsafeIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); for (unsigned int i = 0; i != nb; invIrow += 12, ++i) { if (i == bodyIndex) { @@ -386,7 +386,7 @@ dSubtractVectorCross3(b->tacc,b->avel,tmp); } - bodyIndex = AtomicIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); + bodyIndex = ThrsafeIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); } } } Modified: trunk/ode/src/util.cpp =================================================================== --- trunk/ode/src/util.cpp 2012-12-01 21:56:10 UTC (rev 1910) +++ trunk/ode/src/util.cpp 2012-12-13 22:55:10 UTC (rev 1911) @@ -25,7 +25,7 @@ #include "objects.h" #include "joints/joint.h" #include "util.h" -#include "odeou.h" +#include "threadingutils.h" #include <new> @@ -304,12 +304,12 @@ bool dxWorldProcessContext::TryExtractingStepperArenasHead(dxWorldProcessMemArena *pmaHeadInstance) { dxWorldProcessMemArena *pmaNextInstance = pmaHeadInstance->GetNextMemArena(); - return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaHeadInstance, (atomicptr)pmaNextInstance); + return ThrsafeCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaHeadInstance, (atomicptr)pmaNextInstance); } bool dxWorldProcessContext::TryInsertingStepperArenasHead(dxWorldProcessMemArena *pmaArenaInstance, dxWorldProcessMemArena *pmaExistingHead) { - return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaExistingHead, (atomicptr)pmaArenaInstance); + return ThrsafeCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaExistingHead, (atomicptr)pmaArenaInstance); } @@ -1045,7 +1045,7 @@ size_t dxIslandsProcessingCallContext::ObtainNextIslandToBeProcessed(size_t islandsCount) { - return AtomicIncrementSizeUpToLimit(&m_islandToProcessStorage, islandsCount); + return ThrsafeIncrementSizeUpToLimit(&m_islandToProcessStorage, islandsCount); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-01 21:56:17
|
Revision: 1910 http://opende.svn.sourceforge.net/opende/?rev=1910&view=rev Author: oleh_derevenko Date: 2012-12-01 21:56:10 +0000 (Sat, 01 Dec 2012) Log Message: ----------- Fixed: Issues reported in patches #151 and #22 fixed (collisions with SAPSpace and QuadTreeSpace might not work because geometries list was misused in them) Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/collision_kernel.cpp trunk/ode/src/collision_kernel.h trunk/ode/src/collision_quadtreespace.cpp trunk/ode/src/collision_sapspace.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/CHANGELOG.txt 2012-12-01 21:56:10 UTC (rev 1910) @@ -9,8 +9,11 @@ ------------------------------------------------------------------------------ 12/01/12 Oleh_Derevenko - * Applied patch #160 "IsPointInPolygon in convex.cpp returns wrong - results" (by Janis Rucis) + * Fixed issues reported in patches #151 and #22 (collisions with + SAPSpace and QuadTreeSpace might not work because geometries list + was misused in them). + * Applied patch #160 "IsPointInPolygon in convex.cpp returns wrong + results" (by Janis Rucis) 11/25/12 Oleh Derevenko * Configuration option --disable-threading-intf added Modified: trunk/ode/src/collision_kernel.cpp =================================================================== --- trunk/ode/src/collision_kernel.cpp 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_kernel.cpp 2012-12-01 21:56:10 UTC (rev 1910) @@ -361,6 +361,8 @@ // setup space vars next = 0; tome = 0; + next_ex = 0; + tome_ex = 0; parent_space = 0; dSetZero (aabb,6); category_bits = ~0; Modified: trunk/ode/src/collision_kernel.h =================================================================== --- trunk/ode/src/collision_kernel.h 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_kernel.h 2012-12-01 21:56:10 UTC (rev 1910) @@ -105,6 +105,8 @@ // information used by spaces dxGeom *next; // next geom in linked list of geoms dxGeom **tome; // linked list backpointer + dxGeom *next_ex; // next geom in extra linked list of geoms (for higher level structures) + dxGeom **tome_ex; // extra linked list backpointer (for higher level structures) dxSpace *parent_space;// the space this geom is contained in, 0 if none dReal aabb[6]; // cached AABB for this space unsigned long category_bits,collide_bits; Modified: trunk/ode/src/collision_quadtreespace.cpp =================================================================== --- trunk/ode/src/collision_quadtreespace.cpp 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_quadtreespace.cpp 2012-12-01 21:56:10 UTC (rev 1910) @@ -182,9 +182,9 @@ dxGeom* g = mFirst; while (g){ if (GEOM_ENABLED(g)){ - Collide(g, g->next, UserData, Callback); + Collide(g, g->next_ex, UserData, Callback); } - g = g->next; + g = g->next_ex; } // Recurse for children @@ -209,7 +209,7 @@ if (GEOM_ENABLED(g2)){ collideAABBs (g1, g2, UserData, Callback); } - g2 = g2->next; + g2 = g2->next_ex; } // Collide against children @@ -244,15 +244,15 @@ if (GEOM_ENABLED(g1)){ collideAABBs (g1, g2, UserData, Callback); } - g1 = g1->next; + g1 = g1->next_ex; } } void Block::AddObject(dGeomID Object){ // Add the geom - Object->next = mFirst; + Object->next_ex = mFirst; mFirst = Object; - Object->tome = (dxGeom**)this; + Object->tome_ex = (dxGeom**)this; // Now traverse upwards to tell that we have a geom Block* Block = this; @@ -270,17 +270,17 @@ while (g){ if (g == Object){ if (Last){ - Last->next = g->next; + Last->next_ex = g->next_ex; } - else mFirst = g->next; + else mFirst = g->next_ex; break; } Last = g; - g = g->next; + g = g->next_ex; } - Object->tome = 0; + Object->tome_ex = 0; // Now traverse upwards to tell that we have lost a geom Block* Block = this; @@ -424,7 +424,7 @@ CHILDRECURSE: if (CurrentObject){ dGeomID g = CurrentObject; - CurrentObject = CurrentObject->next; + CurrentObject = CurrentObject->next_ex; CurrentIndex++; #ifdef DRAWBLOCKS @@ -471,7 +471,7 @@ if (current_geom && current_index == Index - 1){ - //current_geom = current_geom->next; // next + //current_geom = current_geom->next_ex; // next current_index = Index; return current_geom; } @@ -486,20 +486,12 @@ void dxQuadTreeSpace::add(dxGeom* g){ CHECK_NOT_LOCKED (this); dAASSERT(g); - dUASSERT(g->parent_space == 0 && g->next == 0, "geom is already in a space"); + dUASSERT(g->tome_ex == 0 && g->next_ex == 0, "geom is already in a space"); - g->gflags |= GEOM_DIRTY | GEOM_AABB_BAD; DirtyList.push(g); - - // add - g->parent_space = this; Blocks[0].GetBlock(g->aabb)->AddObject(g); // Add to best block - count++; - // enumerator has been invalidated - current_geom = 0; - - dGeomMoved(this); + dxSpace::add(g); } void dxQuadTreeSpace::remove(dxGeom* g){ @@ -508,8 +500,7 @@ dUASSERT(g->parent_space == this,"object is not in this space"); // remove - ((Block*)g->tome)->DelObject(g); - count--; + ((Block*)g->tome_ex)->DelObject(g); for (int i = 0; i < DirtyList.size(); i++){ if (DirtyList[i] == g){ @@ -519,17 +510,7 @@ } } - // safeguard - g->next = 0; - g->tome = 0; - g->parent_space = 0; - - // enumerator has been invalidated - current_geom = 0; - - // the bounding box of this space (and that of all the parents) may have - // changed as a consequence of the removal. - dGeomMoved(this); + dxSpace::remove(g); } void dxQuadTreeSpace::dirty(dxGeom* g){ @@ -552,7 +533,7 @@ g->recomputeAABB(); g->gflags &= (~(GEOM_DIRTY|GEOM_AABB_BAD)); - ((Block*)g->tome)->Traverse(g); + ((Block*)g->tome_ex)->Traverse(g); } DirtyList.setSize(0); @@ -592,7 +573,7 @@ if (g2->parent_space == this){ // The block the geom is in - Block* CurrentBlock = (Block*)g2->tome; + Block* CurrentBlock = (Block*)g2->tome_ex; // Collide against block and its children DataCallback dc = {UserData, Callback}; Modified: trunk/ode/src/collision_sapspace.cpp =================================================================== --- trunk/ode/src/collision_sapspace.cpp 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_sapspace.cpp 2012-12-01 21:56:10 UTC (rev 1910) @@ -219,11 +219,11 @@ #define GEOM_ENABLED(g) (((g)->gflags & GEOM_ENABLE_TEST_MASK) == GEOM_ENABLE_TEST_VALUE) -// HACK: We abuse 'next' and 'tome' members of dxGeom to store indice into dirty/geom lists. -#define GEOM_SET_DIRTY_IDX(g,idx) { (g)->next = (dxGeom*)(size_t)(idx); } -#define GEOM_SET_GEOM_IDX(g,idx) { (g)->tome = (dxGeom**)(size_t)(idx); } -#define GEOM_GET_DIRTY_IDX(g) ((int)(size_t)(g)->next) -#define GEOM_GET_GEOM_IDX(g) ((int)(size_t)(g)->tome) +// HACK: We abuse 'next' and 'tome' members of dxGeom to store indices into dirty/geom lists. +#define GEOM_SET_DIRTY_IDX(g,idx) { (g)->next_ex = (dxGeom*)(size_t)(idx); } +#define GEOM_SET_GEOM_IDX(g,idx) { (g)->tome_ex = (dxGeom**)(size_t)(idx); } +#define GEOM_GET_DIRTY_IDX(g) ((int)(size_t)(g)->next_ex) +#define GEOM_GET_GEOM_IDX(g) ((int)(size_t)(g)->tome_ex) #define GEOM_INVALID_IDX (-1) @@ -304,19 +304,15 @@ { CHECK_NOT_LOCKED (this); dAASSERT(g); - dUASSERT(g->parent_space == 0 && g->next == 0, "geom is already in a space"); + dUASSERT(g->tome_ex == 0 && g->next_ex == 0, "geom is already in a space"); - g->gflags |= GEOM_DIRTY | GEOM_AABB_BAD; // add to dirty list GEOM_SET_DIRTY_IDX( g, DirtyList.size() ); GEOM_SET_GEOM_IDX( g, GEOM_INVALID_IDX ); DirtyList.push( g ); - g->parent_space = this; - this->count++; - - dGeomMoved(this); + dxSpace::add(g); } void dxSAPSpace::remove( dxGeom* g ) @@ -350,14 +346,8 @@ GEOM_SET_GEOM_IDX(g,GEOM_INVALID_IDX); GeomList.setSize( geomSize-1 ); } - count--; - // safeguard - g->parent_space = 0; - - // the bounding box of this space (and that of all the parents) may have - // changed as a consequence of the removal. - dGeomMoved(this); + dxSpace::remove(g); } void dxSAPSpace::dirty( dxGeom* g ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-01 21:49:14
|
Revision: 1909 http://opende.svn.sourceforge.net/opende/?rev=1909&view=rev Author: oleh_derevenko Date: 2012-12-01 21:49:07 +0000 (Sat, 01 Dec 2012) Log Message: ----------- Fixed: ODE data initialization for rendering thread added Modified Paths: -------------- trunk/ode/demo/demo_tracks.cpp Modified: trunk/ode/demo/demo_tracks.cpp =================================================================== --- trunk/ode/demo/demo_tracks.cpp 2012-12-01 16:29:49 UTC (rev 1908) +++ trunk/ode/demo/demo_tracks.cpp 2012-12-01 21:49:07 UTC (rev 1909) @@ -155,6 +155,8 @@ void start() { + dAllocateODEDataForThread(dAllocateMaskAll); + world = dWorldCreate(); dWorldSetGravity (world,0,0,-9.8); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-12-01 16:29:56
|
Revision: 1908 http://opende.svn.sourceforge.net/opende/?rev=1908&view=rev Author: oleh_derevenko Date: 2012-12-01 16:29:49 +0000 (Sat, 01 Dec 2012) Log Message: ----------- Changed: Applied patch #160 "IsPointInPolygon in convex.cpp returns wrong results" (by Janis Rucis) Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/convex.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-11-25 22:17:19 UTC (rev 1907) +++ trunk/CHANGELOG.txt 2012-12-01 16:29:49 UTC (rev 1908) @@ -8,6 +8,10 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +12/01/12 Oleh_Derevenko + * Applied patch #160 "IsPointInPolygon in convex.cpp returns wrong + results" (by Janis Rucis) + 11/25/12 Oleh Derevenko * Configuration option --disable-threading-intf added (--no-threading-intf for Windows/Premake). This allows disabling Modified: trunk/ode/src/convex.cpp =================================================================== --- trunk/ode/src/convex.cpp 2012-11-25 22:17:19 UTC (rev 1907) +++ trunk/ode/src/convex.cpp 2012-12-01 16:29:49 UTC (rev 1908) @@ -509,6 +509,7 @@ */ inline bool IsPointInPolygon(dVector3 p, unsigned int *polygon, + dReal *plane, dxConvex *convex, dVector3 out) { @@ -518,79 +519,70 @@ // number of vertices then that many indexes // out returns the closest point on the border of the // polygon if the point is not inside it. - size_t pointcount=polygon[0]; dVector3 a; dVector3 b; - dVector3 c; dVector3 ab; - dVector3 ac; dVector3 ap; - dVector3 bp; - dReal d1; - dReal d2; - dReal d3; - dReal d4; - dReal vc; + dVector3 v; + + unsigned pointcount=polygon[0]; + dIASSERT(pointcount != 0); polygon++; // skip past pointcount - for(size_t i=0;i<pointcount;++i) + + dMultiply0_331 (b,convex->final_posr->R, + &convex->points[(polygon[pointcount-1]*3)]); + b[0]=convex->final_posr->pos[0]+b[0]; + b[1]=convex->final_posr->pos[1]+b[1]; + b[2]=convex->final_posr->pos[2]+b[2]; + + for(unsigned i=0; i != pointcount; ++i) { - dMultiply0_331 (a,convex->final_posr->R,&convex->points[(polygon[i]*3)]); - a[0]=convex->final_posr->pos[0]+a[0]; - a[1]=convex->final_posr->pos[1]+a[1]; - a[2]=convex->final_posr->pos[2]+a[2]; + a[0] = b[0]; + a[1] = b[1]; + a[2] = b[2]; - dMultiply0_331 (b,convex->final_posr->R, - &convex->points[(polygon[(i+1)%pointcount]*3)]); + dMultiply0_331 (b,convex->final_posr->R,&convex->points[(polygon[i]*3)]); b[0]=convex->final_posr->pos[0]+b[0]; b[1]=convex->final_posr->pos[1]+b[1]; b[2]=convex->final_posr->pos[2]+b[2]; - dMultiply0_331 (c,convex->final_posr->R, - &convex->points[(polygon[(i+2)%pointcount]*3)]); - c[0]=convex->final_posr->pos[0]+c[0]; - c[1]=convex->final_posr->pos[1]+c[1]; - c[2]=convex->final_posr->pos[2]+c[2]; - ab[0] = b[0] - a[0]; ab[1] = b[1] - a[1]; ab[2] = b[2] - a[2]; - ac[0] = c[0] - a[0]; - ac[1] = c[1] - a[1]; - ac[2] = c[2] - a[2]; ap[0] = p[0] - a[0]; ap[1] = p[1] - a[1]; ap[2] = p[2] - a[2]; - d1 = dCalcVectorDot3(ab,ap); - d2 = dCalcVectorDot3(ac,ap); - if (d1 <= 0.0 && d2 <= 0.0) + + dCalcVectorCross3(v, ab, plane); + + if (dCalcVectorDot3(ap, v) > REAL(0.0)) { - out[0]=a[0]; - out[1]=a[1]; - out[2]=a[2]; + dReal ab_m2 = dCalcVectorDot3(ab, ab); + dReal s = ab_m2 != REAL(0.0) ? dCalcVectorDot3(ab, ap) / ab_m2 : REAL(0.0); + + if (s <= REAL(0.0)) + { + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + } + else if (s >= REAL(1.0)) + { + out[0] = b[0]; + out[1] = b[1]; + out[2] = b[2]; + } + else + { + out[0] = a[0] + ab[0] * s; + out[1] = a[1] + ab[1] * s; + out[2] = a[2] + ab[2] * s; + } + return false; } - bp[0] = p[0] - b[0]; - bp[1] = p[1] - b[1]; - bp[2] = p[2] - b[2]; - d3 = dCalcVectorDot3(ab,bp); - d4 = dCalcVectorDot3(ac,bp); - if (d3 >= 0.0f && d4 <= d3) - { - out[0]=b[0]; - out[1]=b[1]; - out[2]=b[2]; - return false; - } - vc = d1*d4 - d3*d2; - if (vc < 0.0 && d1 > 0.0 && d3 < 0.0) - { - dReal v = d1 / (d1 - d3); - out[0] = a[0] + (ab[0]*v); - out[1] = a[1] + (ab[1]*v); - out[2] = a[2] + (ab[2]*v); - return false; - } } + return true; } @@ -695,7 +687,7 @@ { // if we get here we know the sphere surface penetrates // the plane - if(IsPointInPolygon(Sphere->final_posr->pos,pPoly,Convex,out)) + if(IsPointInPolygon(Sphere->final_posr->pos,pPoly,plane,Convex,out)) { // finally if we get here we know that the // sphere is directly touching the inside of the polyhedron @@ -882,7 +874,7 @@ target->g2=&cvx2; if(IntersectSegmentPlane(e1,e2,plane,t,target->pos)) { - if(IsPointInPolygon(target->pos,pPoly,&cvx2,q)) + if(IsPointInPolygon(target->pos,pPoly,plane,&cvx2,q)) { target->depth = dInfinity; for(size_t k=0;k<cvx2.planecount;++k) @@ -1443,7 +1435,7 @@ depth, contactpoint)) { - if(IsPointInPolygon(contactpoint,pPoly,convex,out)) + if(IsPointInPolygon(contactpoint,pPoly,plane,convex,out)) { contact->pos[0]=contactpoint[0]; contact->pos[1]=contactpoint[1]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-11-25 22:17:26
|
Revision: 1907 http://opende.svn.sourceforge.net/opende/?rev=1907&view=rev Author: oleh_derevenko Date: 2012-11-25 22:17:19 +0000 (Sun, 25 Nov 2012) Log Message: ----------- Added: Configuration option --disable-threading-intf added (--no-threading-intf for Windows/Premake) to allow eliminating use of atomics in steppers at a cost of disabling threading interface. Modified Paths: -------------- trunk/CHANGELOG.txt trunk/build/config-default.h trunk/build/premake4.lua trunk/configure.ac trunk/ode/src/ode.cpp trunk/ode/src/odeou.cpp trunk/ode/src/odeou.h trunk/ode/src/odetls.cpp trunk/ode/src/odetls.h trunk/ode/src/util.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/CHANGELOG.txt 2012-11-25 22:17:19 UTC (rev 1907) @@ -8,6 +8,13 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +11/25/12 Oleh Derevenko + * Configuration option --disable-threading-intf added + (--no-threading-intf for Windows/Premake). This allows disabling + threading interface support (external implementations may not be + assigned) but eliminates dependency on OU and use of atomics in + steppers. + 11/05/12 Oleh Derevenko * Fixed zero comparisons in OPCODE to use relative error instead of absolute epsilon value (found by Bill Sellers) Modified: trunk/build/config-default.h =================================================================== --- trunk/build/config-default.h 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/build/config-default.h 2012-11-25 22:17:19 UTC (rev 1907) @@ -22,13 +22,15 @@ * Use old implementation of trimesh-trimesh collider * (for backward compatibility only) * - * dOU_ENABLED - always enabled - * dATOMICS_ENABLED - always enabled + * dOU_ENABLED + * dATOMICS_ENABLED * dTLS_ENABLED - * Use generic features of OU library, atomic - * API and TLS API respectively. Using TLS for - * global variables allows calling ODE from - * multiple threads. + * Use generic features of OU library, atomic API + * and TLS API respectively. + * Generic features and atomic API are always enabled, + * unless threading interface support is disabled. + * Using TLS for global variables allows calling ODE + * collision detection functions from multiple threads. * * dBUILTIN_THREADING_IMPL_ENABLED * Include built-in multithreaded threading @@ -43,10 +45,11 @@ #define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 0 -#define dOU_ENABLED 1 -#define dATOMICS_ENABLED 1 +/* #define dOU_ENABLED 1 */ +/* #define dATOMICS_ENABLED 1 */ /* #define dTLS_ENABLED 1 */ +/* #define dTHREADING_INTF_DISABLED 1 */ /* #define dBUILTIN_THREADING_IMPL_ENABLED 1 */ Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/build/premake4.lua 2012-11-25 22:17:19 UTC (rev 1907) @@ -102,10 +102,15 @@ newoption { trigger = "with-builtin-threading-impl", - description = "Include built-in multithreaded threading implementation (still must be created and assigned to be used)." + description = "Include built-in multithreaded threading implementation (still must be created and assigned to be used)" } newoption { + trigger = "no-threading-intf", + description = "Disable threading interface support (external implementations may not be assigned; overrides with-builtin-threading-impl)" + } + + newoption { trigger = "16bit-indices", description = "Use 16-bit indices for trimeshes (default is 32-bit)" } @@ -282,7 +287,6 @@ "../ode/src/joints", "../OPCODE", "../GIMPACT/include", - "../ou/include", "../libccd/src" } @@ -299,10 +303,12 @@ "../ode/src/collision_std.cpp", } --- Include OU files by default to enable atomics --- configuration { "with-ou" } + if _OPTIONS["with-ou"] or not _OPTIONS["no-threading-intf"] then + includedirs { "../ou/include" } files { "../ou/**.h", "../ou/**.cpp" } defines { "_OU_NAMESPACE=odeou" } + end + configuration { "no-dif" } excludes { "../ode/src/export-dif.cpp" } @@ -384,11 +390,18 @@ text = string.gsub(text, "#define dTRIMESH_OPCODE 1", "#define dTRIMESH_GIMPACT 1") end + if _OPTIONS["with-ou"] or not _OPTIONS["no-threading-intf"] then + text = string.gsub(text, "/%* #define dOU_ENABLED 1 %*/", "#define dOU_ENABLED 1") + text = string.gsub(text, "/%* #define dATOMICS_ENABLED 1 %*/", "#define dATOMICS_ENABLED 1") + end + if _OPTIONS["with-ou"] then text = string.gsub(text, "/%* #define dTLS_ENABLED 1 %*/", "#define dTLS_ENABLED 1") end - if _OPTIONS["with-builtin-threading-impl"] then + if _OPTIONS["no-threading-intf"] then + text = string.gsub(text, "/%* #define dTHREADING_INTF_DISABLED 1 %*/", "#define dTHREADING_INTF_DISABLED 1") + elseif _OPTIONS["with-builtin-threading-impl"] then text = string.gsub(text, "/%* #define dBUILTIN_THREADING_IMPL_ENABLED 1 %*/", "#define dBUILTIN_THREADING_IMPL_ENABLED 1") end Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/configure.ac 2012-11-25 22:17:19 UTC (rev 1907) @@ -284,12 +284,21 @@ AC_CHECK_FUNCS([floor memmove memset sqrt sqrtf sinf cosf fabsf atan2f fmodf copysignf copysign snprintf vsnprintf gettimeofday isnan isnanf _isnan _isnanf __isnan __isnanf strchr strstr pthread_attr_setstacklazy]) AC_FUNC_ALLOCA -use_ou="yes" +AC_ARG_ENABLE([threading-intf], + AS_HELP_STRING([--disable-threading-intf], + [disable threading interface support (external implementations may not be assigned; overrides --enable-builtin-threading-impl)] + ), + threading_intf=$enableval,threading_intf=yes) AC_ARG_ENABLE([ou], AS_HELP_STRING([--enable-ou], - [use TLS for global caches (allows threaded collision checks for separated spaces)] + [use TLS for global caches (allows threaded collision checks for isolated spaces)] ), use_ou_tls=$enableval,use_ou_tls=no) +use_ou="no" +if test x$use_ou_tls = xyes -o x$threading_intf = xyes +then + use_ou="yes" +fi if test x$use_ou = xyes then OU_NAMESPACE=odeou @@ -342,14 +351,20 @@ AC_CONFIG_SUBDIRS([ou]) AM_CONDITIONAL(ENABLE_OU, test x$use_ou = xyes) -AC_ARG_ENABLE([builtin-threading-impl], +if test x$threading_intf = xyes +then + AC_ARG_ENABLE([builtin-threading-impl], AS_HELP_STRING([--enable-builtin-threading-impl], [include built-in multithreaded threading implementation (still must be created and assigned to be used)] ), use_builtin_threading_impl=$enableval,use_builtin_threading_impl=no) -if test x$use_builtin_threading_impl = xyes -then - AC_DEFINE([dBUILTIN_THREADING_IMPL_ENABLED],[1],[Built-in multithreaded threading implementation included]) + if test x$use_builtin_threading_impl = xyes + then + AC_DEFINE([dBUILTIN_THREADING_IMPL_ENABLED],[1],[Built-in multithreaded threading implementation included]) + fi +else + AC_DEFINE([dTHREADING_INTF_DISABLED],[1],[Threading interface is disabled]) + use_builtin_threading_impl=no fi col_cylinder_cylinder=none @@ -537,6 +552,7 @@ echo " Is target x86-64: $cpu64" echo " Use old opcode trimesh collider: $old_trimesh" echo " TLS for global caches: $use_ou_tls" +echo " Threading intf enabled: $threading_intf" echo " Built-in threading included: $use_builtin_threading_impl" echo " Enable debug error check: $asserts" echo " Headers will be installed in $includedir/ode" Modified: trunk/ode/src/ode.cpp =================================================================== --- trunk/ode/src/ode.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/ode.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -1781,12 +1781,16 @@ } void dWorldSetStepThreadingImplementation(dWorldID w, - const dxThreadingFunctionsInfo *functions_info, dThreadingImplementationID threading_impl) + const dxThreadingFunctionsInfo *functions_info, dThreadingImplementationID threading_impl) { dUASSERT (w,"bad world argument"); dUASSERT (!functions_info || functions_info->struct_size >= sizeof(*functions_info), "Bad threading functions info"); +#if dTHREADING_INTF_DISABLED + dUASSERT(functions_info == NULL && threading_impl == NULL, "Threading interface is not available"); +#else w->AssignThreadingImpl(functions_info, threading_impl); +#endif } @@ -2223,11 +2227,13 @@ REGISTER_EXTENSION( ODE_EXT_mt_collisions ) #endif // dTLS_ENABLED +#if !dTHREADING_INTF_DISABLED REGISTER_EXTENSION( ODE_EXT_threading ) #if dBUILTIN_THREADING_IMPL_ENABLED REGISTER_EXTENSION( ODE_THR_builtin_impl ) #endif // #if dBUILTIN_THREADING_IMPL_ENABLED +#endif // #if !dTHREADING_INTF_DISABLED //********************************** // EXTENSION LIST END Modified: trunk/ode/src/odeou.cpp =================================================================== --- trunk/ode/src/odeou.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odeou.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -41,6 +41,13 @@ #if dOU_ENABLED + +using _OU_NAMESPACE::EASSERTIONFAILURESEVERITY; +using _OU_NAMESPACE::AFS__MAX; +using _OU_NAMESPACE::CMemoryManagerCustomization; +using _OU_NAMESPACE::CAssertionCheckCustomization; + + BEGIN_NAMESPACE_OU(); template<> const char *const CEnumUnsortedElementArray<EASSERTIONFAILURESEVERITY, AFS__MAX, const char *>::m_aetElementArray[] = Modified: trunk/ode/src/odeou.h =================================================================== --- trunk/ode/src/odeou.h 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odeou.h 2012-11-25 22:17:19 UTC (rev 1907) @@ -1,29 +1,29 @@ /************************************************************************* - * * - * OU library interface file for Open Dynamics Engine, * - * Copyright (C) 2008 Oleh Derevenko. All rights reserved. * - * Email: od...@el... (change all "a" to "e") * - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: ru...@q1... Web: www.q12.org * - * * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ +* * +* OU library interface file for Open Dynamics Engine, * +* Copyright (C) 2008 Oleh Derevenko. All rights reserved. * +* Email: od...@el... (change all "a" to "e") * +* * +* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * +* All rights reserved. Email: ru...@q1... Web: www.q12.org * +* * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of EITHER: * +* (1) The GNU Lesser General Public License as published by the Free * +* Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. The text of the GNU Lesser * +* General Public License is included with this library in the * +* file LICENSE.TXT. * +* (2) The BSD-style license that is included with this library in * +* the file LICENSE-BSD.TXT. * +* * +* This library is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * +* LICENSE.TXT and LICENSE-BSD.TXT for more details. * +* * +*************************************************************************/ /* @@ -56,9 +56,20 @@ #endif -using namespace _OU_NAMESPACE; +using _OU_NAMESPACE::CEnumUnsortedElementArray; +#if dATOMICS_ENABLED +using _OU_NAMESPACE::atomicord32; +using _OU_NAMESPACE::atomicptr; +using _OU_NAMESPACE::InitializeAtomicAPI; +using _OU_NAMESPACE::FinalizeAtomicAPI; +using _OU_NAMESPACE::AtomicCompareExchange; +using _OU_NAMESPACE::AtomicExchange; +using _OU_NAMESPACE::AtomicCompareExchangePointer; +using _OU_NAMESPACE::AtomicExchangePointer; +#endif + class COdeOu { public: @@ -72,9 +83,49 @@ }; -#if dATOMICS_ENABLED +#else // !dOU_ENABLED +typedef unsigned int atomicord32; +typedef size_t atomicptr; + + +#endif // dOU_ENABLED + + +#if !dATOMICS_ENABLED + static inline +bool AtomicCompareExchange(volatile atomicord32 *paoDestination, atomicord32 aoComparand, atomicord32 aoExchange) +{ + return (*paoDestination == aoComparand) ? ((*paoDestination = aoExchange), true) : false; +} + +static inline +atomicord32 AtomicExchange(volatile atomicord32 *paoDestination, atomicord32 aoExchange) +{ + atomicord32 aoDestinationValue = *paoDestination; + *paoDestination = aoExchange; + return aoDestinationValue; +} + +static inline +bool AtomicCompareExchangePointer(volatile atomicptr *papDestination, atomicptr apComparand, atomicptr apExchange) +{ + return (*papDestination == apComparand) ? ((*papDestination = apExchange), true) : false; +} + +static inline +atomicptr AtomicExchangePointer(volatile atomicptr *papDestination, atomicptr apExchange) +{ + atomicptr apDestinationValue = *papDestination; + *papDestination = apExchange; + return apDestinationValue; +} + +#endif // #if !dATOMICS_ENABLED + + +static inline unsigned int AtomicIncrementIntUpToLimit(volatile unsigned int *storagePointer, unsigned int limitValue) { unsigned int resultValue; @@ -107,10 +158,4 @@ } -#endif // #if dATOMICS_ENABLED - - -#endif // dOU_ENABLED - - #endif // _ODE_ODEOU_H_ Modified: trunk/ode/src/odetls.cpp =================================================================== --- trunk/ode/src/odetls.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odetls.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -41,6 +41,10 @@ #if dTLS_ENABLED + +using _OU_NAMESPACE::CTLSInitialization; + + ////////////////////////////////////////////////////////////////////////// // Class static fields Modified: trunk/ode/src/odetls.h =================================================================== --- trunk/ode/src/odetls.h 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/odetls.h 2012-11-25 22:17:19 UTC (rev 1907) @@ -42,6 +42,11 @@ #if dTLS_ENABLED +using _OU_NAMESPACE::tlsvaluetype; +using _OU_NAMESPACE::HTLSKEY; +using _OU_NAMESPACE::CThreadLocalStorage; + + struct TrimeshCollidersCache; Modified: trunk/ode/src/util.cpp =================================================================== --- trunk/ode/src/util.cpp 2012-11-04 23:08:30 UTC (rev 1906) +++ trunk/ode/src/util.cpp 2012-11-25 22:17:19 UTC (rev 1907) @@ -304,12 +304,12 @@ bool dxWorldProcessContext::TryExtractingStepperArenasHead(dxWorldProcessMemArena *pmaHeadInstance) { dxWorldProcessMemArena *pmaNextInstance = pmaHeadInstance->GetNextMemArena(); - return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, pmaHeadInstance, pmaNextInstance); + return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaHeadInstance, (atomicptr)pmaNextInstance); } bool dxWorldProcessContext::TryInsertingStepperArenasHead(dxWorldProcessMemArena *pmaArenaInstance, dxWorldProcessMemArena *pmaExistingHead) { - return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, pmaExistingHead, pmaArenaInstance); + return AtomicCompareExchangePointer((volatile atomicptr *)&m_pmaStepperArenas, (atomicptr)pmaExistingHead, (atomicptr)pmaArenaInstance); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-11-04 23:08:38
|
Revision: 1906 http://opende.svn.sourceforge.net/opende/?rev=1906&view=rev Author: oleh_derevenko Date: 2012-11-04 23:08:30 +0000 (Sun, 04 Nov 2012) Log Message: ----------- Modified Paths: -------------- trunk/CHANGELOG.txt trunk/OPCODE/OPC_RayTriOverlap.h trunk/OPCODE/OPC_TriTriOverlap.h Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-11-04 20:24:26 UTC (rev 1905) +++ trunk/CHANGELOG.txt 2012-11-04 23:08:30 UTC (rev 1906) @@ -8,6 +8,10 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +11/05/12 Oleh Derevenko + * Fixed zero comparisons in OPCODE to use relative error instead of + absolute epsilon value (found by Bill Sellers) + 06/08/12 Daniel K. O. * Removed the need for defining dSINGLE/dDOUBLE; this is stored now in the generated ode/precision.h header. Modified: trunk/OPCODE/OPC_RayTriOverlap.h =================================================================== --- trunk/OPCODE/OPC_RayTriOverlap.h 2012-11-04 20:24:26 UTC (rev 1905) +++ trunk/OPCODE/OPC_RayTriOverlap.h 2012-11-04 23:08:30 UTC (rev 1906) @@ -30,7 +30,7 @@ if(mCulling) { - if(det<LOCAL_EPSILON) return FALSE; + if(det <= LOCAL_EPSILON * FCMin2(edge1.SquareMagnitude(), edge2.SquareMagnitude())) return FALSE; // From here, det is > 0. So we can use integer cmp. // Calculate distance from vert0 to ray origin @@ -62,7 +62,7 @@ else { // the non-culling branch - if(det>-LOCAL_EPSILON && det<LOCAL_EPSILON) return FALSE; + if(FastFabs(det) <= LOCAL_EPSILON * FCMin2(edge1.SquareMagnitude(), edge2.SquareMagnitude())) return FALSE; float OneOverDet = 1.0f / det; // Calculate distance from vert0 to ray origin Modified: trunk/OPCODE/OPC_TriTriOverlap.h =================================================================== --- trunk/OPCODE/OPC_TriTriOverlap.h 2012-11-04 20:24:26 UTC (rev 1905) +++ trunk/OPCODE/OPC_TriTriOverlap.h 2012-11-04 23:08:30 UTC (rev 1906) @@ -195,9 +195,19 @@ // Coplanarity robustness check #ifdef OPC_TRITRI_EPSILON_TEST - if(fabsf(du0)<LOCAL_EPSILON) du0 = 0.0f; - if(fabsf(du1)<LOCAL_EPSILON) du1 = 0.0f; - if(fabsf(du2)<LOCAL_EPSILON) du2 = 0.0f; + float absd1 = FastFabs(d1), sqmagN1 = N1.SquareMagnitude(); + if (absd1>=sqmagN1) + { + if(FastFabs(du0)<=LOCAL_EPSILON*absd1) du0 = 0.0f; + if(FastFabs(du1)<=LOCAL_EPSILON*absd1) du1 = 0.0f; + if(FastFabs(du2)<=LOCAL_EPSILON*absd1) du2 = 0.0f; + } + else + { + if(FastFabs(du0)<=LOCAL_EPSILON*FCMax2(absd1, FCMin2(sqmagN1, U0.SquareMagnitude()))) du0 = 0.0f; + if(FastFabs(du1)<=LOCAL_EPSILON*FCMax2(absd1, FCMin2(sqmagN1, U1.SquareMagnitude()))) du1 = 0.0f; + if(FastFabs(du2)<=LOCAL_EPSILON*FCMax2(absd1, FCMin2(sqmagN1, U2.SquareMagnitude()))) du2 = 0.0f; + } #endif const float du0du1 = du0 * du1; const float du0du2 = du0 * du2; @@ -218,9 +228,19 @@ float dv2 = (N2|V2) + d2; #ifdef OPC_TRITRI_EPSILON_TEST - if(fabsf(dv0)<LOCAL_EPSILON) dv0 = 0.0f; - if(fabsf(dv1)<LOCAL_EPSILON) dv1 = 0.0f; - if(fabsf(dv2)<LOCAL_EPSILON) dv2 = 0.0f; + float absd2 = FastFabs(d2), sqmagN2 = N2.SquareMagnitude(); + if (absd2>=sqmagN2) + { + if(FastFabs(dv0)<=LOCAL_EPSILON*absd2) dv0 = 0.0f; + if(FastFabs(dv1)<=LOCAL_EPSILON*absd2) dv1 = 0.0f; + if(FastFabs(dv2)<=LOCAL_EPSILON*absd2) dv2 = 0.0f; + } + else + { + if(FastFabs(dv0)<=LOCAL_EPSILON*FCMax2(absd2, FCMin2(sqmagN2, V0.SquareMagnitude()))) dv0 = 0.0f; + if(FastFabs(dv1)<=LOCAL_EPSILON*FCMax2(absd2, FCMin2(sqmagN2, V1.SquareMagnitude()))) dv1 = 0.0f; + if(FastFabs(dv2)<=LOCAL_EPSILON*FCMax2(absd2, FCMin2(sqmagN2, V2.SquareMagnitude()))) dv2 = 0.0f; + } #endif const float dv0dv1 = dv0 * dv1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-11-04 20:24:33
|
Revision: 1905 http://opende.svn.sourceforge.net/opende/?rev=1905&view=rev Author: oleh_derevenko Date: 2012-11-04 20:24:26 +0000 (Sun, 04 Nov 2012) Log Message: ----------- Cosmetic: Implemented patch #180 by DonLorenzo Modified Paths: -------------- trunk/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp trunk/drawstuff/src/osx.cpp trunk/drawstuff/src/windows.cpp trunk/drawstuff/src/x11.cpp trunk/ode/demo/demo_ode.cpp trunk/ode/src/error.cpp Modified: trunk/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp =================================================================== --- trunk/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp 2012-08-19 17:37:50 UTC (rev 1904) +++ trunk/contrib/Mac_CFMCarbon/mac_source/drawstuff/src/mac_glut_carbon.cpp 2012-11-04 20:24:26 UTC (rev 1905) @@ -56,6 +56,7 @@ va_list ap; va_start (ap,msg); printMessage ("Error",msg,ap); + va_end (ap); exit (1); } @@ -65,6 +66,7 @@ va_list ap; va_start (ap,msg); printMessage ("INTERNAL ERROR",msg,ap); + va_end (ap); // *((char *)0) = 0; ... commit SEGVicide ? abort(); } @@ -74,6 +76,7 @@ va_list ap; va_start (ap,msg); vprintf (msg,ap); + va_end (ap); } //*************************************************************************** Modified: trunk/drawstuff/src/osx.cpp =================================================================== --- trunk/drawstuff/src/osx.cpp 2012-08-19 17:37:50 UTC (rev 1904) +++ trunk/drawstuff/src/osx.cpp 2012-11-04 20:24:26 UTC (rev 1905) @@ -79,6 +79,7 @@ va_list ap; va_start (ap,msg); printMessage ("Error",msg,ap); + va_end (ap); exit (1); } @@ -88,6 +89,7 @@ va_list ap; va_start (ap,msg); printMessage ("INTERNAL ERROR",msg,ap); + va_end (ap); // *((char *)0) = 0; ... commit SEGVicide ? abort(); } @@ -97,6 +99,7 @@ va_list ap; va_start (ap,msg); vprintf (msg,ap); + va_end (ap); } static void captureFrame( int num ){ Modified: trunk/drawstuff/src/windows.cpp =================================================================== --- trunk/drawstuff/src/windows.cpp 2012-08-19 17:37:50 UTC (rev 1904) +++ trunk/drawstuff/src/windows.cpp 2012-11-04 20:24:26 UTC (rev 1905) @@ -55,6 +55,7 @@ va_list ap; va_start (ap,msg); errorBox ("Warning",msg,ap); + va_end (ap); } @@ -63,6 +64,7 @@ va_list ap; va_start (ap,msg); errorBox ("Error",msg,ap); + va_end (ap); exit (1); } @@ -72,6 +74,7 @@ va_list ap; va_start (ap,msg); errorBox ("INTERNAL ERROR",msg,ap); + va_end (ap); // *((char *)0) = 0; ... commit SEGVicide ? abort(); exit (1); // should never get here, but just in case... @@ -83,6 +86,7 @@ va_list ap; va_start (ap,msg); vprintf (msg,ap); + va_end (ap); } //*************************************************************************** Modified: trunk/drawstuff/src/x11.cpp =================================================================== --- trunk/drawstuff/src/x11.cpp 2012-08-19 17:37:50 UTC (rev 1904) +++ trunk/drawstuff/src/x11.cpp 2012-11-04 20:24:26 UTC (rev 1905) @@ -62,6 +62,7 @@ va_list ap; va_start (ap,msg); printMessage ("Error",msg,ap); + va_end (ap); exit (1); } @@ -71,6 +72,7 @@ va_list ap; va_start (ap,msg); printMessage ("INTERNAL ERROR",msg,ap); + va_end (ap); // *((char *)0) = 0; ... commit SEGVicide ? abort(); } @@ -81,6 +83,7 @@ va_list ap; va_start (ap,msg); vprintf (msg,ap); + va_end (ap); } //*************************************************************************** Modified: trunk/ode/demo/demo_ode.cpp =================================================================== --- trunk/ode/demo/demo_ode.cpp 2012-08-19 17:37:50 UTC (rev 1904) +++ trunk/ode/demo/demo_ode.cpp 2012-11-04 20:24:26 UTC (rev 1905) @@ -951,6 +951,7 @@ va_list ap; va_start (ap,name); vsprintf (mi->name,name,ap); + va_end (ap); if (strlen(mi->name) >= sizeof (mi->name)) dDebug (0,"name too long"); mat.push_back(mi); @@ -967,6 +968,7 @@ va_list ap; va_start (ap,name); vsprintf (mi.name,name,ap); + va_end (ap); if (strlen(mi.name) >= sizeof (mi.name)) dDebug (0,"name too long"); if (strcmp(mp->name,mi.name) != 0) Modified: trunk/ode/src/error.cpp =================================================================== --- trunk/ode/src/error.cpp 2012-08-19 17:37:50 UTC (rev 1904) +++ trunk/ode/src/error.cpp 2012-11-04 20:24:26 UTC (rev 1905) @@ -89,6 +89,7 @@ va_start (ap,msg); if (error_function) error_function (num,msg,ap); else printMessage (num,"ODE Error",msg,ap); + va_end (ap); exit (1); } @@ -99,6 +100,7 @@ va_start (ap,msg); if (debug_function) debug_function (num,msg,ap); else printMessage (num,"ODE INTERNAL ERROR",msg,ap); + va_end (ap); // *((char *)0) = 0; ... commit SEGVicide abort(); } @@ -110,6 +112,7 @@ va_start (ap,msg); if (message_function) message_function (num,msg,ap); else printMessage (num,"ODE Message",msg,ap); + va_end (ap); } #endif @@ -141,6 +144,7 @@ s[sizeof(s)-1] = 0; MessageBox(0,s,title,MB_OK | MB_ICONWARNING); } + va_end (ap); exit (1); } @@ -157,6 +161,7 @@ s[sizeof(s)-1] = 0; MessageBox(0,s,title,MB_OK | MB_ICONSTOP); } + va_end (ap); abort(); } @@ -167,6 +172,7 @@ va_start (ap,msg); if (message_function) message_function (num,msg,ap); else printMessage (num,"ODE Message",msg,ap); + va_end (ap); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |