Преглед изворни кода

Merge branch 'master' into camerafix

Daniel Salvadori пре 7 година
родитељ
комит
128b30524a
1 измењених фајлова са 6 додато и 41 уклоњено
  1. 6 41
      core/node.go

+ 6 - 41
core/node.go

@@ -640,53 +640,18 @@ func (n *Node) UpdateMatrix() bool {
 	return true
 }
 
-// UpdateMatrixWorld updates the world transform matrix for this node and for all of its children.
+// UpdateMatrixWorld updates this node world transform matrix and of all its children
 func (n *Node) UpdateMatrixWorld() {
 
+	n.UpdateMatrix()
 	if n.parent == nil {
-		n.updateMatrixWorld(&n.matrix)
+		n.matrixWorld = n.matrix
 	} else {
 		parent := n.parent.GetNode()
-		n.updateMatrixWorld(&parent.matrixWorld)
+		n.matrixWorld.MultiplyMatrices(&parent.matrixWorld, &n.matrix)
 	}
-}
-
-// updateMatrixWorld is used internally by UpdateMatrixWorld.
-// If the local transform matrix has changed, this method updates it and also the world matrix of this node.
-// Children are updated recursively. If any node has changed, then we update the world matrix
-// of all of its descendants regardless if their local matrices have changed.
-func (n *Node) updateMatrixWorld(parentMatrixWorld *math32.Matrix4) {
-
-	// If the local transform matrix for this node has changed then we need to update the local
-	// matrix for this node and also the world matrix for this and all subsequent nodes.
-	if n.UpdateMatrix() {
-		n.matrixWorld.MultiplyMatrices(parentMatrixWorld, &n.matrix)
-
-		// Update matrices of children recursively, always updating the world matrix
-		for _, ichild := range n.children {
-			ichild.GetNode().updateMatrixWorldNoCheck(&n.matrixWorld)
-		}
-	} else {
-		// Update matrices of children recursively, continuing to check for changes
-		for _, ichild := range n.children {
-			ichild.GetNode().updateMatrixWorld(&n.matrixWorld)
-		}
-	}
-}
-
-// updateMatrixWorldNoCheck is used internally by updateMatrixWorld.
-// This method should be called when a node has changed since it always updates the matrix world.
-func (n *Node) updateMatrixWorldNoCheck(parentMatrixWorld *math32.Matrix4) {
-
-	// Update the local transform matrix (if necessary)
-	n.UpdateMatrix()
-
-	// Always update the matrix world since an ancestor of this node has changed
-	// (i.e. and ancestor had its local transform matrix modified)
-	n.matrixWorld.MultiplyMatrices(parentMatrixWorld, &n.matrix)
-
-	// Update matrices of children recursively
+	// Update this Node children matrices
 	for _, ichild := range n.children {
-		ichild.GetNode().updateMatrixWorldNoCheck(&n.matrixWorld)
+		ichild.UpdateMatrixWorld()
 	}
 }