Skip to content

Commit

Permalink
do not call update 2x on the hipses, render the raytracer with depth=…
Browse files Browse the repository at this point in the history
…1 too
  • Loading branch information
bmatthieu3 committed Sep 27, 2023
1 parent 1981721 commit bda3e50
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/core/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ impl App {
}

// The update from the camera
self.layers.update(&mut self.camera, &self.projection);
//self.layers.update(&mut self.camera, &self.projection);

if self.request_for_new_tiles
&& Time::now() - self.last_time_request_for_new_tiles > DeltaTime::from(200.0)
Expand Down
19 changes: 13 additions & 6 deletions src/core/src/renderable/hips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::{shader::ShaderManager, survey::config::HiPSConfig};

use crate::downloader::request::allsky::Allsky;
use crate::healpix::{cell::HEALPixCell, coverage::HEALPixCoverage};
use crate::math::angle::ToAngle;
use crate::math::lonlat::LonLat;
use crate::time::Time;

Expand All @@ -42,6 +43,8 @@ use std::fmt::Debug;
use wasm_bindgen::JsValue;
use web_sys::WebGl2RenderingContext;

use super::utils::index_patch::CCWCheckPatchIndexIter;

const M: f64 = 280.0 * 280.0;
const N: f64 = 150.0 * 150.0;
const RAP: f64 = 0.7;
Expand Down Expand Up @@ -586,11 +589,13 @@ impl HiPS {
self.textures.contains_tile(cell)
}

pub fn update(&mut self, camera: &mut CameraViewPort, projection: &ProjectionType) {
let raytracing = {
let depth = camera.get_tile_depth();
camera.is_allsky() || depth == 0
};
pub fn update(
&mut self,
raytracer: &RayTracer,
camera: &mut CameraViewPort,
projection: &ProjectionType,
) {
let raytracing = raytracer.is_rendering(camera);

let vertices_recomputation_needed =
!raytracing && (self.textures.reset_available_tiles() | camera.has_moved());
Expand Down Expand Up @@ -814,10 +819,12 @@ impl HiPS {
pos.push(ndc);
}

let patch_indices_iter = DefaultPatchIndexIter::new(
let patch_indices_iter = CCWCheckPatchIndexIter::new(
&(0..=n_segments_by_side),
&(0..=n_segments_by_side),
n_vertices_per_segment,
&pos,
camera,
)
.flatten()
.map(|indices| {
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/renderable/hips/raytracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,6 @@ impl RayTracer {
// Check whether the tile depth is 0 for square projection
// definition domains i.e. Mercator
let depth = camera.get_tile_depth();
camera.is_allsky() || depth == 0
camera.is_allsky() || depth <= 1
}
}
8 changes: 1 addition & 7 deletions src/core/src/renderable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl Layers {
// 1. Update the survey if necessary
let url = self.urls.get(layer).expect("Url should be found");
if let Some(survey) = self.surveys.get_mut(url) {
survey.update(camera, projection);
survey.update(&self.raytracer, camera, projection);

// 2. Draw it if its opacity is not null
survey.draw(shaders, colormaps, camera, raytracer, draw_opt)?;
Expand Down Expand Up @@ -614,12 +614,6 @@ impl Layers {
ready
}

pub fn update(&mut self, camera: &mut CameraViewPort, proj: &ProjectionType) {
for survey in self.surveys.values_mut() {
survey.update(camera, proj);
}
}

// Accessors
// HiPSes getters
pub fn get_hips_from_layer(&self, layer: &str) -> Option<&HiPS> {
Expand Down

0 comments on commit bda3e50

Please sign in to comment.