Skip to content

Commit 34ba1af

Browse files
authored
Added nVerts parameter to OptimizeFaces (#289)
1 parent b08a540 commit 34ba1af

19 files changed

Lines changed: 148 additions & 78 deletions

.github/copilot-instructions.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ These instructions define how GitHub Copilot should assist with this project. Th
1414

1515
- See the tutorial at [Getting Started](https://github.com/microsoft/DirectXMesh/wiki/Getting-Started).
1616
- The recommended way to integrate *DirectXMesh* into your project is by using the *vcpkg* Package Manager.
17-
- You can make use of the nuget.org packages **directxmesh_desktop_2019**, **directxmesh_desktop_win10**, or **directxmesh_uwp**.
17+
- You can make use of the nuget.org packages **directxmesh_desktop_win10** or **directxmesh_uwp**.
1818
- You can also use the library source code directly in your project or as a git submodule.
1919

2020
## General Guidelines
2121

22-
- **Code Style**: The project uses an .editorconfig file to enforce coding standards. Follow the rules defined in `.editorconfig` for indentation, line endings, and other formatting. Additional information can be found on the wiki at [Implementation](https://github.com/microsoft/DirectXTK/wiki/Implementation). The library implementation is written to be compatible with C++14 features, but C++17 is required to build the project for the command-line tools which utilize C++17 filesystem for long file path support.
23-
> Notable `.editorconfig` rules: C/C++ files use 4-space indentation, `crlf` line endings, and `latin1` charset — avoid non-ASCII characters in source files. HLSL files have separate indent/spacing rules defined in `.editorconfig`.
22+
- **Code Style**: The project uses an .editorconfig file to enforce coding standards. Follow the rules defined in `.editorconfig` for indentation, line endings, and other formatting. Additional information can be found on the wiki at [Implementation](https://github.com/microsoft/DirectXTK/wiki/Implementation). The library's public API requires C++11, and the project builds with C++17 (`CMAKE_CXX_STANDARD 17`). The command-line tools also use C++17, including `<filesystem>` for long file path support. This code is designed to build with Visual Studio 2022, Visual Studio 2026, clang for Windows v12 or later, or MinGW 12.2.
23+
> Notable `.editorconfig` rules: C/C++ files use 4-space indentation, `crlf` line endings, and `latin1` charset — avoid non-ASCII characters in source files.
2424
- **Documentation**: The project provides documentation in the form of wiki pages available at [Documentation](https://github.com/microsoft/DirectXMesh/wiki/).
2525
- **Error Handling**: Use C++ exceptions for error handling and uses RAII smart pointers to ensure resources are properly managed. For some functions that return HRESULT error codes, they are marked `noexcept`, use `std::nothrow` for memory allocation, and should not throw exceptions.
26-
- **Testing**: Unit tests for this project are implemented in this repository [Test Suite](https://github.com/walbourn/directxmeshtest/) and can be run using CTest per the instructions at [Test Documentation](https://github.com/walbourn/directxmeshtest/wiki).
26+
- **Testing**: Unit tests for this project are implemented in this repository [Test Suite](https://github.com/walbourn/directxmeshtest/) and can be run using CTest per the instructions at [Test Documentation](https://github.com/walbourn/directxmeshtest/wiki). See [test copilot instructions](https://github.com/walbourn/directxmeshtest/blob/main/.github/copilot-instructions.md) for additional information on the tests.
2727
- **Security**: This project uses secure coding practices from the Microsoft Secure Coding Guidelines, and is subject to the `SECURITY.md` file in the root of the repository. Functions that read input from geometry files are subject to OneFuzz fuzz testing to ensure they are secure against malformed files.
2828
- **Dependencies**: The project uses CMake and VCPKG for managing dependencies, making optional use of DirectXMath and DirectX-Headers. The project can be built without these dependencies, relying on the Windows SDK for core functionality.
2929
- **Continuous Integration**: This project implements GitHub Actions for continuous integration, ensuring that all code changes are tested and validated before merging. This includes building the project for a number of configurations and toolsets, running a subset of unit tests, and static code analysis including GitHub super-linter, CodeQL, and MSVC Code Analysis.
@@ -49,14 +49,14 @@ wiki/ # Local clone of the GitHub wiki documentation repository.
4949

5050
- Use RAII for all resource ownership (memory, file handles, etc.).
5151
- Many classes utilize the pImpl idiom to hide implementation details, and to enable optimized memory alignment in the implementation.
52-
- Use `std::unique_ptr` for exclusive ownership and `std::shared_ptr` for shared ownership.
53-
- Use `Microsoft::WRL::ComPtr` for COM object management.
52+
- Use `std::unique_ptr` for exclusive ownership.
5453
- Make use of anonymous namespaces to limit scope of functions and variables.
5554
- Make use of `assert` for debugging checks, but be sure to validate input parameters in release builds.
5655
- Explicitly `= delete` copy constructors and copy-assignment operators on all classes that use the pImpl idiom.
5756
- Explicitly utilize `= default` or `=delete` for copy constructors, assignment operators, move constructors and move-assignment operators where appropriate.
5857
- Use 16-byte alignment (`_aligned_malloc` / `_aligned_free`) to support SIMD operations in the implementation, but do not expose this requirement in public APIs.
5958
> For non-Windows support, the implementation uses C++17 `aligned_alloc` instead of `_aligned_malloc`.
59+
- All implementation `.cpp` files include `DirectXMeshP.h` as their first include (precompiled header). MinGW builds skip precompiled headers.
6060

6161
#### SAL Annotations
6262

@@ -110,17 +110,18 @@ HRESULT DirectX::ComputeNormals(
110110
#### `noexcept` Rules
111111
112112
- All query and utility functions that cannot fail (e.g., `IsValidVB`, `IsValidIB`) are marked `noexcept`.
113-
- All HRESULT-returning I/O and processing functions are also `noexcept` — errors are communicated via return code, never via exceptions.
113+
- HRESULT-returning functions that do not perform heap allocation or use Standard C++ containers are `noexcept` — errors are communicated via return code, never via exceptions (e.g., `ComputeNormals`, `ReorderIB`, `FinalizeIB`, `FinalizeVB`, `CompactVB`, `OptimizeVertices`, `ComputeCullData`).
114+
- HRESULT-returning functions that use `std::vector`, `std::function`, or other potentially throwing types are *not* marked `noexcept` — they may throw on allocation failure (e.g., `GenerateAdjacencyAndPointReps`, `Validate`, `Clean`, `WeldVertices`, `ComputeMeshlets`, `OptimizeFaces`).
114115
- Constructors and functions that perform heap allocation or utilize Standard C++ containers that may throw are marked `noexcept(false)`.
115116
116117
#### Enum Flags Pattern
117118
118-
Flags enums follow this pattern — a `uint32_t`-based unscoped enum with a `_NONE = 0x0` base case, followed by a call to `DEFINE_ENUM_FLAG_OPERATORS` (defined in `DirectXMesh.inl`) to enable `|`, `&`, and `~` operators:
119+
Flags enums follow this pattern — a `uint32_t`-based unscoped enum with a `_DEFAULT = 0` base case, followed by a call to `DEFINE_ENUM_FLAG_OPERATORS` (invoked in `DirectXMesh.inl`) to enable `|`, `&`, and `~` operators:
119120
120121
```cpp
121122
enum CNORM_FLAGS : uint32_t
122123
{
123-
CNORM_DEFAULT = 0x0,
124+
CNORM_DEFAULT = 0,
124125
// Default is to compute normals using weight-by-angle
125126
126127
CNORM_WEIGHT_BY_AREA = 0x1,
@@ -142,7 +143,7 @@ See [this blog post](https://walbourn.github.io/modern-c++-bitmask-types/) for m
142143

143144
- Don’t use raw pointers for ownership.
144145
- Avoid macros for constants—prefer `constexpr` or `inline` `const`.
145-
- Dont put implementation logic in header files unless using templates, although the SimpleMath library does use an .inl file for performance.
146+
- Don't put implementation logic in header files unless using templates, although the DirectXMesh library does use an .inl file for performance for a few specific utility functions that are called in tight loops (e.g., `IsValidIB`, `IsValidVB`).
146147
- Avoid using `using namespace` in header files to prevent polluting the global namespace.
147148

148149
## Naming Conventions
@@ -174,16 +175,16 @@ Every source file (`.cpp`, `.h`, etc.) must begin with this block:
174175
```
175176

176177
Section separators within files use:
177-
- Major sections: `//-------------------------------------------------------------------------------------`
178-
- Subsections: `//---------------------------------------------------------------------------------`
178+
- Major sections: `//=====================================================================================`
179+
- Subsections: `//-------------------------------------------------------------------------------------`
179180

180181
The project does **not** use Doxygen. API documentation is maintained exclusively on the GitHub wiki.
181182

182183
## References
183184

184185
- [Source git repository on GitHub](https://github.com/microsoft/DirectXMesh.git)
185186
- [DirectXMesh documentation git repository on GitHub](https://github.com/microsoft/DirectXMesh.wiki.git)
186-
- [DirectXMesh test suite git repository on GitHub](https://github.com/walbourn/directxmeshtest.wiki.git).
187+
- [DirectXMesh test suite git repository on GitHub](https://github.com/walbourn/directxmeshtest.git).
187188
- [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)
188189
- [Microsoft Secure Coding Guidelines](https://learn.microsoft.com/en-us/security/develop/secure-coding-guidelines)
189190
- [CMake Documentation](https://cmake.org/documentation/)
@@ -221,8 +222,9 @@ When creating documentation:
221222

222223
## Cross-platform Support Notes
223224

224-
- The code supports building for Windows and Linux.
225+
- The code targets Win32 desktop applications for Windows 8.1 or later, Xbox One, Xbox Series X\|S, Universal Windows Platform (UWP) apps for Windows 10 and Windows 11, and Linux.
225226
- Portability and conformance of the code is validated by building with Visual C++, clang/LLVM for Windows, MinGW, and GCC for Linux compilers.
227+
- The project ships MSBuild projects for Visual Studio 2022 (`.sln` / `.vcxproj`) and Visual Studio 2026 (`.slnx` / `.vcxproj`). VS 2019 projects have been retired.
226228

227229
### Platform and Compiler `#ifdef` Guards
228230

@@ -231,10 +233,12 @@ Use these established guards — do not invent new ones:
231233
| Guard | Purpose |
232234
| --- | --- |
233235
| `_WIN32` | Windows platform (desktop, UWP, Xbox) |
234-
| `_GAMING_XBOX` | Xbox One or Xbox Series X\|S |
235-
| `_GAMING_XBOX_SCARLETT` | Xbox Series X\|S |
236+
| `_GAMING_XBOX` | Xbox platform (GDK - covers both Xbox One and Xbox Series X\|S) |
237+
| `_GAMING_XBOX_SCARLETT` | Xbox Series X\|S (GDK with Xbox Extensions) |
238+
| `_GAMING_XBOX_XBOXONE` | Xbox One (GDK with Xbox Extensions) |
236239
| `_XBOX_ONE && _TITLE` | Legacy Xbox One XDK — **no longer supported**; triggers a `#error` at compile time |
237240
| `_MSC_VER` | MSVC-specific (and MSVC-like clang-cl) pragmas and warning suppression |
241+
| `__INTEL_COMPILER` | Intel C++ Compiler classic warning suppression |
238242
| `__clang__` | Clang/LLVM diagnostic suppressions |
239243
| `__MINGW32__` | MinGW compatibility headers |
240244
| `__GNUC__` | MinGW/GCC DLL attribute equivalents |
@@ -245,17 +249,18 @@ Use these established guards — do not invent new ones:
245249

246250
> `_M_ARM`/ `__arm__` is legacy 32-bit ARM which is deprecated.
247251
248-
Non-Windows builds (Linux/WSL) omit WIC entirely and use `<directx/dxgiformat.h>` and `<wsl/winadapter.h>` from the DirectX-Headers package instead of the Windows SDK.
252+
Non-Windows builds (Linux/WSL) use `<directx/dxgiformat.h>` and `<wsl/winadapter.h>` from the DirectX-Headers package instead of the Windows SDK.
249253

250254
### Error Codes
251255

252-
The following symbols are not custom error codes, but aliases for `HRESULT_FROM_WIN32` error values.
256+
The following symbols are not custom error codes, but aliases for `HRESULT_FROM_WIN32` error codes.
253257

254258
| Symbol | Standard Win32 HRESULT |
255259
| -------- | ------------- |
256260
| `HRESULT_E_ARITHMETIC_OVERFLOW` | `HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)` |
257261
| `HRESULT_E_NOT_SUPPORTED` | `HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)` |
258262
| `HRESULT_E_INVALID_NAME` | `HRESULT_FROM_WIN32(ERROR_INVALID_NAME)` |
263+
| `E_BOUNDS` | `0x8000000BL` (conditionally defined if not already present) |
259264

260265
## Code Review Instructions
261266

.github/workflows/arm64.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props
@@ -45,7 +47,7 @@ jobs:
4547
build_type: [arm64-Debug, arm64-Release, arm64-Debug-UWP, arm64-Release-UWP]
4648

4749
steps:
48-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
50+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4951

5052
- name: 'Install Ninja'
5153
run: choco install ninja

.github/workflows/arm64bvt.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props
@@ -46,10 +48,10 @@ jobs:
4648
build_type: [arm64-Release]
4749

4850
steps:
49-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
51+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5052

5153
- name: Clone test repository
52-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5355
with:
5456
repository: walbourn/directxmeshtest
5557
path: Tests

.github/workflows/bvt.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props
@@ -48,10 +50,10 @@ jobs:
4850
arch: [amd64]
4951

5052
steps:
51-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
53+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5254

5355
- name: Clone test repository
54-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
56+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5557
with:
5658
repository: walbourn/directxmeshtest
5759
path: Tests

.github/workflows/clangcl.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props

.github/workflows/codeql.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props
@@ -49,15 +51,15 @@ jobs:
4951

5052
steps:
5153
- name: Checkout repository
52-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5355

5456
- name: 'Install Ninja'
5557
run: choco install ninja
5658

5759
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
5860

5961
- name: Initialize CodeQL
60-
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
62+
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
6163
with:
6264
languages: c-cpp
6365
build-mode: manual
@@ -71,6 +73,6 @@ jobs:
7173
run: cmake --build out\build\x64-Debug
7274

7375
- name: Perform CodeQL Analysis
74-
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
76+
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
7577
with:
7678
category: "/language:c-cpp"

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props

.github/workflows/msbuild.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*
1718
pull_request:
@@ -20,6 +21,7 @@ on:
2021
- '*.md'
2122
- LICENSE
2223
- '.azuredevops/**'
24+
- '.github/*.md'
2325
- '.nuget/*'
2426
- build/*
2527

.github/workflows/msvc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props
@@ -47,7 +49,7 @@ jobs:
4749

4850
steps:
4951
- name: Checkout repository
50-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
52+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5153

5254
- name: Configure CMake
5355
working-directory: ${{ github.workspace }}
@@ -63,6 +65,6 @@ jobs:
6365

6466
# Upload SARIF file to GitHub Code Scanning Alerts
6567
- name: Upload SARIF to GitHub
66-
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
68+
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v3.29.5
6769
with:
6870
sarif_file: ${{ steps.run-analysis.outputs.sarif }}

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- '*.md'
1313
- LICENSE
1414
- '.azuredevops/**'
15+
- '.github/*.md'
1516
- '.nuget/*'
1617
- build/*.cmd
1718
- build/*.props
@@ -24,6 +25,7 @@ on:
2425
- '*.md'
2526
- LICENSE
2627
- '.azuredevops/**'
28+
- '.github/*.md'
2729
- '.nuget/*'
2830
- build/*.cmd
2931
- build/*.props

0 commit comments

Comments
 (0)