Skip to content

Commit

Permalink
Fix merge artifact undoing bevyengine#13717
Browse files Browse the repository at this point in the history
  • Loading branch information
rparrett committed Jun 20, 2024
1 parent 0a5f0c5 commit f3c1938
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
5 changes: 1 addition & 4 deletions crates/bevy_sprite/src/dynamic_texture_atlas_builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::TextureAtlasLayout;
use bevy_asset::{Assets, Handle};
use bevy_math::{URect, UVec2};
use bevy_render::{
render_asset::{RenderAsset, RenderAssetUsages},
Expand Down Expand Up @@ -44,16 +43,14 @@ impl DynamicTextureAtlasBuilder {
pub fn add_texture(
&mut self,
atlas_layout: &mut TextureAtlasLayout,
textures: &mut Assets<Image>,
texture: &Image,
atlas_texture_handle: &Handle<Image>,
atlas_texture: &mut Image,
) -> Option<usize> {
let allocation = self.atlas_allocator.allocate(size2(
(texture.width() + self.padding).try_into().unwrap(),
(texture.height() + self.padding).try_into().unwrap(),
));
if let Some(allocation) = allocation {
let atlas_texture = textures.get_mut(atlas_texture_handle)?;
assert!(
<GpuImage as RenderAsset>::asset_usage(atlas_texture)
.contains(RenderAssetUsages::MAIN_WORLD),
Expand Down
15 changes: 7 additions & 8 deletions crates/bevy_text/src/font_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,18 @@ impl FontAtlas {
pub fn add_glyph(
&mut self,
textures: &mut Assets<Image>,
texture_atlases: &mut Assets<TextureAtlasLayout>,
atlas_layouts: &mut Assets<TextureAtlasLayout>,
cache_key: cosmic_text::CacheKey,
texture: &Image,
offset: IVec2,
) -> Result<(), TextError> {
let texture_atlas = texture_atlases.get_mut(&self.texture_atlas).unwrap();
let atlas_layout = atlas_layouts.get_mut(&self.texture_atlas).unwrap();
let atlas_texture = textures.get_mut(&self.texture).unwrap();

if let Some(glyph_index) = self.dynamic_texture_atlas_builder.add_texture(
texture_atlas,
textures,
texture,
&self.texture,
) {
if let Some(glyph_index) =
self.dynamic_texture_atlas_builder
.add_texture(atlas_layout, texture, atlas_texture)
{
self.glyph_to_atlas_index.insert(
cache_key,
GlyphAtlasLocation {
Expand Down

0 comments on commit f3c1938

Please sign in to comment.