public void Execute(int i) { int halfLength = BVHArray.Length / 2; int leafNodeId = halfLength + i; BVHAABB leafNodeAABB = BVHArray[leafNodeId].aabb; int parentIndex = BVHArray[leafNodeId].ParentNodeIndex; while (parentIndex != -1) { //todo locks! BVHNode parent = BVHArray[parentIndex]; if (parent.IsValid < 1) { parent.aabb = leafNodeAABB; parent.IsValid = 1; BVHArray[parentIndex] = parent; break; } else { parent.aabb = Utils.GetEncompassingAABB(parent.aabb, leafNodeAABB); parent.IsValid = 2; BVHArray[parentIndex] = parent; } leafNodeAABB = parent.aabb; parentIndex = parent.ParentNodeIndex; } }
public void Execute() { BVHAABB startAABB = results[0]; for (int i = 1; i < results.Length; i++) { startAABB = Utils.GetEncompassingAABB(startAABB, results[i]); } results[0] = startAABB; }
public void Execute(int i) { int start = i * batchSize; int end = (i + 1) * batchSize > AABB.Length ? AABB.Length : (i + 1) * batchSize; BVHAABB startAABB = AABB[start]; for (int k = start + 1; k < end; k++) { startAABB = Utils.GetEncompassingAABB(startAABB, AABB[k]); } results[i] = startAABB; }
public void SerialExecute(int i) { int halfLength = BVHArray.Length / 2; int leafNodeId = halfLength + i; BVHAABB leafNodeAABB = BVHArray[leafNodeId].aabb; int parentIndex = BVHArray[leafNodeId].ParentNodeIndex; while (parentIndex != -1) { BVHNode parent = BVHArray[parentIndex]; if (parent.IsValid == 0) { parent.aabb = leafNodeAABB; parent.IsValid = 1; BVHArray[parentIndex] = parent; } parent.aabb = Utils.GetEncompassingAABB(parent.aabb, leafNodeAABB); parent.IsValid = 2; BVHArray[parentIndex] = parent; leafNodeAABB = parent.aabb; parentIndex = parent.ParentNodeIndex; } }