Skip to content

Commit

Permalink
fixed object highlighting in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Nov 13, 2024
1 parent 3812b09 commit e9d209a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
19 changes: 11 additions & 8 deletions editor/src/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,20 @@ impl SceneRenderPass for HighlightRenderPass {
{
let render_pass_name = ImmutableString::new("Forward");

let mut render_bundle_storage = RenderDataBundleStorage::default();
let observer_info = ObserverInfo {
observer_position: ctx.camera.global_position(),
z_near: ctx.camera.projection().z_near(),
z_far: ctx.camera.projection().z_far(),
view_matrix: ctx.camera.view_matrix(),
projection_matrix: ctx.camera.projection_matrix(),
};

let mut render_bundle_storage =
RenderDataBundleStorage::new_empty(observer_info.clone());

let frustum = ctx.camera.frustum();
let mut render_context = RenderContext {
observer_info: &ObserverInfo {
observer_position: ctx.camera.global_position(),
z_near: ctx.camera.projection().z_near(),
z_far: ctx.camera.projection().z_far(),
view_matrix: ctx.camera.view_matrix(),
projection_matrix: ctx.camera.projection_matrix(),
},
observer_info: &observer_info,
frustum: Some(&frustum),
storage: &mut render_bundle_storage,
graph: &ctx.scene.graph,
Expand Down
10 changes: 9 additions & 1 deletion fyrox-impl/src/renderer/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,6 @@ pub struct LightSource {

/// Bundle storage handles bundle generation for a scene before rendering. It is used to optimize
/// rendering by reducing amount of state changes of OpenGL context.
#[derive(Default)]
pub struct RenderDataBundleStorage {
bundle_map: FxHashMap<u64, usize>,
pub observer_info: ObserverInfo,
Expand All @@ -737,6 +736,15 @@ impl Default for RenderDataBundleStorageOptions {
}

impl RenderDataBundleStorage {
pub fn new_empty(observer_info: ObserverInfo) -> Self {
Self {
bundle_map: Default::default(),
observer_info,
bundles: Default::default(),
light_sources: Default::default(),
}
}

/// Creates a new render bundle storage from the given graph and observer info. It "asks" every node in the
/// graph one-by-one to give render data which is then put in the storage, sorted and ready for rendering.
/// Frustum culling is done on scene node side ([`crate::scene::node::NodeTrait::collect_render_data`]).
Expand Down

0 comments on commit e9d209a

Please sign in to comment.