MCPcopy Create free account
hub / github.com/PerroEngine/Perro / extend

Method extend

perro_source/api_modules/perro_runtime_api/src/sub_apis/node.rs:508–542  ·  view source on GitHub ↗
(&mut self, collection: impl IntoNodeCollection, parent: Option<usize>)

Source from the content-addressed store, hash-verified

506 }
507
508 pub fn extend(&mut self, collection: impl IntoNodeCollection, parent: Option<usize>) -> usize {
509 let mut collection = collection.into_node_collection();
510 let entry_offset = self.entries.len();
511 let spec_offset = self.specs.len();
512 let scene_offset = self.scenes.len();
513 let mut root = collection.root.map(|root| entry_offset + root);
514 for spec in &mut collection.specs {
515 spec.parent = spec.parent.map(|parent| entry_offset + parent).or(parent);
516 }
517 for scene in &mut collection.scenes {
518 scene.parent = scene.parent.map(|parent| entry_offset + parent).or(parent);
519 }
520 for entry in collection.entries {
521 let entry_parent = match entry {
522 NodeCollectionEntry::Node(index) => collection.specs[index].parent,
523 NodeCollectionEntry::Scene(index) => collection.scenes[index].parent,
524 };
525 if root.is_none() && entry_parent == parent {
526 root = Some(self.entries.len());
527 }
528 match entry {
529 NodeCollectionEntry::Node(index) => {
530 self.specs.push(collection.specs[index].clone());
531 self.entries
532 .push(NodeCollectionEntry::Node(spec_offset + index));
533 }
534 NodeCollectionEntry::Scene(index) => {
535 self.scenes.push(collection.scenes[index].clone());
536 self.entries
537 .push(NodeCollectionEntry::Scene(scene_offset + index));
538 }
539 }
540 }
541 root.unwrap_or(entry_offset)
542 }
543}
544
545pub trait IntoNodeCollection {

Callers 15

preview_runtime_orderFunction · 0.80
scan_res_pathsFunction · 0.80
rename_bitmask_instanceFunction · 0.80
rename_value_rowFunction · 0.80
rows_for_hashMethod · 0.80
parseMethod · 0.80
parse_frame_blockMethod · 0.80

Calls 5

SceneClass · 0.85
into_node_collectionMethod · 0.80
cloneMethod · 0.80
lenMethod · 0.45
pushMethod · 0.45