Package com.bulletphysics.collision.narrowphase

Examples of com.bulletphysics.collision.narrowphase.PersistentManifold


    //this.myWorld.dispatcher1 = dispatcher;
    //this.myWorld.setConstraintSolver(this.solver);
    //this.myWorld.destroy();
   
  for(int i = 0 ; i < this.myWorld.getCollisionWorld().getDispatcher().getNumManifolds(); i++){
    PersistentManifold manifold =   this.myWorld.getCollisionWorld().getDispatcher().getManifoldByIndexInternal(i);
    this.myWorld.getCollisionWorld().getDispatcher().clearManifold(manifold);
  }
   
  }
View Full Code Here


        ManifoldResult manifoldResult = new ManifoldResult(rigidBody,
            bodies[i]);
        Algorithm.processCollision(rigidBody, bodies[i],
            GLOBAL.jBullet.myWorld.getDispatchInfo(),
            manifoldResult);
        PersistentManifold pManifold = manifoldResult
            .getPersistentManifold();
        if (pManifold != null){
          GLOBAL.jBullet.myWorld.getCollisionWorld().getDispatcher().releaseManifold(pManifold);
           return true;
        }
View Full Code Here

   
    LOGGER.info("Number of Manifolds: "+ GLOBAL.jBullet.myWorld.getCollisionWorld().getDispatcher().getNumManifolds());

    //GLOBAL.jBullet.myWorld.getBroadphase()
    for(int m = 0; m < GLOBAL.jBullet.myWorld.getDispatcher().getNumManifolds(); m++){
      PersistentManifold manifold = GLOBAL.jBullet.myWorld.getDispatcher().getManifoldByIndexInternal(m);
    //  GLOBAL.jBullet.myWorld.getDispatcher().releaseManifold(manifold);
     
      //LOGGER.info("removing " + manifold.index1a);
      //manifold.clearManifold();
      //GLOBAL.jBullet.myWorld.getDispatcher().releaseManifold(arg0)
View Full Code Here

     */
    //http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Collision_Callbacks_and_Triggers 
    // Aufwendig, scheint aber wenigstens zu gehen, ohne dass die Boxen durch den Boden fallen.
    int numManifolds = getDynamicsWorld().getDispatcher().getNumManifolds();
    for (int i = 0; i < numManifolds; i++) {
      PersistentManifold contactManifold = getDynamicsWorld().getDispatcher().getManifoldByIndexInternal(i);
      CollisionObject objA = (CollisionObject) contactManifold.getBody0();
     
      //Wir wollen nur Kollisionen zwischen Boden und Appendix wissen!
      if (!objA.equals(groundBody)) {
        continue;
      }
      CollisionObject objB = (CollisionObject) contactManifold.getBody1();
      if (!objB.equals(this.getRigidBody())) {
        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

      if ((numConstraints + numManifolds) == 0) {
        // printf("empty\n");
        return 0f;
      }
      PersistentManifold manifold = null;
      CollisionObject colObj0 = null, colObj1 = null;

      //btRigidBody* rb0=0,*rb1=0;

  //  //#ifdef FORCE_REFESH_CONTACT_MANIFOLDS
  //
  //    BEGIN_PROFILE("refreshManifolds");
  //
  //    int i;
  //
  //
  //
  //    for (i=0;i<numManifolds;i++)
  //    {
  //      manifold = manifoldPtr[i];
  //      rb1 = (btRigidBody*)manifold->getBody1();
  //      rb0 = (btRigidBody*)manifold->getBody0();
  //
  //      manifold->refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform());
  //
  //    }
  //
  //    END_PROFILE("refreshManifolds");
  //  //#endif //FORCE_REFESH_CONTACT_MANIFOLDS

      Transform tmpTrans = Stack.alloc(Transform.class);

      //int sizeofSB = sizeof(btSolverBody);
      //int sizeofSC = sizeof(btSolverConstraint);

      //if (1)
      {
        //if m_stackAlloc, try to pack bodies/constraints to speed up solving
        //    btBlock*          sablock;
        //    sablock = stackAlloc->beginBlock();

        //  int memsize = 16;
        //    unsigned char* stackMemory = stackAlloc->allocate(memsize);


        // todo: use stack allocator for this temp memory
        //int minReservation = numManifolds * 2;

        //m_tmpSolverBodyPool.reserve(minReservation);

        //don't convert all bodies, only the one we need so solver the constraints
        /*
        {
        for (int i=0;i<numBodies;i++)
        {
        btRigidBody* rb = btRigidBody::upcast(bodies[i]);
        if (rb &&   (rb->getIslandTag() >= 0))
        {
        btAssert(rb->getCompanionId() < 0);
        int solverBodyId = m_tmpSolverBodyPool.size();
        btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
        initSolverBody(&solverBody,rb);
        rb->setCompanionId(solverBodyId);
        }
        }
        }
        */

        //m_tmpSolverConstraintPool.reserve(minReservation);
        //m_tmpSolverFrictionConstraintPool.reserve(minReservation);

        {
          int i;
         
          Vector3f rel_pos1 = Stack.alloc(Vector3f.class);
          Vector3f rel_pos2 = Stack.alloc(Vector3f.class);

          Vector3f pos1 = Stack.alloc(Vector3f.class);
          Vector3f pos2 = Stack.alloc(Vector3f.class);
          Vector3f vel = Stack.alloc(Vector3f.class);
          Vector3f torqueAxis0 = Stack.alloc(Vector3f.class);
          Vector3f torqueAxis1 = Stack.alloc(Vector3f.class);
          Vector3f vel1 = Stack.alloc(Vector3f.class);
          Vector3f vel2 = Stack.alloc(Vector3f.class);
          Vector3f frictionDir1 = Stack.alloc(Vector3f.class);
          Vector3f frictionDir2 = Stack.alloc(Vector3f.class);
          Vector3f vec = Stack.alloc(Vector3f.class);

          Matrix3f tmpMat = Stack.alloc(Matrix3f.class);
         
          for (i = 0; i < numManifolds; i++) {
            manifold = manifoldPtr.getQuick(manifold_offset+i);
            colObj0 = (CollisionObject) manifold.getBody0();
            colObj1 = (CollisionObject) manifold.getBody1();

            int solverBodyIdA = -1;
            int solverBodyIdB = -1;

            if (manifold.getNumContacts() != 0) {
              if (colObj0.getIslandTag() >= 0) {
                if (colObj0.getCompanionId() >= 0) {
                  // body has already been converted
                  solverBodyIdA = colObj0.getCompanionId();
                }
                else {
                  solverBodyIdA = tmpSolverBodyPool.size();
                  SolverBody solverBody = bodiesPool.get();
                  tmpSolverBodyPool.add(solverBody);
                  initSolverBody(solverBody, colObj0);
                  colObj0.setCompanionId(solverBodyIdA);
                }
              }
              else {
                // create a static body
                solverBodyIdA = tmpSolverBodyPool.size();
                SolverBody solverBody = bodiesPool.get();
                tmpSolverBodyPool.add(solverBody);
                initSolverBody(solverBody, colObj0);
              }

              if (colObj1.getIslandTag() >= 0) {
                if (colObj1.getCompanionId() >= 0) {
                  solverBodyIdB = colObj1.getCompanionId();
                }
                else {
                  solverBodyIdB = tmpSolverBodyPool.size();
                  SolverBody solverBody = bodiesPool.get();
                  tmpSolverBodyPool.add(solverBody);
                  initSolverBody(solverBody, colObj1);
                  colObj1.setCompanionId(solverBodyIdB);
                }
              }
              else {
                // create a static body
                solverBodyIdB = tmpSolverBodyPool.size();
                SolverBody solverBody = bodiesPool.get();
                tmpSolverBodyPool.add(solverBody);
                initSolverBody(solverBody, colObj1);
              }
            }

            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);

View Full Code Here

      int totalPoints = 0;
      {
        short j;
        for (j = 0; j < numManifolds; j++) {
          PersistentManifold manifold = manifoldPtr.getQuick(manifold_offset+j);
          prepareConstraints(manifold, info, debugDrawer);

          for (short p = 0; p < manifoldPtr.getQuick(manifold_offset+j).getNumContacts(); p++) {
            gOrder[totalPoints].manifoldIndex = j;
            gOrder[totalPoints].pointIndex = p;
            totalPoints++;
          }
        }
      }

      {
        int j;
        for (j = 0; j < numConstraints; j++) {
          TypedConstraint constraint = constraints.getQuick(constraints_offset+j);
          constraint.buildJacobian();
        }
      }

      // should traverse the contacts random order...
      int iteration;
      {
        for (iteration = 0; iteration < numiter; iteration++) {
          int j;
          if ((infoGlobal.solverMode & SolverMode.SOLVER_RANDMIZE_ORDER) != 0) {
            if ((iteration & 7) == 0) {
              for (j = 0; j < totalPoints; ++j) {
                // JAVA NOTE: swaps references instead of copying values (but that's fine in this context)
                OrderIndex tmp = gOrder[j];
                int swapi = randInt2(j + 1);
                gOrder[j] = gOrder[swapi];
                gOrder[swapi] = tmp;
              }
            }
          }

          for (j = 0; j < numConstraints; j++) {
            TypedConstraint constraint = constraints.getQuick(constraints_offset+j);
            constraint.solveConstraint(info.timeStep);
          }

          for (j = 0; j < totalPoints; j++) {
            PersistentManifold manifold = manifoldPtr.getQuick(manifold_offset+gOrder[j].manifoldIndex);
            solve((RigidBody) manifold.getBody0(),
                (RigidBody) manifold.getBody1(), manifold.getContactPoint(gOrder[j].pointIndex), info, iteration, debugDrawer);
          }

          for (j = 0; j < totalPoints; j++) {
            PersistentManifold manifold = manifoldPtr.getQuick(manifold_offset+gOrder[j].manifoldIndex);
            solveFriction((RigidBody) manifold.getBody0(),
                (RigidBody) manifold.getBody1(), manifold.getContactPoint(gOrder[j].pointIndex), info, iteration, debugDrawer);
          }

        }
      }
View Full Code Here

      if (collisionPair.algorithm != null) {
        collisionPair.algorithm.getAllContactManifolds(manifoldArray);
      }

      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;
View Full Code Here

    if (getDebugDrawer() != null && (getDebugDrawer().getDebugMode() & DebugDrawModes.DRAW_CONTACT_POINTS) != 0) {
      int numManifolds = getDispatcher().getNumManifolds();
      Vector3f color = Stack.alloc(Vector3f.class);
      color.set(0f, 0f, 0f);
      for (int i = 0; i < numManifolds; i++) {
        PersistentManifold contactManifold = getDispatcher().getManifoldByIndexInternal(i);
        //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);
        }
      }
    }
   
View Full Code Here

        if (collisionPair != null) {
          if (collisionPair.algorithm != null) {
            //manifoldArray.resize(0);
            collisionPair.algorithm.getAllContactManifolds(manifoldArray);
            for (int j=0; j<manifoldArray.size(); j++) {
              PersistentManifold manifold = manifoldArray.getQuick(j);
              if (manifold.getNumContacts() > 0) {
                return false;
              }
            }
          }
        }
View Full Code Here

    btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0);
    manifold->m_index1a = m_manifoldsPtr.size();
    m_manifoldsPtr.push_back(manifold);
    */
   
    PersistentManifold manifold = manifoldsPool.get();
    manifold.init(body0,body1,0);
   
    manifold.index1a = manifoldsPtr.size();
    manifoldsPtr.add(manifold);

    return manifold;
View Full Code Here

TOP

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

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.