Reparent modifiers

This commit is contained in:
alonso.torres 2025-04-16 11:00:33 +02:00
parent f3d13005b2
commit daf048e258
10 changed files with 283 additions and 52 deletions

View file

@ -16,7 +16,7 @@ mod wapi;
mod wasm;
use crate::mem::SerializableResult;
use crate::shapes::{BoolType, ConstraintH, ConstraintV, TransformEntry, Type};
use crate::shapes::{BoolType, ConstraintH, ConstraintV, StructureEntry, TransformEntry, Type};
use crate::utils::uuid_from_u32_quartet;
use crate::uuid::Uuid;
use indexmap::IndexSet;
@ -607,9 +607,31 @@ pub extern "C" fn propagate_modifiers() -> *mut u8 {
});
}
#[no_mangle]
pub extern "C" fn set_structure_modifiers() {
let bytes = mem::bytes();
let entries: Vec<_> = bytes
.chunks(40)
.map(|data| StructureEntry::from_bytes(data.try_into().unwrap()))
.collect();
with_state!(state, {
for entry in entries {
if !state.structure.contains_key(&entry.parent) {
state.structure.insert(entry.parent, Vec::new());
}
state.structure.get_mut(&entry.parent).unwrap().push(entry);
}
});
mem::free_bytes();
}
#[no_mangle]
pub extern "C" fn clean_modifiers() {
with_state!(state, {
state.structure.clear();
state.modifiers.clear();
});
}