GraphiteEditor / GraphiteEditor/Graphite
Typing of disconnected node outputs
- Ngôn ngữ chính
- Rust
- Star
- 27.2k
- Fork
- 1.3k
- Merge trung bình
- 20 giờ 5 phút
- Pull request đã merge (30 ngày)
- 57
Mô tả
When a node is disconnected from the graph output, the type hints for the output are not available. This occurs even if the output type is completely unambiguous such as the « tangent on path » node. This makes it rather frustrating to make graphs since nodes are often disconnected when building a graph.
```diff
diff --git a/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs b/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs
index 685d32e59..8f80c3208 100644
--- a/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs
+++ b/editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs
@@ -337,12 +337,29 @@ impl NodeNetworkInterface {
let Some(implementation) = self.implementation(node_id, network_path) else {
return TypeSource::Error("Could not get implementation");
};
+ info!("Got node");
match implementation {
DocumentNodeImplementation::Network(_) => self.input_type(&InputConnector::Export(*output_index), &[network_path, &[*node_id]].concat()),
- DocumentNodeImplementation::ProtoNode(_) => match self.resolved_types.types.get(&[network_path, &[*node_id]].concat()) {
- Some(resolved_type) => TypeSource::Compiled(resolved_type.output.clone()),
- None => TypeSource::Unknown,
- },
+ DocumentNodeImplementation::ProtoNode(proto_node_identifier) => {
+ if let Some(resolved_type) = self.resolved_types.types.get(&[network_path, &[*node_id]].concat()) {
+ TypeSource::Compiled(resolved_type.output.clone())
+ } else {
+ let Some(implementations) = NODE_REGISTRY.get(proto_node_identifier) else {
+ error!("Protonode {proto_node_identifier:?} not found in registry in output_type");
+ return TypeSource::Error("no protonode");
+ };
+
+ let mut possible_outputs = implementations.keys().map(|io| &io.return_value).collect::>();
+ possible_outputs.dedup();
+ // Only type unambiguous outputs (just one possible type)
+ if let Some([result]) = possible_outputs.as_array() {
+ TypeSource::Compiled((*result).clone())
+ } else {
+ info!("Ambiguous outputs {possible_outputs:#?}");
+ TypeSource::Unknown
+ }
+ }
+ }
DocumentNodeImplementation::Extract => TypeSource::Compiled(concrete!(())),
}
}
```
It should be possible to further filter the possible output types based on the known input types.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu tại editor/src/messages/portfolio/document/utility_types/network_interface/resolved_types.rs, ở NodeNetworkInterface::output_type, sau đó kiểm tra resolved_types.types và cách xử lý NODE_REGISTRY đối với các đầu ra của ProtoNode. Xác minh rằng các node bị ngắt kết nối có một kiểu đầu ra khả dĩ sẽ cung cấp kiểu đó, trong khi các đầu ra không rõ ràng vẫn là unknown; tangent on path node là ví dụ được nêu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rust
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 72/100