Skip to content

Commit

Permalink
Fix ray flickering bug when "Show all rays" was used
Browse files Browse the repository at this point in the history
  • Loading branch information
Atraxus committed Aug 16, 2024
1 parent b74a8f3 commit f49bb63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
7 changes: 2 additions & 5 deletions Intern/rayx-ui/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,12 @@ void Application::run() {

if (m_UIParams.rayInfo.cacheChanged) {
// only start async task if one is not already running
if (!buildRayCacheFuture.valid() ||
(buildRayCacheFuture.valid() && buildRayCacheFuture.wait_for(std::chrono::seconds(0)) != std::future_status::ready)) {
if (buildRayCacheFuture.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
buildRayCacheFuture =
std::async(std::launch::async, &Scene::buildRayCache, m_Scene.get(), std::ref(m_UIParams.rayInfo), std::ref(m_rays));
m_UIParams.rayInfo.cacheChanged = false;
} else {
RAYX_LOG << "Skipping buildRayCache, async task already running.";
m_State = State::BuildingRays;
}
m_State = State::BuildingRays;
}

if (m_UIParams.rayInfo.raysChanged) {
Expand Down
1 change: 0 additions & 1 deletion Intern/rayx-ui/src/RayProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ std::vector<Line> getRays(const RAYX::BundleHistory& rayCache, const RAYX::Beaml
isFirstEvent = false; // Update the flag after the first iteration
}
}
RAYX_LOG << "Number of compile() calls: " << counter;
return rays;
}
void sortRaysByElement(const RAYX::BundleHistory& rays, std::vector<std::vector<RAYX::Ray>>& sortedRays, size_t numElements) {
Expand Down
8 changes: 4 additions & 4 deletions Intern/rayx-ui/src/UserInterface/UIHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,16 @@ void UIHandler::showUISettingsWindow(UIParameters& uiParams) {
uiParams.camController.displaySettings();
ImGui::Separator();
if (!uiParams.rmlPath.empty() && uiParams.rayInfo.raysLoaded) {
size_t tempAmountOfRays = uiParams.rayInfo.amountOfRays;
bool tempRenderAllRays = uiParams.rayInfo.renderAllRays;
size_t currentAmountOfRays = uiParams.rayInfo.amountOfRays;
bool currentRenderAllRays = uiParams.rayInfo.renderAllRays;

displayFilterSlider(uiParams.rayInfo.amountOfRays, uiParams.rayInfo.maxAmountOfRays, uiParams.rayInfo.displayRays,
uiParams.rayInfo.renderAllRays);

if (tempAmountOfRays != uiParams.rayInfo.amountOfRays) {
if (currentAmountOfRays != uiParams.rayInfo.amountOfRays) {
uiParams.rayInfo.raysChanged = true;
}
if (tempRenderAllRays != uiParams.rayInfo.renderAllRays) {
if (currentRenderAllRays != uiParams.rayInfo.renderAllRays) {
uiParams.rayInfo.cacheChanged = true;
}
}
Expand Down

0 comments on commit f49bb63

Please sign in to comment.