Skip to content

Commit

Permalink
ENGINES: Add bounding box check for contains test
Browse files Browse the repository at this point in the history
  • Loading branch information
rjshae authored and DrMcCoy committed Nov 3, 2018
1 parent 3a6e863 commit 05cb8b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/engines/aurora/trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ bool Trigger::contains(float x, float y) const {
// Check the container data
assert(_prepared);

// Check if point is in bounding box
if (!_boundingbox.isIn(x, y))
return false;

glm::vec3 orig(x, y, 1000);
glm::vec3 intersection;

Expand Down Expand Up @@ -100,9 +104,15 @@ void Trigger::render(Graphics::RenderPass pass) {

/*
* Prepare internal data for the contains(x, y) call.
* Run this after the trigger geometry data is loaded.
* Run this after the _geometry data is loaded.
*/
void Trigger::prepare() {
std::vector<glm::vec3>::iterator it;

// Add vertices to the bounding box
for (it = _geometry.begin(); it != _geometry.end(); ++it)
_boundingbox.add(it->x, it->y, it->z);

// Flag as processed
_prepared = true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/engines/aurora/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "glm/vec3.hpp"

#include "src/common/boundingbox.h"

#include "src/graphics/renderable.h"

namespace Engines {
Expand All @@ -51,6 +53,7 @@ class Trigger : public Graphics::Renderable {
void prepare();
private:
bool _prepared;
Common::BoundingBox _boundingbox;
};

} // End of namespace Engines
Expand Down

0 comments on commit 05cb8b4

Please sign in to comment.