MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / updateRaytracingAABBData

Method updateRaytracingAABBData

Source/Falcor/Scene/Scene.cpp:944–1046  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

942 }
943
944 IScene::UpdateFlags Scene::updateRaytracingAABBData(bool forceUpdate)
945 {
946 // This function updates the global list of AABBs for all procedural primitives.
947 // TODO: Move this code to the GPU. Then the CPU copies of some buffers won't be needed anymore.
948 IScene::UpdateFlags flags = IScene::UpdateFlags::None;
949
950 size_t curveAABBCount = 0;
951 for (const auto& curve : mCurveDesc) curveAABBCount += curve.indexCount;
952
953 size_t customAABBCount = mCustomPrimitiveAABBs.size();
954 size_t totalAABBCount = curveAABBCount + customAABBCount;
955
956 if (totalAABBCount > std::numeric_limits<uint32_t>::max())
957 {
958 FALCOR_THROW("Procedural primitive count exceeds the maximum");
959 }
960
961 // If there are no procedural primitives, clear the CPU buffer and return.
962 // We'll leave the GPU buffer to be lazily re-allocated when needed.
963 if (totalAABBCount == 0)
964 {
965 mRtAABBRaw.clear();
966 return flags;
967 }
968
969 mRtAABBRaw.resize(totalAABBCount);
970 uint32_t index = 0;
971
972 size_t firstUpdated = std::numeric_limits<size_t>::max();
973 size_t lastUpdated = 0;
974
975 if (forceUpdate)
976 {
977 // Compute AABBs of curve segments.
978 for (const auto& curve : mCurveDesc)
979 {
980 // Track range of updated AABBs.
981 // TODO: Per-curve flag to indicate changes. For now assume all curves need updating.
982 firstUpdated = std::min(firstUpdated, (size_t)index);
983 lastUpdated = std::max(lastUpdated, (size_t)index + curve.indexCount);
984
985 const auto* indexData = &mCurveIndexData[curve.ibOffset];
986 const auto* staticData = &mCurveStaticData[curve.vbOffset];
987
988 for (uint32_t j = 0; j < curve.indexCount; j++)
989 {
990 AABB curveSegBB;
991 uint32_t v = indexData[j];
992
993 for (uint32_t k = 0; k <= curve.degree; k++)
994 {
995 curveSegBB.include(staticData[v + k].position - float3(staticData[v + k].radius));
996 curveSegBB.include(staticData[v + k].position + float3(staticData[v + k].radius));
997 }
998
999 mRtAABBRaw[index++] = static_cast<RtAABB>(curveSegBB);
1000 }
1001 flags |= IScene::UpdateFlags::CurvesMoved;

Callers

nothing calls this directly

Calls 11

maxFunction · 0.50
minFunction · 0.50
sizeMethod · 0.45
clearMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
setNameMethod · 0.45
setBufferMethod · 0.45
getSizeMethod · 0.45
setBlobMethod · 0.45

Tested by

no test coverage detected