fix(lines): fix lines not clearing when having no points
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -68,6 +68,19 @@ fn build_line_mesh(
|
|||||||
let mut vertex_indecies = Vec::<u32>::new();
|
let mut vertex_indecies = Vec::<u32>::new();
|
||||||
let lines_data = lines.data.lock();
|
let lines_data = lines.data.lock();
|
||||||
if lines_data.is_empty() {
|
if lines_data.is_empty() {
|
||||||
|
*lines.bounds.lock() = Aabb::default();
|
||||||
|
match lines.entity.get() {
|
||||||
|
Some(e) => cmds.entity(**e),
|
||||||
|
None => {
|
||||||
|
let e = cmds.spawn((
|
||||||
|
Name::new("LinesNode"),
|
||||||
|
SpatialNode(Arc::downgrade(&lines.spatial)),
|
||||||
|
));
|
||||||
|
_ = lines.entity.set(e.id().into());
|
||||||
|
e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.remove::<Mesh3d>();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,20 +171,18 @@ fn build_line_mesh(
|
|||||||
let e = cmds.spawn((
|
let e = cmds.spawn((
|
||||||
Name::new("LinesNode"),
|
Name::new("LinesNode"),
|
||||||
SpatialNode(Arc::downgrade(&lines.spatial)),
|
SpatialNode(Arc::downgrade(&lines.spatial)),
|
||||||
|
MeshMaterial3d(materials.add(PbrMaterial {
|
||||||
|
color: Color::WHITE,
|
||||||
|
roughness: 1.0,
|
||||||
|
alpha_mode: AlphaMode::Opaque,
|
||||||
|
..default()
|
||||||
|
})),
|
||||||
));
|
));
|
||||||
_ = lines.entity.set(e.id().into());
|
_ = lines.entity.set(e.id().into());
|
||||||
e
|
e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.insert((
|
.insert(Mesh3d(meshes.add(mesh)));
|
||||||
Mesh3d(meshes.add(mesh)),
|
|
||||||
MeshMaterial3d(materials.add(PbrMaterial {
|
|
||||||
color: Color::WHITE,
|
|
||||||
roughness: 1.0,
|
|
||||||
alpha_mode: AlphaMode::Opaque,
|
|
||||||
..default()
|
|
||||||
})),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ fn spawn_text(
|
|||||||
let max_height = style.bounds.as_ref().map(|v| v.bounds.x);
|
let max_height = style.bounds.as_ref().map(|v| v.bounds.x);
|
||||||
let (width, _height) =
|
let (width, _height) =
|
||||||
text_glyphs.measure(max_width, max_height, &mut font_settings.font_system);
|
text_glyphs.measure(max_width, max_height, &mut font_settings.font_system);
|
||||||
let meshes = generate_meshes(
|
let char_meshes = generate_meshes(
|
||||||
bevy_mesh_text_3d::InputText::Simple {
|
bevy_mesh_text_3d::InputText::Simple {
|
||||||
text: text_string,
|
text: text_string,
|
||||||
material: material_registry.get_handle(
|
material: material_registry.get_handle(
|
||||||
@@ -137,7 +137,7 @@ fn spawn_text(
|
|||||||
if let Some(db) = old_db {
|
if let Some(db) = old_db {
|
||||||
mem::swap(font_settings.font_system.db_mut(), db);
|
mem::swap(font_settings.font_system.db_mut(), db);
|
||||||
}
|
}
|
||||||
let Ok(meshes) = meshes.inspect_err(|err| error!("unable to create text meshes: {err}"))
|
let Ok(meshes) = char_meshes.inspect_err(|err| error!("unable to create text meshes: {err}"))
|
||||||
else {
|
else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user