Changeset 2907 for code/branches/questsystem5/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
- Timestamp:
- Apr 8, 2009, 12:36:08 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/bullet/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
r2662 r2907 69 69 btSliderConstraint::btSliderConstraint() 70 70 :btTypedConstraint(SLIDER_CONSTRAINT_TYPE), 71 m_useLinearReferenceFrameA(true) 71 m_useLinearReferenceFrameA(true), 72 m_useSolveConstraintObsolete(false) 73 // m_useSolveConstraintObsolete(true) 72 74 { 73 75 initParams(); … … 80 82 , m_frameInA(frameInA) 81 83 , m_frameInB(frameInB), 82 m_useLinearReferenceFrameA(useLinearReferenceFrameA) 84 m_useLinearReferenceFrameA(useLinearReferenceFrameA), 85 m_useSolveConstraintObsolete(false) 86 // m_useSolveConstraintObsolete(true) 83 87 { 84 88 initParams(); … … 89 93 void btSliderConstraint::buildJacobian() 90 94 { 95 if (!m_useSolveConstraintObsolete) 96 { 97 return; 98 } 91 99 if(m_useLinearReferenceFrameA) 92 100 { … … 156 164 //----------------------------------------------------------------------------- 157 165 158 void btSliderConstraint:: solveConstraint(btScalar timeStep)159 { 160 m_timeStep = timeStep; 161 if(m_useLinearReferenceFrameA)162 {163 solveConstraintInt(m_rbA, m_rbB);166 void btSliderConstraint::getInfo1(btConstraintInfo1* info) 167 { 168 if (m_useSolveConstraintObsolete) 169 { 170 info->m_numConstraintRows = 0; 171 info->nub = 0; 164 172 } 165 173 else 166 174 { 167 solveConstraintInt(m_rbB, m_rbA); 175 info->m_numConstraintRows = 4; // Fixed 2 linear + 2 angular 176 info->nub = 2; 177 //prepare constraint 178 calculateTransforms(); 179 testLinLimits(); 180 if(getSolveLinLimit() || getPoweredLinMotor()) 181 { 182 info->m_numConstraintRows++; // limit 3rd linear as well 183 info->nub--; 184 } 185 testAngLimits(); 186 if(getSolveAngLimit() || getPoweredAngMotor()) 187 { 188 info->m_numConstraintRows++; // limit 3rd angular as well 189 info->nub--; 190 } 191 } 192 } // btSliderConstraint::getInfo1() 193 194 //----------------------------------------------------------------------------- 195 196 void btSliderConstraint::getInfo2(btConstraintInfo2* info) 197 { 198 btAssert(!m_useSolveConstraintObsolete); 199 int i, s = info->rowskip; 200 const btTransform& trA = getCalculatedTransformA(); 201 const btTransform& trB = getCalculatedTransformB(); 202 btScalar signFact = m_useLinearReferenceFrameA ? btScalar(1.0f) : btScalar(-1.0f); 203 // make rotations around Y and Z equal 204 // the slider axis should be the only unconstrained 205 // rotational axis, the angular velocity of the two bodies perpendicular to 206 // the slider axis should be equal. thus the constraint equations are 207 // p*w1 - p*w2 = 0 208 // q*w1 - q*w2 = 0 209 // where p and q are unit vectors normal to the slider axis, and w1 and w2 210 // are the angular velocity vectors of the two bodies. 211 // get slider axis (X) 212 btVector3 ax1 = trA.getBasis().getColumn(0); 213 // get 2 orthos to slider axis (Y, Z) 214 btVector3 p = trA.getBasis().getColumn(1); 215 btVector3 q = trA.getBasis().getColumn(2); 216 // set the two slider rows 217 info->m_J1angularAxis[0] = p[0]; 218 info->m_J1angularAxis[1] = p[1]; 219 info->m_J1angularAxis[2] = p[2]; 220 info->m_J1angularAxis[s+0] = q[0]; 221 info->m_J1angularAxis[s+1] = q[1]; 222 info->m_J1angularAxis[s+2] = q[2]; 223 224 info->m_J2angularAxis[0] = -p[0]; 225 info->m_J2angularAxis[1] = -p[1]; 226 info->m_J2angularAxis[2] = -p[2]; 227 info->m_J2angularAxis[s+0] = -q[0]; 228 info->m_J2angularAxis[s+1] = -q[1]; 229 info->m_J2angularAxis[s+2] = -q[2]; 230 // compute the right hand side of the constraint equation. set relative 231 // body velocities along p and q to bring the slider back into alignment. 232 // if ax1,ax2 are the unit length slider axes as computed from body1 and 233 // body2, we need to rotate both bodies along the axis u = (ax1 x ax2). 234 // if "theta" is the angle between ax1 and ax2, we need an angular velocity 235 // along u to cover angle erp*theta in one step : 236 // |angular_velocity| = angle/time = erp*theta / stepsize 237 // = (erp*fps) * theta 238 // angular_velocity = |angular_velocity| * (ax1 x ax2) / |ax1 x ax2| 239 // = (erp*fps) * theta * (ax1 x ax2) / sin(theta) 240 // ...as ax1 and ax2 are unit length. if theta is smallish, 241 // theta ~= sin(theta), so 242 // angular_velocity = (erp*fps) * (ax1 x ax2) 243 // ax1 x ax2 is in the plane space of ax1, so we project the angular 244 // velocity to p and q to find the right hand side. 245 btScalar k = info->fps * info->erp * getSoftnessOrthoAng(); 246 btVector3 ax2 = trB.getBasis().getColumn(0); 247 btVector3 u = ax1.cross(ax2); 248 info->m_constraintError[0] = k * u.dot(p); 249 info->m_constraintError[s] = k * u.dot(q); 250 // pull out pos and R for both bodies. also get the connection 251 // vector c = pos2-pos1. 252 // next two rows. we want: vel2 = vel1 + w1 x c ... but this would 253 // result in three equations, so we project along the planespace vectors 254 // so that sliding along the slider axis is disregarded. for symmetry we 255 // also consider rotation around center of mass of two bodies (factA and factB). 256 btTransform bodyA_trans = m_rbA.getCenterOfMassTransform(); 257 btTransform bodyB_trans = m_rbB.getCenterOfMassTransform(); 258 int s2 = 2 * s, s3 = 3 * s; 259 btVector3 c; 260 btScalar miA = m_rbA.getInvMass(); 261 btScalar miB = m_rbB.getInvMass(); 262 btScalar miS = miA + miB; 263 btScalar factA, factB; 264 if(miS > btScalar(0.f)) 265 { 266 factA = miB / miS; 267 } 268 else 269 { 270 factA = btScalar(0.5f); 271 } 272 if(factA > 0.99f) factA = 0.99f; 273 if(factA < 0.01f) factA = 0.01f; 274 factB = btScalar(1.0f) - factA; 275 c = bodyB_trans.getOrigin() - bodyA_trans.getOrigin(); 276 btVector3 tmp = c.cross(p); 277 for (i=0; i<3; i++) info->m_J1angularAxis[s2+i] = factA*tmp[i]; 278 for (i=0; i<3; i++) info->m_J2angularAxis[s2+i] = factB*tmp[i]; 279 tmp = c.cross(q); 280 for (i=0; i<3; i++) info->m_J1angularAxis[s3+i] = factA*tmp[i]; 281 for (i=0; i<3; i++) info->m_J2angularAxis[s3+i] = factB*tmp[i]; 282 283 for (i=0; i<3; i++) info->m_J1linearAxis[s2+i] = p[i]; 284 for (i=0; i<3; i++) info->m_J1linearAxis[s3+i] = q[i]; 285 // compute two elements of right hand side. we want to align the offset 286 // point (in body 2's frame) with the center of body 1. 287 btVector3 ofs; // offset point in global coordinates 288 ofs = trB.getOrigin() - trA.getOrigin(); 289 k = info->fps * info->erp * getSoftnessOrthoLin(); 290 info->m_constraintError[s2] = k * p.dot(ofs); 291 info->m_constraintError[s3] = k * q.dot(ofs); 292 int nrow = 3; // last filled row 293 int srow; 294 // check linear limits linear 295 btScalar limit_err = btScalar(0.0); 296 int limit = 0; 297 if(getSolveLinLimit()) 298 { 299 limit_err = getLinDepth() * signFact; 300 limit = (limit_err > btScalar(0.0)) ? 2 : 1; 301 } 302 int powered = 0; 303 if(getPoweredLinMotor()) 304 { 305 powered = 1; 306 } 307 // if the slider has joint limits or motor, add in the extra row 308 if (limit || powered) 309 { 310 nrow++; 311 srow = nrow * info->rowskip; 312 info->m_J1linearAxis[srow+0] = ax1[0]; 313 info->m_J1linearAxis[srow+1] = ax1[1]; 314 info->m_J1linearAxis[srow+2] = ax1[2]; 315 // linear torque decoupling step: 316 // 317 // we have to be careful that the linear constraint forces (+/- ax1) applied to the two bodies 318 // do not create a torque couple. in other words, the points that the 319 // constraint force is applied at must lie along the same ax1 axis. 320 // a torque couple will result in limited slider-jointed free 321 // bodies from gaining angular momentum. 322 // the solution used here is to apply the constraint forces at the center of mass of the two bodies 323 btVector3 ltd; // Linear Torque Decoupling vector (a torque) 324 // c = btScalar(0.5) * c; 325 ltd = c.cross(ax1); 326 info->m_J1angularAxis[srow+0] = factA*ltd[0]; 327 info->m_J1angularAxis[srow+1] = factA*ltd[1]; 328 info->m_J1angularAxis[srow+2] = factA*ltd[2]; 329 info->m_J2angularAxis[srow+0] = factB*ltd[0]; 330 info->m_J2angularAxis[srow+1] = factB*ltd[1]; 331 info->m_J2angularAxis[srow+2] = factB*ltd[2]; 332 // right-hand part 333 btScalar lostop = getLowerLinLimit(); 334 btScalar histop = getUpperLinLimit(); 335 if(limit && (lostop == histop)) 336 { // the joint motor is ineffective 337 powered = 0; 338 } 339 info->m_constraintError[srow] = 0.; 340 info->m_lowerLimit[srow] = 0.; 341 info->m_upperLimit[srow] = 0.; 342 if(powered) 343 { 344 info->cfm[nrow] = btScalar(0.0); 345 btScalar tag_vel = getTargetLinMotorVelocity(); 346 btScalar mot_fact = getMotorFactor(m_linPos, m_lowerLinLimit, m_upperLinLimit, tag_vel, info->fps * info->erp); 347 // info->m_constraintError[srow] += mot_fact * getTargetLinMotorVelocity(); 348 info->m_constraintError[srow] -= signFact * mot_fact * getTargetLinMotorVelocity(); 349 info->m_lowerLimit[srow] += -getMaxLinMotorForce() * info->fps; 350 info->m_upperLimit[srow] += getMaxLinMotorForce() * info->fps; 351 } 352 if(limit) 353 { 354 k = info->fps * info->erp; 355 info->m_constraintError[srow] += k * limit_err; 356 info->cfm[srow] = btScalar(0.0); // stop_cfm; 357 if(lostop == histop) 358 { // limited low and high simultaneously 359 info->m_lowerLimit[srow] = -SIMD_INFINITY; 360 info->m_upperLimit[srow] = SIMD_INFINITY; 361 } 362 else if(limit == 1) 363 { // low limit 364 info->m_lowerLimit[srow] = -SIMD_INFINITY; 365 info->m_upperLimit[srow] = 0; 366 } 367 else 368 { // high limit 369 info->m_lowerLimit[srow] = 0; 370 info->m_upperLimit[srow] = SIMD_INFINITY; 371 } 372 // bounce (we'll use slider parameter abs(1.0 - m_dampingLimLin) for that) 373 btScalar bounce = btFabs(btScalar(1.0) - getDampingLimLin()); 374 if(bounce > btScalar(0.0)) 375 { 376 btScalar vel = m_rbA.getLinearVelocity().dot(ax1); 377 vel -= m_rbB.getLinearVelocity().dot(ax1); 378 vel *= signFact; 379 // only apply bounce if the velocity is incoming, and if the 380 // resulting c[] exceeds what we already have. 381 if(limit == 1) 382 { // low limit 383 if(vel < 0) 384 { 385 btScalar newc = -bounce * vel; 386 if (newc > info->m_constraintError[srow]) 387 { 388 info->m_constraintError[srow] = newc; 389 } 390 } 391 } 392 else 393 { // high limit - all those computations are reversed 394 if(vel > 0) 395 { 396 btScalar newc = -bounce * vel; 397 if(newc < info->m_constraintError[srow]) 398 { 399 info->m_constraintError[srow] = newc; 400 } 401 } 402 } 403 } 404 info->m_constraintError[srow] *= getSoftnessLimLin(); 405 } // if(limit) 406 } // if linear limit 407 // check angular limits 408 limit_err = btScalar(0.0); 409 limit = 0; 410 if(getSolveAngLimit()) 411 { 412 limit_err = getAngDepth(); 413 limit = (limit_err > btScalar(0.0)) ? 1 : 2; 414 } 415 // if the slider has joint limits, add in the extra row 416 powered = 0; 417 if(getPoweredAngMotor()) 418 { 419 powered = 1; 420 } 421 if(limit || powered) 422 { 423 nrow++; 424 srow = nrow * info->rowskip; 425 info->m_J1angularAxis[srow+0] = ax1[0]; 426 info->m_J1angularAxis[srow+1] = ax1[1]; 427 info->m_J1angularAxis[srow+2] = ax1[2]; 428 429 info->m_J2angularAxis[srow+0] = -ax1[0]; 430 info->m_J2angularAxis[srow+1] = -ax1[1]; 431 info->m_J2angularAxis[srow+2] = -ax1[2]; 432 433 btScalar lostop = getLowerAngLimit(); 434 btScalar histop = getUpperAngLimit(); 435 if(limit && (lostop == histop)) 436 { // the joint motor is ineffective 437 powered = 0; 438 } 439 if(powered) 440 { 441 info->cfm[srow] = btScalar(0.0); 442 btScalar mot_fact = getMotorFactor(m_angPos, m_lowerAngLimit, m_upperAngLimit, getTargetAngMotorVelocity(), info->fps * info->erp); 443 info->m_constraintError[srow] = mot_fact * getTargetAngMotorVelocity(); 444 info->m_lowerLimit[srow] = -getMaxAngMotorForce() * info->fps; 445 info->m_upperLimit[srow] = getMaxAngMotorForce() * info->fps; 446 } 447 if(limit) 448 { 449 k = info->fps * info->erp; 450 info->m_constraintError[srow] += k * limit_err; 451 info->cfm[srow] = btScalar(0.0); // stop_cfm; 452 if(lostop == histop) 453 { 454 // limited low and high simultaneously 455 info->m_lowerLimit[srow] = -SIMD_INFINITY; 456 info->m_upperLimit[srow] = SIMD_INFINITY; 457 } 458 else if(limit == 1) 459 { // low limit 460 info->m_lowerLimit[srow] = 0; 461 info->m_upperLimit[srow] = SIMD_INFINITY; 462 } 463 else 464 { // high limit 465 info->m_lowerLimit[srow] = -SIMD_INFINITY; 466 info->m_upperLimit[srow] = 0; 467 } 468 // bounce (we'll use slider parameter abs(1.0 - m_dampingLimAng) for that) 469 btScalar bounce = btFabs(btScalar(1.0) - getDampingLimAng()); 470 if(bounce > btScalar(0.0)) 471 { 472 btScalar vel = m_rbA.getAngularVelocity().dot(ax1); 473 vel -= m_rbB.getAngularVelocity().dot(ax1); 474 // only apply bounce if the velocity is incoming, and if the 475 // resulting c[] exceeds what we already have. 476 if(limit == 1) 477 { // low limit 478 if(vel < 0) 479 { 480 btScalar newc = -bounce * vel; 481 if(newc > info->m_constraintError[srow]) 482 { 483 info->m_constraintError[srow] = newc; 484 } 485 } 486 } 487 else 488 { // high limit - all those computations are reversed 489 if(vel > 0) 490 { 491 btScalar newc = -bounce * vel; 492 if(newc < info->m_constraintError[srow]) 493 { 494 info->m_constraintError[srow] = newc; 495 } 496 } 497 } 498 } 499 info->m_constraintError[srow] *= getSoftnessLimAng(); 500 } // if(limit) 501 } // if angular limit or powered 502 } // btSliderConstraint::getInfo2() 503 504 //----------------------------------------------------------------------------- 505 506 void btSliderConstraint::solveConstraintObsolete(btSolverBody& bodyA,btSolverBody& bodyB,btScalar timeStep) 507 { 508 if (m_useSolveConstraintObsolete) 509 { 510 m_timeStep = timeStep; 511 if(m_useLinearReferenceFrameA) 512 { 513 solveConstraintInt(m_rbA,bodyA, m_rbB,bodyB); 514 } 515 else 516 { 517 solveConstraintInt(m_rbB,bodyB, m_rbA,bodyA); 518 } 168 519 } 169 520 } // btSliderConstraint::solveConstraint() … … 171 522 //----------------------------------------------------------------------------- 172 523 173 void btSliderConstraint::solveConstraintInt(btRigidBody& rbA, bt RigidBody& rbB)524 void btSliderConstraint::solveConstraintInt(btRigidBody& rbA, btSolverBody& bodyA,btRigidBody& rbB, btSolverBody& bodyB) 174 525 { 175 526 int i; 176 527 // linear 177 btVector3 velA = rbA.getVelocityInLocalPoint(m_relPosA); 178 btVector3 velB = rbB.getVelocityInLocalPoint(m_relPosB); 528 btVector3 velA; 529 bodyA.getVelocityInLocalPointObsolete(m_relPosA,velA); 530 btVector3 velB; 531 bodyB.getVelocityInLocalPointObsolete(m_relPosB,velB); 179 532 btVector3 vel = velA - velB; 180 533 for(i = 0; i < 3; i++) … … 191 544 btScalar normalImpulse = softness * (restitution * depth / m_timeStep - damping * rel_vel) * m_jacLinDiagABInv[i]; 192 545 btVector3 impulse_vector = normal * normalImpulse; 193 rbA.applyImpulse( impulse_vector, m_relPosA); 194 rbB.applyImpulse(-impulse_vector, m_relPosB); 546 547 //rbA.applyImpulse( impulse_vector, m_relPosA); 548 //rbB.applyImpulse(-impulse_vector, m_relPosB); 549 { 550 btVector3 ftorqueAxis1 = m_relPosA.cross(normal); 551 btVector3 ftorqueAxis2 = m_relPosB.cross(normal); 552 bodyA.applyImpulse(normal*rbA.getInvMass(), rbA.getInvInertiaTensorWorld()*ftorqueAxis1,normalImpulse); 553 bodyB.applyImpulse(normal*rbB.getInvMass(), rbB.getInvInertiaTensorWorld()*ftorqueAxis2,-normalImpulse); 554 } 555 556 557 195 558 if(m_poweredLinMotor && (!i)) 196 559 { // apply linear motor … … 218 581 // apply clamped impulse 219 582 impulse_vector = normal * normalImpulse; 220 rbA.applyImpulse( impulse_vector, m_relPosA); 221 rbB.applyImpulse(-impulse_vector, m_relPosB); 583 //rbA.applyImpulse( impulse_vector, m_relPosA); 584 //rbB.applyImpulse(-impulse_vector, m_relPosB); 585 586 { 587 btVector3 ftorqueAxis1 = m_relPosA.cross(normal); 588 btVector3 ftorqueAxis2 = m_relPosB.cross(normal); 589 bodyA.applyImpulse(normal*rbA.getInvMass(), rbA.getInvInertiaTensorWorld()*ftorqueAxis1,normalImpulse); 590 bodyB.applyImpulse(normal*rbB.getInvMass(), rbB.getInvInertiaTensorWorld()*ftorqueAxis2,-normalImpulse); 591 } 592 593 594 222 595 } 223 596 } … … 228 601 btVector3 axisB = m_calculatedTransformB.getBasis().getColumn(0); 229 602 230 const btVector3& angVelA = rbA.getAngularVelocity(); 231 const btVector3& angVelB = rbB.getAngularVelocity(); 603 btVector3 angVelA; 604 bodyA.getAngularVelocity(angVelA); 605 btVector3 angVelB; 606 bodyB.getAngularVelocity(angVelB); 232 607 233 608 btVector3 angVelAroundAxisA = axisA * axisA.dot(angVelA); … … 239 614 //solve orthogonal angular velocity correction 240 615 btScalar len = velrelOrthog.length(); 616 btScalar orthorImpulseMag = 0.f; 617 241 618 if (len > btScalar(0.00001)) 242 619 { 243 620 btVector3 normal = velrelOrthog.normalized(); 244 621 btScalar denom = rbA.computeAngularImpulseDenominator(normal) + rbB.computeAngularImpulseDenominator(normal); 245 velrelOrthog *= (btScalar(1.)/denom) * m_dampingOrthoAng * m_softnessOrthoAng; 622 //velrelOrthog *= (btScalar(1.)/denom) * m_dampingOrthoAng * m_softnessOrthoAng; 623 orthorImpulseMag = (btScalar(1.)/denom) * m_dampingOrthoAng * m_softnessOrthoAng; 246 624 } 247 625 //solve angular positional correction 248 626 btVector3 angularError = axisA.cross(axisB) *(btScalar(1.)/m_timeStep); 627 btVector3 angularAxis = angularError; 628 btScalar angularImpulseMag = 0; 629 249 630 btScalar len2 = angularError.length(); 250 631 if (len2>btScalar(0.00001)) … … 252 633 btVector3 normal2 = angularError.normalized(); 253 634 btScalar denom2 = rbA.computeAngularImpulseDenominator(normal2) + rbB.computeAngularImpulseDenominator(normal2); 254 angularError *= (btScalar(1.)/denom2) * m_restitutionOrthoAng * m_softnessOrthoAng; 635 angularImpulseMag = (btScalar(1.)/denom2) * m_restitutionOrthoAng * m_softnessOrthoAng; 636 angularError *= angularImpulseMag; 255 637 } 256 638 // apply impulse 257 rbA.applyTorqueImpulse(-velrelOrthog+angularError); 258 rbB.applyTorqueImpulse(velrelOrthog-angularError); 639 //rbA.applyTorqueImpulse(-velrelOrthog+angularError); 640 //rbB.applyTorqueImpulse(velrelOrthog-angularError); 641 642 bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*velrelOrthog,-orthorImpulseMag); 643 bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*velrelOrthog,orthorImpulseMag); 644 bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*angularAxis,angularImpulseMag); 645 bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*angularAxis,-angularImpulseMag); 646 647 259 648 btScalar impulseMag; 260 649 //solve angular limits … … 270 659 } 271 660 btVector3 impulse = axisA * impulseMag; 272 rbA.applyTorqueImpulse(impulse); 273 rbB.applyTorqueImpulse(-impulse); 661 //rbA.applyTorqueImpulse(impulse); 662 //rbB.applyTorqueImpulse(-impulse); 663 664 bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*axisA,impulseMag); 665 bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*axisA,-impulseMag); 666 667 668 274 669 //apply angular motor 275 670 if(m_poweredAngMotor) … … 302 697 // apply clamped impulse 303 698 btVector3 motorImp = angImpulse * axisA; 304 m_rbA.applyTorqueImpulse(motorImp); 305 m_rbB.applyTorqueImpulse(-motorImp); 699 //rbA.applyTorqueImpulse(motorImp); 700 //rbB.applyTorqueImpulse(-motorImp); 701 702 bodyA.applyImpulse(btVector3(0,0,0), rbA.getInvInertiaTensorWorld()*axisA,angImpulse); 703 bodyB.applyImpulse(btVector3(0,0,0), rbB.getInvInertiaTensorWorld()*axisA,-angImpulse); 306 704 } 307 705 } … … 313 711 314 712 void btSliderConstraint::calculateTransforms(void){ 315 if(m_useLinearReferenceFrameA )713 if(m_useLinearReferenceFrameA || (!m_useSolveConstraintObsolete)) 316 714 { 317 715 m_calculatedTransformA = m_rbA.getCenterOfMassTransform() * m_frameInA; … … 326 724 m_realPivotBInW = m_calculatedTransformB.getOrigin(); 327 725 m_sliderAxis = m_calculatedTransformA.getBasis().getColumn(0); // along X 328 m_delta = m_realPivotBInW - m_realPivotAInW; 726 if(m_useLinearReferenceFrameA || m_useSolveConstraintObsolete) 727 { 728 m_delta = m_realPivotBInW - m_realPivotAInW; 729 } 730 else 731 { 732 m_delta = m_realPivotAInW - m_realPivotBInW; 733 } 329 734 m_projPivotInW = m_realPivotAInW + m_sliderAxis.dot(m_delta) * m_sliderAxis; 330 735 btVector3 normalWorld; … … 368 773 369 774 //----------------------------------------------------------------------------- 370 371 775 372 776 void btSliderConstraint::testAngLimits(void) … … 380 784 const btVector3 axisB0 = m_calculatedTransformB.getBasis().getColumn(1); 381 785 btScalar rot = btAtan2Fast(axisB0.dot(axisA1), axisB0.dot(axisA0)); 786 m_angPos = rot; 382 787 if(rot < m_lowerAngLimit) 383 788 { … … 392 797 } 393 798 } // btSliderConstraint::testAngLimits() 394 395 799 396 800 //----------------------------------------------------------------------------- 397 398 399 801 400 802 btVector3 btSliderConstraint::getAncorInA(void)
Note: See TracChangeset
for help on using the changeset viewer.