Skip to content

Commit b191fdd

Browse files
committed
Remove 'To u32', 'To u64', and 'To f64' number conversion nodes
1 parent d7fbbac commit b191fdd

File tree

10 files changed

+46
-28
lines changed

10 files changed

+46
-28
lines changed

demo-artwork/changing-seasons.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/isometric-fountain.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/marbled-mandelbrot.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/painted-dreams.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/parametric-dunescape.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/procedural-string-lights.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/red-dress.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/valley-of-spires.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/src/messages/portfolio/document_migration.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,44 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
722722

723723
document.network_interface.replace_reference_name(node_id, network_path, "Sample Polyline".to_string());
724724
}
725+
726+
// Replace "To u32" and "To u64" nodes with "Floor" nodes
727+
if reference == "To u32" || reference == "To u64" {
728+
let node_definition = resolve_document_node_type("Floor").unwrap();
729+
let new_node_template = node_definition.default_node_template();
730+
let document_node = new_node_template.document_node;
731+
document.network_interface.replace_implementation(node_id, network_path, document_node.implementation.clone());
732+
document
733+
.network_interface
734+
.replace_implementation_metadata(node_id, network_path, new_node_template.persistent_node_metadata);
735+
736+
let old_inputs = document.network_interface.replace_inputs(node_id, document_node.inputs.clone(), network_path);
737+
738+
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
739+
740+
document.network_interface.replace_reference_name(node_id, network_path, "Floor".to_string());
741+
document
742+
.network_interface
743+
.set_manual_compostion(node_id, network_path, graph_craft::concrete!(graphene_std::Context).into());
744+
}
745+
746+
// Replace the "To f64" node with the "Identity" node
747+
if reference == "To f64" {
748+
let node_definition = resolve_document_node_type("Identity").unwrap();
749+
let new_node_template = node_definition.default_node_template();
750+
let document_node = new_node_template.document_node;
751+
document.network_interface.replace_implementation(node_id, network_path, document_node.implementation.clone());
752+
document
753+
.network_interface
754+
.replace_implementation_metadata(node_id, network_path, new_node_template.persistent_node_metadata);
755+
756+
let old_inputs = document.network_interface.replace_inputs(node_id, document_node.inputs.clone(), network_path);
757+
758+
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
759+
760+
document.network_interface.replace_reference_name(node_id, network_path, "Identity".to_string());
761+
document.network_interface.set_manual_compostion(node_id, network_path, None);
762+
}
725763
}
726764

727765
// 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
@@ -272,26 +272,6 @@ fn random<U: num_traits::float::Float>(
272272
result * (max - min) + min
273273
}
274274

275-
/// 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.
276-
#[node_macro::node(name("To u32"), category("Math: Numeric"))]
277-
fn to_u32<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U) -> u32 {
278-
let value = U::clamp(value, U::from(0.).unwrap(), U::from(u32::MAX as f64).unwrap());
279-
value.to_u32().unwrap()
280-
}
281-
282-
/// 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.
283-
#[node_macro::node(name("To u64"), category("Math: Numeric"))]
284-
fn to_u64<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U) -> u64 {
285-
let value = U::clamp(value, U::from(0.).unwrap(), U::from(u64::MAX as f64).unwrap());
286-
value.to_u64().unwrap()
287-
}
288-
289-
/// 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.
290-
#[node_macro::node(name("To f64"), category("Math: Numeric"))]
291-
fn to_f64<U: num_traits::int::PrimInt>(_: impl Ctx, #[implementations(u32, u64)] value: U) -> f64 {
292-
value.to_f64().unwrap()
293-
}
294-
295275
/// The rounding function (round) maps an input value to its nearest whole number. Halfway values are rounded away from zero.
296276
#[node_macro::node(category("Math: Numeric"))]
297277
fn round<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U) -> U {

0 commit comments

Comments
 (0)