Go to the documentation of this file.00001 #ifndef SPATIALPARTIONING_H
00002 #define SPATIALPARTIONING_H
00003 #include <boost/unordered_map.hpp>
00004 #include <HashTableData.h>
00005 #include <ObjObject.h>
00006
00007
00012
00018
00019 class SpatialPartioning
00020 {
00021 public:
00023 SpatialPartioning();
00024
00026 ~SpatialPartioning();
00027
00031 void ObjectHashing(ObjObject* _object, std::string _objectName);
00032
00036 void CalculateVertexNeighbours(const ngl::Vector &_vertex, std::vector<HashTableData> &_neighbours);
00037
00040 void CalculateObjectNeighbours(std::vector<ObjObject*> _listOfObjects);
00041
00042 struct ihash : std::unary_function<ngl::Vector, std::size_t>
00043 {
00044 std::size_t operator()(const ngl::Vector &coord) const
00045 {
00046 std::size_t seed = 0xdeadbeef;
00047 boost::hash_combine(seed, coord.m_x);
00048 boost::hash_combine(seed, coord.m_y);
00049 boost::hash_combine(seed, coord.m_z);
00050 return seed;
00051 }
00052 };
00053
00055 void CleanHashTable()
00056 {
00057 m_hashTable.clear();
00058 }
00059
00060
00062 ngl::Vector BBMin, BBMax;
00063
00064 protected:
00065
00067 ngl::Real m_gridCellSize;
00068
00069 private:
00070
00072 typedef boost::unordered_multimap<ngl::Vector, HashTableData, ihash> m_hashTable_t;
00073 m_hashTable_t m_hashTable;
00074
00077 unsigned int HashFunction(ngl::Vector coord);
00078
00082 void VertexHashing(const ngl::Vector &_vertex, unsigned int _vertexIndex, std::string _objectName, bool _isCloth);
00083
00086 ngl::Vector FloorValue(const ngl::Vector &value);
00087
00090 ngl::Real FloorValue(const ngl::Real &value);
00091
00092
00093 };
00094
00095 #endif // SPATIALPARTIONING_H