mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix #155830: Invalid freestyle attributes on CustomData
Freestyle marks should be stored in generic attributes, now fully in AttributeStorage, not CustomData. For reasons I don't fully understand, the edge mark in the file from the report was still stored on CustomData. The versioning code was also never put in a subversion check. Fix this by making the situation clearer: move the versioning to the latest subversion and modify it to create the correct Attribute data. Pull Request: https://projects.blender.org/blender/blender/pulls/155873
This commit is contained in:
parent
667b4194b9
commit
0e6342e77c
4 changed files with 22 additions and 11 deletions
|
|
@ -30,7 +30,7 @@ namespace blender {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 8
|
||||
#define BLENDER_FILE_SUBVERSION 9
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
|
|
|||
|
|
@ -2436,8 +2436,13 @@ void mesh_freestyle_marks_to_generic(Mesh &mesh)
|
|||
if (data != nullptr) {
|
||||
static_assert(sizeof(FreestyleEdge) == sizeof(bool));
|
||||
static_assert(char(FREESTYLE_EDGE_MARK) == char(true));
|
||||
CustomData_add_layer_named_with_data(
|
||||
&mesh.edge_data, CD_PROP_BOOL, data, mesh.edges_num, "freestyle_edge", sharing_info);
|
||||
Attribute::ArrayData array_data{};
|
||||
array_data.data = data;
|
||||
array_data.size = mesh.edges_num;
|
||||
sharing_info->add_user();
|
||||
array_data.sharing_info = ImplicitSharingPtr<>(sharing_info);
|
||||
mesh.attribute_storage.wrap().add(
|
||||
"freestyle_edge", bke::AttrDomain::Edge, bke::AttrType::Bool, std::move(array_data));
|
||||
}
|
||||
if (sharing_info != nullptr) {
|
||||
sharing_info->remove_user_and_delete_if_last();
|
||||
|
|
@ -2460,8 +2465,13 @@ void mesh_freestyle_marks_to_generic(Mesh &mesh)
|
|||
if (data != nullptr) {
|
||||
static_assert(sizeof(FreestyleFace) == sizeof(bool));
|
||||
static_assert(char(FREESTYLE_FACE_MARK) == char(true));
|
||||
CustomData_add_layer_named_with_data(
|
||||
&mesh.face_data, CD_PROP_BOOL, data, mesh.faces_num, "freestyle_face", sharing_info);
|
||||
Attribute::ArrayData array_data{};
|
||||
array_data.data = data;
|
||||
array_data.size = mesh.edges_num;
|
||||
sharing_info->add_user();
|
||||
array_data.sharing_info = ImplicitSharingPtr<>(sharing_info);
|
||||
mesh.attribute_storage.wrap().add(
|
||||
"freestyle_face", bke::AttrDomain::Face, bke::AttrType::Bool, std::move(array_data));
|
||||
}
|
||||
if (sharing_info != nullptr) {
|
||||
sharing_info->remove_user_and_delete_if_last();
|
||||
|
|
|
|||
|
|
@ -4498,12 +4498,6 @@ void blo_do_versions_500(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
|
||||
/* Keep this versioning always enabled at the bottom of the function; it can only be moved
|
||||
* behind a subversion bump when the file format is changed. */
|
||||
for (Mesh &mesh : bmain->meshes) {
|
||||
bke::mesh_freestyle_marks_to_generic(mesh);
|
||||
}
|
||||
|
||||
/* TODO: Can be moved to subversion bump. */
|
||||
AS_asset_library_import_method_ensure_valid(*bmain);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "BLI_sys_types.h"
|
||||
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_mesh_legacy_convert.hh"
|
||||
#include "BKE_node.hh"
|
||||
#include "BKE_node_legacy_types.hh"
|
||||
|
||||
|
|
@ -111,6 +112,12 @@ void blo_do_versions_520(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 502, 9)) {
|
||||
for (Mesh &mesh : bmain->meshes) {
|
||||
bke::mesh_freestyle_marks_to_generic(mesh);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue