Skip to content

Commit 38ef855

Browse files
committed
Remove 'To u32', 'To u64', and 'To f64' number conversion nodes
1 parent a182a73 commit 38ef855

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

editor/src/messages/portfolio/document_migration.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,44 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
834834
}
835835
}
836836
}
837+
838+
// Replace "To u32" and "To u64" nodes with "Floor" nodes
839+
if reference == "To u32" || reference == "To u64" {
840+
let node_definition = resolve_document_node_type("Floor").unwrap();
841+
let new_node_template = node_definition.default_node_template();
842+
let document_node = new_node_template.document_node;
843+
document.network_interface.replace_implementation(node_id, network_path, document_node.implementation.clone());
844+
document
845+
.network_interface
846+
.replace_implementation_metadata(node_id, network_path, new_node_template.persistent_node_metadata);
847+
848+
let old_inputs = document.network_interface.replace_inputs(node_id, document_node.inputs.clone(), network_path);
849+
850+
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
851+
852+
document.network_interface.replace_reference_name(node_id, network_path, "Floor".to_string());
853+
document
854+
.network_interface
855+
.set_manual_compostion(node_id, network_path, graph_craft::concrete!(graphene_std::Context).into());
856+
}
857+
858+
// Replace the "To f64" node with the "Identity" node
859+
if reference == "To f64" {
860+
let node_definition = resolve_document_node_type("Identity").unwrap();
861+
let new_node_template = node_definition.default_node_template();
862+
let document_node = new_node_template.document_node;
863+
document.network_interface.replace_implementation(node_id, network_path, document_node.implementation.clone());
864+
document
865+
.network_interface
866+
.replace_implementation_metadata(node_id, network_path, new_node_template.persistent_node_metadata);
867+
868+
let old_inputs = document.network_interface.replace_inputs(node_id, document_node.inputs.clone(), network_path);
869+
870+
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
871+
872+
document.network_interface.replace_reference_name(node_id, network_path, "Identity".to_string());
873+
document.network_interface.set_manual_compostion(node_id, network_path, None);
874+
}
837875
}
838876

839877
// Ensure layers are positioned as stacks if they are upstream siblings of another layer

node-graph/gmath-nodes/src/lib.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -346,26 +346,6 @@ fn random<U: num_traits::float::Float>(
346346
result * (max - min) + min
347347
}
348348

349-
/// Convert a number to an integer of the type u32, which may be the required type for certain node inputs. This will be removed in the future when automatic type conversion is implemented.
350-
#[node_macro::node(name("To u32"), category("Math: Numeric"))]
351-
fn to_u32<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U) -> u32 {
352-
let value = U::clamp(value, U::from(0.).unwrap(), U::from(u32::MAX as f64).unwrap());
353-
value.to_u32().unwrap()
354-
}
355-
356-
/// Convert a number to an integer of the type u64, which may be the required type for certain node inputs. This will be removed in the future when automatic type conversion is implemented.
357-
#[node_macro::node(name("To u64"), category("Math: Numeric"))]
358-
fn to_u64<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U) -> u64 {
359-
let value = U::clamp(value, U::from(0.).unwrap(), U::from(u64::MAX as f64).unwrap());
360-
value.to_u64().unwrap()
361-
}
362-
363-
/// Convert an integer to a decimal number of the type f64, which may be the required type for certain node inputs. This will be removed in the future when automatic type conversion is implemented.
364-
#[node_macro::node(name("To f64"), category("Math: Numeric"))]
365-
fn to_f64<U: num_traits::int::PrimInt>(_: impl Ctx, #[implementations(u32, u64)] value: U) -> f64 {
366-
value.to_f64().unwrap()
367-
}
368-
369349
/// The rounding function (round) maps an input value to its nearest whole number. Halfway values are rounded away from zero.
370350
#[node_macro::node(category("Math: Numeric"))]
371351
fn round<U: num_traits::float::Float>(

0 commit comments

Comments
 (0)