Closed dasimonde closed 4 months ago
error[E0499]: cannot borrow
context` as mutable more than once at a time
--> src/engine/mod.rs:908:50
|
903 | if let Some(node) = context.scene.graph.try_get_mut(handle_node) {
| ------------------- first mutable borrow occurs here
...
908 | script.on_deinit(&mut context)
| ^^^^^^^^^^^^ second mutable borrow occurs here
...
912 | for script in node
| ---- first borrow later used here
error[E0499]: cannot borrow context
as mutable more than once at a time
--> src/engine/mod.rs:921:50
|
903 | if let Some(node) = context.scene.graph.try_get_mut(handle_node) {
| ------------------- first mutable borrow occurs here
...
912 | for script in node
| _-
913 | | .secondary_scripts
914 | | .iter_mut()
915 | | .map(|i| i.0.as_mut())
916 | | .flatten()
| |- first borrow later used here
...
921 | script.on_deinit(&mut context);
| ^^^^^^^^^^^^ second mutable borrow occurs here
error[E0499]: cannot borrow *context as mutable more than once at a time
--> src/engine/mod.rs:1067:30 |
1052 | let node = match context.scene.graph.try_get_mut(context.handle) { | ------------------- first mutable borrow occurs here ... 1067 | func(script, context); | ^^^^^^^ second mutable borrow occurs here 1068 | }; 1069 | node.script = script; | ---- first borrow later used here ... 1088 | define_process_node!(process_node, ScriptContext); | ------------------------------------------------- in this macro invocation |
---|
= note: this error originates in the macro `define_process_node` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0499]: cannot borrow *context as mutable more than once at a time
--> src/engine/mod.rs:1078:35 |
1052 | let node = match context.scene.graph.try_get_mut(context.handle) { | ------------------- first mutable borrow occurs here ... 1071 | for vec_script in node.secondary_scripts.iter_mut() { | --------------------------------- first borrow later used here ... 1078 | func(&mut script, context); | ^^^^^^^ second mutable borrow occurs here ... 1088 | define_process_node!(process_node, ScriptContext); | ------------------------------------------------- in this macro invocation |
---|
= note: this error originates in the macro `define_process_node` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0499]: cannot borrow *context as mutable more than once at a time
--> src/engine/mod.rs:1067:30 |
1052 | let node = match context.scene.graph.try_get_mut(context.handle) { | ------------------- first mutable borrow occurs here ... 1067 | func(script, context); | ^^^^^^^ second mutable borrow occurs here 1068 | }; 1069 | node.script = script; | ---- first borrow later used here ... 1089 | define_process_node!(process_node_message, ScriptMessageContext); | ---------------------------------------------------------------- in this macro invocation |
---|
= note: this error originates in the macro `define_process_node` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0499]: cannot borrow *context as mutable more than once at a time
--> src/engine/mod.rs:1078:35 |
1052 | let node = match context.scene.graph.try_get_mut(context.handle) { | ------------------- first mutable borrow occurs here ... 1071 | for vec_script in node.secondary_scripts.iter_mut() { | --------------------------------- first borrow later used here ... 1078 | func(&mut script, context); | ^^^^^^^ second mutable borrow occurs here ... 1089 | define_process_node!(process_node_message, ScriptMessageContext); | ---------------------------------------------------------------- in this macro invocation |
---|
= note: this error originates in the macro `define_process_node` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0499]: cannot borrow *scene
as mutable more than once at a time
--> src/engine/mod.rs:1928:41
|
1916 | if let Some(node) = scene.graph.try_get_mut(node_task_handler.node_handle) {
| ----------- first mutable borrow occurs here
...
1928 | scene,
| ^^^^^ second mutable borrow occurs here
...
1940 | node.script.replace(script);
| ---- first borrow later used here
error[E0499]: cannot borrow *scene
as mutable more than once at a time
--> src/engine/mod.rs:1953:45
|
1916 | if let Some(node) = scene.graph.try_get_mut(node_task_handler.node_handle) {
| ----------- first mutable borrow occurs here
...
1943 | for vec_script in node.secondary_scripts.iter_mut() {
| --------------------------------- first borrow later used here
...
1953 | scene,
| ^^^^^ second mutable borrow occurs here
`
Everything should work now. The scripts for nodes in old scenes are loaded correctly now. Also I removed the Option type for the script buffer and combine script variable and the script buffer variable in one variable.
Could you please also fix tests compilation and ensure that they pass? Also CI fails on documentation, run cargo doc --all-features
and fix the warnings/errors too. This PR changes fundamental part of the engine and it must be perfect to not break existing projects.
I have implemented all your change requests and all CI tests are green now
I hope everything is fine now
Nodes can have multiple scripts now