public JobHandle Calculate(JobHandle deps, ComponentDataArray <AABB> AABB) { //UnityEngine.Profiling.Profiler.BeginSample("update bbx"); var bound = GetBoundingBox(AABB); //UnityEngine.Profiling.Profiler.EndSample(); //UnityEngine.Profiling.Profiler.BeginSample("update bvh"); var resetBVH = new ResetBVH() { BVHArray = BVHArray, }; deps = resetBVH.Schedule(BVHArray.Length, 32, deps); var sortMortonCodes = new ComputeAndSortMortonCodes { aabbs = AABB, mortonCodes = mortonCodes, mortonCodesTemp = mortonCodesTemp, indexConverter = indexConverter, indexConverterTemp = indexConverterTemp, radixSortBitValues = radixSortBitValues, radixSortOffsets = radixSortOffsets, sortResultsArrayIsA = sortResultsArrayIsA, Bound = bound }; deps = sortMortonCodes.Schedule(deps); deps.Complete(); var constructBVHChild = new ConstructBVHChildNodes() { AABB = AABB, BVHArray = BVHArray, indexConverter = indexConverter }; deps = constructBVHChild.Schedule(AABB.Length, 32, deps); deps.Complete(); var constructBVHInternal = new ConstructBVHInternalNodes() { BVHArray = BVHArray, mortonCodes = mortonCodes, NumObjects = AABB.Length, ParentIndex = parentIndex }; deps = constructBVHInternal.Schedule(AABB.Length - 1, 32, deps); var updateParentIndex = new UpdateBVHParentIndex() { BVHArray = BVHArray, ParentIndex = parentIndex }; deps = updateParentIndex.Schedule(BVHArray.Length, 32, deps); deps.Complete(); var updateAABB = new UpdateAABB() { BVHArray = BVHArray, //locks = locks }; for (int i = 0; i < AABB.Length; i++) { //updateAABB.Execute(i); } deps = updateAABB.Schedule(AABB.Length, 32, deps); //UnityEngine.Profiling.Profiler.EndSample(); if (bDebug) { deps.Complete(); //Debug.Assert(ValidateBVH(BVHArray)); } /*for (int i = 0; i < BVHArray.Length - 1; i++) * { * if (BVHArray[i].IsValid > 0) * { * //DebugUtils.DrawAABB(BVHArray[i].aabb, UnityEngine.Random.ColorHSV()); * } * if (BVHArray[i].IsValid == 1) * { * // Debug.Log("error at " + i); * } * }*/ return(deps); }
public JobHandle Calculate(JobHandle deps, ComponentDataArray <AABB> AABB) { var bound = GetBoundingBox(AABB); var resetBVH = new ResetBVH() { BVHArray = BVHArray, }; deps = resetBVH.Schedule(BVHArray.Length, 32, deps); var sortMortonCodes = new ComputeAndSortMortonCodes { aabbs = AABB, mortonCodes = mortonCodes, mortonCodesTemp = mortonCodesTemp, indexConverter = indexConverter, indexConverterTemp = indexConverterTemp, radixSortBitValues = radixSortBitValues, radixSortOffsets = radixSortOffsets, sortResultsArrayIsA = sortResultsArrayIsA, Bound = bound }; deps = sortMortonCodes.Schedule(deps); deps.Complete(); var constructBVHChild = new ConstructBVHChildNodes() { AABB = AABB, BVHArray = BVHArray, indexConverter = indexConverter }; deps = constructBVHChild.Schedule(AABB.Length, 32, deps); var constructBVHInternal = new ConstructBVHInternalNodes() { BVHArray = BVHArray, mortonCodes = mortonCodes, NumObjects = AABB.Length }; deps = constructBVHInternal.Schedule(AABB.Length - 1, 32, deps); var updateAABB = new UpdateAABB() { BVHArray = BVHArray }; deps = updateAABB.Schedule(AABB.Length, 32, deps); /*deps.Complete(); * for (int i = 0 ; i < BVHArray.Length / 2; i++) * { * if (BVHArray[i].IsValid > 0) * { * DebugUtils.DrawAABB(BVHArray[i].aabb, UnityEngine.Random.ColorHSV()); * } * }*/ return(deps); }