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;
  Sphere s;

  flip = shape1 is Sphere;

  if(flip){
    o = shape2 as Octree;
    s = shape1 as Sphere;
  }
  else{
    o = shape1 as Octree;
    s = shape2 as Sphere;
  }

  OctreeData? result = sphereIntersect(s,o.node);
  //OctreeData? result = o.node.sphereIntersect(s,);

  //playerCollider.translate(result.normal.multiplyScalar(result.depth));
  if(result != null && result.point != null){
    manifold.addPointVec(result.point!,result.normal,result.depth, flip );
  }
}