Exemple #1
0
  /** Classify points that are closer. */
  public void merge_points(
      Vector4f plane, float margin, ObjectArrayList<Vector3f> points, int point_count) {
    this.point_count = 0;
    penetration_depth = -1000.0f;

    int[] point_indices = intArrays.getFixed(MAX_TRI_CLIPPING);

    for (int _k = 0; _k < point_count; _k++) {
      float _dist = -ClipPolygon.distance_point_plane(plane, points.getQuick(_k)) + margin;

      if (_dist >= 0.0f) {
        if (_dist > penetration_depth) {
          penetration_depth = _dist;
          point_indices[0] = _k;
          this.point_count = 1;
        } else if ((_dist + BulletGlobals.SIMD_EPSILON) >= penetration_depth) {
          point_indices[this.point_count] = _k;
          this.point_count++;
        }
      }
    }

    for (int _k = 0; _k < this.point_count; _k++) {
      this.points[_k].set(points.getQuick(point_indices[_k]));
    }

    intArrays.release(point_indices);
  }
  public boolean overlap_test_conservative(TriangleShapeEx other) {
    float total_margin = getMargin() + other.getMargin();

    Vector4f plane0 = new Vector4f();
    buildTriPlane(plane0);
    Vector4f plane1 = new Vector4f();
    other.buildTriPlane(plane1);

    // classify points on other triangle
    float dis0 = ClipPolygon.distance_point_plane(plane0, other.vertices1[0]) - total_margin;

    float dis1 = ClipPolygon.distance_point_plane(plane0, other.vertices1[1]) - total_margin;

    float dis2 = ClipPolygon.distance_point_plane(plane0, other.vertices1[2]) - total_margin;

    if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f) {
      return false; // classify points on this triangle
    }
    dis0 = ClipPolygon.distance_point_plane(plane1, vertices1[0]) - total_margin;

    dis1 = ClipPolygon.distance_point_plane(plane1, vertices1[1]) - total_margin;

    dis2 = ClipPolygon.distance_point_plane(plane1, vertices1[2]) - total_margin;

    if (dis0 > 0.0f && dis1 > 0.0f && dis2 > 0.0f) {
      return false;
    }
    return true;
  }