Commit Graph

76 Commits

Author SHA1 Message Date
Ray Molenkamp ae25298774 Cleanup: CMake: Modernize bf_blenfont dependencies
Pretty straightforward

- Remove any bf_blenfont paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/115365
2023-11-24 18:29:09 +01:00
Hans Goudey 3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Hans Goudey 7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00
Pratik Borhade 270fc860cf Fix #114685: GP time offset modifier doesn't work if the animation is 1 frame long
This is due to the early return of current frame when start and end of
custom range is same
2023-11-10 16:07:05 +05:30
Campbell Barton 611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Campbell Barton aaf05c2497 Cleanup: various C++ changes (use nullptr, function style casts) 2023-11-07 11:35:16 +11:00
Hans Goudey 89e3ba4e25 Mesh: Replace auto smooth with node group
Design task: #93551

This PR replaces the auto smooth option with a geometry nodes modifier
that sets the sharp edge attribute. This solves a fair number of long-
standing problems related to auto smooth, simplifies the process of
normal computation, and allows Blender to automatically choose between
face, vertex, and face corner normals based on the sharp edge and face
attributes.

Versioning adds a geometry node group to objects with meshes that had
auto-smooth enabled. The modifier can be applied, which also improves
performance.

Auto smooth is now unnecessary to get a combination of sharp and smooth
edges. In general workflows are changed a bit. Separate procedural and
destructive workflows are available. Custom normals can be used
immediately without turning on the removed auto smooth option.

**Procedural**

The node group asset "Smooth by Angle" is the main way to set sharp
normals based on the edge angle. It can be accessed directly in the add
modifier menu. Of course the modifier can be reordered, muted, or
applied like any other, or changed internally like any geometry nodes
modifier.

**Destructive**
Often the sharp edges don't need to be dynamic. This can give better
performance since edge angles don't need to be recalculated. In edit
mode the two operators "Select Sharp Edges" and "Mark Sharp" can be
used. In other modes, the "Shade Smooth by Angle" controls the edge
sharpness directly.

### Breaking API Changes
- `use_auto_smooth` is removed. Face corner normals are now used
  automatically   if there are mixed smooth vs. not smooth tags. Meshes
  now always use custom normals if they exist.
- In Cycles, the lack of the separate auto smooth state makes normals look
  triangulated when all faces are shaded smooth.
- `auto_smooth_angle` is removed. Replaced by a modifier (or operator)
  controlling the sharp edge attribute. This means the mesh itself
  (without an object) doesn't know anything about automatically smoothing
  by angle anymore.
- `create_normals_split`, `calc_normals_split`, and `free_normals_split`
  are removed, and are replaced by the simpler `Mesh.corner_normals`
  collection property. Since it gives access to the normals cache, it
  is automatically updated when relevant data changes.

Addons are updated here: https://projects.blender.org/blender/blender-addons/pulls/104609

### Tests
- `geo_node_curves_test_deform_curves_on_surface` has slightly different
   results because face corner normals are used instead of interpolated
   vertex normals.
- `bf_wavefront_obj_tests` has different export results for one file
  which mixed sharp and smooth faces without turning on auto smooth.
- `cycles_mesh_cpu` has one object which is completely flat shaded.
  Previously every edge was split before rendering, now it looks triangulated.

Pull Request: https://projects.blender.org/blender/blender/pulls/108014
2023-10-20 16:54:08 +02:00
Hans Goudey 8f27baf388 Merge branch 'blender-v4.0-release' 2023-10-09 23:54:43 +02:00
Hans Goudey 976eaae02f Cleanup: Move BKE_object.hh to C++
Simplifies the fix to #111120, where the object bounds functions
may return a C++ type instead of `BoundBox`.

Pull Request: https://projects.blender.org/blender/blender/pulls/113462
2023-10-09 23:41:53 +02:00
Bastien Montagne df0d7c9c3d WM Jobs: Refactor all worker status variables into a single shared struct.
Move the three current 'status variables' (stop, update and progress)
into a single 'WorkerStatus' struct. This is cleaner and will allow for
future workin this area without having to edit tens of 'startjob'
callbacks signatures all the time.

No functional change expected here.

Note: jobs' specific internal code has been modified as little as
possible, in many cases the job's own data still just store pointers to
these three values. Ideally in the future more refactor will be using a
single pointer to the shared `wmJobWorkerStatus` data instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/113343
2023-10-09 12:12:22 +02:00
Hans Goudey 916d4c9d9b Cleanup: Move BKE_screen.h to C++
See #103343
2023-09-25 17:53:11 -04:00
Campbell Barton caef976ceb Cleanup: correct typo "hardeness" to "hardness" in DNA & variable names 2023-09-25 12:05:50 +10:00
Campbell Barton 2721b937fb Cleanup: use braces in headers 2023-09-24 14:52:38 +10:00
Hans Goudey 867f99c2af Cleanup: Move depsgraph headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110816
2023-09-22 03:18:17 +02:00
ChengduLittleA f6082a5042 Cleanup: Use `intern/render_types.h` for lineart_cpu.c
The `intern/` is needed for it to compile successfully on macos.
2023-09-21 10:08:46 +08:00
ChengduLittleA 954ae19b2b Fix #100596: Use sequencer override camera for line art in render
Line art doesn't take sequencer scene override camera into account when
computing line results, now it will try to get override camera info from
render and use that camera if line art override camera itself isn't set.

This will however not fix VSE preview line art result, since the preview
render doesn't give actual camera object, but rather uses a set of clip
planes and matrix info, thus it's probably not possible to do preview
camera override under current architecture.

Pull Request: https://projects.blender.org/blender/blender/pulls/110287
2023-09-19 15:27:47 +02:00
Jacques Lucke b5c89822ac RNA: return PointerRNA from rna create functions
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
2023-09-06 00:48:50 +02:00
Harley Acheson b122faf705 UI: Consistent Menu/Block/Popup Content Ordering
All Content is shown in natural top-down order regardless of where it
is initiated.

Pull Request: https://projects.blender.org/blender/blender/pulls/109798
2023-08-31 20:24:53 +02:00
Hans Goudey 425b871607 Mesh: Replace EdgeHash and EdgeSet with C++ classes
The `EdgeHash` and `EdgeSet` data structures are designed specifically
as a hash of an order agnostic pair of integers. This specialization can
be achieved much more easily with the templated C++ data structures,
which gives improved performance, readability, and type safety.

This PR removes the older data structures and replaces their use with
`Map`, `Set`, or `VectorSet` depending on the situation. The changes
are mostly straightforward, but there are a few places where the old
API made the goals of the code confusing.

The last time these removed data structures were significantly changed,
they were already moving closer to the implementation of the newer
C++ data structures (aa63a87d37).

Pull Request: https://projects.blender.org/blender/blender/pulls/111391
2023-08-29 17:00:33 +02:00
Philipp Oeser 8bae4427ed Fix #111238: Arrow keys in some menus work in the opposite direction
Since menus are created flipped (from event handling point of view), the
root layout block needs to be flagged `UI_BLOCK_IS_FLIP`.
This was missing for a couple of `uiMenuCreateFunc`, namely:
- creating worspaces menu
- modifiers extra ops
- constraints extra ops
- GP modifiers extra ops
- GP Shader FX extra ops

Same fix as f51de2246c.

Not crtitcal, but could go into LTS I guess.

Pull Request: https://projects.blender.org/blender/blender/pulls/111341
2023-08-22 09:35:10 +02:00
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton 86c4ce66af Cleanup: pass ICON_NONE instead of zero to UI functions 2023-08-12 16:29:49 +10:00
Jacques Lucke cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Aras Pranckevicius d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Campbell Barton b879a4f2d8 Cleanup: replace MEM_callocN with MEM_mallocN when overwritten afterward
Also pair allocation with memcpy calls.
2023-08-05 20:06:42 +10:00
Campbell Barton 9ea8477c23 Cleanup: various non-functional C++ changes 2023-08-05 13:57:29 +10:00
Hans Goudey ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00
Hans Goudey bc8c892c65 Cleanup: Move WM headers to C++
Also move a few more headers that included WM headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/110815
2023-08-04 23:11:22 +02:00
Campbell Barton adf58a77ff Cleanup: use LISTBASE_FOREACH & LISTBASE_FOREACH_BACKWARD macros 2023-08-04 08:51:13 +10:00
Campbell Barton de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Campbell Barton c6f3f19648 Cleanup: reduce variable scope when removing in a while loop 2023-08-03 19:17:43 +10:00
Hans Goudey 731d296f35 Cleanup: Move mesh related blenkernel headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110730
2023-08-02 22:14:18 +02:00
Campbell Barton 52acf6a6ec Cleanup: correct file names in comments after C -> C++ renaming
Use back-tick quotes to differentiate these from plain text.
2023-07-31 13:02:30 +10:00
Campbell Barton cfffd813c1 Cleanup: use typed enum for UI_ITEM_* flags
Using an int lead to confusion with other flags often used with buttons.
For e.g. these flags could be easily confused with uiItem::flag.
2023-07-29 15:32:45 +10:00
Campbell Barton ea8d985db8 Cleanup: various C++ cleanups
- Use C++ headers.
- Use function style cast.
- Use boolean literals.
- Remove redundant struct, void.
- Remove redundant parenthesis.
2023-07-28 09:38:07 +10:00
Campbell Barton 4cf728c3dd Cleanup: use boolean for GpencilModifierTypeInfo::is_disabled
Also rename user_render_params to use_render_params
(matching object modifiers).
2023-07-27 22:10:16 +10:00
Campbell Barton cc892efcd4 Cleanup: use snake case, especially for structs that define callbacks
Use snake case for ShaderFxTypeInfo, ModifierTypeInfo,
GpencilModifierTypeInfo & bConstraintTypeInfo.
2023-07-27 12:21:06 +10:00
Campbell Barton d4b2054f1f Cleanup: various C++ cleanups
- Use C++ headers.
- Use function style cast.
- Use boolean literals.
- Remove redundant struct, void.
- Correct struct comment ID's.
2023-07-27 12:21:06 +10:00
Campbell Barton a838e141fe Cleanup: quiet compiler warnings 2023-07-27 10:51:33 +10:00
Jacques Lucke 00e6adb49c Grease Pencil: move legacy grease pencil modifiers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/110493
2023-07-26 13:45:04 +02:00
Hans Goudey aebc743bf1 Cleanup: Make format
Sorry for the noise, I thought I ran this in the previous commit.
2023-07-25 15:23:56 -04:00
Hans Goudey 95edff7495 Cleanup: Rename mesh custom data fields
Implements the rest of #101689, after 5e9ea9243b.

- `vdata` -> `vert_data`
- `edata` -> `edge_data`
- `pdata` -> `face_data`
- `ldata` -> `loop_data`

A deeper rename of `loop` to `corner` will be proposed as a next
step, and renaming `totvert` and `totedge` can be done separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/110432
2023-07-25 21:15:52 +02:00
Ray molenkamp 4ea2baf4ae CMake: revert last weeks modernizations
The cleanup of blenkernel last weeks , caused the house of cards to
collapse on  top of bf_gpu's shader_builder, which is off by default
but used on a daily basis by the rendering team.

Given the fixes forward in #110394 ran into a ODR violation in OSL that
was hiding there for years, I don't see another way forward without
impeding the rendering teams productivity for "quite a while" as there
is no guarantee the OSL issue would be the end of it.

the only way forward appears to be back.

this reverts :

19422044ed
a670b53abe
0f541db97c
be516e8c81
3e88a2f44c
4e64b772f5
9547e7a317
07fe6c5a57

The problematic commit was 07fe6c5a57
as blenkernel links most of blender, it's a bit of a link order issue
magnet. Given all these commits stack, it's near impossible to revert
just that one without spending a significant amount of time resolving
merge conflicts. 99% of that work was automated, so easier to just
revert all of them, and re-do the work, than it is to deal with the
merge conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110438
2023-07-25 16:43:21 +02:00
Hans Goudey f3f31054ba Cleanup: Make format 2023-07-24 16:32:08 -04:00
Hans Goudey 5e9ea9243b Mesh: Rename "polys" to "faces"
Implements part of #101689.

The "poly" name was chosen to distinguish the `MLoop` + `MPoly`
combination from the `MFace` struct it replaced. Those two structures
persisted together for a long time, but nowadays `MPoly` is gone, and
`MFace` is only used in some legacy code like the particle system.

To avoid unnecessarily using a different term, increase consistency
with the UI and with BMesh, and generally make code a bit easier to
read, this commit replaces the `poly` term with `poly`. Most variables
that use the term are renamed too. `Mesh.totface` and `Mesh.fdata` now
have a `_legacy` suffix to reduce confusion. In a next step, `pdata`
can be renamed to `face_data` as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/109819
2023-07-24 22:06:55 +02:00
Ray molenkamp 19422044ed Cleanup: CMake: Modernize bf_bmesh dependencies
Pretty straightforward

- Remove any bmesh paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110363
2023-07-22 02:05:21 +02:00
Ray Molenkamp a670b53abe Cleanup: CMake: Modernize bf_blenfont dependencies
Pretty straightforward

- Remove any blenfont paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110351
2023-07-21 19:13:37 +02:00
Ray molenkamp be516e8c81 Cleanup: CMake: Modernize bf_blentranslation dependencies
Pretty straightforward:

- Remove any blentranslation paths from INC
- Add a dependency though LIB when needed

Slightly different than usual:

blentranslation still had a dependency on imbuf, from a time long
gone, cleaned that up since I was in the area

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110324
2023-07-21 16:22:10 +02:00
Ray molenkamp 3e88a2f44c Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any depsgraph paths from INC
- Add a dependency though LIB when needed

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110317
2023-07-20 22:13:00 +02:00
Ray molenkamp 4e64b772f5 Cleanup: CMake: Modernize bf_windowmanager dependencies
Pretty straightforward

- Remove any windowmanager paths from INC
- Add a dependency though LIB when needed

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109984
2023-07-20 18:52:52 +02:00