Progress
This commit is contained in:
parent
5116bfd51f
commit
c8f9b02acd
|
@ -27,6 +27,16 @@ void BKE_mesh_legacy_convert_hide_layers_to_flags(struct Mesh *mesh);
|
|||
*/
|
||||
void BKE_mesh_legacy_convert_flags_to_hide_layers(struct Mesh *mesh);
|
||||
|
||||
/**
|
||||
* Convert the selected element attributes to the old flag format for writing.
|
||||
*/
|
||||
void BKE_mesh_legacy_convert_selection_layers_to_flags(struct Mesh *mesh);
|
||||
/**
|
||||
* Convert the old selection flags (#SELECT/#ME_FACE_SEL) to the selected element attribute for
|
||||
* reading. Only add the attributes when there are any elements in each domain selected.
|
||||
*/
|
||||
void BKE_mesh_legacy_convert_flags_to_selection_layers(struct Mesh *mesh);
|
||||
|
||||
/**
|
||||
* Recreate #MFace Tessellation.
|
||||
*
|
||||
|
|
|
@ -249,6 +249,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
|
|||
Set<std::string> names_to_skip;
|
||||
if (!BLO_write_is_undo(writer)) {
|
||||
BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
|
||||
BKE_mesh_legacy_convert_selection_layers_to_flags(mesh);
|
||||
/* When converting to the old mesh format, don't save redunant attributes. */
|
||||
names_to_skip.add_multiple_new({".hide_vert", ".hide_edge", ".hide_poly"});
|
||||
}
|
||||
|
@ -337,6 +338,7 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
|
||||
if (!BLO_read_data_is_undo(reader)) {
|
||||
BKE_mesh_legacy_convert_flags_to_hide_layers(mesh);
|
||||
BKE_mesh_legacy_convert_flags_to_selection_layers(mesh);
|
||||
}
|
||||
|
||||
/* We don't expect to load normals from files, since they are derived data. */
|
||||
|
|
|
@ -837,7 +837,7 @@ void BKE_mesh_flush_select_from_polys(Mesh *me)
|
|||
".selection_edge", ATTR_DOMAIN_EDGE);
|
||||
|
||||
/* Use generic domain interpolation to read the polygon attribute on the other domains.
|
||||
* Assume selected faces are not hidden and none of their verts/edges are hidden. */
|
||||
* Assume selected faces are not hidden and none of their vertices/edges are hidden. */
|
||||
attributes.lookup_or_default<bool>(".selection_poly", ATTR_DOMAIN_POINT, false)
|
||||
.materialize(selection_vert.span);
|
||||
attributes.lookup_or_default<bool>(".selection_poly", ATTR_DOMAIN_EDGE, false)
|
||||
|
@ -856,6 +856,7 @@ static void mesh_flush_select_from_verts(const Span<MEdge> edges,
|
|||
MutableSpan<bool> selection_edge,
|
||||
MutableSpan<bool> selection_poly)
|
||||
{
|
||||
/* Select visible edges that have both of their vertices selected. */
|
||||
for (const int i : edges.index_range()) {
|
||||
if (!hide_edge[i]) {
|
||||
const MEdge &edge = edges[i];
|
||||
|
@ -863,6 +864,7 @@ static void mesh_flush_select_from_verts(const Span<MEdge> edges,
|
|||
}
|
||||
}
|
||||
|
||||
/* Select visible faces that have all of their vertices selected. */
|
||||
for (const int i : polys.index_range()) {
|
||||
if (!hide_poly[i]) {
|
||||
const MPoly &poly = polys[i];
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BLI_edgehash.h"
|
||||
#include "BLI_math.h"
|
||||
|
@ -962,3 +963,89 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
|
|||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Selection Attribute and Legacy Flag Conversion
|
||||
* \{ */
|
||||
|
||||
void BKE_mesh_legacy_convert_selection_layers_to_flags(Mesh *mesh)
|
||||
{
|
||||
using namespace blender;
|
||||
using namespace blender::bke;
|
||||
const AttributeAccessor attributes = mesh_attributes(*mesh);
|
||||
|
||||
MutableSpan<MVert> verts(mesh->mvert, mesh->totvert);
|
||||
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
|
||||
".selection_vert", ATTR_DOMAIN_POINT, false);
|
||||
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
SET_FLAG_FROM_TEST(verts[i].flag, selection_vert[i], SELECT);
|
||||
}
|
||||
});
|
||||
|
||||
MutableSpan<MEdge> edges(mesh->medge, mesh->totedge);
|
||||
const VArray<bool> selection_edge = attributes.lookup_or_default<bool>(
|
||||
".selection_edge", ATTR_DOMAIN_EDGE, false);
|
||||
threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
SET_FLAG_FROM_TEST(edges[i].flag, selection_edge[i], SELECT);
|
||||
}
|
||||
});
|
||||
|
||||
MutableSpan<MPoly> polys(mesh->mpoly, mesh->totpoly);
|
||||
const VArray<bool> selection_poly = attributes.lookup_or_default<bool>(
|
||||
".selection_poly", ATTR_DOMAIN_FACE, false);
|
||||
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
SET_FLAG_FROM_TEST(polys[i].flag, selection_poly[i], ME_FACE_SEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
|
||||
{
|
||||
using namespace blender;
|
||||
using namespace blender::bke;
|
||||
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
|
||||
|
||||
const Span<MVert> verts(mesh->mvert, mesh->totvert);
|
||||
if (std::any_of(
|
||||
verts.begin(), verts.end(), [](const MVert &vert) { return vert.flag & SELECT; })) {
|
||||
SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_only_span<bool>(
|
||||
".selection_vert", ATTR_DOMAIN_POINT);
|
||||
threading::parallel_for(verts.index_range(), 4096, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
selection_vert.span[i] = verts[i].flag & SELECT;
|
||||
}
|
||||
});
|
||||
selection_vert.finish();
|
||||
}
|
||||
|
||||
const Span<MEdge> edges(mesh->medge, mesh->totedge);
|
||||
if (std::any_of(
|
||||
edges.begin(), edges.end(), [](const MEdge &edge) { return edge.flag & SELECT; })) {
|
||||
SpanAttributeWriter<bool> selection_edge = attributes.lookup_or_add_for_write_only_span<bool>(
|
||||
".selection_edge", ATTR_DOMAIN_EDGE);
|
||||
threading::parallel_for(edges.index_range(), 4096, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
selection_edge.span[i] = edges[i].flag & SELECT;
|
||||
}
|
||||
});
|
||||
selection_edge.finish();
|
||||
}
|
||||
|
||||
const Span<MPoly> polys(mesh->mpoly, mesh->totpoly);
|
||||
if (std::any_of(
|
||||
polys.begin(), polys.end(), [](const MPoly &poly) { return poly.flag & ME_FACE_SEL; })) {
|
||||
SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_only_span<bool>(
|
||||
".selection_poly", ATTR_DOMAIN_FACE);
|
||||
threading::parallel_for(polys.index_range(), 4096, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
selection_poly.span[i] = polys[i].flag & ME_FACE_SEL;
|
||||
}
|
||||
});
|
||||
selection_poly.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -283,7 +283,6 @@ static void extract_edituv_lines_iter_subdiv_mesh(const DRWSubdivCache *subdiv_c
|
|||
const MPoly *coarse_poly)
|
||||
{
|
||||
MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data);
|
||||
|
||||
int *subdiv_loop_edge_index = (int *)GPU_vertbuf_get_data(subdiv_cache->edges_orig_index);
|
||||
|
||||
const BMFace *efa = bm_original_face_get(mr, coarse_poly - mr->mpoly);
|
||||
|
|
|
@ -869,6 +869,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_edges_lo
|
|||
|
||||
static void mesh_add_verts(Mesh *mesh, int len)
|
||||
{
|
||||
using namespace blender;
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -899,6 +900,7 @@ static void mesh_add_verts(Mesh *mesh, int len)
|
|||
|
||||
static void mesh_add_edges(Mesh *mesh, int len)
|
||||
{
|
||||
using namespace blender;
|
||||
CustomData edata;
|
||||
MEdge *medge;
|
||||
int i, totedge;
|
||||
|
@ -995,7 +997,6 @@ static void mesh_add_polys(Mesh *mesh, int len)
|
|||
|
||||
mesh->totpoly = totpoly;
|
||||
|
||||
/* TODO: Make selection optional. */
|
||||
const bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
|
||||
const bke::SpanAttributeWriter<bool> selection_poly =
|
||||
attributes.lookup_or_add_for_write_span<bool>(".selection_poly", ATTR_DOMAIN_FACE);
|
||||
|
|
|
@ -4144,7 +4144,6 @@ static bool project_paint_clone_face_skip(ProjPaintState *ps,
|
|||
}
|
||||
|
||||
typedef struct {
|
||||
const MPoly *mpoly_orig;
|
||||
const bool *selection_poly_orig;
|
||||
|
||||
const int *index_mp_to_orig;
|
||||
|
@ -4156,7 +4155,6 @@ static void proj_paint_face_lookup_init(const ProjPaintState *ps, ProjPaintFaceL
|
|||
if (ps->do_face_sel) {
|
||||
Mesh *orig_mesh = (Mesh *)ps->ob->data;
|
||||
face_lookup->index_mp_to_orig = CustomData_get_layer(&ps->me_eval->pdata, CD_ORIGINDEX);
|
||||
face_lookup->mpoly_orig = orig_mesh->mpoly;
|
||||
face_lookup->selection_poly_orig = CustomData_get_layer_named(
|
||||
&orig_mesh->pdata, CD_PROP_BOOL, ".selection_poly");
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
*/
|
||||
typedef struct MVert {
|
||||
float co[3];
|
||||
// char flag
|
||||
char flag DNA_DEPRECATED;
|
||||
char bweight;
|
||||
char _pad[3];
|
||||
} MVert;
|
||||
|
@ -85,8 +85,8 @@ typedef struct MPoly {
|
|||
enum {
|
||||
ME_SMOOTH = (1 << 0),
|
||||
#ifdef DNA_DEPRECATED_ALLOW
|
||||
/** Deprecated selection status. Now stored in ".selection_poly" attribute. */
|
||||
// ME_FACE_SEL = (1 << 1),
|
||||
/** Deprecated selection status. Now stored in ".selection_poly" attribute. */
|
||||
ME_FACE_SEL = (1 << 1),
|
||||
#endif
|
||||
/** Deprecated hide status. Now stored in ".hide_poly" attribute. */
|
||||
/* ME_HIDE = (1 << 4), */
|
||||
|
|
Loading…
Reference in New Issue