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 lines_data = lines.data.lock();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -158,20 +171,18 @@ fn build_line_mesh(
|
||||
let e = cmds.spawn((
|
||||
Name::new("LinesNode"),
|
||||
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());
|
||||
e
|
||||
}
|
||||
}
|
||||
.insert((
|
||||
Mesh3d(meshes.add(mesh)),
|
||||
MeshMaterial3d(materials.add(PbrMaterial {
|
||||
color: Color::WHITE,
|
||||
roughness: 1.0,
|
||||
alpha_mode: AlphaMode::Opaque,
|
||||
..default()
|
||||
})),
|
||||
));
|
||||
.insert(Mesh3d(meshes.add(mesh)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ fn spawn_text(
|
||||
let max_height = style.bounds.as_ref().map(|v| v.bounds.x);
|
||||
let (width, _height) =
|
||||
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 {
|
||||
text: text_string,
|
||||
material: material_registry.get_handle(
|
||||
@@ -137,7 +137,7 @@ fn spawn_text(
|
||||
if let Some(db) = old_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 {
|
||||
continue;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user