VR4Medical/ICI/Library/PackageCache/com.unity.xr.openxr@3903c1059bcf/Shared/Native~/openxr_utils.h
2025-07-29 13:45:50 +03:00

32 lines
1.0 KiB
C++

#pragma once
template <class TOUT, class TIN>
TOUT* FindNextPointerType(TIN* typeIn, XrStructureType structureType)
{
auto* baseStruct = reinterpret_cast<XrBaseOutStructure*>(typeIn);
// Loop over the next pointers and look for structureType
while ((baseStruct = static_cast<XrBaseOutStructure*>(baseStruct->next)) != nullptr &&
baseStruct->type != structureType)
{
}
// If we found it, cast to out type. If not we'll return nullptr.
return reinterpret_cast<TOUT*>(baseStruct);
}
template <class TOUT, class TIN>
const TOUT* FindNextPointerType(const TIN* typeIn, XrStructureType structureType)
{
auto* baseStruct = reinterpret_cast<const XrBaseOutStructure*>(typeIn);
// Loop over the next pointers and look for structureType
while ((baseStruct = static_cast<const XrBaseOutStructure*>(baseStruct->next)) != nullptr &&
baseStruct->type != structureType)
{
}
// If we found it, cast to out type. If not we'll return nullptr.
return reinterpret_cast<const TOUT*>(baseStruct);
}