Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix moving particle domain support and single particle crash #3529

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/vapor/NavigationUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ class RENDER_API NavigationUtils : public Wasp::MyBase {
private:
static void propagateTimestep(ControlExec *ce, size_t ts);
static void handleMovingDomainAdjustments(ControlExec *ce, size_t ts_from, size_t ts_to);
static std::tuple<glm::vec3, glm::vec3> getDomainExtentsAtTimestep(ControlExec *ce, const std::string &dataset, size_t ts);
static glm::vec3 getDomainMovementBetweenTimesteps(ControlExec *ce, std::string dataset, size_t from, size_t to);
static std::tuple<glm::vec3, glm::vec3> getRendererExtents(const VAPoR::RenderParams *rp);
static void setRendererExtents(const VAPoR::RenderParams *rp, const glm::vec3 &minExts, const glm::vec3 &maxExts);
static void movingDomainTrackCamera(ControlExec *ce, size_t from, size_t to);
static void movingDomainTrackRenderRegions(ControlExec *ce, size_t from, size_t to);
static void movingDomainTrackParticleRenderRegions(ControlExec *ce, size_t from, size_t to);
};
79 changes: 69 additions & 10 deletions lib/render/NavigationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <vapor/AnimationParams.h>
#include <vapor/GUIStateParams.h>
#include <vapor/AnimationParams.h>
#include <vapor/ParticleParams.h>
#include <cassert>
#include <cfloat>
#include <glm/glm.hpp>
Expand Down Expand Up @@ -483,31 +484,54 @@ void NavigationUtils::handleMovingDomainAdjustments(ControlExec *ce, size_t ts_f

if (trackCamera) movingDomainTrackCamera(ce, ts_from, ts_to);
if (trackDomain) movingDomainTrackRenderRegions(ce, ts_from, ts_to);
if (trackDomain) movingDomainTrackParticleRenderRegions(ce, ts_from, ts_to);
}


glm::vec3 NavigationUtils::getDomainMovementBetweenTimesteps(ControlExec *ce, string dataset, size_t from, size_t to)
std::tuple<glm::vec3, glm::vec3> NavigationUtils::getDomainExtentsAtTimestep(ControlExec *ce, const std::string &dataset, size_t ts)
{
auto paramsMgr = ce->GetParamsMgr();
auto dataStatus = ce->GetDataStatus();
auto guiParams = (GUIStateParams *)paramsMgr->GetParams(GUIStateParams::GetClassType());
string viz = guiParams->GetActiveVizName();

CoordType minExts_, maxExts_;
dataStatus->GetActiveExtents(paramsMgr, viz, dataset, from, minExts_, maxExts_);
vec3 oldMinExts = CoordTypeToVec3(minExts_);
vec3 oldMaxExts = CoordTypeToVec3(maxExts_);
dataStatus->GetActiveExtents(paramsMgr, viz, dataset, ts, minExts_, maxExts_);
vec3 minExts = CoordTypeToVec3(minExts_);
vec3 maxExts = CoordTypeToVec3(maxExts_);

return std::make_tuple(minExts, maxExts);
}


glm::vec3 NavigationUtils::getDomainMovementBetweenTimesteps(ControlExec *ce, string dataset, size_t from, size_t to)
{
vec3 oldMinExts, oldMaxExts, newMinExts, newMaxExts;
std::tie(oldMinExts, oldMaxExts) = getDomainExtentsAtTimestep(ce, dataset, from);
std::tie(newMinExts, newMaxExts) = getDomainExtentsAtTimestep(ce, dataset, to);

vec3 oldDomainCenter = (oldMinExts+oldMaxExts)/2.f;
dataStatus->GetActiveExtents(paramsMgr, viz, dataset, to, minExts_, maxExts_);
vec3 newMinExts = CoordTypeToVec3(minExts_);
vec3 newMaxExts = CoordTypeToVec3(maxExts_);
vec3 newDomainCenter = (newMinExts+newMaxExts)/2.f;
vec3 domainMove = newDomainCenter - oldDomainCenter;

return domainMove;
}


std::tuple<glm::vec3, glm::vec3> NavigationUtils::getRendererExtents(const RenderParams *rp)
{
CoordType minExts_, maxExts_;
rp->GetBox()->GetExtents(minExts_, maxExts_);
return std::make_tuple(CoordTypeToVec3(minExts_), CoordTypeToVec3(maxExts_));
}


void NavigationUtils::setRendererExtents(const RenderParams *rp, const glm::vec3 &minExts, const glm::vec3 &maxExts)
{
rp->GetBox()->SetExtents(Vec3ToCoordType(minExts), Vec3ToCoordType(maxExts));
}


void NavigationUtils::movingDomainTrackCamera(ControlExec *ce, size_t from, size_t to)
{
auto paramsMgr = ce->GetParamsMgr();
Expand Down Expand Up @@ -555,11 +579,46 @@ void NavigationUtils::movingDomainTrackRenderRegions(ControlExec *ce, size_t fro
for (const auto &renderer : renderers) {
string _1, _2, className;
paramsMgr->RenderParamsLookup(renderer, _1, _2, className);
if (className == ParticleParams::GetClassType())
continue;
RenderParams *rp = paramsMgr->GetRenderParams(viz, dataset, className, renderer);

vec3 minExts, maxExts;
std::tie(minExts, maxExts) = getRendererExtents(rp);
setRendererExtents(rp, domainMove+minExts, domainMove+maxExts);
}
}
}


void NavigationUtils::movingDomainTrackParticleRenderRegions(ControlExec *ce, size_t from, size_t to)
{
auto paramsMgr = ce->GetParamsMgr();
GUIStateParams *guiParams = (GUIStateParams *)paramsMgr->GetParams(GUIStateParams::GetClassType());
string viz = guiParams->GetActiveVizName();
auto datasets = guiParams->GetOpenDataSetNames();

for (const auto &dataset : datasets) {
vector<string> renderers;
paramsMgr->GetRenderParamNames(viz, dataset, renderers);
for (const auto &renderer : renderers) {
string _1, _2, className;
paramsMgr->RenderParamsLookup(renderer, _1, _2, className);
if (className != ParticleParams::GetClassType())
continue;
RenderParams *rp = paramsMgr->GetRenderParams(viz, dataset, className, renderer);

CoordType minExts_, maxExts_;
rp->GetBox()->GetExtents(minExts_, maxExts_);
rp->GetBox()->SetExtents(Vec3ToCoordType(domainMove+CoordTypeToVec3(minExts_)), Vec3ToCoordType(domainMove+CoordTypeToVec3(maxExts_)));
vec3 dataExtentsFromMin, dataExtentsFromMax, dataExtentsToMin, dataExtentsToMax, rendererExtentsFromMin, rendererExtentsFromMax;
std::tie(dataExtentsFromMin, dataExtentsFromMax) = getDomainExtentsAtTimestep(ce, dataset, from);
std::tie(dataExtentsToMin, dataExtentsToMax) = getDomainExtentsAtTimestep(ce, dataset, to);
std::tie(rendererExtentsFromMin, rendererExtentsFromMax) = getRendererExtents(rp);

vec3 rendererExtentsFromMinNorm = (rendererExtentsFromMin - dataExtentsFromMin) / (dataExtentsFromMax - dataExtentsFromMin);
vec3 rendererExtentsFromMaxNorm = (rendererExtentsFromMax - dataExtentsFromMin) / (dataExtentsFromMax - dataExtentsFromMin);
vec3 rendererExtentsToMin = (dataExtentsToMax - dataExtentsToMin) * rendererExtentsFromMinNorm + dataExtentsToMin;
vec3 rendererExtentsToMax = (dataExtentsToMax - dataExtentsToMin) * rendererExtentsFromMaxNorm + dataExtentsToMin;

setRendererExtents(rp, rendererExtentsToMin, rendererExtentsToMax);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/vdc/Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ size_t Grid::GetNumDimensions(DimsType dims)
VAssert(dims[i] > 0);
if (dims[i] > 1) nDims++;
}
nDims = std::max(nDims, 1UL); // Otherwise will return 0 dim for single particle
return (nDims);
}

Expand Down