MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / UpdateInstance

Method UpdateInstance

src/engine/Scene.cpp:1222–1249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1220 if (m_Resources == nullptr || uint(geometry.globalGeometryIndex) >= m_Resources->geometryData.size() )
1221 return nullptr;
1222
1223 return &m_Resources->geometryData[geometry.globalGeometryIndex];
1224}
1225
1226
1227void Scene::UpdateInstance(const std::shared_ptr<MeshInstance>& instance)
1228{
1229 SceneGraphNode* node = instance->GetNode();
1230 if (!node)
1231 return;
1232
1233 InstanceData& idata = m_Resources->instanceData[instance->GetInstanceIndex()];
1234 affineToColumnMajor(node->GetLocalToWorldTransformFloat(), idata.transform);
1235 affineToColumnMajor(node->GetPrevLocalToWorldTransformFloat(), idata.prevTransform);
1236
1237 const auto& mesh = instance->GetMesh();
1238 idata.firstGeometryInstanceIndex = instance->GetGeometryInstanceIndex();
1239 idata.numGeometries = uint32_t(mesh->geometries.size());
1240 idata.firstGeometryIndex = idata.numGeometries > 0 ? mesh->geometries[0]->globalGeometryIndex : -1;
1241 idata.flags = 0u;
1242
1243 if (mesh->type == MeshType::CurveDisjointOrthogonalTriangleStrips)
1244 {
1245 idata.flags |= InstanceFlags_CurveDisjointOrthogonalTriangleStrips;
1246 }
1247 else if (mesh->type == MeshType::CurveLinearSweptSpheres)
1248 {
1249 // NVAPI does not support Vulkan, so NvRtIsLssHit() cannot be used to detect LSS hits.
1250 // Instead, we explicitly mark each LSS instance with a flag and check this flag during hit processing.
1251 // For consistency and completeness, this flag is also set for DX12.
1252 idata.flags |= InstanceFlags_CurveLinearSweptSpheres;

Callers

nothing calls this directly

Calls 5

affineToColumnMajorFunction · 0.85
GetNodeMethod · 0.80
GetInstanceIndexMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected