fix(field): ensure node doesn't have a field when adding one
This commit is contained in:
@@ -169,6 +169,10 @@ impl BoxField {
|
|||||||
node.borrow().spatial.is_some(),
|
node.borrow().spatial.is_some(),
|
||||||
"Node does not have a spatial attached!"
|
"Node does not have a spatial attached!"
|
||||||
);
|
);
|
||||||
|
ensure!(
|
||||||
|
node.borrow().field.is_none(),
|
||||||
|
"Node already has a field attached!"
|
||||||
|
);
|
||||||
let box_field = BoxField {
|
let box_field = BoxField {
|
||||||
space: node.borrow().spatial.as_ref().unwrap().clone(),
|
space: node.borrow().spatial.as_ref().unwrap().clone(),
|
||||||
size: Cell::new(size),
|
size: Cell::new(size),
|
||||||
@@ -226,6 +230,10 @@ impl CylinderField {
|
|||||||
node.borrow().spatial.is_some(),
|
node.borrow().spatial.is_some(),
|
||||||
"Node does not have a spatial attached!"
|
"Node does not have a spatial attached!"
|
||||||
);
|
);
|
||||||
|
ensure!(
|
||||||
|
node.borrow().field.is_none(),
|
||||||
|
"Node already has a field attached!"
|
||||||
|
);
|
||||||
let cylinder_field = CylinderField {
|
let cylinder_field = CylinderField {
|
||||||
space: node.borrow().spatial.as_ref().unwrap().clone(),
|
space: node.borrow().spatial.as_ref().unwrap().clone(),
|
||||||
length: Cell::new(length),
|
length: Cell::new(length),
|
||||||
@@ -289,6 +297,10 @@ impl SphereField {
|
|||||||
node.borrow().spatial.is_some(),
|
node.borrow().spatial.is_some(),
|
||||||
"Node does not have a spatial attached!"
|
"Node does not have a spatial attached!"
|
||||||
);
|
);
|
||||||
|
ensure!(
|
||||||
|
node.borrow().field.is_none(),
|
||||||
|
"Node already has a field attached!"
|
||||||
|
);
|
||||||
let sphere_field = SphereField {
|
let sphere_field = SphereField {
|
||||||
space: node.borrow().spatial.as_ref().unwrap().clone(),
|
space: node.borrow().spatial.as_ref().unwrap().clone(),
|
||||||
radius: Cell::new(radius),
|
radius: Cell::new(radius),
|
||||||
|
|||||||
Reference in New Issue
Block a user