Skip to content

Validate

Chuck Walbourn edited this page Jan 21, 2022 · 9 revisions
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 );

Parameters

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.

Return values

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.

Example

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

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 7 Service Pack 1
  • Xbox One
  • Xbox Series X|S
  • Windows Subsystem for Linux

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v16
  • GCC 9.4, 11.3
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 11

DirectX Tool Kit for DirectX 12

DirectXTex

DirectXMath

Tools

Test Suite

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally