
com.almasb.fxgl.physics.RaycastResult Maven / Gradle / Ivy
/*
* FXGL - JavaFX Game Library. The MIT License (MIT).
* Copyright (c) AlmasB ([email protected]).
* See LICENSE for details.
*/
package com.almasb.fxgl.physics;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.core.util.Optional;
import javafx.geometry.Point2D;
/**
* Result of a raycast.
* Contains optional entity and point
* which represent first non ignored physics entity
* and its point of collision in the ray's path.
*
* @author Almas Baimagambetov (AlmasB) ([email protected])
*/
public final class RaycastResult {
public static final RaycastResult NONE = new RaycastResult(null, null);
private Entity entity;
private Point2D point;
RaycastResult(Entity entity, Point2D point) {
this.entity = entity;
this.point = point;
}
/**
* @return the first physics entity that collided with the ray
* whose raycastIgnored flag is false
*/
public Optional getEntity() {
return Optional.ofNullable(entity);
}
/**
* @return the collision point in world coordinates
*/
public Optional getPoint() {
return Optional.ofNullable(point);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy