Merge branch 'tyrav2-develop' into tyrav2-static-dynamic-pipelines
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020-2022, tyra - https://github.com/h4570/tyra
|
||||
# Licenced 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();
|
||||
|
||||
// Methods
|
||||
|
||||
/**
|
||||
* @param origin Vec4 starting point of the ray;
|
||||
* @param direction Vec4 normalized vector pointing to direction;
|
||||
*/
|
||||
void set(const Vec4& origin, const Vec4& direction);
|
||||
|
||||
/**
|
||||
* @brief Set origin of the ray;
|
||||
* @param origin Vec4 starting point of the ray;
|
||||
*/
|
||||
void setOrigin(const Vec4& origin);
|
||||
|
||||
/**
|
||||
* @brief Set direction of the ray;
|
||||
* @param direction Vec4 normalized vector pointing to direction;
|
||||
*/
|
||||
void setDirection(const 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);
|
||||
|
||||
/** @return Distance from the Vec4 point to the origin */
|
||||
float distanceToPoint(const Vec4& point);
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
u8 intersectBox(const Vec4& minCorner, const Vec4& maxCorner, float& distance);
|
||||
|
||||
/** Returns inverse direction */
|
||||
const Vec4 invDir();
|
||||
|
||||
private:
|
||||
Vec4 _origin;
|
||||
Vec4 _direction;
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
@@ -41,6 +41,17 @@ class BBox : public CoreBBox {
|
||||
/** @returns the bottom face (nearer on y-axis) */
|
||||
const BBoxFace& getBottomFace() { return _bottomFace; }
|
||||
|
||||
/** @returns the lower (x, y, z) boundary of the box. */
|
||||
Vec4 min();
|
||||
/** @returns the upper (x, y, z) boundary of the box. */
|
||||
Vec4 max();
|
||||
/**
|
||||
* @param res_min Vec4 to store the min result
|
||||
* @param res_max Vec4 to store the min result
|
||||
* @brief Calc and stores the min and max points of box at a single loop
|
||||
* */
|
||||
void getMinMax(Vec4* res_min, Vec4* res_max);
|
||||
|
||||
protected:
|
||||
float _height, _depth, _width;
|
||||
Vec4 _centerVector;
|
||||
|
||||
@@ -37,6 +37,9 @@ class CoreBBox {
|
||||
void print(const std::string& name) const { print(name.c_str()); }
|
||||
std::string getPrint(const char* name = nullptr) const;
|
||||
|
||||
CoreBBoxFrustum isInFrustum(const Plane* frustumPlanes, const M4x4& model,
|
||||
const float* margins = nullptr) const;
|
||||
|
||||
protected:
|
||||
Vec4 _vertices[8];
|
||||
};
|
||||
|
||||
@@ -25,9 +25,6 @@ class RenderBBox : public CoreBBox {
|
||||
explicit RenderBBox(const std::vector<CoreBBox>& t_bboxes,
|
||||
const u32& startIndex, const u32& stopIndex);
|
||||
|
||||
CoreBBoxFrustum isInFrustum(const Plane* frustumPlanes, const M4x4& model,
|
||||
const float* margins = nullptr) const;
|
||||
|
||||
CoreBBoxFrustum clipIsInFrustum(const Plane* frustumPlanes,
|
||||
const M4x4& model) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user