Commit Graph

1744 Commits

Author SHA1 Message Date
Bastien Montagne
9139005e82 Fix building on Clang19 on Linux.
Commit e9a21cf14c seems to have removed a bit too many includes, this
reverts one change, which seems to be enough to get it working again.

Will let @deadpin decide whether we keep this 'include all' header
include here, or go more refined in our includes.
2025-03-18 11:23:39 +01:00
Bastien Montagne
b87b58b07e OBJ Export: Update 'bitflag smoothgroup' to also consider boundary vertices.
Previous code would consider two different face groups sharing no common
edges as fully isolated from each other, and could assign them the same
bitflag facegroup value.

Following FBX recent option to export these bitflags smoothgroups (!135646),
also consider that two different face groups are connected if they only share
common vertices, and assign them different bitflags values.

NOTE: This seems to be the expected behavior in major DCCs actually
using smoothgroups, only considering boundary edges create groups that
generate broken shading when imported by these tools.

NOTE: The 'unique integer identifers' option is kept for OBJ exporter,
as such OBJ files are also found on internet, depending on which app
generated them.

Pull Request: https://projects.blender.org/blender/blender/pulls/135998
2025-03-18 10:04:38 +01:00
Jesse Yurkovich
e9a21cf14c Cleanup: USD: various non-functional changes
- Use const in more places
- Use more appropriate headers and forward decls elsewhere
- Remove one instance of variable shadowing
- Rename an internal rna enum list and the USD operator property object
  to follow surrounding code and naming guidelines

Pull Request: https://projects.blender.org/blender/blender/pulls/136112
2025-03-18 07:18:19 +01:00
Jesse Yurkovich
e93c6e5f74 USD: Eliminate some unintentional VtArray copies
The `pxr::VtArray<T>` type is based on a copy-on-write scheme that is
very easy to trigger unnecessarily because of how the C++ type system
works[1].

Here we bypass unneeded copies by ensuring we always call the `const`
version of various accessor functions. The offending call-sites were
found by using the `VT_LOG_STACK_ON_ARRAY_DETACH_COPY` env variable.

This yields a very small 2-3% performance benefit when loading in a
typical, mixed-use, asset like e.g. the "4004 Moore Lane" scene.

[1] https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/base/vt/array.h#L139

Pull Request: https://projects.blender.org/blender/blender/pulls/136014
2025-03-17 17:59:17 +01:00
Falk David
5d5782571e Fix #136036: Grease Pencil: SVG export not working for non-poly types
To fix this in the most non-intrusive way, we essentially do what
the modifiers do which is to convert everything to poly curves.
This is also what GPv2 used to do.

Ideally, we would export non-poly curves as bézier curves in the
supported SVG format.

Pull Request: https://projects.blender.org/blender/blender/pulls/136088
2025-03-17 17:29:52 +01:00
Philipp Oeser
d83944f248 Merge branch 'blender-v4.4-release' 2025-03-14 17:32:43 +01:00
Philipp Oeser
8a0d34393d Fix #135969: Crash exporting Grease Pencil with no materials as SVG/PDF
Having no material is not uncommon, e.g. this can happen in blender when
a Curve is coverted to Grease Pencil.

If there is no material, we can still regard that stroke as visible, and use the
default Grease Pencil material in that case.

Pull Request: https://projects.blender.org/blender/blender/pulls/135975
2025-03-14 15:42:54 +01:00
Bastien Montagne
1e976ec37b Cleanup: io: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/135976
2025-03-14 14:52:16 +01:00
Campbell Barton
6ef7dae8ef Cleanup: spelling in comments (make check_spelling_*) 2025-03-13 13:41:17 +11:00
Campbell Barton
bd06baf6e6 WM: rename WM_report* to WM_global_report*, note it's often bad practice
WM_report was originally added for special cases however new code
has been using this in operators for example, where reports should be
sent to the operator via BKE_report, so the caller can handle,
and so Python can catch the errors.

Rename the functions to make them less easily confused with BKE_report
and add a code-comment on why their use should be avoided.
2025-03-11 12:36:17 +11:00
Bastien Montagne
00de07f752 I/O: Smoothgroups: Add option to also consider 'sharp vertices'.
According to reports and testing in blender/blender-addons#104434, DCCs
tend to behave badly when rebuilding normals from 'bitflags'
smoothgroups, if different smoothgroups using the same bitflag value share
(are connected by) some common vertices, even if there are no common
edges between them.

This commit adds a new option to the RNA API generating smooth groups,
to also consider smooth groups only sharing vertices as neighbors.

It also makes related required change to implementation, and some
refactor of the API, splitting public functions between 'normal' and
'bitflags' versions.

This should make changes proposed in blender/blender-addons#105516
much simpler, and allow for a matching behavior in smoothgroups
generated by the OBJ exporter as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/135248
2025-03-07 11:24:37 +01:00
Falk David
e39c83c881 Merge branch 'blender-v4.4-release' 2025-03-06 21:19:31 +01:00
Jesse Yurkovich
0a16ba9911 Fix #135502: Handle Alembic attribute size mismatch when reading points
The Alembic file in the issue had 0 points, and 4 widths, defined for
frame 33 which is certainly incorrect from whichever software produced
said file. However, our import code should have proper guards in place
to more gracefully handle the situation.

Pull Request: https://projects.blender.org/blender/blender/pulls/135548
2025-03-06 20:54:53 +01:00
Campbell Barton
d951428422 Cleanup: spelling in comments
Address warnings from check_spelling.py
2025-03-06 10:49:51 +11:00
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +01:00
Jacques Lucke
c233955ef9 Geometry Nodes: support custom delimiter in Import CSV node
Previously, only `,` was a valid delimiter, but it's also common to have e.g.
tab or semicolon. Only single characters are supported as delimiters. A few
characters are not allowed because they have other meanings: `\n`, `\r`, `"`,
`\\`.

Note: The best way to get a tab character is the use the Special Characters node
currently.

Pull Request: https://projects.blender.org/blender/blender/pulls/135468
2025-03-04 23:58:02 +01:00
Aras Pranckevicius
cc2c6692c0 Cleanup: Name more IMB things as "byte" or "float" instead of "rect" and "rectFloat"
- IB_rect -> IB_byte_data
- IB_rectfloat -> IB_float_data
- Rename some functions:
	- IMB_get_rect_len -> IMB_get_pixel_count
	- IMB_rect_from_float -> IMB_byte_from_float
	- IMB_float_from_rect_ex -> IMB_float_from_byte_ex
	- IMB_float_from_rect -> IMB_float_from_byte
	- imb_addrectImBuf -> IMB_alloc_byte_pixels
	- imb_freerectImBuf -> IMB_free_byte_pixels
	- imb_addrectfloatImBuf -> IMB_alloc_float_pixels
	- imb_freerectfloatImBuf -> IMB_free_float_pixels
	- imb_freemipmapImBuf -> IMB_free_mipmaps
	- imb_freerectImbuf_all -> IMB_free_all_data
- Remove IB_multiview (not used at all)
- Remove obsolete "module" comments in public IMB headers

Pull Request: https://projects.blender.org/blender/blender/pulls/135348
2025-03-03 17:11:45 +01:00
Jesse Yurkovich
ae1a5aa2a1 Fix: USD: Incorrect call to Map::add_new during dupli-vert export
Mistake in 6704647c66. Test coverage being added for another bug fix
uncovered this one.

Problem occurs when exporting an object that is duplicating at least two
other objects with the dupli vert system.

Pull Request: https://projects.blender.org/blender/blender/pulls/135369
2025-03-02 22:51:23 +01:00
Hans Goudey
8b297ab168 Cleanup: Use bNodeTree all_nodes() accessor method
This is always built at runtime.

Pull Request: https://projects.blender.org/blender/blender/pulls/135321
2025-02-28 22:12:34 +01:00
Jesse Yurkovich
6704647c66 Cleanup: IO: Use blender containers for AbstractHierarchyIterator
Use Blender Containers in the AbstractHierarchyIterator system. A future
bug fix in the area is looking like it will require another map so it
seems like a good time to replace the old containers before that lands.

The conversion is complicated due to how the prior code leveraged
`operator[]` to both add and update entries; it was never clear which
operation was being performed. This leads to a somewhat confusing mix
of `add_new`, `add`, and `lookup_or_add` calls. The calls in place now
are what was required based on our existing tests.

Additionally, pointer stability guarantees were a little bit different,
affecting the usage of the `graph_children` function the most.

Pull Request: https://projects.blender.org/blender/blender/pulls/134698
2025-02-28 05:58:46 +01:00
Jesse Yurkovich
ea5ed269ae Merge branch 'blender-v4.4-release' 2025-02-27 16:48:42 -08:00
Jesse Yurkovich
1833d79231 Fix: USD: Don't attempt to export the special custom_normal attribute
Suppress exporting this attribute as there's no conversion to USD that
supports its data type (2d, 16-bit int) and because mesh normals (from
the `corner_normals` API) are already exported. This causes a rather
annoying UI Warning notification that the attribute isn't convertible
during export.

Pull Request: https://projects.blender.org/blender/blender/pulls/135271
2025-02-28 01:47:37 +01:00
Jesse Yurkovich
d6cdaff0c0 Cleanup: USD: remove now unneeded PXR_VERSION guards
These were primarily put in place during the library update period of
4.2 to ease the in-between time when not all platforms had updated
libraries. Also, now that we've begun depending on later version of USD
and MaterialX, there's little reason to pretend that using versions
prior to 24.03 is still supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/135202
2025-02-27 00:15:41 +01:00
Jesse Yurkovich
1254cb7e03 Cleanup: USD: Use newly enabled BKE_fcurve_bezt_resize API
Pull Request: https://projects.blender.org/blender/blender/pulls/135147
2025-02-26 07:31:59 +01:00
Aras Pranckevicius
b02f2e8c59 Merge branch 'blender-v4.4-release' 2025-02-25 14:16:13 +02:00
Nikita Lisitsa
e1bcd08f61 Fix #135073: OBJ import of emissive colors
The emissions strength was only set when using an emissive texture.
Additionally, for colors brighter than 1.0, normalize the color
into 0..1 range and set the strength accordingly.

Pull-Request: https://projects.blender.org/blender/blender/pulls/135094
2025-02-25 14:15:18 +02:00
Jacques Lucke
3eaccd6c2c Fix: Geometry Nodes: use object names in Import OBJ node 2025-02-24 18:57:41 +01:00
Falk David
0db9486057 Merge branch 'blender-v4.4-release' 2025-02-24 14:12:27 +01:00
Sybren A. Stüvel
857743db9d USD: import skeletal animation as slotted Actions
The USD importer was still creating legacy Actions, which are no longer
supported in Blender 4.4. This commit updates the code to produce
slotted Actions instead.

This also avoids the need to create F-Curves "from scratch", but rather
uses the available functionality. This makes the code somewhat easier to
maintain.

Pull Request: https://projects.blender.org/blender/blender/pulls/134866
2025-02-24 12:39:52 +01:00
Campbell Barton
85af07f438 Cleanup: spelling in comments 2025-02-23 21:02:54 +11:00
Maxime-Cots
92aab7c3db USD: Add Capsule_1 and Cylinder_1 Shapes to USD importer
This PR adds support for 2 additional USD Prim Shape Schemas :
* Cylinder_1
* Capsule_1

Additional tests will be added afterwards but a simple test is simply to
import the resulting file:
```python
from pxr import Usd, UsdGeom
stage = Usd.Stage.CreateNew('shapes.usda')
UsdGeom.Xform.Define(stage, '/world')
UsdGeom.Cylinder_1.Define(stage, '/world/cylinder_1')
UsdGeom.Capsule_1.Define(stage, '/world/capsule_1')
stage.GetRootLayer().Save()
```

Linked issue : https://projects.blender.org/blender/blender/issues/134138

Co-authored-by: Nig3l <nig3lpro@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/134944
2025-02-21 22:54:09 +01:00
Jesse Yurkovich
a810737716 USD: Improved sanitation of names with leading digits
USD identifiers cannot start with a digit and, like all unsupported
characters, they will be turned into an `_`. This is a bit unfortunate
since object names like "1" or "2" both become "_" in the output file.
This not only generates a naming collision, which is not currently
handled, but it needlessly loses information even when there is no
collision.

Treat leading digits separately and turn names like "1" and "2" into
"_1" and "_2" respectively. This will allow us to eventually enable the
`light_tree_node_subtended_angle` render test which uses such names for
the lights. Another recent test required investigation and then rework
due to the same problem.

Pull Request: https://projects.blender.org/blender/blender/pulls/134595
2025-02-21 20:17:42 +01:00
Jacques Lucke
88157430c1 Geometry Nodes: eagerly update bounding box after CSV import
This avoids computing the bounding box later (if the positions are not changed).
Since the positions are are zero, the bounding box is just the origin point too.
2025-02-20 11:45:21 +01:00
Jacques Lucke
46ae0a86ca Geometry Nodes: improve multi-threading and avoid redundant work in CSV import
The position attribute was not initialized in parallel. Also there was an accidental
single threaded copy of each attribute because a `std::move` didn't work because
the variable was `const`.
2025-02-20 10:52:15 +01:00
Jesse Yurkovich
c5b34ff17f Cleanup: IO: Use recently added radius accessors for USD and Alembic IO
Use recently added `radius` accessors for USD and Alembic PointClouds
and Curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/134704
2025-02-20 00:23:25 +01:00
Jesse Yurkovich
de5c38e969 Merge branch 'blender-v4.4-release' 2025-02-19 14:09:48 -08:00
Jesse Yurkovich
1ef3808030 Fix: Incorrect radius values used for Alembic points and USD nurbs
These were reading in "widths" and not adjusting the values when setting
Blender's "radius" properties.

Found while cleaning up the radius API usage as part of another change.

Pull Request: https://projects.blender.org/blender/blender/pulls/134709
2025-02-19 23:09:03 +01:00
Jörg Müller
9301a0e159 Compile fix: include limits.h for INT_MIN/MAX.
Pull Request: https://projects.blender.org/blender/blender/pulls/134697
2025-02-19 22:51:07 +01:00
Dalai Felinto
1584cd9aa5 Cleanup: Rename point cloud to pointcloud / POINT_CLOUD to POINTCLOUD
Though "Point Cloud" written as two words is technically correct and should be used in the UI, as one word it's typically easier to write and parse when reading. We had a mix of both before this patch, so better to unify this as well.

This commit also renames the editor/intern/ files to remove pointcloud_ prefix.
point_cloud was only preserved on the user facing strings:

* is_type_point_cloud
* use_new_point_cloud_type

Pull Request: https://projects.blender.org/blender/blender/pulls/134803
2025-02-19 17:11:08 +01:00
илья _
119fc054f8 Cleanup: BKE: Nodes: Pass-by-reference
Restriction of the nodes api to clearly define never-null function arguments.
Side effects: some assertions and null-check (with early return) were removed.
On the caller side is ensured to never derefer null to pass argument (mainly in RNA).
In addition, one pointer argument now actually a return type.

By-reference return types instead of pointers going to be separate kind of
change since also imply of cleaning up variables created from reference.

Also good future improvement would be to mark a copy-constructor as
explicit for DNA node types.

Pull Request: https://projects.blender.org/blender/blender/pulls/134627
2025-02-19 13:44:11 +01:00
Jacques Lucke
3263dd6333 Fix: Geometry Nodes: unescape column names after csv import 2025-02-19 12:36:19 +01:00
Jacques Lucke
ac2cd6c1ef Geometry Nodes: make CSV parser more reliable and faster
This reimplements the CSV parser used by the (still experimental) Import CSV
node.

Reliability is improved by:
* Properly handling quoted fields.
* Unit tests.
* Generalizing the parser to be able to handle customized delimiter, quote and
  escape characters (those are not exposed in the node yet though).
* More accurate detection of column types by actually taking all values of a
  column into account instead of only the first row.

Performance is improved by designing the parser in a way that supports
multi-threaded parsing. I'm measuring about 5x performance improvement which
mainly comes from multi-threading. Some files I wanted to use for benchmarking
didn't load in the version that's in `main` but do load fine with this new
version.

The implementation is now split up into two parts:
1. A general CSV parser in `blenlib` that manages splitting a buffer into
   records and their fields.
2. Application specific parsing of fields into e.g. floats and integers which
   remains in `io/csv/importer`.

This separation simplifies unit testing and makes the core code more reusable.

Pull Request: https://projects.blender.org/blender/blender/pulls/134715
2025-02-19 11:10:59 +01:00
Hans Goudey
b62ba4af33 Fix: CSV import node ignores last character of some columns 2025-02-17 20:14:54 -05:00
Hans Goudey
947658d1b2 Refactor: Simplify CustomData functions by requiring ImplicitSharingInfo
Previously we generally expected CustomData layers to have implicit
sharing info, but we didn't require it. This PR clarifies that we do
require layers with non-null data to have implicit sharing info. This
generally makes code simpler because we don't have to have a separate
code path for non-shared layers. For example, it makes the "totelem"
arguments for layer freeing functions unnecessary, since shared data
knows how to free itself. Those arguments are removed in this PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/134578
2025-02-17 19:44:54 +01:00
Campbell Barton
5087246f39 Cleanup: strip trailing space, sort file lists 2025-02-16 20:42:16 +11:00
Hans Goudey
4727dfd627 Cleanup: Remove unnecessary const qualifiers in function declarations 2025-02-14 14:32:57 -05:00
Bastien Montagne
70f77a5bf3 Merge branch 'blender-v4.4-release' 2025-02-14 18:41:43 +01:00
Bastien Montagne
69f7530f7a Fix (unreported) invalid C-style allocation of non-trivial C++ data. 2025-02-14 18:39:24 +01:00
Bastien Montagne
c43a583370 Merge branch 'blender-v4.4-release' 2025-02-14 17:21:17 +01:00
Falk David
2cc6f7bbb5 Fix #133339: Grease Pencil: Ensure span attribute writers are valid
When calling the `lookup_or_add` functions on `MutableAttributeAccessor`
we need to make sure that the writer is actually created and the call
did not fail.

This fixes many of the instances where we would use an unchecked
attribute writer and potentially crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/134413
2025-02-14 15:54:20 +01:00