glm::vec3 CameraFollowHelper::followPosition() {
    Sphere sphere;

    WorldObject* worldObject = m_target.get();

    sphere.setPosition(worldObject->transform().position());
    sphere.setRadius(worldObject->bounds().minimalGridAABB().diameter() * worldObject->transform().scale());

    if (worldObject->bounds().sphere().radius() > 0) {
        float sizeScaling = 1 + (5.0f / worldObject->bounds().sphere().radius());
        return sphere.position() + (worldObject->transform().orientation() * m_cameraOffset.get() * sizeScaling) * sphere.radius();
    } else {
        return sphere.position();
    }
}
Esempio n. 2
0
float FighterFightTask::pointDistance(const glm::vec3& point) {
    WorldObject* worldObject = boardComputer()->worldObject();
    return glm::length(worldObject->transform().position() - point) - worldObject->bounds().minimalGridSphere().radius() * worldObject->transform().scale();
}