Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-10-10OBJ: add global scale factor import settingAras Pranckevicius
Requested in D16095 proposal - also USD & Alembic have import scale option; OBJ has an export scale object but the import scale was not there for some reason.
2022-10-10Cleanup: spelling in commentsCampbell Barton
2022-10-09Fix T101685: OBJ importer does not assign proper material if "usemtl" is ↵Aras Pranckevicius
before "o" The importer logic was wrongly resetting "current material name" upon encountering a new object ("o" command). However as per OBJ specification, this is incorrect: > Specifies the material name for the element following it. Once a > material is assigned, it cannot be turned off; it can only be > changed. Fixes T101685. Test coverage for this was added in svn tests repo.
2022-10-03Fix T101487: New OBJ importer handles UVs incorrectly when some faces of an ↵Aras Pranckevicius
object don't have UVs The UV data filling logic was incorrectly just skipping over loop entries that don't have a UV coordinate, instead of assigning the default zero UV for them. This was a problem only for meshes where some faces did have UVs, but some other faces did not (T101487).
2022-09-26Cleanup: replace C-style casts with functional casts for numeric typesCampbell Barton
Use function style casts in C++ headers & source.
2022-09-25Cleanup: replace C-style casts with functional casts for numeric typesCampbell Barton
2022-09-25Cleanup: replace static_casts with functional casts for numeric typesCampbell Barton
2022-09-25Cleanup: use 'u' prefixed integer types for brevity & cast styleCampbell Barton
To use function style cast '(unsigned char)x' can't be replaced by 'unsigned char(x)'.
2022-09-23Cleanup: use ELEM macroCampbell Barton
2022-09-14ViewLayer: Lazy sync of scene data.Monique Dewanchand
When a change happens which invalidates view layers the syncing will be postponed until the first usage. This will improve importing or adding many objects in a single operation/script. `BKE_view_layer_need_resync_tag` is used to tag the view layer to be out of sync. Before accessing `BKE_view_layer_active_base_get`, `BKE_view_layer_active_object_get`, `BKE_view_layer_active_collection` or `BKE_view_layer_object_bases` the caller should call `BKE_view_layer_synced_ensure`. Having two functions ensures that partial syncing could be added as smaller patches in the future. Tagging a view layer out of sync could be replaced with a partial sync. Eventually the number of full resyncs could be reduced. After all tagging has been replaced with partial syncs the ensure_sync could be phased out. This patch has been added to discuss the details and consequences of the current approach. For clarity the call to BKE_view_layer_ensure_sync is placed close to the getters. In the future this could be placed in more strategical places to reduce the number of calls or improve performance. Finding those strategical places isn't that clear. When multiple operations are grouped in a single script you might want to always check for resync. Some areas found that can be improved. This list isn't complete. These areas aren't addressed by this patch as these changes would be hard to detect to the reviewer. The idea is to add changes to these areas as a separate patch. It might be that the initial commit would reduce performance compared to master, but will be fixed by the additional patches. **Object duplication** During object duplication the syncing is temporarily disabled. With this patch this isn't useful as when disabled the view_layer is accessed to locate bases. This can be improved by first locating the source bases, then duplicate and sync and locate the new bases. Will be solved in a separate patch for clarity reasons ({D15886}). **Object add** `BKE_object_add` not only adds a new object, but also selects and activates the new base. This requires the view_layer to be resynced. Some callers reverse the selection and activation (See `get_new_constraint_target`). We should make the selection and activation optional. This would make it possible to add multiple objects without having to resync per object. **Postpone Activate Base** Setting the basact is done in many locations. They follow a rule as after an action find the base and set the basact. Finding the base could require a resync. The idea is to store in the view_layer the object which base will be set in the basact during the next sync, reducing the times resyncing needs to happen. Reviewed By: mont29 Maniphest Tasks: T73411 Differential Revision: https://developer.blender.org/D15885
2022-09-14Adding `const Scene*` parameter in many areas.Monique Dewanchand
Related to {D15885} that requires scene parameter to be added in many places. To speed up the review process the adding of the scene parameter was added in a separate patch. Reviewed By: mont29 Maniphest Tasks: T73411 Differential Revision: https://developer.blender.org/D15930
2022-09-13obj: implement support for PBR .mtl extensionsAras Pranckevicius
Implement import & export support for "PBR extensions" in .mtl files (T101029, also fixes T86736). Newly supported parameters: - Roughness (Pr, map_Pr) - Metallic (Pm, map_Pm) - Sheen (Ps, map_Ps) - Clearcoat thickness (Pc) and roughness (Pcr) - Anisotropy (aniso) and rotation (anisor) - Transmittance (Tf / Kt) Exporter has an option to enable these additional PBR parameters export; defaults to off since not all software understands that. Exporter UI tweaked and all material-related options were put into their own separate box. Added/extended test files in Subversion repository for test coverage.
2022-09-13Cleanup: spelling in commentsCampbell Barton
2022-09-12Cleanup: obj: rename MTLMaterial & MTLTexMapType membersAras Pranckevicius
The members were named after .mtl file syntax ("d") instead of their meaning ("alpha"). In preparation for extending OBJ code for more PBR parameters support, rename them for clarity. No functionality changes, just a pure rename.
2022-09-09Cleanup: Simplify BKE_mesh_nomain_to_meshHans Goudey
- Remove "take ownership" argument which was confusing and always true - The argument made ownership very confusing - Better to avoid boolean arguments that switch a function's purpose - Remove "mask" argument which was basically wrong and not used properly - "EVERYTHING" was used because developers are wary of removing data - Instead use `CD_MASK_MESH` for its purpose of original mesh data - Remove use of shallow copied temporary mesh, which is unnecessary now - Split shape key processing into separate functions and use C++ types - Copy fields explicitly rather than using memcpy for the whole struct - Use higher level functions and avoid redundant code - The whole idea is pretty simple and can be built from standard logic - Adjust `CustomData` logic to be consistent with "assign" expectations - Clear the layer data from the source, and moves the anonymous ID Differential Revision: https://developer.blender.org/D15857
2022-09-08Cleanup: Use C++ methods to retrieve attribute accessorsHans Goudey
Replace `mesh_attributes`, `mesh_attributes_for_write` and the point cloud versions with methods on the `Mesh` and `PointCloud` types. This makes them friendlier to use and improves readability. Differential Revision: https://developer.blender.org/D15907
2022-09-07Cleanup: Tweak naming for recently added mesh accessorsHans Goudey
Use `verts` instead of `vertices` and `polys` instead of `polygons` in the API added in 05952aa94d33eeb50. This aligns better with existing naming where the shorter names are much more common.
2022-09-05Mesh: Remove redundant custom data pointersHans Goudey
For copy-on-write, we want to share attribute arrays between meshes where possible. Mutable pointers like `Mesh.mvert` make that difficult by making ownership vague. They also make code more complex by adding redundancy. The simplest solution is just removing them and retrieving layers from `CustomData` as needed. Similar changes have already been applied to curves and point clouds (e9f82d3dc7ee, 410a6efb747f). Removing use of the pointers generally makes code more obvious and more reusable. Mesh data is now accessed with a C++ API (`Mesh::edges()` or `Mesh::edges_for_write()`), and a C API (`BKE_mesh_edges(mesh)`). The CoW changes this commit makes possible are described in T95845 and T95842, and started in D14139 and D14140. The change also simplifies the ongoing mesh struct-of-array refactors from T95965. **RNA/Python Access Performance** Theoretically, accessing mesh elements with the RNA API may become slower, since the layer needs to be found on every random access. However, overhead is already high enough that this doesn't make a noticible differenc, and performance is actually improved in some cases. Random access can be up to 10% faster, but other situations might be a bit slower. Generally using `foreach_get/set` are the best way to improve performance. See the differential revision for more discussion about Python performance. Cycles has been updated to use raw pointers and the internal Blender mesh types, mostly because there is no sense in having this overhead when it's already compiled with Blender. In my tests this roughly halves the Cycles mesh creation time (0.19s to 0.10s for a 1 million face grid). Differential Revision: https://developer.blender.org/D15488
2022-09-05IDMAnagement: Add owner ID pointer to embedded ones.Bastien Montagne
Add a dedicated `owner_id` pointer to ID types that can be embedded (Collections and NodeTrees), and modify slightly come code to make handling those more safe and consistent. This implements first part of T69169. Reviewed By: brecht Differential Revision: https://developer.blender.org/D15838
2022-09-02obj: improve placement of shader nodes in imported materialsAras Pranckevicius
Previously for most materials (especially the ones without any textures), the nodes were "off screen" way to the right, requiring a view framing to even see them. Also, as soon as multiple images were used, many nodes overlapped one another and the connections were all a mess. Simplify all that, and now each node type (coordinate, mapping, image, normal map, bsdf etc.) is in it's own column, with BSDF at zero coordinate. Each used image (along with any possible coordinate, mapping, normal map) is it's own row. The resulting connections are much cleaner.
2022-09-01Cleanup: obj: simplify material node tree creationAras Pranckevicius
As pointed out in D15827 comment, the unique_ptr usage in ShaderNodetreeWrap related code does not sound very useful. Looking at it, whole ShaderNodetreeWrap does not make much sense - it's only ever created, and then immediately just one thing is fetched from it. This very much sounds like "a function", so make it just that - header file contains just a `create_mtl_node_tree` function, and the whole implementation is hidden from the users. Which I've also simplified into just a handful of freestanding functions. No functionality or performance changes, but the code does get ~80 lines shorter.
2022-09-01Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-09-01Fix T100737: OBJ/USD import: imported object has no active material, ↵Aras Pranckevicius
material has 2 users Fixes issues in importers written in C++ (T100737): - Materials had one reference count too much. Affected Collada, Alembic, USD, OBJ importers, looks like "since forever". - Active material index was not properly set on imported meshes. Regression since 3.3 (D15145). Affected Alembic, USD, OBJ. Note: now it sets the first material as the active one, whereas previously the last one was set as active. First one sounds more "intuitive" to me. Reviewed By: Bastien Montagne Differential Revision: https://developer.blender.org/D15831
2022-09-01Merge branch 'blender-v3.3-release'Bastien Montagne
2022-09-01Fix invalid memory handling in C++ OBJ MTL Importer.Bastien Montagne
An ID created with regualr ID management code should never ever be directly freed directly. For embedded nodetrees, there is a dedicated function. Reviewed By: aras_p Differential Revision: https://developer.blender.org/D15827
2022-08-31Mesh: Move material indices to a generic attributeHans Goudey
This patch moves material indices from the mesh `MPoly` struct to a generic integer attribute. The builtin material index was already exposed in geometry nodes, but this makes it a "proper" attribute accessible with Python and visible in the "Attributes" panel. The goals of the refactor are code simplification and memory and performance improvements, mainly because the attribute doesn't have to be stored and processed if there are no materials. However, until 4.0, material indices will still be read and written in the old format, meaning there may be a temporary increase in memory usage. Further notes: * Completely removing the `MPoly.mat_nr` after 4.0 may require changes to DNA or introducing a new `MPoly` type. * Geometry nodes regression tests didn't look at material indices, so the change reveals a bug in the realize instances node that I fixed. * Access to material indices from the RNA `MeshPolygon` type is slower with this patch. The `material_index` attribute can be used instead. * Cycles is changed to read from the attribute instead. * BMesh isn't changed in this patch. Theoretically it could be though, to save 2 bytes per face when less than two materials are used. * Eventually we could use a 16 bit integer attribute type instead. Ref T95967 Differential Revision: https://developer.blender.org/D15675
2022-08-31Cleanup: obj: simplify import/export syntax handling codeAras Pranckevicius
I want to add support for PBR materials extension to OBJ, but the way current I/O code syntax handling was done made it quite cumbersome to extend the number of MTL textures/parameters. Simplify all that by removing FormatHandler template on "syntax" that gets routed through keyword enums, and instead just have simple `write_obj_*` and `write_mtl_*` functions. Simplify MTLMaterial to not contain a map of textures (that is always fully filled with all possible textures), instead now there's a simple array. Rename `tex_map_XX` to `MTLTexMap`. All this does not affect behavior or performance, but it does result in 170 fewer lines of code, and saves a couple kilobytes of executable size.
2022-08-30Attributes: Improve custom data initialization optionsHans Goudey
When allocating new `CustomData` layers, often we do redundant initialization of arrays. For example, it's common that values are allocated, set to their default value, and then set to some other value. This is wasteful, and it negates the benefits of optimizations to the allocator like D15082. There are two reasons for this. The first is array-of-structs storage that makes it annoying to initialize values manually, and the second is confusing options in the Custom Data API. This patch addresses the latter. The `CustomData` "alloc type" options are rearranged. Now, besides the options that use existing layers, there are two remaining: * `CD_SET_DEFAULT` sets the default value. * Usually zeroes, but for colors this is white (how it was before). * Should be used when you add the layer but don't set all values. * `CD_CONSTRUCT` refers to the "default construct" C++ term. * Only necessary or defined for non-trivial types like vertex groups. * Doesn't do anything for trivial types like `int` or `float3`. * Should be used every other time, when all values will be set. The attribute API's `AttributeInit` types are updated as well. To update code, replace `CD_CALLOC` with `CD_SET_DEFAULT` and `CD_DEFAULT` with `CD_CONSTRUCT`. This doesn't cause any functional changes yet. Follow-up commits will change to avoid initializing new layers where the correctness is clear. Differential Revision: https://developer.blender.org/D15617
2022-08-28Cleanup: replace NULL with nullptr for C++ filesCampbell Barton
2022-08-23Merge branch 'blender-v3.3-release'Richard Antalik
2022-08-23Cleanup: formatCampbell Barton
2022-08-23Merge branch 'blender-v3.3-release'Philipp Oeser
2022-08-23Fix: OBJ import unused parameter warningPhilipp Oeser
Since {rB2542fda14d85}, `r_node` is an unused parameter. Changed `load_texture_image` to reflect that. Differential Revision: https://developer.blender.org/D15759
2022-08-16Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-08-16Fix T100421: OBJ importer in 3.3 does not keep the vertex orderAras Pranckevicius
While fixing T100302 (rBd76583cb4a1) I did not realize that the change in imported vertex order would actually matter. Turns out, it does for morph targets / mesh shape keys. So redo the fix in a way that does not change the vertex order. Fixes T100421.
2022-08-11obj: support importing multiple files at onceAras Pranckevicius
Implemented the same way as STL or GPencil SVG importers: loop over the input files, import one by one. Has been requested by the community for quite a long time (e.g. https://blender.community/c/rightclickselect/Jhbbbc/), as well as 3rd party addons to implement just this (https://github.com/p2or/blender-batch-import-wavefront-obj).
2022-08-11Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-08-11Fix T98781: OBJ exporter wrongly writing default material socket values when ↵Aras Pranckevicius
textures are present Report T98781 and part of T97642: the MTLMaterial info only captures image nodes and the default socket values. When the image information is present, do not emit the socket defaults - the .MTL spec states they are multiplied together, but the default value is not used in blender when the socket is connected. Also contains svn tests repository update to extend the test coverage, and update test expectation outputs.
2022-08-10Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-08-10obj: Also find .mtl images by their basename, if all else fails (T77801)Aras Pranckevicius
While T77801 itself is working as expected in the new C++ obj importer, the repro file there uses absolute paths to material images, yet the images themselves are right there in the current folder. The old python based importer did find them, since it was doing a really complex image search. My understanding is that while C++ importer was developed, it was decided to not do that -- however just the "basename file in the mtl directory" sounds simple enough and gets the repro case file work correctly.
2022-08-10Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-08-10Fix T100302: New OBJ importer produces too many vertices when faces don't ↵Aras Pranckevicius
span a continuous range As part of the previous fix (D15410), the importer got code to track min & max vertex indices used as part of the mesh faces. However, if faces refer to a "sparse" (i.e. non-contiguous) subset of all vertices, then the imported mesh would contain all the vertices between min & max range. Replace that with proper tracking of actually used vertex indices for each imported mesh. Fixes T100302. This does affect import performance a tiny bit, e.g. importing Blender 3.0 splash scene goes 21.7s -> 22.1s, and importing rungholt.obj goes 2.37s -> 2.48s. Importer related tests have a bunch of vertex changes in them, since now vertices are added in the order that the faces are referring to them. Which incidentally matches the order that the Python based importer was creating them too.
2022-08-04Merge branch 'blender-v3.3-release'Hans Goudey
2022-08-04Fix: Avoid OBJ importer assert seting normals on mesh with no facesHans Goudey
2022-08-01Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-08-01Fix T99502: OBJ/MTL import: behavior changed for missing texture filesAras Pranckevicius
Python based OBJ importer, as well as glTF2 importer, are creating "placeholder" images for texture images that can't be found. These are empty textures (displayed as magenta), but with their file paths set so that File > External Data > Report Missing Files can report them as missing. Make the new C++ OBJ importer do the same as well. Fixes T99502.
2022-08-01Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-08-01Fix T100076: OBJ import: new importer doesn't use //relative/image/pathsAras Pranckevicius
The Python based importer had logic to immediately turn image paths into relative-to-blender-file paths, if user preference for relative paths is used (which is on by default). The new importer code did not have that. Fixes T100076.
2022-07-31Merge branch 'blender-v3.3-release'Aras Pranckevicius
2022-07-31Fix T100075: OBJ import: images loaded multiple times instead of being reusedAras Pranckevicius
The new OBJ/MTL importer was creating a new image for any referenced texture, even if another material (or another property of the same material) already referenced the same texture. Make it use BKE_image_load_exists function just like Collada or USD importers do. Fixes T100075. Extended test coverage to count imported images; without the fix import_cubes_with_textures_rel would have incorrectly created 5 images instead of 4.