Skip to content

Commit

Permalink
Merge branch 'main' into bevy_main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Nov 10, 2024
2 parents d79710a + 509f61f commit 2530bb7
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 244 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
restore-keys: |
cache-doc-cargo-${{ hashFiles('**/Cargo.toml') }}
cache-doc-cargo
- run: cargo doc --all --features "bevy/x11"
- run: cargo doc --all --features "bevy_winit/x11"
env:
RUSTDOCFLAGS: -D warnings

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.30.1] - 10-Nov-2024

### Changed

- Depend on bevy subcrates for compile time improvement ([#319](https://github.com/mvlabat/bevy_egui/pull/319) by @aevyrie).

## [0.30.0] - 4-Oct-2024

### Added

- `prepare_render` step support for `EguiBevyPaintCallbackImpl` ([#306](https://github.com/mvlabat/bevy_egui/pull/306) by @PPakalns).
- Mobile virtual keyboard support in web ([#279](https://github.com/mvlabat/bevy_egui/pull/279) by @v-kat).
- Requires `Window::prevent_default_event_handling` being set to `false`.
Expand Down
81 changes: 52 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_egui"
version = "0.30.0"
rust-version = "1.80.0" # needed for LazyLock https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html
version = "0.30.1"
rust-version = "1.80.0" # needed for LazyLock https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html
authors = ["mvlabat <[email protected]>"]
description = "A plugin for Egui integration into Bevy"
license = "MIT"
Expand All @@ -20,7 +20,14 @@ immutable_ctx = []
manage_clipboard = ["arboard", "thread_local"]
open_url = ["webbrowser"]
default_fonts = ["egui/default_fonts"]
render = ["bevy/bevy_render"]
render = [
"bevy_render",
"bevy_asset",
"encase",
"bytemuck",
"egui/bytemuck",
"wgpu-types",
]
serde = ["egui/serde"]
# The enabled logs will print with the info log level, to make it less cumbersome to debug in browsers.
log_input_events = []
Expand Down Expand Up @@ -51,47 +58,63 @@ name = "render_egui_to_texture"
required-features = ["render"]

[dependencies]
bevy = { version = "0.15.0-rc.3", default-features = false, features = [
"bevy_asset",
"bevy_winit",
"custom_cursor",
] }
egui = { version = "0.29", default-features = false, features = ["bytemuck"] }
bytemuck = "1"
egui = { version = "0.29", default-features = false }
bevy_app = "0.15.0-rc.3"
bevy_derive = "0.15.0-rc.3"
bevy_ecs = "0.15.0-rc.3"
bevy_input = "0.15.0-rc.3"
bevy_log = "0.15.0-rc.3"
bevy_math = "0.15.0-rc.3"
bevy_reflect = "0.15.0-rc.3"
bevy_time = "0.15.0-rc.3"
bevy_utils = "0.15.0-rc.3"
bevy_winit = { version = "0.15.0-rc.3", features = ["custom_cursor"] }
bevy_window = "0.15.0-rc.3"

# `open_url` feature
webbrowser = { version = "1.0.1", optional = true }
wgpu-types = "23"

# `render` feature
bytemuck = { version = "1", optional = true }
bevy_asset = { version = "0.15.0-rc.3", optional = true }
bevy_render = { version = "0.15.0-rc.3", optional = true }
encase = { version = "0.10", optional = true }
wgpu-types = { version = "23.0", optional = true }

# `manage_clipboard` feature
[target.'cfg(not(any(target_arch = "wasm32", target_os = "android")))'.dependencies]
arboard = { version = "3.2.0", optional = true }
thread_local = { version = "1.1.0", optional = true }

[dev-dependencies]
version-sync = "0.9.4"
bevy = { version = "0.15.0-rc.3", default-features = false, features = [
"x11",
"png",
"bevy_pbr",
"bevy_core_pipeline",
"tonemapping_luts",
"webgl2",
"x11",
"png",
"bevy_pbr",
"bevy_core_pipeline",
"bevy_asset",
"bevy_winit",
"tonemapping_luts",
"webgl2",
] }
egui = { version = "0.29", default-features = false, features = ["bytemuck"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
winit = "0.30"
web-sys = { version = "0.3.63", features = [
"Clipboard",
"ClipboardEvent",
"CompositionEvent",
"DataTransfer",
"Document",
"EventTarget",
"HtmlInputElement",
"InputEvent",
"KeyboardEvent",
"Navigator",
"TouchEvent",
"Window",
"Clipboard",
"ClipboardEvent",
"CompositionEvent",
"DataTransfer",
"Document",
"EventTarget",
"HtmlInputElement",
"InputEvent",
"KeyboardEvent",
"Navigator",
"TouchEvent",
"Window",
] }
js-sys = "0.3.63"
wasm-bindgen = "0.2.84"
Expand Down
72 changes: 34 additions & 38 deletions src/egui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ use crate::{
},
EguiRenderOutput, EguiSettings, RenderTargetSize,
};
use bevy::{
ecs::world::{FromWorld, World},
prelude::{Handle, Resource},
render::{
render_asset::RenderAssetUsages,
render_graph::{Node, NodeRunError, RenderGraphContext},
render_phase::TrackedRenderPass,
render_resource::{
BindGroupLayout, BindGroupLayoutEntry, BindingType, BlendComponent, BlendFactor,
BlendOperation, BlendState, Buffer, BufferAddress, BufferBindingType, BufferDescriptor,
BufferUsages, ColorTargetState, ColorWrites, Extent3d, FragmentState, FrontFace,
IndexFormat, LoadOp, MultisampleState, Operations, PipelineCache, PrimitiveState,
RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor,
SamplerBindingType, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline,
StoreOp, TextureDimension, TextureFormat, TextureSampleType, TextureViewDimension,
VertexBufferLayout, VertexFormat, VertexState, VertexStepMode,
},
renderer::{RenderContext, RenderDevice, RenderQueue},
sync_world::{MainEntity, RenderEntity},
texture::{
GpuImage, Image, ImageAddressMode, ImageFilterMode, ImageSampler,
ImageSamplerDescriptor,
},
view::{ExtractedWindow, ExtractedWindows},
use bevy_asset::prelude::*;
use bevy_ecs::{
prelude::*,
world::{FromWorld, World},
};
use bevy_render::{
render_asset::RenderAssetUsages,
render_graph::{Node, NodeRunError, RenderGraphContext},
render_phase::TrackedRenderPass,
render_resource::{
BindGroupLayout, BindGroupLayoutEntry, BindingType, BlendComponent, BlendFactor,
BlendOperation, BlendState, Buffer, BufferAddress, BufferBindingType, BufferDescriptor,
BufferUsages, ColorTargetState, ColorWrites, Extent3d, FragmentState, FrontFace,
IndexFormat, LoadOp, MultisampleState, Operations, PipelineCache, PrimitiveState,
RenderPassColorAttachment, RenderPassDescriptor, RenderPipelineDescriptor,
SamplerBindingType, Shader, ShaderStages, ShaderType, SpecializedRenderPipeline, StoreOp,
TextureDimension, TextureFormat, TextureSampleType, TextureViewDimension,
VertexBufferLayout, VertexFormat, VertexState, VertexStepMode,
},
renderer::{RenderContext, RenderDevice, RenderQueue},
sync_world::{MainEntity, RenderEntity},
texture::{
GpuImage, Image, ImageAddressMode, ImageFilterMode, ImageSampler, ImageSamplerDescriptor,
},
view::{ExtractedWindow, ExtractedWindows},
};
use bytemuck::cast_slice;
use egui::{TextureFilter, TextureOptions};
Expand Down Expand Up @@ -265,19 +265,19 @@ impl Node for EguiNode {
primitive,
} in paint_jobs
{
let clip_urect = bevy::math::URect {
min: bevy::math::UVec2 {
let clip_urect = bevy_math::URect {
min: bevy_math::UVec2 {
x: (clip_rect.min.x * self.pixels_per_point).round() as u32,
y: (clip_rect.min.y * self.pixels_per_point).round() as u32,
},
max: bevy::math::UVec2 {
max: bevy_math::UVec2 {
x: (clip_rect.max.x * self.pixels_per_point).round() as u32,
y: (clip_rect.max.y * self.pixels_per_point).round() as u32,
},
};

if clip_urect
.intersect(bevy::math::URect::new(
.intersect(bevy_math::URect::new(
0,
0,
window_size.physical_width as u32,
Expand Down Expand Up @@ -505,23 +505,19 @@ impl Node for EguiNode {
requires_reset = false;
}

let clip_urect = bevy::math::URect {
min: bevy::math::UVec2 {
let clip_urect = bevy_math::URect {
min: bevy_math::UVec2 {
x: (draw_command.clip_rect.min.x * self.pixels_per_point).round() as u32,
y: (draw_command.clip_rect.min.y * self.pixels_per_point).round() as u32,
},
max: bevy::math::UVec2 {
max: bevy_math::UVec2 {
x: (draw_command.clip_rect.max.x * self.pixels_per_point).round() as u32,
y: (draw_command.clip_rect.max.y * self.pixels_per_point).round() as u32,
},
};

let scissor_rect = clip_urect.intersect(bevy::math::URect::new(
0,
0,
physical_width,
physical_height,
));
let scissor_rect =
clip_urect.intersect(bevy_math::URect::new(0, 0, physical_width, physical_height));
if scissor_rect.is_empty() {
continue;
}
Expand Down Expand Up @@ -667,7 +663,7 @@ pub(crate) fn texture_options_as_sampler_descriptor(
///
/// Rendering can be implemented using for example:
/// * native wgpu rendering libraries,
/// * or with [`bevy::render::render_phase`] approach.
/// * or with [`bevy_render::render_phase`] approach.
pub struct EguiBevyPaintCallback(Box<dyn EguiBevyPaintCallbackImpl>);

impl EguiBevyPaintCallback {
Expand Down
45 changes: 22 additions & 23 deletions src/egui_render_to_texture_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ use crate::{
render_systems::{EguiPipelines, EguiTextureBindGroups, EguiTextureId, EguiTransforms},
EguiRenderOutput, EguiRenderToTextureHandle, EguiSettings, RenderTargetSize,
};
use bevy::{
ecs::world::World,
render::{
render_asset::RenderAssets,
render_graph::{Node, NodeRunError, RenderGraphContext, RenderLabel},
render_phase::TrackedRenderPass,
render_resource::{
Buffer, BufferAddress, BufferDescriptor, BufferUsages, IndexFormat, LoadOp, Operations,
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, StoreOp,
},
renderer::{RenderContext, RenderDevice, RenderQueue},
sync_world::{MainEntity, RenderEntity},
texture::GpuImage,
use bevy_ecs::world::World;
use bevy_render::{
render_asset::RenderAssets,
render_graph::{Node, NodeRunError, RenderGraphContext, RenderLabel},
render_phase::TrackedRenderPass,
render_resource::{
Buffer, BufferAddress, BufferDescriptor, BufferUsages, IndexFormat, LoadOp, Operations,
PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, StoreOp,
},
renderer::{RenderContext, RenderDevice, RenderQueue},
sync_world::{MainEntity, RenderEntity},
texture::GpuImage,
};

use bytemuck::cast_slice;

/// [`RenderLabel`] type for the Egui Render to Texture pass.
Expand Down Expand Up @@ -113,19 +112,19 @@ impl Node for EguiRenderToTextureNode {
primitive,
} in paint_jobs
{
let clip_urect = bevy::math::URect {
min: bevy::math::UVec2 {
let clip_urect = bevy_math::URect {
min: bevy_math::UVec2 {
x: (clip_rect.min.x * self.pixels_per_point).round() as u32,
y: (clip_rect.min.y * self.pixels_per_point).round() as u32,
},
max: bevy::math::UVec2 {
max: bevy_math::UVec2 {
x: (clip_rect.max.x * self.pixels_per_point).round() as u32,
y: (clip_rect.max.y * self.pixels_per_point).round() as u32,
},
};

if clip_urect
.intersect(bevy::math::URect::new(
.intersect(bevy_math::URect::new(
0,
0,
render_target_size.physical_width as u32,
Expand Down Expand Up @@ -312,7 +311,7 @@ impl Node for EguiRenderToTextureNode {
let mut render_pass = TrackedRenderPass::new(device, render_pass);

let Some(pipeline_id) = egui_pipelines.get(&self.render_to_texture_target_main) else {
bevy::log::error!("no egui_pipeline");
bevy_log::error!("no egui_pipeline");
return Ok(());
};
let Some(pipeline) = pipeline_cache.get_render_pipeline(*pipeline_id) else {
Expand Down Expand Up @@ -346,18 +345,18 @@ impl Node for EguiRenderToTextureNode {
requires_reset = false;
}

let clip_urect = bevy::math::URect {
min: bevy::math::UVec2 {
let clip_urect = bevy_math::URect {
min: bevy_math::UVec2 {
x: (draw_command.clip_rect.min.x * self.pixels_per_point).round() as u32,
y: (draw_command.clip_rect.min.y * self.pixels_per_point).round() as u32,
},
max: bevy::math::UVec2 {
max: bevy_math::UVec2 {
x: (draw_command.clip_rect.max.x * self.pixels_per_point).round() as u32,
y: (draw_command.clip_rect.max.y * self.pixels_per_point).round() as u32,
},
};
let scrissor_rect = clip_urect.intersect(bevy::math::URect::from_corners(
bevy::math::UVec2::ZERO,
let scrissor_rect = clip_urect.intersect(bevy_math::URect::from_corners(
bevy_math::UVec2::ZERO,
gpu_image.size,
));
if scrissor_rect.is_empty() {
Expand Down
Loading

0 comments on commit 2530bb7

Please sign in to comment.