diff --git a/src/pe/ccd/HashGrids.cpp b/src/pe/ccd/HashGrids.cpp index 416b8880583dbcf1e85586d93c0cecdd0e62760c..8f10c5e36aa9b20765720edac86c92063f23c1e4 100644 --- a/src/pe/ccd/HashGrids.cpp +++ b/src/pe/ccd/HashGrids.cpp @@ -1181,7 +1181,6 @@ bool HashGrids::powerOfTwo( size_t number ) size_t HashGrids::intersectionTestCount = 0; //ToDo remove again -std::map<std::string, std::set<size_t>> HashGrids::raySignsCellNeighborMap; // ToDo remove again //================================================================================================= // diff --git a/src/pe/ccd/HashGrids.h b/src/pe/ccd/HashGrids.h index 2140f6deedf20d0e85618f1a4807b18ae33af57f..7278f11734882df8142349fe101a590dc2cc6ed8 100644 --- a/src/pe/ccd/HashGrids.h +++ b/src/pe/ccd/HashGrids.h @@ -45,11 +45,6 @@ #include <pe/utility/BodyCast.h> #include <pe/raytracing/Intersects.h> -#include <sstream> // ToDo remove again - - -#define BLOCKCELL_NORMAL_INDETERMINATE 3 - namespace walberla{ namespace pe{ @@ -104,10 +99,8 @@ public: //********************************************************************************************** static size_t intersectionTestCount; // ToDo remove again - - static std::map<std::string, std::set<size_t>> raySignsCellNeighborMap; // ToDo remove again -//private: // toDo uncomment to change to private again +private: //**Type definitions**************************************************************************** //! Vector for storing (handles to) rigid bodies. typedef std::vector<BodyID> BodyVector; @@ -191,21 +184,20 @@ public: void processBodies( BodyID* bodies, size_t bodyCount, Contacts& contacts ) const; template<typename BodyTuple> - BodyID getRayIntersectingBody(const raytracing::Ray& ray, const AABB& blockAABB, real_t& t, Vec3& n); // todo const + BodyID getRayIntersectingBody(const raytracing::Ray& ray, const AABB& blockAABB, real_t& t, Vec3& n) const; template<typename BodyTuple> const BodyID getBodyIntersectionForBlockCell(const Vector3<int32_t>& blockCell, - const int8_t cellNormalAxis, const int8_t cellNormalDir, const AABB& blockAABB, const raytracing::Ray& ray, - real_t& t_closest, Vec3& n_closest); // todo const + real_t& t_closest, Vec3& n_closest) const; void clear(); //@} //******************************************************************************************* - //private: // ToDo uncomment to change to private again + private: //**Utility functions************************************************************************ /*!\name Utility functions */ //@{ @@ -312,7 +304,7 @@ public: BodyID getClosestBodyIntersectingWithRay(const raytracing::Ray& ray, const AABB& blockAABB, real_t& t, Vec3& n); -//protected: // ToDo uncomment to change to protected again +protected: //**Utility functions*************************************************************************** /*!\name Utility functions */ //@{ @@ -321,7 +313,7 @@ public: //@} //********************************************************************************************** -//private: // ToDo uncomment to change to private again +private: //**Add functions******************************************************************************* /*!\name Add functions */ //@{ @@ -518,10 +510,9 @@ void HashGrids::HashGrid::processBodies( BodyID* bodies, size_t bodyCount, Conta */ template<typename BodyTuple> const BodyID HashGrids::HashGrid::getBodyIntersectionForBlockCell(const Vector3<int32_t>& blockCell, - const int8_t cellNormalAxis, const int8_t cellNormalDir, const AABB& blockAABB, const raytracing::Ray& ray, - real_t& t_closest, Vec3& n_closest) { + real_t& t_closest, Vec3& n_closest) const { real_t t_local; Vec3 n_local; BodyID body = NULL; @@ -534,249 +525,9 @@ const BodyID HashGrids::HashGrid::getBodyIntersectionForBlockCell(const Vector3< real_t z = (real_c(blockCell[2]) + real_t(0.5)) * cellSpan_; const Cell& centerCell = cell_[hashPoint(x, y, z)]; - - //std::vector<uint> relevantNeighborIndices = {13, 9,10,12, 22,21, 25}; - - std::vector<uint> relevantNeighborIndices = {13}; //{13, 9,10,12, 11,14,15,16,17}; - - if (cellNormalAxis == BLOCKCELL_NORMAL_INDETERMINATE) { - relevantNeighborIndices = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26 - }; - } else { - /*if (ray.zDir() < 0) { - if (cellNormalAxis == 0 && cellNormalDir == -1) { - relevantNeighborIndices.push_back(22); - } else if (cellNormalAxis == 2 && cellNormalDir == 1) { - relevantNeighborIndices.push_back(25); - relevantNeighborIndices.push_back(19); - if (ray.yDir() > 0) { - relevantNeighborIndices.push_back(25); - } else { - relevantNeighborIndices.push_back(19); - } - } - } else { - relevantNeighborIndices = {13,0,1,3,4}; - }*/ - /*if (cellNormalAxis == 2 && cellNormalDir == 1) { - relevantNeighborIndices.push_back(9); - relevantNeighborIndices.push_back(10); - relevantNeighborIndices.push_back(12); - } else if (cellNormalAxis == 0 && cellNormalDir == 1) { - relevantNeighborIndices.push_back(1); - relevantNeighborIndices.push_back(10); - relevantNeighborIndices.push_back(4); - }*/ - - /*if (ray.zDir() < 0) { - relevantNeighborIndices.push_back(9); - relevantNeighborIndices.push_back(10); - relevantNeighborIndices.push_back(12); - } - if (ray.xDir() < 0) { - relevantNeighborIndices.push_back(1); - relevantNeighborIndices.push_back(4); - } else { - relevantNeighborIndices.push_back(0); - relevantNeighborIndices.push_back(1); - relevantNeighborIndices.push_back(3); - } - if (ray.yDir() < 0) { - //relevantNeighborIndices.push_back(1); - - }*/ - - if (ray.xDir() > 0 && ray.yDir() < 0 && ray.zDir() < 0) { - // +x, -y, -z - relevantNeighborIndices.push_back(0); - relevantNeighborIndices.push_back(1); - relevantNeighborIndices.push_back(3); - } else if (ray.xDir() > 0 && ray.yDir() > 0 && ray.zDir() < 0) { - // +x, +y, -z - relevantNeighborIndices.push_back(0); - relevantNeighborIndices.push_back(1); - relevantNeighborIndices.push_back(3); - } else if (ray.xDir() < 0 && ray.yDir() < 0 && ray.zDir() < 0) { - // -x, -y, -z - relevantNeighborIndices.push_back(0); - relevantNeighborIndices.push_back(1); - relevantNeighborIndices.push_back(3); - relevantNeighborIndices.push_back(4); - } else if (ray.xDir() < 0 && ray.yDir() > 0 && ray.zDir() < 0) { - // -x, +y, -z - relevantNeighborIndices.push_back(0); - relevantNeighborIndices.push_back(1); - relevantNeighborIndices.push_back(3); - relevantNeighborIndices.push_back(4); - } else if (ray.xDir() < 0 && ray.yDir() < 0 && ray.zDir() > 0) { - // -x, -y, +z - relevantNeighborIndices.push_back(18); - relevantNeighborIndices.push_back(9); - } else if (ray.xDir() < 0 && ray.yDir() > 0 && ray.zDir() > 0) { - // -x, +y, +z - relevantNeighborIndices.push_back(18); - relevantNeighborIndices.push_back(21); - } - } - - /*size_t dirAbsoluteMaxIndex = ray.getDirection().indexOfMax(); - if (dirAbsoluteMaxIndex == 2) { - if (ray.zDir() < 0) { - if (ray.xDir() > 0) { - relevantNeighborIndices = {13, 0, 1, 2, 3, 4, 5, 6, 7, 8}; - } else { - relevantNeighborIndices = {9, 10, 11, 12, 13, 14, 15, 16, 17}; - } - } else { - relevantNeighborIndices = {13, 0, 1, 2, 3, 4, 5, 6, 7, 8}; - } - } else if (dirAbsoluteMaxIndex == 1) { - relevantNeighborIndices = {0, 1, 2, 9, 10, 11, 18, 19, 20}; - } else if (dirAbsoluteMaxIndex == 0) { - relevantNeighborIndices = {0, 3, 6, 9, 12, 15, 18, 21, 24}; - }*/ - - /*if (ray.zDir() > 0) { - relevantNeighborIndices = {13, 0, 1, 2, 3, 4, 5, 6, 7, 8}; - } else { - if (ray.xDir() > 0) { - if (ray.yDir() > 0) { - relevantNeighborIndices = {13, 0, 1, 2, 3, 4, 5, 6, 7, 8}; - } else { - relevantNeighborIndices = {9, 10, 11, 12, 13, 14, 15, 16, 17}; - } - } else { - relevantNeighborIndices = {9, 10, 11, 12, 13, 14, 15, 16, 17}; - } - } - - if (ray.getImageX() == 464 && ray.getImageY() == 24) { - int n = -1; - for (uint i = 0; i < 27; ++i) { - const Cell* nbCell = ¢erCell + centerCell.neighborOffset_[i]; - const BodyVector* nbBodies = nbCell->bodies_; - - if (nbBodies != NULL) { - for (const BodyID& cellBody: *nbBodies) { - HashGrids::intersectionTestCount++; - bool intersects = SingleCast<BodyTuple, raytracing::IntersectsFunctor, bool>::execute(cellBody, intersectsFunc); - if (intersects && t_local < t_closest) { - body = cellBody; - t_closest = t_local; - n_closest = n_local; - n = int(i); - } - } - } - } - if (n != -1) { - WALBERLA_LOG_INFO(ray.getDirection()); - WALBERLA_LOG_INFO(" -> " << n); - } - }*/ - - //relevantNeighborIndices = {0,1,3,4, 9,10,12,13, 18,19,21,22}; - - relevantNeighborIndices = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26 - }; - - std::stringstream raySignsStream; - if (ray.xDir() < 0) { - raySignsStream << "-"; - } else { - raySignsStream << "+"; - } - if (ray.yDir() < 0) { - raySignsStream << "-"; - } else { - raySignsStream << "+"; - } - if (ray.zDir() < 0) { - raySignsStream << "-"; - } else { - raySignsStream << "+"; - } - - int n = -1; - for (uint i = 0; i < relevantNeighborIndices.size(); ++i) { - const Cell* nbCell = ¢erCell + centerCell.neighborOffset_[relevantNeighborIndices[i]]; - const BodyVector* nbBodies = nbCell->bodies_; - - if (nbBodies != NULL) { - for (const BodyID& cellBody: *nbBodies) { - HashGrids::intersectionTestCount++; - bool intersects = SingleCast<BodyTuple, raytracing::IntersectsFunctor, bool>::execute(cellBody, intersectsFunc); - if (intersects && t_local < t_closest) { - body = cellBody; - t_closest = t_local; - n_closest = n_local; - n = relevantNeighborIndices[size_t(i)]; - } - } - } - } - - if (n != -1) { - HashGrids::raySignsCellNeighborMap[raySignsStream.str()].insert(n); - } - -/*#ifndef HASHGRIDS_RAYTRACING_CHECK_ALL_NEIGHBORS - // neighbors whose objects might protrude into center cell: - std::vector<uint> relevantNeighborIndices = {0, 1, 3, 4, 9, 10, 12, 13}; -#else - std::vector<uint> relevantNeighborIndices = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26 - }; -#endif - - if (ray.xDir() > 0 && ray.yDir() < 0 && ray.zDir() < 0) { - // x pos, y neg, z neg - relevantNeighborIndices.push_back(2); // 1/-1/-1 - relevantNeighborIndices.push_back(5); // 1/ 0/-1 - } else if (ray.xDir() > 0 && ray.yDir() > 0 && ray.zDir() < 0) { - // x pos, y pos, z neg - relevantNeighborIndices.push_back(2); // 1/-1/-1 - relevantNeighborIndices.push_back(8); // 1/ 1/-1 - relevantNeighborIndices.push_back(5); // 1/ 0/-1 - relevantNeighborIndices.push_back(7); // 0/ 1/-1 - relevantNeighborIndices.push_back(6); // -1/ 1/-1 - } else if (ray.xDir() < 0 && ray.yDir() > 0 && ray.zDir() < 0) { - // x neg, y pos, z neg - relevantNeighborIndices.push_back(7); // 0/ 1/-1 - relevantNeighborIndices.push_back(6); // -1/ 1/-1 - relevantNeighborIndices.push_back(15);// -1/ 1/ 0 - } else if (ray.xDir() < 0 && ray.yDir() > 0 && ray.zDir() > 0) { - // x neg, y pos, z pos - relevantNeighborIndices.push_back(15); - relevantNeighborIndices.push_back(21); - relevantNeighborIndices.push_back(24); - relevantNeighborIndices.push_back(25); - } else if (ray.xDir() > 0 && ray.yDir() > 0 && ray.zDir() > 0) { - // x pos, y pos, z pos - relevantNeighborIndices.push_back(25); - relevantNeighborIndices.push_back(23); - relevantNeighborIndices.push_back(20); - } else if (ray.xDir() > 0 && ray.yDir() < 0 && ray.zDir() > 0) { - // x pos, y neg, z pos - relevantNeighborIndices.push_back(20); - relevantNeighborIndices.push_back(23); - } else if (ray.xDir() < 0 && ray.yDir() < 0 && ray.zDir() > 0) { - // x neg, y neg, z pos - relevantNeighborIndices.push_back(18); - } - - int n = -1; - for (uint i = 0; i < relevantNeighborIndices.size(); ++i) { - const Cell* nbCell = ¢erCell + centerCell.neighborOffset_[relevantNeighborIndices[i]]; + for (uint i = 0; i < 27; ++i) { + const Cell* nbCell = ¢erCell + centerCell.neighborOffset_[i]; const BodyVector* nbBodies = nbCell->bodies_; if (nbBodies != NULL) { @@ -787,13 +538,10 @@ const BodyID HashGrids::HashGrid::getBodyIntersectionForBlockCell(const Vector3< body = cellBody; t_closest = t_local; n_closest = n_local; - n = int(relevantNeighborIndices[i]); } } } } - */ - //if (n != -1) WALBERLA_LOG_INFO("raydir: " << ray.getDirection() << ", cell for intersection: " << n << ", body: " << body->getID()); return body; } @@ -812,7 +560,7 @@ const BodyID HashGrids::HashGrid::getBodyIntersectionForBlockCell(const Vector3< */ template<typename BodyTuple> BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, const AABB& blockAABB, - real_t& t_closest, Vec3& n_closest) { + real_t& t_closest, Vec3& n_closest) const { const real_t inf = std::numeric_limits<real_t>::max(); BodyID body_local = NULL; @@ -827,9 +575,6 @@ BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, c //WALBERLA_LOG_INFO("cellspan: " << cellSpan_ << " lims: " << blockXCellCountMin << " " << blockXCellCountMax); - int8_t blockCellNormalAxis = BLOCKCELL_NORMAL_INDETERMINATE; - int8_t blockCellNormalDir = 0; - Vec3 firstPoint; if (blockAABB.contains(ray.getOrigin(), cellSpan_)) { firstPoint = ray.getOrigin(); @@ -839,14 +584,6 @@ BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, c if (intersects(blockAABB, ray, t_start, cellSpan_, &firstPointNormal)) { firstPoint = ray.getOrigin() + ray.getDirection()*t_start; firstPoint -= firstPointNormal * (cellSpan_/real_t(2)); - - if (realIsEqual(firstPointNormal.max(), real_t(0))) { - blockCellNormalAxis = int8_t(firstPointNormal.indexOfMin()); - blockCellNormalDir = -1; - } else { - blockCellNormalAxis = int8_t(firstPointNormal.indexOfMax()); - blockCellNormalDir = 1; - } } else { //WALBERLA_LOG_INFO("ray does not intersect block") return NULL; @@ -875,7 +612,6 @@ BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, c Vector3<int32_t> currentCell = firstCell; - // First cell needs extra treatment, as it might lay out of the blocks upper bounds // due to the nature of how it is calculated: If the first point lies on a upper border // it maps to the cell "above" the grid. @@ -883,7 +619,7 @@ BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, c currentCell[1] < blockYCellCountMax && currentCell[2] < blockZCellCountMax) { //WALBERLA_LOG_INFO("found block cell at " << currentCell); - body_local = getBodyIntersectionForBlockCell<BodyTuple>(currentCell, blockCellNormalAxis, blockCellNormalDir, + body_local = getBodyIntersectionForBlockCell<BodyTuple>(currentCell, blockAABB, ray, t_closest, n_closest); if (body_local != NULL) { @@ -896,16 +632,12 @@ BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, c if (tMaxX < tMaxZ) { tMaxX += tDeltaX; currentCell[0] += stepX; - blockCellNormalAxis = 0; - blockCellNormalDir = -stepX; if (currentCell[0] >= blockXCellCountMax || currentCell[0] < blockXCellCountMin) { break; } } else { tMaxZ += tDeltaZ; currentCell[2] += stepZ; - blockCellNormalAxis = 2; - blockCellNormalDir = -stepZ; if (currentCell[2] >= blockZCellCountMax || currentCell[2] < blockZCellCountMin) { break; } @@ -914,16 +646,12 @@ BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, c if (tMaxY < tMaxZ) { tMaxY += tDeltaY; currentCell[1] += stepY; - blockCellNormalAxis = 1; - blockCellNormalDir = -stepY; if (currentCell[1] >= blockYCellCountMax || currentCell[1] < blockYCellCountMin) { break; } } else { tMaxZ += tDeltaZ; currentCell[2] += stepZ; - blockCellNormalAxis = 2; - blockCellNormalDir = -stepZ; if (currentCell[2] >= blockZCellCountMax || currentCell[2] < blockZCellCountMin) { break; } @@ -932,7 +660,7 @@ BodyID HashGrids::HashGrid::getRayIntersectingBody(const raytracing::Ray& ray, c //WALBERLA_LOG_INFO("found block cell at " << currentCell); - body_local = getBodyIntersectionForBlockCell<BodyTuple>(currentCell, blockCellNormalAxis, blockCellNormalDir, + body_local = getBodyIntersectionForBlockCell<BodyTuple>(currentCell, blockAABB, ray, t_closest, n_closest); if (body_local != NULL) { diff --git a/src/pe/raytracing/Raytracer.h b/src/pe/raytracing/Raytracer.h index a274e0ba6ce7e756153884496158061af59fc905..27c5d4f3a9e6a29754b836522b21ce9b851de3d2 100644 --- a/src/pe/raytracing/Raytracer.h +++ b/src/pe/raytracing/Raytracer.h @@ -416,15 +416,10 @@ void Raytracer::rayTrace(const size_t timestep, WcTimingTree* tt) { if (tt != NULL) tt->start("Intersection Testing"); for (size_t x = 0; x < pixelsHorizontal_; x++) { for (size_t y = 0; y < pixelsVertical_; y++) { - - //if (!((std::abs(int(x)-345) == 0 && std::abs(int(y)-77) == 0))) continue; - Vec3 pixelLocation = viewingPlaneOrigin_ + u_*(real_c(x)+real_t(0.5))*pixelWidth_ + v_*(real_c(y)+real_t(0.5))*pixelHeight_; Vec3 direction = (pixelLocation - cameraPosition_).getNormalized(); ray.setDirection(direction); - ray.setImageCoordinate(x, y); - n.reset(); t_closest = inf; body_closest = NULL; @@ -491,18 +486,6 @@ void Raytracer::rayTrace(const size_t timestep, WcTimingTree* tt) { #if defined(COMPARE_NAIVE_AND_HASHGRIDS_RAYTRACING) if (body_naive_closest != body_hashgrids_closest && !realIsEqual(t_naive_closest, t_hashgrids_closest)) { - //WALBERLA_LOG_INFO("bodies at " << x << "/" << y << " dont match up: " << t_naive_closest << " <-> " << t_hashgrids_closest); - /*if (body_naive_closest != NULL) { - WALBERLA_LOG_INFO(" naive: " << body_naive_closest->getID() << " @ " << body_naive_closest->getAABB().minCorner()); - } else { - WALBERLA_LOG_INFO(" naive: none"); - } - if (body_hashgrids_closest) { - WALBERLA_LOG_INFO(" hashgrids: " << body_hashgrids_closest->getID() << " @ " << body_hashgrids_closest->getAABB().minCorner()); - } else { - WALBERLA_LOG_INFO(" hashgrids: none"); - } - WALBERLA_LOG_INFO(" ray dir: " << ray.getDirection());*/ problematicBodies.insert(body_naive_closest); problematicHashgridsFoundBodies.insert(body_hashgrids_closest); errors++; @@ -591,7 +574,8 @@ void Raytracer::rayTrace(const size_t timestep, WcTimingTree* tt) { #endif #if defined(COMPARE_NAIVE_AND_HASHGRIDS_RAYTRACING) WALBERLA_LOG_INFO("Performed " << ccd::HashGrids::intersectionTestCount << " intersection tests in hashgrids"); - WALBERLA_LOG_INFO("Saved " << (int(naiveIntersectionTests)-int(ccd::HashGrids::intersectionTestCount)) << " tests (" << ((real_t(1)-real_c(ccd::HashGrids::intersectionTestCount)/real_c(naiveIntersectionTests))*100) << "%).") + WALBERLA_LOG_INFO("Saved " << (int(naiveIntersectionTests)-int(ccd::HashGrids::intersectionTestCount)) << " tests (" << ((real_t(1)-real_c(ccd::HashGrids::intersectionTestCount)/real_c(naiveIntersectionTests))*100) << "%)."); + ccd::HashGrids::intersectionTestCount = 0; #endif if (tt != NULL) tt->start("Reduction"); diff --git a/tests/pe/Raytracing.cpp b/tests/pe/Raytracing.cpp index 97d36770bc573d64326cf8eb11bcc3b6f61e0a31..b071430340dc22aede355ab62180d3b79e99d71d 100644 --- a/tests/pe/Raytracing.cpp +++ b/tests/pe/Raytracing.cpp @@ -270,12 +270,12 @@ void RaytracerTest() { createPlane(*globalBodyStorage, 0, Vec3(-1,1,1), Vec3(8,2,2), iron); // tilted plane in right bottom back corner - SphereID upperLeftSmallSphere = createSphere(*globalBodyStorage, *forest, storageID, 2, Vec3(6,9.5,9.5), real_t(0.5)); + createSphere(*globalBodyStorage, *forest, storageID, 2, Vec3(6,9.5,9.5), real_t(0.5)); createSphere(*globalBodyStorage, *forest, storageID, 3, Vec3(4,5.5,5), real_t(1)); - SphereID leftSphere = createSphere(*globalBodyStorage, *forest, storageID, 6, Vec3(3,8.5,5), real_t(1)); + createSphere(*globalBodyStorage, *forest, storageID, 6, Vec3(3,8.5,5), real_t(1)); BoxID box = createBox(*globalBodyStorage, *forest, storageID, 7, Vec3(5,6.5,5), Vec3(2,4,3)); if (box != NULL) box->rotate(0,math::M_PI/4,math::M_PI/4); - BoxID upperRightBox = createBox(*globalBodyStorage, *forest, storageID, 8, Vec3(5,1,8), Vec3(2,2,2)); + createBox(*globalBodyStorage, *forest, storageID, 8, Vec3(5,1,8), Vec3(2,2,2)); // Test scene v1 end // Test scene v2 additions start @@ -285,51 +285,6 @@ void RaytracerTest() { if (capsule != NULL) capsule->rotate(0,math::M_PI/3,math::M_PI/4-math::M_PI/8); // Test scene v2 end - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - ccd::HashGrids* hashgrids = blockIt->getData<ccd::HashGrids>(ccdID); - hashgrids->update(); - } - - WALBERLA_LOG_INFO("--- UPPER LEFT SMALL SPHERE"); - WALBERLA_LOG_INFO(" hash: " << upperLeftSmallSphere->getHash()); - WALBERLA_LOG_INFO(" grid: " << upperLeftSmallSphere->getGrid()); - WALBERLA_LOG_INFO(" AABB: " << upperLeftSmallSphere->getAABB()); - WALBERLA_LOG_INFO("--- LEFT SPHERE"); - WALBERLA_LOG_INFO(" hash: " << leftSphere->getHash()); - WALBERLA_LOG_INFO(" grid: " << leftSphere->getGrid()); - WALBERLA_LOG_INFO(" AABB: " << leftSphere->getAABB()); - WALBERLA_LOG_INFO("--- UPPER RIGHT BOX"); - WALBERLA_LOG_INFO(" hash: " << upperRightBox->getHash()); - WALBERLA_LOG_INFO(" grid: " << upperRightBox->getGrid()); - WALBERLA_LOG_INFO(" AABB: " << upperRightBox->getAABB()); - - /*Ray ray(Vec3(-5, 6.5, 5), Vec3(1, 0, 0)); - real_t t = INFINITY; - Vec3 n; - BodyID body = NULL;*/ - - // output info about grids - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - ccd::HashGrids* hashgrids = blockIt->getData<ccd::HashGrids>(ccdID); - for (auto grid: hashgrids->gridList_) { - WALBERLA_LOG_INFO("--- GRID " << grid << " ---"); - WALBERLA_LOG_INFO(" cellSpan: " << grid->getCellSpan()); - WALBERLA_LOG_INFO(" dims: " << grid->xCellCount_ << "/" << grid->yCellCount_ << "/" << grid->zCellCount_); - WALBERLA_LOG_INFO(" items: " << grid->bodyCount_); - WALBERLA_LOG_INFO(" enlargement threshold: " << grid->enlargementThreshold_); - //WALBERLA_LOG_INFO(" offsets: ") - //for (int i = 0; i < 27; i++) { - // WALBERLA_LOG_INFO(" " << i << ": " << grid->stdNeighborOffset_[i]); - //} - } - /*body = hashgrids->getClosestBodyIntersectingWithRay<BodyTuple>(ray, blockIt->getAABB(), t, n); - if (body != NULL) { - WALBERLA_LOG_INFO("body found"); - } else { - WALBERLA_LOG_INFO("body not found"); - }*/ - } - //raytracer.setTBufferOutputDirectory("tbuffer"); //raytracer.setTBufferOutputEnabled(true); raytracer.setImageOutputDirectory("image"); @@ -430,91 +385,6 @@ void RaytracerSpheresTest() { raytracer.rayTrace<BodyTuple>(1); } -void hashgridsPlayground() { - /*using namespace walberla::pe::ccd; - - shared_ptr<BodyStorage> globalBodyStorage = make_shared<BodyStorage>(); - shared_ptr<BlockForest> forest = createBlockForest(AABB(-2,-2,-2,2,2,2), Vec3(1,1,1), Vec3(false, false, false)); - auto storageID = forest->addBlockData(createStorageDataHandling<BodyTuple>(), "Storage"); - HashGrids::HashGrid hashgrid(1.0); // initialize a 4x4x4 hashgrid with cellspan 1.0 (can hold a block with 4x4x4 in size.) - - std::vector<Vec3> centers = { - Vec3(-0.25, -0.75, 0.5), - Vec3(0.5, -0.5, 0.5), - Vec3(-0.25, -0.75, 0.5), - Vec3(1.25, -0.25, 0.5), - Vec3(-1.25, 0.25, 0.5) - }; - std::vector<Vec3> lengths = { - Vec3(1, 1, 1), - Vec3(0.5, 0.5, 0.5), - Vec3(0.5, 0.5, 0.5), - Vec3(1, 1, 1), - Vec3(1, 1, 1) - }; - - for (size_t i = 0; i < centers.size(); i++) { - BoxID box = createBox(*globalBodyStorage, *forest, storageID, walberla::id_t(i), centers[i], lengths[i]); - hashgrid.add(box); - WALBERLA_LOG_INFO("Box " << box->getID() << " at " << centers[i] << " hashed with " << box->getHash()); - } - - WALBERLA_LOG_INFO("domain: " << forest->getDomain()); - - real_t inf = std::numeric_limits<real_t>::max(); - - BodyID closestBody = NULL; - real_t t_closest = inf; - real_t t; - Vec3 n; - - std::vector<Ray> rays = { - Ray(Vec3(-2.5, -1.25, 0.5), Vec3(20, 7, 0).getNormalized()), - Ray(Vec3(1.5, -0.5, 0.5), Vec3(-20, -7, 0).getNormalized()), - Ray(Vec3(-2.25, 1.75, 0.5), Vec3(1, -1, 0).getNormalized()) - }; - - int i = 0; - for (const Ray& ray: rays) { - closestBody = NULL; - t_closest = inf; - - WALBERLA_LOG_INFO("--- ray " << i << ": " << ray.getOrigin() << ", " << ray.getDirection()); - - std::vector<BodyID> bodiesContainer; - hashgrid.possibleRayIntersectingBodies(ray, forest->getDomain(), bodiesContainer); - - WALBERLA_LOG_INFO("Resulting bodies:"); - IntersectsFunctor intersectsFunc(ray, t, n); - for (BodyID const& body : bodiesContainer) { - bool intersects = SingleCast<BodyTuple, IntersectsFunctor, bool>::execute(body, intersectsFunc); - if (intersects && t < t_closest) { - closestBody = body; - t_closest = t; - } - std::cout << body->getID() << " "; - } - std::cout << std::endl; - - if (closestBody != NULL) { - WALBERLA_LOG_INFO("closest: " << closestBody->getID() << " with t = " << t_closest); - } else { - WALBERLA_LOG_INFO("could not find closest body"); - } - - closestBody = NULL; - t_closest = inf; - - closestBody = hashgrid.getRayIntersectingBody<BodyTuple>(ray, forest->getDomain(), t, n); - if (closestBody == NULL) { - WALBERLA_LOG_INFO("couldnt find closest body with direct resolution"); - } else { - WALBERLA_LOG_INFO("closest with direct resolution: " << closestBody->getID() << " with t = " << t); - } - i++; - }*/ -} - ShadingParameters customHashgridsBodyToShadingParams(const BodyID body) { switch (body->getID()) { case 96: @@ -533,7 +403,7 @@ ShadingParameters customHashgridsBodyToShadingParams(const BodyID body) { } -void HashGridsTest(size_t boxes, size_t capsules, size_t spheres, +void HashGridsTest(size_t boxes, size_t capsules, size_t spheres, size_t numberOfViews = 1, real_t boxLenMin = 0.1, real_t boxLenMax = 0.2, bool boxRotation = false, real_t capRadiusMin = 0.1, real_t capRadiusMax = 0.2, real_t capLenMin = 0.1, real_t capLenMax = 0.3, real_t sphereRadiusMin = 0.1, real_t sphereRadiusMax = 0.3) { @@ -557,23 +427,12 @@ void HashGridsTest(size_t boxes, size_t capsules, size_t spheres, auto storageID = forest->addBlockData(createStorageDataHandling<BodyTuple>(), "Storage"); auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling(globalBodyStorage, storageID), "CCD"); - std::vector<IBlock*> blocks; - forest->getBlocks(blocks); - //for (auto block: blocks) { - // WALBERLA_LOG_INFO("block AABB: " << block->getAABB()); - //} - const AABB& forestAABB = forest->getDomain(); bool removeUnproblematic = false; std::vector<walberla::id_t> problematicBodyIDs = {165, 5, 31}; //{50, 44, 66, 155, 170, 51}; std::vector<walberla::id_t> bodySIDs; - //WALBERLA_LOG_INFO("boxCount: " << boxCount); - //WALBERLA_LOG_INFO("capsuleCount: " << capsuleCount); - - //BoxID box = createBox(*globalBodyStorage, *forest, storageID, 1000, Vec3(2.1, 0.5, 0.5), Vec3(0.25, 0.25, 0.25)); - // generate bodies for test std::vector<BodyID> bodies; for (size_t i = 0; i < boxes; i++) { @@ -639,8 +498,6 @@ void HashGridsTest(size_t boxes, size_t capsules, size_t spheres, createPlane(*globalBodyStorage, 0, Vec3(1,0,0), Vec3(forestAABB.xMin(),0,0), iron); // front wall, should not get rendered - //createBox(*globalBodyStorage, *forest, storageID, boxCount+capsuleCount+1, Vec3(2, 2, 2), Vec3(1, 1, 1)); - std::vector<std::tuple<Vec3, Vec3, Vec3>> vectors; // y up, in negative z direction @@ -693,6 +550,10 @@ void HashGridsTest(size_t boxes, size_t capsules, size_t spheres, int i = 0; for (auto& vector: vectors) { + if (i == numberOfViews) { + break; + } + Raytracer raytracer(forest, storageID, globalBodyStorage, ccdID, size_t(640), size_t(480), 49.13, @@ -714,28 +575,14 @@ void HashGridsTest(size_t boxes, size_t capsules, size_t spheres, #endif raytracer.setImageOutputEnabled(true); raytracer.setFilenameTimestepWidth(12); - WALBERLA_LOG_INFO("output #" << i << " to: " << (boxes*100000000 + capsules*10000 + spheres)); + WALBERLA_LOG_INFO("output #" << i << " to: " << (boxes*100000000 + capsules*10000 + spheres) << " in " << raytracer.getImageOutputDirectory()); raytracer.rayTrace<BodyTuple>(boxes*100000000 + capsules*10000 + spheres, &tt); i++; } - /*HashGrids::HashGrid* grid; - for (auto bodyId: problematicBodyIDs) { - BodyID body = getBody(*globalBodyStorage, *forest, storageID, bodySIDs[bodyId]); - //WALBERLA_LOG_INFO(box); - WALBERLA_LOG_INFO("--- BODY " << bodyId << " ---"); - WALBERLA_LOG_INFO("minCorner " << bodyId << ": " << body->getAABB().minCorner()); - WALBERLA_LOG_INFO("hash " << bodyId << ": " << body->getHash()); - WALBERLA_LOG_INFO("cell " << bodyId << ": " << body->getCellId()); - WALBERLA_LOG_INFO("grid " << bodyId << ": " << body->getGrid()); - grid = (HashGrids::HashGrid*)body->getGrid(); - } - WALBERLA_CHECK(grid != NULL); - WALBERLA_LOG_INFO("grid dims: " << grid->xCellCount_ << "/" << grid->yCellCount_ << "/" << grid->zCellCount_);*/ - auto temp = tt.getReduced(); WALBERLA_ROOT_SECTION() { - //std::cout << temp; + std::cout << temp; } } @@ -746,31 +593,6 @@ ShadingParameters customArtifactsBodyToShadingParams(const BodyID body) { return defaultShadingParams(body); } -void printHashgridsRaySignsCellNeighborMap(){ - std::stringstream text; - for (auto it: walberla::pe::ccd::HashGrids::raySignsCellNeighborMap) { - text << it.first << ": "; - int lastn = -1; - for (size_t n: it.second) { - if (n >= 10 && lastn < 10 && n-1 != lastn) { - text << " "; - } - while (int(n)-1 > lastn) { - if (lastn < 10) { - text << " "; - } else { - text << " "; - } - lastn++; - } - lastn = int(n); - text << n << " "; - } - text << std::endl; - } - WALBERLA_LOG_INFO(text.str()); -} - void HashGridsArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, real_t boxLenMax = 0.2) { #if defined(USE_NAIVE_INTERSECTION_FINDING) WALBERLA_LOG_INFO("Using naive method for intersection testing"); @@ -792,23 +614,8 @@ void HashGridsArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, real_t boxLenM auto storageID = forest->addBlockData(createStorageDataHandling<BodyTuple>(), "Storage"); auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling(globalBodyStorage, storageID), "CCD"); - std::vector<IBlock*> blocks; - forest->getBlocks(blocks); - //for (auto block: blocks) { - // WALBERLA_LOG_INFO("block AABB: " << block->getAABB()); - //} - const AABB& forestAABB = forest->getDomain(); - bool removeUnproblematic = false; - std::vector<walberla::id_t> problematicBodyIDs = {165, 5, 31}; //{50, 44, 66, 155, 170, 51}; - std::vector<walberla::id_t> bodySIDs; - - //WALBERLA_LOG_INFO("boxCount: " << boxCount); - //WALBERLA_LOG_INFO("capsuleCount: " << capsuleCount); - - //BoxID box = createBox(*globalBodyStorage, *forest, storageID, 1000, Vec3(2.1, 0.5, 0.5), Vec3(0.25, 0.25, 0.25)); - // generate bodies for test std::vector<BodyID> bodies; for (size_t i = 0; i < boxes; i++) { @@ -834,17 +641,6 @@ void HashGridsArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, real_t boxLenM BoxID box_ = createBox(*globalBodyStorage, *forest, storageID, id, Vec3(x_min, y_min, z_min), Vec3(len, len, len)); WALBERLA_CHECK(box_ != NULL); bodies.push_back(box_); - bodySIDs.push_back(box_->getSystemID()); - } - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - ccd::HashGrids* hashgrids = blockIt->getData<ccd::HashGrids>(ccdID); - hashgrids->update(); - for (auto bodyIt = LocalBodyIterator::begin(*blockIt, storageID); bodyIt != LocalBodyIterator::end(); ++bodyIt) { - if (removeUnproblematic && std::find(problematicBodyIDs.begin(), problematicBodyIDs.end(), bodyIt->getID()) == problematicBodyIDs.end()) { - bodyIt->setPosition(-100, -100, -100); - } - } } /*MaterialID iron = Material::find("iron"); @@ -856,10 +652,6 @@ void HashGridsArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, real_t boxLenM createPlane(*globalBodyStorage, 0, Vec3(1,0,0), Vec3(forestAABB.xMin(),0,0), iron); // front wall, should not get rendered */ - //createBox(*globalBodyStorage, *forest, storageID, boxCount+capsuleCount+1, Vec3(2, 2, 2), Vec3(1, 1, 1)); - - - Lighting lighting(Vec3(forestAABB.xSize()/real_t(2)+1, forestAABB.ySize()/real_t(2), real_t(2)*forestAABB.zMax()+2), // 8, 5, 9.5 gut für ebenen, 0,5,8 Color(1, 1, 1), //diffuse @@ -887,44 +679,12 @@ void HashGridsArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, real_t boxLenM raytracer.setImageOutputEnabled(true); raytracer.setFilenameTimestepWidth(4); tt.stop("Setup"); - WALBERLA_LOG_INFO("output to: " << boxes); + WALBERLA_LOG_INFO("output to: " << boxes << " in " << raytracer.getImageOutputDirectory()); raytracer.rayTrace<BodyTuple>(boxes, &tt); - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - ccd::HashGrids* hashgrids = blockIt->getData<ccd::HashGrids>(ccdID); - for (auto grid: hashgrids->gridList_) { - WALBERLA_LOG_INFO("--- GRID " << grid << " ---"); - WALBERLA_LOG_INFO(" cellSpan: " << grid->getCellSpan()); - WALBERLA_LOG_INFO(" dims: " << grid->xCellCount_ << "/" << grid->yCellCount_ << "/" << grid->zCellCount_); - WALBERLA_LOG_INFO(" items: " << grid->bodyCount_); - WALBERLA_LOG_INFO(" enlargement threshold: " << grid->enlargementThreshold_); - WALBERLA_LOG_INFO(" xCellCount: " << grid->xCellCount_); - WALBERLA_LOG_INFO(" xyCellCount: " << grid->xyCellCount_); - WALBERLA_LOG_INFO(" xyzCellCount: " << grid->xyzCellCount_); - //WALBERLA_LOG_INFO(" offsets: ") - //for (int i = 0; i < 27; i++) { - // WALBERLA_LOG_INFO(" " << i << ": " << grid->stdNeighborOffset_[i]); - //} - } - } - - /*HashGrids::HashGrid* grid; - for (auto bodyId: problematicBodyIDs) { - BodyID body = getBody(*globalBodyStorage, *forest, storageID, bodySIDs[bodyId]); - //WALBERLA_LOG_INFO(box); - WALBERLA_LOG_INFO("--- BODY " << bodyId << " ---"); - WALBERLA_LOG_INFO("minCorner " << bodyId << ": " << body->getAABB().minCorner()); - WALBERLA_LOG_INFO("hash " << bodyId << ": " << body->getHash()); - WALBERLA_LOG_INFO("cell " << bodyId << ": " << body->getCellId()); - WALBERLA_LOG_INFO("grid " << bodyId << ": " << body->getGrid()); - grid = (HashGrids::HashGrid*)body->getGrid(); - } - WALBERLA_CHECK(grid != NULL); - WALBERLA_LOG_INFO("grid dims: " << grid->xCellCount_ << "/" << grid->yCellCount_ << "/" << grid->zCellCount_);*/ - auto temp = tt.getReduced(); WALBERLA_ROOT_SECTION() { - //std::cout << temp; + std::cout << temp; } } @@ -949,23 +709,12 @@ void HashGridsFromNegativeArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, re auto storageID = forest->addBlockData(createStorageDataHandling<BodyTuple>(), "Storage"); auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling(globalBodyStorage, storageID), "CCD"); - std::vector<IBlock*> blocks; - forest->getBlocks(blocks); - //for (auto block: blocks) { - // WALBERLA_LOG_INFO("block AABB: " << block->getAABB()); - //} - const AABB& forestAABB = forest->getDomain(); bool removeUnproblematic = false; std::vector<walberla::id_t> problematicBodyIDs = {165, 5, 31}; //{50, 44, 66, 155, 170, 51}; std::vector<walberla::id_t> bodySIDs; - - //WALBERLA_LOG_INFO("boxCount: " << boxCount); - //WALBERLA_LOG_INFO("capsuleCount: " << capsuleCount); - - //BoxID box = createBox(*globalBodyStorage, *forest, storageID, 1000, Vec3(2.1, 0.5, 0.5), Vec3(0.25, 0.25, 0.25)); - + // generate bodies for test std::vector<BodyID> bodies; for (size_t i = 0; i < boxes; i++) { @@ -1013,10 +762,6 @@ void HashGridsFromNegativeArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, re createPlane(*globalBodyStorage, 0, Vec3(1,0,0), Vec3(forestAABB.xMin(),0,0), iron); // front wall, should not get rendered */ - //createBox(*globalBodyStorage, *forest, storageID, boxCount+capsuleCount+1, Vec3(2, 2, 2), Vec3(1, 1, 1)); - - - Lighting lighting(Vec3(3, 2, -4), // 8, 5, 9.5 gut für ebenen, 0,5,8 Color(1, 1, 1), //diffuse Color(1, 1, 1), //specular @@ -1043,31 +788,15 @@ void HashGridsFromNegativeArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, re raytracer.setImageOutputEnabled(true); raytracer.setFilenameTimestepWidth(5); tt.stop("Setup"); - WALBERLA_LOG_INFO("output to: " << boxes); + WALBERLA_LOG_INFO("output to: " << boxes << " in " << raytracer.getImageOutputDirectory()); raytracer.rayTrace<BodyTuple>(boxes, &tt); - - /*HashGrids::HashGrid* grid; - for (auto bodyId: problematicBodyIDs) { - BodyID body = getBody(*globalBodyStorage, *forest, storageID, bodySIDs[bodyId]); - //WALBERLA_LOG_INFO(box); - WALBERLA_LOG_INFO("--- BODY " << bodyId << " ---"); - WALBERLA_LOG_INFO("minCorner " << bodyId << ": " << body->getAABB().minCorner()); - WALBERLA_LOG_INFO("hash " << bodyId << ": " << body->getHash()); - WALBERLA_LOG_INFO("cell " << bodyId << ": " << body->getCellId()); - WALBERLA_LOG_INFO("grid " << bodyId << ": " << body->getGrid()); - grid = (HashGrids::HashGrid*)body->getGrid(); - } - WALBERLA_CHECK(grid != NULL); - WALBERLA_LOG_INFO("grid dims: " << grid->xCellCount_ << "/" << grid->yCellCount_ << "/" << grid->zCellCount_);*/ - auto temp = tt.getReduced(); WALBERLA_ROOT_SECTION() { - //std::cout << temp; + std::cout << temp; } } - void HashGridsFromNegativeXArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, real_t boxLenMax = 0.2) { #if defined(USE_NAIVE_INTERSECTION_FINDING) WALBERLA_LOG_INFO("Using naive method for intersection testing"); @@ -1089,23 +818,12 @@ void HashGridsFromNegativeXArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, r auto storageID = forest->addBlockData(createStorageDataHandling<BodyTuple>(), "Storage"); auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling(globalBodyStorage, storageID), "CCD"); - std::vector<IBlock*> blocks; - forest->getBlocks(blocks); - //for (auto block: blocks) { - // WALBERLA_LOG_INFO("block AABB: " << block->getAABB()); - //} - const AABB& forestAABB = forest->getDomain(); bool removeUnproblematic = false; std::vector<walberla::id_t> problematicBodyIDs = {165, 5, 31}; //{50, 44, 66, 155, 170, 51}; std::vector<walberla::id_t> bodySIDs; - //WALBERLA_LOG_INFO("boxCount: " << boxCount); - //WALBERLA_LOG_INFO("capsuleCount: " << capsuleCount); - - //BoxID box = createBox(*globalBodyStorage, *forest, storageID, 1000, Vec3(2.1, 0.5, 0.5), Vec3(0.25, 0.25, 0.25)); - // generate bodies for test std::vector<BodyID> bodies; for (size_t i = 0; i < boxes; i++) { @@ -1170,12 +888,12 @@ void HashGridsFromNegativeXArtifactsTest(size_t boxes, real_t boxLenMin = 0.1, r raytracer.setImageOutputEnabled(true); raytracer.setFilenameTimestepWidth(6); tt.stop("Setup"); - WALBERLA_LOG_INFO("output to: " << boxes); + WALBERLA_LOG_INFO("output to: " << boxes << " in " << raytracer.getImageOutputDirectory()); raytracer.rayTrace<BodyTuple>(boxes, &tt); auto temp = tt.getReduced(); WALBERLA_ROOT_SECTION() { - //std::cout << temp; + std::cout << temp; } } @@ -1209,13 +927,7 @@ void HashGridsTestScene() { // create bodies size_t id = 0; - real_t len = 2; - //bodies.push_back(createBox(*globalBodyStorage, *forest, storageID, ++id, minCornerToGpos(Vec3(1.1, 1.1, 1.1), len), Vec3(len, len, len))); - len = 0.6; - //bodies.push_back(createBox(*globalBodyStorage, *forest, storageID, ++id, minCornerToGpos(Vec3(0.6, 0.5, 0.5), len), Vec3(len, len, len))); - //bodies.push_back(createBox(*globalBodyStorage, *forest, storageID, ++id, minCornerToGpos(Vec3(1.7, 0.5, 0.5), len), Vec3(len, len, len))); - //bodies.push_back(createBox(*globalBodyStorage, *forest, storageID, ++id, minCornerToGpos(Vec3(7.2, 0.5, 0.5), len), Vec3(len, len, len))); - //bodies.push_back(createBox(*globalBodyStorage, *forest, storageID, ++id, minCornerToGpos(Vec3(5, 0.5, 0.5), len), Vec3(len, len, len))); + real_t len = 0.6; real_t x_min = 0, y_min = 0; len = 1.2; @@ -1253,21 +965,12 @@ void HashGridsTestScene() { } } - // update hashgrids + /*// update hashgrids for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { ccd::HashGrids* hashgrids = blockIt->getData<ccd::HashGrids>(ccdID); hashgrids->update(); } - // output info about bodies - /*for (auto body: bodies) { - WALBERLA_LOG_INFO("--- BODY " << body->getID() << " ---"); - WALBERLA_LOG_INFO(" corners: " << body->getAABB().minCorner() << ", " << body->getAABB().maxCorner()); - WALBERLA_LOG_INFO(" hash: " << body->getHash()); - //WALBERLA_LOG_INFO(" body index: " << body->getCellId()); - WALBERLA_LOG_INFO(" grid: " << body->getGrid()); - }*/ - // output info about grids for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { ccd::HashGrids* hashgrids = blockIt->getData<ccd::HashGrids>(ccdID); @@ -1278,24 +981,7 @@ void HashGridsTestScene() { WALBERLA_LOG_INFO(" items: " << grid->bodyCount_); WALBERLA_LOG_INFO(" enlargement threshold: " << grid->enlargementThreshold_); } - } - - - /*Ray ray(Vec3(4,4,10), Vec3(0,0,-1)); - real_t t; - Vec3 n; - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) { - ccd::HashGrids* hashgrids = blockIt->getData<ccd::HashGrids>(ccdID); - BodyID body = hashgrids->getClosestBodyIntersectingWithRay<BodyTuple>(ray, blockIt->getAABB(), t, n); - if (body != NULL) { - WALBERLA_LOG_INFO("found body " << body->getID() << ", t = " << t); - WALBERLA_LOG_INFO(" hash: " << body->getHash()); - WALBERLA_LOG_INFO(" grid: " << body->getGrid()); - } else { - WALBERLA_LOG_INFO("did not find body"); - } - }*/ + }*/ std::vector<Raytracer> raytracers; @@ -1398,7 +1084,7 @@ void HashGridsTestScene() { raytracer.setImageOutputEnabled(true); raytracer.setFilenameTimestepWidth(3); - WALBERLA_LOG_INFO("output to: " << i); + WALBERLA_LOG_INFO("output to: " << i << " in " << raytracer.getImageOutputDirectory()); raytracer.rayTrace<BodyTuple>(size_t(i), &tt); @@ -1428,35 +1114,32 @@ int main( int argc, char** argv ) std::vector<size_t> spheres = {0, 50, 40, 120}; for (size_t i = 0; i < boxes.size(); ++i) { - //HashGridsTest(boxes[i], capsules[i], spheres[i]); + HashGridsTest(boxes[i], capsules[i], spheres[i], 3); } //HashGridsTest(boxes[0], capsules[0], spheres[0]); - HashGridsTest(60, 60, 3, - 0.1, 0.3, true, - 0.1, 0.2, 0.1, 0.2, - 0.5, 0.6); + //HashGridsTest(60, 60, 3, 1, + // 0.1, 0.3, true, + // 0.1, 0.2, 0.1, 0.2, + // 0.5, 0.6); - HashGridsTest(400, 0, 0, - 0.2, 0.4); + //HashGridsTest(400, 0, 0, 1, + // 0.2, 0.4); - HashGridsTest(750, 0, 0, - 0.2, 0.3); + //HashGridsTest(750, 0, 0, 1, + // 0.2, 0.3); - HashGridsTest(400, 0, 0, - 0.1, 0.3); + //HashGridsTest(400, 0, 0, 1, + // 0.1, 0.3); HashGridsArtifactsTest(750, 0.2, 0.3); - HashGridsFromNegativeArtifactsTest(750, 0.2, 0.3); + //HashGridsFromNegativeArtifactsTest(750, 0.2, 0.3); HashGridsFromNegativeXArtifactsTest(750, 0.2, 0.3); - printHashgridsRaySignsCellNeighborMap(); - - //HashGridsTest(); - - //hashgridsPlayground(); + HashGridsTest(9999, 0, 4000, 1, + 0.1, 0.2); return EXIT_SUCCESS; }