Skip to content

Commit

Permalink
core: shapes: Union: provide override for is_inside.
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSzuttor committed Feb 24, 2020
1 parent aa852eb commit 9d3f13a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/shapes/Union.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef SHAPES_UNION
#define SHAPES_UNION

#include <boost/range/numeric.hpp>
#include <memory>

#include "Shape.hpp"
Expand Down Expand Up @@ -66,6 +67,14 @@ class Union : public Shape {
dist_compare);
}

bool is_inside(Utils::Vector3d const &pos) const override {
return boost::accumulate(
m_shapes, false,
[&pos](bool inside, std::shared_ptr<Shapes::Shape> const &s) {
return inside && s->is_inside(pos);
});
}

private:
std::vector<std::shared_ptr<Shapes::Shape>> m_shapes;
};
Expand Down

0 comments on commit 9d3f13a

Please sign in to comment.