Package com.bulletphysics.util

Examples of com.bulletphysics.util.IntArrayList


    }

    Transform orgtrans0 = body0.getWorldTransform(Stack.alloc(Transform.class));
    Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));

    IntArrayList collided_results = new IntArrayList();

    gimpact_vs_shape_find_pairs(orgtrans0, orgtrans1, shape0, shape1, collided_results);

    if (collided_results.size() == 0) {
      return;
    }
    shape0.lockChildShapes();

    GIM_ShapeRetriever retriever0 = new GIM_ShapeRetriever(shape0);

    boolean child_has_transform0 = shape0.childrenHasTransform();

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

    int i = collided_results.size();

    while ((i--) != 0) {
      int child_index = collided_results.get(i);
      if (swapped) {
        triface1 = child_index;
      }
      else {
        triface0 = child_index;
View Full Code Here


                Vector3f tmp2 = vectorsPool.get();

                if (hull.numTriangles () > 0)
                {
                  int index = 0;
                  IntArrayList idx = hull.getIndexPointer();
                  ObjectArrayList<Vector3f> vtx = hull.getVertexPointer();

                  gl.glBegin (gl.GL_TRIANGLES);

                  for (int i=0; i<hull.numTriangles (); i++)
                  {
                    int i1 = index++;
                    int i2 = index++;
                    int i3 = index++;
                    assert(i1 < hull.numIndices () &&
                      i2 < hull.numIndices () &&
                      i3 < hull.numIndices ());

                    int index1 = idx.get(i1);
                    int index2 = idx.get(i2);
                    int index3 = idx.get(i3);
                    assert(index1 < hull.numVertices () &&
                      index2 < hull.numVertices () &&
                      index3 < hull.numVertices ());

                    Vector3f v1 = vtx.getQuick(index1);
View Full Code Here

      int srtsgns = (sortaxis.x >= 0 ? 1 : 0) +
          (sortaxis.y >= 0 ? 2 : 0) +
          (sortaxis.z >= 0 ? 4 : 0);
      int inside = (1 << count) - 1;
      ObjectArrayList<sStkNPS> stock = new ObjectArrayList<sStkNPS>();
      IntArrayList ifree = new IntArrayList();
      IntArrayList stack = new IntArrayList();
      int[] signs = new int[/*sizeof(unsigned)*8*/4 * 8];
      assert (count < (/*sizeof(signs)*/128 / /*sizeof(signs[0])*/ 4));
      for (int i = 0; i < count; i++) {
        signs[i] = ((normals[i].x >= 0) ? 1 : 0) +
            ((normals[i].y >= 0) ? 2 : 0) +
            ((normals[i].z >= 0) ? 4 : 0);
      }
      //stock.reserve(SIMPLE_STACKSIZE);
      //stack.reserve(SIMPLE_STACKSIZE);
      //ifree.reserve(SIMPLE_STACKSIZE);
      stack.add(allocate(ifree, stock, new sStkNPS(root, 0, root.volume.ProjectMinimum(sortaxis, srtsgns))));
      do {
        // JAVA NOTE: check
        int id = stack.remove(stack.size() - 1);
        sStkNPS se = stock.getQuick(id);
        ifree.add(id);
        if (se.mask != inside) {
          boolean out = false;
          for (int i = 0, j = 1; (!out) && (i < count); ++i, j <<= 1) {
            if (0 == (se.mask & j)) {
              int side = se.node.volume.Classify(normals[i], offsets[i], signs[i]);
              switch (side) {
                case -1:
                  out = true;
                  break;
                case +1:
                  se.mask |= j;
                  break;
              }
            }
          }
          if (out) {
            continue;
          }
        }
        if (policy.Descent(se.node)) {
          if (se.node.isinternal()) {
            Node[] pns = new Node[]{se.node.childs[0], se.node.childs[1]};
            sStkNPS[] nes = new sStkNPS[]{new sStkNPS(pns[0], se.mask, pns[0].volume.ProjectMinimum(sortaxis, srtsgns)),
              new sStkNPS(pns[1], se.mask, pns[1].volume.ProjectMinimum(sortaxis, srtsgns))
            };
            int q = nes[0].value < nes[1].value ? 1 : 0;
            int j = stack.size();
            if (fullsort && (j > 0)) {
              /* Insert 0  */
              j = nearest(stack, stock, nes[q].value, 0, stack.size());
              stack.add(0);
              //#if DBVT_USE_MEMMOVE
              //memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
              //#else
              for (int k = stack.size() - 1; k > j; --k) {
                stack.set(k, stack.get(k - 1));
              //#endif
              }
              stack.set(j, allocate(ifree, stock, nes[q]));
              /* Insert 1  */
              j = nearest(stack, stock, nes[1 - q].value, j, stack.size());
              stack.add(0);
              //#if DBVT_USE_MEMMOVE
              //memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
              //#else
              for (int k = stack.size() - 1; k > j; --k) {
                stack.set(k, stack.get(k - 1));
              //#endif
              }
              stack.set(j, allocate(ifree, stock, nes[1 - q]));
            }
            else {
              stack.add(allocate(ifree, stock, nes[q]));
              stack.add(allocate(ifree, stock, nes[1 - q]));
            }
          }
          else {
            policy.Process(se.node, se.value);
          }
        }
      }
      while (stack.size() != 0);
    }
  }
View Full Code Here

          for (int i=0; i<ovcount[0]; i++) {
            result.outputVertices.getQuick(i).set(vertexScratch.getQuick(i));
          }

          if (desc.hasHullFlag(HullFlags.REVERSE_ORDER)) {
            IntArrayList source_ptr = hr.indices;
            int source_idx = 0;

            IntArrayList dest_ptr = result.indices;
            int dest_idx = 0;

            for (int i=0; i<hr.faceCount; i++) {
              dest_ptr.set(dest_idx + 0, source_ptr.get(source_idx + 2));
              dest_ptr.set(dest_idx + 1, source_ptr.get(source_idx + 1));
              dest_ptr.set(dest_idx + 2, source_ptr.get(source_idx + 0));
              dest_idx += 3;
              source_idx += 3;
            }
          }
          else {
            for (int i=0; i<hr.indexCount; i++) {
              result.indices.set(i, hr.indices.get(i));
            }
          }
        }
        else {
          result.polygons = true;
          result.numOutputVertices = ovcount[0];
          MiscUtil.resize(result.outputVertices, ovcount[0], Vector3f.class);
          result.numFaces = hr.faceCount;
          result.numIndices = hr.indexCount + hr.faceCount;
          MiscUtil.resize(result.indices, result.numIndices, 0);
          for (int i=0; i<ovcount[0]; i++) {
            result.outputVertices.getQuick(i).set(vertexScratch.getQuick(i));
          }

          //        if ( 1 )
          {
            IntArrayList source_ptr = hr.indices;
            int source_idx = 0;

            IntArrayList dest_ptr = result.indices;
            int dest_idx = 0;

            for (int i=0; i<hr.faceCount; i++) {
              dest_ptr.set(dest_idx + 0, 3);
              if (desc.hasHullFlag(HullFlags.REVERSE_ORDER)) {
                dest_ptr.set(dest_idx + 1, source_ptr.get(source_idx + 2));
                dest_ptr.set(dest_idx + 2, source_ptr.get(source_idx + 1));
                dest_ptr.set(dest_idx + 3, source_ptr.get(source_idx + 0));
              }
              else {
                dest_ptr.set(dest_idx + 1, source_ptr.get(source_idx + 0));
                dest_ptr.set(dest_idx + 2, source_ptr.get(source_idx + 1));
                dest_ptr.set(dest_idx + 3, source_ptr.get(source_idx + 2));
              }

              dest_idx += 4;
              source_idx += 3;
            }
View Full Code Here

  private int calchull(ObjectArrayList<Vector3f> verts, int verts_count, IntArrayList tris_out, int[] tris_count, int vlimit) {
    int rc = calchullgen(verts, verts_count, vlimit);
    if (rc == 0) return 0;
   
    IntArrayList ts = new IntArrayList();

    for (int i=0; i<tris.size(); i++) {
      if (tris.getQuick(i) != null) {
        for (int j = 0; j < 3; j++) {
          ts.add((tris.getQuick(i)).getCoord(j));
        }
        deAllocateTriangle(tris.getQuick(i));
      }
    }
    tris_count[0] = ts.size() / 3;
    MiscUtil.resize(tris_out, ts.size(), 0);

    for (int i=0; i<ts.size(); i++) {
      tris_out.set(i, ts.get(i));
    }
    MiscUtil.resize(tris, 0, Tri.class);

    return 1;
  }
View Full Code Here

      vlimit = 1000000000;
    }
    //int j;
    Vector3f bmin = Stack.alloc((Vector3f) verts.getQuick(0));
    Vector3f bmax = Stack.alloc((Vector3f) verts.getQuick(0));
    IntArrayList isextreme = new IntArrayList();
    //isextreme.reserve(verts_count);
    IntArrayList allow = new IntArrayList();
    //allow.reserve(verts_count);

    for (int j=0; j<verts_count; j++) {
      allow.add(1);
      isextreme.add(0);
      VectorUtil.setMin(bmin, verts.getQuick(j));
      VectorUtil.setMax(bmax, verts.getQuick(j));
    }
    tmp.sub(bmax, bmin);
View Full Code Here

  //BringOutYourDead (John Ratcliff): When you create a convex hull you hand it a large input set of vertices forming a 'point cloud'.
  //After the hull is generated it give you back a set of polygon faces which index the *original* point cloud.
  //The thing is, often times, there are many 'dead vertices' in the point cloud that are on longer referenced by the hull.
  //The routine 'BringOutYourDead' find only the referenced vertices, copies them to an new buffer, and re-indexes the hull so that it is a minimal representation.
  private void bringOutYourDead(ObjectArrayList<Vector3f> verts, int vcount, ObjectArrayList<Vector3f> overts, int[] ocount, IntArrayList indices, int indexcount) {
    IntArrayList tmpIndices = new IntArrayList();
    for (int i=0; i<vertexIndexMapping.size(); i++) {
      tmpIndices.add(vertexIndexMapping.size());
    }

    IntArrayList usedIndices = new IntArrayList();
    MiscUtil.resize(usedIndices, vcount, 0);
    /*
    JAVA NOTE: redudant
    for (int i=0; i<vcount; i++) {
    usedIndices.set(i, 0);
    }
    */

    ocount[0] = 0;

    for (int i=0; i<indexcount; i++) {
      int v = indices.get(i); // original array index

      assert (v >= 0 && v < vcount);

      if (usedIndices.get(v) != 0) { // if already remapped
        indices.set(i, usedIndices.get(v) - 1); // index to new array
      }
      else {
        indices.set(i, ocount[0]);      // new index mapping

        overts.getQuick(ocount[0]).set(verts.getQuick(v)); // copy old vert to new vert array

        for (int k = 0; k < vertexIndexMapping.size(); k++) {
          if (tmpIndices.get(k) == v) {
            vertexIndexMapping.set(k, ocount[0]);
          }
        }

        ocount[0]++; // increment output vert count

        assert (ocount[0] >= 0 && ocount[0] <= vcount);

        usedIndices.set(v, ocount[0]); // assign new index remapping
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.bulletphysics.util.IntArrayList

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.