Package com.bulletphysics.collision.broadphase.AxisSweep3Internal

Examples of com.bulletphysics.collision.broadphase.AxisSweep3Internal.Handle


  protected void sortMinDown(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
    EdgeArray edgeArray = pEdges[axis];
    int pEdge_idx = edge;
    int pPrev_idx = pEdge_idx - 1;

    Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));

    while (edgeArray.getPos(pEdge_idx) < edgeArray.getPos(pPrev_idx)) {
      Handle pHandlePrev = getHandle(edgeArray.getHandle(pPrev_idx));

      if (edgeArray.isMax(pPrev_idx) != 0) {
        // if previous edge is a maximum check the bounds and add an overlap if necessary
        if (updateOverlaps && testOverlap(axis, pHandleEdge, pHandlePrev)) {
          pairCache.addOverlappingPair(pHandleEdge, pHandlePrev);
          if (userPairCallback != null) {
            userPairCallback.addOverlappingPair(pHandleEdge, pHandlePrev);
            //AddOverlap(pEdge->m_handle, pPrev->m_handle);
          }
        }

        // update edge reference in other handle
        pHandlePrev.incMaxEdges(axis);
      }
      else {
        pHandlePrev.incMinEdges(axis);
      }
      pHandleEdge.decMinEdges(axis);

      // swap the edges
      edgeArray.swap(pEdge_idx, pPrev_idx);
View Full Code Here


  // sorting a min edge upwards can only ever *remove* overlaps
  protected void sortMinUp(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
    EdgeArray edgeArray = pEdges[axis];
    int pEdge_idx = edge;
    int pNext_idx = pEdge_idx + 1;
    Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));

    while (edgeArray.getHandle(pNext_idx) != 0 && (edgeArray.getPos(pEdge_idx) >= edgeArray.getPos(pNext_idx))) {
      Handle pHandleNext = getHandle(edgeArray.getHandle(pNext_idx));

      if (edgeArray.isMax(pNext_idx) != 0) {
        // if next edge is maximum remove any overlap between the two handles
        if (updateOverlaps) {
          Handle handle0 = getHandle(edgeArray.getHandle(pEdge_idx));
          Handle handle1 = getHandle(edgeArray.getHandle(pNext_idx));

          pairCache.removeOverlappingPair(handle0, handle1, dispatcher);
          if (userPairCallback != null) {
            userPairCallback.removeOverlappingPair(handle0, handle1, dispatcher);
          }
View Full Code Here

  // sorting a max edge downwards can only ever *remove* overlaps
  protected void sortMaxDown(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
    EdgeArray edgeArray = pEdges[axis];
    int pEdge_idx = edge;
    int pPrev_idx = pEdge_idx - 1;
    Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));

    while (edgeArray.getPos(pEdge_idx) < edgeArray.getPos(pPrev_idx)) {
      Handle pHandlePrev = getHandle(edgeArray.getHandle(pPrev_idx));

      if (edgeArray.isMax(pPrev_idx) == 0) {
        // if previous edge was a minimum remove any overlap between the two handles
        if (updateOverlaps) {
          // this is done during the overlappingpairarray iteration/narrowphase collision
          Handle handle0 = getHandle(edgeArray.getHandle(pEdge_idx));
          Handle handle1 = getHandle(edgeArray.getHandle(pPrev_idx));
          pairCache.removeOverlappingPair(handle0, handle1, dispatcher);
          if (userPairCallback != null) {
            userPairCallback.removeOverlappingPair(handle0, handle1, dispatcher);
          }
        }
View Full Code Here

  // sorting a max edge upwards can only ever *add* overlaps
  protected void sortMaxUp(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
    EdgeArray edgeArray = pEdges[axis];
    int pEdge_idx = edge;
    int pNext_idx = pEdge_idx + 1;
    Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));

    while (edgeArray.getHandle(pNext_idx) != 0 && (edgeArray.getPos(pEdge_idx) >= edgeArray.getPos(pNext_idx))) {
      Handle pHandleNext = getHandle(edgeArray.getHandle(pNext_idx));

      if (edgeArray.isMax(pNext_idx) == 0) {
        // if next edge is a minimum check the bounds and add an overlap if necessary
        if (updateOverlaps && testOverlap(axis, pHandleEdge, pHandleNext)) {
          Handle handle0 = getHandle(edgeArray.getHandle(pEdge_idx));
          Handle handle1 = getHandle(edgeArray.getHandle(pNext_idx));
          pairCache.addOverlappingPair(handle0, handle1);
          if (userPairCallback != null) {
            userPairCallback.addOverlappingPair(handle0, handle1);
          }
        }
View Full Code Here

    quantize(max, aabbMax, 1);

    // allocate a handle
    int handle = allocHandle();

    Handle pHandle = getHandle(handle);

    pHandle.uniqueId = handle;
    //pHandle->m_pOverlaps = 0;
    pHandle.clientObject = pOwner;
    pHandle.collisionFilterGroup = collisionFilterGroup;
    pHandle.collisionFilterMask = collisionFilterMask;
    pHandle.multiSapParentProxy = multiSapProxy;

    // compute current limit of edge arrays
    int limit = numHandles * 2;

    // insert new edges just inside the max boundary edge
    for (int axis = 0; axis < 3; axis++) {
      pHandles[0].setMaxEdges(axis, pHandles[0].getMaxEdges(axis) + 2);

      pEdges[axis].set(limit + 1, limit - 1);

      pEdges[axis].setPos(limit - 1, min[axis]);
      pEdges[axis].setHandle(limit - 1, handle);

      pEdges[axis].setPos(limit, max[axis]);
      pEdges[axis].setHandle(limit, handle);

      pHandle.setMinEdges(axis, limit - 1);
      pHandle.setMaxEdges(axis, limit);
    }

    // now sort the new edges to their correct position
    sortMinDown(0, pHandle.getMinEdges(0), dispatcher, false);
    sortMaxDown(0, pHandle.getMaxEdges(0), dispatcher, false);
    sortMinDown(1, pHandle.getMinEdges(1), dispatcher, false);
    sortMaxDown(1, pHandle.getMaxEdges(1), dispatcher, false);
    sortMinDown(2, pHandle.getMinEdges(2), dispatcher, true);
    sortMaxDown(2, pHandle.getMaxEdges(2), dispatcher, true);

    return handle;
  }
View Full Code Here

    return handle;
  }
 
  public void removeHandle(int handle, Dispatcher dispatcher) {
    Handle pHandle = getHandle(handle);

    // explicitly remove the pairs containing the proxy
    // we could do it also in the sortMinUp (passing true)
    // todo: compare performance
    if (!pairCache.hasDeferredRemoval()) {
      pairCache.removeOverlappingPairsContainingProxy(pHandle, dispatcher);
    }

    // compute current limit of edge arrays
    int limit = numHandles * 2;

    int axis;

    for (axis = 0; axis < 3; axis++) {
      pHandles[0].setMaxEdges(axis, pHandles[0].getMaxEdges(axis) - 2);
    }

    // remove the edges by sorting them up to the end of the list
    for (axis = 0; axis < 3; axis++) {
      EdgeArray pEdges = this.pEdges[axis];
      int max = pHandle.getMaxEdges(axis);
      pEdges.setPos(max, handleSentinel);

      sortMaxUp(axis, max, dispatcher, false);

      int i = pHandle.getMinEdges(axis);
      pEdges.setPos(i, handleSentinel);

      sortMinUp(axis, i, dispatcher, false);

      pEdges.setHandle(limit - 1, 0);
View Full Code Here

    // free the handle
    freeHandle(handle);
  }
 
  public void updateHandle(int handle, Vector3f aabbMin, Vector3f aabbMax, Dispatcher dispatcher) {
    Handle pHandle = getHandle(handle);

    // quantize the new bounds
    int[] min = new int[3], max = new int[3];
    quantize(min, aabbMin, 0);
    quantize(max, aabbMax, 1);

    // update changed edges
    for (int axis = 0; axis < 3; axis++) {
      int emin = pHandle.getMinEdges(axis);
      int emax = pHandle.getMaxEdges(axis);

      int dmin = (int) min[axis] - (int) pEdges[axis].getPos(emin);
      int dmax = (int) max[axis] - (int) pEdges[axis].getPos(emax);

      pEdges[axis].setPos(emin, min[axis]);
View Full Code Here

  //}
 
  public BroadphaseProxy createProxy(Vector3f aabbMin, Vector3f aabbMax, BroadphaseNativeType shapeType, Object userPtr, short collisionFilterGroup, short collisionFilterMask, Dispatcher dispatcher, Object multiSapProxy) {
    int handleId = addHandle(aabbMin, aabbMax, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy);

    Handle handle = getHandle(handleId);

    return handle;
  }
View Full Code Here

    return handle;
  }
 
  public void destroyProxy(BroadphaseProxy proxy, Dispatcher dispatcher) {
    Handle handle = (Handle)proxy;
    removeHandle(handle.uniqueId, dispatcher);
  }
View Full Code Here

    Handle handle = (Handle)proxy;
    removeHandle(handle.uniqueId, dispatcher);
  }

  public void setAabb(BroadphaseProxy proxy, Vector3f aabbMin, Vector3f aabbMax, Dispatcher dispatcher) {
    Handle handle = (Handle) proxy;
    updateHandle(handle.uniqueId, aabbMin, aabbMax, dispatcher);
  }
View Full Code Here

TOP

Related Classes of com.bulletphysics.collision.broadphase.AxisSweep3Internal.Handle

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.