Commit Graph

387 Commits

Author SHA1 Message Date
Aras Pranckevicius 70720c42c2 Fix T96303: C++ OBJ exporter needs presets and skip modifiers.
This patch, D14303, from Aras Pranckevicius adds presets to the OBJ exporter,
and also adds a checkbox (default on) to apply modifiers before export.
2022-03-13 12:04:52 -04:00
Hallam Roberts 3da84d8b08 Cleanup: use M_PI_2 and M_PI_4 where possible
The constant M_PI_4 is added to GLSL to ensure it works there too.

Differential Revision: https://developer.blender.org/D14288
2022-03-11 18:27:58 +01:00
Campbell Barton 1829232598 Cleanup: spelling in comments & some minor clarifications 2022-03-10 16:27:18 +11:00
Campbell Barton 06d9c2c223 Cleanup: spelling in comments 2022-03-08 14:32:34 +11:00
Jacques Lucke 037e1ad140 Merge branch 'blender-v3.1-release' 2022-03-02 17:13:57 +01:00
Jacques Lucke 2fb31f34af Fix T95692: incorrect interpolated children particle hair
Differential Revision: https://developer.blender.org/D14227
2022-03-02 17:12:56 +01:00
Campbell Barton aa500c4fca Cleanup: use back-slash for doxygen commands, color after parameters 2022-03-02 12:11:08 +11:00
Campbell Barton eb0f8317e2 Cleanup: ED_view3d_win_to_delta & ED_view3d_calc_zfac usage
- Rename ED_view3d_win_to_delta `mval` argument to `xy_delta` as it
  as it was misleading since this is an screen-space offset not a region
  relative cursor position (typical use of the name `mval`).
  Also rename the variable passed to this function which also used the
  term `mval` in many places.
- Re-order the output argument of ED_view3d_win_to_delta last.
  use an r_ prefix for return arguments.
- Document how the `zfac` argument is intended to be used.
- Split ED_view3d_calc_zfac into two functions as the `r_flip` argument
  was only used in some special cases.
2022-03-01 11:18:17 +11:00
Michael Kowalski 0a6a74bac4 Fix T94396: USD errors opening saved scenes.
Added call to ensure that the USD plugins are registered
when opening a USD cache archive. This is to avoid USD
load errors due to missing USD file format plugins when
opening blender files that contain USD transform cache
constraints and mesh sequence cache modifilers.

Fixes T94396
2022-02-25 09:27:10 -05:00
Kévin Dietrich 24450fa142 Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-24 03:01:44 +01:00
Kévin Dietrich ba274d20b4 Fix T95959: crash when exporting subdivision to Alembic
When exporting generated coordinates, the subdivision export code was
using the schema for the non-subdivision case, which is invalid as
non-initialized. This typo existed since the initial commit for the
feature (rBf9567f6c63e75feaf701fa7b78669b9a436f13dd).
2022-02-24 02:46:33 +01:00
YimingWu 2234bfbcdb GPencil: Simplify sample modifier improvements.
1. Now handles cyclic strokes correctly.

2.  Added a sharp threshold value to allow preservation of sharp corners.

Reviewed By: Antonio Vazquez (antoniov), Aleš Jelovčan (frogstomp)

Ref D14044
2022-02-22 12:54:35 +08:00
Campbell Barton c3d36b7127 Cleanup: clang-format 2022-02-22 09:56:43 +11:00
Hans Goudey ddf189892c Cleanup: Rename original curve object type enum
This commit renames enums related the "Curve" object type and ID type
to add `_LEGACY` to the end. The idea is to make our aspirations clearer
in the code and to avoid ambiguities between `CURVE` and `CURVES`.

Ref T95355

To summarize for the record, the plans are:
- In the short/medium term, replace the `Curve` object data type with
 `Curves`
- In the longer term (no immediate plans), use a proper data block for
  3D text and surfaces.

Differential Revision: https://developer.blender.org/D14114
2022-02-18 09:50:29 -06:00
Sebastian Parborg b6fe1b0c65 Merge branch 'blender-v3.1-release' 2022-02-17 18:44:18 +01:00
Sebastian Parborg a04300c436 Cleanup: Move more cmake library variables to be advanced
I noticed that there were a few variables that should not be visible per default.
It seems to me to simply be an oversight, so I went ahead and cleaned them up.

Reviewed By: Sybren, Ray molenkamp

Differential Revision: http://developer.blender.org/D14132
2022-02-17 18:42:06 +01:00
Campbell Barton 37821143dd Cleanup: clang-format, use static sets, sort struct declarations 2022-02-16 13:04:20 +11:00
Hans Goudey a9f023e226 BLI: Change dependencies in vector math files
This patch reverses the dependency between `BLI_math_vec_types.hh` and
`BLI_math_vector.hh`. Now the higher level `blender::math` functions
depend on the header that defines the types they work with, rather than
the other way around.

The initial goal was to allow defining an `enable_if` in the types header
and using it in the math header. But I also think this operations to types
dependency is more natural anyway.

This required changing the includes some files used from the type
header to the math implementation header. I took that change a bit
further removing the C vector math header from the C++ header;
I think that helps to make the transition between the two systems
clearer.

Differential Revision: https://developer.blender.org/D14112
2022-02-15 10:27:03 -06:00
Hans Goudey 7d5f6c330f Cleanup: Clang tidy
Use using instead of typedef, remove redundant string init,
use "empty", address qualified auto, use nullptr.
2022-02-13 13:15:53 -06:00
Campbell Barton 281ba8a063 File headers: add missing copyright, add MIT to SPDX licenses 2022-02-11 14:56:03 +11:00
Campbell Barton bff0cf1030 Cleanup: remove white-space before headers 2022-02-11 14:23:54 +11:00
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Sergey Sharybin ad77b52abc Correction to previous Clang strict warning commit
Need to only pop diagnostic if it was really pushed.

Pointed out by Aras Pranckevicius, thanks!
2022-02-10 16:05:11 +01:00
Sergey Sharybin 9e9355190c Fix compilation with strict Clang flags
There is no `-Wformat-truncation` warning in Clang, so tweak checks
around diagnostics pragma accordingly.
2022-02-10 10:55:50 +01:00
Campbell Barton fe80ff446f Cleanup: copyright in headers, spelling in comments
- Order year consistently.
- Minor consistency (case, double-spacing).
- Correct typos.
2022-02-10 10:25:06 +11:00
Howard Trickey f199f03994 Merge branch 'blender-v3.1-release' 2022-02-06 15:00:21 -05:00
Aras Pranckevicius 1d59a7aa77 Fix T95384: new obj exporter inaccurate roughness value in new exporter.
Fixes T95384. New exporter was missing a fix for T94516 that recently got applied to the python exporter.

Also changed the obj export tests code so that when save_failing_test_output is requested and MTL result is different from the golden expectation, it is saved as well, similar to how it's done for the OBJ file result.
2022-02-06 14:53:07 -05:00
Aras Pranckevicius 9261bc9476 Further speedup of new obj exporter.
This change from Aras further parallelizes wihin large meshes (the previous one
just parallelized over objects).

Some stats: on A Windows machine, AMD Ryzen (32 threads):

(one mesh) Monkey subdivided to level 6: 4.9s -> 1.2s (blender 3.1 was 6.3s; 3.0 was 49.4s).
(one mesh) "Rungholt" minecraft level: 8.5s -> 2.9s (3.1 was 10.5s; 3.0 was 73.7s).
(lots of meshes) Blender 3 splash: 6.2s -> 5.2s (3.1 was 48.9s; 3.0 was 392.3s).

On a Linux machine (Threadripper, 48 threads, writing to SSD):
Monkey - 5.08s -> 1.18s (4.2x speedup)
Rungholt - 9.52s -> 3.22s (2.95x speedup)
Blender 3 splash - 5.91s -> 4.61s (1.28x speedup)

For details see patch D14028.
2022-02-06 14:28:22 -05:00
Howard Trickey 94c0a59f95 Merge branch 'blender-v3.1-release'
Also fixed conflicts due to the change in file writing in the new obj exporter
in master, and fixed one of the tests that was added in master but not 3.1.
2022-02-05 18:04:30 -05:00
Aras Pranckevicius c24b2cdebf Fix T95360, new 3.1 obj exporter losing nurbs curve "endpoint".
The new wavefront .obj exporter in 3.1 was producing slightly invalid parm line syntax (missing u), and was not setting first/last N params to zeroes and ones for curves with "endpoint" flag properly.
2022-02-05 17:51:03 -05:00
Hans Goudey 28656293c6 Cleanup: Clang tidy, use braces
Braces missed in b73d3b80fd
2022-02-03 18:27:42 -06:00
Campbell Barton d82372aee3 Cleanup: spelling in comments 2022-02-02 13:53:46 +11:00
Jeroen Bakker 2216699c64 Cleanup: Change NULL to nullptr. 2022-01-31 15:43:13 +01:00
Campbell Barton 012e41fc8b Cleanup: use our own conventions for tags in comments 2022-01-31 10:49:59 +11:00
Aras Pranckevicius 1f7013fb90 Speed up the new OBJ exporter via bigger write buffer and parallelization.
This is a patch from Aras Pranckevicius, D13927. See that patch for full
details. On Windows, the many small fprintfs were taking up a large amount
of time and significant speedup comes from using snprintf into chained buffers,
and writing them all out later.
On both Windows and Linux, parallelizing the processing by Object can also lead
to a significant increase in speed.
The 3.0 splash screen scene exports 8 times faster than the current C++ exporter
on a Windows machine with 32 threads, and 5.8 times faster on a Linux machine
with 48 threads.

There is admittedly more memory usage for this, but it is still using 25 times
less memory than the old python exporter on the 3.0 splash screen scene, so
this seems an acceptable tradeoff. If use cases come up for exporting obj files
that exceed the memory size of users, a flag could be added to not parallelize
and write the buffers out every so often.
2022-01-30 15:03:31 -05:00
Howard Trickey b315678fea Merge branch 'blender-v3.1-release' 2022-01-30 13:57:45 -05:00
Aras Pranckevicius 07514def19 Fix T95328, new obj exporter not exporting custom normals.
Previously, the new obj exporter was only exporting per-vertex normals for faces
marked as "smooth". But a face can have custom normals, as soon as the normals
data layer exists. This change makes it follow the behavior of USD & Collada
exporters and the old Python one, which also export per-vertex normals as soon
as the layer is there. (From Patch D13957.)
2022-01-30 13:48:03 -05:00
Aaron Carlisle e951e81b0f Cleanup: Cmake: remove unnecessary definitions for internationalization
Previously, macros were ifdefed using the cmake option `WITH_INTERNATIONAL`
However, the is unnecessary as withen the functions themselves have checks for building without internationalization.
This also means that many `add_definitions(-DWITH_INTERNATIONAL)` are also unnecessary.

Reviewed By: mont29, LazyDodo

Differential Revision: https://developer.blender.org/D13929
2022-01-29 17:40:27 -05:00
Campbell Barton 9f6b19526d Cleanup: spelling in comments
Also minor wording improvements.
2022-01-28 14:52:47 +11:00
Campbell Barton 7475012e24 Cleanup: rename BLI_paths_equal to BLI_path_cmp_normalized
Changes to recent addition: c85c52f2ce.

Having both BLI_paths_equal and BLI_path_cmp made it ambiguous
which should be used, as `BLI_paths_equal` wasn't the equivalent to
`BLI_path_cmp(..) == 0` as it is for string equals macro `STREQ(..)`.
It's also a more specialized function which is not used for path
comparison throughout Blender's internal path handling logic.

Instead rename this `BLI_path_cmp_normalized` and return the result of
`BLI_path_cmp` to make it clear paths are modified before comparison.

Also add comments about the conventions for Blender's path comparison
as well as a possible equivalent to Python's `os.path.samefile`
for checking if two paths point to the same location on the file-system.
2022-01-28 14:50:16 +11:00
Michael Kowalski c85c52f2ce USD Preview Surface material export.
Add `USD Preview Surface From Nodes` export option, to convert a
Principled BSDF material node network to an approximate USD Preview
Surface shader representation. If this option is disabled, the original
material export behavior is maintained, where viewport setting are saved
to the Preview Surface shader.

Also added the following options for texture export.

  - `Export Textures`: If converting Preview Surface, export textures
    referenced by shader nodes to a 'textures' directory which is a
    sibling of the USD file.
  - `Overwrite Textures`: Allow overwriting existing texture files when
    exporting textures (this option is off by default).
  - `Relative Texture Paths`:  Make texture asset paths relative to the
    USD.

The entry point for the new functionality is
`create_usd_preview_surface_material()`, called from
`USDAbstractWriter::ensure_usd_material()`.  The material conversion
currently handles a small subset of Blender shading nodes,
`BSDF_DIFFUSE`, `BSDF_PRINCIPLED`, `TEX_IMAGE` and `UVMAP`.

Texture export is handled by copying texture files from their original
location to a `textures` folder in the same directory as the USD.
In-memory and packed textures are saved directly to the textures folder.

This patch is based, in part, on code in Tangent Animation's USD
exporter branch.

Reviewed By: sybren, HooglyBoogly

Differential Revision: https://developer.blender.org/D13647
2022-01-27 15:51:50 +01:00
Campbell Barton 43e3a33082 Cleanup: spelling in comments 2022-01-24 14:35:23 +11:00
Kévin Dietrich 807c58aae4 Cleanup: separate function for Alembic edge crease reading 2022-01-23 16:35:11 +01:00
Aras Pranckevicius 9350005d8b Fix T13879 new OBJ exporter not saving files with Unicode characters.
Need to use BLI_fopen instead of fopen.
2022-01-21 20:14:01 -05:00
Howard Trickey 54d69a2fd1 Fix new OBJ exporter to handle instancing.
The new OBJ exporter did not handle object instances.
The fix is to use a dependency graph iterator, asking for instances.
Unfortunately that iterator makes a temporary copy of instance objects
that does not persist past the iteration, but we need to save all the
objects and meshes to write later, so the Object has to be copied now.

This changed some unit tests. Even though the tests don't have instancing,
the iterator also picks up some Text objects as Mesh ones (which is a good
thing), resulting in two more objects in the all_objects.obj file output.
2022-01-21 14:37:33 -05:00
Ankit Meel 36c40760a5 .obj: simplify templates in FileHandler, add comments
- Remove redundant template from `FormattingSyntax`.
- Replace one enable_if with static assert for readability
- Add comments

No functional change expected.

Reviewed by: jacqueslucke
Differential Revision: https://developer.blender.org/D13882
2022-01-21 15:28:04 +05:30
Kévin Dietrich 4425e0cd64 Subdivision: add support for vertex creasing
This adds vertex creasing support for OpenSubDiv for modeling, rendering,
Alembic and USD I/O.

For modeling, vertex creasing follows the edge creasing implementation with an
operator accessible through the Vertex menu in Edit Mode, and some parameter in
the properties panel. The option in the Subsurf and Multires to use edge
creasing also affects vertex creasing.

The vertex crease data is stored as a CustomData layer, unlike edge creases
which for now are stored in `MEdge`, but will in the future also be moved to
a `CustomData` layer. See comments for details on the difference in behavior
for the `CD_CREASE` layer between egdes and vertices.

For Cycles this adds sockets on the Mesh node to hold data about which vertices
are creased (one socket for the indices, one for the weigths).

Viewport rendering of vertex creasing reuses the same color scheme as for edges
and creased vertices are drawn bigger than uncreased vertices.

For Alembic and USD, vertex crease support follows the edge crease
implementation, they are always read, but only exported if a `Subsurf` modifier
is present on the Mesh.

Reviewed By: brecht, fclem, sergey, sybren, campbellbarton

Differential Revision: https://developer.blender.org/D10145
2022-01-20 12:21:34 +01:00
Campbell Barton eb3ff1d6f9 Cleanup: spelling in comments 2022-01-20 11:59:20 +11:00
Campbell Barton 1d536c21dd Cleanup: clang-format 2022-01-20 11:59:20 +11:00
Howard Trickey 6dd89afa96 Fix obj exporter tests by deduping normals and printing with less precision.
Some new obj exporter tests were disabled because the normals were different
in the last decimal place on different platforms.
The old python exporter deduped normals with their coordinates rounded to
four decimal places. This change does the same in the new exporter.
On one test, this produced a file 25% smaller and even ran 10% faster.
2022-01-17 23:22:40 -05:00