fix(fields): fix equations

This commit is contained in:
Nova
2022-09-16 16:57:05 -04:00
parent fb1f5bad97
commit a2f313774b
2 changed files with 3 additions and 7 deletions

View File

@@ -49,11 +49,7 @@ impl BoxField {
impl FieldTrait for BoxField {
fn local_distance(&self, p: Vec3A) -> f32 {
let size = self.size.lock();
let q = vec3(
p.x.abs() - (size.x * 0.5_f32),
p.y.abs() - (size.y * 0.5_f32),
p.z.abs() - (size.z * 0.5_f32),
);
let q = vec3(p.x.abs() - size.x, p.y.abs() - size.y, p.z.abs() - size.z);
let v = vec3a(q.x.max(0_f32), q.y.max(0_f32), q.z.max(0_f32));
v.length() + q.x.max(q.y.max(q.z)).min(0_f32)
}

View File

@@ -38,9 +38,9 @@ impl SphereField {
}
pub fn set_radius_flex(node: &Node, _calling_client: Arc<Client>, data: &[u8]) -> Result<()> {
let root = flexbuffers::Reader::get_root(data)?;
let radius = flexbuffers::Reader::get_root(data)?.get_f64()? as f32;
if let Field::Sphere(sphere_field) = node.field.get().unwrap().as_ref() {
sphere_field.set_radius(root.as_f32());
sphere_field.set_radius(radius);
}
Ok(())
}