Cleanup: Rename Mesh loop_data to corner_data
Related to #110434,efbee2d606
,7c69c8827b
This commit is contained in:
parent
ad6e68d12f
commit
8dd8f932e2
|
@ -437,7 +437,7 @@ static void attr_create_uv_map(Scene *scene,
|
|||
{
|
||||
const blender::Span<blender::int3> corner_tris = b_mesh.corner_tris();
|
||||
const blender::bke::AttributeAccessor b_attributes = b_mesh.attributes();
|
||||
const ustring render_name(CustomData_get_render_layer_name(&b_mesh.loop_data, CD_PROP_FLOAT2));
|
||||
const ustring render_name(CustomData_get_render_layer_name(&b_mesh.corner_data, CD_PROP_FLOAT2));
|
||||
if (!blender_uv_names.empty()) {
|
||||
for (const ustring &uv_name : blender_uv_names) {
|
||||
const bool active_render = uv_name == render_name;
|
||||
|
@ -512,7 +512,8 @@ static void attr_create_subd_uv_map(Scene *scene,
|
|||
|
||||
if (!blender_uv_names.empty()) {
|
||||
const blender::bke::AttributeAccessor b_attributes = b_mesh.attributes();
|
||||
const ustring render_name(CustomData_get_render_layer_name(&b_mesh.loop_data, CD_PROP_FLOAT2));
|
||||
const ustring render_name(
|
||||
CustomData_get_render_layer_name(&b_mesh.corner_data, CD_PROP_FLOAT2));
|
||||
for (const ustring &uv_name : blender_uv_names) {
|
||||
const bool active_render = uv_name == render_name;
|
||||
AttributeStandard uv_std = (active_render) ? ATTR_STD_UV : ATTR_STD_NONE;
|
||||
|
|
|
@ -38,7 +38,8 @@ class PHYSICS_PT_geometry_nodes(Panel):
|
|||
calc_text = iface_("Calculate to Frame")
|
||||
bake_text = iface_("Bake")
|
||||
|
||||
layout.operator("object.simulation_nodes_cache_calculate_to_frame", text=calc_text, translate=False).selected = True
|
||||
layout.operator("object.simulation_nodes_cache_calculate_to_frame",
|
||||
text=calc_text, translate=False).selected = True
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("object.simulation_nodes_cache_bake", text=bake_text, translate=False).selected = True
|
||||
|
|
|
@ -16,7 +16,7 @@ struct BMEditMesh;
|
|||
* \see #BKE_mesh_calc_loop_tangent, same logic but used arrays instead of #BMesh data.
|
||||
*
|
||||
* \note This function is not so normal, its using #BMesh.ldata as input,
|
||||
* but output's to #Mesh.loop_data.
|
||||
* but output's to #Mesh.corner_data.
|
||||
* This is done because #CD_TANGENT is cache data used only for drawing.
|
||||
*/
|
||||
void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
|
||||
|
|
|
@ -505,9 +505,9 @@ bool BKE_mesh_validate_all_customdata(struct CustomData *vert_data,
|
|||
uint totvert,
|
||||
struct CustomData *edge_data,
|
||||
uint edges_num,
|
||||
struct CustomData *loop_data,
|
||||
struct CustomData *corner_data,
|
||||
uint corners_num,
|
||||
struct CustomData *pdata,
|
||||
struct CustomData *face_data,
|
||||
uint faces_num,
|
||||
bool check_meshmask,
|
||||
bool do_verbose,
|
||||
|
|
|
@ -807,9 +807,11 @@ static void mesh_calc_modifiers(Depsgraph *depsgraph,
|
|||
|
||||
/* add an origspace layer if needed */
|
||||
if ((md_datamask->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
|
||||
if (!CustomData_has_layer(&mesh_final->loop_data, CD_ORIGSPACE_MLOOP)) {
|
||||
CustomData_add_layer(
|
||||
&mesh_final->loop_data, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->corners_num);
|
||||
if (!CustomData_has_layer(&mesh_final->corner_data, CD_ORIGSPACE_MLOOP)) {
|
||||
CustomData_add_layer(&mesh_final->corner_data,
|
||||
CD_ORIGSPACE_MLOOP,
|
||||
CD_SET_DEFAULT,
|
||||
mesh_final->corners_num);
|
||||
mesh_init_origspace(mesh_final);
|
||||
}
|
||||
}
|
||||
|
@ -1204,9 +1206,11 @@ static void editbmesh_calc_modifiers(Depsgraph *depsgraph,
|
|||
mesh_set_only_copy(mesh_final, &mask);
|
||||
|
||||
if (mask.lmask & CD_MASK_ORIGSPACE_MLOOP) {
|
||||
if (!CustomData_has_layer(&mesh_final->loop_data, CD_ORIGSPACE_MLOOP)) {
|
||||
CustomData_add_layer(
|
||||
&mesh_final->loop_data, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->corners_num);
|
||||
if (!CustomData_has_layer(&mesh_final->corner_data, CD_ORIGSPACE_MLOOP)) {
|
||||
CustomData_add_layer(&mesh_final->corner_data,
|
||||
CD_ORIGSPACE_MLOOP,
|
||||
CD_SET_DEFAULT,
|
||||
mesh_final->corners_num);
|
||||
mesh_init_origspace(mesh_final);
|
||||
}
|
||||
}
|
||||
|
@ -1622,7 +1626,7 @@ static void mesh_init_origspace(Mesh *mesh)
|
|||
const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
|
||||
|
||||
OrigSpaceLoop *lof_array = (OrigSpaceLoop *)CustomData_get_layer_for_write(
|
||||
&mesh->loop_data, CD_ORIGSPACE_MLOOP, mesh->corners_num);
|
||||
&mesh->corner_data, CD_ORIGSPACE_MLOOP, mesh->corners_num);
|
||||
const Span<float3> positions = mesh->vert_positions();
|
||||
const blender::OffsetIndices faces = mesh->faces();
|
||||
const Span<int> corner_verts = mesh->corner_verts();
|
||||
|
|
|
@ -75,7 +75,7 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM])
|
|||
info[ATTR_DOMAIN_POINT].length = mesh->verts_num;
|
||||
info[ATTR_DOMAIN_EDGE].customdata = &mesh->edge_data;
|
||||
info[ATTR_DOMAIN_EDGE].length = mesh->edges_num;
|
||||
info[ATTR_DOMAIN_CORNER].customdata = &mesh->loop_data;
|
||||
info[ATTR_DOMAIN_CORNER].customdata = &mesh->corner_data;
|
||||
info[ATTR_DOMAIN_CORNER].length = mesh->corners_num;
|
||||
info[ATTR_DOMAIN_FACE].customdata = &mesh->face_data;
|
||||
info[ATTR_DOMAIN_FACE].length = mesh->faces_num;
|
||||
|
|
|
@ -520,8 +520,8 @@ static Mesh *try_load_mesh(const DictionaryValue &io_geometry,
|
|||
Mesh *mesh = BKE_mesh_new_nomain(0, 0, 0, 0);
|
||||
CustomData_free_layer_named(&mesh->vert_data, "position", 0);
|
||||
CustomData_free_layer_named(&mesh->edge_data, ".edge_verts", 0);
|
||||
CustomData_free_layer_named(&mesh->loop_data, ".corner_vert", 0);
|
||||
CustomData_free_layer_named(&mesh->loop_data, ".corner_edge", 0);
|
||||
CustomData_free_layer_named(&mesh->corner_data, ".corner_vert", 0);
|
||||
CustomData_free_layer_named(&mesh->corner_data, ".corner_edge", 0);
|
||||
mesh->verts_num = io_mesh->lookup_int("num_vertices").value_or(0);
|
||||
mesh->edges_num = io_mesh->lookup_int("num_edges").value_or(0);
|
||||
mesh->faces_num = io_mesh->lookup_int("num_polygons").value_or(0);
|
||||
|
|
|
@ -170,7 +170,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh, const CustomData_MeshMasks *ma
|
|||
&dm->faceData,
|
||||
cddata_masks.fmask | CD_MASK_ORIGINDEX,
|
||||
0 /* `mesh->totface` */);
|
||||
CustomData_merge(&mesh->loop_data, &dm->loopData, cddata_masks.lmask, mesh->corners_num);
|
||||
CustomData_merge(&mesh->corner_data, &dm->loopData, cddata_masks.lmask, mesh->corners_num);
|
||||
CustomData_merge(&mesh->face_data, &dm->polyData, cddata_masks.pmask, mesh->faces_num);
|
||||
|
||||
cddm->vert_positions = static_cast<float(*)[3]>(CustomData_get_layer_named_for_write(
|
||||
|
|
|
@ -363,7 +363,7 @@ static void data_transfer_dtdata_type_postprocess(Mesh *me_dst,
|
|||
return;
|
||||
}
|
||||
/* Bake edited destination loop normals into custom normals again. */
|
||||
CustomData *ldata_dst = &me_dst->loop_data;
|
||||
CustomData *ldata_dst = &me_dst->corner_data;
|
||||
|
||||
blender::float3 *loop_nors_dst = static_cast<blender::float3 *>(
|
||||
CustomData_get_layer_for_write(ldata_dst, CD_NORMAL, me_dst->corners_num));
|
||||
|
@ -1052,8 +1052,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
|
|||
cddata_type = CD_PROP_FLOAT2;
|
||||
}
|
||||
else if (cddata_type == CD_FAKE_LNOR) {
|
||||
if (!CustomData_get_layer(&me_dst->loop_data, CD_PROP_FLOAT)) {
|
||||
CustomData_add_layer(&me_dst->loop_data, CD_NORMAL, CD_SET_DEFAULT, me_dst->corners_num);
|
||||
if (!CustomData_get_layer(&me_dst->corner_data, CD_PROP_FLOAT)) {
|
||||
CustomData_add_layer(&me_dst->corner_data, CD_NORMAL, CD_SET_DEFAULT, me_dst->corners_num);
|
||||
}
|
||||
/* Post-process will convert it back to CD_CUSTOMLOOPNORMAL. */
|
||||
data_transfer_layersmapping_add_item_cd(
|
||||
|
@ -1063,15 +1063,15 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
|
|||
mix_factor,
|
||||
mix_weights,
|
||||
me_src->corner_normals().data(),
|
||||
CustomData_get_layer_for_write(&me_dst->loop_data, CD_NORMAL, me_dst->corners_num),
|
||||
CustomData_get_layer_for_write(&me_dst->corner_data, CD_NORMAL, me_dst->corners_num),
|
||||
customdata_data_transfer_interp_normal_normals,
|
||||
space_transform);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(cddata_type & CD_FAKE)) {
|
||||
cd_src = &me_src->loop_data;
|
||||
cd_dst = &me_dst->loop_data;
|
||||
cd_src = &me_src->corner_data;
|
||||
cd_dst = &me_dst->corner_data;
|
||||
|
||||
if (!data_transfer_layersmapping_cdlayers(r_map,
|
||||
eCustomDataType(cddata_type),
|
||||
|
|
|
@ -343,7 +343,8 @@ bool dynamicPaint_outputLayerExists(DynamicPaintSurface *surface, Object *ob, in
|
|||
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
|
||||
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
return (CustomData_get_named_layer_index(&mesh->loop_data, CD_PROP_BYTE_COLOR, name) != -1);
|
||||
return (CustomData_get_named_layer_index(&mesh->corner_data, CD_PROP_BYTE_COLOR, name) !=
|
||||
-1);
|
||||
}
|
||||
if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
|
||||
return (BKE_object_defgroup_name_index(ob, name) != -1);
|
||||
|
@ -1641,9 +1642,9 @@ static void dynamicPaint_setInitialColor(const Scene * /*scene*/, DynamicPaintSu
|
|||
|
||||
/* get uv map */
|
||||
CustomData_validate_layer_name(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, surface->init_layername, uvname);
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, surface->init_layername, uvname);
|
||||
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_named(&mesh->loop_data, CD_PROP_FLOAT2, uvname));
|
||||
CustomData_get_layer_named(&mesh->corner_data, CD_PROP_FLOAT2, uvname));
|
||||
|
||||
if (!mloopuv) {
|
||||
return;
|
||||
|
@ -1688,7 +1689,7 @@ static void dynamicPaint_setInitialColor(const Scene * /*scene*/, DynamicPaintSu
|
|||
if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
|
||||
const blender::Span<int> corner_verts = mesh->corner_verts();
|
||||
const MLoopCol *col = static_cast<const MLoopCol *>(CustomData_get_layer_named(
|
||||
&mesh->loop_data, CD_PROP_BYTE_COLOR, surface->init_layername));
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, surface->init_layername));
|
||||
if (!col) {
|
||||
return;
|
||||
}
|
||||
|
@ -1700,7 +1701,7 @@ static void dynamicPaint_setInitialColor(const Scene * /*scene*/, DynamicPaintSu
|
|||
else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
|
||||
const blender::Span<int3> corner_tris = mesh->corner_tris();
|
||||
const MLoopCol *col = static_cast<const MLoopCol *>(CustomData_get_layer_named(
|
||||
&mesh->loop_data, CD_PROP_BYTE_COLOR, surface->init_layername));
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, surface->init_layername));
|
||||
if (!col) {
|
||||
return;
|
||||
}
|
||||
|
@ -1963,13 +1964,13 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
|
|||
|
||||
/* paint layer */
|
||||
MLoopCol *mloopcol = static_cast<MLoopCol *>(
|
||||
CustomData_get_layer_named_for_write(&result->loop_data,
|
||||
CustomData_get_layer_named_for_write(&result->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
surface->output_name,
|
||||
result->corners_num));
|
||||
/* if output layer is lost from a constructive modifier, re-add it */
|
||||
if (!mloopcol && dynamicPaint_outputLayerExists(surface, ob, 0)) {
|
||||
mloopcol = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->loop_data,
|
||||
mloopcol = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
CD_SET_DEFAULT,
|
||||
corner_verts.size(),
|
||||
|
@ -1978,14 +1979,14 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
|
|||
|
||||
/* wet layer */
|
||||
MLoopCol *mloopcol_wet = static_cast<MLoopCol *>(
|
||||
CustomData_get_layer_named_for_write(&result->loop_data,
|
||||
CustomData_get_layer_named_for_write(&result->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
surface->output_name2,
|
||||
result->corners_num));
|
||||
/* if output layer is lost from a constructive modifier, re-add it */
|
||||
if (!mloopcol_wet && dynamicPaint_outputLayerExists(surface, ob, 1)) {
|
||||
mloopcol_wet = static_cast<MLoopCol *>(
|
||||
CustomData_add_layer_named(&result->loop_data,
|
||||
CustomData_add_layer_named(&result->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
CD_SET_DEFAULT,
|
||||
corner_verts.size(),
|
||||
|
@ -2853,11 +2854,11 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
const blender::Span<int3> corner_tris = mesh->corner_tris();
|
||||
|
||||
/* get uv map */
|
||||
if (CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2)) {
|
||||
if (CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2)) {
|
||||
CustomData_validate_layer_name(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, surface->uvlayer_name, uvname);
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, surface->uvlayer_name, uvname);
|
||||
mloopuv = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_named(&mesh->loop_data, CD_PROP_FLOAT2, uvname));
|
||||
CustomData_get_layer_named(&mesh->corner_data, CD_PROP_FLOAT2, uvname));
|
||||
}
|
||||
|
||||
/* Check for validity */
|
||||
|
|
|
@ -2087,7 +2087,7 @@ static void emit_from_mesh(
|
|||
const int numverts = mesh->verts_num;
|
||||
const MDeformVert *dvert = mesh->deform_verts().data();
|
||||
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_named(&mesh->loop_data, CD_PROP_FLOAT2, ffs->uvlayer_name));
|
||||
CustomData_get_layer_named(&mesh->corner_data, CD_PROP_FLOAT2, ffs->uvlayer_name));
|
||||
|
||||
if (ffs->flags & FLUID_FLOW_INITVELOCITY) {
|
||||
vert_vel = static_cast<float *>(
|
||||
|
|
|
@ -987,8 +987,8 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
|
|||
return mesh->NAME; \
|
||||
}
|
||||
|
||||
static CustomDataAccessInfo corner_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(loop_data),
|
||||
MAKE_CONST_CUSTOM_DATA_GETTER(loop_data),
|
||||
static CustomDataAccessInfo corner_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(corner_data),
|
||||
MAKE_CONST_CUSTOM_DATA_GETTER(corner_data),
|
||||
MAKE_GET_ELEMENT_NUM_GETTER(corners_num)};
|
||||
static CustomDataAccessInfo point_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(vert_data),
|
||||
MAKE_CONST_CUSTOM_DATA_GETTER(vert_data),
|
||||
|
|
|
@ -2276,7 +2276,7 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
|
|||
}
|
||||
if (loop_normals_needed) {
|
||||
const blender::short2 *clnors = static_cast<const blender::short2 *>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_CUSTOMLOOPNORMAL));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_CUSTOMLOOPNORMAL));
|
||||
const bke::AttributeAccessor attributes = mesh->attributes();
|
||||
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
|
||||
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
|
||||
|
|
|
@ -92,7 +92,7 @@ static void mesh_init_data(ID *id)
|
|||
CustomData_reset(&mesh->edge_data);
|
||||
CustomData_reset(&mesh->fdata_legacy);
|
||||
CustomData_reset(&mesh->face_data);
|
||||
CustomData_reset(&mesh->loop_data);
|
||||
CustomData_reset(&mesh->corner_data);
|
||||
|
||||
mesh->runtime = new blender::bke::MeshRuntime();
|
||||
|
||||
|
@ -167,7 +167,8 @@ static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
|
|||
|
||||
CustomData_copy(&mesh_src->vert_data, &mesh_dst->vert_data, mask.vmask, mesh_dst->verts_num);
|
||||
CustomData_copy(&mesh_src->edge_data, &mesh_dst->edge_data, mask.emask, mesh_dst->edges_num);
|
||||
CustomData_copy(&mesh_src->loop_data, &mesh_dst->loop_data, mask.lmask, mesh_dst->corners_num);
|
||||
CustomData_copy(
|
||||
&mesh_src->corner_data, &mesh_dst->corner_data, mask.lmask, mesh_dst->corners_num);
|
||||
CustomData_copy(&mesh_src->face_data, &mesh_dst->face_data, mask.pmask, mesh_dst->faces_num);
|
||||
blender::implicit_sharing::copy_shared_pointer(mesh_src->face_offset_indices,
|
||||
mesh_src->runtime->face_offsets_sharing_info,
|
||||
|
@ -237,10 +238,10 @@ static void mesh_foreach_id(ID *id, LibraryForeachIDData *data)
|
|||
static void mesh_foreach_path(ID *id, BPathForeachPathData *bpath_data)
|
||||
{
|
||||
Mesh *mesh = reinterpret_cast<Mesh *>(id);
|
||||
if (mesh->loop_data.external) {
|
||||
if (mesh->corner_data.external) {
|
||||
BKE_bpath_foreach_path_fixed_process(bpath_data,
|
||||
mesh->loop_data.external->filepath,
|
||||
sizeof(mesh->loop_data.external->filepath));
|
||||
mesh->corner_data.external->filepath,
|
||||
sizeof(mesh->corner_data.external->filepath));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,7 +271,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
|
|||
memset(&mesh->edge_data, 0, sizeof(mesh->edge_data));
|
||||
|
||||
mesh->corners_num = 0;
|
||||
memset(&mesh->loop_data, 0, sizeof(mesh->loop_data));
|
||||
memset(&mesh->corner_data, 0, sizeof(mesh->corner_data));
|
||||
|
||||
mesh->faces_num = 0;
|
||||
memset(&mesh->face_data, 0, sizeof(mesh->face_data));
|
||||
|
@ -279,7 +280,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
|
|||
else {
|
||||
CustomData_blend_write_prepare(mesh->vert_data, vert_layers, {});
|
||||
CustomData_blend_write_prepare(mesh->edge_data, edge_layers, {});
|
||||
CustomData_blend_write_prepare(mesh->loop_data, loop_layers, {});
|
||||
CustomData_blend_write_prepare(mesh->corner_data, loop_layers, {});
|
||||
CustomData_blend_write_prepare(mesh->face_data, face_layers, {});
|
||||
if (!is_undo) {
|
||||
mesh_sculpt_mask_to_legacy(vert_layers);
|
||||
|
@ -306,7 +307,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
|
|||
CustomData_blend_write(
|
||||
writer, &mesh->fdata_legacy, {}, mesh->totface_legacy, CD_MASK_MESH.fmask, &mesh->id);
|
||||
CustomData_blend_write(
|
||||
writer, &mesh->loop_data, loop_layers, mesh->corners_num, CD_MASK_MESH.lmask, &mesh->id);
|
||||
writer, &mesh->corner_data, loop_layers, mesh->corners_num, CD_MASK_MESH.lmask, &mesh->id);
|
||||
CustomData_blend_write(
|
||||
writer, &mesh->face_data, face_layers, mesh->faces_num, CD_MASK_MESH.pmask, &mesh->id);
|
||||
|
||||
|
@ -341,7 +342,7 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
CustomData_blend_read(reader, &mesh->vert_data, mesh->verts_num);
|
||||
CustomData_blend_read(reader, &mesh->edge_data, mesh->edges_num);
|
||||
CustomData_blend_read(reader, &mesh->fdata_legacy, mesh->totface_legacy);
|
||||
CustomData_blend_read(reader, &mesh->loop_data, mesh->corners_num);
|
||||
CustomData_blend_read(reader, &mesh->corner_data, mesh->corners_num);
|
||||
CustomData_blend_read(reader, &mesh->face_data, mesh->faces_num);
|
||||
if (mesh->deform_verts().is_empty()) {
|
||||
/* Vertex group data was also an owning pointer in old Blender versions.
|
||||
|
@ -447,7 +448,7 @@ bool BKE_mesh_has_custom_loop_normals(Mesh *mesh)
|
|||
return CustomData_has_layer(&mesh->edit_mesh->bm->ldata, CD_CUSTOMLOOPNORMAL);
|
||||
}
|
||||
|
||||
return CustomData_has_layer(&mesh->loop_data, CD_CUSTOMLOOPNORMAL);
|
||||
return CustomData_has_layer(&mesh->corner_data, CD_CUSTOMLOOPNORMAL);
|
||||
}
|
||||
|
||||
void BKE_mesh_free_data_for_undo(Mesh *mesh)
|
||||
|
@ -472,7 +473,7 @@ static void mesh_clear_geometry(Mesh &mesh)
|
|||
CustomData_free(&mesh.vert_data, mesh.verts_num);
|
||||
CustomData_free(&mesh.edge_data, mesh.edges_num);
|
||||
CustomData_free(&mesh.fdata_legacy, mesh.totface_legacy);
|
||||
CustomData_free(&mesh.loop_data, mesh.corners_num);
|
||||
CustomData_free(&mesh.corner_data, mesh.corners_num);
|
||||
CustomData_free(&mesh.face_data, mesh.faces_num);
|
||||
if (mesh.face_offset_indices) {
|
||||
blender::implicit_sharing::free_shared_data(&mesh.face_offset_indices,
|
||||
|
@ -597,26 +598,26 @@ MutableSpan<int> Mesh::face_offsets_for_write()
|
|||
Span<int> Mesh::corner_verts() const
|
||||
{
|
||||
return {static_cast<const int *>(
|
||||
CustomData_get_layer_named(&this->loop_data, CD_PROP_INT32, ".corner_vert")),
|
||||
CustomData_get_layer_named(&this->corner_data, CD_PROP_INT32, ".corner_vert")),
|
||||
this->corners_num};
|
||||
}
|
||||
MutableSpan<int> Mesh::corner_verts_for_write()
|
||||
{
|
||||
return {static_cast<int *>(CustomData_get_layer_named_for_write(
|
||||
&this->loop_data, CD_PROP_INT32, ".corner_vert", this->corners_num)),
|
||||
&this->corner_data, CD_PROP_INT32, ".corner_vert", this->corners_num)),
|
||||
this->corners_num};
|
||||
}
|
||||
|
||||
Span<int> Mesh::corner_edges() const
|
||||
{
|
||||
return {static_cast<const int *>(
|
||||
CustomData_get_layer_named(&this->loop_data, CD_PROP_INT32, ".corner_edge")),
|
||||
CustomData_get_layer_named(&this->corner_data, CD_PROP_INT32, ".corner_edge")),
|
||||
this->corners_num};
|
||||
}
|
||||
MutableSpan<int> Mesh::corner_edges_for_write()
|
||||
{
|
||||
return {static_cast<int *>(CustomData_get_layer_named_for_write(
|
||||
&this->loop_data, CD_PROP_INT32, ".corner_edge", this->corners_num)),
|
||||
&this->corner_data, CD_PROP_INT32, ".corner_edge", this->corners_num)),
|
||||
this->corners_num};
|
||||
}
|
||||
|
||||
|
@ -758,7 +759,7 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
|
|||
CustomData_copy_layout(
|
||||
&me_src->face_data, &me_dst->face_data, mask.pmask, CD_SET_DEFAULT, faces_num);
|
||||
CustomData_copy_layout(
|
||||
&me_src->loop_data, &me_dst->loop_data, mask.lmask, CD_SET_DEFAULT, loops_num);
|
||||
&me_src->corner_data, &me_dst->corner_data, mask.lmask, CD_SET_DEFAULT, loops_num);
|
||||
if (do_tessface) {
|
||||
CustomData_copy_layout(
|
||||
&me_src->fdata_legacy, &me_dst->fdata_legacy, mask.fmask, CD_SET_DEFAULT, tessface_num);
|
||||
|
|
|
@ -592,13 +592,13 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh,
|
|||
src_blocks_ofs = Array<const void *>(orig_face.size());
|
||||
get_poly2d_cos(orig_me, orig_face, cos_2d, mim.to_target_transform[orig_me_index], axis_mat);
|
||||
}
|
||||
CustomData *target_cd = &dest_mesh->loop_data;
|
||||
CustomData *target_cd = &dest_mesh->corner_data;
|
||||
const Span<float3> dst_positions = dest_mesh->vert_positions();
|
||||
const Span<int> dst_corner_verts = dest_mesh->corner_verts();
|
||||
for (int i = 0; i < face.size(); ++i) {
|
||||
int loop_index = face[i];
|
||||
int orig_loop_index = norig > 0 ? orig_loops[i] : -1;
|
||||
const CustomData *source_cd = &orig_me->loop_data;
|
||||
const CustomData *source_cd = &orig_me->corner_data;
|
||||
if (orig_loop_index == -1) {
|
||||
/* Will need interpolation weights for this loop's vertex's coordinates.
|
||||
* The coordinate needs to be projected into 2d, just like the interpolating face's
|
||||
|
@ -671,8 +671,8 @@ static void merge_vertex_loop_face_customdata_layers(Mesh *target, MeshesToIMesh
|
|||
target->verts_num);
|
||||
}
|
||||
if (mesh->corners_num) {
|
||||
CustomData_merge_layout(&mesh->loop_data,
|
||||
&target->loop_data,
|
||||
CustomData_merge_layout(&mesh->corner_data,
|
||||
&target->corner_data,
|
||||
CD_MASK_MESH.lmask,
|
||||
CD_SET_DEFAULT,
|
||||
target->corners_num);
|
||||
|
|
|
@ -1074,7 +1074,8 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
|
|||
CustomData_copy(&mesh_src->vert_data, &mesh_dst->vert_data, mask.vmask, mesh_src->verts_num);
|
||||
CustomData_copy(&mesh_src->edge_data, &mesh_dst->edge_data, mask.emask, mesh_src->edges_num);
|
||||
CustomData_copy(&mesh_src->face_data, &mesh_dst->face_data, mask.pmask, mesh_src->faces_num);
|
||||
CustomData_copy(&mesh_src->loop_data, &mesh_dst->loop_data, mask.lmask, mesh_src->corners_num);
|
||||
CustomData_copy(
|
||||
&mesh_src->corner_data, &mesh_dst->corner_data, mask.lmask, mesh_src->corners_num);
|
||||
std::swap(mesh_dst->face_offset_indices, mesh_src->face_offset_indices);
|
||||
std::swap(mesh_dst->runtime->face_offsets_sharing_info,
|
||||
mesh_src->runtime->face_offsets_sharing_info);
|
||||
|
|
|
@ -55,7 +55,7 @@ char *BKE_mesh_debug_info(const Mesh *mesh)
|
|||
BLI_dynstr_append(dynstr, " ),\n");
|
||||
|
||||
BLI_dynstr_append(dynstr, " 'loop_layers': (\n");
|
||||
CustomData_debug_info_from_layers(&mesh->loop_data, indent8, dynstr);
|
||||
CustomData_debug_info_from_layers(&mesh->corner_data, indent8, dynstr);
|
||||
BLI_dynstr_append(dynstr, " ),\n");
|
||||
|
||||
BLI_dynstr_append(dynstr, " 'poly_layers': (\n");
|
||||
|
|
|
@ -24,14 +24,14 @@ static void flip_corner_data(const OffsetIndices<int> faces,
|
|||
|
||||
template<typename T>
|
||||
static void flip_custom_data_type(const OffsetIndices<int> faces,
|
||||
CustomData &loop_data,
|
||||
CustomData &corner_data,
|
||||
const IndexMask &face_selection,
|
||||
const eCustomDataType data_type)
|
||||
{
|
||||
BLI_assert(sizeof(T) == CustomData_sizeof(data_type));
|
||||
for (const int i : IndexRange(CustomData_number_of_layers(&loop_data, data_type))) {
|
||||
for (const int i : IndexRange(CustomData_number_of_layers(&corner_data, data_type))) {
|
||||
T *data = static_cast<T *>(
|
||||
CustomData_get_layer_n_for_write(&loop_data, data_type, i, faces.total_size()));
|
||||
CustomData_get_layer_n_for_write(&corner_data, data_type, i, faces.total_size()));
|
||||
flip_corner_data(faces, face_selection, MutableSpan(data, faces.total_size()));
|
||||
}
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ void mesh_flip_faces(Mesh &mesh, const IndexMask &selection)
|
|||
}
|
||||
});
|
||||
|
||||
flip_custom_data_type<float4x4>(faces, mesh.loop_data, selection, CD_TANGENT);
|
||||
flip_custom_data_type<float4>(faces, mesh.loop_data, selection, CD_MLOOPTANGENT);
|
||||
flip_custom_data_type<short2>(faces, mesh.loop_data, selection, CD_CUSTOMLOOPNORMAL);
|
||||
flip_custom_data_type<GridPaintMask>(faces, mesh.loop_data, selection, CD_GRID_PAINT_MASK);
|
||||
flip_custom_data_type<OrigSpaceLoop>(faces, mesh.loop_data, selection, CD_ORIGSPACE_MLOOP);
|
||||
flip_custom_data_type<MDisps>(faces, mesh.loop_data, selection, CD_MDISPS);
|
||||
flip_custom_data_type<float4x4>(faces, mesh.corner_data, selection, CD_TANGENT);
|
||||
flip_custom_data_type<float4>(faces, mesh.corner_data, selection, CD_MLOOPTANGENT);
|
||||
flip_custom_data_type<short2>(faces, mesh.corner_data, selection, CD_CUSTOMLOOPNORMAL);
|
||||
flip_custom_data_type<GridPaintMask>(faces, mesh.corner_data, selection, CD_GRID_PAINT_MASK);
|
||||
flip_custom_data_type<OrigSpaceLoop>(faces, mesh.corner_data, selection, CD_ORIGSPACE_MLOOP);
|
||||
flip_custom_data_type<MDisps>(faces, mesh.corner_data, selection, CD_MDISPS);
|
||||
if (MDisps *mdisp = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh.loop_data, CD_MDISPS, mesh.corners_num)))
|
||||
CustomData_get_layer_for_write(&mesh.corner_data, CD_MDISPS, mesh.corners_num)))
|
||||
{
|
||||
selection.foreach_index(GrainSize(512), [&](const int i) {
|
||||
for (const int corner : faces[i]) {
|
||||
|
|
|
@ -227,7 +227,7 @@ void BKE_mesh_calc_edges_legacy(Mesh *mesh)
|
|||
verts.data(),
|
||||
mesh->mface,
|
||||
static_cast<MLoop *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MLOOP, mesh->corners_num)),
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MLOOP, mesh->corners_num)),
|
||||
static_cast<const MPoly *>(CustomData_get_layer(&mesh->face_data, CD_MPOLY)),
|
||||
verts.size(),
|
||||
mesh->totface_legacy,
|
||||
|
@ -696,8 +696,9 @@ static void mesh_ensure_tessellation_customdata(Mesh *mesh)
|
|||
* Callers could also check but safer to do here - campbell */
|
||||
}
|
||||
else {
|
||||
const int tottex_original = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const int totcol_original = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_BYTE_COLOR);
|
||||
const int tottex_original = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
const int totcol_original = CustomData_number_of_layers(&mesh->corner_data,
|
||||
CD_PROP_BYTE_COLOR);
|
||||
|
||||
const int tottex_tessface = CustomData_number_of_layers(&mesh->fdata_legacy, CD_MTFACE);
|
||||
const int totcol_tessface = CustomData_number_of_layers(&mesh->fdata_legacy, CD_MCOL);
|
||||
|
@ -705,7 +706,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *mesh)
|
|||
if (tottex_tessface != tottex_original || totcol_tessface != totcol_original) {
|
||||
BKE_mesh_tessface_clear(mesh);
|
||||
|
||||
add_mface_layers(*mesh, &mesh->fdata_legacy, &mesh->loop_data, mesh->totface_legacy);
|
||||
add_mface_layers(*mesh, &mesh->fdata_legacy, &mesh->corner_data, mesh->totface_legacy);
|
||||
|
||||
/* TODO: add some `--debug-mesh` option. */
|
||||
if (G.debug & G_DEBUG) {
|
||||
|
@ -732,7 +733,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
|
|||
{
|
||||
convert_mfaces_to_mpolys(&mesh->id,
|
||||
&mesh->fdata_legacy,
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
&mesh->face_data,
|
||||
mesh->edges_num,
|
||||
mesh->totface_legacy,
|
||||
|
@ -755,36 +756,36 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
|
|||
* meshes and needed to preserve active/render/clone/stencil flags set in pre-bmesh files.
|
||||
*/
|
||||
static void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata_legacy,
|
||||
CustomData *loop_data)
|
||||
CustomData *corner_data)
|
||||
{
|
||||
int act;
|
||||
|
||||
if (CustomData_has_layer(fdata_legacy, CD_MTFACE)) {
|
||||
act = CustomData_get_active_layer(fdata_legacy, CD_MTFACE);
|
||||
CustomData_set_layer_active(loop_data, CD_PROP_FLOAT2, act);
|
||||
CustomData_set_layer_active(corner_data, CD_PROP_FLOAT2, act);
|
||||
|
||||
act = CustomData_get_render_layer(fdata_legacy, CD_MTFACE);
|
||||
CustomData_set_layer_render(loop_data, CD_PROP_FLOAT2, act);
|
||||
CustomData_set_layer_render(corner_data, CD_PROP_FLOAT2, act);
|
||||
|
||||
act = CustomData_get_clone_layer(fdata_legacy, CD_MTFACE);
|
||||
CustomData_set_layer_clone(loop_data, CD_PROP_FLOAT2, act);
|
||||
CustomData_set_layer_clone(corner_data, CD_PROP_FLOAT2, act);
|
||||
|
||||
act = CustomData_get_stencil_layer(fdata_legacy, CD_MTFACE);
|
||||
CustomData_set_layer_stencil(loop_data, CD_PROP_FLOAT2, act);
|
||||
CustomData_set_layer_stencil(corner_data, CD_PROP_FLOAT2, act);
|
||||
}
|
||||
|
||||
if (CustomData_has_layer(fdata_legacy, CD_MCOL)) {
|
||||
act = CustomData_get_active_layer(fdata_legacy, CD_MCOL);
|
||||
CustomData_set_layer_active(loop_data, CD_PROP_BYTE_COLOR, act);
|
||||
CustomData_set_layer_active(corner_data, CD_PROP_BYTE_COLOR, act);
|
||||
|
||||
act = CustomData_get_render_layer(fdata_legacy, CD_MCOL);
|
||||
CustomData_set_layer_render(loop_data, CD_PROP_BYTE_COLOR, act);
|
||||
CustomData_set_layer_render(corner_data, CD_PROP_BYTE_COLOR, act);
|
||||
|
||||
act = CustomData_get_clone_layer(fdata_legacy, CD_MCOL);
|
||||
CustomData_set_layer_clone(loop_data, CD_PROP_BYTE_COLOR, act);
|
||||
CustomData_set_layer_clone(corner_data, CD_PROP_BYTE_COLOR, act);
|
||||
|
||||
act = CustomData_get_stencil_layer(fdata_legacy, CD_MCOL);
|
||||
CustomData_set_layer_stencil(loop_data, CD_PROP_BYTE_COLOR, act);
|
||||
CustomData_set_layer_stencil(corner_data, CD_PROP_BYTE_COLOR, act);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,7 +793,7 @@ void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
|
|||
{
|
||||
convert_mfaces_to_mpolys(&mesh->id,
|
||||
&mesh->fdata_legacy,
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
&mesh->face_data,
|
||||
mesh->edges_num,
|
||||
mesh->totface_legacy,
|
||||
|
@ -805,7 +806,7 @@ void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
|
|||
BKE_mesh_legacy_convert_loops_to_corners(mesh);
|
||||
BKE_mesh_legacy_convert_polys_to_offsets(mesh);
|
||||
|
||||
CustomData_bmesh_do_versions_update_active_layers(&mesh->fdata_legacy, &mesh->loop_data);
|
||||
CustomData_bmesh_do_versions_update_active_layers(&mesh->fdata_legacy, &mesh->corner_data);
|
||||
|
||||
mesh_ensure_tessellation_customdata(mesh);
|
||||
}
|
||||
|
@ -839,7 +840,7 @@ void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
|
|||
* is used to test quads, else, loopindices[face_index][3] is used.
|
||||
*/
|
||||
static void mesh_loops_to_tessdata(CustomData *fdata_legacy,
|
||||
CustomData *loop_data,
|
||||
CustomData *corner_data,
|
||||
MFace *mface,
|
||||
const int *polyindices,
|
||||
uint (*loopindices)[4],
|
||||
|
@ -849,11 +850,11 @@ static void mesh_loops_to_tessdata(CustomData *fdata_legacy,
|
|||
* we could be ~25% quicker with dedicated code.
|
||||
* The issue is, unless having two different functions with nearly the same code,
|
||||
* there's not much ways to solve this. Better IMHO to live with it for now (sigh). */
|
||||
const int numUV = CustomData_number_of_layers(loop_data, CD_PROP_FLOAT2);
|
||||
const int numCol = CustomData_number_of_layers(loop_data, CD_PROP_BYTE_COLOR);
|
||||
const bool hasOrigSpace = CustomData_has_layer(loop_data, CD_ORIGSPACE_MLOOP);
|
||||
const bool hasLoopNormal = CustomData_has_layer(loop_data, CD_NORMAL);
|
||||
const bool hasLoopTangent = CustomData_has_layer(loop_data, CD_TANGENT);
|
||||
const int numUV = CustomData_number_of_layers(corner_data, CD_PROP_FLOAT2);
|
||||
const int numCol = CustomData_number_of_layers(corner_data, CD_PROP_BYTE_COLOR);
|
||||
const bool hasOrigSpace = CustomData_has_layer(corner_data, CD_ORIGSPACE_MLOOP);
|
||||
const bool hasLoopNormal = CustomData_has_layer(corner_data, CD_NORMAL);
|
||||
const bool hasLoopTangent = CustomData_has_layer(corner_data, CD_TANGENT);
|
||||
int findex, i, j;
|
||||
const int *pidx;
|
||||
uint(*lidx)[4];
|
||||
|
@ -862,7 +863,7 @@ static void mesh_loops_to_tessdata(CustomData *fdata_legacy,
|
|||
MTFace *texface = (MTFace *)CustomData_get_layer_n_for_write(
|
||||
fdata_legacy, CD_MTFACE, i, num_faces);
|
||||
const blender::float2 *uv = static_cast<const blender::float2 *>(
|
||||
CustomData_get_layer_n(loop_data, CD_PROP_FLOAT2, i));
|
||||
CustomData_get_layer_n(corner_data, CD_PROP_FLOAT2, i));
|
||||
|
||||
for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces;
|
||||
pidx++, lidx++, findex++, texface++)
|
||||
|
@ -877,7 +878,7 @@ static void mesh_loops_to_tessdata(CustomData *fdata_legacy,
|
|||
MCol(*mcol)[4] = (MCol(*)[4])CustomData_get_layer_n_for_write(
|
||||
fdata_legacy, CD_MCOL, i, num_faces);
|
||||
const MLoopCol *mloopcol = (const MLoopCol *)CustomData_get_layer_n(
|
||||
loop_data, CD_PROP_BYTE_COLOR, i);
|
||||
corner_data, CD_PROP_BYTE_COLOR, i);
|
||||
|
||||
for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, mcol++) {
|
||||
for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
|
||||
|
@ -888,7 +889,7 @@ static void mesh_loops_to_tessdata(CustomData *fdata_legacy,
|
|||
|
||||
if (hasOrigSpace) {
|
||||
OrigSpaceFace *of = (OrigSpaceFace *)CustomData_get_layer(fdata_legacy, CD_ORIGSPACE);
|
||||
const OrigSpaceLoop *lof = (const OrigSpaceLoop *)CustomData_get_layer(loop_data,
|
||||
const OrigSpaceLoop *lof = (const OrigSpaceLoop *)CustomData_get_layer(corner_data,
|
||||
CD_ORIGSPACE_MLOOP);
|
||||
|
||||
for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, of++) {
|
||||
|
@ -901,7 +902,8 @@ static void mesh_loops_to_tessdata(CustomData *fdata_legacy,
|
|||
if (hasLoopNormal) {
|
||||
short(*face_normals)[4][3] = (short(*)[4][3])CustomData_get_layer(fdata_legacy,
|
||||
CD_TESSLOOPNORMAL);
|
||||
const float(*loop_normals)[3] = (const float(*)[3])CustomData_get_layer(loop_data, CD_NORMAL);
|
||||
const float(*loop_normals)[3] = (const float(*)[3])CustomData_get_layer(corner_data,
|
||||
CD_NORMAL);
|
||||
|
||||
for (findex = 0, lidx = loopindices; findex < num_faces; lidx++, findex++, face_normals++) {
|
||||
for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
|
||||
|
@ -913,7 +915,7 @@ static void mesh_loops_to_tessdata(CustomData *fdata_legacy,
|
|||
if (hasLoopTangent) {
|
||||
/* Need to do for all UV maps at some point. */
|
||||
float(*ftangents)[4] = (float(*)[4])CustomData_get_layer(fdata_legacy, CD_TANGENT);
|
||||
const float(*ltangents)[4] = (const float(*)[4])CustomData_get_layer(loop_data, CD_TANGENT);
|
||||
const float(*ltangents)[4] = (const float(*)[4])CustomData_get_layer(corner_data, CD_TANGENT);
|
||||
|
||||
for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces;
|
||||
pidx++, lidx++, findex++)
|
||||
|
@ -1245,7 +1247,7 @@ void BKE_mesh_tessface_calc(Mesh *mesh)
|
|||
mesh->totface_legacy = mesh_tessface_calc(
|
||||
*mesh,
|
||||
&mesh->fdata_legacy,
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
&mesh->face_data,
|
||||
reinterpret_cast<float(*)[3]>(mesh->vert_positions_for_write().data()),
|
||||
mesh->totface_legacy,
|
||||
|
@ -1692,25 +1694,25 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
|
|||
{
|
||||
using namespace blender;
|
||||
using namespace blender::bke;
|
||||
if (!CustomData_has_layer(&mesh->loop_data, CD_MLOOPUV)) {
|
||||
if (!CustomData_has_layer(&mesh->corner_data, CD_MLOOPUV)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Store layer names since they will be removed, used to set the active status of new layers.
|
||||
* Use intermediate #StringRef because the names can be null. */
|
||||
|
||||
Array<std::string> uv_names(CustomData_number_of_layers(&mesh->loop_data, CD_MLOOPUV));
|
||||
Array<std::string> uv_names(CustomData_number_of_layers(&mesh->corner_data, CD_MLOOPUV));
|
||||
for (const int i : uv_names.index_range()) {
|
||||
uv_names[i] = CustomData_get_layer_name(&mesh->loop_data, CD_MLOOPUV, i);
|
||||
uv_names[i] = CustomData_get_layer_name(&mesh->corner_data, CD_MLOOPUV, i);
|
||||
}
|
||||
const int active_name_i = uv_names.as_span().first_index_try(
|
||||
StringRef(CustomData_get_active_layer_name(&mesh->loop_data, CD_MLOOPUV)));
|
||||
StringRef(CustomData_get_active_layer_name(&mesh->corner_data, CD_MLOOPUV)));
|
||||
const int default_name_i = uv_names.as_span().first_index_try(
|
||||
StringRef(CustomData_get_render_layer_name(&mesh->loop_data, CD_MLOOPUV)));
|
||||
StringRef(CustomData_get_render_layer_name(&mesh->corner_data, CD_MLOOPUV)));
|
||||
|
||||
for (const int i : uv_names.index_range()) {
|
||||
const MLoopUV *mloopuv = static_cast<const MLoopUV *>(
|
||||
CustomData_get_layer_named(&mesh->loop_data, CD_MLOOPUV, uv_names[i].c_str()));
|
||||
CustomData_get_layer_named(&mesh->corner_data, CD_MLOOPUV, uv_names[i].c_str()));
|
||||
const uint32_t needed_boolean_attributes = threading::parallel_reduce(
|
||||
IndexRange(mesh->corners_num),
|
||||
4096,
|
||||
|
@ -1761,17 +1763,17 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
|
|||
}
|
||||
});
|
||||
|
||||
CustomData_free_layer_named(&mesh->loop_data, uv_names[i].c_str(), mesh->corners_num);
|
||||
CustomData_free_layer_named(&mesh->corner_data, uv_names[i].c_str(), mesh->corners_num);
|
||||
|
||||
char new_name[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
BKE_id_attribute_calc_unique_name(&mesh->id, uv_names[i].c_str(), new_name);
|
||||
uv_names[i] = new_name;
|
||||
|
||||
CustomData_add_layer_named_with_data(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, coords, mesh->corners_num, new_name, nullptr);
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, coords, mesh->corners_num, new_name, nullptr);
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
if (vert_selection) {
|
||||
CustomData_add_layer_named_with_data(&mesh->loop_data,
|
||||
CustomData_add_layer_named_with_data(&mesh->corner_data,
|
||||
CD_PROP_BOOL,
|
||||
vert_selection,
|
||||
mesh->corners_num,
|
||||
|
@ -1779,7 +1781,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
|
|||
nullptr);
|
||||
}
|
||||
if (edge_selection) {
|
||||
CustomData_add_layer_named_with_data(&mesh->loop_data,
|
||||
CustomData_add_layer_named_with_data(&mesh->corner_data,
|
||||
CD_PROP_BOOL,
|
||||
edge_selection,
|
||||
mesh->corners_num,
|
||||
|
@ -1787,7 +1789,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
|
|||
nullptr);
|
||||
}
|
||||
if (pin) {
|
||||
CustomData_add_layer_named_with_data(&mesh->loop_data,
|
||||
CustomData_add_layer_named_with_data(&mesh->corner_data,
|
||||
CD_PROP_BOOL,
|
||||
pin,
|
||||
mesh->corners_num,
|
||||
|
@ -1798,17 +1800,17 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
|
|||
|
||||
if (active_name_i != -1) {
|
||||
CustomData_set_layer_active_index(
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
CD_PROP_FLOAT2,
|
||||
CustomData_get_named_layer_index(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, uv_names[active_name_i].c_str()));
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, uv_names[active_name_i].c_str()));
|
||||
}
|
||||
if (default_name_i != -1) {
|
||||
CustomData_set_layer_render_index(
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
CD_PROP_FLOAT2,
|
||||
CustomData_get_named_layer_index(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, uv_names[default_name_i].c_str()));
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, uv_names[default_name_i].c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1999,14 +2001,14 @@ void BKE_mesh_legacy_attribute_flags_to_strings(Mesh *mesh)
|
|||
};
|
||||
|
||||
active_from_flags(mesh->vert_data);
|
||||
active_from_flags(mesh->loop_data);
|
||||
active_from_flags(mesh->corner_data);
|
||||
active_from_indices(mesh->vert_data);
|
||||
active_from_indices(mesh->loop_data);
|
||||
active_from_indices(mesh->corner_data);
|
||||
|
||||
default_from_flags(mesh->vert_data);
|
||||
default_from_flags(mesh->loop_data);
|
||||
default_from_flags(mesh->corner_data);
|
||||
default_from_indices(mesh->vert_data);
|
||||
default_from_indices(mesh->loop_data);
|
||||
default_from_indices(mesh->corner_data);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -2018,21 +2020,21 @@ void BKE_mesh_legacy_attribute_flags_to_strings(Mesh *mesh)
|
|||
void BKE_mesh_legacy_convert_loops_to_corners(Mesh *mesh)
|
||||
{
|
||||
using namespace blender;
|
||||
if (CustomData_has_layer_named(&mesh->loop_data, CD_PROP_INT32, ".corner_vert") &&
|
||||
CustomData_has_layer_named(&mesh->loop_data, CD_PROP_INT32, ".corner_edge"))
|
||||
if (CustomData_has_layer_named(&mesh->corner_data, CD_PROP_INT32, ".corner_vert") &&
|
||||
CustomData_has_layer_named(&mesh->corner_data, CD_PROP_INT32, ".corner_edge"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
const Span<MLoop> loops(
|
||||
static_cast<const MLoop *>(CustomData_get_layer(&mesh->loop_data, CD_MLOOP)),
|
||||
static_cast<const MLoop *>(CustomData_get_layer(&mesh->corner_data, CD_MLOOP)),
|
||||
mesh->corners_num);
|
||||
MutableSpan<int> corner_verts(
|
||||
static_cast<int *>(CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->corners_num, ".corner_vert")),
|
||||
&mesh->corner_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->corners_num, ".corner_vert")),
|
||||
mesh->corners_num);
|
||||
MutableSpan<int> corner_edges(
|
||||
static_cast<int *>(CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->corners_num, ".corner_edge")),
|
||||
&mesh->corner_data, CD_PROP_INT32, CD_CONSTRUCT, mesh->corners_num, ".corner_edge")),
|
||||
mesh->corners_num);
|
||||
threading::parallel_for(loops.index_range(), 2048, [&](IndexRange range) {
|
||||
for (const int i : range) {
|
||||
|
@ -2041,7 +2043,7 @@ void BKE_mesh_legacy_convert_loops_to_corners(Mesh *mesh)
|
|||
}
|
||||
});
|
||||
|
||||
CustomData_free_layers(&mesh->loop_data, CD_MLOOP, mesh->corners_num);
|
||||
CustomData_free_layers(&mesh->corner_data, CD_MLOOP, mesh->corners_num);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -2245,7 +2247,7 @@ void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain)
|
|||
if (!(mesh->flag & ME_AUTOSMOOTH_LEGACY)) {
|
||||
continue;
|
||||
}
|
||||
if (CustomData_has_layer(&mesh->loop_data, CD_CUSTOMLOOPNORMAL)) {
|
||||
if (CustomData_has_layer(&mesh->corner_data, CD_CUSTOMLOOPNORMAL)) {
|
||||
continue;
|
||||
}
|
||||
if (!auto_smooth_node_tree) {
|
||||
|
|
|
@ -109,7 +109,7 @@ void BKE_mesh_merge_customdata_for_apply_modifier(Mesh *mesh)
|
|||
if (mesh->corners_num == 0) {
|
||||
return;
|
||||
}
|
||||
const int mloopuv_layers_num = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const int mloopuv_layers_num = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
if (mloopuv_layers_num == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ void BKE_mesh_merge_customdata_for_apply_modifier(Mesh *mesh)
|
|||
Vector<float2 *> mloopuv_layers;
|
||||
mloopuv_layers.reserve(mloopuv_layers_num);
|
||||
for (int a = 0; a < mloopuv_layers_num; a++) {
|
||||
float2 *mloopuv = static_cast<float2 *>(
|
||||
CustomData_get_layer_n_for_write(&mesh->loop_data, CD_PROP_FLOAT2, a, mesh->corners_num));
|
||||
float2 *mloopuv = static_cast<float2 *>(CustomData_get_layer_n_for_write(
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, a, mesh->corners_num));
|
||||
mloopuv_layers.append_unchecked(mloopuv);
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
|
|||
CustomData_copy_data(&mesh->vert_data, &result->vert_data, 0, 0, src_verts_num);
|
||||
CustomData_copy_data(&mesh->edge_data, &result->edge_data, 0, 0, src_edges_num);
|
||||
CustomData_copy_data(&mesh->face_data, &result->face_data, 0, 0, src_faces.size());
|
||||
CustomData_copy_data(&mesh->loop_data, &result->loop_data, 0, 0, src_loops_num);
|
||||
CustomData_copy_data(&mesh->corner_data, &result->corner_data, 0, 0, src_loops_num);
|
||||
|
||||
/* Copy custom data to mirrored geometry. Loops are copied later. */
|
||||
CustomData_copy_data(&mesh->vert_data, &result->vert_data, 0, src_verts_num, src_verts_num);
|
||||
|
@ -317,11 +317,11 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
|
|||
/* reverse the loop, but we keep the first vertex in the face the same,
|
||||
* to ensure that quads are split the same way as on the other side */
|
||||
CustomData_copy_data(
|
||||
&mesh->loop_data, &result->loop_data, src_face.start(), mirror_face.start(), 1);
|
||||
&mesh->corner_data, &result->corner_data, src_face.start(), mirror_face.start(), 1);
|
||||
|
||||
for (int j = 1; j < mirror_face.size(); j++) {
|
||||
CustomData_copy_data(
|
||||
&mesh->loop_data, &result->loop_data, src_face[j], mirror_face.last(j - 1), 1);
|
||||
&mesh->corner_data, &result->corner_data, src_face[j], mirror_face.last(j - 1), 1);
|
||||
}
|
||||
|
||||
blender::MutableSpan<int> mirror_face_edges = result_corner_edges.slice(mirror_face);
|
||||
|
@ -358,11 +358,11 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
|
|||
/* If set, flip around center of each tile. */
|
||||
const bool do_mirr_udim = (mmd->flag & MOD_MIR_MIRROR_UDIM) != 0;
|
||||
|
||||
const int totuv = CustomData_number_of_layers(&result->loop_data, CD_PROP_FLOAT2);
|
||||
const int totuv = CustomData_number_of_layers(&result->corner_data, CD_PROP_FLOAT2);
|
||||
|
||||
for (a = 0; a < totuv; a++) {
|
||||
float(*dmloopuv)[2] = static_cast<float(*)[2]>(CustomData_get_layer_n_for_write(
|
||||
&result->loop_data, CD_PROP_FLOAT2, a, result->corners_num));
|
||||
&result->corner_data, CD_PROP_FLOAT2, a, result->corners_num));
|
||||
int j = src_loops_num;
|
||||
dmloopuv += j; /* second set of loops only */
|
||||
for (; j-- > 0; dmloopuv++) {
|
||||
|
@ -391,12 +391,12 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
|
|||
}
|
||||
|
||||
/* handle custom split normals */
|
||||
if (ob->type == OB_MESH && CustomData_has_layer(&result->loop_data, CD_CUSTOMLOOPNORMAL) &&
|
||||
if (ob->type == OB_MESH && CustomData_has_layer(&result->corner_data, CD_CUSTOMLOOPNORMAL) &&
|
||||
result->faces_num > 0)
|
||||
{
|
||||
blender::Array<blender::float3> loop_normals(result_corner_verts.size());
|
||||
blender::short2 *clnors = static_cast<blender::short2 *>(CustomData_get_layer_for_write(
|
||||
&result->loop_data, CD_CUSTOMLOOPNORMAL, result->corners_num));
|
||||
&result->corner_data, CD_CUSTOMLOOPNORMAL, result->corners_num));
|
||||
blender::bke::mesh::CornerNormalSpaceArray lnors_spacearr;
|
||||
|
||||
/* The transform matrix of a normal must be
|
||||
|
|
|
@ -209,7 +209,7 @@ blender::bke::MeshNormalDomain Mesh::normals_domain() const
|
|||
return MeshNormalDomain::Point;
|
||||
}
|
||||
|
||||
if (CustomData_has_layer(&this->loop_data, CD_CUSTOMLOOPNORMAL)) {
|
||||
if (CustomData_has_layer(&this->corner_data, CD_CUSTOMLOOPNORMAL)) {
|
||||
return MeshNormalDomain::Corner;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ blender::Span<blender::float3> Mesh::corner_normals() const
|
|||
const VArraySpan sharp_edges = *attributes.lookup<bool>("sharp_edge", ATTR_DOMAIN_EDGE);
|
||||
const VArraySpan sharp_faces = *attributes.lookup<bool>("sharp_face", ATTR_DOMAIN_FACE);
|
||||
const short2 *custom_normals = static_cast<const short2 *>(
|
||||
CustomData_get_layer(&this->loop_data, CD_CUSTOMLOOPNORMAL));
|
||||
CustomData_get_layer(&this->corner_data, CD_CUSTOMLOOPNORMAL));
|
||||
mesh::normals_calc_loop(this->vert_positions(),
|
||||
this->edges(),
|
||||
this->faces(),
|
||||
|
@ -1548,13 +1548,13 @@ void normals_loop_custom_set_from_verts(const Span<float3> vert_positions,
|
|||
static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const bool use_vertices)
|
||||
{
|
||||
short2 *clnors = static_cast<short2 *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_CUSTOMLOOPNORMAL, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_CUSTOMLOOPNORMAL, mesh->corners_num));
|
||||
if (clnors != nullptr) {
|
||||
memset(clnors, 0, sizeof(*clnors) * mesh->corners_num);
|
||||
}
|
||||
else {
|
||||
clnors = static_cast<short2 *>(CustomData_add_layer(
|
||||
&mesh->loop_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->corners_num));
|
||||
&mesh->corner_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->corners_num));
|
||||
}
|
||||
MutableAttributeAccessor attributes = mesh->attributes_for_write();
|
||||
SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>(
|
||||
|
|
|
@ -444,7 +444,7 @@ bool BKE_mesh_runtime_is_valid(Mesh *me_eval)
|
|||
me_eval->verts_num,
|
||||
&me_eval->edge_data,
|
||||
me_eval->edges_num,
|
||||
&me_eval->loop_data,
|
||||
&me_eval->corner_data,
|
||||
me_eval->corners_num,
|
||||
&me_eval->face_data,
|
||||
me_eval->faces_num,
|
||||
|
|
|
@ -125,7 +125,7 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
|
|||
using namespace blender::bke;
|
||||
|
||||
if (!uvmap) {
|
||||
uvmap = CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
uvmap = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
|
||||
const AttributeAccessor attributes = mesh->attributes();
|
||||
|
@ -595,7 +595,7 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval,
|
|||
me_eval->corner_tri_faces().data(),
|
||||
uint(corner_tris.size()),
|
||||
sharp_face,
|
||||
&me_eval->loop_data,
|
||||
&me_eval->corner_data,
|
||||
calc_active_tangent,
|
||||
tangent_names,
|
||||
tangent_names_len,
|
||||
|
@ -605,7 +605,7 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval,
|
|||
/* may be nullptr */
|
||||
static_cast<const float(*)[3]>(CustomData_get_layer(&me_eval->vert_data, CD_ORCO)),
|
||||
/* result */
|
||||
&me_eval->loop_data,
|
||||
&me_eval->corner_data,
|
||||
uint(me_eval->corners_num),
|
||||
&tangent_mask);
|
||||
}
|
||||
|
|
|
@ -1030,7 +1030,7 @@ bool BKE_mesh_validate_all_customdata(CustomData *vert_data,
|
|||
const uint verts_num,
|
||||
CustomData *edge_data,
|
||||
const uint edges_num,
|
||||
CustomData *loop_data,
|
||||
CustomData *corner_data,
|
||||
const uint corners_num,
|
||||
CustomData *face_data,
|
||||
const uint faces_num,
|
||||
|
@ -1051,11 +1051,11 @@ bool BKE_mesh_validate_all_customdata(CustomData *vert_data,
|
|||
is_valid &= mesh_validate_customdata(
|
||||
edge_data, mask.emask, edges_num, do_verbose, do_fixes, &is_change_e);
|
||||
is_valid &= mesh_validate_customdata(
|
||||
loop_data, mask.lmask, corners_num, do_verbose, do_fixes, &is_change_l);
|
||||
corner_data, mask.lmask, corners_num, do_verbose, do_fixes, &is_change_l);
|
||||
is_valid &= mesh_validate_customdata(
|
||||
face_data, mask.pmask, faces_num, do_verbose, do_fixes, &is_change_p);
|
||||
|
||||
const int tot_uvloop = CustomData_number_of_layers(loop_data, CD_PROP_FLOAT2);
|
||||
const int tot_uvloop = CustomData_number_of_layers(corner_data, CD_PROP_FLOAT2);
|
||||
if (tot_uvloop > MAX_MTFACE) {
|
||||
PRINT_ERR(
|
||||
"\tMore UV layers than %d allowed, %d last ones won't be available for render, shaders, "
|
||||
|
@ -1065,12 +1065,12 @@ bool BKE_mesh_validate_all_customdata(CustomData *vert_data,
|
|||
}
|
||||
|
||||
/* check indices of clone/stencil */
|
||||
if (do_fixes && CustomData_get_clone_layer(loop_data, CD_PROP_FLOAT2) >= tot_uvloop) {
|
||||
CustomData_set_layer_clone(loop_data, CD_PROP_FLOAT2, 0);
|
||||
if (do_fixes && CustomData_get_clone_layer(corner_data, CD_PROP_FLOAT2) >= tot_uvloop) {
|
||||
CustomData_set_layer_clone(corner_data, CD_PROP_FLOAT2, 0);
|
||||
is_change_l = true;
|
||||
}
|
||||
if (do_fixes && CustomData_get_stencil_layer(loop_data, CD_PROP_FLOAT2) >= tot_uvloop) {
|
||||
CustomData_set_layer_stencil(loop_data, CD_PROP_FLOAT2, 0);
|
||||
if (do_fixes && CustomData_get_stencil_layer(corner_data, CD_PROP_FLOAT2) >= tot_uvloop) {
|
||||
CustomData_set_layer_stencil(corner_data, CD_PROP_FLOAT2, 0);
|
||||
is_change_l = true;
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1091,7 @@ bool BKE_mesh_validate(Mesh *mesh, const bool do_verbose, const bool cddata_chec
|
|||
mesh->verts_num,
|
||||
&mesh->edge_data,
|
||||
mesh->edges_num,
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
mesh->corners_num,
|
||||
&mesh->face_data,
|
||||
mesh->faces_num,
|
||||
|
@ -1144,7 +1144,7 @@ bool BKE_mesh_is_valid(Mesh *mesh)
|
|||
mesh->verts_num,
|
||||
&mesh->edge_data,
|
||||
mesh->edges_num,
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
mesh->corners_num,
|
||||
&mesh->face_data,
|
||||
mesh->faces_num,
|
||||
|
@ -1259,7 +1259,7 @@ void strip_loose_facesloops(Mesh *mesh, blender::BitSpan faces_to_remove)
|
|||
for (a = b = 0; a < mesh->corners_num; a++, corner++) {
|
||||
if (corner_edges[corner] != INVALID_LOOP_EDGE_MARKER) {
|
||||
if (a != b) {
|
||||
CustomData_copy_data(&mesh->loop_data, &mesh->loop_data, a, b, 1);
|
||||
CustomData_copy_data(&mesh->corner_data, &mesh->corner_data, a, b, 1);
|
||||
}
|
||||
new_idx[a] = b;
|
||||
b++;
|
||||
|
@ -1271,7 +1271,7 @@ void strip_loose_facesloops(Mesh *mesh, blender::BitSpan faces_to_remove)
|
|||
}
|
||||
}
|
||||
if (a != b) {
|
||||
CustomData_free_elem(&mesh->loop_data, b, a - b);
|
||||
CustomData_free_elem(&mesh->corner_data, b, a - b);
|
||||
mesh->corners_num = b;
|
||||
}
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ static Mesh *mesh_wrapper_ensure_subdivision(Mesh *mesh)
|
|||
/* If custom normals are present and the option is turned on calculate the split
|
||||
* normals and clear flag so the normals get interpolated to the result mesh. */
|
||||
void *data = CustomData_add_layer(
|
||||
&mesh->loop_data, CD_NORMAL, CD_CONSTRUCT, mesh->corners_num);
|
||||
&mesh->corner_data, CD_NORMAL, CD_CONSTRUCT, mesh->corners_num);
|
||||
memcpy(data, mesh->corner_normals().data(), mesh->corner_normals().size_in_bytes());
|
||||
}
|
||||
|
||||
|
@ -365,8 +365,8 @@ static Mesh *mesh_wrapper_ensure_subdivision(Mesh *mesh)
|
|||
if (use_clnors) {
|
||||
BKE_mesh_set_custom_normals(subdiv_mesh,
|
||||
static_cast<float(*)[3]>(CustomData_get_layer_for_write(
|
||||
&subdiv_mesh->loop_data, CD_NORMAL, mesh->corners_num)));
|
||||
CustomData_free_layers(&subdiv_mesh->loop_data, CD_NORMAL, mesh->corners_num);
|
||||
&subdiv_mesh->corner_data, CD_NORMAL, mesh->corners_num)));
|
||||
CustomData_free_layers(&subdiv_mesh->corner_data, CD_NORMAL, mesh->corners_num);
|
||||
}
|
||||
|
||||
if (!ELEM(subdiv, runtime_data->subdiv_cpu, runtime_data->subdiv_gpu)) {
|
||||
|
|
|
@ -83,10 +83,10 @@ void multires_customdata_delete(Mesh *mesh)
|
|||
}
|
||||
}
|
||||
else {
|
||||
CustomData_external_remove(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->corners_num);
|
||||
CustomData_free_layer_active(&mesh->loop_data, CD_MDISPS, mesh->corners_num);
|
||||
CustomData_external_remove(&mesh->corner_data, &mesh->id, CD_MDISPS, mesh->corners_num);
|
||||
CustomData_free_layer_active(&mesh->corner_data, CD_MDISPS, mesh->corners_num);
|
||||
|
||||
CustomData_free_layer_active(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num);
|
||||
CustomData_free_layer_active(&mesh->corner_data, CD_GRID_PAINT_MASK, mesh->corners_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, Mesh *mesh, i
|
|||
{
|
||||
const blender::OffsetIndices faces = mesh->faces();
|
||||
const MDisps *mdisps = static_cast<const MDisps *>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_MDISPS));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_MDISPS));
|
||||
BLI_bitmap **grid_hidden = ccgdm->gridHidden;
|
||||
int *gridOffset;
|
||||
int j;
|
||||
|
@ -470,7 +470,7 @@ void multires_force_external_reload(Object *object)
|
|||
{
|
||||
Mesh *mesh = BKE_mesh_from_object(object);
|
||||
|
||||
CustomData_external_reload(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
|
||||
CustomData_external_reload(&mesh->corner_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
|
||||
multires_force_sculpt_rebuild(object);
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ static int get_levels_from_disps(Object *ob)
|
|||
int totlvl = 0;
|
||||
|
||||
const MDisps *mdisp = static_cast<const MDisps *>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_MDISPS));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_MDISPS));
|
||||
|
||||
for (const int i : faces.index_range()) {
|
||||
for (const int corner : faces[i]) {
|
||||
|
@ -522,7 +522,7 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o
|
|||
CustomData_get_layer(&mesh->edit_mesh->bm->ldata, CD_MDISPS));
|
||||
}
|
||||
else {
|
||||
mdisp = static_cast<const MDisps *>(CustomData_get_layer(&mesh->loop_data, CD_MDISPS));
|
||||
mdisp = static_cast<const MDisps *>(CustomData_get_layer(&mesh->corner_data, CD_MDISPS));
|
||||
}
|
||||
|
||||
if (mdisp) {
|
||||
|
@ -536,7 +536,7 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o
|
|||
static void multires_set_tot_mdisps(Mesh *mesh, int lvl)
|
||||
{
|
||||
MDisps *mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
int i;
|
||||
|
||||
if (mdisps) {
|
||||
|
@ -656,9 +656,9 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
|
|||
multires_set_tot_mdisps(mesh, mmd->totlvl);
|
||||
multiresModifier_ensure_external_read(mesh, mmd);
|
||||
mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
gpm = static_cast<GridPaintMask *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_GRID_PAINT_MASK, mesh->corners_num));
|
||||
|
||||
multires_force_sculpt_rebuild(ob);
|
||||
|
||||
|
@ -720,7 +720,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd,
|
|||
multires_set_tot_mdisps(mesh, mmd->totlvl);
|
||||
multiresModifier_ensure_external_read(mesh, mmd);
|
||||
MDisps *mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
|
||||
multires_force_sculpt_rebuild(ob);
|
||||
|
||||
|
@ -958,7 +958,7 @@ static void multiresModifier_disp_run(
|
|||
CCGKey key;
|
||||
blender::OffsetIndices faces = mesh->faces();
|
||||
MDisps *mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
GridPaintMask *grid_paint_mask = nullptr;
|
||||
int *gridOffset;
|
||||
int i, gridSize, dGridSize, dSkip;
|
||||
|
@ -981,7 +981,7 @@ static void multiresModifier_disp_run(
|
|||
if (!mdisps) {
|
||||
if (op == CALC_DISPLACEMENTS) {
|
||||
mdisps = static_cast<MDisps *>(
|
||||
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num));
|
||||
CustomData_add_layer(&mesh->corner_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num));
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
@ -1001,7 +1001,7 @@ static void multiresModifier_disp_run(
|
|||
/* multires paint masks */
|
||||
if (key.has_mask) {
|
||||
grid_paint_mask = static_cast<GridPaintMask *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_GRID_PAINT_MASK, mesh->corners_num));
|
||||
}
|
||||
|
||||
/* when adding new faces in edit mode, need to allocate disps */
|
||||
|
@ -1050,7 +1050,7 @@ void multires_modifier_update_mdisps(DerivedMesh *dm, Scene *scene)
|
|||
mmd = ccgdm->multires.mmd;
|
||||
multires_set_tot_mdisps(mesh, mmd->totlvl);
|
||||
multiresModifier_ensure_external_read(mesh, mmd);
|
||||
mdisps = static_cast<const MDisps *>(CustomData_get_layer(&mesh->loop_data, CD_MDISPS));
|
||||
mdisps = static_cast<const MDisps *>(CustomData_get_layer(&mesh->corner_data, CD_MDISPS));
|
||||
|
||||
if (mdisps) {
|
||||
int lvl = ccgdm->multires.lvl;
|
||||
|
@ -1062,7 +1062,7 @@ void multires_modifier_update_mdisps(DerivedMesh *dm, Scene *scene)
|
|||
CCGKey highGridKey, lowGridKey;
|
||||
CCGSubSurf *ss;
|
||||
int i, j, numGrids, highGridSize, lowGridSize;
|
||||
const bool has_mask = CustomData_has_layer(&mesh->loop_data, CD_GRID_PAINT_MASK);
|
||||
const bool has_mask = CustomData_has_layer(&mesh->corner_data, CD_GRID_PAINT_MASK);
|
||||
|
||||
/* Create subsurf DM from original mesh at high level. */
|
||||
/* TODO: use mesh_deform_eval when sculpting on deformed mesh. */
|
||||
|
@ -1141,7 +1141,7 @@ void multires_modifier_update_mdisps(DerivedMesh *dm, Scene *scene)
|
|||
}
|
||||
else {
|
||||
DerivedMesh *cddm, *subdm;
|
||||
const bool has_mask = CustomData_has_layer(&mesh->loop_data, CD_GRID_PAINT_MASK);
|
||||
const bool has_mask = CustomData_has_layer(&mesh->corner_data, CD_GRID_PAINT_MASK);
|
||||
|
||||
/* TODO: use mesh_deform_eval when sculpting on deformed mesh. */
|
||||
cddm = CDDM_from_mesh(mesh);
|
||||
|
@ -1173,7 +1173,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
|
|||
BLI_bitmap **grid_hidden = ccgdm->gridHidden;
|
||||
Mesh *mesh = static_cast<Mesh *>(ccgdm->multires.ob->data);
|
||||
MDisps *mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
int totlvl = ccgdm->multires.totlvl;
|
||||
int lvl = ccgdm->multires.lvl;
|
||||
|
||||
|
@ -1384,7 +1384,7 @@ static void multires_apply_uniform_scale(Object *object, const float scale)
|
|||
{
|
||||
Mesh *mesh = (Mesh *)object->data;
|
||||
MDisps *mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
for (int i = 0; i < mesh->corners_num; i++) {
|
||||
MDisps *grid = &mdisps[i];
|
||||
for (int j = 0; j < grid->totdisp; j++) {
|
||||
|
@ -1405,7 +1405,7 @@ static void multires_apply_smat(Depsgraph * /*depsgraph*/,
|
|||
/* Make sure layer present. */
|
||||
Mesh *mesh = (Mesh *)object->data;
|
||||
multiresModifier_ensure_external_read(mesh, mmd);
|
||||
if (!CustomData_get_layer(&mesh->loop_data, CD_MDISPS)) {
|
||||
if (!CustomData_get_layer(&mesh->corner_data, CD_MDISPS)) {
|
||||
return;
|
||||
}
|
||||
if (is_uniform_scaled_m3(smat)) {
|
||||
|
@ -1464,9 +1464,9 @@ void multires_topology_changed(Mesh *mesh)
|
|||
MDisps *mdisp = nullptr, *cur = nullptr;
|
||||
int i, grid = 0;
|
||||
|
||||
CustomData_external_read(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
|
||||
CustomData_external_read(&mesh->corner_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
|
||||
mdisp = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
|
||||
if (!mdisp) {
|
||||
return;
|
||||
|
@ -1497,17 +1497,17 @@ void multires_topology_changed(Mesh *mesh)
|
|||
|
||||
void multires_ensure_external_read(Mesh *mesh, int top_level)
|
||||
{
|
||||
if (!CustomData_external_test(&mesh->loop_data, CD_MDISPS)) {
|
||||
if (!CustomData_external_test(&mesh->corner_data, CD_MDISPS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Modify the data array from the original mesh, not the evaluated mesh.
|
||||
* When multiple objects share the same mesh, this can lead to memory leaks. */
|
||||
MDisps *mdisps = const_cast<MDisps *>(
|
||||
static_cast<const MDisps *>(CustomData_get_layer(&mesh->loop_data, CD_MDISPS)));
|
||||
static_cast<const MDisps *>(CustomData_get_layer(&mesh->corner_data, CD_MDISPS)));
|
||||
if (mdisps == nullptr) {
|
||||
mdisps = static_cast<MDisps *>(
|
||||
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num));
|
||||
CustomData_add_layer(&mesh->corner_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num));
|
||||
}
|
||||
|
||||
const int totloop = mesh->corners_num;
|
||||
|
@ -1525,7 +1525,7 @@ void multires_ensure_external_read(Mesh *mesh, int top_level)
|
|||
mdisps[i].level = top_level;
|
||||
}
|
||||
|
||||
CustomData_external_read(&mesh->loop_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
|
||||
CustomData_external_read(&mesh->corner_data, &mesh->id, CD_MASK_MDISPS, mesh->corners_num);
|
||||
}
|
||||
void multiresModifier_ensure_external_read(Mesh *mesh, const MultiresModifierData *mmd)
|
||||
{
|
||||
|
|
|
@ -183,10 +183,10 @@ void multiresModifier_subdivide_to_level(Object *object,
|
|||
|
||||
/* There was no multires at all, all displacement is at 0. Can simply make sure all mdisps grids
|
||||
* are allocated at a proper level and return. */
|
||||
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->loop_data, CD_MDISPS);
|
||||
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->corner_data, CD_MDISPS);
|
||||
if (!has_mdisps) {
|
||||
CustomData_add_layer(
|
||||
&coarse_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->corners_num);
|
||||
&coarse_mesh->corner_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->corners_num);
|
||||
}
|
||||
|
||||
/* NOTE: Subdivision happens from the top level of the existing multires modifier. If it is set
|
||||
|
|
|
@ -36,7 +36,7 @@ static void multires_subdivide_create_object_space_linear_grids(Mesh *mesh)
|
|||
const blender::Span<int> corner_verts = mesh->corner_verts();
|
||||
|
||||
MDisps *mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
for (const int p : faces.index_range()) {
|
||||
const blender::IndexRange face = faces[p];
|
||||
const float3 face_center = mesh::face_center_calc(positions, corner_verts.slice(face));
|
||||
|
@ -72,10 +72,10 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
|
|||
|
||||
const int new_top_level = mmd->totlvl + 1;
|
||||
|
||||
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->loop_data, CD_MDISPS);
|
||||
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->corner_data, CD_MDISPS);
|
||||
if (!has_mdisps) {
|
||||
CustomData_add_layer(
|
||||
&coarse_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->corners_num);
|
||||
&coarse_mesh->corner_data, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->corners_num);
|
||||
}
|
||||
|
||||
if (new_top_level == 1) {
|
||||
|
|
|
@ -109,9 +109,9 @@ static void context_init_grid_pointers(MultiresReshapeContext *reshape_context)
|
|||
{
|
||||
Mesh *base_mesh = reshape_context->base_mesh;
|
||||
reshape_context->mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&base_mesh->loop_data, CD_MDISPS, base_mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&base_mesh->corner_data, CD_MDISPS, base_mesh->corners_num));
|
||||
reshape_context->grid_paint_masks = static_cast<GridPaintMask *>(CustomData_get_layer_for_write(
|
||||
&base_mesh->loop_data, CD_GRID_PAINT_MASK, base_mesh->corners_num));
|
||||
&base_mesh->corner_data, CD_GRID_PAINT_MASK, base_mesh->corners_num));
|
||||
}
|
||||
|
||||
static void context_init_commoon(MultiresReshapeContext *reshape_context)
|
||||
|
@ -575,7 +575,7 @@ static void ensure_displacement_grids(Mesh *mesh, const int grid_level)
|
|||
{
|
||||
const int num_grids = mesh->corners_num;
|
||||
MDisps *mdisps = static_cast<MDisps *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_MDISPS, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_MDISPS, mesh->corners_num));
|
||||
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
|
||||
ensure_displacement_grid(&mdisps[grid_index], grid_level);
|
||||
}
|
||||
|
@ -584,7 +584,7 @@ static void ensure_displacement_grids(Mesh *mesh, const int grid_level)
|
|||
static void ensure_mask_grids(Mesh *mesh, const int level)
|
||||
{
|
||||
GridPaintMask *grid_paint_masks = static_cast<GridPaintMask *>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_GRID_PAINT_MASK, mesh->corners_num));
|
||||
if (grid_paint_masks == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -886,9 +886,9 @@ static const char vname[] = "v_remap_index";
|
|||
static void multires_unsubdivide_free_original_datalayers(Mesh *mesh)
|
||||
{
|
||||
const int l_layer_index = CustomData_get_named_layer_index(
|
||||
&mesh->loop_data, CD_PROP_INT32, lname);
|
||||
&mesh->corner_data, CD_PROP_INT32, lname);
|
||||
if (l_layer_index != -1) {
|
||||
CustomData_free_layer(&mesh->loop_data, CD_PROP_INT32, mesh->corners_num, l_layer_index);
|
||||
CustomData_free_layer(&mesh->corner_data, CD_PROP_INT32, mesh->corners_num, l_layer_index);
|
||||
}
|
||||
|
||||
const int v_layer_index = CustomData_get_named_layer_index(
|
||||
|
@ -907,7 +907,7 @@ static void multires_unsubdivide_add_original_index_datalayers(Mesh *mesh)
|
|||
multires_unsubdivide_free_original_datalayers(mesh);
|
||||
|
||||
int *l_index = static_cast<int *>(CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, lname));
|
||||
&mesh->corner_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, lname));
|
||||
|
||||
int *v_index = static_cast<int *>(CustomData_add_layer_named(
|
||||
&mesh->vert_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->verts_num, vname));
|
||||
|
@ -1173,11 +1173,11 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
|
|||
Mesh *base_mesh)
|
||||
{
|
||||
/* Free the current MDISPS and create a new ones. */
|
||||
if (CustomData_has_layer(&base_mesh->loop_data, CD_MDISPS)) {
|
||||
CustomData_free_layers(&base_mesh->loop_data, CD_MDISPS, base_mesh->corners_num);
|
||||
if (CustomData_has_layer(&base_mesh->corner_data, CD_MDISPS)) {
|
||||
CustomData_free_layers(&base_mesh->corner_data, CD_MDISPS, base_mesh->corners_num);
|
||||
}
|
||||
MDisps *mdisps = static_cast<MDisps *>(CustomData_add_layer(
|
||||
&base_mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, base_mesh->corners_num));
|
||||
&base_mesh->corner_data, CD_MDISPS, CD_SET_DEFAULT, base_mesh->corners_num));
|
||||
|
||||
const int totdisp = pow_i(BKE_ccg_gridsize(context->num_total_levels), 2);
|
||||
const int totloop = base_mesh->corners_num;
|
||||
|
|
|
@ -1493,8 +1493,8 @@ static void copy_ccg_data(Mesh *mesh_destination,
|
|||
const eCustomDataType layer_type)
|
||||
{
|
||||
BLI_assert(mesh_destination->corners_num == mesh_source->corners_num);
|
||||
CustomData *data_destination = &mesh_destination->loop_data;
|
||||
CustomData *data_source = &mesh_source->loop_data;
|
||||
CustomData *data_destination = &mesh_destination->corner_data;
|
||||
CustomData *data_source = &mesh_source->corner_data;
|
||||
const int num_elements = mesh_source->corners_num;
|
||||
if (!CustomData_has_layer(data_source, layer_type)) {
|
||||
return;
|
||||
|
|
|
@ -1329,7 +1329,7 @@ static void make_duplis_faces(const DupliContext *ctx)
|
|||
make_child_duplis(ctx, &fdd, make_child_duplis_faces_from_editmesh);
|
||||
}
|
||||
else {
|
||||
const int uv_idx = CustomData_get_render_layer(&me_eval->loop_data, CD_PROP_FLOAT2);
|
||||
const int uv_idx = CustomData_get_render_layer(&me_eval->corner_data, CD_PROP_FLOAT2);
|
||||
FaceDupliData_Mesh fdd{};
|
||||
fdd.params = fdd_params;
|
||||
fdd.totface = me_eval->faces_num;
|
||||
|
@ -1337,7 +1337,7 @@ static void make_duplis_faces(const DupliContext *ctx)
|
|||
fdd.corner_verts = me_eval->corner_verts();
|
||||
fdd.vert_positions = me_eval->vert_positions();
|
||||
fdd.mloopuv = (uv_idx != -1) ? (const float2 *)CustomData_get_layer_n(
|
||||
&me_eval->loop_data, CD_PROP_FLOAT2, uv_idx) :
|
||||
&me_eval->corner_data, CD_PROP_FLOAT2, uv_idx) :
|
||||
nullptr;
|
||||
fdd.orco = (const float(*)[3])CustomData_get_layer(&me_eval->vert_data, CD_ORCO);
|
||||
|
||||
|
|
|
@ -1543,7 +1543,7 @@ static MultiresModifierData *sculpt_multires_modifier_get(const Scene *scene,
|
|||
|
||||
bool need_mdisps = false;
|
||||
|
||||
if (!CustomData_get_layer(&mesh->loop_data, CD_MDISPS)) {
|
||||
if (!CustomData_get_layer(&mesh->corner_data, CD_MDISPS)) {
|
||||
if (!auto_create_mdisps) {
|
||||
/* Multires can't work without displacement layer. */
|
||||
return nullptr;
|
||||
|
@ -1568,7 +1568,7 @@ static MultiresModifierData *sculpt_multires_modifier_get(const Scene *scene,
|
|||
|
||||
if (mmd->sculptlvl > 0 && !(mmd->flags & eMultiresModifierFlag_UseSculptBaseMesh)) {
|
||||
if (need_mdisps) {
|
||||
CustomData_add_layer(&mesh->loop_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num);
|
||||
CustomData_add_layer(&mesh->corner_data, CD_MDISPS, CD_SET_DEFAULT, mesh->corners_num);
|
||||
}
|
||||
|
||||
return mmd;
|
||||
|
@ -1952,13 +1952,13 @@ void BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
|
|||
|
||||
/* if multires is active, create a grid paint mask layer if there
|
||||
* isn't one already */
|
||||
if (mmd && !CustomData_has_layer(&mesh->loop_data, CD_GRID_PAINT_MASK)) {
|
||||
if (mmd && !CustomData_has_layer(&mesh->corner_data, CD_GRID_PAINT_MASK)) {
|
||||
int level = max_ii(1, mmd->sculptlvl);
|
||||
int gridsize = BKE_ccg_gridsize(level);
|
||||
int gridarea = gridsize * gridsize;
|
||||
|
||||
GridPaintMask *gmask = static_cast<GridPaintMask *>(CustomData_add_layer(
|
||||
&mesh->loop_data, CD_GRID_PAINT_MASK, CD_SET_DEFAULT, mesh->corners_num));
|
||||
&mesh->corner_data, CD_GRID_PAINT_MASK, CD_SET_DEFAULT, mesh->corners_num));
|
||||
|
||||
for (int i = 0; i < mesh->corners_num; i++) {
|
||||
GridPaintMask *gpm = &gmask[i];
|
||||
|
|
|
@ -83,7 +83,7 @@ int BKE_paint_canvas_uvmap_layer_index_get(const PaintModeSettings *settings, Ob
|
|||
}
|
||||
|
||||
const Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
return CustomData_get_active_layer_index(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
return CustomData_get_active_layer_index(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
case PAINT_CANVAS_SOURCE_MATERIAL: {
|
||||
/* Use uv map of the canvas. */
|
||||
|
@ -101,7 +101,7 @@ int BKE_paint_canvas_uvmap_layer_index_get(const PaintModeSettings *settings, Ob
|
|||
}
|
||||
|
||||
const Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
return CustomData_get_named_layer_index(&mesh->loop_data, CD_PROP_FLOAT2, slot->uvname);
|
||||
return CustomData_get_named_layer_index(&mesh->corner_data, CD_PROP_FLOAT2, slot->uvname);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -2586,7 +2586,7 @@ static blender::draw::pbvh::PBVH_GPU_Args pbvh_draw_args_init(const Mesh &mesh,
|
|||
switch (pbvh.header.type) {
|
||||
case PBVH_FACES:
|
||||
args.vert_data = &mesh.vert_data;
|
||||
args.loop_data = &mesh.loop_data;
|
||||
args.corner_data = &mesh.corner_data;
|
||||
args.face_data = &mesh.face_data;
|
||||
args.mesh = pbvh.mesh;
|
||||
args.vert_positions = pbvh.vert_positions;
|
||||
|
@ -2604,7 +2604,7 @@ static blender::draw::pbvh::PBVH_GPU_Args pbvh_draw_args_init(const Mesh &mesh,
|
|||
break;
|
||||
case PBVH_GRIDS:
|
||||
args.vert_data = &pbvh.mesh->vert_data;
|
||||
args.loop_data = &pbvh.mesh->loop_data;
|
||||
args.corner_data = &pbvh.mesh->corner_data;
|
||||
args.face_data = &pbvh.mesh->face_data;
|
||||
args.ccg_key = pbvh.gridkey;
|
||||
args.mesh = pbvh.mesh;
|
||||
|
@ -2616,7 +2616,7 @@ static blender::draw::pbvh::PBVH_GPU_Args pbvh_draw_args_init(const Mesh &mesh,
|
|||
case PBVH_BMESH:
|
||||
args.bm = pbvh.header.bm;
|
||||
args.vert_data = &args.bm->vdata;
|
||||
args.loop_data = &args.bm->ldata;
|
||||
args.corner_data = &args.bm->ldata;
|
||||
args.face_data = &args.bm->pdata;
|
||||
args.bm_faces = &node.bm_faces;
|
||||
args.cd_mask_layer = CustomData_get_offset_named(
|
||||
|
|
|
@ -663,7 +663,7 @@ static bool update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image
|
|||
return false;
|
||||
}
|
||||
|
||||
const StringRef active_uv_name = CustomData_get_active_layer_name(&mesh->loop_data,
|
||||
const StringRef active_uv_name = CustomData_get_active_layer_name(&mesh->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
if (active_uv_name.is_empty()) {
|
||||
return false;
|
||||
|
|
|
@ -144,7 +144,7 @@ static void mask_init_data(SubdivCCGMaskEvaluator *mask_evaluator, const Mesh *m
|
|||
GridPaintMaskData *data = static_cast<GridPaintMaskData *>(mask_evaluator->user_data);
|
||||
data->faces = mesh->faces();
|
||||
data->grid_paint_mask = static_cast<const GridPaintMask *>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_GRID_PAINT_MASK));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_GRID_PAINT_MASK));
|
||||
mask_data_init_mapping(mask_evaluator, mesh);
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ static void mask_init_functions(SubdivCCGMaskEvaluator *mask_evaluator)
|
|||
|
||||
bool BKE_subdiv_ccg_mask_init_from_paint(SubdivCCGMaskEvaluator *mask_evaluator, const Mesh *mesh)
|
||||
{
|
||||
if (!CustomData_get_layer(&mesh->loop_data, CD_GRID_PAINT_MASK)) {
|
||||
if (!CustomData_get_layer(&mesh->corner_data, CD_GRID_PAINT_MASK)) {
|
||||
return false;
|
||||
}
|
||||
/* Allocate all required memory. */
|
||||
|
|
|
@ -198,7 +198,7 @@ static int get_num_uv_layers(const OpenSubdiv_Converter *converter)
|
|||
{
|
||||
ConverterStorage *storage = static_cast<ConverterStorage *>(converter->user_data);
|
||||
const Mesh *mesh = storage->mesh;
|
||||
return CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
return CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
|
||||
static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int layer_index)
|
||||
|
@ -206,7 +206,7 @@ static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int la
|
|||
ConverterStorage *storage = static_cast<ConverterStorage *>(converter->user_data);
|
||||
const Mesh *mesh = storage->mesh;
|
||||
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_n(&mesh->loop_data, CD_PROP_FLOAT2, layer_index));
|
||||
CustomData_get_layer_n(&mesh->corner_data, CD_PROP_FLOAT2, layer_index));
|
||||
const int num_vert = mesh->verts_num;
|
||||
const float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT};
|
||||
/* Initialize memory required for the operations. */
|
||||
|
|
|
@ -415,7 +415,7 @@ static void displacement_init_data(SubdivDisplacement *displacement,
|
|||
data->mesh = mesh;
|
||||
data->mmd = mmd;
|
||||
data->faces = mesh->faces();
|
||||
data->mdisps = static_cast<const MDisps *>(CustomData_get_layer(&mesh->loop_data, CD_MDISPS));
|
||||
data->mdisps = static_cast<const MDisps *>(CustomData_get_layer(&mesh->corner_data, CD_MDISPS));
|
||||
data->face_ptex_offset = BKE_subdiv_face_ptex_offset_get(subdiv);
|
||||
data->is_initialized = false;
|
||||
displacement_data_init_mapping(displacement, mesh);
|
||||
|
@ -436,7 +436,7 @@ void BKE_subdiv_displacement_attach_from_multires(Subdiv *subdiv,
|
|||
BKE_subdiv_displacement_detach(subdiv);
|
||||
/* It is possible to have mesh without CD_MDISPS layer. Happens when using
|
||||
* dynamic topology. */
|
||||
if (!CustomData_has_layer(&mesh->loop_data, CD_MDISPS)) {
|
||||
if (!CustomData_has_layer(&mesh->corner_data, CD_MDISPS)) {
|
||||
return;
|
||||
}
|
||||
/* Allocate all required memory. */
|
||||
|
|
|
@ -242,10 +242,10 @@ bool BKE_subdiv_eval_refine_from_mesh(Subdiv *subdiv,
|
|||
mesh->verts_no_face());
|
||||
|
||||
/* Set face-varying data to UV maps. */
|
||||
const int num_uv_layers = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const int num_uv_layers = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
for (int layer_index = 0; layer_index < num_uv_layers; layer_index++) {
|
||||
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_n(&mesh->loop_data, CD_PROP_FLOAT2, layer_index));
|
||||
CustomData_get_layer_n(&mesh->corner_data, CD_PROP_FLOAT2, layer_index));
|
||||
set_face_varying_data_from_uv(subdiv, mesh, mloopuv, layer_index);
|
||||
}
|
||||
/* Set vertex data to orco. */
|
||||
|
|
|
@ -88,10 +88,10 @@ static void subdiv_mesh_ctx_cache_uv_layers(SubdivMeshContext *ctx)
|
|||
{
|
||||
Mesh *subdiv_mesh = ctx->subdiv_mesh;
|
||||
ctx->num_uv_layers = std::min(
|
||||
CustomData_number_of_layers(&subdiv_mesh->loop_data, CD_PROP_FLOAT2), MAX_MTFACE);
|
||||
CustomData_number_of_layers(&subdiv_mesh->corner_data, CD_PROP_FLOAT2), MAX_MTFACE);
|
||||
for (int layer_index = 0; layer_index < ctx->num_uv_layers; layer_index++) {
|
||||
ctx->uv_layers[layer_index] = static_cast<float2 *>(CustomData_get_layer_n_for_write(
|
||||
&subdiv_mesh->loop_data, CD_PROP_FLOAT2, layer_index, subdiv_mesh->corners_num));
|
||||
&subdiv_mesh->corner_data, CD_PROP_FLOAT2, layer_index, subdiv_mesh->corners_num));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ static void subdiv_mesh_ctx_cache_custom_data_layers(SubdivMeshContext *ctx)
|
|||
ctx->edge_origindex = static_cast<int *>(CustomData_get_layer_for_write(
|
||||
&subdiv_mesh->edge_data, CD_ORIGINDEX, subdiv_mesh->edges_num));
|
||||
ctx->loop_origindex = static_cast<int *>(CustomData_get_layer_for_write(
|
||||
&subdiv_mesh->loop_data, CD_ORIGINDEX, subdiv_mesh->corners_num));
|
||||
&subdiv_mesh->corner_data, CD_ORIGINDEX, subdiv_mesh->corners_num));
|
||||
ctx->face_origindex = static_cast<int *>(CustomData_get_layer_for_write(
|
||||
&subdiv_mesh->face_data, CD_ORIGINDEX, subdiv_mesh->faces_num));
|
||||
/* UV layers interpolation. */
|
||||
|
@ -201,7 +201,7 @@ struct VerticesForInterpolation {
|
|||
CustomData vertex_data_storage;
|
||||
bool vertex_data_storage_allocated;
|
||||
/* Indices within vertex_data to interpolate for. The indices are aligned
|
||||
* with uv coordinates in a similar way as indices in loop_data_storage. */
|
||||
* with uv coordinates in a similar way as indices in corner_data_storage. */
|
||||
int vertex_indices[4];
|
||||
};
|
||||
|
||||
|
@ -318,7 +318,7 @@ struct LoopsForInterpolation {
|
|||
/* This field points to a loop data which is to be used for interpolation.
|
||||
* The idea is to avoid unnecessary allocations for regular faces, where
|
||||
* we can simply interpolate corner vertices. */
|
||||
const CustomData *loop_data;
|
||||
const CustomData *corner_data;
|
||||
/* Loops data calculated for ptex corners. There are always 4 elements
|
||||
* in this custom data, aligned the following way:
|
||||
*
|
||||
|
@ -328,10 +328,10 @@ struct LoopsForInterpolation {
|
|||
* index 3 -> uv (1, 0)
|
||||
*
|
||||
* Is allocated for non-regular faces (triangles and n-gons). */
|
||||
CustomData loop_data_storage;
|
||||
bool loop_data_storage_allocated;
|
||||
/* Indices within loop_data to interpolate for. The indices are aligned with
|
||||
* uv coordinates in a similar way as indices in loop_data_storage. */
|
||||
CustomData corner_data_storage;
|
||||
bool corner_data_storage_allocated;
|
||||
/* Indices within corner_data to interpolate for. The indices are aligned with
|
||||
* uv coordinates in a similar way as indices in corner_data_storage. */
|
||||
int loop_indices[4];
|
||||
};
|
||||
|
||||
|
@ -341,18 +341,18 @@ static void loop_interpolation_init(const SubdivMeshContext *ctx,
|
|||
{
|
||||
const Mesh *coarse_mesh = ctx->coarse_mesh;
|
||||
if (coarse_face.size() == 4) {
|
||||
loop_interpolation->loop_data = &coarse_mesh->loop_data;
|
||||
loop_interpolation->corner_data = &coarse_mesh->corner_data;
|
||||
loop_interpolation->loop_indices[0] = coarse_face.start() + 0;
|
||||
loop_interpolation->loop_indices[1] = coarse_face.start() + 1;
|
||||
loop_interpolation->loop_indices[2] = coarse_face.start() + 2;
|
||||
loop_interpolation->loop_indices[3] = coarse_face.start() + 3;
|
||||
loop_interpolation->loop_data_storage_allocated = false;
|
||||
loop_interpolation->corner_data_storage_allocated = false;
|
||||
}
|
||||
else {
|
||||
loop_interpolation->loop_data = &loop_interpolation->loop_data_storage;
|
||||
loop_interpolation->corner_data = &loop_interpolation->corner_data_storage;
|
||||
/* Allocate storage for loops corresponding to ptex corners. */
|
||||
CustomData_copy_layout(&ctx->coarse_mesh->loop_data,
|
||||
&loop_interpolation->loop_data_storage,
|
||||
CustomData_copy_layout(&ctx->coarse_mesh->corner_data,
|
||||
&loop_interpolation->corner_data_storage,
|
||||
CD_MASK_EVERYTHING.lmask,
|
||||
CD_SET_DEFAULT,
|
||||
4);
|
||||
|
@ -361,7 +361,7 @@ static void loop_interpolation_init(const SubdivMeshContext *ctx,
|
|||
loop_interpolation->loop_indices[1] = 1;
|
||||
loop_interpolation->loop_indices[2] = 2;
|
||||
loop_interpolation->loop_indices[3] = 3;
|
||||
loop_interpolation->loop_data_storage_allocated = true;
|
||||
loop_interpolation->corner_data_storage_allocated = true;
|
||||
/* Interpolate center of face right away, it stays unchanged for all
|
||||
* ptex faces. */
|
||||
const float weight = 1.0f / float(coarse_face.size());
|
||||
|
@ -371,8 +371,8 @@ static void loop_interpolation_init(const SubdivMeshContext *ctx,
|
|||
weights[i] = weight;
|
||||
indices[i] = coarse_face.start() + i;
|
||||
}
|
||||
CustomData_interp(&coarse_mesh->loop_data,
|
||||
&loop_interpolation->loop_data_storage,
|
||||
CustomData_interp(&coarse_mesh->corner_data,
|
||||
&loop_interpolation->corner_data_storage,
|
||||
indices.data(),
|
||||
weights.data(),
|
||||
nullptr,
|
||||
|
@ -390,13 +390,13 @@ static void loop_interpolation_from_corner(const SubdivMeshContext *ctx,
|
|||
/* Nothing to do, all indices and data is already assigned. */
|
||||
}
|
||||
else {
|
||||
const CustomData *loop_data = &ctx->coarse_mesh->loop_data;
|
||||
const CustomData *corner_data = &ctx->coarse_mesh->corner_data;
|
||||
LoopsOfPtex loops_of_ptex;
|
||||
loops_of_ptex_get(&loops_of_ptex, coarse_face, corner);
|
||||
/* PTEX face corner corresponds to a face loop with same index. */
|
||||
CustomData_free_elem(&loop_interpolation->loop_data_storage, 0, 1);
|
||||
CustomData_free_elem(&loop_interpolation->corner_data_storage, 0, 1);
|
||||
CustomData_copy_data(
|
||||
loop_data, &loop_interpolation->loop_data_storage, coarse_face.start() + corner, 0, 1);
|
||||
corner_data, &loop_interpolation->corner_data_storage, coarse_face.start() + corner, 0, 1);
|
||||
/* Interpolate remaining ptex face corners, which hits loops
|
||||
* middle points.
|
||||
*
|
||||
|
@ -409,17 +409,27 @@ static void loop_interpolation_from_corner(const SubdivMeshContext *ctx,
|
|||
(first_loop_index - base_loop_index + 1) % coarse_face.size();
|
||||
const int first_indices[2] = {first_loop_index, second_loop_index};
|
||||
const int last_indices[2] = {loops_of_ptex.last_loop, loops_of_ptex.first_loop};
|
||||
CustomData_interp(
|
||||
loop_data, &loop_interpolation->loop_data_storage, first_indices, weights, nullptr, 2, 1);
|
||||
CustomData_interp(
|
||||
loop_data, &loop_interpolation->loop_data_storage, last_indices, weights, nullptr, 2, 3);
|
||||
CustomData_interp(corner_data,
|
||||
&loop_interpolation->corner_data_storage,
|
||||
first_indices,
|
||||
weights,
|
||||
nullptr,
|
||||
2,
|
||||
1);
|
||||
CustomData_interp(corner_data,
|
||||
&loop_interpolation->corner_data_storage,
|
||||
last_indices,
|
||||
weights,
|
||||
nullptr,
|
||||
2,
|
||||
3);
|
||||
}
|
||||
}
|
||||
|
||||
static void loop_interpolation_end(LoopsForInterpolation *loop_interpolation)
|
||||
{
|
||||
if (loop_interpolation->loop_data_storage_allocated) {
|
||||
CustomData_free(&loop_interpolation->loop_data_storage, 4);
|
||||
if (loop_interpolation->corner_data_storage_allocated) {
|
||||
CustomData_free(&loop_interpolation->corner_data_storage, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -829,15 +839,15 @@ static void subdiv_mesh_edge(const SubdivForeachContext *foreach_context,
|
|||
/** \name Loops creation/interpolation
|
||||
* \{ */
|
||||
|
||||
static void subdiv_interpolate_loop_data(const SubdivMeshContext *ctx,
|
||||
const int subdiv_loop_index,
|
||||
const LoopsForInterpolation *loop_interpolation,
|
||||
const float u,
|
||||
const float v)
|
||||
static void subdiv_interpolate_corner_data(const SubdivMeshContext *ctx,
|
||||
const int subdiv_loop_index,
|
||||
const LoopsForInterpolation *loop_interpolation,
|
||||
const float u,
|
||||
const float v)
|
||||
{
|
||||
const float weights[4] = {(1.0f - u) * (1.0f - v), u * (1.0f - v), u * v, (1.0f - u) * v};
|
||||
CustomData_interp(loop_interpolation->loop_data,
|
||||
&ctx->subdiv_mesh->loop_data,
|
||||
CustomData_interp(loop_interpolation->corner_data,
|
||||
&ctx->subdiv_mesh->corner_data,
|
||||
loop_interpolation->loop_indices,
|
||||
weights,
|
||||
nullptr,
|
||||
|
@ -907,7 +917,7 @@ static void subdiv_mesh_loop(const SubdivForeachContext *foreach_context,
|
|||
SubdivMeshContext *ctx = static_cast<SubdivMeshContext *>(foreach_context->user_data);
|
||||
SubdivMeshTLS *tls = static_cast<SubdivMeshTLS *>(tls_v);
|
||||
subdiv_mesh_ensure_loop_interpolation(ctx, tls, coarse_face_index, coarse_corner);
|
||||
subdiv_interpolate_loop_data(ctx, subdiv_loop_index, &tls->loop_interpolation, u, v);
|
||||
subdiv_interpolate_corner_data(ctx, subdiv_loop_index, &tls->loop_interpolation, u, v);
|
||||
subdiv_eval_uv_layer(ctx, subdiv_loop_index, ptex_face_index, u, v);
|
||||
ctx->subdiv_corner_verts[subdiv_loop_index] = subdiv_vertex_index;
|
||||
ctx->subdiv_corner_edges[subdiv_loop_index] = subdiv_edge_index;
|
||||
|
|
|
@ -352,8 +352,8 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
|
|||
/* blue and red are swapped pre 2.62.1, be sane (red == red) now! */
|
||||
static void do_versions_mesh_mloopcol_swap_2_62_1(Mesh *mesh)
|
||||
{
|
||||
for (int a = 0; a < mesh->loop_data.totlayer; a++) {
|
||||
CustomDataLayer *layer = &mesh->loop_data.layers[a];
|
||||
for (int a = 0; a < mesh->corner_data.totlayer; a++) {
|
||||
CustomDataLayer *layer = &mesh->corner_data.layers[a];
|
||||
|
||||
if (layer->type == CD_PROP_BYTE_COLOR) {
|
||||
MLoopCol *mloopcol = static_cast<MLoopCol *>(layer->data);
|
||||
|
|
|
@ -3043,8 +3043,8 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
if (DNA_struct_exists(fd->filesdna, "MTexPoly")) {
|
||||
LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
|
||||
/* If we have UVs, so this file will have MTexPoly layers too! */
|
||||
if (CustomData_has_layer(&me->loop_data, CD_MLOOPUV) ||
|
||||
CustomData_has_layer(&me->loop_data, CD_PROP_FLOAT2))
|
||||
if (CustomData_has_layer(&me->corner_data, CD_MLOOPUV) ||
|
||||
CustomData_has_layer(&me->corner_data, CD_PROP_FLOAT2))
|
||||
{
|
||||
CustomData_update_typemap(&me->face_data);
|
||||
CustomData_free_layers(&me->face_data, CD_MTEXPOLY, me->faces_num);
|
||||
|
|
|
@ -1218,9 +1218,9 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
mesh->edge_data.layers) /
|
||||
sizeof(CustomDataLayer);
|
||||
/* We can be sure that mesh->fdata is empty for files written by 2.90. */
|
||||
mesh->loop_data.totlayer = mesh->loop_data.maxlayer = MEM_allocN_len(
|
||||
mesh->loop_data.layers) /
|
||||
sizeof(CustomDataLayer);
|
||||
mesh->corner_data.totlayer = mesh->corner_data.maxlayer = MEM_allocN_len(
|
||||
mesh->corner_data.layers) /
|
||||
sizeof(CustomDataLayer);
|
||||
mesh->face_data.totlayer = mesh->face_data.maxlayer = MEM_allocN_len(
|
||||
mesh->face_data.layers) /
|
||||
sizeof(CustomDataLayer);
|
||||
|
|
|
@ -3585,18 +3585,18 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
|
||||
if (step) {
|
||||
vact1 = CustomData_get_render_layer_index(&me->vert_data, CD_PROP_COLOR);
|
||||
vact2 = CustomData_get_render_layer_index(&me->loop_data, CD_PROP_BYTE_COLOR);
|
||||
vact2 = CustomData_get_render_layer_index(&me->corner_data, CD_PROP_BYTE_COLOR);
|
||||
}
|
||||
else {
|
||||
vact1 = CustomData_get_active_layer_index(&me->vert_data, CD_PROP_COLOR);
|
||||
vact2 = CustomData_get_active_layer_index(&me->loop_data, CD_PROP_BYTE_COLOR);
|
||||
vact2 = CustomData_get_active_layer_index(&me->corner_data, CD_PROP_BYTE_COLOR);
|
||||
}
|
||||
|
||||
if (vact1 != -1) {
|
||||
actlayer = me->vert_data.layers + vact1;
|
||||
}
|
||||
else if (vact2 != -1) {
|
||||
actlayer = me->loop_data.layers + vact2;
|
||||
actlayer = me->corner_data.layers + vact2;
|
||||
}
|
||||
|
||||
if (actlayer) {
|
||||
|
@ -3750,18 +3750,18 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
|
||||
if (step) {
|
||||
vact1 = CustomData_get_render_layer_index(&me->vert_data, CD_PROP_COLOR);
|
||||
vact2 = CustomData_get_render_layer_index(&me->loop_data, CD_PROP_BYTE_COLOR);
|
||||
vact2 = CustomData_get_render_layer_index(&me->corner_data, CD_PROP_BYTE_COLOR);
|
||||
}
|
||||
else {
|
||||
vact1 = CustomData_get_active_layer_index(&me->vert_data, CD_PROP_COLOR);
|
||||
vact2 = CustomData_get_active_layer_index(&me->loop_data, CD_PROP_BYTE_COLOR);
|
||||
vact2 = CustomData_get_active_layer_index(&me->corner_data, CD_PROP_BYTE_COLOR);
|
||||
}
|
||||
|
||||
if (vact1 != -1) {
|
||||
actlayer = me->vert_data.layers + vact1;
|
||||
}
|
||||
else if (vact2 != -1) {
|
||||
actlayer = me->loop_data.layers + vact2;
|
||||
actlayer = me->corner_data.layers + vact2;
|
||||
}
|
||||
|
||||
if (actlayer) {
|
||||
|
|
|
@ -358,8 +358,8 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
|
|||
|
||||
/* Correct default startup UVs. */
|
||||
Mesh *mesh = static_cast<Mesh *>(BLI_findstring(&bmain->meshes, "Cube", offsetof(ID, name) + 2));
|
||||
if (mesh && (mesh->corners_num == 24) && CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2))
|
||||
{
|
||||
if (mesh && (mesh->corners_num == 24) &&
|
||||
CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2)) {
|
||||
const float uv_values[24][2] = {
|
||||
{0.625, 0.50}, {0.875, 0.50}, {0.875, 0.75}, {0.625, 0.75}, {0.375, 0.75}, {0.625, 0.75},
|
||||
{0.625, 1.00}, {0.375, 1.00}, {0.375, 0.00}, {0.625, 0.00}, {0.625, 0.25}, {0.375, 0.25},
|
||||
|
@ -367,7 +367,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
|
|||
{0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50},
|
||||
};
|
||||
float(*mloopuv)[2] = static_cast<float(*)[2]>(
|
||||
CustomData_get_layer_for_write(&mesh->loop_data, CD_PROP_FLOAT2, mesh->corners_num));
|
||||
CustomData_get_layer_for_write(&mesh->corner_data, CD_PROP_FLOAT2, mesh->corners_num));
|
||||
memcpy(mloopuv, uv_values, sizeof(float[2]) * mesh->corners_num);
|
||||
}
|
||||
|
||||
|
@ -605,7 +605,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
|
|||
else {
|
||||
/* Remove sculpt-mask data in default mesh objects for all non-sculpt templates. */
|
||||
CustomData_free_layers(&mesh->vert_data, CD_PAINT_MASK, mesh->verts_num);
|
||||
CustomData_free_layers(&mesh->loop_data, CD_GRID_PAINT_MASK, mesh->corners_num);
|
||||
CustomData_free_layers(&mesh->corner_data, CD_GRID_PAINT_MASK, mesh->corners_num);
|
||||
}
|
||||
mesh->attributes_for_write().remove(".sculpt_face_set");
|
||||
}
|
||||
|
|
|
@ -454,7 +454,7 @@ void BM_mesh_copy_init_customdata_from_mesh_array(BMesh *bm_dst,
|
|||
CustomData mesh_pdata = CustomData_shallow_copy_remove_non_bmesh_attributes(
|
||||
&me_src->face_data, CD_MASK_BMESH.pmask);
|
||||
CustomData mesh_ldata = CustomData_shallow_copy_remove_non_bmesh_attributes(
|
||||
&me_src->loop_data, CD_MASK_BMESH.lmask);
|
||||
&me_src->corner_data, CD_MASK_BMESH.lmask);
|
||||
|
||||
if (i == 0) {
|
||||
CustomData_copy_layout(&mesh_vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_SET_DEFAULT, 0);
|
||||
|
|
|
@ -230,7 +230,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *
|
|||
mask.emask);
|
||||
CustomData mesh_pdata = CustomData_shallow_copy_remove_non_bmesh_attributes(&mesh->face_data,
|
||||
mask.pmask);
|
||||
CustomData mesh_ldata = CustomData_shallow_copy_remove_non_bmesh_attributes(&mesh->loop_data,
|
||||
CustomData mesh_ldata = CustomData_shallow_copy_remove_non_bmesh_attributes(&mesh->corner_data,
|
||||
mask.lmask);
|
||||
|
||||
blender::Vector<std::string> temporary_layers_to_delete;
|
||||
|
@ -1384,10 +1384,10 @@ static void bm_to_mesh_faces(const BMesh &bm,
|
|||
static void bm_to_mesh_loops(const BMesh &bm, const Span<const BMLoop *> bm_loops, Mesh &mesh)
|
||||
{
|
||||
CustomData_add_layer_named(
|
||||
&mesh.loop_data, CD_PROP_INT32, CD_CONSTRUCT, bm.totloop, ".corner_vert");
|
||||
&mesh.corner_data, CD_PROP_INT32, CD_CONSTRUCT, bm.totloop, ".corner_vert");
|
||||
CustomData_add_layer_named(
|
||||
&mesh.loop_data, CD_PROP_INT32, CD_CONSTRUCT, bm.totloop, ".corner_edge");
|
||||
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.ldata, mesh.loop_data);
|
||||
&mesh.corner_data, CD_PROP_INT32, CD_CONSTRUCT, bm.totloop, ".corner_edge");
|
||||
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.ldata, mesh.corner_data);
|
||||
MutableSpan<int> dst_corner_verts = mesh.corner_verts_for_write();
|
||||
MutableSpan<int> dst_corner_edges = mesh.corner_edges_for_write();
|
||||
threading::parallel_for(dst_corner_verts.index_range(), 1024, [&](const IndexRange range) {
|
||||
|
@ -1467,7 +1467,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParam
|
|||
CustomData_copy_layout(
|
||||
&bm->edata, &mesh->edge_data, mask.emask, CD_CONSTRUCT, mesh->edges_num);
|
||||
CustomData_copy_layout(
|
||||
&bm->ldata, &mesh->loop_data, mask.lmask, CD_CONSTRUCT, mesh->corners_num);
|
||||
&bm->ldata, &mesh->corner_data, mask.lmask, CD_CONSTRUCT, mesh->corners_num);
|
||||
CustomData_copy_layout(
|
||||
&bm->pdata, &mesh->face_data, mask.pmask, CD_CONSTRUCT, mesh->faces_num);
|
||||
}
|
||||
|
@ -1692,7 +1692,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *mesh, const CustomData_MeshMasks
|
|||
CustomData_merge_layout(&bm->vdata, &mesh->vert_data, mask.vmask, CD_CONSTRUCT, mesh->verts_num);
|
||||
CustomData_merge_layout(&bm->edata, &mesh->edge_data, mask.emask, CD_CONSTRUCT, mesh->edges_num);
|
||||
CustomData_merge_layout(
|
||||
&bm->ldata, &mesh->loop_data, mask.lmask, CD_CONSTRUCT, mesh->corners_num);
|
||||
&bm->ldata, &mesh->corner_data, mask.lmask, CD_CONSTRUCT, mesh->corners_num);
|
||||
CustomData_merge_layout(&bm->pdata, &mesh->face_data, mask.pmask, CD_CONSTRUCT, mesh->faces_num);
|
||||
|
||||
/* Add optional mesh attributes before parallel iteration. */
|
||||
|
|
|
@ -588,7 +588,7 @@ static void bmo_get_loop_color_ref(BMesh *bm,
|
|||
CustomData_reset(&me_query.vert_data);
|
||||
CustomData_reset(&me_query.edge_data);
|
||||
CustomData_reset(&me_query.face_data);
|
||||
me_query.loop_data = bm->ldata;
|
||||
me_query.corner_data = bm->ldata;
|
||||
*((short *)me_query.id.name) = ID_ME;
|
||||
|
||||
CustomDataLayer *layer = BKE_id_attribute_from_index(
|
||||
|
|
|
@ -61,7 +61,7 @@ struct PBVH_GPU_Args {
|
|||
Span<int> corner_verts;
|
||||
Span<int> corner_edges;
|
||||
const CustomData *vert_data;
|
||||
const CustomData *loop_data;
|
||||
const CustomData *corner_data;
|
||||
const CustomData *face_data;
|
||||
Span<float3> vert_normals;
|
||||
Span<float3> face_normals;
|
||||
|
|
|
@ -446,7 +446,7 @@ static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
const bool is_edit_object = DRW_object_is_in_edit_mode(ob);
|
||||
Mesh *mesh = (Mesh *)ob->data;
|
||||
const bool has_active_object_uvmap = CustomData_get_active_layer(&mesh->loop_data,
|
||||
const bool has_active_object_uvmap = CustomData_get_active_layer(&mesh->corner_data,
|
||||
CD_PROP_FLOAT2) != -1;
|
||||
const bool has_active_edit_uvmap = is_edit_object &&
|
||||
(CustomData_get_active_layer(&mesh->edit_mesh->bm->ldata,
|
||||
|
|
|
@ -188,7 +188,7 @@ static const CustomData *get_loop_custom_data(const Mesh *mesh)
|
|||
BLI_assert(mesh->edit_mesh->bm != nullptr);
|
||||
return &mesh->edit_mesh->bm->ldata;
|
||||
}
|
||||
return &mesh->loop_data;
|
||||
return &mesh->corner_data;
|
||||
}
|
||||
|
||||
static const CustomData *get_vert_custom_data(const Mesh *mesh)
|
||||
|
|
|
@ -355,7 +355,7 @@ const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *mesh)
|
|||
switch (mesh->runtime->wrapper_type) {
|
||||
case ME_WRAPPER_TYPE_SUBD:
|
||||
case ME_WRAPPER_TYPE_MDATA:
|
||||
return &mesh->loop_data;
|
||||
return &mesh->corner_data;
|
||||
break;
|
||||
case ME_WRAPPER_TYPE_BMESH:
|
||||
return &mesh->edit_mesh->bm->ldata;
|
||||
|
@ -363,7 +363,7 @@ const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *mesh)
|
|||
}
|
||||
|
||||
BLI_assert(0);
|
||||
return &mesh->loop_data;
|
||||
return &mesh->corner_data;
|
||||
}
|
||||
|
||||
const CustomData *mesh_cd_pdata_get_from_mesh(const Mesh *mesh)
|
||||
|
|
|
@ -848,22 +848,22 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
|
||||
|
||||
if (psmd != nullptr && psmd->mesh_final != nullptr) {
|
||||
if (CustomData_has_layer(&psmd->mesh_final->loop_data, CD_PROP_FLOAT2)) {
|
||||
cache->num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->loop_data,
|
||||
if (CustomData_has_layer(&psmd->mesh_final->corner_data, CD_PROP_FLOAT2)) {
|
||||
cache->num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
active_uv = CustomData_get_active_layer(&psmd->mesh_final->loop_data, CD_PROP_FLOAT2);
|
||||
render_uv = CustomData_get_render_layer(&psmd->mesh_final->loop_data, CD_PROP_FLOAT2);
|
||||
active_uv = CustomData_get_active_layer(&psmd->mesh_final->corner_data, CD_PROP_FLOAT2);
|
||||
render_uv = CustomData_get_render_layer(&psmd->mesh_final->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
if (CustomData_has_layer(&psmd->mesh_final->loop_data, CD_PROP_BYTE_COLOR)) {
|
||||
cache->num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->loop_data,
|
||||
if (CustomData_has_layer(&psmd->mesh_final->corner_data, CD_PROP_BYTE_COLOR)) {
|
||||
cache->num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->corner_data,
|
||||
CD_PROP_BYTE_COLOR);
|
||||
if (psmd->mesh_final->active_color_attribute != nullptr) {
|
||||
active_col = CustomData_get_named_layer(&psmd->mesh_final->loop_data,
|
||||
active_col = CustomData_get_named_layer(&psmd->mesh_final->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
psmd->mesh_final->active_color_attribute);
|
||||
}
|
||||
if (psmd->mesh_final->default_color_attribute != nullptr) {
|
||||
render_col = CustomData_get_named_layer(&psmd->mesh_final->loop_data,
|
||||
render_col = CustomData_get_named_layer(&psmd->mesh_final->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
psmd->mesh_final->default_color_attribute);
|
||||
}
|
||||
|
@ -913,7 +913,8 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]);
|
||||
|
||||
char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
|
||||
const char *name = CustomData_get_layer_name(&psmd->mesh_final->loop_data, CD_PROP_FLOAT2, i);
|
||||
const char *name = CustomData_get_layer_name(
|
||||
&psmd->mesh_final->corner_data, CD_PROP_FLOAT2, i);
|
||||
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
|
||||
|
||||
int n = 0;
|
||||
|
@ -950,7 +951,7 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
|
|||
|
||||
char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
|
||||
const char *name = CustomData_get_layer_name(
|
||||
&psmd->mesh_final->loop_data, CD_PROP_BYTE_COLOR, i);
|
||||
&psmd->mesh_final->corner_data, CD_PROP_BYTE_COLOR, i);
|
||||
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
|
||||
|
||||
int n = 0;
|
||||
|
@ -1196,15 +1197,15 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
|
|||
MCol **parent_mcol = nullptr;
|
||||
|
||||
if (psmd != nullptr) {
|
||||
if (CustomData_has_layer(&psmd->mesh_final->loop_data, CD_PROP_FLOAT2)) {
|
||||
num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->loop_data, CD_PROP_FLOAT2);
|
||||
active_uv = CustomData_get_active_layer(&psmd->mesh_final->loop_data, CD_PROP_FLOAT2);
|
||||
if (CustomData_has_layer(&psmd->mesh_final->corner_data, CD_PROP_FLOAT2)) {
|
||||
num_uv_layers = CustomData_number_of_layers(&psmd->mesh_final->corner_data, CD_PROP_FLOAT2);
|
||||
active_uv = CustomData_get_active_layer(&psmd->mesh_final->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
if (CustomData_has_layer(&psmd->mesh_final->loop_data, CD_PROP_BYTE_COLOR)) {
|
||||
num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->loop_data,
|
||||
if (CustomData_has_layer(&psmd->mesh_final->corner_data, CD_PROP_BYTE_COLOR)) {
|
||||
num_col_layers = CustomData_number_of_layers(&psmd->mesh_final->corner_data,
|
||||
CD_PROP_BYTE_COLOR);
|
||||
if (psmd->mesh_final->active_color_attribute != nullptr) {
|
||||
active_col = CustomData_get_named_layer(&psmd->mesh_final->loop_data,
|
||||
active_col = CustomData_get_named_layer(&psmd->mesh_final->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
psmd->mesh_final->active_color_attribute);
|
||||
}
|
||||
|
@ -1226,7 +1227,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
|
|||
|
||||
char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
|
||||
const char *name = CustomData_get_layer_name(
|
||||
&psmd->mesh_final->loop_data, CD_PROP_FLOAT2, i);
|
||||
&psmd->mesh_final->corner_data, CD_PROP_FLOAT2, i);
|
||||
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
|
||||
|
||||
SNPRINTF(uuid, "a%s", attr_safe_name);
|
||||
|
@ -1240,7 +1241,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
|
|||
for (int i = 0; i < num_col_layers; i++) {
|
||||
char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
|
||||
const char *name = CustomData_get_layer_name(
|
||||
&psmd->mesh_final->loop_data, CD_PROP_BYTE_COLOR, i);
|
||||
&psmd->mesh_final->corner_data, CD_PROP_BYTE_COLOR, i);
|
||||
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
|
||||
|
||||
SNPRINTF(uuid, "a%s", attr_safe_name);
|
||||
|
|
|
@ -1428,7 +1428,7 @@ void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup,
|
|||
}
|
||||
|
||||
if (use_uv) {
|
||||
if (const char *name = CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2)) {
|
||||
if (const char *name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2)) {
|
||||
attrs.append(pbvh::GenericRequest{name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
|
||||
}
|
||||
}
|
||||
|
@ -1470,8 +1470,8 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
|
|||
/* UV maps are not in attribute requests. */
|
||||
for (uint i = 0; i < 32; i++) {
|
||||
if (cd_needed.uv & (1 << i)) {
|
||||
int layer_i = CustomData_get_layer_index_n(&mesh->loop_data, CD_PROP_FLOAT2, i);
|
||||
CustomDataLayer *layer = layer_i != -1 ? mesh->loop_data.layers + layer_i : nullptr;
|
||||
int layer_i = CustomData_get_layer_index_n(&mesh->corner_data, CD_PROP_FLOAT2, i);
|
||||
CustomDataLayer *layer = layer_i != -1 ? mesh->corner_data.layers + layer_i : nullptr;
|
||||
if (layer) {
|
||||
attrs.append(pbvh::GenericRequest{layer->name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ static const CustomData *get_cdata(eAttrDomain domain, const PBVH_GPU_Args &args
|
|||
case ATTR_DOMAIN_POINT:
|
||||
return args.vert_data;
|
||||
case ATTR_DOMAIN_CORNER:
|
||||
return args.loop_data;
|
||||
return args.corner_data;
|
||||
case ATTR_DOMAIN_FACE:
|
||||
return args.face_data;
|
||||
default:
|
||||
|
|
|
@ -146,7 +146,7 @@ Vector<SculptBatch> sculpt_batches_get(const Object *ob, SculptBatchFeature feat
|
|||
}
|
||||
|
||||
if (features & SCULPT_BATCH_UV) {
|
||||
if (const char *name = CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2)) {
|
||||
if (const char *name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2)) {
|
||||
attrs.append(pbvh::GenericRequest{name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
|
||||
}
|
||||
}
|
||||
|
@ -177,8 +177,8 @@ Vector<SculptBatch> sculpt_batches_per_material_get(const Object *ob,
|
|||
/* UV maps are not in attribute requests. */
|
||||
for (uint i = 0; i < 32; i++) {
|
||||
if (cd_needed.uv & (1 << i)) {
|
||||
int layer_i = CustomData_get_layer_index_n(&mesh->loop_data, CD_PROP_FLOAT2, i);
|
||||
CustomDataLayer *layer = layer_i != -1 ? mesh->loop_data.layers + layer_i : nullptr;
|
||||
int layer_i = CustomData_get_layer_index_n(&mesh->corner_data, CD_PROP_FLOAT2, i);
|
||||
CustomDataLayer *layer = layer_i != -1 ? mesh->corner_data.layers + layer_i : nullptr;
|
||||
if (layer) {
|
||||
attrs.append(pbvh::GenericRequest{layer->name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER});
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ static void extract_edituv_stretch_angle_init(const MeshRenderData &mr,
|
|||
}
|
||||
else {
|
||||
BLI_assert(mr.extract_type == MR_EXTRACT_MESH);
|
||||
data->uv = (const float2 *)CustomData_get_layer(&mr.mesh->loop_data, CD_PROP_FLOAT2);
|
||||
data->uv = (const float2 *)CustomData_get_layer(&mr.mesh->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ static void extract_edituv_stretch_angle_init_subdiv(const DRWSubdivCache &subdi
|
|||
|
||||
/* UVs are stored contiguously so we need to compute the offset in the UVs buffer for the active
|
||||
* UV layer. */
|
||||
CustomData *cd_ldata = (mr.extract_type == MR_EXTRACT_MESH) ? &mr.mesh->loop_data :
|
||||
CustomData *cd_ldata = (mr.extract_type == MR_EXTRACT_MESH) ? &mr.mesh->corner_data :
|
||||
&mr.bm->ldata;
|
||||
|
||||
uint32_t uv_layers = cache.cd_used.uv;
|
||||
|
|
|
@ -75,7 +75,7 @@ static void compute_area_ratio(const MeshRenderData &mr,
|
|||
}
|
||||
else {
|
||||
BLI_assert(mr.extract_type == MR_EXTRACT_MESH);
|
||||
const float2 *uv_data = (const float2 *)CustomData_get_layer(&mr.mesh->loop_data,
|
||||
const float2 *uv_data = (const float2 *)CustomData_get_layer(&mr.mesh->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
for (int face_index = 0; face_index < mr.face_len; face_index++) {
|
||||
const IndexRange face = mr.faces[face_index];
|
||||
|
|
|
@ -50,7 +50,7 @@ static void extract_fdots_uv_init(const MeshRenderData &mr,
|
|||
data->cd_ofs = CustomData_get_offset(&mr.bm->ldata, CD_PROP_FLOAT2);
|
||||
}
|
||||
else {
|
||||
data->uv_data = (const float(*)[2])CustomData_get_layer(&mr.mesh->loop_data, CD_PROP_FLOAT2);
|
||||
data->uv_data = (const float(*)[2])CustomData_get_layer(&mr.mesh->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static void extract_tan_init_common(const MeshRenderData &mr,
|
|||
GPU_vertformat_deinterleave(format);
|
||||
|
||||
CustomData *cd_ldata = (mr.extract_type == MR_EXTRACT_BMESH) ? &mr.bm->ldata :
|
||||
&mr.mesh->loop_data;
|
||||
&mr.mesh->corner_data;
|
||||
CustomData *cd_vdata = (mr.extract_type == MR_EXTRACT_BMESH) ? &mr.bm->vdata :
|
||||
&mr.mesh->vert_data;
|
||||
uint32_t tan_layers = cache.cd_used.tan;
|
||||
|
@ -171,7 +171,7 @@ static void extract_tan_ex_init(const MeshRenderData &mr,
|
|||
GPUVertFetchMode fetch_mode = GPU_FETCH_INT_TO_FLOAT_UNIT;
|
||||
|
||||
GPUVertFormat format = {0};
|
||||
CustomData loop_data;
|
||||
CustomData corner_data;
|
||||
int v_len = 0;
|
||||
int tan_len = 0;
|
||||
bool use_orco_tan;
|
||||
|
@ -181,7 +181,7 @@ static void extract_tan_ex_init(const MeshRenderData &mr,
|
|||
&format,
|
||||
comp_type,
|
||||
fetch_mode,
|
||||
&loop_data,
|
||||
&corner_data,
|
||||
&v_len,
|
||||
&tan_len,
|
||||
tangent_names,
|
||||
|
@ -195,7 +195,7 @@ static void extract_tan_ex_init(const MeshRenderData &mr,
|
|||
for (int i = 0; i < tan_len; i++) {
|
||||
const char *name = tangent_names[i];
|
||||
const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_named(
|
||||
&loop_data, CD_TANGENT, name);
|
||||
&corner_data, CD_TANGENT, name);
|
||||
for (int ml_index = 0; ml_index < mr.loop_len; ml_index++) {
|
||||
normal_float_to_short_v3(*tan_data, layer_data[ml_index]);
|
||||
(*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
|
||||
|
@ -204,7 +204,7 @@ static void extract_tan_ex_init(const MeshRenderData &mr,
|
|||
}
|
||||
if (use_orco_tan) {
|
||||
const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_n(
|
||||
&loop_data, CD_TANGENT, 0);
|
||||
&corner_data, CD_TANGENT, 0);
|
||||
for (int ml_index = 0; ml_index < mr.loop_len; ml_index++) {
|
||||
normal_float_to_short_v3(*tan_data, layer_data[ml_index]);
|
||||
(*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
|
||||
|
@ -217,7 +217,7 @@ static void extract_tan_ex_init(const MeshRenderData &mr,
|
|||
for (int i = 0; i < tan_len; i++) {
|
||||
const char *name = tangent_names[i];
|
||||
const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_named(
|
||||
&loop_data, CD_TANGENT, name);
|
||||
&corner_data, CD_TANGENT, name);
|
||||
for (int ml_index = 0; ml_index < mr.loop_len; ml_index++) {
|
||||
*tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]);
|
||||
tan_data->w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
|
||||
|
@ -226,7 +226,7 @@ static void extract_tan_ex_init(const MeshRenderData &mr,
|
|||
}
|
||||
if (use_orco_tan) {
|
||||
const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_n(
|
||||
&loop_data, CD_TANGENT, 0);
|
||||
&corner_data, CD_TANGENT, 0);
|
||||
for (int ml_index = 0; ml_index < mr.loop_len; ml_index++) {
|
||||
*tan_data = GPU_normal_convert_i10_v3(layer_data[ml_index]);
|
||||
tan_data->w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
|
||||
|
@ -235,7 +235,7 @@ static void extract_tan_ex_init(const MeshRenderData &mr,
|
|||
}
|
||||
}
|
||||
|
||||
CustomData_free(&loop_data, mr.loop_len);
|
||||
CustomData_free(&corner_data, mr.loop_len);
|
||||
}
|
||||
|
||||
static void extract_tan_init(const MeshRenderData &mr,
|
||||
|
@ -265,7 +265,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache &subdiv_cache,
|
|||
GPUVertCompType comp_type = GPU_COMP_F32;
|
||||
GPUVertFetchMode fetch_mode = GPU_FETCH_FLOAT;
|
||||
GPUVertFormat format = {0};
|
||||
CustomData loop_data;
|
||||
CustomData corner_data;
|
||||
int coarse_len = 0;
|
||||
int tan_len = 0;
|
||||
bool use_orco_tan;
|
||||
|
@ -275,7 +275,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache &subdiv_cache,
|
|||
&format,
|
||||
comp_type,
|
||||
fetch_mode,
|
||||
&loop_data,
|
||||
&corner_data,
|
||||
&coarse_len,
|
||||
&tan_len,
|
||||
tangent_names,
|
||||
|
@ -296,7 +296,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache &subdiv_cache,
|
|||
float(*tan_data)[4] = (float(*)[4])GPU_vertbuf_get_data(coarse_vbo);
|
||||
const char *name = tangent_names[i];
|
||||
const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_named(
|
||||
&loop_data, CD_TANGENT, name);
|
||||
&corner_data, CD_TANGENT, name);
|
||||
for (int ml_index = 0; ml_index < mr.loop_len; ml_index++) {
|
||||
copy_v3_v3(*tan_data, layer_data[ml_index]);
|
||||
(*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? 1.0f : -1.0f;
|
||||
|
@ -313,7 +313,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache &subdiv_cache,
|
|||
if (use_orco_tan) {
|
||||
float(*tan_data)[4] = (float(*)[4])GPU_vertbuf_get_data(coarse_vbo);
|
||||
const float(*layer_data)[4] = (const float(*)[4])CustomData_get_layer_n(
|
||||
&loop_data, CD_TANGENT, 0);
|
||||
&corner_data, CD_TANGENT, 0);
|
||||
for (int ml_index = 0; ml_index < mr.loop_len; ml_index++) {
|
||||
copy_v3_v3(*tan_data, layer_data[ml_index]);
|
||||
(*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? 1.0f : -1.0f;
|
||||
|
@ -328,7 +328,7 @@ static void extract_tan_init_subdiv(const DRWSubdivCache &subdiv_cache,
|
|||
subdiv_cache, coarse_vbo, dst_buffer, GPU_COMP_F32, 4, dst_offset);
|
||||
}
|
||||
|
||||
CustomData_free(&loop_data, mr.loop_len);
|
||||
CustomData_free(&corner_data, mr.loop_len);
|
||||
GPU_vertbuf_discard(coarse_vbo);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ static void extract_uv_init(const MeshRenderData &mr,
|
|||
GPUVertFormat format = {0};
|
||||
|
||||
CustomData *cd_ldata = (mr.extract_type == MR_EXTRACT_BMESH) ? &mr.bm->ldata :
|
||||
&mr.mesh->loop_data;
|
||||
&mr.mesh->corner_data;
|
||||
int v_len = mr.loop_len;
|
||||
uint32_t uv_layers = cache.cd_used.uv;
|
||||
if (!mesh_extract_uv_format_init(&format, cache, cd_ldata, mr.extract_type, uv_layers)) {
|
||||
|
@ -143,7 +143,7 @@ static void extract_uv_init_subdiv(const DRWSubdivCache &subdiv_cache,
|
|||
uint v_len = subdiv_cache.num_subdiv_loops;
|
||||
uint uv_layers;
|
||||
if (!mesh_extract_uv_format_init(
|
||||
&format, cache, &coarse_mesh->loop_data, MR_EXTRACT_MESH, uv_layers))
|
||||
&format, cache, &coarse_mesh->corner_data, MR_EXTRACT_MESH, uv_layers))
|
||||
{
|
||||
/* TODO(kevindietrich): handle this more gracefully. */
|
||||
v_len = 1;
|
||||
|
|
|
@ -1154,7 +1154,7 @@ static int surface_set_exec(bContext *C, wmOperator *op)
|
|||
Object &new_surface_ob = *CTX_data_active_object(C);
|
||||
|
||||
Mesh &new_surface_mesh = *static_cast<Mesh *>(new_surface_ob.data);
|
||||
const char *new_uv_map_name = CustomData_get_active_layer_name(&new_surface_mesh.loop_data,
|
||||
const char *new_uv_map_name = CustomData_get_active_layer_name(&new_surface_mesh.corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
|
||||
CTX_DATA_BEGIN (C, Object *, selected_ob, selected_objects) {
|
||||
|
|
|
@ -719,7 +719,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
|
|||
float vec[3], bmat[3][3];
|
||||
|
||||
const Mesh *mesh = BKE_mesh_from_object(ob);
|
||||
if (!mesh || !CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2)) {
|
||||
if (!mesh || !CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2)) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ static void um_arraystore_compact_ex(UndoMesh *um, const UndoMesh *um_ref, bool
|
|||
&um->store.edata);
|
||||
},
|
||||
[&]() {
|
||||
um_arraystore_cd_compact(&mesh->loop_data,
|
||||
um_arraystore_cd_compact(&mesh->corner_data,
|
||||
mesh->corners_num,
|
||||
create,
|
||||
ARRAY_STORE_INDEX_LOOP,
|
||||
|
@ -565,7 +565,7 @@ static void um_arraystore_expand(UndoMesh *um)
|
|||
|
||||
um_arraystore_cd_expand(um->store.vdata, &mesh->vert_data, mesh->verts_num);
|
||||
um_arraystore_cd_expand(um->store.edata, &mesh->edge_data, mesh->edges_num);
|
||||
um_arraystore_cd_expand(um->store.ldata, &mesh->loop_data, mesh->corners_num);
|
||||
um_arraystore_cd_expand(um->store.ldata, &mesh->corner_data, mesh->corners_num);
|
||||
um_arraystore_cd_expand(um->store.pdata, &mesh->face_data, mesh->faces_num);
|
||||
|
||||
if (um->store.keyblocks) {
|
||||
|
|
|
@ -87,7 +87,7 @@ static CustomData *mesh_customdata_get_type(Mesh *mesh, const char htype, int *r
|
|||
tot = bm->totloop;
|
||||
}
|
||||
else {
|
||||
data = &mesh->loop_data;
|
||||
data = &mesh->corner_data;
|
||||
tot = mesh->corners_num;
|
||||
}
|
||||
break;
|
||||
|
@ -203,9 +203,9 @@ void ED_mesh_uv_loop_reset_ex(Mesh *mesh, const int layernum)
|
|||
}
|
||||
else {
|
||||
/* Collect Mesh UVs */
|
||||
BLI_assert(CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2));
|
||||
BLI_assert(CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2));
|
||||
float2 *mloopuv = static_cast<float2 *>(CustomData_get_layer_n_for_write(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, layernum, mesh->corners_num));
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, layernum, mesh->corners_num));
|
||||
|
||||
const blender::OffsetIndices polys = mesh->faces();
|
||||
for (const int i : polys.index_range()) {
|
||||
|
@ -265,17 +265,17 @@ int ED_mesh_uv_add(
|
|||
}
|
||||
}
|
||||
else {
|
||||
layernum_dst = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
layernum_dst = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
if (layernum_dst >= MAX_MTFACE) {
|
||||
BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i UV maps", MAX_MTFACE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2) && do_init) {
|
||||
if (CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2) && do_init) {
|
||||
CustomData_add_layer_named_with_data(
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
CD_PROP_FLOAT2,
|
||||
MEM_dupallocN(CustomData_get_layer(&mesh->loop_data, CD_PROP_FLOAT2)),
|
||||
MEM_dupallocN(CustomData_get_layer(&mesh->corner_data, CD_PROP_FLOAT2)),
|
||||
mesh->corners_num,
|
||||
unique_name,
|
||||
nullptr);
|
||||
|
@ -284,11 +284,11 @@ int ED_mesh_uv_add(
|
|||
}
|
||||
else {
|
||||
CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, unique_name);
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, unique_name);
|
||||
}
|
||||
|
||||
if (active_set || layernum_dst == 0) {
|
||||
CustomData_set_layer_active(&mesh->loop_data, CD_PROP_FLOAT2, layernum_dst);
|
||||
CustomData_set_layer_active(&mesh->corner_data, CD_PROP_FLOAT2, layernum_dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,14 +306,14 @@ int ED_mesh_uv_add(
|
|||
static const bool *mesh_loop_boolean_custom_data_get_by_name(const Mesh &mesh, const char *name)
|
||||
{
|
||||
return static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh.loop_data, CD_PROP_BOOL, name));
|
||||
CustomData_get_layer_named(&mesh.corner_data, CD_PROP_BOOL, name));
|
||||
}
|
||||
|
||||
const bool *ED_mesh_uv_map_vert_select_layer_get(const Mesh *mesh, const int uv_index)
|
||||
{
|
||||
using namespace blender::bke;
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, uv_index);
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, uv_index);
|
||||
return mesh_loop_boolean_custom_data_get_by_name(
|
||||
*mesh, BKE_uv_map_vert_select_name_get(uv_name, buffer));
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ const bool *ED_mesh_uv_map_edge_select_layer_get(const Mesh *mesh, const int uv_
|
|||
|
||||
using namespace blender::bke;
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, uv_index);
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, uv_index);
|
||||
return mesh_loop_boolean_custom_data_get_by_name(
|
||||
*mesh, BKE_uv_map_edge_select_name_get(uv_name, buffer));
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ const bool *ED_mesh_uv_map_pin_layer_get(const Mesh *mesh, const int uv_index)
|
|||
{
|
||||
using namespace blender::bke;
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, uv_index);
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, uv_index);
|
||||
return mesh_loop_boolean_custom_data_get_by_name(*mesh,
|
||||
BKE_uv_map_pin_name_get(uv_name, buffer));
|
||||
}
|
||||
|
@ -341,10 +341,10 @@ const bool *ED_mesh_uv_map_pin_layer_get(const Mesh *mesh, const int uv_index)
|
|||
static bool *ensure_corner_boolean_attribute(Mesh &mesh, const blender::StringRefNull name)
|
||||
{
|
||||
bool *data = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh.loop_data, CD_PROP_BOOL, name.c_str(), mesh.corners_num));
|
||||
&mesh.corner_data, CD_PROP_BOOL, name.c_str(), mesh.corners_num));
|
||||
if (!data) {
|
||||
data = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh.loop_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh.faces_num, name.c_str()));
|
||||
&mesh.corner_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh.faces_num, name.c_str()));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
@ -353,21 +353,21 @@ bool *ED_mesh_uv_map_vert_select_layer_ensure(Mesh *mesh, const int uv_index)
|
|||
{
|
||||
using namespace blender::bke;
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, uv_index);
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, uv_index);
|
||||
return ensure_corner_boolean_attribute(*mesh, BKE_uv_map_vert_select_name_get(uv_name, buffer));
|
||||
}
|
||||
bool *ED_mesh_uv_map_edge_select_layer_ensure(Mesh *mesh, const int uv_index)
|
||||
{
|
||||
using namespace blender::bke;
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, uv_index);
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, uv_index);
|
||||
return ensure_corner_boolean_attribute(*mesh, BKE_uv_map_edge_select_name_get(uv_name, buffer));
|
||||
}
|
||||
bool *ED_mesh_uv_map_pin_layer_ensure(Mesh *mesh, const int uv_index)
|
||||
{
|
||||
using namespace blender::bke;
|
||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, uv_index);
|
||||
const char *uv_name = CustomData_get_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, uv_index);
|
||||
return ensure_corner_boolean_attribute(*mesh, BKE_uv_map_pin_name_get(uv_name, buffer));
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ void ED_mesh_uv_ensure(Mesh *mesh, const char *name)
|
|||
}
|
||||
}
|
||||
else {
|
||||
layernum_dst = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
layernum_dst = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
if (layernum_dst == 0) {
|
||||
ED_mesh_uv_add(mesh, name, true, true, nullptr);
|
||||
}
|
||||
|
@ -730,7 +730,8 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
|
|||
BM_data_layer_add(&bm, &bm.ldata, CD_CUSTOMLOOPNORMAL);
|
||||
}
|
||||
else {
|
||||
CustomData_add_layer(&mesh->loop_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->corners_num);
|
||||
CustomData_add_layer(
|
||||
&mesh->corner_data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, mesh->corners_num);
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&mesh->id, 0);
|
||||
|
@ -862,8 +863,8 @@ static void mesh_add_loops(Mesh *mesh, int len)
|
|||
totloop = mesh->corners_num + len; /* new face count */
|
||||
|
||||
/* update customdata */
|
||||
CustomData_copy_layout(&mesh->loop_data, &ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
|
||||
CustomData_copy_data(&mesh->loop_data, &ldata, 0, 0, mesh->corners_num);
|
||||
CustomData_copy_layout(&mesh->corner_data, &ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
|
||||
CustomData_copy_data(&mesh->corner_data, &ldata, 0, 0, mesh->corners_num);
|
||||
|
||||
if (!CustomData_has_layer_named(&ldata, CD_PROP_INT32, ".corner_vert")) {
|
||||
CustomData_add_layer_named(&ldata, CD_PROP_INT32, CD_SET_DEFAULT, totloop, ".corner_vert");
|
||||
|
@ -874,8 +875,8 @@ static void mesh_add_loops(Mesh *mesh, int len)
|
|||
|
||||
BKE_mesh_runtime_clear_cache(mesh);
|
||||
|
||||
CustomData_free(&mesh->loop_data, mesh->corners_num);
|
||||
mesh->loop_data = ldata;
|
||||
CustomData_free(&mesh->corner_data, mesh->corners_num);
|
||||
mesh->corner_data = ldata;
|
||||
|
||||
mesh->corners_num = totloop;
|
||||
|
||||
|
@ -998,9 +999,9 @@ static void mesh_remove_loops(Mesh *mesh, int len)
|
|||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
CustomData_ensure_layers_are_mutable(&mesh->loop_data, mesh->corners_num);
|
||||
CustomData_ensure_layers_are_mutable(&mesh->corner_data, mesh->corners_num);
|
||||
const int totloop = mesh->corners_num - len;
|
||||
CustomData_free_elem(&mesh->loop_data, totloop, len);
|
||||
CustomData_free_elem(&mesh->corner_data, totloop, len);
|
||||
mesh->corners_num = totloop;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,8 +229,9 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
CustomData_merge_layout(&mesh->loop_data, ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
|
||||
CustomData_copy_data_named(&mesh->loop_data, ldata, 0, *loopofs, mesh->corners_num);
|
||||
CustomData_merge_layout(
|
||||
&mesh->corner_data, ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
|
||||
CustomData_copy_data_named(&mesh->corner_data, ldata, 0, *loopofs, mesh->corners_num);
|
||||
|
||||
for (a = 0; a < mesh->corners_num; a++) {
|
||||
corner_verts[a] += *vertofs;
|
||||
|
@ -664,7 +665,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
|
|||
|
||||
mesh->vert_data = vert_data;
|
||||
mesh->edge_data = edge_data;
|
||||
mesh->loop_data = ldata;
|
||||
mesh->corner_data = ldata;
|
||||
mesh->face_data = face_data;
|
||||
|
||||
/* old material array */
|
||||
|
|
|
@ -2242,7 +2242,8 @@ static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* Decide which UV map to use for attachment. */
|
||||
Mesh *surface_mesh = static_cast<Mesh *>(surface_ob->data);
|
||||
const char *uv_name = CustomData_get_active_layer_name(&surface_mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const char *uv_name = CustomData_get_active_layer_name(&surface_mesh->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
if (uv_name != nullptr) {
|
||||
curves_id->surface_uv_map = BLI_strdup(uv_name);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2)) {
|
||||
if (!CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking");
|
||||
|
||||
ok = false;
|
||||
|
|
|
@ -502,7 +502,7 @@ static bool bake_object_check(const Scene *scene,
|
|||
}
|
||||
}
|
||||
else if (target == R_BAKE_TARGET_IMAGE_TEXTURES) {
|
||||
if (CustomData_get_active_layer_index(&mesh->loop_data, CD_PROP_FLOAT2) == -1) {
|
||||
if (CustomData_get_active_layer_index(&mesh->corner_data, CD_PROP_FLOAT2) == -1) {
|
||||
BKE_reportf(
|
||||
reports, RPT_ERROR, "No active UV layer found in the object \"%s\"", ob->id.name + 2);
|
||||
return false;
|
||||
|
@ -1434,7 +1434,7 @@ static int bake(const BakeAPIRender *bkr,
|
|||
|
||||
if (bkr->uv_layer[0] != '\0') {
|
||||
Mesh *mesh = (Mesh *)ob_low->data;
|
||||
if (CustomData_get_named_layer(&mesh->loop_data, CD_PROP_FLOAT2, bkr->uv_layer) == -1) {
|
||||
if (CustomData_get_named_layer(&mesh->corner_data, CD_PROP_FLOAT2, bkr->uv_layer) == -1) {
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
"No UV layer named \"%s\" found in the object \"%s\"",
|
||||
|
|
|
@ -188,14 +188,14 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C,
|
|||
*r_free = true;
|
||||
return item;
|
||||
}
|
||||
int num_data = CustomData_number_of_layers(&me_eval->loop_data, CD_PROP_FLOAT2);
|
||||
int num_data = CustomData_number_of_layers(&me_eval->corner_data, CD_PROP_FLOAT2);
|
||||
|
||||
RNA_enum_item_add_separator(&item, &totitem);
|
||||
|
||||
for (int i = 0; i < num_data; i++) {
|
||||
tmp_item.value = i;
|
||||
tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(
|
||||
&me_eval->loop_data, CD_PROP_FLOAT2, i);
|
||||
&me_eval->corner_data, CD_PROP_FLOAT2, i);
|
||||
RNA_enum_item_add(&item, &totitem, &tmp_item);
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C,
|
|||
dt_add_vcol_layers(&me_eval->vert_data, cddata_masks.vmask, &item, &totitem);
|
||||
}
|
||||
if (data_type & (DT_TYPE_MLOOPCOL_LOOP | DT_TYPE_MPROPCOL_LOOP)) {
|
||||
dt_add_vcol_layers(&me_eval->loop_data, cddata_masks.lmask, &item, &totitem);
|
||||
dt_add_vcol_layers(&me_eval->corner_data, cddata_masks.lmask, &item, &totitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2416,7 +2416,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (CustomData_external_test(&mesh->loop_data, CD_MDISPS)) {
|
||||
if (CustomData_external_test(&mesh->corner_data, CD_MDISPS)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -2426,8 +2426,9 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
|
|||
BLI_path_rel(filepath, BKE_main_blendfile_path(bmain));
|
||||
}
|
||||
|
||||
CustomData_external_add(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->corners_num, filepath);
|
||||
CustomData_external_write(&mesh->loop_data, &mesh->id, CD_MASK_MESH.lmask, mesh->corners_num, 0);
|
||||
CustomData_external_add(&mesh->corner_data, &mesh->id, CD_MDISPS, mesh->corners_num, filepath);
|
||||
CustomData_external_write(
|
||||
&mesh->corner_data, &mesh->id, CD_MASK_MESH.lmask, mesh->corners_num, 0);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -2449,7 +2450,7 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (CustomData_external_test(&mesh->loop_data, CD_MDISPS)) {
|
||||
if (CustomData_external_test(&mesh->corner_data, CD_MDISPS)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -2502,12 +2503,12 @@ static int multires_external_pack_exec(bContext *C, wmOperator * /*op*/)
|
|||
Object *ob = ED_object_active_context(C);
|
||||
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
|
||||
if (!CustomData_external_test(&mesh->loop_data, CD_MDISPS)) {
|
||||
if (!CustomData_external_test(&mesh->corner_data, CD_MDISPS)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* XXX don't remove. */
|
||||
CustomData_external_remove(&mesh->loop_data, &mesh->id, CD_MDISPS, mesh->corners_num);
|
||||
CustomData_external_remove(&mesh->corner_data, &mesh->id, CD_MDISPS, mesh->corners_num);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -4071,7 +4071,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!CustomData_has_layer(&ps->me_eval->loop_data, CD_PROP_FLOAT2)) {
|
||||
if (!CustomData_has_layer(&ps->me_eval->corner_data, CD_PROP_FLOAT2)) {
|
||||
ps->me_eval = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
@ -4128,7 +4128,7 @@ static void proj_paint_layer_clone_init(ProjPaintState *ps, ProjPaintLayerClone
|
|||
|
||||
/* use clone mtface? */
|
||||
if (ps->do_layer_clone) {
|
||||
const int layer_num = CustomData_get_clone_layer(&((Mesh *)ps->ob->data)->loop_data,
|
||||
const int layer_num = CustomData_get_clone_layer(&((Mesh *)ps->ob->data)->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
|
||||
ps->poly_to_loop_uv_clone = static_cast<const float(**)[2]>(
|
||||
|
@ -4136,13 +4136,13 @@ static void proj_paint_layer_clone_init(ProjPaintState *ps, ProjPaintLayerClone
|
|||
|
||||
if (layer_num != -1) {
|
||||
mloopuv_clone_base = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_n(&ps->me_eval->loop_data, CD_PROP_FLOAT2, layer_num));
|
||||
CustomData_get_layer_n(&ps->me_eval->corner_data, CD_PROP_FLOAT2, layer_num));
|
||||
}
|
||||
|
||||
if (mloopuv_clone_base == nullptr) {
|
||||
/* get active instead */
|
||||
mloopuv_clone_base = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer(&ps->me_eval->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&ps->me_eval->corner_data, CD_PROP_FLOAT2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4172,10 +4172,10 @@ static bool project_paint_clone_face_skip(ProjPaintState *ps,
|
|||
if (lc->slot_clone != lc->slot_last_clone) {
|
||||
if (!lc->slot_clone->uvname ||
|
||||
!(lc->mloopuv_clone_base = static_cast<const float(*)[2]>(CustomData_get_layer_named(
|
||||
&ps->me_eval->loop_data, CD_PROP_FLOAT2, lc->slot_clone->uvname))))
|
||||
&ps->me_eval->corner_data, CD_PROP_FLOAT2, lc->slot_clone->uvname))))
|
||||
{
|
||||
lc->mloopuv_clone_base = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer(&ps->me_eval->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&ps->me_eval->corner_data, CD_PROP_FLOAT2));
|
||||
}
|
||||
lc->slot_last_clone = lc->slot_clone;
|
||||
}
|
||||
|
@ -4358,17 +4358,17 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
|
|||
/* all faces should have a valid slot, reassert here */
|
||||
if (slot == nullptr) {
|
||||
mloopuv_base = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer(&ps->me_eval->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&ps->me_eval->corner_data, CD_PROP_FLOAT2));
|
||||
tpage = ps->canvas_ima;
|
||||
}
|
||||
else {
|
||||
if (slot != slot_last) {
|
||||
if (!slot->uvname ||
|
||||
!(mloopuv_base = static_cast<const float(*)[2]>(CustomData_get_layer_named(
|
||||
&ps->me_eval->loop_data, CD_PROP_FLOAT2, slot->uvname))))
|
||||
&ps->me_eval->corner_data, CD_PROP_FLOAT2, slot->uvname))))
|
||||
{
|
||||
mloopuv_base = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer(&ps->me_eval->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&ps->me_eval->corner_data, CD_PROP_FLOAT2));
|
||||
}
|
||||
slot_last = slot;
|
||||
}
|
||||
|
@ -4547,17 +4547,17 @@ static void project_paint_begin(const bContext *C,
|
|||
|
||||
if (ps->do_layer_stencil || ps->do_stencil_brush) {
|
||||
// int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_PROP_FLOAT2);
|
||||
int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->loop_data,
|
||||
int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
if (layer_num != -1) {
|
||||
ps->mloopuv_stencil_eval = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_n(&ps->me_eval->loop_data, CD_PROP_FLOAT2, layer_num));
|
||||
CustomData_get_layer_n(&ps->me_eval->corner_data, CD_PROP_FLOAT2, layer_num));
|
||||
}
|
||||
|
||||
if (ps->mloopuv_stencil_eval == nullptr) {
|
||||
/* get active instead */
|
||||
ps->mloopuv_stencil_eval = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer(&ps->me_eval->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&ps->me_eval->corner_data, CD_PROP_FLOAT2));
|
||||
}
|
||||
|
||||
if (ps->do_stencil_brush) {
|
||||
|
@ -6466,7 +6466,7 @@ bool ED_paint_proj_mesh_data_check(Scene *scene,
|
|||
}
|
||||
|
||||
mesh = BKE_mesh_from_object(ob);
|
||||
layernum = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
layernum = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
|
||||
if (layernum == 0) {
|
||||
has_uvs = false;
|
||||
|
|
|
@ -321,15 +321,15 @@ static void imapaint_pick_uv(const Mesh *me_eval,
|
|||
|
||||
if (!(slot && slot->uvname &&
|
||||
(mloopuv = static_cast<const float(*)[2]>(CustomData_get_layer_named(
|
||||
&me_eval->loop_data, CD_PROP_FLOAT2, slot->uvname)))))
|
||||
&me_eval->corner_data, CD_PROP_FLOAT2, slot->uvname)))))
|
||||
{
|
||||
mloopuv = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer(&me_eval->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&me_eval->corner_data, CD_PROP_FLOAT2));
|
||||
}
|
||||
}
|
||||
else {
|
||||
mloopuv = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer(&me_eval->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&me_eval->corner_data, CD_PROP_FLOAT2));
|
||||
}
|
||||
|
||||
tri_uv[0] = mloopuv[tris[i][0]];
|
||||
|
@ -417,7 +417,7 @@ void paint_sample_color(
|
|||
uint faceindex;
|
||||
uint faces_num = mesh->faces_num;
|
||||
|
||||
if (CustomData_has_layer(&me_eval->loop_data, CD_PROP_FLOAT2)) {
|
||||
if (CustomData_has_layer(&me_eval->corner_data, CD_PROP_FLOAT2)) {
|
||||
ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph);
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
|
|
@ -154,7 +154,8 @@ static void SCULPT_dynamic_topology_disable_ex(
|
|||
mesh->totface_legacy = 0;
|
||||
CustomData_copy(&geometry->vert_data, &mesh->vert_data, CD_MASK_MESH.vmask, geometry->totvert);
|
||||
CustomData_copy(&geometry->edge_data, &mesh->edge_data, CD_MASK_MESH.emask, geometry->totedge);
|
||||
CustomData_copy(&geometry->loop_data, &mesh->loop_data, CD_MASK_MESH.lmask, geometry->totloop);
|
||||
CustomData_copy(
|
||||
&geometry->corner_data, &mesh->corner_data, CD_MASK_MESH.lmask, geometry->totloop);
|
||||
CustomData_copy(
|
||||
&geometry->face_data, &mesh->face_data, CD_MASK_MESH.pmask, geometry->faces_num);
|
||||
implicit_sharing::copy_shared_pointer(geometry->face_offset_indices,
|
||||
|
@ -328,7 +329,8 @@ enum WarnFlag check_attribute_warning(Scene *scene, Object *ob)
|
|||
if (!dyntopo_supports_customdata_layers({mesh->face_data.layers, mesh->face_data.totlayer})) {
|
||||
flag |= LDATA;
|
||||
}
|
||||
if (!dyntopo_supports_customdata_layers({mesh->loop_data.layers, mesh->loop_data.totlayer})) {
|
||||
if (!dyntopo_supports_customdata_layers({mesh->corner_data.layers, mesh->corner_data.totlayer}))
|
||||
{
|
||||
flag |= LDATA;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ struct NodeGeometry {
|
|||
|
||||
CustomData vert_data;
|
||||
CustomData edge_data;
|
||||
CustomData loop_data;
|
||||
CustomData corner_data;
|
||||
CustomData face_data;
|
||||
int *face_offset_indices;
|
||||
const ImplicitSharingInfo *face_offsets_sharing_info;
|
||||
|
|
|
@ -753,7 +753,8 @@ static void store_geometry_data(NodeGeometry *geometry, Object *object)
|
|||
|
||||
CustomData_copy(&mesh->vert_data, &geometry->vert_data, CD_MASK_MESH.vmask, mesh->verts_num);
|
||||
CustomData_copy(&mesh->edge_data, &geometry->edge_data, CD_MASK_MESH.emask, mesh->edges_num);
|
||||
CustomData_copy(&mesh->loop_data, &geometry->loop_data, CD_MASK_MESH.lmask, mesh->corners_num);
|
||||
CustomData_copy(
|
||||
&mesh->corner_data, &geometry->corner_data, CD_MASK_MESH.lmask, mesh->corners_num);
|
||||
CustomData_copy(&mesh->face_data, &geometry->face_data, CD_MASK_MESH.pmask, mesh->faces_num);
|
||||
implicit_sharing::copy_shared_pointer(mesh->face_offset_indices,
|
||||
mesh->runtime->face_offsets_sharing_info,
|
||||
|
@ -782,7 +783,8 @@ static void restore_geometry_data(NodeGeometry *geometry, Object *object)
|
|||
|
||||
CustomData_copy(&geometry->vert_data, &mesh->vert_data, CD_MASK_MESH.vmask, geometry->totvert);
|
||||
CustomData_copy(&geometry->edge_data, &mesh->edge_data, CD_MASK_MESH.emask, geometry->totedge);
|
||||
CustomData_copy(&geometry->loop_data, &mesh->loop_data, CD_MASK_MESH.lmask, geometry->totloop);
|
||||
CustomData_copy(
|
||||
&geometry->corner_data, &mesh->corner_data, CD_MASK_MESH.lmask, geometry->totloop);
|
||||
CustomData_copy(&geometry->face_data, &mesh->face_data, CD_MASK_MESH.pmask, geometry->faces_num);
|
||||
implicit_sharing::copy_shared_pointer(geometry->face_offset_indices,
|
||||
geometry->face_offsets_sharing_info,
|
||||
|
@ -794,7 +796,7 @@ static void geometry_free_data(NodeGeometry *geometry)
|
|||
{
|
||||
CustomData_free(&geometry->vert_data, geometry->totvert);
|
||||
CustomData_free(&geometry->edge_data, geometry->totedge);
|
||||
CustomData_free(&geometry->loop_data, geometry->totloop);
|
||||
CustomData_free(&geometry->corner_data, geometry->totloop);
|
||||
CustomData_free(&geometry->face_data, geometry->faces_num);
|
||||
implicit_sharing::free_shared_data(&geometry->face_offset_indices,
|
||||
&geometry->face_offsets_sharing_info);
|
||||
|
|
|
@ -91,7 +91,7 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
|
|||
if (ob && ob->type == OB_MESH) {
|
||||
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
|
||||
if (CustomData_get_layer(&mesh->loop_data, CD_PROP_FLOAT2) != nullptr) {
|
||||
if (CustomData_get_layer(&mesh->corner_data, CD_PROP_FLOAT2) != nullptr) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -592,9 +592,9 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||
&mesh->edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh->edges_num, ".edge_verts");
|
||||
blender::MutableSpan<int> face_offsets = mesh->face_offsets_for_write();
|
||||
int *corner_verts = (int *)CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, ".corner_vert");
|
||||
&mesh->corner_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, ".corner_vert");
|
||||
int *corner_edges = (int *)CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, ".corner_edge");
|
||||
&mesh->corner_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, ".corner_edge");
|
||||
int *material_indices = (int *)CustomData_add_layer_named(
|
||||
&mesh->face_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->faces_num, "material_index");
|
||||
blender::float2 *loopsuv[2] = {nullptr};
|
||||
|
@ -602,22 +602,22 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||
if (hasTex) {
|
||||
// First UV layer
|
||||
loopsuv[0] = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvNames[0]));
|
||||
CustomData_set_layer_active(&mesh->loop_data, CD_PROP_FLOAT2, 0);
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvNames[0]));
|
||||
CustomData_set_layer_active(&mesh->corner_data, CD_PROP_FLOAT2, 0);
|
||||
|
||||
// Second UV layer
|
||||
loopsuv[1] = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvNames[1]));
|
||||
CustomData_set_layer_active(&mesh->loop_data, CD_PROP_FLOAT2, 1);
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvNames[1]));
|
||||
CustomData_set_layer_active(&mesh->corner_data, CD_PROP_FLOAT2, 1);
|
||||
}
|
||||
|
||||
// colors and transparency (the latter represented by grayscale colors)
|
||||
MLoopCol *colors = (MLoopCol *)CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, mesh->corners_num, "Color");
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, mesh->corners_num, "Color");
|
||||
MLoopCol *transp = (MLoopCol *)CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, mesh->corners_num, "Alpha");
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, mesh->corners_num, "Alpha");
|
||||
BKE_id_attributes_active_color_set(
|
||||
&mesh->id, CustomData_get_layer_name(&mesh->loop_data, CD_PROP_BYTE_COLOR, 0));
|
||||
&mesh->id, CustomData_get_layer_name(&mesh->corner_data, CD_PROP_BYTE_COLOR, 0));
|
||||
|
||||
mesh->mat = (Material **)MEM_mallocN(sizeof(Material *) * mesh->totcol, "MaterialList");
|
||||
for (const auto item : group->materials.items()) {
|
||||
|
|
|
@ -82,8 +82,8 @@ static Mesh *create_mesh_no_attributes(const Mesh ¶ms_mesh,
|
|||
mesh->corners_num = corners_num;
|
||||
CustomData_free_layer_named(&mesh->vert_data, "position", 0);
|
||||
CustomData_free_layer_named(&mesh->edge_data, ".edge_verts", 0);
|
||||
CustomData_free_layer_named(&mesh->loop_data, ".corner_vert", 0);
|
||||
CustomData_free_layer_named(&mesh->loop_data, ".corner_edge", 0);
|
||||
CustomData_free_layer_named(&mesh->corner_data, ".corner_vert", 0);
|
||||
CustomData_free_layer_named(&mesh->corner_data, ".corner_edge", 0);
|
||||
BKE_mesh_copy_parameters_for_eval(mesh, ¶ms_mesh);
|
||||
return mesh;
|
||||
}
|
||||
|
|
|
@ -1610,7 +1610,7 @@ static Mesh *create_merged_mesh(const Mesh &mesh,
|
|||
if (poly_ctx == OUT_OF_CONTEXT) {
|
||||
int mp_loop_len = src_faces[i].size();
|
||||
CustomData_copy_data(
|
||||
&mesh.loop_data, &result->loop_data, src_faces[i].start(), loop_cur, mp_loop_len);
|
||||
&mesh.corner_data, &result->corner_data, src_faces[i].start(), loop_cur, mp_loop_len);
|
||||
for (; mp_loop_len--; loop_cur++) {
|
||||
dst_corner_verts[loop_cur] = vert_final_map[dst_corner_verts[loop_cur]];
|
||||
dst_corner_edges[loop_cur] = edge_final_map[dst_corner_edges[loop_cur]];
|
||||
|
@ -1634,8 +1634,11 @@ static Mesh *create_merged_mesh(const Mesh &mesh,
|
|||
continue;
|
||||
}
|
||||
do {
|
||||
customdata_weld(
|
||||
&mesh.loop_data, &result->loop_data, group_buffer.data(), iter.group_len, loop_cur);
|
||||
customdata_weld(&mesh.corner_data,
|
||||
&result->corner_data,
|
||||
group_buffer.data(),
|
||||
iter.group_len,
|
||||
loop_cur);
|
||||
dst_corner_verts[loop_cur] = vert_final_map[iter.v];
|
||||
dst_corner_edges[loop_cur] = edge_final_map[iter.e];
|
||||
loop_cur++;
|
||||
|
@ -1668,7 +1671,7 @@ static Mesh *create_merged_mesh(const Mesh &mesh,
|
|||
}
|
||||
do {
|
||||
customdata_weld(
|
||||
&mesh.loop_data, &result->loop_data, group_buffer.data(), iter.group_len, loop_cur);
|
||||
&mesh.corner_data, &result->corner_data, group_buffer.data(), iter.group_len, loop_cur);
|
||||
dst_corner_verts[loop_cur] = vert_final_map[iter.v];
|
||||
dst_corner_edges[loop_cur] = edge_final_map[iter.e];
|
||||
loop_cur++;
|
||||
|
|
|
@ -173,7 +173,7 @@ void debug_randomize_face_order(Mesh *mesh)
|
|||
Array<int> new_face_offsets = make_new_offset_indices(old_faces, old_by_new_map);
|
||||
const OffsetIndices<int> new_faces = new_face_offsets.as_span();
|
||||
|
||||
reorder_customdata_groups(mesh->loop_data, old_faces, new_faces, new_by_old_map);
|
||||
reorder_customdata_groups(mesh->corner_data, old_faces, new_faces, new_by_old_map);
|
||||
|
||||
mesh->face_offsets_for_write().copy_from(new_face_offsets);
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ void ABCGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
|
|||
UVSample uvs_and_indices;
|
||||
|
||||
if (args_.export_params->uvs) {
|
||||
const char *name = get_uv_sample(uvs_and_indices, m_custom_data_config, &mesh->loop_data);
|
||||
const char *name = get_uv_sample(uvs_and_indices, m_custom_data_config, &mesh->corner_data);
|
||||
|
||||
if (!uvs_and_indices.indices.empty() && !uvs_and_indices.uvs.empty()) {
|
||||
OV2fGeomParam::Sample uv_sample;
|
||||
|
@ -241,7 +241,7 @@ void ABCGenericMeshWriter::write_mesh(HierarchyContext &context, Mesh *mesh)
|
|||
|
||||
write_custom_data(abc_poly_mesh_schema_.getArbGeomParams(),
|
||||
m_custom_data_config,
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ void ABCGenericMeshWriter::write_subd(HierarchyContext &context, Mesh *mesh)
|
|||
|
||||
UVSample sample;
|
||||
if (args_.export_params->uvs) {
|
||||
const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->loop_data);
|
||||
const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->corner_data);
|
||||
|
||||
if (!sample.indices.empty() && !sample.uvs.empty()) {
|
||||
OV2fGeomParam::Sample uv_sample;
|
||||
|
@ -308,7 +308,7 @@ void ABCGenericMeshWriter::write_subd(HierarchyContext &context, Mesh *mesh)
|
|||
|
||||
write_custom_data(abc_subdiv_schema_.getArbGeomParams(),
|
||||
m_custom_data_config,
|
||||
&mesh->loop_data,
|
||||
&mesh->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ void ABCGenericMeshWriter::write_arb_geo_params(Mesh *mesh)
|
|||
else {
|
||||
arb_geom_params = abc_poly_mesh_.getSchema().getArbGeomParams();
|
||||
}
|
||||
write_custom_data(arb_geom_params, m_custom_data_config, &mesh->loop_data, CD_PROP_BYTE_COLOR);
|
||||
write_custom_data(arb_geom_params, m_custom_data_config, &mesh->corner_data, CD_PROP_BYTE_COLOR);
|
||||
}
|
||||
|
||||
bool ABCGenericMeshWriter::get_velocities(Mesh *mesh, std::vector<Imath::V3f> &vels)
|
||||
|
|
|
@ -390,7 +390,7 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
|
|||
}
|
||||
|
||||
void *cd_ptr = CustomData_get_layer_named_for_write(
|
||||
&mesh->loop_data, cd_data_type, name, mesh->corners_num);
|
||||
&mesh->corner_data, cd_data_type, name, mesh->corners_num);
|
||||
if (cd_ptr != nullptr) {
|
||||
/* layer already exists, so just return it. */
|
||||
return cd_ptr;
|
||||
|
@ -399,7 +399,7 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
|
|||
/* Create a new layer. */
|
||||
int numloops = mesh->corners_num;
|
||||
cd_ptr = CustomData_add_layer_named(
|
||||
&mesh->loop_data, cd_data_type, CD_SET_DEFAULT, numloops, name);
|
||||
&mesh->corner_data, cd_data_type, CD_SET_DEFAULT, numloops, name);
|
||||
return cd_ptr;
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ CDStreamConfig get_config(Mesh *mesh)
|
|||
config.totvert = mesh->verts_num;
|
||||
config.totloop = mesh->corners_num;
|
||||
config.faces_num = mesh->faces_num;
|
||||
config.loopdata = &mesh->loop_data;
|
||||
config.loopdata = &mesh->corner_data;
|
||||
config.add_customdata_cb = add_customdata_cb;
|
||||
|
||||
return config;
|
||||
|
|
|
@ -31,9 +31,9 @@ static std::string getActiveUVLayerName(Object *ob)
|
|||
{
|
||||
Mesh *mesh = (Mesh *)ob->data;
|
||||
|
||||
int num_layers = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int num_layers = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
if (num_layers) {
|
||||
return std::string(bc_CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2));
|
||||
return std::string(bc_CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2));
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
@ -81,7 +81,7 @@ void GeometryExporter::operator()(Object *ob)
|
|||
/* writes <source> for normal coords */
|
||||
createNormalsSource(geom_id, mesh, nor);
|
||||
|
||||
bool has_uvs = bool(CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2));
|
||||
bool has_uvs = bool(CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2));
|
||||
|
||||
/* writes <source> for uv coords if mesh has uv coords */
|
||||
if (has_uvs) {
|
||||
|
@ -165,7 +165,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *mesh, KeyBlock *kb)
|
|||
/* writes <source> for normal coords */
|
||||
createNormalsSource(geom_id, mesh, nor);
|
||||
|
||||
bool has_uvs = bool(CustomData_has_layer(&mesh->loop_data, CD_PROP_FLOAT2));
|
||||
bool has_uvs = bool(CustomData_has_layer(&mesh->corner_data, CD_PROP_FLOAT2));
|
||||
|
||||
/* writes <source> for uv coords if mesh has uv coords */
|
||||
if (has_uvs) {
|
||||
|
@ -369,8 +369,8 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
|
|||
til.push_back(normals_input);
|
||||
|
||||
/* if mesh has uv coords writes <input> for TEXCOORD */
|
||||
int num_layers = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int active_uv = CustomData_get_active_layer(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int num_layers = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
int active_uv = CustomData_get_active_layer(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
for (int i = 0; i < num_layers; i++) {
|
||||
if (!this->export_settings.get_active_uv_only() || i == active_uv) {
|
||||
|
||||
|
@ -385,13 +385,13 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
|
|||
}
|
||||
}
|
||||
|
||||
int totlayer_mcol = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_BYTE_COLOR);
|
||||
int totlayer_mcol = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_BYTE_COLOR);
|
||||
if (totlayer_mcol > 0) {
|
||||
int map_index = 0;
|
||||
|
||||
for (int a = 0; a < totlayer_mcol; a++) {
|
||||
const char *layer_name = bc_CustomData_get_layer_name(
|
||||
&mesh->loop_data, CD_PROP_BYTE_COLOR, a);
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, a);
|
||||
COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR,
|
||||
makeUrl(makeVertexColorSourceId(geom_id, layer_name)),
|
||||
(has_uvs) ? 3 : 2, /* all color layers have same index order */
|
||||
|
@ -476,7 +476,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *mesh)
|
|||
void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *mesh)
|
||||
{
|
||||
/* Find number of vertex color layers */
|
||||
int totlayer_mcol = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_BYTE_COLOR);
|
||||
int totlayer_mcol = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_BYTE_COLOR);
|
||||
if (totlayer_mcol == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -486,11 +486,12 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *mesh)
|
|||
|
||||
map_index++;
|
||||
const MLoopCol *mloopcol = (const MLoopCol *)CustomData_get_layer_n(
|
||||
&mesh->loop_data, CD_PROP_BYTE_COLOR, a);
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, a);
|
||||
|
||||
COLLADASW::FloatSourceF source(mSW);
|
||||
|
||||
const char *layer_name = bc_CustomData_get_layer_name(&mesh->loop_data, CD_PROP_BYTE_COLOR, a);
|
||||
const char *layer_name = bc_CustomData_get_layer_name(
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, a);
|
||||
std::string layer_id = makeVertexColorSourceId(geom_id, layer_name);
|
||||
source.setId(layer_id);
|
||||
|
||||
|
@ -539,16 +540,16 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *mesh)
|
|||
int totuv = mesh->corners_num;
|
||||
const blender::OffsetIndices faces = mesh->faces();
|
||||
|
||||
int num_layers = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int num_layers = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
|
||||
/* write <source> for each layer
|
||||
* each <source> will get id like meshName + "map-channel-1" */
|
||||
int active_uv_index = CustomData_get_active_layer_index(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int active_uv_index = CustomData_get_active_layer_index(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
for (int a = 0; a < num_layers; a++) {
|
||||
int layer_index = CustomData_get_layer_index_n(&mesh->loop_data, CD_PROP_FLOAT2, a);
|
||||
int layer_index = CustomData_get_layer_index_n(&mesh->corner_data, CD_PROP_FLOAT2, a);
|
||||
if (!this->export_settings.get_active_uv_only() || layer_index == active_uv_index) {
|
||||
const blender::float2 *uv_map = static_cast<const blender::float2 *>(
|
||||
CustomData_get_layer_n(&mesh->loop_data, CD_PROP_FLOAT2, a));
|
||||
CustomData_get_layer_n(&mesh->corner_data, CD_PROP_FLOAT2, a));
|
||||
|
||||
COLLADASW::FloatSourceF source(mSW);
|
||||
std::string layer_id = makeTexcoordSourceId(
|
||||
|
|
|
@ -40,13 +40,13 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial &bind_materia
|
|||
/* Create <bind_vertex_input> for each uv map. */
|
||||
Mesh *mesh = (Mesh *)ob->data;
|
||||
|
||||
int num_layers = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int num_layers = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
|
||||
int map_index = 0;
|
||||
int active_uv_index = CustomData_get_active_layer_index(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int active_uv_index = CustomData_get_active_layer_index(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
for (int b = 0; b < num_layers; b++) {
|
||||
if (!active_uv_only || b == active_uv_index) {
|
||||
const char *name = bc_CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, b);
|
||||
const char *name = bc_CustomData_get_layer_name(&mesh->corner_data, CD_PROP_FLOAT2, b);
|
||||
im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", map_index++));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *mesh)
|
|||
mesh->corners_num = total_loop_count;
|
||||
BKE_mesh_face_offsets_ensure_alloc(mesh);
|
||||
CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, ".corner_vert");
|
||||
&mesh->corner_data, CD_PROP_INT32, CD_SET_DEFAULT, mesh->corners_num, ".corner_vert");
|
||||
|
||||
uint totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
|
||||
for (int i = 0; i < totuvset; i++) {
|
||||
|
@ -473,10 +473,10 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *mesh)
|
|||
COLLADAFW::String &uvname = info->mName;
|
||||
/* Allocate space for UV_data */
|
||||
CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvname.c_str());
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvname.c_str());
|
||||
}
|
||||
/* activate the first uv map */
|
||||
CustomData_set_layer_active(&mesh->loop_data, CD_PROP_FLOAT2, 0);
|
||||
CustomData_set_layer_active(&mesh->corner_data, CD_PROP_FLOAT2, 0);
|
||||
}
|
||||
|
||||
int totcolset = collada_mesh->getColors().getInputInfosArray().getCount();
|
||||
|
@ -485,16 +485,16 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *mesh)
|
|||
COLLADAFW::MeshVertexData::InputInfos *info =
|
||||
collada_mesh->getColors().getInputInfosArray()[i];
|
||||
COLLADAFW::String colname = extract_vcolname(info->mName);
|
||||
CustomData_add_layer_named(&mesh->loop_data,
|
||||
CustomData_add_layer_named(&mesh->corner_data,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
CD_SET_DEFAULT,
|
||||
mesh->corners_num,
|
||||
colname.c_str());
|
||||
}
|
||||
BKE_id_attributes_active_color_set(
|
||||
&mesh->id, CustomData_get_layer_name(&mesh->loop_data, CD_PROP_BYTE_COLOR, 0));
|
||||
&mesh->id, CustomData_get_layer_name(&mesh->corner_data, CD_PROP_BYTE_COLOR, 0));
|
||||
BKE_id_attributes_default_color_set(
|
||||
&mesh->id, CustomData_get_layer_name(&mesh->loop_data, CD_PROP_BYTE_COLOR, 0));
|
||||
&mesh->id, CustomData_get_layer_name(&mesh->corner_data, CD_PROP_BYTE_COLOR, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
|
|||
uvset_index++) {
|
||||
COLLADAFW::IndexList &index_list = *index_list_array_uvcoord[uvset_index];
|
||||
blender::float2 *mloopuv = static_cast<blender::float2 *>(
|
||||
CustomData_get_layer_named_for_write(&mesh->loop_data,
|
||||
CustomData_get_layer_named_for_write(&mesh->corner_data,
|
||||
CD_PROP_FLOAT2,
|
||||
index_list.getName().c_str(),
|
||||
mesh->corners_num));
|
||||
|
@ -766,7 +766,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
|
|||
COLLADAFW::IndexList &color_index_list = *mp->getColorIndices(vcolor_index);
|
||||
COLLADAFW::String colname = extract_vcolname(color_index_list.getName());
|
||||
MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_named_for_write(
|
||||
&mesh->loop_data, CD_PROP_BYTE_COLOR, colname.c_str(), mesh->corners_num);
|
||||
&mesh->corner_data, CD_PROP_BYTE_COLOR, colname.c_str(), mesh->corners_num);
|
||||
if (mloopcol == nullptr) {
|
||||
fprintf(stderr,
|
||||
"Collada import: Mesh [%s] : Unknown reference to VCOLOR [#%s].\n",
|
||||
|
|
|
@ -365,7 +365,7 @@ bool bc_is_root_bone(Bone *aBone, bool deform_bones_only)
|
|||
int bc_get_active_UVLayer(Object *ob)
|
||||
{
|
||||
Mesh *mesh = (Mesh *)ob->data;
|
||||
return CustomData_get_active_layer_index(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
return CustomData_get_active_layer_index(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
}
|
||||
|
||||
std::string bc_url_encode(std::string data)
|
||||
|
@ -1066,9 +1066,10 @@ void bc_copy_m4d_v44(double (&r)[4][4], std::vector<std::vector<double>> &a)
|
|||
*/
|
||||
static std::string bc_get_active_uvlayer_name(Mesh *mesh)
|
||||
{
|
||||
int num_layers = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int num_layers = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
if (num_layers) {
|
||||
const char *layer_name = bc_CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const char *layer_name = bc_CustomData_get_active_layer_name(&mesh->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
if (layer_name) {
|
||||
return std::string(layer_name);
|
||||
}
|
||||
|
@ -1091,9 +1092,10 @@ static std::string bc_get_active_uvlayer_name(Object *ob)
|
|||
*/
|
||||
static std::string bc_get_uvlayer_name(Mesh *mesh, int layer)
|
||||
{
|
||||
int num_layers = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
int num_layers = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
if (num_layers && layer < num_layers) {
|
||||
const char *layer_name = bc_CustomData_get_layer_name(&mesh->loop_data, CD_PROP_FLOAT2, layer);
|
||||
const char *layer_name = bc_CustomData_get_layer_name(
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, layer);
|
||||
if (layer_name) {
|
||||
return std::string(layer_name);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ static void generate_vertex_map(const Mesh *mesh,
|
|||
bool export_uv = false;
|
||||
VArraySpan<float2> uv_map;
|
||||
if (export_params.export_uv) {
|
||||
const StringRef uv_name = CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const StringRef uv_name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
if (!uv_name.is_empty()) {
|
||||
const bke::AttributeAccessor attributes = mesh->attributes();
|
||||
uv_map = *attributes.lookup<float2>(uv_name, ATTR_DOMAIN_CORNER);
|
||||
|
@ -173,7 +173,7 @@ static void load_custom_attributes(const Mesh *mesh,
|
|||
{
|
||||
const bke::AttributeAccessor attributes = mesh->attributes();
|
||||
const StringRef color_name = mesh->active_color_attribute;
|
||||
const StringRef uv_name = CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const StringRef uv_name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
const int64_t size = ply_to_vertex.size();
|
||||
|
||||
attributes.for_all([&](const bke::AttributeIDRef &attribute_id,
|
||||
|
|
|
@ -375,7 +375,7 @@ void MeshData::write_submeshes(const Mesh *mesh)
|
|||
const Span<int> tri_faces = mesh->corner_tri_faces();
|
||||
const std::pair<bke::MeshNormalDomain, Span<float3>> normals = get_mesh_normals(*mesh);
|
||||
const bke::AttributeAccessor attributes = mesh->attributes();
|
||||
const StringRef active_uv = CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const StringRef active_uv = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
const VArraySpan uv_map = *attributes.lookup<float2>(active_uv, ATTR_DOMAIN_CORNER);
|
||||
const VArraySpan material_indices = *attributes.lookup<int>("material_index", ATTR_DOMAIN_FACE);
|
||||
|
||||
|
|
|
@ -993,10 +993,10 @@ void USDMeshReader::read_custom_data(const ImportSettings *settings,
|
|||
|
||||
if (!active_uv_set_name.IsEmpty()) {
|
||||
int layer_index = CustomData_get_named_layer_index(
|
||||
&mesh->loop_data, CD_PROP_FLOAT2, active_uv_set_name.GetText());
|
||||
&mesh->corner_data, CD_PROP_FLOAT2, active_uv_set_name.GetText());
|
||||
if (layer_index > -1) {
|
||||
CustomData_set_layer_active_index(&mesh->loop_data, CD_PROP_FLOAT2, layer_index);
|
||||
CustomData_set_layer_render_index(&mesh->loop_data, CD_PROP_FLOAT2, layer_index);
|
||||
CustomData_set_layer_active_index(&mesh->corner_data, CD_PROP_FLOAT2, layer_index);
|
||||
CustomData_set_layer_render_index(&mesh->corner_data, CD_PROP_FLOAT2, layer_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ static std::string get_mesh_active_uvlayer_name(const Object *ob)
|
|||
|
||||
const Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
|
||||
const char *name = CustomData_get_active_layer_name(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const char *name = CustomData_get_active_layer_name(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
|
||||
return name ? name : "";
|
||||
}
|
||||
|
|
|
@ -119,10 +119,10 @@ void USDGenericMeshWriter::write_custom_data(const Mesh *mesh, pxr::UsdGeomMesh
|
|||
const bke::AttributeAccessor attributes = mesh->attributes();
|
||||
|
||||
char *active_set_name = nullptr;
|
||||
const int active_uv_set_index = CustomData_get_render_layer_index(&mesh->loop_data,
|
||||
const int active_uv_set_index = CustomData_get_render_layer_index(&mesh->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
if (active_uv_set_index != -1) {
|
||||
active_set_name = mesh->loop_data.layers[active_uv_set_index].name;
|
||||
active_set_name = mesh->corner_data.layers[active_uv_set_index].name;
|
||||
}
|
||||
|
||||
attributes.for_all(
|
||||
|
|
|
@ -268,7 +268,7 @@ Span<int> OBJMesh::calc_poly_vertex_indices(const int face_index) const
|
|||
|
||||
void OBJMesh::store_uv_coords_and_indices()
|
||||
{
|
||||
const StringRef active_uv_name = CustomData_get_active_layer_name(&export_mesh_->loop_data,
|
||||
const StringRef active_uv_name = CustomData_get_active_layer_name(&export_mesh_->corner_data,
|
||||
CD_PROP_FLOAT2);
|
||||
if (active_uv_name.is_empty()) {
|
||||
uv_coords_.clear();
|
||||
|
|
|
@ -143,7 +143,7 @@ class obj_importer_test : public BlendfileLoadingBaseTest {
|
|||
float3 normal_first = lnors != nullptr ? lnors[0] : float3(0, 0, 0);
|
||||
EXPECT_V3_NEAR(normal_first, exp.normal_first, 0.0001f);
|
||||
const float2 *mloopuv = static_cast<const float2 *>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_PROP_FLOAT2));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_PROP_FLOAT2));
|
||||
float2 uv_first = mloopuv ? *mloopuv : float2(0, 0);
|
||||
EXPECT_V2_NEAR(uv_first, exp.uv_first, 0.0001f);
|
||||
if (exp.color_first.x >= 0) {
|
||||
|
|
|
@ -76,7 +76,7 @@ typedef struct Mesh {
|
|||
int edges_num;
|
||||
/** The number of polygons/faces in the mesh, and the size of #face_data. */
|
||||
int faces_num;
|
||||
/** The number of face corners in the mesh, and the size of #loop_data. */
|
||||
/** The number of face corners in the mesh, and the size of #corner_data. */
|
||||
int corners_num;
|
||||
|
||||
/**
|
||||
|
@ -90,7 +90,7 @@ typedef struct Mesh {
|
|||
CustomData vert_data;
|
||||
CustomData edge_data;
|
||||
CustomData face_data;
|
||||
CustomData loop_data;
|
||||
CustomData corner_data;
|
||||
|
||||
/**
|
||||
* List of vertex group (#bDeformGroup) names and flags only. Actual weights are stored in dvert.
|
||||
|
|
|
@ -111,7 +111,7 @@ DNA_STRUCT_RENAME_ELEM(MaskLayer, restrictflag, visibility_flag)
|
|||
DNA_STRUCT_RENAME_ELEM(MaterialLineArt, transparency_mask, material_mask_bits)
|
||||
DNA_STRUCT_RENAME_ELEM(Mesh, edata, edge_data)
|
||||
DNA_STRUCT_RENAME_ELEM(Mesh, fdata, fdata_legacy)
|
||||
DNA_STRUCT_RENAME_ELEM(Mesh, ldata, loop_data)
|
||||
DNA_STRUCT_RENAME_ELEM(Mesh, ldata, corner_data)
|
||||
DNA_STRUCT_RENAME_ELEM(Mesh, loc, texspace_location)
|
||||
DNA_STRUCT_RENAME_ELEM(Mesh, pdata, face_data)
|
||||
DNA_STRUCT_RENAME_ELEM(Mesh, poly_offset_indices, face_offset_indices)
|
||||
|
|
|
@ -87,7 +87,7 @@ static CustomData *rna_mesh_vdata_helper(Mesh *mesh)
|
|||
|
||||
static CustomData *rna_mesh_ldata_helper(Mesh *mesh)
|
||||
{
|
||||
return (mesh->edit_mesh) ? &mesh->edit_mesh->bm->ldata : &mesh->loop_data;
|
||||
return (mesh->edit_mesh) ? &mesh->edit_mesh->bm->ldata : &mesh->corner_data;
|
||||
}
|
||||
|
||||
static CustomData *rna_mesh_vdata(const PointerRNA *ptr)
|
||||
|
@ -499,7 +499,7 @@ static void rna_MeshLoop_tangent_get(PointerRNA *ptr, float *values)
|
|||
Mesh *mesh = rna_mesh(ptr);
|
||||
const int index = rna_MeshLoop_index_get(ptr);
|
||||
const float(*layer)[4] = static_cast<const float(*)[4]>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_MLOOPTANGENT));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_MLOOPTANGENT));
|
||||
|
||||
if (!layer) {
|
||||
zero_v3(values);
|
||||
|
@ -514,7 +514,7 @@ static float rna_MeshLoop_bitangent_sign_get(PointerRNA *ptr)
|
|||
Mesh *mesh = rna_mesh(ptr);
|
||||
const int index = rna_MeshLoop_index_get(ptr);
|
||||
const float(*vec)[4] = static_cast<const float(*)[4]>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_MLOOPTANGENT));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_MLOOPTANGENT));
|
||||
|
||||
return (vec) ? vec[index][3] : 0.0f;
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ static void rna_MeshLoop_bitangent_get(PointerRNA *ptr, float *values)
|
|||
Mesh *mesh = rna_mesh(ptr);
|
||||
const int index = rna_MeshLoop_index_get(ptr);
|
||||
const float(*vec)[4] = static_cast<const float(*)[4]>(
|
||||
CustomData_get_layer(&mesh->loop_data, CD_MLOOPTANGENT));
|
||||
CustomData_get_layer(&mesh->corner_data, CD_MLOOPTANGENT));
|
||||
|
||||
if (vec) {
|
||||
cross_v3_v3v3(values, mesh->corner_normals()[index], vec[index]);
|
||||
|
@ -952,10 +952,10 @@ static int rna_MeshUVLoopLayer_data_length(PointerRNA *ptr)
|
|||
static MBoolProperty *MeshUVLoopLayer_get_bool_layer(Mesh *mesh, char const *name)
|
||||
{
|
||||
void *layer = CustomData_get_layer_named_for_write(
|
||||
&mesh->loop_data, CD_PROP_BOOL, name, mesh->corners_num);
|
||||
&mesh->corner_data, CD_PROP_BOOL, name, mesh->corners_num);
|
||||
if (layer == nullptr) {
|
||||
layer = CustomData_add_layer_named(
|
||||
&mesh->loop_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name);
|
||||
&mesh->corner_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name);
|
||||
}
|
||||
|
||||
BLI_assert(layer);
|
||||
|
@ -1715,10 +1715,10 @@ static bool get_uv_index_and_layer(const PointerRNA *ptr,
|
|||
const blender::float2 *uv_coord = static_cast<const blender::float2 *>(ptr->data);
|
||||
|
||||
/* We don't know from which attribute the RNA pointer is from, so we need to scan them all. */
|
||||
const int uv_layers_num = CustomData_number_of_layers(&mesh->loop_data, CD_PROP_FLOAT2);
|
||||
const int uv_layers_num = CustomData_number_of_layers(&mesh->corner_data, CD_PROP_FLOAT2);
|
||||
for (int layer_i = 0; layer_i < uv_layers_num; layer_i++) {
|
||||
const blender::float2 *layer_data = static_cast<const blender::float2 *>(
|
||||
CustomData_get_layer_n(&mesh->loop_data, CD_PROP_FLOAT2, layer_i));
|
||||
CustomData_get_layer_n(&mesh->corner_data, CD_PROP_FLOAT2, layer_i));
|
||||
const ptrdiff_t index = uv_coord - layer_data;
|
||||
if (index >= 0 && index < mesh->corners_num) {
|
||||
*r_uv_map_index = layer_i;
|
||||
|
@ -3054,7 +3054,7 @@ static void rna_def_mesh(BlenderRNA *brna)
|
|||
|
||||
/* UV loop layers */
|
||||
prop = RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_collection_sdna(prop, nullptr, "loop_data.layers", "loop_data.totlayer");
|
||||
RNA_def_property_collection_sdna(prop, nullptr, "corner_data.layers", "corner_data.totlayer");
|
||||
RNA_def_property_collection_funcs(prop,
|
||||
"rna_Mesh_uv_layers_begin",
|
||||
nullptr,
|
||||
|
@ -3104,7 +3104,7 @@ static void rna_def_mesh(BlenderRNA *brna)
|
|||
/* Vertex colors */
|
||||
|
||||
prop = RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_collection_sdna(prop, nullptr, "loop_data.layers", "loop_data.totlayer");
|
||||
RNA_def_property_collection_sdna(prop, nullptr, "corner_data.layers", "corner_data.totlayer");
|
||||
RNA_def_property_collection_funcs(prop,
|
||||
"rna_Mesh_vertex_colors_begin",
|
||||
nullptr,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue