detectCollision method

  1. @override
void detectCollision(
  1. Shape shape1,
  2. Shape shape2,
  3. ContactManifold manifold
)
override

Detect collision of the shapes provided

Implementation

@override
void detectCollision(Shape shape1,Shape shape2,ContactManifold manifold){
  Octree o;
  Capsule c;

  flip = shape1 is Capsule;

  if(flip){
    o = shape2 as Octree;
    c = shape1 as Capsule;
  }
  else{
    o = shape1 as Octree;
    c = shape2 as Capsule;
  }

  OctreeData? result = capsuleIntersect(c,o.node);
  //playerCollider.translate(result.normal.multiplyScalar(result.depth));
  if(result != null && result.point != null){
    manifold.addPointVec(result.point!,result.normal,result.depth, flip );
  }
}