mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:16:16 +02:00
fixed line spacing and added BoundingBox support
This commit is contained in:
parent
6d3ec662a1
commit
b3ef9868e3
2 changed files with 157 additions and 138 deletions
|
@ -8,6 +8,16 @@
|
|||
#include "VoxelProjectedShadow.h"
|
||||
#include "GeometryUtil.h"
|
||||
|
||||
|
||||
bool BoundingBox::contains(const BoundingBox& box) const {
|
||||
return (
|
||||
(box.corner.x >= corner.x) &&
|
||||
(box.corner.y >= corner.y) &&
|
||||
(box.corner.x + box.size.x <= corner.x + size.x) &&
|
||||
(box.corner.y + box.size.y <= corner.y + size.y)
|
||||
);
|
||||
};
|
||||
|
||||
void VoxelProjectedShadow::setVertex(int vertex, const glm::vec2& point) {
|
||||
_vertices[vertex] = point;
|
||||
|
||||
|
@ -50,8 +60,6 @@ bool VoxelProjectedShadow::occludes(const VoxelProjectedShadow& occludee) const
|
|||
}
|
||||
|
||||
bool VoxelProjectedShadow::pointInside(const glm::vec2& point) const {
|
||||
bool pointInside = false; // assume the worst
|
||||
|
||||
// first check the bounding boxes, the point mush be fully within the boounding box of this shadow
|
||||
if ((point.x > getMaxX()) ||
|
||||
(point.y > getMaxY()) ||
|
||||
|
|
|
@ -14,13 +14,20 @@ const int MAX_SHADOW_VERTEX_COUNT = 6;
|
|||
|
||||
typedef glm::vec2 ShadowVertices[MAX_SHADOW_VERTEX_COUNT];
|
||||
|
||||
class VoxelProjectedShadow
|
||||
{
|
||||
class BoundingBox {
|
||||
public:
|
||||
BoundingBox(glm::vec2 corner, glm::vec2 size) : corner(corner), size(size) {};
|
||||
glm::vec2 corner;
|
||||
glm::vec2 size;
|
||||
bool contains(const BoundingBox& box) const;
|
||||
};
|
||||
|
||||
class VoxelProjectedShadow {
|
||||
|
||||
public:
|
||||
|
||||
VoxelProjectedShadow() : _vertexCount(0), _maxX(0.0f), _maxY(0.0f), _minX(FLT_MAX), _minY(FLT_MAX) { };
|
||||
VoxelProjectedShadow(int vertexCount) : _vertexCount(vertexCount), _maxX(0.0f), _maxY(0.0f), _minX(FLT_MAX), _minY(FLT_MAX)
|
||||
VoxelProjectedShadow(int vertexCount = 0) :
|
||||
_vertexCount(vertexCount), _maxX(-FLT_MAX), _maxY(-FLT_MAX), _minX(FLT_MAX), _minY(FLT_MAX)
|
||||
{ };
|
||||
|
||||
~VoxelProjectedShadow() { };
|
||||
|
@ -38,6 +45,10 @@ public:
|
|||
float getMinX() const { return _minX; }
|
||||
float getMinY() const { return _minY; }
|
||||
|
||||
BoundingBox getBoundingBox() const {
|
||||
return BoundingBox(glm::vec2(_minX,_minY), glm::vec2(_maxX - _minX, _maxY - _minY));
|
||||
};
|
||||
|
||||
private:
|
||||
int _vertexCount;
|
||||
ShadowVertices _vertices;
|
||||
|
|
Loading…
Reference in a new issue