protected override Vector3 UpdateTarget(RichFunnel fn) { Matrix4x4 matrix = this.graph.GetMatrix(); Matrix4x4 inverse = matrix.inverse; Debug.DrawRay(matrix.MultiplyPoint3x4(this.tr.position), Vector3.up * 2f, Color.red); Debug.DrawRay(inverse.MultiplyPoint3x4(this.tr.position), Vector3.up * 2f, Color.green); this.buffer.Clear(); Vector3 vector = this.tr.position; Vector3 vector2 = matrix.MultiplyPoint3x4(vector); bool flag; vector2 = fn.Update(vector2, this.buffer, 2, out this.lastCorner, out flag); vector = inverse.MultiplyPoint3x4(vector2); Debug.DrawRay(vector, Vector3.up * 3f, Color.black); for (int i = 0; i < this.buffer.Count; i++) { this.buffer[i] = inverse.MultiplyPoint3x4(this.buffer[i]); Debug.DrawRay(this.buffer[i], Vector3.up * 3f, Color.yellow); } if (flag && !this.waitingForPathCalc) { this.UpdatePath(); } return(vector); }
protected override Vector3 UpdateTarget(RichFunnel fn) { Matrix4x4 m = graph.GetMatrix(); Matrix4x4 mi = m.inverse; Debug.DrawRay(m.MultiplyPoint3x4(tr.position), Vector3.up * 2, Color.red); Debug.DrawRay(mi.MultiplyPoint3x4(tr.position), Vector3.up * 2, Color.green); buffer.Clear(); /* Current position. We read and write to tr.position as few times as possible since doing so * is much slower than to read and write from/to a local variable */ Vector3 position = tr.position; bool requiresRepath; // Update, but first convert our position to graph space, then convert the result back to world space var positionInGraphSpace = m.MultiplyPoint3x4(position); positionInGraphSpace = fn.Update(positionInGraphSpace, buffer, 2, out lastCorner, out requiresRepath); position = mi.MultiplyPoint3x4(positionInGraphSpace); Debug.DrawRay(position, Vector3.up * 3, Color.black); // convert the result to world space from graph space for (int i = 0; i < buffer.Count; i++) { buffer[i] = mi.MultiplyPoint3x4(buffer[i]); Debug.DrawRay(buffer[i], Vector3.up * 3, Color.yellow); } if (requiresRepath && !waitingForPathCalc) { UpdatePath(); } return(position); }