public void Execute(int index) { int halfBVHSize = BVHArray.Length / 2; int2 range = determineRange(index); int first = range.x; int last = range.y; // Determine where to split the range. int split = findSplit(first, last); int childAIndex = split == first ? split + halfBVHSize : split; int childBIndex = (split + 1) == last ? split + halfBVHSize + 1 : split + 1; BVHNode thisnode = new BVHNode(); thisnode.RightNodeIndex = childBIndex; thisnode.LeftNodeIndex = childAIndex; thisnode.EntityId = Entity.Null; thisnode.IsValid = 0; //No AABB Updated BVHArray[index] = thisnode; ParentIndex[childAIndex] = index; ParentIndex[childBIndex] = index; }
public void Execute(int i) { BVHNode node = BVHArray[i]; node.ParentNodeIndex = i == 0 ? -1 : ParentIndex[i]; BVHArray[i] = node; }
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(int i) { BVHNode bvhNode = BVHArray[i]; bvhNode.IsValid = 0; bvhNode.ParentNodeIndex = -1; bvhNode.aabb = new BVHAABB(); BVHArray[i] = bvhNode; }
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; } }
public void Execute(int i) { int halfLength = BVHArray.Length / 2; if (i < halfLength) { return; } int localId = i - halfLength; if (localId >= AABB.Length) { return; } int entityindex = indexConverter[i - halfLength]; BVHNode bvhNode = new BVHNode(); bvhNode.aabb = AABB[entityindex]; bvhNode.EntityId = Entities[entityindex]; bvhNode.RightNodeIndex = i; bvhNode.LeftNodeIndex = -1; bvhNode.IsValid = 2; BVHArray[i] = bvhNode; }