worldmaking / mischmasch

https://www.alicelab.world/msvr
MIT License
9 stars 1 forks source link

can we filter the sync protocol messages based on the automerge.change message? #240

Open michaelpalumbo opened 1 year ago

michaelpalumbo commented 1 year ago

use: given a set of incoming changes, if we have their change messages (i.e. 'add op', 'add cable', 'update param value') then we can tell Patch.js to set the dirty flag(s) only for the associated part of the system. in other words, if a module's position or quaternion is changed, there's no reason to set the this.dirty.audio.param as true. (and it will cause unnecessary prcoessing of graph and/or audio graph changes if we are setting all the flags to true each time we receive an automerge sync message (which can be very often))

follow this issue I posted here

// possible pseudocode
// after we receive a sync message and apply it to the doc in *Patch.js:receiveSyncMessages:case 'syncMessage'*
let changes = Automerge.getChanges(this.document, nextDoc) // note this is returns a Uint8Array
// run a for..loop to process each change
// write a switch statement on each change message
switch (changeMsg) {
  case 'add op':
    this.dirty.vr = true
    this.dirty.audio.graph = true
  break;
  case 'param':
    this.dirty.vr = true
    this.dirty.audio.param = true
  break;  
}