Package com.bulletphysics.collision.narrowphase

Examples of com.bulletphysics.collision.narrowphase.ManifoldPoint


        continue;
      }
     
      int numContacts = contactManifold.getNumContacts();
      for (int j = 0; j < numContacts; j++) {
        ManifoldPoint pt = contactManifold.getContactPoint(j);
        if (pt.getDistance() < 0.f) {
          result = true;
        }
      }
     
    }
View Full Code Here


            float relaxation;

            for (int j = 0; j < manifold.getNumContacts(); j++) {

              ManifoldPoint cp = manifold.getContactPoint(j);

              if (cp.getDistance() <= 0f) {
                cp.getPositionWorldOnA(pos1);
                cp.getPositionWorldOnB(pos2);

                rel_pos1.sub(pos1, colObj0.getWorldTransform(tmpTrans).origin);
                rel_pos2.sub(pos2, colObj1.getWorldTransform(tmpTrans).origin);

                relaxation = 1f;
                float rel_vel;

                int frictionIndex = tmpSolverConstraintPool.size();

                {
                  SolverConstraint solverConstraint = constraintsPool.get();
                  tmpSolverConstraintPool.add(solverConstraint);
                  RigidBody rb0 = RigidBody.upcast(colObj0);
                  RigidBody rb1 = RigidBody.upcast(colObj1);

                  solverConstraint.solverBodyIdA = solverBodyIdA;
                  solverConstraint.solverBodyIdB = solverBodyIdB;
                  solverConstraint.constraintType = SolverConstraintType.SOLVER_CONTACT_1D;
                 
                  solverConstraint.originalContactPoint = cp;

                  torqueAxis0.cross(rel_pos1, cp.normalWorldOnB);

                  if (rb0 != null) {
                    solverConstraint.angularComponentA.set(torqueAxis0);
                    rb0.getInvInertiaTensorWorld(tmpMat).transform(solverConstraint.angularComponentA);
                  }
                  else {
                    solverConstraint.angularComponentA.set(0f, 0f, 0f);
                  }

                  torqueAxis1.cross(rel_pos2, cp.normalWorldOnB);

                  if (rb1 != null) {
                    solverConstraint.angularComponentB.set(torqueAxis1);
                    rb1.getInvInertiaTensorWorld(tmpMat).transform(solverConstraint.angularComponentB);
                  }
                  else {
                    solverConstraint.angularComponentB.set(0f, 0f, 0f);
                  }

                  {
                    //#ifdef COMPUTE_IMPULSE_DENOM
                    //btScalar denom0 = rb0->computeImpulseDenominator(pos1,cp.m_normalWorldOnB);
                    //btScalar denom1 = rb1->computeImpulseDenominator(pos2,cp.m_normalWorldOnB);
                    //#else             
                    float denom0 = 0f;
                    float denom1 = 0f;
                    if (rb0 != null) {
                      vec.cross(solverConstraint.angularComponentA, rel_pos1);
                      denom0 = rb0.getInvMass() + cp.normalWorldOnB.dot(vec);
                    }
                    if (rb1 != null) {
                      vec.cross(solverConstraint.angularComponentB, rel_pos2);
                      denom1 = rb1.getInvMass() + cp.normalWorldOnB.dot(vec);
                    }
                    //#endif //COMPUTE_IMPULSE_DENOM   

                    float denom = relaxation / (denom0 + denom1);
                    solverConstraint.jacDiagABInv = denom;
                  }

                  solverConstraint.contactNormal.set(cp.normalWorldOnB);
                  solverConstraint.relpos1CrossNormal.cross(rel_pos1, cp.normalWorldOnB);
                  solverConstraint.relpos2CrossNormal.cross(rel_pos2, cp.normalWorldOnB);

                  if (rb0 != null) {
                    rb0.getVelocityInLocalPoint(rel_pos1, vel1);
                  }
                  else {
                    vel1.set(0f, 0f, 0f);
                  }
                 
                  if (rb1 != null) {
                    rb1.getVelocityInLocalPoint(rel_pos2, vel2);
                  }
                  else {
                    vel2.set(0f, 0f, 0f);
                  }

                  vel.sub(vel1, vel2);

                  rel_vel = cp.normalWorldOnB.dot(vel);

                  solverConstraint.penetration = Math.min(cp.getDistance() + infoGlobal.linearSlop, 0f);
                  //solverConstraint.m_penetration = cp.getDistance();
                 
                  solverConstraint.friction = cp.combinedFriction;
                  solverConstraint.restitution = restitutionCurve(rel_vel, cp.combinedRestitution);
                  if (solverConstraint.restitution <= 0f) {
View Full Code Here

   
    int numPoolConstraints = tmpSolverConstraintPool.size();
    for (int j=0; j<numPoolConstraints; j++) {

      SolverConstraint solveManifold = tmpSolverConstraintPool.getQuick(j);
      ManifoldPoint pt = (ManifoldPoint) solveManifold.originalContactPoint;
      assert (pt != null);
      pt.appliedImpulse = solveManifold.appliedImpulse;
      pt.appliedImpulseLateral1 = tmpSolverFrictionConstraintPool.getQuick(solveManifold.frictionIndex).appliedImpulse;
      pt.appliedImpulseLateral1 = tmpSolverFrictionConstraintPool.getQuick(solveManifold.frictionIndex + 1).appliedImpulse;
View Full Code Here

      Vector3f torqueAxis1 = Stack.alloc(Vector3f.class);
      Vector3f ftorqueAxis0 = Stack.alloc(Vector3f.class);
      Vector3f ftorqueAxis1 = Stack.alloc(Vector3f.class);
     
      for (int i = 0; i < numpoints; i++) {
        ManifoldPoint cp = manifoldPtr.getContactPoint(i);
        if (cp.getDistance() <= 0f) {
          cp.getPositionWorldOnA(pos1);
          cp.getPositionWorldOnB(pos2);

          rel_pos1.sub(pos1, body0.getCenterOfMassPosition(tmpVec));
          rel_pos2.sub(pos2, body1.getCenterOfMassPosition(tmpVec));

          // this jacobian entry is re-used for all iterations
          Matrix3f mat1 = body0.getCenterOfMassTransform(Stack.alloc(Transform.class)).basis;
          mat1.transpose();

          Matrix3f mat2 = body1.getCenterOfMassTransform(Stack.alloc(Transform.class)).basis;
          mat2.transpose();

          JacobianEntry jac = jacobiansPool.get();
          jac.init(mat1, mat2,
              rel_pos1, rel_pos2, cp.normalWorldOnB,
              body0.getInvInertiaDiagLocal(Stack.alloc(Vector3f.class)), body0.getInvMass(),
              body1.getInvInertiaDiagLocal(Stack.alloc(Vector3f.class)), body1.getInvMass());

          float jacDiagAB = jac.getDiagonal();
          jacobiansPool.release(jac);

          ConstraintPersistentData cpd = (ConstraintPersistentData) cp.userPersistentData;
          if (cpd != null) {
            // might be invalid
            cpd.persistentLifeTime++;
            if (cpd.persistentLifeTime != cp.getLifeTime()) {
              //printf("Invalid: cpd->m_persistentLifeTime = %i cp.getLifeTime() = %i\n",cpd->m_persistentLifeTime,cp.getLifeTime());
              //new (cpd) btConstraintPersistentData;
              cpd.reset();
              cpd.persistentLifeTime = cp.getLifeTime();

            }
            else {
            //printf("Persistent: cpd->m_persistentLifeTime = %i cp.getLifeTime() = %i\n",cpd->m_persistentLifeTime,cp.getLifeTime());
            }
          }
          else {
            // todo: should this be in a pool?
            //void* mem = btAlignedAlloc(sizeof(btConstraintPersistentData),16);
            //cpd = new (mem)btConstraintPersistentData;
            cpd = new ConstraintPersistentData();
            //assert(cpd != null);

            totalCpd++;
            //printf("totalCpd = %i Created Ptr %x\n",totalCpd,cpd);
            cp.userPersistentData = cpd;
            cpd.persistentLifeTime = cp.getLifeTime();
          //printf("CREATED: %x . cpd->m_persistentLifeTime = %i cp.getLifeTime() = %i\n",cpd,cpd->m_persistentLifeTime,cp.getLifeTime());
          }
          assert (cpd != null);

          cpd.jacDiagABInv = 1f / jacDiagAB;

          // Dependent on Rigidbody A and B types, fetch the contact/friction response func
          // perhaps do a similar thing for friction/restutution combiner funcs...

          cpd.frictionSolverFunc = frictionDispatch[body0.frictionSolverType][body1.frictionSolverType];
          cpd.contactSolverFunc = contactDispatch[body0.contactSolverType][body1.contactSolverType];

          body0.getVelocityInLocalPoint(rel_pos1, vel1);
          body1.getVelocityInLocalPoint(rel_pos2, vel2);
          vel.sub(vel1, vel2);

          float rel_vel;
          rel_vel = cp.normalWorldOnB.dot(vel);

          float combinedRestitution = cp.combinedRestitution;

          cpd.penetration = cp.getDistance(); ///btScalar(info.m_numIterations);
          cpd.friction = cp.combinedFriction;
          cpd.restitution = restitutionCurve(rel_vel, combinedRestitution);
          if (cpd.restitution <= 0f) {
            cpd.restitution = 0f;
          }
View Full Code Here

      for (int j=0; j<manifoldArray.size(); j++) {
        PersistentManifold manifold = manifoldArray.getQuick(j);
        float directionSign = manifold.getBody0() == ghostObject? -1.0f : 1.0f;
        for (int p=0; p<manifold.getNumContacts(); p++) {
          ManifoldPoint pt = manifold.getContactPoint(p);

          float dist = pt.getDistance();
          if (dist < 0.0f) {
            if (dist < maxPen) {
              maxPen = dist;
              touchingNormal.set(pt.normalWorldOnB);//??
              touchingNormal.scale(directionSign);
View Full Code Here

        //btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
        //btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());

        int numContacts = contactManifold.getNumContacts();
        for (int j = 0; j < numContacts; j++) {
          ManifoldPoint cp = contactManifold.getContactPoint(j);
          getDebugDrawer().drawContactPoint(cp.positionWorldOnB, cp.normalWorldOnB, cp.getDistance(), cp.getLifeTime(), color);
        }
      }
    }
   
    if (getDebugDrawer() != null && (getDebugDrawer().getDebugMode() & (DebugDrawModes.DRAW_WIREFRAME | DebugDrawModes.DRAW_AABB)) != 0) {
View Full Code Here

    else {
      rootTransA.invXform(pointA, localA);
      rootTransB.invXform(pointInWorld, localB);
    }

    ManifoldPoint newPt = pointsPool.get();
    newPt.init(localA, localB, normalOnBInWorld, depth);

    newPt.positionWorldOnA.set(pointA);
    newPt.positionWorldOnB.set(pointInWorld);

    int insertIndex = manifoldPtr.getCacheEntry(newPt);
View Full Code Here

                if (pair.algorithm != null) {
                    pair.algorithm.getAllContactManifolds(manifolds);
                }
                for (PersistentManifold manifold : manifolds) {
                    for (int point = 0; point < manifold.getNumContacts(); ++point) {
                        ManifoldPoint manifoldPoint = manifold.getContactPoint(point);
                        if (manifoldPoint.getDistance() < 0) {
                            collisionPairs.add(new PhysicsSystem.CollisionPair(entity, otherEntity));
                            break;
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of com.bulletphysics.collision.narrowphase.ManifoldPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.