Commit Graph

933 Commits

Author SHA1 Message Date
Iliya Katueshenock
962e4c3056 Fix #110083: Fix incorrect initialization of bounds max
See: https://en.cppreference.com/w/cpp/types/numeric_limits

Pull Request: https://projects.blender.org/blender/blender/pulls/110084
2023-07-14 03:16:05 +02:00
Brecht Van Lommel
7551767f9f USD: more complete import and export of lights
* Exposure import
* Diffuse factor support
* Correct disk radius
* Better non-normalized intensity import
* Sun radius export

Pull Request: https://projects.blender.org/blender/blender/pulls/109929
2023-07-13 19:14:04 +02:00
Campbell Barton
ef1ddbaaca Cleanup: remove double spaces after a full-stop 2023-07-13 13:40:25 +10:00
Ray Molenkamp
370ca90632 Cleanup: Add missing copyright notice
missed in the initial commit.
2023-07-12 19:53:19 -06:00
Ray Molenkamp
98336cb8ca USD: Use pre-compiled headers
bf_usd is a bit slow to build, and most time is spend on the front end
of the compiler parsing USD's headers.

this change enables pre-compiled headers for the most expensive
headers to parse.

When building `bf_usd` single threaded with -j1 (for accurate measurements)

```
before Wall time:      0h 4min 30sec 931 ms 504299 ns
after  Wall time:      0h 0min 50sec 808 ms 24399 ns
```

Pull Request: https://projects.blender.org/blender/blender/pulls/110027
2023-07-12 22:55:57 +02:00
Harley Acheson
565436bf5f UI: SVG Thumbnails
Allow SVG files to have previews in the File Browser. Adds
nanosvgrast.h to extern\nanosvg\, which is an SVG rasterizer that is
an optional part of the nanosvg source.

Pull Request: https://projects.blender.org/blender/blender/pulls/109567
2023-07-12 22:39:23 +02:00
Jacques Lucke
3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

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

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp
57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Bastien Montagne
f07fee0188 UI Translations: Add bunch of nissing error messages from IO C++ code and modifiers.
Also fix some incorrect usages of `N_` macro instead of `TIP_` one
(these error messages typically need to get translated explicitely, not
only marked for extraction).
2023-07-10 12:45:28 +02:00
Kévin Dietrich
b183e3ae89 Cleanup: Alembic, use a structure to hold interpolation settings
The Alembic importer can optionnaly interpolate vertex and matrix data.
To detect if two samples can be interpolated `get_weight_and_index`
needs to be called which output the interpolation weight and the indices
for the floor and ceil samples separately. Either the weight or the
indices could be used to determine if interpolation was needed.

This adds a `SampleInterpolationSettings` structure to hold the weight
and indices together so we don't need to manage multiple local
variables, and replaces `get_weight_and_index` with
`get_sample_interpolation_settings` which returns either a
`SampleInterpolationSettings` or nothing if no interpolation is
necessary.

This also modifies `AbcMeshData` to have an optional
`SampleInterpolationSettings` and removes members used for interpolation
from `CDStreamConfig`, which simplifies the latter structure as well as
the check in `read_mverts` to verify if interpolation is needed.

`get_config` also no longer needs a parameter for setting the now removed
`use_vertex_interpolation` member from `CDStreamConfig`. This was only
used for Mesh vertex interpolation despite also being set in the points
reader (which does not yet support any interpolation).

No functional changes.

Pull Request: #109155
2023-07-09 01:26:07 +02:00
Brecht Van Lommel
05c97df2de USD: improve light units conversion
* Use pi factor to convert between radiant flux and intensity
* Mark lights as normalized on export
* Add spot light export support
* Add treatAsPoint support for import and export
* Empirically match normalized distant light
* Fix wrong unnormalized point/sphere/disk light unit in Cycles

Overall it should be much closer now for all light types. Point and distant
light units are inconsistent between renderers, so not possible to match
everything there.

Ref #109404

Pull Request: https://projects.blender.org/blender/blender/pulls/109795
2023-07-07 18:20:39 +02:00
Campbell Barton
23acedd432 Cleanup: code-comments 2023-07-07 15:11:19 +10:00
Brecht Van Lommel
c4ddf16950 Cleanup: remove unused light struct member 2023-07-05 19:16:39 +02:00
Brecht Van Lommel
57d85b32a9 Lights: remove unused Blender Internal properties
For falloff, attenuation and shadow buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/109738
2023-07-05 18:54:36 +02:00
Campbell Barton
785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Campbell Barton
093a948322 Cleanup: remove_cc_flag use in CMake
- Pass multiple arguments at once.
- Move comments above each argument.
- Quote the arguments (for consistency).
2023-07-05 13:27:21 +10:00
Campbell Barton
9753e70e37 Cleanup: move BLI_str_replace into BLI_string_utils.h
String search & replace is a higher level function (unlike BLI_string.h)
which handlers lower level replacements for printing and string copying.

Also use BLI_string_* prefix (matching other utilities).

This makes it possible to use BLI_string in Blender's internal utilities
without depending on DynStr, MemArena... etc.
2023-07-04 12:02:25 +10:00
Campbell Barton
0dfeccfc6b Cleanup: pass strings as const references where appropriate 2023-06-29 10:55:58 +10:00
Campbell Barton
472c461816 Cleanup: spelling in comments 2023-06-21 11:28:58 +10:00
Martijn Versteegh
c78ea4cefc Merge branch 'blender-v3.6-release' 2023-06-20 16:27:07 +02:00
Martijn Versteegh
77c37fb01d Fix #108053: Make the Collada UV sets enumerated from zero
The UV sets incorrectly used the CustomData layer index instead of the
count within the FLOAT2 layers.

Pull Request: https://projects.blender.org/blender/blender/pulls/109056
2023-06-20 16:24:33 +02:00
Bastien Montagne
27965a64a9 Merge branch 'blender-v3.6-release' 2023-06-20 12:42:14 +02:00
Michael Kowalski
a6f3afe995 Fix: USD export: wrong emissive color in viewport material
When a Blender material has no nodes, its viewport color,
roughness and metallic values are saved as inputs to a simple
USD Preview Surface.  This pull request fixes a bug where
the Blender material's viewport color is also saved as
the USD Preview Surface emissiveColor attribute.

This bug was accidentally introduced in #107947.

To reproduce the issue, open the default Blender scene,
turn off nodes on the material and set the material's viewport
color.  Export to USDA and notice that the color is incorrectly
set as the emissiveColor input in the USD shader.

Pull Request: https://projects.blender.org/blender/blender/pulls/109138
2023-06-20 12:35:39 +02:00
Kévin Dietrich
c49af381c0 Alembic: set output error string for subdivision meshes
This will ensure that errors will be propagated to the modifier when
reading subdivision meshes.
2023-06-20 11:49:49 +02:00
Kévin Dietrich
79cd8d6682 Alembic: add missing topology check for subd meshes
No functional changes.
2023-06-20 11:49:49 +02:00
Jeroen Bakker
966afa70c7 Cleanup make format 2023-06-19 15:47:18 +02:00
Lukas Tönne
550c61d34f Fix: Added missing header include for STRNCPY.
Test compile broken by 8bcad285de
2023-06-19 14:25:26 +02:00
Campbell Barton
8bcad285de Cleanup: remove strcpy usage 2023-06-19 20:40:49 +10:00
Hans Goudey
6301775f48 Cleanup: Access geometry bounds more directly
More consistently return geometry bounds with the `Bounds` type that
holds the min and max in one variable. This simplifies some code and
reduces the need to initialize separate min and max variables first.
Meshes now use the same `bounds_min_max()` function as curves and
point clouds, though the wrapper mesh isn't affected yet.

The motivation is to make some of the changes for #96968 simpler.
2023-06-16 08:14:25 -04:00
Campbell Barton
57cd40e622 Cleanup: rename corners to corner_verts
Be specific as there are corner edges too.
2023-06-16 12:20:34 +10:00
Kévin Dietrich
973562ec0c Merge remote-tracking branch 'origin/blender-v3.6-release' into main 2023-06-15 14:01:29 +02:00
Kévin Dietrich
61efaec173 Fix Alembic crash when importing a SubD mesh
The counters for polygons count and face corners count were inverted,
leading to various out of bounds accesses due to wrong data size
allocation.

Not sure where the bug comes from, whether it's original, or a typo from
some refactor.
2023-06-15 14:00:24 +02:00
Campbell Barton
4a93de9cc9 License headers: move copyright statements into SPDX-FileCopyrightText 2023-06-15 16:47:51 +10:00
Kévin Dietrich
907e27df51 Merge remote-tracking branch 'origin/blender-v3.6-release' into main 2023-06-15 05:47:13 +02:00
Kévin Dietrich
f0cd966750 Fix #100485: Alembic export crash with names containing a forward slash
As Alembic stores hierarchies as paths separated by a forward slash, such
character cannot be used in a name. This resulted in an uncaught thrown
exception. To fix this, replace '/' with '_' like for other illegal
characters.
2023-06-15 05:44:09 +02:00
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Kévin Dietrich
f509c213d0 Merge remote-tracking branch 'origin/blender-v3.6-release' into main 2023-06-15 03:41:07 +02:00
Kévin Dietrich
ae5fc2a7f8 Fix #105409: vertex interpolation corrupts Alembic mesh
The Alembic data streaming can optionally interpolate between vertex of
two adjacent frames in order to smooth out the transition between
frames.

However, the decision to interpolate is only based on the vertex count.
This is not too robust as topology/connectivity can still differ even if
the number of vertices is the same (for example physics simulations and
videogrammetry can be set to output the same vertex count, but optimize
the triangle placement). This lead to vertices of unrelated polygons
being interpolated across frames.

To fix this, we now also check if the connectivity across frames is the
same, instead of just checking the topology counters. Although the bug
is revealed by the vertex interpolation routine, a similar fix is applied
to the check on topology change used to decide if the modifier has to be
evaluated for orco evaluation.

Pull Request: #105867
2023-06-15 03:40:14 +02:00
Hans Goudey
68c6402666 Cleanup: Use C++ accessor for mesh position attribute 2023-06-14 12:37:52 -04:00
Hans Goudey
7826aed105 Cleanup: Use C++ accessors for mesh data 2023-06-14 12:37:52 -04:00
Campbell Barton
ffdce441ee License headers: use SPDX-FileCopyrightText for source/
There are still some files that need to be manually updated due to
missing copyright dates.
2023-06-14 23:36:23 +10:00
Hans Goudey
e5ec04d73c Mesh: Move vertex/edge crease to generic attributes
Store subdivision surface creases in two new named float attributes:
- `crease_vert`
- `crease_edge`
This is similar to 2a56403cb0.

The attributes are naming conventions, so their data type and domain
aren't enforced, and may be interpolated when necessary. Editing tools
and the subdivision surface modifier use the hard-coded name. It might
be best if these were edited as generic attributes in the future, but
in the meantime using generic attributes helps.

The attributes are visible in the list, which is how they're now meant
to be removed. They are now interchangeable with any tool that works
with the generic attribute system-- even tools like vertex paint can
affect creases now.

This is a breaking change. Forward compatibility isn't preserved for
versions before 3.6, and the `crease` property in RNA is removed in
favor of making a smaller API surface area with just the attribute API.
`Mesh.vertex_creases` and `Mesh.edge_creases` now just return the
matching attribute if possible, and are now implemented in Python.
New functions `*ensure` and `*remove` also replace the operators to
add and remove the layers for Python.

A few extrude node test files have to be updated because of different
(now generic) attribute interpolation behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/108089
2023-06-13 20:23:39 +02:00
Hans Goudey
3db0c59ec1 Cleanup: Use functional cast for std::string_view
See https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast
2023-06-12 15:38:16 -04:00
Brecht Van Lommel
ff7dc64234 Cleanup: remove unused USD plugin path registration
It is now in a location where USD automatically picks it up.
2023-06-07 20:06:22 +02:00
guishe
fb348137d5 Cleanup: Move IO files to C++
Changes:
1. `UNUSED` AND `UNUSED_VARS`   ->   `/*arg*/`
2. `NULL` -> `nullptr`
3. `Function style cast` for `enums` values
4. `void *` -> `static_cast<T*>`
5. Use standard includes `#include <file.h>` ->`#include <cfile>`
6. Replace designated initializers with member assignment
7. `typdef struct N{...} N; ` -> `struct N{...}`

See: #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/108477
2023-06-07 00:52:34 +02:00
Hans Goudey
81da428cec Merge branch 'blender-v3.6-release' 2023-06-05 20:20:26 -04:00
Hans Goudey
41d994c9ac Fix #108571: OBJ vertex group import crash
`tot_loop_idx` was increased before it was used to set the set
the vertex group value of the current face corner's vertex.
2023-06-05 20:20:03 -04:00