Update J3ML & AABB
This commit is contained in:
@@ -42,7 +42,7 @@ CPMAddPackage(
|
||||
|
||||
CPMAddPackage(
|
||||
NAME J3ML
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Prerelease-2.zip
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Prerelease-3.zip
|
||||
)
|
||||
|
||||
|
||||
|
2
include/engine/occlusion.h
Normal file
2
include/engine/occlusion.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
|
12
include/types/collision/axisAlignedBoundingBox.h
Normal file
12
include/types/collision/axisAlignedBoundingBox.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <types/vertex.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
struct AxisAlignedBoundingBox {
|
||||
LinearAlgebra::Vector3 minimums;
|
||||
LinearAlgebra::Vector3 maximums;
|
||||
};
|
||||
|
||||
namespace BoundingBox {
|
||||
AxisAlignedBoundingBox calculate(VertexArray* vArray);
|
||||
}
|
1
src/engine/occlusion.cpp
Normal file
1
src/engine/occlusion.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <engine/occlusion.h>
|
30
src/types/axisAlignedBoundingBox.cpp
Normal file
30
src/types/axisAlignedBoundingBox.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <types/collision/axisAlignedBoundingBox.h>
|
||||
#include <limits>
|
||||
AxisAlignedBoundingBox BoundingBox::calculate(VertexArray* vArray) {
|
||||
float minX = std::numeric_limits<float>::max();
|
||||
float minY = std::numeric_limits<float>::max();
|
||||
float minZ = std::numeric_limits<float>::max();
|
||||
float maxX = -std::numeric_limits<float>::max();
|
||||
float maxY = -std::numeric_limits<float>::max();
|
||||
float maxZ = -std::numeric_limits<float>::max();
|
||||
|
||||
for (const auto& vertex : vArray->vertices) {
|
||||
if (vertex.x < minX)
|
||||
minX = vertex.x;
|
||||
if (vertex.y < minY)
|
||||
minY = vertex.y;
|
||||
if (vertex.z < minZ)
|
||||
minZ = vertex.z;
|
||||
|
||||
if (vertex.x > maxX)
|
||||
maxX = vertex.x;
|
||||
if (vertex.y > maxY)
|
||||
maxY = vertex.y;
|
||||
if (vertex.z > maxZ)
|
||||
maxZ = vertex.z;
|
||||
}
|
||||
|
||||
LinearAlgebra::Vector3 minimums (minX, minY, minZ);
|
||||
LinearAlgebra::Vector3 maximums(maxX, maxY, maxZ);
|
||||
return AxisAlignedBoundingBox(minimums,maximums);
|
||||
}
|
Reference in New Issue
Block a user