utility functions
This commit is contained in:
@@ -21,17 +21,31 @@ namespace Tyra {
|
||||
/** Bounding box */
|
||||
class CoreBBox {
|
||||
public:
|
||||
explicit CoreBBox();
|
||||
CoreBBox();
|
||||
CoreBBox(const CoreBBox& t_bbox);
|
||||
explicit CoreBBox(Vec4* t_vertices, u32* faces, u32 t_count);
|
||||
explicit CoreBBox(Vec4* t_vertices, u32 t_count);
|
||||
explicit CoreBBox(Vec4* t_vertices);
|
||||
explicit CoreBBox(const CoreBBox& t_bbox);
|
||||
explicit CoreBBox(CoreBBox** t_bboxes, const u32& count);
|
||||
explicit CoreBBox(const std::vector<CoreBBox>& t_bboxes,
|
||||
const u32& startIndex, const u32& stopIndex);
|
||||
|
||||
static CoreBBox create(const Vec4& center, const float& size);
|
||||
|
||||
/**
|
||||
* 0 - lowX, lowY, lowZ
|
||||
* 1 - lowX, lowY, hiZ
|
||||
* 2 - lowX, hiY, lowZ
|
||||
* 3 - lowX, hiY, hiZ
|
||||
* 4 - hiX, lowY, lowZ
|
||||
* 5 - hiX, lowY, hiZ
|
||||
* 6 - hiX, hiY, lowZ
|
||||
* 7 - hiX, hiY, hiZ
|
||||
*/
|
||||
Vec4 vertices[8];
|
||||
|
||||
void operator=(const CoreBBox& v);
|
||||
|
||||
const Vec4& operator[](const u8& i) const { return vertices[i]; }
|
||||
|
||||
const u8 getVertexCount() const { return 8; }
|
||||
@@ -41,13 +55,14 @@ class CoreBBox {
|
||||
void print(const std::string& name) const { print(name.c_str()); }
|
||||
std::string getPrint(const char* name = nullptr) const;
|
||||
|
||||
/**
|
||||
* @brief Check if bbox is in view frustum
|
||||
*
|
||||
* @param frustumPlanes Available in engine.renderer.core.renderer3D.frustumPlanes
|
||||
* @param model Model matrix
|
||||
* @param margins Optional margins
|
||||
*/
|
||||
/**
|
||||
* @brief Check if bbox is in view frustum
|
||||
*
|
||||
* @param frustumPlanes Available in
|
||||
* engine.renderer.core.renderer3D.frustumPlanes
|
||||
* @param model Model matrix
|
||||
* @param margins Optional margins
|
||||
*/
|
||||
CoreBBoxFrustum isInFrustum(const Plane* frustumPlanes, const M4x4& model,
|
||||
const float* margins = nullptr) const;
|
||||
};
|
||||
|
||||
+9
-9
@@ -11,7 +11,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "./ee_clip_vertex.hpp"
|
||||
#include "./planes_clip_vertex.hpp"
|
||||
#include "debug/debug.hpp"
|
||||
#include "renderer/renderer_settings.hpp"
|
||||
|
||||
@@ -21,30 +21,30 @@ struct EEClipAlgorithmSettings {
|
||||
bool lerpNormals, lerpTexCoords, lerpColors;
|
||||
};
|
||||
|
||||
class EEClipAlgorithm {
|
||||
class PlanesClipAlgorithm {
|
||||
public:
|
||||
EEClipAlgorithm();
|
||||
~EEClipAlgorithm();
|
||||
PlanesClipAlgorithm();
|
||||
~PlanesClipAlgorithm();
|
||||
|
||||
void init(const RendererSettings& settings);
|
||||
|
||||
u8 clip(EEClipVertex* o_vertices, EEClipVertexPtrs* i_vertices,
|
||||
u8 clip(PlanesClipVertex* o_vertices, PlanesClipVertexPtrs* i_vertices,
|
||||
const EEClipAlgorithmSettings& settings);
|
||||
|
||||
static float clipMargin;
|
||||
|
||||
private:
|
||||
float halfWidth, halfHeight, near, far;
|
||||
EEClipVertex* tempVertices;
|
||||
PlanesClipVertex* tempVertices;
|
||||
|
||||
float getValueByPlane(const EEClipVertex& v, const int& plane);
|
||||
float getValueByPlane(const PlanesClipVertex& v, const int& plane);
|
||||
|
||||
bool isInside(const int& plane, const float& v, const float& w,
|
||||
const float& planeLimitValue);
|
||||
|
||||
/** @return clipped size */
|
||||
u8 clipAgainstPlane(EEClipVertex* original, const u8& originalSize,
|
||||
EEClipVertex* clipped, const int& plane,
|
||||
u8 clipAgainstPlane(PlanesClipVertex* original, const u8& originalSize,
|
||||
PlanesClipVertex* clipped, const int& plane,
|
||||
const float& planeLimitValue,
|
||||
const EEClipAlgorithmSettings& settings);
|
||||
};
|
||||
+2
-2
@@ -14,11 +14,11 @@
|
||||
|
||||
namespace Tyra {
|
||||
|
||||
struct EEClipVertex {
|
||||
struct PlanesClipVertex {
|
||||
Vec4 position, normal, st, color;
|
||||
};
|
||||
|
||||
struct EEClipVertexPtrs {
|
||||
struct PlanesClipVertexPtrs {
|
||||
Vec4 *position, *normal, *st, *color;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user