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: <ole...@us...> - 2012-08-19 17:37:58
|
Revision: 1904 http://opende.svn.sourceforge.net/opende/?rev=1904&view=rev Author: oleh_derevenko Date: 2012-08-19 17:37:50 +0000 (Sun, 19 Aug 2012) Log Message: ----------- Changed: First stage of dxStepIsland/dxQuickStepIsland changed to be executed in threaded manner Modified Paths: -------------- trunk/ode/src/ode.cpp trunk/ode/src/odeou.h 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/ode.cpp =================================================================== --- trunk/ode/src/ode.cpp 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/ode.cpp 2012-08-19 17:37:50 UTC (rev 1904) @@ -1800,7 +1800,7 @@ dxWorldProcessIslandsInfo islandsinfo; if (dxReallocateWorldProcessContext (w, islandsinfo, stepsize, &dxEstimateStepMemoryRequirements)) { - if (dxProcessIslands (w, islandsinfo, stepsize, &dxStepIsland)) + if (dxProcessIslands (w, islandsinfo, stepsize, &dxStepIsland, &dxEstimateStepMaxCallCount)) { result = true; } @@ -1819,7 +1819,7 @@ dxWorldProcessIslandsInfo islandsinfo; if (dxReallocateWorldProcessContext (w, islandsinfo, stepsize, &dxEstimateQuickStepMemoryRequirements)) { - if (dxProcessIslands (w, islandsinfo, stepsize, &dxQuickStepIsland)) + if (dxProcessIslands (w, islandsinfo, stepsize, &dxQuickStepIsland, &dxEstimateQuickStepMaxCallCount)) { result = true; } Modified: trunk/ode/src/odeou.h =================================================================== --- trunk/ode/src/odeou.h 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/odeou.h 2012-08-19 17:37:50 UTC (rev 1904) @@ -72,6 +72,44 @@ }; +#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 // #if dATOMICS_ENABLED + + #endif // dOU_ENABLED Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/quickstep.cpp 2012-08-19 17:37:50 UTC (rev 1904) @@ -32,7 +32,15 @@ #include "joints/joint.h" #include "lcp.h" #include "util.h" +#include "odeou.h" +#include <new> + + +#define dMIN(A,B) ((A)>(B) ? (B) : (A)) +#define dMAX(A,B) ((B)>(A) ? (B) : (A)) + + typedef const dReal *dRealPtr; typedef dReal *dRealMutablePtr; @@ -109,6 +117,70 @@ #define IFTIMING(x) ((void)0) #endif + +struct dJointWithInfo1 +{ + dxJoint *joint; + dxJoint::Info1 info; +}; + +struct dxQuickStepperStage0Outputs +{ + size_t 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) + { + } + + dxStepperProcessingCallContext *m_stepperCallContext; + void *m_stageMemArenaState; + dReal *m_invI; + dJointWithInfo1 *m_jointinfos; + dxQuickStepperStage0Outputs m_stage0Outputs; +}; + +struct dxQuickStepperStage0BodiesCallContext +{ + dxQuickStepperStage0BodiesCallContext(dxStepperProcessingCallContext *stepperCallContext, dReal *invI): + m_stepperCallContext(stepperCallContext), m_invI(invI), + m_tagsTaken(0), m_gravityTaken(0), m_inertiaBodyIndex(0) + { + } + + dxStepperProcessingCallContext *m_stepperCallContext; + dReal *m_invI; + atomicord32 m_tagsTaken; + atomicord32 m_gravityTaken; + unsigned int volatile m_inertiaBodyIndex; +}; + +struct dxQuickStepperStage0JointsCallContext +{ + dxQuickStepperStage0JointsCallContext(dxStepperProcessingCallContext *stepperCallContext, dJointWithInfo1 *jointinfos, dxQuickStepperStage0Outputs *stage0Outputs): + m_stepperCallContext(stepperCallContext), m_jointinfos(jointinfos), m_stage0Outputs(stage0Outputs) + { + } + + dxStepperProcessingCallContext *m_stepperCallContext; + dJointWithInfo1 *m_jointinfos; + dxQuickStepperStage0Outputs *m_stage0Outputs; +}; + +static int dxQuickStepIsland_Stage0_Bodies_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxQuickStepIsland_Stage0_Joints_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxQuickStepIsland_Stage1_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); + +static void dxQuickStepIsland_Stage0_Bodies(dxQuickStepperStage0BodiesCallContext *callContext); +static void dxQuickStepIsland_Stage0_Joints(dxQuickStepperStage0JointsCallContext *callContext); +static void dxQuickStepIsland_Stage1(dxQuickStepperStage1CallContext *callContext); + //*************************************************************************** // various common computations involving the matrix J @@ -583,58 +655,79 @@ } } -struct dJointWithInfo1 -{ - dxJoint *joint; - dxJoint::Info1 info; -}; - +/*extern */ void dxQuickStepIsland(dxStepperProcessingCallContext *callContext) { IFTIMING(dTimerStart("preprocessing")); dxWorldProcessMemArena *memarena = callContext->m_stepperArena; dxWorld *world = callContext->m_world; - dxBody * const *body = callContext->m_islandBodiesStart; unsigned int nb = callContext->m_islandBodiesCount; - dxJoint * const *_joint = callContext->m_islandJointsStart; unsigned int _nj = callContext->m_islandJointsCount; - dReal stepsize = callContext->m_stepSize; + 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); + + void *stagesMemArenaState = memarena->SaveState(); + + dxQuickStepperStage1CallContext *stage1CallContext = (dxQuickStepperStage1CallContext *)memarena->AllocateBlock(sizeof(dxQuickStepperStage1CallContext)); + new(stage1CallContext) dxQuickStepperStage1CallContext(callContext, stagesMemArenaState, invI, jointinfos); + + dxQuickStepperStage0BodiesCallContext *stage0BodiesCallContext = (dxQuickStepperStage0BodiesCallContext *)memarena->AllocateBlock(sizeof(dxQuickStepperStage0BodiesCallContext)); + new(stage0BodiesCallContext) dxQuickStepperStage0BodiesCallContext(callContext, invI); + + dxQuickStepperStage0JointsCallContext *stage0JointsCallContext = (dxQuickStepperStage0JointsCallContext *)memarena->AllocateBlock(sizeof(dxQuickStepperStage0JointsCallContext)); + new(stage0JointsCallContext) dxQuickStepperStage0JointsCallContext(callContext, jointinfos, &stage1CallContext->m_stage0Outputs); + + if (allowedThreads == 1) { - // number all bodies in the body list - set their tag values - for (unsigned int i=0; i<nb; i++) body[i]->tag = i; + dxQuickStepIsland_Stage0_Bodies(stage0BodiesCallContext); + dxQuickStepIsland_Stage0_Joints(stage0JointsCallContext); + dxQuickStepIsland_Stage1(stage1CallContext); } + else + { + unsigned bodyThreads = allowedThreads; + unsigned jointThreads = 1; - // for all bodies, compute the inertia tensor and its inverse in the global - // frame, and compute the rotational force and add it to the torque - // accumulator. I and invI are a vertical stack of 3x4 matrices, one per body. - dReal *invI = memarena->AllocateArray<dReal> (3*4*(size_t)nb); + dCallReleaseeID stage1CallReleasee; + world->PostThreadedCallForUnawareReleasee(NULL, &stage1CallReleasee, bodyThreads + jointThreads, callContext->m_finalReleasee, + NULL, &dxQuickStepIsland_Stage1_Callback, stage1CallContext, 0, "QuickStepIsland Stage1"); - { - dReal *invIrow = invI; - dxBody *const *const bodyend = body + nb; - for (dxBody *const *bodycurr = body; bodycurr != bodyend; invIrow += 12, bodycurr++) { - dMatrix3 tmp; - dxBody *b = *bodycurr; + world->PostThreadedCallsGroup(NULL, bodyThreads, stage1CallReleasee, &dxQuickStepIsland_Stage0_Bodies_Callback, stage0BodiesCallContext, "QuickStepIsland Stage0-Bodies"); - // compute inverse inertia tensor in global frame - dMultiply2_333 (tmp,b->invI,b->posr.R); - dMultiply0_333 (invIrow,b->posr.R,tmp); + world->PostThreadedCall(NULL, NULL, 0, stage1CallReleasee, NULL, &dxQuickStepIsland_Stage0_Joints_Callback, stage0JointsCallContext, 0, "QuickStepIsland Stage0-Joints"); + dIASSERT(jointThreads == 1); + } +} - if ((b->flags & dxBodyGyroscopic) != 0) { - dMatrix3 I; - // compute inertia tensor in global frame - dMultiply2_333 (tmp,b->mass.I,b->posr.R); - dMultiply0_333 (I,b->posr.R,tmp); - // compute rotational force - dMultiply0_331 (tmp,I,b->avel); - dSubtractVectorCross3(b->tacc,b->avel,tmp); - } - } +static +int dxQuickStepIsland_Stage0_Bodies_Callback(void *_callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage0BodiesCallContext *callContext = (dxQuickStepperStage0BodiesCallContext *)_callContext; + dxQuickStepIsland_Stage0_Bodies(callContext); + return 1; +} + +static +void dxQuickStepIsland_Stage0_Bodies(dxQuickStepperStage0BodiesCallContext *callContext) +{ + dxBody * const *body = callContext->m_stepperCallContext->m_islandBodiesStart; + unsigned int nb = callContext->m_stepperCallContext->m_islandBodiesCount; + + if (AtomicExchange(&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) { + dxWorld *world = callContext->m_stepperCallContext->m_world; + // add the gravity force to all bodies // since gravity does normally have only one component it's more efficient // to run three loops for each individual component @@ -668,17 +761,58 @@ } } + // for all bodies, compute the inertia tensor and its inverse in the global + // frame, and compute the rotational force and add it to the torque + // 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); + + for (unsigned int i = 0; i != nb; invIrow += 12, ++i) { + if (i == bodyIndex) { + dMatrix3 tmp; + dxBody *b = body[i]; + + // compute inverse inertia tensor in global frame + dMultiply2_333 (tmp,b->invI,b->posr.R); + dMultiply0_333 (invIrow,b->posr.R,tmp); + + if ((b->flags & dxBodyGyroscopic) != 0) { + dMatrix3 I; + // compute inertia tensor in global frame + dMultiply2_333 (tmp,b->mass.I,b->posr.R); + dMultiply0_333 (I,b->posr.R,tmp); + // compute rotational force + dMultiply0_331 (tmp,I,b->avel); + dSubtractVectorCross3(b->tacc,b->avel,tmp); + } + + bodyIndex = AtomicIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); + } + } + } +} + +static +int dxQuickStepIsland_Stage0_Joints_Callback(void *_callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage0JointsCallContext *callContext = (dxQuickStepperStage0JointsCallContext *)_callContext; + dxQuickStepIsland_Stage0_Joints(callContext); + return 1; +} + +static +void dxQuickStepIsland_Stage0_Joints(dxQuickStepperStage0JointsCallContext *callContext) +{ + dxJoint * const *_joint = callContext->m_stepperCallContext->m_islandJointsStart; + unsigned int _nj = callContext->m_stepperCallContext->m_islandJointsCount; + // get joint information (m = total constraint dimension, nub = number of unbounded variables). // joints with m=0 are inactive and are removed from the joints array // entirely, so that the code that follows does not consider them. - dJointWithInfo1 *const jointiinfos = memarena->AllocateArray<dJointWithInfo1> (_nj); - size_t nj; - unsigned int m; - unsigned int mfb; // number of rows of Jacobian we will have to save for joint feedback - { unsigned int mcurr = 0, mfbcurr = 0; - dJointWithInfo1 *jicurr = jointiinfos; + dJointWithInfo1 *jicurr = callContext->m_jointinfos; dxJoint *const *const _jend = _joint + _nj; for (dxJoint *const *_jcurr = _joint; _jcurr != _jend; _jcurr++) { // jicurr=dest, _jcurr=src dxJoint *j = *_jcurr; @@ -695,13 +829,52 @@ jicurr++; } } - nj = jicurr - jointiinfos; - m = mcurr; - mfb = mfbcurr; + callContext->m_stage0Outputs->nj = jicurr - callContext->m_jointinfos; + callContext->m_stage0Outputs->m = mcurr; + callContext->m_stage0Outputs->mfb = mfbcurr; } +} - memarena->ShrinkArray<dJointWithInfo1>(jointiinfos, _nj, nj); +static +int dxQuickStepIsland_Stage1_Callback(void *_stage1CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxQuickStepperStage1CallContext *stage1CallContext = (dxQuickStepperStage1CallContext *)_stage1CallContext; + dxQuickStepIsland_Stage1(stage1CallContext); + return 1; +} +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; + } + + 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 + + unsigned int _nj = callContext->m_islandJointsCount; + memarena->ShrinkArray<dJointWithInfo1>(jointinfos, _nj, nj); + } + + dxWorld *world = callContext->m_world; + dxBody * const *body = callContext->m_islandBodiesStart; + unsigned int nb = callContext->m_islandBodiesCount; + // if there are constraints, compute the constraint force dReal *J = NULL; int *jb = NULL; @@ -743,7 +916,7 @@ dReal *c = memarena->AllocateArray<dReal> (m); dSetZero (c, m); - const dReal stepsizeRecip = dRecip(stepsize); + const dReal stepsizeRecip = dRecip(callContext->m_stepSize); { IFTIMING (dTimerNow ("create J")); @@ -767,7 +940,7 @@ dReal *Jcopyrow = Jcopy; unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; jicurr++) { dReal *const Jrow = J + (size_t)ofsi * 12; @@ -811,7 +984,7 @@ { // create an array of body numbers for each joint row int *jb_ptr = jb; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; jicurr++) { dxJoint *joint = jicurr->joint; @@ -863,7 +1036,7 @@ #ifdef WARM_STARTING { dReal *lambdscurr = lambda; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; jicurr++) { unsigned int infom = jicurr->info.m; @@ -888,7 +1061,7 @@ //@@@ note that this doesn't work for contact joints yet, as they are // recreated every iteration const dReal *lambdacurr = lambda; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; jicurr++) { unsigned int infom = jicurr->info.m; @@ -902,6 +1075,7 @@ // they should not be used again. { + dReal stepsize = callContext->m_stepSize; // add stepsize * cforce to the body velocity const dReal *cforcecurr = cforce; dxBody *const *const bodyend = body + nb; @@ -921,7 +1095,7 @@ dReal data[6]; const dReal *lambdacurr = lambda; const dReal *Jcopyrow = Jcopy; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; jicurr++) { dxJoint *joint = jicurr->joint; @@ -958,6 +1132,7 @@ { IFTIMING (dTimerNow ("compute velocity update")); + dReal stepsize = callContext->m_stepSize; // compute the velocity update: // add stepsize * invM * fe to the body velocity const dReal *invIrow = invI; @@ -998,6 +1173,7 @@ #endif { + dReal stepsize = callContext->m_stepSize; // update the position and orientation from the new linear/angular velocity // (over the given timestep) IFTIMING (dTimerNow ("update position")); @@ -1043,6 +1219,7 @@ return res; } +/*extern */ size_t dxEstimateQuickStepMemoryRequirements ( dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj) { @@ -1073,9 +1250,9 @@ res += dEFFICIENT_SIZE(sizeof(dReal) * 3 * 4 * (size_t)nb); // for invI { - size_t sub1_res1 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * (size_t)_nj); // for initial jointiinfos + size_t sub1_res1 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * (size_t)_nj); // for initial jointinfos - size_t sub1_res2 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * (size_t)nj); // for shrunk jointiinfos + size_t sub1_res2 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * (size_t)nj); // for shrunk jointinfos 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 @@ -1089,7 +1266,7 @@ size_t sub3_res2 = 0; - sub2_res1 += (sub3_res1 >= sub3_res2) ? sub3_res1 : sub3_res2; + sub2_res1 += dMAX(sub3_res1, sub3_res2); } size_t sub2_res2 = dEFFICIENT_SIZE(sizeof(dReal) * (size_t)m); // for lambda @@ -1105,20 +1282,33 @@ size_t sub4_res2 = 0; - sub3_res2 += (sub4_res1 >= sub4_res2) ? sub4_res1 : sub4_res2; + sub3_res2 += dMAX(sub4_res1, sub4_res2); } #endif - sub2_res2 += (sub3_res1 >= sub3_res2) ? sub3_res1 : sub3_res2; + sub2_res2 += dMAX(sub3_res1, sub3_res2); } - sub1_res2 += (sub2_res1 >= sub2_res2) ? sub2_res1 : sub2_res2; + sub1_res2 += dMAX(sub2_res1, sub2_res2); } } - res += (sub1_res1 >= sub1_res2) ? sub1_res1 : sub1_res2; + size_t sub1_res12_max = dMAX(sub1_res1, sub1_res2); + size_t stage01_contexts = dEFFICIENT_SIZE(sizeof(dxQuickStepperStage0BodiesCallContext)) + + dEFFICIENT_SIZE(sizeof(dxQuickStepperStage0JointsCallContext)) + + dEFFICIENT_SIZE(sizeof(dxQuickStepperStage1CallContext)); + res += dMAX(sub1_res12_max, stage01_contexts); } return res; } +/*extern */ +unsigned dxEstimateQuickStepMaxCallCount( + unsigned activeThreadCount, unsigned allowedThreadCount) +{ + unsigned result = 1 // dxQuickStepIsland itself + + (allowedThreadCount + 1) // allowedThreadCount * dxQuickStepIsland_Stage0_Bodies + dxQuickStepIsland_Stage0_Joints + + 1; // dxQuickStepIsland_Stage1 + return result; +} Modified: trunk/ode/src/quickstep.h =================================================================== --- trunk/ode/src/quickstep.h 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/quickstep.h 2012-08-19 17:37:50 UTC (rev 1904) @@ -30,6 +30,8 @@ size_t dxEstimateQuickStepMemoryRequirements( dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj); +unsigned dxEstimateQuickStepMaxCallCount( + unsigned activeThreadCount, unsigned allowedThreadCount); void dxQuickStepIsland(dxStepperProcessingCallContext *callContext); Modified: trunk/ode/src/step.cpp =================================================================== --- trunk/ode/src/step.cpp 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/step.cpp 2012-08-19 17:37:50 UTC (rev 1904) @@ -31,7 +31,15 @@ #include "joints/joint.h" #include "lcp.h" #include "util.h" +#include "odeou.h" +#include <new> + + +#define dMIN(A,B) ((A)>(B) ? (B) : (A)) +#define dMAX(A,B) ((B)>(A) ? (B) : (A)) + + //**************************************************************************** // misc defines @@ -44,6 +52,72 @@ #define IFTIMING(x) ((void)0) #endif + +struct dJointWithInfo1 +{ + dxJoint *joint; + dxJoint::Info1 info; +}; + +struct dxStepperStage0Outputs +{ + size_t ji_start; + size_t ji_end; + unsigned int m; + unsigned int nub; +}; + +struct dxStepperStage1CallContext +{ + dxStepperStage1CallContext(dxStepperProcessingCallContext *stepperCallContext, void *stageMemArenaState, dReal *invI, dJointWithInfo1 *jointinfos): + m_stepperCallContext(stepperCallContext), m_stageMemArenaState(stageMemArenaState), + m_invI(invI), m_jointinfos(jointinfos) + { + } + + dxStepperProcessingCallContext *m_stepperCallContext; + void *m_stageMemArenaState; + dReal *m_invI; + dJointWithInfo1 *m_jointinfos; + dxStepperStage0Outputs m_stage0Outputs; +}; + +struct dxStepperStage0BodiesCallContext +{ + dxStepperStage0BodiesCallContext(dxStepperProcessingCallContext *stepperCallContext, dReal *invI): + m_stepperCallContext(stepperCallContext), m_invI(invI), + m_tagsTaken(0), m_gravityTaken(0), m_inertiaBodyIndex(0) + { + } + + dxStepperProcessingCallContext *m_stepperCallContext; + dReal *m_invI; + atomicord32 m_tagsTaken; + atomicord32 m_gravityTaken; + unsigned int volatile m_inertiaBodyIndex; +}; + +struct dxStepperStage0JointsCallContext +{ + dxStepperStage0JointsCallContext(dxStepperProcessingCallContext *stepperCallContext, dJointWithInfo1 *jointinfos, dxStepperStage0Outputs *stage0Outputs): + m_stepperCallContext(stepperCallContext), m_jointinfos(jointinfos), m_stage0Outputs(stage0Outputs) + { + } + + dxStepperProcessingCallContext *m_stepperCallContext; + dJointWithInfo1 *m_jointinfos; + dxStepperStage0Outputs *m_stage0Outputs; +}; + +static int dxStepIsland_Stage0_Bodies_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxStepIsland_Stage0_Joints_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); +static int dxStepIsland_Stage1_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); + +static void dxStepIsland_Stage0_Bodies(dxStepperStage0BodiesCallContext *callContext); +static void dxStepIsland_Stage0_Joints(dxStepperStage0JointsCallContext *callContext); +static void dxStepIsland_Stage1(dxStepperStage1CallContext *callContext); + + //**************************************************************************** // special matrix multipliers @@ -176,14 +250,7 @@ } //**************************************************************************** -// an optimized version of dInternalStepIsland1() -struct dJointWithInfo1 -{ - dxJoint *joint; - dxJoint::Info1 info; -}; - /*extern */ void dxStepIsland(dxStepperProcessingCallContext *callContext) { @@ -191,48 +258,75 @@ dxWorldProcessMemArena *memarena = callContext->m_stepperArena; dxWorld *world = callContext->m_world; - dxBody * const *body = callContext->m_islandBodiesStart; unsigned int nb = callContext->m_islandBodiesCount; - dxJoint * const *_joint = callContext->m_islandJointsStart; unsigned int _nj = callContext->m_islandJointsCount; - dReal stepsize = callContext->m_stepSize; + dReal *invI = memarena->AllocateArray<dReal> (3*4*(size_t)nb); + // Reserve twice as much memory and start from the middle so that regardless of + // what direction the array grows to there would be sufficient room available. + const size_t ji_reserve_count = 2 * (size_t)_nj; + dJointWithInfo1 *const jointinfos = memarena->AllocateArray<dJointWithInfo1> (ji_reserve_count); + + const unsigned allowedThreads = callContext->m_stepperAllowedThreads; + dIASSERT(allowedThreads != 0); + + void *stagesMemArenaState = memarena->SaveState(); + + dxStepperStage1CallContext *stage1CallContext = (dxStepperStage1CallContext *)memarena->AllocateBlock(sizeof(dxStepperStage1CallContext)); + new(stage1CallContext) dxStepperStage1CallContext(callContext, stagesMemArenaState, invI, jointinfos); + + dxStepperStage0BodiesCallContext *stage0BodiesCallContext = (dxStepperStage0BodiesCallContext *)memarena->AllocateBlock(sizeof(dxStepperStage0BodiesCallContext)); + new(stage0BodiesCallContext) dxStepperStage0BodiesCallContext(callContext, invI); + + dxStepperStage0JointsCallContext *stage0JointsCallContext = (dxStepperStage0JointsCallContext *)memarena->AllocateBlock(sizeof(dxStepperStage0JointsCallContext)); + new(stage0JointsCallContext) dxStepperStage0JointsCallContext(callContext, jointinfos, &stage1CallContext->m_stage0Outputs); + + if (allowedThreads == 1) { - // number all bodies in the body list - set their tag values - for (unsigned int i=0; i<nb; ++i) body[i]->tag = i; + dxStepIsland_Stage0_Bodies(stage0BodiesCallContext); + dxStepIsland_Stage0_Joints(stage0JointsCallContext); + dxStepIsland_Stage1(stage1CallContext); } + else + { + unsigned bodyThreads = allowedThreads; + unsigned jointThreads = 1; - // for all bodies, compute the inertia tensor and its inverse in the global - // frame, and compute the rotational force and add it to the torque - // accumulator. invI are vertically stacked 3x4 matrices, one per body. - // @@@ check computation of rotational force. + dCallReleaseeID stage1CallReleasee; + world->PostThreadedCallForUnawareReleasee(NULL, &stage1CallReleasee, bodyThreads + jointThreads, callContext->m_finalReleasee, + NULL, &dxStepIsland_Stage1_Callback, stage1CallContext, 0, "StepIsland Stage1"); - dReal *invI = memarena->AllocateArray<dReal> (3*4*(size_t)nb); + world->PostThreadedCallsGroup(NULL, bodyThreads, stage1CallReleasee, &dxStepIsland_Stage0_Bodies_Callback, stage0BodiesCallContext, "StepIsland Stage0-Bodies"); - { // Identical to QuickStep - dReal *invIrow = invI; - dxBody *const *const bodyend = body + nb; - for (dxBody *const *bodycurr = body; bodycurr != bodyend; invIrow += 12, ++bodycurr) { - dMatrix3 tmp; - dxBody *b = *bodycurr; + world->PostThreadedCall(NULL, NULL, 0, stage1CallReleasee, NULL, &dxStepIsland_Stage0_Joints_Callback, stage0JointsCallContext, 0, "StepIsland Stage0-Joints"); + dIASSERT(jointThreads == 1); + } +} - // compute inverse inertia tensor in global frame - dMultiply2_333 (tmp,b->invI,b->posr.R); - dMultiply0_333 (invIrow,b->posr.R,tmp); +static +int dxStepIsland_Stage0_Bodies_Callback(void *_callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxStepperStage0BodiesCallContext *callContext = (dxStepperStage0BodiesCallContext *)_callContext; + dxStepIsland_Stage0_Bodies(callContext); + return 1; +} - if ((b->flags & dxBodyGyroscopic) != 0) { - dMatrix3 I; - // compute inertia tensor in global frame - dMultiply2_333 (tmp,b->mass.I,b->posr.R); - dMultiply0_333 (I,b->posr.R,tmp); - // compute rotational force - dMultiply0_331 (tmp,I,b->avel); - dSubtractVectorCross3 (b->tacc,b->avel,tmp); - } - } +static +void dxStepIsland_Stage0_Bodies(dxStepperStage0BodiesCallContext *callContext) +{ + dxBody * const *body = callContext->m_stepperCallContext->m_islandBodiesStart; + unsigned int nb = callContext->m_stepperCallContext->m_islandBodiesCount; + + if (AtomicExchange(&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; } - { // Identical to QuickStep + if (AtomicExchange(&callContext->m_gravityTaken, 1) == 0) + { + dxWorld *world = callContext->m_stepperCallContext->m_world; + // add the gravity force to all bodies // since gravity does normally have only one component it's more efficient // to run three loops for each individual component @@ -266,6 +360,53 @@ } } + // for all bodies, compute the inertia tensor and its inverse in the global + // frame, and compute the rotational force and add it to the torque + // 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); + + for (unsigned int i = 0; i != nb; invIrow += 12, ++i) { + if (i == bodyIndex) { + dMatrix3 tmp; + dxBody *b = body[i]; + + // compute inverse inertia tensor in global frame + dMultiply2_333 (tmp,b->invI,b->posr.R); + dMultiply0_333 (invIrow,b->posr.R,tmp); + + if ((b->flags & dxBodyGyroscopic) != 0) { + dMatrix3 I; + // compute inertia tensor in global frame + dMultiply2_333 (tmp,b->mass.I,b->posr.R); + dMultiply0_333 (I,b->posr.R,tmp); + // compute rotational force + dMultiply0_331 (tmp,I,b->avel); + dSubtractVectorCross3(b->tacc,b->avel,tmp); + } + + bodyIndex = AtomicIncrementIntUpToLimit(&callContext->m_inertiaBodyIndex, nb); + } + } + } +} + +static +int dxStepIsland_Stage0_Joints_Callback(void *_callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxStepperStage0JointsCallContext *callContext = (dxStepperStage0JointsCallContext *)_callContext; + dxStepIsland_Stage0_Joints(callContext); + return 1; +} + +static +void dxStepIsland_Stage0_Joints(dxStepperStage0JointsCallContext *callContext) +{ + dxJoint * const *_joint = callContext->m_stepperCallContext->m_islandJointsStart; + dJointWithInfo1 *jointinfos = callContext->m_jointinfos; + unsigned int _nj = callContext->m_stepperCallContext->m_islandJointsCount; + // get m = total constraint dimension, nub = number of unbounded variables. // create constraint offset array and number-of-rows array for all joints. // the constraints are re-ordered as follows: the purely unbounded @@ -278,20 +419,13 @@ // also number all active joints in the joint list (set their tag values). // inactive joints receive a tag value of -1. - // Reserve twice as much memory and start from the middle so that regardless of - // what direction the array grows to there would be sufficient room available. - const size_t ji_reserve_count = 2 * (size_t)_nj; - dJointWithInfo1 *jointiinfos = memarena->AllocateArray<dJointWithInfo1> (ji_reserve_count); - unsigned int nub; size_t ji_start, ji_end; - unsigned int m = 0; - { unsigned int mcurr = 0; size_t unb_start, mix_start, mix_end, lcp_end; unb_start = mix_start = mix_end = lcp_end = _nj; - dJointWithInfo1 *jicurr = jointiinfos + lcp_end; + dJointWithInfo1 *jicurr = jointinfos + lcp_end; dxJoint *const *const _jend = _joint + _nj; dxJoint *const *_jcurr = _joint; while (true) { @@ -299,10 +433,10 @@ // Switch to growing array forward { bool fwd_end_reached = false; - dJointWithInfo1 *jimixend = jointiinfos + mix_end; + dJointWithInfo1 *jimixend = jointinfos + mix_end; while (true) { // jicurr=dest, _jcurr=src if (_jcurr == _jend) { - lcp_end = jicurr - jointiinfos; + lcp_end = jicurr - jointinfos; fwd_end_reached = true; break; } @@ -317,7 +451,7 @@ } else if (jicurr->info.nub < jicurr->info.m) { // A mixed case if (unb_start == mix_start) { // no unbounded infos yet - just move to opposite side of mixed-s unb_start = mix_start = mix_start - 1; - dJointWithInfo1 *jimixstart = jointiinfos + mix_start; + dJointWithInfo1 *jimixstart = jointinfos + mix_start; jimixstart->info = jicurr->info; jimixstart->joint = j; } else if (jimixend != jicurr) { // have to swap to the tail of mixed-s @@ -332,11 +466,11 @@ } } else { // A purely unbounded case -- break out and proceed growing in opposite direction unb_start = unb_start - 1; - dJointWithInfo1 *jiunbstart = jointiinfos + unb_start; + dJointWithInfo1 *jiunbstart = jointinfos + unb_start; jiunbstart->info = jicurr->info; jiunbstart->joint = j; - lcp_end = jicurr - jointiinfos; - mix_end = jimixend - jointiinfos; + lcp_end = jicurr - jointinfos; + mix_end = jimixend - jointinfos; jicurr = jiunbstart - 1; break; } @@ -352,11 +486,11 @@ // Switch to growing array backward { bool bkw_end_reached = false; - dJointWithInfo1 *jimixstart = jointiinfos + mix_start - 1; + dJointWithInfo1 *jimixstart = jointinfos + mix_start - 1; while (true) { // jicurr=dest, _jcurr=src if (_jcurr == _jend) { - unb_start = (jicurr + 1) - jointiinfos; - mix_start = (jimixstart + 1) - jointiinfos; + unb_start = (jicurr + 1) - jointinfos; + mix_start = (jimixstart + 1) - jointinfos; bkw_end_reached = true; break; } @@ -370,7 +504,7 @@ --jicurr; } else if (jicurr->info.nub != 0) { // A mixed case if (mix_end == lcp_end) { // no lcp infos yet - just move to opposite side of mixed-s - dJointWithInfo1 *jimixend = jointiinfos + mix_end; + dJointWithInfo1 *jimixend = jointinfos + mix_end; lcp_end = mix_end = mix_end + 1; jimixend->info = jicurr->info; jimixend->joint = j; @@ -385,12 +519,12 @@ jimixstart = jicurr = jicurr - 1; } } else { // A purely lcp case -- break out and proceed growing in opposite direction - dJointWithInfo1 *jilcpend = jointiinfos + lcp_end; + dJointWithInfo1 *jilcpend = jointinfos + lcp_end; lcp_end = lcp_end + 1; jilcpend->info = jicurr->info; jilcpend->joint = j; - unb_start = (jicurr + 1) - jointiinfos; - mix_start = (jimixstart + 1) - jointiinfos; + unb_start = (jicurr + 1) - jointinfos; + mix_start = (jimixstart + 1) - jointinfos; jicurr = jilcpend + 1; break; } @@ -404,26 +538,70 @@ } } - nub = (unsigned)(mix_start - unb_start); + callContext->m_stage0Outputs->m = mcurr; + callContext->m_stage0Outputs->nub = (unsigned)(mix_start - unb_start); dIASSERT((size_t)(mix_start - unb_start) <= (size_t)UINT_MAX); ji_start = unb_start; ji_end = lcp_end; - m = mcurr; } - memarena->ShrinkArray<dJointWithInfo1>(jointiinfos, ji_reserve_count, ji_end); - jointiinfos += ji_start; - unsigned int nj = (unsigned int)(ji_end - ji_start); - dIASSERT((size_t)(ji_end - ji_start) <= (size_t)UINT_MAX); - { - const dJointWithInfo1 *jicurr = jointiinfos; - const dJointWithInfo1 *const jiend = jicurr + nj; + const dJointWithInfo1 *jicurr = jointinfos + ji_start; + const dJointWithInfo1 *const jiend = jointinfos + ji_end; for (unsigned int i = 0; jicurr != jiend; i++, ++jicurr) { jicurr->joint->tag = i; } } + callContext->m_stage0Outputs->ji_start = ji_start; + callContext->m_stage0Outputs->ji_end = ji_end; +} + +static +int dxStepIsland_Stage1_Callback(void *_stage1CallContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) +{ + dxStepperStage1CallContext *stage1CallContext = (dxStepperStage1CallContext *)_stage1CallContext; + dxStepIsland_Stage1(stage1CallContext); + return 1; +} + +static +void dxStepIsland_Stage1(dxStepperStage1CallContext *stage1CallContext) +{ + dxStepperProcessingCallContext *callContext; + dJointWithInfo1 *_jointinfos; + dReal *invI; + size_t ji_start, ji_end; + unsigned int m; + unsigned int nub; + { + callContext = stage1CallContext->m_stepperCallContext; + _jointinfos = stage1CallContext->m_jointinfos; + invI = stage1CallContext->m_invI; + ji_start = stage1CallContext->m_stage0Outputs.ji_start; + ji_end = stage1CallContext->m_stage0Outputs.ji_end; + m = stage1CallContext->m_stage0Outputs.m; + nub = stage1CallContext->m_stage0Outputs.nub; + } + + 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 compiler warnings about unused variable assignment + + unsigned int _nj = callContext->m_islandJointsCount; + const size_t ji_reserve_count = 2 * (size_t)_nj; + memarena->ShrinkArray<dJointWithInfo1>(_jointinfos, ji_reserve_count, ji_end); + } + + dxWorld *world = callContext->m_world; + dxBody * const *body = callContext->m_islandBodiesStart; + unsigned int nb = callContext->m_islandBodiesCount; + dJointWithInfo1 *jointinfos = _jointinfos + ji_start; + unsigned int nj = (unsigned int)(ji_end - ji_start); + dIASSERT((size_t)(ji_end - ji_start) <= (size_t)UINT_MAX); + // this will be set to the force due to the constraints dReal *cforce = memarena->AllocateArray<dReal> ((size_t)nb*8); dSetZero (cforce,(size_t)nb*8); @@ -466,7 +644,7 @@ dReal *cfm = memarena->AllocateArray<dReal> (m); dSetValue (cfm,m,world->global_cfm); - const dReal stepsizeRecip = dRecip(stepsize); + const dReal stepsizeRecip = dRecip(callContext->m_stepSize); dReal *JinvM = memarena->AllocateArray<dReal> (2*8*(size_t)m); dSetZero (JinvM,2*8*(size_t)m); @@ -497,7 +675,7 @@ Jinfo.erp = world->global_erp; unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; ++jicurr) { const unsigned int infom = jicurr->info.m; @@ -535,7 +713,7 @@ // format as J so we just go through the constraints in J multiplying by // the appropriate scalars and matrices. unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; ++jicurr) { const unsigned int infom = jicurr->info.m; @@ -580,7 +758,7 @@ const unsigned int mskip = dPAD(m); unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (unsigned int i = 0; jicurr != jiend; i++, ++jicurr) { const unsigned int infom = jicurr->info.m; @@ -595,7 +773,7 @@ // joint that should not be considered int j0 = n0->joint->tag; if (j0 != -1 && (unsigned)j0 < i) { - const dJointWithInfo1 *jiother = jointiinfos + j0; + const dJointWithInfo1 *jiother = jointinfos + j0; size_t ofsother = (jiother->joint->node[1].body == jb0) ? 8*(size_t)jiother->info.m : 0; // set block of A MultiplyAdd2_p8r (Arow + ofs[j0], JinvMrow, @@ -612,7 +790,7 @@ // joint that should not be considered int j1 = n1->joint->tag; if (j1 != -1 && (unsigned)j1 < i) { - const dJointWithInfo1 *jiother = jointiinfos + j1; + const dJointWithInfo1 *jiother = jointinfos + j1; size_t ofsother = (jiother->joint->node[1].body == jb1) ? 8*(size_t)jiother->info.m : 0; // set block of A MultiplyAdd2_p8r (Arow + ofs[j1], JinvMrow + 8*(size_t)infom, @@ -633,7 +811,7 @@ const unsigned int mskip = dPAD(m); unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; ++jicurr) { const unsigned int infom = jicurr->info.m; @@ -666,7 +844,7 @@ // compute the right hand side `rhs' IFTIMING(dTimerNow ("compute rhs")); - const dReal stepsizeRecip = dRecip(stepsize); + const dReal stepsizeRecip = dRecip(callContext->m_stepSize); dReal *tmp1 = memarena->AllocateArray<dReal> ((size_t)nb*8); //dSetZero (tmp1,nb*8); @@ -694,7 +872,7 @@ { // put J*tmp1 into rhs unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; ++jicurr) { const unsigned int infom = jicurr->info.m; @@ -729,7 +907,7 @@ // compute the constraint force `cforce' // compute cforce = J'*lambda unsigned ofsi = 0; - const dJointWithInfo1 *jicurr = jointiinfos; + const dJointWithInfo1 *jicurr = jointinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (; jicurr != jiend; ++jicurr) { const unsigned int infom = jicurr->info.m; @@ -792,6 +970,8 @@ // compute the velocity update IFTIMING(dTimerNow ("compute velocity update")); + const dReal stepsize = callContext->m_stepSize; + // add fe to cforce and multiply cforce by stepsize dReal data[4]; const dReal *invIrow = invI; @@ -812,10 +992,13 @@ // update the position and orientation from the new linear/angular velocity // (over the given timestep) IFTIMING(dTimerNow ("update position")); + + const dReal stepsize = callContext->m_stepSize; + dxBody *const *const bodyend = body + nb; for (dxBody *const *bodycurr = body; bodycurr != bodyend; ++bodycurr) { dxBody *b = *bodycurr; - dxStepBody (b,stepsize); + dxStepBody (b, stepsize); } } @@ -839,11 +1022,11 @@ IFTIMING(dTimerEnd()); if (m > 0) IFTIMING(dTimerReport (stdout,1)); - } //**************************************************************************** +/*extern */ size_t dxEstimateStepMemoryRequirements (dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj) { unsigned int nj, m; @@ -871,10 +1054,10 @@ res += dEFFICIENT_SIZE(sizeof(dReal) * 3 * 4 * (size_t)nb); // for invI { - size_t sub1_res1 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * 2 * (size_t)_nj); // for initial jointiinfos + size_t sub1_res1 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * 2 * (size_t)_nj); // for initial jointinfos // The array can't grow right more than by nj - size_t sub1_res2 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * ((size_t)_nj + (size_t)nj)); // for shrunk jointiinfos + size_t sub1_res2 = dEFFICIENT_SIZE(sizeof(dJointWithInfo1) * ((size_t)_nj + (size_t)nj)); // for shrunk jointinfos sub1_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 8 * (size_t)nb); // for cforce if (m > 0) { sub1_res2 += dEFFICIENT_SIZE(sizeof(dReal) * 2 * 8 * (size_t)m); // for J @@ -890,7 +1073,7 @@ size_t sub3_res2 = 0; - sub2_res1 += (sub3_res1 >= sub3_res2) ? sub3_res1 : sub3_res2; + sub2_res1 += dMAX(sub3_res1, sub3_res2); } size_t sub2_res2 = 0; @@ -901,7 +1084,7 @@ size_t sub4_res2 = 0; - sub3_res1 += (sub4_res1 >= sub4_res2) ? sub4_res1 : sub4_res2; + sub3_res1 += dMAX(sub4_res1, sub4_res2); } size_t sub3_res2 = dEFFICIENT_SIZE(sizeof(dReal) * (size_t)m); // for lambda @@ -910,20 +1093,33 @@ size_t sub4_res2 = 0; - sub3_res2 += (sub4_res1 >= sub4_res2) ? sub4_res1 : sub4_res2; + sub3_res2 += dMAX(sub4_res1, sub4_res2); } - sub2_res2 += (sub3_res1 >= sub3_res2) ? sub3_res1 : sub3_res2; + sub2_res2 += dMAX(sub3_res1, sub3_res2); } - sub1_res2 += (sub2_res1 >= sub2_res2) ? sub2_res1 : sub2_res2; + sub1_res2 += dMAX(sub2_res1, sub2_res2); } } - res += (sub1_res1 >= sub1_res2) ? sub1_res1 : sub1_res2; + size_t sub1_res12_max = dMAX(sub1_res1, sub1_res2); + size_t stage01_contexts = dEFFICIENT_SIZE(sizeof(dxStepperStage0BodiesCallContext)) + + dEFFICIENT_SIZE(sizeof(dxStepperStage0JointsCallContext)) + + dEFFICIENT_SIZE(sizeof(dxStepperStage1CallContext)); + res += dMAX(sub1_res12_max, stage01_contexts); } return res; } +/*extern */ +unsigned dxEstimateStepMaxCallCount( + unsigned activeThreadCount, unsigned allowedThreadCount) +{ + unsigned result = 1 // dxStepIsland itself + + (allowedThreadCount + 1) // allowedThreadCount * dxStepIsland_Stage0_Bodies + dxStepIsland_Stage0_Joints + + 1; // dxStepIsland_Stage1 + return result; +} Modified: trunk/ode/src/step.h =================================================================== --- trunk/ode/src/step.h 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/step.h 2012-08-19 17:37:50 UTC (rev 1904) @@ -30,6 +30,8 @@ size_t dxEstimateStepMemoryRequirements( dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj); +unsigned dxEstimateStepMaxCallCount( + unsigned activeThreadCount, unsigned allowedThreadCount); void dxStepIsland(dxStepperProcessingCallContext *callContext); Modified: trunk/ode/src/util.cpp =================================================================== --- trunk/ode/src/util.cpp 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/util.cpp 2012-08-19 17:37:50 UTC (rev 1904) @@ -26,10 +26,12 @@ #include "joints/joint.h" #include "util.h" #include "odeou.h" + #include <new> #define dMIN(A,B) ((A)>(B) ? (B) : (A)) +#define dMAX(A,B) ((B)>(A) ? (B) : (A)) //**************************************************************************** @@ -331,11 +333,12 @@ { dxIslandsProcessingCallContext(dxWorld *world, const dxWorldProcessIslandsInfo &islandsInfo, dReal stepSize, dstepper_fn_t stepper): m_world(world), m_islandsInfo(islandsInfo), m_stepSize(stepSize), m_stepper(stepper), - m_groupReleasee(NULL), m_islandToProcessStorage(0) + m_groupReleasee(NULL), m_islandToProcessStorage(0), m_stepperAllowedThreads(0) { } void AssignGroupReleasee(dCallReleaseeID groupReleasee) { m_groupReleasee = groupReleasee; } + void SetStepperAllowedThreads(unsigned allowedThreadsLimit) { m_stepperAllowedThreads = allowedThreadsLimit; } static int ThreadedProcessGroup_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); bool ThreadedProcessGroup(); @@ -352,11 +355,12 @@ size_t ObtainNextIslandToBeProcessed(size_t islandsCount); dxWorld *const m_world; - dxWorldProcessIslandsInfo const &m_islandsInfo; + dxWorldProcessIslandsInfo const &m_islandsInfo; dReal const m_stepSize; dstepper_fn_t const m_stepper; dCallReleaseeID m_groupReleasee; size_t volatile m_islandToProcessStorage; + unsigned m_stepperAllowedThreads; }; @@ -367,7 +371,7 @@ dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart): m_islandsProcessingContext(islandsProcessingContext), m_islandIndex(0), m_stepperArena(stepperArena), m_arenaInitialState(arenaInitialState), - m_stepperCallContext(islandsProcessingContext->m_world, islandsProcessingContext->m_stepSize, stepperArena, islandBodiesStart, islandJointsStart) + m_stepperCallContext(islandsProcessingContext->m_world, islandsProcessingContext->m_stepSize, islandsProcessingContext->m_stepperAllowedThreads, stepperArena, islandBodiesStart, islandJointsStart) { } @@ -841,12 +845,16 @@ return maxreq; } -static unsigned EstimateIslandProcessingSimultaneousCallsMaximumCount(unsigned allowedThreadCount, unsigned activeThreadCount) +static unsigned EstimateIslandProcessingSimultaneousCallsMaximumCount(unsigned activeThreadCount, unsigned islandsAllowedThreadCount, + unsigned stepperAllowedThreadCount, dmaxcallcountestimate_fn_t maxCallCountEstimator) { + unsigned stepperCallsMaximum = maxCallCountEstimator(activeThreadCount, stepperAllowedThreadCount); + unsigned islandsIntermediateCallsMaximum = (1 + 2); // ThreadedProcessIslandSearch_Callback + (ThreadedProcessIslandStepper_Callback && ThreadedProcessIslandSearch_Callback) + unsigned result = 1 // ThreadedProcessGroup_Callback - + allowedThreadCount * (1 + 2) // ThreadedProcessIslandSearch_Callback + (ThreadedProcessIslandStepper_Callback && ThreadedProcessIslandSearch_Callback) - + dMIN(allowedThreadCount, (unsigned)(activeThreadCount - allowedThreadCount)) // ThreadedProcessJobStart_Callback + + islandsAllowedThreadCount * dMAX(stepperCallsMaximum, islandsIntermediateCallsMaximum) + + dMIN(islandsAllowedThreadCount, (unsigned)(activeThreadCount - islandsAllowedThreadCount)) // ThreadedProcessJobStart_Callback /*...the end*/; return result; } @@ -862,7 +870,7 @@ // bodies will not be included in the simulation. disabled bodies are // re-enabled if they are found to be part of an active island. bool dxProcessIslands (dxWorld *world, const dxWorldProcessIslandsInfo &islandsInfo, - dReal stepSize, dstepper_fn_t stepper) + dReal stepSize, dstepper_fn_t stepper, dmaxcallcountestimate_fn_t maxCallCountEstimator) { bool result = false; @@ -878,24 +886,27 @@ int summaryFault = 0; unsigned activeThreadCount; - const unsigned allowedThreadCount = world->GetThreadingIslandsMaxThreadsCount(&activeThreadCount); - dIASSERT(allowedThreadCount != 0); - dIASSERT(activeThreadCount >= allowedThreadCount); + const unsigned islandsAllowedThreadCount = world->GetThreadingIslandsMaxThreadsCount(&activeThreadCount); + dIASSERT(islandsAllowedThreadCount != 0); + dIASSERT(activeThreadCount >= islandsAllowedThreadCount); - unsigned simultaneousCallsCount = EstimateIslandProcessingSimultaneousCallsMaximumCount(allowedThreadCount, activeThreadCount); + unsigned stepperAllowedThreadCount = islandsAllowedThreadCount; // For now, set stepper allowed threads equal to island stepping threads + + unsigned simultaneousCallsCount = EstimateIslandProcessingSimultaneousCallsMaximumCount(activeThreadCount, islandsAllowedThreadCount, stepperAllowedThreadCount, maxCallCountEstimator); if (!world->PreallocateResourcesForThreadedCalls(simultaneousCallsCount)) { break; } dCallReleaseeID groupReleasee; // First post a group call with dependency count set to number of expected threads - world->PostThreadedCall(&summaryFault, &groupReleasee, allowedThreadCount, NULL, pcwGroupCallWait, + world->PostThreadedCall(&summaryFault, &groupReleasee, islandsAllowedThreadCount, NULL, pcwGroupCallWait, &dxIslandsProcessingCallContext::ThreadedProcessGroup_Callback, (void *)&callContext, 0, "World Islands Stepping Group"); callContext.AssignGroupReleasee(groupReleasee); + callContext.SetStepperAllowedThreads(stepperAllowedThreadCount); // Summary fault flag may be omitted as any failures will automatically propagate to dependent releasee (i.e. to groupReleasee) - world->PostThreadedCallsGroup(NULL, allowedThreadCount, groupReleasee, + world->PostThreadedCallsGroup(NULL, islandsAllowedThreadCount, groupReleasee, &dxIslandsProcessingCallContext::ThreadedProcessJobStart_Callback, (void *)&callContext, "World Islands Stepping Start"); // Wait until group completes (since jobs were the dependencies of the group the group is going to complete only after all the jobs end) @@ -1034,23 +1045,7 @@ size_t dxIslandsProcessingCallContext::ObtainNextIslandToBeProcessed(size_t islandsCount) { - size_t islandToProcess; - - while (true) - { - islandToProcess = m_islandToProcessStorage; - if (islandToProcess == islandsCount) - { - break; - } - - if (AtomicCompareExchangePointer((volatile atomicptr *)&m_islandToProcessStorage, (atomicptr)islandToProcess, (atomicptr)(islandToProcess + 1))) - { - break; - } - } - - return islandToProcess; + return AtomicIncrementSizeUpToLimit(&m_islandToProcessStorage, islandsCount); } Modified: trunk/ode/src/util.h =================================================================== --- trunk/ode/src/util.h 2012-07-30 08:29:46 UTC (rev 1903) +++ trunk/ode/src/util.h 2012-08-19 17:37:50 UTC (rev 1904) @@ -283,17 +283,18 @@ private: size_t m_IslandCount; - unsigned int const *m_pIslandSizes; - dxBody *const *m_pBodies; - dxJoint *const *m_pJoints; + unsigned int const *m_pIslandSizes; + dxBody *const *m_pBodies; + dxJoint *const *m_pJoints; }; struct dxStepperProcessingCallContext { - dxStepperProcessingCallContext(dxWorld *world, dReal stepSize, dxWorldProcessMemArena *stepperArena, - dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart): + dxStepperProcessingCallContext(dxWorld *world, dReal stepSize, unsigned stepperAllowedThreads, + dxWorldProcessMemArena *stepperArena, dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart): m_world(world), m_stepSize(stepSize), m_stepperArena(stepperArena), m_finalReleasee(NULL), - m_islandBodiesStart(islandBodiesStart), m_islandJoints... [truncated message content] |
From: <ole...@us...> - 2012-07-30 08:29:53
|
Revision: 1903 http://opende.svn.sourceforge.net/opende/?rev=1903&view=rev Author: oleh_derevenko Date: 2012-07-30 08:29:46 +0000 (Mon, 30 Jul 2012) Log Message: ----------- Changed: demo_convex_cd.cpp has been removed from project Modified Paths: -------------- trunk/build/premake4.lua trunk/ode/demo/Makefile.am Removed Paths: ------------- trunk/ode/demo/demo_convex_cd.cpp Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-07-29 12:47:22 UTC (rev 1902) +++ trunk/build/premake4.lua 2012-07-30 08:29:46 UTC (rev 1903) @@ -16,7 +16,6 @@ "chain1", "chain2", "collision", - "convex", "crash", "cylvssphere", "dball", Modified: trunk/ode/demo/Makefile.am =================================================================== --- trunk/ode/demo/Makefile.am 2012-07-29 12:47:22 UTC (rev 1902) +++ trunk/ode/demo/Makefile.am 2012-07-30 08:29:46 UTC (rev 1903) @@ -20,7 +20,6 @@ demo_chain1 \ demo_chain2 \ demo_collision \ - demo_convex_cd \ demo_crash \ demo_cylvssphere \ demo_dball \ Deleted: trunk/ode/demo/demo_convex_cd.cpp =================================================================== --- trunk/ode/demo/demo_convex_cd.cpp 2012-07-29 12:47:22 UTC (rev 1902) +++ trunk/ode/demo/demo_convex_cd.cpp 2012-07-30 08:29:46 UTC (rev 1903) @@ -1,395 +0,0 @@ -/************************************************************************* - * * - * 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. * - * * - *************************************************************************/ - -#include <stdio.h> -#include <math.h> -#include <ode/ode.h> -#include <drawstuff/drawstuff.h> -#include "texturepath.h" - -#ifdef _MSC_VER -#pragma warning(disable:4244 4305) // for VC++, no precision loss complaints -#endif - - -#ifndef M_PI -#define M_PI (3.14159265358979323846) -#endif - -//<---- Convex Object -dReal planes[]= // planes for a cube - { - 1.0f ,0.0f ,0.0f ,0.25f, - 0.0f ,1.0f ,0.0f ,0.25f, - 0.0f ,0.0f ,1.0f ,0.25f, - -1.0f,0.0f ,0.0f ,0.25f, - 0.0f ,-1.0f,0.0f ,0.25f, - 0.0f ,0.0f ,-1.0f,0.25f - /* - 1.0f ,0.0f ,0.0f ,2.0f, - 0.0f ,1.0f ,0.0f ,1.0f, - 0.0f ,0.0f ,1.0f ,1.0f, - 0.0f ,0.0f ,-1.0f,1.0f, - 0.0f ,-1.0f,0.0f ,1.0f, - -1.0f,0.0f ,0.0f ,0.0f - */ - }; -const unsigned int planecount=6; - -dReal points[]= // points for a cube - { - 0.25f,0.25f,0.25f, // point 0 - -0.25f,0.25f,0.25f, // point 1 - - 0.25f,-0.25f,0.25f, // point 2 - -0.25f,-0.25f,0.25f,// point 3 - - 0.25f,0.25f,-0.25f, // point 4 - -0.25f,0.25f,-0.25f,// point 5 - - 0.25f,-0.25f,-0.25f,// point 6 - -0.25f,-0.25f,-0.25f,// point 7 - }; -const unsigned int pointcount=8; -unsigned int polygons[] = //Polygons for a cube (6 squares) - { - 4,0,2,6,4, // positive X Side 0 - 4,1,0,4,5, // positive Y Side 1 - 4,0,1,3,2, // positive Z Side 2 - 4,3,1,5,7, // negative X Side 3 - 4,2,3,7,6, // negative Y Side 4 - 4,5,4,6,7, // negative Z Side 5 - }; -//----> Convex Object - -#ifdef dDOUBLE -#define dsDrawConvex dsDrawConvexD -#define dsDrawBox dsDrawBoxD -#endif - -dGeomID* geoms; -dGeomID boxes[2]; -dGeomID convex[2]; -dSpaceID space; -dWorldID world; -dJointGroupID contactgroup; -/* -glRotate Matrix: -( xx(1-c)+c xy(1-c)-zs xz(1-c)+ys 0 ) -| | -| yx(1-c)+zs yy(1-c)+c yz(1-c)-xs 0 | -| xz(1-c)-ys yz(1-c)+xs zz(1-c)+c 0 | -| | -( 0 0 0 1 ) -Where c = cos(angle), s = sine(angle), and ||( x,y,z )|| = 1 - (if not, the GL will normalize this vector). -*/ - -dVector3 geom1pos={0.0,0.250,0.50}; -dQuaternion geom1quat={1,0,0,0}; -dQuaternion geom0quat={0.7071,0,0.7071,0}; - -bool DumpInfo=true; -int drawmode = DS_WIREFRAME; - -#if 0 -const dReal fixed_pos_0[]={0.703704,-0.748281,0.249495}; -const dReal fixed_rot_0[]={0.996994,-0.001009,-0.077468,0.000000, - -0.077468,-0.000117,-0.996995,0.000000, - 0.000996, 1.000000,-0.000195,0.000000}; - -const dReal fixed_pos_1[]={0.894169,-0.372081,0.249432}; -const dReal fixed_rot_1[]={-0.999461, 0.032777,0.001829,0.000000, - -0.032777,-0.999463,0.000033,0.000000, - 0.001829,-0.000027,0.999998,0.000000}; - -#else -// for EDGE-EDGE test -const dReal fixed_pos_0[]={0.0,0.0,0.25}; -const dReal fixed_rot_0[]={ 1,0,0,0,0,1,0,0,0,0,1,0 }; -const dReal fixed_pos_1[]={0.000000,0.450000,0.600000}; -const dReal fixed_rot_1[]={0.708311,-0.705472,-0.000000,0.000000, - 0.516939,0.519297,-0.679785,0.000000, - 0.480067,0.481293,0.733034,0.000000}; -#endif -void start() -{ - // adjust the starting viewpoint a bit - float xyz[3],hpr[3]; - dsGetViewpoint (xyz,hpr); - hpr[0] += 7; - dsSetViewpoint (xyz,hpr); - convex[0]=dCreateConvex (space, - planes, - planecount, - points, - pointcount, - polygons); - convex[1]=dCreateConvex (space, - planes, - planecount, - points, - pointcount, - polygons); - boxes[0]=dCreateBox(space,0.5,0.5,0.5); - boxes[1]=dCreateBox(space,0.5,0.5,0.5); - geoms=convex; - -#if 0 - dMatrix3 m1 = { 1,0,0,0,0,1,0,0,0,0,1,0 }; - dMatrix3 m2 = { 1,0,0,0,0,1,0,0,0,0,1,0 }; - dGeomSetPosition (convex[0], - 0.0, - 0.0, - 0.25); - dGeomSetPosition (convex[1], - geom1pos[0], - geom1pos[1], - geom1pos[2]); - dQtoR (geom0quat, m1); - dGeomSetRotation (convex[0],m1); - dQtoR (geom1quat, m2); - dGeomSetRotation (convex[1],m2); - - dGeomSetPosition (boxes[0], - 0.0, - 0.0, - 0.25); - dGeomSetPosition (boxes[1], - geom1pos[0], - geom1pos[1], - geom1pos[2]); - dQtoR (geom0quat, m1); - dGeomSetRotation (boxes[0],m1); - dQtoR (geom1quat, m2); - dGeomSetRotation (boxes[1],m2); -#else - dGeomSetPosition (convex[0], - fixed_pos_0[0], - fixed_pos_0[1], - fixed_pos_0[2]); - dGeomSetPosition (convex[1], - fixed_pos_1[0], - fixed_pos_1[1], - fixed_pos_1[2]); - dGeomSetRotation (convex[0],fixed_rot_0); - dGeomSetRotation (convex[1],fixed_rot_1); - dGeomSetPosition (boxes[0], - fixed_pos_0[0], - fixed_pos_0[1], - fixed_pos_0[2]); - dGeomSetPosition (boxes[1], - fixed_pos_1[0], - fixed_pos_1[1], - fixed_pos_1[2]); - dGeomSetRotation (boxes[0],fixed_rot_0); - dGeomSetRotation (boxes[1],fixed_rot_1); -#endif - -} - -int dCollideConvexConvex (dxGeom *o1, dxGeom *o2, int flags, - dContactGeom *contact, int skip); -int dCollideBoxBox (dxGeom *o1, dxGeom *o2, int flags, - dContactGeom *contact, int skip); - -void simLoop (int pause) -{ - int contactcount; - const dReal ss[3] = {0.02,0.02,0.02}; - dContactGeom contacts[8]; -if(geoms==convex) - contactcount = dCollideConvexConvex(geoms[0],geoms[1],8,contacts,sizeof(dContactGeom)); -else - contactcount = dCollideBoxBox(geoms[0],geoms[1],8,contacts,sizeof(dContactGeom)); - - //fprintf(stdout,"Contact Count %d\n",contactcount); - const dReal* pos; - const dReal* R; - dsSetTexture (DS_WOOD); - pos = dGeomGetPosition (geoms[0]); - R = dGeomGetRotation (geoms[0]); - dsSetColor (0.6f,0.6f,1); - dsSetDrawMode(drawmode); - dsDrawConvex(pos,R,planes, - planecount, - points, - pointcount, - polygons); - dsSetDrawMode(DS_POLYFILL); - pos = dGeomGetPosition (geoms[1]); - R = dGeomGetRotation (geoms[1]); - dsSetColor (0.4f,1,1); - dsSetDrawMode(drawmode); - dsDrawConvex(pos,R,planes, - planecount, - points, - pointcount, - polygons); - dsSetDrawMode(DS_POLYFILL); - /*if (show_contacts) */ - dMatrix3 RI; - dRSetIdentity (RI); - dsSetColor (1.0f,0,0); - for(int i=0;i<contactcount;++i) - { - if(DumpInfo) - { - //DumpInfo=false; - fprintf(stdout,"Contact %d Normal %f,%f,%f Depth %f Pos %f %f %f ", - i, - contacts[i].normal[0], - contacts[i].normal[1], - contacts[i].normal[2], - contacts[i].depth, - contacts[i].pos[0], - contacts[i].pos[1], - contacts[i].pos[2]); - if(contacts[i].g1==geoms[0]) - { - fprintf(stdout,"Geoms 1 2\n"); - } - else - { - fprintf(stdout,"Geoms 2 1\n"); - } - } - dsDrawBox (contacts[i].pos,RI,ss); - } - if(DumpInfo) - DumpInfo=false; - -} - - -void command (int cmd) -{ - // note: 0.0174532925 radians = 1 degree - dQuaternion q; - //dMatrix3 m; - bool changed = false; - switch(cmd) - { - case 'w': - geom1pos[0]+=0.05; - changed = true; - break; - case 'a': - geom1pos[1]-=0.05; - changed = true; - break; - case 's': - geom1pos[0]-=0.05; - changed = true; - break; - case 'd': - geom1pos[1]+=0.05; - changed = true; - break; - case 'e': - geom1pos[2]-=0.05; - changed = true; - break; - case 'q': - geom1pos[2]+=0.05; - changed = true; - break; - case 'i': - dQFromAxisAndAngle (q, 0, 0, 1,0.0174532925); - dQMultiply0(geom1quat,geom1quat,q); - changed = true; - break; - case 'j': - dQFromAxisAndAngle (q, 1, 0, 0,0.0174532925); - dQMultiply0(geom1quat,geom1quat,q); - changed = true; - break; - case 'k': - dQFromAxisAndAngle (q, 0, 0, 1,-0.0174532925); - dQMultiply0(geom1quat,geom1quat,q); - changed = true; - break; - case 'l': - dQFromAxisAndAngle (q, 1, 0, 0,-0.0174532925); - dQMultiply0(geom1quat,geom1quat,q); - changed = true; - break; - case 'm': - (drawmode!=DS_POLYFILL)? drawmode=DS_POLYFILL:drawmode=DS_WIREFRAME; - break; - case 'n': - (geoms!=convex)? geoms=convex:geoms=boxes; - if(geoms==convex) - { - printf("CONVEX------------------------------------------------------>\n"); - } - else - { - printf("BOX--------------------------------------------------------->\n"); - } - break; - default: - dsPrint ("received command %d (`%c')\n",cmd,cmd); - } - (void)changed; -#if 0 - dGeomSetPosition (geoms[1], - geom1pos[0], - geom1pos[1], - geom1pos[2]); - dQtoR (geom1quat, m); - dGeomSetRotation(geoms[1],m); - if(changed) - { - printf("POS: %f,%f,%f\n",geom1pos[0],geom1pos[1],geom1pos[2]); - printf("ROT:\n%f,%f,%f,%f\n%f,%f,%f,%f\n%f,%f,%f,%f\n", - m[0],m[1],m[2],m[3], - m[4],m[5],m[6],m[7], - m[8],m[9],m[10],m[11]); - } -#endif - DumpInfo=true; -} - - -int main (int argc, char **argv) -{ - // setup pointers to callback functions - dsFunctions fn; - fn.version = DS_VERSION; - fn.start = &start; - fn.step = &simLoop; - fn.command = command; - fn.stop = 0; - fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH; // uses default - world = dWorldCreate(); - space = dHashSpaceCreate (0); - contactgroup = dJointGroupCreate (0); - - // run simulation - dsSimulationLoop (argc,argv,400,400,&fn); - dJointGroupDestroy (contactgroup); - dSpaceDestroy (space); - dWorldDestroy (world); - - return 0; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-07-29 12:47:29
|
Revision: 1902 http://opende.svn.sourceforge.net/opende/?rev=1902&view=rev Author: oleh_derevenko Date: 2012-07-29 12:47:22 +0000 (Sun, 29 Jul 2012) Log Message: ----------- Cosmetic: Cosmetic code changes towards threading the stepper functions Modified Paths: -------------- trunk/include/ode/collision.h trunk/ode/src/joints/joint.h trunk/ode/src/ode.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/include/ode/collision.h =================================================================== --- trunk/include/ode/collision.h 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/include/ode/collision.h 2012-07-29 12:47:22 UTC (rev 1902) @@ -421,7 +421,7 @@ enum { - dGeomColliderMergeContactsValue__Default = 0, /* Used with Set... to restore default value*/ + dGeomColliderMergeContactsValue__Default = 0, /* Used with Set... to restore default value*/ dGeomColliderMergeContactsValue_None = 1, dGeomColliderMergeContactsValue_Normals = 2, dGeomColliderMergeContactsValue_Full = 3 Modified: trunk/ode/src/joints/joint.h =================================================================== --- trunk/ode/src/joints/joint.h 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/joints/joint.h 2012-07-29 12:47:22 UTC (rev 1902) @@ -77,7 +77,7 @@ { // Structure size should not exceed sizeof(pointer) bytes to have // to have good memory pattern in dxQuickStepper() - int8 m, nub; + uint8 m, nub; }; // info returned by getInfo2 function @@ -127,7 +127,7 @@ // will be smaller, it can save a bit of memory from being reserved // for calculations if that smaller value is returned. - int8 max_m; // Estimate of maximal `m' in Info1 + uint8 max_m; // Estimate of maximal `m' in Info1 }; Modified: trunk/ode/src/ode.cpp =================================================================== --- trunk/ode/src/ode.cpp 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/ode.cpp 2012-07-29 12:47:22 UTC (rev 1902) @@ -1800,7 +1800,7 @@ dxWorldProcessIslandsInfo islandsinfo; if (dxReallocateWorldProcessContext (w, islandsinfo, stepsize, &dxEstimateStepMemoryRequirements)) { - if (dxProcessIslands (w, islandsinfo, stepsize, &dInternalStepIsland)) + if (dxProcessIslands (w, islandsinfo, stepsize, &dxStepIsland)) { result = true; } @@ -1819,7 +1819,7 @@ dxWorldProcessIslandsInfo islandsinfo; if (dxReallocateWorldProcessContext (w, islandsinfo, stepsize, &dxEstimateQuickStepMemoryRequirements)) { - if (dxProcessIslands (w, islandsinfo, stepsize, &dxQuickStepper)) + if (dxProcessIslands (w, islandsinfo, stepsize, &dxQuickStepIsland)) { result = true; } Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/quickstep.cpp 2012-07-29 12:47:22 UTC (rev 1902) @@ -589,13 +589,17 @@ dxJoint::Info1 info; }; -void dxQuickStepper (dxWorldProcessMemArena *memarena, - dxWorld *world, dxBody * const *body, unsigned int nb, - dxJoint * const *_joint, unsigned int _nj, dReal stepsize) +void dxQuickStepIsland(dxStepperProcessingCallContext *callContext) { IFTIMING(dTimerStart("preprocessing")); - const dReal stepsize1 = dRecip(stepsize); + dxWorldProcessMemArena *memarena = callContext->m_stepperArena; + dxWorld *world = callContext->m_world; + dxBody * const *body = callContext->m_islandBodiesStart; + unsigned int nb = callContext->m_islandBodiesCount; + dxJoint * const *_joint = callContext->m_islandJointsStart; + unsigned int _nj = callContext->m_islandJointsCount; + dReal stepsize = callContext->m_stepSize; { // number all bodies in the body list - set their tag values @@ -618,7 +622,7 @@ dMultiply2_333 (tmp,b->invI,b->posr.R); dMultiply0_333 (invIrow,b->posr.R,tmp); - if (b->flags & dxBodyGyroscopic) { + if ((b->flags & dxBodyGyroscopic) != 0) { dMatrix3 I; // compute inertia tensor in global frame dMultiply2_333 (tmp,b->mass.I,b->posr.R); @@ -639,7 +643,7 @@ if (gravity_x) { for (dxBody *const *bodycurr = body; bodycurr != bodyend; bodycurr++) { dxBody *b = *bodycurr; - if ((b->flags & dxBodyNoGravity)==0) { + if ((b->flags & dxBodyNoGravity) == 0) { b->facc[0] += b->mass.mass * gravity_x; } } @@ -648,7 +652,7 @@ if (gravity_y) { for (dxBody *const *bodycurr = body; bodycurr != bodyend; bodycurr++) { dxBody *b = *bodycurr; - if ((b->flags & dxBodyNoGravity)==0) { + if ((b->flags & dxBodyNoGravity) == 0) { b->facc[1] += b->mass.mass * gravity_y; } } @@ -657,7 +661,7 @@ if (gravity_z) { for (dxBody *const *bodycurr = body; bodycurr != bodyend; bodycurr++) { dxBody *b = *bodycurr; - if ((b->flags & dxBodyNoGravity)==0) { + if ((b->flags & dxBodyNoGravity) == 0) { b->facc[2] += b->mass.mass * gravity_z; } } @@ -669,42 +673,35 @@ // entirely, so that the code that follows does not consider them. dJointWithInfo1 *const jointiinfos = memarena->AllocateArray<dJointWithInfo1> (_nj); size_t nj; + unsigned int m; + unsigned int mfb; // number of rows of Jacobian we will have to save for joint feedback { + unsigned int mcurr = 0, mfbcurr = 0; dJointWithInfo1 *jicurr = jointiinfos; dxJoint *const *const _jend = _joint + _nj; for (dxJoint *const *_jcurr = _joint; _jcurr != _jend; _jcurr++) { // jicurr=dest, _jcurr=src dxJoint *j = *_jcurr; j->getInfo1 (&jicurr->info); - dIASSERT (jicurr->info.m >= 0 && jicurr->info.m <= 6 && jicurr->info.nub >= 0 && jicurr->info.nub <= jicurr->info.m); - if (jicurr->info.m > 0) { + dIASSERT (/*jicurr->info.m >= 0 && */jicurr->info.m <= 6 && /*jicurr->info.nub >= 0 && */jicurr->info.nub <= jicurr->info.m); + + unsigned int jm = jicurr->info.m; + if (jm != 0) { + mcurr += jm; + if (j->feedback != NULL) { + mfbcurr += jm; + } jicurr->joint = j; jicurr++; } } nj = jicurr - jointiinfos; - } - - memarena->ShrinkArray<dJointWithInfo1>(jointiinfos, _nj, nj); - - unsigned int m; - unsigned int mfb; // number of rows of Jacobian we will have to save for joint feedback - - { - unsigned int mcurr = 0, mfbcurr = 0; - const dJointWithInfo1 *jicurr = jointiinfos; - const dJointWithInfo1 *const jiend = jicurr + nj; - for (; jicurr != jiend; jicurr++) { - unsigned int jm = jicurr->info.m; - mcurr += jm; - if (jicurr->joint->feedback) - mfbcurr += jm; - } - m = mcurr; mfb = mfbcurr; } + memarena->ShrinkArray<dJointWithInfo1>(jointiinfos, _nj, nj); + // if there are constraints, compute the constraint force dReal *J = NULL; int *jb = NULL; @@ -746,6 +743,8 @@ dReal *c = memarena->AllocateArray<dReal> (m); dSetZero (c, m); + const dReal stepsizeRecip = dRecip(stepsize); + { IFTIMING (dTimerNow ("create J")); // get jacobian data from constraints. an m*12 matrix will be created @@ -763,7 +762,7 @@ // dxJoint::Info2 Jinfo; Jinfo.rowskip = 12; - Jinfo.fps = stepsize1; + Jinfo.fps = stepsizeRecip; Jinfo.erp = world->global_erp; dReal *Jcopyrow = Jcopy; @@ -840,9 +839,9 @@ 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] * stepsize1; + 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] * stepsize1; + for (unsigned int k=0; k<3; k++) tmp1curr[3+k] += b->avel[k] * stepsizeRecip; } // put J*tmp1 into rhs @@ -851,10 +850,10 @@ } END_STATE_SAVE(memarena, tmp1state); // complete rhs - for (unsigned int i=0; i<m; i++) rhs[i] = c[i]*stepsize1 - rhs[i]; + for (unsigned int i=0; i<m; i++) rhs[i] = c[i]*stepsizeRecip - rhs[i]; // scale CFM - for (unsigned int j=0; j<m; j++) cfm[j] *= stepsize1; + for (unsigned int j=0; j<m; j++) cfm[j] *= stepsizeRecip; } END_STATE_SAVE(memarena, cstate); Modified: trunk/ode/src/quickstep.h =================================================================== --- trunk/ode/src/quickstep.h 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/quickstep.h 2012-07-29 12:47:22 UTC (rev 1902) @@ -25,16 +25,13 @@ #include <ode/common.h> -class dxWorldProcessMemArena; +struct dxStepperProcessingCallContext; -size_t dxEstimateQuickStepMemoryRequirements ( +size_t dxEstimateQuickStepMemoryRequirements( dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj); -void dxQuickStepper ( - dxWorldProcessMemArena *memarena, dxWorld *world, - dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj, - dReal stepsize); +void dxQuickStepIsland(dxStepperProcessingCallContext *callContext); #endif Modified: trunk/ode/src/step.cpp =================================================================== --- trunk/ode/src/step.cpp 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/step.cpp 2012-07-29 12:47:22 UTC (rev 1902) @@ -184,18 +184,22 @@ dxJoint::Info1 info; }; -static void dInternalStepIsland_x2 (dxWorldProcessMemArena *memarena, - dxWorld *world, dxBody * const *body, unsigned int nb, - dxJoint * const *_joint, unsigned int _nj, dReal stepsize) +/*extern */ +void dxStepIsland(dxStepperProcessingCallContext *callContext) { IFTIMING(dTimerStart("preprocessing")); - const dReal stepsizeRecip = dRecip(stepsize); + dxWorldProcessMemArena *memarena = callContext->m_stepperArena; + dxWorld *world = callContext->m_world; + dxBody * const *body = callContext->m_islandBodiesStart; + unsigned int nb = callContext->m_islandBodiesCount; + dxJoint * const *_joint = callContext->m_islandJointsStart; + unsigned int _nj = callContext->m_islandJointsCount; + dReal stepsize = callContext->m_stepSize; { // number all bodies in the body list - set their tag values - unsigned int i; - for (i=0; i<nb; ++i) body[i]->tag = i; + for (unsigned int i=0; i<nb; ++i) body[i]->tag = i; } // for all bodies, compute the inertia tensor and its inverse in the global @@ -216,7 +220,7 @@ dMultiply2_333 (tmp,b->invI,b->posr.R); dMultiply0_333 (invIrow,b->posr.R,tmp); - if (b->flags & dxBodyGyroscopic) { + if ((b->flags & dxBodyGyroscopic) != 0) { dMatrix3 I; // compute inertia tensor in global frame dMultiply2_333 (tmp,b->mass.I,b->posr.R); @@ -237,7 +241,7 @@ if (gravity_x) { for (dxBody *const *bodycurr = body; bodycurr != bodyend; ++bodycurr) { dxBody *b = *bodycurr; - if ((b->flags & dxBodyNoGravity)==0) { + if ((b->flags & dxBodyNoGravity) == 0) { b->facc[0] += b->mass.mass * gravity_x; } } @@ -246,7 +250,7 @@ if (gravity_y) { for (dxBody *const *bodycurr = body; bodycurr != bodyend; ++bodycurr) { dxBody *b = *bodycurr; - if ((b->flags & dxBodyNoGravity)==0) { + if ((b->flags & dxBodyNoGravity) == 0) { b->facc[1] += b->mass.mass * gravity_y; } } @@ -255,7 +259,7 @@ if (gravity_z) { for (dxBody *const *bodycurr = body; bodycurr != bodyend; ++bodycurr) { dxBody *b = *bodycurr; - if ((b->flags & dxBodyNoGravity)==0) { + if ((b->flags & dxBodyNoGravity) == 0) { b->facc[2] += b->mass.mass * gravity_z; } } @@ -280,8 +284,10 @@ dJointWithInfo1 *jointiinfos = memarena->AllocateArray<dJointWithInfo1> (ji_reserve_count); unsigned int nub; size_t ji_start, ji_end; + unsigned int m = 0; { + unsigned int mcurr = 0; size_t unb_start, mix_start, mix_end, lcp_end; unb_start = mix_start = mix_end = lcp_end = _nj; @@ -302,8 +308,9 @@ } dxJoint *j = *_jcurr++; j->getInfo1 (&jicurr->info); - dIASSERT (jicurr->info.m >= 0 && jicurr->info.m <= 6 && jicurr->info.nub >= 0 && jicurr->info.nub <= jicurr->info.m); - if (jicurr->info.m > 0) { + dIASSERT (/*jicurr->info.m >= 0 && */jicurr->info.m <= 6 && /*jicurr->info.nub >= 0 && */jicurr->info.nub <= jicurr->info.m); + if (jicurr->info.m != 0) { + mcurr += jicurr->info.m; if (jicurr->info.nub == 0) { // A lcp info - a correct guess!!! jicurr->joint = j; ++jicurr; @@ -355,12 +362,13 @@ } dxJoint *j = *_jcurr++; j->getInfo1 (&jicurr->info); - dIASSERT (jicurr->info.m >= 0 && jicurr->info.m <= 6 && jicurr->info.nub >= 0 && jicurr->info.nub <= jicurr->info.m); - if (jicurr->info.m > 0) { + dIASSERT (/*jicurr->info.m >= 0 && */jicurr->info.m <= 6 && /*jicurr->info.nub >= 0 && */jicurr->info.nub <= jicurr->info.m); + if (jicurr->info.m != 0) { + mcurr += jicurr->info.m; if (jicurr->info.nub == jicurr->info.m) { // An unbounded info - a correct guess!!! jicurr->joint = j; --jicurr; - } else if (jicurr->info.nub > 0) { // A mixed case + } else if (jicurr->info.nub != 0) { // A mixed case if (mix_end == lcp_end) { // no lcp infos yet - just move to opposite side of mixed-s dJointWithInfo1 *jimixend = jointiinfos + mix_end; lcp_end = mix_end = mix_end + 1; @@ -400,6 +408,7 @@ dIASSERT((size_t)(mix_start - unb_start) <= (size_t)UINT_MAX); ji_start = unb_start; ji_end = lcp_end; + m = mcurr; } memarena->ShrinkArray<dJointWithInfo1>(jointiinfos, ji_reserve_count, ji_end); @@ -407,19 +416,12 @@ unsigned int nj = (unsigned int)(ji_end - ji_start); dIASSERT((size_t)(ji_end - ji_start) <= (size_t)UINT_MAX); - unsigned int m = 0; - { - unsigned int mcurr = 0; const dJointWithInfo1 *jicurr = jointiinfos; const dJointWithInfo1 *const jiend = jicurr + nj; for (unsigned int i = 0; jicurr != jiend; i++, ++jicurr) { jicurr->joint->tag = i; - unsigned int jm = jicurr->info.m; - mcurr += jm; } - - m = mcurr; } // this will be set to the force due to the constraints @@ -464,6 +466,8 @@ dReal *cfm = memarena->AllocateArray<dReal> (m); dSetValue (cfm,m,world->global_cfm); + const dReal stepsizeRecip = dRecip(stepsize); + dReal *JinvM = memarena->AllocateArray<dReal> (2*8*(size_t)m); dSetZero (JinvM,2*8*(size_t)m); @@ -662,6 +666,8 @@ // compute the right hand side `rhs' IFTIMING(dTimerNow ("compute rhs")); + const dReal stepsizeRecip = dRecip(stepsize); + dReal *tmp1 = memarena->AllocateArray<dReal> ((size_t)nb*8); //dSetZero (tmp1,nb*8); @@ -838,13 +844,6 @@ //**************************************************************************** -void dInternalStepIsland (dxWorldProcessMemArena *memarena, - dxWorld *world, dxBody * const *body, unsigned int nb, - dxJoint * const *joint, unsigned int nj, dReal stepsize) -{ - dInternalStepIsland_x2 (memarena,world,body,nb,joint,nj,stepsize); -} - size_t dxEstimateStepMemoryRequirements (dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj) { unsigned int nj, m; Modified: trunk/ode/src/step.h =================================================================== --- trunk/ode/src/step.h 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/step.h 2012-07-29 12:47:22 UTC (rev 1902) @@ -25,16 +25,13 @@ #include <ode/common.h> -class dxWorldProcessMemArena; +struct dxStepperProcessingCallContext; -size_t dxEstimateStepMemoryRequirements ( +size_t dxEstimateStepMemoryRequirements( dxBody * const *body, unsigned int nb, dxJoint * const *_joint, unsigned int _nj); -void dInternalStepIsland ( - dxWorldProcessMemArena *memarena, dxWorld *world, - dxBody * const *body, unsigned int nb, dxJoint * const *joint, unsigned int nj, - dReal stepsize); +void dxStepIsland(dxStepperProcessingCallContext *callContext); Modified: trunk/ode/src/util.cpp =================================================================== --- trunk/ode/src/util.cpp 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/util.cpp 2012-07-29 12:47:22 UTC (rev 1902) @@ -325,7 +325,7 @@ //**************************************************************************** // Threading call contexts -struct dxStepperCallContext; +struct dxSingleIslandCallContext; struct dxIslandsProcessingCallContext { @@ -344,28 +344,30 @@ void ThreadedProcessJobStart(); static int ThreadedProcessIslandSearch_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); - void ThreadedProcessIslandSearch(dxStepperCallContext *stepperCallContext); + void ThreadedProcessIslandSearch(dxSingleIslandCallContext *stepperCallContext); static int ThreadedProcessIslandStepper_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee); - void ThreadedProcessIslandStepper(dxStepperCallContext *stepperCallContext); + void ThreadedProcessIslandStepper(dxSingleIslandCallContext *stepperCallContext); size_t ObtainNextIslandToBeProcessed(size_t islandsCount); - dxWorld *const m_world; - const dxWorldProcessIslandsInfo &m_islandsInfo; - dReal const m_stepSize; - dstepper_fn_t const m_stepper; - dCallReleaseeID m_groupReleasee; - volatile size_t m_islandToProcessStorage; + dxWorld *const m_world; + dxWorldProcessIslandsInfo const &m_islandsInfo; + dReal const m_stepSize; + dstepper_fn_t const m_stepper; + dCallReleaseeID m_groupReleasee; + size_t volatile m_islandToProcessStorage; }; -struct dxStepperCallContext + +struct dxSingleIslandCallContext { - dxStepperCallContext(dxIslandsProcessingCallContext *islandsProcessingContext, dxWorldProcessMemArena *stepperArena, - size_t islandIndex, dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart): - m_islandsProcessingContext(islandsProcessingContext), m_stepperArena(stepperArena), - m_islandIndex(islandIndex), m_islandBodiesStart(islandBodiesStart), m_islandJointsStart(islandJointsStart), - m_islandBodiesCount(0), m_islandJointsCount(0) + dxSingleIslandCallContext(dxIslandsProcessingCallContext *islandsProcessingContext, + dxWorldProcessMemArena *stepperArena, void *arenaInitialState, + dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart): + m_islandsProcessingContext(islandsProcessingContext), m_islandIndex(0), + m_stepperArena(stepperArena), m_arenaInitialState(arenaInitialState), + m_stepperCallContext(islandsProcessingContext->m_world, islandsProcessingContext->m_stepSize, stepperArena, islandBodiesStart, islandJointsStart) { } @@ -374,25 +376,33 @@ m_islandIndex = islandIndex; } - void AssignIslandSelection(dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart, unsigned islandBodiesCount, unsigned islandJointsCount) + void AssignIslandSelection(dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart, + unsigned islandBodiesCount, unsigned islandJointsCount) { - m_islandBodiesStart = islandBodiesStart; - m_islandJointsStart = islandJointsStart; - m_islandBodiesCount = islandBodiesCount; - m_islandJointsCount = islandJointsCount; + m_stepperCallContext.AssignIslandSelection(islandBodiesStart, islandJointsStart, islandBodiesCount, islandJointsCount); } + dxBody *const *GetSelectedIslandBodiesEnd() const { return m_stepperCallContext.GetSelectedIslandBodiesEnd(); } + dxJoint *const *GetSelectedIslandJointsEnd() const { return m_stepperCallContext.GetSelectedIslandJointsEnd(); } + + void RestoreSavedMemArenaStateForStepper() + { + m_stepperArena->RestoreState(m_arenaInitialState); + } + + void AssignStepperCallFinalReleasee(dCallReleaseeID finalReleasee) + { + m_stepperCallContext.AssignStepperCallFinalReleasee(finalReleasee); + } + dxIslandsProcessingCallContext *m_islandsProcessingContext; + size_t m_islandIndex; dxWorldProcessMemArena *m_stepperArena; - size_t m_islandIndex; - dxBody *const *m_islandBodiesStart; - dxJoint *const *m_islandJointsStart; - unsigned m_islandBodiesCount; - unsigned m_islandJointsCount; + void *m_arenaInitialState; + dxStepperProcessingCallContext m_stepperCallContext; }; - //**************************************************************************** // Auto disabling @@ -931,11 +941,11 @@ dxBody *const *islandBodiesStart = islandsInfo.GetBodiesArray(); dxJoint *const *islandJointsStart = islandsInfo.GetJointsArray(); - size_t islandIndex = 0; + dxSingleIslandCallContext *stepperCallContext = (dxSingleIslandCallContext *)stepperArena->AllocateBlock(sizeof(dxSingleIslandCallContext)); + // Save area state after context allocation to be restored for the stepper + void *arenaState = stepperArena->SaveState(); + new(stepperCallContext) dxSingleIslandCallContext(this, stepperArena, arenaState, islandBodiesStart, islandJointsStart); - dxStepperCallContext *stepperCallContext = (dxStepperCallContext *)stepperArena->AllocateBlock(sizeof(dxStepperCallContext)); - new(stepperCallContext) dxStepperCallContext(this, stepperArena, islandIndex, islandBodiesStart, islandJointsStart); - // Summary fault flag may be omitted as any failures will automatically propagate to dependent releasee (i.e. to m_groupReleasee) m_world->PostThreadedCallForUnawareReleasee(NULL, NULL, 0, m_groupReleasee, NULL, &dxIslandsProcessingCallContext::ThreadedProcessIslandSearch_Callback, (void *)stepperCallContext, 0, "World Islands Stepping Selection"); @@ -943,12 +953,12 @@ int dxIslandsProcessingCallContext::ThreadedProcessIslandSearch_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) { - dxStepperCallContext *stepperCallContext = static_cast<dxStepperCallContext *>(callContext); + dxSingleIslandCallContext *stepperCallContext = static_cast<dxSingleIslandCallContext *>(callContext); stepperCallContext->m_islandsProcessingContext->ThreadedProcessIslandSearch(stepperCallContext); return true; } -void dxIslandsProcessingCallContext::ThreadedProcessIslandSearch(dxStepperCallContext *stepperCallContext) +void dxIslandsProcessingCallContext::ThreadedProcessIslandSearch(dxSingleIslandCallContext *stepperCallContext) { bool finalizeJob = false; @@ -960,8 +970,8 @@ if (islandToProcess != islandsCount) { // First time, the counts are zeros and on next passes, adding counts will skip island that has just been processed by stepper - dxBody *const *islandBodiesStart = stepperCallContext->m_islandBodiesStart + stepperCallContext->m_islandBodiesCount; - dxJoint *const *islandJointsStart = stepperCallContext->m_islandJointsStart + stepperCallContext->m_islandJointsCount; + dxBody *const *islandBodiesStart = stepperCallContext->GetSelectedIslandBodiesEnd(); + dxJoint *const *islandJointsStart = stepperCallContext->GetSelectedIslandJointsEnd(); size_t islandIndex = stepperCallContext->m_islandIndex; for (; ; ++islandIndex) { @@ -976,12 +986,17 @@ ++islandIndex; stepperCallContext->AssignIslandSearchProgress(islandIndex); + // Restore saved stepper memory arena position + stepperCallContext->RestoreSavedMemArenaStateForStepper(); + dCallReleaseeID nextSearchReleasee; // Summary fault flag may be omitted as any failures will automatically propagate to dependent releasee (i.e. to m_groupReleasee) m_world->PostThreadedCallForUnawareReleasee(NULL, &nextSearchReleasee, 1, m_groupReleasee, NULL, &dxIslandsProcessingCallContext::ThreadedProcessIslandSearch_Callback, (void *)stepperCallContext, 0, "World Islands Stepping Selection"); + stepperCallContext->AssignStepperCallFinalReleasee(nextSearchReleasee); + m_world->PostThreadedCall(NULL, NULL, 0, nextSearchReleasee, NULL, &dxIslandsProcessingCallContext::ThreadedProcessIslandStepper_Callback, (void *)stepperCallContext, 0, "Island Stepping Job Start"); @@ -998,7 +1013,7 @@ if (finalizeJob) { dxWorldProcessMemArena *stepperArena = stepperCallContext->m_stepperArena; - stepperCallContext->dxStepperCallContext::~dxStepperCallContext(); + stepperCallContext->dxSingleIslandCallContext::~dxSingleIslandCallContext(); dxWorldProcessContext *context = m_world->UnsafeGetWorldProcessingContext(); context->ReturnStepperMemArena(stepperArena); @@ -1007,22 +1022,14 @@ int dxIslandsProcessingCallContext::ThreadedProcessIslandStepper_Callback(void *callContext, dcallindex_t callInstanceIndex, dCallReleaseeID callThisReleasee) { - dxStepperCallContext *stepperCallContext = static_cast<dxStepperCallContext *>(callContext); + dxSingleIslandCallContext *stepperCallContext = static_cast<dxSingleIslandCallContext *>(callContext); stepperCallContext->m_islandsProcessingContext->ThreadedProcessIslandStepper(stepperCallContext); return true; } -void dxIslandsProcessingCallContext::ThreadedProcessIslandStepper(dxStepperCallContext *stepperCallContext) +void dxIslandsProcessingCallContext::ThreadedProcessIslandStepper(dxSingleIslandCallContext *stepperCallContext) { - dxBody *const *islandBodiesStart = stepperCallContext->m_islandBodiesStart; - dxJoint *const *islandJointsStart = stepperCallContext->m_islandJointsStart; - unsigned islandBodiesCount = stepperCallContext->m_islandBodiesCount; - unsigned islandJointsCount = stepperCallContext->m_islandJointsCount; - - dxWorldProcessMemArena *stepperArena = stepperCallContext->m_stepperArena; - BEGIN_STATE_SAVE(stepperArena, stepperState) { - m_stepper(stepperArena, m_world, islandBodiesStart, islandBodiesCount, islandJointsStart, islandJointsCount, m_stepSize); - } END_STATE_SAVE(stepperArena, stepperState); + m_stepper(&stepperCallContext->m_stepperCallContext); } size_t dxIslandsProcessingCallContext::ObtainNextIslandToBeProcessed(size_t islandsCount) @@ -1175,7 +1182,7 @@ size_t stepperReq = BuildIslandsAndEstimateStepperMemoryRequirements(islandsInfo, islandsArena, world, stepSize, stepperEstimate); dIASSERT(stepperReq == dEFFICIENT_SIZE(stepperReq)); - size_t stepperReqWithCallContext = stepperReq + dEFFICIENT_SIZE(sizeof(dxStepperCallContext)); + size_t stepperReqWithCallContext = stepperReq + dEFFICIENT_SIZE(sizeof(dxSingleIslandCallContext)); unsigned islandThreadsCount = world->GetThreadingIslandsMaxThreadsCount(); if (!context->ReallocateStepperMemArenas(world, islandThreadsCount, stepperReqWithCallContext, Modified: trunk/ode/src/util.h =================================================================== --- trunk/ode/src/util.h 2012-07-23 09:49:48 UTC (rev 1901) +++ trunk/ode/src/util.h 2012-07-29 12:47:22 UTC (rev 1902) @@ -282,19 +282,52 @@ dxJoint *const *GetJointsArray() const { return m_pJoints; } private: - size_t m_IslandCount; - unsigned int const *m_pIslandSizes; - dxBody *const *m_pBodies; - dxJoint *const *m_pJoints; + size_t m_IslandCount; + unsigned int const *m_pIslandSizes; + dxBody *const *m_pBodies; + dxJoint *const *m_pJoints; }; +struct dxStepperProcessingCallContext +{ + dxStepperProcessingCallContext(dxWorld *world, dReal stepSize, dxWorldProcessMemArena *stepperArena, + dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart): + m_world(world), m_stepSize(stepSize), m_stepperArena(stepperArena), m_finalReleasee(NULL), + m_islandBodiesStart(islandBodiesStart), m_islandJointsStart(islandJointsStart), m_islandBodiesCount(0), m_islandJointsCount(0) + { + } + void AssignIslandSelection(dxBody *const *islandBodiesStart, dxJoint *const *islandJointsStart, + unsigned islandBodiesCount, unsigned islandJointsCount) + { + m_islandBodiesStart = islandBodiesStart; + m_islandJointsStart = islandJointsStart; + m_islandBodiesCount = islandBodiesCount; + m_islandJointsCount = islandJointsCount; + } + + dxBody *const *GetSelectedIslandBodiesEnd() const { return m_islandBodiesStart + m_islandBodiesCount; } + dxJoint *const *GetSelectedIslandJointsEnd() const { return m_islandJointsStart + m_islandJointsCount; } + + void AssignStepperCallFinalReleasee(dCallReleaseeID finalReleasee) + { + m_finalReleasee = finalReleasee; + } + + dxWorld *const m_world; + dReal const m_stepSize; + dxWorldProcessMemArena *m_stepperArena; + dCallReleaseeID m_finalReleasee; + dxBody *const *m_islandBodiesStart; + dxJoint *const *m_islandJointsStart; + unsigned m_islandBodiesCount; + unsigned m_islandJointsCount; +}; + #define BEGIN_STATE_SAVE(memarena, state) void *state = memarena->SaveState(); #define END_STATE_SAVE(memarena, state) memarena->RestoreState(state) -typedef void (*dstepper_fn_t) (dxWorldProcessMemArena *memarena, - dxWorld *world, dxBody * const *body, unsigned int nb, - dxJoint * const *_joint, unsigned int _nj, dReal stepsize); +typedef void (*dstepper_fn_t) (dxStepperProcessingCallContext *callContext); bool dxProcessIslands (dxWorld *world, const dxWorldProcessIslandsInfo &islandsInfo, dReal stepSize, dstepper_fn_t stepper); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-07-23 09:49:57
|
Revision: 1901 http://opende.svn.sourceforge.net/opende/?rev=1901&view=rev Author: oleh_derevenko Date: 2012-07-23 09:49:48 +0000 (Mon, 23 Jul 2012) Log Message: ----------- Internal: Changed: Got rid of dynamic_cast in joints. Modified Paths: -------------- trunk/ode/src/joints/dball.cpp trunk/ode/src/joints/dhinge.cpp Modified: trunk/ode/src/joints/dball.cpp =================================================================== --- trunk/ode/src/joints/dball.cpp 2012-07-23 09:39:44 UTC (rev 1900) +++ trunk/ode/src/joints/dball.cpp 2012-07-23 09:49:48 UTC (rev 1901) @@ -151,7 +151,7 @@ void dJointSetDBallAnchor1( dJointID j, dReal x, dReal y, dReal z ) { - dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dxJointDBall* joint = static_cast<dxJointDBall*>(j); dUASSERT( joint, "bad joint argument" ); if ( joint->flags & dJOINT_REVERSE ) { @@ -178,7 +178,7 @@ void dJointSetDBallAnchor2( dJointID j, dReal x, dReal y, dReal z ) { - dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dxJointDBall* joint = static_cast<dxJointDBall*>(j); dUASSERT( joint, "bad joint argument" ); @@ -205,7 +205,7 @@ dReal dJointGetDBallDistance(dJointID j) { - dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dxJointDBall* joint = static_cast<dxJointDBall*>(j); dUASSERT( joint, "bad joint argument" ); return joint->targetDistance; @@ -214,7 +214,7 @@ void dJointGetDBallAnchor1( dJointID j, dVector3 result ) { - dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dxJointDBall* joint = static_cast<dxJointDBall*>(j); dUASSERT( joint, "bad joint argument" ); dUASSERT( result, "bad result argument" ); @@ -234,7 +234,7 @@ void dJointGetDBallAnchor2( dJointID j, dVector3 result ) { - dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dxJointDBall* joint = static_cast<dxJointDBall*>(j); dUASSERT( joint, "bad joint argument" ); dUASSERT( result, "bad result argument" ); @@ -254,7 +254,7 @@ void dJointSetDBallParam( dJointID j, int parameter, dReal value ) { - dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dxJointDBall* joint = static_cast<dxJointDBall*>(j); dUASSERT( joint, "bad joint argument" ); switch ( parameter ) { @@ -270,7 +270,7 @@ dReal dJointGetDBallParam( dJointID j, int parameter ) { - dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dxJointDBall* joint = static_cast<dxJointDBall*>(j); dUASSERT( joint, "bad joint argument" ); switch ( parameter ) { Modified: trunk/ode/src/joints/dhinge.cpp =================================================================== --- trunk/ode/src/joints/dhinge.cpp 2012-07-23 09:39:44 UTC (rev 1900) +++ trunk/ode/src/joints/dhinge.cpp 2012-07-23 09:49:48 UTC (rev 1901) @@ -156,7 +156,7 @@ void dJointSetDHingeAxis( dJointID j, dReal x, dReal y, dReal z ) { - dxJointDHinge* joint = dynamic_cast<dxJointDHinge*>(j); + dxJointDHinge* joint = static_cast<dxJointDHinge*>(j); dUASSERT( joint, "bad joint argument" ); dBodyVectorFromWorld(joint->node[0].body, x, y, z, joint->axis1); @@ -173,7 +173,7 @@ void dJointGetDHingeAxis( dJointID j, dVector3 result ) { - dxJointDHinge* joint = dynamic_cast<dxJointDHinge*>(j); + dxJointDHinge* joint = static_cast<dxJointDHinge*>(j); dUASSERT( joint, "bad joint argument" ); dBodyVectorToWorld(joint->node[0].body, joint->axis1[0], joint->axis1[1], joint->axis1[2], result); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-07-23 09:39:51
|
Revision: 1900 http://opende.svn.sourceforge.net/opende/?rev=1900&view=rev Author: oleh_derevenko Date: 2012-07-23 09:39:44 +0000 (Mon, 23 Jul 2012) Log Message: ----------- Fixed: Fixed precision substitution on Windows to maintain compatibility with *NIX scripts Modified Paths: -------------- trunk/build/premake4.lua trunk/include/ode/precision.h.in trunk/libccd/src/ccd/precision.h.in Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-07-21 12:18:41 UTC (rev 1899) +++ trunk/build/premake4.lua 2012-07-23 09:39:44 UTC (rev 1900) @@ -421,17 +421,17 @@ outfile:close() end - function generate(directive, precstr) - generateheader("../include/ode/precision.h", "@ODE_PRECISION_DEF@", directive .. " d" .. precstr) - generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION_DEF@", directive .. " CCD_" .. precstr) + function generate(precstr) + generateheader("../include/ode/precision.h", "@ODE_PRECISION@", "d" .. precstr) + generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION@", "CCD_" .. precstr) end if _OPTIONS["only-single"] then - generate("define", "SINGLE") + generate("SINGLE") elseif _OPTIONS["only-double"] then - generate("define", "DOUBLE") + generate("DOUBLE") else - generate("error", "<PRECISION> is undefined") + generate("UNDEFINEDPRECISION") end ---------------------------------------------------------------------- Modified: trunk/include/ode/precision.h.in =================================================================== --- trunk/include/ode/precision.h.in 2012-07-21 12:18:41 UTC (rev 1899) +++ trunk/include/ode/precision.h.in 2012-07-23 09:39:44 UTC (rev 1900) @@ -10,7 +10,7 @@ #elif defined(dIDEDOUBLE) #define dDOUBLE #else -#@ODE_PRECISION_DEF@ +#define @ODE_PRECISION@ #endif #endif Modified: trunk/libccd/src/ccd/precision.h.in =================================================================== --- trunk/libccd/src/ccd/precision.h.in 2012-07-21 12:18:41 UTC (rev 1899) +++ trunk/libccd/src/ccd/precision.h.in 2012-07-23 09:39:44 UTC (rev 1900) @@ -8,7 +8,7 @@ #elif defined(CCD_IDEDOUBLE) #define CCD_DOUBLE #else -#@CCD_PRECISION_DEF@ +#define @CCD_PRECISION@ #endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-07-21 12:18:47
|
Revision: 1899 http://opende.svn.sourceforge.net/opende/?rev=1899&view=rev Author: oleh_derevenko Date: 2012-07-21 12:18:41 +0000 (Sat, 21 Jul 2012) Log Message: ----------- Changed: Unnecessary dependency on inttypes.h removed (was causing problems with MSVC on Windows) Modified Paths: -------------- trunk/ode/src/threading_impl_templates.h Modified: trunk/ode/src/threading_impl_templates.h =================================================================== --- trunk/ode/src/threading_impl_templates.h 2012-07-21 12:17:09 UTC (rev 1898) +++ trunk/ode/src/threading_impl_templates.h 2012-07-21 12:18:41 UTC (rev 1899) @@ -43,9 +43,7 @@ #include <new> -#include <inttypes.h> - #define dMAKE_JOBINSTANCE_RELEASEE(job_instance) ((dCallReleaseeID)(job_instance)) #define dMAKE_RELEASEE_JOBINSTANCE(releasee) ((dxThreadedJobInfo *)(releasee)) @@ -74,7 +72,7 @@ union { dmutexindex_t m_mutex_count; - uint64_t m_reserved_for_allignment; + unsigned long m_reserved_for_allignment[2]; } m_un; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-07-21 12:17:16
|
Revision: 1898 http://opende.svn.sourceforge.net/opende/?rev=1898&view=rev Author: oleh_derevenko Date: 2012-07-21 12:17:09 +0000 (Sat, 21 Jul 2012) Log Message: ----------- Changed: Generation of precision.h fixed in Premake scripts on Windows Modified Paths: -------------- trunk/build/premake4.lua trunk/include/ode/odeconfig.h trunk/include/ode/precision.h.in trunk/libccd/src/ccd/precision.h.in Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-07-18 10:32:26 UTC (rev 1897) +++ trunk/build/premake4.lua 2012-07-21 12:17:09 UTC (rev 1898) @@ -155,7 +155,7 @@ end -- special validation for Xcode - if _ACTION == "xcode3" and (not _OPTIONS["only-single"] and not _OPTIONS["only-double"]) then + if _ACTION == "xcode3" and (not _OPTIONS["only-static"] and not _OPTIONS["only-shared"]) then error( "Xcode does not support different library types in a single project.\n" .. "Please use one of the flags: --only-static or --only-shared", 0) @@ -212,11 +212,11 @@ configuration { "Release*" } flags { "OptimizeSpeed", "NoFramePointer" } --- configuration { "only-single or *Single*" } --- defines { "dSINGLE", "CCD_SINGLE" } + configuration { "*Single*" } + defines { "dIDESINGLE", "CCD_IDESINGLE" } --- configuration { "only-double or *Double*" } --- defines { "dDOUBLE", "CCD_DOUBLE" } + configuration { "*Double*" } + defines { "dIDEDOUBLE", "CCD_IDEDOUBLE" } configuration { "Windows" } defines { "WIN32" } @@ -421,17 +421,18 @@ outfile:close() end - function generate(precstr) - generateheader("../include/ode/precision.h", "@ODE_PRECISION@", "d" .. precstr) - generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION@", "CCD_" .. precstr) + function generate(directive, precstr) + generateheader("../include/ode/precision.h", "@ODE_PRECISION_DEF@", directive .. " d" .. precstr) + generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION_DEF@", directive .. " CCD_" .. precstr) end if _OPTIONS["only-single"] then - generate("SINGLE") + generate("define", "SINGLE") + elseif _OPTIONS["only-double"] then + generate("define", "DOUBLE") + else + generate("error", "<PRECISION> is undefined") end - if _OPTIONS["only-double"] then - generate("DOUBLE") - end ---------------------------------------------------------------------- -- The DrawStuff library project Modified: trunk/include/ode/odeconfig.h =================================================================== --- trunk/include/ode/odeconfig.h 2012-07-18 10:32:26 UTC (rev 1897) +++ trunk/include/ode/odeconfig.h 2012-07-21 12:17:09 UTC (rev 1898) @@ -114,7 +114,7 @@ #define _ode_copysign(x, y) _copysign(x, y) #define _ode_nextafterf(x, y) _nextafterf(x, y) #define _ode_nextafter(x, y) _nextafter(x, y) - #if !defined(_WIN64) && dSINGLE + #if !defined(_WIN64) && defined(dSINGLE) #define _ODE__NEXTAFTERF_REQUIRED ODE_EXTERN_C float _nextafterf(float x, float y); #endif Modified: trunk/include/ode/precision.h.in =================================================================== --- trunk/include/ode/precision.h.in 2012-07-18 10:32:26 UTC (rev 1897) +++ trunk/include/ode/precision.h.in 2012-07-21 12:17:09 UTC (rev 1898) @@ -5,6 +5,12 @@ * but never both! */ -#define @ODE_PRECISION@ +#if defined(dIDESINGLE) +#define dSINGLE +#elif defined(dIDEDOUBLE) +#define dDOUBLE +#else +#@ODE_PRECISION_DEF@ +#endif #endif Modified: trunk/libccd/src/ccd/precision.h.in =================================================================== --- trunk/libccd/src/ccd/precision.h.in 2012-07-18 10:32:26 UTC (rev 1897) +++ trunk/libccd/src/ccd/precision.h.in 2012-07-21 12:17:09 UTC (rev 1898) @@ -3,6 +3,12 @@ /* define either CCD_SINGLE or CCD_DOUBLE */ -#define @CCD_PRECISION@ +#if defined(CCD_IDESINGLE) +#define CCD_SINGLE +#elif defined(CCD_IDEDOUBLE) +#define CCD_DOUBLE +#else +#@CCD_PRECISION_DEF@ +#endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-07-18 10:32:32
|
Revision: 1897 http://opende.svn.sourceforge.net/opende/?rev=1897&view=rev Author: oleh_derevenko Date: 2012-07-18 10:32:26 +0000 (Wed, 18 Jul 2012) Log Message: ----------- Changed: <time.h> included in threading.h to support environments that do not have time_t defined by default Modified Paths: -------------- trunk/include/ode/threading.h Modified: trunk/include/ode/threading.h =================================================================== --- trunk/include/ode/threading.h 2012-07-18 10:17:44 UTC (rev 1896) +++ trunk/include/ode/threading.h 2012-07-18 10:32:26 UTC (rev 1897) @@ -33,6 +33,8 @@ #define _ODE_THREADING_H_ #include <ode/odeconfig.h> +// Include <time.h> since time_t is used and it is not available by default in some OSes +#include <time.h> #ifdef __cplusplus This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-07-18 10:17:53
|
Revision: 1896 http://opende.svn.sourceforge.net/opende/?rev=1896&view=rev Author: oleh_derevenko Date: 2012-07-18 10:17:44 +0000 (Wed, 18 Jul 2012) Log Message: ----------- Cosmetic: A warning fixed in LLVM compiler Modified Paths: -------------- trunk/ode/src/odeou.cpp Modified: trunk/ode/src/odeou.cpp =================================================================== --- trunk/ode/src/odeou.cpp 2012-07-17 19:04:43 UTC (rev 1895) +++ trunk/ode/src/odeou.cpp 2012-07-18 10:17:44 UTC (rev 1896) @@ -41,12 +41,15 @@ #if dOU_ENABLED +BEGIN_NAMESPACE_OU(); template<> const char *const CEnumUnsortedElementArray<EASSERTIONFAILURESEVERITY, AFS__MAX, const char *>::m_aetElementArray[] = { "assert", // AFS_ASSERT, "check", // AFS_CHECK, }; +END_NAMESPACE_OU(); + static const CEnumUnsortedElementArray<EASSERTIONFAILURESEVERITY, AFS__MAX, const char *> g_aszAssertionFailureSeverityNames; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2012-07-17 19:04:49
|
Revision: 1895 http://opende.svn.sourceforge.net/opende/?rev=1895&view=rev Author: bram Date: 2012-07-17 19:04:43 +0000 (Tue, 17 Jul 2012) Log Message: ----------- format strings should be const Modified Paths: -------------- trunk/include/ode/misc.h trunk/ode/src/mat.cpp trunk/ode/src/mat.h Modified: trunk/include/ode/misc.h =================================================================== --- trunk/include/ode/misc.h 2012-06-09 18:15:15 UTC (rev 1894) +++ trunk/include/ode/misc.h 2012-07-17 19:04:43 UTC (rev 1895) @@ -55,10 +55,10 @@ /* print out a matrix */ #ifdef __cplusplus -ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt = "%10.4f ", +ODE_API void dPrintMatrix (const dReal *A, int n, int m, const char *fmt = "%10.4f ", FILE *f=stdout); #else -ODE_API void dPrintMatrix (const dReal *A, int n, int m, char *fmt, FILE *f); +ODE_API void dPrintMatrix (const dReal *A, int n, int m, const char *fmt, FILE *f); #endif /* make a random vector with entries between +/- range. A has n elements. */ Modified: trunk/ode/src/mat.cpp =================================================================== --- trunk/ode/src/mat.cpp 2012-06-09 18:15:15 UTC (rev 1894) +++ trunk/ode/src/mat.cpp 2012-07-17 19:04:43 UTC (rev 1895) @@ -208,7 +208,7 @@ } -void dMatrix::print (char *fmt, FILE *f) +void dMatrix::print (const char *fmt, FILE *f) { for (int i=0; i<n; i++) { for (int j=0; j<m; j++) fprintf (f,fmt,data[i*m+j]); Modified: trunk/ode/src/mat.h =================================================================== --- trunk/ode/src/mat.h 2012-06-09 18:15:15 UTC (rev 1894) +++ trunk/ode/src/mat.h 2012-07-17 19:04:43 UTC (rev 1895) @@ -63,7 +63,7 @@ void clearUpperTriangle(); void clearLowerTriangle(); void makeRandom (dReal range); - void print (char *fmt = "%10.4f ", FILE *f=stdout); + void print (const char *fmt = "%10.4f ", FILE *f=stdout); dReal maxDifference (const dMatrix &); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-06-09 18:15:21
|
Revision: 1894 http://opende.svn.sourceforge.net/opende/?rev=1894&view=rev Author: danielosmari Date: 2012-06-09 18:15:15 +0000 (Sat, 09 Jun 2012) Log Message: ----------- added missing header templates Added Paths: ----------- trunk/include/ode/precision.h.in trunk/libccd/src/ccd/precision.h.in Added: trunk/include/ode/precision.h.in =================================================================== --- trunk/include/ode/precision.h.in (rev 0) +++ trunk/include/ode/precision.h.in 2012-06-09 18:15:15 UTC (rev 1894) @@ -0,0 +1,10 @@ +#ifndef _ODE_PRECISION_H_ +#define _ODE_PRECISION_H_ + +/* Define dSINGLE for single precision, dDOUBLE for double precision, + * but never both! + */ + +#define @ODE_PRECISION@ + +#endif Added: trunk/libccd/src/ccd/precision.h.in =================================================================== --- trunk/libccd/src/ccd/precision.h.in (rev 0) +++ trunk/libccd/src/ccd/precision.h.in 2012-06-09 18:15:15 UTC (rev 1894) @@ -0,0 +1,8 @@ +#ifndef __CCD_PRECISION_H__ +#define __CCD_PRECISION_H__ + +/* define either CCD_SINGLE or CCD_DOUBLE */ + +#define @CCD_PRECISION@ + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-06-09 03:21:50
|
Revision: 1893 http://opende.svn.sourceforge.net/opende/?rev=1893&view=rev Author: danielosmari Date: 2012-06-09 03:21:44 +0000 (Sat, 09 Jun 2012) Log Message: ----------- update the premake script to generate precision.h headers for ODE and libccd Modified Paths: -------------- trunk/build/premake4.lua Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-06-08 22:29:43 UTC (rev 1892) +++ trunk/build/premake4.lua 2012-06-09 03:21:44 UTC (rev 1893) @@ -150,6 +150,8 @@ os.rmdir(action.trigger) end os.remove("../ode/src/config.h") + os.remove("../include/ode/precision.h") + os.remove("../libccd/src/ccd/precision.h") end -- special validation for Xcode @@ -173,6 +175,7 @@ configs = newconfigs end + if not _OPTIONS["only-single"] and not _OPTIONS["only-double"] then addconfigs("Single", "Double") end @@ -209,11 +212,11 @@ configuration { "Release*" } flags { "OptimizeSpeed", "NoFramePointer" } - configuration { "only-single or *Single*" } - defines { "dSINGLE", "CCD_SINGLE" } +-- configuration { "only-single or *Single*" } +-- defines { "dSINGLE", "CCD_SINGLE" } - configuration { "only-double or *Double*" } - defines { "dDOUBLE", "CCD_DOUBLE" } +-- configuration { "only-double or *Double*" } +-- defines { "dDOUBLE", "CCD_DOUBLE" } configuration { "Windows" } defines { "WIN32" } @@ -372,8 +375,8 @@ ---------------------------------------------------------------------- if _ACTION and _ACTION ~= "clean" then - io.input("config-default.h") - local text = io.read("*a") + local infile = io.open("config-default.h", "r") + local text = infile:read("*a") if _OPTIONS["no-trimesh"] then text = string.gsub(text, "#define dTRIMESH_ENABLED 1", "/* #define dTRIMESH_ENABLED 1 */") @@ -398,11 +401,37 @@ text = string.gsub(text, "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 0", "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 1") end - io.output("../ode/src/config.h") - io.write(text) - io.close() + local outfile = io.open("../ode/src/config.h", "w") + outfile:write(text) + outfile:close() end +---------------------------- +-- Write precision headers +---------------------------- + + function generateheader(headerfile, placeholder, precstr) + local outfile = io.open(headerfile, "w") + for i in io.lines(headerfile .. ".in") + do + local j,_ = string.gsub(i, placeholder, precstr) + --print("writing " .. j .. " into " .. headerfile) + outfile:write(j .. "\n") + end + outfile:close() + end + + function generate(precstr) + generateheader("../include/ode/precision.h", "@ODE_PRECISION@", "d" .. precstr) + generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION@", "CCD_" .. precstr) + end + + if _OPTIONS["only-single"] then + generate("SINGLE") + end + if _OPTIONS["only-double"] then + generate("DOUBLE") + end ---------------------------------------------------------------------- -- The DrawStuff library project @@ -445,7 +474,6 @@ links { "X11", "GL", "GLU" } end - ---------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-06-08 23:17:17
|
Revision: 1892 http://opende.svn.sourceforge.net/opende/?rev=1892&view=rev Author: danielosmari Date: 2012-06-08 22:29:43 +0000 (Fri, 08 Jun 2012) Log Message: ----------- generate include/ode/precision.h to set the precision instead of command-line defines; general code cleanup to get rid of GCC warnings Modified Paths: -------------- trunk/CHANGELOG.txt trunk/GIMPACT/include/GIMPACT/gim_memory.h trunk/GIMPACT/src/gim_boxpruning.cpp trunk/GIMPACT/src/gim_memory.cpp trunk/INSTALL.txt trunk/Makefile.am trunk/OPCODE/Ice/Makefile.am trunk/OPCODE/Makefile.am trunk/OPCODE/OPC_LSSAABBOverlap.h trunk/README.txt trunk/drawstuff/src/Makefile.am trunk/include/drawstuff/Makefile.am trunk/include/drawstuff/drawstuff.h trunk/include/ode/Makefile.am trunk/include/ode/collision.h trunk/include/ode/collision_space.h trunk/include/ode/collision_trimesh.h trunk/include/ode/common.h trunk/include/ode/contact.h trunk/include/ode/mass.h trunk/include/ode/matrix.h trunk/include/ode/objects.h trunk/include/ode/ode.h trunk/include/ode/odeinit.h trunk/include/ode/odemath.h trunk/include/ode/odemath_legacy.h trunk/include/ode/threading.h trunk/include/ode/threading_impl.h trunk/libccd/configure.ac trunk/libccd/src/Makefile.am trunk/libccd/src/alloc.c trunk/libccd/src/ccd/ccd.h trunk/libccd/src/ccd/compiler.h trunk/libccd/src/ccd/simplex.h trunk/libccd/src/ccd/support.h trunk/libccd/src/ccd/vec3.h trunk/libccd/src/ccd.c trunk/libccd/src/mpr.c trunk/libccd/src/polytope.c trunk/libccd/src/support.c trunk/libccd/src/vec3.c trunk/ode/demo/Makefile.am trunk/ode/demo/demo_basket.cpp trunk/ode/demo/demo_chain1.c trunk/ode/demo/demo_convex_cd.cpp trunk/ode/demo/demo_cyl.cpp trunk/ode/demo/demo_cylvssphere.cpp trunk/ode/demo/demo_feedback.cpp trunk/ode/demo/demo_heightfield.cpp trunk/ode/demo/demo_jointPR.cpp trunk/ode/demo/demo_jointPU.cpp trunk/ode/demo/demo_plane2d.cpp trunk/ode/demo/texturepath.h trunk/ode/src/Makefile.am trunk/ode/src/collision_cylinder_trimesh.cpp trunk/ode/src/collision_kernel.h trunk/ode/src/collision_sapspace.cpp trunk/ode/src/collision_trimesh_internal.h trunk/ode/src/collision_trimesh_trimesh_new.cpp trunk/ode/src/fastltsolve.c trunk/ode/src/heightfield.h trunk/ode/src/joints/Makefile.am trunk/ode/src/joints/plane2d.cpp trunk/ode/src/nextafterf.c trunk/ode/src/objects.h trunk/ode/src/odeinit.cpp trunk/ode/src/threading_impl_templates.h trunk/ode/src/util.cpp trunk/ode/src/util.h trunk/ode-config.in trunk/ode.pc.in Added Paths: ----------- trunk/bootstrap trunk/configure.ac Removed Paths: ------------- trunk/autogen.sh trunk/configure.in Property Changed: ---------------- trunk/ode/demo/demo_basket.cpp trunk/ode/demo/demo_convex_cd.cpp trunk/ode/demo/demo_cylvssphere.cpp trunk/ode/demo/demo_feedback.cpp trunk/ode/demo/demo_heightfield.cpp trunk/ode/demo/demo_jointPR.cpp trunk/ode/demo/demo_moving_convex.cpp trunk/ode/demo/demo_plane2d.cpp trunk/ode/demo/texturepath.h Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/CHANGELOG.txt 2012-06-08 22:29:43 UTC (rev 1892) @@ -8,6 +8,11 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +06/08/12 Daniel K. O. + * Removed the need for defining dSINGLE/dDOUBLE; this is stored now in + the generated ode/precision.h header. + * Some code cleanup to get rid of GCC warnings. + 05/30/12 Daniel K. O. * Made drawstuff draw shadows for lines. * Fixed dhinge's last constraint to properly handle rotations. Modified: trunk/GIMPACT/include/GIMPACT/gim_memory.h =================================================================== --- trunk/GIMPACT/include/GIMPACT/gim_memory.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/GIMPACT/include/GIMPACT/gim_memory.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -408,7 +408,7 @@ G_BUFFER_MANAGER_SYSTEM, G_BUFFER_MANAGER_SHARED, - G_BUFFER_MANAGER__MAX, + G_BUFFER_MANAGER__MAX }; //! @} Modified: trunk/GIMPACT/src/gim_boxpruning.cpp =================================================================== --- trunk/GIMPACT/src/gim_boxpruning.cpp 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/GIMPACT/src/gim_boxpruning.cpp 2012-06-08 22:29:43 UTC (rev 1892) @@ -515,4 +515,5 @@ GIM_DYNARRAY_PUSH_ITEM(GUINT32,(*collided),i); } } + (void)tparam; } Modified: trunk/GIMPACT/src/gim_memory.cpp =================================================================== --- trunk/GIMPACT/src/gim_memory.cpp 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/GIMPACT/src/gim_memory.cpp 2012-06-08 22:29:43 UTC (rev 1892) @@ -254,10 +254,12 @@ return (GPTR)pdata; } +#if 0 static GPTR _shared_buffer_realloc_function(GPTR buffer_handle,GUINT32 oldsize,int old_usage,GUINT32 newsize,int new_usage) { return 0; } +#endif static void _shared_buffer_free_function(GPTR buffer_handle,GUINT32 size) { Modified: trunk/INSTALL.txt =================================================================== --- trunk/INSTALL.txt 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/INSTALL.txt 2012-06-08 22:29:43 UTC (rev 1892) @@ -6,8 +6,11 @@ 3. Building with Code::Blocks 4. Building with Something Else + + 1. BUILDING WITH VISUAL STUDIO (2002 and up) +============================================ If you downloaded this source code from Subversion you must first use the Premake build system to generate project files. @@ -24,13 +27,20 @@ Note that Visual Studio 6 is not supported and users are advised to upgrade to at least Visual Studio 2005 Express (it's free!) + + + 2. BUILDING WITH AUTOTOOLS (Linux, OS X, MSYS, etc.) +==================================================== +2.1 FROM SUBVERSION REPOSITORY +------------------------------ + If you downloaded the source code from Subversion you must bootstrap the process by running the command: - $ sh autogen.sh + $ ./bootstrap For this command to work you need a set of tools typically available on BSD and Linux distributions with development packages installed. OS X @@ -42,25 +52,31 @@ warnings depending on your platform, these are (for now) harmless warnings regarding scripts from other m4 installed packages. - Run the configure script to autodetect your build environment. +2.2 FROM A RELEASED TARBALL +--------------------------- + + First extract the archive (e.g. tar xvfz <filename.tar.gz>) and enter + the created directory (ode-x.y). + + Run the configure script to autodetect your build environment: $ ./configure By default this will build ODE as a static library with single-precision - math, trimesh support, and debug symbols enabled. You can modify these - defaults by passing additional parameters to configure. For a full list - of available options, type + math, trimesh support with OPCODE, and debug symbols enabled. You can + modify these defaults by passing additional parameters to + configure. For a full list of available options, type: $ ./configure --help Some of the more popular options are - --enable-double-precision enable double-precision math - --with-trimesh=none disables the trimesh support - --with-trimesh=opcode use OPCODE for trimesh code - --with-trimesh=gimpact use GIMPACT for trimesh code + --enable-double-precision enable double-precision math + --with-trimesh=none disables the trimesh support + --with-trimesh=opcode use OPCODE for trimesh code + --with-trimesh=gimpact use GIMPACT for trimesh code - --enabled-shared builds a shared library + --enabled-shared builds a shared library To pass specific flags for an optimized build, you must do so in the CFLAGS and CXXFLAGS enviroment variables, or as arguments @@ -82,7 +98,11 @@ compilation and linking flags for programs. The old stand-alone "ode-config" script is also installed for compatibility. + + + 3. BUILDING WITH Code::Blocks +============================= Because Code::Blocks supports so many different platforms, we do not provide workspaces. Instead, use Premake to create a workspace tailored @@ -95,17 +115,17 @@ $ cd build $ premake4 --help - - + + + + 4. BUILDING WITH SOMETHING ELSE +=============================== ODE uses the Premake tool to provide support for several different toolsets. Premake adds support for new toolsets on a regular basis, so yours might be supported. Check the Premake website at http://premake.sourceforge.net/, and then follow the directions for Code::Blocks above, substituting your toolset target in place of `codeblocks`. - - - Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/Makefile.am 2012-06-08 22:29:43 UTC (rev 1892) @@ -36,7 +36,7 @@ release: dist-gzip dist-bzip2 @echo Created release packages for ${PACKAGE}-${VERSION}. -EXTRA_DIST = autogen.sh build tools \ +EXTRA_DIST = bootstrap build tools \ CHANGELOG.txt INSTALL.txt README.txt LICENSE.TXT \ bindings Modified: trunk/OPCODE/Ice/Makefile.am =================================================================== --- trunk/OPCODE/Ice/Makefile.am 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/OPCODE/Ice/Makefile.am 2012-06-08 22:29:43 UTC (rev 1892) @@ -1,4 +1,6 @@ -AM_CPPFLAGS = -I $(top_srcdir)/OPCODE -I $(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/OPCODE \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include noinst_LTLIBRARIES = libIce.la libIce_la_SOURCES = \ Modified: trunk/OPCODE/Makefile.am =================================================================== --- trunk/OPCODE/Makefile.am 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/OPCODE/Makefile.am 2012-06-08 22:29:43 UTC (rev 1892) @@ -1,7 +1,8 @@ SUBDIRS = Ice noinst_LTLIBRARIES = libOPCODE.la -AM_CPPFLAGS= -fno-strict-aliasing -I$(top_srcdir)/include +AM_CPPFLAGS= -I$(top_srcdir)/include \ + -I$(top_builddir)/include libOPCODE_la_SOURCES = OPC_AABBCollider.cpp OPC_AABBCollider.h \ OPC_AABBTree.cpp OPC_AABBTree.h \ Modified: trunk/OPCODE/OPC_LSSAABBOverlap.h =================================================================== --- trunk/OPCODE/OPC_LSSAABBOverlap.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/OPCODE/OPC_LSSAABBOverlap.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -448,6 +448,7 @@ Point kPnt = kDiff; Point kDir = rkLine.mDir; +#if 0 // Apply reflections so that direction vector has nonnegative components. bool bReflect[3]; for(int i=0;i<3;i++) @@ -463,6 +464,7 @@ bReflect[i] = false; } } +#endif float fSqrDistance = 0.0f; Modified: trunk/README.txt =================================================================== --- trunk/README.txt 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/README.txt 2012-06-08 22:29:43 UTC (rev 1892) @@ -22,7 +22,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files LICENSE.TXT and LICENSE-BSD.TXT for more details. - * Installation instructions are in the INSTALL file + * Installation instructions are in the INSTALL.txt file * The ODE web pages are at http://ode.org/ Deleted: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/autogen.sh 2012-06-08 22:29:43 UTC (rev 1892) @@ -1,58 +0,0 @@ -#!/bin/sh - -# The version nr detection is not working. -# It fails if there is a '-' char in the version nr e.g. -# We should not use it until fixed. - Bram - -## The reason this uses sed instead of "grep --only-matches" -## is because MinGW's grep is an old version and does not contain that flag. -#automake_version=`automake --version | grep --regexp='[+0-9].[+0-9].[+0-9]' | sed -n 's/[* ()A-Za-z]//g;p'` -#automake_mayor=${automake_version%.*.*} -#automake_minor=${automake_version%.*} -#automake_minor=${automake_minor##*.} -#automake_revision=${automake_version##*.} -#echo "AutoMake Version: $automake_mayor.$automake_minor.$automake_revision" -# -#if [ $automake_mayor -eq 1 ]; then -# if [ $automake_minor -lt 8 ]; then -# echo "Automake must be 1.8.2 or higher, please upgrade" -# exit -# else -# if [ $automake_minor -eq 8 ] && [ $automake_revision -lt 2 ]; then -# echo "Automake must be 1.8.2 or higher, please upgrade" -# exit -# fi -# fi -#fi - -echo "Please make sure that you use automake 1.11 or later" -echo "On OSX, install latest libtool, as the OS provided glibtoolize will not work" -echo "Warnings about underquoted definitions are harmless" - -echo "Running aclocal" -aclocal -I m4 --install || exit 1 -# on Mac libtoolize is called glibtoolize -LIBTOOLIZE=libtoolize -#if [ `uname -s` = Darwin ]; then -# LIBTOOLIZE=glibtoolize -#fi -echo "Running $LIBTOOLIZE" -$LIBTOOLIZE --copy --automake || exit 1 -echo "Running autoheader" -autoheader || exit 1 -echo "Running automake" -automake --foreign --add-missing --copy || exit 1 -echo "Running autoconf" -autoconf || exit 1 - -echo "Running bootstrap in ou directory" -(cd ou && ./bootstrap) - -#./configure $* - -if [ -d libccd ]; then - echo "Running bootstrap in libccd directory" - (cd libccd && ./bootstrap) -fi; - -echo "Now you are ready to run ./configure" Copied: trunk/bootstrap (from rev 1891, trunk/autogen.sh) =================================================================== --- trunk/bootstrap (rev 0) +++ trunk/bootstrap 2012-06-08 22:29:43 UTC (rev 1892) @@ -0,0 +1,33 @@ +#!/bin/sh + +echo "Please make sure that you use automake 1.11 or later" + echo "Warnings about underquoted definitions are harmless" +if [ `uname -s` = Darwin ]; then + echo "On OSX, install latest libtool, as the OS provided glibtoolize will not work" +fi + +echo "Running aclocal" +aclocal -I m4 --install || exit 1 +# on Mac libtoolize is called glibtoolize +LIBTOOLIZE=libtoolize +#if [ `uname -s` = Darwin ]; then +# LIBTOOLIZE=glibtoolize +#fi +echo "Running $LIBTOOLIZE" +$LIBTOOLIZE --copy --automake || exit 1 +echo "Running autoheader" +autoheader || exit 1 +echo "Running automake" +automake --foreign --add-missing --copy || exit 1 +echo "Running autoconf" +autoconf || exit 1 + +echo "Running bootstrap in ou directory" +(cd ou && ./bootstrap) + +if [ -d libccd ]; then + echo "Running bootstrap in libccd directory" + (cd libccd && ./bootstrap) +fi; + +echo "Now you are ready to run ./configure" Copied: trunk/configure.ac (from rev 1891, trunk/configure.in) =================================================================== --- trunk/configure.ac (rev 0) +++ trunk/configure.ac 2012-06-08 22:29:43 UTC (rev 1892) @@ -0,0 +1,545 @@ +dnl AC_INIT does not take a macro as a version nr: set it separately! - Bram +AC_INIT([ODE],[0.12],[od...@od...]) +ODE_VERSION=0.12 +AC_SUBST(ODE_VERSION) + +# Those are instructions from the Libtool manual: +# 1. Start with version information of `0:0:0' for each libtool library. +# +# 2. Update the version information only immediately before a public +# release of your software. More frequent updates are unnecessary, +# and only guarantee that the current interface number gets larger +# faster. +# +# 3. If the library source code has changed at all since the last +# update, then increment REVISION (`C:R:A' becomes `C:r+1:A'). +# +# 4. If any interfaces have been added, removed, or changed since the +# last update, increment CURRENT, and set REVISION to 0. +# +# 5. If any interfaces have been added since the last public release, +# then increment AGE. +# +# 6. If any interfaces have been removed since the last public release, +# then set AGE to 0. +CURRENT=3 +REVISION=0 +AGE=0 + +AC_ARG_ENABLE(version-info, + AS_HELP_STRING([--disable-version-info], + [don't encode version information in the generated library]), + version_info=$enableval, + version_info=yes) +if test x$version_info = xyes +then + ODE_VERSION_INFO="-version-info $CURRENT:$REVISION:$AGE" +else + ODE_VERSION_INFO="-avoid-version" +fi +AC_SUBST(ODE_VERSION_INFO) + + +AC_CONFIG_SRCDIR([ode/src/ode.cpp]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_CANONICAL_HOST + +AM_INIT_AUTOMAKE(1.10 foreign) +AC_CONFIG_HEADERS([ode/src/config.h]) + +dnl This is needed because we have subdirectories +AC_PROG_MAKE_SET +AC_PROG_CXX +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_CPP +AC_PROG_AWK +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MKDIR_P +AC_DISABLE_SHARED +LT_INIT([disable-shared win32-dll]) +AC_CHECK_TOOLS([WINDRES], [windres]) + +AC_C_BIGENDIAN +AC_C_INLINE +AC_C_VOLATILE +PKG_PROG_PKG_CONFIG + + +dnl this may NOT be the machine on which the code is going to run in, +dnl so allow users to compile programs for their target machine. +pentium=no +cpu64=no +case "$host_cpu" in + i586 | i686 | i786 ) + pentium=yes + AC_DEFINE(PENTIUM,1,[compiling for a pentium on a gcc-based platform?]) + ;; + x86_64* ) + pentium=yes + cpu64=yes + AC_DEFINE(X86_64_SYSTEM,1,[compiling for a X86_64 system on a gcc-based platform?]) + ;; +esac + +AM_CONDITIONAL(X86_64_SYSTEM, test x$cpu64 = xyes) + + + + + + +dnl check for required headers +AC_CHECK_HEADERS( [alloca.h stdio.h inttypes.h stdint.h stdlib.h math.h \ + string.h stdarg.h malloc.h float.h time.h sys/time.h \ + limits.h stddef.h]) + + +opcode=no +gimpact=no +AC_ARG_WITH(trimesh, AS_HELP_STRING([--with-trimesh=[opcode|gimpact|none]], + [use the specified system for trimesh support @<:@default=opcode@:>@]), + trimesh=$withval,trimesh=opcode +) +if test "$trimesh" = opcode +then + opcode=yes +fi +if test "$trimesh" = gimpact +then + gimpact=yes +fi + +AM_CONDITIONAL(OPCODE, test $opcode = yes) +AM_CONDITIONAL(GIMPACT, test $gimpact = yes) +AM_CONDITIONAL(TRIMESH, test $opcode = yes -o $gimpact = yes) + + +AC_MSG_CHECKING(if double precision is requested) +AC_ARG_ENABLE(double-precision, + AS_HELP_STRING([--enable-double-precision], + [Configure ODE to work with double precision, if not specified, single precision is used @<:@default=no@:>@]), + usedouble=$enableval,usedouble=no) +AC_MSG_RESULT([$usedouble]) +if test "$usedouble" = yes; +then + ODE_PRECISION=dDOUBLE +else + ODE_PRECISION=dSINGLE +fi +AC_SUBST(ODE_PRECISION) + + +AC_ARG_WITH([drawstuff], + AS_HELP_STRING([--with-drawstuff=X11|Win32|OSX|none], + [force a particular drawstuff implementation or disable it.[default=autodetect]]), + [drawstuff=$withval],[drawstuff=]) + +dnl Set some Platform Specific Variables +EXTRA_LIBTOOL_LDFLAGS= +case "$host_os" in + cygwin* | mingw*) + if test "x$drawstuff" = x + then + drawstuff="Win32" # if in a Windows enviroment + fi + EXTRA_LIBTOOL_LDFLAGS="-no-undefined" + ;; + *apple* | *darwin*) # For Mac OS X + if test "x$drawstuff" = x + then + drawstuff="OSX" + fi + dnl We need to use C++ compilation and linking for ode on Mac + dnl Might as well do it for all code. + CC="$CXX" + LINK="$CXXLINK" + ;; + *) + if test "x$drawstuff" = x + then + drawstuff="X11" # if anything else default to X11 + fi + ;; +esac +AC_SUBST(EXTRA_LIBTOOL_LDFLAGS) + + +dnl Set Drawstuff variables +AC_MSG_CHECKING([which drawstuff lib to build]) +AC_MSG_RESULT($drawstuff) + +if test "x$drawstuff" = "xX11" +then + # The built-in macro, X_PATH, causes too many problems, these days everyone uses Xorg, + # so we can ask pkg-config to find it for us. + PKG_CHECK_MODULES(X11, x11, [], [drawstuff="none"]) +fi + +dnl Check for OpenGL +if test "x$drawstuff" = "xOSX"; then + AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1], + [Use the Apple OpenGL framework.]) + GL_LIBS="-framework OpenGL -framework GLUT" +elif test "x$drawstuff" != "xnone"; then + have_gl_headers=yes + AC_CHECK_HEADERS(GL/gl.h GL/glu.h GL/glext.h, , + [have_gl_headers=no], + [[#ifdef WIN32 + #include <windows.h> + #endif + #if HAVE_GL_GL_H + #include <GL/gl.h> + #endif + #if HAVE_GL_GLU_H + #include <GL/glu.h> + #endif + ]]) + have_gl=no + have_glu=no + TEMP_LDFLAGS="$LDFLAGS" + AC_CHECK_LIB(GL, main, [GL_LIBS="-lGL"; have_gl=yes]) + AC_CHECK_LIB(GLU, main, [GL_LIBS="-lGLU $GL_LIBS"; have_glu=yes], , -lGL) + AC_CHECK_LIB(opengl32, main, [GL_LIBS="-lopengl32"; have_gl=yes]) + AC_CHECK_LIB(glu32, main, [GL_LIBS="-lglu32 $GL_LIBS"; have_glu=yes], , -lopengl32) + LDFLAGS="$TEMP_LDFLAGS" + if test $have_gl = no -o $have_glu = no -o $have_gl_headers = no; then + drawstuff="none" + fi +fi +AC_SUBST(GL_LIBS) + +dnl Set Conditionals +AM_CONDITIONAL(WIN32, test x$drawstuff = xWin32) +AM_CONDITIONAL(X11, test x$drawstuff = xX11) +AM_CONDITIONAL(OSX, test x$drawstuff = xOSX) +AM_CONDITIONAL(ENABLE_DRAWSTUFF, test x$drawstuff != xnone) + +dnl Check if we want to build demos +AC_MSG_CHECKING(if demos should be built) +AC_ARG_ENABLE(demos, + AS_HELP_STRING([--disable-demos], [don't build demos]), + enable_demos=$enableval,enable_demos=yes) +if test x$drawstuff = xnone -a x$enable_demos = xyes ; then + enable_demos=no + AC_MSG_RESULT($enable_demos) + AC_MSG_WARN([Demos will not be built because OpenGL doesn't seem to work. See `config.log' for details.]) +else + AC_MSG_RESULT($enable_demos) +fi + + +dnl stdc++ is required when linking C programs against ode +AC_CHECK_LIB(stdc++,main,[LIBSTDCXX="-lstdc++"],[LIBSTDCXX=]) +AC_SUBST(LIBSTDCXX) +AC_CHECK_LIB(pthread,main,[LIBS="$LIBS -lpthread"]) + + +dnl test if we will build demos +AM_CONDITIONAL(ENABLE_DEMOS, test x$enable_demos = xyes) + + +dnl Check if the user wants the old timesh collider +old_trimesh=no +AC_ARG_ENABLE([old-trimesh], AS_HELP_STRING([--enable-old-trimesh],[enable use of the old trimesh collider]), + [old_trimesh=$enableval] + ) +if test x$old_trimesh = xyes -a $trimesh = opcode; then + AC_DEFINE(dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER, 1, + [Use the old trimesh-trimesh collider]) +else + old_trimesh=no +fi + + +dnl Check if the user wants to profile ODE using gprof +AC_MSG_CHECKING(for gprof) +AC_ARG_ENABLE([gprof], + AS_HELP_STRING([--enable-gprof],[enable profiling with gprof]), + gprof=$enableval, + gprof=no) +if test "$gprof" != no +then + CFLAGS="-pg $CFLAGS" + CXXFLAGS="-pg $CXXFLAGS" + AC_MSG_RESULT(enabled) + AC_CHECK_LIB(gmon, main,[LIBS="$LIBS -lgmon"]) +else + AC_MSG_RESULT(no) +fi + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_INT32_T +AC_FUNC_OBSTACK +AC_TYPE_SIZE_T +AC_TYPE_UINT32_T + +dnl Check for autoscan sugested functions +AC_CHECK_LIB(m, [main]) +AC_CHECK_LIB(sunmath, [main]) +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([ou], + AS_HELP_STRING([--enable-ou], + [use TLS for global caches (allows threaded collision checks for separated spaces)] + ), + use_ou_tls=$enableval,use_ou_tls=no) +if test x$use_ou = xyes +then + OU_NAMESPACE=odeou + AC_CONFIG_COMMANDS_POST([export OU_NAMESPACE=odeou]) + AC_DEFINE([_OU_NAMESPACE],[odeou],[libou namespace for ODE]) + AC_DEFINE([dOU_ENABLED],[1],[Generic OU features are enabled]) + AC_DEFINE([dATOMICS_ENABLED],[1],[Atomic API of OU is enabled]) + if test x$use_ou_tls = xyes + then + AC_DEFINE([dTLS_ENABLED],[1],[Thread Local Storage API of OU is enabled]) + fi + + case "$host_os" in + cygwin* | mingw*) + targetos=_OU_TARGET_OS_WINDOWS + ;; + *qnx*) + targetos=_OU_TARGET_OS_QNX + ;; + *apple* | *darwin*) + targetos=_OU_TARGET_OS_MAC + ;; + *sunos*) + targetos=_OU_TARGET_OS_SUNOS + ;; + *aix*) + targetos=_OU_TARGET_OS_AIX + ;; + *) + targetos=_OU_TARGET_OS_GENUNIX + ;; + esac + + if test $targetos = _OU_TARGET_OS_MAC + then + MAC_OS_X_VERSION=1000 + AC_CHECK_FUNC([OSAtomicAdd32Barrier], [MAC_OS_X_VERSION=1040]) + AC_CHECK_FUNC([OSAtomicAnd32OrigBarrier], [MAC_OS_X_VERSION=1050]) + AC_DEFINE_UNQUOTED(MAC_OS_X_VERSION, $MAC_OS_X_VERSION, [Mac OS X version setting for OU Library]) + fi + + if test $targetos = _OU_TARGET_OS_SUNOS + then + AC_CHECK_FUNC(atomic_inc_32_nv, [], + [targetos=_OU_TARGET_OS_GENUNIX]) + fi + + AC_DEFINE_UNQUOTED(_OU_TARGET_OS, $targetos, [Target OS setting for OU Library]) +fi +AC_CONFIG_SUBDIRS([ou]) +AM_CONDITIONAL(ENABLE_OU, test x$use_ou = xyes) + +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]) +fi + +col_cylinder_cylinder=none +col_box_cylinder=default +col_capsule_cylinder=none +col_convex_box=none +col_convex_capsule=none +col_convex_cylinder=none +col_convex_sphere=default +col_convex_convex=default + + +libccd=no +libccd_all=no +AC_ARG_ENABLE(libccd, AS_HELP_STRING([--enable-libccd], + [enable all libccd colliders (except box-cylinder)]), + libccd_all=$enableval) +if test x$libccd_all = xyes +then + col_cylinder_cylinder=libccd + col_capsule_cylinder=libccd + col_convex_box=libccd + col_convex_capsule=libccd + col_convex_cylinder=libccd + col_convex_sphere=libccd + col_convex_convex=libccd + libccd=yes +fi + + +AC_ARG_WITH([cylinder-cylinder], AS_HELP_STRING([--with-cylinder-cylinder=@<:@none,libccd@:>@], [use specific collider for cylinder-cylinder]), + col_cylinder_cylinder=$withval) + +AC_ARG_WITH([box-cylinder], + AS_HELP_STRING([--with-box-cylinder=@<:@default,libccd@:>@], [use specific collider for box-cylinder]), + col_box_cylinder=$withval) + +AC_ARG_WITH([capsule-cylinder], AS_HELP_STRING([--with-capsule-cylinder=@<:@none,libccd@:>@], [use specific collider for capsule-cylinder]), + col_capsule_cylinder=$withval) + +AC_ARG_WITH([convex-box], AS_HELP_STRING([--with-convex-box=@<:@none,libccd@:>@], [use specific collider for convex-box]), + col_convex_box=$withval) + +AC_ARG_WITH([convex-capsule], AS_HELP_STRING([--with-convex-capsule=@<:@none,libccd@:>@], [use specific collider for convex-capsule]), + col_convex_capsule=$withval) + +AC_ARG_WITH([convex-cylinder], AS_HELP_STRING([--with-convex-cylinder=@<:@none,libccd@:>@], [use specific collider for convex-cylinder]), + col_convex_cylinder=$withval) + +AC_ARG_WITH([convex-sphere], AS_HELP_STRING([--with-convex-sphere=@<:@default,libccd@:>@], [use specific collider for convex-sphere]), + col_convex_sphere=$withval) + +AC_ARG_WITH([convex-convex], AS_HELP_STRING([--with-convex-convex=@<:@default,libccd@:>@], [use specific collider for convex-convex]), + col_convex_convex=$withval) + +if test x$col_cylinder_cylinder = xlibccd -o \ + x$col_box_cylinder = xlibccd -o \ + x$col_capsule_cylinder = xlibccd -o \ + x$col_convex_box = xlibccd -o \ + x$col_convex_capsule = libccd -o \ + x$col_convex_cylinder = xlibccd -o \ + x$col_convex_sphere = libccd -o \ + x$col_convex_convex = libccd +then + libccd=yes +fi + +AC_CONFIG_SUBDIRS([libccd]) + +AM_CONDITIONAL(LIBCCD, test x$libccd != xno) +AM_CONDITIONAL(LIBCCD_BOX_CYL, test x$col_box_cylinder = xlibccd) +AM_CONDITIONAL(LIBCCD_CYL_CYL, test x$col_cylinder_cylinder = xlibccd) +AM_CONDITIONAL(LIBCCD_CAP_CYL, test x$col_capsule_cylinder = xlibccd) +AM_CONDITIONAL(LIBCCD_CONVEX_BOX, test x$col_convex_box = xlibccd) +AM_CONDITIONAL(LIBCCD_CONVEX_CAP, test x$col_convex_capsule = xlibccd) +AM_CONDITIONAL(LIBCCD_CONVEX_CYL, test x$col_convex_cylinder = xlibccd) +AM_CONDITIONAL(LIBCCD_CONVEX_SPHERE, test x$col_convex_sphere = xlibccd) +AM_CONDITIONAL(LIBCCD_CONVEX_CONVEX, test x$col_convex_convex = xlibccd) + + + +AC_ARG_ENABLE([asserts], + AS_HELP_STRING([--disable-asserts], + [disables debug error checking]), + asserts=$enableval,asserts=yes) +if test x$asserts = xno +then + CPPFLAGS="$CPPFLAGS -DdNODEBUG" + if test x$use_ou = xyes + then + CPPFLAGS="$CPPFLAGS -DNDEBUG" + fi +fi + + +dnl include found system headers into config.h +AH_TOP([ +#ifndef ODE_CONFIG_H +#define ODE_CONFIG_H +]) +AH_BOTTOM([ + +#ifdef HAVE_ALLOCA_H +#include <alloca.h> +#endif +#ifdef HAVE_MALLOC_H +#include <malloc.h> +#endif +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +/* an integer type that we can safely cast a pointer to and + * from without loss of bits. + */ +typedef uintptr_t intP; + + +#ifdef dSINGLE + #define dEpsilon FLT_EPSILON +#else + #define dEpsilon DBL_EPSILON +#endif + + +#endif /* #define ODE_CONFIG_H */ +]) + +dnl Finally write our Makefiles +AC_CONFIG_FILES([ + Makefile + drawstuff/Makefile + drawstuff/src/Makefile + drawstuff/dstest/Makefile + include/Makefile + include/drawstuff/Makefile + include/ode/Makefile + include/ode/precision.h + ode/Makefile + ode/src/Makefile + ode/src/joints/Makefile + ode/demo/Makefile + OPCODE/Makefile + OPCODE/Ice/Makefile + GIMPACT/Makefile + GIMPACT/include/Makefile + GIMPACT/include/GIMPACT/Makefile + GIMPACT/src/Makefile + tests/Makefile + tests/UnitTest++/Makefile + tests/UnitTest++/src/Makefile + tests/UnitTest++/src/Posix/Makefile + tests/UnitTest++/src/Win32/Makefile + ode-config + ode.pc + ]) +AC_OUTPUT + +chmod +x ode-config + +BUILDDIR=`pwd` + +dnl Print some useful information +echo "Configuration:" +echo " Build system type: $build" +echo " Host system type: $host" +echo " Use double precision: $usedouble" +echo " Use drawstuff: $drawstuff" +echo " Demos enabled: $enable_demos" +echo " Use OPCODE: $opcode" +echo " Use GIMPACT: $gimpact" +echo " Custom colliders:" +echo " cylinder-cylinder: $col_cylinder_cylinder" +echo " box-cylinder: $col_box_cylinder" +echo " capsule-cylinder: $col_capsule_cylinder" +echo " convex-box: $col_convex_box" +echo " convex-capsule: $col_convex_capsule" +echo " convex-cylinder: $col_convex_cylinder" +echo " convex-sphere: $col_convex_sphere" +echo " convex-convex: $col_convex_convex" +echo " Is target a Pentium: $pentium" +echo " Is target x86-64: $cpu64" +echo " Use old opcode trimesh collider: $old_trimesh" +echo " TLS for global caches: $use_ou_tls" +echo " Built-in threading included: $use_builtin_threading_impl" +echo " Enable debug error check: $asserts" +echo " Headers will be installed in $includedir/ode" +echo " Libraries will be installed in $libdir" +echo " Building in directory $BUILDDIR" + Deleted: trunk/configure.in =================================================================== --- trunk/configure.in 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/configure.in 2012-06-08 22:29:43 UTC (rev 1892) @@ -1,547 +0,0 @@ -dnl AC_INIT does not take a macro as a version nr: set it separately! - Bram -AC_INIT([ODE],[0.12],[od...@od...]) -ODE_RELEASE=0.12 -AC_SUBST(ODE_RELEASE) - -# Those are instructions from the Libtool manual: -# 1. Start with version information of `0:0:0' for each libtool library. -# -# 2. Update the version information only immediately before a public -# release of your software. More frequent updates are unnecessary, -# and only guarantee that the current interface number gets larger -# faster. -# -# 3. If the library source code has changed at all since the last -# update, then increment REVISION (`C:R:A' becomes `C:r+1:A'). -# -# 4. If any interfaces have been added, removed, or changed since the -# last update, increment CURRENT, and set REVISION to 0. -# -# 5. If any interfaces have been added since the last public release, -# then increment AGE. -# -# 6. If any interfaces have been removed since the last public release, -# then set AGE to 0. -CURRENT=3 -REVISION=0 -AGE=0 - -AC_ARG_ENABLE(version-info, - AS_HELP_STRING([--disable-version-info], - [don't encode version information in the generated library]), - version_info=$enableval, - version_info=yes) -if test x$version_info = xyes -then - ODE_VERSION_INFO="-version-info $CURRENT:$REVISION:$AGE" -else - ODE_VERSION_INFO="-avoid-version" -fi -AC_SUBST(ODE_VERSION_INFO) - - -AC_CONFIG_SRCDIR([ode/src/ode.cpp]) -AC_CONFIG_MACRO_DIR([m4]) - -AC_CANONICAL_HOST - -AM_INIT_AUTOMAKE(1.10 foreign) -AC_CONFIG_HEADERS([ode/src/config.h]) - -dnl This is needed because we have subdirectories -AC_PROG_MAKE_SET -AC_PROG_CXX -AC_PROG_CC -AM_PROG_CC_C_O -AC_PROG_CPP -AC_PROG_AWK -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MKDIR_P -AC_DISABLE_SHARED -LT_INIT([disable-shared win32-dll]) -AC_CHECK_TOOLS([WINDRES], [windres]) - -AC_C_BIGENDIAN -AC_C_INLINE -AC_C_VOLATILE -PKG_PROG_PKG_CONFIG - - -dnl this may NOT be the machine on which the code is going to run in, -dnl so allow users to compile programs for their target machine. -pentium=no -cpu64=no -case "$host_cpu" in - i586 | i686 | i786 ) - pentium=yes - AC_DEFINE(PENTIUM,1,[compiling for a pentium on a gcc-based platform?]) - ;; - x86_64* ) - pentium=yes - cpu64=yes - AC_DEFINE(X86_64_SYSTEM,1,[compiling for a X86_64 system on a gcc-based platform?]) - ;; -esac - -AM_CONDITIONAL(X86_64_SYSTEM, test x$cpu64 = xyes) - - - - - - -dnl check for required headers -AC_CHECK_HEADERS( [alloca.h stdio.h inttypes.h stdint.h stdlib.h math.h \ - string.h stdarg.h malloc.h float.h time.h sys/time.h \ - limits.h stddef.h]) - - -opcode=no -gimpact=no -AC_ARG_WITH(trimesh, AS_HELP_STRING([--with-trimesh=[opcode|gimpact|none]], - [use the specified system for trimesh support @<:@default=opcode@:>@]), - trimesh=$withval,trimesh=opcode -) -if test "$trimesh" = opcode -then - opcode=yes -fi -if test "$trimesh" = gimpact -then - gimpact=yes -fi - -AM_CONDITIONAL(OPCODE, test $opcode = yes) -AM_CONDITIONAL(GIMPACT, test $gimpact = yes) -AM_CONDITIONAL(TRIMESH, test $opcode = yes -o $gimpact = yes) - - -AC_MSG_CHECKING(if double precision is requested) -AC_ARG_ENABLE(double-precision, - AS_HELP_STRING([--enable-double-precision], - [Configure ODE to work with double precision, if not specified, single precision is used] - ), - precision=$enableval,precision=no) -AC_MSG_RESULT([$precision]) -if test "$precision" = yes; -then - ODE_PRECISION=-DdDOUBLE -else - ODE_PRECISION=-DdSINGLE -fi - -CPPFLAGS="$CPPFLAGS $ODE_PRECISION" -AC_SUBST(ODE_PRECISION) - - -AC_ARG_WITH([drawstuff], - AS_HELP_STRING([--with-drawstuff=X11|Win32|OSX|none], - [force a particular drawstuff implementation or disable it.[default=autodetect]]), - [drawstuff=$withval],[drawstuff=]) - -dnl Set some Platform Specific Variables -EXTRA_LIBTOOL_LDFLAGS= -case "$host_os" in - cygwin* | mingw*) - if test "x$drawstuff" = x - then - drawstuff="Win32" # if in a Windows enviroment - fi - EXTRA_LIBTOOL_LDFLAGS="-no-undefined" - ;; - *apple* | *darwin*) # For Mac OS X - if test "x$drawstuff" = x - then - drawstuff="OSX" - fi - dnl We need to use C++ compilation and linking for ode on Mac - dnl Might as well do it for all code. - CC="$CXX" - LINK="$CXXLINK" - ;; - *) - if test "x$drawstuff" = x - then - drawstuff="X11" # if anything else default to X11 - fi - ;; -esac -AC_SUBST(EXTRA_LIBTOOL_LDFLAGS) - - -dnl Set Drawstuff variables -AC_MSG_CHECKING([which drawstuff lib to build]) -AC_MSG_RESULT($drawstuff) - -if test "x$drawstuff" = "xX11" -then - # The built-in macro, X_PATH, causes too many problems, these days everyone uses Xorg, - # so we can ask pkg-config to find it for us. - PKG_CHECK_MODULES(X11, x11, [], [drawstuff="none"]) -fi - -dnl Check for OpenGL -if test "x$drawstuff" = "xOSX"; then - AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1], - [Use the Apple OpenGL framework.]) - GL_LIBS="-framework OpenGL -framework GLUT" -elif test "x$drawstuff" != "xnone"; then - have_gl_headers=yes - AC_CHECK_HEADERS(GL/gl.h GL/glu.h GL/glext.h, , - [have_gl_headers=no], - [[#ifdef WIN32 - #include <windows.h> - #endif - #if HAVE_GL_GL_H - #include <GL/gl.h> - #endif - #if HAVE_GL_GLU_H - #include <GL/glu.h> - #endif - ]]) - have_gl=no - have_glu=no - TEMP_LDFLAGS="$LDFLAGS" - AC_CHECK_LIB(GL, main, [GL_LIBS="-lGL"; have_gl=yes]) - AC_CHECK_LIB(GLU, main, [GL_LIBS="-lGLU $GL_LIBS"; have_glu=yes], , -lGL) - AC_CHECK_LIB(opengl32, main, [GL_LIBS="-lopengl32"; have_gl=yes]) - AC_CHECK_LIB(glu32, main, [GL_LIBS="-lglu32 $GL_LIBS"; have_glu=yes], , -lopengl32) - LDFLAGS="$TEMP_LDFLAGS" - if test $have_gl = no -o $have_glu = no -o $have_gl_headers = no; then - drawstuff="none" - fi -fi -AC_SUBST(GL_LIBS) - -dnl Set Conditionals -AM_CONDITIONAL(WIN32, test x$drawstuff = xWin32) -AM_CONDITIONAL(X11, test x$drawstuff = xX11) -AM_CONDITIONAL(OSX, test x$drawstuff = xOSX) -AM_CONDITIONAL(ENABLE_DRAWSTUFF, test x$drawstuff != xnone) - -dnl Check if we want to build demos -AC_MSG_CHECKING(if demos should be built) -AC_ARG_ENABLE(demos, - AS_HELP_STRING([--disable-demos], [don't build demos]), - enable_demos=$enableval,enable_demos=yes) -if test x$drawstuff = xnone -a x$enable_demos = xyes ; then - enable_demos=no - AC_MSG_RESULT($enable_demos) - AC_MSG_WARN([Demos will not be built because OpenGL doesn't seem to work. See `config.log' for details.]) -else - AC_MSG_RESULT($enable_demos) -fi - - -dnl stdc++ is required when linking C programs against ode -AC_CHECK_LIB(stdc++,main,[LIBSTDCXX="-lstdc++"],[LIBSTDCXX=]) -AC_SUBST(LIBSTDCXX) -AC_CHECK_LIB(pthread,main,[LIBS="$LIBS -lpthread"]) - - -dnl test if we will build demos -AM_CONDITIONAL(ENABLE_DEMOS, test x$enable_demos = xyes) - - -dnl Check if the user wants the old timesh collider -old_trimesh=no -AC_ARG_ENABLE([old-trimesh], AS_HELP_STRING([--enable-old-trimesh],[enable use of the old trimesh collider]), - [old_trimesh=$enableval] - ) -if test x$old_trimesh = xyes -a $trimesh = opcode; then - AC_DEFINE(dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER, 1, - [Use the old trimesh-trimesh collider]) -else - old_trimesh=no -fi - - -dnl Check if the user wants to profile ODE using gprof -AC_MSG_CHECKING(for gprof) -AC_ARG_ENABLE([gprof], - AS_HELP_STRING([--enable-gprof],[enable profiling with gprof]), - gprof=$enableval, - gprof=no) -if test "$gprof" != no -then - CFLAGS="-pg $CFLAGS" - CXXFLAGS="-pg $CXXFLAGS" - AC_MSG_RESULT(enabled) - AC_CHECK_LIB(gmon, main,[LIBS="$LIBS -lgmon"]) -else - AC_MSG_RESULT(no) -fi - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_C_INLINE -AC_TYPE_INT32_T -AC_FUNC_OBSTACK -AC_TYPE_SIZE_T -AC_TYPE_UINT32_T - -dnl Check for autoscan sugested functions -AC_CHECK_LIB(m, [main]) -AC_CHECK_LIB(sunmath, [main]) -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([ou], - AS_HELP_STRING([--enable-ou], - [use TLS for global caches (allows threaded collision checks for separated spaces)] - ), - use_ou_tls=$enableval,use_ou_tls=no) -if test x$use_ou = xyes -then - OU_NAMESPACE=odeou - AC_CONFIG_COMMANDS_POST([export OU_NAMESPACE=odeou]) - AC_DEFINE([_OU_NAMESPACE],[odeou],[libou namespace for ODE]) - AC_DEFINE([dOU_ENABLED],[1],[Generic OU features are enabled]) - AC_DEFINE([dATOMICS_ENABLED],[1],[Atomic API of OU is enabled]) - if test x$use_ou_tls = xyes - then - AC_DEFINE([dTLS_ENABLED],[1],[Thread Local Storage API of OU is enabled]) - fi - - case "$host_os" in - cygwin* | mingw*) - targetos=_OU_TARGET_OS_WINDOWS - ;; - *qnx*) - targetos=_OU_TARGET_OS_QNX - ;; - *apple* | *darwin*) - targetos=_OU_TARGET_OS_MAC - ;; - *sunos*) - targetos=_OU_TARGET_OS_SUNOS - ;; - *aix*) - targetos=_OU_TARGET_OS_AIX - ;; - *) - targetos=_OU_TARGET_OS_GENUNIX - ;; - esac - - if test $targetos = _OU_TARGET_OS_MAC - then - MAC_OS_X_VERSION=1000 - AC_CHECK_FUNC([OSAtomicAdd32Barrier], [MAC_OS_X_VERSION=1040]) - AC_CHECK_FUNC([OSAtomicAnd32OrigBarrier], [MAC_OS_X_VERSION=1050]) - AC_DEFINE_UNQUOTED(MAC_OS_X_VERSION, $MAC_OS_X_VERSION, [Mac OS X version setting for OU Library]) - fi - - if test $targetos = _OU_TARGET_OS_SUNOS - then - AC_CHECK_FUNC(atomic_inc_32_nv, [], - [targetos=_OU_TARGET_OS_GENUNIX]) - fi - - AC_DEFINE_UNQUOTED(_OU_TARGET_OS, $targetos, [Target OS setting for OU Library]) -fi -AC_CONFIG_SUBDIRS([ou]) -AM_CONDITIONAL(ENABLE_OU, test x$use_ou = xyes) - -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]) -fi - -col_cylinder_cylinder=none -col_box_cylinder=default -col_capsule_cylinder=none -col_convex_box=none -col_convex_capsule=none -col_convex_cylinder=none -col_convex_sphere=default -col_convex_convex=default - - -libccd=no -libccd_all=no -AC_ARG_ENABLE(libccd, AS_HELP_STRING([--enable-libccd], - [enable all libccd colliders (except box-cylinder)]), - libccd_all=$enableval) -if test x$libccd_all = xyes -then - col_cylinder_cylinder=libccd - col_capsule_cylinder=libccd - col_convex_box=libccd - col_convex_capsule=libccd - col_convex_cylinder=libccd - col_convex_sphere=libccd - col_convex_convex=libccd - libccd=yes -fi - - -AC_ARG_WITH([cylinder-cylinder], AS_HELP_STRING([--with-cylinder-cylinder=@<:@none,libccd@:>@], [use specific collider for cylinder-cylinder]), - col_cylinder_cylinder=$withval) - -AC_ARG_WITH([box-cylinder], - AS_HELP_STRING([--with-box-cylinder=@<:@default,libccd@:>@], [use specific collider for box-cylinder]), - col_box_cylinder=$withval) - -AC_ARG_WITH([capsule-cylinder], AS_HELP_STRING([--with-capsule-cylinder=@<:@none,libccd@:>@], [use specific collider for capsule-cylinder]), - col_capsule_cylinder=$withval) - -AC_ARG_WITH([convex-box], AS_HELP_STRING([--with-convex-box=@<:@none,libccd@:>@], [use specific collider for convex-box]), - col_convex_box=$withval) - -AC_ARG_WITH([convex-capsule], AS_HELP_STRING([--with-convex-capsule=@<:@none,libccd@:>@], [use specific collider for convex-capsule]), - col_convex_capsule=$withval) - -AC_ARG_WITH([convex-cylinder], AS_HELP_STRING([--with-convex-cylinder=@<:@none,libccd@:>@], [use specific collider for convex-cylinder]), - col_convex_cylinder=$withval) - -AC_ARG_WITH([convex-sphere], AS_HELP_STRING([--with-convex-sphere=@<:@default,libccd@:>@], [use specific collider for convex-sphere]), - col_convex_sphere=$withval) - -AC_ARG_WITH([convex-convex], AS_HELP_STRING([--with-convex-convex=@<:@default,libccd@:>@], [use specific collider for convex-convex]), - col_convex_convex=$withval) - -if test x$col_cylinder_cylinder = xlibccd -o \ - x$col_box_cylinder = xlibccd -o \ - x$col_capsule_cylinder = xlibccd -o \ - x$col_convex_box = xlibccd -o \ - x$col_convex_capsule = libccd -o \ - x$col_convex_cylinder = xlibccd -o \ - x$col_convex_sphere = libccd -o \ - x$col_convex_convex = libccd -then - libccd=yes -fi - -AC_CONFIG_SUBDIRS([libccd]) - -AM_CONDITIONAL(LIBCCD, test x$libccd != xno) -AM_CONDITIONAL(LIBCCD_BOX_CYL, test x$col_box_cylinder = xlibccd) -AM_CONDITIONAL(LIBCCD_CYL_CYL, test x$col_cylinder_cylinder = xlibccd) -AM_CONDITIONAL(LIBCCD_CAP_CYL, test x$col_capsule_cylinder = xlibccd) -AM_CONDITIONAL(LIBCCD_CONVEX_BOX, test x$col_convex_box = xlibccd) -AM_CONDITIONAL(LIBCCD_CONVEX_CAP, test x$col_convex_capsule = xlibccd) -AM_CONDITIONAL(LIBCCD_CONVEX_CYL, test x$col_convex_cylinder = xlibccd) -AM_CONDITIONAL(LIBCCD_CONVEX_SPHERE, test x$col_convex_sphere = xlibccd) -AM_CONDITIONAL(LIBCCD_CONVEX_CONVEX, test x$col_convex_convex = xlibccd) - - - -AC_ARG_ENABLE([asserts], - AS_HELP_STRING([--disable-asserts], - [disables debug error checking]), - asserts=$enableval,asserts=yes) -if test x$asserts = xno -then - CPPFLAGS="$CPPFLAGS -DdNODEBUG" - if test x$use_ou = xyes - then - CPPFLAGS="$CPPFLAGS -DNDEBUG" - fi -fi - - -dnl include found system headers into config.h -AH_TOP([ -#ifndef ODE_CONFIG_H -#define ODE_CONFIG_H -]) -AH_BOTTOM([ - -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif -#ifdef HAVE_MALLOC_H -#include <malloc.h> -#endif -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif -#ifdef HAVE_INTTYPES_H -#include <inttypes.h> -#endif - -/* an integer type that we can safely cast a pointer to and - * from without loss of bits. - */ -typedef uintptr_t intP; - - -#ifdef dSINGLE - #define dEpsilon FLT_EPSILON -#else - #define dEpsilon DBL_EPSILON -#endif - - -#endif /* #define ODE_CONFIG_H */ -]) - -dnl Finally write our Makefiles -AC_CONFIG_FILES([ - Makefile - include/Makefile - include/ode/Makefile - include/drawstuff/Makefile - ode/Makefile - ode/src/Makefile - ode/src/joints/Makefile - drawstuff/Makefile - drawstuff/src/Makefile - drawstuff/dstest/Makefile - ode/demo/Makefile - OPCODE/Makefile - OPCODE/Ice/Makefile - GIMPACT/Makefile - GIMPACT/include/Makefile - GIMPACT/include/GIMPACT/Makefile - GIMPACT/src/Makefile - tests/Makefile - tests/UnitTest++/Makefile - tests/UnitTest++/src/Makefile - tests/UnitTest++/src/Posix/Makefile - tests/UnitTest++/src/Win32/Makefile - ode-config - ode.pc - ]) -AC_OUTPUT - -chmod +x ode-config - -BUILDDIR=`pwd` - -dnl Print some useful information -echo "Configuration:" -echo " Build system type: $build" -echo " Host system type: $host" -echo " Use double precision: $precision" -echo " Use drawstuff: $drawstuff" -echo " Demos enabled: $enable_demos" -echo " Use OPCODE: $opcode" -echo " Use GIMPACT: $gimpact" -echo " Custom colliders:" -echo " cylinder-cylinder: $col_cylinder_cylinder" -echo " box-cylinder: $col_box_cylinder" -echo " capsule-cylinder: $col_capsule_cylinder" -echo " convex-box: $col_convex_box" -echo " convex-capsule: $col_convex_capsule" -echo " convex-cylinder: $col_convex_cylinder" -echo " convex-sphere: $col_convex_sphere" -echo " convex-convex: $col_convex_convex" -echo " Is target a Pentium: $pentium" -echo " Is target x86-64: $cpu64" -echo " Use old opcode trimesh collider: $old_trimesh" -echo " TLS for global caches: $use_ou_tls" -echo " Built-in threading included: $use_builtin_threading_impl" -echo " Enable debug error check: $asserts" -echo " Headers will be installed in $includedir/ode" -echo " Libraries will be installed in $libdir" -echo " Building in directory $BUILDDIR" - Modified: trunk/drawstuff/src/Makefile.am =================================================================== --- trunk/drawstuff/src/Makefile.am 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/drawstuff/src/Makefile.am 2012-06-08 22:29:43 UTC (rev 1892) @@ -4,6 +4,7 @@ noinst_LTLIBRARIES = libdrawstuff.la libdrawstuff_la_SOURCES = drawstuff.cpp internal.h AM_CPPFLAGS = -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ -DDEFAULT_PATH_TO_TEXTURES='"$(top_srcdir)/drawstuff/textures/"' \ $(X11_CFLAGS) Modified: trunk/include/drawstuff/Makefile.am =================================================================== --- trunk/include/drawstuff/Makefile.am 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/drawstuff/Makefile.am 2012-06-08 22:29:43 UTC (rev 1892) @@ -1,3 +1,2 @@ - noinst_HEADERS = drawstuff.h version.h Modified: trunk/include/drawstuff/drawstuff.h =================================================================== --- trunk/include/drawstuff/drawstuff.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/drawstuff/drawstuff.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -69,7 +69,7 @@ DS_WOOD, DS_CHECKERED, DS_GROUND, - DS_SKY, + DS_SKY }; /* draw modes */ @@ -297,7 +297,7 @@ */ DS_API void dsSetDrawMode(int mode); -// Backwards compatible API +/* Backwards compatible API */ #define dsDrawCappedCylinder dsDrawCapsule #define dsDrawCappedCylinderD dsDrawCapsuleD #define dsSetCappedCylinderQuality dsSetCapsuleQuality Modified: trunk/include/ode/Makefile.am =================================================================== --- trunk/include/ode/Makefile.am 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/Makefile.am 2012-06-08 22:29:43 UTC (rev 1892) @@ -24,4 +24,8 @@ threading_impl.h \ odeconfig.h -EXTRA_DIST = README +EXTRA_DIST = README precision.h.in + +dist_libode_la_include_HEADERS = precision.h + + Modified: trunk/include/ode/collision.h =================================================================== --- trunk/include/ode/collision.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/collision.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -26,9 +26,6 @@ #include <ode/common.h> #include <ode/collision_space.h> #include <ode/contact.h> -// Include odeinit.h for backward compatibility as some of initialization APIs -// were initally declared in current header. -#include <ode/odeinit.h> #ifdef __cplusplus extern "C" { @@ -424,7 +421,7 @@ enum { - dGeomColliderMergeContactsValue__Default = 0, // Used with Set... to restore default value + dGeomColliderMergeContactsValue__Default = 0, /* Used with Set... to restore default value*/ dGeomColliderMergeContactsValue_None = 1, dGeomColliderMergeContactsValue_Normals = 2, dGeomColliderMergeContactsValue_Full = 3 @@ -892,7 +889,7 @@ dFirstSpaceClass, dSimpleSpaceClass = dFirstSpaceClass, dHashSpaceClass, - dSweepAndPruneSpaceClass, // SAP + dSweepAndPruneSpaceClass, /* SAP */ dQuadTreeSpaceClass, dLastSpaceClass = dQuadTreeSpaceClass, @@ -964,7 +961,7 @@ ODE_API dReal dGeomSpherePointDepth (dGeomID sphere, dReal x, dReal y, dReal z); -//--> Convex Functions +/*--> Convex Functions*/ ODE_API dGeomID dCreateConvex (dSpaceID space, dReal *_planes, unsigned int _planecount, @@ -976,7 +973,7 @@ unsigned int _count, dReal *_points, unsigned int _pointcount,unsigned int *_polygons); -//<-- Convex Functions +/*<-- Convex Functions*/ /** * @defgroup collide_box Box Class @@ -1053,7 +1050,7 @@ ODE_API void dGeomCapsuleGetParams (dGeomID ccylinder, dReal *radius, dReal *length); ODE_API dReal dGeomCapsulePointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z); -// For now we want to have a backwards compatible C-API, note: C++ API is not. +/* For now we want to have a backwards compatible C-API, note: C++ API is not.*/ #define dCreateCCylinder dCreateCapsule #define dGeomCCylinderSetParams dGeomCapsuleSetParams #define dGeomCCylinderGetParams dGeomCapsuleGetParams @@ -1096,7 +1093,7 @@ /* heightfield functions */ -// Data storage for heightfield data. +/* Data storage for heightfield data.*/ struct dxHeightfieldData; typedef struct dxHeightfieldData* dHeightfieldDataID; @@ -1471,7 +1468,7 @@ const dVector3 side1, const dVector3 _p2, const dMatrix3 R2, const dVector3 side2); -// The meaning of flags parameter is the same as in dCollide() +/* The meaning of flags parameter is the same as in dCollide()*/ ODE_API int dBoxBox (const dVector3 p1, const dMatrix3 R1, const dVector3 side1, const dVector3 p2, const dMatrix3 R2, const dVector3 side2, Modified: trunk/include/ode/collision_space.h =================================================================== --- trunk/include/ode/collision_space.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/collision_space.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -54,8 +54,8 @@ ODE_API dSpaceID dQuadTreeSpaceCreate (dSpaceID space, const dVector3 Center, const dVector3 Extents, int Depth); -// SAP -// Order XZY or ZXY usually works best, if your Y is up. +/* SAP */ +/* Order XZY or ZXY usually works best, if your Y is up. */ #define dSAP_AXES_XYZ ((0)|(1<<2)|(2<<4)) #define dSAP_AXES_XZY ((0)|(2<<2)|(1<<4)) #define dSAP_AXES_YXZ ((1)|(0<<2)|(2<<4)) Modified: trunk/include/ode/collision_trimesh.h =================================================================== --- trunk/include/ode/collision_trimesh.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/collision_trimesh.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -156,7 +156,7 @@ ODE_API dTriMeshDataID dGeomTriMeshGetData(dGeomID g); -// enable/disable/check temporal coherence +/* enable/disable/check temporal coherence*/ ODE_API void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable); ODE_API int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass); Modified: trunk/include/ode/common.h =================================================================== --- trunk/include/ode/common.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/common.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -23,6 +23,8 @@ #ifndef _ODE_COMMON_H_ #define _ODE_COMMON_H_ +#include <ode/precision.h> + #include <ode/odeconfig.h> #include <ode/error.h> @@ -54,31 +56,33 @@ typedef float dReal; #ifdef dDOUBLE #error You can only #define dSINGLE or dDOUBLE, not both. -#endif // dDOUBLE +#endif /* dDOUBLE */ #elif defined(dDOUBLE) typedef double dReal; #else #error You must #define dSINGLE or dDOUBLE #endif -// Detect if we've got both trimesh engines enabled. +/* Detect if we've got both trimesh engines enabled. */ #if dTRIMESH_ENABLED #if dTRIMESH_OPCODE && dTRIMESH_GIMPACT #error You can only #define dTRIMESH_OPCODE or dTRIMESH_GIMPACT, not both. #endif -#endif // dTRIMESH_ENABLED +#endif /* dTRIMESH_ENABLED */ -// Define a type for indices, either 16 or 32 bit, based on build option -// TODO: Currently GIMPACT only supports 32 bit indices. +/* + * Define a type for indices, either 16 or 32 bit, based on build option + * TODO: Currently GIMPACT only supports 32 bit indices. + */ #if dTRIMESH_16BIT_INDICES #if dTRIMESH_GIMPACT typedef uint32 dTriIndex; -#else // dTRIMESH_GIMPACT +#else /* dTRIMESH_GIMPACT */ typedef uint16 dTriIndex; -#endif // dTRIMESH_GIMPACT -#else // dTRIMESH_16BIT_INDICES +#endif /* dTRIMESH_GIMPACT */ +#else /* dTRIMESH_16BIT_INDICES */ typedef uint32 dTriIndex; -#endif // dTRIMESH_16BIT_INDICES +#endif /* dTRIMESH_16BIT_INDICES */ /* round an integer up to a multiple of 4, except that 0 and 1 are unmodified * (used to compute matrix leading dimensions) @@ -209,7 +213,7 @@ dJointTypePU, dJointTypePiston, dJointTypeDBall, - dJointTypeDHinge, + dJointTypeDHinge } dJointType; @@ -262,14 +266,14 @@ dParamSuspensionCFM, \ dParamERP, \ - ////////////////////////////////////////////////////////////////////////////// - /// \enum D_ALL_PARAM_NAMES_X - /// - /// \var dParamGroup This is the starting value of the different group - /// (i.e. dParamGroup1, dParamGroup2, dParamGroup3) - /// It also helps in the use of parameter - /// (dParamGroup2 | dParamFMax) == dParamFMax2 - ////////////////////////////////////////////////////////////////////////////// + /* + * \enum D_ALL_PARAM_NAMES_X + * + * \var dParamGroup This is the starting value of the different group + * (i.e. dParamGroup1, dParamGroup2, dParamGroup3) + * It also helps in the use of parameter + * (dParamGroup2 | dParamFMax) == dParamFMax2 + */ #define D_ALL_PARAM_NAMES_X(start,x) \ dParamGroup ## x = start, \ /* parameters for limits and motors */ \ @@ -289,7 +293,7 @@ enum { D_ALL_PARAM_NAMES(0) - dParamsInGroup, ///< Number of parameter in a group + dParamsInGroup, /* < Number of parameter in a group */ D_ALL_PARAM_NAMES_X(0x000,1) D_ALL_PARAM_NAMES_X(0x100,2) D_ALL_PARAM_NAMES_X(0x200,3) Modified: trunk/include/ode/contact.h =================================================================== --- trunk/include/ode/contact.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/contact.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -80,11 +80,11 @@ * @ingroup collide */ typedef struct dContactGeom { - dVector3 pos; ///< contact position - dVector3 normal; ///< normal vector - dReal depth; ///< penetration depth - dGeomID g1,g2; ///< the colliding geoms - int side1,side2; ///< (to be documented) + dVector3 pos; /*< contact position*/ + dVector3 normal; /*< normal vector*/ + dReal depth; /*< penetration depth*/ + dGeomID g1,g2; /*< the colliding geoms*/ + int side1,side2; /*< (to be documented)*/ } dContactGeom; Modified: trunk/include/ode/mass.h =================================================================== --- trunk/include/ode/mass.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/mass.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -80,7 +80,7 @@ ODE_API void dMassAdd (dMass *a, const dMass *b); -// Backwards compatible API +/* Backwards compatible API */ ODE_API ODE_API_DEPRECATED void dMassSetCappedCylinder(dMass *a, dReal b, int c, dReal d, dReal e); ODE_API ODE_API_DEPRECATED void dMassSetCappedCylinderTotal(dMass *a, dReal b, int c, dReal d, dReal e); Modified: trunk/include/ode/matrix.h =================================================================== --- trunk/include/ode/matrix.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/matrix.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -241,7 +241,7 @@ return n2 * sizeof(dReal) + _dEstimateLDLTAddTLTmpbufSize(nskip); } -// For internal use +/* 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) @@ -270,7 +270,7 @@ #define dEstimateLDLTRemoveTmpbufSize(n2, nskip) _dEstimateLDLTRemoveTmpbufSize(n2, nskip) -#endif // defined(__ODE__) +#endif /* defined(__ODE__) */ #ifdef __cplusplus Modified: trunk/include/ode/objects.h =================================================================== --- trunk/include/ode/objects.h 2012-05-31 02:33:23 UTC (rev 1891) +++ trunk/include/ode/objects.h 2012-06-08 22:29:43 UTC (rev 1892) @@ -243,7 +243,7 @@ typedef struct { unsigned struct_size; - float reserve_factor; // Use float as precision does not matter here + float reserve_factor; /* U... [truncated message content] |
From: <dan...@us...> - 2012-05-31 02:33:30
|
Revision: 1891 http://opende.svn.sourceforge.net/opende/?rev=1891&view=rev Author: danielosmari Date: 2012-05-31 02:33:23 +0000 (Thu, 31 May 2012) Log Message: ----------- * Drawstuff now shows shadows for lines. * Fixed dhinge constraint (reported by Dimitris Papavasiliou) * Updated some libtool scripts * Removed 'force' option from bootstrap/autogen.sh scripts. Modified Paths: -------------- trunk/CHANGELOG.txt trunk/autogen.sh trunk/drawstuff/src/drawstuff.cpp trunk/libccd/bootstrap trunk/m4/libtool.m4 trunk/m4/ltoptions.m4 trunk/m4/ltversion.m4 trunk/ode/demo/demo_dhinge.cpp trunk/ode/src/joints/dhinge.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/CHANGELOG.txt 2012-05-31 02:33:23 UTC (rev 1891) @@ -8,6 +8,10 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +05/30/12 Daniel K. O. + * Made drawstuff draw shadows for lines. + * Fixed dhinge's last constraint to properly handle rotations. + 05/03/12 Daniel K. O. * Added two new joints: Double Ball and Double Hinge. Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/autogen.sh 2012-05-31 02:33:23 UTC (rev 1891) @@ -37,7 +37,7 @@ # LIBTOOLIZE=glibtoolize #fi echo "Running $LIBTOOLIZE" -$LIBTOOLIZE --copy --force --automake || exit 1 +$LIBTOOLIZE --copy --automake || exit 1 echo "Running autoheader" autoheader || exit 1 echo "Running automake" Modified: trunk/drawstuff/src/drawstuff.cpp =================================================================== --- trunk/drawstuff/src/drawstuff.cpp 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/drawstuff/src/drawstuff.cpp 2012-05-31 02:33:23 UTC (rev 1891) @@ -1495,10 +1495,8 @@ } -void dsDrawLine (const float pos1[3], const float pos2[3]) +static void drawLine(const float pos1[3], const float pos2[3]) { - setupDrawingMode(); - glColor3f (color[0],color[1],color[2]); glDisable (GL_LIGHTING); glLineWidth (2); glShadeModel (GL_FLAT); @@ -1509,9 +1507,27 @@ } -void dsDrawBoxD (const double pos[3], const double R[12], - const double sides[3]) +extern "C" void dsDrawLine (const float pos1[3], const float pos2[3]) { + setupDrawingMode(); + glColor4f(color[0], color[1], color[2], color[3]); + drawLine(pos1, pos2); + + if (use_shadows) { + setShadowDrawingMode(); + setShadowTransform(); + + drawLine(pos1, pos2); + + glPopMatrix(); + glDepthRange (0,1); + } +} + + +extern "C" void dsDrawBoxD (const double pos[3], const double R[12], + const double sides[3]) +{ int i; float pos2[3],R2[12],fsides[3]; for (i=0; i<3; i++) pos2[i]=(float)pos[i]; Modified: trunk/libccd/bootstrap =================================================================== --- trunk/libccd/bootstrap 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/libccd/bootstrap 2012-05-31 02:33:23 UTC (rev 1891) @@ -5,8 +5,8 @@ if [ `uname -s` = Darwin ]; then LIBTOOLIZE=glibtoolize fi -$LIBTOOLIZE -f -c --automake +$LIBTOOLIZE -c --automake aclocal -autoheader -f +autoheader autoconf -automake -a --foreign -f -c +automake -a --foreign -c Modified: trunk/m4/libtool.m4 =================================================================== --- trunk/m4/libtool.m4 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/m4/libtool.m4 2012-05-31 02:33:23 UTC (rev 1891) @@ -1,8 +1,8 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -11,8 +11,8 @@ m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -# Inc. +# 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. @@ -146,6 +146,8 @@ AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl @@ -637,7 +639,7 @@ m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." @@ -801,6 +803,7 @@ m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], @@ -822,6 +825,31 @@ ])# _LT_LANG +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], @@ -852,6 +880,10 @@ m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) @@ -954,7 +986,13 @@ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -962,6 +1000,7 @@ rm -rf libconftest.dylib* rm -f conftest.* fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no @@ -973,6 +1012,7 @@ [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF @@ -990,7 +1030,9 @@ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? - if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -1035,8 +1077,8 @@ ]) -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ @@ -1047,6 +1089,8 @@ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi @@ -1330,14 +1374,27 @@ CFLAGS="$SAVE_CFLAGS" fi ;; -sparc*-*solaris*) +*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD="${LD-ld}_sol2" + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -1414,13 +1471,13 @@ if test -n "$RANLIB"; then case $host_os in openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -1600,6 +1657,11 @@ lt_cv_sys_max_cmd_len=196608 ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -1639,7 +1701,7 @@ # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ + while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do @@ -2185,7 +2247,7 @@ case $host_os in aix3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH @@ -2194,7 +2256,7 @@ ;; aix[[4-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes @@ -2259,7 +2321,7 @@ ;; bsdi[[45]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' @@ -2398,7 +2460,7 @@ ;; dgux*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' @@ -2406,10 +2468,6 @@ shlibpath_var=LD_LIBRARY_PATH ;; -freebsd1*) - dynamic_linker=no - ;; - freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -2417,7 +2475,7 @@ objformat=`/usr/bin/objformat` else case $host_os in - freebsd[[123]]*) objformat=aout ;; + freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi @@ -2435,7 +2493,7 @@ esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2*) + freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) @@ -2455,17 +2513,18 @@ ;; gnu*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" @@ -2526,7 +2585,7 @@ ;; interix[[3-9]]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' @@ -2542,7 +2601,7 @@ nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; @@ -2579,9 +2638,9 @@ dynamic_linker=no ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2662,7 +2721,7 @@ ;; newsos6) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -2731,7 +2790,7 @@ ;; solaris*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2756,7 +2815,7 @@ ;; sysv4 | sysv4.3*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -2780,7 +2839,7 @@ sysv4*MP*) if test -d /usr/nec ;then - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH @@ -2811,7 +2870,7 @@ tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' @@ -2821,7 +2880,7 @@ ;; uts4*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH @@ -3243,7 +3302,7 @@ lt_cv_deplibs_check_method=pass_all ;; -# This must be Linux ELF. +# This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; @@ -3663,6 +3722,7 @@ # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ @@ -4247,7 +4307,9 @@ case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi ;; esac else @@ -4339,18 +4401,33 @@ ;; *) case `$CC -V 2>&1 | sed 5q` in - *Sun\ F* | *Sun*Fortran*) + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; esac ;; esac @@ -4510,7 +4587,9 @@ ;; cygwin* | mingw* | cegcc*) case $cc_basename in - cl*) ;; + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] @@ -4538,7 +4617,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -4789,8 +4867,7 @@ xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ @@ -5086,6 +5163,7 @@ # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' @@ -5132,10 +5210,6 @@ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -5148,7 +5222,7 @@ ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) + freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes @@ -5187,7 +5261,6 @@ fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes @@ -5629,9 +5702,6 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], @@ -5789,7 +5859,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported @@ -6160,7 +6229,7 @@ esac ;; - freebsd[[12]]*) + freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no @@ -6921,12 +6990,18 @@ } }; _LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary @@ -7123,7 +7198,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7256,7 +7330,6 @@ _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no @@ -7446,6 +7519,77 @@ ])# _LT_LANG_GCJ_CONFIG +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler @@ -7515,6 +7659,13 @@ dnl AC_DEFUN([LT_AC_PROG_GCJ], []) +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], Modified: trunk/m4/ltoptions.m4 =================================================================== --- trunk/m4/ltoptions.m4 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/m4/ltoptions.m4 2012-05-31 02:33:23 UTC (rev 1891) @@ -326,9 +326,24 @@ # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for lt_pkg in $withval; do + IFS="$lt_save_ifs" + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) Modified: trunk/m4/ltversion.m4 =================================================================== --- trunk/m4/ltversion.m4 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/m4/ltversion.m4 2012-05-31 02:33:23 UTC (rev 1891) @@ -9,15 +9,15 @@ # @configure_input@ -# serial 3293 ltversion.m4 +# serial 3337 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4]) -m4_define([LT_PACKAGE_REVISION], [1.3293]) +m4_define([LT_PACKAGE_VERSION], [2.4.2]) +m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4' -macro_revision='1.3293' +[macro_version='2.4.2' +macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) Modified: trunk/ode/demo/demo_dhinge.cpp =================================================================== --- trunk/ode/demo/demo_dhinge.cpp 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/ode/demo/demo_dhinge.cpp 2012-05-31 02:33:23 UTC (rev 1891) @@ -36,6 +36,7 @@ dBodyID body1; dBodyID body2; dJointID joint1, joint2; +bool applyForce = false; void start() { @@ -67,19 +68,30 @@ dMassSetBox(&mass, 1, 0.2, 0.2, 1); dBodySetMass(body2, &mass); +#if 1 joint1 = dJointCreateDHinge(world, 0); dJointAttach(joint1, body1, 0); dJointSetDHingeAxis(joint1, 0, 1, 0); dJointSetDHingeAnchor1(joint1, 0, 0, 3.5); dJointSetDHingeAnchor2(joint1, 0, 0, 4.5); +#endif +#if 1 joint2 = dJointCreateDHinge(world, 0); dJointAttach(joint2, body1, body2); dJointSetDHingeAxis(joint2, 1, 0, 0); dJointSetDHingeAnchor1(joint2, 0, 0, 2.5); dJointSetDHingeAnchor2(joint2, 0, 0, 1.5); +#else + joint2 = dJointCreateDBall(world, 0); + dJointAttach(joint2, body1, body2); + dJointSetDBallAnchor1(joint2, 0, 0, 2.5); + dJointSetDBallAnchor2(joint2, 0, 0, 1.5); +#endif + //dBodyAddForce(body1, 20, 0, 0); + // initial camera position static float xyz[3] = {3.8966, -2.0614, 4.0300}; static float hpr[3] = {153.5, -16.5, 0}; @@ -101,15 +113,13 @@ const dReal *rot = dGeomGetRotation(g); switch (gclass) { - case dSphereClass: - dsSetColorAlpha(0, 0.75, 0.5, 1); - dsSetTexture (DS_CHECKERED); - dsDrawSphere(pos, rot, dGeomSphereGetRadius(g)); - break; case dBoxClass: { dVector3 lengths; - dsSetColorAlpha(1, 1, 0, 1); + if (applyForce) + dsSetColor(1, .5, 0); + else + dsSetColor(1, 1, 0); dsSetTexture (DS_WOOD); dGeomBoxGetLengths(g, lengths); dsDrawBox(pos, rot, lengths); @@ -121,6 +131,7 @@ } } + void simLoop(int pause) { if (!pause) { @@ -128,21 +139,27 @@ static dReal t = 0; const dReal step = 0.005; - const unsigned nsteps = 4; + const unsigned nsteps = 2; for (unsigned i=0; i<nsteps; ++i) { - dReal f = sin(t*1.2)*0.8; - dBodyAddForceAtRelPos(body1, - f, 0, 0, - 0, 0, -0.5); // at the lower end + applyForce = fmodf(t, 3.) > 2.; - dReal g = sin(t*0.7)*0.8; - dBodyAddForceAtRelPos(body2, - 0, g, 0, - 0, 0, -0.5); // at the lower end - + if (applyForce) { + dReal f = 0.3 * sin(t*1.2); + dBodyAddForceAtRelPos(body1, + f, 0, 0, + 0, 0, -0.5); // at the lower end + + dReal g = 0.3 * sin(t*0.7); + dBodyAddForceAtRelPos(body2, + 0, g, 0, + 0, 0, -0.5); // at the lower end + } + t += step; + if (t > 20.) + t = 0.; dWorldQuickStep(world, step); } @@ -156,15 +173,16 @@ drawGeom(g); } - +#if 1 dVector3 a11, a12; dJointGetDHingeAnchor1(joint1, a11); dJointGetDHingeAnchor2(joint1, a12); dsSetColor(1, 0, 0); dsDrawLine(a11, a12); - //printf("Error 1: %f\n", fabs(dJointGetDHingeDistance(joint1) - dCalcPointsDistance3(a11, a12))); +#endif +#if 1 dVector3 a21, a22; dJointGetDHingeAnchor1(joint2, a21); dJointGetDHingeAnchor2(joint2, a22); @@ -172,6 +190,7 @@ dsDrawLine(a21, a22); //printf("Error 2: %f\n", fabs(dJointGetDHingeDistance(joint2) - dCalcPointsDistance3(a21, a22))); +#endif } Modified: trunk/ode/src/joints/dhinge.cpp =================================================================== --- trunk/ode/src/joints/dhinge.cpp 2012-05-28 23:30:46 UTC (rev 1890) +++ trunk/ode/src/joints/dhinge.cpp 2012-05-31 02:33:23 UTC (rev 1891) @@ -100,16 +100,48 @@ info->c[2] = k * dCalcVectorDot3( u, q ); - // linear constraint, along the axis + + + /* + * Constraint along the axis: translation along it should couple angular movement. + * This is just the ball-and-socket derivation, projected onto the hinge axis, + * producing a single constraint at the end. + * + * The choice of "ball" position can be arbitrary; we could place it at the center + * of one of the bodies, canceling out its rotational jacobian; or we could make + * everything symmetrical by just placing at the midpoint between the centers. + * + * I like symmetry, so I'll use the second approach here. I'll call the midpoint h. + * + * Of course, if the second body is NULL, the first body is pretty much locked + * along this axis, and the linear constraint is enough. + */ + info->J1l[row3+0] = globalAxis1[0]; info->J1l[row3+1] = globalAxis1[1]; info->J1l[row3+2] = globalAxis1[2]; + if ( node[1].body ) { + + dVector3 h; + dAddScaledVectors3(h, node[0].body->posr.pos, node[1].body->posr.pos, -0.5, 0.5); + + dVector3 omega; + dCalcVectorCross3(omega, h, globalAxis1); + info->J1a[row3+0] = omega[0]; + info->J1a[row3+1] = omega[1]; + info->J1a[row3+2] = omega[2]; + info->J2l[row3+0] = -globalAxis1[0]; info->J2l[row3+1] = -globalAxis1[1]; info->J2l[row3+2] = -globalAxis1[2]; + + info->J2a[row3+0] = omega[0]; + info->J2a[row3+1] = omega[1]; + info->J2a[row3+2] = omega[2]; } + // error correction: both anchors should lie on the same plane perpendicular to the axis dVector3 globalA1, globalA2; dBodyGetRelPointPos(node[0].body, anchor1[0], anchor1[1], anchor1[2], globalA1); if ( node[1].body ) @@ -118,7 +150,7 @@ dCopyVector3(globalA2, anchor2); dVector3 d; - dSubtractVectors3(d, globalA1, globalA2); + dSubtractVectors3(d, globalA1, globalA2); // displacement error info->c[3] = -k * dCalcVectorDot3(globalAxis1, d); } @@ -144,7 +176,7 @@ dxJointDHinge* joint = dynamic_cast<dxJointDHinge*>(j); dUASSERT( joint, "bad joint argument" ); - dBodyVectorFromWorld(joint->node[0].body, joint->axis1[0], joint->axis1[1], joint->axis1[2], result); + dBodyVectorToWorld(joint->node[0].body, joint->axis1[0], joint->axis1[1], joint->axis1[2], result); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-05-28 23:30:53
|
Revision: 1890 http://opende.svn.sourceforge.net/opende/?rev=1890&view=rev Author: danielosmari Date: 2012-05-28 23:30:46 +0000 (Mon, 28 May 2012) Log Message: ----------- fixed distribution of bootstrap for libccd, added new demos to premake script Modified Paths: -------------- trunk/build/premake4.lua trunk/libccd/Makefile.am Modified: trunk/build/premake4.lua =================================================================== --- trunk/build/premake4.lua 2012-05-28 23:23:39 UTC (rev 1889) +++ trunk/build/premake4.lua 2012-05-28 23:30:46 UTC (rev 1890) @@ -16,8 +16,11 @@ "chain1", "chain2", "collision", + "convex", "crash", "cylvssphere", + "dball", + "dhinge", "feedback", "friction", "gyroscopic", @@ -42,9 +45,10 @@ local trimesh_demos = { "basket", "cyl", + "moving_convex", "moving_trimesh", - "trimesh", - "tracks" + "tracks", + "trimesh" } if not _OPTIONS["no-trimesh"] then Modified: trunk/libccd/Makefile.am =================================================================== --- trunk/libccd/Makefile.am 2012-05-28 23:23:39 UTC (rev 1889) +++ trunk/libccd/Makefile.am 2012-05-28 23:30:46 UTC (rev 1890) @@ -1,5 +1,6 @@ SUBDIRS = src EXTRA_DIST = \ - BSD-LICENSE \ - README + bootstrap \ + BSD-LICENSE \ + README This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-05-28 23:23:45
|
Revision: 1889 http://opende.svn.sourceforge.net/opende/?rev=1889&view=rev Author: danielosmari Date: 2012-05-28 23:23:39 +0000 (Mon, 28 May 2012) Log Message: ----------- added bootstrap to extra dist files Modified Paths: -------------- tags/0.12/libccd/Makefile.am Modified: tags/0.12/libccd/Makefile.am =================================================================== --- tags/0.12/libccd/Makefile.am 2012-05-03 14:27:45 UTC (rev 1888) +++ tags/0.12/libccd/Makefile.am 2012-05-28 23:23:39 UTC (rev 1889) @@ -1,5 +1,6 @@ SUBDIRS = src EXTRA_DIST = \ - BSD-LICENSE \ - README + bootstrap \ + BSD-LICENSE \ + README This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-05-03 14:27:57
|
Revision: 1888 http://opende.svn.sourceforge.net/opende/?rev=1888&view=rev Author: danielosmari Date: 2012-05-03 14:27:45 +0000 (Thu, 03 May 2012) Log Message: ----------- added two new joints: Double Ball (DBall) and Double Hinge (DHinge) Modified Paths: -------------- trunk/CHANGELOG.txt trunk/include/ode/common.h trunk/include/ode/objects.h trunk/ode/demo/Makefile.am trunk/ode/src/joints/Makefile.am trunk/ode/src/joints/joints.h trunk/ode/src/ode.cpp Added Paths: ----------- trunk/ode/demo/demo_dball.cpp trunk/ode/demo/demo_dhinge.cpp trunk/ode/src/joints/dball.cpp trunk/ode/src/joints/dball.h trunk/ode/src/joints/dhinge.cpp trunk/ode/src/joints/dhinge.h Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-04-22 07:06:35 UTC (rev 1887) +++ trunk/CHANGELOG.txt 2012-05-03 14:27:45 UTC (rev 1888) @@ -8,6 +8,9 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +05/03/12 Daniel K. O. + * Added two new joints: Double Ball and Double Hinge. + 04/22/12 Daniel K. O. * Fixed plane2d joint: uninitialized variables (reported by Dimitris Papavasiliou) Modified: trunk/include/ode/common.h =================================================================== --- trunk/include/ode/common.h 2012-04-22 07:06:35 UTC (rev 1887) +++ trunk/include/ode/common.h 2012-05-03 14:27:45 UTC (rev 1888) @@ -207,7 +207,9 @@ dJointTypePlane2D, dJointTypePR, dJointTypePU, - dJointTypePiston + dJointTypePiston, + dJointTypeDBall, + dJointTypeDHinge, } dJointType; Modified: trunk/include/ode/objects.h =================================================================== --- trunk/include/ode/objects.h 2012-04-22 07:06:35 UTC (rev 1887) +++ trunk/include/ode/objects.h 2012-05-03 14:27:45 UTC (rev 1888) @@ -1695,6 +1695,23 @@ ODE_API dJointID dJointCreatePlane2D (dWorldID, dJointGroupID); /** + * @brief Create a new joint of the double ball type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateDBall (dWorldID, dJointGroupID); + +/** + * @brief Create a new joint of the double hinge type. + * @ingroup joints + * @param dJointGroupID set to 0 to allocate the joint normally. + * If it is nonzero the joint is allocated in the given joint group. + */ +ODE_API dJointID dJointCreateDHinge (dWorldID, dJointGroupID); + + +/** * @brief Destroy a joint. * @ingroup joints * @@ -2993,8 +3010,107 @@ /** + * @brief set anchor1 for double ball joint * @ingroup joints */ +ODE_API void dJointSetDBallAnchor1(dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set anchor2 for double ball joint + * @ingroup joints + */ +ODE_API void dJointSetDBallAnchor2(dJointID, dReal x, dReal y, dReal z); + +/** + * @brief get anchor1 from double ball joint + * @ingroup joints + */ +ODE_API void dJointGetDBallAnchor1(dJointID, dVector3 result); + +/** + * @brief get anchor2 from double ball joint + * @ingroup joints + */ +ODE_API void dJointGetDBallAnchor2(dJointID, dVector3 result); + +/** + * @brief get the set distance from double ball joint + * @ingroup joints + */ +ODE_API dReal dJointGetDBallDistance(dJointID); + +/** + * @brief set double ball joint parameter + * @ingroup joints + */ +ODE_API void dJointSetDBallParam(dJointID, int parameter, dReal value); + +/** + * @brief get double ball joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetDBallParam(dJointID, int parameter); + +/** + * @brief set axis for double hinge joint + * @ingroup joints + */ +ODE_API void dJointSetDHingeAxis(dJointID, dReal x, dReal y, dReal z); + +/** + * @brief get axis for double hinge joint + * @ingroup joints + */ +ODE_API void dJointGetDHingeAxis(dJointID, dVector3 result); + +/** + * @brief set anchor1 for double hinge joint + * @ingroup joints + */ +ODE_API void dJointSetDHingeAnchor1(dJointID, dReal x, dReal y, dReal z); + +/** + * @brief set anchor2 for double hinge joint + * @ingroup joints + */ +ODE_API void dJointSetDHingeAnchor2(dJointID, dReal x, dReal y, dReal z); + +/** + * @brief get anchor1 from double hinge joint + * @ingroup joints + */ +ODE_API void dJointGetDHingeAnchor1(dJointID, dVector3 result); + +/** + * @brief get anchor2 from double hinge joint + * @ingroup joints + */ +ODE_API void dJointGetDHingeAnchor2(dJointID, dVector3 result); + +/** + * @brief get the set distance from double hinge joint + * @ingroup joints + */ +ODE_API dReal dJointGetDHingeDistance(dJointID); + +/** + * @brief set double hinge joint parameter + * @ingroup joints + */ +ODE_API void dJointSetDHingeParam(dJointID, int parameter, dReal value); + +/** + * @brief get double hinge joint parameter + * @ingroup joints + */ +ODE_API dReal dJointGetDHingeParam(dJointID, int parameter); + + + + +/** + * @ingroup joints + */ ODE_API dJointID dConnectingJoint (dBodyID, dBodyID); /** Modified: trunk/ode/demo/Makefile.am =================================================================== --- trunk/ode/demo/Makefile.am 2012-04-22 07:06:35 UTC (rev 1887) +++ trunk/ode/demo/Makefile.am 2012-05-03 14:27:45 UTC (rev 1888) @@ -22,6 +22,8 @@ demo_convex_cd \ demo_crash \ demo_cylvssphere \ + demo_dball \ + demo_dhinge \ demo_feedback \ demo_friction \ demo_gyroscopic \ @@ -54,6 +56,8 @@ demo_convex_cd_DEPENDENCIES = $(top_builddir)/ode/src/libode.la demo_crash_SOURCES = demo_crash.cpp demo_cylvssphere_SOURCES = demo_cylvssphere.cpp +demo_dball_SOURCES = demo_dball.cpp +demo_dhinge_SOURCES = demo_dhinge.cpp demo_feedback_SOURCES = demo_feedback.cpp demo_friction_SOURCES = demo_friction.cpp demo_gyroscopic_SOURCES = demo_gyroscopic.cpp Added: trunk/ode/demo/demo_dball.cpp =================================================================== --- trunk/ode/demo/demo_dball.cpp (rev 0) +++ trunk/ode/demo/demo_dball.cpp 2012-05-03 14:27:45 UTC (rev 1888) @@ -0,0 +1,194 @@ +/************************************************************************* + * * + * 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. * + * * + *************************************************************************/ + +#include <ode/ode.h> +#include <drawstuff/drawstuff.h> +#include "texturepath.h" + +#ifdef dDOUBLE +#define dsDrawSphere dsDrawSphereD +#define dsDrawBox dsDrawBoxD +#define dsDrawLine dsDrawLineD +#endif + + +dWorldID world; +dSpaceID space; +dBodyID body1; +dBodyID body2; +dJointID joint1, joint2; + +void start() +{ + world = dWorldCreate(); + dWorldSetGravity (world,0,0,-9.8); + + dWorldSetDamping(world, 1e-4, 1e-5); +// dWorldSetERP(world, 1); + + space = dSimpleSpaceCreate (0); + + body1 = dBodyCreate(world); + body2 = dBodyCreate(world); + + dBodySetPosition(body1, 0, 0, 3); + dBodySetPosition(body2, 0, 0, 1); + + + dGeomID g; + dMass mass; + + g = dCreateBox(space, 0.2, 0.2, 1); + dGeomSetBody(g, body1); + dMassSetBox(&mass, 1, 0.2, 0.2, 1); + dBodySetMass(body1, &mass); + + g = dCreateBox(space, 0.2, 0.2, 1); + dGeomSetBody(g, body2); + dMassSetBox(&mass, 1, 0.2, 0.2, 1); + dBodySetMass(body2, &mass); + + joint1 = dJointCreateDBall(world, 0); + dJointAttach(joint1, body1, 0); + dJointSetDBallAnchor1(joint1, 0, 0, 3.5); + dJointSetDBallAnchor2(joint1, 0, 0, 4.5); + + joint2 = dJointCreateDBall(world, 0); + dJointAttach(joint2, body1, body2); + dJointSetDBallAnchor1(joint2, 0, 0, 2.5); + dJointSetDBallAnchor2(joint2, 0, 0, 1.5); + + + // initial camera position + static float xyz[3] = {3.8966, -2.0614, 4.0300}; + static float hpr[3] = {153.5, -16.5, 0}; + dsSetViewpoint (xyz,hpr); +} + +void stop() +{ + dSpaceDestroy(space); + + dWorldDestroy(world); +} + + +void drawGeom(dGeomID g) +{ + int gclass = dGeomGetClass(g); + const dReal *pos = dGeomGetPosition(g); + const dReal *rot = dGeomGetRotation(g); + + switch (gclass) { + case dSphereClass: + dsSetColorAlpha(0, 0.75, 0.5, 1); + dsSetTexture (DS_CHECKERED); + dsDrawSphere(pos, rot, dGeomSphereGetRadius(g)); + break; + case dBoxClass: + { + dVector3 lengths; + dsSetColorAlpha(1, 1, 0, 1); + dsSetTexture (DS_WOOD); + dGeomBoxGetLengths(g, lengths); + dsDrawBox(pos, rot, lengths); + break; + } + + default: + {} + } +} + +void simLoop(int pause) +{ + if (!pause) { + + static dReal t = 0; + + const dReal step = 0.005; + const unsigned nsteps = 4; + + for (unsigned i=0; i<nsteps; ++i) { + + dReal f = sin(t*1.2)*0.8; + dBodyAddForceAtRelPos(body1, + f, 0, 0, + 0, 0, -0.5); // at the lower end + + dReal g = sin(t*0.7)*0.8; + dBodyAddForceAtRelPos(body2, + 0, g, 0, + 0, 0, -0.5); // at the lower end + t += step; + + dWorldQuickStep(world, step); + } + } + + // now we draw everything + unsigned ngeoms = dSpaceGetNumGeoms(space); + for (unsigned i=0; i<ngeoms; ++i) { + dGeomID g = dSpaceGetGeom(space, i); + + drawGeom(g); + } + + dVector3 a11, a12; + dJointGetDBallAnchor1(joint1, a11); + dJointGetDBallAnchor2(joint1, a12); + dsSetColor(1, 0, 0); + dsDrawLine(a11, a12); + + //printf("Error 1: %f\n", fabs(dJointGetDBallDistance(joint1) - dCalcPointsDistance3(a11, a12))); + + dVector3 a21, a22; + dJointGetDBallAnchor1(joint2, a21); + dJointGetDBallAnchor2(joint2, a22); + dsSetColor(0, 1, 0); + dsDrawLine(a21, a22); + + //printf("Error 2: %f\n", fabs(dJointGetDBallDistance(joint2) - dCalcPointsDistance3(a21, a22))); +} + + + +int main(int argc, char **argv) +{ + // setup pointers to drawstuff callback functions + dsFunctions fn; + fn.version = DS_VERSION; + fn.start = &start; + fn.step = &simLoop; + fn.command = 0; + fn.stop = stop; + fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH; + + // create world + dInitODE(); + + // run demo + dsSimulationLoop (argc, argv, 800, 600, &fn); + + dCloseODE(); + return 0; +} Property changes on: trunk/ode/demo/demo_dball.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ode/demo/demo_dhinge.cpp =================================================================== --- trunk/ode/demo/demo_dhinge.cpp (rev 0) +++ trunk/ode/demo/demo_dhinge.cpp 2012-05-03 14:27:45 UTC (rev 1888) @@ -0,0 +1,198 @@ +/************************************************************************* + * * + * 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. * + * * + *************************************************************************/ + +#include <ode/ode.h> +#include <drawstuff/drawstuff.h> +#include "texturepath.h" + +#ifdef dDOUBLE +#define dsDrawSphere dsDrawSphereD +#define dsDrawBox dsDrawBoxD +#define dsDrawLine dsDrawLineD +#endif + + +dWorldID world; +dSpaceID space; +dBodyID body1; +dBodyID body2; +dJointID joint1, joint2; + +void start() +{ + world = dWorldCreate(); + dWorldSetGravity (world,0,0,-9.8); + + dWorldSetDamping(world, 1e-4, 1e-5); +// dWorldSetERP(world, 1); + + space = dSimpleSpaceCreate (0); + + body1 = dBodyCreate(world); + body2 = dBodyCreate(world); + + dBodySetPosition(body1, 0, 0, 3); + dBodySetPosition(body2, 0, 0, 1); + + + dGeomID g; + dMass mass; + + g = dCreateBox(space, 0.2, 0.2, 1); + dGeomSetBody(g, body1); + dMassSetBox(&mass, 1, 0.2, 0.2, 1); + dBodySetMass(body1, &mass); + + g = dCreateBox(space, 0.2, 0.2, 1); + dGeomSetBody(g, body2); + dMassSetBox(&mass, 1, 0.2, 0.2, 1); + dBodySetMass(body2, &mass); + + joint1 = dJointCreateDHinge(world, 0); + dJointAttach(joint1, body1, 0); + dJointSetDHingeAxis(joint1, 0, 1, 0); + dJointSetDHingeAnchor1(joint1, 0, 0, 3.5); + dJointSetDHingeAnchor2(joint1, 0, 0, 4.5); + + joint2 = dJointCreateDHinge(world, 0); + dJointAttach(joint2, body1, body2); + dJointSetDHingeAxis(joint2, 1, 0, 0); + dJointSetDHingeAnchor1(joint2, 0, 0, 2.5); + dJointSetDHingeAnchor2(joint2, 0, 0, 1.5); + + + // initial camera position + static float xyz[3] = {3.8966, -2.0614, 4.0300}; + static float hpr[3] = {153.5, -16.5, 0}; + dsSetViewpoint (xyz,hpr); +} + +void stop() +{ + dSpaceDestroy(space); + + dWorldDestroy(world); +} + + +void drawGeom(dGeomID g) +{ + int gclass = dGeomGetClass(g); + const dReal *pos = dGeomGetPosition(g); + const dReal *rot = dGeomGetRotation(g); + + switch (gclass) { + case dSphereClass: + dsSetColorAlpha(0, 0.75, 0.5, 1); + dsSetTexture (DS_CHECKERED); + dsDrawSphere(pos, rot, dGeomSphereGetRadius(g)); + break; + case dBoxClass: + { + dVector3 lengths; + dsSetColorAlpha(1, 1, 0, 1); + dsSetTexture (DS_WOOD); + dGeomBoxGetLengths(g, lengths); + dsDrawBox(pos, rot, lengths); + break; + } + + default: + {} + } +} + +void simLoop(int pause) +{ + if (!pause) { + + static dReal t = 0; + + const dReal step = 0.005; + const unsigned nsteps = 4; + + for (unsigned i=0; i<nsteps; ++i) { + + dReal f = sin(t*1.2)*0.8; + dBodyAddForceAtRelPos(body1, + f, 0, 0, + 0, 0, -0.5); // at the lower end + + dReal g = sin(t*0.7)*0.8; + dBodyAddForceAtRelPos(body2, + 0, g, 0, + 0, 0, -0.5); // at the lower end + + t += step; + + dWorldQuickStep(world, step); + } + } + + // now we draw everything + unsigned ngeoms = dSpaceGetNumGeoms(space); + for (unsigned i=0; i<ngeoms; ++i) { + dGeomID g = dSpaceGetGeom(space, i); + + drawGeom(g); + } + + + dVector3 a11, a12; + dJointGetDHingeAnchor1(joint1, a11); + dJointGetDHingeAnchor2(joint1, a12); + dsSetColor(1, 0, 0); + dsDrawLine(a11, a12); + + //printf("Error 1: %f\n", fabs(dJointGetDHingeDistance(joint1) - dCalcPointsDistance3(a11, a12))); + + dVector3 a21, a22; + dJointGetDHingeAnchor1(joint2, a21); + dJointGetDHingeAnchor2(joint2, a22); + dsSetColor(0, 1, 0); + dsDrawLine(a21, a22); + + //printf("Error 2: %f\n", fabs(dJointGetDHingeDistance(joint2) - dCalcPointsDistance3(a21, a22))); +} + + + +int main(int argc, char **argv) +{ + // setup pointers to drawstuff callback functions + dsFunctions fn; + fn.version = DS_VERSION; + fn.start = &start; + fn.step = &simLoop; + fn.command = 0; + fn.stop = stop; + fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH; + + // create world + dInitODE(); + + // run demo + dsSimulationLoop (argc, argv, 800, 600, &fn); + + dCloseODE(); + return 0; +} Property changes on: trunk/ode/demo/demo_dhinge.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ode/src/joints/Makefile.am =================================================================== --- trunk/ode/src/joints/Makefile.am 2012-04-22 07:06:35 UTC (rev 1887) +++ trunk/ode/src/joints/Makefile.am 2012-05-03 14:27:45 UTC (rev 1888) @@ -6,6 +6,8 @@ joint.h joint.cpp \ joint_internal.h \ ball.h ball.cpp \ + dball.h dball.cpp \ + dhinge.h dhinge.cpp \ hinge.h hinge.cpp \ slider.h slider.cpp \ contact.h contact.cpp \ Added: trunk/ode/src/joints/dball.cpp =================================================================== --- trunk/ode/src/joints/dball.cpp (rev 0) +++ trunk/ode/src/joints/dball.cpp 2012-05-03 14:27:45 UTC (rev 1888) @@ -0,0 +1,306 @@ +/************************************************************************* + * * + * 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. * + * * + *************************************************************************/ + + +#include <ode/odeconfig.h> +#include "config.h" +#include "dball.h" +#include "joint_internal.h" + +/* + * Double Ball joint: tries to maintain a fixed distance between two anchor + * points. + */ + +dxJointDBall::dxJointDBall(dxWorld *w) : + dxJoint(w) +{ + dSetZero(anchor1, 3); + dSetZero(anchor2, 3); + targetDistance = 0; + erp = world->global_erp; + cfm = world->global_cfm; +} + +void +dxJointDBall::getSureMaxInfo( SureMaxInfo* info ) +{ + info->max_m = 1; +} +void +dxJointDBall::getInfo1( dxJoint::Info1 *info ) +{ + info->m = 1; + info->nub = 1; +} + +void +dxJointDBall::getInfo2( dxJoint::Info2 *info ) +{ + info->erp = erp; + info->cfm[0] = cfm; + + dVector3 globalA1, globalA2; + dBodyGetRelPointPos(node[0].body, anchor1[0], anchor1[1], anchor1[2], globalA1); + if (node[1].body) + dBodyGetRelPointPos(node[1].body, anchor2[0], anchor2[1], anchor2[2], globalA2); + else + dCopyVector3(globalA2, anchor2); + + dVector3 q; + dSubtractVectors3(q, globalA1, globalA2); + +#ifdef dSINGLE + const dReal MIN_LENGTH = REAL(1e-7); +#else + const dReal MIN_LENGTH = REAL(1e-12); +#endif + + if (dCalcVectorLength3(q) < MIN_LENGTH) { + // too small, let's choose an arbitrary direction + // heuristic: difference in velocities at anchors + dVector3 v1, v2; + dBodyGetPointVel(node[0].body, globalA1[0], globalA1[1], globalA1[2], v1); + if (node[1].body) + dBodyGetPointVel(node[1].body, globalA2[0], globalA2[1], globalA2[2], v2); + else + dSetZero(v2, 3); + dSubtractVectors3(q, v1, v2); + + if (dCalcVectorLength3(q) < MIN_LENGTH) { + // this direction is as good as any + q[0] = 1; + q[1] = 0; + q[2] = 0; + } + } + dNormalize3(q); + + info->J1l[0] = q[0]; + info->J1l[1] = q[1]; + info->J1l[2] = q[2]; + + dVector3 relA1; + dBodyVectorToWorld(node[0].body, + anchor1[0], anchor1[1], anchor1[2], + relA1); + + dMatrix3 a1m; + dSetZero(a1m, 12); + dSetCrossMatrixMinus(a1m, relA1, 4); + + dMultiply1_331(info->J1a, a1m, q); + + if (node[1].body) { + info->J2l[0] = -q[0]; + info->J2l[1] = -q[1]; + info->J2l[2] = -q[2]; + + dVector3 relA2; + dBodyVectorToWorld(node[1].body, + anchor2[0], anchor2[1], anchor2[2], + relA2); + dMatrix3 a2m; + dSetZero(a2m, 12); + dSetCrossMatrixPlus(a2m, relA2, 4); + dMultiply1_331(info->J2a, a2m, q); + } + + const dReal k = info->fps * info->erp; + info->c[0] = k * (targetDistance - dCalcPointsDistance3(globalA1, globalA2)); + +} + + +void +dxJointDBall::updateTargetDistance() +{ + dVector3 p1, p2; + + if (node[0].body) + dBodyGetRelPointPos(node[0].body, anchor1[0], anchor1[1], anchor1[2], p1); + else + dCopyVector3(p1, anchor1); + if (node[1].body) + dBodyGetRelPointPos(node[1].body, anchor2[0], anchor2[1], anchor2[2], p2); + else + dCopyVector3(p2, anchor2); + + targetDistance = dCalcPointsDistance3(p1, p2); +} + + +void dJointSetDBallAnchor1( dJointID j, dReal x, dReal y, dReal z ) +{ + dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dUASSERT( joint, "bad joint argument" ); + + if ( joint->flags & dJOINT_REVERSE ) { + if (joint->node[1].body) + dBodyGetPosRelPoint(joint->node[1].body, x, y, z, joint->anchor2); + else { + joint->anchor2[0] = x; + joint->anchor2[1] = y; + joint->anchor2[2] = z; + } + } else { + if (joint->node[0].body) + dBodyGetPosRelPoint(joint->node[0].body, x, y, z, joint->anchor1); + else { + joint->anchor1[0] = x; + joint->anchor1[1] = y; + joint->anchor1[2] = z; + } + } + + joint->updateTargetDistance(); +} + + +void dJointSetDBallAnchor2( dJointID j, dReal x, dReal y, dReal z ) +{ + dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dUASSERT( joint, "bad joint argument" ); + + + if ( joint->flags & dJOINT_REVERSE ) { + if (joint->node[0].body) + dBodyGetPosRelPoint(joint->node[0].body, x, y, z, joint->anchor1); + else { + joint->anchor1[0] = x; + joint->anchor1[1] = y; + joint->anchor1[2] = z; + } + } else { + if (joint->node[1].body) + dBodyGetPosRelPoint(joint->node[1].body, x, y, z, joint->anchor2); + else { + joint->anchor2[0] = x; + joint->anchor2[1] = y; + joint->anchor2[2] = z; + } + } + + joint->updateTargetDistance(); +} + +dReal dJointGetDBallDistance(dJointID j) +{ + dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dUASSERT( joint, "bad joint argument" ); + + return joint->targetDistance; +} + + +void dJointGetDBallAnchor1( dJointID j, dVector3 result ) +{ + dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dUASSERT( joint, "bad joint argument" ); + dUASSERT( result, "bad result argument" ); + + if ( joint->flags & dJOINT_REVERSE ) { + if (joint->node[1].body) + dBodyGetRelPointPos(joint->node[1].body, joint->anchor2[0], joint->anchor2[1], joint->anchor2[2], result); + else + dCopyVector3(result, joint->anchor2); + } else { + if (joint->node[0].body) + dBodyGetRelPointPos(joint->node[0].body, joint->anchor1[0], joint->anchor1[1], joint->anchor1[2], result); + else + dCopyVector3(result, joint->anchor1); + } +} + + +void dJointGetDBallAnchor2( dJointID j, dVector3 result ) +{ + dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dUASSERT( joint, "bad joint argument" ); + dUASSERT( result, "bad result argument" ); + + if ( joint->flags & dJOINT_REVERSE ) { + if (joint->node[0].body) + dBodyGetRelPointPos(joint->node[0].body, joint->anchor1[0], joint->anchor1[1], joint->anchor1[2], result); + else + dCopyVector3(result, joint->anchor1); + } else { + if (joint->node[1].body) + dBodyGetRelPointPos(joint->node[1].body, joint->anchor2[0], joint->anchor2[1], joint->anchor2[2], result); + else + dCopyVector3(result, joint->anchor2); + } +} + + +void dJointSetDBallParam( dJointID j, int parameter, dReal value ) +{ + dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dUASSERT( joint, "bad joint argument" ); + + switch ( parameter ) { + case dParamCFM: + joint->cfm = value; + break; + case dParamERP: + joint->erp = value; + break; + } +} + + +dReal dJointGetDBallParam( dJointID j, int parameter ) +{ + dxJointDBall* joint = dynamic_cast<dxJointDBall*>(j); + dUASSERT( joint, "bad joint argument" ); + + switch ( parameter ) { + case dParamCFM: + return joint->cfm; + case dParamERP: + return joint->erp; + default: + return 0; + } +} + + +dJointType +dxJointDBall::type() const +{ + return dJointTypeDBall; +} + +size_t +dxJointDBall::size() const +{ + return sizeof( *this ); +} + +void +dxJointDBall::setRelativeValues() +{ + updateTargetDistance(); +} + + + Property changes on: trunk/ode/src/joints/dball.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ode/src/joints/dball.h =================================================================== --- trunk/ode/src/joints/dball.h (rev 0) +++ trunk/ode/src/joints/dball.h 2012-05-03 14:27:45 UTC (rev 1888) @@ -0,0 +1,55 @@ +/************************************************************************* + * * + * 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_JOINT_DBALL_H_ +#define _ODE_JOINT_DBALL_H_ + +#include "joint.h" + +// ball and socket + +struct dxJointDBall : public dxJoint +{ + dVector3 anchor1; // anchor w.r.t first body + dVector3 anchor2; // anchor w.r.t second body + dReal erp; // error reduction + dReal cfm; // constraint force mix in + dReal targetDistance; + + void set( int num, dReal value ); + dReal get( int num ); + + void updateTargetDistance(); + + dxJointDBall( dxWorld *w ); + virtual void getSureMaxInfo( SureMaxInfo* info ); + virtual void getInfo1( Info1* info ); + virtual void getInfo2( Info2* info ); + virtual dJointType type() const; + virtual size_t size() const; + + virtual void setRelativeValues(); +}; + + +#endif + Property changes on: trunk/ode/src/joints/dball.h ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ode/src/joints/dhinge.cpp =================================================================== --- trunk/ode/src/joints/dhinge.cpp (rev 0) +++ trunk/ode/src/joints/dhinge.cpp 2012-05-03 14:27:45 UTC (rev 1888) @@ -0,0 +1,201 @@ +/************************************************************************* + * * + * 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. * + * * + *************************************************************************/ + + +#include <ode/odeconfig.h> +#include "config.h" +#include "dhinge.h" +#include "joint_internal.h" + +/* + * Double Hinge joint + */ + +dxJointDHinge::dxJointDHinge(dxWorld* w) : + dxJointDBall(w) +{ + dSetZero(axis1, 3); + dSetZero(axis2, 3); +} + + +void +dxJointDHinge::getSureMaxInfo( SureMaxInfo* info ) +{ + info->max_m = 4; +} + + +void +dxJointDHinge::getInfo1( dxJoint::Info1* info ) +{ + info->m = 4; + info->nub = 4; +} + + +void +dxJointDHinge::getInfo2( dxJoint::Info2* info ) +{ + dxJointDBall::getInfo2( info ); // sets row0 + + const int skip = info->rowskip; + const int row1 = skip; + const int row2 = 2*skip; + const int row3 = 3*skip; + + dVector3 globalAxis1; + dBodyVectorToWorld(node[0].body, axis1[0], axis1[1], axis1[2], globalAxis1); + + // angular constraints, perpendicular to axis + dVector3 p, q; + dPlaneSpace(globalAxis1, p, q); + info->J1a[row1+0] = p[0]; + info->J1a[row1+1] = p[1]; + info->J1a[row1+2] = p[2]; + info->J1a[row2+0] = q[0]; + info->J1a[row2+1] = q[1]; + info->J1a[row2+2] = q[2]; + + if ( node[1].body ) { + info->J2a[row1+0] = -p[0]; + info->J2a[row1+1] = -p[1]; + info->J2a[row1+2] = -p[2]; + info->J2a[row2+0] = -q[0]; + info->J2a[row2+1] = -q[1]; + info->J2a[row2+2] = -q[2]; + } + + dVector3 globalAxis2; + if ( node[1].body ) + dBodyVectorToWorld(node[1].body, axis2[0], axis2[1], axis2[2], globalAxis2); + else + dCopyVector3(globalAxis2, axis2); + + // similar to the hinge joint + dVector3 u; + dCalcVectorCross3(u, globalAxis1, globalAxis2); + const dReal k = info->fps * info->erp; + + info->c[1] = k * dCalcVectorDot3( u, p ); + info->c[2] = k * dCalcVectorDot3( u, q ); + + + // linear constraint, along the axis + info->J1l[row3+0] = globalAxis1[0]; + info->J1l[row3+1] = globalAxis1[1]; + info->J1l[row3+2] = globalAxis1[2]; + if ( node[1].body ) { + info->J2l[row3+0] = -globalAxis1[0]; + info->J2l[row3+1] = -globalAxis1[1]; + info->J2l[row3+2] = -globalAxis1[2]; + } + + dVector3 globalA1, globalA2; + dBodyGetRelPointPos(node[0].body, anchor1[0], anchor1[1], anchor1[2], globalA1); + if ( node[1].body ) + dBodyGetRelPointPos(node[1].body, anchor2[0], anchor2[1], anchor2[2], globalA2); + else + dCopyVector3(globalA2, anchor2); + + dVector3 d; + dSubtractVectors3(d, globalA1, globalA2); + info->c[3] = -k * dCalcVectorDot3(globalAxis1, d); +} + +void dJointSetDHingeAxis( dJointID j, dReal x, dReal y, dReal z ) +{ + dxJointDHinge* joint = dynamic_cast<dxJointDHinge*>(j); + dUASSERT( joint, "bad joint argument" ); + + dBodyVectorFromWorld(joint->node[0].body, x, y, z, joint->axis1); + if (joint->node[1].body) + dBodyVectorFromWorld(joint->node[1].body, x, y, z, joint->axis2); + else { + joint->axis2[0] = x; + joint->axis2[1] = y; + joint->axis2[2] = z; + } + dNormalize3(joint->axis1); + dNormalize3(joint->axis2); +} + +void dJointGetDHingeAxis( dJointID j, dVector3 result ) +{ + dxJointDHinge* joint = dynamic_cast<dxJointDHinge*>(j); + dUASSERT( joint, "bad joint argument" ); + + dBodyVectorFromWorld(joint->node[0].body, joint->axis1[0], joint->axis1[1], joint->axis1[2], result); +} + + +void dJointSetDHingeAnchor1( dJointID j, dReal x, dReal y, dReal z ) +{ + dJointSetDBallAnchor1(j, x, y, z); +} + + +void dJointSetDHingeAnchor2( dJointID j, dReal x, dReal y, dReal z ) +{ + dJointSetDBallAnchor2(j, x, y, z); +} + +dReal dJointGetDHingeDistance(dJointID j) +{ + return dJointGetDBallDistance(j); +} + + +void dJointGetDHingeAnchor1( dJointID j, dVector3 result ) +{ + dJointGetDBallAnchor1(j, result); +} + + +void dJointGetDHingeAnchor2( dJointID j, dVector3 result ) +{ + dJointGetDBallAnchor2(j, result); +} + + +void dJointSetDHingeParam( dJointID j, int parameter, dReal value ) +{ + dJointSetDBallParam(j, parameter, value); +} + + +dReal dJointGetDHingeParam( dJointID j, int parameter ) +{ + return dJointGetDBallParam(j, parameter); +} + +dJointType +dxJointDHinge::type() const +{ + return dJointTypeDHinge; +} + +size_t +dxJointDHinge::size() const +{ + return sizeof( *this ); +} Property changes on: trunk/ode/src/joints/dhinge.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ode/src/joints/dhinge.h =================================================================== --- trunk/ode/src/joints/dhinge.h (rev 0) +++ trunk/ode/src/joints/dhinge.h 2012-05-03 14:27:45 UTC (rev 1888) @@ -0,0 +1,43 @@ +/************************************************************************* + * * + * 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_JOINT_DHINGE_ +#define _ODE_JOINT_DHINGE_ + +#include "dball.h" + +struct dxJointDHinge : public dxJointDBall +{ + dVector3 axis1, axis2; + + dxJointDHinge(dxWorld *w); + + virtual void getSureMaxInfo( SureMaxInfo* info ); + virtual void getInfo1( Info1* info ); + virtual void getInfo2( Info2* info ); + virtual dJointType type() const; + virtual size_t size() const; + +}; + + +#endif Property changes on: trunk/ode/src/joints/dhinge.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ode/src/joints/joints.h =================================================================== --- trunk/ode/src/joints/joints.h 2012-04-22 07:06:35 UTC (rev 1887) +++ trunk/ode/src/joints/joints.h 2012-05-03 14:27:45 UTC (rev 1888) @@ -28,6 +28,8 @@ #include "joint.h" #include "ball.h" +#include "dball.h" +#include "dhinge.h" #include "hinge.h" #include "slider.h" #include "contact.h" Modified: trunk/ode/src/ode.cpp =================================================================== --- trunk/ode/src/ode.cpp 2012-04-22 07:06:35 UTC (rev 1887) +++ trunk/ode/src/ode.cpp 2012-05-03 14:27:45 UTC (rev 1888) @@ -1257,6 +1257,19 @@ return createJoint<dxJointPlane2D> (w,group); } +dxJoint * dJointCreateDBall (dWorldID w, dJointGroupID group) +{ + dAASSERT (w); + return createJoint<dxJointDBall> (w,group); +} + +dxJoint * dJointCreateDHinge (dWorldID w, dJointGroupID group) +{ + dAASSERT (w); + return createJoint<dxJointDHinge> (w,group); +} + + static void FinalizeAndDestroyJointInstance(dxJoint *j, bool delete_it) { // if any group joints have their world pointer set to 0, their world was This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-04-22 07:06:42
|
Revision: 1887 http://opende.svn.sourceforge.net/opende/?rev=1887&view=rev Author: danielosmari Date: 2012-04-22 07:06:35 +0000 (Sun, 22 Apr 2012) Log Message: ----------- fixed uninitialized variable bug in plane2d, fixed autoconf build broken on last commit Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/joints/Makefile.am trunk/ode/src/joints/plane2d.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-04-14 16:56:37 UTC (rev 1886) +++ trunk/CHANGELOG.txt 2012-04-22 07:06:35 UTC (rev 1887) @@ -8,6 +8,10 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +04/22/12 Daniel K. O. + * Fixed plane2d joint: uninitialized variables (reported by Dimitris + Papavasiliou) + 04/14/12 Oleh Derevenko * Assertion checking macros moved into library private headers. Modified: trunk/ode/src/joints/Makefile.am =================================================================== --- trunk/ode/src/joints/Makefile.am 2012-04-14 16:56:37 UTC (rev 1886) +++ trunk/ode/src/joints/Makefile.am 2012-04-22 07:06:35 UTC (rev 1887) @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/ode/src noinst_LTLIBRARIES = libjoints.la Modified: trunk/ode/src/joints/plane2d.cpp =================================================================== --- trunk/ode/src/joints/plane2d.cpp 2012-04-14 16:56:37 UTC (rev 1886) +++ trunk/ode/src/joints/plane2d.cpp 2012-04-22 07:06:35 UTC (rev 1887) @@ -75,11 +75,19 @@ info->m = 3; if ( motor_x.fmax > 0 ) - row_motor_x = info->m ++; + row_motor_x = info->m++; + else + row_motor_x = 0; + if ( motor_y.fmax > 0 ) - row_motor_y = info->m ++; + row_motor_y = info->m++; + else + row_motor_y = 0; + if ( motor_angle.fmax > 0 ) - row_motor_angle = info->m ++; + row_motor_angle = info->m++; + else + row_motor_angle = 0; } @@ -90,14 +98,14 @@ int r0 = 0; int r1 = info->rowskip; int r2 = 2 * r1; - dReal eps = info->fps * info->erp; + dReal eps = info->fps * info->erp; /* v = v1, w = omega1 (v2, omega2 not important (== static environment)) constraint equations: - xz = 0 + vz = 0 wx = 0 wy = 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-04-14 16:56:45
|
Revision: 1886 http://opende.svn.sourceforge.net/opende/?rev=1886&view=rev Author: oleh_derevenko Date: 2012-04-14 16:56:37 +0000 (Sat, 14 Apr 2012) Log Message: ----------- Assertion checking macros moved into library private headers Modified Paths: -------------- trunk/CHANGELOG.txt trunk/include/ode/error.h trunk/include/ode/odemath.h trunk/ode/demo/demo_heightfield.cpp 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_libccd.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_distance.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/collision_util.cpp trunk/ode/src/collision_util.h 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/mass.cpp trunk/ode/src/objects.h trunk/ode/src/ode.cpp trunk/ode/src/odeinit.cpp trunk/ode/src/odemath.cpp trunk/ode/src/odetls.cpp trunk/ode/src/plane.cpp trunk/ode/src/quickstep.cpp trunk/ode/src/ray.cpp trunk/ode/src/rotation.cpp trunk/ode/src/sphere.cpp trunk/ode/src/step.cpp trunk/ode/src/threading_base.cpp Added Paths: ----------- trunk/ode/src/error.h trunk/ode/src/odemath.h Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/CHANGELOG.txt 2012-04-14 16:56:37 UTC (rev 1886) @@ -8,6 +8,9 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +04/14/12 Oleh Derevenko + * Assertion checking macros moved into library private headers. + 04/13/12 Daniel K. O. * Applied patch from bug #3431829 - better handling of capsule-box with deep penetrations. Modified: trunk/include/ode/error.h =================================================================== --- trunk/include/ode/error.h 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/include/ode/error.h 2012-04-14 16:56:37 UTC (rev 1886) @@ -56,57 +56,6 @@ ODE_API void dMessage (int num, const char *msg, ...); - - -/* debugging: - * IASSERT is an internal assertion, i.e. a consistency check. if it fails - * we want to know where. - * UASSERT is a user assertion, i.e. if it fails a nice error message - * should be printed for the user. - * AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)" - * is printed. - * DEBUGMSG just prints out a message - */ - -# if defined(__STDC__) && __STDC_VERSION__ >= 199901L -# define __FUNCTION__ __func__ -# endif -#ifndef dNODEBUG -# ifdef __GNUC__ -# define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ - "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); } } -# define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \ - msg " in %s()", __FUNCTION__); } } -# define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \ - msg " in %s() [%s:%u]", __FUNCTION__,__FILE__,__LINE__); } -# else // not __GNUC__ -# define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ - "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); } } -# define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \ - msg " (%s:%u)", __FILE__,__LINE__); } } -# define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \ - msg " (%s:%u)", __FILE__,__LINE__); } -# endif -# define dIVERIFY(a) dIASSERT(a) -#else -# define dIASSERT(a) ((void)0) -# define dUASSERT(a,msg) ((void)0) -# define dDEBUGMSG(msg) ((void)0) -# define dIVERIFY(a) ((void)(a)) -#endif - -# ifdef __GNUC__ -# define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ - "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); *(int *)0 = 0; } } -# else // not __GNUC__ -# define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ - "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); *(int *)0 = 0; } } -# endif - -// Argument assert is a special case of user assert -#define dAASSERT(a) dUASSERT(a,"Bad argument(s)") - - #ifdef __cplusplus } #endif Modified: trunk/include/ode/odemath.h =================================================================== --- trunk/include/ode/odemath.h 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/include/ode/odemath.h 2012-04-14 16:56:37 UTC (rev 1886) @@ -426,31 +426,6 @@ ODE_API void dNormalize3 (dVector3 a); // Potentially asserts on zero vec ODE_API void dNormalize4 (dVector4 a); // Potentially asserts on zero vec -#if defined(__ODE__) - -int _dSafeNormalize3 (dVector3 a); -int _dSafeNormalize4 (dVector4 a); - -ODE_PURE_INLINE void _dNormalize3(dVector3 a) -{ - int bNormalizationResult = _dSafeNormalize3(a); - dIVERIFY(bNormalizationResult); -} - -ODE_PURE_INLINE void _dNormalize4(dVector4 a) -{ - int bNormalizationResult = _dSafeNormalize4(a); - dIVERIFY(bNormalizationResult); -} - -// For internal use -#define dSafeNormalize3(a) _dSafeNormalize3(a) -#define dSafeNormalize4(a) _dSafeNormalize4(a) -#define dNormalize3(a) _dNormalize3(a) -#define dNormalize4(a) _dNormalize4(a) - -#endif // defined(__ODE__) - /* * given a unit length "normal" vector n, generate vectors p and q vectors * that are an orthonormal basis for the plane space perpendicular to n. Modified: trunk/ode/demo/demo_heightfield.cpp =================================================================== --- trunk/ode/demo/demo_heightfield.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/demo/demo_heightfield.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -155,9 +155,6 @@ dReal heightfield_callback( void* pUserData, int x, int z ) { - dIASSERT( x < HFIELD_WSTEP ); - dIASSERT( z < HFIELD_DSTEP ); - dReal fx = ( ((dReal)x) - ( HFIELD_WSTEP-1 )/2 ) / (dReal)( HFIELD_WSTEP-1 ); dReal fz = ( ((dReal)z) - ( HFIELD_DSTEP-1 )/2 ) / (dReal)( HFIELD_DSTEP-1 ); Modified: trunk/ode/src/Makefile.am =================================================================== --- trunk/ode/src/Makefile.am 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/Makefile.am 2012-04-14 16:56:37 UTC (rev 1886) @@ -35,7 +35,7 @@ collision_util.cpp collision_util.h \ convex.cpp \ cylinder.cpp \ - error.cpp \ + error.cpp error.h \ export-dif.cpp \ heightfield.cpp heightfield.h \ lcp.cpp lcp.h \ @@ -48,7 +48,7 @@ obstack.cpp obstack.h \ ode.cpp \ odeinit.cpp \ - odemath.cpp \ + odemath.cpp odemath.h \ odeou.h \ odetls.h \ plane.cpp \ Modified: trunk/ode/src/box.cpp =================================================================== --- trunk/ode/src/box.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/box.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -33,8 +33,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Modified: trunk/ode/src/capsule.cpp =================================================================== --- trunk/ode/src/capsule.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/capsule.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -33,8 +33,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Modified: trunk/ode/src/collision_cylinder_box.cpp =================================================================== --- trunk/ode/src/collision_cylinder_box.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_cylinder_box.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -28,8 +28,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_util.h" static const int MAX_CYLBOX_CLIP_POINTS = 16; Modified: trunk/ode/src/collision_cylinder_plane.cpp =================================================================== --- trunk/ode/src/collision_cylinder_plane.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_cylinder_plane.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -32,10 +32,9 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include <ode/objects.h> - #include "config.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-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_cylinder_sphere.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -43,10 +43,9 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include <ode/objects.h> - #include "config.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-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_cylinder_trimesh.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -29,8 +29,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_util.h" #include "collision_trimesh_internal.h" #include "util.h" Modified: trunk/ode/src/collision_kernel.cpp =================================================================== --- trunk/ode/src/collision_kernel.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_kernel.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -31,8 +31,8 @@ #include <ode/matrix.h> #include <ode/rotation.h> #include <ode/objects.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_util.h" #include "collision_std.h" Modified: trunk/ode/src/collision_libccd.cpp =================================================================== --- trunk/ode/src/collision_libccd.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_libccd.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -21,12 +21,14 @@ *************************************************************************/ #include <ode/collision.h> -#include <ode/odemath.h> #include <ccd/ccd.h> #include <ccd/quat.h> +#include "config.h" +#include "odemath.h" #include "collision_libccd.h" #include "collision_std.h" + struct _ccd_obj_t { ccd_vec3_t pos; ccd_quat_t rot, rot_inv; Modified: trunk/ode/src/collision_transform.cpp =================================================================== --- trunk/ode/src/collision_transform.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_transform.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -29,8 +29,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.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-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_box.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -32,8 +32,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.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-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_ccylinder.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -53,8 +53,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_util.h" #include "collision_trimesh_internal.h" #include "util.h" Modified: trunk/ode/src/collision_trimesh_distance.cpp =================================================================== --- trunk/ode/src/collision_trimesh_distance.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_distance.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -25,9 +25,9 @@ // that can be found at http://www.magic-software.com/License/free.pdf #include <ode/common.h> -#include <ode/odemath.h> #include <ode/collision.h> #include "config.h" +#include "odemath.h" #include "collision_trimesh_internal.h" //------------------------------------------------------------------------------ Modified: trunk/ode/src/collision_trimesh_gimpact.cpp =================================================================== --- trunk/ode/src/collision_trimesh_gimpact.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_gimpact.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -23,8 +23,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #if dTRIMESH_ENABLED Modified: trunk/ode/src/collision_trimesh_opcode.cpp =================================================================== --- trunk/ode/src/collision_trimesh_opcode.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_opcode.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -25,8 +25,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.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-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_plane.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -25,8 +25,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #if dTRIMESH_ENABLED Modified: trunk/ode/src/collision_trimesh_ray.cpp =================================================================== --- trunk/ode/src/collision_trimesh_ray.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_ray.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -25,8 +25,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #if dTRIMESH_ENABLED Modified: trunk/ode/src/collision_trimesh_sphere.cpp =================================================================== --- trunk/ode/src/collision_trimesh_sphere.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_sphere.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -25,8 +25,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_util.h" #ifdef HAVE_CONFIG_H Modified: trunk/ode/src/collision_trimesh_trimesh.cpp =================================================================== --- trunk/ode/src/collision_trimesh_trimesh.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_trimesh.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -29,8 +29,10 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" + + // Classic Implementation #if dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER Modified: trunk/ode/src/collision_trimesh_trimesh_new.cpp =================================================================== --- trunk/ode/src/collision_trimesh_trimesh_new.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_trimesh_trimesh_new.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -30,9 +30,10 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" + // New Implementation #if !dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER Modified: trunk/ode/src/collision_util.cpp =================================================================== --- trunk/ode/src/collision_util.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_util.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -29,8 +29,8 @@ #include <ode/common.h> #include <ode/collision.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_util.h" //**************************************************************************** Modified: trunk/ode/src/collision_util.h =================================================================== --- trunk/ode/src/collision_util.h 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/collision_util.h 2012-04-14 16:56:37 UTC (rev 1886) @@ -31,8 +31,8 @@ #include <ode/common.h> #include <ode/contact.h> -#include <ode/odemath.h> #include <ode/rotation.h> +#include "odemath.h" // given a pointer `p' to a dContactGeom, return the dContactGeom at Modified: trunk/ode/src/convex.cpp =================================================================== --- trunk/ode/src/convex.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/convex.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -27,8 +27,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Modified: trunk/ode/src/cylinder.cpp =================================================================== --- trunk/ode/src/cylinder.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/cylinder.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -33,8 +33,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Added: trunk/ode/src/error.h =================================================================== --- trunk/ode/src/error.h (rev 0) +++ trunk/ode/src/error.h 2012-04-14 16:56:37 UTC (rev 1886) @@ -0,0 +1,81 @@ +/************************************************************************* + * * + * 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. * + * * + *************************************************************************/ + +/* Library private error handling functions and macros */ + +#ifndef _ODE__PRIVATE_ERROR_H_ +#define _ODE__PRIVATE_ERROR_H_ + +#include <ode/error.h> + + + +/* debugging: + * IASSERT is an internal assertion, i.e. a consistency check. if it fails + * we want to know where. + * UASSERT is a user assertion, i.e. if it fails a nice error message + * should be printed for the user. + * AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)" + * is printed. + * DEBUGMSG just prints out a message + */ + +# if defined(__STDC__) && __STDC_VERSION__ >= 199901L +# define __FUNCTION__ __func__ +# endif +#ifndef dNODEBUG +# ifdef __GNUC__ +# define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ + "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); } } +# define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \ + msg " in %s()", __FUNCTION__); } } +# define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \ + msg " in %s() [%s:%u]", __FUNCTION__,__FILE__,__LINE__); } +# else // not __GNUC__ +# define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ + "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); } } +# define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \ + msg " (%s:%u)", __FILE__,__LINE__); } } +# define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \ + msg " (%s:%u)", __FILE__,__LINE__); } +# endif +# define dIVERIFY(a) dIASSERT(a) +#else +# define dIASSERT(a) ((void)0) +# define dUASSERT(a,msg) ((void)0) +# define dDEBUGMSG(msg) ((void)0) +# define dIVERIFY(a) ((void)(a)) +#endif + +# ifdef __GNUC__ +# define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ + "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); *(int *)0 = 0; } } +# else // not __GNUC__ +# define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \ + "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); *(int *)0 = 0; } } +# endif + +// Argument assert is a special case of user assert +#define dAASSERT(a) dUASSERT(a,"Bad argument(s)") + + +#endif Property changes on: trunk/ode/src/error.h ___________________________________________________________________ Added: svn:mime-type + text/cpp Added: svn:eol-style + native Modified: trunk/ode/src/heightfield.cpp =================================================================== --- trunk/ode/src/heightfield.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/heightfield.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -32,8 +32,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Modified: trunk/ode/src/joints/joint.cpp =================================================================== --- trunk/ode/src/joints/joint.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/joints/joint.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -30,10 +30,10 @@ */ #include <ode/ode.h> -#include <ode/odemath.h> #include <ode/rotation.h> #include <ode/matrix.h> #include "config.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-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/joints/joint_internal.h 2012-04-14 16:56:37 UTC (rev 1886) @@ -26,10 +26,11 @@ #include <ode/matrix.h> -#include <ode/odemath.h> #include <ode/rotation.h> #include <ode/objects.h> +#include "odemath.h" + #define checktype(j,t) dUASSERT(j->type() == dJointType##t, \ "joint type is not " #t) Modified: trunk/ode/src/mass.cpp =================================================================== --- trunk/ode/src/mass.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/mass.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -22,9 +22,9 @@ #include <ode/odeconfig.h> #include <ode/mass.h> -#include <ode/odemath.h> #include <ode/matrix.h> #include "config.h" +#include "odemath.h" // Local dependencies #include "collision_kernel.h" Modified: trunk/ode/src/objects.h =================================================================== --- trunk/ode/src/objects.h 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/objects.h 2012-04-14 16:56:37 UTC (rev 1886) @@ -29,6 +29,7 @@ #include <ode/common.h> #include <ode/memory.h> #include <ode/mass.h> +#include "error.h" #include "array.h" #include "threading_base.h" Modified: trunk/ode/src/ode.cpp =================================================================== --- trunk/ode/src/ode.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/ode.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -28,11 +28,11 @@ // numerics. #include <ode/ode.h> -#include <ode/odemath.h> #include <ode/matrix.h> #include <ode/memory.h> #include <ode/error.h> #include "config.h" +#include "odemath.h" #include "objects.h" #include "joints/joints.h" #include "step.h" Modified: trunk/ode/src/odeinit.cpp =================================================================== --- trunk/ode/src/odeinit.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/odeinit.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -27,11 +27,11 @@ */ #include <ode/common.h> -#include <ode/odemath.h> #include <ode/odeinit.h> // <ode/objects.h> included for dWorldQuickStepCleanup() #include <ode/objects.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_trimesh_internal.h" #include "odetls.h" Modified: trunk/ode/src/odemath.cpp =================================================================== --- trunk/ode/src/odemath.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/odemath.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -21,8 +21,8 @@ *************************************************************************/ #include <ode/common.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #undef dSafeNormalize3 Added: trunk/ode/src/odemath.h =================================================================== --- trunk/ode/src/odemath.h (rev 0) +++ trunk/ode/src/odemath.h 2012-04-14 16:56:37 UTC (rev 1886) @@ -0,0 +1,52 @@ +/************************************************************************* + * * + * 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__PRIVATE_ODEMATH_H_ +#define _ODE__PRIVATE_ODEMATH_H_ + +#include <ode/odemath.h> +#include "error.h" + + +int _dSafeNormalize3 (dVector3 a); +int _dSafeNormalize4 (dVector4 a); + +ODE_PURE_INLINE void _dNormalize3(dVector3 a) +{ + int bNormalizationResult = _dSafeNormalize3(a); + dIVERIFY(bNormalizationResult); +} + +ODE_PURE_INLINE void _dNormalize4(dVector4 a) +{ + int bNormalizationResult = _dSafeNormalize4(a); + dIVERIFY(bNormalizationResult); +} + +// For internal use +#define dSafeNormalize3(a) _dSafeNormalize3(a) +#define dSafeNormalize4(a) _dSafeNormalize4(a) +#define dNormalize3(a) _dNormalize3(a) +#define dNormalize4(a) _dNormalize4(a) + + +#endif Property changes on: trunk/ode/src/odemath.h ___________________________________________________________________ Added: svn:mime-type + text/cpp Added: svn:eol-style + native Modified: trunk/ode/src/odetls.cpp =================================================================== --- trunk/ode/src/odetls.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/odetls.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -32,8 +32,8 @@ */ #include <ode/common.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "odetls.h" #include "collision_trimesh_internal.h" #include "util.h" Modified: trunk/ode/src/plane.cpp =================================================================== --- trunk/ode/src/plane.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/plane.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -33,8 +33,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Modified: trunk/ode/src/quickstep.cpp =================================================================== --- trunk/ode/src/quickstep.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/quickstep.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -21,13 +21,13 @@ *************************************************************************/ #include <ode/common.h> -#include <ode/odemath.h> #include <ode/rotation.h> #include <ode/timer.h> #include <ode/error.h> #include <ode/matrix.h> #include <ode/misc.h> #include "config.h" +#include "odemath.h" #include "objects.h" #include "joints/joint.h" #include "lcp.h" Modified: trunk/ode/src/ray.cpp =================================================================== --- trunk/ode/src/ray.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/ray.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -33,8 +33,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Modified: trunk/ode/src/rotation.cpp =================================================================== --- trunk/ode/src/rotation.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/rotation.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -28,8 +28,8 @@ */ #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #define _R(i,j) R[(i)*4+(j)] Modified: trunk/ode/src/sphere.cpp =================================================================== --- trunk/ode/src/sphere.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/sphere.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -33,8 +33,8 @@ #include <ode/collision.h> #include <ode/matrix.h> #include <ode/rotation.h> -#include <ode/odemath.h> #include "config.h" +#include "odemath.h" #include "collision_kernel.h" #include "collision_std.h" #include "collision_util.h" Modified: trunk/ode/src/step.cpp =================================================================== --- trunk/ode/src/step.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/step.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -21,12 +21,12 @@ *************************************************************************/ #include <ode/odeconfig.h> -#include <ode/odemath.h> #include <ode/rotation.h> #include <ode/timer.h> #include <ode/error.h> #include <ode/matrix.h> #include "config.h" +#include "odemath.h" #include "objects.h" #include "joints/joint.h" #include "lcp.h" Modified: trunk/ode/src/threading_base.cpp =================================================================== --- trunk/ode/src/threading_base.cpp 2012-04-14 08:40:31 UTC (rev 1885) +++ trunk/ode/src/threading_base.cpp 2012-04-14 16:56:37 UTC (rev 1886) @@ -32,6 +32,7 @@ #include <ode/common.h> #include "config.h" +#include "error.h" #include "threading_base.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-04-14 08:40:38
|
Revision: 1885 http://opende.svn.sourceforge.net/opende/?rev=1885&view=rev Author: oleh_derevenko Date: 2012-04-14 08:40:31 +0000 (Sat, 14 Apr 2012) Log Message: ----------- Indentation corrected in new code. MSVC compilation error fixed. Modified Paths: -------------- trunk/include/ode/common.h trunk/ode/src/capsule.cpp trunk/ode/src/joints/contact.cpp Modified: trunk/include/ode/common.h =================================================================== --- trunk/include/ode/common.h 2012-04-13 22:47:13 UTC (rev 1884) +++ trunk/include/ode/common.h 2012-04-14 08:40:31 UTC (rev 1885) @@ -98,7 +98,7 @@ #if defined(dSINGLE) -#define REAL(x) (x ## f) /* form a constant */ +#define REAL(x) (x##f) /* form a constant */ #define dRecip(x) ((1.0f/(x))) /* reciprocal */ #define dSqrt(x) (sqrtf(x)) /* square root */ #define dRecipSqrt(x) ((1.0f/sqrtf(x))) /* reciprocal square root */ Modified: trunk/ode/src/capsule.cpp =================================================================== --- trunk/ode/src/capsule.cpp 2012-04-13 22:47:13 UTC (rev 1884) +++ trunk/ode/src/capsule.cpp 2012-04-14 08:40:31 UTC (rev 1885) @@ -197,40 +197,41 @@ dVector3 pl,pb; dClosestLineBoxPoints (p1,p2,c,R,side,pl,pb); - // if the capsule is penetrated further than radius - // then pl and pb are equal (up to mindist) -> unknown normal - // use normal vector of closest box surface + // if the capsule is penetrated further than radius + // then pl and pb are equal (up to mindist) -> unknown normal + // use normal vector of closest box surface #ifdef dSINGLE - dReal mindist = REAL(1e-6); + dReal mindist = REAL(1e-6); #else - dReal mindist = REAL(1e-15); + dReal mindist = REAL(1e-15); #endif - if (dCalcPointsDistance3(pl, pb)<mindist) { - dVector3 normal; - dReal depth; - int code; - // consider capsule as box - dReal rad2 = radius*REAL(2.0); - const dVector3 capboxside = {rad2, rad2, cyl->lz + rad2}; - int num = dBoxBox (c, R, side, - o1->final_posr->pos, o1->final_posr->R, capboxside, - normal, &depth, &code, flags, contact, skip); + if (dCalcPointsDistance3(pl, pb)<mindist) { + // consider capsule as box + dVector3 normal; + dReal depth; + int code; + // WARNING! rad2 is declared as #define in Microsoft headers (as well as psh2, chx2, grp2, frm2, rct2, ico2, stc2, lst2, cmb2, edt2, scr2). Avoid abbreviations! + /* dReal rad2 = radius*REAL(2.0); */ dReal radiusMul2 = radius * REAL(2.0); + const dVector3 capboxside = {radiusMul2, radiusMul2, cyl->lz + radiusMul2}; + int num = dBoxBox (c, R, side, + o1->final_posr->pos, o1->final_posr->R, capboxside, + normal, &depth, &code, flags, contact, skip); - for (int i=0; i<num; i++) { - dContactGeom *currContact = CONTACT(contact,i*skip); - currContact->normal[0] = normal[0]; - currContact->normal[1] = normal[1]; - currContact->normal[2] = normal[2]; - currContact->g1 = o1; - currContact->g2 = o2; - currContact->side1 = -1; - currContact->side2 = -1; + for (int i=0; i<num; i++) { + dContactGeom *currContact = CONTACT(contact,i*skip); + currContact->normal[0] = normal[0]; + currContact->normal[1] = normal[1]; + currContact->normal[2] = normal[2]; + currContact->g1 = o1; + currContact->g2 = o2; + currContact->side1 = -1; + currContact->side2 = -1; + } + return num; + } else { + // generate contact point + return dCollideSpheres (pl,radius,pb,0,contact); } - return num; - } else { - // generate contact point - return dCollideSpheres (pl,radius,pb,0,contact); - } } Modified: trunk/ode/src/joints/contact.cpp =================================================================== --- trunk/ode/src/joints/contact.cpp 2012-04-13 22:47:13 UTC (rev 1884) +++ trunk/ode/src/joints/contact.cpp 2012-04-14 08:40:31 UTC (rev 1885) @@ -196,19 +196,19 @@ info->J1l[s+2] = t1[2]; dCalcVectorCross3( info->J1a + s, c1, t1 ); if ( node[1].body ) - { - info->J2l[s+0] = -t1[0]; - info->J2l[s+1] = -t1[1]; - info->J2l[s+2] = -t1[2]; - dReal *J2a_plus_s = info->J2a + s; - dCalcVectorCross3( J2a_plus_s, c2, t1 ); - dNegateVector3( J2a_plus_s ); - } + { + info->J2l[s+0] = -t1[0]; + info->J2l[s+1] = -t1[1]; + info->J2l[s+2] = -t1[2]; + dReal *J2a_plus_s = info->J2a + s; + dCalcVectorCross3( J2a_plus_s, c2, t1 ); + dNegateVector3( J2a_plus_s ); + } // set right hand side if ( contact.surface.mode & dContactMotion1 ) - { - info->c[rowFriction1] = contact.surface.motion1; - } + { + info->c[rowFriction1] = contact.surface.motion1; + } // set LCP bounds and friction index. this depends on the approximation // mode info->lo[rowFriction1] = -contact.surface.mu; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-04-13 22:47:20
|
Revision: 1884 http://opende.svn.sourceforge.net/opende/?rev=1884&view=rev Author: danielosmari Date: 2012-04-13 22:47:13 +0000 (Fri, 13 Apr 2012) Log Message: ----------- fixed bug with contacts with zero mu and non-zero mu2; now either mu or mu2 can be set to zero Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/joints/contact.cpp trunk/tests/Makefile.am trunk/tests/collision.cpp trunk/tests/main.cpp Added Paths: ----------- trunk/tests/friction.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-04-13 20:40:19 UTC (rev 1883) +++ trunk/CHANGELOG.txt 2012-04-13 22:47:13 UTC (rev 1884) @@ -11,7 +11,7 @@ 04/13/12 Daniel K. O. * Applied patch from bug #3431829 - better handling of capsule-box with deep penetrations. - * Applied patch from Jon Watte - better handling of zero mu with mu2. + * Fixed zero-mu issues: now either mu or mu2 can be set to zero. 03/17/12 Oleh Derevenko * Threaded execution support interface added. Optional built-in threading Modified: trunk/ode/src/joints/contact.cpp =================================================================== --- trunk/ode/src/joints/contact.cpp 2012-04-13 20:40:19 UTC (rev 1883) +++ trunk/ode/src/joints/contact.cpp 2012-04-13 22:47:13 UTC (rev 1884) @@ -54,7 +54,7 @@ if ( contact.surface.mode & dContactMu2 ) { if ( contact.surface.mu2 < 0 ) contact.surface.mu2 = 0; - if ( ( contact.surface.mu > 0 ) || ( contact.surface.mu2 > 0 ) ) m++; + if ( contact.surface.mu > 0 ) m++; if ( contact.surface.mu2 > 0 ) m++; if ( contact.surface.mu == dInfinity ) nub ++; if ( contact.surface.mu2 == dInfinity ) nub ++; @@ -76,6 +76,9 @@ { int s = info->rowskip; int s2 = 2 * s; + const int rowNormal = 0; + const int rowFriction1 = 1; + int rowFriction2 = 2; // we might decrease it to 1, so no const // get normal, with sign adjusted for body1/body2 polarity dVector3 normal; @@ -125,7 +128,7 @@ if ( depth < 0 ) depth = 0; if ( contact.surface.mode & dContactSoftCFM ) - info->cfm[0] = contact.surface.soft_cfm; + info->cfm[rowNormal] = contact.surface.soft_cfm; dReal motionN = 0; @@ -133,12 +136,12 @@ motionN = contact.surface.motionN; const dReal pushout = k * depth + motionN; - info->c[0] = pushout; + info->c[rowNormal] = pushout; // note: this cap should not limit bounce velocity const dReal maxvel = world->contactp.max_vel; - if ( info->c[0] > maxvel ) - info->c[0] = maxvel; + if ( info->c[rowNormal] > maxvel ) + info->c[rowNormal] = maxvel; // deal with bounce if ( contact.surface.mode & dContactBounce ) @@ -153,12 +156,12 @@ } outgoing -= motionN; // only apply bounce if the outgoing velocity is greater than the - // threshold, and if the resulting c[0] exceeds what we already have. + // threshold, and if the resulting c[rowNormal] exceeds what we already have. if ( contact.surface.bounce_vel >= 0 && ( -outgoing ) > contact.surface.bounce_vel ) { - dReal newc = - contact.surface.bounce * outgoing + motionN; - if ( newc > info->c[0] ) info->c[0] = newc; + const dReal newc = - contact.surface.bounce * outgoing + motionN; + if ( newc > info->c[rowNormal] ) info->c[rowNormal] = newc; } } @@ -166,55 +169,67 @@ info->lo[0] = 0; info->hi[0] = dInfinity; + if ( the_m == 1 ) // no friction, there is nothing else to do + return; + // now do jacobian for tangential forces dVector3 t1, t2; // two vectors tangential to normal + if ( contact.surface.mode & dContactFDir1 ) // use fdir1 ? + { + t1[0] = contact.fdir1[0]; + t1[1] = contact.fdir1[1]; + t1[2] = contact.fdir1[2]; + dCalcVectorCross3( t2, normal, t1 ); + } + else + { + dPlaneSpace( normal, t1, t2 ); + } + // first friction direction - if ( the_m >= 2 ) + + if ( contact.surface.mu > 0 ) { - if ( contact.surface.mode & dContactFDir1 ) // use fdir1 ? - { - t1[0] = contact.fdir1[0]; - t1[1] = contact.fdir1[1]; - t1[2] = contact.fdir1[2]; - dCalcVectorCross3( t2, normal, t1 ); - } - else - { - dPlaneSpace( normal, t1, t2 ); - } info->J1l[s+0] = t1[0]; 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]; - info->J2l[s+1] = -t1[1]; - info->J2l[s+2] = -t1[2]; - dReal *J2a_plus_s = info->J2a + s; - dCalcVectorCross3( J2a_plus_s, c2, t1 ); - dNegateVector3( J2a_plus_s ); - } + { + info->J2l[s+0] = -t1[0]; + info->J2l[s+1] = -t1[1]; + info->J2l[s+2] = -t1[2]; + dReal *J2a_plus_s = info->J2a + s; + dCalcVectorCross3( J2a_plus_s, c2, t1 ); + dNegateVector3( J2a_plus_s ); + } // set right hand side if ( contact.surface.mode & dContactMotion1 ) - { - info->c[1] = contact.surface.motion1; - } + { + info->c[rowFriction1] = contact.surface.motion1; + } // set LCP bounds and friction index. this depends on the approximation // mode - info->lo[1] = -contact.surface.mu; - info->hi[1] = contact.surface.mu; + info->lo[rowFriction1] = -contact.surface.mu; + info->hi[rowFriction1] = contact.surface.mu; if ( contact.surface.mode & dContactApprox1_1 ) - info->findex[1] = 0; + info->findex[rowFriction1] = 0; // set slip (constraint force mixing) if ( contact.surface.mode & dContactSlip1 ) - info->cfm[1] = contact.surface.slip1; + info->cfm[rowFriction1] = contact.surface.slip1; + } else { + // there was no friction for direction 1, so the second friction constraint + // has to be on this line instead + s2 = s; + rowFriction2 = rowFriction1; } + const dReal mu2 = contact.surface.mode & dContactMu2 ? contact.surface.mu2 : contact.surface.mu; + // second friction direction - if ( the_m >= 3 ) + if ( mu2 > 0 ) { info->J1l[s2+0] = t2[0]; info->J1l[s2+1] = t2[1]; @@ -232,26 +247,19 @@ // set right hand side if ( contact.surface.mode & dContactMotion2 ) { - info->c[2] = contact.surface.motion2; + info->c[rowFriction2] = contact.surface.motion2; } // set LCP bounds and friction index. this depends on the approximation // mode - if ( contact.surface.mode & dContactMu2 ) - { - info->lo[2] = -contact.surface.mu2; - info->hi[2] = contact.surface.mu2; - } - else - { - info->lo[2] = -contact.surface.mu; - info->hi[2] = contact.surface.mu; - } + info->lo[rowFriction2] = -mu2; + info->hi[rowFriction2] = mu2; + if ( contact.surface.mode & dContactApprox1_2 ) - info->findex[2] = 0; + info->findex[rowFriction2] = 0; // set slip (constraint force mixing) if ( contact.surface.mode & dContactSlip2 ) - info->cfm[2] = contact.surface.slip2; + info->cfm[rowFriction2] = contact.surface.slip2; } } Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2012-04-13 20:40:19 UTC (rev 1883) +++ trunk/tests/Makefile.am 2012-04-13 22:47:13 UTC (rev 1884) @@ -18,7 +18,12 @@ TESTS = tests -tests_SOURCES = main.cpp joint.cpp odemath.cpp collision.cpp \ +tests_SOURCES = \ + collision.cpp \ + friction.cpp \ + joint.cpp \ + main.cpp \ + odemath.cpp \ joints/ball.cpp \ joints/fixed.cpp \ joints/hinge.cpp \ Modified: trunk/tests/collision.cpp =================================================================== --- trunk/tests/collision.cpp 2012-04-13 20:40:19 UTC (rev 1883) +++ trunk/tests/collision.cpp 2012-04-13 22:47:13 UTC (rev 1884) @@ -16,8 +16,6 @@ return; #endif - dInitODE(); - { const int VertexCount = 4; const int IndexCount = 2*3; @@ -95,7 +93,6 @@ CHECK_ARRAY_EQUAL(rtrinormal, cg[i].normal, 3); } } - dCloseODE(); } @@ -106,7 +103,6 @@ * This test demonstrated a bug in the AABB handling of the * heightfield. */ - dInitODE(); { // Create quick heightfield with dummy data dHeightfieldDataID heightfieldData = dGeomHeightfieldDataCreate(); @@ -127,6 +123,5 @@ dGeomDestroy(ray); dGeomHeightfieldDataDestroy(heightfieldData); } - dCloseODE(); } Added: trunk/tests/friction.cpp =================================================================== --- trunk/tests/friction.cpp (rev 0) +++ trunk/tests/friction.cpp 2012-04-13 22:47:13 UTC (rev 1884) @@ -0,0 +1,186 @@ +/************************************************************************* + * * + * 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. * + * * + *************************************************************************/ +//234567890123456789012345678901234567890123456789012345678901234567890123456789 +// 1 2 3 4 5 6 7 + +//////////////////////////////////////////////////////////////////////////////// +// This file create unit test for some of the functions found in: +// ode/src/joint.cpp +// +// +//////////////////////////////////////////////////////////////////////////////// +#include <algorithm> +#include <UnitTest++.h> +#include <ode/ode.h> +#include "../ode/src/joints/joints.h" + + +/* + * Tests for contact friction + */ + +SUITE(JointContact) +{ + struct ContactSetup + { + dWorldID world; + dBodyID body1; + dBodyID body2; + dJointID joint; + + ContactSetup() + { + world = dWorldCreate(); + body1 = dBodyCreate(world); + body2 = dBodyCreate(world); + + dBodySetPosition(body1, -1, 0, 0); + dBodySetPosition(body2, 1, 0, 0); + } + + ~ContactSetup() + { + dBodyDestroy(body1); + dBodyDestroy(body2); + dWorldDestroy(world); + } + }; + + TEST_FIXTURE(ContactSetup, + test_ZeroMu) + { + dxJoint::Info1 info1; + dxJoint::Info2 info2; + dReal dummy_J[3][12] = {{0}}; + dReal dummy_c[3]; + dReal dummy_cfm[3]; + dReal dummy_lo[3]; + dReal dummy_hi[3]; + int dummy_findex[3]; + + info2.fps = 100; + info2.erp = 0; + info2.J1l = dummy_J[0]; + info2.J1a = dummy_J[0] + 3; + info2.J2l = dummy_J[0] + 6; + info2.J2a = dummy_J[0] + 9; + info2.rowskip = 12; + info2.c = dummy_c; + info2.cfm = dummy_cfm; + info2.lo = dummy_lo; + info2.hi = dummy_hi; + info2.findex = dummy_findex; + +#define ZERO_ALL do { \ + memset(dummy_J, 0, sizeof dummy_J); \ + memset(dummy_c, 0, sizeof dummy_c); \ + memset(dummy_cfm, 0, sizeof dummy_cfm); \ + memset(dummy_lo, 0, sizeof dummy_lo); \ + memset(dummy_hi, 0, sizeof dummy_hi); \ + std::fill(dummy_findex, dummy_findex+3, -1);; \ + } \ + while (0) + + dContact contact; + contact.surface.mode = dContactMu2 | dContactFDir1 | dContactApprox1; + + contact.geom.pos[0] = 0; + contact.geom.pos[1] = 0; + contact.geom.pos[2] = 0; + + // normal points into body1 + contact.geom.normal[0] = -1; + contact.geom.normal[1] = 0; + contact.geom.normal[2] = 0; + + contact.geom.depth = 0; + + contact.geom.g1 = 0; + contact.geom.g2 = 0; + + // we ask for fdir1 = +Y, so fdir2 = normal x fdir1 = -Z + contact.fdir1[0] = 0; + contact.fdir1[1] = 1; + contact.fdir1[2] = 0; + + /* + * First, test with mu = 0, mu2 = 1 + * Because there is no friction on the first direction (+Y) the body + * is allowed to translate in the Y axis and rotate around the Z axis. + * + * That is, the only constraint will be for the second dir (-Z): + * so J[1] = [ 0 0 -1 0 1 0 0 0 1 0 1 0 ] + */ + contact.surface.mu = 0; + contact.surface.mu2 = 1; + joint = dJointCreateContact(world, 0, &contact); + dJointAttach(joint, body1, body2); + joint->getInfo1(&info1); + CHECK_EQUAL(2, (int)info1.m); + ZERO_ALL; + joint->getInfo2(&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); + CHECK_CLOSE(0, dummy_J[1][3], 1e-6); + CHECK_CLOSE(1, dummy_J[1][4], 1e-6); + CHECK_CLOSE(0, dummy_J[1][5], 1e-6); + CHECK_CLOSE(0, dummy_J[1][6], 1e-6); + CHECK_CLOSE(0, dummy_J[1][7], 1e-6); + CHECK_CLOSE(1, dummy_J[1][8], 1e-6); + CHECK_CLOSE(0, dummy_J[1][9], 1e-6); + CHECK_CLOSE(1, dummy_J[1][10], 1e-6); + CHECK_CLOSE(0, dummy_J[1][11], 1e-6); + CHECK_EQUAL(0, dummy_findex[1]); // because of dContactApprox1 + dJointDestroy(joint); + + + /* + * Now try with no frictino in the second direction. The Jacobian should look like: + * J[1] = [ 0 1 0 0 0 1 0 -1 0 0 0 1 ] + */ + // try again, with zero mu2 + contact.surface.mu = 1; + contact.surface.mu2 = 0; + joint = dJointCreateContact(world, 0, &contact); + dJointAttach(joint, body1, body2); + joint->getInfo1(&info1); + CHECK_EQUAL(2, (int)info1.m); + ZERO_ALL; + joint->getInfo2(&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); + CHECK_CLOSE(0, dummy_J[1][3], 1e-6); + CHECK_CLOSE(0, dummy_J[1][4], 1e-6); + CHECK_CLOSE(1, dummy_J[1][5], 1e-6); + CHECK_CLOSE(0, dummy_J[1][6], 1e-6); + CHECK_CLOSE(-1, dummy_J[1][7], 1e-6); + CHECK_CLOSE(0, dummy_J[1][8], 1e-6); + CHECK_CLOSE(0, dummy_J[1][9], 1e-6); + CHECK_CLOSE(0, dummy_J[1][10], 1e-6); + CHECK_CLOSE(1, dummy_J[1][11], 1e-6); + CHECK_EQUAL(0, dummy_findex[1]); // because of dContactApprox1 + dJointDestroy(joint); + } + +} Property changes on: trunk/tests/friction.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/tests/main.cpp =================================================================== --- trunk/tests/main.cpp 2012-04-13 20:40:19 UTC (rev 1883) +++ trunk/tests/main.cpp 2012-04-13 22:47:13 UTC (rev 1884) @@ -2,8 +2,12 @@ // #include <UnitTest++.h> +#include <ode/ode.h> int main() { - return UnitTest::RunAllTests(); + dInitODE(); + int res = UnitTest::RunAllTests(); + dCloseODE(); + return res; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-04-13 20:40:26
|
Revision: 1883 http://opende.svn.sourceforge.net/opende/?rev=1883&view=rev Author: danielosmari Date: 2012-04-13 20:40:19 +0000 (Fri, 13 Apr 2012) Log Message: ----------- - applied patch from bug #3431829 - deep capsule-box collisions - applied patch from Jon Watte: handle mu=0, mu2>0 Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/capsule.cpp trunk/ode/src/joints/contact.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-04-07 17:36:51 UTC (rev 1882) +++ trunk/CHANGELOG.txt 2012-04-13 20:40:19 UTC (rev 1883) @@ -8,6 +8,11 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +04/13/12 Daniel K. O. + * Applied patch from bug #3431829 - better handling of capsule-box with + deep penetrations. + * Applied patch from Jon Watte - better handling of zero mu with mu2. + 03/17/12 Oleh Derevenko * Threaded execution support interface added. Optional built-in threading implementation added. Modified: trunk/ode/src/capsule.cpp =================================================================== --- trunk/ode/src/capsule.cpp 2012-04-07 17:36:51 UTC (rev 1882) +++ trunk/ode/src/capsule.cpp 2012-04-13 20:40:19 UTC (rev 1883) @@ -160,21 +160,6 @@ return dCollideSpheres (p,ccyl->radius,o2->final_posr->pos,sphere->radius,contact); } -// use this instead of dCollideSpheres if the spheres are at the same point, -// but the normal is known (e.g. in capsule-box collision) -int dCollideSpheresZeroDist (dVector3 p1, dReal r1, dVector3 p2, dReal r2, - dVector3 normal, dContactGeom *c) -{ - c->normal[0] = normal[0]; - c->normal[1] = normal[1]; - c->normal[2] = normal[2]; - c->depth = r1 + r2; - dReal k = REAL(0.5) * (r2 - r1); - c->pos[0] = p1[0] + c->normal[0]*k; - c->pos[1] = p1[1] + c->normal[1]*k; - c->pos[2] = p1[2] + c->normal[2]*k; - return 1; -} int dCollideCapsuleBox (dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, int skip) @@ -212,23 +197,40 @@ dVector3 pl,pb; dClosestLineBoxPoints (p1,p2,c,R,side,pl,pb); - // if the capsule is penetrated further than radius - // than pl and pb are equal -> unknown normal - // use vector to center of box as normal + // if the capsule is penetrated further than radius + // then pl and pb are equal (up to mindist) -> unknown normal + // use normal vector of closest box surface #ifdef dSINGLE - dReal mindist = REAL(1e-9); + dReal mindist = REAL(1e-6); #else - dReal mindist = REAL(1e-18); + dReal mindist = REAL(1e-15); #endif - if (dCalcPointsDistance3(pl, pb)<mindist) { - dVector3 normal; // pb-c (vector from center of box to pb) - for (int i=0; i<3; i++) normal[i] = pb[i]-c[i]; - dSafeNormalize3(normal); - return dCollideSpheresZeroDist (pl,radius,pb,0,normal,contact); - } else { - // generate contact point - return dCollideSpheres (pl,radius,pb,0,contact); + if (dCalcPointsDistance3(pl, pb)<mindist) { + dVector3 normal; + dReal depth; + int code; + // consider capsule as box + dReal rad2 = radius*REAL(2.0); + const dVector3 capboxside = {rad2, rad2, cyl->lz + rad2}; + int num = dBoxBox (c, R, side, + o1->final_posr->pos, o1->final_posr->R, capboxside, + normal, &depth, &code, flags, contact, skip); + + for (int i=0; i<num; i++) { + dContactGeom *currContact = CONTACT(contact,i*skip); + currContact->normal[0] = normal[0]; + currContact->normal[1] = normal[1]; + currContact->normal[2] = normal[2]; + currContact->g1 = o1; + currContact->g2 = o2; + currContact->side1 = -1; + currContact->side2 = -1; } + return num; + } else { + // generate contact point + return dCollideSpheres (pl,radius,pb,0,contact); + } } Modified: trunk/ode/src/joints/contact.cpp =================================================================== --- trunk/ode/src/joints/contact.cpp 2012-04-07 17:36:51 UTC (rev 1882) +++ trunk/ode/src/joints/contact.cpp 2012-04-13 20:40:19 UTC (rev 1883) @@ -53,8 +53,8 @@ if ( contact.surface.mu < 0 ) contact.surface.mu = 0; if ( contact.surface.mode & dContactMu2 ) { - if ( contact.surface.mu > 0 ) m++; if ( contact.surface.mu2 < 0 ) contact.surface.mu2 = 0; + if ( ( contact.surface.mu > 0 ) || ( contact.surface.mu2 > 0 ) ) m++; if ( contact.surface.mu2 > 0 ) m++; if ( contact.surface.mu == dInfinity ) nub ++; if ( contact.surface.mu2 == dInfinity ) nub ++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ole...@us...> - 2012-04-07 17:37:01
|
Revision: 1882 http://opende.svn.sourceforge.net/opende/?rev=1882&view=rev Author: oleh_derevenko Date: 2012-04-07 17:36:51 +0000 (Sat, 07 Apr 2012) Log Message: ----------- Indentation changed to four spaces in main sources Modified Paths: -------------- trunk/ode/src/array.cpp trunk/ode/src/array.h 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_kernel.h trunk/ode/src/collision_libccd.cpp trunk/ode/src/collision_libccd.h trunk/ode/src/collision_quadtreespace.cpp trunk/ode/src/collision_sapspace.cpp trunk/ode/src/collision_space.cpp trunk/ode/src/collision_space_internal.h trunk/ode/src/collision_std.h trunk/ode/src/collision_transform.cpp trunk/ode/src/collision_transform.h trunk/ode/src/collision_trimesh_box.cpp trunk/ode/src/collision_trimesh_ccylinder.cpp trunk/ode/src/collision_trimesh_colliders.h trunk/ode/src/collision_trimesh_disabled.cpp trunk/ode/src/collision_trimesh_distance.cpp trunk/ode/src/collision_trimesh_gimpact.cpp trunk/ode/src/collision_trimesh_internal.h 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/collision_util.cpp trunk/ode/src/collision_util.h trunk/ode/src/convex.cpp trunk/ode/src/cylinder.cpp trunk/ode/src/error.cpp trunk/ode/src/export-dif.cpp trunk/ode/src/fastdot.c trunk/ode/src/fastldlt.c trunk/ode/src/fastlsolve.c trunk/ode/src/fastltsolve.c trunk/ode/src/heightfield.cpp trunk/ode/src/heightfield.h trunk/ode/src/joints/amotor.cpp trunk/ode/src/joints/ball.cpp trunk/ode/src/joints/contact.cpp trunk/ode/src/joints/fixed.cpp trunk/ode/src/joints/hinge.cpp 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/null.cpp trunk/ode/src/joints/piston.cpp trunk/ode/src/joints/plane2d.cpp trunk/ode/src/joints/pr.cpp trunk/ode/src/joints/pu.cpp trunk/ode/src/joints/slider.cpp trunk/ode/src/joints/universal.cpp trunk/ode/src/lcp.cpp trunk/ode/src/lcp.h trunk/ode/src/mass.cpp trunk/ode/src/mat.cpp trunk/ode/src/mat.h trunk/ode/src/matrix.cpp trunk/ode/src/memory.cpp trunk/ode/src/misc.cpp trunk/ode/src/nextafterf.c trunk/ode/src/objects.cpp trunk/ode/src/objects.h trunk/ode/src/obstack.cpp trunk/ode/src/obstack.h trunk/ode/src/ode.cpp trunk/ode/src/odeinit.cpp trunk/ode/src/odemath.cpp trunk/ode/src/odeou.cpp trunk/ode/src/odeou.h trunk/ode/src/odetls.cpp trunk/ode/src/odetls.h trunk/ode/src/plane.cpp trunk/ode/src/quickstep.cpp trunk/ode/src/quickstep.h trunk/ode/src/ray.cpp trunk/ode/src/rotation.cpp trunk/ode/src/sphere.cpp trunk/ode/src/step.cpp trunk/ode/src/step.h trunk/ode/src/threading_atomics_provs.h trunk/ode/src/threading_base.cpp trunk/ode/src/threading_base.h trunk/ode/src/threading_fake_sync.h trunk/ode/src/threading_impl.cpp trunk/ode/src/threading_impl_posix.h trunk/ode/src/threading_impl_templates.h trunk/ode/src/threading_impl_win.h trunk/ode/src/threading_pool_posix.cpp trunk/ode/src/threading_pool_win.cpp trunk/ode/src/timer.cpp trunk/ode/src/util.cpp trunk/ode/src/util.h Modified: trunk/ode/src/array.cpp =================================================================== --- trunk/ode/src/array.cpp 2012-03-29 08:47:56 UTC (rev 1881) +++ trunk/ode/src/array.cpp 2012-04-07 17:36:51 UTC (rev 1882) @@ -29,53 +29,53 @@ static inline int roundUpToPowerOfTwo (int x) { - int i = 1; - while (i < x) i <<= 1; - return i; + int i = 1; + while (i < x) i <<= 1; + return i; } void dArrayBase::_freeAll (int sizeofT) { - if (_data) { - if (_data == this+1) return; // if constructLocalArray() was called - dFree (_data,_anum * sizeofT); - } + if (_data) { + if (_data == this+1) return; // if constructLocalArray() was called + dFree (_data,_anum * sizeofT); + } } void dArrayBase::_setSize (int newsize, int sizeofT) { - if (newsize < 0) return; - if (newsize > _anum) { - if (_data == this+1) { - // this is a no-no, because constructLocalArray() was called - dDebug (0,"setSize() out of space in LOCAL array"); + if (newsize < 0) return; + if (newsize > _anum) { + if (_data == this+1) { + // this is a no-no, because constructLocalArray() was called + dDebug (0,"setSize() out of space in LOCAL array"); + } + int newanum = roundUpToPowerOfTwo (newsize); + if (_data) _data = dRealloc (_data, _anum*sizeofT, newanum*sizeofT); + else _data = dAlloc (newanum*sizeofT); + _anum = newanum; } - int newanum = roundUpToPowerOfTwo (newsize); - if (_data) _data = dRealloc (_data, _anum*sizeofT, newanum*sizeofT); - else _data = dAlloc (newanum*sizeofT); - _anum = newanum; - } - _size = newsize; + _size = newsize; } void * dArrayBase::operator new (size_t size) { - return dAlloc (size); + return dAlloc (size); } void dArrayBase::operator delete (void *ptr, size_t size) { - dFree (ptr,size); + dFree (ptr,size); } void dArrayBase::constructLocalArray (int __anum) { - _size = 0; - _anum = __anum; - _data = this+1; + _size = 0; + _anum = __anum; + _data = this+1; } Modified: trunk/ode/src/array.h =================================================================== --- trunk/ode/src/array.h 2012-03-29 08:47:56 UTC (rev 1881) +++ trunk/ode/src/array.h 2012-04-07 17:36:51 UTC (rev 1882) @@ -46,89 +46,89 @@ class dArrayBase { protected: - int _size; // number of elements in `data' - int _anum; // allocated number of elements in `data' - void *_data; // array data + int _size; // number of elements in `data' + int _anum; // allocated number of elements in `data' + void *_data; // array data - void _freeAll (int sizeofT); - void _setSize (int newsize, int sizeofT); - // set the array size to `newsize', allocating more memory if necessary. - // if newsize>_anum and is a power of two then this is guaranteed to - // set _size and _anum to newsize. + void _freeAll (int sizeofT); + void _setSize (int newsize, int sizeofT); + // set the array size to `newsize', allocating more memory if necessary. + // if newsize>_anum and is a power of two then this is guaranteed to + // set _size and _anum to newsize. public: - // not: dArrayBase () { _size=0; _anum=0; _data=0; } + // not: dArrayBase () { _size=0; _anum=0; _data=0; } - int size() const { return _size; } - int allocatedSize() const { return _anum; } - void * operator new (size_t size); - void operator delete (void *ptr, size_t size); + int size() const { return _size; } + int allocatedSize() const { return _anum; } + void * operator new (size_t size); + void operator delete (void *ptr, size_t size); - void constructor() { _size=0; _anum=0; _data=0; } - // if this structure is allocated with malloc() instead of new, you can - // call this to set it up. + void constructor() { _size=0; _anum=0; _data=0; } + // if this structure is allocated with malloc() instead of new, you can + // call this to set it up. - void constructLocalArray (int __anum); - // this helper function allows non-reallocating arrays to be constructed - // on the stack (or in the heap if necessary). this is something of a - // kludge and should be used with extreme care. this function acts like - // a constructor - it is called on uninitialized memory that will hold the - // Array structure and the data. __anum is the number of elements that - // are allocated. the memory MUST be allocated with size: - // sizeof(ArrayBase) + __anum*sizeof(T) - // arrays allocated this way will never try to reallocate or free the - // memory - that's your job. + void constructLocalArray (int __anum); + // this helper function allows non-reallocating arrays to be constructed + // on the stack (or in the heap if necessary). this is something of a + // kludge and should be used with extreme care. this function acts like + // a constructor - it is called on uninitialized memory that will hold the + // Array structure and the data. __anum is the number of elements that + // are allocated. the memory MUST be allocated with size: + // sizeof(ArrayBase) + __anum*sizeof(T) + // arrays allocated this way will never try to reallocate or free the + // memory - that's your job. }; template <class T> class dArray : public dArrayBase { public: - void equals (const dArray<T> &x) { - setSize (x.size()); - memcpy (_data,x._data,x._size * sizeof(T)); - } + void equals (const dArray<T> &x) { + setSize (x.size()); + memcpy (_data,x._data,x._size * sizeof(T)); + } - dArray () { constructor(); } - dArray (const dArray<T> &x) { constructor(); equals (x); } - ~dArray () { _freeAll(sizeof(T)); } - void setSize (int newsize) { _setSize (newsize,sizeof(T)); } - T *data() const { return (T*) _data; } - T & operator[] (int i) const { return ((T*)_data)[i]; } - void operator = (const dArray<T> &x) { equals (x); } + dArray () { constructor(); } + dArray (const dArray<T> &x) { constructor(); equals (x); } + ~dArray () { _freeAll(sizeof(T)); } + void setSize (int newsize) { _setSize (newsize,sizeof(T)); } + T *data() const { return (T*) _data; } + T & operator[] (int i) const { return ((T*)_data)[i]; } + void operator = (const dArray<T> &x) { equals (x); } - void push (const T item) { - if (_size < _anum) _size++; else _setSize (_size+1,sizeof(T)); - memcpy (&(((T*)_data)[_size-1]), &item, sizeof(T)); - } + void push (const T item) { + if (_size < _anum) _size++; else _setSize (_size+1,sizeof(T)); + memcpy (&(((T*)_data)[_size-1]), &item, sizeof(T)); + } - void swap (dArray<T> &x) { - int tmp1; - void *tmp2; - tmp1=_size; _size=x._size; x._size=tmp1; - tmp1=_anum; _anum=x._anum; x._anum=tmp1; - tmp2=_data; _data=x._data; x._data=tmp2; - } + void swap (dArray<T> &x) { + int tmp1; + void *tmp2; + tmp1=_size; _size=x._size; x._size=tmp1; + tmp1=_anum; _anum=x._anum; x._anum=tmp1; + tmp2=_data; _data=x._data; x._data=tmp2; + } - // insert the item at the position `i'. if i<0 then add the item to the - // start, if i >= size then add the item to the end of the array. - void insert (int i, const T item) { - if (_size < _anum) _size++; else _setSize (_size+1,sizeof(T)); - if (i >= (_size-1)) i = _size-1; // add to end - else { - if (i < 0) i=0; // add to start - int n = _size-1-i; - if (n>0) memmove (((T*)_data) + i+1, ((T*)_data) + i, n*sizeof(T)); + // insert the item at the position `i'. if i<0 then add the item to the + // start, if i >= size then add the item to the end of the array. + void insert (int i, const T item) { + if (_size < _anum) _size++; else _setSize (_size+1,sizeof(T)); + if (i >= (_size-1)) i = _size-1; // add to end + else { + if (i < 0) i=0; // add to start + int n = _size-1-i; + if (n>0) memmove (((T*)_data) + i+1, ((T*)_data) + i, n*sizeof(T)); + } + ((T*)_data)[i] = item; } - ((T*)_data)[i] = item; - } - void remove (int i) { - if (i >= 0 && i < _size) { // passing this test guarantees size>0 - int n = _size-1-i; - if (n>0) memmove (((T*)_data) + i, ((T*)_data) + i+1, n*sizeof(T)); - _size--; + void remove (int i) { + if (i >= 0 && i < _size) { // passing this test guarantees size>0 + int n = _size-1-i; + if (n>0) memmove (((T*)_data) + i, ((T*)_data) + i+1, n*sizeof(T)); + _size--; + } } - } }; Modified: trunk/ode/src/box.cpp =================================================================== --- trunk/ode/src/box.cpp 2012-03-29 08:47:56 UTC (rev 1881) +++ trunk/ode/src/box.cpp 2012-04-07 17:36:51 UTC (rev 1882) @@ -22,10 +22,10 @@ /* -standard ODE geometry primitives: public API and pairwise collision functions. + standard ODE geometry primitives: public API and pairwise collision functions. -the rule is that only the low level primitive collision functions should set -dContactGeom::g1 and dContactGeom::g2. + the rule is that only the low level primitive collision functions should set + dContactGeom::g1 and dContactGeom::g2. */ @@ -48,128 +48,128 @@ dxBox::dxBox (dSpaceID space, dReal lx, dReal ly, dReal lz) : dxGeom (space,1) { - dAASSERT (lx >= 0 && ly >= 0 && lz >= 0); - type = dBoxClass; - side[0] = lx; - side[1] = ly; - side[2] = lz; - updateZeroSizedFlag(!lx || !ly || !lz); + dAASSERT (lx >= 0 && ly >= 0 && lz >= 0); + type = dBoxClass; + side[0] = lx; + side[1] = ly; + side[2] = lz; + updateZeroSizedFlag(!lx || !ly || !lz); } void dxBox::computeAABB() { - const dMatrix3& R = final_posr->R; - const dVector3& pos = final_posr->pos; - - dReal xrange = REAL(0.5) * (dFabs (R[0] * side[0]) + - dFabs (R[1] * side[1]) + dFabs (R[2] * side[2])); - dReal yrange = REAL(0.5) * (dFabs (R[4] * side[0]) + - dFabs (R[5] * side[1]) + dFabs (R[6] * side[2])); - dReal zrange = REAL(0.5) * (dFabs (R[8] * side[0]) + - dFabs (R[9] * side[1]) + dFabs (R[10] * side[2])); - aabb[0] = pos[0] - xrange; - aabb[1] = pos[0] + xrange; - aabb[2] = pos[1] - yrange; - aabb[3] = pos[1] + yrange; - aabb[4] = pos[2] - zrange; - aabb[5] = pos[2] + zrange; + const dMatrix3& R = final_posr->R; + const dVector3& pos = final_posr->pos; + + dReal xrange = REAL(0.5) * (dFabs (R[0] * side[0]) + + dFabs (R[1] * side[1]) + dFabs (R[2] * side[2])); + dReal yrange = REAL(0.5) * (dFabs (R[4] * side[0]) + + dFabs (R[5] * side[1]) + dFabs (R[6] * side[2])); + dReal zrange = REAL(0.5) * (dFabs (R[8] * side[0]) + + dFabs (R[9] * side[1]) + dFabs (R[10] * side[2])); + aabb[0] = pos[0] - xrange; + aabb[1] = pos[0] + xrange; + aabb[2] = pos[1] - yrange; + aabb[3] = pos[1] + yrange; + aabb[4] = pos[2] - zrange; + aabb[5] = pos[2] + zrange; } dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz) { - return new dxBox (space,lx,ly,lz); + return new dxBox (space,lx,ly,lz); } void dGeomBoxSetLengths (dGeomID g, dReal lx, dReal ly, dReal lz) { - dUASSERT (g && g->type == dBoxClass,"argument not a box"); - dAASSERT (lx >= 0 && ly >= 0 && lz >= 0); - dxBox *b = (dxBox*) g; - b->side[0] = lx; - b->side[1] = ly; - b->side[2] = lz; - b->updateZeroSizedFlag(!lx || !ly || !lz); - dGeomMoved (g); + dUASSERT (g && g->type == dBoxClass,"argument not a box"); + dAASSERT (lx >= 0 && ly >= 0 && lz >= 0); + dxBox *b = (dxBox*) g; + b->side[0] = lx; + b->side[1] = ly; + b->side[2] = lz; + b->updateZeroSizedFlag(!lx || !ly || !lz); + dGeomMoved (g); } void dGeomBoxGetLengths (dGeomID g, dVector3 result) { - dUASSERT (g && g->type == dBoxClass,"argument not a box"); - dxBox *b = (dxBox*) g; - result[0] = b->side[0]; - result[1] = b->side[1]; - result[2] = b->side[2]; + dUASSERT (g && g->type == dBoxClass,"argument not a box"); + dxBox *b = (dxBox*) g; + result[0] = b->side[0]; + result[1] = b->side[1]; + result[2] = b->side[2]; } dReal dGeomBoxPointDepth (dGeomID g, dReal x, dReal y, dReal z) { - dUASSERT (g && g->type == dBoxClass,"argument not a box"); - g->recomputePosr(); - dxBox *b = (dxBox*) g; + dUASSERT (g && g->type == dBoxClass,"argument not a box"); + g->recomputePosr(); + dxBox *b = (dxBox*) g; - // Set p = (x,y,z) relative to box center - // - // This will be (0,0,0) if the point is at (side[0]/2,side[1]/2,side[2]/2) + // Set p = (x,y,z) relative to box center + // + // This will be (0,0,0) if the point is at (side[0]/2,side[1]/2,side[2]/2) - dVector3 p,q; + dVector3 p,q; - p[0] = x - b->final_posr->pos[0]; - p[1] = y - b->final_posr->pos[1]; - p[2] = z - b->final_posr->pos[2]; + p[0] = x - b->final_posr->pos[0]; + p[1] = y - b->final_posr->pos[1]; + p[2] = z - b->final_posr->pos[2]; - // Rotate p into box's coordinate frame, so we can - // treat the OBB as an AABB + // Rotate p into box's coordinate frame, so we can + // treat the OBB as an AABB - dMultiply1_331 (q,b->final_posr->R,p); + dMultiply1_331 (q,b->final_posr->R,p); - // Record distance from point to each successive box side, and see - // if the point is inside all six sides + // Record distance from point to each successive box side, and see + // if the point is inside all six sides - dReal dist[6]; - int i; + dReal dist[6]; + int i; - bool inside = true; + bool inside = true; - for (i=0; i < 3; i++) { - dReal side = b->side[i] * REAL(0.5); + for (i=0; i < 3; i++) { + dReal side = b->side[i] * REAL(0.5); - dist[i ] = side - q[i]; - dist[i+3] = side + q[i]; + dist[i ] = side - q[i]; + dist[i+3] = side + q[i]; - if ((dist[i] < 0) || (dist[i+3] < 0)) { - inside = false; + if ((dist[i] < 0) || (dist[i+3] < 0)) { + inside = false; + } } - } - // If point is inside the box, the depth is the smallest positive distance - // to any side + // If point is inside the box, the depth is the smallest positive distance + // to any side - if (inside) { - dReal smallest_dist = (dReal) (unsigned) -1; + if (inside) { + dReal smallest_dist = (dReal) (unsigned) -1; - for (i=0; i < 6; i++) { - if (dist[i] < smallest_dist) smallest_dist = dist[i]; + for (i=0; i < 6; i++) { + if (dist[i] < smallest_dist) smallest_dist = dist[i]; + } + + return smallest_dist; } - return smallest_dist; - } + // Otherwise, if point is outside the box, the depth is the largest + // distance to any side. This is an approximation to the 'proper' + // solution (the proper solution may be larger in some cases). - // Otherwise, if point is outside the box, the depth is the largest - // distance to any side. This is an approximation to the 'proper' - // solution (the proper solution may be larger in some cases). + dReal largest_dist = 0; - dReal largest_dist = 0; + for (i=0; i < 6; i++) { + if (dist[i] > largest_dist) largest_dist = dist[i]; + } - for (i=0; i < 6; i++) { - if (dist[i] > largest_dist) largest_dist = dist[i]; - } - - return -largest_dist; + return -largest_dist; } //**************************************************************************** @@ -186,55 +186,55 @@ static int intersectRectQuad (dReal h[2], dReal p[8], dReal ret[16]) { - // q (and r) contain nq (and nr) coordinate points for the current (and - // chopped) polygons - int nq=4,nr; - dReal buffer[16]; - dReal *q = p; - dReal *r = ret; - for (int dir=0; dir <= 1; dir++) { - // direction notation: xy[0] = x axis, xy[1] = y axis - for (int sign=-1; sign <= 1; sign += 2) { - // chop q along the line xy[dir] = sign*h[dir] - dReal *pq = q; - dReal *pr = r; - nr = 0; - for (int i=nq; i > 0; i--) { - // go through all points in q and all lines between adjacent points - if (sign*pq[dir] < h[dir]) { - // this point is inside the chopping line - pr[0] = pq[0]; - pr[1] = pq[1]; - pr += 2; - nr++; - if (nr & 8) { - q = r; - goto done; - } - } - dReal *nextq = (i > 1) ? pq+2 : q; - if ((sign*pq[dir] < h[dir]) ^ (sign*nextq[dir] < h[dir])) { - // this line crosses the chopping line - pr[1-dir] = pq[1-dir] + (nextq[1-dir]-pq[1-dir]) / - (nextq[dir]-pq[dir]) * (sign*h[dir]-pq[dir]); - pr[dir] = sign*h[dir]; - pr += 2; - nr++; - if (nr & 8) { - q = r; - goto done; - } - } - pq += 2; - } - q = r; - r = (q==ret) ? buffer : ret; - nq = nr; + // q (and r) contain nq (and nr) coordinate points for the current (and + // chopped) polygons + int nq=4,nr; + dReal buffer[16]; + dReal *q = p; + dReal *r = ret; + for (int dir=0; dir <= 1; dir++) { + // direction notation: xy[0] = x axis, xy[1] = y axis + for (int sign=-1; sign <= 1; sign += 2) { + // chop q along the line xy[dir] = sign*h[dir] + dReal *pq = q; + dReal *pr = r; + nr = 0; + for (int i=nq; i > 0; i--) { + // go through all points in q and all lines between adjacent points + if (sign*pq[dir] < h[dir]) { + // this point is inside the chopping line + pr[0] = pq[0]; + pr[1] = pq[1]; + pr += 2; + nr++; + if (nr & 8) { + q = r; + goto done; + } + } + dReal *nextq = (i > 1) ? pq+2 : q; + if ((sign*pq[dir] < h[dir]) ^ (sign*nextq[dir] < h[dir])) { + // this line crosses the chopping line + pr[1-dir] = pq[1-dir] + (nextq[1-dir]-pq[1-dir]) / + (nextq[dir]-pq[dir]) * (sign*h[dir]-pq[dir]); + pr[dir] = sign*h[dir]; + pr += 2; + nr++; + if (nr & 8) { + q = r; + goto done; + } + } + pq += 2; + } + q = r; + r = (q==ret) ? buffer : ret; + nq = nr; + } } - } - done: - if (q != ret) memcpy (ret,q,nr*2*sizeof(dReal)); - return nr; +done: + if (q != ret) memcpy (ret,q,nr*2*sizeof(dReal)); + return nr; } @@ -248,66 +248,66 @@ void cullPoints (int n, dReal p[], int m, int i0, int iret[]) { - // compute the centroid of the polygon in cx,cy - int i,j; - dReal a,cx,cy,q; - if (n==1) { - cx = p[0]; - cy = p[1]; - } - else if (n==2) { - cx = REAL(0.5)*(p[0] + p[2]); - cy = REAL(0.5)*(p[1] + p[3]); - } - else { - a = 0; - cx = 0; - cy = 0; - for (i=0; i<(n-1); i++) { - q = p[i*2]*p[i*2+3] - p[i*2+2]*p[i*2+1]; - a += q; - cx += q*(p[i*2]+p[i*2+2]); - cy += q*(p[i*2+1]+p[i*2+3]); + // compute the centroid of the polygon in cx,cy + int i,j; + dReal a,cx,cy,q; + if (n==1) { + cx = p[0]; + cy = p[1]; } - q = p[n*2-2]*p[1] - p[0]*p[n*2-1]; - a = dRecip(REAL(3.0)*(a+q)); - cx = a*(cx + q*(p[n*2-2]+p[0])); - cy = a*(cy + q*(p[n*2-1]+p[1])); - } + else if (n==2) { + cx = REAL(0.5)*(p[0] + p[2]); + cy = REAL(0.5)*(p[1] + p[3]); + } + else { + a = 0; + cx = 0; + cy = 0; + for (i=0; i<(n-1); i++) { + q = p[i*2]*p[i*2+3] - p[i*2+2]*p[i*2+1]; + a += q; + cx += q*(p[i*2]+p[i*2+2]); + cy += q*(p[i*2+1]+p[i*2+3]); + } + q = p[n*2-2]*p[1] - p[0]*p[n*2-1]; + a = dRecip(REAL(3.0)*(a+q)); + cx = a*(cx + q*(p[n*2-2]+p[0])); + cy = a*(cy + q*(p[n*2-1]+p[1])); + } - // compute the angle of each point w.r.t. the centroid - dReal A[8]; - for (i=0; i<n; i++) A[i] = dAtan2(p[i*2+1]-cy,p[i*2]-cx); + // compute the angle of each point w.r.t. the centroid + dReal A[8]; + for (i=0; i<n; i++) A[i] = dAtan2(p[i*2+1]-cy,p[i*2]-cx); - // search for points that have angles closest to A[i0] + i*(2*pi/m). - int avail[8]; - for (i=0; i<n; i++) avail[i] = 1; - avail[i0] = 0; - iret[0] = i0; - iret++; - for (j=1; j<m; j++) { - a = (dReal)(dReal(j)*(2*M_PI/m) + A[i0]); - if (a > M_PI) a -= (dReal)(2*M_PI); - dReal maxdiff=1e9,diff; + // search for points that have angles closest to A[i0] + i*(2*pi/m). + int avail[8]; + for (i=0; i<n; i++) avail[i] = 1; + avail[i0] = 0; + iret[0] = i0; + iret++; + for (j=1; j<m; j++) { + a = (dReal)(dReal(j)*(2*M_PI/m) + A[i0]); + if (a > M_PI) a -= (dReal)(2*M_PI); + dReal maxdiff=1e9,diff; #ifndef dNODEBUG - *iret = i0; // iret is not allowed to keep this value + *iret = i0; // iret is not allowed to keep this value #endif - for (i=0; i<n; i++) { - if (avail[i]) { - diff = dFabs (A[i]-a); - if (diff > M_PI) diff = (dReal) (2*M_PI - diff); - if (diff < maxdiff) { - maxdiff = diff; - *iret = i; - } - } - } + for (i=0; i<n; i++) { + if (avail[i]) { + diff = dFabs (A[i]-a); + if (diff > M_PI) diff = (dReal) (2*M_PI - diff); + if (diff < maxdiff) { + maxdiff = diff; + *iret = i; + } + } + } #ifndef dNODEBUG - dIASSERT (*iret != i0); // ensure iret got set + dIASSERT (*iret != i0); // ensure iret got set #endif - avail[*iret] = 0; - iret++; - } + avail[*iret] = 0; + iret++; + } } @@ -329,80 +329,80 @@ int dBoxBox (const dVector3 p1, const dMatrix3 R1, - const dVector3 side1, const dVector3 p2, - const dMatrix3 R2, const dVector3 side2, - dVector3 normal, dReal *depth, int *return_code, - int flags, dContactGeom *contact, int skip) + const dVector3 side1, const dVector3 p2, + const dMatrix3 R2, const dVector3 side2, + dVector3 normal, dReal *depth, int *return_code, + int flags, dContactGeom *contact, int skip) { - const dReal fudge_factor = REAL(1.05); - dVector3 p,pp,normalC={0,0,0}; - const dReal *normalR = 0; - dReal A[3],B[3],R11,R12,R13,R21,R22,R23,R31,R32,R33, - Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33,s,s2,l,expr1_val; - int i,j,invert_normal,code; + const dReal fudge_factor = REAL(1.05); + dVector3 p,pp,normalC={0,0,0}; + const dReal *normalR = 0; + dReal A[3],B[3],R11,R12,R13,R21,R22,R23,R31,R32,R33, + Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33,s,s2,l,expr1_val; + int i,j,invert_normal,code; - // get vector from centers of box 1 to box 2, relative to box 1 - p[0] = p2[0] - p1[0]; - p[1] = p2[1] - p1[1]; - p[2] = p2[2] - p1[2]; - dMultiply1_331 (pp,R1,p); // get pp = p relative to body 1 + // get vector from centers of box 1 to box 2, relative to box 1 + p[0] = p2[0] - p1[0]; + p[1] = p2[1] - p1[1]; + p[2] = p2[2] - p1[2]; + dMultiply1_331 (pp,R1,p); // get pp = p relative to body 1 - // get side lengths / 2 - A[0] = side1[0]*REAL(0.5); - A[1] = side1[1]*REAL(0.5); - A[2] = side1[2]*REAL(0.5); - B[0] = side2[0]*REAL(0.5); - B[1] = side2[1]*REAL(0.5); - B[2] = side2[2]*REAL(0.5); + // get side lengths / 2 + A[0] = side1[0]*REAL(0.5); + A[1] = side1[1]*REAL(0.5); + A[2] = side1[2]*REAL(0.5); + B[0] = side2[0]*REAL(0.5); + B[1] = side2[1]*REAL(0.5); + B[2] = side2[2]*REAL(0.5); - // Rij is R1'*R2, i.e. the relative rotation between R1 and R2 - R11 = dCalcVectorDot3_44(R1+0,R2+0); R12 = dCalcVectorDot3_44(R1+0,R2+1); R13 = dCalcVectorDot3_44(R1+0,R2+2); - R21 = dCalcVectorDot3_44(R1+1,R2+0); R22 = dCalcVectorDot3_44(R1+1,R2+1); R23 = dCalcVectorDot3_44(R1+1,R2+2); - R31 = dCalcVectorDot3_44(R1+2,R2+0); R32 = dCalcVectorDot3_44(R1+2,R2+1); R33 = dCalcVectorDot3_44(R1+2,R2+2); + // Rij is R1'*R2, i.e. the relative rotation between R1 and R2 + R11 = dCalcVectorDot3_44(R1+0,R2+0); R12 = dCalcVectorDot3_44(R1+0,R2+1); R13 = dCalcVectorDot3_44(R1+0,R2+2); + R21 = dCalcVectorDot3_44(R1+1,R2+0); R22 = dCalcVectorDot3_44(R1+1,R2+1); R23 = dCalcVectorDot3_44(R1+1,R2+2); + R31 = dCalcVectorDot3_44(R1+2,R2+0); R32 = dCalcVectorDot3_44(R1+2,R2+1); R33 = dCalcVectorDot3_44(R1+2,R2+2); - Q11 = dFabs(R11); Q12 = dFabs(R12); Q13 = dFabs(R13); - Q21 = dFabs(R21); Q22 = dFabs(R22); Q23 = dFabs(R23); - Q31 = dFabs(R31); Q32 = dFabs(R32); Q33 = dFabs(R33); + Q11 = dFabs(R11); Q12 = dFabs(R12); Q13 = dFabs(R13); + Q21 = dFabs(R21); Q22 = dFabs(R22); Q23 = dFabs(R23); + Q31 = dFabs(R31); Q32 = dFabs(R32); Q33 = dFabs(R33); - // for all 15 possible separating axes: - // * see if the axis separates the boxes. if so, return 0. - // * find the depth of the penetration along the separating axis (s2) - // * if this is the largest depth so far, record it. - // the normal vector will be set to the separating axis with the smallest - // depth. note: normalR is set to point to a column of R1 or R2 if that is - // the smallest depth normal so far. otherwise normalR is 0 and normalC is - // set to a vector relative to body 1. invert_normal is 1 if the sign of - // the normal should be flipped. + // for all 15 possible separating axes: + // * see if the axis separates the boxes. if so, return 0. + // * find the depth of the penetration along the separating axis (s2) + // * if this is the largest depth so far, record it. + // the normal vector will be set to the separating axis with the smallest + // depth. note: normalR is set to point to a column of R1 or R2 if that is + // the smallest depth normal so far. otherwise normalR is 0 and normalC is + // set to a vector relative to body 1. invert_normal is 1 if the sign of + // the normal should be flipped. - do { + do { #define TST(expr1,expr2,norm,cc) \ expr1_val = (expr1); /* Avoid duplicate evaluation of expr1 */ \ s2 = dFabs(expr1_val) - (expr2); \ if (s2 > 0) return 0; \ if (s2 > s) { \ - s = s2; \ - normalR = norm; \ - invert_normal = ((expr1_val) < 0); \ - code = (cc); \ - if (flags & CONTACTS_UNIMPORTANT) break; \ - } + s = s2; \ + normalR = norm; \ + invert_normal = ((expr1_val) < 0); \ + code = (cc); \ + if (flags & CONTACTS_UNIMPORTANT) break; \ + } - s = -dInfinity; - invert_normal = 0; - code = 0; + s = -dInfinity; + invert_normal = 0; + code = 0; - // separating axis = u1,u2,u3 - TST (pp[0],(A[0] + B[0]*Q11 + B[1]*Q12 + B[2]*Q13),R1+0,1); - TST (pp[1],(A[1] + B[0]*Q21 + B[1]*Q22 + B[2]*Q23),R1+1,2); - TST (pp[2],(A[2] + B[0]*Q31 + B[1]*Q32 + B[2]*Q33),R1+2,3); + // separating axis = u1,u2,u3 + TST (pp[0],(A[0] + B[0]*Q11 + B[1]*Q12 + B[2]*Q13),R1+0,1); + TST (pp[1],(A[1] + B[0]*Q21 + B[1]*Q22 + B[2]*Q23),R1+1,2); + TST (pp[2],(A[2] + B[0]*Q31 + B[1]*Q32 + B[2]*Q33),R1+2,3); - // separating axis = v1,v2,v3 - TST (dCalcVectorDot3_41(R2+0,p),(A[0]*Q11 + A[1]*Q21 + A[2]*Q31 + B[0]),R2+0,4); - TST (dCalcVectorDot3_41(R2+1,p),(A[0]*Q12 + A[1]*Q22 + A[2]*Q32 + B[1]),R2+1,5); - TST (dCalcVectorDot3_41(R2+2,p),(A[0]*Q13 + A[1]*Q23 + A[2]*Q33 + B[2]),R2+2,6); + // separating axis = v1,v2,v3 + TST (dCalcVectorDot3_41(R2+0,p),(A[0]*Q11 + A[1]*Q21 + A[2]*Q31 + B[0]),R2+0,4); + TST (dCalcVectorDot3_41(R2+1,p),(A[0]*Q12 + A[1]*Q22 + A[2]*Q32 + B[1]),R2+1,5); + TST (dCalcVectorDot3_41(R2+2,p),(A[0]*Q13 + A[1]*Q23 + A[2]*Q33 + B[2]),R2+2,6); - // note: cross product axes need to be scaled when s is computed. - // normal (n1,n2,n3) is relative to box 1. + // note: cross product axes need to be scaled when s is computed. + // normal (n1,n2,n3) is relative to box 1. #undef TST #define TST(expr1,expr2,n1,n2,n3,cc) \ expr1_val = (expr1); /* Avoid duplicate evaluation of expr1 */ \ @@ -410,469 +410,469 @@ if (s2 > 0) return 0; \ l = dSqrt ((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \ if (l > 0) { \ - s2 /= l; \ - if (s2*fudge_factor > s) { \ - s = s2; \ - normalR = 0; \ - normalC[0] = (n1)/l; normalC[1] = (n2)/l; normalC[2] = (n3)/l; \ - invert_normal = ((expr1_val) < 0); \ - code = (cc); \ - if (flags & CONTACTS_UNIMPORTANT) break; \ - } \ - } + s2 /= l; \ + if (s2*fudge_factor > s) { \ + s = s2; \ + normalR = 0; \ + normalC[0] = (n1)/l; normalC[1] = (n2)/l; normalC[2] = (n3)/l; \ + invert_normal = ((expr1_val) < 0); \ + code = (cc); \ + if (flags & CONTACTS_UNIMPORTANT) break; \ + } \ + } - // We only need to check 3 edges per box - // since parallel edges are equivalent. + // We only need to check 3 edges per box + // since parallel edges are equivalent. - // separating axis = u1 x (v1,v2,v3) - TST(pp[2]*R21-pp[1]*R31,(A[1]*Q31+A[2]*Q21+B[1]*Q13+B[2]*Q12),0,-R31,R21,7); - TST(pp[2]*R22-pp[1]*R32,(A[1]*Q32+A[2]*Q22+B[0]*Q13+B[2]*Q11),0,-R32,R22,8); - TST(pp[2]*R23-pp[1]*R33,(A[1]*Q33+A[2]*Q23+B[0]*Q12+B[1]*Q11),0,-R33,R23,9); + // separating axis = u1 x (v1,v2,v3) + TST(pp[2]*R21-pp[1]*R31,(A[1]*Q31+A[2]*Q21+B[1]*Q13+B[2]*Q12),0,-R31,R21,7); + TST(pp[2]*R22-pp[1]*R32,(A[1]*Q32+A[2]*Q22+B[0]*Q13+B[2]*Q11),0,-R32,R22,8); + TST(pp[2]*R23-pp[1]*R33,(A[1]*Q33+A[2]*Q23+B[0]*Q12+B[1]*Q11),0,-R33,R23,9); - // separating axis = u2 x (v1,v2,v3) - TST(pp[0]*R31-pp[2]*R11,(A[0]*Q31+A[2]*Q11+B[1]*Q23+B[2]*Q22),R31,0,-R11,10); - TST(pp[0]*R32-pp[2]*R12,(A[0]*Q32+A[2]*Q12+B[0]*Q23+B[2]*Q21),R32,0,-R12,11); - TST(pp[0]*R33-pp[2]*R13,(A[0]*Q33+A[2]*Q13+B[0]*Q22+B[1]*Q21),R33,0,-R13,12); + // separating axis = u2 x (v1,v2,v3) + TST(pp[0]*R31-pp[2]*R11,(A[0]*Q31+A[2]*Q11+B[1]*Q23+B[2]*Q22),R31,0,-R11,10); + TST(pp[0]*R32-pp[2]*R12,(A[0]*Q32+A[2]*Q12+B[0]*Q23+B[2]*Q21),R32,0,-R12,11); + TST(pp[0]*R33-pp[2]*R13,(A[0]*Q33+A[2]*Q13+B[0]*Q22+B[1]*Q21),R33,0,-R13,12); - // separating axis = u3 x (v1,v2,v3) - TST(pp[1]*R11-pp[0]*R21,(A[0]*Q21+A[1]*Q11+B[1]*Q33+B[2]*Q32),-R21,R11,0,13); - TST(pp[1]*R12-pp[0]*R22,(A[0]*Q22+A[1]*Q12+B[0]*Q33+B[2]*Q31),-R22,R12,0,14); - TST(pp[1]*R13-pp[0]*R23,(A[0]*Q23+A[1]*Q13+B[0]*Q32+B[1]*Q31),-R23,R13,0,15); + // separating axis = u3 x (v1,v2,v3) + TST(pp[1]*R11-pp[0]*R21,(A[0]*Q21+A[1]*Q11+B[1]*Q33+B[2]*Q32),-R21,R11,0,13); + TST(pp[1]*R12-pp[0]*R22,(A[0]*Q22+A[1]*Q12+B[0]*Q33+B[2]*Q31),-R22,R12,0,14); + TST(pp[1]*R13-pp[0]*R23,(A[0]*Q23+A[1]*Q13+B[0]*Q32+B[1]*Q31),-R23,R13,0,15); #undef TST - } while (0); + } while (0); - if (!code) return 0; + if (!code) return 0; - // if we get to this point, the boxes interpenetrate. compute the normal - // in global coordinates. - if (normalR) { - normal[0] = normalR[0]; - normal[1] = normalR[4]; - normal[2] = normalR[8]; - } - else { - dMultiply0_331 (normal,R1,normalC); - } - if (invert_normal) { - normal[0] = -normal[0]; - normal[1] = -normal[1]; - normal[2] = -normal[2]; - } - *depth = -s; + // if we get to this point, the boxes interpenetrate. compute the normal + // in global coordinates. + if (normalR) { + normal[0] = normalR[0]; + normal[1] = normalR[4]; + normal[2] = normalR[8]; + } + else { + dMultiply0_331 (normal,R1,normalC); + } + if (invert_normal) { + normal[0] = -normal[0]; + normal[1] = -normal[1]; + normal[2] = -normal[2]; + } + *depth = -s; - // compute contact point(s) + // compute contact point(s) - if (code > 6) { - // An edge from box 1 touches an edge from box 2. - // find a point pa on the intersecting edge of box 1 - dVector3 pa; - dReal sign; - // Copy p1 into pa - for (i=0; i<3; i++) pa[i] = p1[i]; // why no memcpy? - // Get world position of p2 into pa - for (j=0; j<3; j++) { - sign = (dCalcVectorDot3_14(normal,R1+j) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) pa[i] += sign * A[j] * R1[i*4+j]; + if (code > 6) { + // An edge from box 1 touches an edge from box 2. + // find a point pa on the intersecting edge of box 1 + dVector3 pa; + dReal sign; + // Copy p1 into pa + for (i=0; i<3; i++) pa[i] = p1[i]; // why no memcpy? + // Get world position of p2 into pa + for (j=0; j<3; j++) { + sign = (dCalcVectorDot3_14(normal,R1+j) > 0) ? REAL(1.0) : REAL(-1.0); + for (i=0; i<3; i++) pa[i] += sign * A[j] * R1[i*4+j]; + } + + // find a point pb on the intersecting edge of box 2 + dVector3 pb; + // Copy p2 into pb + for (i=0; i<3; i++) pb[i] = p2[i]; // why no memcpy? + // Get world position of p2 into pb + for (j=0; j<3; j++) { + sign = (dCalcVectorDot3_14(normal,R2+j) > 0) ? REAL(-1.0) : REAL(1.0); + for (i=0; i<3; i++) pb[i] += sign * B[j] * R2[i*4+j]; + } + + dReal alpha,beta; + dVector3 ua,ub; + // Get direction of first edge + for (i=0; i<3; i++) ua[i] = R1[((code)-7)/3 + i*4]; + // Get direction of second edge + for (i=0; i<3; i++) ub[i] = R2[((code)-7)%3 + i*4]; + // Get closest points between edges (one at each) + dLineClosestApproach (pa,ua,pb,ub,&alpha,&beta); + for (i=0; i<3; i++) pa[i] += ua[i]*alpha; + for (i=0; i<3; i++) pb[i] += ub[i]*beta; + // Set the contact point as halfway between the 2 closest points + for (i=0; i<3; i++) contact[0].pos[i] = REAL(0.5)*(pa[i]+pb[i]); + contact[0].depth = *depth; + *return_code = code; + return 1; } - // find a point pb on the intersecting edge of box 2 - dVector3 pb; - // Copy p2 into pb - for (i=0; i<3; i++) pb[i] = p2[i]; // why no memcpy? - // Get world position of p2 into pb - for (j=0; j<3; j++) { - sign = (dCalcVectorDot3_14(normal,R2+j) > 0) ? REAL(-1.0) : REAL(1.0); - for (i=0; i<3; i++) pb[i] += sign * B[j] * R2[i*4+j]; + // okay, we have a face-something intersection (because the separating + // axis is perpendicular to a face). define face 'a' to be the reference + // face (i.e. the normal vector is perpendicular to this) and face 'b' to be + // the incident face (the closest face of the other box). + // Note: Unmodified parameter values are being used here + const dReal *Ra,*Rb,*pa,*pb,*Sa,*Sb; + if (code <= 3) { // One of the faces of box 1 is the reference face + Ra = R1; // Rotation of 'a' + Rb = R2; // Rotation of 'b' + pa = p1; // Center (location) of 'a' + pb = p2; // Center (location) of 'b' + Sa = A; // Side Lenght of 'a' + Sb = B; // Side Lenght of 'b' } - - dReal alpha,beta; - dVector3 ua,ub; - // Get direction of first edge - for (i=0; i<3; i++) ua[i] = R1[((code)-7)/3 + i*4]; - // Get direction of second edge - for (i=0; i<3; i++) ub[i] = R2[((code)-7)%3 + i*4]; - // Get closest points between edges (one at each) - dLineClosestApproach (pa,ua,pb,ub,&alpha,&beta); - for (i=0; i<3; i++) pa[i] += ua[i]*alpha; - for (i=0; i<3; i++) pb[i] += ub[i]*beta; - // Set the contact point as halfway between the 2 closest points - for (i=0; i<3; i++) contact[0].pos[i] = REAL(0.5)*(pa[i]+pb[i]); - contact[0].depth = *depth; - *return_code = code; - return 1; - } + else { // One of the faces of box 2 is the reference face + Ra = R2; // Rotation of 'a' + Rb = R1; // Rotation of 'b' + pa = p2; // Center (location) of 'a' + pb = p1; // Center (location) of 'b' + Sa = B; // Side Lenght of 'a' + Sb = A; // Side Lenght of 'b' + } - // okay, we have a face-something intersection (because the separating - // axis is perpendicular to a face). define face 'a' to be the reference - // face (i.e. the normal vector is perpendicular to this) and face 'b' to be - // the incident face (the closest face of the other box). - // Note: Unmodified parameter values are being used here - const dReal *Ra,*Rb,*pa,*pb,*Sa,*Sb; - if (code <= 3) { // One of the faces of box 1 is the reference face - Ra = R1; // Rotation of 'a' - Rb = R2; // Rotation of 'b' - pa = p1; // Center (location) of 'a' - pb = p2; // Center (location) of 'b' - Sa = A; // Side Lenght of 'a' - Sb = B; // Side Lenght of 'b' - } - else { // One of the faces of box 2 is the reference face - Ra = R2; // Rotation of 'a' - Rb = R1; // Rotation of 'b' - pa = p2; // Center (location) of 'a' - pb = p1; // Center (location) of 'b' - Sa = B; // Side Lenght of 'a' - Sb = A; // Side Lenght of 'b' - } + // nr = normal vector of reference face dotted with axes of incident box. + // anr = absolute values of nr. + /* + The normal is flipped if necessary so it always points outward from box 'a', + box 'b' is thus always the incident box + */ + dVector3 normal2,nr,anr; + if (code <= 3) { + normal2[0] = normal[0]; + normal2[1] = normal[1]; + normal2[2] = normal[2]; + } + else { + normal2[0] = -normal[0]; + normal2[1] = -normal[1]; + normal2[2] = -normal[2]; + } + // Rotate normal2 in incident box opposite direction + dMultiply1_331 (nr,Rb,normal2); + anr[0] = dFabs (nr[0]); + anr[1] = dFabs (nr[1]); + anr[2] = dFabs (nr[2]); - // nr = normal vector of reference face dotted with axes of incident box. - // anr = absolute values of nr. - /* - The normal is flipped if necessary so it always points outward from box 'a', - box 'b' is thus always the incident box - */ - dVector3 normal2,nr,anr; - if (code <= 3) { - normal2[0] = normal[0]; - normal2[1] = normal[1]; - normal2[2] = normal[2]; - } - else { - normal2[0] = -normal[0]; - normal2[1] = -normal[1]; - normal2[2] = -normal[2]; - } - // Rotate normal2 in incident box opposite direction - dMultiply1_331 (nr,Rb,normal2); - anr[0] = dFabs (nr[0]); - anr[1] = dFabs (nr[1]); - anr[2] = dFabs (nr[2]); + // find the largest compontent of anr: this corresponds to the normal + // for the incident face. the other axis numbers of the incident face + // are stored in a1,a2. + int lanr,a1,a2; + if (anr[1] > anr[0]) { + if (anr[1] > anr[2]) { + a1 = 0; + lanr = 1; + a2 = 2; + } + else { + a1 = 0; + a2 = 1; + lanr = 2; + } + } + else { + if (anr[0] > anr[2]) { + lanr = 0; + a1 = 1; + a2 = 2; + } + else { + a1 = 0; + a2 = 1; + lanr = 2; + } + } - // find the largest compontent of anr: this corresponds to the normal - // for the incident face. the other axis numbers of the incident face - // are stored in a1,a2. - int lanr,a1,a2; - if (anr[1] > anr[0]) { - if (anr[1] > anr[2]) { - a1 = 0; - lanr = 1; - a2 = 2; + // compute center point of incident face, in reference-face coordinates + dVector3 center; + if (nr[lanr] < 0) { + for (i=0; i<3; i++) center[i] = pb[i] - pa[i] + Sb[lanr] * Rb[i*4+lanr]; } else { - a1 = 0; - a2 = 1; - lanr = 2; + for (i=0; i<3; i++) center[i] = pb[i] - pa[i] - Sb[lanr] * Rb[i*4+lanr]; } - } - else { - if (anr[0] > anr[2]) { - lanr = 0; - a1 = 1; - a2 = 2; + + // find the normal and non-normal axis numbers of the reference box + int codeN,code1,code2; + if (code <= 3) codeN = code-1; else codeN = code-4; + if (codeN==0) { + code1 = 1; + code2 = 2; } + else if (codeN==1) { + code1 = 0; + code2 = 2; + } else { - a1 = 0; - a2 = 1; - lanr = 2; + code1 = 0; + code2 = 1; } - } - // compute center point of incident face, in reference-face coordinates - dVector3 center; - if (nr[lanr] < 0) { - for (i=0; i<3; i++) center[i] = pb[i] - pa[i] + Sb[lanr] * Rb[i*4+lanr]; - } - else { - for (i=0; i<3; i++) center[i] = pb[i] - pa[i] - Sb[lanr] * Rb[i*4+lanr]; - } + // find the four corners of the incident face, in reference-face coordinates + dReal quad[8]; // 2D coordinate of incident face (x,y pairs) + dReal c1,c2,m11,m12,m21,m22; + c1 = dCalcVectorDot3_14 (center,Ra+code1); + c2 = dCalcVectorDot3_14 (center,Ra+code2); + // optimize this? - we have already computed this data above, but it is not + // stored in an easy-to-index format. for now it's quicker just to recompute + // the four dot products. + m11 = dCalcVectorDot3_44 (Ra+code1,Rb+a1); + m12 = dCalcVectorDot3_44 (Ra+code1,Rb+a2); + m21 = dCalcVectorDot3_44 (Ra+code2,Rb+a1); + m22 = dCalcVectorDot3_44 (Ra+code2,Rb+a2); + { + dReal k1 = m11*Sb[a1]; + dReal k2 = m21*Sb[a1]; + dReal k3 = m12*Sb[a2]; + dReal k4 = m22*Sb[a2]; + quad[0] = c1 - k1 - k3; + quad[1] = c2 - k2 - k4; + quad[2] = c1 - k1 + k3; + quad[3] = c2 - k2 + k4; + quad[4] = c1 + k1 + k3; + quad[5] = c2 + k2 + k4; + quad[6] = c1 + k1 - k3; + quad[7] = c2 + k2 - k4; + } - // find the normal and non-normal axis numbers of the reference box - int codeN,code1,code2; - if (code <= 3) codeN = code-1; else codeN = code-4; - if (codeN==0) { - code1 = 1; - code2 = 2; - } - else if (codeN==1) { - code1 = 0; - code2 = 2; - } - else { - code1 = 0; - code2 = 1; - } + // find the size of the reference face + dReal rect[2]; + rect[0] = Sa[code1]; + rect[1] = Sa[code2]; - // find the four corners of the incident face, in reference-face coordinates - dReal quad[8]; // 2D coordinate of incident face (x,y pairs) - dReal c1,c2,m11,m12,m21,m22; - c1 = dCalcVectorDot3_14 (center,Ra+code1); - c2 = dCalcVectorDot3_14 (center,Ra+code2); - // optimize this? - we have already computed this data above, but it is not - // stored in an easy-to-index format. for now it's quicker just to recompute - // the four dot products. - m11 = dCalcVectorDot3_44 (Ra+code1,Rb+a1); - m12 = dCalcVectorDot3_44 (Ra+code1,Rb+a2); - m21 = dCalcVectorDot3_44 (Ra+code2,Rb+a1); - m22 = dCalcVectorDot3_44 (Ra+code2,Rb+a2); - { - dReal k1 = m11*Sb[a1]; - dReal k2 = m21*Sb[a1]; - dReal k3 = m12*Sb[a2]; - dReal k4 = m22*Sb[a2]; - quad[0] = c1 - k1 - k3; - quad[1] = c2 - k2 - k4; - quad[2] = c1 - k1 + k3; - quad[3] = c2 - k2 + k4; - quad[4] = c1 + k1 + k3; - quad[5] = c2 + k2 + k4; - quad[6] = c1 + k1 - k3; - quad[7] = c2 + k2 - k4; - } + // intersect the incident and reference faces + dReal ret[16]; + int n = intersectRectQuad (rect,quad,ret); + if (n < 1) return 0; // this should never happen - // find the size of the reference face - dReal rect[2]; - rect[0] = Sa[code1]; - rect[1] = Sa[code2]; - - // intersect the incident and reference faces - dReal ret[16]; - int n = intersectRectQuad (rect,quad,ret); - if (n < 1) return 0; // this should never happen - - // convert the intersection points into reference-face coordinates, - // and compute the contact position and depth for each point. only keep - // those points that have a positive (penetrating) depth. delete points in - // the 'ret' array as necessary so that 'point' and 'ret' correspond. - dReal point[3*8]; // penetrating contact points - dReal dep[8]; // depths for those points - dReal det1 = dRecip(m11*m22 - m12*m21); - m11 *= det1; - m12 *= det1; - m21 *= det1; - m22 *= det1; - int cnum = 0; // number of penetrating contact points found - for (j=0; j < n; j++) { - dReal k1 = m22*(ret[j*2]-c1) - m12*(ret[j*2+1]-c2); - dReal k2 = -m21*(ret[j*2]-c1) + m11*(ret[j*2+1]-c2); - for (i=0; i<3; i++) point[cnum*3+i] = - center[i] + k1*Rb[i*4+a1] + k2*Rb[i*4+a2]; - dep[cnum] = Sa[codeN] - dCalcVectorDot3(normal2,point+cnum*3); - if (dep[cnum] >= 0) { - ret[cnum*2] = ret[j*2]; - ret[cnum*2+1] = ret[j*2+1]; - cnum++; - if ((cnum | CONTACTS_UNIMPORTANT) == (flags & (NUMC_MASK | CONTACTS_UNIMPORTANT))) { - break; - } + // convert the intersection points into reference-face coordinates, + // and compute the contact position and depth for each point. only keep + // those points that have a positive (penetrating) depth. delete points in + // the 'ret' array as necessary so that 'point' and 'ret' correspond. + dReal point[3*8]; // penetrating contact points + dReal dep[8]; // depths for those points + dReal det1 = dRecip(m11*m22 - m12*m21); + m11 *= det1; + m12 *= det1; + m21 *= det1; + m22 *= det1; + int cnum = 0; // number of penetrating contact points found + for (j=0; j < n; j++) { + dReal k1 = m22*(ret[j*2]-c1) - m12*(ret[j*2+1]-c2); + dReal k2 = -m21*(ret[j*2]-c1) + m11*(ret[j*2+1]-c2); + for (i=0; i<3; i++) point[cnum*3+i] = + center[i] + k1*Rb[i*4+a1] + k2*Rb[i*4+a2]; + dep[cnum] = Sa[codeN] - dCalcVectorDot3(normal2,point+cnum*3); + if (dep[cnum] >= 0) { + ret[cnum*2] = ret[j*2]; + ret[cnum*2+1] = ret[j*2+1]; + cnum++; + if ((cnum | CONTACTS_UNIMPORTANT) == (flags & (NUMC_MASK | CONTACTS_UNIMPORTANT))) { + break; + } + } } - } - if (cnum < 1) { - return 0; // this should not happen, yet does at times (demo_plane2d single precision). - } + if (cnum < 1) { + return 0; // this should not happen, yet does at times (demo_plane2d single precision). + } - // we can't generate more contacts than we actually have - int maxc = flags & NUMC_MASK; - if (maxc > cnum) maxc = cnum; - if (maxc < 1) maxc = 1; // Even though max count must not be zero this check is kept for backward compatibility as this is a public function + // we can't generate more contacts than we actually have + int maxc = flags & NUMC_MASK; + if (maxc > cnum) maxc = cnum; + if (maxc < 1) maxc = 1; // Even though max count must not be zero this check is kept for backward compatibility as this is a public function - if (cnum <= maxc) { - // we have less contacts than we need, so we use them all - for (j=0; j < cnum; j++) { - dContactGeom *con = CONTACT(contact,skip*j); - for (i=0; i<3; i++) con->pos[i] = point[j*3+i] + pa[i]; - con->depth = dep[j]; + if (cnum <= maxc) { + // we have less contacts than we need, so we use them all + for (j=0; j < cnum; j++) { + dContactGeom *con = CONTACT(contact,skip*j); + for (i=0; i<3; i++) con->pos[i] = point[j*3+i] + pa[i]; + con->depth = dep[j]; + } } - } - else { - dIASSERT(!(flags & CONTACTS_UNIMPORTANT)); // cnum should be generated not greater than maxc so that "then" clause is executed - // we have more contacts than are wanted, some of them must be culled. - // find the deepest point, it is always the first contact. - int i1 = 0; - dReal maxdepth = dep[0]; - for (i=1; i<cnum; i++) { - if (dep[i] > maxdepth) { - maxdepth = dep[i]; - i1 = i; - } - } + else { + dIASSERT(!(flags & CONTACTS_UNIMPORTANT)); // cnum should be generated not greater than maxc so that "then" clause is executed + // we have more contacts than are wanted, some of them must be culled. + // find the deepest point, it is always the first contact. + int i1 = 0; + dReal maxdepth = dep[0]; + for (i=1; i<cnum; i++) { + if (dep[i] > maxdepth) { + maxdepth = dep[i]; + i1 = i; + } + } - int iret[8]; - cullPoints (cnum,ret,maxc,i1,iret); + int iret[8]; + cullPoints (cnum,ret,maxc,i1,iret); - for (j=0; j < maxc; j++) { - dContactGeom *con = CONTACT(contact,skip*j); - for (i=0; i<3; i++) con->pos[i] = point[iret[j]*3+i] + pa[i]; - con->depth = dep[iret[j]]; + for (j=0; j < maxc; j++) { + dContactGeom *con = CONTACT(contact,skip*j); + for (i=0; i<3; i++) con->pos[i] = point[iret[j]*3+i] + pa[i]; + con->depth = dep[iret[j]]; + } + cnum = maxc; } - cnum = maxc; - } - *return_code = code; - return cnum; + *return_code = code; + return cnum; } int dCollideBoxBox (dxGeom *o1, dxGeom *o2, int flags, - dContactGeom *contact, int skip) + dContactGeom *contact, int skip) { - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->type == dBoxClass); - dIASSERT (o2->type == dBoxClass); - dIASSERT ((flags & NUMC_MASK) >= 1); + dIASSERT (skip >= (int)sizeof(dContactGeom)); + dIASSERT (o1->type == dBoxClass); + dIASSERT (o2->type == dBoxClass); + dIASSERT ((flags & NUMC_MASK) >= 1); - dVector3 normal; - dReal depth; - int code; - dxBox *b1 = (dxBox*) o1; - dxBox *b2 = (dxBox*) o2; - int num = dBoxBox (o1->final_posr->pos,o1->final_posr->R,b1->side, o2->final_posr->pos,o2->final_posr->R,b2->side, - normal,&depth,&code,flags,contact,skip); - for (int i=0; i<num; i++) { - dContactGeom *currContact = CONTACT(contact,i*skip); - currContact->normal[0] = -normal[0]; - currContact->normal[1] = -normal[1]; - currContact->normal[2] = -normal[2]; - currContact->g1 = o1; - currContact->g2 = o2; - currContact->side1 = -1; - currContact->side2 = -1; - } - return num; + dVector3 normal; + dReal depth; + int code; + dxBox *b1 = (dxBox*) o1; + dxBox *b2 = (dxBox*) o2; + int num = dBoxBox (o1->final_posr->pos,o1->final_posr->R,b1->side, o2->final_posr->pos,o2->final_posr->R,b2->side, + normal,&depth,&code,flags,contact,skip); + for (int i=0; i<num; i++) { + dContactGeom *currContact = CONTACT(contact,i*skip); + currContact->normal[0] = -normal[0]; + currContact->normal[1] = -normal[1]; + currContact->normal[2] = -normal[2]; + currContact->g1 = o1; + currContact->g2 = o2; + currContact->side1 = -1; + currContact->side2 = -1; + } + return num; } int dCollideBoxPlane (dxGeom *o1, dxGeom *o2, - int flags, dContactGeom *contact, int skip) + int flags, dContactGeom *contact, int skip) { - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->type == dBoxClass); - dIASSERT (o2->type == dPlaneClass); - dIASSERT ((flags & NUMC_MASK) >= 1); + dIASSERT (skip >= (int)sizeof(dContactGeom)); + dIASSERT (o1->type == dBoxClass); + dIASSERT (o2->type == dPlaneClass); + dIASSERT ((flags & NUMC_MASK) >= 1); - dxBox *box = (dxBox*) o1; - dxPlane *plane = (dxPlane*) o2; + dxBox *box = (dxBox*) o1; + dxPlane *plane = (dxPlane*) o2; - contact->g1 = o1; - contact->g2 = o2; - contact->side1 = -1; - contact->side2 = -1; - - int ret = 0; + contact->g1 = o1; + contact->g2 = o2; + contact->side1 = -1; + contact->side2 = -1; - //@@@ problem: using 4-vector (plane->p) as 3-vector (normal). - const dReal *R = o1->final_posr->R; // rotation of box - const dReal *n = plane->p; // normal vector + int ret = 0; - // project sides lengths along normal vector, get absolute values - dReal Q1 = dCalcVectorDot3_14(n,R+0); - dReal Q2 = dCalcVectorDot3_14(n,R+1); - dReal Q3 = dCalcVectorDot3_14(n,R+2); - dReal A1 = box->side[0] * Q1; - dReal A2 = box->side[1] * Q2; - dReal A3 = box->side[2] * Q3; - dReal B1 = dFabs(A1); - dReal B2 = dFabs(A2); - dReal B3 = dFabs(A3); + //@@@ problem: using 4-vector (plane->p) as 3-vector (normal). + const dReal *R = o1->final_posr->R; // rotation of box + const dReal *n = plane->p; // normal vector - // early exit test - dReal depth = plane->p[3] + REAL(0.5)*(B1+B2+B3) - dCalcVectorDot3(n,o1->final_posr->pos); - if (depth < 0) return 0; + // project sides lengths along normal vector, get absolute values + dReal Q1 = dCalcVectorDot3_14(n,R+0); + dReal Q2 = dCalcVectorDot3_14(n,R+1); + dReal Q3 = dCalcVectorDot3_14(n,R+2); + dReal A1 = box->side[0] * Q1; + dReal A2 = box->side[1] * Q2; + dReal A3 = box->side[2] * Q3; + dReal B1 = dFabs(A1); + dReal B2 = dFabs(A2); + dReal B3 = dFabs(A3); - // find number of contacts requested - int maxc = flags & NUMC_MASK; - // if (maxc < 1) maxc = 1; // an assertion is made on entry - if (maxc > 4) maxc = 4; // not more than 4 contacts per box allowed + // early exit test + dReal depth = plane->p[3] + REAL(0.5)*(B1+B2+B3) - dCalcVectorDot3(n,o1->final_posr->pos); + if (depth < 0) return 0; - // find deepest point - dVector3 p; - p[0] = o1->final_posr->pos[0]; - p[1] = o1->final_posr->pos[1]; - p[2] = o1->final_posr->pos[2]; + // find number of contacts requested + int maxc = flags & NUMC_MASK; + // if (maxc < 1) maxc = 1; // an assertion is made on entry + if (maxc > 4) maxc = 4; // not more than 4 contacts per box allowed + + // find deepest point + dVector3 p; + p[0] = o1->final_posr->pos[0]; + p[1] = o1->final_posr->pos[1]; + p[2] = o1->final_posr->pos[2]; #define FOO(i,op) \ - p[0] op REAL(0.5)*box->side[i] * R[0+i]; \ - p[1] op REAL(0.5)*box->side[i] * R[4+i]; \ - p[2] op REAL(0.5)*box->side[i] * R[8+i]; + p[0] op REAL(0.5)*box->side[i] * R[0+i]; \ + p[1] op REAL(0.5)*box->side[i] * R[4+i]; \ + p[2] op REAL(0.5)*box->side[i] * R[8+i]; #define BAR(i,iinc) if (A ## iinc > 0) { FOO(i,-=) } else { FOO(i,+=) } - BAR(0,1); - BAR(1,2); - BAR(2,3); + BAR(0,1); + BAR(1,2); + BAR(2,3); #undef FOO #undef BAR - // the deepest point is the first contact point - contact->pos[0] = p[0]; - contact->pos[1] = p[1]; - contact->pos[2] = p[2]; - contact->depth = depth; - ret = 1; // ret is number of contact points found so far - if (maxc == 1) goto done; + // the deepest point is the first contact point + contact->pos[0] = p[0]; + contact->pos[1] = p[1]; + contact->pos[2] = p[2]; + contact->depth = depth; + ret = 1; // ret is number of contact points found so far + if (maxc == 1) goto done; - // get the second and third contact points by starting from `p' and going - // along the two sides with the smallest projected length. + // get the second and third contact points by starting from `p' and going + // along the two sides with the smallest projected length. #define FOO(i,j,op) \ - CONTACT(contact,i*skip)->pos[0] = p[0] op box->side[j] * R[0+j]; \ - CONTACT(contact,i*skip)->pos[1] = p[1] op box->side[j] * R[4+j]; \ - CONTACT(contact,i*skip)->pos[2] = p[2] op box->side[j] * R[8+j]; + CONTACT(contact,i*skip)->pos[0] = p[0] op box->side[j] * R[0+j]; \ + CONTACT(contact,i*skip)->pos[1] = p[1] op box->side[j] * R[4+j]; \ + CONTACT(contact,i*skip)->pos[2] = p[2] op box->side[j] * R[8+j]; #define BAR(ctact,side,sideinc) \ - if (depth - B ## sideinc < 0) goto done; \ - if (A ## sideinc > 0) { FOO(ctact,side,+); } else { FOO(ctact,side,-); } \ - CONTACT(contact,ctact*skip)->depth = depth - B ## sideinc; \ - ret++; + if (depth - B ## sideinc < 0) goto done; \ + if (A ## sideinc > 0) { FOO(ctact,side,+); } else { FOO(ctact,side,-); } \ + CONTACT(contact,ctact*skip)->depth = depth - B ## sideinc; \ + ret++; - if (B1 < B2) { - if (B3 < B1) goto use_side_3; else { - BAR(1,0,1); // use side 1 - if (maxc == 2) goto done; - if (B2 < B3) goto contact2_2; else goto contact2_3; + if (B1 < B2) { + if (B3 < B1) goto use_side_3; else { + BAR(1,0,1); // use side 1 + if (maxc == 2) goto done; + if (B2 < B3) goto contact2_2; else goto contact2_3; + } } - } - else { - if (B3 < B2) { - use_side_3: // use side 3 - BAR(1,2,3); - if (maxc == 2) goto done; - if (B1 < B2) goto contact2_1; else goto contact2_2; - } else { - BAR(1,1,2); // use side 2 - if (maxc == 2) goto done; - if (B1 < B3) goto contact2_1; else goto contact2_3; + if (B3 < B2) { +use_side_3: // use side 3 + BAR(1,2,3); + if (maxc == 2) goto done; + if (B1 < B2) goto contact2_1; else goto contact2_2; + } + else { + BAR(1,1,2); // use side 2 + if (maxc == 2) goto done; + if (B1 < B3) goto... [truncated message content] |
From: <ole...@us...> - 2012-03-29 08:48:06
|
Revision: 1881 http://opende.svn.sourceforge.net/opende/?rev=1881&view=rev Author: oleh_derevenko Date: 2012-03-29 08:47:56 +0000 (Thu, 29 Mar 2012) Log Message: ----------- Header name characters case fixed for compatibility with POSIX systems Modified Paths: -------------- trunk/ode/src/threading_impl_win.h Modified: trunk/ode/src/threading_impl_win.h =================================================================== --- trunk/ode/src/threading_impl_win.h 2012-03-29 04:43:42 UTC (rev 1880) +++ trunk/ode/src/threading_impl_win.h 2012-03-29 08:47:56 UTC (rev 1881) @@ -43,7 +43,7 @@ #if !defined(_WIN32_WINNT) #define _WIN32_WINNT 0x0400 #endif -#include <Windows.h> +#include <windows.h> #endif // #if dBUILTIN_THREADING_IMPL_ENABLED This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-03-29 04:43:48
|
Revision: 1880 http://opende.svn.sourceforge.net/opende/?rev=1880&view=rev Author: danielosmari Date: 2012-03-29 04:43:42 +0000 (Thu, 29 Mar 2012) Log Message: ----------- test removed as no alternative implementation is provided Modified Paths: -------------- trunk/libccd/configure.ac Modified: trunk/libccd/configure.ac =================================================================== --- trunk/libccd/configure.ac 2012-03-29 04:39:41 UTC (rev 1879) +++ trunk/libccd/configure.ac 2012-03-29 04:43:42 UTC (rev 1880) @@ -27,7 +27,6 @@ # Checks for library functions. AC_FUNC_FORK -AC_FUNC_REALLOC AC_CHECK_FUNCS([clock_gettime]) use_double=no This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |