-
Notifications
You must be signed in to change notification settings - Fork 158
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_DEFAULTis used to detect the most basic problems such as invalid index entries. If adjacency is provided, then that array is also validated. -
VALIDATE_BACKFACINGis used to detect a duplicate neighbor which usually indicates inconsistent winding order. This requires adjacency. -
VALIDATE_BOWTIESis used to detect two fans of triangles that use the same vertex, but are not adjacent. This requires adjacency. -
VALIDATE_DEGENERATEis used to detect degenerate triangles (i.e. 3 points forming only a line or a point). This does not require adjacency. -
VALIDATE_UNUSEDis 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_ADJis 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, E_OUTOFMEMORY, and HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW).
In most cases these functions will succeed or return a HRESULT error code.
These functions make use of Standard C++ Library containers so can throw C++ exceptions in some cases.
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 validationAll 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 - v20
- GCC 10.5, 11.4, 12.3, 13.3, 14.2
- MinGW 12.2, 13.2
- CMake 3.21
DirectX Tool Kit for DirectX 11