24 Commits

Author SHA1 Message Date
Brecht Van Lommel
9711efece7 Fix #141085: Cycles adaptive subdivision crash with zero length edges
As produced by booleans in the reported blend file.

Pull Request: https://projects.blender.org/blender/blender/pulls/141105
2025-06-28 00:03:45 +02:00
Campbell Barton
e5deeafe92 Cleanup: spelling in comments (make check_spelling_*) 2025-05-22 11:11:48 +10:00
Brecht Van Lommel
59b4842117 Cycles: Adaptive subdivision triangular patches
There is a corner case where one side of a quad needs splitting and the other
side has only one segment. Previously this would produce either gaps or after
recent changes to stitch together geometry, uninitialized memory.

Now solve this by splitting into triangular patches, as suggested in the
DiagSplit paper. These triangular patches can be further subdivided themselves.
Dicing has special cases for 1 or 2 segments on edges. For more segments it
works the same as: quad dicing: A regular inner triangle grid stitched to the
outer edges.

Fix #136973: Inconsistent results with adaptive subdivision

Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:04:11 +02:00
Brecht Van Lommel
98104d63ca Refactor: Track max subdivision depth per edge instead of per patch
This ensure results are consistent between patches for the upcoming triangle
patch case, where we can't assume alternating subdivision like quads.

Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:04:08 +02:00
Brecht Van Lommel
d6b42d3eac Refactor: Rename subpatch members to prepare for triangular patch
Pull Request: https://projects.blender.org/blender/blender/pulls/139062
2025-05-19 12:03:58 +02:00
Campbell Barton
42ad772a1f Cleanup: spelling & repeated terms (make check_spelling_*)
Also use comment blocks for English text.
2025-03-27 01:13:34 +00:00
Brecht Van Lommel
c448bf16e5 Cycles: Multithread adaptive subdivision dicing
* Perform attribute interpolation as part of dicing.
* Remove temporary subd uv and face index attributes.

On a MacBook M3 with 12 P-cores and 4 E-cores, these changes overall give
a 10x-14x speedup on various scenes. Note that splitting is still single
threaded and can be expensive, and UV subdivision can be optimized more.

Pull Request: https://projects.blender.org/blender/blender/pulls/136411
2025-03-24 09:42:47 +01:00
Brecht Van Lommel
4e16c4bd7d Refactor: Cycles: Tweaks to adaptive subdivision dicing
* Move dicing out of DiagSplit, caller now uses EdgeDice
* Merge, rename and reorder various EdgeDice functions
* Compute triangle indices for subpatches in advance

Pull Request: https://projects.blender.org/blender/blender/pulls/136411
2025-03-24 09:42:45 +01:00
Brecht Van Lommel
17fbfbc2d5 Refactor: Cycles: Subdivision avoids writing vertices multiple times
For performance and determinism with upcoming multithreading.

Pull Request: https://projects.blender.org/blender/blender/pulls/136411
2025-03-24 09:42:43 +01:00
Campbell Barton
6ef7dae8ef Cleanup: spelling in comments (make check_spelling_*) 2025-03-13 13:41:17 +11:00
Brecht Van Lommel
b1559b3ff4 Cycles: Adaptive subdivision patches without inner grid
Means low res patches can have 2 instead of 4 triangles.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:36 +01:00
Brecht Van Lommel
de821416c7 Cycles: Adaptive subdivision dicing and splitting improvements
* Share vertices between patches instead of using stitch map
* Switch to OpenSubdiv compatible counter-clockwise indexing
* Simplify patch edge reverse direction logic
* Add more comments to splitting and dicing

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:33 +01:00
Brecht Van Lommel
e84b377eae Refactor: Simplify subd patch code
* Remove unused linear patch normals
* Renaming for consistency and clarity
* Shuffle order of function definitions

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:20 +01:00
Brecht Van Lommel
57ff24cb99 Refactor: Cycles: Add const keyword to more function parameters
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:23:24 +01:00
Brecht Van Lommel
dd51c8660b Refactor: Cycles: Add const keyword where possible, using clang-tidy
Check was misc-const-correctness, combined with readability-isolate-declaration
as suggested by the docs.

Temporarily clang-format "QualifierAlignment: Left" was used to get consistency
with the prevailing order of keywords.

Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:23:20 +01:00
Brecht Van Lommel
60bec183cb Refactor: Cycles: Replace foreach() by range based for loops
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:23:05 +01:00
Brecht Van Lommel
d0c2e68e5f Refactor: Cycles: Automated clang-tidy fixups in Cycles
* Use .empty() and .data()
* Use nullptr instead of 0
* No else after return
* Simple class member initialization
* Add override for virtual methods
* Include C++ instead of C headers
* Remove some unused includes
* Use default constructors
* Always use braces
* Consistent names in definition and declaration
* Change typedef to using

Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:22:55 +01:00
Brecht Van Lommel
3c2a6fbb9c Refactor: Cycles: Use nullptr instead of NULL
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:22:43 +01:00
Campbell Barton
5b9740c913 Cleanup: use braces for sources in intern/
Omitted intern/itasc as some of these sources are from KDL:
https://www.orocos.org/kdl.html
2023-09-17 09:05:40 +10:00
Campbell Barton
c12994612b License headers: use SPDX-FileCopyrightText in intern/cycles 2023-06-14 16:53:23 +10:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Sergey Sharybin
d32d787f5f Clang-Format: Allow empty functions to be single-line
For example

```
OIIOOutputDriver::~OIIOOutputDriver()
{
}
```

becomes

```
OIIOOutputDriver::~OIIOOutputDriver() {}
```

Saves quite some vertical space, which is especially handy for
constructors.

Pull Request: https://projects.blender.org/blender/blender/pulls/105594
2023-03-29 16:50:54 +02:00
Brecht Van Lommel
9cfc7967dd Cycles: use SPDX license headers
* Replace license text in headers with SPDX identifiers.
* Remove specific license info from outdated readme.txt, instead leave details
  to the source files.
* Add list of SPDX license identifiers used, and corresponding license texts.
* Update copyright dates while we're at it.

Ref D14069, T95597
2022-02-11 17:47:34 +01:00
Brecht Van Lommel
fd25e883e2 Cycles: remove prefix from source code file names
Remove prefix of filenames that is the same as the folder name. This used
to help when #includes were using individual files, but now they are always
relative to the cycles root directory and so the prefixes are redundant.

For patches and branches, git merge and rebase should be able to detect the
renames and move over code to the right file.
2021-10-26 15:37:04 +02:00