Program: 96832
Project: 96832
Buggy source:
/** 
 * Checks for collisions between every component in the scene that belongs to the registered types registered using the register() method.
 */
public void checkCollisions(){
  if (scene.entities.size() == 0) {
    childrenInScene=0;
    return;
  }
  if (scene.entities.size() != childrenInScene) {
    entities.clear();
    broadphase.clear();
    childrenInScene=0;
    for (    Entity3D entity : scene.entities) {
      CollisionComponent3D component=entity.getComponent(CollisionComponent3D.class);
      if (component != null) {
        broadphase.insert(component);
        entities.add(entity);
      }
      childrenInScene++;
    }
  }
  for (  Entity3D entity : entities) {
    TransformComponent3D transform=entity.getComponent(TransformComponent3D.class);
    CollisionComponent3D collision=entity.getComponent(CollisionComponent3D.class);
    if (transform.transformed) {
      broadphase.remove(collision);
      broadphase.insert(collision);
    }
  }
  for (  CollisionTag type1 : collisionMap.keySet()) {
    for (    Entity3D entity : entities) {
      CollisionComponent3D collision=entity.getComponent(CollisionComponent3D.class);
      if (type1 == collision.tag) {
        List<CollisionComponent3D> collidables=broadphase.retrieve(collision);
        for (        CollisionTag type2 : collisionMap.get(type1)) {
          for (          CollisionComponent3D collidable : collidables)           if (collidable.tag == type2)           if (collision.polyhedron.intersects(collidable.polyhedron))           collision.callback.handleCollision(collision.entity);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Checks for collisions between every component in the scene that belongs to the registered types registered using the register() method.
 */
public void checkCollisions(){
  if (scene.entities.size() == 0) {
    childrenInScene=0;
    return;
  }
  if (scene.numEntities() != childrenInScene) {
    entities.clear();
    broadphase.clear();
    childrenInScene=0;
    updateEntities(scene.entities);
  }
  for (  Entity3D entity : entities) {
    TransformComponent3D transform=entity.getComponent(TransformComponent3D.class);
    for (    IComponent3D component : entity.getComponents()) {
      if (component instanceof CollisionComponent3D) {
        CollisionComponent3D collision=(CollisionComponent3D)component;
        if (transform.transformed) {
          broadphase.remove(collision);
          broadphase.insert(collision);
        }
      }
    }
  }
  for (  CollisionTag type1 : collisionMap.keySet()) {
    for (    Entity3D entity : entities) {
      CollisionComponent3D collision=entity.getComponent(CollisionComponent3D.class);
      if (type1 == collision.tag) {
        List<CollisionComponent3D> collidables=broadphase.retrieve(collision);
        for (        CollisionTag type2 : collisionMap.get(type1)) {
          for (          CollisionComponent3D collidable : collidables)           if (collidable.tag == type2)           if (collision.polyhedron.intersects(collidable.polyhedron))           collision.callback.handleCollision(collision.entity,collidable);
        }
      }
    }
  }
}