pex-renderer icon indicating copy to clipboard operation
pex-renderer copied to clipboard

Avoid creating parent stack in transform

Open vorg opened this issue 7 years ago • 3 comments

The following piece of code with array cration in a loop via unshift an for each function could be replaced with a for loop and new mat4.premultiply function

  mat4.identity(this.modelMatrix)
  var parents = []
  var parent = this
  while (parent) {
    parents.unshift(parent) // TODO: GC
    parent = parent.parent
  }
  parents.forEach((p) => { // TODO: forEach
    mat4.mult(this.modelMatrix, p.localModelMatrix)
  })

vorg avatar Aug 06 '18 22:08 vorg

Couldn't we just multiply the local matrix by the parent modelMatrix? Effectively traversing the children instead of the parents?

dmnsgn avatar Jan 21 '19 16:01 dmnsgn