diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/Collision/BoundingIntervalHierarchy.cpp | 1 | ||||
| -rw-r--r-- | src/common/Collision/BoundingIntervalHierarchy.h | 2 | ||||
| -rw-r--r-- | src/common/Collision/RegularGrid.h | 33 |
3 files changed, 14 insertions, 22 deletions
diff --git a/src/common/Collision/BoundingIntervalHierarchy.cpp b/src/common/Collision/BoundingIntervalHierarchy.cpp index e37d00b802a..7e58d6c9003 100644 --- a/src/common/Collision/BoundingIntervalHierarchy.cpp +++ b/src/common/Collision/BoundingIntervalHierarchy.cpp @@ -16,6 +16,7 @@ */ #include "BoundingIntervalHierarchy.h" +#include <stdexcept> void BIH::buildHierarchy(std::vector<uint32>& tempTree, buildData& dat, BuildStats& stats) const { diff --git a/src/common/Collision/BoundingIntervalHierarchy.h b/src/common/Collision/BoundingIntervalHierarchy.h index 5c9c69ed1b6..5674ee2057d 100644 --- a/src/common/Collision/BoundingIntervalHierarchy.h +++ b/src/common/Collision/BoundingIntervalHierarchy.h @@ -24,8 +24,6 @@ #include <G3D/Ray.h> #include <G3D/Vector3.h> #include <algorithm> -#include <limits> -#include <stdexcept> #include <vector> #define MAX_STACK_SIZE 64 diff --git a/src/common/Collision/RegularGrid.h b/src/common/Collision/RegularGrid.h index ec89e3825ff..459388d2662 100644 --- a/src/common/Collision/RegularGrid.h +++ b/src/common/Collision/RegularGrid.h @@ -22,7 +22,6 @@ #include "IteratorPair.h" #include <G3D/Ray.h> #include <G3D/BoundsTrait.h> -#include <G3D/PositionTrait.h> #include <memory> #include <unordered_map> @@ -34,8 +33,7 @@ struct NodeCreator{ template<class T, class Node, class NodeCreatorFunc = NodeCreator<Node>, -class BoundsFunc = BoundsTrait<T>, -class PositionFunc = PositionTrait<T> +class BoundsFunc = BoundsTrait<T> > class TC_COMMON_API RegularGrid2D { @@ -45,15 +43,14 @@ public: CELL_NUMBER = 64, }; - #define HGRID_MAP_SIZE (533.33333f * 64.f) // shouldn't be changed - #define CELL_SIZE float(HGRID_MAP_SIZE/(float)CELL_NUMBER) + #define CELL_SIZE 533.33333f - typedef std::unordered_multimap<const T*, Node*> MemberTable; + typedef std::unordered_multimap<T const*, Node*> MemberTable; MemberTable memberTable; std::unique_ptr<Node> nodes[CELL_NUMBER][CELL_NUMBER] = { }; - void insert(const T& value) + void insert(T const& value) { G3D::AABox bounds = G3D::AABox::empty(); BoundsFunc::getBounds(value, bounds); @@ -70,7 +67,7 @@ public: } } - void remove(const T& value) + void remove(T const& value) { for (auto& p : Trinity::Containers::MapEqualRange(memberTable, &value)) p.second->remove(value); @@ -86,21 +83,18 @@ public: n->balance(); } - bool contains(const T& value) const { return memberTable.count(&value) > 0; } + bool contains(T const& value) const { return memberTable.contains(&value); } bool empty() const { return memberTable.empty(); } struct Cell { int x, y; - bool operator==(Cell const& c2) const - { - return x == c2.x && y == c2.y; - } + + friend bool operator==(Cell const&, Cell const&) = default; static Cell ComputeCell(float fx, float fy) { - Cell c = { int(fx * (1.f / CELL_SIZE) + (CELL_NUMBER / 2)), int(fy * (1.f / CELL_SIZE) + (CELL_NUMBER / 2)) }; - return c; + return { .x = int(fx * (1.f / CELL_SIZE) + (CELL_NUMBER / 2)), .y = int(fy * (1.f / CELL_SIZE) + (CELL_NUMBER / 2)) }; } bool isValid() const { return x >= 0 && x < CELL_NUMBER && y >= 0 && y < CELL_NUMBER; } @@ -115,13 +109,13 @@ public: } template<typename RayCallback> - void intersectRay(const G3D::Ray& ray, RayCallback& intersectCallback, float max_dist) + void intersectRay(G3D::Ray const& ray, RayCallback& intersectCallback, float max_dist) { intersectRay(ray, intersectCallback, max_dist, ray.origin() + ray.direction() * max_dist); } template<typename RayCallback> - void intersectRay(const G3D::Ray& ray, RayCallback& intersectCallback, float& max_dist, const G3D::Vector3& end) + void intersectRay(G3D::Ray const& ray, RayCallback& intersectCallback, float& max_dist, G3D::Vector3 const& end) { Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y); if (!cell.isValid()) @@ -197,7 +191,7 @@ public: } template<typename IsectCallback> - void intersectPoint(const G3D::Vector3& point, IsectCallback& intersectCallback) + void intersectPoint(G3D::Vector3 const& point, IsectCallback& intersectCallback) { Cell cell = Cell::ComputeCell(point.x, point.y); if (!cell.isValid()) @@ -208,7 +202,7 @@ public: // Optimized verson of intersectRay function for rays with vertical directions template<typename RayCallback> - void intersectZAllignedRay(const G3D::Ray& ray, RayCallback& intersectCallback, float& max_dist) + void intersectZAllignedRay(G3D::Ray const& ray, RayCallback& intersectCallback, float& max_dist) { Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y); if (!cell.isValid()) @@ -219,6 +213,5 @@ public: }; #undef CELL_SIZE -#undef HGRID_MAP_SIZE #endif |
