refactor: remove many unwrap calls

This commit is contained in:
Nova
2023-01-25 11:50:53 -05:00
parent b5e87d5911
commit 529b86fa91
26 changed files with 163 additions and 133 deletions

View File

@@ -75,7 +75,7 @@ pub fn create_box_field_flex(_node: &Node, calling_client: Arc<Client>, data: &[
let node = Node::create(&calling_client, "/field", info.name, true);
let parent = find_spatial_parent(&calling_client, info.parent_path)?;
let transform = parse_transform(info.transform, true, true, false);
let node = node.add_to_scenegraph();
let node = node.add_to_scenegraph()?;
Spatial::add_to(&node, Some(parent), transform, false)?;
BoxField::add_to(&node, info.size)?;
Ok(())

View File

@@ -81,7 +81,7 @@ pub fn create_cylinder_field_flex(
let node = Node::create(&calling_client, "/field", info.name, true);
let parent = find_spatial_parent(&calling_client, info.parent_path)?;
let transform = parse_transform(info.transform, true, true, false);
let node = node.add_to_scenegraph();
let node = node.add_to_scenegraph()?;
Spatial::add_to(&node, Some(parent), transform, false)?;
CylinderField::add_to(&node, info.length, info.radius)?;
Ok(())

View File

@@ -217,13 +217,13 @@ impl Deref for Field {
}
}
pub fn create_interface(client: &Arc<Client>) {
pub fn create_interface(client: &Arc<Client>) -> Result<()> {
let node = Node::create(client, "", "field", false);
node.add_local_signal("create_box_field", create_box_field_flex);
node.add_local_signal("create_cylinder_field", create_cylinder_field_flex);
node.add_local_signal("create_sphere_field", create_sphere_field_flex);
node.add_local_signal("create_torus_field", create_torus_field_flex);
node.add_to_scenegraph();
node.add_to_scenegraph().map(|_| ())
}
pub fn find_field(client: &Client, path: &str) -> Result<Arc<Field>> {

View File

@@ -81,7 +81,7 @@ pub fn create_sphere_field_flex(
.unwrap_or_else(|| Vector3::from([0.0; 3]))
.into(),
);
let node = node.add_to_scenegraph();
let node = node.add_to_scenegraph()?;
Spatial::add_to(&node, Some(parent), transform, false)?;
SphereField::add_to(&node, info.radius)?;
Ok(())

View File

@@ -81,7 +81,7 @@ pub fn create_torus_field_flex(
let node = Node::create(&calling_client, "/field", info.name, true);
let parent = find_spatial_parent(&calling_client, info.parent_path)?;
let transform = parse_transform(info.transform, true, true, false);
let node = node.add_to_scenegraph();
let node = node.add_to_scenegraph()?;
Spatial::add_to(&node, Some(parent), transform, false)?;
TorusField::add_to(&node, info.radius_a, info.radius_b)?;
Ok(())