diff --git a/yt_idv/scene_components/base_component.py b/yt_idv/scene_components/base_component.py index 51d32bd..e70c499 100644 --- a/yt_idv/scene_components/base_component.py +++ b/yt_idv/scene_components/base_component.py @@ -64,7 +64,7 @@ class SceneComponent(traitlets.HasTraits): _program1_invalid = True _program2_invalid = True _cmap_bounds_invalid = True - _data_geometry = traitlets.Unicode(default_value='cartesian') + _data_geometry = traitlets.Unicode(default_value="cartesian") display_name = traitlets.Unicode(allow_none=True) @@ -83,29 +83,32 @@ class SceneComponent(traitlets.HasTraits): active = traitlets.Bool(True) @traitlets.observe("_data_geometry") - def _update_geometry_pp_directives(self, change): - if change['new'] == 'spherical' and change['old'] == 'cartesian': - # this should only happen once on initial data load, so only handling the - # change from the default value. - current_shader = component_shaders[self.name][self.render_method] - with self.hold_trait_notifications(): - for shd in ('vertex', 'geometry', 'fragment'): - # update the preprocessor directive state for this shader - self._program1_pp_defs.add_definition(shd, ("SPHERICAL_GEOM", "")) - pp_defs = self._program1_pp_defs[shd] - - # update shader attributes of self - new_shader_tuple = (current_shader[f"first_{shd}"], pp_defs) + def _update_geometry_pp_directives(self, change): + if change["new"] == "spherical" and change["old"] == "cartesian": + # this should only happen once on initial data load, so only handling the + # change from the default value. + current_shader = component_shaders[self.name][self.render_method] + with self.hold_trait_notifications(): + for shd in ("vertex", "geometry", "fragment"): + # update the preprocessor directive state for this shader + self._program1_pp_defs.add_definition(shd, ("SPHERICAL_GEOM", "")) + pp_defs = self._program1_pp_defs[shd] + + # update shader attributes of self + new_shader_tuple = (current_shader[f"first_{shd}"], pp_defs) setattr(self, f"{shd}_shader", new_shader_tuple) # all of the above shader attribute changes will trigger further - # traitlet changes that cause _recompile_shader to run - - self._data_geometry = change['new'] + # traitlet changes that cause _recompile_shader to run + + self._data_geometry = change["new"] @traitlets.observe("data") def _update_geometry(self, change): - if hasattr(change["new"], '_yt_geom_str') and change["new"]._yt_geom_str == 'spherical': + if ( + hasattr(change["new"], "_yt_geom_str") + and change["new"]._yt_geom_str == "spherical" + ): self._data_geometry = change["new"]._yt_geom_str @traitlets.observe("display_bounds") diff --git a/yt_idv/scene_components/blocks.py b/yt_idv/scene_components/blocks.py index 3b4f302..a4346e8 100644 --- a/yt_idv/scene_components/blocks.py +++ b/yt_idv/scene_components/blocks.py @@ -138,7 +138,7 @@ def draw(self, scene, program): with bitmap_tex.bind(target=1): GL.glDrawArrays(GL.GL_POINTS, tex_ind * each, each) - def _set_uniforms(self, scene, shader_program): + def _set_uniforms(self, scene, shader_program): if self.data._yt_geom_str == "spherical": axis_id = self.data.data_source.ds.coordinates.axis_id shader_program._set_uniform("id_theta", axis_id["theta"]) diff --git a/yt_idv/scene_data/block_collection.py b/yt_idv/scene_data/block_collection.py index 1645ab1..1e7873b 100644 --- a/yt_idv/scene_data/block_collection.py +++ b/yt_idv/scene_data/block_collection.py @@ -17,7 +17,7 @@ class BlockCollection(SceneData): scale = traitlets.Bool(False) blocks_by_grid = traitlets.Instance(defaultdict, (list,)) grids_by_block = traitlets.Dict(default_value=()) - _yt_geom_str = traitlets.Unicode('cartesian') + _yt_geom_str = traitlets.Unicode("cartesian") @traitlets.default("vertex_array") def _default_vertex_array(self): @@ -44,8 +44,7 @@ def add_data(self, field, no_ghost=False): # note: casting to string for compatibility with new and old geometry # attributes (now an enum member in latest yt), # see https://github.com/yt-project/yt/pull/4244 - - + # Every time we change our data source, we wipe all existing ones. # We now set up our vertices into our current data source. vert, dx, le, re = [], [], [], [] @@ -114,7 +113,7 @@ def add_data(self, field, no_ghost=False): ) # Now we set up our textures - self._load_textures() + self._load_textures() def _set_geometry_attributes(self, le, re): # set any vertex_array attributes that depend on the yt geometry type diff --git a/yt_idv/shaders/grid_expand.geom.glsl b/yt_idv/shaders/grid_expand.geom.glsl index f178b31..2f47266 100644 --- a/yt_idv/shaders/grid_expand.geom.glsl +++ b/yt_idv/shaders/grid_expand.geom.glsl @@ -76,7 +76,7 @@ void main() { left_edge_cart = vleft_edge_cart[0]; right_edge_cart = vright_edge_cart[0]; #endif - + dx = vdx[0]; v_model = newPos; texture_offset = ivec3(0); diff --git a/yt_idv/shaders/known_uniforms.inc.glsl b/yt_idv/shaders/known_uniforms.inc.glsl index 57d6aa3..920d3a5 100644 --- a/yt_idv/shaders/known_uniforms.inc.glsl +++ b/yt_idv/shaders/known_uniforms.inc.glsl @@ -73,4 +73,3 @@ uniform float cart_bbox_max_width; // draw outline control uniform float draw_boundary; uniform vec4 boundary_color; - diff --git a/yt_idv/shaders/ray_tracing.frag.glsl b/yt_idv/shaders/ray_tracing.frag.glsl index 7a6bbf1..57e8d99 100644 --- a/yt_idv/shaders/ray_tracing.frag.glsl +++ b/yt_idv/shaders/ray_tracing.frag.glsl @@ -137,7 +137,7 @@ void main() while(t <= t1) { // texture position - #ifdef SPHERICAL_GEOM + #ifdef SPHERICAL_GEOM ray_position_native = cart_to_sphere_vec3(ray_position); within_el = within_bb(ray_position_native); #else