Files
tyra-linux/engine/inc/physics/ray.hpp
T
2022-08-14 20:01:49 +02:00

57 lines
1.4 KiB
C++

/*
# _____ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022-2022, tyra - https://github.com/h4570/tyra
# Licensed under Apache License 2.0
# Wellington Carvalho <wellcoj@gmail.com>
*/
#include "math/vec4.hpp"
#pragma once
namespace Tyra {
/**
* Class for raycasting.
*/
class Ray {
public:
/** @brief Constructor create a ampty ray */
Ray();
/**
* @param origin The origin of the ray
* @param direction The direction of the ray (normalized Vec4)
*/
Ray(const Vec4& origin, const Vec4& direction);
~Ray();
Vec4 origin;
Vec4 direction;
/**
* @return Vec4 that is a given distance along this Ray
* @param t - the distance along the Ray to retrieve a position for.
*/
Vec4 at(const float& t) const;
/** @return Distance from the Vec4 point to the origin */
float distanceToPoint(const Vec4& point) const;
/**
* @param minCorner - pointer to min corner position. (bottom left)
* @param maxCorner - pointer to max corner position. (top right)
* @param distance - the box to intersect with.
* @return Vec4 point of intersection
*/
bool intersectBox(const Vec4& minCorner, const Vec4& maxCorner,
float& distance) const;
/** Returns inverse direction */
Vec4 invDir() const;
};
} // namespace Tyra