Commit Graph

1120 Commits

Author SHA1 Message Date
Campbell Barton
15db0cb446 Cleanup: use style for doxygen comment blocks 2023-11-30 14:15:11 +11:00
Campbell Barton
3b5031f1cb Cleanup: use 'r_' prefix for output arguments, order last
Also clarify some naming.
2023-11-30 10:42:18 +11:00
Ray molenkamp
94817f64b9 Cleanup: CMake: Modernize bf_intern_utfconv dependencies
- Remove any bf_intern_utfconv paths from INC
- Add a dependency though LIB when missing
- an empty target is created for non windows builds, so we don't have to
if(WIN32) this all over the place

context: https://devtalk.blender.org/t/cmake-cleanup/30260
Pull Request: https://projects.blender.org/blender/blender/pulls/115373
2023-11-28 01:11:15 +01:00
Charles Wardlaw
a9c8bf305b Cleanup: USD: Fix unused declaration and argument
Pull Request: https://projects.blender.org/blender/blender/pulls/115495
2023-11-27 21:08:17 +01:00
Charles Wardlaw
925fb66693 USD: Improved texture coordinate translation (UsdTransform2d)
The UsdTransform2d shader was previously ignored, and the material
read would stop when it found these nodes. This resulted in many
surfaces having their textures mapped incorrectly when imported
into Blender, and worse, resulted in the loss of that data when
round-tripping back out of Blender.

This patch adds support for the Transform 2D node and also ensures
that the wrap modes are similarly written correctly.

Co-authored-by: Charles Wardlaw <kattkieru@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/114821
2023-11-27 17:18:46 +01:00
Hans Goudey
14e3523ac2 Refactor: Further improvements to geometry bounds
Implement the next phases of bounds improvement design #96968.
Mainly the following changes:

Don't use `Object.runtime.bb` for performance caching volume bounds.
This is redundant with the cache in most geometry data-block types.
Instead, this becomes `Object.runtime.bounds_eval`, and is only used
where it's actually needed: syncing the bounds from the evaluated
geometry in the active depsgraph to the original object.

Remove all redundant functions to access geometry bounds with an
Object argument. These make the whole design confusing, since they
access geometry bounds at an object level.

Use `std::optional<Bounds<float3>>` to pass and store bounds instead
of an allocated `BoundBox` struct. This uses less space, avoids
small heap allocations, and generally simplifies code, since we
usually only want the min and max anyway.

After this, to avoid performance regressions, we should also cache
bounds in volumes, and maybe the legacy curve and GP data types
(though it might not be worth the effort for those legacy types).

Pull Request: https://projects.blender.org/blender/blender/pulls/114933
2023-11-27 16:14:49 +01:00
Campbell Barton
27c660707d Cleanup: spelling in comments, variables 2023-11-27 09:54:36 +11:00
Campbell Barton
c7ead98d4e License headers: add SPDX copyright entries 2023-11-27 09:27:52 +11:00
Ray Molenkamp
1b6cd937ff Cleanup: CMake: Modernize bf_imbuf dependencies
Pretty straightforward

- Remove any bf_imbuf 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/115425
2023-11-25 23:37:24 +01:00
Ray Molenkamp
6b70c04724 Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any bf_depsgraph 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/115422
2023-11-25 22:51:59 +01:00
Ray Molenkamp
b683bcc46c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any bf_intern_clog 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/115323
2023-11-24 17:12:24 +01:00
Hans Goudey
75f24a5f14 Hydra: Parallelize and simplify submesh export
- Only calculate normals on the necessary domain
- Functions for exporting generic data
- Parallelize export of multiple submeshes
- Parallelize export within a single submesh
- Resize vectors to correct size to avoid reallocation
- Simplify hot loops to improve performance
- Optimize single material case to avoid index remapping

`write_submeshes` timing information (average of many runs)
| Test                           | Before    | After     |
| ------------------------------ | --------- | --------- |
| 6 million vert mesh            | 791.99 ms | 130.75 ms |
| 1.5 million vert 100 materials | crash     | 48.27 ms  |
| Mr. Elephant test file         | 778.95 ms | 277.06 ms |

Pull Request: https://projects.blender.org/blender/blender/pulls/113412
2023-11-21 23:40:54 +01:00
Charles Wardlaw
e6ff1348cb Fix: USD Export: Calculate extents property for lights
Lights without calculated extents are not considered correct USD.
This is now possible with the APIs provided by recent USD versions.

Pull Request: https://projects.blender.org/blender/blender/pulls/113910
2023-11-20 20:51:34 -05:00
Aras Pranckevicius
0d0aad6280 IO: add STL import/export tests
Pull Request: https://projects.blender.org/blender/blender/pulls/115164
2023-11-20 11:19:50 +01:00
Hans Goudey
41f9f2753a Refactor: Mesh: Include wrapper positions in bounds result
Avoid the need to call the separate `BKE_mesh_wrapper_minmax` function
that dealt with the edit mesh wrapper. This makes the API inconsistent,
since other mesh functions don't implicitly deal with the wrapper.
But the bounds are a bit of a special case anyway in regard
to the GPU subdivision wrapper already, and this is much more
convenient in the rest of the refactors for #96968.
2023-11-19 18:36:19 -05:00
Hans Goudey
8a0079053f Cleanup: Remove mistaken reference binding to temporary 2023-11-19 15:55:55 -05:00
dupoxy
323259a7da Fix: IO: C++ STL exporter using 'PLY' in error message
Pull Request: https://projects.blender.org/blender/blender/pulls/115148
2023-11-19 18:33:50 +01:00
Aras Pranckevicius
17c793e43c IO: C++ STL exporter
There was a C++ STL importer since Blender 3.3, but no corresponding C++ STL exporter. This PR is adding said exporter: taking https://projects.blender.org/blender/blender/pulls/105598 and finishing it (agreed with original author).

Exporting Suzanne with 6 level subdivision (4 million triangles), on Apple M1 Max:
- Binary: python exporter 7.8 sec -> C++ exporter 0.9 sec.
- Ascii: python exporter 13.1 sec -> C++ exporter 4.5 sec.

Co-authored-by: Iyad Ahmed <iyadahmed430@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/114862
2023-11-19 16:41:20 +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
georgiy.m.markelov@gmail.com
d3971628e1 Hydra: Use BKE_camera_params to simplify camera code
Ref #110765

Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/114370
2023-11-15 19:03:22 +01:00
Hans Goudey
4bcdc57fc8 Refactor: Move object runtime data to separate allocation
Move object runtime data to a separate header and allocate it separately
as `blender::bke::ObjectRuntime`. This is how node, mesh, curves, and
point cloud runtime data is stored.

Benefits:
- Allow using C++ types in object runtime data
- Reduce space required for Object struct in files
- Increase conceptual separation between DNA and runtime data
- Remove the need to add manual padding in runtime data
- Include runtime struct definition only in files that require it

Pull Request: https://projects.blender.org/blender/blender/pulls/113957
2023-11-15 18:46:07 +01:00
Jesse Yurkovich
3a312babe6 Fix #114847: Skip past more newlines when parsing PLY files
When parsing PLY files it was possible that the buffer would contain
leading newline characters which were not being accounted for.

Ensure we skip past them each time we refill the buffer. Also properly
return an error string when handling such lines in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/114878
2023-11-15 08:31:55 +01:00
Hans Goudey
fdae173ed4 Cleanup: Fix debug build error after recent commit 2023-11-14 12:03:52 +01:00
Sergey Sharybin
2020f35981 Cleanup: Avoid shallow copy in PLY exporter
It is not clear why shallow copy needs to be created to access
some fields which are copied from the input object. Just use that
object directly.

Shallow copying is a weird and legacy concept, it should not be
used without huge disclaimer why it is unavoidable in the new
code.

Pull Request: https://projects.blender.org/blender/blender/pulls/114791
2023-11-14 10:59:22 +01:00
Hans Goudey
932f20135d Cleanup: Avoid shallow copy in OBJ exporter
Similar to #114791, but a bit more complex since the object
was also used to access materials and vertex groups later on.

Pull Request: https://projects.blender.org/blender/blender/pulls/114796
2023-11-14 10:58:58 +01:00
Hans Goudey
7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00
Bastien Montagne
89d67df37b Merge branch 'blender-v4.0-release' 2023-11-13 12:44:59 +01:00
Michael Kowalski
f2d15d4fd1 Fix: USD: Wrong UsdUVTexture rgb output type.
This fixes a bug where the rgb UsdUVTexture shader output
attributes were created with incorrect type color3f when
connected to UsdPreviewSurface diffuseColor and emissiveColor
inputs. The UsdPreviewSurface specification requires the
UsdUVTexture rgb output to be of type float3.

This was happening because the UsdUVTexture outputs were created
implicitly by the call to UsdShadeInput::ConnectToSource().  I.e.,
because the diffuseColor and emissiveColor inputs are of type
color3f, this was the type assigned by default to the rgb source
attributes as well.

Now explicitly creating the UsdUVTexture shader output attributes
with the correct types.

Pull Request: https://projects.blender.org/blender/blender/pulls/114728
2023-11-13 12:44:21 +01:00
Iliya Katueshenock
4f03d502e6 Cleanup: Remove iostreams include from timeit header
Continuation of #110986

Pull Request: https://projects.blender.org/blender/blender/pulls/111010
2023-11-13 10:42:29 +01:00
Jesse Yurkovich
7d375793bd Merge branch 'blender-v4.0-release' 2023-11-09 11:08:38 -08:00
Jesse Yurkovich
360684d5a4 Fix #114047: Use correct collection during USD import
Ensure that the view layer is properly synced before trying to get the
active collection.

Without the sync, imported objects typically get placed in the global
Scene Collection rather than the new collection that was just created
for the import.

Pull Request: https://projects.blender.org/blender/blender/pulls/114650
2023-11-09 20:07:51 +01:00
Christoph Lendenfeld
69a3c5c7fc Refactor: move code related to fcurve keyframe insertion
No functional changes.

Move the functions
`insert_vert_fcurve` and
`insert_bezt_fcurve`
from `ED_keyframing.hh` / `keyframing.cc`
to `ANIM_fcurve.hh` / `fcurve.cc`
in animrig

Pull Request: https://projects.blender.org/blender/blender/pulls/114570
2023-11-07 14:33:52 +01:00
Campbell Barton
611930e5a8 Cleanup: use std::min/max instead of MIN2/MAX2 macros 2023-11-07 16:33:19 +11:00
Campbell Barton
134393e846 Cleanup: spelling in comments 2023-11-04 14:08:13 +11:00
Bastien Montagne
9b0ea21a5b USD: Fix Export progress report.
This progress report was utterly broken and useless when not exporting
animations, and not great either with animation export. This commit
fixes:
* Not generating any progress report when exporting a single frame.
* Assuming actual data export covers 100% of progress.

That last point is the biggest change, now actual export (be it
animated or still) only covers 75% of the whole range. The rest is used
to cover depsgraph building and updates (which can be noticiably slow
with big scenes), stage writing, etc.

Progression is still far from linear in time, but at least it gives
better feedback on actual progress of the whole export.

Pull Request: https://projects.blender.org/blender/blender/pulls/114416
2023-11-03 18:00:45 +01:00
Aras Pranckevicius
6833202ab3 PLY: improve import of custom vertex normals
Several improvements how PLY files containing vertex normals are imported:
- When they are present on a regular mesh, the code no longer sets
  all faces as "flat" (since that makes custom normals be ignored).
- When they are present on a pure point cloud (i.e. no faces),
  custom vertex normals are added as a float3 point domain attribute
  (ref #114371).
2023-11-03 17:41:27 +02:00
Bastien Montagne
ba37c59e13 Merge branch 'blender-v4.0-release' 2023-11-03 11:04:23 +01:00
Bastien Montagne
cc6c5cb7f4 Fix #114415: USDZ conversion happens outside of main thread.
USDZ conversion currently requires to change the 'current working
directory', due to internal USD library limitations.

This can only be done from main thread (and is highly discouraged in
general). This implies that USDZ conversion cannot happen from the Job
worker thread.

This commit moves it to the `endjob` callback of the USD export job
instead, as it is guaranteed to be executed from caller thread, i.e.
main thread in this case.

Pull Request: https://projects.blender.org/blender/blender/pulls/114420
2023-11-03 10:55:55 +01:00
Aras Pranckevicius
42ee315b60 Fix #114304: OBJ import crash when some faces have normals, and others do not
The file that reproduces this had some faces of a mesh with vertex
normals, while some other faces were without vertex normals.
The parsing code assigns INT32_MAX as a fallback of "I could not parse
the normal index as a number" case, but later on code was not
catching this "normal index might be invalid" case. Fixes #114304
2023-11-03 09:45:32 +01:00
Aras Pranckevicius
d59c6d3e5c PLY: fix unreported crash when exporting multiple objects with different presence of vertex colors
Similar to e98cc412e, exporting PLY essentially merges all meshes into
one. And if any of them has vertex colors to export, they all
should get a fake/dummy vertex color entry.
2023-11-03 08:52:36 +02:00
Aras Pranckevicius
e98cc412ef Fix #114346: PLY export crash with multiple objects that have different custom attributes
Custom attribute export (#114320) code did not realize that
PLY exports everything as one single "mesh" with the same vertex
data for everything. So if exporting several input meshes and they
have different vertex attributes, the result needs to have a union
of all present attributes, with fake/zero data for the ones
that were not actually present. Fixes #114346.
2023-11-02 22:58:26 +02:00
Aras Pranckevicius
afe297231d Fix #114304: OBJ import crash when some faces have normals, and others do not
The file that reproduces this had some faces of a mesh with vertex
normals, while some other faces were without vertex normals.
The parsing code assigns INT32_MAX as a fallback of "I could not parse
the normal index as a number" case, but later on code was not
catching this "normal index might be invalid" case. Fixes #114304
2023-11-02 21:35:02 +02:00
Hans Goudey
22e706e87a Cleanup: Use utility function to fill triangle face offsets 2023-11-02 13:48:13 +01:00
Bastien Montagne
730b5057a7 Fix #114237: USD import crashes on reporting during cache handling.
This usage of the whole USD `USDStageReader` as 'cache handle' feels a
bit... uncomfortable to me. It implicitely assumes that all data in this
owned by the reader (or has a lifetime that contains the whole handle
lifetime). IMHO, if such struct is expected to have a long lifetime, it
should be documented, and probably needs better design for sub-data
handling then. Am curious to know if there is a good reason why the
handle itself is not a simple trivial class, able to re-generate an
actual complete USD reader on demand?

Or maybe we need to find a better place to store the `wmJobWorkerStatus`
data?

Anyway, for now this PR addresses the issue by ensuring that the
`worker_status` stored in the `USDImportParams` is not `nullptr` before
trying to access it for the reports.

This is more of a short-term solution though, imho there should be a way
to pass a reportlist to this codepath, and ensure the `wmJobWorkerStatus`
is always valid?

Pull Request: https://projects.blender.org/blender/blender/pulls/114337
2023-11-02 12:45:29 +01:00
Julian Eisel
1ef36fffc2 Merge branch 'blender-v4.0-release' 2023-10-31 15:00:21 +01:00
Michael Kowalski
1e7f5b1e61 USD: fix cache reader open error handling.
This commit fixes error handling logic implemented in #113524.

- No longer calling WM_reportf, which is not thread safe.
- Freeing the reader before returning early.

Pull Request: https://projects.blender.org/blender/blender/pulls/114298
2023-10-31 14:50:47 +01:00
Aras Pranckevicius
0eb6aef3b0 PLY: import/export custom vertex attributes (#108948)
Implements #108948 - support for custom point domain attributes for PLY
import and export. Notes:

- Custom attributes are always represented as scalar floats. PLY itself
  has some data types that blender can't fully represent, e.g. double or
  uint32, or some that fit into a float just fine but blender does not have
  them as separate types (e.g. int16).
- When importing, any PLY vertex attribute that is not one of "standard"
  names (position, normal, etc.) gets turned into a custom attribute.
- For exporting, more complex custom attributes (e.g. 2D/3D floats,
  quaternions, colors) get turned into several PLY attributes, with "_x"
  like suffix.

Custom attribute import/export is on by default in the UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/114320
Reviewed By: Hans Goudey
2023-10-31 14:07:51 +01:00
Brecht Van Lommel
39107b3133 Revert changes from main commits that were merged into blender-v4.0-release
The last good commit was 8474716abb.

After this commits from main were pushed to blender-v4.0-release. These are
being reverted.

Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
2023-10-30 21:40:35 +01:00
Campbell Barton
d31c61edee Cleanup: spelling in comments 2023-10-27 12:13:48 +11:00
Dalai Felinto
7b7cef7998 Merge remote-tracking branch 'origin/blender-v4.0-release' 2023-10-24 16:09:51 +02:00