-
Notifications
You must be signed in to change notification settings - Fork 152
Validate
DirectXMesh |
---|
Returns a failure HRESULT
if the mesh description is invalid, and optionally includes diagnostic messages describing the problem(s) encountered. Clean can fix many of these issues.
HRESULT Validate(
const uint16_t* indices, size_t nFaces, size_t nVerts,
const uint32_t* adjacency,
VALIDATE_FLAGS flags, std::wstring* msgs );
HRESULT Validate(
const uint32_t* indices, size_t nFaces, size_t nVerts,
const uint32_t* adjacency,
VALIDATE_FLAGS flags, std::wstring* msgs );
flags: Combination of control flags to indicate what issues to detect.
-
VALIDATE_DEFAULT
is used to detect the most basic problems such as invalid index entries. If adjacency is provided, then that array is also validated. -
VALIDATE_BACKFACING
is used to detect a duplicate neighbor which usually indicates inconsistent winding order. This requires adjacency. -
VALIDATE_BOWTIES
is used to detect two fans of triangles that use the same vertex, but are not adjacent. This requires adjacency. -
VALIDATE_DEGENERATE
is used to detect degenerate triangles (i.e. 3 points forming only a line or a point). This does not require adjacency. -
VALIDATE_UNUSED
is used to detect issues with 'unused' triangles such as partial 'unused' faces. If adjacency is provided, it also validates that 'unused' faces are not neighbors of other faces. -
VALIDATE_ASYMMETRIC_ADJ
is used to check that every neighbor face links back to the original face. This requires adjacency.
Depending on the flags combinations, adjacency can be nullptr.
msgs: An optional string description of the problems encountered. This is an empty string if the mesh is valid. Can be nullptr if messages are not desired.
Returns S_OK
if the mesh is valid with respect to the provided control flags.
Will return E_FAIL
if the mesh is not valid with respect to the provided control flags.
Other possible failure codes include E_INVALIDARG
and E_OUTOFMEMORY
.
auto mesh = std::make_unique<WaveFrontReader<uint16_t>>();
if ( FAILED( mesh->Load( L"test.obj" ) ) )
// Error
size_t nFaces = mesh->indices.size() / 3;
size_t nVerts = mesh->vertices.size();
hr = Validate( mesh->indices.data(), nFaces, nVerts, nullptr, VALIDATE_DEFAULT );
if ( FAILED(hr) )
// E_FAIL indicates that mesh failed validation
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- GCC 10.5, 11.4, 12.3
- MinGW 12.2, 13.2
- CMake 3.20
DirectX Tool Kit for DirectX 11