forked from blender/blender
main sync #3
@ -233,15 +233,26 @@ void CustomData_free_temporary(struct CustomData *data, int totelem);
|
|||||||
* backed by an external data array. the different allocation types are
|
* backed by an external data array. the different allocation types are
|
||||||
* defined above. returns the data of the layer.
|
* defined above. returns the data of the layer.
|
||||||
*/
|
*/
|
||||||
void *CustomData_add_layer(
|
void *CustomData_add_layer(struct CustomData *data,
|
||||||
struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem);
|
eCustomDataType type,
|
||||||
|
eCDAllocType alloctype,
|
||||||
|
int totelem);
|
||||||
|
const void *CustomData_add_layer_with_data(struct CustomData *data,
|
||||||
|
eCustomDataType type,
|
||||||
|
void *layer_data,
|
||||||
|
int totelem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as above but accepts a name.
|
* Same as above but accepts a name.
|
||||||
*/
|
*/
|
||||||
void *CustomData_add_layer_named(struct CustomData *data,
|
void *CustomData_add_layer_named(struct CustomData *data,
|
||||||
int type,
|
eCustomDataType type,
|
||||||
eCDAllocType alloctype,
|
eCDAllocType alloctype,
|
||||||
void *layer,
|
int totelem,
|
||||||
|
const char *name);
|
||||||
|
const void *CustomData_add_layer_named_with_data(struct CustomData *data,
|
||||||
|
eCustomDataType type,
|
||||||
|
void *layer_data,
|
||||||
int totelem,
|
int totelem,
|
||||||
const char *name);
|
const char *name);
|
||||||
void *CustomData_add_layer_anonymous(struct CustomData *data,
|
void *CustomData_add_layer_anonymous(struct CustomData *data,
|
||||||
|
@ -798,7 +798,7 @@ BLI_INLINE int *BKE_mesh_material_indices_for_write(Mesh *mesh)
|
|||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
return (int *)CustomData_add_layer_named(
|
return (int *)CustomData_add_layer_named(
|
||||||
&mesh->pdata, CD_PROP_INT32, CD_SET_DEFAULT, NULL, mesh->totpoly, "material_index");
|
&mesh->pdata, CD_PROP_INT32, CD_SET_DEFAULT, mesh->totpoly, "material_index");
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_INLINE const float (*BKE_mesh_vert_positions(const Mesh *mesh))[3]
|
BLI_INLINE const float (*BKE_mesh_vert_positions(const Mesh *mesh))[3]
|
||||||
@ -850,7 +850,7 @@ BLI_INLINE MDeformVert *BKE_mesh_deform_verts_for_write(Mesh *mesh)
|
|||||||
return dvert;
|
return dvert;
|
||||||
}
|
}
|
||||||
return (MDeformVert *)CustomData_add_layer(
|
return (MDeformVert *)CustomData_add_layer(
|
||||||
&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, mesh->totvert);
|
&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, mesh->totvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -99,7 +99,7 @@ static float *dm_getVertArray(DerivedMesh *dm)
|
|||||||
|
|
||||||
if (!positions) {
|
if (!positions) {
|
||||||
positions = (float(*)[3])CustomData_add_layer_named(
|
positions = (float(*)[3])CustomData_add_layer_named(
|
||||||
&dm->vertData, CD_PROP_FLOAT3, CD_SET_DEFAULT, nullptr, dm->getNumVerts(dm), "position");
|
&dm->vertData, CD_PROP_FLOAT3, CD_SET_DEFAULT, dm->getNumVerts(dm), "position");
|
||||||
CustomData_set_layer_flag(&dm->vertData, CD_PROP_FLOAT3, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(&dm->vertData, CD_PROP_FLOAT3, CD_FLAG_TEMPORARY);
|
||||||
dm->copyVertArray(dm, positions);
|
dm->copyVertArray(dm, positions);
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ static MEdge *dm_getEdgeArray(DerivedMesh *dm)
|
|||||||
|
|
||||||
if (!edge) {
|
if (!edge) {
|
||||||
edge = (MEdge *)CustomData_add_layer(
|
edge = (MEdge *)CustomData_add_layer(
|
||||||
&dm->edgeData, CD_MEDGE, CD_SET_DEFAULT, nullptr, dm->getNumEdges(dm));
|
&dm->edgeData, CD_MEDGE, CD_SET_DEFAULT, dm->getNumEdges(dm));
|
||||||
CustomData_set_layer_flag(&dm->edgeData, CD_MEDGE, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(&dm->edgeData, CD_MEDGE, CD_FLAG_TEMPORARY);
|
||||||
dm->copyEdgeArray(dm, edge);
|
dm->copyEdgeArray(dm, edge);
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ static MLoop *dm_getLoopArray(DerivedMesh *dm)
|
|||||||
|
|
||||||
if (!mloop) {
|
if (!mloop) {
|
||||||
mloop = (MLoop *)CustomData_add_layer(
|
mloop = (MLoop *)CustomData_add_layer(
|
||||||
&dm->loopData, CD_MLOOP, CD_SET_DEFAULT, nullptr, dm->getNumLoops(dm));
|
&dm->loopData, CD_MLOOP, CD_SET_DEFAULT, dm->getNumLoops(dm));
|
||||||
CustomData_set_layer_flag(&dm->loopData, CD_MLOOP, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(&dm->loopData, CD_MLOOP, CD_FLAG_TEMPORARY);
|
||||||
dm->copyLoopArray(dm, mloop);
|
dm->copyLoopArray(dm, mloop);
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ static MPoly *dm_getPolyArray(DerivedMesh *dm)
|
|||||||
|
|
||||||
if (!mpoly) {
|
if (!mpoly) {
|
||||||
mpoly = (MPoly *)CustomData_add_layer(
|
mpoly = (MPoly *)CustomData_add_layer(
|
||||||
&dm->polyData, CD_MPOLY, CD_SET_DEFAULT, nullptr, dm->getNumPolys(dm));
|
&dm->polyData, CD_MPOLY, CD_SET_DEFAULT, dm->getNumPolys(dm));
|
||||||
CustomData_set_layer_flag(&dm->polyData, CD_MPOLY, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(&dm->polyData, CD_MPOLY, CD_FLAG_TEMPORARY);
|
||||||
dm->copyPolyArray(dm, mpoly);
|
dm->copyPolyArray(dm, mpoly);
|
||||||
}
|
}
|
||||||
@ -505,7 +505,7 @@ static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orc
|
|||||||
layerorco = (float(*)[3])CustomData_get_layer_for_write(&mesh->vdata, layer, mesh->totvert);
|
layerorco = (float(*)[3])CustomData_get_layer_for_write(&mesh->vdata, layer, mesh->totvert);
|
||||||
if (!layerorco) {
|
if (!layerorco) {
|
||||||
layerorco = (float(*)[3])CustomData_add_layer(
|
layerorco = (float(*)[3])CustomData_add_layer(
|
||||||
&mesh->vdata, layer, CD_SET_DEFAULT, nullptr, mesh->totvert);
|
&mesh->vdata, eCustomDataType(layer), CD_SET_DEFAULT, mesh->totvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(layerorco, orco, sizeof(float[3]) * totvert);
|
memcpy(layerorco, orco, sizeof(float[3]) * totvert);
|
||||||
@ -886,11 +886,11 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||||||
((nextmask.vmask | nextmask.emask | nextmask.pmask) & CD_MASK_ORIGINDEX)) {
|
((nextmask.vmask | nextmask.emask | nextmask.pmask) & CD_MASK_ORIGINDEX)) {
|
||||||
/* calc */
|
/* calc */
|
||||||
CustomData_add_layer(
|
CustomData_add_layer(
|
||||||
&mesh_final->vdata, CD_ORIGINDEX, CD_CONSTRUCT, nullptr, mesh_final->totvert);
|
&mesh_final->vdata, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->totvert);
|
||||||
CustomData_add_layer(
|
CustomData_add_layer(
|
||||||
&mesh_final->edata, CD_ORIGINDEX, CD_CONSTRUCT, nullptr, mesh_final->totedge);
|
&mesh_final->edata, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->totedge);
|
||||||
CustomData_add_layer(
|
CustomData_add_layer(
|
||||||
&mesh_final->pdata, CD_ORIGINDEX, CD_CONSTRUCT, nullptr, mesh_final->totpoly);
|
&mesh_final->pdata, CD_ORIGINDEX, CD_CONSTRUCT, mesh_final->totpoly);
|
||||||
|
|
||||||
/* Not worth parallelizing this,
|
/* Not worth parallelizing this,
|
||||||
* gives less than 0.1% overall speedup in best of best cases... */
|
* gives less than 0.1% overall speedup in best of best cases... */
|
||||||
@ -929,11 +929,8 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||||||
/* add an origspace layer if needed */
|
/* add an origspace layer if needed */
|
||||||
if ((md_datamask->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
|
if ((md_datamask->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
|
||||||
if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
|
if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
|
||||||
CustomData_add_layer(&mesh_final->ldata,
|
CustomData_add_layer(
|
||||||
CD_ORIGSPACE_MLOOP,
|
&mesh_final->ldata, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->totloop);
|
||||||
CD_SET_DEFAULT,
|
|
||||||
nullptr,
|
|
||||||
mesh_final->totloop);
|
|
||||||
mesh_init_origspace(mesh_final);
|
mesh_init_origspace(mesh_final);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1380,11 +1377,8 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
|
|||||||
|
|
||||||
if (mask.lmask & CD_MASK_ORIGSPACE_MLOOP) {
|
if (mask.lmask & CD_MASK_ORIGSPACE_MLOOP) {
|
||||||
if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
|
if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
|
||||||
CustomData_add_layer(&mesh_final->ldata,
|
CustomData_add_layer(
|
||||||
CD_ORIGSPACE_MLOOP,
|
&mesh_final->ldata, CD_ORIGSPACE_MLOOP, CD_SET_DEFAULT, mesh_final->totloop);
|
||||||
CD_SET_DEFAULT,
|
|
||||||
nullptr,
|
|
||||||
mesh_final->totloop);
|
|
||||||
mesh_init_origspace(mesh_final);
|
mesh_init_origspace(mesh_final);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,18 +181,15 @@ static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data
|
|||||||
{
|
{
|
||||||
switch (initializer.type) {
|
switch (initializer.type) {
|
||||||
case AttributeInit::Type::Construct: {
|
case AttributeInit::Type::Construct: {
|
||||||
void *data = CustomData_add_layer(
|
void *data = CustomData_add_layer(&custom_data, data_type, CD_CONSTRUCT, domain_num);
|
||||||
&custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num);
|
|
||||||
return data != nullptr;
|
return data != nullptr;
|
||||||
}
|
}
|
||||||
case AttributeInit::Type::DefaultValue: {
|
case AttributeInit::Type::DefaultValue: {
|
||||||
void *data = CustomData_add_layer(
|
void *data = CustomData_add_layer(&custom_data, data_type, CD_SET_DEFAULT, domain_num);
|
||||||
&custom_data, data_type, CD_SET_DEFAULT, nullptr, domain_num);
|
|
||||||
return data != nullptr;
|
return data != nullptr;
|
||||||
}
|
}
|
||||||
case AttributeInit::Type::VArray: {
|
case AttributeInit::Type::VArray: {
|
||||||
void *data = CustomData_add_layer(
|
void *data = CustomData_add_layer(&custom_data, data_type, CD_CONSTRUCT, domain_num);
|
||||||
&custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num);
|
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -202,8 +199,8 @@ static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data
|
|||||||
}
|
}
|
||||||
case AttributeInit::Type::MoveArray: {
|
case AttributeInit::Type::MoveArray: {
|
||||||
void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
|
void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
|
||||||
void *data = CustomData_add_layer(
|
const void *data = CustomData_add_layer_with_data(
|
||||||
&custom_data, data_type, CD_ASSIGN, source_data, domain_num);
|
&custom_data, data_type, source_data, domain_num);
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
MEM_freeN(source_data);
|
MEM_freeN(source_data);
|
||||||
return false;
|
return false;
|
||||||
@ -219,19 +216,36 @@ static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data
|
|||||||
static void *add_generic_custom_data_layer(CustomData &custom_data,
|
static void *add_generic_custom_data_layer(CustomData &custom_data,
|
||||||
const eCustomDataType data_type,
|
const eCustomDataType data_type,
|
||||||
const eCDAllocType alloctype,
|
const eCDAllocType alloctype,
|
||||||
void *layer_data,
|
const int domain_size,
|
||||||
const int domain_num,
|
|
||||||
const AttributeIDRef &attribute_id)
|
const AttributeIDRef &attribute_id)
|
||||||
{
|
{
|
||||||
if (!attribute_id.is_anonymous()) {
|
if (!attribute_id.is_anonymous()) {
|
||||||
char attribute_name_c[MAX_CUSTOMDATA_LAYER_NAME];
|
char attribute_name_c[MAX_CUSTOMDATA_LAYER_NAME];
|
||||||
attribute_id.name().copy(attribute_name_c);
|
attribute_id.name().copy(attribute_name_c);
|
||||||
return CustomData_add_layer_named(
|
return CustomData_add_layer_named(
|
||||||
&custom_data, data_type, alloctype, layer_data, domain_num, attribute_name_c);
|
&custom_data, data_type, alloctype, domain_size, attribute_name_c);
|
||||||
}
|
}
|
||||||
const AnonymousAttributeID &anonymous_id = attribute_id.anonymous_id();
|
const AnonymousAttributeID &anonymous_id = attribute_id.anonymous_id();
|
||||||
return CustomData_add_layer_anonymous(
|
return CustomData_add_layer_anonymous(
|
||||||
&custom_data, data_type, alloctype, layer_data, domain_num, &anonymous_id);
|
&custom_data, data_type, alloctype, nullptr, domain_size, &anonymous_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const void *add_generic_custom_data_layer_with_existing_data(
|
||||||
|
CustomData &custom_data,
|
||||||
|
const eCustomDataType data_type,
|
||||||
|
void *layer_data,
|
||||||
|
const int domain_size,
|
||||||
|
const AttributeIDRef &attribute_id)
|
||||||
|
{
|
||||||
|
if (!attribute_id.is_anonymous()) {
|
||||||
|
char attribute_name_c[MAX_CUSTOMDATA_LAYER_NAME];
|
||||||
|
attribute_id.name().copy(attribute_name_c);
|
||||||
|
return CustomData_add_layer_named_with_data(
|
||||||
|
&custom_data, data_type, layer_data, domain_size, attribute_name_c);
|
||||||
|
}
|
||||||
|
const AnonymousAttributeID &anonymous_id = attribute_id.anonymous_id();
|
||||||
|
return CustomData_add_layer_anonymous(
|
||||||
|
&custom_data, data_type, CD_ASSIGN, layer_data, domain_size, &anonymous_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attribute_id,
|
static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attribute_id,
|
||||||
@ -244,17 +258,17 @@ static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attr
|
|||||||
switch (initializer.type) {
|
switch (initializer.type) {
|
||||||
case AttributeInit::Type::Construct: {
|
case AttributeInit::Type::Construct: {
|
||||||
add_generic_custom_data_layer(
|
add_generic_custom_data_layer(
|
||||||
custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num, attribute_id);
|
custom_data, data_type, CD_CONSTRUCT, domain_num, attribute_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AttributeInit::Type::DefaultValue: {
|
case AttributeInit::Type::DefaultValue: {
|
||||||
add_generic_custom_data_layer(
|
add_generic_custom_data_layer(
|
||||||
custom_data, data_type, CD_SET_DEFAULT, nullptr, domain_num, attribute_id);
|
custom_data, data_type, CD_SET_DEFAULT, domain_num, attribute_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AttributeInit::Type::VArray: {
|
case AttributeInit::Type::VArray: {
|
||||||
void *data = add_generic_custom_data_layer(
|
void *data = add_generic_custom_data_layer(
|
||||||
custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num, attribute_id);
|
custom_data, data_type, CD_CONSTRUCT, domain_num, attribute_id);
|
||||||
if (data != nullptr) {
|
if (data != nullptr) {
|
||||||
const GVArray &varray = static_cast<const AttributeInitVArray &>(initializer).varray;
|
const GVArray &varray = static_cast<const AttributeInitVArray &>(initializer).varray;
|
||||||
varray.materialize_to_uninitialized(varray.index_range(), data);
|
varray.materialize_to_uninitialized(varray.index_range(), data);
|
||||||
@ -263,8 +277,8 @@ static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attr
|
|||||||
}
|
}
|
||||||
case AttributeInit::Type::MoveArray: {
|
case AttributeInit::Type::MoveArray: {
|
||||||
void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
|
void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
|
||||||
add_generic_custom_data_layer(
|
add_generic_custom_data_layer_with_existing_data(
|
||||||
custom_data, data_type, CD_ASSIGN, source_data, domain_num, attribute_id);
|
custom_data, data_type, source_data, domain_num, attribute_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -633,7 +647,7 @@ bool CustomDataAttributes::create(const AttributeIDRef &attribute_id,
|
|||||||
const eCustomDataType data_type)
|
const eCustomDataType data_type)
|
||||||
{
|
{
|
||||||
void *result = add_generic_custom_data_layer(
|
void *result = add_generic_custom_data_layer(
|
||||||
data, data_type, CD_SET_DEFAULT, nullptr, size_, attribute_id);
|
data, data_type, CD_SET_DEFAULT, size_, attribute_id);
|
||||||
return result != nullptr;
|
return result != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,8 +655,8 @@ bool CustomDataAttributes::create_by_move(const AttributeIDRef &attribute_id,
|
|||||||
const eCustomDataType data_type,
|
const eCustomDataType data_type,
|
||||||
void *buffer)
|
void *buffer)
|
||||||
{
|
{
|
||||||
void *result = add_generic_custom_data_layer(
|
const void *result = add_generic_custom_data_layer_with_existing_data(
|
||||||
data, data_type, CD_ASSIGN, buffer, size_, attribute_id);
|
data, data_type, buffer, size_, attribute_id);
|
||||||
return result != nullptr;
|
return result != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,12 +59,8 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num)
|
|||||||
CustomData_reset(&this->point_data);
|
CustomData_reset(&this->point_data);
|
||||||
CustomData_reset(&this->curve_data);
|
CustomData_reset(&this->curve_data);
|
||||||
|
|
||||||
CustomData_add_layer_named(&this->point_data,
|
CustomData_add_layer_named(
|
||||||
CD_PROP_FLOAT3,
|
&this->point_data, CD_PROP_FLOAT3, CD_CONSTRUCT, this->point_num, ATTR_POSITION.c_str());
|
||||||
CD_CONSTRUCT,
|
|
||||||
nullptr,
|
|
||||||
this->point_num,
|
|
||||||
ATTR_POSITION.c_str());
|
|
||||||
|
|
||||||
this->curve_offsets = (int *)MEM_malloc_arrayN(this->curve_num + 1, sizeof(int), __func__);
|
this->curve_offsets = (int *)MEM_malloc_arrayN(this->curve_num + 1, sizeof(int), __func__);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -230,8 +226,7 @@ static MutableSpan<T> get_mutable_attribute(CurvesGeometry &curves,
|
|||||||
if (data != nullptr) {
|
if (data != nullptr) {
|
||||||
return {data, num};
|
return {data, num};
|
||||||
}
|
}
|
||||||
data = (T *)CustomData_add_layer_named(
|
data = (T *)CustomData_add_layer_named(&custom_data, type, CD_SET_DEFAULT, num, name.c_str());
|
||||||
&custom_data, type, CD_SET_DEFAULT, nullptr, num, name.c_str());
|
|
||||||
MutableSpan<T> span = {data, num};
|
MutableSpan<T> span = {data, num};
|
||||||
if (num > 0 && span.first() != default_value) {
|
if (num > 0 && span.first() != default_value) {
|
||||||
span.fill(default_value);
|
span.fill(default_value);
|
||||||
|
@ -2835,7 +2835,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
|
|||||||
return &data->layers[index];
|
return &data->layers[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CustomData_add_layer(
|
static void *customdata_add_layer(
|
||||||
CustomData *data, const int type, eCDAllocType alloctype, void *layerdata, const int totelem)
|
CustomData *data, const int type, eCDAllocType alloctype, void *layerdata, const int totelem)
|
||||||
{
|
{
|
||||||
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
|
||||||
@ -2851,8 +2851,24 @@ void *CustomData_add_layer(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CustomData_add_layer_named(CustomData *data,
|
void *CustomData_add_layer(CustomData *data,
|
||||||
const int type,
|
const eCustomDataType type,
|
||||||
|
const eCDAllocType alloctype,
|
||||||
|
const int totelem)
|
||||||
|
{
|
||||||
|
return customdata_add_layer(data, type, alloctype, nullptr, totelem);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *CustomData_add_layer_with_data(CustomData *data,
|
||||||
|
const eCustomDataType type,
|
||||||
|
void *layer_data,
|
||||||
|
const int totelem)
|
||||||
|
{
|
||||||
|
return customdata_add_layer(data, type, CD_ASSIGN, layer_data, totelem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *customdata_add_layer_named(CustomData *data,
|
||||||
|
const eCustomDataType type,
|
||||||
const eCDAllocType alloctype,
|
const eCDAllocType alloctype,
|
||||||
void *layerdata,
|
void *layerdata,
|
||||||
const int totelem,
|
const int totelem,
|
||||||
@ -2869,6 +2885,21 @@ void *CustomData_add_layer_named(CustomData *data,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *CustomData_add_layer_named(CustomData *data,
|
||||||
|
const eCustomDataType type,
|
||||||
|
const eCDAllocType alloctype,
|
||||||
|
const int totelem,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
return customdata_add_layer_named(data, type, alloctype, nullptr, totelem, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const void *CustomData_add_layer_named_with_data(
|
||||||
|
CustomData *data, const eCustomDataType type, void *layer_data, int totelem, const char *name)
|
||||||
|
{
|
||||||
|
return customdata_add_layer_named(data, type, CD_ASSIGN, layer_data, totelem, name);
|
||||||
|
}
|
||||||
|
|
||||||
void *CustomData_add_layer_anonymous(CustomData *data,
|
void *CustomData_add_layer_anonymous(CustomData *data,
|
||||||
const int type,
|
const int type,
|
||||||
const eCDAllocType alloctype,
|
const eCDAllocType alloctype,
|
||||||
|
@ -369,7 +369,7 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
|
|||||||
const bool do_loop_nors_dst = (loop_nors_dst == nullptr);
|
const bool do_loop_nors_dst = (loop_nors_dst == nullptr);
|
||||||
if (do_loop_nors_dst) {
|
if (do_loop_nors_dst) {
|
||||||
loop_nors_dst = static_cast<blender::float3 *>(
|
loop_nors_dst = static_cast<blender::float3 *>(
|
||||||
CustomData_add_layer(ldata_dst, CD_NORMAL, CD_SET_DEFAULT, nullptr, me_dst->totloop));
|
CustomData_add_layer(ldata_dst, CD_NORMAL, CD_SET_DEFAULT, me_dst->totloop));
|
||||||
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||||
}
|
}
|
||||||
if (dirty_nors_dst || do_loop_nors_dst) {
|
if (dirty_nors_dst || do_loop_nors_dst) {
|
||||||
@ -416,8 +416,8 @@ static void data_transfer_dtdata_type_postprocess(Object * /*ob_src*/,
|
|||||||
CustomData_get_layer_for_write(ldata_dst, CD_CUSTOMLOOPNORMAL, me_dst->totloop));
|
CustomData_get_layer_for_write(ldata_dst, CD_CUSTOMLOOPNORMAL, me_dst->totloop));
|
||||||
|
|
||||||
if (!custom_nors_dst) {
|
if (!custom_nors_dst) {
|
||||||
custom_nors_dst = static_cast<short(*)[2]>(CustomData_add_layer(
|
custom_nors_dst = static_cast<short(*)[2]>(
|
||||||
ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, me_dst->totloop));
|
CustomData_add_layer(ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, me_dst->totloop));
|
||||||
}
|
}
|
||||||
|
|
||||||
bke::MutableAttributeAccessor attributes = me_dst->attributes_for_write();
|
bke::MutableAttributeAccessor attributes = me_dst->attributes_for_write();
|
||||||
@ -623,7 +623,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
|
|||||||
if (use_create) {
|
if (use_create) {
|
||||||
/* Create as much data layers as necessary! */
|
/* Create as much data layers as necessary! */
|
||||||
for (; idx_dst < idx_src; idx_dst++) {
|
for (; idx_dst < idx_src; idx_dst++) {
|
||||||
CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
|
CustomData_add_layer(
|
||||||
|
cd_dst, eCustomDataType(cddata_type), CD_SET_DEFAULT, num_elem_dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -677,7 +678,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
|
|||||||
if ((idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name)) == -1) {
|
if ((idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name)) == -1) {
|
||||||
if (use_create) {
|
if (use_create) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst, name);
|
cd_dst, eCustomDataType(cddata_type), CD_SET_DEFAULT, num_elem_dst, name);
|
||||||
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
|
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -756,7 +757,8 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
|
|||||||
if (!use_create) {
|
if (!use_create) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
|
data_dst = CustomData_add_layer(
|
||||||
|
cd_dst, eCustomDataType(cddata_type), CD_SET_DEFAULT, num_elem_dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r_map) {
|
if (r_map) {
|
||||||
@ -797,7 +799,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
data_dst = CustomData_add_layer(
|
data_dst = CustomData_add_layer(
|
||||||
cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
|
cd_dst, eCustomDataType(cddata_type), CD_SET_DEFAULT, num_elem_dst);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data_dst = CustomData_get_layer_n_for_write(cd_dst, cddata_type, idx_dst, num_elem_dst);
|
data_dst = CustomData_get_layer_n_for_write(cd_dst, cddata_type, idx_dst, num_elem_dst);
|
||||||
@ -812,7 +814,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
|
|||||||
}
|
}
|
||||||
/* Create as much data layers as necessary! */
|
/* Create as much data layers as necessary! */
|
||||||
for (; num <= idx_dst; num++) {
|
for (; num <= idx_dst; num++) {
|
||||||
CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst);
|
CustomData_add_layer(cd_dst, eCustomDataType(cddata_type), CD_SET_DEFAULT, num_elem_dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data_dst = CustomData_get_layer_n_for_write(cd_dst, cddata_type, idx_dst, num_elem_dst);
|
data_dst = CustomData_get_layer_n_for_write(cd_dst, cddata_type, idx_dst, num_elem_dst);
|
||||||
@ -824,7 +826,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
cd_dst, cddata_type, CD_SET_DEFAULT, nullptr, num_elem_dst, name);
|
cd_dst, eCustomDataType(cddata_type), CD_SET_DEFAULT, num_elem_dst, name);
|
||||||
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
|
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
|
||||||
}
|
}
|
||||||
data_dst = CustomData_get_layer_n_for_write(cd_dst, cddata_type, idx_dst, num_elem_dst);
|
data_dst = CustomData_get_layer_n_for_write(cd_dst, cddata_type, idx_dst, num_elem_dst);
|
||||||
@ -989,7 +991,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
|
|||||||
if (r_map && cddata_type == CD_FAKE_SEAM) {
|
if (r_map && cddata_type == CD_FAKE_SEAM) {
|
||||||
if (!CustomData_get_layer_named(&me_dst->edata, CD_PROP_BOOL, ".uv_seam")) {
|
if (!CustomData_get_layer_named(&me_dst->edata, CD_PROP_BOOL, ".uv_seam")) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&me_dst->edata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me_dst->totedge, ".uv_seam");
|
&me_dst->edata, CD_PROP_BOOL, CD_SET_DEFAULT, me_dst->totedge, ".uv_seam");
|
||||||
}
|
}
|
||||||
data_transfer_layersmapping_add_item_cd(
|
data_transfer_layersmapping_add_item_cd(
|
||||||
r_map,
|
r_map,
|
||||||
@ -1007,7 +1009,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
|
|||||||
if (r_map && cddata_type == CD_FAKE_SHARP) {
|
if (r_map && cddata_type == CD_FAKE_SHARP) {
|
||||||
if (!CustomData_get_layer_named(&me_dst->edata, CD_PROP_BOOL, "sharp_edge")) {
|
if (!CustomData_get_layer_named(&me_dst->edata, CD_PROP_BOOL, "sharp_edge")) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&me_dst->edata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me_dst->totedge, "sharp_edge");
|
&me_dst->edata, CD_PROP_BOOL, CD_SET_DEFAULT, me_dst->totedge, "sharp_edge");
|
||||||
}
|
}
|
||||||
data_transfer_layersmapping_add_item_cd(
|
data_transfer_layersmapping_add_item_cd(
|
||||||
r_map,
|
r_map,
|
||||||
@ -1093,7 +1095,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
|
|||||||
if (r_map && cddata_type == CD_FAKE_SHARP) {
|
if (r_map && cddata_type == CD_FAKE_SHARP) {
|
||||||
if (!CustomData_get_layer_named(&me_dst->pdata, CD_PROP_BOOL, "sharp_face")) {
|
if (!CustomData_get_layer_named(&me_dst->pdata, CD_PROP_BOOL, "sharp_face")) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&me_dst->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me_dst->totpoly, "sharp_face");
|
&me_dst->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, me_dst->totpoly, "sharp_face");
|
||||||
}
|
}
|
||||||
data_transfer_layersmapping_add_item_cd(
|
data_transfer_layersmapping_add_item_cd(
|
||||||
r_map,
|
r_map,
|
||||||
|
@ -1262,7 +1262,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||||||
* Again, use_create is not relevant in this case */
|
* Again, use_create is not relevant in this case */
|
||||||
if (!data_dst) {
|
if (!data_dst) {
|
||||||
data_dst = static_cast<MDeformVert *>(
|
data_dst = static_cast<MDeformVert *>(
|
||||||
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, num_elem_dst));
|
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (idx_src--) {
|
while (idx_src--) {
|
||||||
@ -1323,8 +1323,8 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||||||
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
|
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
|
||||||
* use_create is not relevant in this case */
|
* use_create is not relevant in this case */
|
||||||
if (!data_dst) {
|
if (!data_dst) {
|
||||||
data_dst = static_cast<MDeformVert *>(CustomData_add_layer(
|
data_dst = static_cast<MDeformVert *>(
|
||||||
cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, num_elem_dst));
|
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
data_transfer_layersmapping_add_item(r_map,
|
data_transfer_layersmapping_add_item(r_map,
|
||||||
@ -1467,7 +1467,7 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
|
|||||||
* use_create is not relevant in this case */
|
* use_create is not relevant in this case */
|
||||||
if (!data_dst) {
|
if (!data_dst) {
|
||||||
data_dst = static_cast<MDeformVert *>(
|
data_dst = static_cast<MDeformVert *>(
|
||||||
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, num_elem_dst));
|
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
data_transfer_layersmapping_add_item(r_map,
|
data_transfer_layersmapping_add_item(r_map,
|
||||||
|
@ -1958,7 +1958,6 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
|
|||||||
mloopcol = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->ldata,
|
mloopcol = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->ldata,
|
||||||
CD_PROP_BYTE_COLOR,
|
CD_PROP_BYTE_COLOR,
|
||||||
CD_SET_DEFAULT,
|
CD_SET_DEFAULT,
|
||||||
nullptr,
|
|
||||||
loops.size(),
|
loops.size(),
|
||||||
surface->output_name));
|
surface->output_name));
|
||||||
}
|
}
|
||||||
@ -1972,7 +1971,6 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
|
|||||||
CustomData_add_layer_named(&result->ldata,
|
CustomData_add_layer_named(&result->ldata,
|
||||||
CD_PROP_BYTE_COLOR,
|
CD_PROP_BYTE_COLOR,
|
||||||
CD_SET_DEFAULT,
|
CD_SET_DEFAULT,
|
||||||
nullptr,
|
|
||||||
loops.size(),
|
loops.size(),
|
||||||
surface->output_name2));
|
surface->output_name2));
|
||||||
}
|
}
|
||||||
@ -2003,7 +2001,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
|
|||||||
/* apply weights into a vertex group, if doesn't exists add a new layer */
|
/* apply weights into a vertex group, if doesn't exists add a new layer */
|
||||||
if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) {
|
if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) {
|
||||||
dvert = static_cast<MDeformVert *>(CustomData_add_layer(
|
dvert = static_cast<MDeformVert *>(CustomData_add_layer(
|
||||||
&result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, sData->total_points));
|
&result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, sData->total_points));
|
||||||
}
|
}
|
||||||
if (defgrp_index != -1 && dvert) {
|
if (defgrp_index != -1 && dvert) {
|
||||||
for (int i = 0; i < sData->total_points; i++) {
|
for (int i = 0; i < sData->total_points; i++) {
|
||||||
|
@ -194,7 +194,7 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
|
|||||||
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
|
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
|
||||||
CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) {
|
CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), "");
|
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, int(loopdata_out_len), "");
|
||||||
}
|
}
|
||||||
if (calc_act && act_uv_name[0]) {
|
if (calc_act && act_uv_name[0]) {
|
||||||
BKE_mesh_add_loop_tangent_named_layer_for_uv(
|
BKE_mesh_add_loop_tangent_named_layer_for_uv(
|
||||||
|
@ -1463,15 +1463,15 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob)
|
|||||||
Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name + 2);
|
Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name + 2);
|
||||||
|
|
||||||
mesh->totvert = int(process.curvertex);
|
mesh->totvert = int(process.curvertex);
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named_with_data(
|
||||||
&mesh->vdata, CD_PROP_FLOAT3, CD_ASSIGN, process.co, mesh->totvert, "position");
|
&mesh->vdata, CD_PROP_FLOAT3, process.co, mesh->totvert, "position");
|
||||||
process.co = nullptr;
|
process.co = nullptr;
|
||||||
|
|
||||||
mesh->totpoly = int(process.curindex);
|
mesh->totpoly = int(process.curindex);
|
||||||
MPoly *polys = static_cast<MPoly *>(
|
MPoly *polys = static_cast<MPoly *>(
|
||||||
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, nullptr, mesh->totpoly));
|
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, mesh->totpoly));
|
||||||
MLoop *mloop = static_cast<MLoop *>(
|
MLoop *mloop = static_cast<MLoop *>(
|
||||||
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CONSTRUCT, nullptr, mesh->totpoly * 4));
|
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CONSTRUCT, mesh->totpoly * 4));
|
||||||
|
|
||||||
int loop_offset = 0;
|
int loop_offset = 0;
|
||||||
for (int i = 0; i < mesh->totpoly; i++) {
|
for (int i = 0; i < mesh->totpoly; i++) {
|
||||||
|
@ -838,7 +838,7 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
|
|||||||
else {
|
else {
|
||||||
if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
|
if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
|
||||||
vs = (MVertSkin *)CustomData_add_layer(
|
vs = (MVertSkin *)CustomData_add_layer(
|
||||||
&me->vdata, CD_MVERT_SKIN, CD_SET_DEFAULT, nullptr, me->totvert);
|
&me->vdata, CD_MVERT_SKIN, CD_SET_DEFAULT, me->totvert);
|
||||||
|
|
||||||
/* Mark an arbitrary vertex as root */
|
/* Mark an arbitrary vertex as root */
|
||||||
if (vs) {
|
if (vs) {
|
||||||
@ -860,7 +860,7 @@ bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
|
if (!CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
|
||||||
CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_SET_DEFAULT, nullptr, me->totpoly);
|
CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_SET_DEFAULT, me->totpoly);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -965,16 +965,16 @@ static void mesh_ensure_cdlayers_primary(Mesh *mesh)
|
|||||||
{
|
{
|
||||||
if (!CustomData_get_layer_named(&mesh->vdata, CD_PROP_FLOAT3, "position")) {
|
if (!CustomData_get_layer_named(&mesh->vdata, CD_PROP_FLOAT3, "position")) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, mesh->totvert, "position");
|
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh->totvert, "position");
|
||||||
}
|
}
|
||||||
if (!CustomData_get_layer(&mesh->edata, CD_MEDGE)) {
|
if (!CustomData_get_layer(&mesh->edata, CD_MEDGE)) {
|
||||||
CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh->totedge);
|
CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, mesh->totedge);
|
||||||
}
|
}
|
||||||
if (!CustomData_get_layer(&mesh->ldata, CD_MLOOP)) {
|
if (!CustomData_get_layer(&mesh->ldata, CD_MLOOP)) {
|
||||||
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop);
|
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, mesh->totloop);
|
||||||
}
|
}
|
||||||
if (!CustomData_get_layer(&mesh->pdata, CD_MPOLY)) {
|
if (!CustomData_get_layer(&mesh->pdata, CD_MPOLY)) {
|
||||||
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
|
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, mesh->totpoly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,7 +1094,7 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
|
|||||||
* even in cases where the source mesh does not. */
|
* even in cases where the source mesh does not. */
|
||||||
mesh_ensure_cdlayers_primary(me_dst);
|
mesh_ensure_cdlayers_primary(me_dst);
|
||||||
if (do_tessface && !CustomData_get_layer(&me_dst->fdata, CD_MFACE)) {
|
if (do_tessface && !CustomData_get_layer(&me_dst->fdata, CD_MFACE)) {
|
||||||
CustomData_add_layer(&me_dst->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, me_dst->totface);
|
CustomData_add_layer(&me_dst->fdata, CD_MFACE, CD_SET_DEFAULT, me_dst->totface);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expect that normals aren't copied at all, since the destination mesh is new. */
|
/* Expect that normals aren't copied at all, since the destination mesh is new. */
|
||||||
@ -1183,7 +1183,7 @@ static void ensure_orig_index_layer(CustomData &data, const int size)
|
|||||||
if (CustomData_has_layer(&data, CD_ORIGINDEX)) {
|
if (CustomData_has_layer(&data, CD_ORIGINDEX)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int *indices = (int *)CustomData_add_layer(&data, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, size);
|
int *indices = (int *)CustomData_add_layer(&data, CD_ORIGINDEX, CD_SET_DEFAULT, size);
|
||||||
range_vn_i(indices, size, 0);
|
range_vn_i(indices, size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1360,7 +1360,7 @@ void BKE_mesh_orco_ensure(Object *ob, Mesh *mesh)
|
|||||||
/* Orcos are stored in normalized 0..1 range by convention. */
|
/* Orcos are stored in normalized 0..1 range by convention. */
|
||||||
float(*orcodata)[3] = BKE_mesh_orco_verts_get(ob);
|
float(*orcodata)[3] = BKE_mesh_orco_verts_get(ob);
|
||||||
BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->totvert, false);
|
BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->totvert, false);
|
||||||
CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, orcodata, mesh->totvert);
|
CustomData_add_layer_with_data(&mesh->vdata, CD_ORCO, orcodata, mesh->totvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh *BKE_mesh_from_object(Object *ob)
|
Mesh *BKE_mesh_from_object(Object *ob)
|
||||||
@ -1830,7 +1830,7 @@ static float (*ensure_corner_normal_layer(Mesh &mesh))[3]
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
r_loop_normals = (float(*)[3])CustomData_add_layer(
|
r_loop_normals = (float(*)[3])CustomData_add_layer(
|
||||||
&mesh.ldata, CD_NORMAL, CD_SET_DEFAULT, nullptr, mesh.totloop);
|
&mesh.ldata, CD_NORMAL, CD_SET_DEFAULT, mesh.totloop);
|
||||||
CustomData_set_layer_flag(&mesh.ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(&mesh.ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||||
}
|
}
|
||||||
return r_loop_normals;
|
return r_loop_normals;
|
||||||
|
@ -240,7 +240,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool keep_existing_edges, const bool select
|
|||||||
/* Free old CustomData and assign new one. */
|
/* Free old CustomData and assign new one. */
|
||||||
CustomData_free(&mesh->edata, mesh->totedge);
|
CustomData_free(&mesh->edata, mesh->totedge);
|
||||||
CustomData_reset(&mesh->edata);
|
CustomData_reset(&mesh->edata);
|
||||||
CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_ASSIGN, new_edges.data(), new_totedge);
|
CustomData_add_layer_with_data(&mesh->edata, CD_MEDGE, new_edges.data(), new_totedge);
|
||||||
mesh->totedge = new_totedge;
|
mesh->totedge = new_totedge;
|
||||||
|
|
||||||
if (select_new_edges) {
|
if (select_new_edges) {
|
||||||
|
@ -215,7 +215,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
|
|||||||
"sharp_face", ATTR_DOMAIN_FACE);
|
"sharp_face", ATTR_DOMAIN_FACE);
|
||||||
|
|
||||||
blender::float2 *mloopuv = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
blender::float2 *mloopuv = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, mesh->totloop, DATA_("UVMap")));
|
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->totloop, DATA_("UVMap")));
|
||||||
|
|
||||||
int dst_vert = 0;
|
int dst_vert = 0;
|
||||||
int dst_edge = 0;
|
int dst_edge = 0;
|
||||||
|
@ -228,7 +228,7 @@ void BKE_mesh_calc_edges_legacy(Mesh *me)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
edges = (MEdge *)CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, edges, totedge);
|
edges = (MEdge *)CustomData_add_layer_with_data(&me->edata, CD_MEDGE, edges, totedge);
|
||||||
me->totedge = totedge;
|
me->totedge = totedge;
|
||||||
|
|
||||||
BKE_mesh_tag_topology_changed(me);
|
BKE_mesh_tag_topology_changed(me);
|
||||||
@ -394,19 +394,17 @@ static void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *ldata, int to
|
|||||||
for (int i = 0; i < fdata->totlayer; i++) {
|
for (int i = 0; i < fdata->totlayer; i++) {
|
||||||
if (fdata->layers[i].type == CD_MTFACE) {
|
if (fdata->layers[i].type == CD_MTFACE) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
|
ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, totloop, fdata->layers[i].name);
|
||||||
}
|
}
|
||||||
else if (fdata->layers[i].type == CD_MCOL) {
|
else if (fdata->layers[i].type == CD_MCOL) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
|
ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, totloop, fdata->layers[i].name);
|
||||||
}
|
}
|
||||||
else if (fdata->layers[i].type == CD_MDISPS) {
|
else if (fdata->layers[i].type == CD_MDISPS) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(ldata, CD_MDISPS, CD_SET_DEFAULT, totloop, fdata->layers[i].name);
|
||||||
ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
|
|
||||||
}
|
}
|
||||||
else if (fdata->layers[i].type == CD_TESSLOOPNORMAL) {
|
else if (fdata->layers[i].type == CD_TESSLOOPNORMAL) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(ldata, CD_NORMAL, CD_SET_DEFAULT, totloop, fdata->layers[i].name);
|
||||||
ldata, CD_NORMAL, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,18 +438,18 @@ static void convert_mfaces_to_mpolys(ID *id,
|
|||||||
CustomData_free(pdata, totpoly_i);
|
CustomData_free(pdata, totpoly_i);
|
||||||
|
|
||||||
totpoly = totface_i;
|
totpoly = totface_i;
|
||||||
mpoly = (MPoly *)CustomData_add_layer(pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, totpoly);
|
mpoly = (MPoly *)CustomData_add_layer(pdata, CD_MPOLY, CD_SET_DEFAULT, totpoly);
|
||||||
int *material_indices = static_cast<int *>(
|
int *material_indices = static_cast<int *>(
|
||||||
CustomData_get_layer_named_for_write(pdata, CD_PROP_INT32, "material_index", totpoly));
|
CustomData_get_layer_named_for_write(pdata, CD_PROP_INT32, "material_index", totpoly));
|
||||||
if (material_indices == nullptr) {
|
if (material_indices == nullptr) {
|
||||||
material_indices = static_cast<int *>(CustomData_add_layer_named(
|
material_indices = static_cast<int *>(CustomData_add_layer_named(
|
||||||
pdata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, totpoly, "material_index"));
|
pdata, CD_PROP_INT32, CD_SET_DEFAULT, totpoly, "material_index"));
|
||||||
}
|
}
|
||||||
bool *sharp_faces = static_cast<bool *>(
|
bool *sharp_faces = static_cast<bool *>(
|
||||||
CustomData_get_layer_named_for_write(pdata, CD_PROP_BOOL, "sharp_face", totpoly));
|
CustomData_get_layer_named_for_write(pdata, CD_PROP_BOOL, "sharp_face", totpoly));
|
||||||
if (!sharp_faces) {
|
if (!sharp_faces) {
|
||||||
sharp_faces = static_cast<bool *>(CustomData_add_layer_named(
|
sharp_faces = static_cast<bool *>(
|
||||||
pdata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, totpoly, "sharp_face"));
|
CustomData_add_layer_named(pdata, CD_PROP_BOOL, CD_SET_DEFAULT, totpoly, "sharp_face"));
|
||||||
}
|
}
|
||||||
|
|
||||||
numTex = CustomData_number_of_layers(fdata, CD_MTFACE);
|
numTex = CustomData_number_of_layers(fdata, CD_MTFACE);
|
||||||
@ -463,7 +461,7 @@ static void convert_mfaces_to_mpolys(ID *id,
|
|||||||
totloop += mf->v4 ? 4 : 3;
|
totloop += mf->v4 ? 4 : 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
mloop = (MLoop *)CustomData_add_layer(ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, totloop);
|
mloop = (MLoop *)CustomData_add_layer(ldata, CD_MLOOP, CD_SET_DEFAULT, totloop);
|
||||||
|
|
||||||
CustomData_to_bmeshpoly(fdata, ldata, totloop);
|
CustomData_to_bmeshpoly(fdata, ldata, totloop);
|
||||||
|
|
||||||
@ -625,28 +623,25 @@ static void add_mface_layers(Mesh &mesh, CustomData *fdata, CustomData *ldata, i
|
|||||||
|
|
||||||
for (int i = 0; i < ldata->totlayer; i++) {
|
for (int i = 0; i < ldata->totlayer; i++) {
|
||||||
if (ldata->layers[i].type == CD_PROP_FLOAT2) {
|
if (ldata->layers[i].type == CD_PROP_FLOAT2) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(fdata, CD_MTFACE, CD_SET_DEFAULT, total, ldata->layers[i].name);
|
||||||
fdata, CD_MTFACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
|
|
||||||
}
|
}
|
||||||
if (ldata->layers[i].type == CD_PROP_BYTE_COLOR) {
|
if (ldata->layers[i].type == CD_PROP_BYTE_COLOR) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(fdata, CD_MCOL, CD_SET_DEFAULT, total, ldata->layers[i].name);
|
||||||
fdata, CD_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
|
|
||||||
}
|
}
|
||||||
else if (ldata->layers[i].type == CD_PREVIEW_MLOOPCOL) {
|
else if (ldata->layers[i].type == CD_PREVIEW_MLOOPCOL) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
fdata, CD_PREVIEW_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
|
fdata, CD_PREVIEW_MCOL, CD_SET_DEFAULT, total, ldata->layers[i].name);
|
||||||
}
|
}
|
||||||
else if (ldata->layers[i].type == CD_ORIGSPACE_MLOOP) {
|
else if (ldata->layers[i].type == CD_ORIGSPACE_MLOOP) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
fdata, CD_ORIGSPACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
|
fdata, CD_ORIGSPACE, CD_SET_DEFAULT, total, ldata->layers[i].name);
|
||||||
}
|
}
|
||||||
else if (ldata->layers[i].type == CD_NORMAL) {
|
else if (ldata->layers[i].type == CD_NORMAL) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
fdata, CD_TESSLOOPNORMAL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
|
fdata, CD_TESSLOOPNORMAL, CD_SET_DEFAULT, total, ldata->layers[i].name);
|
||||||
}
|
}
|
||||||
else if (ldata->layers[i].type == CD_TANGENT) {
|
else if (ldata->layers[i].type == CD_TANGENT) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(fdata, CD_TANGENT, CD_SET_DEFAULT, total, ldata->layers[i].name);
|
||||||
fdata, CD_TANGENT, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1157,11 +1152,11 @@ static int mesh_tessface_calc(Mesh &mesh,
|
|||||||
sizeof(*mface_to_poly_map) * size_t(totface));
|
sizeof(*mface_to_poly_map) * size_t(totface));
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface);
|
CustomData_add_layer_with_data(fdata, CD_MFACE, mface, totface);
|
||||||
|
|
||||||
/* #CD_ORIGINDEX will contain an array of indices from tessellation-faces to the polygons
|
/* #CD_ORIGINDEX will contain an array of indices from tessellation-faces to the polygons
|
||||||
* they are directly tessellated from. */
|
* they are directly tessellated from. */
|
||||||
CustomData_add_layer(fdata, CD_ORIGINDEX, CD_ASSIGN, mface_to_poly_map, totface);
|
CustomData_add_layer_with_data(fdata, CD_ORIGINDEX, mface_to_poly_map, totface);
|
||||||
add_mface_layers(mesh, fdata, ldata, totface);
|
add_mface_layers(mesh, fdata, ldata, totface);
|
||||||
|
|
||||||
/* NOTE: quad detection issue - fourth vertex-index vs fourth loop-index:
|
/* NOTE: quad detection issue - fourth vertex-index vs fourth loop-index:
|
||||||
@ -1314,8 +1309,8 @@ void BKE_mesh_legacy_face_set_to_generic(Mesh *mesh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (faceset_data != nullptr) {
|
if (faceset_data != nullptr) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named_with_data(
|
||||||
&mesh->pdata, CD_PROP_INT32, CD_ASSIGN, faceset_data, mesh->totpoly, ".sculpt_face_set");
|
&mesh->pdata, CD_PROP_INT32, faceset_data, mesh->totpoly, ".sculpt_face_set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1365,7 +1360,7 @@ void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh)
|
|||||||
const Span<MVert> verts(mesh->mvert, mesh->totvert);
|
const Span<MVert> verts(mesh->mvert, mesh->totvert);
|
||||||
if (mesh->cd_flag & ME_CDFLAG_VERT_BWEIGHT) {
|
if (mesh->cd_flag & ME_CDFLAG_VERT_BWEIGHT) {
|
||||||
float *weights = static_cast<float *>(
|
float *weights = static_cast<float *>(
|
||||||
CustomData_add_layer(&mesh->vdata, CD_BWEIGHT, CD_CONSTRUCT, nullptr, verts.size()));
|
CustomData_add_layer(&mesh->vdata, CD_BWEIGHT, CD_CONSTRUCT, verts.size()));
|
||||||
for (const int i : verts.index_range()) {
|
for (const int i : verts.index_range()) {
|
||||||
weights[i] = verts[i].bweight_legacy / 255.0f;
|
weights[i] = verts[i].bweight_legacy / 255.0f;
|
||||||
}
|
}
|
||||||
@ -1376,7 +1371,7 @@ void BKE_mesh_legacy_bevel_weight_to_layers(Mesh *mesh)
|
|||||||
if (!CustomData_has_layer(&mesh->edata, CD_BWEIGHT)) {
|
if (!CustomData_has_layer(&mesh->edata, CD_BWEIGHT)) {
|
||||||
if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
|
if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
|
||||||
float *weights = static_cast<float *>(
|
float *weights = static_cast<float *>(
|
||||||
CustomData_add_layer(&mesh->edata, CD_BWEIGHT, CD_CONSTRUCT, nullptr, edges.size()));
|
CustomData_add_layer(&mesh->edata, CD_BWEIGHT, CD_CONSTRUCT, edges.size()));
|
||||||
for (const int i : edges.index_range()) {
|
for (const int i : edges.index_range()) {
|
||||||
weights[i] = edges[i].bweight_legacy / 255.0f;
|
weights[i] = edges[i].bweight_legacy / 255.0f;
|
||||||
}
|
}
|
||||||
@ -1418,7 +1413,7 @@ void BKE_mesh_legacy_edge_crease_to_layers(Mesh *mesh)
|
|||||||
const Span<MEdge> edges = mesh->edges();
|
const Span<MEdge> edges = mesh->edges();
|
||||||
if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) {
|
if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) {
|
||||||
float *creases = static_cast<float *>(
|
float *creases = static_cast<float *>(
|
||||||
CustomData_add_layer(&mesh->edata, CD_CREASE, CD_CONSTRUCT, nullptr, edges.size()));
|
CustomData_add_layer(&mesh->edata, CD_CREASE, CD_CONSTRUCT, edges.size()));
|
||||||
for (const int i : edges.index_range()) {
|
for (const int i : edges.index_range()) {
|
||||||
creases[i] = edges[i].crease_legacy / 255.0f;
|
creases[i] = edges[i].crease_legacy / 255.0f;
|
||||||
}
|
}
|
||||||
@ -1802,29 +1797,26 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh)
|
|||||||
});
|
});
|
||||||
|
|
||||||
CustomData_free_layer_named(&mesh->ldata, name.c_str(), mesh->totloop);
|
CustomData_free_layer_named(&mesh->ldata, name.c_str(), mesh->totloop);
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named_with_data(
|
||||||
&mesh->ldata, CD_PROP_FLOAT2, CD_ASSIGN, coords, mesh->totloop, name.c_str());
|
&mesh->ldata, CD_PROP_FLOAT2, coords, mesh->totloop, name.c_str());
|
||||||
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
char buffer[MAX_CUSTOMDATA_LAYER_NAME];
|
||||||
if (vert_selection) {
|
if (vert_selection) {
|
||||||
CustomData_add_layer_named(&mesh->ldata,
|
CustomData_add_layer_named_with_data(&mesh->ldata,
|
||||||
CD_PROP_BOOL,
|
CD_PROP_BOOL,
|
||||||
CD_ASSIGN,
|
|
||||||
vert_selection,
|
vert_selection,
|
||||||
mesh->totloop,
|
mesh->totloop,
|
||||||
BKE_uv_map_vert_select_name_get(name.c_str(), buffer));
|
BKE_uv_map_vert_select_name_get(name.c_str(), buffer));
|
||||||
}
|
}
|
||||||
if (edge_selection) {
|
if (edge_selection) {
|
||||||
CustomData_add_layer_named(&mesh->ldata,
|
CustomData_add_layer_named_with_data(&mesh->ldata,
|
||||||
CD_PROP_BOOL,
|
CD_PROP_BOOL,
|
||||||
CD_ASSIGN,
|
|
||||||
edge_selection,
|
edge_selection,
|
||||||
mesh->totloop,
|
mesh->totloop,
|
||||||
BKE_uv_map_edge_select_name_get(name.c_str(), buffer));
|
BKE_uv_map_edge_select_name_get(name.c_str(), buffer));
|
||||||
}
|
}
|
||||||
if (pin) {
|
if (pin) {
|
||||||
CustomData_add_layer_named(&mesh->ldata,
|
CustomData_add_layer_named_with_data(&mesh->ldata,
|
||||||
CD_PROP_BOOL,
|
CD_PROP_BOOL,
|
||||||
CD_ASSIGN,
|
|
||||||
pin,
|
pin,
|
||||||
mesh->totloop,
|
mesh->totloop,
|
||||||
BKE_uv_map_pin_name_get(name.c_str(), buffer));
|
BKE_uv_map_pin_name_get(name.c_str(), buffer));
|
||||||
@ -2000,7 +1992,7 @@ void BKE_mesh_legacy_convert_verts_to_positions(Mesh *mesh)
|
|||||||
mesh->totvert);
|
mesh->totvert);
|
||||||
MutableSpan<float3> positions(
|
MutableSpan<float3> positions(
|
||||||
static_cast<float3 *>(CustomData_add_layer_named(
|
static_cast<float3 *>(CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, mesh->totvert, "position")),
|
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh->totvert, "position")),
|
||||||
mesh->totvert);
|
mesh->totvert);
|
||||||
threading::parallel_for(verts.index_range(), 2048, [&](IndexRange range) {
|
threading::parallel_for(verts.index_range(), 2048, [&](IndexRange range) {
|
||||||
for (const int i : range) {
|
for (const int i : range) {
|
||||||
|
@ -1850,7 +1850,7 @@ static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clnors = (short(*)[2])CustomData_add_layer(
|
clnors = (short(*)[2])CustomData_add_layer(
|
||||||
&mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, numloops);
|
&mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, numloops);
|
||||||
}
|
}
|
||||||
MutableAttributeAccessor attributes = mesh->attributes_for_write();
|
MutableAttributeAccessor attributes = mesh->attributes_for_write();
|
||||||
SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>(
|
SpanAttributeWriter<bool> sharp_edges = attributes.lookup_or_add_for_write_span<bool>(
|
||||||
|
@ -1357,7 +1357,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||||||
const bool do_loop_nors_dst = (loop_nors_dst == nullptr);
|
const bool do_loop_nors_dst = (loop_nors_dst == nullptr);
|
||||||
if (!loop_nors_dst) {
|
if (!loop_nors_dst) {
|
||||||
loop_nors_dst = static_cast<float(*)[3]>(
|
loop_nors_dst = static_cast<float(*)[3]>(
|
||||||
CustomData_add_layer(ldata_dst, CD_NORMAL, CD_SET_DEFAULT, nullptr, numloops_dst));
|
CustomData_add_layer(ldata_dst, CD_NORMAL, CD_SET_DEFAULT, numloops_dst));
|
||||||
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||||
}
|
}
|
||||||
if (dirty_nors_dst || do_loop_nors_dst) {
|
if (dirty_nors_dst || do_loop_nors_dst) {
|
||||||
|
@ -290,7 +290,7 @@ void BKE_mesh_remesh_reproject_paint_mask(Mesh *target, const Mesh *source)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
target_mask = (float *)CustomData_add_layer(
|
target_mask = (float *)CustomData_add_layer(
|
||||||
&target->vdata, CD_PAINT_MASK, CD_CONSTRUCT, nullptr, target->totvert);
|
&target->vdata, CD_PAINT_MASK, CD_CONSTRUCT, target->totvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
blender::threading::parallel_for(IndexRange(target->totvert), 4096, [&](const IndexRange range) {
|
blender::threading::parallel_for(IndexRange(target->totvert), 4096, [&](const IndexRange range) {
|
||||||
@ -384,7 +384,7 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)
|
|||||||
int elem_num = domain == ATTR_DOMAIN_POINT ? target->totvert : target->totloop;
|
int elem_num = domain == ATTR_DOMAIN_POINT ? target->totvert : target->totloop;
|
||||||
|
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
target_cdata, layer->type, CD_SET_DEFAULT, nullptr, elem_num, layer->name);
|
target_cdata, eCustomDataType(layer->type), CD_SET_DEFAULT, elem_num, layer->name);
|
||||||
layer_i = CustomData_get_named_layer_index(target_cdata, layer->type, layer->name);
|
layer_i = CustomData_get_named_layer_index(target_cdata, layer->type, layer->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,8 +311,7 @@ void BKE_mesh_add_loop_tangent_named_layer_for_uv(CustomData *uv_data,
|
|||||||
{
|
{
|
||||||
if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 &&
|
if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 &&
|
||||||
CustomData_get_named_layer_index(uv_data, CD_PROP_FLOAT2, layer_name) != -1) {
|
CustomData_get_named_layer_index(uv_data, CD_PROP_FLOAT2, layer_name) != -1) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(tan_data, CD_TANGENT, CD_SET_DEFAULT, numLoopData, layer_name);
|
||||||
tan_data, CD_TANGENT, CD_SET_DEFAULT, nullptr, numLoopData, layer_name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,7 +441,7 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
|
|||||||
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
|
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
|
||||||
CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) {
|
CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, nullptr, int(loopdata_out_len), "");
|
loopdata_out, CD_TANGENT, CD_SET_DEFAULT, int(loopdata_out_len), "");
|
||||||
}
|
}
|
||||||
if (calc_act && act_uv_name[0]) {
|
if (calc_act && act_uv_name[0]) {
|
||||||
BKE_mesh_add_loop_tangent_named_layer_for_uv(
|
BKE_mesh_add_loop_tangent_named_layer_for_uv(
|
||||||
|
@ -1352,8 +1352,8 @@ void BKE_mesh_calc_edges_tessface(Mesh *mesh)
|
|||||||
/* write new edges into a temporary CustomData */
|
/* write new edges into a temporary CustomData */
|
||||||
CustomData edgeData;
|
CustomData edgeData;
|
||||||
CustomData_reset(&edgeData);
|
CustomData_reset(&edgeData);
|
||||||
CustomData_add_layer(&edgeData, CD_MEDGE, CD_SET_DEFAULT, nullptr, numEdges);
|
CustomData_add_layer(&edgeData, CD_MEDGE, CD_SET_DEFAULT, numEdges);
|
||||||
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, numEdges);
|
CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_SET_DEFAULT, numEdges);
|
||||||
|
|
||||||
MEdge *ege = (MEdge *)CustomData_get_layer_for_write(&edgeData, CD_MEDGE, mesh->totedge);
|
MEdge *ege = (MEdge *)CustomData_get_layer_for_write(&edgeData, CD_MEDGE, mesh->totedge);
|
||||||
int *index = (int *)CustomData_get_layer_for_write(&edgeData, CD_ORIGINDEX, mesh->totedge);
|
int *index = (int *)CustomData_get_layer_for_write(&edgeData, CD_ORIGINDEX, mesh->totedge);
|
||||||
|
@ -993,7 +993,7 @@ static void multiresModifier_disp_run(
|
|||||||
if (!mdisps) {
|
if (!mdisps) {
|
||||||
if (op == CALC_DISPLACEMENTS) {
|
if (op == CALC_DISPLACEMENTS) {
|
||||||
mdisps = static_cast<MDisps *>(
|
mdisps = static_cast<MDisps *>(
|
||||||
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, me->totloop));
|
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_SET_DEFAULT, me->totloop));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
@ -1528,7 +1528,7 @@ void multires_ensure_external_read(struct Mesh *mesh, int top_level)
|
|||||||
CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop));
|
CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop));
|
||||||
if (mdisps == nullptr) {
|
if (mdisps == nullptr) {
|
||||||
mdisps = static_cast<MDisps *>(
|
mdisps = static_cast<MDisps *>(
|
||||||
CustomData_add_layer(&mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, mesh->totloop));
|
CustomData_add_layer(&mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, mesh->totloop));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int totloop = mesh->totloop;
|
const int totloop = mesh->totloop;
|
||||||
|
@ -179,8 +179,7 @@ void multiresModifier_subdivide_to_level(Object *object,
|
|||||||
* are allocated at a proper level and return. */
|
* are allocated at a proper level and return. */
|
||||||
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
|
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
|
||||||
if (!has_mdisps) {
|
if (!has_mdisps) {
|
||||||
CustomData_add_layer(
|
CustomData_add_layer(&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->totloop);
|
||||||
&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, coarse_mesh->totloop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NOTE: Subdivision happens from the top level of the existing multires modifier. If it is set
|
/* NOTE: Subdivision happens from the top level of the existing multires modifier. If it is set
|
||||||
|
@ -74,8 +74,7 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
|
|||||||
|
|
||||||
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
|
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
|
||||||
if (!has_mdisps) {
|
if (!has_mdisps) {
|
||||||
CustomData_add_layer(
|
CustomData_add_layer(&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, coarse_mesh->totloop);
|
||||||
&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, coarse_mesh->totloop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_top_level == 1) {
|
if (new_top_level == 1) {
|
||||||
|
@ -903,10 +903,10 @@ static void multires_unsubdivide_add_original_index_datalayers(Mesh *mesh)
|
|||||||
multires_unsubdivide_free_original_datalayers(mesh);
|
multires_unsubdivide_free_original_datalayers(mesh);
|
||||||
|
|
||||||
int *l_index = static_cast<int *>(CustomData_add_layer_named(
|
int *l_index = static_cast<int *>(CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, mesh->totloop, lname));
|
&mesh->ldata, CD_PROP_INT32, CD_SET_DEFAULT, mesh->totloop, lname));
|
||||||
|
|
||||||
int *v_index = static_cast<int *>(CustomData_add_layer_named(
|
int *v_index = static_cast<int *>(CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, mesh->totvert, vname));
|
&mesh->vdata, CD_PROP_INT32, CD_SET_DEFAULT, mesh->totvert, vname));
|
||||||
|
|
||||||
/* Initialize these data-layer with the indices in the current mesh. */
|
/* Initialize these data-layer with the indices in the current mesh. */
|
||||||
for (int i = 0; i < mesh->totloop; i++) {
|
for (int i = 0; i < mesh->totloop; i++) {
|
||||||
@ -1186,8 +1186,8 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
|
|||||||
if (CustomData_has_layer(&base_mesh->ldata, CD_MDISPS)) {
|
if (CustomData_has_layer(&base_mesh->ldata, CD_MDISPS)) {
|
||||||
CustomData_free_layers(&base_mesh->ldata, CD_MDISPS, base_mesh->totloop);
|
CustomData_free_layers(&base_mesh->ldata, CD_MDISPS, base_mesh->totloop);
|
||||||
}
|
}
|
||||||
MDisps *mdisps = static_cast<MDisps *>(CustomData_add_layer(
|
MDisps *mdisps = static_cast<MDisps *>(
|
||||||
&base_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, base_mesh->totloop));
|
CustomData_add_layer(&base_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, base_mesh->totloop));
|
||||||
|
|
||||||
const int totdisp = pow_i(BKE_ccg_gridsize(context->num_total_levels), 2);
|
const int totdisp = pow_i(BKE_ccg_gridsize(context->num_total_levels), 2);
|
||||||
const int totloop = base_mesh->totloop;
|
const int totloop = base_mesh->totloop;
|
||||||
|
@ -1672,7 +1672,8 @@ static void copy_ccg_data(Mesh *mesh_destination, Mesh *mesh_source, int layer_t
|
|||||||
const int layer_index = CustomData_get_layer_index(data_destination, layer_type);
|
const int layer_index = CustomData_get_layer_index(data_destination, layer_type);
|
||||||
CustomData_free_layer(data_destination, layer_type, num_elements, layer_index);
|
CustomData_free_layer(data_destination, layer_type, num_elements, layer_index);
|
||||||
BLI_assert(!CustomData_has_layer(data_destination, layer_type));
|
BLI_assert(!CustomData_has_layer(data_destination, layer_type));
|
||||||
CustomData_add_layer(data_destination, layer_type, CD_SET_DEFAULT, nullptr, num_elements);
|
CustomData_add_layer(
|
||||||
|
data_destination, eCustomDataType(layer_type), CD_SET_DEFAULT, num_elements);
|
||||||
BLI_assert(CustomData_has_layer(data_destination, layer_type));
|
BLI_assert(CustomData_has_layer(data_destination, layer_type));
|
||||||
CustomData_copy_layer_type_data(data_source, data_destination, layer_type, 0, 0, num_elements);
|
CustomData_copy_layer_type_data(data_source, data_destination, layer_type, 0, 0, num_elements);
|
||||||
}
|
}
|
||||||
|
@ -1582,7 +1582,7 @@ static MultiresModifierData *sculpt_multires_modifier_get(const Scene *scene,
|
|||||||
|
|
||||||
if (mmd->sculptlvl > 0 && !(mmd->flags & eMultiresModifierFlag_UseSculptBaseMesh)) {
|
if (mmd->sculptlvl > 0 && !(mmd->flags & eMultiresModifierFlag_UseSculptBaseMesh)) {
|
||||||
if (need_mdisps) {
|
if (need_mdisps) {
|
||||||
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, me->totloop);
|
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_SET_DEFAULT, me->totloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mmd;
|
return mmd;
|
||||||
@ -1976,7 +1976,7 @@ bool *BKE_sculpt_hide_poly_ensure(Mesh *mesh)
|
|||||||
return hide_poly;
|
return hide_poly;
|
||||||
}
|
}
|
||||||
return static_cast<bool *>(CustomData_add_layer_named(
|
return static_cast<bool *>(CustomData_add_layer_named(
|
||||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, mesh->totpoly, ".hide_poly"));
|
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, ".hide_poly"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
|
int BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
|
||||||
@ -2001,8 +2001,8 @@ int BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
|
|||||||
int gridarea = gridsize * gridsize;
|
int gridarea = gridsize * gridsize;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
gmask = static_cast<GridPaintMask *>(CustomData_add_layer(
|
gmask = static_cast<GridPaintMask *>(
|
||||||
&me->ldata, CD_GRID_PAINT_MASK, CD_SET_DEFAULT, nullptr, me->totloop));
|
CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK, CD_SET_DEFAULT, me->totloop));
|
||||||
|
|
||||||
for (i = 0; i < me->totloop; i++) {
|
for (i = 0; i < me->totloop; i++) {
|
||||||
GridPaintMask *gpm = &gmask[i];
|
GridPaintMask *gpm = &gmask[i];
|
||||||
@ -2050,7 +2050,7 @@ int BKE_sculpt_mask_layers_ensure(Depsgraph *depsgraph,
|
|||||||
|
|
||||||
/* Create vertex paint mask layer if there isn't one already. */
|
/* Create vertex paint mask layer if there isn't one already. */
|
||||||
if (!paint_mask) {
|
if (!paint_mask) {
|
||||||
CustomData_add_layer(&me->vdata, CD_PAINT_MASK, CD_SET_DEFAULT, nullptr, me->totvert);
|
CustomData_add_layer(&me->vdata, CD_PAINT_MASK, CD_SET_DEFAULT, me->totvert);
|
||||||
/* The evaluated mesh must be updated to contain the new data. */
|
/* The evaluated mesh must be updated to contain the new data. */
|
||||||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||||
ret |= SCULPT_MASK_LAYER_CALC_VERT;
|
ret |= SCULPT_MASK_LAYER_CALC_VERT;
|
||||||
@ -2512,7 +2512,7 @@ static bool sculpt_attribute_create(SculptSession *ss,
|
|||||||
|
|
||||||
BLI_assert(CustomData_get_named_layer_index(cdata, proptype, name) == -1);
|
BLI_assert(CustomData_get_named_layer_index(cdata, proptype, name) == -1);
|
||||||
|
|
||||||
CustomData_add_layer_named(cdata, proptype, CD_SET_DEFAULT, nullptr, totelem, name);
|
CustomData_add_layer_named(cdata, proptype, CD_SET_DEFAULT, totelem, name);
|
||||||
int index = CustomData_get_named_layer_index(cdata, proptype, name);
|
int index = CustomData_get_named_layer_index(cdata, proptype, name);
|
||||||
|
|
||||||
if (!permanent) {
|
if (!permanent) {
|
||||||
|
@ -3518,12 +3518,8 @@ bool *BKE_pbvh_get_vert_hide_for_write(PBVH *pbvh)
|
|||||||
if (pbvh->hide_vert) {
|
if (pbvh->hide_vert) {
|
||||||
return pbvh->hide_vert;
|
return pbvh->hide_vert;
|
||||||
}
|
}
|
||||||
pbvh->hide_vert = static_cast<bool *>(CustomData_add_layer_named(&pbvh->mesh->vdata,
|
pbvh->hide_vert = static_cast<bool *>(CustomData_add_layer_named(
|
||||||
CD_PROP_BOOL,
|
&pbvh->mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, pbvh->mesh->totvert, ".hide_vert"));
|
||||||
CD_SET_DEFAULT,
|
|
||||||
nullptr,
|
|
||||||
pbvh->mesh->totvert,
|
|
||||||
".hide_vert"));
|
|
||||||
return pbvh->hide_vert;
|
return pbvh->hide_vert;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3889,7 +3885,7 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
|
|||||||
|
|
||||||
if (!hide_poly) {
|
if (!hide_poly) {
|
||||||
hide_poly = static_cast<bool *>(CustomData_add_layer_named(
|
hide_poly = static_cast<bool *>(CustomData_add_layer_named(
|
||||||
&mesh->pdata, CD_PROP_BOOL, CD_CONSTRUCT, nullptr, mesh->totpoly, ".hide_poly"));
|
&mesh->pdata, CD_PROP_BOOL, CD_CONSTRUCT, mesh->totpoly, ".hide_poly"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,6 @@ static void pointcloud_init_data(ID *id)
|
|||||||
CustomData_add_layer_named(&pointcloud->pdata,
|
CustomData_add_layer_named(&pointcloud->pdata,
|
||||||
CD_PROP_FLOAT3,
|
CD_PROP_FLOAT3,
|
||||||
CD_SET_DEFAULT,
|
CD_SET_DEFAULT,
|
||||||
nullptr,
|
|
||||||
pointcloud->totpoint,
|
pointcloud->totpoint,
|
||||||
POINTCLOUD_ATTR_POSITION);
|
POINTCLOUD_ATTR_POSITION);
|
||||||
|
|
||||||
|
@ -1180,8 +1180,8 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
|
|||||||
|
|
||||||
BLI_rw_mutex_lock(&ccgdm->origindex_cache_rwlock, THREAD_LOCK_WRITE);
|
BLI_rw_mutex_lock(&ccgdm->origindex_cache_rwlock, THREAD_LOCK_WRITE);
|
||||||
|
|
||||||
origindex = static_cast<int *>(CustomData_add_layer(
|
origindex = static_cast<int *>(
|
||||||
&dm->vertData, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, dm->numVertData));
|
CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_SET_DEFAULT, dm->numVertData));
|
||||||
|
|
||||||
totorig = ccgSubSurf_getNumVerts(ss);
|
totorig = ccgSubSurf_getNumVerts(ss);
|
||||||
totnone = dm->numVertData - totorig;
|
totnone = dm->numVertData - totorig;
|
||||||
@ -1219,8 +1219,8 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
|
|||||||
return origindex;
|
return origindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
origindex = static_cast<int *>(CustomData_add_layer(
|
origindex = static_cast<int *>(
|
||||||
&dm->edgeData, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, dm->numEdgeData));
|
CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_SET_DEFAULT, dm->numEdgeData));
|
||||||
|
|
||||||
totedge = ccgSubSurf_getNumEdges(ss);
|
totedge = ccgSubSurf_getNumEdges(ss);
|
||||||
totorig = totedge * (edgeSize - 1);
|
totorig = totedge * (edgeSize - 1);
|
||||||
@ -1262,8 +1262,8 @@ static void *ccgDM_get_poly_data_layer(DerivedMesh *dm, int type)
|
|||||||
return origindex;
|
return origindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
origindex = static_cast<int *>(CustomData_add_layer(
|
origindex = static_cast<int *>(
|
||||||
&dm->polyData, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, dm->numPolyData));
|
CustomData_add_layer(&dm->polyData, CD_ORIGINDEX, CD_SET_DEFAULT, dm->numPolyData));
|
||||||
|
|
||||||
totface = ccgSubSurf_getNumFaces(ss);
|
totface = ccgSubSurf_getNumFaces(ss);
|
||||||
|
|
||||||
|
@ -273,27 +273,27 @@ static void customdata_version_242(Mesh *me)
|
|||||||
int a, mtfacen, mcoln;
|
int a, mtfacen, mcoln;
|
||||||
|
|
||||||
if (!me->vdata.totlayer) {
|
if (!me->vdata.totlayer) {
|
||||||
CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert);
|
CustomData_add_layer_with_data(&me->vdata, CD_MVERT, me->mvert, me->totvert);
|
||||||
|
|
||||||
if (me->dvert) {
|
if (me->dvert) {
|
||||||
CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert);
|
CustomData_add_layer_with_data(&me->vdata, CD_MDEFORMVERT, me->dvert, me->totvert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!me->edata.totlayer) {
|
if (!me->edata.totlayer) {
|
||||||
CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge);
|
CustomData_add_layer_with_data(&me->edata, CD_MEDGE, me->medge, me->totedge);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!me->fdata.totlayer) {
|
if (!me->fdata.totlayer) {
|
||||||
CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface);
|
CustomData_add_layer_with_data(&me->fdata, CD_MFACE, me->mface, me->totface);
|
||||||
|
|
||||||
if (me->tface) {
|
if (me->tface) {
|
||||||
if (me->mcol) {
|
if (me->mcol) {
|
||||||
MEM_freeN(me->mcol);
|
MEM_freeN(me->mcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_SET_DEFAULT, NULL, me->totface);
|
me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_SET_DEFAULT, me->totface);
|
||||||
me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_SET_DEFAULT, NULL, me->totface);
|
me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_SET_DEFAULT, me->totface);
|
||||||
|
|
||||||
mtf = me->mtface;
|
mtf = me->mtface;
|
||||||
mcol = me->mcol;
|
mcol = me->mcol;
|
||||||
@ -308,7 +308,7 @@ static void customdata_version_242(Mesh *me)
|
|||||||
me->tface = NULL;
|
me->tface = NULL;
|
||||||
}
|
}
|
||||||
else if (me->mcol) {
|
else if (me->mcol) {
|
||||||
me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface);
|
CustomData_add_layer_with_data(&me->fdata, CD_MCOL, me->mcol, me->totface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,8 +591,7 @@ void BM_mesh_copy_init_customdata_all_layers(BMesh *bm_dst,
|
|||||||
const int size = *(&allocsize->totvert + i);
|
const int size = *(&allocsize->totvert + i);
|
||||||
|
|
||||||
for (int l = 0; l < src->totlayer; l++) {
|
for (int l = 0; l < src->totlayer; l++) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(dst, src->layers[l].type, CD_SET_DEFAULT, 0, src->layers[l].name);
|
||||||
dst, src->layers[l].type, CD_SET_DEFAULT, NULL, 0, src->layers[l].name);
|
|
||||||
}
|
}
|
||||||
CustomData_bmesh_init_pool(dst, size, htypes[i]);
|
CustomData_bmesh_init_pool(dst, size, htypes[i]);
|
||||||
}
|
}
|
||||||
|
@ -841,7 +841,7 @@ void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
|
|||||||
/* The pool is now owned by `olddata` and must not be shared. */
|
/* The pool is now owned by `olddata` and must not be shared. */
|
||||||
data->pool = NULL;
|
data->pool = NULL;
|
||||||
|
|
||||||
CustomData_add_layer(data, type, CD_SET_DEFAULT, NULL, 0);
|
CustomData_add_layer(data, type, CD_SET_DEFAULT, 0);
|
||||||
|
|
||||||
update_data_blocks(bm, &olddata, data);
|
update_data_blocks(bm, &olddata, data);
|
||||||
if (olddata.layers) {
|
if (olddata.layers) {
|
||||||
@ -856,7 +856,7 @@ void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *
|
|||||||
/* The pool is now owned by `olddata` and must not be shared. */
|
/* The pool is now owned by `olddata` and must not be shared. */
|
||||||
data->pool = NULL;
|
data->pool = NULL;
|
||||||
|
|
||||||
CustomData_add_layer_named(data, type, CD_SET_DEFAULT, NULL, 0, name);
|
CustomData_add_layer_named(data, type, CD_SET_DEFAULT, 0, name);
|
||||||
|
|
||||||
update_data_blocks(bm, &olddata, data);
|
update_data_blocks(bm, &olddata, data);
|
||||||
if (olddata.layers) {
|
if (olddata.layers) {
|
||||||
|
@ -233,22 +233,19 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
|
|||||||
BKE_uv_map_vert_select_name_get(
|
BKE_uv_map_vert_select_name_get(
|
||||||
CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name);
|
CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name);
|
||||||
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
|
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, me->totloop, name);
|
||||||
&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me->totloop, name);
|
|
||||||
temporary_layers_to_delete.append(std::string(name));
|
temporary_layers_to_delete.append(std::string(name));
|
||||||
}
|
}
|
||||||
BKE_uv_map_edge_select_name_get(
|
BKE_uv_map_edge_select_name_get(
|
||||||
CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name);
|
CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name);
|
||||||
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
|
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, me->totloop, name);
|
||||||
&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me->totloop, name);
|
|
||||||
temporary_layers_to_delete.append(std::string(name));
|
temporary_layers_to_delete.append(std::string(name));
|
||||||
}
|
}
|
||||||
BKE_uv_map_pin_name_get(CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index),
|
BKE_uv_map_pin_name_get(CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index),
|
||||||
name);
|
name);
|
||||||
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
|
if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, me->totloop, name);
|
||||||
&mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me->totloop, name);
|
|
||||||
temporary_layers_to_delete.append(std::string(name));
|
temporary_layers_to_delete.append(std::string(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,7 +338,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
|
|||||||
|
|
||||||
if (is_new) {
|
if (is_new) {
|
||||||
if (tot_shape_keys || params->add_key_index) {
|
if (tot_shape_keys || params->add_key_index) {
|
||||||
CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_ASSIGN, nullptr, 0);
|
CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_SET_DEFAULT, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +371,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
|
|||||||
for (i = 0, block = static_cast<KeyBlock *>(me->key->block.first); i < tot_shape_keys;
|
for (i = 0, block = static_cast<KeyBlock *>(me->key->block.first); i < tot_shape_keys;
|
||||||
block = block->next, i++) {
|
block = block->next, i++) {
|
||||||
if (is_new) {
|
if (is_new) {
|
||||||
CustomData_add_layer_named(&bm->vdata, CD_SHAPEKEY, CD_ASSIGN, nullptr, 0, block->name);
|
CustomData_add_layer_named(&bm->vdata, CD_SHAPEKEY, CD_SET_DEFAULT, 0, block->name);
|
||||||
int j = CustomData_get_layer_index_n(&bm->vdata, CD_SHAPEKEY, i);
|
int j = CustomData_get_layer_index_n(&bm->vdata, CD_SHAPEKEY, i);
|
||||||
bm->vdata.layers[j].uid = block->uid;
|
bm->vdata.layers[j].uid = block->uid;
|
||||||
}
|
}
|
||||||
@ -1249,8 +1246,7 @@ static void bm_to_mesh_verts(const BMesh &bm,
|
|||||||
MutableSpan<bool> select_vert,
|
MutableSpan<bool> select_vert,
|
||||||
MutableSpan<bool> hide_vert)
|
MutableSpan<bool> hide_vert)
|
||||||
{
|
{
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(&mesh.vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh.totvert, "position");
|
||||||
&mesh.vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, mesh.totvert, "position");
|
|
||||||
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.vdata, mesh.vdata);
|
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.vdata, mesh.vdata);
|
||||||
MutableSpan<float3> dst_vert_positions = mesh.vert_positions_for_write();
|
MutableSpan<float3> dst_vert_positions = mesh.vert_positions_for_write();
|
||||||
threading::parallel_for(dst_vert_positions.index_range(), 1024, [&](const IndexRange range) {
|
threading::parallel_for(dst_vert_positions.index_range(), 1024, [&](const IndexRange range) {
|
||||||
@ -1280,7 +1276,7 @@ static void bm_to_mesh_edges(const BMesh &bm,
|
|||||||
MutableSpan<bool> sharp_edge,
|
MutableSpan<bool> sharp_edge,
|
||||||
MutableSpan<bool> uv_seams)
|
MutableSpan<bool> uv_seams)
|
||||||
{
|
{
|
||||||
CustomData_add_layer(&mesh.edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh.totedge);
|
CustomData_add_layer(&mesh.edata, CD_MEDGE, CD_SET_DEFAULT, mesh.totedge);
|
||||||
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.edata, mesh.edata);
|
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.edata, mesh.edata);
|
||||||
MutableSpan<MEdge> dst_edges = mesh.edges_for_write();
|
MutableSpan<MEdge> dst_edges = mesh.edges_for_write();
|
||||||
threading::parallel_for(dst_edges.index_range(), 512, [&](const IndexRange range) {
|
threading::parallel_for(dst_edges.index_range(), 512, [&](const IndexRange range) {
|
||||||
@ -1322,7 +1318,7 @@ static void bm_to_mesh_faces(const BMesh &bm,
|
|||||||
MutableSpan<bool> sharp_faces,
|
MutableSpan<bool> sharp_faces,
|
||||||
MutableSpan<int> material_indices)
|
MutableSpan<int> material_indices)
|
||||||
{
|
{
|
||||||
CustomData_add_layer(&mesh.pdata, CD_MPOLY, CD_CONSTRUCT, nullptr, mesh.totpoly);
|
CustomData_add_layer(&mesh.pdata, CD_MPOLY, CD_CONSTRUCT, mesh.totpoly);
|
||||||
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.pdata, mesh.pdata);
|
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.pdata, mesh.pdata);
|
||||||
MutableSpan<MPoly> dst_polys = mesh.polys_for_write();
|
MutableSpan<MPoly> dst_polys = mesh.polys_for_write();
|
||||||
threading::parallel_for(dst_polys.index_range(), 1024, [&](const IndexRange range) {
|
threading::parallel_for(dst_polys.index_range(), 1024, [&](const IndexRange range) {
|
||||||
@ -1358,7 +1354,7 @@ 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)
|
static void bm_to_mesh_loops(const BMesh &bm, const Span<const BMLoop *> bm_loops, Mesh &mesh)
|
||||||
{
|
{
|
||||||
CustomData_add_layer(&mesh.ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh.totloop);
|
CustomData_add_layer(&mesh.ldata, CD_MLOOP, CD_SET_DEFAULT, mesh.totloop);
|
||||||
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.ldata, mesh.ldata);
|
const Vector<BMeshToMeshLayerInfo> info = bm_to_mesh_copy_info_calc(bm.ldata, mesh.ldata);
|
||||||
MutableSpan<MLoop> dst_loops = mesh.loops_for_write();
|
MutableSpan<MLoop> dst_loops = mesh.loops_for_write();
|
||||||
threading::parallel_for(dst_loops.index_range(), 1024, [&](const IndexRange range) {
|
threading::parallel_for(dst_loops.index_range(), 1024, [&](const IndexRange range) {
|
||||||
|
@ -273,11 +273,10 @@ int ED_mesh_uv_add(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CustomData_has_layer(&me->ldata, CD_PROP_FLOAT2) && do_init) {
|
if (CustomData_has_layer(&me->ldata, CD_PROP_FLOAT2) && do_init) {
|
||||||
CustomData_add_layer_named(&me->ldata,
|
CustomData_add_layer_named_with_data(
|
||||||
|
&me->ldata,
|
||||||
CD_PROP_FLOAT2,
|
CD_PROP_FLOAT2,
|
||||||
CD_DUPLICATE,
|
MEM_dupallocN(CustomData_get_layer(&me->ldata, CD_PROP_FLOAT2)),
|
||||||
const_cast<float2 *>(static_cast<const float2 *>(
|
|
||||||
CustomData_get_layer(&me->ldata, CD_PROP_FLOAT2))),
|
|
||||||
me->totloop,
|
me->totloop,
|
||||||
unique_name);
|
unique_name);
|
||||||
|
|
||||||
@ -285,7 +284,7 @@ int ED_mesh_uv_add(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&me->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, me->totloop, unique_name);
|
&me->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, me->totloop, unique_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active_set || layernum_dst == 0) {
|
if (active_set || layernum_dst == 0) {
|
||||||
@ -343,7 +342,7 @@ static bool *ensure_corner_boolean_attribute(Mesh &mesh, const blender::StringRe
|
|||||||
CustomData_get_layer_named_for_write(&mesh.ldata, CD_PROP_BOOL, name.c_str(), mesh.totloop));
|
CustomData_get_layer_named_for_write(&mesh.ldata, CD_PROP_BOOL, name.c_str(), mesh.totloop));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = static_cast<bool *>(CustomData_add_layer_named(
|
data = static_cast<bool *>(CustomData_add_layer_named(
|
||||||
&mesh.ldata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, mesh.totpoly, name.c_str()));
|
&mesh.ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh.totpoly, name.c_str()));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -634,7 +633,7 @@ static int mesh_customdata_add_exec__internal(bContext *C, char htype, int type)
|
|||||||
BM_data_layer_add(mesh->edit_mesh->bm, data, type);
|
BM_data_layer_add(mesh->edit_mesh->bm, data, type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CustomData_add_layer(data, type, CD_SET_DEFAULT, nullptr, tot);
|
CustomData_add_layer(data, eCustomDataType(type), CD_SET_DEFAULT, tot);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEG_id_tag_update(&mesh->id, 0);
|
DEG_id_tag_update(&mesh->id, 0);
|
||||||
@ -809,7 +808,7 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
|
|||||||
sharp_edges.finish();
|
sharp_edges.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomData_add_layer(&me->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, me->totloop);
|
CustomData_add_layer(&me->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, me->totloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEG_id_tag_update(&me->id, 0);
|
DEG_id_tag_update(&me->id, 0);
|
||||||
@ -1144,8 +1143,7 @@ static void mesh_add_verts(Mesh *mesh, int len)
|
|||||||
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
|
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
|
||||||
|
|
||||||
if (!CustomData_get_layer_named(&vdata, CD_PROP_FLOAT3, "position")) {
|
if (!CustomData_get_layer_named(&vdata, CD_PROP_FLOAT3, "position")) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(&vdata, CD_PROP_FLOAT3, CD_SET_DEFAULT, totvert, "position");
|
||||||
&vdata, CD_PROP_FLOAT3, CD_SET_DEFAULT, nullptr, totvert, "position");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomData_free(&mesh->vdata, mesh->totvert);
|
CustomData_free(&mesh->vdata, mesh->totvert);
|
||||||
@ -1179,7 +1177,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
|
|||||||
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
|
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
|
||||||
|
|
||||||
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
|
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
|
||||||
CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, totedge);
|
CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, totedge);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomData_free(&mesh->edata, mesh->totedge);
|
CustomData_free(&mesh->edata, mesh->totedge);
|
||||||
@ -1212,7 +1210,7 @@ static void mesh_add_loops(Mesh *mesh, int len)
|
|||||||
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
|
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
|
||||||
|
|
||||||
if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
|
if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
|
||||||
CustomData_add_layer(&ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, totloop);
|
CustomData_add_layer(&ldata, CD_MLOOP, CD_SET_DEFAULT, totloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
BKE_mesh_runtime_clear_cache(mesh);
|
BKE_mesh_runtime_clear_cache(mesh);
|
||||||
@ -1240,7 +1238,7 @@ static void mesh_add_polys(Mesh *mesh, int len)
|
|||||||
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
|
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
|
||||||
|
|
||||||
if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
|
if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
|
||||||
CustomData_add_layer(&pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, totpoly);
|
CustomData_add_layer(&pdata, CD_MPOLY, CD_SET_DEFAULT, totpoly);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomData_free(&mesh->pdata, mesh->totpoly);
|
CustomData_free(&mesh->pdata, mesh->totpoly);
|
||||||
|
@ -257,7 +257,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
|
|||||||
CustomData_get_layer_named_for_write(pdata, CD_PROP_INT32, "material_index", totpoly));
|
CustomData_get_layer_named_for_write(pdata, CD_PROP_INT32, "material_index", totpoly));
|
||||||
if (!material_indices && totcol > 1) {
|
if (!material_indices && totcol > 1) {
|
||||||
material_indices = (int *)CustomData_add_layer_named(
|
material_indices = (int *)CustomData_add_layer_named(
|
||||||
pdata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, totpoly, "material_index");
|
pdata, CD_PROP_INT32, CD_SET_DEFAULT, totpoly, "material_index");
|
||||||
}
|
}
|
||||||
if (material_indices) {
|
if (material_indices) {
|
||||||
for (a = 0; a < me->totpoly; a++) {
|
for (a = 0; a < me->totpoly; a++) {
|
||||||
@ -583,10 +583,10 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
|
|||||||
CustomData_reset(&pdata);
|
CustomData_reset(&pdata);
|
||||||
|
|
||||||
float3 *vert_positions = (float3 *)CustomData_add_layer_named(
|
float3 *vert_positions = (float3 *)CustomData_add_layer_named(
|
||||||
&vdata, CD_PROP_FLOAT3, CD_SET_DEFAULT, nullptr, totvert, "position");
|
&vdata, CD_PROP_FLOAT3, CD_SET_DEFAULT, totvert, "position");
|
||||||
edge = (MEdge *)CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, totedge);
|
edge = (MEdge *)CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, totedge);
|
||||||
mloop = (MLoop *)CustomData_add_layer(&ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, totloop);
|
mloop = (MLoop *)CustomData_add_layer(&ldata, CD_MLOOP, CD_SET_DEFAULT, totloop);
|
||||||
polys = (MPoly *)CustomData_add_layer(&pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, totpoly);
|
polys = (MPoly *)CustomData_add_layer(&pdata, CD_MPOLY, CD_SET_DEFAULT, totpoly);
|
||||||
|
|
||||||
vertofs = 0;
|
vertofs = 0;
|
||||||
edgeofs = 0;
|
edgeofs = 0;
|
||||||
|
@ -53,7 +53,7 @@ void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
|
|||||||
|
|
||||||
/* if there's is no facemap layer then create one */
|
/* if there's is no facemap layer then create one */
|
||||||
if ((facemap = CustomData_get_layer_for_write(&me->pdata, CD_FACEMAP, me->totpoly)) == NULL) {
|
if ((facemap = CustomData_get_layer_for_write(&me->pdata, CD_FACEMAP, me->totpoly)) == NULL) {
|
||||||
facemap = CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_SET_DEFAULT, NULL, me->totpoly);
|
facemap = CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_SET_DEFAULT, me->totpoly);
|
||||||
}
|
}
|
||||||
|
|
||||||
facemap[facenum] = fmap_nr;
|
facemap[facenum] = fmap_nr;
|
||||||
|
@ -651,10 +651,9 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/,
|
|||||||
me->totvert = verts_num;
|
me->totvert = verts_num;
|
||||||
me->totedge = edges_num;
|
me->totedge = edges_num;
|
||||||
|
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(&me->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, verts_num, "position");
|
||||||
&me->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, verts_num, "position");
|
CustomData_add_layer(&me->edata, CD_MEDGE, CD_SET_DEFAULT, edges_num);
|
||||||
CustomData_add_layer(&me->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, edges_num);
|
CustomData_add_layer(&me->fdata, CD_MFACE, CD_SET_DEFAULT, 0);
|
||||||
CustomData_add_layer(&me->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, 0);
|
|
||||||
|
|
||||||
blender::MutableSpan<float3> positions = me->vert_positions_for_write();
|
blender::MutableSpan<float3> positions = me->vert_positions_for_write();
|
||||||
blender::MutableSpan<MEdge> edges = me->edges_for_write();
|
blender::MutableSpan<MEdge> edges = me->edges_for_write();
|
||||||
@ -731,8 +730,8 @@ static void add_shapekey_layers(Mesh &mesh_dest, const Mesh &mesh_src)
|
|||||||
memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src.totvert));
|
memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src.totvert));
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named_with_data(
|
||||||
&mesh_dest.vdata, CD_SHAPEKEY, CD_ASSIGN, array, mesh_dest.totvert, kb->name);
|
&mesh_dest.vdata, CD_SHAPEKEY, array, mesh_dest.totvert, kb->name);
|
||||||
const int ci = CustomData_get_layer_index_n(&mesh_dest.vdata, CD_SHAPEKEY, i);
|
const int ci = CustomData_get_layer_index_n(&mesh_dest.vdata, CD_SHAPEKEY, i);
|
||||||
|
|
||||||
mesh_dest.vdata.layers[ci].uid = kb->uid;
|
mesh_dest.vdata.layers[ci].uid = kb->uid;
|
||||||
@ -2938,7 +2937,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
|
|||||||
const Span<float3> positions_eval = me_eval_deform->vert_positions();
|
const Span<float3> positions_eval = me_eval_deform->vert_positions();
|
||||||
|
|
||||||
/* add vertex weights to original mesh */
|
/* add vertex weights to original mesh */
|
||||||
CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, me->totvert);
|
CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, me->totvert);
|
||||||
|
|
||||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||||
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
|
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
|
||||||
|
@ -81,7 +81,7 @@ static void partialvis_update_mesh(Object *ob,
|
|||||||
CustomData_get_layer_named_for_write(&me->vdata, CD_PROP_BOOL, ".hide_vert", me->totvert));
|
CustomData_get_layer_named_for_write(&me->vdata, CD_PROP_BOOL, ".hide_vert", me->totvert));
|
||||||
if (hide_vert == nullptr) {
|
if (hide_vert == nullptr) {
|
||||||
hide_vert = static_cast<bool *>(CustomData_add_layer_named(
|
hide_vert = static_cast<bool *>(CustomData_add_layer_named(
|
||||||
&me->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, me->totvert, ".hide_vert"));
|
&me->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, me->totvert, ".hide_vert"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
|
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
|
||||||
|
@ -1862,7 +1862,8 @@ static void sculpt_undo_set_active_layer(struct bContext *C, SculptAttrRef *attr
|
|||||||
CustomData *cdata = attr->domain == ATTR_DOMAIN_POINT ? &me->vdata : &me->ldata;
|
CustomData *cdata = attr->domain == ATTR_DOMAIN_POINT ? &me->vdata : &me->ldata;
|
||||||
int totelem = attr->domain == ATTR_DOMAIN_POINT ? me->totvert : me->totloop;
|
int totelem = attr->domain == ATTR_DOMAIN_POINT ? me->totvert : me->totloop;
|
||||||
|
|
||||||
CustomData_add_layer_named(cdata, attr->type, CD_SET_DEFAULT, nullptr, totelem, attr->name);
|
CustomData_add_layer_named(
|
||||||
|
cdata, eCustomDataType(attr->type), CD_SET_DEFAULT, totelem, attr->name);
|
||||||
layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
|
layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,34 +582,34 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||||||
mesh->totcol = group->materials.size();
|
mesh->totcol = group->materials.size();
|
||||||
|
|
||||||
float3 *vert_positions = (float3 *)CustomData_add_layer_named(
|
float3 *vert_positions = (float3 *)CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_FLOAT3, CD_SET_DEFAULT, nullptr, mesh->totvert, "position");
|
&mesh->vdata, CD_PROP_FLOAT3, CD_SET_DEFAULT, mesh->totvert, "position");
|
||||||
MEdge *edges = (MEdge *)CustomData_add_layer(
|
MEdge *edges = (MEdge *)CustomData_add_layer(
|
||||||
&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh->totedge);
|
&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, mesh->totedge);
|
||||||
MPoly *polys = (MPoly *)CustomData_add_layer(
|
MPoly *polys = (MPoly *)CustomData_add_layer(
|
||||||
&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
|
&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, mesh->totpoly);
|
||||||
MLoop *loops = (MLoop *)CustomData_add_layer(
|
MLoop *loops = (MLoop *)CustomData_add_layer(
|
||||||
&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop);
|
&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, mesh->totloop);
|
||||||
int *material_indices = (int *)CustomData_add_layer_named(
|
int *material_indices = (int *)CustomData_add_layer_named(
|
||||||
&mesh->pdata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, mesh->totpoly, "material_index");
|
&mesh->pdata, CD_PROP_INT32, CD_SET_DEFAULT, mesh->totpoly, "material_index");
|
||||||
blender::float2 *loopsuv[2] = {nullptr};
|
blender::float2 *loopsuv[2] = {nullptr};
|
||||||
|
|
||||||
if (hasTex) {
|
if (hasTex) {
|
||||||
// First UV layer
|
// First UV layer
|
||||||
loopsuv[0] = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
loopsuv[0] = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, mesh->totloop, uvNames[0]));
|
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->totloop, uvNames[0]));
|
||||||
CustomData_set_layer_active(&mesh->ldata, CD_PROP_FLOAT2, 0);
|
CustomData_set_layer_active(&mesh->ldata, CD_PROP_FLOAT2, 0);
|
||||||
|
|
||||||
// Second UV layer
|
// Second UV layer
|
||||||
loopsuv[1] = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
loopsuv[1] = static_cast<blender::float2 *>(CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, mesh->totloop, uvNames[1]));
|
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->totloop, uvNames[1]));
|
||||||
CustomData_set_layer_active(&mesh->ldata, CD_PROP_FLOAT2, 1);
|
CustomData_set_layer_active(&mesh->ldata, CD_PROP_FLOAT2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// colors and transparency (the latter represented by grayscale colors)
|
// colors and transparency (the latter represented by grayscale colors)
|
||||||
MLoopCol *colors = (MLoopCol *)CustomData_add_layer_named(
|
MLoopCol *colors = (MLoopCol *)CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, mesh->totloop, "Color");
|
&mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, mesh->totloop, "Color");
|
||||||
MLoopCol *transp = (MLoopCol *)CustomData_add_layer_named(
|
MLoopCol *transp = (MLoopCol *)CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, mesh->totloop, "Alpha");
|
&mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, mesh->totloop, "Alpha");
|
||||||
BKE_id_attributes_active_color_set(
|
BKE_id_attributes_active_color_set(
|
||||||
&mesh->id, CustomData_get_layer_name(&mesh->ldata, CD_PROP_BYTE_COLOR, 0));
|
&mesh->id, CustomData_get_layer_name(&mesh->ldata, CD_PROP_BYTE_COLOR, 0));
|
||||||
|
|
||||||
|
@ -135,11 +135,11 @@ static void add_new_edges(Mesh &mesh,
|
|||||||
|
|
||||||
CustomData_free(&mesh.edata, mesh.totedge);
|
CustomData_free(&mesh.edata, mesh.totedge);
|
||||||
mesh.totedge = new_edges.size();
|
mesh.totedge = new_edges.size();
|
||||||
CustomData_add_layer(&mesh.edata, CD_MEDGE, CD_CONSTRUCT, nullptr, mesh.totedge);
|
CustomData_add_layer(&mesh.edata, CD_MEDGE, CD_CONSTRUCT, mesh.totedge);
|
||||||
mesh.edges_for_write().copy_from(new_edges);
|
mesh.edges_for_write().copy_from(new_edges);
|
||||||
|
|
||||||
if (new_orig_indices != nullptr) {
|
if (new_orig_indices != nullptr) {
|
||||||
CustomData_add_layer(&mesh.edata, CD_ORIGINDEX, CD_ASSIGN, new_orig_indices, mesh.totedge);
|
CustomData_add_layer_with_data(&mesh.edata, CD_ORIGINDEX, new_orig_indices, mesh.totedge);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NewAttributeData &new_data : dst_attributes) {
|
for (NewAttributeData &new_data : dst_attributes) {
|
||||||
|
@ -538,7 +538,7 @@ void read_generated_coordinates(const ICompoundProperty &prop,
|
|||||||
cd_data = CustomData_get_layer_for_write(&mesh->vdata, CD_ORCO, mesh->totvert);
|
cd_data = CustomData_get_layer_for_write(&mesh->vdata, CD_ORCO, mesh->totvert);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cd_data = CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_CONSTRUCT, nullptr, totvert);
|
cd_data = CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_CONSTRUCT, totvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
float(*orcodata)[3] = static_cast<float(*)[3]>(cd_data);
|
float(*orcodata)[3] = static_cast<float(*)[3]>(cd_data);
|
||||||
|
@ -392,8 +392,7 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
|
|||||||
|
|
||||||
/* Create a new layer. */
|
/* Create a new layer. */
|
||||||
int numloops = mesh->totloop;
|
int numloops = mesh->totloop;
|
||||||
cd_ptr = CustomData_add_layer_named(
|
cd_ptr = CustomData_add_layer_named(&mesh->ldata, cd_data_type, CD_SET_DEFAULT, numloops, name);
|
||||||
&mesh->ldata, cd_data_type, CD_SET_DEFAULT, nullptr, numloops, name);
|
|
||||||
return cd_ptr;
|
return cd_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,7 +890,7 @@ static void read_vertex_creases(Mesh *mesh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
float *vertex_crease_data = (float *)CustomData_add_layer(
|
float *vertex_crease_data = (float *)CustomData_add_layer(
|
||||||
&mesh->vdata, CD_CREASE, CD_SET_DEFAULT, nullptr, mesh->totvert);
|
&mesh->vdata, CD_CREASE, CD_SET_DEFAULT, mesh->totvert);
|
||||||
const int totvert = mesh->totvert;
|
const int totvert = mesh->totvert;
|
||||||
|
|
||||||
for (int i = 0, v = indices->size(); i < v; ++i) {
|
for (int i = 0, v = indices->size(); i < v; ++i) {
|
||||||
@ -917,7 +916,7 @@ static void read_edge_creases(Mesh *mesh,
|
|||||||
EdgeHash *edge_hash = BLI_edgehash_new_ex(__func__, edges.size());
|
EdgeHash *edge_hash = BLI_edgehash_new_ex(__func__, edges.size());
|
||||||
|
|
||||||
float *creases = static_cast<float *>(
|
float *creases = static_cast<float *>(
|
||||||
CustomData_add_layer(&mesh->edata, CD_CREASE, CD_SET_DEFAULT, nullptr, edges.size()));
|
CustomData_add_layer(&mesh->edata, CD_CREASE, CD_SET_DEFAULT, edges.size()));
|
||||||
|
|
||||||
for (const int i : edges.index_range()) {
|
for (const int i : edges.index_range()) {
|
||||||
MEdge *edge = &edges[i];
|
MEdge *edge = &edges[i];
|
||||||
|
@ -351,8 +351,7 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
|
|||||||
}
|
}
|
||||||
|
|
||||||
me->totvert = pos.getFloatValues()->getCount() / stride;
|
me->totvert = pos.getFloatValues()->getCount() / stride;
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(&me->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, me->totvert, "position");
|
||||||
&me->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, me->totvert, "position");
|
|
||||||
MutableSpan<float3> positions = me->vert_positions_for_write();
|
MutableSpan<float3> positions = me->vert_positions_for_write();
|
||||||
for (const int i : positions.index_range()) {
|
for (const int i : positions.index_range()) {
|
||||||
get_vector(positions[i], pos, i, stride);
|
get_vector(positions[i], pos, i, stride);
|
||||||
@ -456,8 +455,8 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||||||
if (total_poly_count > 0) {
|
if (total_poly_count > 0) {
|
||||||
me->totpoly = total_poly_count;
|
me->totpoly = total_poly_count;
|
||||||
me->totloop = total_loop_count;
|
me->totloop = total_loop_count;
|
||||||
CustomData_add_layer(&me->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, me->totpoly);
|
CustomData_add_layer(&me->pdata, CD_MPOLY, CD_SET_DEFAULT, me->totpoly);
|
||||||
CustomData_add_layer(&me->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, me->totloop);
|
CustomData_add_layer(&me->ldata, CD_MLOOP, CD_SET_DEFAULT, me->totloop);
|
||||||
|
|
||||||
uint totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
|
uint totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
|
||||||
for (int i = 0; i < totuvset; i++) {
|
for (int i = 0; i < totuvset; i++) {
|
||||||
@ -474,7 +473,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||||||
COLLADAFW::String &uvname = info->mName;
|
COLLADAFW::String &uvname = info->mName;
|
||||||
/* Allocate space for UV_data */
|
/* Allocate space for UV_data */
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&me->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, me->totloop, uvname.c_str());
|
&me->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, me->totloop, uvname.c_str());
|
||||||
}
|
}
|
||||||
/* activate the first uv map */
|
/* activate the first uv map */
|
||||||
CustomData_set_layer_active(&me->ldata, CD_PROP_FLOAT2, 0);
|
CustomData_set_layer_active(&me->ldata, CD_PROP_FLOAT2, 0);
|
||||||
@ -487,7 +486,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||||||
collada_mesh->getColors().getInputInfosArray()[i];
|
collada_mesh->getColors().getInputInfosArray()[i];
|
||||||
COLLADAFW::String colname = extract_vcolname(info->mName);
|
COLLADAFW::String colname = extract_vcolname(info->mName);
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&me->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, me->totloop, colname.c_str());
|
&me->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, me->totloop, colname.c_str());
|
||||||
}
|
}
|
||||||
BKE_id_attributes_active_color_set(
|
BKE_id_attributes_active_color_set(
|
||||||
&me->id, CustomData_get_layer_name(&me->ldata, CD_PROP_BYTE_COLOR, 0));
|
&me->id, CustomData_get_layer_name(&me->ldata, CD_PROP_BYTE_COLOR, 0));
|
||||||
@ -558,7 +557,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
|||||||
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
|
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
|
||||||
|
|
||||||
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
|
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
|
||||||
CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, totedge);
|
CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, totedge);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomData_free(&mesh->edata, mesh->totedge);
|
CustomData_free(&mesh->edata, mesh->totedge);
|
||||||
@ -621,7 +620,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
|
|||||||
CustomData_get_layer_named_for_write(&me->pdata, CD_PROP_BOOL, "sharp_face", me->totpoly));
|
CustomData_get_layer_named_for_write(&me->pdata, CD_PROP_BOOL, "sharp_face", me->totpoly));
|
||||||
if (!sharp_faces) {
|
if (!sharp_faces) {
|
||||||
sharp_faces = static_cast<bool *>(CustomData_add_layer_named(
|
sharp_faces = static_cast<bool *>(CustomData_add_layer_named(
|
||||||
&me->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, me->totpoly, "sharp_face"));
|
&me->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, me->totpoly, "sharp_face"));
|
||||||
}
|
}
|
||||||
|
|
||||||
COLLADAFW::MeshPrimitiveArray &prim_arr = collada_mesh->getMeshPrimitives();
|
COLLADAFW::MeshPrimitiveArray &prim_arr = collada_mesh->getMeshPrimitives();
|
||||||
|
@ -23,14 +23,14 @@ Mesh *convert_ply_to_mesh(PlyData &data, Mesh *mesh, const PLYImportParams ¶
|
|||||||
/* Add vertices to the mesh. */
|
/* Add vertices to the mesh. */
|
||||||
mesh->totvert = int(data.vertices.size());
|
mesh->totvert = int(data.vertices.size());
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, mesh->totvert, "position");
|
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh->totvert, "position");
|
||||||
mesh->vert_positions_for_write().copy_from(data.vertices);
|
mesh->vert_positions_for_write().copy_from(data.vertices);
|
||||||
|
|
||||||
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
|
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
|
||||||
|
|
||||||
if (!data.edges.is_empty()) {
|
if (!data.edges.is_empty()) {
|
||||||
mesh->totedge = int(data.edges.size());
|
mesh->totedge = int(data.edges.size());
|
||||||
CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh->totedge);
|
CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, mesh->totedge);
|
||||||
MutableSpan<MEdge> edges = mesh->edges_for_write();
|
MutableSpan<MEdge> edges = mesh->edges_for_write();
|
||||||
for (int i = 0; i < mesh->totedge; i++) {
|
for (int i = 0; i < mesh->totedge; i++) {
|
||||||
edges[i].v1 = data.edges[i].first;
|
edges[i].v1 = data.edges[i].first;
|
||||||
@ -47,8 +47,8 @@ Mesh *convert_ply_to_mesh(PlyData &data, Mesh *mesh, const PLYImportParams ¶
|
|||||||
/* Add number of loops from the vertex indices in the face. */
|
/* Add number of loops from the vertex indices in the face. */
|
||||||
mesh->totloop += data.faces[i].size();
|
mesh->totloop += data.faces[i].size();
|
||||||
}
|
}
|
||||||
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
|
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, mesh->totpoly);
|
||||||
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop);
|
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, mesh->totloop);
|
||||||
MutableSpan<MPoly> polys = mesh->polys_for_write();
|
MutableSpan<MPoly> polys = mesh->polys_for_write();
|
||||||
MutableSpan<MLoop> loops = mesh->loops_for_write();
|
MutableSpan<MLoop> loops = mesh->loops_for_write();
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@ Mesh *STLMeshHelper::to_mesh(Main *bmain, char *mesh_name)
|
|||||||
|
|
||||||
mesh->totvert = verts_.size();
|
mesh->totvert = verts_.size();
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, mesh->totvert, "position");
|
&mesh->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh->totvert, "position");
|
||||||
mesh->vert_positions_for_write().copy_from(verts_);
|
mesh->vert_positions_for_write().copy_from(verts_);
|
||||||
|
|
||||||
mesh->totpoly = tris_.size();
|
mesh->totpoly = tris_.size();
|
||||||
mesh->totloop = tris_.size() * 3;
|
mesh->totloop = tris_.size() * 3;
|
||||||
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
|
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, mesh->totpoly);
|
||||||
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop);
|
CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, mesh->totloop);
|
||||||
MutableSpan<MPoly> polys = mesh->polys_for_write();
|
MutableSpan<MPoly> polys = mesh->polys_for_write();
|
||||||
MutableSpan<MLoop> loops = mesh->loops_for_write();
|
MutableSpan<MLoop> loops = mesh->loops_for_write();
|
||||||
threading::parallel_for(tris_.index_range(), 2048, [&](IndexRange tris_range) {
|
threading::parallel_for(tris_.index_range(), 2048, [&](IndexRange tris_range) {
|
||||||
|
@ -162,8 +162,7 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, const int data_type
|
|||||||
|
|
||||||
/* Create a new layer. */
|
/* Create a new layer. */
|
||||||
numloops = mesh->totloop;
|
numloops = mesh->totloop;
|
||||||
cd_ptr = CustomData_add_layer_named(
|
cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_SET_DEFAULT, numloops, name);
|
||||||
loopdata, cd_data_type, CD_SET_DEFAULT, nullptr, numloops, name);
|
|
||||||
return cd_ptr;
|
return cd_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,7 +531,7 @@ void USDMeshReader::read_vertex_creases(Mesh *mesh, const double motionSampleTim
|
|||||||
}
|
}
|
||||||
|
|
||||||
float *creases = static_cast<float *>(
|
float *creases = static_cast<float *>(
|
||||||
CustomData_add_layer(&mesh->vdata, CD_CREASE, CD_SET_DEFAULT, nullptr, mesh->totvert));
|
CustomData_add_layer(&mesh->vdata, CD_CREASE, CD_SET_DEFAULT, mesh->totvert));
|
||||||
|
|
||||||
for (size_t i = 0; i < corner_indices.size(); i++) {
|
for (size_t i = 0; i < corner_indices.size(); i++) {
|
||||||
creases[corner_indices[i]] = corner_sharpnesses[i];
|
creases[corner_indices[i]] = corner_sharpnesses[i];
|
||||||
|
@ -477,7 +477,7 @@ static void rna_MeshVertex_hide_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hide_vert = (bool *)CustomData_add_layer_named(
|
hide_vert = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totvert, ".hide_vert");
|
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totvert, ".hide_vert");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshVertex_index_get(ptr);
|
const int index = rna_MeshVertex_index_get(ptr);
|
||||||
hide_vert[index] = value;
|
hide_vert[index] = value;
|
||||||
@ -503,7 +503,7 @@ static void rna_MeshVertex_select_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
select_vert = (bool *)CustomData_add_layer_named(
|
select_vert = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totvert, ".select_vert");
|
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totvert, ".select_vert");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshVertex_index_get(ptr);
|
const int index = rna_MeshVertex_index_get(ptr);
|
||||||
select_vert[index] = value;
|
select_vert[index] = value;
|
||||||
@ -522,7 +522,7 @@ static void rna_MeshVertex_bevel_weight_set(PointerRNA *ptr, float value)
|
|||||||
Mesh *mesh = rna_mesh(ptr);
|
Mesh *mesh = rna_mesh(ptr);
|
||||||
const int index = rna_MeshVertex_index_get(ptr);
|
const int index = rna_MeshVertex_index_get(ptr);
|
||||||
float *values = (float *)CustomData_add_layer(
|
float *values = (float *)CustomData_add_layer(
|
||||||
&mesh->vdata, CD_BWEIGHT, CD_SET_DEFAULT, NULL, mesh->totvert);
|
&mesh->vdata, CD_BWEIGHT, CD_SET_DEFAULT, mesh->totvert);
|
||||||
values[index] = clamp_f(value, 0.0f, 1.0f);
|
values[index] = clamp_f(value, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value)
|
|||||||
Mesh *mesh = rna_mesh(ptr);
|
Mesh *mesh = rna_mesh(ptr);
|
||||||
const int index = rna_MeshEdge_index_get(ptr);
|
const int index = rna_MeshEdge_index_get(ptr);
|
||||||
float *values = (float *)CustomData_add_layer(
|
float *values = (float *)CustomData_add_layer(
|
||||||
&mesh->edata, CD_BWEIGHT, CD_SET_DEFAULT, NULL, mesh->totedge);
|
&mesh->edata, CD_BWEIGHT, CD_SET_DEFAULT, mesh->totedge);
|
||||||
values[index] = clamp_f(value, 0.0f, 1.0f);
|
values[index] = clamp_f(value, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +556,7 @@ static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
|
|||||||
Mesh *mesh = rna_mesh(ptr);
|
Mesh *mesh = rna_mesh(ptr);
|
||||||
const int index = rna_MeshEdge_index_get(ptr);
|
const int index = rna_MeshEdge_index_get(ptr);
|
||||||
float *values = (float *)CustomData_add_layer(
|
float *values = (float *)CustomData_add_layer(
|
||||||
&mesh->edata, CD_CREASE, CD_SET_DEFAULT, NULL, mesh->totedge);
|
&mesh->edata, CD_CREASE, CD_SET_DEFAULT, mesh->totedge);
|
||||||
values[index] = clamp_f(value, 0.0f, 1.0f);
|
values[index] = clamp_f(value, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,7 +654,7 @@ static void rna_MeshPolygon_hide_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hide_poly = (bool *)CustomData_add_layer_named(
|
hide_poly = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totpoly, ".hide_poly");
|
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, ".hide_poly");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshPolygon_index_get(ptr);
|
const int index = rna_MeshPolygon_index_get(ptr);
|
||||||
hide_poly[index] = value;
|
hide_poly[index] = value;
|
||||||
@ -680,7 +680,7 @@ static void rna_MeshPolygon_use_smooth_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sharp_faces = (bool *)CustomData_add_layer_named(
|
sharp_faces = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totpoly, "sharp_face");
|
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, "sharp_face");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshPolygon_index_get(ptr);
|
const int index = rna_MeshPolygon_index_get(ptr);
|
||||||
sharp_faces[index] = !value;
|
sharp_faces[index] = !value;
|
||||||
@ -706,7 +706,7 @@ static void rna_MeshPolygon_select_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
select_poly = (bool *)CustomData_add_layer_named(
|
select_poly = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totpoly, ".select_poly");
|
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, ".select_poly");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshPolygon_index_get(ptr);
|
const int index = rna_MeshPolygon_index_get(ptr);
|
||||||
select_poly[index] = value;
|
select_poly[index] = value;
|
||||||
@ -954,7 +954,7 @@ static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, bool value)
|
|||||||
FreestyleEdge *fed = CustomData_get_layer_for_write(&me->edata, CD_FREESTYLE_EDGE, me->totedge);
|
FreestyleEdge *fed = CustomData_get_layer_for_write(&me->edata, CD_FREESTYLE_EDGE, me->totedge);
|
||||||
|
|
||||||
if (!fed) {
|
if (!fed) {
|
||||||
fed = CustomData_add_layer(&me->edata, CD_FREESTYLE_EDGE, CD_SET_DEFAULT, NULL, me->totedge);
|
fed = CustomData_add_layer(&me->edata, CD_FREESTYLE_EDGE, CD_SET_DEFAULT, me->totedge);
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
fed[index].flag |= FREESTYLE_EDGE_MARK;
|
fed[index].flag |= FREESTYLE_EDGE_MARK;
|
||||||
@ -980,7 +980,7 @@ static void rna_MPoly_freestyle_face_mark_set(PointerRNA *ptr, bool value)
|
|||||||
FreestyleFace *ffa = CustomData_get_layer_for_write(&me->pdata, CD_FREESTYLE_FACE, me->totpoly);
|
FreestyleFace *ffa = CustomData_get_layer_for_write(&me->pdata, CD_FREESTYLE_FACE, me->totpoly);
|
||||||
|
|
||||||
if (!ffa) {
|
if (!ffa) {
|
||||||
ffa = CustomData_add_layer(&me->pdata, CD_FREESTYLE_FACE, CD_SET_DEFAULT, NULL, me->totpoly);
|
ffa = CustomData_add_layer(&me->pdata, CD_FREESTYLE_FACE, CD_SET_DEFAULT, me->totpoly);
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
ffa[index].flag |= FREESTYLE_FACE_MARK;
|
ffa[index].flag |= FREESTYLE_FACE_MARK;
|
||||||
@ -1032,7 +1032,7 @@ static MBoolProperty *MeshUVLoopLayer_get_bool_layer(Mesh *mesh, char const *nam
|
|||||||
&mesh->ldata, CD_PROP_BOOL, name, mesh->totloop);
|
&mesh->ldata, CD_PROP_BOOL, name, mesh->totloop);
|
||||||
if (layer == NULL) {
|
if (layer == NULL) {
|
||||||
layer = CustomData_add_layer_named(
|
layer = CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totloop, name);
|
&mesh->ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totloop, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLI_assert(layer);
|
BLI_assert(layer);
|
||||||
@ -1715,7 +1715,7 @@ static void rna_MeshEdge_hide_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hide_edge = (bool *)CustomData_add_layer_named(
|
hide_edge = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totedge, ".hide_edge");
|
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".hide_edge");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshEdge_index_get(ptr);
|
const int index = rna_MeshEdge_index_get(ptr);
|
||||||
hide_edge[index] = value;
|
hide_edge[index] = value;
|
||||||
@ -1741,7 +1741,7 @@ static void rna_MeshEdge_select_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
select_edge = (bool *)CustomData_add_layer_named(
|
select_edge = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totedge, ".select_edge");
|
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".select_edge");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshEdge_index_get(ptr);
|
const int index = rna_MeshEdge_index_get(ptr);
|
||||||
select_edge[index] = value;
|
select_edge[index] = value;
|
||||||
@ -1767,7 +1767,7 @@ static void rna_MeshEdge_use_edge_sharp_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sharp_edge = (bool *)CustomData_add_layer_named(
|
sharp_edge = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totedge, "sharp_edge");
|
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, "sharp_edge");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshEdge_index_get(ptr);
|
const int index = rna_MeshEdge_index_get(ptr);
|
||||||
sharp_edge[index] = value;
|
sharp_edge[index] = value;
|
||||||
@ -1793,7 +1793,7 @@ static void rna_MeshEdge_use_seam_set(PointerRNA *ptr, bool value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
seam_edge = (bool *)CustomData_add_layer_named(
|
seam_edge = (bool *)CustomData_add_layer_named(
|
||||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totedge, ".uv_seam");
|
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".uv_seam");
|
||||||
}
|
}
|
||||||
const int index = rna_MeshEdge_index_get(ptr);
|
const int index = rna_MeshEdge_index_get(ptr);
|
||||||
seam_edge[index] = value;
|
seam_edge[index] = value;
|
||||||
@ -2503,8 +2503,7 @@ static void rna_Mesh_sculpt_vertex_color_remove(struct Mesh *me,
|
|||||||
CustomDataLayer *cdl = NULL; \
|
CustomDataLayer *cdl = NULL; \
|
||||||
int index; \
|
int index; \
|
||||||
\
|
\
|
||||||
CustomData_add_layer_named( \
|
CustomData_add_layer_named(&me->cdata, cd_prop_type, CD_SET_DEFAULT, me->countvar, name); \
|
||||||
&me->cdata, cd_prop_type, CD_SET_DEFAULT, NULL, me->countvar, name); \
|
|
||||||
index = CustomData_get_named_layer_index(&me->cdata, cd_prop_type, name); \
|
index = CustomData_get_named_layer_index(&me->cdata, cd_prop_type, name); \
|
||||||
\
|
\
|
||||||
cdl = (index == -1) ? NULL : &(me->cdata.layers[index]); \
|
cdl = (index == -1) ? NULL : &(me->cdata.layers[index]); \
|
||||||
|
@ -45,7 +45,7 @@ static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh,
|
|||||||
static void rna_Mesh_create_normals_split(Mesh *mesh)
|
static void rna_Mesh_create_normals_split(Mesh *mesh)
|
||||||
{
|
{
|
||||||
if (!CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
|
if (!CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
|
||||||
CustomData_add_layer(&mesh->ldata, CD_NORMAL, CD_SET_DEFAULT, NULL, mesh->totloop);
|
CustomData_add_layer(&mesh->ldata, CD_NORMAL, CD_SET_DEFAULT, mesh->totloop);
|
||||||
CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ static void rna_Mesh_calc_tangents(Mesh *mesh, ReportList *reports, const char *
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
r_looptangents = CustomData_add_layer(
|
r_looptangents = CustomData_add_layer(
|
||||||
&mesh->ldata, CD_MLOOPTANGENT, CD_SET_DEFAULT, NULL, mesh->totloop);
|
&mesh->ldata, CD_MLOOPTANGENT, CD_SET_DEFAULT, mesh->totloop);
|
||||||
CustomData_set_layer_flag(&mesh->ldata, CD_MLOOPTANGENT, CD_FLAG_TEMPORARY);
|
CustomData_set_layer_flag(&mesh->ldata, CD_MLOOPTANGENT, CD_FLAG_TEMPORARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ static void deformVerts(ModifierData *md,
|
|||||||
if (!(layerorco = CustomData_get_layer_for_write(
|
if (!(layerorco = CustomData_get_layer_for_write(
|
||||||
&mesh_src->vdata, CD_CLOTH_ORCO, mesh_src->totvert))) {
|
&mesh_src->vdata, CD_CLOTH_ORCO, mesh_src->totvert))) {
|
||||||
layerorco = CustomData_add_layer(
|
layerorco = CustomData_add_layer(
|
||||||
&mesh_src->vdata, CD_CLOTH_ORCO, CD_SET_DEFAULT, NULL, mesh_src->totvert);
|
&mesh_src->vdata, CD_CLOTH_ORCO, CD_SET_DEFAULT, mesh_src->totvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(layerorco, kb->data, sizeof(float[3]) * verts_num);
|
memcpy(layerorco, kb->data, sizeof(float[3]) * verts_num);
|
||||||
|
@ -1358,13 +1358,13 @@ static void modifyGeometry(ModifierData *md,
|
|||||||
* #eModifierTypeFlag_SupportsMapping flag is set. If the layers did not exist before, it is
|
* #eModifierTypeFlag_SupportsMapping flag is set. If the layers did not exist before, it is
|
||||||
* assumed that the output mesh does not have a mapping to the original mesh. */
|
* assumed that the output mesh does not have a mapping to the original mesh. */
|
||||||
if (use_orig_index_verts) {
|
if (use_orig_index_verts) {
|
||||||
CustomData_add_layer(&mesh->vdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh->totvert);
|
CustomData_add_layer(&mesh->vdata, CD_ORIGINDEX, CD_SET_DEFAULT, mesh->totvert);
|
||||||
}
|
}
|
||||||
if (use_orig_index_edges) {
|
if (use_orig_index_edges) {
|
||||||
CustomData_add_layer(&mesh->edata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh->totedge);
|
CustomData_add_layer(&mesh->edata, CD_ORIGINDEX, CD_SET_DEFAULT, mesh->totedge);
|
||||||
}
|
}
|
||||||
if (use_orig_index_polys) {
|
if (use_orig_index_polys) {
|
||||||
CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh->totpoly);
|
CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, mesh->totpoly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,7 +546,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
|
|||||||
|
|
||||||
if (clnors == nullptr) {
|
if (clnors == nullptr) {
|
||||||
clnors = static_cast<short(*)[2]>(
|
clnors = static_cast<short(*)[2]>(
|
||||||
CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, loops.size()));
|
CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, loops.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index);
|
MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index);
|
||||||
|
@ -285,7 +285,7 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co
|
|||||||
/* add uvs */
|
/* add uvs */
|
||||||
if (CustomData_number_of_layers(&result->ldata, CD_PROP_FLOAT2) < MAX_MTFACE) {
|
if (CustomData_number_of_layers(&result->ldata, CD_PROP_FLOAT2) < MAX_MTFACE) {
|
||||||
gogd.mloopuvs = static_cast<float(*)[2]>(CustomData_add_layer_named(
|
gogd.mloopuvs = static_cast<float(*)[2]>(CustomData_add_layer_named(
|
||||||
&result->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, polys_num * 4, "UVMap"));
|
&result->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, polys_num * 4, "UVMap"));
|
||||||
|
|
||||||
if (gogd.mloopuvs) { /* unlikely to fail */
|
if (gogd.mloopuvs) { /* unlikely to fail */
|
||||||
gogd.ix = 1.0 / gogd.rx;
|
gogd.ix = 1.0 / gogd.rx;
|
||||||
@ -366,21 +366,13 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||||||
|
|
||||||
if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
|
if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
|
||||||
const blender::Span<MLoop> loops = result->loops();
|
const blender::Span<MLoop> loops = result->loops();
|
||||||
MLoopCol *mloopcols = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->ldata,
|
MLoopCol *mloopcols = static_cast<MLoopCol *>(CustomData_add_layer_named(
|
||||||
CD_PROP_BYTE_COLOR,
|
&result->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, loops.size(), omd->foamlayername));
|
||||||
CD_SET_DEFAULT,
|
|
||||||
nullptr,
|
|
||||||
loops.size(),
|
|
||||||
omd->foamlayername));
|
|
||||||
|
|
||||||
MLoopCol *mloopcols_spray = nullptr;
|
MLoopCol *mloopcols_spray = nullptr;
|
||||||
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
|
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
|
||||||
mloopcols_spray = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->ldata,
|
mloopcols_spray = static_cast<MLoopCol *>(CustomData_add_layer_named(
|
||||||
CD_PROP_BYTE_COLOR,
|
&result->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, loops.size(), omd->spraylayername));
|
||||||
CD_SET_DEFAULT,
|
|
||||||
nullptr,
|
|
||||||
loops.size(),
|
|
||||||
omd->spraylayername));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mloopcols) { /* unlikely to fail */
|
if (mloopcols) { /* unlikely to fail */
|
||||||
|
@ -412,7 +412,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||||||
"sharp_face", ATTR_DOMAIN_FACE);
|
"sharp_face", ATTR_DOMAIN_FACE);
|
||||||
|
|
||||||
if (!CustomData_has_layer(&result->pdata, CD_ORIGINDEX)) {
|
if (!CustomData_has_layer(&result->pdata, CD_ORIGINDEX)) {
|
||||||
CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, int(maxPolys));
|
CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, int(maxPolys));
|
||||||
}
|
}
|
||||||
|
|
||||||
int *origindex = static_cast<int *>(
|
int *origindex = static_cast<int *>(
|
||||||
|
@ -1896,7 +1896,7 @@ static BMesh *build_skin(SkinNode *skin_nodes,
|
|||||||
static void skin_set_orig_indices(Mesh *mesh)
|
static void skin_set_orig_indices(Mesh *mesh)
|
||||||
{
|
{
|
||||||
int *orig = static_cast<int *>(
|
int *orig = static_cast<int *>(
|
||||||
CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CONSTRUCT, nullptr, mesh->totpoly));
|
CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CONSTRUCT, mesh->totpoly));
|
||||||
copy_vn_i(orig, mesh->totpoly, ORIGINDEX_NONE);
|
copy_vn_i(orig, mesh->totpoly, ORIGINDEX_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,8 +384,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||||||
|
|
||||||
float *result_edge_bweight = nullptr;
|
float *result_edge_bweight = nullptr;
|
||||||
if (do_bevel_convex) {
|
if (do_bevel_convex) {
|
||||||
result_edge_bweight = static_cast<float *>(CustomData_add_layer(
|
result_edge_bweight = static_cast<float *>(
|
||||||
&result->edata, CD_BWEIGHT, CD_SET_DEFAULT, nullptr, result->totedge));
|
CustomData_add_layer(&result->edata, CD_BWEIGHT, CD_SET_DEFAULT, result->totedge));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initializes: (`i_end`, `do_shell_align`, `vert_index`). */
|
/* Initializes: (`i_end`, `do_shell_align`, `vert_index`). */
|
||||||
@ -1037,7 +1037,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||||||
float *result_edge_crease = nullptr;
|
float *result_edge_crease = nullptr;
|
||||||
if (crease_rim || crease_outer || crease_inner) {
|
if (crease_rim || crease_outer || crease_inner) {
|
||||||
result_edge_crease = (float *)CustomData_add_layer(
|
result_edge_crease = (float *)CustomData_add_layer(
|
||||||
&result->edata, CD_CREASE, CD_SET_DEFAULT, nullptr, result->totedge);
|
&result->edata, CD_CREASE, CD_SET_DEFAULT, result->totedge);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add faces & edges */
|
/* add faces & edges */
|
||||||
|
@ -2004,8 +2004,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
|
|||||||
float *result_edge_bweight = static_cast<float *>(
|
float *result_edge_bweight = static_cast<float *>(
|
||||||
CustomData_get_layer_for_write(&result->edata, CD_BWEIGHT, result->totedge));
|
CustomData_get_layer_for_write(&result->edata, CD_BWEIGHT, result->totedge));
|
||||||
if (bevel_convex != 0.0f || orig_vert_bweight != nullptr) {
|
if (bevel_convex != 0.0f || orig_vert_bweight != nullptr) {
|
||||||
result_edge_bweight = static_cast<float *>(CustomData_add_layer(
|
result_edge_bweight = static_cast<float *>(
|
||||||
&result->edata, CD_BWEIGHT, CD_SET_DEFAULT, nullptr, result->totedge));
|
CustomData_add_layer(&result->edata, CD_BWEIGHT, CD_SET_DEFAULT, result->totedge));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks that result has dvert data. */
|
/* Checks that result has dvert data. */
|
||||||
@ -2021,7 +2021,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
|
|||||||
float *result_edge_crease = nullptr;
|
float *result_edge_crease = nullptr;
|
||||||
if (vertex_crease) {
|
if (vertex_crease) {
|
||||||
result_edge_crease = (float *)CustomData_add_layer(
|
result_edge_crease = (float *)CustomData_add_layer(
|
||||||
&result->edata, CD_CREASE, CD_SET_DEFAULT, nullptr, result->totedge);
|
&result->edata, CD_CREASE, CD_SET_DEFAULT, result->totedge);
|
||||||
/* delete all vertex creases in the result if a rim is used. */
|
/* delete all vertex creases in the result if a rim is used. */
|
||||||
if (do_rim) {
|
if (do_rim) {
|
||||||
CustomData_free_layers(&result->vdata, CD_CREASE, result->totvert);
|
CustomData_free_layers(&result->vdata, CD_CREASE, result->totvert);
|
||||||
|
@ -119,7 +119,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||||||
* (e.g. if a preceding modifier could not preserve it). */
|
* (e.g. if a preceding modifier could not preserve it). */
|
||||||
if (!CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
|
if (!CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
|
||||||
CustomData_add_layer_named(
|
CustomData_add_layer_named(
|
||||||
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, mesh->totloop, umd->uvlayer_name);
|
&mesh->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->totloop, umd->uvlayer_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure we're using an existing layer */
|
/* make sure we're using an existing layer */
|
||||||
|
@ -568,8 +568,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||||||
* it helps when generating clnor spaces and default normals. */
|
* it helps when generating clnor spaces and default normals. */
|
||||||
const bool has_clnors = clnors != nullptr;
|
const bool has_clnors = clnors != nullptr;
|
||||||
if (!clnors) {
|
if (!clnors) {
|
||||||
clnors = static_cast<short(*)[2]>(CustomData_add_layer(
|
clnors = static_cast<short(*)[2]>(
|
||||||
&result->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, loops.size()));
|
CustomData_add_layer(&result->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, loops.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
const MDeformVert *dvert;
|
const MDeformVert *dvert;
|
||||||
|
@ -74,7 +74,7 @@ static void write_vertex_creases(Mesh &mesh, const VArray<float> &crease_varray)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
crease = static_cast<float *>(
|
crease = static_cast<float *>(
|
||||||
CustomData_add_layer(&mesh.vdata, CD_CREASE, CD_CONSTRUCT, nullptr, mesh.totvert));
|
CustomData_add_layer(&mesh.vdata, CD_CREASE, CD_CONSTRUCT, mesh.totvert));
|
||||||
}
|
}
|
||||||
materialize_and_clamp_creases(crease_varray, {crease, mesh.totvert});
|
materialize_and_clamp_creases(crease_varray, {crease, mesh.totvert});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user