* Fix regressions * Fix copy to points properties --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
9e2bda36b0
commit
408f9bffa1
File diff suppressed because one or more lines are too long
|
|
@ -41,7 +41,6 @@ pub struct NodePropertiesContext<'a> {
|
|||
impl NodePropertiesContext<'_> {
|
||||
pub fn call_widget_override(&mut self, node_id: &NodeId, index: usize) -> Option<Vec<LayoutGroup>> {
|
||||
let Some(input_properties_row) = self.network_interface.input_properties_row(node_id, index, self.selection_network_path) else {
|
||||
log::error!("Could not get input properties row at the beginning of call_widget_override");
|
||||
return None;
|
||||
};
|
||||
if let Some(widget_override) = &input_properties_row.widget_override {
|
||||
|
|
@ -2410,7 +2409,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
PropertiesRow::with_override(
|
||||
"Random Scale Bias",
|
||||
WidgetOverride::Number(NumberInputSettings {
|
||||
min: Some(0.),
|
||||
mode: NumberInputMode::Range,
|
||||
range_min: Some(-50.),
|
||||
range_max: Some(50.),
|
||||
|
|
@ -2710,7 +2708,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
};
|
||||
}
|
||||
let node_registry = graphene_core::registry::NODE_REGISTRY.lock().unwrap();
|
||||
'outer: for (id, metadata) in graphene_core::registry::NODE_METADATA.lock().unwrap().drain() {
|
||||
'outer: for (id, metadata) in graphene_core::registry::NODE_METADATA.lock().unwrap().iter() {
|
||||
use graphene_core::registry::*;
|
||||
|
||||
for node in custom.iter() {
|
||||
|
|
@ -2722,7 +2720,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
..
|
||||
} = node;
|
||||
match implementation {
|
||||
DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier { name }) if name == &id => continue 'outer,
|
||||
DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier { name }) if name == id => continue 'outer,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
@ -2734,7 +2732,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
description,
|
||||
properties,
|
||||
} = metadata;
|
||||
let Some(implementations) = &node_registry.get(&id) else { continue };
|
||||
let Some(implementations) = &node_registry.get(id) else { continue };
|
||||
let valid_inputs: HashSet<_> = implementations.iter().map(|(_, node_io)| node_io.call_argument.clone()).collect();
|
||||
let first_node_io = implementations.first().map(|(_, node_io)| node_io).unwrap_or(const { &NodeIOTypes::empty() });
|
||||
let mut input_type = &first_node_io.call_argument;
|
||||
|
|
@ -2769,7 +2767,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
document_node: DocumentNode {
|
||||
inputs,
|
||||
manual_composition: Some(input_type.clone()),
|
||||
implementation: DocumentNodeImplementation::ProtoNode(id.into()),
|
||||
implementation: DocumentNodeImplementation::ProtoNode(id.clone().into()),
|
||||
visible: true,
|
||||
skip_deduplication: false,
|
||||
..Default::default()
|
||||
|
|
@ -2793,7 +2791,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
},
|
||||
category: category.unwrap_or("UNCATEGORIZED"),
|
||||
description: Cow::Borrowed(description),
|
||||
properties,
|
||||
properties: *properties,
|
||||
};
|
||||
custom.push(node);
|
||||
}
|
||||
|
|
@ -3007,6 +3005,27 @@ fn static_input_properties() -> InputProperties {
|
|||
}) {
|
||||
number_input = number_input.mode(mode);
|
||||
}
|
||||
if let Some(range_min) = context
|
||||
.network_interface
|
||||
.input_metadata(&node_id, index, "range_min", context.selection_network_path)
|
||||
.and_then(|value| value.as_f64())
|
||||
{
|
||||
number_input = number_input.range_min(Some(range_min));
|
||||
}
|
||||
if let Some(range_max) = context
|
||||
.network_interface
|
||||
.input_metadata(&node_id, index, "range_max", context.selection_network_path)
|
||||
.and_then(|value| value.as_f64())
|
||||
{
|
||||
number_input = number_input.range_max(Some(range_max));
|
||||
}
|
||||
if let Some(is_integer) = context
|
||||
.network_interface
|
||||
.input_metadata(&node_id, index, "is_integer", context.selection_network_path)
|
||||
.and_then(|value| value.as_bool())
|
||||
{
|
||||
number_input = number_input.is_integer(is_integer);
|
||||
}
|
||||
let blank_assist = context
|
||||
.network_interface
|
||||
.input_metadata(&node_id, index, "blank_assist", context.selection_network_path)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ pub fn start_widgets(document_node: &DocumentNode, node_id: NodeId, index: usize
|
|||
widgets
|
||||
}
|
||||
|
||||
pub(crate) fn property_from_type(node_id: NodeId, index: usize, ty: &Type, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
pub(crate) fn property_from_type(node_id: NodeId, index: usize, ty: &Type, number_options: (Option<f64>, Option<f64>, Option<(f64, f64)>), context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let Some(name) = context.network_interface.input_name(&node_id, index, context.selection_network_path) else {
|
||||
log::warn!("A widget failed to be built for node {node_id}, index {index} because the input name could not be determined");
|
||||
return vec![];
|
||||
|
|
@ -104,7 +104,7 @@ pub(crate) fn property_from_type(node_id: NodeId, index: usize, ty: &Type, conte
|
|||
return vec![];
|
||||
};
|
||||
|
||||
let (mut number_min, mut number_max, range) = (None, None, None);
|
||||
let (mut number_min, mut number_max, range) = number_options;
|
||||
let mut number_input = NumberInput::default();
|
||||
if let Some((range_start, range_end)) = range {
|
||||
number_min = Some(range_start);
|
||||
|
|
@ -253,7 +253,7 @@ pub(crate) fn property_from_type(node_id: NodeId, index: usize, ty: &Type, conte
|
|||
}
|
||||
}
|
||||
Type::Generic(_) => vec![TextLabel::new("Generic type (not supported)").widget_holder()].into(),
|
||||
Type::Fn(_, out) => return property_from_type(node_id, index, out, context),
|
||||
Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, context),
|
||||
Type::Future(_) => vec![TextLabel::new("Future type (not supported)").widget_holder()].into(),
|
||||
};
|
||||
extra_widgets.push(widgets);
|
||||
|
|
@ -2114,12 +2114,42 @@ pub(crate) fn generate_node_properties(node_id: NodeId, context: &mut NodeProper
|
|||
let number_of_inputs = context.network_interface.number_of_inputs(&node_id, context.selection_network_path);
|
||||
for input_index in 1..number_of_inputs {
|
||||
let row = context.call_widget_override(&node_id, input_index).unwrap_or_else(|| {
|
||||
let input_type = context.network_interface.input_type(&InputConnector::node(node_id, input_index), context.selection_network_path);
|
||||
property_from_type(node_id, input_index, &input_type.0, context)
|
||||
let Some(implementation) = context.network_interface.implementation(&node_id, context.selection_network_path) else {
|
||||
log::error!("Could not get implementation for node {node_id}");
|
||||
return Vec::new();
|
||||
};
|
||||
|
||||
let mut number_options = (None, None, None);
|
||||
let input_type = match implementation {
|
||||
DocumentNodeImplementation::ProtoNode(proto_node_identifier) => {
|
||||
if let Some(field) = graphene_core::registry::NODE_METADATA
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get(&proto_node_identifier.name.clone().into_owned())
|
||||
.and_then(|metadata| metadata.fields.get(input_index))
|
||||
{
|
||||
number_options = (field.number_min, field.number_max, field.number_mode_range);
|
||||
}
|
||||
let Some(implementations) = &interpreted_executor::node_registry::NODE_REGISTRY.get(proto_node_identifier) else {
|
||||
log::error!("Could not get implementation for protonode {proto_node_identifier:?}");
|
||||
return Vec::new();
|
||||
};
|
||||
let first_node_io = implementations.keys().next().unwrap_or(const { &graphene_std::NodeIOTypes::empty() });
|
||||
let Some(input_type) = first_node_io.inputs.get(input_index) else {
|
||||
log::error!("Could not get input type for protonode {proto_node_identifier:?} at index {input_index:?}");
|
||||
return Vec::new();
|
||||
};
|
||||
input_type.clone()
|
||||
}
|
||||
_ => context.network_interface.input_type(&InputConnector::node(node_id, input_index), context.selection_network_path).0,
|
||||
};
|
||||
|
||||
property_from_type(node_id, input_index, &input_type, number_options, context)
|
||||
});
|
||||
layout.extend(row);
|
||||
}
|
||||
}
|
||||
|
||||
if layout.is_empty() {
|
||||
layout = node_no_properties(node_id, context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6294,18 +6294,24 @@ pub struct DocumentNodePersistentMetadataInputNames {
|
|||
|
||||
impl From<DocumentNodePersistentMetadataInputNames> for DocumentNodePersistentMetadata {
|
||||
fn from(old: DocumentNodePersistentMetadataInputNames) -> Self {
|
||||
let ret = DocumentNodePersistentMetadata {
|
||||
let input_properties = old
|
||||
.reference
|
||||
.as_ref()
|
||||
.and_then(|reference| resolve_document_node_type(reference))
|
||||
.map(|definition| definition.node_template.persistent_node_metadata.input_properties.clone())
|
||||
.unwrap_or(old.input_names.into_iter().map(|name| name.as_str().into()).collect());
|
||||
|
||||
DocumentNodePersistentMetadata {
|
||||
reference: old.reference,
|
||||
display_name: old.display_name,
|
||||
input_properties: old.input_names.into_iter().map(|name| name.as_str().into()).collect(),
|
||||
input_properties,
|
||||
output_names: old.output_names,
|
||||
has_primary_output: old.has_primary_output,
|
||||
locked: old.locked,
|
||||
pinned: old.pinned,
|
||||
node_type_metadata: old.node_type_metadata,
|
||||
network_metadata: old.network_metadata,
|
||||
};
|
||||
ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue